From 917de2bab458d51b4149a1b794cbb1b6b9562171 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 22 Jun 2010 23:36:47 +0200 Subject: Initial Cairo rendering commit: solid shapes, gradients, opacity and patterns (bzr r9508.1.1) --- src/display/canvas-arena.cpp | 25 +++- src/display/canvas-bpath.cpp | 22 ++- src/display/inkscape-cairo.cpp | 35 +++++ src/display/inkscape-cairo.h | 5 +- src/display/nr-arena-item.cpp | 13 +- src/display/nr-arena-shape.cpp | 259 ++++++++++++++++++---------------- src/display/nr-arena-shape.h | 3 + src/display/sodipodi-ctrl.cpp | 283 +++++++++++++++++++------------------- src/display/sodipodi-ctrl.h | 2 +- src/display/sodipodi-ctrlrect.cpp | 35 ++++- src/display/sp-canvas-util.cpp | 29 +--- src/display/sp-canvas-util.h | 5 - src/display/sp-canvas.cpp | 53 +++++-- src/display/sp-canvas.h | 14 +- src/display/sp-ctrlline.cpp | 6 +- src/sp-gradient.cpp | 86 +++++++++++- src/sp-paint-server.cpp | 32 +++++ src/sp-paint-server.h | 4 + src/sp-pattern.cpp | 128 +++++++++++++++++ 19 files changed, 682 insertions(+), 357 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 733f9a513..86d902be2 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -190,6 +190,7 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) gint bw, bh; SPCanvasArena *arena = SP_CANVAS_ARENA (item); + SPCanvas *canvas = item->canvas; nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, @@ -209,19 +210,31 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) area.x1 = buf->rect.x1; area.y1 = buf->rect.y1; + sp_canvas_prepare_buffer(buf); + nr_pixblock_setup_extern (&cb, NR_PIXBLOCK_MODE_R8G8B8A8P, area.x0, area.y0, area.x1, area.y1, buf->buf, buf->buf_rowstride, FALSE, FALSE); cb.visible_area = buf->visible_rect; - cairo_t *ct = nr_create_cairo_context (&area, &cb); - nr_arena_item_invoke_render (ct, arena->root, &area, &cb, 0); + //cairo_t *ct = nr_create_cairo_context (&area, &cb); + + cairo_save(buf->ct); + //cairo_translate(buf->ct, area.x0 - canvas->x0, area.y0 - canvas->y0); + nr_arena_item_invoke_render (buf->ct, arena->root, &area, &cb, 0); + cairo_restore(buf->ct); + + //cairo_surface_t *cst = cairo_get_target(ct); + + //cairo_save(buf->ct); + //cairo_set_source_surface(buf->ct, cst, 0, 0); + //cairo_paint(buf->ct); + //cairo_restore(buf->ct); - cairo_surface_t *cst = cairo_get_target(ct); - cairo_destroy (ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); + //cairo_destroy (ct); + //cairo_surface_finish (cst); + //cairo_surface_destroy (cst); nr_pixblock_release (&cb); } diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index c47806615..5726fef02 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -149,8 +149,6 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) { SPCanvasBPath *cbp = SP_CANVAS_BPATH (item); - sp_canvas_prepare_buffer(buf); - Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1)); if ( !cbp->curve || @@ -164,33 +162,29 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) bool dofill = ((cbp->fill_rgba & 0xff) != 0); bool dostroke = ((cbp->stroke_rgba & 0xff) != 0); - cairo_set_tolerance(buf->ct, 1.25); // low quality, but good enough for canvas items + cairo_set_tolerance(buf->ct, 0.5); cairo_new_path(buf->ct); - if (!dofill) - feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, true, 1); - else - feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, false, 1); + feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + /* optimized_stroke = */ !dofill, 1); if (dofill) { // RGB / BGR - cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(cbp->fill_rgba), SP_RGBA32_G_F(cbp->fill_rgba), SP_RGBA32_R_F(cbp->fill_rgba), SP_RGBA32_A_F(cbp->fill_rgba)); + ink_cairo_set_source_rgba32(buf->ct, cbp->fill_rgba); cairo_set_fill_rule(buf->ct, cbp->fill_rule == SP_WIND_RULE_EVENODD? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); - if (dostroke) - cairo_fill_preserve(buf->ct); - else - cairo_fill(buf->ct); + cairo_fill_preserve(buf->ct); } if (dostroke) { - // RGB / BGR - cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(cbp->stroke_rgba), SP_RGBA32_G_F(cbp->stroke_rgba), SP_RGBA32_R_F(cbp->stroke_rgba), SP_RGBA32_A_F(cbp->stroke_rgba)); + ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); cairo_set_line_width(buf->ct, 1); if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { cairo_set_dash (buf->ct, cbp->dashes, 2, 0); } cairo_stroke(buf->ct); + } else { + cairo_new_path(buf->ct); } } diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp index a3e550fc5..fa5a7cfe2 100644 --- a/src/display/inkscape-cairo.cpp +++ b/src/display/inkscape-cairo.cpp @@ -53,12 +53,14 @@ nr_create_cairo_context_for_data (NRRectL *area, NRRectL *buf_area, unsigned cha return ct; } +#if 0 /** Creates a cairo context to render to the given SPCanvasBuf on the given area */ cairo_t * nr_create_cairo_context_canvasbuf (NRRectL */*area*/, SPCanvasBuf *b) { return nr_create_cairo_context_for_data (&(b->rect), &(b->rect), b->buf, b->buf_rowstride); } +#endif /** Creates a cairo context to render to the given NRPixBlock on the given area */ @@ -236,6 +238,39 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv) } } +void +ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba) +{ + cairo_set_source_rgba(ct, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba), SP_RGBA32_A_F(rgba)); +} + +static void +ink_cairo_convert_matrix(cairo_matrix_t &cm, Geom::Matrix const &m) +{ + cm.xx = m[0]; + cm.xy = m[2]; + cm.x0 = m[4]; + cm.yx = m[1]; + cm.yy = m[3]; + cm.y0 = m[5]; +} + +void +ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m) +{ + cairo_matrix_t cm; + ink_cairo_convert_matrix(cm, m); + cairo_transform(ct, &cm); +} + +void +ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m) +{ + cairo_matrix_t cm; + ink_cairo_convert_matrix(cm, m); + cairo_pattern_set_matrix(cp, &cm); +} + /* Local Variables: mode:c++ diff --git a/src/display/inkscape-cairo.h b/src/display/inkscape-cairo.h index cb4d474a6..74dc10995 100644 --- a/src/display/inkscape-cairo.h +++ b/src/display/inkscape-cairo.h @@ -19,11 +19,14 @@ struct NRPixBlock; class SPCanvasBuf; -cairo_t *nr_create_cairo_context_canvasbuf (NRRectL *area, SPCanvasBuf *b); cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb); void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); +void ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba); +void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m); +void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m); + #endif /* Local Variables: diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index b80df7273..d101a9e54 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -369,6 +369,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area return item->state | NR_ARENA_ITEM_STATE_RENDER; } +#if 0 NRPixBlock cpb; if (item->px) { /* Has cache pixblock, render this and return */ @@ -386,9 +387,9 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area pb->empty = FALSE; return item->state | NR_ARENA_ITEM_STATE_RENDER; } - +#endif NRPixBlock *dpb = pb; - +#if 0 /* Setup cache if we can */ if ((!(flags & NR_ARENA_ITEM_RENDER_NO_CACHE)) && (carea.x0 <= item->drawbox.x0) && (carea.y0 <= item->drawbox.y0) && @@ -411,12 +412,14 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // Set nocache flag for downstream rendering flags |= NR_ARENA_ITEM_RENDER_NO_CACHE; } +#endif /* Determine, whether we need temporary buffer */ - if (item->clip || item->mask +/* if (item->clip || item->mask || ((item->opacity != 255) && !item->render_opacity) || (item->filter && filter) || item->background_new - || (item->parent && item->parent->background_pb)) { + || (item->parent && item->parent->background_pb))*/ + if (0) { /* Setup and render item buffer */ NRPixBlock ipb; @@ -575,7 +578,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area item->background_pb = NULL; } else { /* Just render */ - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, dpb, flags); + unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, const_cast(area), dpb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { /* Clean up and return error */ if (dpb != pb) diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index a3b295a4e..9ec8f1100 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -145,6 +145,8 @@ nr_arena_shape_finalize(NRObject *object) if (shape->cached_stroke) delete shape->cached_stroke; if (shape->fill_painter) sp_painter_free(shape->fill_painter); if (shape->stroke_painter) sp_painter_free(shape->stroke_painter); + if (shape->fill_pattern) cairo_pattern_destroy(shape->fill_pattern); + if (shape->stroke_pattern) cairo_pattern_destroy(shape->stroke_pattern); if (shape->style) sp_style_unref(shape->style); if (shape->curve) shape->curve->unref(); @@ -317,13 +319,15 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g delete shape->stroke_shp; shape->stroke_shp = NULL; } - if (shape->fill_painter) { - sp_painter_free(shape->fill_painter); - shape->fill_painter = NULL; + + // clear Cairo patterns to force update + if (shape->fill_pattern) { + cairo_pattern_destroy(shape->fill_pattern); + shape->fill_pattern = NULL; } - if (shape->stroke_painter) { - sp_painter_free(shape->stroke_painter); - shape->stroke_painter = NULL; + if (shape->stroke_pattern) { + cairo_pattern_destroy(shape->stroke_pattern); + shape->stroke_pattern = NULL; } if (!shape->curve || @@ -366,31 +370,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g item->bbox.x1 = static_cast(ceil ((*boundingbox)[0][1])); item->bbox.y1 = static_cast(ceil ((*boundingbox)[1][1])); - item->render_opacity = TRUE; - if ( shape->_fill.paint.type() == NRArenaShape::Paint::SERVER ) { - if (gc && gc->parent) { - shape->fill_painter = sp_paint_server_painter_new(shape->_fill.paint.server(), - gc->transform, gc->parent->transform, - &shape->paintbox); - } - item->render_opacity = FALSE; - } - if ( shape->_stroke.paint.type() == NRArenaShape::Paint::SERVER ) { - if (gc && gc->parent) { - shape->stroke_painter = sp_paint_server_painter_new(shape->_stroke.paint.server(), - gc->transform, gc->parent->transform, - &shape->paintbox); - } - item->render_opacity = FALSE; - } - if ( (shape->_fill.paint.type() != NRArenaShape::Paint::NONE && - shape->_stroke.paint.type() != NRArenaShape::Paint::NONE) - || (shape->markers) - ) - { - // don't merge item opacity with paint opacity if there is a stroke on the fill, or markers on stroke - item->render_opacity = FALSE; - } + // to render opacity, use Cairo groups + item->render_opacity = FALSE; + + // update patterns when rendering if (beststate & NR_ARENA_ITEM_STATE_BBOX) { for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { @@ -745,92 +728,6 @@ cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect a return item->state; } -// cairo stroke rendering (flat color only so far!): -// works on canvas, but wrongs the colors in nonpremul buffers: icons and png export -// (need to switch them to premul before this can be enabled) -void -cairo_arena_shape_render_stroke(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) -{ - NRArenaShape *shape = NR_ARENA_SHAPE(item); - SPStyle const *style = shape->style; - - float const scale = shape->ctm.descrim(); - - if (fabs(shape->_stroke.width * scale) < 0.01) - return; - - cairo_t *ct = nr_create_cairo_context (area, pb); - - if (!ct) - return; - - guint32 rgba; - if ( item->render_opacity ) { - rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity * - SP_SCALE24_TO_FLOAT(style->opacity.value) ); - } else { - rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity ); - } - - // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat - // by setting color channels in the "wrong" order - cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); - - float style_width = MAX(0.125, shape->_stroke.width * scale); - cairo_set_line_width(ct, style_width); - - switch (shape->_stroke.cap) { - case NRArenaShape::BUTT_CAP: - cairo_set_line_cap(ct, CAIRO_LINE_CAP_BUTT); - break; - case NRArenaShape::ROUND_CAP: - cairo_set_line_cap(ct, CAIRO_LINE_CAP_ROUND); - break; - case NRArenaShape::SQUARE_CAP: - cairo_set_line_cap(ct, CAIRO_LINE_CAP_SQUARE); - break; - } - switch (shape->_stroke.join) { - case NRArenaShape::MITRE_JOIN: - cairo_set_line_join(ct, CAIRO_LINE_JOIN_MITER); - break; - case NRArenaShape::ROUND_JOIN: - cairo_set_line_join(ct, CAIRO_LINE_JOIN_ROUND); - break; - case NRArenaShape::BEVEL_JOIN: - cairo_set_line_join(ct, CAIRO_LINE_JOIN_BEVEL); - break; - } - - cairo_set_miter_limit (ct, style->stroke_miterlimit.value); - - if (style->stroke_dash.n_dash) { - NRVpathDash dash; - dash.offset = style->stroke_dash.offset * scale; - dash.n_dash = style->stroke_dash.n_dash; - dash.dash = g_new(double, dash.n_dash); - for (int i = 0; i < dash.n_dash; i++) { - dash.dash[i] = style->stroke_dash.dash[i] * scale; - } - cairo_set_dash (ct, dash.dash, dash.n_dash, dash.offset); - g_free(dash.dash); - } - - cairo_set_tolerance(ct, 0.1); - cairo_new_path(ct); - - feed_pathvector_to_cairo (ct, shape->curve->get_pathvector(), shape->ctm, to_2geom(area->upgrade()), true, style_width); - - cairo_stroke(ct); - - cairo_surface_t *cst = cairo_get_target(ct); - cairo_destroy (ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); - - pb->empty = FALSE; -} - /** * Renders the item. Markers are just composed into the parent buffer. */ @@ -841,9 +738,10 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (!shape->curve) return item->state; if (!shape->style) return item->state; + if (!ct) return item->state; bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - bool print_colors_preview = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); + //bool print_colors_preview = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); if (outline) { // cairo outline rendering @@ -875,6 +773,121 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock SPStyle const *style = shape->style; + // set up context and feed path + float opacity = SP_SCALE24_TO_FLOAT(shape->style->opacity.value); + bool needs_opacity = ((1.0 - opacity) >= 1e-3); + + cairo_save(ct); + //cairo_new_path(ct); // we assume the context is clean + cairo_translate(ct, -area->x0, -area->y0); + ink_cairo_transform(ct, shape->ctm); + + // update fill and stroke paints. + // this cannot be done during nr_arena_shape_update, because we need a Cairo context + // to use groups for svg:pattern + if (!shape->fill_pattern) { + switch (shape->_fill.paint.type()) { + case NRArenaShape::Paint::SERVER: { + SPPaintServer *ps = shape->_fill.paint.server(); + shape->fill_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_fill.opacity); + } break; + case NRArenaShape::Paint::COLOR: { + SPColor const &c = shape->_fill.paint.color(); + shape->fill_pattern = cairo_pattern_create_rgba( + c.v.c[0], c.v.c[1], c.v.c[2], shape->_fill.opacity); + } break; + default: break; + } + } + + if (!shape->stroke_pattern) { + switch (shape->_stroke.paint.type()) { + case NRArenaShape::Paint::SERVER: { + SPPaintServer *ps = shape->_stroke.paint.server(); + shape->stroke_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_stroke.opacity); + } break; + case NRArenaShape::Paint::COLOR: { + SPColor const &c = shape->_stroke.paint.color(); + shape->stroke_pattern = cairo_pattern_create_rgba( + c.v.c[0], c.v.c[1], c.v.c[2], shape->_stroke.opacity); + } break; + default: break; + } + } + + if (shape->fill_pattern || shape->stroke_pattern) { + + if (needs_opacity) { + cairo_push_group(ct); + } + + // TODO: remove segments outside of bbox when no dashes present + feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); + + if (shape->fill_pattern) { + switch (shape->_fill.rule) { + case NRArenaShape::EVEN_ODD: + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + break; + default: + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + break; + } + cairo_set_source(ct, shape->fill_pattern); + cairo_fill_preserve(ct); + } + + if (shape->stroke_pattern) { + // float style_width = shape->_stroke.width * scale; + cairo_set_line_width(ct, shape->_stroke.width); + + // stroke caps + switch (shape->_stroke.cap) { + case NRArenaShape::BUTT_CAP: + cairo_set_line_cap(ct, CAIRO_LINE_CAP_BUTT); + break; + case NRArenaShape::ROUND_CAP: + cairo_set_line_cap(ct, CAIRO_LINE_CAP_ROUND); + break; + case NRArenaShape::SQUARE_CAP: + cairo_set_line_cap(ct, CAIRO_LINE_CAP_SQUARE); + break; + } + // stroke join + switch (shape->_stroke.join) { + case NRArenaShape::MITRE_JOIN: + cairo_set_line_join(ct, CAIRO_LINE_JOIN_MITER); + break; + case NRArenaShape::ROUND_JOIN: + cairo_set_line_join(ct, CAIRO_LINE_JOIN_ROUND); + break; + case NRArenaShape::BEVEL_JOIN: + cairo_set_line_join(ct, CAIRO_LINE_JOIN_BEVEL); + break; + } + + // miter limit + cairo_set_miter_limit (ct, style->stroke_miterlimit.value); + + // dashes + if (style->stroke_dash.n_dash) { + cairo_set_dash (ct, style->stroke_dash.dash, style->stroke_dash.n_dash, + style->stroke_dash.offset); + } + cairo_set_source(ct, shape->stroke_pattern); + cairo_stroke_preserve(ct); + } + cairo_new_path(ct); // clear path + + if (needs_opacity) { + cairo_pop_group_to_source(ct); + cairo_paint_with_alpha(ct, opacity); + } + } // has fill or stroke pattern + + cairo_restore(ct); + +/* if (shape->fill_shp) { NRPixBlock m; guint32 rgba; @@ -917,10 +930,11 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock nr_pixblock_release(&m); } - if (shape->stroke_shp && shape->_stroke.paint.type() == NRArenaShape::Paint::COLOR) { + if (shape->_stroke.paint.type() == NRArenaShape::Paint::COLOR) { - // cairo_arena_shape_render_stroke(item, area, pb); + + guint32 rgba; NRPixBlock m; @@ -951,6 +965,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock pb->empty = FALSE; nr_pixblock_release(&m); + } else if (shape->stroke_shp && shape->_stroke.paint.type() == NRArenaShape::Paint::SERVER) { @@ -973,8 +988,8 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } nr_pixblock_release(&m); - } - + } +*/ } // non-cairo non-outline branch /* Render markers into parent buffer */ diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index 455757806..a88129286 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -115,6 +115,9 @@ struct NRArenaShape : public NRArenaItem { /* State data */ Geom::Matrix ctm; + cairo_pattern_t *fill_pattern; + cairo_pattern_t *stroke_pattern; + SPPainter *fill_painter; SPPainter *stroke_painter; // the 2 cached polygons, for rasterizations uses diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index caa5fa697..c85fb586b 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -13,6 +13,7 @@ #include "display-forward.h" #include "sodipodi-ctrl.h" #include "libnr/nr-pixops.h" +#include "display/inkscape-cairo.h" enum { ARG_0, @@ -176,11 +177,14 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) sp_canvas_item_request_update (item); break; - case ARG_FILL_COLOR: - ctrl->fill_color = GTK_VALUE_INT (*arg); + case ARG_FILL_COLOR: { + // treat colors with zero alpha as opaque + guint32 fill = GTK_VALUE_INT (*arg); + fill = ((fill & 0xff) == 0 && fill) ? fill | 0xff : fill; + ctrl->fill_color = fill; ctrl->build = FALSE; sp_canvas_item_request_update (item); - break; + } break; case ARG_STROKED: ctrl->stroked = GTK_VALUE_BOOL (*arg); @@ -188,11 +192,14 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) sp_canvas_item_request_update (item); break; - case ARG_STROKE_COLOR: - ctrl->stroke_color = GTK_VALUE_INT (*arg); + case ARG_STROKE_COLOR: { + // treat colors with zero alpha as opaque + guint32 stroke = GTK_VALUE_INT (*arg); + stroke = ((stroke & 0xff) == 0 && stroke) ? stroke | 0xff : stroke; + ctrl->stroke_color = stroke; ctrl->build = FALSE; sp_canvas_item_request_update (item); - break; + } break; case ARG_PIXBUF: pixbuf = (GdkPixbuf*)(GTK_VALUE_POINTER (*arg)); @@ -298,11 +305,11 @@ sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) static void sp_ctrl_build_cache (SPCtrl *ctrl) { - guchar * p, *q; - gint size, x, y, z, s, a, side, c; - guint8 fr, fg, fb, fa, sr, sg, sb, sa; + //guchar * p, *q; + //int size, x, y, z, s, a, side, c; + //guint8 fr, fg, fb, fa, sr, sg, sb, sa; - if (ctrl->filled) { + /*if (ctrl->filled) { fr = (ctrl->fill_color >> 24) & 0xff; fg = (ctrl->fill_color >> 16) & 0xff; fb = (ctrl->fill_color >> 8) & 0xff; @@ -317,147 +324,85 @@ sp_ctrl_build_cache (SPCtrl *ctrl) sa = (ctrl->stroke_color) & 0xff; } else { sr = fr; sg = fg; sb = fb; sa = fa; - } + }*/ + int w, h; // for clarity; w and h are always odd + w = h = (ctrl->span * 2 +1); + int c = ctrl->span ; - side = (ctrl->span * 2 +1); - c = ctrl->span ; - size = (side) * (side) * 4; - if (side < 2) return; + if (ctrl->cache) { + cairo_surface_finish(ctrl->cache); + cairo_surface_destroy(ctrl->cache); + } + ctrl->cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + cairo_t *cr = cairo_create(ctrl->cache); - if (ctrl->cache) - g_free (ctrl->cache); - ctrl->cache = (guchar*)g_malloc (size); + bool supress_fill = false; + bool supress_paint = false; switch (ctrl->shape) { case SP_CTRL_SHAPE_SQUARE: - p = ctrl->cache; - for (x=0; x < side; x++) { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; - } - for (y = 2; y < side; y++) { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; - for (x=2; x < side; x++) { - *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa; - } - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; - } - for (x=0; x < side; x++) { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; - } + cairo_rectangle(cr, 0, 0, w, h); ctrl->build = TRUE; break; case SP_CTRL_SHAPE_DIAMOND: - p = ctrl->cache; - for (y = 0; y < side; y++) { - z = abs (c - y); - for (x = 0; x < z; x++) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - } - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++; - for (; x < side - z -1; x++) { - *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa; - } - if (z != c) { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++; - } - for (; x < side; x++) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - } - } + cairo_move_to(cr, c, 0); // c stands for "center" - it is half of the width / height + cairo_line_to(cr, w, c); + cairo_line_to(cr, c, h); + cairo_line_to(cr, 0, c); + cairo_close_path(cr); + ctrl->build = TRUE; break; case SP_CTRL_SHAPE_CIRCLE: - p = ctrl->cache; - q = p + size -1; - s = -1; - for (y = 0; y <= c ; y++) { - a = abs (c - y); - z = (gint)(0.0 + sqrt ((c+.4)*(c+.4) - a*a)); - x = 0; - while (x < c-z) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; - x++; - } - do { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; - *q-- = sa; *q-- = sb; *q-- = sg; *q-- = sr; - x++; - } while (x < c-s); - while (x < MIN(c+s+1, c+z)) { - *p++ = fr; *p++ = fg; *p++ = fb; *p++ = fa; - *q-- = fa; *q-- = fb; *q-- = fg; *q-- = fr; - x++; - } - do { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; - *q-- = sa; *q-- = sb; *q-- = sg; *q-- = sr; - x++; - } while (x <= c+z); - while (x < side) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00; - x++; - } - s = z; - } + cairo_arc(cr, 0.5+c, 0.5+c, c, 0, 2*M_PI); + cairo_close_path(cr); ctrl->build = TRUE; break; case SP_CTRL_SHAPE_CROSS: - p = ctrl->cache; - for (y = 0; y < side; y++) { - z = abs (c - y); - for (x = 0; x < c-z; x++) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - } - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++; - for (; x < c + z; x++) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - } - if (z != 0) { - *p++ = sr; *p++ = sg; *p++ = sb; *p++ = sa; x++; - } - for (; x < side; x++) { - *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; - } - } + cairo_move_to(cr, 0.5+c, 0); // top stroke + cairo_line_to(cr, 0.5+c, c); + cairo_move_to(cr, w, 0.5+c); // right stroke + cairo_line_to(cr, w, c+1); + cairo_move_to(cr, 0.5+c, h); // bottom stroke + cairo_line_to(cr, 0.5+c, c+1); + cairo_move_to(cr, 0, 0.5+c); // left stroke + cairo_line_to(cr, c, 0.5+c); + supress_fill = true; ctrl->build = TRUE; break; case SP_CTRL_SHAPE_BITMAP: if (ctrl->pixbuf) { - unsigned char *px; - unsigned int rs; - px = gdk_pixbuf_get_pixels (ctrl->pixbuf); - rs = gdk_pixbuf_get_rowstride (ctrl->pixbuf); - for (y = 0; y < side; y++){ - unsigned char *s, *d; - s = px + y * rs; - d = ctrl->cache + 4 * side * y; - for (x = 0; x < side; x++) { - if (s[3] < 0x80) { - d[0] = 0x00; - d[1] = 0x00; - d[2] = 0x00; - d[3] = 0x00; - } else if (s[0] < 0x80) { - d[0] = sr; - d[1] = sg; - d[2] = sb; - d[3] = sa; + gdk_cairo_set_source_pixbuf(cr, ctrl->pixbuf, 0, 0); + cairo_paint(cr); + cairo_surface_flush(ctrl->cache); + + // TODO lame!!! find a way to do this without direct pixel manipulation. + int stride = cairo_image_surface_get_stride(ctrl->cache); + guint32 *px = reinterpret_cast(cairo_image_surface_get_data(ctrl->cache)); + + // fix byte order. fill_color is 0xrrggbbaa, cairo needs 0xaarrggbb. + // both quantities are native-endian, so it should be portable. + guint32 fill = ctrl->fill_color; + guint32 stroke = ctrl->stroke_color; + fill = ((fill & 0xff) << 24) | ((fill & 0xffffff00) >> 8); + stroke = ((stroke & 0xff) << 24) | ((stroke & 0xffffff00) >> 8); + + for (int i = 0; i < h; ++i) { + for (int j = 0; j < w; ++j) { + int index = i * stride / 4 + j; + if (px[index] & 0xff000000) { + px[index] = px[index] ? stroke : fill; } else { - d[0] = fr; - d[1] = fg; - d[2] = fb; - d[3] = fa; + px[index] = 0; } - s += 4; - d += 4; } } + cairo_surface_mark_dirty(ctrl->cache); + supress_paint = true; } else { g_print ("control has no pixmap\n"); } @@ -466,19 +411,9 @@ sp_ctrl_build_cache (SPCtrl *ctrl) case SP_CTRL_SHAPE_IMAGE: if (ctrl->pixbuf) { - guint r = gdk_pixbuf_get_rowstride (ctrl->pixbuf); - guchar * pix; - q = gdk_pixbuf_get_pixels (ctrl->pixbuf); - p = ctrl->cache; - for (y = 0; y < side; y++){ - pix = q + (y * r); - for (x = 0; x < side; x++) { - *p++ = *pix++; - *p++ = *pix++; - *p++ = *pix++; - *p++ = *pix++; - } - } + gdk_cairo_set_source_pixbuf(cr, ctrl->pixbuf, 0, 0); + cairo_paint(cr); + supress_paint = true; } else { g_print ("control has no pixmap\n"); } @@ -489,6 +424,20 @@ sp_ctrl_build_cache (SPCtrl *ctrl) break; } + if (ctrl->build && !supress_paint) { + if (ctrl->filled && !supress_fill) { + ink_cairo_set_source_rgba32(cr, ctrl->fill_color); + cairo_fill_preserve(cr); + } + if (ctrl->stroked) { + ink_cairo_set_source_rgba32(cr, ctrl->stroke_color); + cairo_set_line_width(cr, 2); + cairo_clip_preserve(cr); + cairo_stroke(cr); + } + } + + cairo_destroy(cr); } // composite background, foreground, alpha for xor mode @@ -499,29 +448,74 @@ sp_ctrl_build_cache (SPCtrl *ctrl) static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) { - gint y0, y1, y, x0,x1,x; - guchar *p, *q, a; + //gint y0, y1, y, x0,x1,x; + //guchar *p, *q, a; SPCtrl *ctrl = SP_CTRL (item); if (!ctrl->defined) return; if ((!ctrl->filled) && (!ctrl->stroked)) return; - sp_canvas_prepare_buffer (buf); - // the control-image is rendered into ctrl->cache if (!ctrl->build) { sp_ctrl_build_cache (ctrl); } + cairo_set_source_surface(buf->ct, ctrl->cache, + ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0); + cairo_paint(buf->ct); + + /* + double x0 = ctrl->box.x0; + double y0 = ctrl->box.y0; + double w = ctrl->box.x1 - ctrl->box.x0 + 1; + double h = ctrl->box.y1 - ctrl->box.y0 + 1; + //guint32 fill = ctrl->fill_color; + //fill = (fill & 0xff == 0 && fill) ? fill | 0xff : fill; + + + switch (ctrl->shape) { + case SP_CTRL_SHAPE_SQUARE: + cairo_rectangle(buf->ct, x0, y0, w, h); + break; + case SP_CTRL_SHAPE_DIAMOND: + cairo_move_to(buf->ct, x0 + w/2, y0); + cairo_line_to(buf->ct, x0 + w, y0 + h/2); + cairo_line_to(buf->ct, x0 + w/2, y0 + h); + cairo_line_to(buf->ct, x0, y0 + h/2); + cairo_close_path(buf->ct); + break; + //case SP_CTRL_SHAPE_CIRCLE: + default: + cairo_arc(buf->ct, x0 + w/2, y0 + h/2, w/2, 0, 2*M_PI); + cairo_close_path(buf->ct); + break; + } + + //if (ctrl->mode == SP_CTRL_MODE_XOR) { + // cairo_set_operator(buf->ct, CAIRO_OPERATOR_XOR); + //} + if (ctrl->filled) { + ink_cairo_set_source_rgba32(buf->ct, ctrl->fill_color); + cairo_fill_preserve(buf->ct); + } + if (ctrl->stroked) { + ink_cairo_set_source_rgba32(buf->ct, ctrl->stroke_color); + cairo_set_line_width(buf->ct, 2); + cairo_clip_preserve(buf->ct); + cairo_stroke_preserve(buf->ct); + } + + cairo_new_path(buf->ct); + cairo_restore(buf->ct);*/ + + #if 0 // then we render from ctrl->cache y0 = MAX (ctrl->box.y0, buf->rect.y0); y1 = MIN (ctrl->box.y1, buf->rect.y1 - 1); x0 = MAX (ctrl->box.x0, buf->rect.x0); x1 = MIN (ctrl->box.x1, buf->rect.x1 - 1); - bool colormode; - for (y = y0; y <= y1; y++) { p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; q = ctrl->cache + ((y - ctrl->box.y0) * (ctrl->span*2+1) + (x0 - ctrl->box.x0)) * 4; @@ -548,6 +542,7 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) } } } + #endif ctrl->shown = TRUE; } diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 859735e4f..ed4db27fe 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -50,7 +50,7 @@ struct SPCtrl : public SPCanvasItem{ bool _moved; NRRectL box; /* NB! x1 & y1 are included */ - guchar *cache; + cairo_surface_t *cache; GdkPixbuf * pixbuf; void moveto(Geom::Point const p); diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index dcd6dc0a6..09bfde6fb 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -18,7 +18,7 @@ #include "display-forward.h" #include "sp-canvas-util.h" #include "sodipodi-ctrlrect.h" -#include "libnr/nr-pixops.h" +#include "display/inkscape-cairo.h" /* * Currently we do not have point method, as it should always be painted @@ -84,7 +84,7 @@ static void sp_ctrlrect_destroy(GtkObject *object) (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); } } - +#if 0 /* FIXME: use definitions from somewhere else */ #define RGBA_R(v) ((v) >> 24) #define RGBA_G(v) (((v) >> 16) & 0xff) @@ -154,6 +154,7 @@ static void sp_ctrlrect_area(SPCanvasBuf *buf, gint xs, gint ys, gint xe, gint y } } } +#endif static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf) { @@ -189,13 +190,38 @@ void CtrlRect::init() void CtrlRect::render(SPCanvasBuf *buf) { + static double const dashes[2] = {4.0, 4.0}; + if ((_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) && (_area.x0 < buf->rect.x1) && (_area.y0 < buf->rect.y1) && ((_area.x1 + _shadow_size) >= buf->rect.x0) && - ((_area.y1 + _shadow_size) >= buf->rect.y0)) { - sp_canvas_prepare_buffer(buf); + ((_area.y1 + _shadow_size) >= buf->rect.y0)) + { + cairo_save(buf->ct); + cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_set_line_width(buf->ct, 1); + if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0); + cairo_rectangle(buf->ct, 0.5 + _area.x0, 0.5 + _area.y0, + _area.x1 - _area.x0, _area.y1 - _area.y0); + if (_has_fill) { + ink_cairo_set_source_rgba32(buf->ct, _fill_color); + cairo_fill_preserve(buf->ct); + } + ink_cairo_set_source_rgba32(buf->ct, _border_color); + cairo_stroke(buf->ct); + + if (_shadow_size > 0) { + ink_cairo_set_source_rgba32(buf->ct, _shadow_color); + cairo_rectangle(buf->ct, 1 + _area.x1, _area.y0 + _shadow_size, + _shadow_size, _area.y1 - _area.y0 + 1); // right shadow + cairo_rectangle(buf->ct, _area.x0 + _shadow_size, 1 + _area.y1, + _area.x1 - _area.x0 - _shadow_size + 1, _shadow_size); + cairo_fill(buf->ct); + } + cairo_restore(buf->ct); +#if 0 /* Top */ sp_ctrlrect_hline(buf, _area.y0, _area.x0, _area.x1, _border_color, _dashed); /* Bottom */ @@ -217,6 +243,7 @@ void CtrlRect::render(SPCanvasBuf *buf) sp_ctrlrect_area(buf, _area.x0 + 1, _area.y0 + 1, _area.x1 - 1, _area.y1 - 1, _fill_color); } +#endif } } diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index a23b157df..970fea0e5 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -43,36 +43,11 @@ void sp_canvas_prepare_buffer (SPCanvasBuf *buf) { if (buf->is_empty) { - sp_canvas_clear_buffer(buf); - buf->is_empty = false; - } -} - -void -sp_canvas_clear_buffer (SPCanvasBuf *buf) -{ - unsigned char r, g, b; - - r = (buf->bg_color >> 16) & 0xff; - g = (buf->bg_color >> 8) & 0xff; - b = buf->bg_color & 0xff; - - if ((r != g) || (r != b)) { - int x, y; - for (y = buf->rect.y0; y < buf->rect.y1; y++) { - unsigned char *p; - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride; - for (x = buf->rect.x0; x < buf->rect.x1; x++) { - *p++ = r; - *p++ = g; - *p++ = b; - } - } - } else { int y; for (y = buf->rect.y0; y < buf->rect.y1; y++) { - memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, r, 4 * (buf->rect.x1 - buf->rect.x0)); + memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, 0, 4 * (buf->rect.x1 - buf->rect.x0)); } + buf->is_empty = false; } } diff --git a/src/display/sp-canvas-util.h b/src/display/sp-canvas-util.h index 4708126e5..e86eeba20 100644 --- a/src/display/sp-canvas-util.h +++ b/src/display/sp-canvas-util.h @@ -21,11 +21,6 @@ void sp_canvas_update_bbox (SPCanvasItem *item, int x1, int y1, int x2, int y2); void sp_canvas_item_reset_bounds (SPCanvasItem *item); void sp_canvas_prepare_buffer (SPCanvasBuf *buf); -/* fill buffer with background color */ - -void -sp_canvas_clear_buffer (SPCanvasBuf * buf); - /* get i2p (item to parent) affine transformation as general 6-element array */ Geom::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c6778c8c5..29a5cd740 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1649,18 +1649,32 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, buf.visible_rect.y0 = draw_y1; buf.visible_rect.x1 = draw_x2; buf.visible_rect.y1 = draw_y2; - GdkColor *color = &widget->style->bg[GTK_STATE_NORMAL]; - buf.bg_color = (((color->red & 0xff00) << 8) - | (color->green & 0xff00) - | (color->blue >> 8)); buf.is_empty = true; - - buf.ct = nr_create_cairo_context_canvasbuf (&(buf.visible_rect), &buf); + //buf.bg_color = &widget->style->bg[GTK_STATE_NORMAL]; + //buf.ct = nr_create_cairo_context_canvasbuf (&(buf.visible_rect), &buf); + buf.ct = gdk_cairo_create(widget->window); + + // fix coordinates, clip all drawing to the tile and clear the background + // TODO: the translation is done to remain compatible with legacy code. + // Fix the code so it doesn't refer to buf.rect and remove the translation. + cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); // ? + cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_set_line_width(buf.ct, 3); + //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); + //cairo_stroke_preserve(buf.ct); + cairo_clip(buf.ct); + + gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]); + cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); + //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + cairo_paint(buf.ct); + cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER); if (canvas->root->flags & SP_CANVAS_ITEM_VISIBLE) { SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf); } +#if 0 #if ENABLE_LCMS cmsHTRANSFORM transf = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1702,22 +1716,22 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, // use gdk_draw_rgb_image_dithalign, for unfortunately gdk can only handle 24 bpp, which cairo // cannot handle at all. Still, this way is currently faster even despite the blit with squeeze. -///#define CANVAS_OUTPUT_VIA_CAIRO +//#define CANVAS_OUTPUT_VIA_CAIRO #ifdef CANVAS_OUTPUT_VIA_CAIRO - buf.cst = cairo_image_surface_create_for_data ( + cairo_surface_t *cst = cairo_image_surface_create_for_data ( buf.buf, CAIRO_FORMAT_ARGB32, // unpacked, i.e. 32 bits! one byte is unused x1 - x0, y1 - y0, buf.buf_rowstride ); cairo_t *window_ct = gdk_cairo_create(SP_CANVAS_WINDOW (canvas)); - cairo_set_source_surface (window_ct, buf.cst, x0 - canvas->x0, y0 - canvas->y0); + cairo_set_source_surface (window_ct, cst, x0 - canvas->x0, y0 - canvas->y0); cairo_paint (window_ct); cairo_destroy (window_ct); - cairo_surface_finish (buf.cst); - cairo_surface_destroy (buf.cst); + cairo_surface_finish (cst); + cairo_surface_destroy (cst); #else @@ -1746,11 +1760,12 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, nr_pixblock_release (&b4); #endif } +#endif - cairo_surface_t *cst = cairo_get_target(buf.ct); + //cairo_surface_t *cst = cairo_get_target(buf.ct); cairo_destroy (buf.ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); + //cairo_surface_finish (cst); + //cairo_surface_destroy (cst); if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { nr_pixelstore_256K_free (buf.buf); @@ -1816,11 +1831,21 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) if (bw * bh < setup->max_pixels) { // We are small enough + GdkRectangle r; + r.x = this_rect.x0 - setup->canvas->x0; + r.y = this_rect.y0 - setup->canvas->y0; + r.width = this_rect.x1 - this_rect.x0; + r.height = this_rect.y1 - this_rect.y0; + + GdkWindow *window = GTK_WIDGET(setup->canvas)->window; + gdk_window_begin_paint_rect(window, &r); + sp_canvas_paint_single_buffer (setup->canvas, this_rect.x0, this_rect.y0, this_rect.x1, this_rect.y1, setup->big_rect.x0, setup->big_rect.y0, setup->big_rect.x1, setup->big_rect.y1, bw); + gdk_window_end_paint(window); return 1; } diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index a2af080ef..6a2ee074e 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -52,18 +52,16 @@ enum { }; /** - * The canvas buf contains the actual pixels. + * Structure used when rendering canvas items. */ -struct SPCanvasBuf{ - guchar *buf; - int buf_rowstride; +struct SPCanvasBuf { + cairo_t *ct; NRRectL rect; NRRectL visible_rect; - /// Background color, given as 0xrrggbb - guint32 bg_color; - // If empty, ignore contents of buffer and use a solid area of bg_color + + unsigned char *buf; + int buf_rowstride; bool is_empty; - cairo_t *ct; }; /** diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index 033c8d1f8..043736d94 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -106,11 +106,7 @@ sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf) if (cl->s == cl->e) return; - sp_canvas_prepare_buffer (buf); - - guint32 rgba = cl->rgba; - cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); - + ink_cairo_set_source_rgba32(buf->ct, cl->rgba); cairo_set_line_width(buf->ct, 1); cairo_new_path(buf->ct); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 3d4d69672..f63436e71 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -31,6 +31,7 @@ #include #include +#include "display/inkscape-cairo.h" #include "libnr/nr-gradient.h" #include "libnr/nr-pixops.h" #include "svg/svg.h" @@ -1425,7 +1426,7 @@ static SPPainter *sp_lineargradient_painter_new(SPPaintServer *ps, Geom::Matrix const &parent_transform, NRRect const *bbox); static void sp_lineargradient_painter_free(SPPaintServer *ps, SPPainter *painter); - +static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); static void sp_lg_fill(SPPainter *painter, NRPixBlock *pb); static SPGradientClass *lg_parent_class; @@ -1469,6 +1470,7 @@ static void sp_lineargradient_class_init(SPLinearGradientClass *klass) ps_class->painter_new = sp_lineargradient_painter_new; ps_class->painter_free = sp_lineargradient_painter_free; + ps_class->pattern_new = sp_lineargradient_create_pattern; } /** @@ -1700,6 +1702,7 @@ static SPPainter *sp_radialgradient_painter_new(SPPaintServer *ps, Geom::Matrix const &parent_transform, NRRect const *bbox); static void sp_radialgradient_painter_free(SPPaintServer *ps, SPPainter *painter); +static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); static void sp_rg_fill(SPPainter *painter, NRPixBlock *pb); @@ -1744,6 +1747,7 @@ static void sp_radialgradient_class_init(SPRadialGradientClass *klass) ps_class->painter_new = sp_radialgradient_painter_new; ps_class->painter_free = sp_radialgradient_painter_free; + ps_class->pattern_new = sp_radialgradient_create_pattern; } /** @@ -1950,6 +1954,86 @@ sp_rg_fill(SPPainter *painter, NRPixBlock *pb) nr_render((NRRenderer *) &rgp->rgr, pb, NULL); } +/* CAIRO RENDERING STUFF */ + +static void +sp_gradient_pattern_common_setup(cairo_pattern_t *cp, + SPGradient *gr, + NRRect const *bbox, + double opacity) +{ + // set spread type + switch (sp_gradient_get_spread(gr)) { + case SP_GRADIENT_SPREAD_REFLECT: + cairo_pattern_set_extend(cp, CAIRO_EXTEND_REFLECT); + break; + case SP_GRADIENT_SPREAD_REPEAT: + cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); + break; + case SP_GRADIENT_SPREAD_PAD: + default: + cairo_pattern_set_extend(cp, CAIRO_EXTEND_PAD); + break; + } + + // add stops + for (std::vector::iterator i = gr->vector.stops.begin(); + i != gr->vector.stops.end(); ++i) + { + // multiply stop opacity by paint opacity + cairo_pattern_add_color_stop_rgba(cp, i->offset, + i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity); + } + + // set pattern matrix + Geom::Matrix gs2user = gr->gradientTransform; + if (gr->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { + Geom::Matrix bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + gs2user *= bbox2user; + } + ink_cairo_pattern_set_matrix(cp, gs2user.inverse()); +} + +static cairo_pattern_t * +sp_radialgradient_create_pattern(SPPaintServer *ps, + cairo_t */* ct */, + NRRect const *bbox, + double opacity) +{ + SPRadialGradient *rg = SP_RADIALGRADIENT(ps); + SPGradient *gr = SP_GRADIENT(ps); + + if (!gr->color) sp_gradient_ensure_colors(gr); + + cairo_pattern_t *cp = cairo_pattern_create_radial( + rg->fx.computed, rg->fy.computed, 0, + rg->cx.computed, rg->cy.computed, rg->r.computed); + + sp_gradient_pattern_common_setup(cp, gr, bbox, opacity); + + return cp; +} + +static cairo_pattern_t * +sp_lineargradient_create_pattern(SPPaintServer *ps, + cairo_t */* ct */, + NRRect const *bbox, + double opacity) +{ + SPLinearGradient *lg = SP_LINEARGRADIENT(ps); + SPGradient *gr = SP_GRADIENT(ps); + + if (!gr->color) sp_gradient_ensure_colors(gr); + + cairo_pattern_t *cp = cairo_pattern_create_linear( + lg->x1.computed, lg->y1.computed, + lg->x2.computed, lg->y2.computed); + + sp_gradient_pattern_common_setup(cp, gr, bbox, opacity); + + return cp; +} + /* Local Variables: mode:c++ diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index 258323a93..e49e6a378 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -26,6 +26,7 @@ static void sp_paint_server_init(SPPaintServer *ps); static void sp_paint_server_release(SPObject *object); static void sp_painter_stale_fill(SPPainter *painter, NRPixBlock *pb); +static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); static SPObjectClass *parent_class; static GSList *stale_painters = NULL; @@ -55,6 +56,7 @@ static void sp_paint_server_class_init(SPPaintServerClass *psc) { SPObjectClass *sp_object_class = (SPObjectClass *) psc; sp_object_class->release = sp_paint_server_release; + psc->pattern_new = sp_paint_server_create_dummy_pattern; parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); } @@ -106,6 +108,36 @@ SPPainter *sp_paint_server_painter_new(SPPaintServer *ps, return painter; } +cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, + cairo_t *ct, + NRRect const *bbox, + double opacity) +{ + // NOTE: the ct argument is used for when rendering patterns + // to create a group, instead of explicitly creating a temporary surface + g_return_val_if_fail(ps != NULL, NULL); + g_return_val_if_fail(SP_IS_PAINT_SERVER(ps), NULL); + g_return_val_if_fail(bbox != NULL, NULL); + + cairo_pattern_t *cp = NULL; + SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps); + if ( psc->pattern_new ) { + cp = (*psc->pattern_new)(ps, ct, bbox, opacity); + } + + return cp; +} + +static cairo_pattern_t * +sp_paint_server_create_dummy_pattern(SPPaintServer */*ps*/, + cairo_t */* ct */, + NRRect const */*bbox*/, + double /* opacity */) +{ + cairo_pattern_t *cp = cairo_pattern_create_rgb(1.0, 0.0, 1.0); + return cp; +} + static void sp_paint_server_painter_free(SPPaintServer *ps, SPPainter *painter) { g_return_if_fail(ps != NULL); diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index a76daf4d1..d1fc9b7ac 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -15,6 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include #include "sp-object.h" #include "uri-references.h" @@ -57,11 +58,14 @@ struct SPPaintServerClass { SPPainter * (* painter_new) (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &parent_transform, const NRRect *bbox); /** Free SPPaint instance. */ void (* painter_free) (SPPaintServer *ps, SPPainter *painter); + + cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, const NRRect *bbox, double opacity); }; GType sp_paint_server_get_type (void); SPPainter *sp_paint_server_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &parent_transform, const NRRect *bbox); +cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); SPPainter *sp_painter_free (SPPainter *painter); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ec0d0d576..8d1e8dab5 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -23,6 +23,7 @@ #include <2geom/transforms.h> #include "macros.h" #include "svg/svg.h" +#include "display/inkscape-cairo.h" #include "display/nr-arena.h" #include "display/nr-arena-group.h" #include "attributes.h" @@ -76,6 +77,7 @@ static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern static SPPainter *sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &parent_transform, const NRRect *bbox); static void sp_pattern_painter_free (SPPaintServer *ps, SPPainter *painter); +static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); static SPPaintServerClass * pattern_parent_class; @@ -123,6 +125,7 @@ sp_pattern_class_init (SPPatternClass *klass) ps_class->painter_new = sp_pattern_painter_new; ps_class->painter_free = sp_pattern_painter_free; + ps_class->pattern_new = sp_pattern_create_pattern; } static void @@ -1016,3 +1019,128 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) } } } + +static cairo_pattern_t * +sp_pattern_create_pattern(SPPaintServer *ps, + cairo_t *base_ct, + NRRect const *bbox, + double opacity) +{ + SPPattern *pat = SP_PATTERN (ps); + Geom::Matrix ps2user; + bool needs_opacity = (1.0 - opacity) >= 1e-3; + bool visible = opacity >= 1e-3; + + if (!visible) + return NULL; + + if (pat->viewBox_set) { + gdouble tmp_x = pattern_width (pat) / (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0); + gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0); + + // FIXME: preserveAspectRatio must be taken into account here too! + Geom::Matrix vb2ps (tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - pattern_viewBox(pat)->x0 * tmp_x, pattern_y(pat) - pattern_viewBox(pat)->y0 * tmp_y); + + ps2user = vb2ps * pattern_patternTransform(pat); + } else { + /* No viewbox, have to parse units */ + ps2user = pattern_patternTransform(pat); + if (pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { + /* BBox to user coordinate system */ + Geom::Matrix bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + ps2user *= bbox2user; + } + ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; + } + + /* Create arena */ + NRArena *arena = NRArena::create(); + unsigned int dkey = sp_item_display_key_new (1); + NRArenaGroup *root = NRArenaGroup::create(arena); + + /* Show items */ + for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + // find the first one with item children + if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { + for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_ITEM (child)) { + // for each item in pattern, show it on our arena, add to the group, + // and connect to the release signal in case the item gets deleted + NRArenaItem *cai; + cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_REFERENCE_FLAGS); + nr_arena_item_append_child (root, cai); + } + } + break; // do not go further up the chain if children are found + } + } + + double x = pattern_x(pat); + double y = pattern_y(pat); + double w = pattern_width(pat); + double h = pattern_height(pat); + + cairo_matrix_t cm; + cairo_get_matrix(base_ct, &cm); + Geom::Matrix full(cm.xx, cm.yx, cm.xy, cm.yy, 0, 0); + + // oversample the pattern slightly + // TODO: find optimum value. Maybe sqrt(2)? + Geom::Point c(Geom::Point(w, h)*ps2user.descrim()*full.descrim()*1.2); + c[Geom::X] = ceil(c[Geom::X]); + c[Geom::Y] = ceil(c[Geom::Y]); + Geom::Matrix t = Geom::Scale(c[Geom::X]/w, c[Geom::Y]/h); + + NRRectL one_tile; + one_tile.x0 = (int) floor(x); + one_tile.y0 = (int) floor(y); + one_tile.x1 = (int) ceil(x+w); + one_tile.y1 = (int) ceil(y+h); + + cairo_surface_t *target = cairo_get_target(base_ct); + cairo_surface_t *temp = cairo_surface_create_similar(target, CAIRO_CONTENT_COLOR_ALPHA, + c[Geom::X], c[Geom::Y]); + cairo_t *ct = cairo_create(temp); + ink_cairo_transform(ct, t); + + // render pattern. + if (needs_opacity) { + cairo_push_group(ct); // this group is for pattern + opacity + } + + // TODO: make sure there are no leaks. + NRPixBlock pb; + nr_pixblock_setup (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, one_tile.x0, one_tile.y0, + one_tile.x1, one_tile.y1, TRUE); + NRGC gc(NULL); + gc.transform = Geom::identity(); + nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); + nr_arena_item_invoke_render (ct, root, &one_tile, &pb, 0); + nr_object_unref(arena); + nr_pixblock_release(&pb); + + if (needs_opacity) { + cairo_pop_group_to_source(ct); // pop raw pattern + cairo_paint_with_alpha(ct, opacity); // apply opacity + } + + cairo_pattern_t *cp = cairo_pattern_create_for_surface(temp); + cairo_surface_destroy(temp); + + // Apply transformation to user space. Also compensate for oversampling. + ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * t); + cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); + + return cp; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 1496385d1be9d733b06e0cd94839e2ef32c959bc Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 22 Jun 2010 23:45:17 +0200 Subject: Fix cross control point (bzr r9508.1.2) --- src/display/sodipodi-ctrl.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index c85fb586b..dc79f5969 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -337,7 +337,6 @@ sp_ctrl_build_cache (SPCtrl *ctrl) ctrl->cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); cairo_t *cr = cairo_create(ctrl->cache); - bool supress_fill = false; bool supress_paint = false; switch (ctrl->shape) { @@ -362,15 +361,13 @@ sp_ctrl_build_cache (SPCtrl *ctrl) break; case SP_CTRL_SHAPE_CROSS: - cairo_move_to(cr, 0.5+c, 0); // top stroke - cairo_line_to(cr, 0.5+c, c); - cairo_move_to(cr, w, 0.5+c); // right stroke - cairo_line_to(cr, w, c+1); - cairo_move_to(cr, 0.5+c, h); // bottom stroke - cairo_line_to(cr, 0.5+c, c+1); - cairo_move_to(cr, 0, 0.5+c); // left stroke - cairo_line_to(cr, c, 0.5+c); - supress_fill = true; + cairo_move_to(cr, 0.5, 0.5); + cairo_line_to(cr, -0.5+w, -0.5+h); + cairo_move_to(cr, -0.5+w, 0.5); // right stroke + cairo_line_to(cr, 0.5, -0.5+h); + cairo_set_line_width(cr, 1); + cairo_stroke(cr); + supress_paint = true; ctrl->build = TRUE; break; @@ -425,7 +422,7 @@ sp_ctrl_build_cache (SPCtrl *ctrl) } if (ctrl->build && !supress_paint) { - if (ctrl->filled && !supress_fill) { + if (ctrl->filled) { ink_cairo_set_source_rgba32(cr, ctrl->fill_color); cairo_fill_preserve(cr); } -- cgit v1.2.3 From 31f84a59da72b31b932833ce1af7d78f0a67e185 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 26 Jun 2010 03:02:06 +0200 Subject: Implement clipping (slightly incorrect) and masking (bzr r9508.1.4) --- src/display/Makefile_insert | 2 + src/display/cairo-utils.cpp | 113 ++++++ src/display/cairo-utils.h | 88 +++++ src/display/nr-arena-glyphs.cpp | 11 +- src/display/nr-arena-group.cpp | 6 +- src/display/nr-arena-item.cpp | 148 +++---- src/display/nr-arena-item.h | 4 +- src/display/nr-arena-shape.cpp | 838 ++++++---------------------------------- src/display/nr-arena-shape.h | 68 +--- src/display/sp-canvas.cpp | 38 +- 10 files changed, 446 insertions(+), 870 deletions(-) create mode 100644 src/display/cairo-utils.cpp create mode 100644 src/display/cairo-utils.h (limited to 'src') diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 58e667402..7660d2c70 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -33,6 +33,8 @@ ink_common_sources += \ display/canvas-temporary-item-list.h \ display/canvas-text.h \ display/canvas-text.cpp \ + display/cairo-utils.h \ + display/cairo-utils.cpp \ display/curve.cpp \ display/curve.h \ display/display-forward.h \ diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp new file mode 100644 index 000000000..58db5d551 --- /dev/null +++ b/src/display/cairo-utils.cpp @@ -0,0 +1,113 @@ +/* + * Helper functions to use cairo with inkscape + * + * Copyright (C) 2007 bulia byak + * Copyright (C) 2008 Johan Engelen + * + * Released under GNU GPL + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include <2geom/matrix.h> +#include "display/cairo-utils.h" +#include "display/inkscape-cairo.h" +#include "color.h" + +namespace Inkscape { + +CairoGroup::CairoGroup(cairo_t *_ct) : ct(_ct), pushed(false) {} +CairoGroup::~CairoGroup() { + if (pushed) { + cairo_pattern_t *p = cairo_pop_group(ct); + cairo_pattern_destroy(p); + } +} +void CairoGroup::push() { + cairo_push_group(ct); + pushed = true; +} +void CairoGroup::push_with_content(cairo_content_t content) { + cairo_push_group_with_content(ct, content); + pushed = true; +} +cairo_pattern_t *CairoGroup::pop() { + if (pushed) { + cairo_pattern_t *ret = cairo_pop_group(ct); + pushed = false; + return ret; + } else { + throw std::logic_error("Cairo group popped without pushing it first"); + } +} +Cairo::RefPtr CairoGroup::popmm() { + if (pushed) { + cairo_pattern_t *ret = cairo_pop_group(ct); + Cairo::RefPtr retmm(new Cairo::Pattern(ret, true)); + pushed = false; + return retmm; + } else { + throw std::logic_error("Cairo group popped without pushing it first"); + } +} +void CairoGroup::pop_to_source() { + if (pushed) { + cairo_pop_group_to_source(ct); + pushed = false; + } +} + +CairoContext::CairoContext(cairo_t *obj, bool ref) + : Cairo::Context(obj, ref) +{} + +void CairoContext::transform(Geom::Matrix const &m) +{ + cairo_matrix_t cm; + cm.xx = m[0]; + cm.xy = m[2]; + cm.x0 = m[4]; + cm.yx = m[1]; + cm.yy = m[3]; + cm.y0 = m[5]; + cairo_transform(cobj(), &cm); +} + +void CairoContext::set_source_rgba32(guint32 color) +{ + double red = SP_RGBA32_R_F(color); + double gre = SP_RGBA32_G_F(color); + double blu = SP_RGBA32_B_F(color); + double alp = SP_RGBA32_A_F(color); + cairo_set_source_rgba(cobj(), red, gre, blu, alp); +} + +void CairoContext::append_path(Geom::PathVector const &pv) +{ + feed_pathvector_to_cairo(cobj(), pv); +} + +Cairo::RefPtr CairoContext::create(Cairo::RefPtr const &target) +{ + cairo_t *ct = cairo_create(target->cobj()); + Cairo::RefPtr ret(new CairoContext(ct, true)); + return ret; +} + +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h new file mode 100644 index 000000000..feed987bd --- /dev/null +++ b/src/display/cairo-utils.h @@ -0,0 +1,88 @@ +/** + * @file + * @brief Cairo integration helpers + *//* + * Authors: + * Krzysztof Kosiński + * + * Copyright (C) 2010 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_CAIRO_UTILS_H +#define SEEN_INKSCAPE_DISPLAY_CAIRO_UTILS_H + +#include +#include +#include <2geom/forward.h> + +namespace Inkscape { + +/** @brief RAII idiom for Cairo groups. + * Groups are temporary surfaces used when rendering e.g. masks and opacity. + * Use this class to ensure that each group push is matched with a pop. */ +class CairoGroup { +public: + CairoGroup(cairo_t *_ct); + ~CairoGroup(); + void push(); + void push_with_content(cairo_content_t content); + cairo_pattern_t *pop(); + Cairo::RefPtr popmm(); + void pop_to_source(); +private: + cairo_t *ct; + bool pushed; +}; + +/** @brief RAII idiom for Cairo state saving */ +class CairoSave { +public: + CairoSave(cairo_t *_ct, bool save=false) + : ct(_ct) + , saved(save) + { + if (save) { + cairo_save(ct); + } + } + void save() { + if (!saved) { + cairo_save(ct); + saved = true; + } + } + ~CairoSave() { + if (saved) + cairo_restore(ct); + } +private: + cairo_t *ct; + bool saved; +}; + +/** @brief Cairo context with Inkscape-specific operations */ +class CairoContext : public Cairo::Context { +public: + CairoContext(cairo_t *obj, bool ref = false); + + void transform(Geom::Matrix const &m); + void set_source_rgba32(guint32 color); + void append_path(Geom::PathVector const &pv); + + static Cairo::RefPtr create(Cairo::RefPtr const &target); +}; + +} // namespace Inkscape + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 33b08a91c..d229157ed 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -44,7 +44,7 @@ static void nr_arena_glyphs_init(NRArenaGlyphs *glyphs); static void nr_arena_glyphs_finalize(NRObject *object); static guint nr_arena_glyphs_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); -static guint nr_arena_glyphs_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb); +static guint nr_arena_glyphs_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area); static NRArenaItem *nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *glyphs_parent_class; @@ -220,7 +220,7 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s } static guint -nr_arena_glyphs_clip(NRArenaItem *item, NRRectL */*area*/, NRPixBlock */*pb*/) +nr_arena_glyphs_clip(cairo_t *ct, NRArenaItem *item, NRRectL */*area*/) { NRArenaGlyphs *glyphs; @@ -319,7 +319,7 @@ static void nr_arena_glyphs_group_finalize(NRObject *object); static guint nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static unsigned int nr_arena_glyphs_group_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb); +static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area); static NRArenaItem *nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int sticky); static NRArenaGroupClass *group_parent_class; @@ -572,17 +572,18 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi } static unsigned int -nr_arena_glyphs_group_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) +nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area) { NRArenaGroup *group = NR_ARENA_GROUP(item); guint ret = item->state; /* Render children fill mask */ + /* for (NRArenaItem *child = group->children; child != NULL; child = child->next) { ret = nr_arena_glyphs_fill_mask(NR_ARENA_GLYPHS(child), area, pb); if (!(ret & NR_ARENA_ITEM_STATE_RENDER)) return ret; - } + }*/ return ret; } diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 38d37c233..0fa5f332a 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -35,7 +35,7 @@ static void nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *c static unsigned int nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); static unsigned int nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static unsigned int nr_arena_group_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb); +static unsigned int nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area); static NRArenaItem *nr_arena_group_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *parent_class; @@ -233,7 +233,7 @@ nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } static unsigned int -nr_arena_group_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) +nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) { NRArenaGroup *group = NR_ARENA_GROUP (item); @@ -241,7 +241,7 @@ nr_arena_group_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) /* Just compose children into parent buffer */ for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - ret = nr_arena_item_invoke_clip (child, area, pb); + ret = nr_arena_item_invoke_clip (ct, child, area); if (ret & NR_ARENA_ITEM_STATE_INVALID) break; } diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index d101a9e54..8f11db191 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -17,9 +17,11 @@ #include #include +#include #include #include +#include "display/cairo-utils.h" #include "nr-arena.h" #include "nr-arena-item.h" #include "gc-core.h" @@ -321,6 +323,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (item->state & NR_ARENA_ITEM_STATE_BBOX, item->state); + if (!ct) return item->state; #ifdef NR_ARENA_ITEM_VERBOSE printf ("Invoke render %p: %d %d - %d %d\n", item, area->x0, area->y0, @@ -341,78 +344,36 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area } if (outline) { - // No caching in outline mode for now; investigate if it really gives any advantage with cairo. - // Also no attempts to clip anything; just render everything: item, clip, mask - // First, render the object itself - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, pb, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } + // No caching in outline mode for now; investigate if it really gives any advantage with cairo. + // Also no attempts to clip anything; just render everything: item, clip, mask + // First, render the object itself + unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, pb, flags); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + /* Clean up and return error */ + item->state |= NR_ARENA_ITEM_STATE_INVALID; + return item->state; + } - // render clip and mask, if any - guint32 saved_rgba = item->arena->outlinecolor; // save current outline color - // render clippath as an object, using a different color - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (item->clip) { - item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips - NR_ARENA_ITEM_VIRTUAL (item->clip, render) (ct, item->clip, &carea, pb, flags); - } - // render mask as an object, using a different color - if (item->mask) { - item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks - NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, &carea, pb, flags); - } - item->arena->outlinecolor = saved_rgba; // restore outline color + // render clip and mask, if any + guint32 saved_rgba = item->arena->outlinecolor; // save current outline color + // render clippath as an object, using a different color + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (item->clip) { + item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips + NR_ARENA_ITEM_VIRTUAL (item->clip, render) (ct, item->clip, &carea, pb, flags); + } + // render mask as an object, using a different color + if (item->mask) { + item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks + NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, &carea, pb, flags); + } + item->arena->outlinecolor = saved_rgba; // restore outline color - return item->state | NR_ARENA_ITEM_STATE_RENDER; + return item->state | NR_ARENA_ITEM_STATE_RENDER; } #if 0 - NRPixBlock cpb; - if (item->px) { - /* Has cache pixblock, render this and return */ - nr_pixblock_setup_extern (&cpb, NR_PIXBLOCK_MODE_R8G8B8A8P, - /* fixme: This probably cannot overflow, because we render only if visible */ - /* fixme: and pixel cache is there only for small items */ - /* fixme: But this still needs extra check (Lauris) */ - item->drawbox.x0, item->drawbox.y0, - item->drawbox.x1, item->drawbox.y1, - item->px, - 4 * (item->drawbox.x1 - item->drawbox.x0), FALSE, - FALSE); - nr_blit_pixblock_pixblock (pb, &cpb); - nr_pixblock_release (&cpb); - pb->empty = FALSE; - return item->state | NR_ARENA_ITEM_STATE_RENDER; - } -#endif NRPixBlock *dpb = pb; -#if 0 - /* Setup cache if we can */ - if ((!(flags & NR_ARENA_ITEM_RENDER_NO_CACHE)) && - (carea.x0 <= item->drawbox.x0) && (carea.y0 <= item->drawbox.y0) && - (carea.x1 >= item->drawbox.x1) && (carea.y1 >= item->drawbox.y1) && - (((item->drawbox.x1 - item->drawbox.x0) * (item->drawbox.y1 - - item->drawbox.y0)) <= 4096)) { - // Item drawbox is fully in renderable area and size is acceptable - carea.x0 = item->drawbox.x0; - carea.y0 = item->drawbox.y0; - carea.x1 = item->drawbox.x1; - carea.y1 = item->drawbox.y1; - item->px = - new (GC::ATOMIC) unsigned char[4 * (carea.x1 - carea.x0) * - (carea.y1 - carea.y0)]; - nr_pixblock_setup_extern (&cpb, NR_PIXBLOCK_MODE_R8G8B8A8P, carea.x0, - carea.y0, carea.x1, carea.y1, item->px, - 4 * (carea.x1 - carea.x0), TRUE, TRUE); - cpb.visible_area = pb->visible_area; - dpb = &cpb; - // Set nocache flag for downstream rendering - flags |= NR_ARENA_ITEM_RENDER_NO_CACHE; - } -#endif /* Determine, whether we need temporary buffer */ /* if (item->clip || item->mask @@ -596,12 +557,59 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area pb->empty = FALSE; item->state |= NR_ARENA_ITEM_STATE_IMAGE; } +#endif + + using namespace Inkscape; + + // clipping and masks + unsigned int state; + Cairo::Context cct(ct); + Cairo::RefPtr mask; + CairoSave clipsave(ct); + CairoGroup maskgroup(ct); + CairoGroup drawgroup(ct); + + if (item->clip) { + clipsave.save(); + state = nr_arena_item_invoke_clip(ct, item->clip, const_cast(area)); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + item->state |= NR_ARENA_ITEM_STATE_INVALID; + return item->state; + } + + cct.clip(); + } + + if (item->mask) { + maskgroup.push_with_content(CAIRO_CONTENT_ALPHA); + + state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, const_cast(area), pb, flags); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + item->state |= NR_ARENA_ITEM_STATE_INVALID; + return item->state; + } + mask = maskgroup.popmm(); + } + + if (mask) { + drawgroup.push(); + } + state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, const_cast(area), pb, flags); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + /* Clean up and return error */ + item->state |= NR_ARENA_ITEM_STATE_INVALID; + return item->state; + } + if (mask) { + drawgroup.pop_to_source(); + cct.mask(mask); + } return item->state | NR_ARENA_ITEM_STATE_RENDER; } unsigned int -nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) +nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) { nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), @@ -610,12 +618,12 @@ nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) * NR_ARENA_ITEM_STATE_CLIP (and showed a warning on the console); * anyone know why we stopped doing so? */ - nr_return_val_if_fail ((pb->area.x1 - pb->area.x0) >= + /*nr_return_val_if_fail ((pb->area.x1 - pb->area.x0) >= (area->x1 - area->x0), NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail ((pb->area.y1 - pb->area.y0) >= (area->y1 - area->y0), - NR_ARENA_ITEM_STATE_INVALID); + NR_ARENA_ITEM_STATE_INVALID);*/ #ifdef NR_ARENA_ITEM_VERBOSE printf ("Invoke clip by %p: %d %d - %d %d, item bbox %d %d - %d %d\n", @@ -627,7 +635,7 @@ nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) /* Need render that item */ if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) { return ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> - clip (item, area, pb); + clip (ct, item, area); } } diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 2faa7d2d0..035013cd8 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -129,7 +129,7 @@ struct NRArenaItemClass : public NRObjectClass { unsigned int (* update) (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); unsigned int (* render) (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); - unsigned int (* clip) (NRArenaItem *item, NRRectL *area, NRPixBlock *pb); + unsigned int (* clip) (cairo_t *ct, NRArenaItem *item, NRRectL *area); NRArenaItem * (* pick) (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); }; @@ -159,7 +159,7 @@ unsigned int nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC unsigned int nr_arena_item_invoke_render(cairo_t *ct, NRArenaItem *item, NRRectL const *area, NRPixBlock *pb, unsigned int flags); -unsigned int nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb); +unsigned int nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area); NRArenaItem *nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); void nr_arena_item_request_update (NRArenaItem *item, unsigned int reset, unsigned int propagate); diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 9ec8f1100..548a17127 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -55,7 +55,7 @@ static void nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *ch static guint nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); static unsigned int nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static guint nr_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb); +static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area); static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *shape_parent_class; @@ -112,21 +112,15 @@ nr_arena_shape_init(NRArenaShape *shape) shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; shape->ctm.setIdentity(); - shape->fill_painter = NULL; - shape->stroke_painter = NULL; - shape->cached_fill = NULL; - shape->cached_stroke = NULL; - shape->cached_fpartialy = false; - shape->cached_spartialy = false; - shape->fill_shp = NULL; - shape->stroke_shp = NULL; shape->delayed_shp = false; + shape->fill_pattern = NULL; + shape->stroke_pattern = NULL; + shape->path = NULL; + shape->approx_bbox.x0 = shape->approx_bbox.y0 = 0; shape->approx_bbox.x1 = shape->approx_bbox.y1 = 0; - shape->cached_fctm.setIdentity(); - shape->cached_sctm.setIdentity(); shape->markers = NULL; @@ -139,14 +133,9 @@ nr_arena_shape_finalize(NRObject *object) { NRArenaShape *shape = (NRArenaShape *) object; - if (shape->fill_shp) delete shape->fill_shp; - if (shape->stroke_shp) delete shape->stroke_shp; - if (shape->cached_fill) delete shape->cached_fill; - if (shape->cached_stroke) delete shape->cached_stroke; - if (shape->fill_painter) sp_painter_free(shape->fill_painter); - if (shape->stroke_painter) sp_painter_free(shape->stroke_painter); if (shape->fill_pattern) cairo_pattern_destroy(shape->fill_pattern); if (shape->stroke_pattern) cairo_pattern_destroy(shape->stroke_pattern); + if (shape->path) cairo_path_destroy(shape->path); if (shape->style) sp_style_unref(shape->style); if (shape->curve) shape->curve->unref(); @@ -228,10 +217,6 @@ nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArena nr_arena_item_request_render(child); } -void nr_arena_shape_update_stroke(NRArenaShape *shape, NRGC* gc, NRRectL *area); -void nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool force_shape = false); -void nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::OptRect &bbox); - /** * Updates the arena shape 'item' and all of its children, including the markers. */ @@ -244,6 +229,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g unsigned int beststate = NR_ARENA_ITEM_STATE_ALL; + // update markers unsigned int newstate; for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { newstate = nr_arena_item_invoke_update(child, area, gc, state, reset); @@ -280,6 +266,20 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); + // clear Cairo data to force update + if (shape->fill_pattern) { + cairo_pattern_destroy(shape->fill_pattern); + shape->fill_pattern = NULL; + } + if (shape->stroke_pattern) { + cairo_pattern_destroy(shape->stroke_pattern); + shape->stroke_pattern = NULL; + } + if (shape->path) { + cairo_path_destroy(shape->path); + shape->path = NULL; + } + if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); @@ -287,7 +287,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g float width, scale; scale = gc->transform.descrim(); width = MAX(0.125, shape->_stroke.width * scale); - if ( fabs(shape->_stroke.width * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord + if ( fabs(shape->_stroke.width * scale) > 0.01 ) { boundingbox->expandBy(width); } // those pesky miters, now @@ -297,7 +297,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g boundingbox->expandBy(miterMax); } } - } + } /// \todo just write item->bbox = boundingbox if (boundingbox) { @@ -310,25 +310,8 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g } if ( area && nr_rect_l_test_intersect_ptr(area, &shape->approx_bbox) ) shape->delayed_shp=false; - /* Release state data */ - if (shape->fill_shp) { - delete shape->fill_shp; - shape->fill_shp = NULL; - } - if (shape->stroke_shp) { - delete shape->stroke_shp; - shape->stroke_shp = NULL; - } - - // clear Cairo patterns to force update - if (shape->fill_pattern) { - cairo_pattern_destroy(shape->fill_pattern); - shape->fill_pattern = NULL; - } - if (shape->stroke_pattern) { - cairo_pattern_destroy(shape->stroke_pattern); - shape->stroke_pattern = NULL; - } + // TODO: compute a better bounding box that respects miters + item->bbox = shape->approx_bbox; if (!shape->curve || !shape->style || @@ -336,45 +319,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g (( shape->_fill.paint.type() == NRArenaShape::Paint::NONE ) && ( shape->_stroke.paint.type() == NRArenaShape::Paint::NONE && !outline) )) { - item->bbox = shape->approx_bbox; + //item->bbox = shape->approx_bbox; return NR_ARENA_ITEM_STATE_ALL; } - /* Build state data */ - if ( shape->delayed_shp ) { - item->bbox=shape->approx_bbox; - } else { - nr_arena_shape_update_stroke(shape, gc, area); - nr_arena_shape_update_fill(shape, gc, area); - - boundingbox = Geom::OptRect(); - nr_arena_shape_add_bboxes(shape, boundingbox); - - /// \todo just write shape->approx_bbox = boundingbox - if (boundingbox) { - shape->approx_bbox.x0 = static_cast(floor((*boundingbox)[0][0])); - shape->approx_bbox.y0 = static_cast(floor((*boundingbox)[1][0])); - shape->approx_bbox.x1 = static_cast(ceil ((*boundingbox)[0][1])); - shape->approx_bbox.y1 = static_cast(ceil ((*boundingbox)[1][1])); - } else { - shape->approx_bbox = NR_RECT_L_EMPTY; - } - } - - if (!boundingbox) - return NR_ARENA_ITEM_STATE_ALL; - - /// \todo just write item->bbox = boundingbox - item->bbox.x0 = static_cast(floor((*boundingbox)[0][0])); - item->bbox.y0 = static_cast(floor((*boundingbox)[1][0])); - item->bbox.x1 = static_cast(ceil ((*boundingbox)[0][1])); - item->bbox.y1 = static_cast(ceil ((*boundingbox)[1][1])); - - // to render opacity, use Cairo groups - item->render_opacity = FALSE; - - // update patterns when rendering - if (beststate & NR_ARENA_ITEM_STATE_BBOX) { for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { nr_rect_l_union(&item->bbox, &item->bbox, &child->bbox); @@ -384,325 +332,6 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g return NR_ARENA_ITEM_STATE_ALL; } -int matrix_is_isometry(Geom::Matrix p) { - Geom::Matrix tp; - // transposition - tp[0]=p[0]; - tp[1]=p[2]; - tp[2]=p[1]; - tp[3]=p[3]; - for (int i = 4; i < 6; i++) // shut valgrind up :) - tp[i] = p[i] = 0; - Geom::Matrix isom = tp*p; // A^T * A = adjunct? - // Is the adjunct nearly an identity function? - if (isom.isTranslation(0.01)) { - // the transformation is an isometry -> no need to recompute - // the uncrossed polygon - if ( p.det() < 0 ) - return -1; - else - return 1; - } - return 0; -} - -static bool is_inner_area(NRRectL const &outer, NRRectL const &inner) { - return (outer.x0 <= inner.x0 && outer.y0 <= inner.y0 && outer.x1 >= inner.x1 && outer.y1 >= inner.y1); -} - -/* returns true if the pathvector has a region that needs fill. - * is for optimizing purposes, so should be fast and can falsely return true. - * CANNOT falsely return false. */ -static bool has_inner_area(Geom::PathVector const & pv) { - // return false for the cases where there is surely no region to be filled - if (pv.empty()) - return false; - - if ( (pv.size() == 1) && (pv.front().size() <= 1) ) { - // vector has only one path with only one segment, see if that's a non-curve segment: that would mean no internal region - if ( is_straight_curve(pv.front().front()) ) - { - return false; - } - } - - return true; //too costly to see if it has region to be filled, so return true. -} - -/** force_shape is used for clipping paths, when we need the shape for clipping even if it's not filled */ -void -nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool force_shape) -{ - if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE || force_shape) && - has_inner_area(shape->curve->get_pathvector()) ) { - - Geom::Matrix cached_to_new = Geom::identity(); - int isometry = 0; - if ( shape->cached_fill ) { - if (shape->cached_fctm == gc->transform) { - isometry = 2; // identity - } else { - cached_to_new = shape->cached_fctm.inverse() * gc->transform; - isometry = matrix_is_isometry(cached_to_new); - } - if (0 != isometry && !is_inner_area(shape->cached_farea, *area)) - isometry = 0; - } - if ( isometry == 0 ) { - if ( shape->cached_fill == NULL ) shape->cached_fill=new Shape; - shape->cached_fill->Reset(); - - Path* thePath=new Path; - Shape* theShape=new Shape; - { - Geom::Matrix tempMat(gc->transform); - thePath->LoadPathVector(shape->curve->get_pathvector(), tempMat, true); - } - - if (is_inner_area(*area, NR_ARENA_ITEM(shape)->bbox)) { - thePath->Convert(1.0); - shape->cached_fpartialy = false; - } else { - thePath->Convert(area, 1.0); - shape->cached_fpartialy = true; - } - - thePath->Fill(theShape, 0); - - if ( shape->_fill.rule == NRArenaShape::EVEN_ODD ) { - shape->cached_fill->ConvertToShape(theShape, fill_oddEven); - // alternatively, this speeds up rendering of oddeven shapes but disables AA :( - //shape->cached_fill->Copy(theShape); - } else { - shape->cached_fill->ConvertToShape(theShape, fill_nonZero); - } - shape->cached_fctm=gc->transform; - shape->cached_farea = *area; - delete theShape; - delete thePath; - if ( shape->fill_shp == NULL ) - shape->fill_shp = new Shape; - - shape->fill_shp->Copy(shape->cached_fill); - - } else if ( 2 == isometry ) { - if ( shape->fill_shp == NULL ) { - shape->fill_shp = new Shape; - shape->fill_shp->Copy(shape->cached_fill); - } - } else { - - if ( shape->fill_shp == NULL ) - shape->fill_shp = new Shape; - - shape->fill_shp->Reset(shape->cached_fill->numberOfPoints(), - shape->cached_fill->numberOfEdges()); - for (int i = 0; i < shape->cached_fill->numberOfPoints(); i++) - shape->fill_shp->AddPoint(to_2geom(shape->cached_fill->getPoint(i).x) * cached_to_new); - if ( isometry == 1 ) { - for (int i = 0; i < shape->cached_fill->numberOfEdges(); i++) - shape->fill_shp->AddEdge(shape->cached_fill->getEdge(i).st, - shape->cached_fill->getEdge(i).en); - } else if ( isometry == -1 ) { // need to flip poly. - for (int i = 0; i < shape->cached_fill->numberOfEdges(); i++) - shape->fill_shp->AddEdge(shape->cached_fill->getEdge(i).en, - shape->cached_fill->getEdge(i).st); - } - shape->fill_shp->ForceToPolygon(); - shape->fill_shp->needPointsSorting(); - shape->fill_shp->needEdgesSorting(); - } - shape->delayed_shp |= shape->cached_fpartialy; - } -} - -void -nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) -{ - SPStyle* style = shape->style; - - float const scale = gc->transform.descrim(); - - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - if (outline) { - // cairo does not need the livarot path for rendering - return; - } - - // after switching normal stroke rendering to cairo too, optimize this: lower tolerance, disregard dashes - // (since it will only be used for picking, not for rendering) - - if (outline || - ((shape->_stroke.paint.type() != NRArenaShape::Paint::NONE) && - ( fabs(shape->_stroke.width * scale) > 0.01 ))) { // sinon c'est 0=oon veut pas de bord - - float style_width = MAX(0.125, shape->_stroke.width * scale); - float width; - if (outline) { - width = 0.5; // 1 pixel wide, independent of zoom - } else { - width = style_width; - } - - Geom::Matrix cached_to_new = Geom::identity(); - - int isometry = 0; - if ( shape->cached_stroke ) { - if (shape->cached_sctm == gc->transform) { - isometry = 2; // identity - } else { - cached_to_new = shape->cached_sctm.inverse() * gc->transform; - isometry = matrix_is_isometry(cached_to_new); - } - if (0 != isometry && !is_inner_area(shape->cached_sarea, *area)) - isometry = 0; - if (0 != isometry && width != shape->cached_width) { - // if this happens without setting style, we have just switched to outline or back - isometry = 0; - } - } - - if ( isometry == 0 ) { - if ( shape->cached_stroke == NULL ) shape->cached_stroke=new Shape; - shape->cached_stroke->Reset(); - Path* thePath = new Path; - Shape* theShape = new Shape; - { - Geom::Matrix tempMat( gc->transform ); - thePath->LoadPathVector(shape->curve->get_pathvector(), tempMat, true); - } - - // add some padding to the rendering area, so clipped path does not go into a render area - NRRectL padded_area = *area; - padded_area.x0 -= (NR::ICoord)width; - padded_area.x1 += (NR::ICoord)width; - padded_area.y0 -= (NR::ICoord)width; - padded_area.y1 += (NR::ICoord)width; - if ((style->stroke_dash.n_dash && !outline) || is_inner_area(padded_area, NR_ARENA_ITEM(shape)->bbox)) { - thePath->Convert((outline) ? 4.0 : 1.0); - shape->cached_spartialy = false; - } - else { - thePath->Convert(&padded_area, (outline) ? 4.0 : 1.0); - shape->cached_spartialy = true; - } - - if (style->stroke_dash.n_dash && !outline) { - thePath->DashPolylineFromStyle(style, scale, 1.0); - } - - ButtType butt=butt_straight; - switch (shape->_stroke.cap) { - case NRArenaShape::BUTT_CAP: - butt = butt_straight; - break; - case NRArenaShape::ROUND_CAP: - butt = butt_round; - break; - case NRArenaShape::SQUARE_CAP: - butt = butt_square; - break; - } - JoinType join=join_straight; - switch (shape->_stroke.join) { - case NRArenaShape::MITRE_JOIN: - join = join_pointy; - break; - case NRArenaShape::ROUND_JOIN: - join = join_round; - break; - case NRArenaShape::BEVEL_JOIN: - join = join_straight; - break; - } - - if (outline) { - butt = butt_straight; - join = join_straight; - } - - thePath->Stroke(theShape, false, 0.5*width, join, butt, - 0.5*width*shape->_stroke.mitre_limit); - - - if (outline) { - // speeds it up, but uses evenodd for the stroke shape (which does not matter for 1-pixel wide outline) - shape->cached_stroke->Copy(theShape); - } else { - shape->cached_stroke->ConvertToShape(theShape, fill_nonZero); - } - - shape->cached_width = width; - - shape->cached_sctm=gc->transform; - shape->cached_sarea = *area; - delete thePath; - delete theShape; - if ( shape->stroke_shp == NULL ) shape->stroke_shp=new Shape; - - shape->stroke_shp->Copy(shape->cached_stroke); - - } else if ( 2 == isometry ) { - if ( shape->stroke_shp == NULL ) { - shape->stroke_shp=new Shape; - shape->stroke_shp->Copy(shape->cached_stroke); - } - } else { - if ( shape->stroke_shp == NULL ) - shape->stroke_shp=new Shape; - shape->stroke_shp->Reset(shape->cached_stroke->numberOfPoints(), shape->cached_stroke->numberOfEdges()); - for (int i = 0; i < shape->cached_stroke->numberOfPoints(); i++) - shape->stroke_shp->AddPoint(to_2geom(shape->cached_stroke->getPoint(i).x) * cached_to_new); - if ( isometry == 1 ) { - for (int i = 0; i < shape->cached_stroke->numberOfEdges(); i++) - shape->stroke_shp->AddEdge(shape->cached_stroke->getEdge(i).st, - shape->cached_stroke->getEdge(i).en); - } else if ( isometry == -1 ) { - for (int i = 0; i < shape->cached_stroke->numberOfEdges(); i++) - shape->stroke_shp->AddEdge(shape->cached_stroke->getEdge(i).en, - shape->cached_stroke->getEdge(i).st); - } - shape->stroke_shp->ForceToPolygon(); - shape->stroke_shp->needPointsSorting(); - shape->stroke_shp->needEdgesSorting(); - } - shape->delayed_shp |= shape->cached_spartialy; - } -} - - -void -nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::OptRect &bbox) -{ - /* TODO: are these two if's mutually exclusive? ( i.e. "shape->stroke_shp <=> !shape->fill_shp" ) - * if so, then this can be written much more compact ! */ - - if ( shape->stroke_shp ) { - Shape *larger = shape->stroke_shp; - larger->CalcBBox(); - larger->leftX = floor(larger->leftX); - larger->rightX = ceil(larger->rightX); - larger->topY = floor(larger->topY); - larger->bottomY = ceil(larger->bottomY); - Geom::Rect stroke_bbox( Geom::Interval(larger->leftX, larger->rightX), - Geom::Interval(larger->topY, larger->bottomY) ); - bbox.unionWith(stroke_bbox); - } - - if ( shape->fill_shp ) { - Shape *larger = shape->fill_shp; - larger->CalcBBox(); - larger->leftX = floor(larger->leftX); - larger->rightX = ceil(larger->rightX); - larger->topY = floor(larger->topY); - larger->bottomY = ceil(larger->bottomY); - Geom::Rect fill_bbox( Geom::Interval(larger->leftX, larger->rightX), - Geom::Interval(larger->topY, larger->bottomY) ); - bbox.unionWith(fill_bbox); - } -} - // cairo outline rendering: static unsigned int cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect area) @@ -740,6 +369,11 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (!shape->style) return item->state; if (!ct) return item->state; + // skip if not within bounding box + if (!nr_rect_l_test_intersect_ptr(area, &item->bbox)) { + return item->state; + } + bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); //bool print_colors_preview = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); @@ -750,246 +384,89 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; } else { - - if ( shape->delayed_shp ) { - if ( nr_rect_l_test_intersect_ptr(area, &item->bbox) ) { - NRGC tempGC(NULL); - tempGC.transform=shape->ctm; - shape->delayed_shp = false; - nr_arena_shape_update_stroke(shape,&tempGC,&pb->visible_area); - nr_arena_shape_update_fill(shape,&tempGC,&pb->visible_area); -/* NRRect bbox; - bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0; - nr_arena_shape_add_bboxes(shape,bbox); - item->bbox.x0 = (gint32)(bbox.x0 - 1.0F); - item->bbox.y0 = (gint32)(bbox.y0 - 1.0F); - item->bbox.x1 = (gint32)(bbox.x1 + 1.0F); - item->bbox.y1 = (gint32)(bbox.y1 + 1.0F); - shape->approx_bbox=item->bbox;*/ - } else { - return item->state; - } - } - - SPStyle const *style = shape->style; - - // set up context and feed path - float opacity = SP_SCALE24_TO_FLOAT(shape->style->opacity.value); - bool needs_opacity = ((1.0 - opacity) >= 1e-3); - - cairo_save(ct); - //cairo_new_path(ct); // we assume the context is clean - cairo_translate(ct, -area->x0, -area->y0); - ink_cairo_transform(ct, shape->ctm); - - // update fill and stroke paints. - // this cannot be done during nr_arena_shape_update, because we need a Cairo context - // to use groups for svg:pattern - if (!shape->fill_pattern) { - switch (shape->_fill.paint.type()) { - case NRArenaShape::Paint::SERVER: { - SPPaintServer *ps = shape->_fill.paint.server(); - shape->fill_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_fill.opacity); - } break; - case NRArenaShape::Paint::COLOR: { - SPColor const &c = shape->_fill.paint.color(); - shape->fill_pattern = cairo_pattern_create_rgba( - c.v.c[0], c.v.c[1], c.v.c[2], shape->_fill.opacity); - } break; - default: break; - } - } - - if (!shape->stroke_pattern) { - switch (shape->_stroke.paint.type()) { - case NRArenaShape::Paint::SERVER: { - SPPaintServer *ps = shape->_stroke.paint.server(); - shape->stroke_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_stroke.opacity); - } break; - case NRArenaShape::Paint::COLOR: { - SPColor const &c = shape->_stroke.paint.color(); - shape->stroke_pattern = cairo_pattern_create_rgba( - c.v.c[0], c.v.c[1], c.v.c[2], shape->_stroke.opacity); - } break; - default: break; - } - } - - if (shape->fill_pattern || shape->stroke_pattern) { - - if (needs_opacity) { - cairo_push_group(ct); - } - - // TODO: remove segments outside of bbox when no dashes present - feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); - - if (shape->fill_pattern) { - switch (shape->_fill.rule) { - case NRArenaShape::EVEN_ODD: - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); - break; - default: - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); - break; + SPStyle const *style = shape->style; + + // set up context and feed path + float opacity = SP_SCALE24_TO_FLOAT(shape->style->opacity.value); + bool needs_opacity = ((1.0 - opacity) >= 1e-3); + + // we assume the context has no path + cairo_save(ct); + cairo_translate(ct, -area->x0, -area->y0); + ink_cairo_transform(ct, shape->ctm); + + // update fill and stroke paints. + // this cannot be done during nr_arena_shape_update, because we need a Cairo context + // to render svg:pattern + if (!shape->fill_pattern) { + switch (shape->_fill.paint.type()) { + case NRArenaShape::Paint::SERVER: { + SPPaintServer *ps = shape->_fill.paint.server(); + shape->fill_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_fill.opacity); + } break; + case NRArenaShape::Paint::COLOR: { + SPColor const &c = shape->_fill.paint.color(); + shape->fill_pattern = cairo_pattern_create_rgba( + c.v.c[0], c.v.c[1], c.v.c[2], shape->_fill.opacity); + } break; + default: break; } - cairo_set_source(ct, shape->fill_pattern); - cairo_fill_preserve(ct); } - if (shape->stroke_pattern) { - // float style_width = shape->_stroke.width * scale; - cairo_set_line_width(ct, shape->_stroke.width); - - // stroke caps - switch (shape->_stroke.cap) { - case NRArenaShape::BUTT_CAP: - cairo_set_line_cap(ct, CAIRO_LINE_CAP_BUTT); - break; - case NRArenaShape::ROUND_CAP: - cairo_set_line_cap(ct, CAIRO_LINE_CAP_ROUND); - break; - case NRArenaShape::SQUARE_CAP: - cairo_set_line_cap(ct, CAIRO_LINE_CAP_SQUARE); - break; - } - // stroke join - switch (shape->_stroke.join) { - case NRArenaShape::MITRE_JOIN: - cairo_set_line_join(ct, CAIRO_LINE_JOIN_MITER); - break; - case NRArenaShape::ROUND_JOIN: - cairo_set_line_join(ct, CAIRO_LINE_JOIN_ROUND); - break; - case NRArenaShape::BEVEL_JOIN: - cairo_set_line_join(ct, CAIRO_LINE_JOIN_BEVEL); - break; - } - - // miter limit - cairo_set_miter_limit (ct, style->stroke_miterlimit.value); - - // dashes - if (style->stroke_dash.n_dash) { - cairo_set_dash (ct, style->stroke_dash.dash, style->stroke_dash.n_dash, - style->stroke_dash.offset); + if (!shape->stroke_pattern) { + switch (shape->_stroke.paint.type()) { + case NRArenaShape::Paint::SERVER: { + SPPaintServer *ps = shape->_stroke.paint.server(); + shape->stroke_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_stroke.opacity); + } break; + case NRArenaShape::Paint::COLOR: { + SPColor const &c = shape->_stroke.paint.color(); + shape->stroke_pattern = cairo_pattern_create_rgba( + c.v.c[0], c.v.c[1], c.v.c[2], shape->_stroke.opacity); + } break; + default: break; } - cairo_set_source(ct, shape->stroke_pattern); - cairo_stroke_preserve(ct); } - cairo_new_path(ct); // clear path - if (needs_opacity) { - cairo_pop_group_to_source(ct); - cairo_paint_with_alpha(ct, opacity); - } - } // has fill or stroke pattern - - cairo_restore(ct); + if (shape->fill_pattern || shape->stroke_pattern) { -/* - if (shape->fill_shp) { - NRPixBlock m; - guint32 rgba; - - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); - - // if memory allocation failed, abort render - if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) { - nr_pixblock_release (&m); - return (item->state); - } - - m.visible_area = pb->visible_area; - nr_pixblock_render_shape_mask_or(m,shape->fill_shp); - m.empty = FALSE; - - if (shape->_fill.paint.type() == NRArenaShape::Paint::NONE) { - // do not render fill in any way - } else if (shape->_fill.paint.type() == NRArenaShape::Paint::COLOR) { - - const SPColor* fill_color = &shape->_fill.paint.color(); - if ( item->render_opacity ) { - rgba = fill_color->toRGBA32( shape->_fill.opacity * - SP_SCALE24_TO_FLOAT(style->opacity.value) ); - } else { - rgba = fill_color->toRGBA32( shape->_fill.opacity ); + if (needs_opacity) { + cairo_push_group(ct); } - if (print_colors_preview) - nr_arena_separate_color_plates(&rgba); + // TODO: remove segments outside of bbox when no dashes present + feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); - nr_blit_pixblock_mask_rgba32(pb, &m, rgba); - pb->empty = FALSE; - } else if (shape->_fill.paint.type() == NRArenaShape::Paint::SERVER) { - if (shape->fill_painter) { - nr_arena_render_paintserver_fill(pb, area, shape->fill_painter, shape->_fill.opacity, &m); + if (shape->fill_pattern) { + cairo_set_fill_rule(ct, shape->_fill.rule); + cairo_set_source(ct, shape->fill_pattern); + cairo_fill_preserve(ct); } - } - - nr_pixblock_release(&m); - } - - if (shape->_stroke.paint.type() == NRArenaShape::Paint::COLOR) { - - - - - guint32 rgba; - NRPixBlock m; - - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); - - // if memory allocation failed, abort render - if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) { - nr_pixblock_release (&m); - return (item->state); - } - - m.visible_area = pb->visible_area; - nr_pixblock_render_shape_mask_or(m, shape->stroke_shp); - m.empty = FALSE; - const SPColor* stroke_color = &shape->_stroke.paint.color(); - if ( item->render_opacity ) { - rgba = stroke_color->toRGBA32( shape->_stroke.opacity * - SP_SCALE24_TO_FLOAT(style->opacity.value) ); - } else { - rgba = stroke_color->toRGBA32( shape->_stroke.opacity ); - } - - if (print_colors_preview) - nr_arena_separate_color_plates(&rgba); - - nr_blit_pixblock_mask_rgba32(pb, &m, rgba); - pb->empty = FALSE; - - nr_pixblock_release(&m); - - - } else if (shape->stroke_shp && shape->_stroke.paint.type() == NRArenaShape::Paint::SERVER) { + if (shape->stroke_pattern) { + cairo_set_line_width(ct, shape->_stroke.width); + cairo_set_line_cap(ct, shape->_stroke.cap); + cairo_set_line_join(ct, shape->_stroke.join); + cairo_set_miter_limit (ct, style->stroke_miterlimit.value); - NRPixBlock m; - - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); - - // if memory allocation failed, abort render - if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) { - nr_pixblock_release (&m); - return (item->state); - } + // dashes + if (style->stroke_dash.n_dash) { + cairo_set_dash (ct, style->stroke_dash.dash, style->stroke_dash.n_dash, + style->stroke_dash.offset); + } + cairo_set_source(ct, shape->stroke_pattern); + cairo_stroke_preserve(ct); + } + cairo_new_path(ct); // clear path - m.visible_area = pb->visible_area; - nr_pixblock_render_shape_mask_or(m, shape->stroke_shp); - m.empty = FALSE; + if (needs_opacity) { + cairo_pop_group_to_source(ct); + cairo_paint_with_alpha(ct, opacity); + } + } // has fill or stroke pattern - if (shape->stroke_painter) { - nr_arena_render_paintserver_fill(pb, area, shape->stroke_painter, shape->_stroke.opacity, &m); - } + cairo_restore(ct); - nr_pixblock_release(&m); - } -*/ } // non-cairo non-outline branch /* Render markers into parent buffer */ @@ -1002,88 +479,19 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } -// cairo clipping: this basically works except for the stride-must-be-divisible-by-4 cairo bug; -// reenable this when the bug is fixed and remove the rest of this function -// TODO -#if defined(DEADCODE) && !defined(DEADCODE) -static guint -cairo_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) -{ - NRArenaShape *shape = NR_ARENA_SHAPE(item); - if (!shape->curve) return item->state; - - cairo_t *ct = nr_create_cairo_context (area, pb); - - if (!ct) - return item->state; - - cairo_set_source_rgba(ct, 0, 0, 0, 1); - - cairo_new_path(ct); - - feed_pathvector_to_cairo (ct, shape->curve->get_pathvector(), shape->ctm, (area)->upgrade(), false, 0); - - cairo_fill(ct); - - cairo_surface_t *cst = cairo_get_target(ct); - cairo_destroy (ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); - - pb->empty = FALSE; - - return item->state; -} -#endif //defined(DEADCODE) && !defined(DEADCODE) - - static guint -nr_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) +nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area) { - //return cairo_arena_shape_clip(item, area, pb); - + // NOTE: for now this is incorrect, because it doesn't honor clip-rule, + // and will be incorrect for nested clipping paths. NRArenaShape *shape = NR_ARENA_SHAPE(item); if (!shape->curve) return item->state; - if ( shape->delayed_shp || shape->fill_shp == NULL) { // we need a fill shape no matter what - if ( nr_rect_l_test_intersect_ptr(area, &item->bbox) ) { - NRGC tempGC(NULL); - tempGC.transform=shape->ctm; - shape->delayed_shp = false; - nr_arena_shape_update_fill(shape, &tempGC, &pb->visible_area, true); - } else { - return item->state; - } - } - - if ( shape->fill_shp ) { - NRPixBlock m; - - /* fixme: We can OR in one step (Lauris) */ - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); - - // if memory allocation failed, abort - if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) { - nr_pixblock_release (&m); - return (item->state); - } - - m.visible_area = pb->visible_area; - nr_pixblock_render_shape_mask_or(m,shape->fill_shp); - - for (int y = area->y0; y < area->y1; y++) { - unsigned char *s, *d; - s = NR_PIXBLOCK_PX(&m) + (y - area->y0) * m.rs; - d = NR_PIXBLOCK_PX(pb) + (y - area->y0) * pb->rs; - for (int x = area->x0; x < area->x1; x++) { - *d = NR_COMPOSEA_111(*s, *d); - d ++; - s ++; - } - } - nr_pixblock_release(&m); - pb->empty = FALSE; - } + cairo_save(ct); + cairo_translate(ct, -area->x0, -area->y0); + ink_cairo_transform(ct, shape->ctm); + feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); + cairo_restore(ct); return item->state; } @@ -1191,18 +599,6 @@ void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve,bool justTrans) g_return_if_fail(shape != NULL); g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); - if ( justTrans == false ) { - // dirty cached versions - if ( shape->cached_fill ) { - delete shape->cached_fill; - shape->cached_fill=NULL; - } - if ( shape->cached_stroke ) { - delete shape->cached_stroke; - shape->cached_stroke=NULL; - } - } - nr_arena_item_request_render(NR_ARENA_ITEM(shape)); if (shape->curve) { @@ -1233,7 +629,7 @@ void NRArenaShape::setFillOpacity(double opacity) { _invalidateCachedFill(); } -void NRArenaShape::setFillRule(NRArenaShape::FillRule rule) { +void NRArenaShape::setFillRule(cairo_fill_rule_t rule) { _fill.rule = rule; _invalidateCachedFill(); } @@ -1263,12 +659,12 @@ void NRArenaShape::setMitreLimit(double limit) { _invalidateCachedStroke(); } -void NRArenaShape::setLineCap(NRArenaShape::CapType cap) { +void NRArenaShape::setLineCap(cairo_line_cap_t cap) { _stroke.cap = cap; _invalidateCachedStroke(); } -void NRArenaShape::setLineJoin(NRArenaShape::JoinType join) { +void NRArenaShape::setLineJoin(cairo_line_join_t join) { _stroke.join = join; _invalidateCachedStroke(); } @@ -1299,11 +695,11 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) shape->setFillOpacity(SP_SCALE24_TO_FLOAT(style->fill_opacity.value)); switch (style->fill_rule.computed) { case SP_WIND_RULE_EVENODD: { - shape->setFillRule(NRArenaShape::EVEN_ODD); + shape->setFillRule(CAIRO_FILL_RULE_EVEN_ODD); break; } case SP_WIND_RULE_NONZERO: { - shape->setFillRule(NRArenaShape::NONZERO); + shape->setFillRule(CAIRO_FILL_RULE_WINDING); break; } default: { @@ -1324,15 +720,15 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) shape->setStrokeOpacity(SP_SCALE24_TO_FLOAT(style->stroke_opacity.value)); switch (style->stroke_linecap.computed) { case SP_STROKE_LINECAP_ROUND: { - shape->setLineCap(NRArenaShape::ROUND_CAP); + shape->setLineCap(CAIRO_LINE_CAP_ROUND); break; } case SP_STROKE_LINECAP_SQUARE: { - shape->setLineCap(NRArenaShape::SQUARE_CAP); + shape->setLineCap(CAIRO_LINE_CAP_SQUARE); break; } case SP_STROKE_LINECAP_BUTT: { - shape->setLineCap(NRArenaShape::BUTT_CAP); + shape->setLineCap(CAIRO_LINE_CAP_BUTT); break; } default: { @@ -1341,15 +737,15 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) } switch (style->stroke_linejoin.computed) { case SP_STROKE_LINEJOIN_ROUND: { - shape->setLineJoin(NRArenaShape::ROUND_JOIN); + shape->setLineJoin(CAIRO_LINE_JOIN_ROUND); break; } case SP_STROKE_LINEJOIN_BEVEL: { - shape->setLineJoin(NRArenaShape::BEVEL_JOIN); + shape->setLineJoin(CAIRO_LINE_JOIN_BEVEL); break; } case SP_STROKE_LINEJOIN_MITER: { - shape->setLineJoin(NRArenaShape::MITRE_JOIN); + shape->setLineJoin(CAIRO_LINE_JOIN_MITER); break; } default: { diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index a88129286..97001c82d 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -17,6 +17,7 @@ #define NR_ARENA_SHAPE(obj) (NR_CHECK_INSTANCE_CAST ((obj), NR_TYPE_ARENA_SHAPE, NRArenaShape)) #define NR_IS_ARENA_SHAPE(obj) (NR_CHECK_INSTANCE_TYPE ((obj), NR_TYPE_ARENA_SHAPE)) +#include #include "display/display-forward.h" #include "display/canvas-bpath.h" #include "forward.h" @@ -91,23 +92,6 @@ struct NRArenaShape : public NRArenaItem { } }; - enum FillRule { - EVEN_ODD, - NONZERO - }; - - enum CapType { - ROUND_CAP, - SQUARE_CAP, - BUTT_CAP - }; - - enum JoinType { - ROUND_JOIN, - BEVEL_JOIN, - MITRE_JOIN - }; - /* Shape data */ SPCurve *curve; SPStyle *style; @@ -117,37 +101,15 @@ struct NRArenaShape : public NRArenaItem { cairo_pattern_t *fill_pattern; cairo_pattern_t *stroke_pattern; + cairo_path_t *path; - SPPainter *fill_painter; - SPPainter *stroke_painter; - // the 2 cached polygons, for rasterizations uses - Shape *fill_shp; - Shape *stroke_shp; - // the stroke width of stroke_shp, to detect when it changes (on normal/outline switching) and rebuild - float cached_width; // delayed_shp=true means the *_shp polygons are not computed yet // they'll be computed on demand in *_render(), *_pick() or *_clip() // the goal is to not uncross polygons that are outside the viewing region bool delayed_shp; // approximate bounding box, for the case when the polygons have been delayed NRRectL approx_bbox; - // cache for transformations: cached_fill and cached_stroke are - // polygons computed for the cached_fctm and cache_sctm respectively - // when the transformation changes interactively (tracked by the - // SP_OBJECT_USER_MODIFIED_FLAG_B), we check if it's an isometry wrt - // the cached ctm. if it's an isometry, just apply it to the cached - // polygon to get the *_shp polygon. Otherwise, recompute so this - // works fine for translation and rotation, but not scaling and - // skewing - Geom::Matrix cached_fctm; - Geom::Matrix cached_sctm; - NRRectL cached_farea; - NRRectL cached_sarea; - bool cached_fpartialy; - bool cached_spartialy; - - Shape *cached_fill; - Shape *cached_stroke; + /* Markers */ NRArenaItem *markers; @@ -164,29 +126,21 @@ struct NRArenaShape : public NRArenaItem { void setFill(SPPaintServer *server); void setFill(SPColor const &color); void setFillOpacity(double opacity); - void setFillRule(FillRule rule); + void setFillRule(cairo_fill_rule_t rule); void setStroke(SPPaintServer *server); void setStroke(SPColor const &color); void setStrokeOpacity(double opacity); void setStrokeWidth(double width); - void setLineCap(CapType cap); - void setLineJoin(JoinType join); + void setLineCap(cairo_line_cap_t cap); + void setLineJoin(cairo_line_join_t join); void setMitreLimit(double limit); void setPaintBox(Geom::Rect const &pbox); void _invalidateCachedFill() { - if (cached_fill) { - delete cached_fill; - cached_fill = NULL; - } } void _invalidateCachedStroke() { - if (cached_stroke) { - delete cached_stroke; - cached_stroke = NULL; - } } struct Style { @@ -195,17 +149,17 @@ struct NRArenaShape : public NRArenaItem { double opacity; }; struct FillStyle : public Style { - FillStyle() : rule(EVEN_ODD) {} - FillRule rule; + FillStyle() : rule(CAIRO_FILL_RULE_EVEN_ODD) {} + cairo_fill_rule_t rule; } _fill; struct StrokeStyle : public Style { StrokeStyle() - : cap(ROUND_CAP), join(ROUND_JOIN), + : cap(CAIRO_LINE_CAP_ROUND), join(CAIRO_LINE_JOIN_ROUND), width(0.0), mitre_limit(0.0) {} - CapType cap; - JoinType join; + cairo_line_cap_t cap; + cairo_line_join_t join; double width; double mitre_limit; } _stroke; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 29a5cd740..31e80d1f9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1650,19 +1650,20 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, buf.visible_rect.x1 = draw_x2; buf.visible_rect.y1 = draw_y2; buf.is_empty = true; - //buf.bg_color = &widget->style->bg[GTK_STATE_NORMAL]; - //buf.ct = nr_create_cairo_context_canvasbuf (&(buf.visible_rect), &buf); - buf.ct = gdk_cairo_create(widget->window); + //buf.ct = gdk_cairo_create(widget->window); + + // create temporary surface + cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0); + buf.ct = cairo_create(imgs); + //cairo_translate(buf.ct, -x0, -y0); // fix coordinates, clip all drawing to the tile and clear the background - // TODO: the translation is done to remain compatible with legacy code. - // Fix the code so it doesn't refer to buf.rect and remove the translation. - cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); // ? - cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); + //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); //cairo_set_line_width(buf.ct, 3); //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); //cairo_stroke_preserve(buf.ct); - cairo_clip(buf.ct); + //cairo_clip(buf.ct); gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]); cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); @@ -1762,8 +1763,21 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } #endif + // output to X + cairo_destroy(buf.ct); + + cairo_t *xct = gdk_cairo_create(widget->window); + cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0); + cairo_rectangle(xct, 0, 0, x1-x0, y1-y0); + cairo_clip(xct); + cairo_set_source_surface(xct, imgs, 0, 0); + cairo_set_operator(xct, CAIRO_OPERATOR_SOURCE); + cairo_paint(xct); + cairo_destroy(xct); + cairo_surface_destroy(imgs); + //cairo_surface_t *cst = cairo_get_target(buf.ct); - cairo_destroy (buf.ct); + //cairo_destroy (buf.ct); //cairo_surface_finish (cst); //cairo_surface_destroy (cst); @@ -1831,21 +1845,21 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) if (bw * bh < setup->max_pixels) { // We are small enough - GdkRectangle r; + /*GdkRectangle r; r.x = this_rect.x0 - setup->canvas->x0; r.y = this_rect.y0 - setup->canvas->y0; r.width = this_rect.x1 - this_rect.x0; r.height = this_rect.y1 - this_rect.y0; GdkWindow *window = GTK_WIDGET(setup->canvas)->window; - gdk_window_begin_paint_rect(window, &r); + gdk_window_begin_paint_rect(window, &r);*/ sp_canvas_paint_single_buffer (setup->canvas, this_rect.x0, this_rect.y0, this_rect.x1, this_rect.y1, setup->big_rect.x0, setup->big_rect.y0, setup->big_rect.x1, setup->big_rect.y1, bw); - gdk_window_end_paint(window); + //gdk_window_end_paint(window); return 1; } -- cgit v1.2.3 From cf6ce8045cd7a019c263d557fd2ea6c3b8a0e669 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 28 Jun 2010 02:37:10 +0200 Subject: Text rendering. Factor out style handling into nr-style.h (bzr r9508.1.5) --- src/display/Makefile_insert | 110 +++++++------ src/display/nr-arena-glyphs.cpp | 357 ++++++++-------------------------------- src/display/nr-arena-glyphs.h | 28 +--- src/display/nr-arena-item.cpp | 4 +- src/display/nr-arena-shape.cpp | 237 +++----------------------- src/display/nr-arena-shape.h | 110 +------------ src/display/nr-style.cpp | 218 ++++++++++++++++++++++++ src/display/nr-style.h | 82 +++++++++ 8 files changed, 466 insertions(+), 680 deletions(-) create mode 100644 src/display/nr-style.cpp create mode 100644 src/display/nr-style.h (limited to 'src') diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 7660d2c70..c6cdcbb6d 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -4,37 +4,22 @@ display/canvas-arena.$(OBJEXT): helper/sp-marshal.h display/sp-canvas.$(OBJEXT): helper/sp-marshal.h ink_common_sources += \ - display/nr-3dutils.h \ - display/nr-3dutils.cpp \ - display/nr-arena-forward.h \ - display/nr-arena.cpp \ - display/nr-arena.h \ - display/nr-arena-item.cpp \ - display/nr-arena-item.h \ - display/nr-arena-group.cpp \ - display/nr-arena-group.h \ - display/nr-arena-image.cpp \ - display/nr-arena-image.h \ - display/nr-arena-shape.cpp \ - display/nr-arena-shape.h \ - display/nr-arena-glyphs.cpp \ - display/nr-arena-glyphs.h \ + display/cairo-utils.cpp \ + display/cairo-utils.h \ display/canvas-arena.cpp \ display/canvas-arena.h \ + display/canvas-axonomgrid.cpp \ + display/canvas-axonomgrid.h \ display/canvas-bpath.cpp \ display/canvas-bpath.h \ display/canvas-grid.cpp \ display/canvas-grid.h \ - display/canvas-axonomgrid.cpp \ - display/canvas-axonomgrid.h \ display/canvas-temporary-item.cpp \ display/canvas-temporary-item.h \ display/canvas-temporary-item-list.cpp \ display/canvas-temporary-item-list.h \ - display/canvas-text.h \ display/canvas-text.cpp \ - display/cairo-utils.h \ - display/cairo-utils.cpp \ + display/canvas-text.h \ display/curve.cpp \ display/curve.h \ display/display-forward.h \ @@ -42,41 +27,34 @@ ink_common_sources += \ display/gnome-canvas-acetate.h \ display/guideline.cpp \ display/guideline.h \ - display/nr-plain-stuff-gdk.cpp \ - display/nr-plain-stuff-gdk.h \ - display/nr-plain-stuff.cpp \ - display/nr-plain-stuff.h \ - display/nr-svgfonts.cpp \ - display/nr-svgfonts.h \ - display/rendermode.h \ - display/snap-indicator.cpp \ - display/snap-indicator.h \ - display/sodipodi-ctrl.cpp \ - display/sodipodi-ctrl.h \ - display/sodipodi-ctrlrect.cpp \ - display/sodipodi-ctrlrect.h \ - display/sp-canvas-util.cpp \ - display/sp-canvas-util.h \ - display/sp-canvas.cpp \ - display/sp-canvas.h \ - display/sp-ctrlline.cpp \ - display/sp-ctrlline.h \ - display/sp-ctrlpoint.cpp \ - display/sp-ctrlpoint.h \ - display/sp-ctrlquadr.cpp \ - display/sp-ctrlquadr.h \ - display/nr-filter.cpp \ - display/nr-filter.h \ + display/inkscape-cairo.cpp \ + display/inkscape-cairo.h \ + display/nr-3dutils.cpp \ + display/nr-3dutils.h \ + display/nr-arena.cpp \ + display/nr-arena-forward.h \ + display/nr-arena-glyphs.cpp \ + display/nr-arena-glyphs.h \ + display/nr-arena-group.cpp \ + display/nr-arena-group.h \ + display/nr-arena.h \ + display/nr-arena-image.cpp \ + display/nr-arena-image.h \ + display/nr-arena-item.cpp \ + display/nr-arena-item.h \ + display/nr-arena-shape.cpp \ + display/nr-arena-shape.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ display/nr-filter-colormatrix.cpp \ display/nr-filter-colormatrix.h \ display/nr-filter-component-transfer.cpp \ display/nr-filter-component-transfer.h \ - display/nr-filter-composite.h \ display/nr-filter-composite.cpp \ + display/nr-filter-composite.h \ display/nr-filter-convolve-matrix.cpp \ display/nr-filter-convolve-matrix.h \ + display/nr-filter.cpp \ display/nr-filter-diffuselighting.cpp \ display/nr-filter-diffuselighting.h \ display/nr-filter-displacement-map.cpp \ @@ -87,6 +65,7 @@ ink_common_sources += \ display/nr-filter-gaussian.h \ display/nr-filter-getalpha.cpp \ display/nr-filter-getalpha.h \ + display/nr-filter.h \ display/nr-filter-image.cpp \ display/nr-filter-image.h \ display/nr-filter-merge.cpp \ @@ -95,6 +74,7 @@ ink_common_sources += \ display/nr-filter-morphology.h \ display/nr-filter-offset.cpp \ display/nr-filter-offset.h \ + display/nr-filter-pixops.h \ display/nr-filter-primitive.cpp \ display/nr-filter-primitive.h \ display/nr-filter-slot.cpp \ @@ -105,21 +85,43 @@ ink_common_sources += \ display/nr-filter-tile.h \ display/nr-filter-turbulence.cpp \ display/nr-filter-turbulence.h \ - display/nr-filter-pixops.h \ display/nr-filter-types.h \ - display/nr-filter-units.h \ display/nr-filter-units.cpp \ - display/nr-filter-utils.h \ + display/nr-filter-units.h \ display/nr-filter-utils.cpp \ + display/nr-filter-utils.h \ + display/nr-light.cpp \ + display/nr-light.h \ + display/nr-light-types.h \ + display/nr-plain-stuff.cpp \ + display/nr-plain-stuff-gdk.cpp \ + display/nr-plain-stuff-gdk.h \ + display/nr-plain-stuff.h \ + display/nr-style.cpp \ + display/nr-style.h \ + display/nr-svgfonts.cpp \ + display/nr-svgfonts.h \ display/pixblock-scaler.cpp \ display/pixblock-scaler.h \ display/pixblock-transform.cpp \ display/pixblock-transform.h \ - display/inkscape-cairo.cpp \ - display/inkscape-cairo.h \ - display/nr-light.h \ - display/nr-light.cpp \ - display/nr-light-types.h + display/rendermode.h \ + display/snap-indicator.cpp \ + display/snap-indicator.h \ + display/sodipodi-ctrl.cpp \ + display/sodipodi-ctrl.h \ + display/sodipodi-ctrlrect.cpp \ + display/sodipodi-ctrlrect.h \ + display/sp-canvas.cpp \ + display/sp-canvas.h \ + display/sp-canvas-util.cpp \ + display/sp-canvas-util.h \ + display/sp-ctrlline.cpp \ + display/sp-ctrlline.h \ + display/sp-ctrlpoint.cpp \ + display/sp-ctrlpoint.h \ + display/sp-ctrlquadr.cpp \ + display/sp-ctrlquadr.h # ###################### # ### CxxTest stuff #### diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index d229157ed..8e1b659c7 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -24,6 +24,7 @@ #include "nr-arena-glyphs.h" #include #include "inkscape-cairo.h" +#include "helper/geom.h" #ifdef test_glyph_liv #include "../display/canvas-bpath.h" @@ -86,13 +87,9 @@ nr_arena_glyphs_class_init(NRArenaGlyphsClass *klass) static void nr_arena_glyphs_init(NRArenaGlyphs *glyphs) { - glyphs->style = NULL; glyphs->g_transform.setIdentity(); glyphs->font = NULL; glyphs->glyph = 0; - - glyphs->rfont = NULL; - glyphs->sfont = NULL; glyphs->x = glyphs->y = 0.0; } @@ -101,120 +98,58 @@ nr_arena_glyphs_finalize(NRObject *object) { NRArenaGlyphs *glyphs = static_cast(object); - if (glyphs->rfont) { - glyphs->rfont->Unref(); - glyphs->rfont=NULL; - } - if (glyphs->sfont) { - glyphs->sfont->Unref(); - glyphs->sfont=NULL; - } - if (glyphs->font) { glyphs->font->Unref(); glyphs->font=NULL; } - if (glyphs->style) { - sp_style_unref(glyphs->style); - glyphs->style = NULL; - } - ((NRObjectClass *) glyphs_parent_class)->finalize(object); } static guint nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*state*/, guint /*reset*/) { - NRArenaGlyphs *glyphs; - raster_font *rfont; + NRArenaGlyphs *glyphs = NR_ARENA_GLYPHS(item); + NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item->parent); - glyphs = NR_ARENA_GLYPHS(item); - - if (!glyphs->font || !glyphs->style) + if (!glyphs->font || !ggroup->style) return NR_ARENA_ITEM_STATE_ALL; - if ((glyphs->style->fill.isNone()) && (glyphs->style->stroke.isNone())) + if (ggroup->nrstyle.fill.type == NRStyle::PAINT_NONE && ggroup->nrstyle.stroke.type == NRStyle::PAINT_NONE) return NR_ARENA_ITEM_STATE_ALL; - NRRect bbox; - bbox.x0 = bbox.y0 = NR_HUGE; - bbox.x1 = bbox.y1 = -NR_HUGE; - - float const scale = gc->transform.descrim(); - - if (!glyphs->style->fill.isNone()) { - Geom::Matrix t; - t = glyphs->g_transform * gc->transform; - glyphs->x = t[4]; - glyphs->y = t[5]; - t[4]=0; - t[5]=0; - rfont = glyphs->font->RasterFont(t, 0); - if (glyphs->rfont) glyphs->rfont->Unref(); - glyphs->rfont = rfont; - - if (glyphs->style->stroke.isNone() || fabs(glyphs->style->stroke_width.computed * scale) <= 0.01) { // Optimization: do fill bbox only if there's no stroke - NRRect narea; - if ( glyphs->rfont ) glyphs->rfont->BBox(glyphs->glyph, &narea); - bbox.x0 = narea.x0 + glyphs->x; - bbox.y0 = narea.y0 + glyphs->y; - bbox.x1 = narea.x1 + glyphs->x; - bbox.y1 = narea.y1 + glyphs->y; + Geom::OptRect b; + Geom::Matrix t = glyphs->g_transform * gc->transform; + glyphs->x = t[4]; + glyphs->y = t[5]; + + b = bounds_exact_transformed(*glyphs->font->PathVector(glyphs->glyph), t); + if (b && ggroup->nrstyle.stroke.type != NRStyle::PAINT_NONE) { + float width, scale; + scale = gc->transform.descrim(); + width = MAX(0.125, ggroup->nrstyle.stroke_width * scale); + if ( fabs(ggroup->nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true + b->expandBy(width); } - } - - if (!glyphs->style->stroke.isNone()) { - /* Build state data */ - Geom::Matrix t; - t = glyphs->g_transform * gc->transform; - glyphs->x = t[4]; - glyphs->y = t[5]; - t[4]=0; - t[5]=0; - - if ( fabs(glyphs->style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - font_style nstyl; - nstyl.transform = t; - nstyl.stroke_width=MAX(0.125, glyphs->style->stroke_width.computed * scale); - if ( glyphs->style->stroke_linecap.computed == SP_STROKE_LINECAP_BUTT ) nstyl.stroke_cap=butt_straight; - if ( glyphs->style->stroke_linecap.computed == SP_STROKE_LINECAP_ROUND ) nstyl.stroke_cap=butt_round; - if ( glyphs->style->stroke_linecap.computed == SP_STROKE_LINECAP_SQUARE ) nstyl.stroke_cap=butt_square; - if ( glyphs->style->stroke_linejoin.computed == SP_STROKE_LINEJOIN_MITER ) nstyl.stroke_join=join_pointy; - if ( glyphs->style->stroke_linejoin.computed == SP_STROKE_LINEJOIN_ROUND ) nstyl.stroke_join=join_round; - if ( glyphs->style->stroke_linejoin.computed == SP_STROKE_LINEJOIN_BEVEL ) nstyl.stroke_join=join_straight; - nstyl.stroke_miter_limit = glyphs->style->stroke_miterlimit.value; - nstyl.nbDash=0; - nstyl.dash_offset = 0; - nstyl.dashes=NULL; - if ( glyphs->style->stroke_dash.n_dash > 0 ) { - nstyl.dash_offset = glyphs->style->stroke_dash.offset * scale; - nstyl.nbDash=glyphs->style->stroke_dash.n_dash; - nstyl.dashes=(double*)malloc(nstyl.nbDash*sizeof(double)); - for (int i = 0; i < nstyl.nbDash; i++) nstyl.dashes[i]= glyphs->style->stroke_dash.dash[i] * scale; - } - rfont = glyphs->font->RasterFont( nstyl); - if ( nstyl.dashes ) free(nstyl.dashes); - if (glyphs->sfont) glyphs->sfont->Unref(); - glyphs->sfont = rfont; - - NRRect narea; - if ( glyphs->sfont ) glyphs->sfont->BBox(glyphs->glyph, &narea); - narea.x0-=nstyl.stroke_width; - narea.y0-=nstyl.stroke_width; - narea.x1+=nstyl.stroke_width; - narea.y1+=nstyl.stroke_width; - bbox.x0 = narea.x0 + glyphs->x; - bbox.y0 = narea.y0 + glyphs->y; - bbox.x1 = narea.x1 + glyphs->x; - bbox.y1 = narea.y1 + glyphs->y; + // those pesky miters, now + float miterMax = width * ggroup->nrstyle.miter_limit; + if ( miterMax > 0.01 ) { + // grunt mode. we should compute the various miters instead + // (one for each point on the curve) + b->expandBy(miterMax); } } - if (nr_rect_d_test_empty(bbox)) return NR_ARENA_ITEM_STATE_ALL; - item->bbox.x0 = static_cast(floor(bbox.x0)); - item->bbox.y0 = static_cast(floor(bbox.y0)); - item->bbox.x1 = static_cast(ceil (bbox.x1)); - item->bbox.y1 = static_cast(ceil (bbox.y1)); + if (b) { + item->bbox.x0 = static_cast(floor(b->left())); + item->bbox.y0 = static_cast(floor(b->top())); + item->bbox.x1 = static_cast(ceil (b->right())); + item->bbox.y1 = static_cast(ceil (b->bottom())); + } else { + item->bbox.x0 = 0; + item->bbox.y0 = 0; + item->bbox.x1 = -1; + item->bbox.y1 = -1; + } return NR_ARENA_ITEM_STATE_ALL; } @@ -226,7 +161,7 @@ nr_arena_glyphs_clip(cairo_t *ct, NRArenaItem *item, NRRectL */*area*/) glyphs = NR_ARENA_GLYPHS(item); - if (!glyphs->font ) return item->state; + if (!glyphs->font) return item->state; /* TODO : render to greyscale pixblock provided for clipping */ @@ -241,7 +176,6 @@ nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned i glyphs = NR_ARENA_GLYPHS(item); if (!glyphs->font ) return NULL; - if (!glyphs->style) return NULL; double const x = p[Geom::X]; double const y = p[Geom::Y]; @@ -273,46 +207,6 @@ nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int nr_arena_item_request_update(NR_ARENA_ITEM(glyphs), NR_ARENA_ITEM_STATE_ALL, FALSE); } -void -nr_arena_glyphs_set_style(NRArenaGlyphs *glyphs, SPStyle *style) -{ - nr_return_if_fail(glyphs != NULL); - nr_return_if_fail(NR_IS_ARENA_GLYPHS(glyphs)); - - if (style) sp_style_ref(style); - if (glyphs->style) sp_style_unref(glyphs->style); - glyphs->style = style; - - nr_arena_item_request_update(NR_ARENA_ITEM(glyphs), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -static guint -nr_arena_glyphs_fill_mask(NRArenaGlyphs *glyphs, NRRectL *area, NRPixBlock *m) -{ - /* fixme: area == m->area, so merge these */ - - NRArenaItem *item = NR_ARENA_ITEM(glyphs); - - if (glyphs->rfont && nr_rect_l_test_intersect_ptr(area, &item->bbox)) { - raster_glyph *g = glyphs->rfont->GetGlyph(glyphs->glyph); - if ( g ) g->Blit(Geom::Point(glyphs->x, glyphs->y), *m); - } - - return item->state; -} - -static guint -nr_arena_glyphs_stroke_mask(NRArenaGlyphs *glyphs, NRRectL *area, NRPixBlock *m) -{ - NRArenaItem *item = NR_ARENA_ITEM(glyphs); - if (glyphs->sfont && nr_rect_l_test_intersect_ptr(area, &item->bbox)) { - raster_glyph *g=glyphs->sfont->GetGlyph(glyphs->glyph); - if ( g ) g->Blit(Geom::Point(glyphs->x, glyphs->y),*m); - } - - return item->state; -} - static void nr_arena_glyphs_group_class_init(NRArenaGlyphsGroupClass *klass); static void nr_arena_glyphs_group_init(NRArenaGlyphsGroup *group); static void nr_arena_glyphs_group_finalize(NRObject *object); @@ -364,10 +258,7 @@ nr_arena_glyphs_group_init(NRArenaGlyphsGroup *group) { group->style = NULL; group->paintbox.x0 = group->paintbox.y0 = 0.0F; - group->paintbox.x1 = group->paintbox.y1 = 1.0F; - - group->fill_painter = NULL; - group->stroke_painter = NULL; + group->paintbox.x1 = group->paintbox.y1 = -1.0F; } static void @@ -375,16 +266,6 @@ nr_arena_glyphs_group_finalize(NRObject *object) { NRArenaGlyphsGroup *group=static_cast(object); - if (group->fill_painter) { - sp_painter_free(group->fill_painter); - group->fill_painter = NULL; - } - - if (group->stroke_painter) { - sp_painter_free(group->stroke_painter); - group->stroke_painter = NULL; - } - if (group->style) { sp_style_unref(group->style); group->style = NULL; @@ -398,34 +279,7 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s { NRArenaGlyphsGroup *group = NR_ARENA_GLYPHS_GROUP(item); - if (group->fill_painter) { - sp_painter_free(group->fill_painter); - group->fill_painter = NULL; - } - - if (group->stroke_painter) { - sp_painter_free(group->stroke_painter); - group->stroke_painter = NULL; - } - - item->render_opacity = TRUE; - if (group->style->fill.isPaintserver()) { - group->fill_painter = sp_paint_server_painter_new(SP_STYLE_FILL_SERVER(group->style), - gc->transform, gc->parent->transform, - &group->paintbox); - item->render_opacity = FALSE; - } - - if (group->style->stroke.isPaintserver()) { - group->stroke_painter = sp_paint_server_painter_new(SP_STYLE_STROKE_SERVER(group->style), - gc->transform, gc->parent->transform, - &group->paintbox); - item->render_opacity = FALSE; - } - - if ( item->render_opacity == TRUE && !group->style->stroke.isNone() && !group->style->fill.isNone() ) { - item->render_opacity=FALSE; - } + group->nrstyle.update(); if (((NRArenaItemClass *) group_parent_class)->update) return ((NRArenaItemClass *) group_parent_class)->update(item, area, gc, state, reset); @@ -441,16 +295,11 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi NRArenaGroup *group = NR_ARENA_GROUP(item); NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); - SPStyle const *style = ggroup->style; - guint ret = item->state; - bool print_colors_preview = (item->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); + if (!ct) return item->state; if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - if (!ct) - return item->state; - guint32 rgba = item->arena->outlinecolor; // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat // by setting color channels in the "wrong" order @@ -469,112 +318,59 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi pb->empty = FALSE; } - return ret; + return item->state; } + // NOTE: this is very similar to nr-arena-shape.cpp; the only difference is path feeding + bool needs_opacity = ((1.0 - ggroup->nrstyle.opacity) >= 0.01); + bool has_stroke, has_fill; + cairo_save(ct); + cairo_translate(ct, -area->x0, -area->y0); + ink_cairo_transform(ct, ggroup->ctm); - /* Fill */ - if (!style->fill.isNone() || item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - NRPixBlock m; - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); + has_fill = ggroup->nrstyle.prepareFill(ct, &ggroup->paintbox); + has_stroke = ggroup->nrstyle.prepareStroke(ct, &ggroup->paintbox); - // if memory allocation failed, abort - if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) { - nr_pixblock_release (&m); - return (item->state); + if (has_fill || has_stroke) { + if (needs_opacity) { + cairo_push_group(ct); } - m.visible_area = pb->visible_area; + for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { + NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); + Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); - /* Render children fill mask */ - for (child = group->children; child != NULL; child = child->next) { - ret = nr_arena_glyphs_fill_mask(NR_ARENA_GLYPHS(child), area, &m); - if (!(ret & NR_ARENA_ITEM_STATE_RENDER)) { - nr_pixblock_release(&m); - return ret; - } + cairo_save(ct); + ink_cairo_transform(ct, g->g_transform); + feed_pathvector_to_cairo(ct, pathv); + cairo_restore(ct); } - /* Composite into buffer */ - if (style->fill.isPaintserver()) { - if (ggroup->fill_painter) { - nr_arena_render_paintserver_fill(pb, area, ggroup->fill_painter, SP_SCALE24_TO_FLOAT(style->fill_opacity.value), &m); - } - } else if (style->fill.isColor() || item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - guint32 rgba; - if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - // In outline mode, render fill only, using outlinecolor - rgba = item->arena->outlinecolor; - } else if ( item->render_opacity ) { - rgba = style->fill.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->fill_opacity.value) * - SP_SCALE24_TO_FLOAT(style->opacity.value) ); - } else { - rgba = style->fill.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->fill_opacity.value) ); - } - - if (print_colors_preview) - nr_arena_separate_color_plates(&rgba); - - nr_blit_pixblock_mask_rgba32(pb, &m, rgba); - pb->empty = FALSE; + if (has_fill) { + ggroup->nrstyle.applyFill(ct); + cairo_fill_preserve(ct); } - - nr_pixblock_release(&m); - } - - /* Stroke */ - if (!style->stroke.isNone() && !(item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE)) { - NRPixBlock m; - guint32 rgba; - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); - - // if memory allocation failed, abort - if (m.size != NR_PIXBLOCK_SIZE_TINY && m.data.px == NULL) { - nr_pixblock_release (&m); - return (item->state); + if (has_stroke) { + ggroup->nrstyle.applyStroke(ct); + cairo_stroke_preserve(ct); } + cairo_new_path(ct); // clear path - m.visible_area = pb->visible_area; - /* Render children stroke mask */ - for (child = group->children; child != NULL; child = child->next) { - ret = nr_arena_glyphs_stroke_mask(NR_ARENA_GLYPHS(child), area, &m); - if (!(ret & NR_ARENA_ITEM_STATE_RENDER)) { - nr_pixblock_release(&m); - return ret; - } - } - /* Composite into buffer */ - if (style->stroke.isPaintserver()) { - if (ggroup->stroke_painter) { - nr_arena_render_paintserver_fill(pb, area, ggroup->stroke_painter, SP_SCALE24_TO_FLOAT(style->stroke_opacity.value), &m); - } - } else if (style->stroke.isColor()) { - if ( item->render_opacity ) { - rgba = style->stroke.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->stroke_opacity.value) * - SP_SCALE24_TO_FLOAT(style->opacity.value) ); - } else { - rgba = style->stroke.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->stroke_opacity.value) ); - } - - if (print_colors_preview) - nr_arena_separate_color_plates(&rgba); - - nr_blit_pixblock_mask_rgba32(pb, &m, rgba); - pb->empty = FALSE; - } else { - // nothing + if (needs_opacity) { + cairo_pop_group_to_source(ct); + cairo_paint_with_alpha(ct, ggroup->nrstyle.opacity); } - nr_pixblock_release(&m); - } + } // has fill or stroke pattern + cairo_restore(ct); - return ret; + return item->state; } static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area) { - NRArenaGroup *group = NR_ARENA_GROUP(item); + //NRArenaGroup *group = NR_ARENA_GROUP(item); guint ret = item->state; @@ -630,7 +426,6 @@ nr_arena_glyphs_group_add_component(NRArenaGlyphsGroup *sg, font_instance *font, nr_arena_item_append_child(NR_ARENA_ITEM(group), new_arena); nr_arena_item_unref(new_arena); nr_arena_glyphs_set_path(NR_ARENA_GLYPHS(new_arena), NULL, FALSE, font, glyph, &transform); - nr_arena_glyphs_set_style(NR_ARENA_GLYPHS(new_arena), sg->style); } } @@ -640,16 +435,11 @@ nr_arena_glyphs_group_set_style(NRArenaGlyphsGroup *sg, SPStyle *style) nr_return_if_fail(sg != NULL); nr_return_if_fail(NR_IS_ARENA_GLYPHS_GROUP(sg)); - NRArenaGroup *group = NR_ARENA_GROUP(sg); - if (style) sp_style_ref(style); if (sg->style) sp_style_unref(sg->style); sg->style = style; - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - nr_return_if_fail(NR_IS_ARENA_GLYPHS(child)); - nr_arena_glyphs_set_style(NR_ARENA_GLYPHS(child), sg->style); - } + sg->nrstyle.set(style); nr_arena_item_request_update(NR_ARENA_ITEM(sg), NR_ARENA_ITEM_STATE_ALL, FALSE); } @@ -667,9 +457,8 @@ nr_arena_glyphs_group_set_paintbox(NRArenaGlyphsGroup *gg, NRRect const *pbox) gg->paintbox.x1 = pbox->x1; gg->paintbox.y1 = pbox->y1; } else { - /* fixme: We kill warning, although not sure what to do here (Lauris) */ gg->paintbox.x0 = gg->paintbox.y0 = 0.0F; - gg->paintbox.x1 = gg->paintbox.y1 = 256.0F; + gg->paintbox.x1 = gg->paintbox.y1 = -1.0F; } nr_arena_item_request_update(NR_ARENA_ITEM(gg), NR_ARENA_ITEM_STATE_ALL, FALSE); diff --git a/src/display/nr-arena-glyphs.h b/src/display/nr-arena-glyphs.h index 5bf94f3fc..f0580282f 100644 --- a/src/display/nr-arena-glyphs.h +++ b/src/display/nr-arena-glyphs.h @@ -17,12 +17,12 @@ #define NR_ARENA_GLYPHS(obj) (NR_CHECK_INSTANCE_CAST ((obj), NR_TYPE_ARENA_GLYPHS, NRArenaGlyphs)) #define NR_IS_ARENA_GLYPHS(obj) (NR_CHECK_INSTANCE_TYPE ((obj), NR_TYPE_ARENA_GLYPHS)) -#include - -#include -#include -#include -#include +#include "libnrtype/nrtype-forward.h" +#include "display/display-forward.h" +#include "forward.h" +#include "sp-paint-server.h" +#include "display/nr-arena-item.h" +#include "display/nr-style.h" #define test_glyph_liv @@ -32,22 +32,11 @@ NRType nr_arena_glyphs_get_type (void); struct NRArenaGlyphs : public NRArenaItem { /* Glyphs data */ - SPStyle *style; Geom::Matrix g_transform; font_instance *font; gint glyph; - - raster_font *rfont; - raster_font *sfont; float x, y; -// Geom::Matrix cached_tr; -// Shape *cached_shp; -// bool cached_shp_dirty; -// bool cached_style_dirty; - -// Shape *stroke_shp; - static NRArenaGlyphs *create(NRArena *arena) { NRArenaGlyphs *obj=reinterpret_cast(nr_object_new(NR_TYPE_ARENA_GLYPHS)); obj->init(arena); @@ -79,11 +68,8 @@ typedef struct NRArenaGlyphsGroupClass NRArenaGlyphsGroupClass; NRType nr_arena_glyphs_group_get_type (void); struct NRArenaGlyphsGroup : public NRArenaGroup { - //SPStyle *style; NRRect paintbox; - /* State data */ - SPPainter *fill_painter; - SPPainter *stroke_painter; + NRStyle nrstyle; static NRArenaGlyphsGroup *create(NRArena *arena) { NRArenaGlyphsGroup *obj=reinterpret_cast(nr_object_new(NR_TYPE_ARENA_GLYPHS_GROUP)); diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 8f11db191..ca9528f16 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -565,8 +565,8 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area unsigned int state; Cairo::Context cct(ct); Cairo::RefPtr mask; - CairoSave clipsave(ct); - CairoGroup maskgroup(ct); + CairoSave clipsave(ct); // RAII for save / restore + CairoGroup maskgroup(ct); // RAII for push_group / pop_group CairoGroup drawgroup(ct); if (item->clip) { diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 548a17127..f0a621bf0 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -23,6 +23,7 @@ #include #include <2geom/pathvector.h> #include <2geom/curves.h> +#include #include #include #include @@ -110,20 +111,14 @@ nr_arena_shape_init(NRArenaShape *shape) shape->style = NULL; shape->paintbox.x0 = shape->paintbox.y0 = 0.0F; shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; - shape->ctm.setIdentity(); - shape->delayed_shp = false; - - shape->fill_pattern = NULL; - shape->stroke_pattern = NULL; shape->path = NULL; shape->approx_bbox.x0 = shape->approx_bbox.y0 = 0; shape->approx_bbox.x1 = shape->approx_bbox.y1 = 0; shape->markers = NULL; - shape->last_pick = NULL; shape->repick_after = 0; } @@ -133,10 +128,7 @@ nr_arena_shape_finalize(NRObject *object) { NRArenaShape *shape = (NRArenaShape *) object; - if (shape->fill_pattern) cairo_pattern_destroy(shape->fill_pattern); - if (shape->stroke_pattern) cairo_pattern_destroy(shape->stroke_pattern); if (shape->path) cairo_path_destroy(shape->path); - if (shape->style) sp_style_unref(shape->style); if (shape->curve) shape->curve->unref(); @@ -267,14 +259,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); // clear Cairo data to force update - if (shape->fill_pattern) { - cairo_pattern_destroy(shape->fill_pattern); - shape->fill_pattern = NULL; - } - if (shape->stroke_pattern) { - cairo_pattern_destroy(shape->stroke_pattern); - shape->stroke_pattern = NULL; - } + shape->nrstyle.update(); if (shape->path) { cairo_path_destroy(shape->path); shape->path = NULL; @@ -283,17 +268,18 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); - if (boundingbox && (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE || outline)) { + if (boundingbox && (shape->nrstyle.stroke.type != NRStyle::PAINT_NONE || outline)) { float width, scale; scale = gc->transform.descrim(); - width = MAX(0.125, shape->_stroke.width * scale); - if ( fabs(shape->_stroke.width * scale) > 0.01 ) { + width = MAX(0.125, shape->nrstyle.stroke_width * scale); + if ( fabs(shape->nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true boundingbox->expandBy(width); } // those pesky miters, now - float miterMax=width*shape->_stroke.mitre_limit; + float miterMax = width * shape->nrstyle.miter_limit; if ( miterMax > 0.01 ) { - // grunt mode. we should compute the various miters instead (one for each point on the curve) + // grunt mode. we should compute the various miters instead + // (one for each point on the curve) boundingbox->expandBy(miterMax); } } @@ -316,8 +302,8 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (!shape->curve || !shape->style || shape->curve->is_empty() || - (( shape->_fill.paint.type() == NRArenaShape::Paint::NONE ) && - ( shape->_stroke.paint.type() == NRArenaShape::Paint::NONE && !outline) )) + (( shape->nrstyle.fill.type != NRStyle::PAINT_NONE ) && + ( shape->nrstyle.stroke.type != NRStyle::PAINT_NONE && !outline) )) { //item->bbox = shape->approx_bbox; return NR_ARENA_ITEM_STATE_ALL; @@ -384,12 +370,8 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; } else { - SPStyle const *style = shape->style; - - // set up context and feed path - float opacity = SP_SCALE24_TO_FLOAT(shape->style->opacity.value); - bool needs_opacity = ((1.0 - opacity) >= 1e-3); - + bool needs_opacity = ((1.0 - shape->nrstyle.opacity) >= 0.01); + bool has_stroke, has_fill; // we assume the context has no path cairo_save(ct); cairo_translate(ct, -area->x0, -area->y0); @@ -398,76 +380,33 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock // update fill and stroke paints. // this cannot be done during nr_arena_shape_update, because we need a Cairo context // to render svg:pattern - if (!shape->fill_pattern) { - switch (shape->_fill.paint.type()) { - case NRArenaShape::Paint::SERVER: { - SPPaintServer *ps = shape->_fill.paint.server(); - shape->fill_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_fill.opacity); - } break; - case NRArenaShape::Paint::COLOR: { - SPColor const &c = shape->_fill.paint.color(); - shape->fill_pattern = cairo_pattern_create_rgba( - c.v.c[0], c.v.c[1], c.v.c[2], shape->_fill.opacity); - } break; - default: break; - } - } - - if (!shape->stroke_pattern) { - switch (shape->_stroke.paint.type()) { - case NRArenaShape::Paint::SERVER: { - SPPaintServer *ps = shape->_stroke.paint.server(); - shape->stroke_pattern = sp_paint_server_create_pattern(ps, ct, &shape->paintbox, shape->_stroke.opacity); - } break; - case NRArenaShape::Paint::COLOR: { - SPColor const &c = shape->_stroke.paint.color(); - shape->stroke_pattern = cairo_pattern_create_rgba( - c.v.c[0], c.v.c[1], c.v.c[2], shape->_stroke.opacity); - } break; - default: break; - } - } - - if (shape->fill_pattern || shape->stroke_pattern) { + has_fill = shape->nrstyle.prepareFill(ct, &shape->paintbox); + has_stroke = shape->nrstyle.prepareStroke(ct, &shape->paintbox); + if (has_fill || has_stroke) { if (needs_opacity) { cairo_push_group(ct); } // TODO: remove segments outside of bbox when no dashes present feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); - - if (shape->fill_pattern) { - cairo_set_fill_rule(ct, shape->_fill.rule); - cairo_set_source(ct, shape->fill_pattern); + if (has_fill) { + shape->nrstyle.applyFill(ct); cairo_fill_preserve(ct); } - - if (shape->stroke_pattern) { - cairo_set_line_width(ct, shape->_stroke.width); - cairo_set_line_cap(ct, shape->_stroke.cap); - cairo_set_line_join(ct, shape->_stroke.join); - cairo_set_miter_limit (ct, style->stroke_miterlimit.value); - - // dashes - if (style->stroke_dash.n_dash) { - cairo_set_dash (ct, style->stroke_dash.dash, style->stroke_dash.n_dash, - style->stroke_dash.offset); - } - cairo_set_source(ct, shape->stroke_pattern); + if (has_stroke) { + shape->nrstyle.applyStroke(ct); cairo_stroke_preserve(ct); } cairo_new_path(ct); // clear path if (needs_opacity) { cairo_pop_group_to_source(ct); - cairo_paint_with_alpha(ct, opacity); + cairo_paint_with_alpha(ct, shape->nrstyle.opacity); } } // has fill or stroke pattern - cairo_restore(ct); - - } // non-cairo non-outline branch + } /* Render markers into parent buffer */ for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { @@ -522,17 +461,17 @@ nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int double width; if (outline) { width = 0.5; - } else if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE && shape->_stroke.opacity > 1e-3) { + } else if (shape->nrstyle.stroke.type != NRStyle::PAINT_NONE && shape->nrstyle.stroke.opacity > 1e-3) { float const scale = shape->ctm.descrim(); - width = MAX(0.125, shape->_stroke.width * scale) / 2; + width = MAX(0.125, shape->nrstyle.stroke_width * scale) / 2; } else { width = 0; } double dist = NR_HUGE; int wind = 0; - bool needfill = (shape->_fill.paint.type() != NRArenaShape::Paint::NONE - && shape->_fill.opacity > 1e-3 && !outline); + bool needfill = (shape->nrstyle.fill.type != NRStyle::PAINT_NONE + && shape->nrstyle.fill.opacity > 1e-3 && !outline); if (item->arena->canvasarena) { Geom::Rect viewbox = item->arena->canvasarena->item.canvas->getViewbox(); @@ -614,61 +553,6 @@ void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve,bool justTrans) nr_arena_item_request_update(NR_ARENA_ITEM(shape), NR_ARENA_ITEM_STATE_ALL, FALSE); } -void NRArenaShape::setFill(SPPaintServer *server) { - _fill.paint.set(server); - _invalidateCachedFill(); -} - -void NRArenaShape::setFill(SPColor const &color) { - _fill.paint.set(color); - _invalidateCachedFill(); -} - -void NRArenaShape::setFillOpacity(double opacity) { - _fill.opacity = opacity; - _invalidateCachedFill(); -} - -void NRArenaShape::setFillRule(cairo_fill_rule_t rule) { - _fill.rule = rule; - _invalidateCachedFill(); -} - -void NRArenaShape::setStroke(SPPaintServer *server) { - _stroke.paint.set(server); - _invalidateCachedStroke(); -} - -void NRArenaShape::setStroke(SPColor const &color) { - _stroke.paint.set(color); - _invalidateCachedStroke(); -} - -void NRArenaShape::setStrokeOpacity(double opacity) { - _stroke.opacity = opacity; - _invalidateCachedStroke(); -} - -void NRArenaShape::setStrokeWidth(double width) { - _stroke.width = width; - _invalidateCachedStroke(); -} - -void NRArenaShape::setMitreLimit(double limit) { - _stroke.mitre_limit = limit; - _invalidateCachedStroke(); -} - -void NRArenaShape::setLineCap(cairo_line_cap_t cap) { - _stroke.cap = cap; - _invalidateCachedStroke(); -} - -void NRArenaShape::setLineJoin(cairo_line_join_t join) { - _stroke.join = join; - _invalidateCachedStroke(); -} - /** nr_arena_shape_set_style * * Unrefs any existing style and ref's to the given one, then requests an update of the arena @@ -683,76 +567,7 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) if (shape->style) sp_style_unref(shape->style); shape->style = style; - if ( style->fill.isPaintserver() ) { - shape->setFill(style->getFillPaintServer()); - } else if ( style->fill.isColor() ) { - shape->setFill(style->fill.value.color); - } else if ( style->fill.isNone() ) { - shape->setFill(NULL); - } else { - g_assert_not_reached(); - } - shape->setFillOpacity(SP_SCALE24_TO_FLOAT(style->fill_opacity.value)); - switch (style->fill_rule.computed) { - case SP_WIND_RULE_EVENODD: { - shape->setFillRule(CAIRO_FILL_RULE_EVEN_ODD); - break; - } - case SP_WIND_RULE_NONZERO: { - shape->setFillRule(CAIRO_FILL_RULE_WINDING); - break; - } - default: { - g_assert_not_reached(); - } - } - - if ( style->stroke.isPaintserver() ) { - shape->setStroke(style->getStrokePaintServer()); - } else if ( style->stroke.isColor() ) { - shape->setStroke(style->stroke.value.color); - } else if ( style->stroke.isNone() ) { - shape->setStroke(NULL); - } else { - g_assert_not_reached(); - } - shape->setStrokeWidth(style->stroke_width.computed); - shape->setStrokeOpacity(SP_SCALE24_TO_FLOAT(style->stroke_opacity.value)); - switch (style->stroke_linecap.computed) { - case SP_STROKE_LINECAP_ROUND: { - shape->setLineCap(CAIRO_LINE_CAP_ROUND); - break; - } - case SP_STROKE_LINECAP_SQUARE: { - shape->setLineCap(CAIRO_LINE_CAP_SQUARE); - break; - } - case SP_STROKE_LINECAP_BUTT: { - shape->setLineCap(CAIRO_LINE_CAP_BUTT); - break; - } - default: { - g_assert_not_reached(); - } - } - switch (style->stroke_linejoin.computed) { - case SP_STROKE_LINEJOIN_ROUND: { - shape->setLineJoin(CAIRO_LINE_JOIN_ROUND); - break; - } - case SP_STROKE_LINEJOIN_BEVEL: { - shape->setLineJoin(CAIRO_LINE_JOIN_BEVEL); - break; - } - case SP_STROKE_LINEJOIN_MITER: { - shape->setLineJoin(CAIRO_LINE_JOIN_MITER); - break; - } - default: { - g_assert_not_reached(); - } - } - shape->setMitreLimit(style->stroke_miterlimit.value); + shape->nrstyle.set(style); //if shape has a filter if (style->filter.set && style->getFilter()) { diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index 97001c82d..66c8bc344 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -19,88 +19,21 @@ #include #include "display/display-forward.h" -#include "display/canvas-bpath.h" #include "forward.h" -#include "sp-paint-server.h" #include "nr-arena-item.h" - -#include "../color.h" - -#include "../livarot/Shape.h" +#include "nr-style.h" NRType nr_arena_shape_get_type (void); struct NRArenaShape : public NRArenaItem { - class Paint { - public: - enum Type { - NONE, - COLOR, - SERVER - }; - - Paint() : _type(NONE), _color(0), _server(NULL) {} - Paint(Paint const &p) { _assign(p); } - virtual ~Paint() { clear(); } - - Type type() const { return _type; } - SPPaintServer *server() const { return _server; } - SPColor const &color() const { return _color; } - - Paint &operator=(Paint const &p) { - set(p); - return *this; - } - - void set(Paint const &p) { - clear(); - _assign(p); - } - void set(SPColor const &color) { - clear(); - _type = COLOR; - _color = color; - } - void set(SPPaintServer *server) { - clear(); - if (server) { - _type = SERVER; - _server = server; - sp_object_ref(_server, NULL); - } - } - void clear() { - if ( _type == SERVER ) { - sp_object_unref(_server, NULL); - _server = NULL; - } - _type = NONE; - } - - private: - Type _type; - SPColor _color; - SPPaintServer *_server; - - void _assign(Paint const &p) { - _type = p._type; - _server = p._server; - _color = p._color; - if (_server) { - sp_object_ref(_server, NULL); - } - } - }; - /* Shape data */ SPCurve *curve; SPStyle *style; + NRStyle nrstyle; NRRect paintbox; /* State data */ Geom::Matrix ctm; - cairo_pattern_t *fill_pattern; - cairo_pattern_t *stroke_pattern; cairo_path_t *path; // delayed_shp=true means the *_shp polygons are not computed yet @@ -123,46 +56,7 @@ struct NRArenaShape : public NRArenaItem { return obj; } - void setFill(SPPaintServer *server); - void setFill(SPColor const &color); - void setFillOpacity(double opacity); - void setFillRule(cairo_fill_rule_t rule); - - void setStroke(SPPaintServer *server); - void setStroke(SPColor const &color); - void setStrokeOpacity(double opacity); - void setStrokeWidth(double width); - void setLineCap(cairo_line_cap_t cap); - void setLineJoin(cairo_line_join_t join); - void setMitreLimit(double limit); - void setPaintBox(Geom::Rect const &pbox); - - void _invalidateCachedFill() { - } - void _invalidateCachedStroke() { - } - - struct Style { - Style() : opacity(0.0) {} - Paint paint; - double opacity; - }; - struct FillStyle : public Style { - FillStyle() : rule(CAIRO_FILL_RULE_EVEN_ODD) {} - cairo_fill_rule_t rule; - } _fill; - struct StrokeStyle : public Style { - StrokeStyle() - : cap(CAIRO_LINE_CAP_ROUND), join(CAIRO_LINE_JOIN_ROUND), - width(0.0), mitre_limit(0.0) - {} - - cairo_line_cap_t cap; - cairo_line_join_t join; - double width; - double mitre_limit; - } _stroke; }; struct NRArenaShapeClass { diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp new file mode 100644 index 000000000..c15dd78a3 --- /dev/null +++ b/src/display/nr-style.cpp @@ -0,0 +1,218 @@ +/** + * @file + * @brief Style information for rendering + *//* + * Authors: + * Krzysztof Kosiński + * + * Copyright (C) 2010 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-style.h" +#include "style.h" +#include "sp-paint-server.h" +#include "display/canvas-bpath.h" // contains SPStrokeJoinType, SPStrokeCapType etc. (WTF!) + +void NRStyle::Paint::clear() +{ + if (server) { + sp_object_unref(server, NULL); + server = NULL; + } + type = PAINT_NONE; +} + +void NRStyle::Paint::set(SPColor const &c) +{ + clear(); + type = PAINT_COLOR; + color = c; +} + +void NRStyle::Paint::set(SPPaintServer *ps) +{ + clear(); + if (ps) { + type = PAINT_SERVER; + server = ps; + sp_object_ref(server, NULL); + } +} + +NRStyle::NRStyle() + : fill() + , stroke() + , stroke_width(0.0) + , miter_limit(0.0) + , n_dash(0) + , dash(NULL) + , dash_offset(0.0) + , fill_rule(CAIRO_FILL_RULE_EVEN_ODD) + , line_cap(CAIRO_LINE_CAP_BUTT) + , line_join(CAIRO_LINE_JOIN_MITER) +{} + +NRStyle::~NRStyle() +{ + cairo_pattern_destroy(fill_pattern); + cairo_pattern_destroy(stroke_pattern); + if (dash) delete dash; +} + +void NRStyle::set(SPStyle *style) +{ + if ( style->fill.isPaintserver() ) { + fill.set(style->getFillPaintServer()); + } else if ( style->fill.isColor() ) { + fill.set(style->fill.value.color); + } else if ( style->fill.isNone() ) { + fill.clear(); + } else { + g_assert_not_reached(); + } + fill.opacity = SP_SCALE24_TO_FLOAT(style->fill_opacity.value); + + switch (style->fill_rule.computed) { + case SP_WIND_RULE_EVENODD: + fill_rule = CAIRO_FILL_RULE_EVEN_ODD; + break; + case SP_WIND_RULE_NONZERO: + fill_rule = CAIRO_FILL_RULE_WINDING; + break; + default: + g_assert_not_reached(); + } + + if ( style->stroke.isPaintserver() ) { + stroke.set(style->getStrokePaintServer()); + } else if ( style->stroke.isColor() ) { + stroke.set(style->stroke.value.color); + } else if ( style->stroke.isNone() ) { + stroke.clear(); + } else { + g_assert_not_reached(); + } + stroke.opacity = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value); + stroke_width = style->stroke_width.computed; + switch (style->stroke_linecap.computed) { + case SP_STROKE_LINECAP_ROUND: + line_cap = CAIRO_LINE_CAP_ROUND; + break; + case SP_STROKE_LINECAP_SQUARE: + line_cap = CAIRO_LINE_CAP_SQUARE; + break; + case SP_STROKE_LINECAP_BUTT: + line_cap = CAIRO_LINE_CAP_BUTT; + break; + default: + g_assert_not_reached(); + } + switch (style->stroke_linejoin.computed) { + case SP_STROKE_LINEJOIN_ROUND: + line_join = CAIRO_LINE_JOIN_ROUND; + break; + case SP_STROKE_LINEJOIN_BEVEL: + line_join = CAIRO_LINE_JOIN_BEVEL; + break; + case SP_STROKE_LINEJOIN_MITER: + line_join = CAIRO_LINE_JOIN_MITER; + break; + default: + g_assert_not_reached(); + } + miter_limit = style->stroke_miterlimit.value; + + delete [] dash; + + n_dash = style->stroke_dash.n_dash; + if (n_dash != 0) { + dash_offset = style->stroke_dash.offset; + dash = new double[n_dash]; + for (unsigned int i = 0; i < n_dash; ++i) { + dash[i] = style->stroke_dash.dash[i]; + } + } else { + dash_offset = 0.0; + dash = NULL; + } + + opacity = SP_SCALE24_TO_FLOAT(style->opacity.value); + + update(); +} + +bool NRStyle::prepareFill(cairo_t *ct, NRRect *paintbox) +{ + // update fill pattern + if (!fill_pattern) { + switch (fill.type) { + case PAINT_SERVER: + fill_pattern = sp_paint_server_create_pattern(fill.server, ct, paintbox, fill.opacity); + break; + case PAINT_COLOR: { + SPColor const &c = fill.color; + fill_pattern = cairo_pattern_create_rgba( + c.v.c[0], c.v.c[1], c.v.c[2], fill.opacity); + } break; + default: break; + } + } + if (!fill_pattern) return false; + return true; +} + +void NRStyle::applyFill(cairo_t *ct) +{ + cairo_set_source(ct, fill_pattern); + cairo_set_fill_rule(ct, fill_rule); +} + +bool NRStyle::prepareStroke(cairo_t *ct, NRRect *paintbox) +{ + if (!stroke_pattern) { + switch (stroke.type) { + case PAINT_SERVER: + stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct, paintbox, stroke.opacity); + break; + case PAINT_COLOR: { + SPColor const &c = stroke.color; + stroke_pattern = cairo_pattern_create_rgba( + c.v.c[0], c.v.c[1], c.v.c[2], stroke.opacity); + } break; + default: break; + } + } + if (!stroke_pattern) return false; + return true; +} + +void NRStyle::applyStroke(cairo_t *ct) +{ + cairo_set_source(ct, stroke_pattern); + cairo_set_line_width(ct, stroke_width); + cairo_set_line_cap(ct, line_cap); + cairo_set_line_join(ct, line_join); + cairo_set_miter_limit(ct, miter_limit); + cairo_set_dash(ct, dash, n_dash, dash_offset); +} + +void NRStyle::update() +{ + // force pattern update + cairo_pattern_destroy(fill_pattern); + cairo_pattern_destroy(stroke_pattern); + fill_pattern = NULL; + stroke_pattern = NULL; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-style.h b/src/display/nr-style.h new file mode 100644 index 000000000..b2116a6c5 --- /dev/null +++ b/src/display/nr-style.h @@ -0,0 +1,82 @@ +/** + * @file + * @brief Style information for rendering + *//* + * Authors: + * Krzysztof Kosiński + * + * Copyright (C) 2010 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_NR_ARENA_STYLE_H +#define SEEN_INKSCAPE_DISPLAY_NR_ARENA_STYLE_H + +#include +#include "color.h" + +class SPColor; +class SPPaintServer; +class SPStyle; +struct NRRect; + +struct NRStyle { + NRStyle(); + ~NRStyle(); + + void set(SPStyle *); + bool prepareFill(cairo_t *ct, NRRect *paintbox); + bool prepareStroke(cairo_t *ct, NRRect *paintbox); + void applyFill(cairo_t *ct); + void applyStroke(cairo_t *ct); + void update(); + + enum PaintType { + PAINT_NONE, + PAINT_COLOR, + PAINT_SERVER + }; + + struct Paint { + Paint() : type(PAINT_NONE), color(0), server(NULL), opacity(1.0) {} + ~Paint() { clear(); } + + PaintType type; + SPColor color; + SPPaintServer *server; + float opacity; + + void clear(); + void set(SPColor const &c); + void set(SPPaintServer *ps); + }; + + Paint fill; + Paint stroke; + float stroke_width; + float miter_limit; + float opacity; + unsigned int n_dash; + double *dash; + float dash_offset; + cairo_fill_rule_t fill_rule; + cairo_line_cap_t line_cap; + cairo_line_join_t line_join; + + cairo_pattern_t *fill_pattern; + cairo_pattern_t *stroke_pattern; +}; + +#endif + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 5db2b5e8aa1f645c25d41cc4fedf98d5ce41ebbe Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 29 Jun 2010 22:01:17 +0200 Subject: Bitmap image rendering (bzr r9508.1.6) --- src/display/nr-arena-image.cpp | 95 +++++++++++++++++------------------------- src/display/nr-arena-image.h | 15 ++++--- src/sp-image.cpp | 15 ++++--- 3 files changed, 56 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index ec11d9ed1..6b71abaa0 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -18,6 +18,7 @@ #include "../preferences.h" #include "nr-arena-image.h" #include "style.h" +#include "display/inkscape-cairo.h" #include "display/nr-arena.h" #include "display/nr-filter.h" #include "display/nr-filter-gaussian.h" @@ -82,14 +83,13 @@ nr_arena_image_class_init (NRArenaImageClass *klass) static void nr_arena_image_init (NRArenaImage *image) { - image->px = NULL; - - image->pxw = image->pxh = image->pxrs = 0; + image->pixbuf = NULL; image->x = image->y = 0.0; image->width = 256.0; image->height = 256.0; image->grid2px.setIdentity(); + image->px2grid.setIdentity(); image->style = 0; image->render_opacity = TRUE; @@ -101,6 +101,8 @@ nr_arena_image_finalize (NRObject *object) NRArenaImage *image = NR_ARENA_IMAGE (object); image->px = NULL; + if (image->pixbuf != NULL) + g_object_unref(image->pixbuf); ((NRObjectClass *) parent_class)->finalize (object); } @@ -118,9 +120,9 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned /* Copy affine */ grid2px = gc->transform.inverse(); double hscale, vscale; // todo: replace with Geom::Scale - if (image->px) { - hscale = image->pxw / image->width; - vscale = image->pxh / image->height; + if (image->pixbuf) { + hscale = gdk_pixbuf_get_width(image->pixbuf) / image->width; + vscale = gdk_pixbuf_get_height(image->pixbuf) / image->height; } else { hscale = 1.0; vscale = 1.0; @@ -137,7 +139,7 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned image->grid2px[5] -= image->y * vscale; /* Calculate bbox */ - if (image->px) { + if (image->pixbuf) { NRRect bbox; bbox.x0 = image->x; @@ -170,58 +172,36 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned #define b2i (image->grid2px) static unsigned int -nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixBlock *pb, unsigned int /*flags*/ ) +nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int /*flags*/ ) { + if (!ct) + return item->state; +#if 0 Inkscape::Preferences *prefs = Inkscape::Preferences::get(); nr_arena_image_x_sample = prefs->getInt("/options/bitmapoversample/value", 1); nr_arena_image_y_sample = nr_arena_image_x_sample; - +#endif bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); NRArenaImage *image = NR_ARENA_IMAGE (item); - Geom::Matrix d2s; - - d2s[0] = b2i[0]; - d2s[1] = b2i[1]; - d2s[2] = b2i[2]; - d2s[3] = b2i[3]; - d2s[4] = b2i[0] * pb->area.x0 + b2i[2] * pb->area.y0 + b2i[4]; - d2s[5] = b2i[1] * pb->area.x0 + b2i[3] * pb->area.y0 + b2i[5]; - if (!outline) { + if (!image->pixbuf) return item->state; - if (!image->px) return item->state; - - guint32 Falpha = item->opacity; - if (Falpha < 1) return item->state; + // FIXME: at the moment gdk_cairo_set_source_pixbuf creates an ARGB copy + // of the pixbuf. Fix this in Cairo and/or GDK. + cairo_save(ct); + cairo_translate(ct, -area->x0, -area->y0); + gdk_cairo_set_source_pixbuf(ct, image->pixbuf, 0, 0); - unsigned char * dpx = NR_PIXBLOCK_PX (pb); - int const drs = pb->rs; - int const dw = pb->area.x1 - pb->area.x0; - int const dh = pb->area.y1 - pb->area.y0; + cairo_pattern_t *p = cairo_get_source(ct); + ink_cairo_pattern_set_matrix(p, image->grid2px); - unsigned char * spx = image->px; - int const srs = image->pxrs; - int const sw = image->pxw; - int const sh = image->pxh; - - if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8) { - /* fixme: This is not implemented yet (Lauris) */ - /* nr_R8G8B8_R8G8B8_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample); */ - } else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample); - } else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8N) { - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample); - } - - pb->empty = FALSE; + cairo_paint_with_alpha(ct, ((double) item->opacity) / 255.0); + cairo_restore(ct); } else { // outline; draw a rect instead - - if (!ct) - return item->state; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat // by setting color channels in the "wrong" order @@ -252,7 +232,6 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB pb->empty = FALSE; } - return item->state; } @@ -282,7 +261,7 @@ nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned in { NRArenaImage *image = NR_ARENA_IMAGE (item); - if (!image->px) return NULL; + if (!image->pixbuf) return NULL; bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); @@ -302,10 +281,10 @@ nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned in } else { - unsigned char *const pixels = image->px; - int const width = image->pxw; - int const height = image->pxh; - int const rowstride = image->pxrs; + unsigned char *const pixels = gdk_pixbuf_get_pixels(image->pixbuf); + int const width = gdk_pixbuf_get_width(image->pixbuf); + int const height = gdk_pixbuf_get_height(image->pixbuf); + int const rowstride = gdk_pixbuf_get_rowstride(image->pixbuf); Geom::Point tp = p * image->grid2px; int const ix = (int)(tp[Geom::X]); int const iy = (int)(tp[Geom::Y]); @@ -322,15 +301,19 @@ nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned in /* Utility */ void -nr_arena_image_set_pixels (NRArenaImage *image, unsigned char const *px, unsigned int pxw, unsigned int pxh, unsigned int pxrs) +nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb) { nr_return_if_fail (image != NULL); nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); - image->px = (unsigned char *) px; - image->pxw = pxw; - image->pxh = pxh; - image->pxrs = pxrs; + // when done in this order, it won't break if pb == image->pixbuf and the refcount is 1 + if (pb != NULL) { + g_object_ref (pb); + } + if (image->pixbuf != NULL) { + g_object_unref(image->pixbuf); + } + image->pixbuf = pb; nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-arena-image.h b/src/display/nr-arena-image.h index 209cb8de6..c2a3b805c 100644 --- a/src/display/nr-arena-image.h +++ b/src/display/nr-arena-image.h @@ -13,20 +13,18 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include "nr-arena-item.h" +#include "style.h" + #define NR_TYPE_ARENA_IMAGE (nr_arena_image_get_type ()) #define NR_ARENA_IMAGE(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA_IMAGE, NRArenaImage)) #define NR_IS_ARENA_IMAGE(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA_IMAGE)) -#include "nr-arena-item.h" -#include "style.h" - NRType nr_arena_image_get_type (void); struct NRArenaImage : public NRArenaItem { - unsigned char *px; - unsigned int pxw; - unsigned int pxh; - unsigned int pxrs; + GdkPixbuf *pixbuf; double x, y; double width, height; @@ -35,6 +33,7 @@ struct NRArenaImage : public NRArenaItem { /* From GRID to PIXELS */ Geom::Matrix grid2px; + Geom::Matrix px2grid; SPStyle *style; @@ -49,7 +48,7 @@ struct NRArenaImageClass { NRArenaItemClass parent_class; }; -void nr_arena_image_set_pixels (NRArenaImage *image, unsigned char const *px, unsigned int pxw, unsigned int pxh, unsigned int pxrs); +void nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb); void nr_arena_image_set_geometry (NRArenaImage *image, double x, double y, double width, double height); void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 68bafdeab..106d03149 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1155,6 +1155,8 @@ sp_image_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int NRArenaItem *ai = NRArenaImage::create(arena); if (image->pixbuf) { + nr_arena_image_set_pixbuf(NR_ARENA_IMAGE(ai), image->pixbuf); +#if 0 int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8; int rs = gdk_pixbuf_get_rowstride(image->pixbuf); nr_arena_image_set_style(NR_ARENA_IMAGE(ai), SP_OBJECT_STYLE(SP_OBJECT(item))); @@ -1171,14 +1173,17 @@ sp_image_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int image->trimheight, rs); } +#endif } else { - nr_arena_image_set_pixels(NR_ARENA_IMAGE(ai), NULL, 0, 0, 0); + nr_arena_image_set_pixbuf(NR_ARENA_IMAGE(ai), NULL); } - if (image->aspect_align == SP_ASPECT_NONE) { + + // TODO: reenable preserveAspectRatio + //if (image->aspect_align == SP_ASPECT_NONE) { nr_arena_image_set_geometry(NR_ARENA_IMAGE(ai), image->x.computed, image->y.computed, image->width.computed, image->height.computed); - } else { // preserveAspectRatio - nr_arena_image_set_geometry(NR_ARENA_IMAGE(ai), image->viewx, image->viewy, image->viewwidth, image->viewheight); - } + //} else { // preserveAspectRatio + // nr_arena_image_set_geometry(NR_ARENA_IMAGE(ai), image->viewx, image->viewy, image->viewwidth, image->viewheight); + //} return ai; } -- cgit v1.2.3 From 55f7e59c13b6fb502a0cfbbe811f2f3f90cc6f80 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 29 Jun 2010 23:05:56 +0200 Subject: Fix icons (bzr r9508.1.7) --- src/display/sodipodi-ctrl.cpp | 2 +- src/sp-image.cpp | 16 ++++++--------- src/widgets/icon.cpp | 47 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index dc79f5969..ed4c91d3b 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -392,7 +392,7 @@ sp_ctrl_build_cache (SPCtrl *ctrl) for (int j = 0; j < w; ++j) { int index = i * stride / 4 + j; if (px[index] & 0xff000000) { - px[index] = px[index] ? stroke : fill; + px[index] = (px[index] & 0x00ffffff) ? stroke : fill; } else { px[index] = 0; } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 106d03149..32ba3f021 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1311,19 +1311,15 @@ sp_image_update_canvas_image (SPImage *image) } for (SPItemView *v = item->display; v != NULL; v = v->next) { - int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8; - int rs = gdk_pixbuf_get_rowstride(image->pixbuf); nr_arena_image_set_style(NR_ARENA_IMAGE(v->arenaitem), SP_OBJECT_STYLE(SP_OBJECT(image))); - if (image->aspect_align == SP_ASPECT_NONE) { - nr_arena_image_set_pixels(NR_ARENA_IMAGE(v->arenaitem), - gdk_pixbuf_get_pixels(image->pixbuf), - gdk_pixbuf_get_width(image->pixbuf), - gdk_pixbuf_get_height(image->pixbuf), - rs); + // TODO: reenable preserveAspectRatio + //if (image->aspect_align == SP_ASPECT_NONE) { + nr_arena_image_set_pixbuf(NR_ARENA_IMAGE(v->arenaitem), + image->pixbuf); nr_arena_image_set_geometry(NR_ARENA_IMAGE(v->arenaitem), image->x.computed, image->y.computed, image->width.computed, image->height.computed); - } else { // preserveAspectRatio + /*} else { // preserveAspectRatio nr_arena_image_set_pixels(NR_ARENA_IMAGE(v->arenaitem), gdk_pixbuf_get_pixels(image->pixbuf) + image->trimx*pixskip + image->trimy*rs, image->trimwidth, @@ -1332,7 +1328,7 @@ sp_image_update_canvas_image (SPImage *image) nr_arena_image_set_geometry(NR_ARENA_IMAGE(v->arenaitem), image->viewx, image->viewy, image->viewwidth, image->viewheight); - } + }*/ } } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5d91d3532..51bdfef66 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -913,6 +913,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, { bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg"); guchar *px = NULL; + int w, h, stride; if (doc) { SPObject *object = doc->getObjectById(name); @@ -1010,19 +1011,59 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.x0, (double)area.y0, (double)area.x1, (double)area.y1 ); g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.x0, (double)ua.y0, (double)ua.x1, (double)ua.y1 ); } + + w = ua.x1 - ua.x0; + h = ua.y1 - ua.y0; + stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); + /* Set up pixblock */ - px = g_new(guchar, 4 * psize * psize); - memset(px, 0x00, 4 * psize * psize); + px = g_new(guchar, stride * h); + memset(px, 0x00, stride * h); + /* Render */ + cairo_surface_t *s = cairo_image_surface_create_for_data(px, + CAIRO_FORMAT_ARGB32, w, h, stride); + cairo_t *ct = cairo_create(s); + NRPixBlock B; nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, ua.x0, ua.y0, ua.x1, ua.y1, px + 4 * psize * (ua.y0 - area.y0) + 4 * (ua.x0 - area.x0), 4 * psize, FALSE, FALSE ); - nr_arena_item_invoke_render(NULL, root, &ua, &B, + nr_arena_item_invoke_render(ct, root, &ua, &B, NR_ARENA_ITEM_RENDER_NO_CACHE ); nr_pixblock_release(&B); + cairo_destroy(ct); + cairo_surface_destroy(s); + + // convert to GdkPixbuf format + guint32 *ipx = reinterpret_cast(px); + for (int i = 0; i < h; ++i) { + for (int j = 0; j < w; ++j) { + int index = i * stride / 4 + j; + guint32 c = ipx[index]; + guint32 o = 0; + guint32 a = (c & 0xff000000) >> 24; + if (a != 0) { + // extract color components + guint32 r = (c & 0x00ff0000) >> 16; + guint32 g = (c & 0x0000ff00) >> 8; + guint32 b = (c & 0x000000ff); + // unpremultiply; adding a/2 gives correct rounding + r = (r * 255 + a/2) / a; + b = (b * 255 + a/2) / a; + g = (g * 255 + a/2) / a; + // combine into output +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + o = (r) | (g << 8) | (b << 16) | (a << 24); +#else + o = (r << 24) | (g << 16) | (b << 8) | (a); +#endif + } + ipx[index] = o; + } + } if ( Inkscape::Preferences::get()->getBool("/debug/icons/overlaySvg") ) { sp_icon_overlay_pixels( px, psize, psize, 4 * psize, 0x00, 0x00, 0xff ); -- cgit v1.2.3 From 13b15b7b977eecbededd1734f5ab001f0c44d21f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 30 Jun 2010 00:41:48 +0200 Subject: Consolidate Cairo utils in display/cairo-utils.h. Fix icons harder. (bzr r9508.1.8) --- src/display/Makefile_insert | 2 - src/display/cairo-utils.cpp | 341 +++++++++++++++++++++++- src/display/cairo-utils.h | 17 ++ src/display/canvas-arena.cpp | 31 +-- src/display/canvas-bpath.cpp | 7 +- src/display/canvas-text.cpp | 2 +- src/display/inkscape-cairo.cpp | 283 -------------------- src/display/inkscape-cairo.h | 40 --- src/display/nr-arena-glyphs.cpp | 16 +- src/display/nr-arena-image.cpp | 2 +- src/display/nr-arena-shape.cpp | 155 ++--------- src/display/nr-svgfonts.cpp | 4 +- src/display/sodipodi-ctrl.cpp | 2 +- src/display/sodipodi-ctrlrect.cpp | 2 +- src/display/sp-canvas.cpp | 2 +- src/display/sp-ctrlline.cpp | 12 +- src/display/sp-ctrlpoint.cpp | 2 +- src/display/sp-ctrlquadr.cpp | 10 +- src/extension/internal/cairo-render-context.cpp | 2 +- src/sp-gradient.cpp | 2 +- src/sp-pattern.cpp | 2 +- src/ui/dialog/icon-preview.cpp | 17 +- src/widgets/icon.cpp | 65 ++--- 23 files changed, 443 insertions(+), 575 deletions(-) delete mode 100644 src/display/inkscape-cairo.cpp delete mode 100644 src/display/inkscape-cairo.h (limited to 'src') diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index c6cdcbb6d..da5ded824 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -27,8 +27,6 @@ ink_common_sources += \ display/gnome-canvas-acetate.h \ display/guideline.cpp \ display/guideline.h \ - display/inkscape-cairo.cpp \ - display/inkscape-cairo.h \ display/nr-3dutils.cpp \ display/nr-3dutils.h \ display/nr-arena.cpp \ diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 58db5d551..7bfdd7dd7 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -12,12 +12,19 @@ # include #endif +#include "display/cairo-utils.h" + #include -#include +#include <2geom/pathvector.h> +#include <2geom/bezier-curve.h> +#include <2geom/hvlinesegment.h> #include <2geom/matrix.h> -#include "display/cairo-utils.h" -#include "display/inkscape-cairo.h" +#include <2geom/point.h> +#include <2geom/path.h> +#include <2geom/transforms.h> +#include <2geom/sbasis-to-bezier.h> #include "color.h" +#include "helper/geom-curves.h" namespace Inkscape { @@ -101,6 +108,334 @@ Cairo::RefPtr CairoContext::create(Cairo::RefPtr c } // namespace Inkscape +/* + * Can be called recursively. + * If optimize_stroke == false, the view Rect is not used. + */ +static void +feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & trans, Geom::Rect view, bool optimize_stroke) +{ + if( is_straight_curve(c) ) + { + Geom::Point end_tr = c.finalPoint() * trans; + if (!optimize_stroke) { + cairo_line_to(cr, end_tr[0], end_tr[1]); + } else { + Geom::Rect swept(c.initialPoint()*trans, end_tr); + if (swept.intersects(view)) { + cairo_line_to(cr, end_tr[0], end_tr[1]); + } else { + cairo_move_to(cr, end_tr[0], end_tr[1]); + } + } + } + else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast(&c)) { + std::vector points = quadratic_bezier->points(); + points[0] *= trans; + points[1] *= trans; + points[2] *= trans; + Geom::Point b1 = points[0] + (2./3) * (points[1] - points[0]); + Geom::Point b2 = b1 + (1./3) * (points[2] - points[0]); + if (!optimize_stroke) { + cairo_curve_to(cr, b1[0], b1[1], b2[0], b2[1], points[2][0], points[2][1]); + } else { + Geom::Rect swept(points[0], points[2]); + swept.expandTo(points[1]); + if (swept.intersects(view)) { + cairo_curve_to(cr, b1[0], b1[1], b2[0], b2[1], points[2][0], points[2][1]); + } else { + cairo_move_to(cr, points[2][0], points[2][1]); + } + } + } + else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast(&c)) { + std::vector points = cubic_bezier->points(); + //points[0] *= trans; // don't do this one here for fun: it is only needed for optimized strokes + points[1] *= trans; + points[2] *= trans; + points[3] *= trans; + if (!optimize_stroke) { + cairo_curve_to(cr, points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]); + } else { + points[0] *= trans; // didn't transform this point yet + Geom::Rect swept(points[0], points[3]); + swept.expandTo(points[1]); + swept.expandTo(points[2]); + if (swept.intersects(view)) { + cairo_curve_to(cr, points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]); + } else { + cairo_move_to(cr, points[3][0], points[3][1]); + } + } + } +// else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast(c)) { +// //TODO: get at the innards and spit them out to cairo +// } + else { + //this case handles sbasis as well as all other curve types + Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); + + //recurse to convert the new path resulting from the sbasis to svgd + for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { + feed_curve_to_cairo(cr, *iter, trans, view, optimize_stroke); + } + } +} + + +/** Feeds path-creating calls to the cairo context translating them from the Path */ +static void +feed_path_to_cairo (cairo_t *ct, Geom::Path const &path) +{ + if (path.empty()) + return; + + cairo_move_to(ct, path.initialPoint()[0], path.initialPoint()[1] ); + + for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) { + feed_curve_to_cairo(ct, *cit, Geom::identity(), Geom::Rect(), false); // optimize_stroke is false, so the view rect is not used + } + + if (path.closed()) { + cairo_close_path(ct); + } +} + +/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */ +static void +feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width) +{ + if (!area) + return; + if (path.empty()) + return; + + // Transform all coordinates to coords within "area" + Geom::Point shift = area->min(); + Geom::Rect view = *area; + view.expandBy (stroke_width); + view = view * (Geom::Matrix)Geom::Translate(-shift); + // Pass transformation to feed_curve, so that we don't need to create a whole new path. + Geom::Matrix transshift(trans * Geom::Translate(-shift)); + + Geom::Point initial = path.initialPoint() * transshift; + cairo_move_to(ct, initial[0], initial[1] ); + + for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) { + feed_curve_to_cairo(ct, *cit, transshift, view, optimize_stroke); + } + + if (path.closed()) { + if (!optimize_stroke) { + cairo_close_path(ct); + } else { + cairo_line_to(ct, initial[0], initial[1]); + /* We cannot use cairo_close_path(ct) here because some parts of the path may have been + clipped and not drawn (maybe the before last segment was outside view area), which + would result in closing the "subpath" after the last interruption, not the entire path. + + However, according to cairo documentation: + The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate + in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead, + there is a line join connecting the final and initial segments of the sub-path. + + The correct fix will be possible when cairo introduces methods for moving without + ending/starting subpaths, which we will use for skipping invisible segments; then we + will be able to use cairo_close_path here. This issue also affects ps/eps/pdf export, + see bug 168129 + */ + } + } +} + +/** Feeds path-creating calls to the cairo context translating them from the PathVector, with the given transform and shift + * One must have done cairo_new_path(ct); before calling this function. */ +void +feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width) +{ + if (!area) + return; + if (pathv.empty()) + return; + + for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { + feed_path_to_cairo(ct, *it, trans, area, optimize_stroke, stroke_width); + } +} + +/** Feeds path-creating calls to the cairo context translating them from the PathVector + * One must have done cairo_new_path(ct); before calling this function. */ +void +feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv) +{ + if (pathv.empty()) + return; + + for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { + feed_path_to_cairo(ct, *it); + } +} + +void +ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba) +{ + cairo_set_source_rgba(ct, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba), SP_RGBA32_A_F(rgba)); +} + +void +ink_cairo_set_source_color(cairo_t *ct, SPColor const &c, double opacity) +{ + cairo_set_source_rgba(ct, c.v.c[0], c.v.c[1], c.v.c[2], opacity); +} + +static void +ink_cairo_convert_matrix(cairo_matrix_t &cm, Geom::Matrix const &m) +{ + cm.xx = m[0]; + cm.xy = m[2]; + cm.x0 = m[4]; + cm.yx = m[1]; + cm.yy = m[3]; + cm.y0 = m[5]; +} + +void +ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m) +{ + cairo_matrix_t cm; + ink_cairo_convert_matrix(cm, m); + cairo_transform(ct, &cm); +} + +void +ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m) +{ + cairo_matrix_t cm; + ink_cairo_convert_matrix(cm, m); + cairo_pattern_set_matrix(cp, &cm); +} + +// taken from Cairo sources +static inline guint32 premul_alpha(guint32 color, guint32 alpha) +{ + guint32 temp = alpha * color + 128; + return (temp + (temp >> 8)) >> 8; +} + +/** + * @brief Convert pixel data from GdkPixbuf format to ARGB. + * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. + * This involves premultiplying alpha and shuffling around the channels. + * Pixbuf data must have an alpha channel, otherwise the results are undefined + * (usually a segfault). + */ +void +convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int stride) +{ + // TODO: optimize until it squeaks. + guint32 *ipx = reinterpret_cast(data); + + for (int i = 0; i < h; ++i) { + for (int j = 0; j < w; ++j) { + int index = i * stride / 4 + j; + guint32 c = ipx[index]; + guint32 o = 0; +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + guint32 a = (c & 0xff000000) >> 24; +#else + guint32 a = (c & 0x000000ff); +#endif + if (a != 0) { + // extract color components +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + guint32 r = (c & 0x000000ff); + guint32 g = (c & 0x0000ff00) >> 8; + guint32 b = (c & 0x00ff0000) >> 16; +#else + guint32 r = (c & 0xff000000) >> 24; + guint32 g = (c & 0x00ff0000) >> 16; + guint32 b = (c & 0x0000ff00) >> 8; +#endif + // premultiply + r = premul_alpha(r, a); + b = premul_alpha(b, a); + g = premul_alpha(g, a); + // combine into output + o = (a << 24) | (r << 16) | (g << 8) | (b); + } + ipx[index] = o; + } + } +} + +/** + * @brief Convert pixel data from ARGB to GdkPixbuf format. + * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. + * This involves premultiplying alpha and shuffling around the channels. + */ +void +convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int stride) +{ + // TODO: optimize until it squeaks. + guint32 *ipx = reinterpret_cast(data); + for (int i = 0; i < h; ++i) { + for (int j = 0; j < w; ++j) { + int index = i * stride / 4 + j; + guint32 c = ipx[index]; + guint32 o = 0; + guint32 a = (c & 0xff000000) >> 24; + if (a != 0) { + // extract color components + guint32 r = (c & 0x00ff0000) >> 16; + guint32 g = (c & 0x0000ff00) >> 8; + guint32 b = (c & 0x000000ff); + // unpremultiply; adding a/2 gives correct rounding + // (taken from Cairo sources) + r = (r * 255 + a/2) / a; + b = (b * 255 + a/2) / a; + g = (g * 255 + a/2) / a; + // combine into output +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + o = (r) | (g << 8) | (b << 16) | (a << 24); +#else + o = (r << 24) | (g << 16) | (b << 8) | (a); +#endif + } + ipx[index] = o; + } + } +} + +/** + * @brief Converts GdkPixbuf's data to premultiplied ARGB. + * This function will convert a GdkPixbuf in place into Cairo's native pixel format. + * Note that this is a hack intended to save memory. When the pixbuf is Cairo's format, + * using it with GTK will result in corrupted drawings. + */ +void +convert_pixbuf_normal_to_argb32_mutant(GdkPixbuf *pb) +{ + convert_pixels_pixbuf_to_argb32( + gdk_pixbuf_get_pixels(pb), + gdk_pixbuf_get_width(pb), + gdk_pixbuf_get_height(pb), + gdk_pixbuf_get_rowstride(pb)); +} + +/** + * @brief Converts GdkPixbuf's data back to its native format. + * Once this is done, the pixbuf can be used with GTK again. + */ +void +convert_pixbuf_argb32_to_normal(GdkPixbuf *pb) +{ + convert_pixels_argb32_to_pixbuf( + gdk_pixbuf_get_pixels(pb), + gdk_pixbuf_get_width(pb), + gdk_pixbuf_get_height(pb), + gdk_pixbuf_get_rowstride(pb)); +} + /* Local Variables: mode:c++ diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index feed987bd..882742d5f 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -13,9 +13,12 @@ #define SEEN_INKSCAPE_DISPLAY_CAIRO_UTILS_H #include +#include #include #include <2geom/forward.h> +struct SPColor; + namespace Inkscape { /** @brief RAII idiom for Cairo groups. @@ -75,6 +78,20 @@ public: } // namespace Inkscape +void ink_cairo_set_source_color(cairo_t *ct, SPColor const &color, double opacity); +void ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba); +void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m); +void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m); + +void convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int rs); +void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); +void convert_pixbuf_normal_to_argb32(GdkPixbuf *); +void convert_pixbuf_argb32_to_normal(GdkPixbuf *); + +// TODO: move those to 2Geom +void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); +void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); + #endif /* Local Variables: diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 86d902be2..086c0a27d 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -12,16 +12,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include -#include -#include +#include "libnr/nr-blit.h" +#include "display/display-forward.h" +#include "display/sp-canvas-util.h" #include "helper/sp-marshal.h" -#include -#include -#include -#include +#include "display/nr-arena.h" +#include "display/nr-arena-group.h" +#include "display/canvas-arena.h" +#include "display/cairo-utils.h" enum { ARENA_EVENT, @@ -190,7 +190,7 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) gint bw, bh; SPCanvasArena *arena = SP_CANVAS_ARENA (item); - SPCanvas *canvas = item->canvas; + //SPCanvas *canvas = item->canvas; nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, @@ -218,23 +218,8 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) FALSE, FALSE); cb.visible_area = buf->visible_rect; - //cairo_t *ct = nr_create_cairo_context (&area, &cb); - cairo_save(buf->ct); - //cairo_translate(buf->ct, area.x0 - canvas->x0, area.y0 - canvas->y0); nr_arena_item_invoke_render (buf->ct, arena->root, &area, &cb, 0); - cairo_restore(buf->ct); - - //cairo_surface_t *cst = cairo_get_target(ct); - - //cairo_save(buf->ct); - //cairo_set_source_surface(buf->ct, cst, 0, 0); - //cairo_paint(buf->ct); - //cairo_restore(buf->ct); - - //cairo_destroy (ct); - //cairo_surface_finish (cst); - //cairo_surface_destroy (cst); nr_pixblock_release (&cb); } diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 5726fef02..cf9127352 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -16,12 +16,11 @@ # include "config.h" #endif #include "color.h" -#include "sp-canvas-util.h" -#include "inkscape-cairo.h" -#include "canvas-bpath.h" +#include "display/sp-canvas-util.h" +#include "display/canvas-bpath.h" #include "display/display-forward.h" #include "display/curve.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include #include "helper/geom.h" diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index d32bc20c3..90f7c47c6 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -16,7 +16,7 @@ #include "display-forward.h" #include "sp-canvas-util.h" #include "canvas-text.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include #include #include "desktop.h" diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp deleted file mode 100644 index fa5a7cfe2..000000000 --- a/src/display/inkscape-cairo.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Helper functions to use cairo with inkscape - * - * Copyright (C) 2007 bulia byak - * Copyright (C) 2008 Johan Engelen - * - * Released under GNU GPL - * - */ - -#include - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include "../style.h" -#include "nr-arena.h" -#include "sp-canvas.h" -#include <2geom/pathvector.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> -#include <2geom/matrix.h> -#include <2geom/point.h> -#include <2geom/path.h> -#include <2geom/transforms.h> -#include <2geom/sbasis-to-bezier.h> -#include "helper/geom-curves.h" - -/** Creates a cairo context to render to the given pixblock on the given area */ -cairo_t * -nr_create_cairo_context_for_data (NRRectL *area, NRRectL *buf_area, unsigned char *px, unsigned int rowstride) -{ - if (!nr_rect_l_test_intersect_ptr(buf_area, area)) - return NULL; - - NRRectL clip; - nr_rect_l_intersect (&clip, buf_area, area); - unsigned char *dpx = px + (clip.y0 - buf_area->y0) * rowstride + 4 * (clip.x0 - buf_area->x0); - int width = area->x1 - area->x0; - int height = area->y1 - area->y0; - // even though cairo cannot draw in nonpremul mode, select ARGB32 for R8G8B8A8N as the closest; later eliminate R8G8B8A8N everywhere - cairo_surface_t* cst = cairo_image_surface_create_for_data - (dpx, - CAIRO_FORMAT_ARGB32, - width, - height, - rowstride); - cairo_t *ct = cairo_create (cst); - - return ct; -} - -#if 0 -/** Creates a cairo context to render to the given SPCanvasBuf on the given area */ -cairo_t * -nr_create_cairo_context_canvasbuf (NRRectL */*area*/, SPCanvasBuf *b) -{ - return nr_create_cairo_context_for_data (&(b->rect), &(b->rect), b->buf, b->buf_rowstride); -} -#endif - - -/** Creates a cairo context to render to the given NRPixBlock on the given area */ -cairo_t * -nr_create_cairo_context (NRRectL *area, NRPixBlock *pb) -{ - return nr_create_cairo_context_for_data (area, &(pb->area), NR_PIXBLOCK_PX (pb), pb->rs); -} - -/* - * Can be called recursively. - * If optimize_stroke == false, the view Rect is not used. - */ -static void -feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & trans, Geom::Rect view, bool optimize_stroke) -{ - if( is_straight_curve(c) ) - { - Geom::Point end_tr = c.finalPoint() * trans; - if (!optimize_stroke) { - cairo_line_to(cr, end_tr[0], end_tr[1]); - } else { - Geom::Rect swept(c.initialPoint()*trans, end_tr); - if (swept.intersects(view)) { - cairo_line_to(cr, end_tr[0], end_tr[1]); - } else { - cairo_move_to(cr, end_tr[0], end_tr[1]); - } - } - } - else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast(&c)) { - std::vector points = quadratic_bezier->points(); - points[0] *= trans; - points[1] *= trans; - points[2] *= trans; - Geom::Point b1 = points[0] + (2./3) * (points[1] - points[0]); - Geom::Point b2 = b1 + (1./3) * (points[2] - points[0]); - if (!optimize_stroke) { - cairo_curve_to(cr, b1[0], b1[1], b2[0], b2[1], points[2][0], points[2][1]); - } else { - Geom::Rect swept(points[0], points[2]); - swept.expandTo(points[1]); - if (swept.intersects(view)) { - cairo_curve_to(cr, b1[0], b1[1], b2[0], b2[1], points[2][0], points[2][1]); - } else { - cairo_move_to(cr, points[2][0], points[2][1]); - } - } - } - else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast(&c)) { - std::vector points = cubic_bezier->points(); - //points[0] *= trans; // don't do this one here for fun: it is only needed for optimized strokes - points[1] *= trans; - points[2] *= trans; - points[3] *= trans; - if (!optimize_stroke) { - cairo_curve_to(cr, points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]); - } else { - points[0] *= trans; // didn't transform this point yet - Geom::Rect swept(points[0], points[3]); - swept.expandTo(points[1]); - swept.expandTo(points[2]); - if (swept.intersects(view)) { - cairo_curve_to(cr, points[1][0], points[1][1], points[2][0], points[2][1], points[3][0], points[3][1]); - } else { - cairo_move_to(cr, points[3][0], points[3][1]); - } - } - } -// else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast(c)) { -// //TODO: get at the innards and spit them out to cairo -// } - else { - //this case handles sbasis as well as all other curve types - Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); - - //recurse to convert the new path resulting from the sbasis to svgd - for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) { - feed_curve_to_cairo(cr, *iter, trans, view, optimize_stroke); - } - } -} - - -/** Feeds path-creating calls to the cairo context translating them from the Path */ -static void -feed_path_to_cairo (cairo_t *ct, Geom::Path const &path) -{ - if (path.empty()) - return; - - cairo_move_to(ct, path.initialPoint()[0], path.initialPoint()[1] ); - - for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) { - feed_curve_to_cairo(ct, *cit, Geom::identity(), Geom::Rect(), false); // optimize_stroke is false, so the view rect is not used - } - - if (path.closed()) { - cairo_close_path(ct); - } -} - -/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */ -static void -feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width) -{ - if (!area) - return; - if (path.empty()) - return; - - // Transform all coordinates to coords within "area" - Geom::Point shift = area->min(); - Geom::Rect view = *area; - view.expandBy (stroke_width); - view = view * (Geom::Matrix)Geom::Translate(-shift); - // Pass transformation to feed_curve, so that we don't need to create a whole new path. - Geom::Matrix transshift(trans * Geom::Translate(-shift)); - - Geom::Point initial = path.initialPoint() * transshift; - cairo_move_to(ct, initial[0], initial[1] ); - - for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) { - feed_curve_to_cairo(ct, *cit, transshift, view, optimize_stroke); - } - - if (path.closed()) { - if (!optimize_stroke) { - cairo_close_path(ct); - } else { - cairo_line_to(ct, initial[0], initial[1]); - /* We cannot use cairo_close_path(ct) here because some parts of the path may have been - clipped and not drawn (maybe the before last segment was outside view area), which - would result in closing the "subpath" after the last interruption, not the entire path. - - However, according to cairo documentation: - The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate - in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead, - there is a line join connecting the final and initial segments of the sub-path. - - The correct fix will be possible when cairo introduces methods for moving without - ending/starting subpaths, which we will use for skipping invisible segments; then we - will be able to use cairo_close_path here. This issue also affects ps/eps/pdf export, - see bug 168129 - */ - } - } -} - -/** Feeds path-creating calls to the cairo context translating them from the PathVector, with the given transform and shift - * One must have done cairo_new_path(ct); before calling this function. */ -void -feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width) -{ - if (!area) - return; - if (pathv.empty()) - return; - - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { - feed_path_to_cairo(ct, *it, trans, area, optimize_stroke, stroke_width); - } -} - -/** Feeds path-creating calls to the cairo context translating them from the PathVector - * One must have done cairo_new_path(ct); before calling this function. */ -void -feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv) -{ - if (pathv.empty()) - return; - - for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) { - feed_path_to_cairo(ct, *it); - } -} - -void -ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba) -{ - cairo_set_source_rgba(ct, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba), SP_RGBA32_A_F(rgba)); -} - -static void -ink_cairo_convert_matrix(cairo_matrix_t &cm, Geom::Matrix const &m) -{ - cm.xx = m[0]; - cm.xy = m[2]; - cm.x0 = m[4]; - cm.yx = m[1]; - cm.yy = m[3]; - cm.y0 = m[5]; -} - -void -ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m) -{ - cairo_matrix_t cm; - ink_cairo_convert_matrix(cm, m); - cairo_transform(ct, &cm); -} - -void -ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m) -{ - cairo_matrix_t cm; - ink_cairo_convert_matrix(cm, m); - cairo_pattern_set_matrix(cp, &cm); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/inkscape-cairo.h b/src/display/inkscape-cairo.h deleted file mode 100644 index 74dc10995..000000000 --- a/src/display/inkscape-cairo.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __INKSCAPE_CAIRO_H__ -#define __INKSCAPE_CAIRO_H__ - -/* - * Helper functions to use cairo with inkscape - * - * Copyright (C) 2007 bulia byak - * Copyright (C) 2008 Johan Engelen - * - * Released under GNU GPL - * - */ - -#include <2geom/forward.h> -#include -#include -#include "libnr/nr-rect.h" - -struct NRPixBlock; -class SPCanvasBuf; - -cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb); -void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); -void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); - -void ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba); -void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m); -void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m); - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 8e1b659c7..84aa1c231 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -16,21 +16,19 @@ #ifdef HAVE_CONFIG_H # include #endif -#include -#include +#include "libnr/nr-blit.h" +#include "libnr/nr-convert2geom.h" #include <2geom/matrix.h> -#include "../style.h" -#include "nr-arena.h" -#include "nr-arena-glyphs.h" +#include "style.h" +#include "display/nr-arena.h" +#include "display/nr-arena-glyphs.h" #include -#include "inkscape-cairo.h" +#include "display/cairo-utils.h" #include "helper/geom.h" #ifdef test_glyph_liv #include "../display/canvas-bpath.h" -#include -#include -#include +#include "libnrtype/font-instance.h" // defined in nr-arena-shape.cpp void nr_pixblock_render_shape_mask_or(NRPixBlock &m, Shape *theS); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 6b71abaa0..ec0a2ab02 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -18,7 +18,7 @@ #include "../preferences.h" #include "nr-arena-image.h" #include "style.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include "display/nr-arena.h" #include "display/nr-filter.h" #include "display/nr-filter-gaussian.h" diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index f0a621bf0..de9a0c0fd 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -12,38 +12,31 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include +#include +#include + +#include <2geom/curves.h> +#include <2geom/pathvector.h> #include <2geom/svg-path.h> #include <2geom/svg-path-parser.h> -#include -#include -#include +#include "display/cairo-utils.h" +#include "display/canvas-arena.h" #include "display/curve.h" -#include -#include -#include -#include <2geom/pathvector.h> -#include <2geom/curves.h> -#include -#include -#include -#include -#include -#include "inkscape-cairo.h" -#include "helper/geom.h" +#include "display/nr-arena.h" +#include "display/nr-arena-shape.h" +#include "display/nr-filter.h" #include "helper/geom-curves.h" +#include "helper/geom.h" +#include "libnr/nr-blit.h" +#include "libnr/nr-convert2geom.h" +#include "libnr/nr-pixops.h" +#include "preferences.h" #include "sp-filter.h" #include "sp-filter-reference.h" -#include "display/nr-filter.h" -#include -#include -#include "preferences.h" - -#include +#include "style.h" #include "svg/svg.h" -#include - -//int showRuns=0; -void nr_pixblock_render_shape_mask_or(NRPixBlock &m,Shape* theS); static void nr_arena_shape_class_init(NRArenaShapeClass *klass); static void nr_arena_shape_init(NRArenaShape *shape); @@ -613,118 +606,6 @@ void NRArenaShape::setPaintBox(Geom::Rect const &pbox) nr_arena_item_request_update(this, NR_ARENA_ITEM_STATE_ALL, FALSE); } -static void -shape_run_A8_OR(raster_info &dest,void */*data*/,int st,float vst,int en,float ven) -{ - if ( st >= en ) return; - if ( vst < 0 ) vst=0; - if ( vst > 1 ) vst=1; - if ( ven < 0 ) ven=0; - if ( ven > 1 ) ven=1; - float sv=vst; - float dv=ven-vst; - int len=en-st; - unsigned char* d=(unsigned char*)dest.buffer; - d+=(st-dest.startPix); - if ( fabs(dv) < 0.001 ) { - if ( vst > 0.999 ) { - /* Simple copy */ - while (len > 0) { - d[0] = 255; - d += 1; - len -= 1; - } - } else { - sv*=256; - unsigned int c0_24=(int)sv; - c0_24&=0xFF; - while (len > 0) { - /* Draw */ - d[0] = NR_COMPOSEA_111(c0_24,d[0]); - d += 1; - len -= 1; - } - } - } else { - if ( en <= st+1 ) { - sv=0.5*(vst+ven); - sv*=256; - unsigned int c0_24=(int)sv; - c0_24&=0xFF; - /* Draw */ - d[0] = NR_COMPOSEA_111(c0_24,d[0]); - } else { - dv/=len; - sv+=0.5*dv; // correction trapezoidale - sv*=16777216; - dv*=16777216; - int c0_24 = static_cast(CLAMP(sv, 0, 16777216)); - int s0_24 = static_cast(dv); - while (len > 0) { - unsigned int ca; - /* Draw */ - ca = c0_24 >> 16; - if ( ca > 255 ) ca=255; - d[0] = NR_COMPOSEA_111(ca,d[0]); - d += 1; - c0_24 += s0_24; - c0_24 = CLAMP(c0_24, 0, 16777216); - len -= 1; - } - } - } -} - -void nr_pixblock_render_shape_mask_or(NRPixBlock &m,Shape* theS) -{ - theS->CalcBBox(); - float l = theS->leftX, r = theS->rightX, t = theS->topY, b = theS->bottomY; - int il,ir,it,ib; - il=(int)floor(l); - ir=(int)ceil(r); - it=(int)floor(t); - ib=(int)ceil(b); - - if ( il >= m.area.x1 || ir <= m.area.x0 || it >= m.area.y1 || ib <= m.area.y0 ) return; - if ( il < m.area.x0 ) il=m.area.x0; - if ( it < m.area.y0 ) it=m.area.y0; - if ( ir > m.area.x1 ) ir=m.area.x1; - if ( ib > m.area.y1 ) ib=m.area.y1; - - /* This is the FloatLigne version. See svn (prior to Apr 2006) for versions using BitLigne or direct BitLigne. */ - int curPt; - float curY; - theS->BeginQuickRaster(curY, curPt); - - FloatLigne *theI = new FloatLigne(); - IntLigne *theIL = new IntLigne(); - - theS->DirectQuickScan(curY, curPt, (float) it, true, 1.0); - - char *mdata = (char*)m.data.px; - if ( m.size == NR_PIXBLOCK_SIZE_TINY ) mdata=(char*)m.data.p; - uint32_t *ligStart = ((uint32_t*)(mdata + ((il - m.area.x0) + m.rs * (it - m.area.y0)))); - for (int y = it; y < ib; y++) { - theI->Reset(); - theS->QuickScan(curY, curPt, ((float)(y+1)), theI, 1.0); - theI->Flatten(); - theIL->Copy(theI); - - raster_info dest; - dest.startPix=il; - dest.endPix=ir; - dest.sth=il; - dest.stv=y; - dest.buffer=ligStart; - theIL->Raster(dest, NULL, shape_run_A8_OR); - ligStart=((uint32_t*)(((char*)ligStart)+m.rs)); - } - theS->EndQuickRaster(); - delete theI; - delete theIL; -} - - /* Local Variables: mode:c++ diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 7a0db664a..98b085333 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -18,8 +18,8 @@ #include #include #include "svg/svg.h" -#include "inkscape-cairo.h" -#include "nr-svgfonts.h" +#include "display/cairo-utils.h" +#include "display/nr-svgfonts.h" //*************************// // UserFont Implementation // diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index ed4c91d3b..37685c5da 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -13,7 +13,7 @@ #include "display-forward.h" #include "sodipodi-ctrl.h" #include "libnr/nr-pixops.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" enum { ARG_0, diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index 09bfde6fb..2ebf310c7 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -18,7 +18,7 @@ #include "display-forward.h" #include "sp-canvas-util.h" #include "sodipodi-ctrlrect.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" /* * Currently we do not have point method, as it should always be painted diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 31e80d1f9..571b573e1 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -42,7 +42,7 @@ #endif // ENABLE_LCMS #include "display/rendermode.h" #include "libnr/nr-blit.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" #include "sp-namedview.h" diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index 043736d94..7db029dd3 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -19,15 +19,15 @@ * */ -#include "display-forward.h" -#include "sp-canvas-util.h" -#include "sp-ctrlline.h" - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include "display/inkscape-cairo.h" + +#include "display/sp-ctrlline.h" +#include "display/display-forward.h" +#include "display/sp-canvas-util.h" +#include "display/cairo-utils.h" +#include "color.h" static void sp_ctrlline_class_init (SPCtrlLineClass *klass); diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp index 279d3f7f8..9f791676e 100644 --- a/src/display/sp-ctrlpoint.cpp +++ b/src/display/sp-ctrlpoint.cpp @@ -19,7 +19,7 @@ # include "config.h" #endif #include -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" static void sp_ctrlpoint_class_init (SPCtrlPointClass *klass); diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index b307684e5..4372f871c 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -11,14 +11,14 @@ * Released under GNU GPL */ -#include "display-forward.h" -#include "sp-canvas-util.h" -#include "sp-ctrlquadr.h" - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "display/inkscape-cairo.h" + +#include "display-forward.h" +#include "sp-canvas-util.h" +#include "sp-ctrlquadr.h" +#include "display/cairo-utils.h" #include "color.h" struct SPCtrlQuadr : public SPCanvasItem{ diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index cf3c72432..8b40f60b4 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -37,7 +37,7 @@ #include "display/nr-arena-group.h" #include "display/curve.h" #include "display/canvas-bpath.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include "sp-item.h" #include "sp-item-group.h" #include "style.h" diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index f63436e71..ba15f2651 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -31,7 +31,7 @@ #include #include -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include "libnr/nr-gradient.h" #include "libnr/nr-pixops.h" #include "svg/svg.h" diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 8d1e8dab5..5f0c4aebd 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -23,7 +23,7 @@ #include <2geom/transforms.h> #include "macros.h" #include "svg/svg.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include "display/nr-arena.h" #include "display/nr-arena-group.h" #include "attributes.h" diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 9a46254ab..c7ed9f92b 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -38,7 +38,7 @@ extern "C" { // takes doc, root, icon, and icon name to produce pixels guchar * sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, - const gchar *name, unsigned int psize ); + const gchar *name, unsigned int psize, unsigned &stride); } namespace Inkscape { @@ -159,10 +159,11 @@ IconPreviewPanel::IconPreviewPanel() : int previous = 0; int avail = 0; for ( int i = numEntries - 1; i >= 0; --i ) { - pixMem[i] = new guchar[4 * sizes[i] * sizes[i]]; - memset( pixMem[i], 0x00, 4 * sizes[i] * sizes[i] ); + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, sizes[i]); + pixMem[i] = new guchar[sizes[i] * stride]; + memset( pixMem[i], 0x00, sizes[i] * stride ); - GdkPixbuf *pb = gdk_pixbuf_new_from_data( pixMem[i], GDK_COLORSPACE_RGB, TRUE, 8, sizes[i], sizes[i], sizes[i] * 4, /*(GdkPixbufDestroyNotify)g_free*/NULL, NULL ); + GdkPixbuf *pb = gdk_pixbuf_new_from_data( pixMem[i], GDK_COLORSPACE_RGB, TRUE, 8, sizes[i], sizes[i], stride, /*(GdkPixbufDestroyNotify)g_free*/NULL, NULL ); GtkImage* img = GTK_IMAGE( gtk_image_new_from_pixbuf( pb ) ); images[i] = Glib::wrap(img); Glib::ustring label(*labels[i]); @@ -384,14 +385,16 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) arena, visionkey, SP_ITEM_SHOW_DISPLAY ); for ( int i = 0; i < numEntries; i++ ) { - guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i] ); + unsigned unused; + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, sizes[i]); + guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i], unused); // g_message( " size %d %s", sizes[i], (px ? "worked" : "failed") ); if ( px ) { - memcpy( pixMem[i], px, sizes[i] * sizes[i] * 4 ); + memcpy( pixMem[i], px, sizes[i] * stride ); g_free( px ); px = 0; } else { - memset( pixMem[i], 0, sizes[i] * sizes[i] * 4 ); + memset( pixMem[i], 0, sizes[i] * stride ); } images[i]->queue_draw(); } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 51bdfef66..1eb3ef0ab 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -25,6 +25,7 @@ #include "inkscape.h" #include "document.h" #include "sp-item.h" +#include "display/cairo-utils.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "io/sys.h" @@ -909,11 +910,11 @@ GdkPixbuf *sp_icon_image_load_pixmap(gchar const *name, unsigned /*lsize*/, unsi // takes doc, root, icon, and icon name to produce pixels extern "C" guchar * sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, - gchar const *name, unsigned psize ) + gchar const *name, unsigned psize, + unsigned &stride) { bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg"); guchar *px = NULL; - int w, h, stride; if (doc) { SPObject *object = doc->getObjectById(name); @@ -1012,25 +1013,23 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.x0, (double)ua.y0, (double)ua.x1, (double)ua.y1 ); } - w = ua.x1 - ua.x0; - h = ua.y1 - ua.y0; - stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); + stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, psize); /* Set up pixblock */ - px = g_new(guchar, stride * h); - memset(px, 0x00, stride * h); + px = g_new(guchar, stride * psize); + memset(px, 0x00, stride * psize); /* Render */ cairo_surface_t *s = cairo_image_surface_create_for_data(px, - CAIRO_FORMAT_ARGB32, w, h, stride); + CAIRO_FORMAT_ARGB32, psize, psize, stride); cairo_t *ct = cairo_create(s); NRPixBlock B; nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, ua.x0, ua.y0, ua.x1, ua.y1, - px + 4 * psize * (ua.y0 - area.y0) + + px + stride * (ua.y0 - area.y0) + 4 * (ua.x0 - area.x0), - 4 * psize, FALSE, FALSE ); + stride, FALSE, FALSE ); nr_arena_item_invoke_render(ct, root, &ua, &B, NR_ARENA_ITEM_RENDER_NO_CACHE ); nr_pixblock_release(&B); @@ -1038,35 +1037,10 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, cairo_surface_destroy(s); // convert to GdkPixbuf format - guint32 *ipx = reinterpret_cast(px); - for (int i = 0; i < h; ++i) { - for (int j = 0; j < w; ++j) { - int index = i * stride / 4 + j; - guint32 c = ipx[index]; - guint32 o = 0; - guint32 a = (c & 0xff000000) >> 24; - if (a != 0) { - // extract color components - guint32 r = (c & 0x00ff0000) >> 16; - guint32 g = (c & 0x0000ff00) >> 8; - guint32 b = (c & 0x000000ff); - // unpremultiply; adding a/2 gives correct rounding - r = (r * 255 + a/2) / a; - b = (b * 255 + a/2) / a; - g = (g * 255 + a/2) / a; - // combine into output -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - o = (r) | (g << 8) | (b << 16) | (a << 24); -#else - o = (r << 24) | (g << 16) | (b << 8) | (a); -#endif - } - ipx[index] = o; - } - } + convert_pixels_argb32_to_pixbuf(px, psize, psize, stride); if ( Inkscape::Preferences::get()->getBool("/debug/icons/overlaySvg") ) { - sp_icon_overlay_pixels( px, psize, psize, 4 * psize, 0x00, 0x00, 0xff ); + sp_icon_overlay_pixels( px, psize, psize, stride, 0x00, 0x00, 0xff ); } } } @@ -1119,8 +1093,7 @@ static std::list &icons_svg_paths() } // this function renders icons from icons.svg and returns the pixels. -static guchar *load_svg_pixels(gchar const *name, - unsigned /*lsize*/, unsigned psize) +static guchar *load_svg_pixels(gchar const *name, unsigned psize, unsigned &stride) { SPDocument *doc = NULL; NRArenaItem *root = NULL; @@ -1197,7 +1170,7 @@ static guchar *load_svg_pixels(gchar const *name, continue; } - px = sp_icon_doc_icon( doc, root, name, psize ); + px = sp_icon_doc_icon( doc, root, name, psize, stride); // if (px) { // g_message("Found icon %s in %s", name, doc_filename); // } @@ -1251,19 +1224,20 @@ bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize) if (dump) { g_message("prerender_icon [%s] %d:%d", name, lsize, psize); } - guchar* px = load_svg_pixels(name, lsize, psize); + unsigned stride; + guchar* px = load_svg_pixels(name, psize, stride); if ( !px ) { // check for a fallback name if ( legacyNames.find(name) != legacyNames.end() ) { if ( dump ) { g_message("load_svg_pixels([%s]=%s, %d, %d)", name, legacyNames[name].c_str(), lsize, psize); } - px = load_svg_pixels(legacyNames[name].c_str(), lsize, psize); + px = load_svg_pixels(legacyNames[name].c_str(), psize, stride); } } if (px) { GdkPixbuf* pb = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, TRUE, 8, - psize, psize, psize * 4, + psize, psize, stride, reinterpret_cast(g_free), NULL ); pb_cache[key] = pb; addToIconSet(pb, name, lsize, psize); @@ -1289,10 +1263,11 @@ static GdkPixbuf *sp_icon_image_load_svg(gchar const *name, GtkIconSize lsize, u // did we already load this icon at this scale/size? GdkPixbuf* pb = get_cached_pixbuf(key); if (!pb) { - guchar *px = load_svg_pixels(name, lsize, psize); + unsigned stride; + guchar *px = load_svg_pixels(name, psize, stride); if (px) { pb = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB, TRUE, 8, - psize, psize, psize * 4, + psize, psize, stride, (GdkPixbufDestroyNotify)g_free, NULL); pb_cache[key] = pb; addToIconSet(pb, name, lsize, psize); -- cgit v1.2.3 From c64911a3ecd14e5eb1a0ddcd338cd8bb2bc01ce7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 30 Jun 2010 01:42:53 +0200 Subject: Fix PNG export (bzr r9508.1.9) --- src/helper/png-write.cpp | 70 +++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b1c135db0..908b1fb20 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -16,22 +16,23 @@ # include "config.h" #endif -#include -#include -#include +#include "interface.h" +#include "libnr/nr-pixops.h" +#include "libnr/nr-translate-scale-ops.h" #include <2geom/rect.h> #include #include #include "png-write.h" #include "io/sys.h" -#include -#include -#include -#include -#include -#include +#include "display/nr-arena-item.h" +#include "display/nr-arena.h" +#include "document.h" +#include "sp-item.h" +#include "sp-root.h" +#include "sp-defs.h" #include "preferences.h" #include "rdf.h" +#include "display/cairo-utils.h" /* This is an example of how to use libpng to read and write PNG files. * The file libpng.txt is much more verbose then this. If you have not @@ -49,7 +50,7 @@ static unsigned int const MAX_STRIPE_SIZE = 1024*1024; struct SPEBP { unsigned long int width, height, sheight; - guchar r, g, b, a; + guint32 background; NRArenaItem *root; // the root arena item to show; it is assumed that all unneeded items are hidden guchar *px; unsigned (*status)(float, void *); @@ -122,7 +123,7 @@ void PngTextList::add(gchar const* key, gchar const* text) static bool sp_png_write_rgba_striped(SPDocument *doc, gchar const *filename, unsigned long int width, unsigned long int height, double xdpi, double ydpi, - int (* get_rows)(guchar const **rows, int row, int num_rows, void *data), + int (* get_rows)(guchar const **rows, void **to_free, int row, int num_rows, void *data), void *data) { struct SPEBP *ebp = (struct SPEBP *) data; @@ -272,10 +273,12 @@ sp_png_write_rgba_striped(SPDocument *doc, png_bytep* row_pointers = new png_bytep[ebp->sheight]; r = 0; - while (r < static_cast< png_uint_32 > (height) ) { - int n = get_rows((unsigned char const **) row_pointers, r, height-r, data); + while (r < static_cast(height)) { + void *to_free; + int n = get_rows((unsigned char const **) row_pointers, &to_free, r, height-r, data); if (!n) break; png_write_rows(png_ptr, row_pointers, n); + g_free(to_free); r += n; } @@ -305,7 +308,7 @@ sp_png_write_rgba_striped(SPDocument *doc, * */ static int -sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data) +sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, void *data) { struct SPEBP *ebp = (struct SPEBP *) data; @@ -332,26 +335,36 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data) nr_arena_item_invoke_update(ebp->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ebp->width); + unsigned char *px = g_new(guchar, num_rows * stride); + + cairo_surface_t *s = cairo_image_surface_create_for_data( + px, CAIRO_FORMAT_ARGB32, ebp->width, num_rows, stride); + cairo_t *ct = cairo_create(s); + ink_cairo_set_source_rgba32(ct, ebp->background); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_OVER); + NRPixBlock pb; nr_pixblock_setup_extern(&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, ebp->px, 4 * ebp->width, FALSE, FALSE); - for (int r = 0; r < num_rows; r++) { - guchar *p = NR_PIXBLOCK_PX(&pb) + r * pb.rs; - for (int c = 0; c < static_cast(ebp->width); c++) { - *p++ = ebp->r; - *p++ = ebp->g; - *p++ = ebp->b; - *p++ = ebp->a; - } - } - /* Render */ - nr_arena_item_invoke_render(NULL, ebp->root, &bbox, &pb, 0); + nr_arena_item_invoke_render(ct, ebp->root, &bbox, &pb, 0); + + cairo_destroy(ct); + cairo_surface_destroy(s); + + *to_free = px; + + // PNG stores data as unpremultiplied big-endian RGBA, which means + // it's identical to the GdkPixbuf format. + convert_pixels_argb32_to_pixbuf(px, ebp->width, num_rows, stride); for (int r = 0; r < num_rows; r++) { - rows[r] = NR_PIXBLOCK_PX(&pb) + r * pb.rs; + rows[r] = px + r * stride; } nr_pixblock_release(&pb); @@ -452,10 +465,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, struct SPEBP ebp; ebp.width = width; ebp.height = height; - ebp.r = NR_RGBA32_R(bgcolor); - ebp.g = NR_RGBA32_G(bgcolor); - ebp.b = NR_RGBA32_B(bgcolor); - ebp.a = NR_RGBA32_A(bgcolor); + ebp.background = bgcolor; /* Create new arena */ NRArena *const arena = NRArena::create(); -- cgit v1.2.3 From e83b5a202a9e028e3407123cddafa06510756b66 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 4 Jul 2010 02:56:02 +0200 Subject: Remove some cruft (bzr r9508.1.10) --- src/display/canvas-arena.cpp | 12 +---------- src/display/nr-arena-glyphs.cpp | 6 ++++-- src/display/nr-arena-image.cpp | 4 +--- src/display/nr-arena-item.cpp | 1 + src/display/nr-arena-item.h | 45 +++++++++++++++-------------------------- src/display/nr-arena-shape.cpp | 7 ++----- src/display/nr-arena-shape.h | 2 -- src/display/sp-canvas-util.cpp | 4 ++-- src/display/sp-canvas.cpp | 11 +++------- 9 files changed, 30 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 086c0a27d..db8e1757c 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -203,7 +203,6 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) if ((bw < 1) || (bh < 1)) return; NRRectL area; - NRPixBlock cb; area.x0 = buf->rect.x0; area.y0 = buf->rect.y0; @@ -212,16 +211,7 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) sp_canvas_prepare_buffer(buf); - nr_pixblock_setup_extern (&cb, NR_PIXBLOCK_MODE_R8G8B8A8P, area.x0, area.y0, area.x1, area.y1, - buf->buf, - buf->buf_rowstride, - FALSE, FALSE); - - cb.visible_area = buf->visible_rect; - - nr_arena_item_invoke_render (buf->ct, arena->root, &area, &cb, 0); - - nr_pixblock_release (&cb); + nr_arena_item_invoke_render (buf->ct, arena->root, &area, NULL, 0); } static double diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 84aa1c231..ad3006950 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -304,6 +304,9 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode + NRRect temp(area->x0, area->y0, area->x1, area->y1); + Geom::OptRect area_2geom = temp.upgrade_2geom(); + for (child = group->children; child != NULL; child = child->next) { NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); @@ -311,9 +314,8 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi cairo_new_path(ct); Geom::Matrix transform = g->g_transform * group->ctm; - feed_pathvector_to_cairo (ct, *pathv, transform, to_2geom((pb->area).upgrade()), false, 0); + feed_pathvector_to_cairo (ct, *pathv, transform, area_2geom, false, 0); cairo_fill(ct); - pb->empty = FALSE; } return item->state; diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index ec0a2ab02..9f883a77c 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -210,7 +210,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_set_line_width(ct, 0.5); cairo_new_path(ct); - Geom::Point shift(pb->area.x0, pb->area.y0); + Geom::Point shift(area->x0, area->y0); Geom::Point c00 = image->c00 - shift; Geom::Point c01 = image->c01 - shift; Geom::Point c11 = image->c11 - shift; @@ -229,8 +229,6 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_line_to (ct, c01[Geom::X], c01[Geom::Y]); cairo_stroke(ct); - - pb->empty = FALSE; } return item->state; } diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index ca9528f16..08fbe1f1c 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -85,6 +85,7 @@ nr_arena_item_init (NRArenaItem *item) memset (&item->bbox, 0, sizeof (item->bbox)); memset (&item->drawbox, 0, sizeof (item->drawbox)); item->transform = NULL; + item->ctm.setIdentity(); item->opacity = 255; item->render_opacity = FALSE; diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 035013cd8..468d352bc 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -84,35 +84,22 @@ struct NRArenaItem : public NRObject { /* Opacity itself */ unsigned int opacity : 8; - /* Key for secondary rendering */ - unsigned int key; - - /* BBox in grid coordinates */ - NRRectL bbox; - /* Redraw area in grid coordinates = bbox filter-enlarged and clipped/masked */ - NRRectL drawbox; - /* BBox in item coordinates - this should be a bounding box as - * specified in SVG standard. Required by filters. */ - Geom::OptRect item_bbox; - /* Our affine */ - Geom::Matrix *transform; - /* Clip item */ - NRArenaItem *clip; - /* Mask item */ - NRArenaItem *mask; - /* Filter to be applied after rendering this object, NULL if none */ - Inkscape::Filters::Filter *filter; - /* Rendered buffer */ - unsigned char *px; - - /* Single data member */ - void *data; - - /* Current Transformation Matrix */ - Geom::Matrix ctm; - - /* These hold background buffer state for filter rendering */ - NRPixBlock *background_pb; + unsigned int key; ///< Some SPItems can have more than one NRArenaItem, + ///this value is a hack used to distinguish between them + + NRRectL bbox; ///< Bounding box in pixel grid coordinates; (0,0) is at page origin + NRRectL drawbox; ///< Bounding box enlarged by filters, shrinked by clips and masks + Geom::OptRect item_bbox; ///< Bounding box in item coordinates, required by filters + Geom::Matrix *transform; ///< Incremental transform of this item, as given by the transform= attribute + Geom::Matrix ctm; ///< Total transform from pixel grid to item coords + NRArenaItem *clip; ///< Clipping path + NRArenaItem *mask; ///< Mask + Inkscape::Filters::Filter *filter; ///< Filter + unsigned char *px; ///< Render cache; unused + + void *data; ///< Anonymous data member - this is used to associate SPItems with arena items + + NRPixBlock *background_pb; ///< Background for filters; unused bool background_new; void init(NRArena *arena) { diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index de9a0c0fd..3f673c944 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -104,7 +104,6 @@ nr_arena_shape_init(NRArenaShape *shape) shape->style = NULL; shape->paintbox.x0 = shape->paintbox.y0 = 0.0F; shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; - shape->ctm.setIdentity(); shape->delayed_shp = false; shape->path = NULL; @@ -223,7 +222,6 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (!(state & NR_ARENA_ITEM_STATE_RENDER)) { /* We do not have to create rendering structures */ - shape->ctm = gc->transform; if (state & NR_ARENA_ITEM_STATE_BBOX) { if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); @@ -246,7 +244,6 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g } shape->delayed_shp=true; - shape->ctm = gc->transform; boundingbox = Geom::OptRect(); bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); @@ -358,8 +355,8 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (outline) { // cairo outline rendering - pb->empty = FALSE; - unsigned int ret = cairo_arena_shape_render_outline (ct, item, to_2geom((&pb->area)->upgrade())); + NRRect temp(area->x0, area->y0, area->x1, area->y1); + unsigned int ret = cairo_arena_shape_render_outline (ct, item, temp.upgrade_2geom()); if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; } else { diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index 66c8bc344..2e917bb46 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -31,8 +31,6 @@ struct NRArenaShape : public NRArenaItem { SPStyle *style; NRStyle nrstyle; NRRect paintbox; - /* State data */ - Geom::Matrix ctm; cairo_path_t *path; diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index 970fea0e5..83604a1bf 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -42,13 +42,13 @@ sp_canvas_item_reset_bounds (SPCanvasItem *item) void sp_canvas_prepare_buffer (SPCanvasBuf *buf) { - if (buf->is_empty) { + /*if (buf->is_empty) { int y; for (y = buf->rect.y0; y < buf->rect.y1; y++) { memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, 0, 4 * (buf->rect.x1 - buf->rect.x0)); } buf->is_empty = false; - } + }*/ } Geom::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 571b573e1..4c74af6d9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1630,17 +1630,12 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, { GtkWidget *widget = GTK_WIDGET (canvas); - SPCanvasBuf buf; - if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { - buf.buf = nr_pixelstore_256K_new (FALSE, 0); - } else { - buf.buf = nr_pixelstore_1M_new (FALSE, 0); - } - // Mark the region clean sp_canvas_mark_rect(canvas, x0, y0, x1, y1, 0); - buf.buf_rowstride = sw * 4; + SPCanvasBuf buf; + buf.buf = NULL; + buf.buf_rowstride = 0; buf.rect.x0 = x0; buf.rect.y0 = y0; buf.rect.x1 = x1; -- cgit v1.2.3 From b986b0fb26a23899a51e564ef07880a0166680cc Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 7 Jul 2010 18:41:53 +0200 Subject: Smaller intermediate rendering regions (bzr r9508.1.11) --- src/display/cairo-utils.cpp | 2 +- src/display/nr-arena-image.cpp | 4 +-- src/display/nr-arena-item.cpp | 61 ++++++++++++++++++++++++++++++++---------- src/display/nr-filter.cpp | 2 +- src/display/nr-filter.h | 3 ++- 5 files changed, 52 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 7bfdd7dd7..8aaf838ed 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -413,7 +413,7 @@ convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int stride) * using it with GTK will result in corrupted drawings. */ void -convert_pixbuf_normal_to_argb32_mutant(GdkPixbuf *pb) +convert_pixbuf_normal_to_argb32(GdkPixbuf *pb) { convert_pixels_pixbuf_to_argb32( gdk_pixbuf_get_pixels(pb), diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 9f883a77c..f198b176b 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -203,9 +203,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } else { // outline; draw a rect instead Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); - // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat - // by setting color channels in the "wrong" order - cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); + ink_cairo_set_source_rgba32(ct, rgba); cairo_set_line_width(ct, 0.5); cairo_new_path(ct); diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 08fbe1f1c..338940fb6 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -335,6 +335,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area if (!item->visible) return item->state | NR_ARENA_ITEM_STATE_RENDER; + // carea is the bounding box for intermediate rendering. NRRectL carea; nr_rect_l_intersect (&carea, area, &item->drawbox); if (nr_rect_l_test_empty(carea)) @@ -564,27 +565,46 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // clipping and masks unsigned int state; - Cairo::Context cct(ct); + + cairo_t *this_ct = ct; + NRRectL *this_area = const_cast(area); + + bool needs_intermediate_rendering = false; + bool &nir = needs_intermediate_rendering; + + // this item needs an intermediate rendering if: + nir |= (item->mask != NULL); // 1. it has a mask + nir |= (item->filter != NULL && filter); // 2. it has a filter + + if (needs_intermediate_rendering) { + cairo_surface_t *intermediate = cairo_surface_create_similar( + cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, + carea.x1 - carea.x0, carea.y1 - carea.y0); + this_ct = cairo_create(intermediate); + this_area = &carea; + cairo_surface_destroy(intermediate); // the surface will be held in memory by this_ct + } + + Cairo::Context cct(this_ct); Cairo::RefPtr mask; - CairoSave clipsave(ct); // RAII for save / restore - CairoGroup maskgroup(ct); // RAII for push_group / pop_group - CairoGroup drawgroup(ct); + CairoSave clipsave(this_ct); // RAII for save / restore + CairoGroup maskgroup(this_ct); // RAII for push_group / pop_group + CairoGroup drawgroup(this_ct); - if (item->clip) { + if (item->clip && !(item->filter && filter)) { clipsave.save(); - state = nr_arena_item_invoke_clip(ct, item->clip, const_cast(area)); + state = nr_arena_item_invoke_clip(this_ct, item->clip, this_area); if (state & NR_ARENA_ITEM_STATE_INVALID) { item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } - cct.clip(); } if (item->mask) { maskgroup.push_with_content(CAIRO_CONTENT_ALPHA); - state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, const_cast(area), pb, flags); + state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (this_ct, item->mask, this_area, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; @@ -592,18 +612,31 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area mask = maskgroup.popmm(); } - if (mask) { + /*if (mask) { drawgroup.push(); - } - state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, const_cast(area), pb, flags); + }*/ + state = NR_ARENA_ITEM_VIRTUAL (item, render) (this_ct, item, this_area, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { /* Clean up and return error */ item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } - if (mask) { - drawgroup.pop_to_source(); - cct.mask(mask); + if (needs_intermediate_rendering) { + cairo_surface_t *intermediate = cairo_get_target(this_ct); + cairo_set_source_surface(ct, intermediate, carea.x0 - area->x0, carea.y0 - area->y0); + if (mask) { + // bring mask into the coordinate system of ct + cairo_pattern_t *cmask = mask->cobj(); + cairo_matrix_t m; + cairo_pattern_get_matrix(cmask, &m); + cairo_matrix_translate(&m, area->x0 - carea.x0, area->y0 - carea.y0); + cairo_pattern_set_matrix(cmask, &m); + cairo_mask(ct, cmask); + } else { + cairo_paint(ct); + } + cairo_set_source_rgba(ct,0,0,0,0); + cairo_destroy(this_ct); } return item->state | NR_ARENA_ITEM_STATE_RENDER; diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 3b19ff69b..24079be4e 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -129,7 +129,7 @@ Filter::~Filter() } -int Filter::render(NRArenaItem const *item, NRPixBlock *pb) +int Filter::render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct) { if (!_primitive[0]) { // TODO: Should clear the input buffer instead of just returning diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 318e1030f..08d0254d1 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -13,6 +13,7 @@ */ //#include "display/nr-arena-item.h" +#include #include "display/nr-filter-primitive.h" #include "display/nr-filter-types.h" #include "libnr/nr-pixblock.h" @@ -29,7 +30,7 @@ namespace Filters { class Filter : public Inkscape::GC::Managed<> { public: - int render(NRArenaItem const *item, NRPixBlock *pb); + int render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct); /** * Creates a new filter primitive under this filter object. -- cgit v1.2.3 From 2f5eafec8d66d018d760b85a829c1d4ba1b0ed6d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 7 Jul 2010 19:21:03 +0200 Subject: Switch to nearest neighbor filtering when image is larger than original (bzr r9508.1.12) --- src/display/cairo-utils.cpp | 14 ++++++++++++++ src/display/cairo-utils.h | 1 + src/display/nr-arena-image.cpp | 5 +++++ 3 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 8aaf838ed..bb401dc87 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -315,6 +315,20 @@ ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m) cairo_pattern_set_matrix(cp, &cm); } +void +ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double y) +{ + guchar *data = gdk_pixbuf_get_pixels(pb); + int w = gdk_pixbuf_get_width(pb); + int h = gdk_pixbuf_get_height(pb); + int stride = gdk_pixbuf_get_rowstride(pb); + + cairo_surface_t *pbs = cairo_image_surface_create_for_data( + data, CAIRO_FORMAT_ARGB32, w, h, stride); + cairo_set_source_surface(ct, pbs, x, y); + cairo_surface_destroy(pbs); +} + // taken from Cairo sources static inline guint32 premul_alpha(guint32 color, guint32 alpha) { diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 882742d5f..096dc6046 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -82,6 +82,7 @@ void ink_cairo_set_source_color(cairo_t *ct, SPColor const &color, double opacit void ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba); void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m); void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m); +void ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double y); void convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int rs); void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index f198b176b..325cff65a 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -197,6 +197,11 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_pattern_t *p = cairo_get_source(ct); ink_cairo_pattern_set_matrix(p, image->grid2px); + Geom::Matrix total = item->ctm * image->grid2px.inverse(); + if (total.expansionX() > 1.0 || total.expansionY() > 1.0) { + cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST); + } + cairo_paint_with_alpha(ct, ((double) item->opacity) / 255.0); cairo_restore(ct); -- cgit v1.2.3 From b80e2b5bb72ebb814745bd58ccf10bfa617dd7e9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 7 Jul 2010 20:08:47 +0200 Subject: Fix group opacity (bzr r9508.1.13) --- src/display/nr-arena-glyphs.cpp | 10 ---------- src/display/nr-arena-item.cpp | 23 +++++++++++++++++++++-- src/display/nr-arena-shape.cpp | 10 ---------- src/display/nr-style.cpp | 2 -- src/display/nr-style.h | 1 - 5 files changed, 21 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index ad3006950..faf10bd38 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -322,7 +322,6 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi } // NOTE: this is very similar to nr-arena-shape.cpp; the only difference is path feeding - bool needs_opacity = ((1.0 - ggroup->nrstyle.opacity) >= 0.01); bool has_stroke, has_fill; cairo_save(ct); @@ -333,10 +332,6 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi has_stroke = ggroup->nrstyle.prepareStroke(ct, &ggroup->paintbox); if (has_fill || has_stroke) { - if (needs_opacity) { - cairo_push_group(ct); - } - for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); @@ -356,11 +351,6 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi cairo_stroke_preserve(ct); } cairo_new_path(ct); // clear path - - if (needs_opacity) { - cairo_pop_group_to_source(ct); - cairo_paint_with_alpha(ct, ggroup->nrstyle.opacity); - } } // has fill or stroke pattern cairo_restore(ct); diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 338940fb6..f5731c0e3 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -571,10 +571,14 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area bool needs_intermediate_rendering = false; bool &nir = needs_intermediate_rendering; + bool needs_opacity = (item->opacity != 255); // this item needs an intermediate rendering if: nir |= (item->mask != NULL); // 1. it has a mask nir |= (item->filter != NULL && filter); // 2. it has a filter + nir |= needs_opacity; // 3. it is non-opaque + + double opacity = static_cast(item->opacity) / 255.0; if (needs_intermediate_rendering) { cairo_surface_t *intermediate = cairo_surface_create_similar( @@ -590,6 +594,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area CairoSave clipsave(this_ct); // RAII for save / restore CairoGroup maskgroup(this_ct); // RAII for push_group / pop_group CairoGroup drawgroup(this_ct); + CairoGroup maskopacitygroup(this_ct); if (item->clip && !(item->filter && filter)) { clipsave.save(); @@ -603,12 +608,20 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area if (item->mask) { maskgroup.push_with_content(CAIRO_CONTENT_ALPHA); - + // handle opacity of a masked object by composing it with the mask + // this uses 1/4 the memory of composing it with full rendering + if (needs_opacity) { + maskopacitygroup.push(); + } state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (this_ct, item->mask, this_area, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } + if (needs_opacity) { + maskopacitygroup.pop_to_source(); + cct.paint_with_alpha(opacity); + } mask = maskgroup.popmm(); } @@ -632,8 +645,14 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area cairo_matrix_translate(&m, area->x0 - carea.x0, area->y0 - carea.y0); cairo_pattern_set_matrix(cmask, &m); cairo_mask(ct, cmask); + // opacity of masked objects is handled by premultiplying the mask } else { - cairo_paint(ct); + // opacity of non-masked objects must be rendered explicitly + if (needs_opacity) { + cairo_paint_with_alpha(ct, opacity); + } else { + cairo_paint(ct); + } } cairo_set_source_rgba(ct,0,0,0,0); cairo_destroy(this_ct); diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 3f673c944..b51f3a9cf 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -360,7 +360,6 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; } else { - bool needs_opacity = ((1.0 - shape->nrstyle.opacity) >= 0.01); bool has_stroke, has_fill; // we assume the context has no path cairo_save(ct); @@ -374,10 +373,6 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock has_stroke = shape->nrstyle.prepareStroke(ct, &shape->paintbox); if (has_fill || has_stroke) { - if (needs_opacity) { - cairo_push_group(ct); - } - // TODO: remove segments outside of bbox when no dashes present feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); if (has_fill) { @@ -389,11 +384,6 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_stroke_preserve(ct); } cairo_new_path(ct); // clear path - - if (needs_opacity) { - cairo_pop_group_to_source(ct); - cairo_paint_with_alpha(ct, shape->nrstyle.opacity); - } } // has fill or stroke pattern cairo_restore(ct); } diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index c15dd78a3..bf2f2d305 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -137,8 +137,6 @@ void NRStyle::set(SPStyle *style) dash = NULL; } - opacity = SP_SCALE24_TO_FLOAT(style->opacity.value); - update(); } diff --git a/src/display/nr-style.h b/src/display/nr-style.h index b2116a6c5..e741e46b4 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -55,7 +55,6 @@ struct NRStyle { Paint stroke; float stroke_width; float miter_limit; - float opacity; unsigned int n_dash; double *dash; float dash_offset; -- cgit v1.2.3 From a7a57737691a21d824fcdf5641046cb0187580fd Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 7 Jul 2010 20:49:40 +0200 Subject: Grid rendering (bzr r9508.1.14) --- src/display/canvas-axonomgrid.cpp | 99 +++++++++---------------- src/display/canvas-grid.cpp | 149 ++++++++++++++++++++++---------------- 2 files changed, 121 insertions(+), 127 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 37469fa73..1383f7f4e 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -17,26 +17,24 @@ * For example: the line drawing code should not be here. There _must_ be a function somewhere else that can provide this functionality... */ -#include "sp-canvas-util.h" -#include "canvas-axonomgrid.h" -#include "util/mathfns.h" #include "2geom/line.h" -#include "display-forward.h" -#include - -#include "canvas-grid.h" +#include "desktop.h" #include "desktop-handles.h" +#include "display/cairo-utils.h" +#include "display/canvas-axonomgrid.h" +#include "display/canvas-grid.h" +#include "display/display-forward.h" +#include "display/sp-canvas-util.h" +#include "document.h" #include "helper/units.h" -#include "svg/svg-color.h" -#include "xml/node-event-vector.h" -#include "sp-object.h" - -#include "sp-namedview.h" #include "inkscape.h" -#include "desktop.h" - -#include "document.h" +#include "libnr/nr-pixops.h" #include "preferences.h" +#include "sp-namedview.h" +#include "sp-object.h" +#include "svg/svg-color.h" +#include "util/mathfns.h" +#include "xml/node-event-vector.h" #define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params @@ -48,37 +46,6 @@ enum Dim3 { X=0, Y, Z }; static double deg_to_rad(double deg) { return deg*M_PI/180.0;} - -/** - \brief This function renders a pixel on a particular buffer. - - The topleft of the buffer equals - ( rect.x0 , rect.y0 ) in screen coordinates - ( 0 , 0 ) in setpixel coordinates - The bottomright of the buffer equals - ( rect.x1 , rect,y1 ) in screen coordinates - ( rect.x1 - rect.x0 , rect.y1 - rect.y0 ) in setpixel coordinates -*/ -static void -sp_caxonomgrid_setpixel (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) -{ -#ifdef SAFE_SETPIXEL - if ( (x >= buf->rect.x0) && (x < buf->rect.x1) && (y >= buf->rect.y0) && (y < buf->rect.y1) ) { -#endif - guint r, g, b, a; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - guchar * p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); -#ifdef SAFE_SETPIXEL - } -#endif -} - /** \brief This function renders a line on a particular canvas buffer, using Bresenham's line drawing function. @@ -88,6 +55,12 @@ sp_caxonomgrid_setpixel (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) static void sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba) { + cairo_move_to(buf->ct, 0.5 + x0, 0.5 + y0); + cairo_line_to(buf->ct, 0.5 + x1, 0.5 + y1); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_stroke(buf->ct); + +#if 0 int dy = y1 - y0; int dx = x1 - x0; int stepx, stepy; @@ -121,30 +94,19 @@ sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, g sp_caxonomgrid_setpixel(buf, x0, y0, rgba); } } - +#endif } static void sp_grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) { - if ((x >= buf->rect.x0) && (x < buf->rect.x1)) { - guint r, g, b, a; - gint y0, y1, y; - guchar *p; - r = NR_RGBA32_R(rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - y0 = MAX (buf->rect.y0, ys); - y1 = MIN (buf->rect.y1, ye + 1); - p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - for (y = y0; y < y1; y++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += buf->buf_rowstride; - } - } + if ((x < buf->rect.x0) || (x >= buf->rect.x1)) + return; + + cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys); + cairo_line_to(buf->ct, 0.5 + x, 0.5 + ye); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_stroke(buf->ct); } namespace Inkscape { @@ -564,6 +526,11 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) _empcolor = empcolor; } + cairo_save(buf->ct); + cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_set_line_width(buf->ct, 1.0); + cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); + // gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'. // sc = screencoordinates ( for example "buf->rect.x0" is in screencoordinates ) // bc = buffer patch coordinates @@ -661,6 +628,8 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor); } } + + cairo_restore(buf->ct); } CanvasAxonomGridSnapper::CanvasAxonomGridSnapper(CanvasAxonomGrid *grid, SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d) diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index a79a6b610..5dae228b4 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -13,25 +13,23 @@ #define INKSCAPE_CANVAS_GRID_C -#include "sp-canvas-util.h" -#include "util/mathfns.h" -#include "display-forward.h" -#include +#include "desktop.h" #include "desktop-handles.h" +#include "display/cairo-utils.h" +#include "display/canvas-axonomgrid.h" +#include "display/canvas-grid.h" +#include "display/display-forward.h" +#include "display/sp-canvas-util.h" +#include "document.h" #include "helper/units.h" -#include "svg/svg-color.h" -#include "xml/node-event-vector.h" -#include "sp-object.h" - -#include "sp-namedview.h" #include "inkscape.h" -#include "desktop.h" - -#include "../document.h" +#include "libnr/nr-pixops.h" #include "preferences.h" - -#include "canvas-grid.h" -#include "canvas-axonomgrid.h" +#include "sp-namedview.h" +#include "sp-object.h" +#include "svg/svg-color.h" +#include "util/mathfns.h" +#include "xml/node-event-vector.h" namespace Inkscape { @@ -830,65 +828,86 @@ CanvasXYGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/) static void grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba) { - if ((y >= buf->rect.y0) && (y < buf->rect.y1)) { - guint r, g, b, a; - gint x0, x1, x; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - x0 = MAX (buf->rect.x0, xs); - x1 = MIN (buf->rect.x1, xe + 1); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (x = x0; x < x1; x++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += 4; - } + if ((y < buf->rect.y0) || (y >= buf->rect.y1)) + return; + + cairo_move_to(buf->ct, 0.5 + xs, 0.5 + y); + cairo_line_to(buf->ct, 0.5 + xe, 0.5 + y); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_stroke(buf->ct); +#if 0 + guint r, g, b, a; + gint x0, x1, x; + guchar *p; + r = NR_RGBA32_R (rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + x0 = MAX (buf->rect.x0, xs); + x1 = MIN (buf->rect.x1, xe + 1); + p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; + for (x = x0; x < x1; x++) { + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); + p += 4; } +#endif } static void grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) { - if ((x >= buf->rect.x0) && (x < buf->rect.x1)) { - guint r, g, b, a; - gint y0, y1, y; - guchar *p; - r = NR_RGBA32_R(rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - y0 = MAX (buf->rect.y0, ys); - y1 = MIN (buf->rect.y1, ye + 1); - p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - for (y = y0; y < y1; y++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += buf->buf_rowstride; - } + if ((x < buf->rect.x0) || (x >= buf->rect.x1)) + return; + + cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys); + cairo_line_to(buf->ct, 0.5 + x, 0.5 + ye); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_stroke(buf->ct); + #if 0 + guint r, g, b, a; + gint y0, y1, y; + guchar *p; + r = NR_RGBA32_R(rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + y0 = MAX (buf->rect.y0, ys); + y1 = MIN (buf->rect.y1, ye + 1); + p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; + for (y = y0; y < y1; y++) { + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); + p += buf->buf_rowstride; } + #endif } static void grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) { - if ( (y >= buf->rect.y0) && (y < buf->rect.y1) - && (x >= buf->rect.x0) && (x < buf->rect.x1) ) { - guint r, g, b, a; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - } + if ( (y < buf->rect.y0) || (y >= buf->rect.y1) + || (x < buf->rect.x0) || (x >= buf->rect.x1) ) + return; + + cairo_rectangle(buf->ct, x, y, 1, 1); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_fill(buf->ct); + +#if 0 + guint r, g, b, a; + guchar *p; + r = NR_RGBA32_R (rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); +#endif } void @@ -909,6 +928,11 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) _empcolor = empcolor; } + cairo_save(buf->ct); + cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_set_line_width(buf->ct, 1.0); + cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); + if (!render_dotted) { gint ylinenum; gdouble y; @@ -960,6 +984,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) } } + cairo_restore(buf->ct); } CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d) -- cgit v1.2.3 From 8217b2f74c9db38d7a64ce41eeb6c9659aae1ceb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 12 Jul 2010 21:57:46 +0200 Subject: Gaussian blur (bzr r9508.1.15) --- src/display/cairo-utils.cpp | 72 +++++++++++ src/display/cairo-utils.h | 7 ++ src/display/nr-arena-item.cpp | 34 +++++- src/display/nr-filter-gaussian.cpp | 206 ++++++++++++++++++++++++++++++- src/display/nr-filter-gaussian.h | 1 + src/display/nr-filter-primitive.cpp | 7 ++ src/display/nr-filter-primitive.h | 1 + src/display/nr-filter-slot.cpp | 237 ++++++++++++++++++++++++------------ src/display/nr-filter-slot.h | 63 +++++----- src/display/nr-filter.cpp | 72 ++++++++--- src/display/nr-filter.h | 7 +- 11 files changed, 574 insertions(+), 133 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index bb401dc87..a063a62bb 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -329,6 +329,78 @@ ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double cairo_surface_destroy(pbs); } +/** @brief Create an exact copy of a surface. + * Creates a surface that has the same type, content type, dimensions and contents + * as the specified surface. */ +cairo_surface_t * +ink_cairo_surface_copy(cairo_surface_t *s) +{ + cairo_surface_t *ns = ink_cairo_surface_create_identical(s); + + cairo_t *ct = cairo_create(ns); + cairo_set_source_surface(ct, s, 0, 0); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + + return ns; +} + +/** @brief Create a surface that differs only in pixel content. + * Creates a surface that has the same type, content type and dimensions + * as the specified surface. Pixel contents are not copied. */ +cairo_surface_t * +ink_cairo_surface_create_identical(cairo_surface_t *s) +{ + cairo_surface_t *ns = cairo_surface_create_similar(s, cairo_surface_get_content(s), + ink_cairo_surface_get_width(s), ink_cairo_surface_get_height(s)); + return ns; +} + +/** @brief Extract the alpha channel into a new surface. + * Creates a surface with a content type of CAIRO_CONTENT_ALPHA that contains + * the alpha values of pixels from @a s. */ +cairo_surface_t * +ink_cairo_extract_alpha(cairo_surface_t *s) +{ + cairo_surface_t *alpha = cairo_surface_create_similar(s, CAIRO_CONTENT_ALPHA, + ink_cairo_surface_get_width(s), ink_cairo_surface_get_height(s)); + + cairo_t *ct = cairo_create(alpha); + cairo_set_source_surface(ct, s, 0, 0); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + + return alpha; +} + +cairo_surface_t * +ink_cairo_surface_unshare(cairo_surface_t *s) +{ + if (cairo_surface_get_reference_count(s) > 1) { + return ink_cairo_surface_copy(s); + } else { + cairo_surface_reference(s); + return s; + } +} + +int +ink_cairo_surface_get_width(cairo_surface_t *surface) +{ + // For now only image surface is handled. + // Later add others, e.g. cairo-gl + assert(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE); + return cairo_image_surface_get_width(surface); +} +int +ink_cairo_surface_get_height(cairo_surface_t *surface) +{ + assert(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE); + return cairo_image_surface_get_height(surface); +} + // taken from Cairo sources static inline guint32 premul_alpha(guint32 color, guint32 alpha) { diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 096dc6046..cfd33330b 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -84,6 +84,13 @@ void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m); void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m); void ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double y); +cairo_surface_t *ink_cairo_surface_copy(cairo_surface_t *s); +cairo_surface_t *ink_cairo_surface_create_identical(cairo_surface_t *s); +cairo_surface_t *ink_cairo_extract_alpha(cairo_surface_t *s); +cairo_surface_t *ink_cairo_surface_unshare(cairo_surface_t *s); +int ink_cairo_surface_get_width(cairo_surface_t *surface); +int ink_cairo_surface_get_height(cairo_surface_t *surface); + void convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int rs); void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); void convert_pixbuf_normal_to_argb32(GdkPixbuf *); diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index f5731c0e3..e7cf08722 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -336,6 +336,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area return item->state | NR_ARENA_ITEM_STATE_RENDER; // carea is the bounding box for intermediate rendering. + // NOTE: carea might be larger than area, because of filter effects. NRRectL carea; nr_rect_l_intersect (&carea, area, &item->drawbox); if (nr_rect_l_test_empty(carea)) @@ -587,25 +588,39 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area this_ct = cairo_create(intermediate); this_area = &carea; cairo_surface_destroy(intermediate); // the surface will be held in memory by this_ct + } else { + cairo_reference(this_ct); } - Cairo::Context cct(this_ct); + // The pipeline needs to be different for filters. + // First we render the item into an intermediate surface. Then the filter rotates + // the surface to user coordinates (if necessary) and runs the rendering. + // Once that's done we retrieve the result, rotating it back to screen coords. + // Clipping and masking happens after the filter result is ready. + if (item->filter && filter) { + } + + Cairo::Context cct(this_ct, true); + Cairo::Context base_ct(ct); Cairo::RefPtr mask; - CairoSave clipsave(this_ct); // RAII for save / restore + CairoSave clipsave(ct); // RAII for save / restore CairoGroup maskgroup(this_ct); // RAII for push_group / pop_group CairoGroup drawgroup(this_ct); CairoGroup maskopacitygroup(this_ct); - if (item->clip && !(item->filter && filter)) { + // always clip the base context, not the one on the intermediate surface + // this is because filters must be done before clipping + if (item->clip) { clipsave.save(); - state = nr_arena_item_invoke_clip(this_ct, item->clip, this_area); + state = nr_arena_item_invoke_clip(ct, item->clip, const_cast(area)); if (state & NR_ARENA_ITEM_STATE_INVALID) { item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } - cct.clip(); + base_ct.clip(); } + // render mask on the intermediate context and store it if (item->mask) { maskgroup.push_with_content(CAIRO_CONTENT_ALPHA); // handle opacity of a masked object by composing it with the mask @@ -628,12 +643,20 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area /*if (mask) { drawgroup.push(); }*/ + + // render the object (possibly to the intermediate surface) state = NR_ARENA_ITEM_VIRTUAL (item, render) (this_ct, item, this_area, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { /* Clean up and return error */ item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } + + // apply filter + if (item->filter && filter) { + item->filter->render(item, ct, area, this_ct, &carea); + } + if (needs_intermediate_rendering) { cairo_surface_t *intermediate = cairo_get_target(this_ct); cairo_set_source_surface(ct, intermediate, carea.x0 - area->x0, carea.y0 - area->y0); @@ -655,7 +678,6 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area } } cairo_set_source_rgba(ct,0,0,0,0); - cairo_destroy(this_ct); } return item->state | NR_ARENA_ITEM_STATE_RENDER; diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 9509eaef7..2e6bed070 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -27,6 +27,7 @@ #include "2geom/isnan.h" +#include "display/cairo-utils.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" @@ -284,6 +285,12 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, int const n1, int const n2, IIRValue const b[N+1], double const M[N*N], IIRValue *const tmpdata[], int const num_threads) { +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + static unsigned int const alpha_PC = PC-1; +#else + static unsigned int const alpha_PC = 0; +#endif + #if HAVE_OPENMP #pragma omp parallel for num_threads(num_threads) #else @@ -319,8 +326,8 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, calcTriggsSdikaInitialization(M, u, iplus, iplus, b[0], v); dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { - dstimg[PC-1] = clip_round_cast(v[0][PC-1]); - for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[PC-1]); + dstimg[alpha_PC] = clip_round_cast(v[0][alpha_PC]); + for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[alpha_PC]); } else { for(unsigned int c=0; c(v[0][c]); } @@ -334,8 +341,8 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, } dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { - dstimg[PC-1] = clip_round_cast(v[0][PC-1]); - for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[PC-1]); + dstimg[alpha_PC] = clip_round_cast(v[0][alpha_PC]); + for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[alpha_PC]); } else { for(unsigned int c=0; c(v[0][c]); } @@ -537,6 +544,197 @@ upsample(PT *const dst, int const dstr1, int const dstr2, unsigned int const dn1 } } +static void +gaussian_pass_IIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_surface_t *dest, + IIRValue **tmpdata, int num_threads) +{ + // Filter variables + IIRValue b[N+1]; // scaling coefficient + filter coefficients (can be 10.21 fixed point) + double bf[N]; // computed filter coefficients + double M[N*N]; // matrix used for initialization procedure (has to be double) + + // Compute filter + calcFilter(deviation, bf); + for(size_t i=0; i( + cairo_image_surface_get_data(dest), d == Geom::X ? 1 : stride, d == Geom::X ? stride : 1, + cairo_image_surface_get_data(src), d == Geom::X ? 1 : stride, d == Geom::X ? stride : 1, + w, h, b, M, tmpdata, num_threads); + break; + case CAIRO_FORMAT_ARGB32: ///< Premultiplied 8 bit RGBA + filter2D_IIR( + cairo_image_surface_get_data(dest), d == Geom::X ? 4 : stride, d == Geom::X ? stride : 4, + cairo_image_surface_get_data(src), d == Geom::X ? 4 : stride, d == Geom::X ? stride : 4, + w, h, b, M, tmpdata, num_threads); + break; + default: + assert(false); + }; +} + +static void +gaussian_pass_FIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_surface_t *dest, + int num_threads) +{ + int scr_len = _effect_area_scr(deviation); + // Filter kernel for x direction + FIRValue kernel[scr_len+1]; + _make_kernel(kernel, deviation); + + int stride = cairo_image_surface_get_stride(src); + int w = cairo_image_surface_get_width(src); + int h = cairo_image_surface_get_height(src); + if (d != Geom::X) std::swap(w, h); + + // Filter (x) + switch (cairo_image_surface_get_format(src)) { + case CAIRO_FORMAT_A8: ///< Grayscale + filter2D_FIR( + cairo_image_surface_get_data(dest), d == Geom::X ? 1 : stride, d == Geom::X ? stride : 1, + cairo_image_surface_get_data(src), d == Geom::X ? 1 : stride, d == Geom::X ? stride : 1, + w, h, kernel, scr_len, num_threads); + break; + case CAIRO_FORMAT_ARGB32: ///< Premultiplied 8 bit RGBA + filter2D_FIR( + cairo_image_surface_get_data(dest), d == Geom::X ? 4 : stride, d == Geom::X ? stride : 4, + cairo_image_surface_get_data(src), d == Geom::X ? 4 : stride, d == Geom::X ? stride : 4, + w, h, kernel, scr_len, num_threads); + break; + default: + assert(false); + }; +} + +void FilterGaussian::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *in = slot.getcairo(_input); + if (!in) return; + + // zero deviation = transparent black as output + if (_deviation_x <= 0 || _deviation_y <= 0) { + cairo_surface_t *blank = ink_cairo_surface_create_identical(in); + slot.set(_output, blank); + cairo_surface_destroy(blank); + return; + } + + Geom::Matrix trans = slot.get_units().get_matrix_primitiveunits2pb(); + + int w_orig = ink_cairo_surface_get_width(in); + int h_orig = ink_cairo_surface_get_height(in); + double deviation_x_orig = _deviation_x * trans.expansionX(); + double deviation_y_orig = _deviation_y * trans.expansionY(); + cairo_format_t fmt = cairo_image_surface_get_format(in); + int bytes_per_pixel = 0; + switch (fmt) { + case CAIRO_FORMAT_A8: + bytes_per_pixel = 1; break; + case CAIRO_FORMAT_ARGB32: + default: + bytes_per_pixel = 4; break; + } + +#if HAVE_OPENMP + int threads = Inkscape::Preferences::get()->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); +#else + int threads = 1; +#endif + + int quality = slot.get_blurquality(); + int x_step = 1 << _effect_subsample_step_log2(deviation_x_orig, quality); + int y_step = 1 << _effect_subsample_step_log2(deviation_y_orig, quality); + bool resampling = x_step > 1 || y_step > 1; + int w_downsampled = resampling ? static_cast(ceil(static_cast(w_orig)/x_step))+1 : w_orig; + int h_downsampled = resampling ? static_cast(ceil(static_cast(h_orig)/y_step))+1 : h_orig; + double deviation_x = deviation_x_orig / x_step; + double deviation_y = deviation_y_orig / y_step; + int scr_len_x = _effect_area_scr(deviation_x); + int scr_len_y = _effect_area_scr(deviation_y); + + // Decide which filter to use for X and Y + // This threshold was determined by trial-and-error for one specific machine, + // so there's a good chance that it's not optimal. + // Whatever you do, don't go below 1 (and preferrably not even below 2), as + // the IIR filter gets unstable there. + bool use_IIR_x = deviation_x > 3; + bool use_IIR_y = deviation_y > 3; + + // Temporary storage for IIR filter + // NOTE: This can be eliminated, but it reduces the precision a bit + IIRValue * tmpdata[threads]; + std::fill_n(tmpdata, threads, (IIRValue*)0); + if ( use_IIR_x || use_IIR_y ) { + for(int i = 0; i < threads; ++i) { + tmpdata[i] = new IIRValue[std::max(w_downsampled,h_downsampled)*bytes_per_pixel]; + } + } + + cairo_surface_t *downsampled = NULL; + if (resampling) { + downsampled = cairo_surface_create_similar(in, cairo_surface_get_content(in), + w_downsampled, h_downsampled); + cairo_t *ct = cairo_create(downsampled); + cairo_scale(ct, static_cast(w_downsampled)/w_orig, static_cast(h_downsampled)/h_orig); + cairo_set_source_surface(ct, in, 0, 0); + cairo_paint(ct); + cairo_destroy(ct); + } else { + downsampled = ink_cairo_surface_copy(in); + } + cairo_surface_flush(downsampled); + + if (scr_len_x > 0) { + if (use_IIR_x) { + gaussian_pass_IIR(Geom::X, deviation_x, downsampled, downsampled, tmpdata, threads); + } else { + gaussian_pass_FIR(Geom::X, deviation_x, downsampled, downsampled, threads); + } + } + + if (scr_len_y > 0) { + if (use_IIR_y) { + gaussian_pass_IIR(Geom::Y, deviation_y, downsampled, downsampled, tmpdata, threads); + } else { + gaussian_pass_FIR(Geom::Y, deviation_y, downsampled, downsampled, threads); + } + } + + cairo_surface_mark_dirty(downsampled); + if (resampling) { + cairo_surface_t *upsampled = cairo_surface_create_similar(downsampled, cairo_surface_get_content(downsampled), + w_orig, h_orig); + cairo_t *ct = cairo_create(upsampled); + cairo_scale(ct, static_cast(w_orig)/w_downsampled, static_cast(h_orig)/h_downsampled); + cairo_set_source_surface(ct, downsampled, 0, 0); + cairo_paint(ct); + cairo_destroy(ct); + + slot.set(_output, upsampled); + cairo_surface_destroy(upsampled); + cairo_surface_destroy(downsampled); + } else { + slot.set(_output, downsampled); + cairo_surface_destroy(downsampled); + } +} + int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) { // TODO: Meaningful return values? (If they're checked at all.) diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 763e42de2..7bcabdba9 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -38,6 +38,7 @@ public: static FilterPrimitive *create(); virtual ~FilterGaussian(); + virtual void render_cairo(FilterSlot &slot); virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &m); virtual FilterTraits get_input_traits(); diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index b70ae57fe..31e314055 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -37,6 +37,13 @@ FilterPrimitive::~FilterPrimitive() // Nothing to do here } +void FilterPrimitive::render_cairo(FilterSlot &slot) +{ + // passthrough + cairo_surface_t *in = slot.getcairo(_input); + slot.set(_output, in); +} + void FilterPrimitive::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*m*/) { // This doesn't need to do anything by default diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 74b41211b..a7ae0125e 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -43,6 +43,7 @@ public: FilterPrimitive(); virtual ~FilterPrimitive(); + virtual void render_cairo(FilterSlot &slot); virtual int render(FilterSlot &slot, FilterUnits const &units) = 0; virtual void area_enlarge(NRRectL &area, Geom::Matrix const &m); diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 7df9ab979..d700cd433 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -14,6 +14,8 @@ #include #include +#include <2geom/transforms.h> +#include "display/cairo-utils.h" #include "display/nr-arena-item.h" #include "display/nr-filter-types.h" #include "display/nr-filter-gaussian.h" @@ -64,95 +66,153 @@ inline static int _min2(const double a, const double b) { namespace Inkscape { namespace Filters { -FilterSlot::FilterSlot(int slots, NRArenaItem const *item) - : _last_out(-1), - filterquality(FILTER_QUALITY_BEST), - blurquality(BLUR_QUALITY_BEST), - _arena_item(item) +FilterSlot::FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, + cairo_surface_t *graphic, NRRectL const *graphicarea, FilterUnits const &u) + : _item(item) + , _source_graphic(graphic) + , _background_ct(bgct) + , _source_graphic_area(graphicarea) + , _background_area(bgarea) + , _units(u) + , _last_out(NR_FILTER_SOURCEGRAPHIC) + , filterquality(FILTER_QUALITY_BEST) + , blurquality(BLUR_QUALITY_BEST) { - _slot_count = ((slots > 0) ? slots : 2); - _slot = new NRPixBlock*[_slot_count]; - _slot_number = new int[_slot_count]; - - for (int i = 0 ; i < _slot_count ; i++) { - _slot[i] = NULL; - _slot_number[i] = NR_FILTER_SLOT_NOT_SET; - } + using Geom::X; + using Geom::Y; + + // compute slot bbox + Geom::Rect bbox( + Geom::Point(_source_graphic_area->x0, _source_graphic_area->y0), + Geom::Point(_source_graphic_area->x1, _source_graphic_area->y1)); + + Geom::Matrix trans = _units.get_matrix_display2pb(); + + Geom::Rect bbox_trans = bbox * trans; + Geom::Point min = bbox_trans.min(); + Geom::Point max = bbox_trans.max(); + _slot_area.x0 = floor(min[X]); + _slot_area.y0 = floor(min[Y]); + _slot_area.x1 = ceil(max[X]); + _slot_area.y1 = ceil(max[Y]); } FilterSlot::~FilterSlot() { - for (int i = 0 ; i < _slot_count ; i++) { - if (_slot[i]) { - nr_pixblock_release(_slot[i]); - delete _slot[i]; - } + for (SlotMap::iterator i = _slots.begin(); i != _slots.end(); ++i) { + cairo_surface_destroy(i->second); } - delete[] _slot; - delete[] _slot_number; } -NRPixBlock *FilterSlot::get(int slot_nr) +cairo_surface_t *FilterSlot::getcairo(int slot_nr) { - int index = _get_index(slot_nr); - assert(index >= 0); + //int index = _get_index(slot_nr); + //assert(index >= 0); + + if (slot_nr == NR_FILTER_SLOT_NOT_SET) + slot_nr = _last_out; + + SlotMap::iterator s = _slots.find(slot_nr); /* If we didn't have the specified image, but we could create it * from the other information we have, let's do that */ - if (_slot[index] == NULL - && (slot_nr == NR_FILTER_SOURCEALPHA + if (s == _slots.end() + && (slot_nr == NR_FILTER_SOURCEGRAPHIC + || slot_nr == NR_FILTER_SOURCEALPHA || slot_nr == NR_FILTER_BACKGROUNDIMAGE || slot_nr == NR_FILTER_BACKGROUNDALPHA || slot_nr == NR_FILTER_FILLPAINT || slot_nr == NR_FILTER_STROKEPAINT)) { - /* If needed, fetch background */ - if (slot_nr == NR_FILTER_BACKGROUNDIMAGE) { - NRPixBlock *pb; - pb = nr_arena_item_get_background(_arena_item); - if (pb) { - pb->empty = false; - this->set(NR_FILTER_BACKGROUNDIMAGE, pb); - } else { - NRPixBlock *source = this->get(NR_FILTER_SOURCEGRAPHIC); - pb = new NRPixBlock(); - if (!pb) return NULL; // Allocation failed - nr_pixblock_setup_fast(pb, source->mode, - source->area.x0, source->area.y0, - source->area.x1, source->area.y1, true); - if (pb->size != NR_PIXBLOCK_SIZE_TINY && pb->data.px == NULL) { - // allocation failed - delete pb; - return NULL; - } - pb->empty = FALSE; - this->set(NR_FILTER_BACKGROUNDIMAGE, pb); - } - } else if (slot_nr == NR_FILTER_SOURCEALPHA) { - /* If only a alpha channel is needed, strip it from full image */ - NRPixBlock *src = get(NR_FILTER_SOURCEGRAPHIC); - NRPixBlock *sa = filter_get_alpha(src); - set(NR_FILTER_SOURCEALPHA, sa); - } else if (slot_nr == NR_FILTER_BACKGROUNDALPHA) { - NRPixBlock *src = get(NR_FILTER_BACKGROUNDIMAGE); - NRPixBlock *ba = filter_get_alpha(src); - set(NR_FILTER_BACKGROUNDALPHA, ba); - } else if (slot_nr == NR_FILTER_FILLPAINT) { - /* When a paint is needed, fetch it from arena item */ - // TODO - } else if (slot_nr == NR_FILTER_STROKEPAINT) { - // TODO + switch (slot_nr) { + case NR_FILTER_SOURCEGRAPHIC: { + cairo_surface_t *tr = _get_transformed_source_graphic(); + _set_internal(NR_FILTER_SOURCEGRAPHIC, tr); + cairo_surface_destroy(tr); + } break; + case NR_FILTER_BACKGROUNDIMAGE: { + // TODO + //cairo_surface_t *bg = _get_transformed_background(); + //_set_internal(NR_FILTER_BACKGROUNDIMAGE, bg); + //cairo_surface_destroy(bg); + } break; + case NR_FILTER_SOURCEALPHA: { + cairo_surface_t *src = getcairo(NR_FILTER_SOURCEGRAPHIC); + cairo_surface_t *alpha = ink_cairo_extract_alpha(src); + _set_internal(NR_FILTER_SOURCEALPHA, alpha); + cairo_surface_destroy(alpha); + } break; + case NR_FILTER_BACKGROUNDALPHA: { + cairo_surface_t *src = getcairo(NR_FILTER_BACKGROUNDIMAGE); + cairo_surface_t *ba = ink_cairo_extract_alpha(src); + _set_internal(NR_FILTER_BACKGROUNDALPHA, ba); + cairo_surface_destroy(ba); + } break; + case NR_FILTER_FILLPAINT: //TODO + case NR_FILTER_STROKEPAINT: //TODO + default: + break; } + s = _slots.find(slot_nr); } - if (_slot[index]) { - _slot[index]->empty = false; + if (s == _slots.end()) { + // create empty surface + // TODO + return NULL; } + return s->second; - assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr); - return _slot[index]; + //assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr); + //return _slot[index]; +} + +cairo_surface_t *FilterSlot::_get_transformed_source_graphic() +{ + Geom::Matrix trans = _units.get_matrix_display2pb(); + + cairo_surface_t *tsg = cairo_surface_create_similar( + _source_graphic, cairo_surface_get_content(_source_graphic), + _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); + cairo_t *tsg_ct = cairo_create(tsg); + + cairo_translate(tsg_ct, -_slot_area.x0, -_slot_area.y0); + ink_cairo_transform(tsg_ct, trans); + cairo_translate(tsg_ct, _source_graphic_area->x0, _source_graphic_area->y0); + cairo_set_source_surface(tsg_ct, _source_graphic, 0, 0); + cairo_set_operator(tsg_ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(tsg_ct); + cairo_destroy(tsg_ct); + + return tsg; +} + +cairo_surface_t *FilterSlot::_get_transformed_background() +{ + return NULL; } +cairo_surface_t *FilterSlot::get_result(int res) +{ + Geom::Matrix trans = _units.get_matrix_pb2display(); + + cairo_surface_t *r = cairo_surface_create_similar(_source_graphic, + cairo_surface_get_content(_source_graphic), + _source_graphic_area->x1 - _source_graphic_area->x0, + _source_graphic_area->y1 - _source_graphic_area->y0); + cairo_t *r_ct = cairo_create(r); + + cairo_translate(r_ct, -_source_graphic_area->x0, -_source_graphic_area->y0); + ink_cairo_transform(r_ct, trans); + cairo_translate(r_ct, _slot_area.x0, _slot_area.y0); + cairo_set_source_surface(r_ct, getcairo(res), 0, 0); + cairo_set_operator(r_ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(r_ct); + cairo_destroy(r_ct); + + return r; +} +/* void FilterSlot::get_final(int slot_nr, NRPixBlock *result) { NRPixBlock *final_usr = get(slot_nr); Geom::Matrix trans = units.get_matrix_pb2display(); @@ -173,10 +233,33 @@ void FilterSlot::get_final(int slot_nr, NRPixBlock *result) { } else { nr_blit_pixblock_pixblock(result, final_usr); } +}*/ + +void FilterSlot::_set_internal(int slot_nr, cairo_surface_t *surface) +{ + // destroy after referencing + // this way assigning a surface to a slot it already occupies will not cause errors + cairo_surface_reference(surface); + + SlotMap::iterator s = _slots.find(slot_nr); + if (s != _slots.end()) { + cairo_surface_destroy(s->second); + } + + _slots[slot_nr] = surface; } -void FilterSlot::set(int slot_nr, NRPixBlock *pb) +void FilterSlot::set(int slot_nr, cairo_surface_t *surface) { + g_return_if_fail(surface != NULL); + + if (slot_nr == NR_FILTER_SLOT_NOT_SET) + slot_nr = NR_FILTER_UNNAMED_SLOT; + + _set_internal(slot_nr, surface); + _last_out = slot_nr; + +#if 0 /* Unnamed slot is for saving filter primitive results, when parameter * 'result' is not set. Only the filter immediately after this one * can access unnamed results, so we don't have to worry about overwriting @@ -216,6 +299,11 @@ void FilterSlot::set(int slot_nr, NRPixBlock *pb) trans[1] * x1 + trans[3] * y0 + trans[5], trans[1] * x1 + trans[3] * y1 + trans[5]); + cairo_surface_t *trans_s = cairo_surface_create_similar(s, + CAIRO_CONTENT_COLOR, max_x - min_x, max_y - min_y); + cairo_t *ct = cairo_create(trans_s); + + nr_pixblock_setup_fast(trans_pb, pb->mode, min_x, min_y, max_x, max_y, true); @@ -270,25 +358,24 @@ void FilterSlot::set(int slot_nr, NRPixBlock *pb) } _slot[index] = pb; _last_out = index; +#endif } int FilterSlot::get_slot_count() { + return _slots.size(); + /* int seek = _slot_count; do { seek--; } while (!_slot[seek] && _slot_number[seek] == NR_FILTER_SLOT_NOT_SET); - return seek + 1; -} - -NRArenaItem const* FilterSlot::get_arenaitem() -{ - return _arena_item; + return seek + 1;*/ } int FilterSlot::_get_index(int slot_nr) { +#if 0 assert(slot_nr >= 0 || slot_nr == NR_FILTER_SLOT_NOT_SET || slot_nr == NR_FILTER_SOURCEGRAPHIC || @@ -340,10 +427,8 @@ int FilterSlot::_get_index(int slot_nr) index = seek + 1; } return index; -} - -void FilterSlot::set_units(FilterUnits const &units) { - this->units = units; +#endif + return 0; } void FilterSlot::set_quality(FilterQuality const q) { diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 8d7a82d2d..92f66ddf8 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -14,6 +14,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include #include "libnr/nr-pixblock.h" #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" @@ -26,13 +28,11 @@ namespace Filters { class FilterSlot { public: /** Creates a new FilterSlot object. - * First parameter specifies the amount of slots this SilterSlot - * should reserve beforehand. If a negative number is given, - * two slots will be reserved. - * Second parameter specifies the arena item, which should be used + * Parameter specifies the surface which should be used * for background accesses from filters. */ - FilterSlot(int slots, NRArenaItem const *item); + FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, + cairo_surface_t *graphic, NRRectL const *graphicarea, FilterUnits const &u); /** Destroys the FilterSlot object and all its contents */ virtual ~FilterSlot(); @@ -45,15 +45,8 @@ public: * If the defined filter slot is not set before, this function * returns NULL. Also, that filter slot is created in process. */ - NRPixBlock *get(int slot); - - /** Gets the final result from this filter. - * The result is fetched from the specified slot, see description of - * method get for valid values. The pixblock 'result' will be modified - * to contain the result image, ready to be used in the rest of rendering - * pipeline - */ - void get_final(int slot, NRPixBlock *result); + cairo_surface_t *getcairo(int slot); + NRPixBlock *get(int slot) { return NULL; } /** Sets or re-sets the pixblock associated with given slot. * If there was a pixblock already assigned with this slot, @@ -63,16 +56,19 @@ public: * Pixblocks passed to this function should be reserved with * c++ -style new-operator. */ - void set(int slot, NRPixBlock *pb); + void set(int slot, cairo_surface_t *s); + + void set(int, NRPixBlock*){} + + cairo_surface_t *get_result(int slot_nr); + + NRRectL const *get_slot_area(); /** Returns the number of slots in use. */ int get_slot_count(); - /** arenaitem getter method*/ - NRArenaItem const* get_arenaitem(); - /** Sets the unit system to be used for the internal images. */ - void set_units(FilterUnits const &units); + //void set_units(FilterUnits const &units); /** Sets the filtering quality. Affects used interpolation methods */ void set_quality(FilterQuality const q); @@ -83,25 +79,36 @@ public: /** Gets the gaussian filtering quality. Affects used interpolation methods */ int get_blurquality(void); -private: - NRPixBlock **_slot; - int *_slot_number; - int _slot_count; + FilterUnits const &get_units() const { return _units; } +private: + typedef std::map SlotMap; + SlotMap _slots; + NRArenaItem *_item; + + //Geom::Rect _source_bbox; ///< bounding box of source graphic surface + //Geom::Rect _intermediate_bbox; ///< bounding box of intermediate surfaces + + NRRectL _slot_area; + cairo_surface_t *_source_graphic; + cairo_t *_background_ct; + NRRectL const *_source_graphic_area; + NRRectL const *_background_area; ///< needed to extract background + FilterUnits const &_units; int _last_out; - FilterQuality filterquality; - int blurquality; - NRArenaItem const *_arena_item; - - FilterUnits units; + cairo_surface_t *_get_transformed_source_graphic(); + cairo_surface_t *_get_transformed_background(); + cairo_surface_t *_get_fill_paint(); + cairo_surface_t *_get_stroke_paint(); /** Returns the table index of given slot. If that slot does not exist, * it is created. Table index can be used to read the correct * pixblock from _slot */ int _get_index(int slot); + void _set_internal(int slot, cairo_surface_t *s); }; } /* namespace Filters */ diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 24079be4e..a5b5801b1 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "display/nr-filter.h" #include "display/nr-filter-primitive.h" @@ -129,20 +130,21 @@ Filter::~Filter() } -int Filter::render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct) +int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea, cairo_t *graphic, NRRectL const *area) { if (!_primitive[0]) { - // TODO: Should clear the input buffer instead of just returning - return 1; + // when no primitives are defined, clear source graphic + cairo_set_source_rgba(graphic, 0,0,0,0); + cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); + cairo_paint(graphic); + cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); + return 1; } FilterQuality const filterquality = (FilterQuality)item->arena->filterquality; int const blurquality = item->arena->blurquality; Geom::Matrix trans = item->ctm; - FilterSlot slot(_slot_count, item); - slot.set_quality(filterquality); - slot.set_blurquality(blurquality); Geom::Rect item_bbox; { @@ -165,11 +167,17 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct) units.set_item_bbox(item_bbox); units.set_filter_area(filter_area); - // TODO: with filterRes of 0x0 should return an empty image std::pair resolution = _filter_resolution(filter_area, trans, filterquality); - if(!(resolution.first > 0 && resolution.second > 0)) - return 1; + if (!(resolution.first > 0 && resolution.second > 0)) { + // zero resolution - clear source graphic and return + cairo_set_source_rgba(graphic, 0,0,0,0); + cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); + cairo_paint(graphic); + cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); + return 1; + } + units.set_resolution(resolution.first, resolution.second); if (_x_pixels > 0) { units.set_automatic_resolution(false); @@ -178,17 +186,44 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct) units.set_automatic_resolution(true); } - units.set_paraller(false); + /*units.set_paraller(false); for (int i = 0 ; i < _primitive_count ; i++) { if (_primitive[i]->get_input_traits() & TRAIT_PARALLER) { units.set_paraller(true); break; } + }*/ + units.set_paraller(true); + + FilterSlot slot(const_cast(item), bgct, bgarea, cairo_get_target(graphic), area, units); + slot.set_quality(filterquality); + slot.set_blurquality(blurquality); + + for (int i = 0 ; i < _primitive_count ; i++) { + _primitive[i]->render_cairo(slot); } - slot.set_units(units); + cairo_surface_t *result = slot.get_result(_output_slot); + cairo_set_source_surface(graphic, result, 0, 0); + cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); + cairo_paint(graphic); + cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); + cairo_surface_destroy(result); + + //slot.set_units(units); + + /*cairo_surface_t *in = cairo_surface_create_similar( + cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, + area->x1 - area->x0, area->y1 - area->y0); + cairo_t *inct = cairo_create(in); + cairo_translate(inct, -area->x0, -area->y0); + cairo_set_source_surface(inct, cairo_get_target(ct), 0, 0); + cairo_paint(inct); + slot.set(NR_FILTER_SOURCEGRAPHIC, in); + cairo_destroy(inct); + cairo_surface_destroy(in);*/ - NRPixBlock *in = new NRPixBlock; + /*NRPixBlock *in = new NRPixBlock; nr_pixblock_setup_fast(in, pb->mode, pb->area.x0, pb->area.y0, pb->area.x1, pb->area.y1, true); if (in->size != NR_PIXBLOCK_SIZE_TINY && in->data.px == NULL) { @@ -197,10 +232,10 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct) } nr_blit_pixblock_pixblock(in, pb); in->empty = FALSE; - slot.set(NR_FILTER_SOURCEGRAPHIC, in); + slot.set(NR_FILTER_SOURCEGRAPHIC, in);*/ // Check that we are rendering a non-empty area - in = slot.get(NR_FILTER_SOURCEGRAPHIC); + /*in = slot.get(NR_FILTER_SOURCEGRAPHIC); if (in->area.x1 - in->area.x0 <= 0 || in->area.y1 - in->area.y0 <= 0) { if (in->area.x1 - in->area.x0 < 0 || in->area.y1 - in->area.y0 < 0) { g_warning("Inkscape::Filters::Filter::render: negative area! (%d, %d) (%d, %d)", @@ -209,17 +244,18 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct) return 0; } in = NULL; // in is now handled by FilterSlot, we should not touch it + */ - for (int i = 0 ; i < _primitive_count ; i++) { + /*for (int i = 0 ; i < _primitive_count ; i++) { _primitive[i]->render(slot, units); - } + }*/ - slot.get_final(_output_slot, pb); + //slot.get_final(_output_slot, ct, area); // Take note of the amount of used image slots // -> next time this filter is rendered, we can reserve enough slots // immediately - _slot_count = slot.get_slot_count(); + //_slot_count = slot.get_slot_count(); return 0; } diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 08d0254d1..cd805043c 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -30,7 +30,12 @@ namespace Filters { class Filter : public Inkscape::GC::Managed<> { public: - int render(NRArenaItem const *item, NRPixBlock *pb, cairo_t *ct); + /** Given background state from @a bgct and an intermediate rendering from the surface + * backing @a graphic, modify the contents of the surface backing @a graphic to represent + * the results of filter rendering. @a bgarea and @a area specify bounding boxes + * of both surfaces in world coordinates; Cairo contexts are assumed to be in default state + * (0,0 = surface origin, no path, OVER operator) */ + int render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea, cairo_t *graphic, NRRectL const *area); /** * Creates a new filter primitive under this filter object. -- cgit v1.2.3 From bb8404b19557519bd828113fa93604b10e9e7fe3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 14 Jul 2010 04:32:10 +0200 Subject: Merge redundant *-fns.h into respective filter headers. Move gaussian blur to filters directory. Blend filter effect. (bzr r9508.1.16) --- src/Makefile_insert | 3 - src/desktop-style.cpp | 2 +- src/display/cairo-utils.cpp | 20 +- src/display/nr-arena-group.cpp | 2 - src/display/nr-arena-image.cpp | 4 - src/display/nr-arena-item.h | 31 +-- src/display/nr-filter-blend.cpp | 253 +++++++++++++++++++ src/display/nr-filter-blend.h | 2 + src/display/nr-filter-gaussian.cpp | 429 +------------------------------- src/display/nr-filter-gaussian.h | 3 +- src/display/nr-filter-primitive.h | 16 +- src/display/nr-filter-slot.cpp | 39 ++- src/filter-chemistry.cpp | 2 +- src/filter-chemistry.h | 11 +- src/filters/Makefile_insert | 91 +++---- src/filters/blend-fns.h | 38 --- src/filters/blend.cpp | 3 +- src/filters/blend.h | 23 +- src/filters/colormatrix-fns.h | 38 --- src/filters/colormatrix.cpp | 1 + src/filters/colormatrix.h | 26 +- src/filters/componenttransfer-fns.h | 38 --- src/filters/componenttransfer.cpp | 5 +- src/filters/componenttransfer.h | 31 +-- src/filters/composite-fns.h | 38 --- src/filters/composite.cpp | 4 +- src/filters/composite.h | 23 +- src/filters/convolvematrix-fns.h | 38 --- src/filters/convolvematrix.cpp | 6 +- src/filters/convolvematrix.h | 25 +- src/filters/diffuselighting-fns.h | 38 --- src/filters/diffuselighting.cpp | 3 +- src/filters/diffuselighting.h | 43 ++-- src/filters/displacementmap-fns.h | 38 --- src/filters/displacementmap.cpp | 6 +- src/filters/displacementmap.h | 23 +- src/filters/distantlight.cpp | 6 +- src/filters/flood-fns.h | 38 --- src/filters/flood.cpp | 5 +- src/filters/flood.h | 25 +- src/filters/gaussian-blur.cpp | 212 ++++++++++++++++ src/filters/gaussian-blur.h | 51 ++++ src/filters/image-fns.h | 38 --- src/filters/image.h | 25 +- src/filters/merge-fns.h | 38 --- src/filters/merge.cpp | 1 + src/filters/merge.h | 21 +- src/filters/mergenode.cpp | 5 +- src/filters/morphology-fns.h | 38 --- src/filters/morphology.cpp | 1 + src/filters/morphology.h | 22 +- src/filters/offset-fns.h | 38 --- src/filters/offset.cpp | 3 +- src/filters/offset.h | 24 +- src/filters/pointlight.cpp | 6 +- src/filters/specularlighting-fns.h | 38 --- src/filters/specularlighting.cpp | 1 + src/filters/specularlighting.h | 30 ++- src/filters/spotlight.cpp | 6 +- src/filters/tile-fns.h | 38 --- src/filters/tile.cpp | 5 +- src/filters/tile.h | 25 +- src/filters/turbulence-fns.h | 38 --- src/filters/turbulence.h | 22 +- src/preferences-skeleton.h | 1 - src/sp-filter-fns.h | 53 ---- src/sp-filter-primitive.h | 9 +- src/sp-filter-reference.cpp | 1 + src/sp-filter-reference.h | 5 +- src/sp-filter.cpp | 1 + src/sp-filter.h | 67 ++--- src/sp-gaussian-blur-fns.h | 40 --- src/sp-gaussian-blur.cpp | 212 ---------------- src/sp-gaussian-blur.h | 45 ---- src/sp-object-repr.cpp | 2 +- src/spray-context.cpp | 6 - src/tweak-context.cpp | 3 +- src/ui/dialog/filter-effects-dialog.cpp | 2 +- 78 files changed, 941 insertions(+), 1702 deletions(-) delete mode 100644 src/filters/blend-fns.h delete mode 100644 src/filters/colormatrix-fns.h delete mode 100644 src/filters/componenttransfer-fns.h delete mode 100644 src/filters/composite-fns.h delete mode 100644 src/filters/convolvematrix-fns.h delete mode 100644 src/filters/diffuselighting-fns.h delete mode 100644 src/filters/displacementmap-fns.h delete mode 100644 src/filters/flood-fns.h create mode 100644 src/filters/gaussian-blur.cpp create mode 100644 src/filters/gaussian-blur.h delete mode 100644 src/filters/image-fns.h delete mode 100644 src/filters/merge-fns.h delete mode 100644 src/filters/morphology-fns.h delete mode 100644 src/filters/offset-fns.h delete mode 100644 src/filters/specularlighting-fns.h delete mode 100644 src/filters/tile-fns.h delete mode 100644 src/filters/turbulence-fns.h delete mode 100644 src/sp-filter-fns.h delete mode 100644 src/sp-gaussian-blur-fns.h delete mode 100644 src/sp-gaussian-blur.cpp delete mode 100644 src/sp-gaussian-blur.h (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index 36c9de34f..2298ddb42 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -152,7 +152,6 @@ ink_common_sources += \ sp-desc.cpp sp-desc.h \ sp-ellipse.cpp sp-ellipse.h \ sp-filter.cpp sp-filter.h number-opt-number.h \ - sp-filter-fns.h \ sp-filter-primitive.cpp sp-filter-primitive.h \ sp-filter-reference.cpp sp-filter-reference.h \ sp-filter-units.h \ @@ -161,8 +160,6 @@ ink_common_sources += \ sp-flowtext.h sp-flowtext.cpp \ sp-font.cpp sp-font.h \ sp-font-face.cpp sp-font-face.h \ - sp-gaussian-blur.cpp sp-gaussian-blur.h \ - sp-gaussian-blur-fns.h \ sp-glyph.cpp sp-glyph.h \ sp-glyph-kerning.cpp sp-glyph-kerning.h \ sp-gradient.cpp sp-gradient.h \ diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 26f29d172..1b277a381 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -28,7 +28,7 @@ #include "filters/blend.h" #include "sp-filter.h" #include "sp-filter-reference.h" -#include "sp-gaussian-blur.h" +#include "filters/gaussian-blur.h" #include "sp-flowtext.h" #include "sp-flowregion.h" #include "sp-flowdiv.h" diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index a063a62bb..36202f42e 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -337,11 +337,21 @@ ink_cairo_surface_copy(cairo_surface_t *s) { cairo_surface_t *ns = ink_cairo_surface_create_identical(s); - cairo_t *ct = cairo_create(ns); - cairo_set_source_surface(ct, s, 0, 0); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_destroy(ct); + if (cairo_surface_get_type(s) == CAIRO_SURFACE_TYPE_IMAGE) { + // use memory copy instead of using a Cairo context + cairo_surface_flush(s); + int stride = cairo_image_surface_get_stride(s); + int h = cairo_image_surface_get_height(s); + memcpy(cairo_image_surface_get_data(ns), cairo_image_surface_get_data(s), stride * h); + cairo_surface_mark_dirty(ns); + } else { + // generic implementation + cairo_t *ct = cairo_create(ns); + cairo_set_source_surface(ct, s, 0, 0); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + } return ns; } diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 0fa5f332a..3bc78ea56 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -14,12 +14,10 @@ #include "display/nr-arena-group.h" #include "display/nr-filter.h" -#include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" #include "style.h" #include "sp-filter.h" #include "sp-filter-reference.h" -#include "sp-gaussian-blur.h" #include "filters/blend.h" #include "display/nr-filter-blend.h" #include "helper/geom.h" diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 325cff65a..422b691b7 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -21,12 +21,8 @@ #include "display/cairo-utils.h" #include "display/nr-arena.h" #include "display/nr-filter.h" -#include "display/nr-filter-gaussian.h" #include "sp-filter.h" #include "sp-filter-reference.h" -#include "sp-gaussian-blur.h" -#include "filters/blend.h" -#include "display/nr-filter-blend.h" int nr_arena_image_x_sample = 1; int nr_arena_image_y_sample = 1; diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 468d352bc..447307535 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -1,6 +1,3 @@ -#ifndef __NR_ARENA_ITEM_H__ -#define __NR_ARENA_ITEM_H__ - /* * RGBA display list system for inkscape * @@ -13,6 +10,22 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_DISPLAY_NR_ARENA_ITEM_H +#define SEEN_DISPLAY_NR_ARENA_ITEM_H + +#include +#include <2geom/matrix.h> +#include +#include +#include +#include "gc-soft-ptr.h" +#include "nr-arena-forward.h" + +namespace Inkscape { +namespace Filters { +class Filter; +} } + #define NR_TYPE_ARENA_ITEM (nr_arena_item_get_type ()) #define NR_ARENA_ITEM(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA_ITEM, NRArenaItem)) #define NR_IS_ARENA_ITEM(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA_ITEM)) @@ -52,15 +65,6 @@ #define NR_ARENA_ITEM_RENDER_NO_CACHE (1 << 0) -#include <2geom/matrix.h> -#include -#include -#include -#include "gc-soft-ptr.h" -#include "nr-arena-forward.h" -#include "display/nr-filter.h" -#include - struct NRGC { NRGC(NRGC const *p) : parent(p) {} NRGC const *parent; @@ -181,8 +185,7 @@ NRArenaItem *nr_arena_item_detach (NRArenaItem *parent, NRArenaItem *child); #define NR_ARENA_ITEM_SET_KEY(i,k) (((NRArenaItem *) (i))->key = (k)) #define NR_ARENA_ITEM_GET_KEY(i) (((NRArenaItem *) (i))->key) - -#endif /* !__NR_ARENA_ITEM_H__ */ +#endif /* !SEEN_DISPLAY_NR_ARENA_ITEM_H */ /* Local Variables: diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 4645d9bc0..4ce37ae3b 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -15,6 +15,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "display/cairo-utils.h" #include "display/nr-filter-blend.h" #include "display/nr-filter-pixops.h" #include "display/nr-filter-primitive.h" @@ -24,6 +29,7 @@ #include "libnr/nr-pixblock.h" #include "libnr/nr-blit.h" #include "libnr/nr-pixops.h" +#include "preferences.h" namespace Inkscape { namespace Filters { @@ -125,6 +131,247 @@ FilterPrimitive * FilterBlend::create() { FilterBlend::~FilterBlend() {} +#define EXTRACT_ARGB32(px,a,r,g,b) \ + guint32 a, r, g, b; \ + a = (px & 0xff000000) >> 24; \ + r = (px & 0x00ff0000) >> 16; \ + g = (px & 0x0000ff00) >> 8; \ + b = (px & 0x000000ff); + +#define ASSEMBLE_ARGB32(px,a,r,g,b) \ + guint32 px = (a << 24) | (r << 16) | (g << 8) | b; + +// cr = (1-qa)*cb + (1-qb)*ca + ca*cb +struct BlendMultiply { + void operator()(guint32 in1, guint32 in2, guint32 *out) + { + EXTRACT_ARGB32(in1, aa, ra, ga, ba) + EXTRACT_ARGB32(in2, ab, rb, gb, bb) + + guint32 ao = 255*255 - (255-aa)*(255-ab); ao = (ao + 127) / 255; + guint32 ro = (255-aa)*rb + (255-ab)*ra + ra*rb; ro = (ro + 127) / 255; + guint32 go = (255-aa)*gb + (255-ab)*ga + ga*gb; go = (go + 127) / 255; + guint32 bo = (255-aa)*bb + (255-ab)*ba + ba*bb; bo = (bo + 127) / 255; + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + *out = pxout; + } +}; + +// cr = cb + ca - ca * cb +struct BlendScreen { + void operator()(guint32 in1, guint32 in2, guint32 *out) + { + EXTRACT_ARGB32(in1, aa, ra, ga, ba) + EXTRACT_ARGB32(in2, ab, rb, gb, bb) + + guint32 ao = 255*255 - (255-aa)*(255-ab); ao = (ao + 127) / 255; + guint32 ro = 255*(rb + ra) - ra * rb; ro = (ro + 127) / 255; + guint32 go = 255*(gb + ga) - ga * gb; go = (go + 127) / 255; + guint32 bo = 255*(bb + ba) - ba * bb; bo = (bo + 127) / 255; + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + *out = pxout; + } +}; + +// cr = Min ((1 - qa) * cb + ca, (1 - qb) * ca + cb) +struct BlendDarken { + void operator()(guint32 in1, guint32 in2, guint32 *out) + { + EXTRACT_ARGB32(in1, aa, ra, ga, ba) + EXTRACT_ARGB32(in2, ab, rb, gb, bb) + + guint32 ao = 255*255 - (255-aa)*(255-ab); ao = (ao + 127) / 255; + guint32 ro = std::min((255-aa)*rb + 255*ra, (255-ab)*ra + 255*rb); ro = (ro + 127) / 255; + guint32 go = std::min((255-aa)*gb + 255*ga, (255-ab)*ga + 255*gb); go = (go + 127) / 255; + guint32 bo = std::min((255-aa)*bb + 255*ba, (255-ab)*ba + 255*bb); bo = (bo + 127) / 255; + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + *out = pxout; + } +}; + +// cr = Max ((1 - qa) * cb + ca, (1 - qb) * ca + cb) +struct BlendLighten { + void operator()(guint32 in1, guint32 in2, guint32 *out) + { + EXTRACT_ARGB32(in1, aa, ra, ga, ba) + EXTRACT_ARGB32(in2, ab, rb, gb, bb) + + guint32 ao = 255*255 - (255-aa)*(255-ab); ao = (ao + 127) / 255; + guint32 ro = std::max((255-aa)*rb + 255*ra, (255-ab)*ra + 255*rb); ro = (ro + 127) / 255; + guint32 go = std::max((255-aa)*gb + 255*ga, (255-ab)*ga + 255*gb); go = (go + 127) / 255; + guint32 bo = std::max((255-aa)*bb + 255*ba, (255-ab)*ba + 255*bb); bo = (bo + 127) / 255; + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + *out = pxout; + } +}; + +/* +struct BlendAlpha +static inline void blend_alpha(guint32 in1, guint32 in2, guint32 *out) +{ + EXTRACT_ARGB32(in1, a1, a2, a3, a4); + EXTRACT_ARGB32(in2, b1, b2, b3, b4); + + guint32 o1 = 255*255 - (255-a1)*(255-b1); o1 = (o1+127) / 255; + guint32 o2 = 255*255 - (255-a2)*(255-b2); o2 = (o2+127) / 255; + guint32 o3 = 255*255 - (255-a3)*(255-b3); o3 = (o3+127) / 255; + guint32 o4 = 255*255 - (255-a4)*(255-b4); o4 = (o4+127) / 255; + + ASSEMBLE_ARGB32(pxout, o1, o2, o3, o4); + *out = pxout; +} +*/ + +template +void surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_surface_t *out) +{ + cairo_surface_flush(in1); + cairo_surface_flush(in2); + + // WARNING: code below assumes that: + // 1. Cairo ARGB32 surface strides are always divisible by 4 + // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces + + int w = cairo_image_surface_get_width(in2); + int h = cairo_image_surface_get_height(in2); + int stride1 = cairo_image_surface_get_stride(in1); + int stride2 = cairo_image_surface_get_stride(in2); + int strideout = cairo_image_surface_get_stride(out); + int bpp1 = cairo_image_surface_get_format(in1) == CAIRO_FORMAT_A8 ? 1 : 4; + int bpp2 = cairo_image_surface_get_format(in2) == CAIRO_FORMAT_A8 ? 1 : 4; + // assumption: out surface is CAIRO_FORMAT_ARGB32 if at least one input is ARGB32 + + guint32 *const in1_data = (guint32*) cairo_image_surface_get_data(in1); + guint32 *const in2_data = (guint32*) cairo_image_surface_get_data(in2); + guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); + + #if HAVE_OPENMP + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + #endif + + if (bpp1 == 4) { + if (bpp2 == 4) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in1_p = in1_data + i * stride1/4; + guint32 *in2_p = in2_data + i * stride2/4; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + Blend()(*in1_p, *in2_p, out_p); + ++in1_p; + ++in2_p; + ++out_p; + } + } + } else { + // bpp2 == 1 + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in1_p = in1_data + i * stride1/4; + guint8 *in2_p = reinterpret_cast(in2_data) + i * stride2; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + guint32 in2_px = *in2_p; + in2_px <<= 24; + Blend()(*in1_p, in2_px, out_p); + ++in1_p; + ++in2_p; + ++out_p; + } + } + } + } else { + if (bpp2 == 4) { + // bpp1 == 1 + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; + guint32 *in2_p = in2_data + i * stride2/4; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + guint32 in1_px = *in1_p; + in1_px <<= 24; + Blend()(in1_px, *in2_p, out_p); + ++in1_p; + ++in2_p; + ++out_p; + } + } + } else { + // bpp1 == 1 && bpp2 == 1 + // don't do anything - this should have been handled via Cairo blending + g_assert_not_reached(); + } + } + + cairo_surface_mark_dirty(out); +} + +void FilterBlend::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input1 = slot.getcairo(_input); + cairo_surface_t *input2 = slot.getcairo(_input2); + + cairo_content_t ct1 = cairo_surface_get_content(input1); + cairo_content_t ct2 = cairo_surface_get_content(input2); + + // input2 is the "background" image + // out should be ARGB32 if any of the inputs is ARGB32 + cairo_surface_t *out = NULL; + if ((ct1 == CAIRO_CONTENT_ALPHA && ct2 == CAIRO_CONTENT_ALPHA) + || _blend_mode == BLEND_NORMAL) + { + out = ink_cairo_surface_copy(input2); + cairo_t *out_ct = cairo_create(out); + cairo_set_source_surface(out_ct, input1, 0, 0); + cairo_paint(out_ct); + cairo_destroy(out_ct); + } else { + // blend mode != normal and at least 1 surface is not pure alpha + // create surface identical to the ARGB32 surface + if (ct1 == CAIRO_CONTENT_ALPHA) { + out = ink_cairo_surface_create_identical(input2); + } else { + out = ink_cairo_surface_create_identical(input1); + } + + // TODO: convert to Cairo blending operators once we start using the 1.10 series + switch (_blend_mode) { + case BLEND_MULTIPLY: + surface_blend(input1, input2, out); + break; + case BLEND_SCREEN: + surface_blend(input1, input2, out); + break; + case BLEND_DARKEN: + surface_blend(input1, input2, out); + break; + case BLEND_LIGHTEN: + surface_blend(input1, input2, out); + break; + case BLEND_NORMAL: + default: + // this was handled before + g_assert_not_reached(); + break; + } + } + + slot.set(_output, out); + cairo_surface_destroy(out); +} + int FilterBlend::render(FilterSlot &slot, FilterUnits const & /*units*/) { NRPixBlock *in1 = slot.get(_input); NRPixBlock *in2 = slot.get(_input2); @@ -202,6 +449,12 @@ int FilterBlend::render(FilterSlot &slot, FilterUnits const & /*units*/) { return 0; } +bool FilterBlend::can_handle_affine(Geom::Matrix const &) +{ + // blend is a per-pixel primitive and is immutable under transformations + return true; +} + void FilterBlend::set_input(int slot) { _input = slot; } diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index ffdd62118..45da07f27 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -39,7 +39,9 @@ public: static FilterPrimitive *create(); virtual ~FilterBlend(); + virtual void render_cairo(FilterSlot &slot); virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual bool can_handle_affine(Geom::Matrix const &); virtual void set_input(int slot); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 2e6bed070..1e59748c4 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -32,8 +32,6 @@ #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" #include <2geom/matrix.h> #include "util/fixed_point.h" #include "preferences.h" @@ -193,21 +191,6 @@ _effect_subsample_step_log2(double const deviation, int const quality) return stepsize_l2; } -/** - * Sanity check function for indexing pixblocks. - * Catches reading and writing outside the pixblock area. - * When enabled, decreases filter rendering speed massively. - */ -static inline void -_check_index(NRPixBlock const * const pb, int const location, int const line) -{ - if (false) { - int max_loc = pb->rs * (pb->area.y1 - pb->area.y0); - if (location < 0 || location >= max_loc) - g_warning("Location %d out of bounds (0 ... %d) at line %d", location, max_loc, line); - } -} - static void calcFilter(double const sigma, double b[N]) { assert(N==3); std::complex const d1_org(1.40098, 1.00236); @@ -287,8 +270,10 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, { #if G_BYTE_ORDER == G_LITTLE_ENDIAN static unsigned int const alpha_PC = PC-1; + #define PREMUL_ALPHA_LOOP for(unsigned int c=0; c(v[0][alpha_PC]); - for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[alpha_PC]); + PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast(v[0][c], std::numeric_limits::min(), dstimg[alpha_PC]); } else { for(unsigned int c=0; c(v[0][c]); } @@ -342,7 +327,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { dstimg[alpha_PC] = clip_round_cast(v[0][alpha_PC]); - for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[alpha_PC]); + PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast(v[0][c], std::numeric_limits::min(), dstimg[alpha_PC]); } else { for(unsigned int c=0; c(v[0][c]); } @@ -457,93 +442,6 @@ filter2D_FIR(PT *const dst, int const dstr1, int const dstr2, } } -template -static void -downsample(PT *const dst, int const dstr1, int const dstr2, int const dn1, int const dn2, - PT const *const src, int const sstr1, int const sstr2, int const sn1, int const sn2, - int const step1_l2, int const step2_l2) -{ - unsigned int const divisor_l2 = step1_l2+step2_l2; // step1*step2=2^(step1_l2+step2_l2) - unsigned int const round_offset = (1<((sum[ch]+round_offset)>>divisor_l2); - } - } - } -} - -template -static void -upsample(PT *const dst, int const dstr1, int const dstr2, unsigned int const dn1, unsigned int const dn2, - PT const *const src, int const sstr1, int const sstr2, unsigned int const sn1, unsigned int const sn2, - unsigned int const step1_l2, unsigned int const step2_l2) -{ - assert(((sn1-1)<=dn1 && ((sn2-1)<=dn2); // The last pixel of the source image should fall outside the destination image - unsigned int const divisor_l2 = step1_l2+step2_l2; // step1*step2=2^(step1_l2+step2_l2) - unsigned int const round_offset = (1<(a>>divisor_l2); - - // compute a = a0*(ix-1)+a1*(xi+1)+round_offset - a = a - a0 + a1; - } - - // compute a0 = a00*(iy-1)+a01*(yi+1) and similar for a1 - a0 = a0 - a00 + a01; - a1 = a1 - a10 + a11; - } - } - } - } -} - static void gaussian_pass_IIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_surface_t *dest, IIRValue **tmpdata, int num_threads) @@ -735,315 +633,6 @@ void FilterGaussian::render_cairo(FilterSlot &slot) } } -int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) -{ - // TODO: Meaningful return values? (If they're checked at all.) - - /* in holds the input pixblock */ - NRPixBlock *original_in = slot.get(_input); - - /* If to either direction, the standard deviation is zero or - * input image is not defined, - * a transparent black image should be returned. */ - if (_deviation_x <= 0 || _deviation_y <= 0 || original_in == NULL) { - NRPixBlock *src = original_in; - if (src == NULL) { - g_warning("Missing source image for feGaussianBlur (in=%d)", _input); - // A bit guessing here, but source graphic is likely to be of - // right size - src = slot.get(NR_FILTER_SOURCEGRAPHIC); - } - NRPixBlock *out = new NRPixBlock; - nr_pixblock_setup_fast(out, src->mode, src->area.x0, src->area.y0, - src->area.x1, src->area.y1, true); - if (out->size != NR_PIXBLOCK_SIZE_TINY && out->data.px != NULL) { - out->empty = false; - slot.set(_output, out); - } - return 0; - } - - // Gaussian blur is defined to operate on non-premultiplied color values. - // So, convert the input first it uses non-premultiplied color values. - // And please note that this should not be done AFTER resampling, as resampling a non-premultiplied image - // does not simply yield a non-premultiplied version of the resampled premultiplied image!!! - NRPixBlock *in = original_in; - if (in->mode == NR_PIXBLOCK_MODE_R8G8B8A8N) { - in = nr_pixblock_new_fast(NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in->area.x0, original_in->area.y0, - original_in->area.x1, original_in->area.y1, - false); - if (!in) { - // ran out of memory - return 0; - } - nr_blit_pixblock_pixblock(in, original_in); - } - - Geom::Matrix trans = units.get_matrix_primitiveunits2pb(); - - // Some common constants - int const width_org = in->area.x1-in->area.x0, height_org = in->area.y1-in->area.y0; - double const deviation_x_org = _deviation_x * trans.expansionX(); - double const deviation_y_org = _deviation_y * trans.expansionY(); - int const PC = NR_PIXBLOCK_BPP(in); -#if HAVE_OPENMP - int const NTHREADS = std::max(1,std::min(8, Inkscape::Preferences::get()->getInt("/options/threading/numthreads", omp_get_num_procs()))); -#else - int const NTHREADS = 1; -#endif // HAVE_OPENMP - - // Subsampling constants - int const quality = slot.get_blurquality(); - int const x_step_l2 = _effect_subsample_step_log2(deviation_x_org, quality); - int const y_step_l2 = _effect_subsample_step_log2(deviation_y_org, quality); - int const x_step = 1< 1 || y_step > 1; - int const width = resampling ? static_cast(ceil(static_cast(width_org)/x_step))+1 : width_org; - int const height = resampling ? static_cast(ceil(static_cast(height_org)/y_step))+1 : height_org; - double const deviation_x = deviation_x_org / x_step; - double const deviation_y = deviation_y_org / y_step; - int const scr_len_x = _effect_area_scr(deviation_x); - int const scr_len_y = _effect_area_scr(deviation_y); - - // Decide which filter to use for X and Y - // This threshold was determined by trial-and-error for one specific machine, - // so there's a good chance that it's not optimal. - // Whatever you do, don't go below 1 (and preferrably not even below 2), as - // the IIR filter gets unstable there. - bool const use_IIR_x = deviation_x > 3; - bool const use_IIR_y = deviation_y > 3; - - // new buffer for the subsampled output - NRPixBlock *out = new NRPixBlock; - nr_pixblock_setup_fast(out, in->mode, in->area.x0/x_step, in->area.y0/y_step, - in->area.x0/x_step+width, in->area.y0/y_step+height, true); - if (out->size != NR_PIXBLOCK_SIZE_TINY && out->data.px == NULL) { - // alas, we've accomplished a lot, but ran out of memory - so abort - if (in != original_in) nr_pixblock_free(in); - delete out; - return 0; - } - // Temporary storage for IIR filter - // NOTE: This can be eliminated, but it reduces the precision a bit - IIRValue * tmpdata[NTHREADS]; - std::fill_n(tmpdata, NTHREADS, (IIRValue*)0); - if ( use_IIR_x || use_IIR_y ) { - for(int i=0; i0) { - delete[] tmpdata[i]; - } - delete out; - return 0; - } - } - } - - // Resampling (if necessary), goes from in -> out (setting ssin to out if used) - NRPixBlock *ssin = in; - if ( resampling ) { - ssin = out; - // Downsample - switch(in->mode) { - case NR_PIXBLOCK_MODE_A8: ///< Grayscale - downsample(NR_PIXBLOCK_PX(out), 1, out->rs, width, height, NR_PIXBLOCK_PX(in), 1, in->rs, width_org, height_org, x_step_l2, y_step_l2); - break; - case NR_PIXBLOCK_MODE_R8G8B8: ///< 8 bit RGB - downsample(NR_PIXBLOCK_PX(out), 3, out->rs, width, height, NR_PIXBLOCK_PX(in), 3, in->rs, width_org, height_org, x_step_l2, y_step_l2); - break; - //case NR_PIXBLOCK_MODE_R8G8B8A8N: ///< Normal 8 bit RGBA - // downsample(NR_PIXBLOCK_PX(out), 4, out->rs, width, height, NR_PIXBLOCK_PX(in), 4, in->rs, width_org, height_org, x_step_l2, y_step_l2); - // break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: ///< Premultiplied 8 bit RGBA - downsample(NR_PIXBLOCK_PX(out), 4, out->rs, width, height, NR_PIXBLOCK_PX(in), 4, in->rs, width_org, height_org, x_step_l2, y_step_l2); - break; - default: - assert(false); - }; - } - - // Horizontal filtering, goes from ssin -> out (ssin might be equal to out, but these algorithms can be used in-place) - if (use_IIR_x) { - // Filter variables - IIRValue b[N+1]; // scaling coefficient + filter coefficients (can be 10.21 fixed point) - double bf[N]; // computed filter coefficients - double M[N*N]; // matrix used for initialization procedure (has to be double) - - // Compute filter (x) - calcFilter(deviation_x, bf); - for(size_t i=0; imode) { - case NR_PIXBLOCK_MODE_A8: ///< Grayscale - filter2D_IIR(NR_PIXBLOCK_PX(out), 1, out->rs, NR_PIXBLOCK_PX(ssin), 1, ssin->rs, width, height, b, M, tmpdata, NTHREADS); - break; - case NR_PIXBLOCK_MODE_R8G8B8: ///< 8 bit RGB - filter2D_IIR(NR_PIXBLOCK_PX(out), 3, out->rs, NR_PIXBLOCK_PX(ssin), 3, ssin->rs, width, height, b, M, tmpdata, NTHREADS); - break; - //case NR_PIXBLOCK_MODE_R8G8B8A8N: ///< Normal 8 bit RGBA - // filter2D_IIR(NR_PIXBLOCK_PX(out), 4, out->rs, NR_PIXBLOCK_PX(ssin), 4, ssin->rs, width, height, b, M, tmpdata, NTHREADS); - // break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: ///< Premultiplied 8 bit RGBA - filter2D_IIR(NR_PIXBLOCK_PX(out), 4, out->rs, NR_PIXBLOCK_PX(ssin), 4, ssin->rs, width, height, b, M, tmpdata, NTHREADS); - break; - default: - assert(false); - }; - } else if ( scr_len_x > 0 ) { // !use_IIR_x - // Filter kernel for x direction - FIRValue kernel[scr_len_x+1]; - _make_kernel(kernel, deviation_x); - - // Filter (x) - switch(in->mode) { - case NR_PIXBLOCK_MODE_A8: ///< Grayscale - filter2D_FIR(NR_PIXBLOCK_PX(out), 1, out->rs, NR_PIXBLOCK_PX(ssin), 1, ssin->rs, width, height, kernel, scr_len_x, NTHREADS); - break; - case NR_PIXBLOCK_MODE_R8G8B8: ///< 8 bit RGB - filter2D_FIR(NR_PIXBLOCK_PX(out), 3, out->rs, NR_PIXBLOCK_PX(ssin), 3, ssin->rs, width, height, kernel, scr_len_x, NTHREADS); - break; - //case NR_PIXBLOCK_MODE_R8G8B8A8N: ///< Normal 8 bit RGBA - // filter2D_FIR(NR_PIXBLOCK_PX(out), 4, out->rs, NR_PIXBLOCK_PX(ssin), 4, ssin->rs, width, height, kernel, scr_len_x, NTHREADS); - // break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: ///< Premultiplied 8 bit RGBA - filter2D_FIR(NR_PIXBLOCK_PX(out), 4, out->rs, NR_PIXBLOCK_PX(ssin), 4, ssin->rs, width, height, kernel, scr_len_x, NTHREADS); - break; - default: - assert(false); - }; - } else if ( out != ssin ) { // out can be equal to ssin if resampling is used - nr_blit_pixblock_pixblock(out, ssin); - } - - // Vertical filtering, goes from out -> out - if (use_IIR_y) { - // Filter variables - IIRValue b[N+1]; // scaling coefficient + filter coefficients (can be 10.21 fixed point) - double bf[N]; // computed filter coefficients - double M[N*N]; // matrix used for initialization procedure (has to be double) - - // Compute filter (y) - calcFilter(deviation_y, bf); - for(size_t i=0; imode) { - case NR_PIXBLOCK_MODE_A8: ///< Grayscale - filter2D_IIR(NR_PIXBLOCK_PX(out), out->rs, 1, NR_PIXBLOCK_PX(out), out->rs, 1, height, width, b, M, tmpdata, NTHREADS); - break; - case NR_PIXBLOCK_MODE_R8G8B8: ///< 8 bit RGB - filter2D_IIR(NR_PIXBLOCK_PX(out), out->rs, 3, NR_PIXBLOCK_PX(out), out->rs, 3, height, width, b, M, tmpdata, NTHREADS); - break; - //case NR_PIXBLOCK_MODE_R8G8B8A8N: ///< Normal 8 bit RGBA - // filter2D_IIR(NR_PIXBLOCK_PX(out), out->rs, 4, NR_PIXBLOCK_PX(out), out->rs, 4, height, width, b, M, tmpdata, NTHREADS); - // break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: ///< Premultiplied 8 bit RGBA - filter2D_IIR(NR_PIXBLOCK_PX(out), out->rs, 4, NR_PIXBLOCK_PX(out), out->rs, 4, height, width, b, M, tmpdata, NTHREADS); - break; - default: - assert(false); - }; - } else if ( scr_len_y > 0 ) { // !use_IIR_y - // Filter kernel for y direction - FIRValue kernel[scr_len_y+1]; - _make_kernel(kernel, deviation_y); - - // Filter (y) - switch(in->mode) { - case NR_PIXBLOCK_MODE_A8: ///< Grayscale - filter2D_FIR(NR_PIXBLOCK_PX(out), out->rs, 1, NR_PIXBLOCK_PX(out), out->rs, 1, height, width, kernel, scr_len_y, NTHREADS); - break; - case NR_PIXBLOCK_MODE_R8G8B8: ///< 8 bit RGB - filter2D_FIR(NR_PIXBLOCK_PX(out), out->rs, 3, NR_PIXBLOCK_PX(out), out->rs, 3, height, width, kernel, scr_len_y, NTHREADS); - break; - //case NR_PIXBLOCK_MODE_R8G8B8A8N: ///< Normal 8 bit RGBA - // filter2D_FIR(NR_PIXBLOCK_PX(out), out->rs, 4, NR_PIXBLOCK_PX(out), out->rs, 4, height, width, kernel, scr_len_y, NTHREADS); - // break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: ///< Premultiplied 8 bit RGBA - filter2D_FIR(NR_PIXBLOCK_PX(out), out->rs, 4, NR_PIXBLOCK_PX(out), out->rs, 4, height, width, kernel, scr_len_y, NTHREADS); - break; - default: - assert(false); - }; - } - - for(int i=0; iempty = FALSE; - slot.set(_output, out); - } else { - // New buffer for the final output, same resolution as the in buffer - NRPixBlock *finalout = new NRPixBlock; - nr_pixblock_setup_fast(finalout, in->mode, in->area.x0, in->area.y0, - in->area.x1, in->area.y1, true); - if (finalout->size != NR_PIXBLOCK_SIZE_TINY && finalout->data.px == NULL) { - // alas, we've accomplished a lot, but ran out of memory - so abort - if (in != original_in) nr_pixblock_free(in); - nr_pixblock_release(out); - delete out; - return 0; - } - - // Upsample - switch(in->mode) { - case NR_PIXBLOCK_MODE_A8: ///< Grayscale - upsample(NR_PIXBLOCK_PX(finalout), 1, finalout->rs, width_org, height_org, NR_PIXBLOCK_PX(out), 1, out->rs, width, height, x_step_l2, y_step_l2); - break; - case NR_PIXBLOCK_MODE_R8G8B8: ///< 8 bit RGB - upsample(NR_PIXBLOCK_PX(finalout), 3, finalout->rs, width_org, height_org, NR_PIXBLOCK_PX(out), 3, out->rs, width, height, x_step_l2, y_step_l2); - break; - //case NR_PIXBLOCK_MODE_R8G8B8A8N: ///< Normal 8 bit RGBA - // upsample(NR_PIXBLOCK_PX(finalout), 4, finalout->rs, width_org, height_org, NR_PIXBLOCK_PX(out), 4, out->rs, width, height, x_step_l2, y_step_l2); - // break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: ///< Premultiplied 8 bit RGBA - upsample(NR_PIXBLOCK_PX(finalout), 4, finalout->rs, width_org, height_org, NR_PIXBLOCK_PX(out), 4, out->rs, width, height, x_step_l2, y_step_l2); - break; - default: - assert(false); - }; - - // We don't need the out buffer anymore - nr_pixblock_release(out); - delete out; - - // The final out buffer gets returned - finalout->empty = FALSE; - slot.set(_output, finalout); - } - - // If we downsampled the input, clean up the downsampled data - if (in != original_in) nr_pixblock_free(in); - - return 0; -} - void FilterGaussian::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { int area_x = _effect_area_scr(_deviation_x * trans.expansionX()); @@ -1057,8 +646,14 @@ void FilterGaussian::area_enlarge(NRRectL &area, Geom::Matrix const &trans) area.y1 += area_max; } -FilterTraits FilterGaussian::get_input_traits() { - return TRAIT_PARALLER; +bool FilterGaussian::can_handle_affine(Geom::Matrix const &m) +{ + if (Geom::are_near(_deviation_x, _deviation_y)) { + // TODO after 2Geom sync, change this to m.preservesAngles() + return Geom::are_near(m[0], m[3]) && Geom::are_near(m[1], -m[2]); + } else { + return false; + } } void FilterGaussian::set_deviation(double deviation) diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 7bcabdba9..01ce9efcb 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -39,9 +39,8 @@ public: virtual ~FilterGaussian(); virtual void render_cairo(FilterSlot &slot); - virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &m); - virtual FilterTraits get_input_traits(); + virtual bool can_handle_affine(Geom::Matrix const &m); /** * Set the standard deviation value for gaussian blur. Deviation along diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index a7ae0125e..89927fdbd 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -44,7 +44,7 @@ public: virtual ~FilterPrimitive(); virtual void render_cairo(FilterSlot &slot); - virtual int render(FilterSlot &slot, FilterUnits const &units) = 0; + virtual int render(FilterSlot &slot, FilterUnits const &units) { return 0; } virtual void area_enlarge(NRRectL &area, Geom::Matrix const &m); /** @@ -109,6 +109,20 @@ public: */ virtual FilterTraits get_input_traits(); + /** @brief Indicate whether the filter primitive can handle the given affine. + * + * Results of some filter primitives depend on the coordinate system used when rendering. + * A gaussian blur will equal x and y deviation will remain unchanged by rotations. + * Per-pixel filters like color matrix and blend will not change regardless of + * the transformation. + * + * When any filter returns false, filter rendering is performed on an intermediate surface + * with edges parallel to the axes of the user coordinate system. This means + * the matrices from FilterUnits will contain at most a (possibly non-uniform) scale + * and a translation. When all primitives of the filter return false, the rendering is + * performed in display coordinate space and no intermediate surface is used. */ + virtual bool can_handle_affine(Geom::Matrix const &) { return false; } + protected: int _input; int _output; diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index d700cd433..5371499e4 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -20,7 +20,6 @@ #include "display/nr-filter-types.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-slot.h" -#include "display/nr-filter-getalpha.h" #include "display/nr-filter-units.h" #include "display/pixblock-scaler.h" #include "display/pixblock-transform.h" @@ -131,10 +130,9 @@ cairo_surface_t *FilterSlot::getcairo(int slot_nr) cairo_surface_destroy(tr); } break; case NR_FILTER_BACKGROUNDIMAGE: { - // TODO - //cairo_surface_t *bg = _get_transformed_background(); - //_set_internal(NR_FILTER_BACKGROUNDIMAGE, bg); - //cairo_surface_destroy(bg); + cairo_surface_t *bg = _get_transformed_background(); + _set_internal(NR_FILTER_BACKGROUNDIMAGE, bg); + cairo_surface_destroy(bg); } break; case NR_FILTER_SOURCEALPHA: { cairo_surface_t *src = getcairo(NR_FILTER_SOURCEGRAPHIC); @@ -158,8 +156,12 @@ cairo_surface_t *FilterSlot::getcairo(int slot_nr) if (s == _slots.end()) { // create empty surface - // TODO - return NULL; + cairo_surface_t *empty = cairo_surface_create_similar( + _source_graphic, cairo_surface_get_content(_source_graphic), + _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); + _set_internal(slot_nr, empty); + cairo_surface_destroy(empty); + s = _slots.find(slot_nr); } return s->second; @@ -189,7 +191,23 @@ cairo_surface_t *FilterSlot::_get_transformed_source_graphic() cairo_surface_t *FilterSlot::_get_transformed_background() { - return NULL; + Geom::Matrix trans = _units.get_matrix_display2pb(); + + cairo_surface_t *bg = cairo_get_target(_background_ct); + cairo_surface_t *tbg = cairo_surface_create_similar( + bg, cairo_surface_get_content(bg), + _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); + cairo_t *tbg_ct = cairo_create(tbg); + + cairo_translate(tbg_ct, -_slot_area.x0, -_slot_area.y0); + ink_cairo_transform(tbg_ct, trans); + cairo_translate(tbg_ct, _background_area->x0, _background_area->y0); + cairo_set_source_surface(tbg_ct, bg, 0, 0); + cairo_set_operator(tbg_ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(tbg_ct); + cairo_destroy(tbg_ct); + + return tbg; } cairo_surface_t *FilterSlot::get_result(int res) @@ -299,11 +317,6 @@ void FilterSlot::set(int slot_nr, cairo_surface_t *surface) trans[1] * x1 + trans[3] * y0 + trans[5], trans[1] * x1 + trans[3] * y1 + trans[5]); - cairo_surface_t *trans_s = cairo_surface_create_similar(s, - CAIRO_CONTENT_COLOR, max_x - min_x, max_y - min_y); - cairo_t *ct = cairo_create(trans_s); - - nr_pixblock_setup_fast(trans_pb, pb->mode, min_x, min_y, max_x, max_y, true); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 363663ac3..298531db0 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -22,9 +22,9 @@ #include "filter-enums.h" #include "filters/blend.h" +#include "filters/gaussian-blur.h" #include "sp-filter.h" #include "sp-filter-reference.h" -#include "sp-gaussian-blur.h" #include "svg/css-ostringstream.h" #include "libnr/nr-matrix-fns.h" diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index 1b18ec11a..67531d630 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -1,6 +1,3 @@ -#ifndef __SP_FILTER_CHEMISTRY_H__ -#define __SP_FILTER_CHEMISTRY_H__ - /* * Various utility methods for filters * @@ -14,8 +11,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_FILTER_CHEMISTRY_H +#define SEEN_SP_FILTER_CHEMISTRY_H + #include "forward.h" -#include "sp-filter.h" +#include "display/nr-filter-types.h" + +class SPFilter; +class SPFilterPrimitive; SPFilterPrimitive *filter_add_primitive(SPFilter *filter, Inkscape::Filters::FilterPrimitiveType); SPFilter *new_filter (SPDocument *document); diff --git a/src/filters/Makefile_insert b/src/filters/Makefile_insert index dde7cdb68..ea9ff4b56 100644 --- a/src/filters/Makefile_insert +++ b/src/filters/Makefile_insert @@ -1,59 +1,46 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ - filters/blend.cpp \ - filters/blend-fns.h \ - filters/blend.h \ - filters/colormatrix.cpp \ - filters/colormatrix-fns.h \ - filters/colormatrix.h \ - filters/componenttransfer.cpp \ - filters/componenttransfer-fns.h \ + filters/blend.cpp \ + filters/blend.h \ + filters/colormatrix.cpp \ + filters/colormatrix.h \ + filters/componenttransfer.cpp \ filters/componenttransfer-funcnode.cpp \ filters/componenttransfer-funcnode.h \ - filters/componenttransfer.h \ - filters/composite.cpp \ - filters/composite-fns.h \ - filters/composite.h \ - filters/convolvematrix.cpp \ - filters/convolvematrix-fns.h \ - filters/convolvematrix.h \ - filters/diffuselighting.cpp \ - filters/diffuselighting-fns.h \ - filters/diffuselighting.h \ - filters/displacementmap.cpp \ - filters/displacementmap-fns.h \ - filters/displacementmap.h \ - filters/distantlight.cpp \ - filters/distantlight.h \ - filters/flood.cpp \ - filters/flood-fns.h \ - filters/flood.h \ - filters/image.cpp \ - filters/image-fns.h \ - filters/image.h \ - filters/merge.cpp \ - filters/merge-fns.h \ - filters/merge.h \ - filters/mergenode.cpp \ - filters/mergenode.h \ - filters/morphology.cpp \ - filters/morphology-fns.h \ - filters/morphology.h \ - filters/offset.cpp \ - filters/offset-fns.h \ - filters/offset.h \ - filters/pointlight.cpp \ - filters/pointlight.h \ - filters/specularlighting.cpp \ - filters/specularlighting-fns.h \ - filters/specularlighting.h \ - filters/spotlight.cpp \ - filters/spotlight.h \ - filters/tile.cpp \ - filters/tile-fns.h \ - filters/tile.h \ - filters/turbulence.cpp \ - filters/turbulence-fns.h \ + filters/componenttransfer.h \ + filters/composite.cpp \ + filters/composite.h \ + filters/convolvematrix.cpp \ + filters/convolvematrix.h \ + filters/diffuselighting.cpp \ + filters/diffuselighting.h \ + filters/displacementmap.cpp \ + filters/displacementmap.h \ + filters/distantlight.cpp \ + filters/distantlight.h \ + filters/flood.cpp \ + filters/flood.h \ + filters/gaussian-blur.cpp \ + filters/gaussian-blur.h \ + filters/image.cpp \ + filters/image.h \ + filters/merge.cpp \ + filters/merge.h \ + filters/mergenode.cpp \ + filters/mergenode.h \ + filters/morphology.cpp \ + filters/morphology.h \ + filters/offset.cpp \ + filters/offset.h \ + filters/pointlight.cpp \ + filters/pointlight.h \ + filters/specularlighting.cpp \ + filters/specularlighting.h \ + filters/spotlight.cpp \ + filters/spotlight.h \ + filters/tile.cpp \ + filters/tile.h \ + filters/turbulence.cpp \ filters/turbulence.h diff --git a/src/filters/blend-fns.h b/src/filters/blend-fns.h deleted file mode 100644 index f08ed9dd1..000000000 --- a/src/filters/blend-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEBLEND_FNS_H -#define SP_FEBLEND_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeBlend; - -#define SP_TYPE_FEBLEND (sp_feBlend_get_type()) -#define SP_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEBLEND, SPFeBlend)) -#define SP_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEBLEND, SPFeBlendClass)) -#define SP_IS_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEBLEND)) -#define SP_IS_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEBLEND)) - -GType sp_feBlend_get_type(); - -#endif /* !SP_FEBLEND_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 5998d7be3..795cbff20 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -20,9 +20,10 @@ #include +#include "sp-filter.h" +#include "filters/blend.h" #include "attributes.h" #include "svg/svg.h" -#include "blend.h" #include "xml/repr.h" #include "display/nr-filter.h" diff --git a/src/filters/blend.h b/src/filters/blend.h index 9f3cab475..4fd763166 100644 --- a/src/filters/blend.h +++ b/src/filters/blend.h @@ -1,10 +1,6 @@ -#ifndef SP_FEBLEND_H_SEEN -#define SP_FEBLEND_H_SEEN - -/** \file - * SVG implementation, see Blend.cpp. - */ -/* +/** @file + * @brief SVG blend filter effect + *//* * Authors: * Hugo Rodrigues * Niko Kiirala @@ -14,16 +10,21 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "blend-fns.h" +#ifndef SP_FEBLEND_H_SEEN +#define SP_FEBLEND_H_SEEN +#include "sp-filter-primitive.h" #include "display/nr-filter-blend.h" -/* FeBlend base class */ +#define SP_TYPE_FEBLEND (sp_feBlend_get_type()) +#define SP_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEBLEND, SPFeBlend)) +#define SP_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEBLEND, SPFeBlendClass)) +#define SP_IS_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEBLEND)) +#define SP_IS_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEBLEND)) + class SPFeBlendClass; struct SPFeBlend : public SPFilterPrimitive { - /** BLEND ATTRIBUTES HERE */ Inkscape::Filters::FilterBlendMode blend_mode; int in2; }; diff --git a/src/filters/colormatrix-fns.h b/src/filters/colormatrix-fns.h deleted file mode 100644 index 3a4a8d35c..000000000 --- a/src/filters/colormatrix-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FECOLORMATRIX_FNS_H -#define SP_FECOLORMATRIX_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeColorMatrix; - -#define SP_TYPE_FECOLORMATRIX (sp_feColorMatrix_get_type()) -#define SP_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOLORMATRIX, SPFeColorMatrix)) -#define SP_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOLORMATRIX, SPFeColorMatrixClass)) -#define SP_IS_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOLORMATRIX)) -#define SP_IS_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOLORMATRIX)) - -GType sp_feColorMatrix_get_type(); - -#endif /* !SP_FECOLORMATRIX_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index 3f60ea05c..07567cce6 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -27,6 +27,7 @@ #include "xml/repr.h" #include "helper-fns.h" +#include "display/nr-filter.h" #include "display/nr-filter-colormatrix.h" /* FeColorMatrix base class */ diff --git a/src/filters/colormatrix.h b/src/filters/colormatrix.h index 69be96928..71c19db4d 100644 --- a/src/filters/colormatrix.h +++ b/src/filters/colormatrix.h @@ -1,10 +1,6 @@ -#ifndef SP_FECOLORMATRIX_H_SEEN -#define SP_FECOLORMATRIX_H_SEEN - -/** \file - * SVG implementation, see ColorMatrix.cpp. - */ -/* +/** @file + * @brief SVG color matrix filter effect + *//* * Authors: * Hugo Rodrigues * @@ -12,17 +8,22 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SP_FECOLORMATRIX_H_SEEN +#define SP_FECOLORMATRIX_H_SEEN -#include "sp-filter.h" -#include "colormatrix-fns.h" -#include "display/nr-filter-colormatrix.h" #include +#include "sp-filter-primitive.h" +#include "display/nr-filter-colormatrix.h" + +#define SP_TYPE_FECOLORMATRIX (sp_feColorMatrix_get_type()) +#define SP_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOLORMATRIX, SPFeColorMatrix)) +#define SP_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOLORMATRIX, SPFeColorMatrixClass)) +#define SP_IS_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOLORMATRIX)) +#define SP_IS_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOLORMATRIX)) -/* FeColorMatrix base class */ class SPFeColorMatrixClass; struct SPFeColorMatrix : public SPFilterPrimitive { - /** COLORMATRIX ATTRIBUTES HERE */ Inkscape::Filters::FilterColorMatrixType type; gdouble value; std::vector values; @@ -34,7 +35,6 @@ struct SPFeColorMatrixClass { GType sp_feColorMatrix_get_type(); - #endif /* !SP_FECOLORMATRIX_H_SEEN */ /* diff --git a/src/filters/componenttransfer-fns.h b/src/filters/componenttransfer-fns.h deleted file mode 100644 index 49983770a..000000000 --- a/src/filters/componenttransfer-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FECOMPONENTTRANSFER_FNS_H -#define SP_FECOMPONENTTRANSFER_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeComponentTransfer; - -#define SP_TYPE_FECOMPONENTTRANSFER (sp_feComponentTransfer_get_type()) -#define SP_FECOMPONENTTRANSFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOMPONENTTRANSFER, SPFeComponentTransfer)) -#define SP_FECOMPONENTTRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOMPONENTTRANSFER, SPFeComponentTransferClass)) -#define SP_IS_FECOMPONENTTRANSFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOMPONENTTRANSFER)) -#define SP_IS_FECOMPONENTTRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOMPONENTTRANSFER)) - -GType sp_feComponentTransfer_get_type(); - -#endif /* !SP_FECOMPONENTTRANSFER_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 27e63eaa6..4853ab8cd 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -22,9 +22,10 @@ #include "document.h" #include "attributes.h" #include "svg/svg.h" -#include "componenttransfer.h" -#include "componenttransfer-funcnode.h" +#include "filters/componenttransfer.h" +#include "filters/componenttransfer-funcnode.h" #include "xml/repr.h" +#include "display/nr-filter.h" #include "display/nr-filter-component-transfer.h" /* FeComponentTransfer base class */ diff --git a/src/filters/componenttransfer.h b/src/filters/componenttransfer.h index 8281d9aea..be66d5a82 100644 --- a/src/filters/componenttransfer.h +++ b/src/filters/componenttransfer.h @@ -1,10 +1,6 @@ -#ifndef SP_FECOMPONENTTRANSFER_H_SEEN -#define SP_FECOMPONENTTRANSFER_H_SEEN - -/** \file - * SVG implementation, see ComponentTransfer.cpp. - */ -/* +/** @file + * @brief SVG component transferfilter effect + *//* * Authors: * Hugo Rodrigues * @@ -12,18 +8,25 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SP_FECOMPONENTTRANSFER_H_SEEN +#define SP_FECOMPONENTTRANSFER_H_SEEN + +#include "sp-filter-primitive.h" -#include "sp-filter.h" -#include "componenttransfer-fns.h" -#include "display/nr-filter-component-transfer.h" -#include +#define SP_TYPE_FECOMPONENTTRANSFER (sp_feComponentTransfer_get_type()) +#define SP_FECOMPONENTTRANSFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOMPONENTTRANSFER, SPFeComponentTransfer)) +#define SP_FECOMPONENTTRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOMPONENTTRANSFER, SPFeComponentTransferClass)) +#define SP_IS_FECOMPONENTTRANSFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOMPONENTTRANSFER)) +#define SP_IS_FECOMPONENTTRANSFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOMPONENTTRANSFER)) + +namespace Inkscape { +namespace Filters { +class FilterComponentTransfer; +} } -/* FeComponentTransfer base class */ class SPFeComponentTransferClass; struct SPFeComponentTransfer : public SPFilterPrimitive { - /** COMPONENTTRANSFER ATTRIBUTES HERE */ - Inkscape::Filters::FilterComponentTransfer *renderer; }; diff --git a/src/filters/composite-fns.h b/src/filters/composite-fns.h deleted file mode 100644 index c79cb17bb..000000000 --- a/src/filters/composite-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FECOMPOSITE_FNS_H -#define SP_FECOMPOSITE_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeComposite; - -#define SP_TYPE_FECOMPOSITE (sp_feComposite_get_type()) -#define SP_FECOMPOSITE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOMPOSITE, SPFeComposite)) -#define SP_FECOMPOSITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOMPOSITE, SPFeCompositeClass)) -#define SP_IS_FECOMPOSITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOMPOSITE)) -#define SP_IS_FECOMPOSITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOMPOSITE)) - -GType sp_feComposite_get_type(); - -#endif /* !SP_FECOMPOSITE_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 93c692f94..0c534e01d 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -19,10 +19,12 @@ #include "attributes.h" #include "svg/svg.h" -#include "composite.h" +#include "filters/composite.h" #include "helper-fns.h" #include "xml/repr.h" +#include "display/nr-filter.h" #include "display/nr-filter-composite.h" +#include "sp-filter.h" /* FeComposite base class */ diff --git a/src/filters/composite.h b/src/filters/composite.h index 095d7616d..126d8e71b 100644 --- a/src/filters/composite.h +++ b/src/filters/composite.h @@ -1,10 +1,6 @@ -#ifndef SP_FECOMPOSITE_H_SEEN -#define SP_FECOMPOSITE_H_SEEN - -/** \file - * SVG implementation, see Composite.cpp. - */ -/* +/** @file + * @brief SVG composite filter effect + *//* * Authors: * Hugo Rodrigues * @@ -12,9 +8,16 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SP_FECOMPOSITE_H_SEEN +#define SP_FECOMPOSITE_H_SEEN -#include "sp-filter.h" -#include "composite-fns.h" +#include "sp-filter-primitive.h" + +#define SP_TYPE_FECOMPOSITE (sp_feComposite_get_type()) +#define SP_FECOMPOSITE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOMPOSITE, SPFeComposite)) +#define SP_FECOMPOSITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOMPOSITE, SPFeCompositeClass)) +#define SP_IS_FECOMPOSITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOMPOSITE)) +#define SP_IS_FECOMPOSITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOMPOSITE)) enum FeCompositeOperator { // Default value is 'over', but let's distinquish specifying the @@ -29,7 +32,6 @@ enum FeCompositeOperator { COMPOSITE_ENDOPERATOR }; -/* FeComposite base class */ class SPFeCompositeClass; struct SPFeComposite : public SPFilterPrimitive { @@ -44,7 +46,6 @@ struct SPFeCompositeClass { GType sp_feComposite_get_type(); - #endif /* !SP_FECOMPOSITE_H_SEEN */ /* diff --git a/src/filters/convolvematrix-fns.h b/src/filters/convolvematrix-fns.h deleted file mode 100644 index 76baf7f41..000000000 --- a/src/filters/convolvematrix-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FECONVOLVEMATRIX_FNS_H -#define SP_FECONVOLVEMATRIX_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeConvolveMatrix; - -#define SP_TYPE_FECONVOLVEMATRIX (sp_feConvolveMatrix_get_type()) -#define SP_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECONVOLVEMATRIX, SPFeConvolveMatrix)) -#define SP_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECONVOLVEMATRIX, SPFeConvolveMatrixClass)) -#define SP_IS_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECONVOLVEMATRIX)) -#define SP_IS_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECONVOLVEMATRIX)) - -GType sp_feConvolveMatrix_get_type(); - -#endif /* !SP_FECONVOLVEMATRIX_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index 6440f340a..4444b82ce 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -19,15 +19,15 @@ #endif #include - +#include #include #include "attributes.h" #include "svg/svg.h" -#include "convolvematrix.h" +#include "filters/convolvematrix.h" #include "helper-fns.h" #include "xml/repr.h" +#include "display/nr-filter.h" #include "display/nr-filter-convolve-matrix.h" -#include /* FeConvolveMatrix base class */ diff --git a/src/filters/convolvematrix.h b/src/filters/convolvematrix.h index 1e8545040..11120698d 100644 --- a/src/filters/convolvematrix.h +++ b/src/filters/convolvematrix.h @@ -1,8 +1,5 @@ -#ifndef SP_FECONVOLVEMATRIX_H_SEEN -#define SP_FECONVOLVEMATRIX_H_SEEN - -/** \file - * SVG implementation, see ConvolveMatrix.cpp. +/** @file + * @brief SVG matrix convolution filter effect */ /* * Authors: @@ -13,18 +10,23 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SP_FECONVOLVEMATRIX_H_SEEN +#define SP_FECONVOLVEMATRIX_H_SEEN -#include "sp-filter.h" -#include "convolvematrix-fns.h" +#include +#include "sp-filter-primitive.h" #include "number-opt-number.h" #include "display/nr-filter-convolve-matrix.h" -#include -/* FeConvolveMatrix base class */ +#define SP_TYPE_FECONVOLVEMATRIX (sp_feConvolveMatrix_get_type()) +#define SP_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECONVOLVEMATRIX, SPFeConvolveMatrix)) +#define SP_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECONVOLVEMATRIX, SPFeConvolveMatrixClass)) +#define SP_IS_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECONVOLVEMATRIX)) +#define SP_IS_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECONVOLVEMATRIX)) + class SPFeConvolveMatrixClass; struct SPFeConvolveMatrix : public SPFilterPrimitive { - /* CONVOLVEMATRIX ATTRIBUTES */ NumberOptNumber order; std::vector kernelMatrix; double divisor, bias; @@ -32,7 +34,7 @@ struct SPFeConvolveMatrix : public SPFilterPrimitive { Inkscape::Filters::FilterConvolveMatrixEdgeMode edgeMode; NumberOptNumber kernelUnitLength; bool preserveAlpha; - //some helper variables: + bool targetXIsSet; bool targetYIsSet; bool divisorIsSet; @@ -45,7 +47,6 @@ struct SPFeConvolveMatrixClass { GType sp_feConvolveMatrix_get_type(); - #endif /* !SP_FECONVOLVEMATRIX_H_SEEN */ /* diff --git a/src/filters/diffuselighting-fns.h b/src/filters/diffuselighting-fns.h deleted file mode 100644 index b91ed80f6..000000000 --- a/src/filters/diffuselighting-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEDIFFUSELIGHTING_FNS_H -#define SP_FEDIFFUSELIGHTING_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeDiffuseLighting; - -#define SP_TYPE_FEDIFFUSELIGHTING (sp_feDiffuseLighting_get_type()) -#define SP_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLighting)) -#define SP_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLightingClass)) -#define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) -#define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) - -GType sp_feDiffuseLighting_get_type(); - -#endif /* !SP_FEDIFFUSELIGHTING_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index bdc569083..117b9d145 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -23,7 +23,8 @@ #include "svg/svg.h" #include "sp-object.h" #include "svg/svg-color.h" -#include "diffuselighting.h" +#include "filters/diffuselighting.h" +#include "display/nr-filter.h" #include "xml/repr.h" #include "display/nr-filter-diffuselighting.h" diff --git a/src/filters/diffuselighting.h b/src/filters/diffuselighting.h index 3c6c0ae73..0cb62c5a7 100644 --- a/src/filters/diffuselighting.h +++ b/src/filters/diffuselighting.h @@ -1,46 +1,46 @@ -#ifndef SP_FEDIFFUSELIGHTING_H_SEEN -#define SP_FEDIFFUSELIGHTING_H_SEEN - -/** \file - * SVG implementation, see DiffuseLighting.cpp. - */ -/* +/** @file + * @brief SVG diffuse lighting filter effect + *//* * Authors: * Hugo Rodrigues * Jean-Rene Reinhard * - * Copyright (C) 2006 Hugo Rodrigues - * 2007 authors - * + * Copyright (C) 2006-2007 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "diffuselighting-fns.h" +#ifndef SP_FEDIFFUSELIGHTING_H_SEEN +#define SP_FEDIFFUSELIGHTING_H_SEEN + +#include "sp-filter-primitive.h" +#include "number-opt-number.h" namespace Inkscape { namespace Filters { class FilterDiffuseLighting; -} -} +} } + +#define SP_TYPE_FEDIFFUSELIGHTING (sp_feDiffuseLighting_get_type()) +#define SP_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLighting)) +#define SP_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLightingClass)) +#define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) +#define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) + +namespace Inkscape { +namespace Filters { +class FilterDiffuseLighting; +} } -/* FeDiffuseLighting base class */ class SPFeDiffuseLightingClass; struct SPFeDiffuseLighting : public SPFilterPrimitive { - /** DIFFUSELIGHTING ATTRIBUTES HERE */ - /** surfaceScale attribute */ gfloat surfaceScale; guint surfaceScale_set : 1; - /** diffuseConstant attribute */ gfloat diffuseConstant; guint diffuseConstant_set : 1; - /** kernelUnitLength attribute */ NumberOptNumber kernelUnitLength; - /** lighting-color property */ guint32 lighting_color; guint lighting_color_set : 1; - /** pointer to the associated renderer */ Inkscape::Filters::FilterDiffuseLighting *renderer; }; @@ -50,7 +50,6 @@ struct SPFeDiffuseLightingClass { GType sp_feDiffuseLighting_get_type(); - #endif /* !SP_FEDIFFUSELIGHTING_H_SEEN */ /* diff --git a/src/filters/displacementmap-fns.h b/src/filters/displacementmap-fns.h deleted file mode 100644 index 6d92c6b78..000000000 --- a/src/filters/displacementmap-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEDISPLACEMENTMAP_FNS_H -#define SP_FEDISPLACEMENTMAP_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeDisplacementMap; - -#define SP_TYPE_FEDISPLACEMENTMAP (sp_feDisplacementMap_get_type()) -#define SP_FEDISPLACEMENTMAP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDISPLACEMENTMAP, SPFeDisplacementMap)) -#define SP_FEDISPLACEMENTMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDISPLACEMENTMAP, SPFeDisplacementMapClass)) -#define SP_IS_FEDISPLACEMENTMAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDISPLACEMENTMAP)) -#define SP_IS_FEDISPLACEMENTMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDISPLACEMENTMAP)) - -GType sp_feDisplacementMap_get_type(); - -#endif /* !SP_FEDISPLACEMENTMAP_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index baa17d785..cfa8e427e 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -19,10 +19,12 @@ #include "attributes.h" #include "svg/svg.h" -#include "displacementmap.h" +#include "filters/displacementmap.h" #include "xml/repr.h" -#include "display/nr-filter-displacement-map.h" +#include "sp-filter.h" #include "helper-fns.h" +#include "display/nr-filter.h" +#include "display/nr-filter-displacement-map.h" /* FeDisplacementMap base class */ diff --git a/src/filters/displacementmap.h b/src/filters/displacementmap.h index 6a8ac9cd9..414b3e663 100644 --- a/src/filters/displacementmap.h +++ b/src/filters/displacementmap.h @@ -1,10 +1,6 @@ -#ifndef SP_FEDISPLACEMENTMAP_H_SEEN -#define SP_FEDISPLACEMENTMAP_H_SEEN - /** \file - * SVG implementation, see DisplacementMap.cpp. - */ -/* + * SVG displacement map filter effect + *//* * Authors: * Hugo Rodrigues * @@ -13,8 +9,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "displacementmap-fns.h" +#ifndef SP_FEDISPLACEMENTMAP_H_SEEN +#define SP_FEDISPLACEMENTMAP_H_SEEN + +#include "sp-filter-primitive.h" + +#define SP_TYPE_FEDISPLACEMENTMAP (sp_feDisplacementMap_get_type()) +#define SP_FEDISPLACEMENTMAP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDISPLACEMENTMAP, SPFeDisplacementMap)) +#define SP_FEDISPLACEMENTMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDISPLACEMENTMAP, SPFeDisplacementMapClass)) +#define SP_IS_FEDISPLACEMENTMAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDISPLACEMENTMAP)) +#define SP_IS_FEDISPLACEMENTMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDISPLACEMENTMAP)) enum FilterDisplacementMapChannelSelector { DISPLACEMENTMAP_CHANNEL_RED, @@ -24,11 +28,9 @@ enum FilterDisplacementMapChannelSelector { DISPLACEMENTMAP_CHANNEL_ENDTYPE }; -/* FeDisplacementMap base class */ class SPFeDisplacementMapClass; struct SPFeDisplacementMap : public SPFilterPrimitive { - /** DISPLACEMENTMAP ATTRIBUTES HERE */ int in2; double scale; FilterDisplacementMapChannelSelector xChannelSelector; @@ -41,7 +43,6 @@ struct SPFeDisplacementMapClass { GType sp_feDisplacementMap_get_type(); - #endif /* !SP_FEDISPLACEMENTMAP_H_SEEN */ /* diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 41584c4a4..de33d967e 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -22,9 +22,9 @@ #include "attributes.h" #include "document.h" -#include "distantlight.h" -#include "diffuselighting-fns.h" -#include "specularlighting-fns.h" +#include "filters/distantlight.h" +#include "filters/diffuselighting.h" +#include "filters/specularlighting.h" #include "xml/repr.h" #define SP_MACROS_SILENT diff --git a/src/filters/flood-fns.h b/src/filters/flood-fns.h deleted file mode 100644 index 8cc507274..000000000 --- a/src/filters/flood-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEFLOOD_FNS_H -#define SP_FEFLOOD_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeFlood; - -#define SP_TYPE_FEFLOOD (sp_feFlood_get_type()) -#define SP_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEFLOOD, SPFeFlood)) -#define SP_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEFLOOD, SPFeFloodClass)) -#define SP_IS_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFLOOD)) -#define SP_IS_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFLOOD)) - -GType sp_feFlood_get_type(); - -#endif /* !SP_FEFLOOD_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp index 221b0daf2..8b7d4c5cd 100644 --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@ -21,9 +21,12 @@ #include "attributes.h" #include "svg/svg.h" -#include "flood.h" +#include "svg/svg-color.h" +#include "filters/flood.h" #include "xml/repr.h" #include "helper-fns.h" +#include "display/nr-filter.h" +#include "display/nr-filter-flood.h" /* FeFlood base class */ diff --git a/src/filters/flood.h b/src/filters/flood.h index f386e2cd4..220faca83 100644 --- a/src/filters/flood.h +++ b/src/filters/flood.h @@ -1,10 +1,6 @@ -#ifndef SP_FEFLOOD_H_SEEN -#define SP_FEFLOOD_H_SEEN - -/** \file - * SVG implementation, see Flood.cpp. - */ -/* +/** @file + * @brief SVG flood filter effect + *//* * Authors: * Hugo Rodrigues * @@ -13,18 +9,21 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "flood-fns.h" +#ifndef SP_FEFLOOD_H_SEEN +#define SP_FEFLOOD_H_SEEN + +#include "sp-filter-primitive.h" #include "svg/svg-icc-color.h" -#include "display/nr-filter.h" -#include "display/nr-filter-flood.h" +#define SP_TYPE_FEFLOOD (sp_feFlood_get_type()) +#define SP_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEFLOOD, SPFeFlood)) +#define SP_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEFLOOD, SPFeFloodClass)) +#define SP_IS_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFLOOD)) +#define SP_IS_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFLOOD)) -/* FeFlood base class */ class SPFeFloodClass; struct SPFeFlood : public SPFilterPrimitive { - /** FLOOD ATTRIBUTES HERE */ guint32 color; SVGICCColor *icc; double opacity; diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp new file mode 100644 index 000000000..3f7cea0c9 --- /dev/null +++ b/src/filters/gaussian-blur.cpp @@ -0,0 +1,212 @@ +#define __SP_GAUSSIANBLUR_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * Hugo Rodrigues + * Niko Kiirala + * + * Copyright (C) 2006,2007 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "filters/gaussian-blur.h" +#include "xml/repr.h" + +#include "display/nr-filter.h" +#include "display/nr-filter-primitive.h" +#include "display/nr-filter-gaussian.h" +#include "display/nr-filter-types.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +/* GaussianBlur base class */ + +static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass); +static void sp_gaussianBlur_init(SPGaussianBlur *gaussianBlur); + +static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_gaussianBlur_release(SPObject *object); +static void sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static void sp_gaussianBlur_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); + +static SPFilterPrimitiveClass *gaussianBlur_parent_class; + +GType +sp_gaussianBlur_get_type() +{ + static GType gaussianBlur_type = 0; + + if (!gaussianBlur_type) { + GTypeInfo gaussianBlur_info = { + sizeof(SPGaussianBlurClass), + NULL, NULL, + (GClassInitFunc) sp_gaussianBlur_class_init, + NULL, NULL, + sizeof(SPGaussianBlur), + 16, + (GInstanceInitFunc) sp_gaussianBlur_init, + NULL, /* value_table */ + }; + gaussianBlur_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPGaussianBlur", &gaussianBlur_info, (GTypeFlags)0); + } + return gaussianBlur_type; +} + +static void +sp_gaussianBlur_class_init(SPGaussianBlurClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; + + gaussianBlur_parent_class = (SPFilterPrimitiveClass *)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_gaussianBlur_build; + sp_object_class->release = sp_gaussianBlur_release; + sp_object_class->write = sp_gaussianBlur_write; + sp_object_class->set = sp_gaussianBlur_set; + sp_object_class->update = sp_gaussianBlur_update; + + sp_primitive_class->build_renderer = sp_gaussianBlur_build_renderer; +} + +static void +sp_gaussianBlur_init(SPGaussianBlur */*gaussianBlur*/) +{ +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPGaussianBlur variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + if (((SPObjectClass *) gaussianBlur_parent_class)->build) { + ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr); + } + + sp_object_read_attr(object, "stdDeviation"); + +} + +/** + * Drops any allocated memory. + */ +static void +sp_gaussianBlur_release(SPObject *object) +{ + + if (((SPObjectClass *) gaussianBlur_parent_class)->release) + ((SPObjectClass *) gaussianBlur_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPGaussianBlur. + */ +static void +sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value) +{ + SPGaussianBlur *gaussianBlur = SP_GAUSSIANBLUR(object); + + switch(key) { + case SP_ATTR_STDDEVIATION: + gaussianBlur->stdDeviation.set(value); + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + default: + if (((SPObjectClass *) gaussianBlur_parent_class)->set) + ((SPObjectClass *) gaussianBlur_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags) +{ + if (flags & SP_OBJECT_MODIFIED_FLAG) { + sp_object_read_attr(object, "stdDeviation"); + } + + if (((SPObjectClass *) gaussianBlur_parent_class)->update) { + ((SPObjectClass *) gaussianBlur_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +{ + /* TODO: Don't just clone, but create a new repr node and write all + * relevant values into it */ + if (!repr) { + repr = SP_OBJECT_REPR(object)->duplicate(doc); + } + + if (((SPObjectClass *) gaussianBlur_parent_class)->write) { + ((SPObjectClass *) gaussianBlur_parent_class)->write(object, doc, repr, flags); + } + + return repr; +} + + +void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num) +{ + blur->stdDeviation.setNumber(num); +} +void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num, float optnum) +{ + blur->stdDeviation.setNumber(num); + blur->stdDeviation.setOptNumber(optnum); +} + +static void sp_gaussianBlur_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter) { + SPGaussianBlur *sp_blur = SP_GAUSSIANBLUR(primitive); + + int handle = filter->add_primitive(Inkscape::Filters::NR_FILTER_GAUSSIANBLUR); + Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(handle); + Inkscape::Filters::FilterGaussian *nr_blur = dynamic_cast(nr_primitive); + + sp_filter_primitive_renderer_common(primitive, nr_primitive); + + gfloat num = sp_blur->stdDeviation.getNumber(); + if (num >= 0.0) { + gfloat optnum = sp_blur->stdDeviation.getOptNumber(); + if(optnum >= 0.0) + nr_blur->set_deviation((double) num, (double) optnum); + else + nr_blur->set_deviation((double) num); + } +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/gaussian-blur.h b/src/filters/gaussian-blur.h new file mode 100644 index 000000000..5607080fe --- /dev/null +++ b/src/filters/gaussian-blur.h @@ -0,0 +1,51 @@ +/** @file + * @brief SVG Gaussian blur filter effect + *//* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SP_GAUSSIANBLUR_H_SEEN +#define SP_GAUSSIANBLUR_H_SEEN + +#include "sp-filter-primitive.h" +#include "number-opt-number.h" + +#define SP_TYPE_GAUSSIANBLUR (sp_gaussianBlur_get_type()) +#define SP_GAUSSIANBLUR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GAUSSIANBLUR, SPGaussianBlur)) +#define SP_GAUSSIANBLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GAUSSIANBLUR, SPGaussianBlurClass)) +#define SP_IS_GAUSSIANBLUR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GAUSSIANBLUR)) +#define SP_IS_GAUSSIANBLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GAUSSIANBLUR)) + +/* GaussianBlur base class */ +class SPGaussianBlurClass; + +struct SPGaussianBlur : public SPFilterPrimitive { + /** stdDeviation attribute */ + NumberOptNumber stdDeviation; +}; + +struct SPGaussianBlurClass { + SPFilterPrimitiveClass parent_class; +}; + +GType sp_gaussianBlur_get_type(); +void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num); +void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num, float optnum); + +#endif /* !SP_GAUSSIANBLUR_H_SEEN */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/image-fns.h b/src/filters/image-fns.h deleted file mode 100644 index 0a8b453fe..000000000 --- a/src/filters/image-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEIMAGE_FNS_H -#define SP_FEIMAGE_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeImage; - -#define SP_TYPE_FEIMAGE (sp_feImage_get_type()) -#define SP_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEIMAGE, SPFeImage)) -#define SP_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEIMAGE, SPFeImageClass)) -#define SP_IS_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEIMAGE)) -#define SP_IS_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEIMAGE)) - -GType sp_feImage_get_type(); - -#endif /* !SP_FEIMAGE_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/image.h b/src/filters/image.h index 78e719ac7..a8fb65d6a 100644 --- a/src/filters/image.h +++ b/src/filters/image.h @@ -1,10 +1,6 @@ -#ifndef SP_FEIMAGE_H_SEEN -#define SP_FEIMAGE_H_SEEN - -/** \file - * SVG implementation, see Image.cpp. - */ -/* +/** @file + * @brief SVG image filter effect + *//* * Authors: * Felipe Corrêa da Silva Sanches * Hugo Rodrigues @@ -14,17 +10,23 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "image-fns.h" +#ifndef SP_FEIMAGE_H_SEEN +#define SP_FEIMAGE_H_SEEN + +#include "sp-filter-primitive.h" #include "svg/svg-length.h" #include "sp-item.h" #include "uri-references.h" -/* FeImage base class */ +#define SP_TYPE_FEIMAGE (sp_feImage_get_type()) +#define SP_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEIMAGE, SPFeImage)) +#define SP_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEIMAGE, SPFeImageClass)) +#define SP_IS_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEIMAGE)) +#define SP_IS_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEIMAGE)) + class SPFeImageClass; struct SPFeImage : public SPFilterPrimitive { - /** IMAGE ATTRIBUTES HERE */ gchar *href; SVGLength x, y, height, width; SPDocument *document; @@ -41,7 +43,6 @@ struct SPFeImageClass { GType sp_feImage_get_type(); - #endif /* !SP_FEIMAGE_H_SEEN */ /* diff --git a/src/filters/merge-fns.h b/src/filters/merge-fns.h deleted file mode 100644 index 24bda1ae2..000000000 --- a/src/filters/merge-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEMERGE_FNS_H -#define SP_FEMERGE_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeMerge; - -#define SP_TYPE_FEMERGE (sp_feMerge_get_type()) -#define SP_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEMERGE, SPFeMerge)) -#define SP_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEMERGE, SPFeMergeClass)) -#define SP_IS_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMERGE)) -#define SP_IS_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMERGE)) - -GType sp_feMerge_get_type(); - -#endif /* !SP_FEMERGE_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 437cb4b55..798b7dfcc 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -23,6 +23,7 @@ #include "merge.h" #include "mergenode.h" +#include "display/nr-filter.h" #include "display/nr-filter-merge.h" /* FeMerge base class */ diff --git a/src/filters/merge.h b/src/filters/merge.h index 5d28faba9..c28eaa1f6 100644 --- a/src/filters/merge.h +++ b/src/filters/merge.h @@ -1,22 +1,23 @@ -#ifndef SP_FEMERGE_H_SEEN -#define SP_FEMERGE_H_SEEN - /** \file - * SVG implementation, see Merge.cpp. - */ -/* + * SVG merge filter effect + *//* * Authors: * Hugo Rodrigues * * Copyright (C) 2006 Hugo Rodrigues - * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SP_FEMERGE_H_SEEN +#define SP_FEMERGE_H_SEEN + +#include "sp-filter-primitive.h" -#include "sp-filter.h" -#include "merge-fns.h" +#define SP_TYPE_FEMERGE (sp_feMerge_get_type()) +#define SP_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEMERGE, SPFeMerge)) +#define SP_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEMERGE, SPFeMergeClass)) +#define SP_IS_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMERGE)) +#define SP_IS_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMERGE)) -/* FeMerge base class */ class SPFeMergeClass; struct SPFeMerge : public SPFilterPrimitive { diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 8a4e0dd0a..4ff569364 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -20,8 +20,9 @@ #include "attributes.h" #include "xml/repr.h" -#include "mergenode.h" -#include "merge.h" +#include "filters/mergenode.h" +#include "filters/merge.h" +#include "display/nr-filter-types.h" static void sp_feMergeNode_class_init(SPFeMergeNodeClass *klass); static void sp_feMergeNode_init(SPFeMergeNode *skeleton); diff --git a/src/filters/morphology-fns.h b/src/filters/morphology-fns.h deleted file mode 100644 index a0550405d..000000000 --- a/src/filters/morphology-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEMORPHOLOGY_FNS_H -#define SP_FEMORPHOLOGY_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeMorphology; - -#define SP_TYPE_FEMORPHOLOGY (sp_feMorphology_get_type()) -#define SP_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEMORPHOLOGY, SPFeMorphology)) -#define SP_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEMORPHOLOGY, SPFeMorphologyClass)) -#define SP_IS_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMORPHOLOGY)) -#define SP_IS_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMORPHOLOGY)) - -GType sp_feMorphology_get_type(); - -#endif /* !SP_FEMORPHOLOGY_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index 1530dae8c..f6f9dc609 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -24,6 +24,7 @@ #include "svg/svg.h" #include "morphology.h" #include "xml/repr.h" +#include "display/nr-filter.h" #include "display/nr-filter-morphology.h" /* FeMorphology base class */ diff --git a/src/filters/morphology.h b/src/filters/morphology.h index 20abf8a8d..01eb2f59b 100644 --- a/src/filters/morphology.h +++ b/src/filters/morphology.h @@ -1,10 +1,6 @@ -#ifndef SP_FEMORPHOLOGY_H_SEEN -#define SP_FEMORPHOLOGY_H_SEEN - /** \file - * SVG implementation, see Morphology.cpp. - */ -/* + * @brief SVG morphology filter effect + *//* * Authors: * Hugo Rodrigues * @@ -13,18 +9,22 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "morphology-fns.h" +#ifndef SP_FEMORPHOLOGY_H_SEEN +#define SP_FEMORPHOLOGY_H_SEEN + +#include "sp-filter-primitive.h" #include "number-opt-number.h" -#include "display/nr-filter.h" #include "display/nr-filter-morphology.h" +#define SP_TYPE_FEMORPHOLOGY (sp_feMorphology_get_type()) +#define SP_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEMORPHOLOGY, SPFeMorphology)) +#define SP_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEMORPHOLOGY, SPFeMorphologyClass)) +#define SP_IS_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMORPHOLOGY)) +#define SP_IS_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMORPHOLOGY)) -/* FeMorphology base class */ class SPFeMorphologyClass; struct SPFeMorphology : public SPFilterPrimitive { - /** MORPHOLOGY ATTRIBUTES HERE */ Inkscape::Filters::FilterMorphologyOperator Operator; NumberOptNumber radius; }; diff --git a/src/filters/offset-fns.h b/src/filters/offset-fns.h deleted file mode 100644 index 38561c188..000000000 --- a/src/filters/offset-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FEOFFSET_FNS_H -#define SP_FEOFFSET_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeOffset; - -#define SP_TYPE_FEOFFSET (sp_feOffset_get_type()) -#define SP_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEOFFSET, SPFeOffset)) -#define SP_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEOFFSET, SPFeOffsetClass)) -#define SP_IS_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEOFFSET)) -#define SP_IS_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEOFFSET)) - -GType sp_feOffset_get_type(); - -#endif /* !SP_FEOFFSET_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index 61ea45ff2..b436fd0fb 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -20,9 +20,10 @@ #include "attributes.h" #include "svg/svg.h" -#include "offset.h" +#include "filters/offset.h" #include "helper-fns.h" #include "xml/repr.h" +#include "display/nr-filter.h" #include "display/nr-filter-offset.h" /* FeOffset base class */ diff --git a/src/filters/offset.h b/src/filters/offset.h index 72d852514..5319ff84e 100644 --- a/src/filters/offset.h +++ b/src/filters/offset.h @@ -1,10 +1,6 @@ -#ifndef SP_FEOFFSET_H_SEEN -#define SP_FEOFFSET_H_SEEN - -/** \file - * SVG implementation, see Offset.cpp. - */ -/* +/** @file + * @brief SVG offset filter effect + *//* * Authors: * Hugo Rodrigues * @@ -13,14 +9,20 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "offset-fns.h" +#ifndef SP_FEOFFSET_H_SEEN +#define SP_FEOFFSET_H_SEEN + +#include "sp-filter-primitive.h" + +#define SP_TYPE_FEOFFSET (sp_feOffset_get_type()) +#define SP_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEOFFSET, SPFeOffset)) +#define SP_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEOFFSET, SPFeOffsetClass)) +#define SP_IS_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEOFFSET)) +#define SP_IS_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEOFFSET)) -/* FeOffset base class */ class SPFeOffsetClass; struct SPFeOffset : public SPFilterPrimitive { - /** OFFSET ATTRIBUTES HERE */ double dx, dy; }; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index ce58cf13e..5bb662c0f 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -22,9 +22,9 @@ #include "attributes.h" #include "document.h" -#include "pointlight.h" -#include "diffuselighting-fns.h" -#include "specularlighting-fns.h" +#include "filters/pointlight.h" +#include "filters/diffuselighting.h" +#include "filters/specularlighting.h" #include "xml/repr.h" #define SP_MACROS_SILENT diff --git a/src/filters/specularlighting-fns.h b/src/filters/specularlighting-fns.h deleted file mode 100644 index bd48ba684..000000000 --- a/src/filters/specularlighting-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FESPECULARLIGHTING_FNS_H -#define SP_FESPECULARLIGHTING_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeSpecularLighting; - -#define SP_TYPE_FESPECULARLIGHTING (sp_feSpecularLighting_get_type()) -#define SP_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FESPECULARLIGHTING, SPFeSpecularLighting)) -#define SP_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FESPECULARLIGHTING, SPFeSpecularLightingClass)) -#define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) -#define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) - -GType sp_feSpecularLighting_get_type(); - -#endif /* !SP_FESPECULARLIGHTING_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 03a0c7f96..1b6000522 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -25,6 +25,7 @@ #include "svg/svg-color.h" #include "specularlighting.h" #include "xml/repr.h" +#include "display/nr-filter.h" #include "display/nr-filter-specularlighting.h" /* FeSpecularLighting base class */ diff --git a/src/filters/specularlighting.h b/src/filters/specularlighting.h index cdca5f99f..8d26b8cfe 100644 --- a/src/filters/specularlighting.h +++ b/src/filters/specularlighting.h @@ -1,10 +1,6 @@ -#ifndef SP_FESPECULARLIGHTING_H_SEEN -#define SP_FESPECULARLIGHTING_H_SEEN - -/** \file - * SVG implementation, see SpecularLighting.cpp. - */ -/* +/** @file + * @brief SVG specular lighting filter effect + *//* * Authors: * Hugo Rodrigues * Jean-Rene Reinhard @@ -15,8 +11,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "specularlighting-fns.h" +#ifndef SP_FESPECULARLIGHTING_H_SEEN +#define SP_FESPECULARLIGHTING_H_SEEN + +#include "sp-filter-primitive.h" +#include "number-opt-number.h" + +#define SP_TYPE_FESPECULARLIGHTING (sp_feSpecularLighting_get_type()) +#define SP_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FESPECULARLIGHTING, SPFeSpecularLighting)) +#define SP_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FESPECULARLIGHTING, SPFeSpecularLightingClass)) +#define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) +#define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) namespace Inkscape { namespace Filters { @@ -24,23 +29,16 @@ class FilterSpecularLighting; } } -/* FeSpecularLighting base class */ class SPFeSpecularLightingClass; struct SPFeSpecularLighting : public SPFilterPrimitive { - /** SPECULARLIGHTING ATTRIBUTES HERE */ - /** surfaceScale attribute */ gfloat surfaceScale; guint surfaceScale_set : 1; - /** specularConstant attribute */ gfloat specularConstant; guint specularConstant_set : 1; - /** specularConstant attribute */ gfloat specularExponent; guint specularExponent_set : 1; - /** kernelUnitLenght attribute */ NumberOptNumber kernelUnitLength; - /** lighting-color property */ guint32 lighting_color; guint lighting_color_set : 1; diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 3b518f0b4..10815cfb1 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -22,9 +22,9 @@ #include "attributes.h" #include "document.h" -#include "spotlight.h" -#include "diffuselighting-fns.h" -#include "specularlighting-fns.h" +#include "filters/spotlight.h" +#include "filters/diffuselighting.h" +#include "filters/specularlighting.h" #include "xml/repr.h" #define SP_MACROS_SILENT diff --git a/src/filters/tile-fns.h b/src/filters/tile-fns.h deleted file mode 100644 index b7c4c5f27..000000000 --- a/src/filters/tile-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FETILE_FNS_H -#define SP_FETILE_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeTile; - -#define SP_TYPE_FETILE (sp_feTile_get_type()) -#define SP_FETILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FETILE, SPFeTile)) -#define SP_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FETILE, SPFeTileClass)) -#define SP_IS_FETILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FETILE)) -#define SP_IS_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETILE)) - -GType sp_feTile_get_type(); - -#endif /* !SP_FETILE_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp index 877f70b27..c87d78554 100644 --- a/src/filters/tile.cpp +++ b/src/filters/tile.cpp @@ -19,9 +19,10 @@ #include "attributes.h" #include "svg/svg.h" -#include "tile.h" +#include "filters/tile.h" #include "xml/repr.h" - +#include "display/nr-filter.h" +#include "display/nr-filter-tile.h" /* FeTile base class */ diff --git a/src/filters/tile.h b/src/filters/tile.h index 9e12ca7ee..45c43213d 100644 --- a/src/filters/tile.h +++ b/src/filters/tile.h @@ -1,10 +1,6 @@ -#ifndef SP_FETILE_H_SEEN -#define SP_FETILE_H_SEEN - -/** \file - * SVG implementation, see Tile.cpp. - */ -/* +/** @file + * @brief SVG tile filter effect + *//* * Authors: * Hugo Rodrigues * @@ -13,17 +9,21 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "tile-fns.h" +#ifndef SP_FETILE_H_SEEN +#define SP_FETILE_H_SEEN -#include "display/nr-filter.h" -#include "display/nr-filter-tile.h" +#include "sp-filter-primitive.h" + +#define SP_TYPE_FETILE (sp_feTile_get_type()) +#define SP_FETILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FETILE, SPFeTile)) +#define SP_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FETILE, SPFeTileClass)) +#define SP_IS_FETILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FETILE)) +#define SP_IS_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETILE)) /* FeTile base class */ class SPFeTileClass; struct SPFeTile : public SPFilterPrimitive { - /** TILE ATTRIBUTES HERE */ }; @@ -33,7 +33,6 @@ struct SPFeTileClass { GType sp_feTile_get_type(); - #endif /* !SP_FETILE_H_SEEN */ /* diff --git a/src/filters/turbulence-fns.h b/src/filters/turbulence-fns.h deleted file mode 100644 index 43b4450a5..000000000 --- a/src/filters/turbulence-fns.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SP_FETURBULENCE_FNS_H -#define SP_FETURBULENCE_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPFeTurbulence; - -#define SP_TYPE_FETURBULENCE (sp_feTurbulence_get_type()) -#define SP_FETURBULENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FETURBULENCE, SPFeTurbulence)) -#define SP_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FETURBULENCE, SPFeTurbulenceClass)) -#define SP_IS_FETURBULENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FETURBULENCE)) -#define SP_IS_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETURBULENCE)) - -GType sp_feTurbulence_get_type(); - -#endif /* !SP_FETURBULENCE_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/filters/turbulence.h b/src/filters/turbulence.h index 792a6181a..e9403a164 100644 --- a/src/filters/turbulence.h +++ b/src/filters/turbulence.h @@ -1,10 +1,6 @@ -#ifndef SP_FETURBULENCE_H_SEEN -#define SP_FETURBULENCE_H_SEEN - -/** \file - * SVG implementation, see Turbulence.cpp. - */ -/* +/** @file + * @brief SVG turbulence filter effect + *//* * Authors: * Felipe Corrêa da Silva Sanches * Hugo Rodrigues @@ -14,11 +10,19 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-filter.h" -#include "turbulence-fns.h" +#ifndef SP_FETURBULENCE_H_SEEN +#define SP_FETURBULENCE_H_SEEN + +#include "sp-filter-primitive.h" #include "number-opt-number.h" #include "display/nr-filter-turbulence.h" +#define SP_TYPE_FETURBULENCE (sp_feTurbulence_get_type()) +#define SP_FETURBULENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FETURBULENCE, SPFeTurbulence)) +#define SP_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FETURBULENCE, SPFeTurbulenceClass)) +#define SP_IS_FETURBULENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FETURBULENCE)) +#define SP_IS_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETURBULENCE)) + /* FeTurbulence base class */ class SPFeTurbulenceClass; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index c334ae31e..0c8834951 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -344,7 +344,6 @@ static char const preferences_skeleton[] = " \n" -" \n" " \n" "\n" " " diff --git a/src/sp-filter-fns.h b/src/sp-filter-fns.h deleted file mode 100644 index 4e1b012a3..000000000 --- a/src/sp-filter-fns.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef SEEN_SP_FILTER_FNS_H -#define SEEN_SP_FILTER_FNS_H - -/** \file - * Macros and fn declarations related to filters. - */ - -#include -#include -#include "libnr/nr-forward.h" -#include "sp-filter-units.h" -#include "sp-filter-primitive.h" - -class SPFilter; - -namespace Inkscape { -namespace XML { -class Node; -} -} - -#define SP_TYPE_FILTER (sp_filter_get_type()) -#define SP_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FILTER, SPFilter)) -#define SP_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FILTER, SPFilterClass)) -#define SP_IS_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FILTER)) -#define SP_IS_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FILTER)) - -#define SP_FILTER_FILTER_UNITS(f) (SP_FILTER(f)->filterUnits) -#define SP_FILTER_PRIMITIVE_UNITS(f) (SP_FILTER(f)->primitiveUnits) - -GType sp_filter_get_type(); - -//need to define function -void sp_filter_set_filter_units(SPFilter *filter, SPFilterUnits filterUnits); -//need to define function -void sp_filter_set_primitive_units(SPFilter *filter, SPFilterUnits filterUnits); - -SPFilterPrimitive *add_primitive(SPFilter *filter, SPFilterPrimitive *primitive); -SPFilterPrimitive *get_primitive(SPFilter *filter, int index); - - -#endif /* !SEEN_SP_FILTER_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/sp-filter-primitive.h b/src/sp-filter-primitive.h index 3a7e73861..1ed101489 100644 --- a/src/sp-filter-primitive.h +++ b/src/sp-filter-primitive.h @@ -15,9 +15,6 @@ */ #include "sp-object.h" -#include "display/nr-filter.h" -#include "display/nr-filter-primitive.h" -#include "display/nr-filter-types.h" #define SP_TYPE_FILTER_PRIMITIVE (sp_filter_primitive_get_type ()) #define SP_FILTER_PRIMITIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_FILTER_PRIMITIVE, SPFilterPrimitive)) @@ -27,6 +24,12 @@ class SPFilterPrimitive; class SPFilterPrimitiveClass; +namespace Inkscape { +namespace Filters { +class Filter; +class FilterPrimitive; +} } + struct SPFilterPrimitive : public SPObject { int image_in, image_out; diff --git a/src/sp-filter-reference.cpp b/src/sp-filter-reference.cpp index 18e187603..79860d5d8 100644 --- a/src/sp-filter-reference.cpp +++ b/src/sp-filter-reference.cpp @@ -1,3 +1,4 @@ +#include "sp-filter.h" #include "sp-filter-reference.h" bool diff --git a/src/sp-filter-reference.h b/src/sp-filter-reference.h index 216ff1d6f..e5a3bc8ec 100644 --- a/src/sp-filter-reference.h +++ b/src/sp-filter-reference.h @@ -2,8 +2,10 @@ #define SEEN_SP_FILTER_REFERENCE_H #include "uri-references.h" -#include "sp-filter-fns.h" + class SPObject; +class SPDocument; +class SPFilter; class SPFilterReference : public Inkscape::URIReference { public: @@ -18,7 +20,6 @@ protected: virtual bool _acceptObject(SPObject *obj) const; }; - #endif /* !SEEN_SP_FILTER_REFERENCE_H */ /* diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 4cbafe50c..44db09b86 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -28,6 +28,7 @@ using std::pair; #include "document.h" #include "sp-filter.h" #include "sp-filter-reference.h" +#include "sp-filter-primitive.h" #include "uri.h" #include "xml/repr.h" #include diff --git a/src/sp-filter.h b/src/sp-filter.h index 5ad3863e5..527a0b8a1 100644 --- a/src/sp-filter.h +++ b/src/sp-filter.h @@ -1,10 +1,6 @@ -#ifndef SP_FILTER_H_SEEN -#define SP_FILTER_H_SEEN - /** \file - * SVG implementation, see sp-filter.cpp. - */ -/* + * SVG element + *//* * Authors: * Hugo Rodrigues * Niko Kiirala @@ -13,6 +9,8 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SP_FILTER_H_SEEN +#define SP_FILTER_H_SEEN #include @@ -21,18 +19,24 @@ #include "number-opt-number.h" #include "sp-object.h" #include "sp-filter-units.h" -#include "sp-filter-fns.h" #include "svg/svg-length.h" -#include "display/nr-filter.h" -/* Filter base class */ +#define SP_TYPE_FILTER (sp_filter_get_type()) +#define SP_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FILTER, SPFilter)) +#define SP_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FILTER, SPFilterClass)) +#define SP_IS_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FILTER)) +#define SP_IS_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FILTER)) -/* MACROS DEFINED IN FILE sp-filter-fns.h */ +#define SP_FILTER_FILTER_UNITS(f) (SP_FILTER(f)->filterUnits) +#define SP_FILTER_PRIMITIVE_UNITS(f) (SP_FILTER(f)->primitiveUnits) -struct SPFilterReference; +namespace Inkscape { +namespace Filters { +class Filter; +} } -class SPFilter; -class SPFilterClass; +struct SPFilterReference; +class SPFilterPrimitive; struct ltstr { bool operator()(const char* s1, const char* s2) const; @@ -70,34 +74,31 @@ struct SPFilterClass { SPObjectClass parent_class; }; -/* - * Initializes the given Inkscape::Filters::Filter object as a renderer for this - * SPFilter object. - */ +GType sp_filter_get_type(); + +void sp_filter_set_filter_units(SPFilter *filter, SPFilterUnits filterUnits); +void sp_filter_set_primitive_units(SPFilter *filter, SPFilterUnits filterUnits); +SPFilterPrimitive *add_primitive(SPFilter *filter, SPFilterPrimitive *primitive); +SPFilterPrimitive *get_primitive(SPFilter *filter, int index); + +/* Initializes the given Inkscape::Filters::Filter object as a renderer for this + * SPFilter object. */ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr_filter); -/* - * Returns the number of filter primitives in this SPFilter object. - */ +/// Returns the number of filter primitives in this SPFilter object. int sp_filter_primitive_count(SPFilter *filter); -/** - * Returns a slot number for given image name, or -1 for unknown name. - */ +/// Returns a slot number for given image name, or -1 for unknown name. int sp_filter_get_image_name(SPFilter *filter, gchar const *name); -/** - * Returns slot number for given image name, even if it's unknown. - */ + +/// Returns slot number for given image name, even if it's unknown. int sp_filter_set_image_name(SPFilter *filter, gchar const *name); -/** - * Finds image name based on it's slot number. Returns 0 for unknown slot - * numbers. - */ + +/** Finds image name based on it's slot number. Returns 0 for unknown slot + * numbers. */ gchar const *sp_filter_name_for_image(SPFilter const *filter, int const image); -/* - * Returns a result image name that is not in use inside this filter. - */ +/// Returns a result image name that is not in use inside this filter. Glib::ustring sp_filter_get_new_result_name(SPFilter *filter); #endif /* !SP_FILTER_H_SEEN */ diff --git a/src/sp-gaussian-blur-fns.h b/src/sp-gaussian-blur-fns.h deleted file mode 100644 index 030739263..000000000 --- a/src/sp-gaussian-blur-fns.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef SP_GAUSSIANBLUR_FNS_H -#define SP_GAUSSIANBLUR_FNS_H - -/** \file - * Macros and fn declarations related to gaussian blur filter. - */ - -#include -#include - -namespace Inkscape { -namespace XML { -class Node; -} -} - -class SPGaussianBlur; - -#define SP_TYPE_GAUSSIANBLUR (sp_gaussianBlur_get_type()) -#define SP_GAUSSIANBLUR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GAUSSIANBLUR, SPGaussianBlur)) -#define SP_GAUSSIANBLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GAUSSIANBLUR, SPGaussianBlurClass)) -#define SP_IS_GAUSSIANBLUR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GAUSSIANBLUR)) -#define SP_IS_GAUSSIANBLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GAUSSIANBLUR)) - -GType sp_gaussianBlur_get_type(); -void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num); -void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num, float optnum); - -#endif /* !SP_GAUSSIANBLUR_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/sp-gaussian-blur.cpp b/src/sp-gaussian-blur.cpp deleted file mode 100644 index e6eab5032..000000000 --- a/src/sp-gaussian-blur.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#define __SP_GAUSSIANBLUR_CPP__ - -/** \file - * SVG implementation. - * - */ -/* - * Authors: - * Hugo Rodrigues - * Niko Kiirala - * - * Copyright (C) 2006,2007 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "attributes.h" -#include "svg/svg.h" -#include "sp-gaussian-blur.h" -#include "xml/repr.h" - -#include "display/nr-filter.h" -#include "display/nr-filter-primitive.h" -#include "display/nr-filter-gaussian.h" -#include "display/nr-filter-types.h" - -//#define SP_MACROS_SILENT -//#include "macros.h" - -/* GaussianBlur base class */ - -static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass); -static void sp_gaussianBlur_init(SPGaussianBlur *gaussianBlur); - -static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -static void sp_gaussianBlur_release(SPObject *object); -static void sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value); -static void sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags); -static Inkscape::XML::Node *sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_gaussianBlur_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); - -static SPFilterPrimitiveClass *gaussianBlur_parent_class; - -GType -sp_gaussianBlur_get_type() -{ - static GType gaussianBlur_type = 0; - - if (!gaussianBlur_type) { - GTypeInfo gaussianBlur_info = { - sizeof(SPGaussianBlurClass), - NULL, NULL, - (GClassInitFunc) sp_gaussianBlur_class_init, - NULL, NULL, - sizeof(SPGaussianBlur), - 16, - (GInstanceInitFunc) sp_gaussianBlur_init, - NULL, /* value_table */ - }; - gaussianBlur_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPGaussianBlur", &gaussianBlur_info, (GTypeFlags)0); - } - return gaussianBlur_type; -} - -static void -sp_gaussianBlur_class_init(SPGaussianBlurClass *klass) -{ - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - - gaussianBlur_parent_class = (SPFilterPrimitiveClass *)g_type_class_peek_parent(klass); - - sp_object_class->build = sp_gaussianBlur_build; - sp_object_class->release = sp_gaussianBlur_release; - sp_object_class->write = sp_gaussianBlur_write; - sp_object_class->set = sp_gaussianBlur_set; - sp_object_class->update = sp_gaussianBlur_update; - - sp_primitive_class->build_renderer = sp_gaussianBlur_build_renderer; -} - -static void -sp_gaussianBlur_init(SPGaussianBlur */*gaussianBlur*/) -{ -} - -/** - * Reads the Inkscape::XML::Node, and initializes SPGaussianBlur variables. For this to get called, - * our name must be associated with a repr via "sp_object_type_register". Best done through - * sp-object-repr.cpp's repr_name_entries array. - */ -static void -sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ - if (((SPObjectClass *) gaussianBlur_parent_class)->build) { - ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr); - } - - sp_object_read_attr(object, "stdDeviation"); - -} - -/** - * Drops any allocated memory. - */ -static void -sp_gaussianBlur_release(SPObject *object) -{ - - if (((SPObjectClass *) gaussianBlur_parent_class)->release) - ((SPObjectClass *) gaussianBlur_parent_class)->release(object); -} - -/** - * Sets a specific value in the SPGaussianBlur. - */ -static void -sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value) -{ - SPGaussianBlur *gaussianBlur = SP_GAUSSIANBLUR(object); - - switch(key) { - case SP_ATTR_STDDEVIATION: - gaussianBlur->stdDeviation.set(value); - object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - default: - if (((SPObjectClass *) gaussianBlur_parent_class)->set) - ((SPObjectClass *) gaussianBlur_parent_class)->set(object, key, value); - break; - } - -} - -/** - * Receives update notifications. - */ -static void -sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags) -{ - if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "stdDeviation"); - } - - if (((SPObjectClass *) gaussianBlur_parent_class)->update) { - ((SPObjectClass *) gaussianBlur_parent_class)->update(object, ctx, flags); - } -} - -/** - * Writes its settings to an incoming repr object, if any. - */ -static Inkscape::XML::Node * -sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) -{ - /* TODO: Don't just clone, but create a new repr node and write all - * relevant values into it */ - if (!repr) { - repr = SP_OBJECT_REPR(object)->duplicate(doc); - } - - if (((SPObjectClass *) gaussianBlur_parent_class)->write) { - ((SPObjectClass *) gaussianBlur_parent_class)->write(object, doc, repr, flags); - } - - return repr; -} - - -void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num) -{ - blur->stdDeviation.setNumber(num); -} -void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num, float optnum) -{ - blur->stdDeviation.setNumber(num); - blur->stdDeviation.setOptNumber(optnum); -} - -static void sp_gaussianBlur_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter) { - SPGaussianBlur *sp_blur = SP_GAUSSIANBLUR(primitive); - - int handle = filter->add_primitive(Inkscape::Filters::NR_FILTER_GAUSSIANBLUR); - Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(handle); - Inkscape::Filters::FilterGaussian *nr_blur = dynamic_cast(nr_primitive); - - sp_filter_primitive_renderer_common(primitive, nr_primitive); - - gfloat num = sp_blur->stdDeviation.getNumber(); - if (num >= 0.0) { - gfloat optnum = sp_blur->stdDeviation.getOptNumber(); - if(optnum >= 0.0) - nr_blur->set_deviation((double) num, (double) optnum); - else - nr_blur->set_deviation((double) num); - } -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/sp-gaussian-blur.h b/src/sp-gaussian-blur.h deleted file mode 100644 index c86ee3288..000000000 --- a/src/sp-gaussian-blur.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef SP_GAUSSIANBLUR_H_SEEN -#define SP_GAUSSIANBLUR_H_SEEN - -/** \file - * SVG implementation, see sp-gaussianBlur.cpp. - */ -/* - * Authors: - * Hugo Rodrigues - * - * Copyright (C) 2006 Hugo Rodrigues - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "sp-filter.h" -#include "sp-gaussian-blur-fns.h" - -/* GaussianBlur base class */ -class SPGaussianBlurClass; - -struct SPGaussianBlur : public SPFilterPrimitive { - /** stdDeviation attribute */ - NumberOptNumber stdDeviation; -}; - -struct SPGaussianBlurClass { - SPFilterPrimitiveClass parent_class; -}; - -GType sp_gaussianBlur_get_type(); - - -#endif /* !SP_GAUSSIANBLUR_H_SEEN */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 62143e3ab..cc289317e 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -59,7 +59,6 @@ #include "color-profile-fns.h" #include "xml/repr.h" #include "sp-filter.h" -#include "sp-gaussian-blur.h" #include "filters/blend.h" #include "filters/colormatrix.h" #include "filters/componenttransfer.h" @@ -70,6 +69,7 @@ #include "filters/distantlight.h" #include "filters/displacementmap.h" #include "filters/flood.h" +#include "filters/gaussian-blur.h" #include "filters/image.h" #include "filters/merge.h" #include "filters/morphology.h" diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 2bdac197f..ee168f136 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -1,5 +1,3 @@ -#define __SP_SPRAY_CONTEXT_C__ - /* * Spray Tool * @@ -36,7 +34,6 @@ #include "desktop.h" #include "desktop-events.h" #include "desktop-handles.h" -#include "unistd.h" #include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-spray.xpm" @@ -72,9 +69,6 @@ #include "style.h" #include "box3d.h" #include "sp-item-transform.h" -#include "filter-chemistry.h" -#include "sp-gaussian-blur-fns.h" -#include "sp-gaussian-blur.h" #include "spray-context.h" #include "ui/dialog/dialog-manager.h" diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 13299b5a4..36357ab84 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -72,8 +72,7 @@ #include "box3d.h" #include "sp-item-transform.h" #include "filter-chemistry.h" -#include "sp-gaussian-blur-fns.h" -#include "sp-gaussian-blur.h" +#include "filters/gaussian-blur.h" #include "tweak-context.h" diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 1672c4b69..4ec719bf4 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -48,13 +48,13 @@ #include "filters/convolvematrix.h" #include "filters/displacementmap.h" #include "filters/distantlight.h" +#include "filters/gaussian-blur.h" #include "filters/merge.h" #include "filters/mergenode.h" #include "filters/offset.h" #include "filters/pointlight.h" #include "filters/spotlight.h" #include "sp-filter-primitive.h" -#include "sp-gaussian-blur.h" #include "style.h" #include "svg/svg-color.h" -- cgit v1.2.3 From 9edca8fe56eed686ef3d83c7caba23c82348efee Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 14 Jul 2010 08:42:21 +0200 Subject: Flood and merge filters (bzr r9508.1.17) --- src/display/cairo-utils.cpp | 8 ++ src/display/cairo-utils.h | 1 + src/display/nr-filter-blend.cpp | 153 ------------------------------------ src/display/nr-filter-blend.h | 3 - src/display/nr-filter-flood.cpp | 77 +++++++++--------- src/display/nr-filter-flood.h | 10 +-- src/display/nr-filter-gaussian.cpp | 1 + src/display/nr-filter-gaussian.h | 6 +- src/display/nr-filter-merge.cpp | 101 +++++++----------------- src/display/nr-filter-merge.h | 7 +- src/display/nr-filter-primitive.cpp | 2 +- src/display/nr-filter-primitive.h | 16 ++-- 12 files changed, 91 insertions(+), 294 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 36202f42e..ce56c21f5 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -367,6 +367,14 @@ ink_cairo_surface_create_identical(cairo_surface_t *s) return ns; } +cairo_surface_t * +ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c) +{ + cairo_surface_t *ns = cairo_surface_create_similar(s, c, + ink_cairo_surface_get_width(s), ink_cairo_surface_get_height(s)); + return ns; +} + /** @brief Extract the alpha channel into a new surface. * Creates a surface with a content type of CAIRO_CONTENT_ALPHA that contains * the alpha values of pixels from @a s. */ diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index cfd33330b..3845d5ebb 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -86,6 +86,7 @@ void ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, do cairo_surface_t *ink_cairo_surface_copy(cairo_surface_t *s); cairo_surface_t *ink_cairo_surface_create_identical(cairo_surface_t *s); +cairo_surface_t *ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c); cairo_surface_t *ink_cairo_extract_alpha(cairo_surface_t *s); cairo_surface_t *ink_cairo_surface_unshare(cairo_surface_t *s); int ink_cairo_surface_get_width(cairo_surface_t *surface); diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 4ce37ae3b..758b49fe4 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -21,14 +21,9 @@ #include "display/cairo-utils.h" #include "display/nr-filter-blend.h" -#include "display/nr-filter-pixops.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-types.h" -#include "display/nr-filter-units.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixops.h" #include "preferences.h" namespace Inkscape { @@ -48,77 +43,6 @@ namespace Filters { * cb = Color (RGB) at a given pixel for image B - premultiplied */ -/* - * These blending equations given in SVG standard are for color values - * in the range 0..1. As these values are stored as unsigned char values, - * they need some reworking. An unsigned char value can be thought as - * 0.8 fixed point representation of color value. This is how I've - * ended up with these equations here. - */ - -// Set alpha / opacity. This line is same for all the blending modes, -// so let's save some copy-pasting. -#define SET_ALPHA r[3] = NR_NORMALIZE_21((255 * 255) - (255 - a[3]) * (255 - b[3])) - -// cr = (1 - qa) * cb + ca -inline void -blend_normal(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_COMPOSEPPP_1111(a[0],a[3],b[0]); - r[1] = NR_COMPOSEPPP_1111(a[1],a[3],b[1]); - r[2] = NR_COMPOSEPPP_1111(a[2],a[3],b[2]); - SET_ALPHA; -} - -// cr = (1-qa)*cb + (1-qb)*ca + ca*cb -inline void -blend_multiply(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21((255 - a[3]) * b[0] + (255 - b[3]) * a[0] - + a[0] * b[0]); - r[1] = NR_NORMALIZE_21((255 - a[3]) * b[1] + (255 - b[3]) * a[1] - + a[1] * b[1]); - r[2] = NR_NORMALIZE_21((255 - a[3]) * b[2] + (255 - b[3]) * a[2] - + a[2] * b[2]); - SET_ALPHA; -} - -// cr = cb + ca - ca * cb -inline void -blend_screen(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21((b[0] + a[0]) * 255 - a[0] * b[0]); - r[1] = NR_NORMALIZE_21((b[1] + a[1]) * 255 - a[1] * b[1]); - r[2] = NR_NORMALIZE_21((b[2] + a[2]) * 255 - a[2] * b[2]); - SET_ALPHA; -} - -// cr = Min ((1 - qa) * cb + ca, (1 - qb) * ca + cb) -inline void -blend_darken(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21(std::min(NR_COMPOSEPPP_1112(a[0],a[3],b[0]), - NR_COMPOSEPPP_1112(b[0],b[3],a[0]))); - r[1] = NR_NORMALIZE_21(std::min(NR_COMPOSEPPP_1112(a[1],a[3],b[1]), - NR_COMPOSEPPP_1112(b[1],b[3],a[1]))); - r[2] = NR_NORMALIZE_21(std::min(NR_COMPOSEPPP_1112(a[2],a[3],b[2]), - NR_COMPOSEPPP_1112(b[2],b[3],a[2]))); - SET_ALPHA; -} - -// cr = Max ((1 - qa) * cb + ca, (1 - qb) * ca + cb) -inline void -blend_lighten(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21(std::max(NR_COMPOSEPPP_1112(a[0],a[3],b[0]), - NR_COMPOSEPPP_1112(b[0],b[3],a[0]))); - r[1] = NR_NORMALIZE_21(std::max(NR_COMPOSEPPP_1112(a[1],a[3],b[1]), - NR_COMPOSEPPP_1112(b[1],b[3],a[1]))); - r[2] = NR_NORMALIZE_21(std::max(NR_COMPOSEPPP_1112(a[2],a[3],b[2]), - NR_COMPOSEPPP_1112(b[2],b[3],a[2]))); - SET_ALPHA; -} - FilterBlend::FilterBlend() : _blend_mode(BLEND_NORMAL), _input2(NR_FILTER_SLOT_NOT_SET) @@ -372,83 +296,6 @@ void FilterBlend::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -int FilterBlend::render(FilterSlot &slot, FilterUnits const & /*units*/) { - NRPixBlock *in1 = slot.get(_input); - NRPixBlock *in2 = slot.get(_input2); - NRPixBlock *original_in1 = in1; - NRPixBlock *original_in2 = in2; - NRPixBlock *out; - - // Bail out if either one of source images is missing - if (!in1 || !in2) { - g_warning("Missing source image for feBlend (in=%d in2=%d)", _input, _input2); - return 1; - } - - out = new NRPixBlock; - NRRectL out_area; - nr_rect_l_union(&out_area, &in1->area, &in2->area); - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8P, - out_area.x0, out_area.y0, out_area.x1, out_area.y1, - true); - - // Blending modes are defined for premultiplied RGBA values, - // thus convert them to that format before blending - if (in1->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - in1 = new NRPixBlock; - nr_pixblock_setup_fast(in1, NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in1->area.x0, original_in1->area.y0, - original_in1->area.x1, original_in1->area.y1, - false); - nr_blit_pixblock_pixblock(in1, original_in1); - } - if (in2->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - in2 = new NRPixBlock; - nr_pixblock_setup_fast(in2, NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in2->area.x0, original_in2->area.y0, - original_in2->area.x1, original_in2->area.y1, - false); - nr_blit_pixblock_pixblock(in2, original_in2); - } - - /* pixops_mix is defined in display/nr-filter-pixops.h - * It mixes the two input images with the function given as template - * and places the result in output image. - */ - switch (_blend_mode) { - case BLEND_MULTIPLY: - pixops_mix(*out, *in1, *in2); - break; - case BLEND_SCREEN: - pixops_mix(*out, *in1, *in2); - break; - case BLEND_DARKEN: - pixops_mix(*out, *in1, *in2); - break; - case BLEND_LIGHTEN: - pixops_mix(*out, *in1, *in2); - break; - case BLEND_NORMAL: - default: - pixops_mix(*out, *in1, *in2); - break; - } - - if (in1 != original_in1) { - nr_pixblock_release(in1); - delete in1; - } - if (in2 != original_in2) { - nr_pixblock_release(in2); - delete in2; - } - - out->empty = FALSE; - slot.set(_output, out); - - return 0; -} - bool FilterBlend::can_handle_affine(Geom::Matrix const &) { // blend is a per-pixel primitive and is immutable under transformations diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 45da07f27..94c782156 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -18,8 +18,6 @@ */ #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" namespace Inkscape { namespace Filters { @@ -40,7 +38,6 @@ public: virtual ~FilterBlend(); virtual void render_cairo(FilterSlot &slot); - virtual int render(FilterSlot &slot, FilterUnits const &units); virtual bool can_handle_affine(Geom::Matrix const &); virtual void set_input(int slot); diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index fd0600cdb..7afd25e2d 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -13,10 +13,12 @@ # include "config.h" #endif +#include "display/cairo-utils.h" #include "display/nr-filter-flood.h" -#include "display/nr-filter-utils.h" +#include "display/nr-filter-slot.h" #include "svg/svg-icc-color.h" #include "svg/svg-color.h" +#include "color.h" namespace Inkscape { namespace Filters { @@ -31,48 +33,39 @@ FilterPrimitive * FilterFlood::create() { FilterFlood::~FilterFlood() {} -int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) { -//g_message("rendering feflood"); - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feFlood (in=%d)", _input); - return 1; - } - - int i; - int in_w = in->area.x1 - in->area.x0; - int in_h = in->area.y1 - in->area.y0; - - NRPixBlock *out = new NRPixBlock; - - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - - unsigned char *out_data = NR_PIXBLOCK_PX(out); - unsigned char r,g,b,a; - - - r = CLAMP_D_TO_U8((color >> 24) % 256); - g = CLAMP_D_TO_U8((color >> 16) % 256); - b = CLAMP_D_TO_U8((color >> 8) % 256); - a = CLAMP_D_TO_U8(opacity*255); - -#if ENABLE_LCMS - icc_color_to_sRGB(icc, &r, &g, &b); -//g_message("result: r:%d g:%d b:%d", r, g, b); -#endif //ENABLE_LCMS - - for(i=0; i < 4*in_h*in_w; i+=4){ - out_data[i]=r; - out_data[i+1]=g; - out_data[i+2]=b; - out_data[i+3]=a; - } - - out->empty = FALSE; +void FilterFlood::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + + double r, g, b, a; + r = SP_RGBA32_R_F(color); + g = SP_RGBA32_G_F(color); + b = SP_RGBA32_B_F(color); + a = opacity; + + #if ENABLE_LCMS + guchar ru, gu, bu; + icc_color_to_sRGB(icc, &ru, &gu, &bu); + r = SP_COLOR_U_TO_F(ru); + g = SP_COLOR_U_TO_F(gu); + b = SP_COLOR_U_TO_F(bu); + #endif + + cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + cairo_t *ct = cairo_create(out); + cairo_set_source_rgba(ct, r, g, b, a); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + slot.set(_output, out); - return 0; + cairo_surface_destroy(out); +} + +bool FilterFlood::can_handle_affine(Geom::Matrix const &) +{ + // flood is a per-pixel primitive and is immutable under transformations + return true; } void FilterFlood::set_color(guint32 c) { diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 98c374bbd..6f2e5b5d5 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -13,9 +13,8 @@ */ #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" -#include "svg/svg-color.h" + +class SVGICCColor; namespace Inkscape { namespace Filters { @@ -25,11 +24,12 @@ public: FilterFlood(); static FilterPrimitive *create(); virtual ~FilterFlood(); - + + virtual void render_cairo(FilterSlot &slot); + virtual bool can_handle_affine(Geom::Matrix const &); virtual void set_opacity(double o); virtual void set_color(guint32 c); virtual void set_icc(SVGICCColor *icc_color); - virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); private: double opacity; diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 1e59748c4..fbaa9eaa5 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -32,6 +32,7 @@ #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" +#include "display/nr-filter-slot.h" #include <2geom/matrix.h> #include "util/fixed_point.h" #include "preferences.h" diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 01ce9efcb..ebc0f8f52 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -14,12 +14,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" -#include "libnr/nr-pixblock.h" #include <2geom/forward.h> -#include "libnr/nr-rect-l.h" +#include "display/nr-filter-primitive.h" enum { BLUR_QUALITY_BEST = 2, diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index b913e2cd7..406f74c9e 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -9,28 +9,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include - -#include "2geom/isnan.h" -#include "filters/merge.h" +#include "display/cairo-utils.h" #include "display/nr-filter-merge.h" -#include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-pixops.h" - -inline void -composite_over(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = a[0] + NR_NORMALIZE_21(b[0] * (255 - a[3])); - r[1] = a[1] + NR_NORMALIZE_21(b[1] * (255 - a[3])); - r[2] = a[2] + NR_NORMALIZE_21(b[2] * (255 - a[3])); - r[3] = a[3] + NR_NORMALIZE_21(b[3] * (255 - a[3])); -} namespace Inkscape { namespace Filters { @@ -46,70 +29,42 @@ FilterPrimitive * FilterMerge::create() { FilterMerge::~FilterMerge() {} -int FilterMerge::render(FilterSlot &slot, FilterUnits const &/*units*/) { - NRPixBlock *in[_input_image.size()]; - NRPixBlock *original_in[_input_image.size()]; - - for (unsigned int i = 0 ; i < _input_image.size() ; i++) { - in[i] = slot.get(_input_image[i]); - original_in[i] = in[i]; - } - - NRPixBlock *out; - - // Bail out if one of source images is missing - for (unsigned int i = 0 ; i < _input_image.size() ; i++) { - bool missing = false; - if (!in[i]) { - g_warning("Missing source image for feMerge (number=%d slot=%d)", i, _input_image[i]); - missing = true; - } - if (missing) return 1; - } - - out = new NRPixBlock; - NRRectL out_area = in[0]->area; - for (unsigned int i = 1 ; i < _input_image.size() ; i++) { - nr_rect_l_union(&out_area, &out_area, &in[i]->area); - } - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8P, - out_area.x0, out_area.y0, out_area.x1, out_area.y1, - true); - - // Merge is defined for premultiplied RGBA values, thus convert them to - // that format before blending - for (unsigned int i = 0 ; i < _input_image.size() ; i++) { - if (in[i]->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - in[i] = new NRPixBlock; - nr_pixblock_setup_fast(in[i], NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in[i]->area.x0, - original_in[i]->area.y0, - original_in[i]->area.x1, - original_in[i]->area.y1, - false); - nr_blit_pixblock_pixblock(in[i], original_in[i]); +void FilterMerge::render_cairo(FilterSlot &slot) +{ + if (_input_image.size() == 0) return; + + // output is RGBA if at least one input is RGBA + bool rgba32 = false; + cairo_surface_t *out = NULL; + for (std::vector::iterator i = _input_image.begin(); i != _input_image.end(); ++i) { + cairo_surface_t *in = slot.getcairo(*i); + if (cairo_surface_get_content(in) == CAIRO_CONTENT_COLOR_ALPHA) { + out = ink_cairo_surface_create_identical(in); + rgba32 = true; + break; } } - /* pixops_mix is defined in display/nr-filter-pixops.h - * It mixes the two input images with the function given as template - * and places the result in output image. - */ - for (unsigned int i = 0 ; i < _input_image.size() ; i++) { - pixops_mix(*out, *in[i], *out); + if (!rgba32) { + out = ink_cairo_surface_create_identical(slot.getcairo(_input_image[0])); } + cairo_t *out_ct = cairo_create(out); - for (unsigned int i = 0 ; i < _input_image.size() ; i++) { - if (in[i] != original_in[i]) { - nr_pixblock_release(in[i]); - delete in[i]; - } + for (std::vector::iterator i = _input_image.begin(); i != _input_image.end(); ++i) { + cairo_surface_t *in = slot.getcairo(*i); + cairo_set_source_surface(out_ct, in, 0, 0); + cairo_paint(out_ct); } - out->empty = FALSE; + cairo_destroy(out_ct); slot.set(_output, out); + cairo_surface_destroy(out); +} - return 0; +bool FilterMerge::can_handle_affine(Geom::Matrix const &) +{ + // Merge is a per-pixel primitive and is immutable under transformations + return true; } void FilterMerge::set_input(int slot) { diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index b7737e347..a7871641b 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -13,11 +13,7 @@ */ #include - -#include "filters/merge.h" #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" namespace Inkscape { namespace Filters { @@ -28,7 +24,8 @@ public: static FilterPrimitive *create(); virtual ~FilterMerge(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &); + virtual bool can_handle_affine(Geom::Matrix const &); virtual void set_input(int input); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index 31e314055..c81afb874 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -12,8 +12,8 @@ */ #include "display/nr-filter-primitive.h" +#include "display/nr-filter-slot.h" #include "display/nr-filter-types.h" -#include "libnr/nr-pixblock.h" #include "svg/svg-length.h" namespace Inkscape { diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 89927fdbd..1205b1d30 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -1,6 +1,3 @@ -#ifndef __NR_FILTER_PRIMITIVE_H__ -#define __NR_FILTER_PRIMITIVE_H__ - /* * SVG filters rendering * @@ -11,15 +8,20 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_NR_FILTER_PRIMITIVE_H +#define SEEN_NR_FILTER_PRIMITIVE_H -#include "display/nr-filter-slot.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-rect-l.h" +#include <2geom/forward.h> #include "svg/svg-length.h" +struct NRRectL; + namespace Inkscape { namespace Filters { +class FilterSlot; +class FilterUnits; + /* * Different filter effects need different types of inputs. This is what * traits are used for: one can specify, what special restrictions @@ -112,7 +114,7 @@ public: /** @brief Indicate whether the filter primitive can handle the given affine. * * Results of some filter primitives depend on the coordinate system used when rendering. - * A gaussian blur will equal x and y deviation will remain unchanged by rotations. + * A gaussian blur with equal x and y deviation will remain unchanged by rotations. * Per-pixel filters like color matrix and blend will not change regardless of * the transformation. * -- cgit v1.2.3 From 3aad4454df3d57a6c45496c701421b18e4c3aa81 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 15 Jul 2010 00:11:18 +0200 Subject: Offset filter (bzr r9508.1.18) --- src/display/nr-filter-blend.cpp | 1 + src/display/nr-filter-offset.cpp | 47 ++++++++++++++++------------------------ src/display/nr-filter-offset.h | 3 ++- 3 files changed, 22 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 758b49fe4..8a1cfa6f4 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -159,6 +159,7 @@ void surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_surface_t * // WARNING: code below assumes that: // 1. Cairo ARGB32 surface strides are always divisible by 4 // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces + // 3. Both surfaces are of the same size int w = cairo_image_surface_get_width(in2); int h = cairo_image_surface_get_height(in2); diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index fd4f55053..b44c5fac7 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -9,11 +9,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "display/cairo-utils.h" #include "display/nr-filter-offset.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" #include "libnr/nr-rect-l.h" namespace Inkscape { @@ -33,37 +32,29 @@ FilterPrimitive * FilterOffset::create() { FilterOffset::~FilterOffset() {} -int FilterOffset::render(FilterSlot &slot, FilterUnits const &units) { - NRPixBlock *in = slot.get(_input); - // Bail out if source image is missing - if (!in) { - g_warning("Missing source image for feOffset (in=%d)", _input); - return 1; - } - - NRPixBlock *out = new NRPixBlock; +void FilterOffset::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); - Geom::Matrix trans = units.get_matrix_primitiveunits2pb(); + Geom::Matrix trans = slot.get_units().get_matrix_primitiveunits2pb(); Geom::Point offset(dx, dy); offset *= trans; offset[X] -= trans[4]; offset[Y] -= trans[5]; - nr_pixblock_setup_fast(out, in->mode, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - nr_blit_pixblock_pixblock(out, in); + cairo_set_source_surface(ct, in, offset[X], offset[Y]); + cairo_paint(ct); + cairo_destroy(ct); - out->area.x0 += static_cast(offset[X]); - out->area.y0 += static_cast(offset[Y]); - out->area.x1 += static_cast(offset[X]); - out->area.y1 += static_cast(offset[Y]); - out->visible_area = out->area; - - out->empty = FALSE; slot.set(_output, out); + cairo_surface_destroy(out); +} - return 0; +bool FilterOffset::can_handle_affine(Geom::Matrix const &) +{ + return true; } void FilterOffset::set_dx(double amount) { @@ -82,15 +73,15 @@ void FilterOffset::area_enlarge(NRRectL &area, Geom::Matrix const &trans) offset[Y] -= trans[5]; if (offset[X] > 0) { - area.x0 -= static_cast(offset[X]); + area.x0 -= ceil(offset[X]); } else { - area.x1 -= static_cast(offset[X]); + area.x1 -= floor(offset[X]); } if (offset[Y] > 0) { - area.y0 -= static_cast(offset[Y]); + area.y0 -= ceil(offset[Y]); } else { - area.y1 -= static_cast(offset[Y]); + area.y1 -= floor(offset[Y]); } } diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index b00ad25fe..8404aa3d9 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -26,8 +26,9 @@ public: static FilterPrimitive *create(); virtual ~FilterOffset(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); + virtual bool can_handle_affine(Geom::Matrix const &); void set_dx(double amount); void set_dy(double amount); -- cgit v1.2.3 From d204ded3f6106fd25ffbc43f32d5ec5ac3dcb26d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 16 Jul 2010 22:06:46 +0200 Subject: Split out surface blending template into a separate file (bzr r9508.1.19) --- src/display/Makefile_insert | 1 + src/display/cairo-templates.h | 143 ++++++++++++++++++++++++++++++++++++++++ src/display/nr-filter-blend.cpp | 128 ++++------------------------------- 3 files changed, 157 insertions(+), 115 deletions(-) create mode 100644 src/display/cairo-templates.h (limited to 'src') diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index da5ded824..621dc43d5 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -4,6 +4,7 @@ display/canvas-arena.$(OBJEXT): helper/sp-marshal.h display/sp-canvas.$(OBJEXT): helper/sp-marshal.h ink_common_sources += \ + display/cairo-templates.h \ display/cairo-utils.cpp \ display/cairo-utils.h \ display/canvas-arena.cpp \ diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h new file mode 100644 index 000000000..8bc8b1f49 --- /dev/null +++ b/src/display/cairo-templates.h @@ -0,0 +1,143 @@ +/** + * @file + * @brief Cairo software blending templates + *//* + * Authors: + * Krzysztof Kosiński + * + * Copyright (C) 2010 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_CAIRO_TEMPLATES_H +#define SEEN_INKSCAPE_DISPLAY_CAIRO_TEMPLATES_H + +#ifdef HAVE_OPENMP +#include +#include "preferences.h" +#endif + +#include +#include + +/** + * @brief Blend two surfaces using the supplied functor. + * This template blends two Cairo image surfaces using a blending functor that takes + * two 32-bit ARGB pixel values and returns a modified 32-bit pixel value. + * Differences in input surface formats are handled transparently. In future, this template + * will also handle software fallback for GL surfaces. */ +template +void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_surface_t *out, Blend blend) +{ + cairo_surface_flush(in1); + cairo_surface_flush(in2); + + // WARNING: code below assumes that: + // 1. Cairo ARGB32 surface strides are always divisible by 4 + // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces + // 3. Both surfaces are of the same size + // 4. Output surface is ARGB32 if at least one input is ARGB32 + + int w = cairo_image_surface_get_width(in2); + int h = cairo_image_surface_get_height(in2); + int stride1 = cairo_image_surface_get_stride(in1); + int stride2 = cairo_image_surface_get_stride(in2); + int strideout = cairo_image_surface_get_stride(out); + int bpp1 = cairo_image_surface_get_format(in1) == CAIRO_FORMAT_A8 ? 1 : 4; + int bpp2 = cairo_image_surface_get_format(in2) == CAIRO_FORMAT_A8 ? 1 : 4; + + guint32 *const in1_data = (guint32*) cairo_image_surface_get_data(in1); + guint32 *const in2_data = (guint32*) cairo_image_surface_get_data(in2); + guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); + + #if HAVE_OPENMP + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + #endif + + if (bpp1 == 4) { + if (bpp2 == 4) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in1_p = in1_data + i * stride1/4; + guint32 *in2_p = in2_data + i * stride2/4; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + *out_p = blend(*in1_p, *in2_p); + ++in1_p; + ++in2_p; + ++out_p; + } + } + } else { + // bpp2 == 1 + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in1_p = in1_data + i * stride1/4; + guint8 *in2_p = reinterpret_cast(in2_data) + i * stride2; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + guint32 in2_px = *in2_p; + in2_px <<= 24; + *out_p = blend(*in1_p, in2_px); + ++in1_p; + ++in2_p; + ++out_p; + } + } + } + } else { + if (bpp2 == 4) { + // bpp1 == 1 + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; + guint32 *in2_p = in2_data + i * stride2/4; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + guint32 in1_px = *in1_p; + in1_px <<= 24; + *out_p = blend(in1_px, *in2_p); + ++in1_p; + ++in2_p; + ++out_p; + } + } + } else { + // bpp1 == 1 && bpp2 == 1 + // don't do anything - this should have been handled via Cairo blending + g_assert_not_reached(); + } + } + + cairo_surface_mark_dirty(out); +} + +// helper macros for pixel extraction +#define EXTRACT_ARGB32(px,a,r,g,b) \ + guint32 a, r, g, b; \ + a = (px & 0xff000000) >> 24; \ + r = (px & 0x00ff0000) >> 16; \ + g = (px & 0x0000ff00) >> 8; \ + b = (px & 0x000000ff); + +#define ASSEMBLE_ARGB32(px,a,r,g,b) \ + guint32 px = (a << 24) | (r << 16) | (g << 8) | b; + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 8a1cfa6f4..9e911d199 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -19,6 +19,7 @@ #include "config.h" #endif +#include "display/cairo-templates.h" #include "display/cairo-utils.h" #include "display/nr-filter-blend.h" #include "display/nr-filter-primitive.h" @@ -55,19 +56,9 @@ FilterPrimitive * FilterBlend::create() { FilterBlend::~FilterBlend() {} -#define EXTRACT_ARGB32(px,a,r,g,b) \ - guint32 a, r, g, b; \ - a = (px & 0xff000000) >> 24; \ - r = (px & 0x00ff0000) >> 16; \ - g = (px & 0x0000ff00) >> 8; \ - b = (px & 0x000000ff); - -#define ASSEMBLE_ARGB32(px,a,r,g,b) \ - guint32 px = (a << 24) | (r << 16) | (g << 8) | b; - // cr = (1-qa)*cb + (1-qb)*ca + ca*cb struct BlendMultiply { - void operator()(guint32 in1, guint32 in2, guint32 *out) + guint32 operator()(guint32 in1, guint32 in2) { EXTRACT_ARGB32(in1, aa, ra, ga, ba) EXTRACT_ARGB32(in2, ab, rb, gb, bb) @@ -78,13 +69,13 @@ struct BlendMultiply { guint32 bo = (255-aa)*bb + (255-ab)*ba + ba*bb; bo = (bo + 127) / 255; ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) - *out = pxout; + return pxout; } }; // cr = cb + ca - ca * cb struct BlendScreen { - void operator()(guint32 in1, guint32 in2, guint32 *out) + guint32 operator()(guint32 in1, guint32 in2) { EXTRACT_ARGB32(in1, aa, ra, ga, ba) EXTRACT_ARGB32(in2, ab, rb, gb, bb) @@ -95,13 +86,13 @@ struct BlendScreen { guint32 bo = 255*(bb + ba) - ba * bb; bo = (bo + 127) / 255; ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) - *out = pxout; + return pxout; } }; // cr = Min ((1 - qa) * cb + ca, (1 - qb) * ca + cb) struct BlendDarken { - void operator()(guint32 in1, guint32 in2, guint32 *out) + guint32 operator()(guint32 in1, guint32 in2) { EXTRACT_ARGB32(in1, aa, ra, ga, ba) EXTRACT_ARGB32(in2, ab, rb, gb, bb) @@ -112,13 +103,13 @@ struct BlendDarken { guint32 bo = std::min((255-aa)*bb + 255*ba, (255-ab)*ba + 255*bb); bo = (bo + 127) / 255; ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) - *out = pxout; + return pxout; } }; // cr = Max ((1 - qa) * cb + ca, (1 - qb) * ca + cb) struct BlendLighten { - void operator()(guint32 in1, guint32 in2, guint32 *out) + guint32 operator()(guint32 in1, guint32 in2) { EXTRACT_ARGB32(in1, aa, ra, ga, ba) EXTRACT_ARGB32(in2, ab, rb, gb, bb) @@ -129,7 +120,7 @@ struct BlendLighten { guint32 bo = std::max((255-aa)*bb + 255*ba, (255-ab)*ba + 255*bb); bo = (bo + 127) / 255; ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) - *out = pxout; + return pxout; } }; @@ -150,99 +141,6 @@ static inline void blend_alpha(guint32 in1, guint32 in2, guint32 *out) } */ -template -void surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_surface_t *out) -{ - cairo_surface_flush(in1); - cairo_surface_flush(in2); - - // WARNING: code below assumes that: - // 1. Cairo ARGB32 surface strides are always divisible by 4 - // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces - // 3. Both surfaces are of the same size - - int w = cairo_image_surface_get_width(in2); - int h = cairo_image_surface_get_height(in2); - int stride1 = cairo_image_surface_get_stride(in1); - int stride2 = cairo_image_surface_get_stride(in2); - int strideout = cairo_image_surface_get_stride(out); - int bpp1 = cairo_image_surface_get_format(in1) == CAIRO_FORMAT_A8 ? 1 : 4; - int bpp2 = cairo_image_surface_get_format(in2) == CAIRO_FORMAT_A8 ? 1 : 4; - // assumption: out surface is CAIRO_FORMAT_ARGB32 if at least one input is ARGB32 - - guint32 *const in1_data = (guint32*) cairo_image_surface_get_data(in1); - guint32 *const in2_data = (guint32*) cairo_image_surface_get_data(in2); - guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); - - #if HAVE_OPENMP - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - #endif - - if (bpp1 == 4) { - if (bpp2 == 4) { - #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) - #endif - for (int i = 0; i < h; ++i) { - guint32 *in1_p = in1_data + i * stride1/4; - guint32 *in2_p = in2_data + i * stride2/4; - guint32 *out_p = out_data + i * strideout/4; - for (int j = 0; j < w; ++j) { - Blend()(*in1_p, *in2_p, out_p); - ++in1_p; - ++in2_p; - ++out_p; - } - } - } else { - // bpp2 == 1 - #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) - #endif - for (int i = 0; i < h; ++i) { - guint32 *in1_p = in1_data + i * stride1/4; - guint8 *in2_p = reinterpret_cast(in2_data) + i * stride2; - guint32 *out_p = out_data + i * strideout/4; - for (int j = 0; j < w; ++j) { - guint32 in2_px = *in2_p; - in2_px <<= 24; - Blend()(*in1_p, in2_px, out_p); - ++in1_p; - ++in2_p; - ++out_p; - } - } - } - } else { - if (bpp2 == 4) { - // bpp1 == 1 - #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) - #endif - for (int i = 0; i < h; ++i) { - guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; - guint32 *in2_p = in2_data + i * stride2/4; - guint32 *out_p = out_data + i * strideout/4; - for (int j = 0; j < w; ++j) { - guint32 in1_px = *in1_p; - in1_px <<= 24; - Blend()(in1_px, *in2_p, out_p); - ++in1_p; - ++in2_p; - ++out_p; - } - } - } else { - // bpp1 == 1 && bpp2 == 1 - // don't do anything - this should have been handled via Cairo blending - g_assert_not_reached(); - } - } - - cairo_surface_mark_dirty(out); -} - void FilterBlend::render_cairo(FilterSlot &slot) { cairo_surface_t *input1 = slot.getcairo(_input); @@ -274,16 +172,16 @@ void FilterBlend::render_cairo(FilterSlot &slot) // TODO: convert to Cairo blending operators once we start using the 1.10 series switch (_blend_mode) { case BLEND_MULTIPLY: - surface_blend(input1, input2, out); + ink_cairo_surface_blend(input1, input2, out, BlendMultiply()); break; case BLEND_SCREEN: - surface_blend(input1, input2, out); + ink_cairo_surface_blend(input1, input2, out, BlendScreen()); break; case BLEND_DARKEN: - surface_blend(input1, input2, out); + ink_cairo_surface_blend(input1, input2, out, BlendDarken()); break; case BLEND_LIGHTEN: - surface_blend(input1, input2, out); + ink_cairo_surface_blend(input1, input2, out, BlendLighten()); break; case BLEND_NORMAL: default: -- cgit v1.2.3 From ad8d4b3dc89eee0d50857f7cc48e9d54451aeb37 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 17 Jul 2010 01:36:51 +0200 Subject: Composite filter (bzr r9508.1.20) --- src/display/cairo-templates.h | 122 +++++++++++++++++++++++++++++------- src/display/cairo-utils.cpp | 47 +++++++++++--- src/display/cairo-utils.h | 3 +- src/display/nr-filter-blend.cpp | 11 +--- src/display/nr-filter-composite.cpp | 73 ++++++++++++++++++++- src/display/nr-filter-composite.h | 3 +- 6 files changed, 218 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 8bc8b1f49..79e461cf8 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -17,6 +17,7 @@ #include "preferences.h" #endif +#include #include #include @@ -32,7 +33,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s cairo_surface_flush(in1); cairo_surface_flush(in2); - // WARNING: code below assumes that: + // ASSUMPTIONS // 1. Cairo ARGB32 surface strides are always divisible by 4 // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces // 3. Both surfaces are of the same size @@ -45,30 +46,50 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s int strideout = cairo_image_surface_get_stride(out); int bpp1 = cairo_image_surface_get_format(in1) == CAIRO_FORMAT_A8 ? 1 : 4; int bpp2 = cairo_image_surface_get_format(in2) == CAIRO_FORMAT_A8 ? 1 : 4; + int bppout = std::max(bpp1, bpp2); + + // Check whether we can loop over pixels without taking stride into account. + bool fast_path = true; + fast_path &= (stride1 == w * bpp1); + fast_path &= (stride2 == w * bpp2); + fast_path &= (strideout == w * bppout); + + int limit = w * h; guint32 *const in1_data = (guint32*) cairo_image_surface_get_data(in1); guint32 *const in2_data = (guint32*) cairo_image_surface_get_data(in2); guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); + // NOTE + // OpenMP probably doesn't help much here. + // It would be better to render more than 1 tile at a time. #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); #endif + // The number of code paths here is evil. if (bpp1 == 4) { if (bpp2 == 4) { - #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) - #endif - for (int i = 0; i < h; ++i) { - guint32 *in1_p = in1_data + i * stride1/4; - guint32 *in2_p = in2_data + i * stride2/4; - guint32 *out_p = out_data + i * strideout/4; - for (int j = 0; j < w; ++j) { - *out_p = blend(*in1_p, *in2_p); - ++in1_p; - ++in2_p; - ++out_p; + if (fast_path) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < limit; ++i) { + *(out_data + i) = blend(*(in1_data + i), *(in2_data + i)); + } + } else { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in1_p = in1_data + i * stride1/4; + guint32 *in2_p = in2_data + i * stride2/4; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + *out_p = blend(*in1_p, *in2_p); + ++in1_p; ++in2_p; ++out_p; + } } } } else { @@ -84,9 +105,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s guint32 in2_px = *in2_p; in2_px <<= 24; *out_p = blend(*in1_p, in2_px); - ++in1_p; - ++in2_p; - ++out_p; + ++in1_p; ++in2_p; ++out_p; } } } @@ -104,21 +123,82 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s guint32 in1_px = *in1_p; in1_px <<= 24; *out_p = blend(in1_px, *in2_p); - ++in1_p; - ++in2_p; - ++out_p; + ++in1_p; ++in2_p; ++out_p; } } } else { // bpp1 == 1 && bpp2 == 1 - // don't do anything - this should have been handled via Cairo blending - g_assert_not_reached(); + if (fast_path) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < limit; ++i) { + guint8 *in1_p = reinterpret_cast(in1_data) + i; + guint8 *in2_p = reinterpret_cast(in2_data) + i; + guint8 *out_p = reinterpret_cast(out_data) + i; + guint32 in1_px = *in1_p; in1_px <<= 24; + guint32 in2_px = *in2_p; in2_px <<= 24; + guint32 out_px = blend(in1_px, in2_px); + *out_p = out_px >> 24; + } + } else { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; + guint8 *in2_p = reinterpret_cast(in2_data) + i * stride2; + guint8 *out_p = reinterpret_cast(out_data) + i * strideout; + for (int j = 0; j < w; ++j) { + guint32 in1_px = *in1_p; in1_px <<= 24; + guint32 in2_px = *in2_p; in2_px <<= 24; + guint32 out_px = blend(in1_px, in2_px); + *out_p = out_px >> 24; + ++in1_p; ++in2_p; ++out_p; + } + } + } } } cairo_surface_mark_dirty(out); } +#if 0 +template +ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter filter) +{ + cairo_surface_flush(in); + + // ASSUMPTIONS + // 1. Cairo ARGB32 surface strides are always divisible by 4 + // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces + // 3. Surfaces have the same dimensions and pixel formats + + int w = cairo_image_surface_get_width(in); + int h = cairo_image_surface_get_height(in); + int stridein = cairo_image_surface_get_stride(in); + int strideout = cairo_image_surface_get_stride(out); + int bpp = cairo_image_surface_get_format(in) == CAIRO_FORMAT_A8 ? 1 : 4; + + guint32 *const in_data = (guint32*) cairo_image_surface_get_data(in); + guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); + + #if HAVE_OPENMP + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + #endif + + if (bpp == 4) { + + } else { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + } +} +#endif + // helper macros for pixel extraction #define EXTRACT_ARGB32(px,a,r,g,b) \ guint32 a, r, g, b; \ diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index ce56c21f5..c46caa7be 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -362,8 +362,7 @@ ink_cairo_surface_copy(cairo_surface_t *s) cairo_surface_t * ink_cairo_surface_create_identical(cairo_surface_t *s) { - cairo_surface_t *ns = cairo_surface_create_similar(s, cairo_surface_get_content(s), - ink_cairo_surface_get_width(s), ink_cairo_surface_get_height(s)); + cairo_surface_t *ns = ink_cairo_surface_create_same_size(s, cairo_surface_get_content(s)); return ns; } @@ -381,8 +380,7 @@ ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c) cairo_surface_t * ink_cairo_extract_alpha(cairo_surface_t *s) { - cairo_surface_t *alpha = cairo_surface_create_similar(s, CAIRO_CONTENT_ALPHA, - ink_cairo_surface_get_width(s), ink_cairo_surface_get_height(s)); + cairo_surface_t *alpha = ink_cairo_surface_create_same_size(s, CAIRO_CONTENT_ALPHA); cairo_t *ct = cairo_create(alpha); cairo_set_source_surface(ct, s, 0, 0); @@ -394,13 +392,44 @@ ink_cairo_extract_alpha(cairo_surface_t *s) } cairo_surface_t * -ink_cairo_surface_unshare(cairo_surface_t *s) +ink_cairo_surface_create_output(cairo_surface_t *image, cairo_surface_t *bg) +{ + cairo_content_t imgt = cairo_surface_get_content(image); + cairo_content_t bgt = cairo_surface_get_content(bg); + cairo_surface_t *out = NULL; + + if (bgt == CAIRO_CONTENT_ALPHA && imgt == CAIRO_CONTENT_ALPHA) { + out = ink_cairo_surface_create_identical(bg); + } else { + out = ink_cairo_surface_create_same_size(bg, CAIRO_CONTENT_COLOR_ALPHA); + } + + return out; +} + +void +ink_cairo_surface_blit(cairo_surface_t *src, cairo_surface_t *dest) { - if (cairo_surface_get_reference_count(s) > 1) { - return ink_cairo_surface_copy(s); + if (cairo_surface_get_type(src) == CAIRO_SURFACE_TYPE_IMAGE && + cairo_surface_get_type(dest) == CAIRO_SURFACE_TYPE_IMAGE && + cairo_image_surface_get_format(src) == cairo_image_surface_get_format(dest) && + cairo_image_surface_get_height(src) == cairo_image_surface_get_height(dest) && + cairo_image_surface_get_width(src) == cairo_image_surface_get_width(dest) && + cairo_image_surface_get_stride(src) == cairo_image_surface_get_stride(dest)) + { + // use memory copy instead of using a Cairo context + cairo_surface_flush(src); + int stride = cairo_image_surface_get_stride(src); + int h = cairo_image_surface_get_height(src); + memcpy(cairo_image_surface_get_data(dest), cairo_image_surface_get_data(src), stride * h); + cairo_surface_mark_dirty(dest); } else { - cairo_surface_reference(s); - return s; + // generic implementation + cairo_t *ct = cairo_create(dest); + cairo_set_source_surface(ct, src, 0, 0); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); } } diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 3845d5ebb..1406636d0 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -88,7 +88,8 @@ cairo_surface_t *ink_cairo_surface_copy(cairo_surface_t *s); cairo_surface_t *ink_cairo_surface_create_identical(cairo_surface_t *s); cairo_surface_t *ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c); cairo_surface_t *ink_cairo_extract_alpha(cairo_surface_t *s); -cairo_surface_t *ink_cairo_surface_unshare(cairo_surface_t *s); +cairo_surface_t *ink_cairo_surface_create_output(cairo_surface_t *image, cairo_surface_t *bg); +void ink_cairo_surface_blit(cairo_surface_t *src, cairo_surface_t *dest); int ink_cairo_surface_get_width(cairo_surface_t *surface); int ink_cairo_surface_get_height(cairo_surface_t *surface); diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 9e911d199..d146dc46d 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -151,23 +151,18 @@ void FilterBlend::render_cairo(FilterSlot &slot) // input2 is the "background" image // out should be ARGB32 if any of the inputs is ARGB32 - cairo_surface_t *out = NULL; + cairo_surface_t *out = ink_cairo_surface_create_output(input1, input2); + if ((ct1 == CAIRO_CONTENT_ALPHA && ct2 == CAIRO_CONTENT_ALPHA) || _blend_mode == BLEND_NORMAL) { - out = ink_cairo_surface_copy(input2); + ink_cairo_surface_blit(input2, out); cairo_t *out_ct = cairo_create(out); cairo_set_source_surface(out_ct, input1, 0, 0); cairo_paint(out_ct); cairo_destroy(out_ct); } else { // blend mode != normal and at least 1 surface is not pure alpha - // create surface identical to the ARGB32 surface - if (ct1 == CAIRO_CONTENT_ALPHA) { - out = ink_cairo_surface_create_identical(input2); - } else { - out = ink_cairo_surface_create_identical(input1); - } // TODO: convert to Cairo blending operators once we start using the 1.10 series switch (_blend_mode) { diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index 51652d743..e6abb7bae 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -12,7 +12,8 @@ #include #include "2geom/isnan.h" -#include "filters/composite.h" +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-filter-composite.h" #include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" @@ -99,6 +100,30 @@ FilterPrimitive * FilterComposite::create() { FilterComposite::~FilterComposite() {} +struct BlendArithmetic { + BlendArithmetic(double k1, double k2, double k3, double k4) + : _k1(round(k1 * 255)) + , _k2(round(k2 * 255*255)) + , _k3(round(k3 * 255*255)) + , _k4(round(k4 * 255*255*255)) + {} + guint32 operator()(guint32 in1, guint32 in2) { + EXTRACT_ARGB32(in1, aa, ra, ga, ba) + EXTRACT_ARGB32(in2, ab, rb, gb, bb) + + guint32 ao = _k1*aa*ab + _k2*aa + _k3*ab + _k4; ao = (ao + 255*255) / (255*255); + guint32 ro = _k1*ra*rb + _k2*ra + _k3*rb + _k4; ro = (ro + 255*255) / (255*255); + guint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4; go = (go + 255*255) / (255*255); + guint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4; bo = (bo + 255*255) / (255*255); + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + return pxout; + } +private: + guint32 _k1, _k2, _k3, _k4; +}; + +#if 0 int FilterComposite::render(FilterSlot &slot, FilterUnits const &/*units*/) { NRPixBlock *in1 = slot.get(_input); NRPixBlock *in2 = slot.get(_input2); @@ -179,6 +204,52 @@ int FilterComposite::render(FilterSlot &slot, FilterUnits const &/*units*/) { return 0; } +#endif + +void FilterComposite::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input1 = slot.getcairo(_input); + cairo_surface_t *input2 = slot.getcairo(_input2); + + cairo_surface_t *out = ink_cairo_surface_create_output(input1, input2); + + if (op == COMPOSITE_ARITHMETIC) { + ink_cairo_surface_blend(input1, input2, out, BlendArithmetic(k1, k2, k3, k4)); + } else { + ink_cairo_surface_blit(input2, out); + cairo_t *ct = cairo_create(out); + cairo_set_source_surface(ct, input1, 0, 0); + switch(op) { + case COMPOSITE_IN: + cairo_set_operator(ct, CAIRO_OPERATOR_IN); + break; + case COMPOSITE_OUT: + cairo_set_operator(ct, CAIRO_OPERATOR_OUT); + break; + case COMPOSITE_ATOP: + cairo_set_operator(ct, CAIRO_OPERATOR_ATOP); + break; + case COMPOSITE_XOR: + cairo_set_operator(ct, CAIRO_OPERATOR_XOR); + break; + case COMPOSITE_OVER: + case COMPOSITE_DEFAULT: + default: + // OVER is the default operator + break; + } + cairo_paint(ct); + cairo_destroy(ct); + } + + slot.set(_output, out); + cairo_surface_destroy(out); +} + +bool FilterComposite::can_handle_affine(Geom::Matrix const &) +{ + return true; +} void FilterComposite::set_input(int input) { _input = input; diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index b24666531..192e79c69 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -26,7 +26,8 @@ public: static FilterPrimitive *create(); virtual ~FilterComposite(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &); + virtual bool can_handle_affine(Geom::Matrix const &); virtual void set_input(int input); virtual void set_input(int input, int slot); -- cgit v1.2.3 From bea4b360af15585d9b9c009f26dd24646c9d62d1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 17 Jul 2010 02:04:58 +0200 Subject: Minor cleanup of composite filter (bzr r9508.1.21) --- src/display/nr-filter-composite.cpp | 150 ------------------------------------ 1 file changed, 150 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index e6abb7bae..5c00898d4 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -15,75 +15,8 @@ #include "display/cairo-templates.h" #include "display/cairo-utils.h" #include "display/nr-filter-composite.h" -#include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "display/nr-filter-utils.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-pixops.h" - -inline void -composite_over(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_COMPOSEPPP_1111(a[0],a[3],b[0]); - r[1] = NR_COMPOSEPPP_1111(a[1],a[3],b[1]); - r[2] = NR_COMPOSEPPP_1111(a[2],a[3],b[2]); - r[3] = NR_COMPOSEPPP_1111(a[3],a[3],b[3]); -} - -inline void -composite_in(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21(a[0] * b[3]); - r[1] = NR_NORMALIZE_21(a[1] * b[3]); - r[2] = NR_NORMALIZE_21(a[2] * b[3]); - r[3] = NR_NORMALIZE_21(a[3] * b[3]); -} - -inline void -composite_out(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21(a[0] * (255 - b[3])); - r[1] = NR_NORMALIZE_21(a[1] * (255 - b[3])); - r[2] = NR_NORMALIZE_21(a[2] * (255 - b[3])); - r[3] = NR_NORMALIZE_21(a[3] * (255 - b[3])); -} - -inline void -composite_atop(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21(a[0] * b[3] + b[0] * (255 - a[3])); - r[1] = NR_NORMALIZE_21(a[1] * b[3] + b[1] * (255 - a[3])); - r[2] = NR_NORMALIZE_21(a[2] * b[3] + b[2] * (255 - a[3])); - r[3] = b[3]; -} - -inline void -composite_xor(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - r[0] = NR_NORMALIZE_21(a[0] * (255 - b[3]) + b[0] * (255 - a[3])); - r[1] = NR_NORMALIZE_21(a[1] * (255 - b[3]) + b[1] * (255 - a[3])); - r[2] = NR_NORMALIZE_21(a[2] * (255 - b[3]) + b[2] * (255 - a[3])); - r[3] = NR_NORMALIZE_21(a[3] * (255 - b[3]) + b[3] * (255 - a[3])); -} - -// BUGBUG / TODO -// This makes arithmetic compositing non re-entrant and non thread safe. -static int arith_k1, arith_k2, arith_k3, arith_k4; -inline void -composite_arithmetic(unsigned char *r, unsigned char const *a, unsigned char const *b) -{ - using Inkscape::Filters::clamp3; - r[0] = NR_NORMALIZE_31(clamp3(arith_k1 * a[0] * b[0] - + arith_k2 * a[0] + arith_k3 * b[0] + arith_k4)); - r[1] = NR_NORMALIZE_31(clamp3(arith_k1 * a[1] * b[1] - + arith_k2 * a[1] + arith_k3 * b[1] + arith_k4)); - r[2] = NR_NORMALIZE_31(clamp3(arith_k1 * a[2] * b[2] - + arith_k2 * a[2] + arith_k3 * b[2] + arith_k4)); - r[3] = NR_NORMALIZE_31(clamp3(arith_k1 * a[3] * b[3] - + arith_k2 * a[3] + arith_k3 * b[3] + arith_k4)); -} namespace Inkscape { namespace Filters { @@ -123,89 +56,6 @@ private: guint32 _k1, _k2, _k3, _k4; }; -#if 0 -int FilterComposite::render(FilterSlot &slot, FilterUnits const &/*units*/) { - NRPixBlock *in1 = slot.get(_input); - NRPixBlock *in2 = slot.get(_input2); - NRPixBlock *original_in1 = in1; - NRPixBlock *original_in2 = in2; - NRPixBlock *out; - - // Bail out if either one of source images is missing - if (!in1 || !in2) { - g_warning("Missing source image for feComposite (in=%d in2=%d)", _input, _input2); - return 1; - } - - out = new NRPixBlock; - NRRectL out_area; - nr_rect_l_union(&out_area, &in1->area, &in2->area); - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8P, - out_area.x0, out_area.y0, out_area.x1, out_area.y1, - true); - - // Blending modes are defined for premultiplied RGBA values, - // thus convert them to that format before blending - if (in1->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - in1 = nr_pixblock_new_fast(NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in1->area.x0, original_in1->area.y0, - original_in1->area.x1, original_in1->area.y1, - false); - nr_blit_pixblock_pixblock(in1, original_in1); - } - if (in2->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - in2 = nr_pixblock_new_fast(NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in2->area.x0, original_in2->area.y0, - original_in2->area.x1, original_in2->area.y1, - false); - nr_blit_pixblock_pixblock(in2, original_in2); - } - - /* pixops_mix is defined in display/nr-filter-pixops.h - * It mixes the two input images with the function given as template - * and places the result in output image. - */ - switch (op) { - case COMPOSITE_IN: - pixops_mix(*out, *in1, *in2); - break; - case COMPOSITE_OUT: - pixops_mix(*out, *in1, *in2); - break; - case COMPOSITE_ATOP: - pixops_mix(*out, *in1, *in2); - break; - case COMPOSITE_XOR: - pixops_mix(*out, *in1, *in2); - break; - case COMPOSITE_ARITHMETIC: - arith_k1 = (int)round(k1 * 255); - arith_k2 = (int)round(k2 * 255 * 255); - arith_k3 = (int)round(k3 * 255 * 255); - arith_k4 = (int)round(k4 * 255 * 255 * 255); - pixops_mix(*out, *in1, *in2); - break; - case COMPOSITE_DEFAULT: - case COMPOSITE_OVER: - default: - pixops_mix(*out, *in1, *in2); - break; - } - - if (in1 != original_in1) { - nr_pixblock_free(in1); - } - if (in2 != original_in2) { - nr_pixblock_free(in2); - } - - out->empty = FALSE; - slot.set(_output, out); - - return 0; -} -#endif - void FilterComposite::render_cairo(FilterSlot &slot) { cairo_surface_t *input1 = slot.getcairo(_input); -- cgit v1.2.3 From 3f3908d396d95fe8f6271a57250275e1cf7264d1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 17 Jul 2010 17:12:34 +0200 Subject: Fix flood filter to really paint the specified color (bzr r9508.1.22) --- src/display/nr-filter-flood.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 7afd25e2d..f09738202 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -37,18 +37,19 @@ void FilterFlood::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); - double r, g, b, a; - r = SP_RGBA32_R_F(color); - g = SP_RGBA32_G_F(color); - b = SP_RGBA32_B_F(color); - a = opacity; + double r = SP_RGBA32_R_F(color); + double g = SP_RGBA32_G_F(color); + double b = SP_RGBA32_B_F(color); + double a = opacity; #if ENABLE_LCMS - guchar ru, gu, bu; - icc_color_to_sRGB(icc, &ru, &gu, &bu); - r = SP_COLOR_U_TO_F(ru); - g = SP_COLOR_U_TO_F(gu); - b = SP_COLOR_U_TO_F(bu); + if (icc) { + guchar ru, gu, bu; + icc_color_to_sRGB(icc, &ru, &gu, &bu); + r = SP_COLOR_U_TO_F(ru); + g = SP_COLOR_U_TO_F(gu); + b = SP_COLOR_U_TO_F(bu); + } #endif cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); -- cgit v1.2.3 From 1a554f7ff6f7a4790ac95e0167aaab5d4130d41f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 17 Jul 2010 17:14:22 +0200 Subject: Color matrix filter. Fix arithmetic operator in feComposite (bzr r9508.1.23) --- src/display/cairo-templates.h | 100 +++++++++++++++++--- src/display/nr-filter-colormatrix.cpp | 172 +++++++++++++++++++++++++++++++++- src/display/nr-filter-colormatrix.h | 6 +- src/display/nr-filter-composite.cpp | 21 +++-- src/display/nr-filter.cpp | 7 +- 5 files changed, 278 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 79e461cf8..c64ad78c1 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -146,7 +146,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s #pragma omp parallel for num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { - guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; + guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; guint8 *in2_p = reinterpret_cast(in2_data) + i * stride2; guint8 *out_p = reinterpret_cast(out_data) + i * strideout; for (int j = 0; j < w; ++j) { @@ -164,22 +164,29 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s cairo_surface_mark_dirty(out); } -#if 0 template -ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter filter) +void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter filter) { cairo_surface_flush(in); // ASSUMPTIONS // 1. Cairo ARGB32 surface strides are always divisible by 4 // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces - // 3. Surfaces have the same dimensions and pixel formats + // 3. Surfaces have the same dimensions + // 4. Output surface is A8 if input is A8 int w = cairo_image_surface_get_width(in); int h = cairo_image_surface_get_height(in); int stridein = cairo_image_surface_get_stride(in); int strideout = cairo_image_surface_get_stride(out); - int bpp = cairo_image_surface_get_format(in) == CAIRO_FORMAT_A8 ? 1 : 4; + int bppin = cairo_image_surface_get_format(in) == CAIRO_FORMAT_A8 ? 1 : 4; + int bppout = cairo_image_surface_get_format(out) == CAIRO_FORMAT_A8 ? 1 : 4; + int limit = w * h; + + // Check whether we can loop over pixels without taking stride into account. + bool fast_path = true; + fast_path &= (stridein == w * bppin); + fast_path &= (strideout == w * bppout); guint32 *const in_data = (guint32*) cairo_image_surface_get_data(in); guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); @@ -189,17 +196,86 @@ ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter filte int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); #endif - if (bpp == 4) { - + if (bppin == 4) { + if (bppout == 4) { + // bppin == 4, bppout == 4 + if (fast_path) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < limit; ++i) { + *(out_data + i) = filter(*(in_data + i)); + } + } else { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in_p = in_data + i * stridein/4; + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + *out_p = filter(*in_p); + ++in_p; ++out_p; + } + } + } + } else { + // bppin == 4, bppout == 1 + // we use this path with COLORMATRIX_LUMINANCETOALPHA + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *in_p = in_data + i * stridein/4; + guint8 *out_p = reinterpret_cast(out_data) + i * strideout; + for (int j = 0; j < w; ++j) { + guint32 out_px = filter(*in_p); + *out_p = out_px >> 24; + ++in_p; ++out_p; + } + } + } } else { - #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) - #endif + // bppin == 1, bppout == 1 + // Note: there is no path for bppin == 1, bppout == 4 because it is useless + if (fast_path) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < limit; ++i) { + guint8 *in_p = reinterpret_cast(in_data) + i; + guint8 *out_p = reinterpret_cast(out_data) + i; + guint32 in_px = *in_p; in_px <<= 24; + guint32 out_px = filter(in_px); + *out_p = out_px >> 24; + } + } else { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint8 *in_p = reinterpret_cast(in_data) + i * stridein; + guint8 *out_p = reinterpret_cast(out_data) + i * strideout; + for (int j = 0; j < w; ++j) { + guint32 in_px = *in_p; in_px <<= 24; + guint32 out_px = filter(in_px); + *out_p = out_px >> 24; + ++in_p; ++out_p; + } + } + } } } -#endif -// helper macros for pixel extraction +// Some helpers for pixel manipulation + +G_GNUC_CONST inline gint32 +pxclamp(gint32 v, gint32 low, gint32 high) { + if (v < low) return low; + if (v > high) return high; + return v; +} + #define EXTRACT_ARGB32(px,a,r,g,b) \ guint32 a, r, g, b; \ a = (px & 0xff000000) >> 24; \ diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 0b24649a9..d0926ebcc 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -10,11 +10,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-filter-colormatrix.h" #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" -#include "libnr/nr-blit.h" -#include namespace Inkscape { namespace Filters { @@ -30,6 +32,7 @@ FilterPrimitive * FilterColorMatrix::create() { FilterColorMatrix::~FilterColorMatrix() {} +#if 0 int FilterColorMatrix::render(FilterSlot &slot, FilterUnits const &/*units*/) { NRPixBlock *in = slot.get(_input); if (!in) { @@ -194,6 +197,169 @@ int FilterColorMatrix::render(FilterSlot &slot, FilterUnits const &/*units*/) { slot.set(_output, out); return 0; } +#endif + +struct ColorMatrixMatrix { + ColorMatrixMatrix(std::vector const &values) { + unsigned limit = std::min(20ul, values.size()); + for (unsigned i = 0; i < limit; ++i) { + if (i % 5 == 4) { + _v[i] = round(values[i]*255*255); + } else { + _v[i] = round(values[i]*255); + } + } + for (unsigned i = limit; i < 20; ++i) { + _v[i] = 0; + } + } + + static inline guint32 premul_alpha(guint32 color, guint32 alpha) + { + guint32 temp = alpha * color + 128; + return (temp + (temp >> 8)) >> 8; + } + + guint32 operator()(guint32 in) { + EXTRACT_ARGB32(in, a, r, g, b) + // we need to un-premultiply alpha values for this type of matrix + // TODO: unpremul can be ignored if there is an identity mapping on the alpha channel + if (a != 0) { + r = (r * 255 + a/2) / a; + b = (b * 255 + a/2) / a; + g = (g * 255 + a/2) / a; + } + + gint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + a*_v[3] + _v[4]; + gint32 go = r*_v[5] + g*_v[6] + b*_v[7] + a*_v[8] + _v[9]; + gint32 bo = r*_v[10] + g*_v[11] + b*_v[12] + a*_v[13] + _v[14]; + gint32 ao = r*_v[15] + g*_v[16] + b*_v[17] + a*_v[18] + _v[19]; + ro = (pxclamp(ro, 0, 255*255) + 127) / 255; + go = (pxclamp(go, 0, 255*255) + 127) / 255; + bo = (pxclamp(bo, 0, 255*255) + 127) / 255; + ao = (pxclamp(ao, 0, 255*255) + 127) / 255; + + ro = premul_alpha(ro, ao); + go = premul_alpha(go, ao); + bo = premul_alpha(bo, ao); + + ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) + return pxout; + } +private: + gint32 _v[20]; +}; + +struct ColorMatrixSaturate { + ColorMatrixSaturate(double v_in) { + // clamp parameter instead of clamping color values + double v = CLAMP(v_in, 0.0, 1.0); + _v[0] = 0.213+0.787*v; _v[1] = 0.715-0.715*v; _v[2] = 0.072-0.072*v; + _v[3] = 0.213-0.213*v; _v[4] = 0.715+0.285*v; _v[5] = 0.072-0.072*v; + _v[6] = 0.213-0.213*v; _v[7] = 0.715-0.715*v; _v[8] = 0.072+0.928*v; + } + + guint32 operator()(guint32 in) { + EXTRACT_ARGB32(in, a, r, g, b) + + // Note: this cannot be done in fixed point, because the loss of precision + // causes overflow for some values of v + guint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + 0.5; + guint32 go = r*_v[3] + g*_v[4] + b*_v[5] + 0.5; + guint32 bo = r*_v[6] + g*_v[7] + b*_v[8] + 0.5; + + ASSEMBLE_ARGB32(pxout, a, ro, go, bo) + return pxout; + } +private: + double _v[9]; +}; + +struct ColorMatrixHueRotate { + ColorMatrixHueRotate(double v) { + double sinhue, coshue; + sincos(v * M_PI/180.0, &sinhue, &coshue); + + _v[0] = round((0.213 +0.787*coshue -0.213*sinhue)*255); + _v[1] = round((0.715 -0.715*coshue -0.715*sinhue)*255); + _v[2] = round((0.072 -0.072*coshue +0.928*sinhue)*255); + + _v[3] = round((0.213 -0.213*coshue +0.143*sinhue)*255); + _v[4] = round((0.715 +0.285*coshue +0.140*sinhue)*255); + _v[5] = round((0.072 -0.072*coshue -0.283*sinhue)*255); + + _v[6] = round((0.213 -0.213*coshue -0.787*sinhue)*255); + _v[7] = round((0.715 -0.715*coshue +0.715*sinhue)*255); + _v[8] = round((0.072 +0.928*coshue +0.072*sinhue)*255); + } + guint32 operator()(guint32 in) { + EXTRACT_ARGB32(in, a, r, g, b) + gint32 maxpx = a*255; + gint32 ro = r*_v[0] + g*_v[1] + b*_v[2]; + gint32 go = r*_v[3] + g*_v[4] + b*_v[5]; + gint32 bo = r*_v[6] + g*_v[7] + b*_v[8]; + ro = (pxclamp(ro, 0, maxpx) + 127) / 255; + go = (pxclamp(go, 0, maxpx) + 127) / 255; + bo = (pxclamp(bo, 0, maxpx) + 127) / 255; + + ASSEMBLE_ARGB32(pxout, a, ro, go, bo) + return pxout; + } +private: + gint32 _v[9]; +}; + +struct ColorMatrixLuminanceToAlpha { + guint32 operator()(guint32 in) { + // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 + EXTRACT_ARGB32(in, a, r, g, b) + // unpremultiply color values + if (a != 0) { + r = (r * 255 + a/2) / a; + b = (b * 255 + a/2) / a; + g = (g * 255 + a/2) / a; + } + guint32 ao = r*54 + g*182 + b*18; + return ((ao + 127) / 255) << 24; + } +}; + +void FilterColorMatrix::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = NULL; + if (type == COLORMATRIX_LUMINANCETOALPHA) { + out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_ALPHA); + } else { + out = ink_cairo_surface_create_identical(input); + } + + switch (type) { + case COLORMATRIX_MATRIX: + ink_cairo_surface_filter(input, out, ColorMatrixMatrix(values)); + break; + case COLORMATRIX_SATURATE: + ink_cairo_surface_filter(input, out, ColorMatrixSaturate(value)); + break; + case COLORMATRIX_HUEROTATE: + ink_cairo_surface_filter(input, out, ColorMatrixHueRotate(value)); + break; + case COLORMATRIX_LUMINANCETOALPHA: + ink_cairo_surface_filter(input, out, ColorMatrixLuminanceToAlpha()); + break; + case COLORMATRIX_ENDTYPE: + default: + break; + } + + slot.set(_output, out); + cairo_surface_destroy(out); +} + +bool FilterColorMatrix::can_handle_affine(Geom::Matrix const &) +{ + return true; +} void FilterColorMatrix::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/) { @@ -207,7 +373,7 @@ void FilterColorMatrix::set_value(gdouble v){ value = v; } -void FilterColorMatrix::set_values(std::vector &v){ +void FilterColorMatrix::set_values(std::vector const &v){ values = v; } diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index 47b454c53..e3beb943d 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -34,11 +34,13 @@ public: static FilterPrimitive *create(); virtual ~FilterColorMatrix(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); + virtual bool can_handle_affine(Geom::Matrix const &); + virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); virtual void set_type(FilterColorMatrixType type); virtual void set_value(gdouble value); - virtual void set_values(std::vector &values); + virtual void set_values(std::vector const &values); private: std::vector values; gdouble value; diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index 5c00898d4..de9905161 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -33,8 +33,8 @@ FilterPrimitive * FilterComposite::create() { FilterComposite::~FilterComposite() {} -struct BlendArithmetic { - BlendArithmetic(double k1, double k2, double k3, double k4) +struct ComposeArithmetic { + ComposeArithmetic(double k1, double k2, double k3, double k4) : _k1(round(k1 * 255)) , _k2(round(k2 * 255*255)) , _k3(round(k3 * 255*255)) @@ -44,16 +44,21 @@ struct BlendArithmetic { EXTRACT_ARGB32(in1, aa, ra, ga, ba) EXTRACT_ARGB32(in2, ab, rb, gb, bb) - guint32 ao = _k1*aa*ab + _k2*aa + _k3*ab + _k4; ao = (ao + 255*255) / (255*255); - guint32 ro = _k1*ra*rb + _k2*ra + _k3*rb + _k4; ro = (ro + 255*255) / (255*255); - guint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4; go = (go + 255*255) / (255*255); - guint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4; bo = (bo + 255*255) / (255*255); + gint32 ao = _k1*aa*ab + _k2*aa + _k3*ab + _k4; + gint32 ro = _k1*ra*rb + _k2*ra + _k3*rb + _k4; + 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); ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) return pxout; } private: - guint32 _k1, _k2, _k3, _k4; + gint32 _k1, _k2, _k3, _k4; }; void FilterComposite::render_cairo(FilterSlot &slot) @@ -64,7 +69,7 @@ void FilterComposite::render_cairo(FilterSlot &slot) cairo_surface_t *out = ink_cairo_surface_create_output(input1, input2); if (op == COMPOSITE_ARITHMETIC) { - ink_cairo_surface_blend(input1, input2, out, BlendArithmetic(k1, k2, k3, k4)); + ink_cairo_surface_blend(input1, input2, out, ComposeArithmetic(k1, k2, k3, k4)); } else { ink_cairo_surface_blit(input2, out); cairo_t *ct = cairo_create(out); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index a5b5801b1..667a3cc14 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -186,13 +186,14 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea units.set_automatic_resolution(true); } - /*units.set_paraller(false); + units.set_paraller(false); + Geom::Matrix pbtrans = units.get_matrix_display2pb(); for (int i = 0 ; i < _primitive_count ; i++) { - if (_primitive[i]->get_input_traits() & TRAIT_PARALLER) { + if (!_primitive[i]->can_handle_affine(pbtrans)) { units.set_paraller(true); break; } - }*/ + } units.set_paraller(true); FilterSlot slot(const_cast(item), bgct, bgarea, cairo_get_target(graphic), area, units); -- cgit v1.2.3 From 73150a4a03282c19b4b04bd2e3b5ff02fb15952e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 18 Jul 2010 01:31:07 +0200 Subject: Component transfer filter (bzr r9508.1.24) --- src/display/cairo-templates.h | 1 + src/display/cairo-utils.cpp | 7 - src/display/cairo-utils.h | 6 + src/display/nr-filter-colormatrix.cpp | 176 +---------- src/display/nr-filter-colormatrix.h | 7 +- src/display/nr-filter-component-transfer.cpp | 426 +++++++++++++++++---------- src/display/nr-filter-component-transfer.h | 9 +- 7 files changed, 283 insertions(+), 349 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index c64ad78c1..efbd9c094 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -265,6 +265,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter } } } + cairo_surface_mark_dirty(out); } // Some helpers for pixel manipulation diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index c46caa7be..a05d28170 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -448,13 +448,6 @@ ink_cairo_surface_get_height(cairo_surface_t *surface) return cairo_image_surface_get_height(surface); } -// taken from Cairo sources -static inline guint32 premul_alpha(guint32 color, guint32 alpha) -{ - guint32 temp = alpha * color + 128; - return (temp + (temp >> 8)) >> 8; -} - /** * @brief Convert pixel data from GdkPixbuf format to ARGB. * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 1406636d0..02bfe0f73 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -98,6 +98,12 @@ void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); void convert_pixbuf_normal_to_argb32(GdkPixbuf *); void convert_pixbuf_argb32_to_normal(GdkPixbuf *); +inline guint32 premul_alpha(guint32 color, guint32 alpha) +{ + guint32 temp = alpha * color + 128; + return (temp + (temp >> 8)) >> 8; +} + // TODO: move those to 2Geom void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index d0926ebcc..94459e3aa 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -15,8 +15,7 @@ #include "display/cairo-templates.h" #include "display/cairo-utils.h" #include "display/nr-filter-colormatrix.h" -#include "display/nr-filter-units.h" -#include "display/nr-filter-utils.h" +#include "display/nr-filter-slot.h" namespace Inkscape { namespace Filters { @@ -32,173 +31,6 @@ FilterPrimitive * FilterColorMatrix::create() { FilterColorMatrix::~FilterColorMatrix() {} -#if 0 -int FilterColorMatrix::render(FilterSlot &slot, FilterUnits const &/*units*/) { - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feColorMatrix (in=%d)", _input); - return 1; - } - - NRPixBlock *out = new NRPixBlock; - if ((type==COLORMATRIX_SATURATE || type==COLORMATRIX_HUEROTATE) && in->mode != NR_PIXBLOCK_MODE_R8G8B8A8N) { - // saturate and hueRotate do not touch the alpha channel and are linear (per-pixel) operations, so no premultiplied -> non-premultiplied operation is necessary - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8P, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - } else { - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - } - - // this primitive is defined for non-premultiplied RGBA values, - // thus convert them to that format - // However, since not all operations care, the input is only transformed if necessary. - bool free_in_on_exit = false; - if (in->mode != out->mode) { - NRPixBlock *original_in = in; - in = new NRPixBlock; - nr_pixblock_setup_fast(in, out->mode, - original_in->area.x0, original_in->area.y0, - original_in->area.x1, original_in->area.y1, - true); - nr_blit_pixblock_pixblock(in, original_in); - free_in_on_exit = true; - } - - unsigned char *in_data = NR_PIXBLOCK_PX(in); - unsigned char *out_data = NR_PIXBLOCK_PX(out); - unsigned char r,g,b,a; - int x,y,x0,y0,x1,y1,i; - x0=in->area.x0; - y0=in->area.y0; - x1=in->area.x1; - y1=in->area.y1; - - switch(type){ - case COLORMATRIX_MATRIX: - { - if (values.size()!=20) { - g_warning("ColorMatrix: values parameter error. Wrong size: %i.", static_cast(values.size())); - return -1; - } - double a04 = 255*values[4]; - double a14 = 255*values[9]; - double a24 = 255*values[14]; - double a34 = 255*values[19]; - for (x=x0;x( r*a00 + g*a01 + b*a02 + .5 ); - out_data[i+1] = static_cast( r*a10 + g*a11 + b*a12 + .5 ); - out_data[i+2] = static_cast( r*a20 + g*a21 + b*a22 + .5 ); - out_data[i+3] = a; - } - } - } - break; - case COLORMATRIX_HUEROTATE: - { - double coshue = cos(value * M_PI/180.0); - double sinhue = sin(value * M_PI/180.0); - double a00 = 0.213 + coshue*( 0.787) + sinhue*(-0.213); - double a01 = 0.715 + coshue*(-0.715) + sinhue*(-0.715); - double a02 = 0.072 + coshue*(-0.072) + sinhue*( 0.928); - double a10 = 0.213 + coshue*(-0.213) + sinhue*( 0.143); - double a11 = 0.715 + coshue*( 0.285) + sinhue*( 0.140); - double a12 = 0.072 + coshue*(-0.072) + sinhue*(-0.283); - double a20 = 0.213 + coshue*(-0.213) + sinhue*(-0.787); - double a21 = 0.715 + coshue*(-0.715) + sinhue*( 0.715); - double a22 = 0.072 + coshue*( 0.928) + sinhue*( 0.072); - if (in->mode==NR_PIXBLOCK_MODE_R8G8B8A8P) { - // Although it does not change the alpha channel, it can give "out-of-bound" results, and in this case the bound is determined by the alpha channel - for (x=x0;x(std::max(0.0,std::min((double)a, r*a00 + g*a01 + b*a02 + .5 ))); - out_data[i+1] = static_cast(std::max(0.0,std::min((double)a, r*a10 + g*a11 + b*a12 + .5 ))); - out_data[i+2] = static_cast(std::max(0.0,std::min((double)a, r*a20 + g*a21 + b*a22 + .5 ))); - out_data[i+3] = a; - } - } - } else { - for (x=x0;x( r*0.2125 + g*0.7154 + b*0.0721 + .5 ); - } - } - break; - case COLORMATRIX_ENDTYPE: - break; - } - - if (free_in_on_exit) { - nr_pixblock_release(in); - delete in; - } - - out->empty = FALSE; - slot.set(_output, out); - return 0; -} -#endif - struct ColorMatrixMatrix { ColorMatrixMatrix(std::vector const &values) { unsigned limit = std::min(20ul, values.size()); @@ -214,12 +46,6 @@ struct ColorMatrixMatrix { } } - static inline guint32 premul_alpha(guint32 color, guint32 alpha) - { - guint32 temp = alpha * color + 128; - return (temp + (temp >> 8)) >> 8; - } - guint32 operator()(guint32 in) { EXTRACT_ARGB32(in, a, r, g, b) // we need to un-premultiply alpha values for this type of matrix diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index e3beb943d..c95c84568 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -12,14 +12,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include <2geom/forward.h> #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" -#include namespace Inkscape { namespace Filters { +class FilterSlot; + enum FilterColorMatrixType { COLORMATRIX_MATRIX, COLORMATRIX_SATURATE, diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index ab9990360..05795d670 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -10,13 +10,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-filter-component-transfer.h" -#include "display/nr-filter-units.h" -#include "display/nr-filter-utils.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixops.h" #include +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" +#include "display/nr-filter-component-transfer.h" +#include "display/nr-filter-slot.h" namespace Inkscape { namespace Filters { @@ -32,170 +30,278 @@ FilterPrimitive * FilterComponentTransfer::create() { FilterComponentTransfer::~FilterComponentTransfer() {} -int FilterComponentTransfer::render(FilterSlot &slot, FilterUnits const &/*units*/) { - NRPixBlock *in = slot.get(_input); +struct ComponentTransfer { + ComponentTransfer(guint32 color) + : _shift(color * 8) + , _mask(0xff << _shift) + {} +protected: + guint32 _shift; + guint32 _mask; +}; + +template +struct ComponentTransferTable; + +template <> +struct ComponentTransferTable : public ComponentTransfer { + ComponentTransferTable(guint32 color, std::vector const &values) + : ComponentTransfer(color) + , _v(values.size()) + { + for (unsigned i = 0; i< values.size(); ++i) { + _v[i] = round(CLAMP(values[i], 0.0, 1.0) * 255); + } + } + guint32 operator()(guint32 in) { + guint32 component = (in & _mask) >> _shift; + guint32 alpha = (in & 0xff000000) >> 24; + if (alpha == 0) return in; + + component = (255 * component + alpha/2) / alpha; + guint32 k = (_v.size() - 1) * component; + guint32 dx = k % 255; k /= 255; + component = _v[k]*255 + (_v[k+1] - _v[k])*dx; + component = (component + 127) / 255; + component = premul_alpha(component, alpha); + return (in & ~_mask) | (component << _shift); + } +private: + std::vector _v; +}; + +template <> +struct ComponentTransferTable { + ComponentTransferTable(std::vector const &values) + : _v(values.size()) + { + for (unsigned i = 0; i< values.size(); ++i) { + _v[i] = round(CLAMP(values[i], 0.0, 1.0) * 255); + } + } + guint32 operator()(guint32 in) { + guint32 alpha = (in & 0xff000000) >> 24; + if (alpha == 0) return in; + + guint32 k = (_v.size() - 1) * alpha; + guint32 dx = k % 255; k /= 255; + alpha = _v[k]*255 + (_v[k+1] - _v[k])*dx; + alpha = (alpha + 127) / 255; + return (in & 0x00ffffff) | (alpha << 24); + } +private: + std::vector _v; +}; + +template +struct ComponentTransferDiscrete; + +template <> +struct ComponentTransferDiscrete : public ComponentTransfer { + ComponentTransferDiscrete(guint32 color, std::vector const &values) + : ComponentTransfer(color) + , _v(values.size()) + { + for (unsigned i = 0; i< values.size(); ++i) { + _v[i] = round(CLAMP(values[i], 0.0, 1.0) * 255); + } + } + guint32 operator()(guint32 in) { + guint32 component = (in & _mask) >> _shift; + guint32 alpha = (in & 0xff000000) >> 24; + if (alpha == 0) return in; + + component = (255 * component + alpha/2) / alpha; + guint32 k = (_v.size() - 1) * component / 255; + component = _v[k]; + component = premul_alpha(component, alpha); + return (in & ~_mask) | (component << _shift); + } +private: + std::vector _v; +}; + +template <> +struct ComponentTransferDiscrete { + ComponentTransferDiscrete(std::vector const &values) + : _v(values.size()) + { + for (unsigned i = 0; i< values.size(); ++i) { + _v[i] = round(CLAMP(values[i], 0.0, 1.0) * 255); + } + } + guint32 operator()(guint32 in) { + guint32 alpha = (in & 0xff000000) >> 24; + if (alpha == 0) return in; + + guint32 k = (_v.size() - 1) * alpha / 255; + alpha = _v[k]; + return (in & 0x00ffffff) | (alpha << 24); + } +private: + std::vector _v; +}; + +template +struct ComponentTransferLinear; + +template <> +struct ComponentTransferLinear : public ComponentTransfer { + ComponentTransferLinear(guint32 color, double intercept, double slope) + : ComponentTransfer(color) + , _intercept(round(intercept*255*255)) + , _slope(round(slope*255)) + {} + guint32 operator()(guint32 in) { + gint32 component = (in & _mask) >> _shift; + guint32 alpha = (in & 0xff000000) >> 24; + if (alpha == 0) return 0; - if (!in) { - g_warning("Missing source image for feComponentTransfer (in=%d)", _input); - return 1; + // TODO: this can probably be reduced to something simpler + component = (255 * component + alpha/2) / alpha; + component = pxclamp(_slope * component + _intercept, 0, 255*255); + component = (component + 127) / 255; + component = premul_alpha(component, alpha); + return (in & ~_mask) | (component << _shift); } +private: + gint32 _intercept; + gint32 _slope; +}; - int x0=in->area.x0; - int x1=in->area.x1; - int y0=in->area.y0; - int y1=in->area.y1; - - // this primitive is defined for RGBA values, - // thus convert them to that format before blending - bool free_in_on_exit = false; - if (in->mode != NR_PIXBLOCK_MODE_R8G8B8A8N && in->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - NRPixBlock *original_in = in; - in = new NRPixBlock; - nr_pixblock_setup_fast(in, NR_PIXBLOCK_MODE_R8G8B8A8N, - original_in->area.x0, original_in->area.y0, - original_in->area.x1, original_in->area.y1, - false); - nr_blit_pixblock_pixblock(in, original_in); - free_in_on_exit = true; +template <> +struct ComponentTransferLinear { + ComponentTransferLinear(double intercept, double slope) + : _intercept(round(intercept*255*255)) + , _slope(round(slope*255)) + {} + guint32 operator()(guint32 in) { + gint32 alpha = (in & 0xff000000) >> 24; + alpha = pxclamp(_slope * alpha + _intercept, 0, 255*255); + alpha = (alpha + 127) / 255; + return (in & 0x00ffffff) | (alpha << 24); } - bool premultiplied = in->mode == NR_PIXBLOCK_MODE_R8G8B8A8P; - - NRPixBlock *out = new NRPixBlock; - nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true); - - unsigned char *in_data = NR_PIXBLOCK_PX(in); - unsigned char *out_data = NR_PIXBLOCK_PX(out); - - (void)in_data; - (void)out_data; - - int size = 4 * (y1-y0) * (x1-x0); - int i; - - int color=4; - while(color-->0) { - int _vsize = tableValues[color].size(); - double _intercept = intercept[color]; - double _slope = slope[color]; - double _amplitude = amplitude[color]; - double _exponent = exponent[color]; - double _offset = offset[color]; - switch(type[color]){ - case COMPONENTTRANSFER_TYPE_IDENTITY: - for(i=color;i _tableValues(tableValues[color]); - // Scale by 255 and add .5 to avoid having to add it later for rounding purposes - // Note that this means that CLAMP_D_TO_U8 cannot be used here (as it includes rounding!) - for(i=0;i<_vsize;i++) { - _tableValues[i] = std::max(0.,std::min(255.,255*_tableValues[i])) + .5; - } - for(i=color;i((_vsize-1) * in_data[i]); - double dx = ((_vsize-1) * in_data[i])/255.0 - k; - out_data[i] = static_cast(_tableValues[k] + dx * (_tableValues[k+1] - _tableValues[k])); - } - } else { - std::vector _tableValues(tableValues[color]); - for(i=0;i<_vsize;i++) { - _tableValues[i] = std::max(0.,std::min(1.,_tableValues[i])); - } - for(i=color;i _tableValues(_vsize); - // Convert to unsigned char - for(i=0;i<_vsize;i++) { - _tableValues[i] = CLAMP_D_TO_U8(255*tableValues[color][i]); - } - for(i=color;i((_vsize-1) * in_data[i]); - out_data[i] = _tableValues[k]; - } - } else { - std::vector _tableValues(tableValues[color]); - for(i=0;i<_vsize;i++) { - _tableValues[i] = std::max(0.,std::min(1.,_tableValues[i])); - } - for(i=color;i +struct ComponentTransferGamma; + +template <> +struct ComponentTransferGamma : public ComponentTransfer { + ComponentTransferGamma(guint32 color, double amplitude, double exponent, double offset) + : ComponentTransfer(color) + , _amplitude(amplitude) + , _exponent(exponent) + , _offset(offset) + {} + guint32 operator()(guint32 in) { + double component = (in & _mask) >> _shift; + guint32 alpha = (in & 0xff000000) >> 24; + if (alpha == 0) return 0; + + double alphaf = alpha; + component /= alphaf; + component = _amplitude * pow(component, _exponent) + _offset; + guint32 cpx = pxclamp(component * alphaf, 0, 255); + return (in & ~_mask) | (cpx << _shift); + } +private: + double _amplitude; + double _exponent; + double _offset; +}; + +template <> +struct ComponentTransferGamma { + ComponentTransferGamma(double amplitude, double exponent, double offset) + : _amplitude(amplitude) + , _exponent(exponent) + , _offset(offset) + {} + guint32 operator()(guint32 in) { + double alpha = (in & 0xff000000) >> 24; + alpha /= 255.0; + alpha = _amplitude * pow(alpha, _exponent) + _offset; + guint32 cpx = pxclamp(alpha * 255.0, 0, 255); + return (in & 0x00ffffff) | (cpx << 24); + } +private: + double _amplitude; + double _exponent; + double _offset; +}; + +void FilterComponentTransfer::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + //cairo_surface_t *outtemp = ink_cairo_surface_create_identical(out); + ink_cairo_surface_blit(input, out); + + // parameters: R = 0, G = 1, B = 2, A = 3 + // Cairo: R = 2, G = 1, B = 0, A = 3 + for (unsigned i = 0; i < 3; ++i) { + guint32 color = 2 - i; + switch (type[i]) { + case COMPONENTTRANSFER_TYPE_TABLE: + ink_cairo_surface_filter(out, out, + ComponentTransferTable(color, tableValues[i])); + break; + case COMPONENTTRANSFER_TYPE_DISCRETE: + ink_cairo_surface_filter(out, out, + ComponentTransferDiscrete(color, tableValues[i])); + break; + case COMPONENTTRANSFER_TYPE_LINEAR: + ink_cairo_surface_filter(out, out, + ComponentTransferLinear(color, intercept[i], slope[i])); + break; + case COMPONENTTRANSFER_TYPE_GAMMA: + ink_cairo_surface_filter(out, out, + ComponentTransferGamma(color, amplitude[i], exponent[i], offset[i])); + break; + case COMPONENTTRANSFER_TYPE_ERROR: + case COMPONENTTRANSFER_TYPE_IDENTITY: + default: + break; } + //ink_cairo_surface_blit(out, outtemp); } - if (free_in_on_exit) { - nr_pixblock_release(in); - delete in; + // fast paths for alpha channel + switch (type[3]) { + case COMPONENTTRANSFER_TYPE_TABLE: + ink_cairo_surface_filter(out, out, + ComponentTransferTable(tableValues[3])); + break; + case COMPONENTTRANSFER_TYPE_DISCRETE: + ink_cairo_surface_filter(out, out, + ComponentTransferDiscrete(tableValues[3])); + break; + case COMPONENTTRANSFER_TYPE_LINEAR: + ink_cairo_surface_filter(out, out, + ComponentTransferLinear(intercept[3], slope[3])); + break; + case COMPONENTTRANSFER_TYPE_GAMMA: + ink_cairo_surface_filter(out, out, + ComponentTransferGamma(amplitude[3], exponent[3], offset[3])); + break; + case COMPONENTTRANSFER_TYPE_ERROR: + case COMPONENTTRANSFER_TYPE_IDENTITY: + default: + break; } - out->empty = FALSE; slot.set(_output, out); - return 0; + cairo_surface_destroy(out); + //cairo_surface_destroy(outtemp); +} + +bool FilterComponentTransfer::can_handle_affine(Geom::Matrix const &) +{ + return true; } void FilterComponentTransfer::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/) diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index eb76bd543..1e69deb15 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -12,14 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" #include +#include "display/nr-filter-primitive.h" namespace Inkscape { namespace Filters { +class FilterSlot; + enum FilterComponentTransferType { COMPONENTTRANSFER_TYPE_IDENTITY, COMPONENTTRANSFER_TYPE_TABLE, @@ -35,7 +35,8 @@ public: static FilterPrimitive *create(); virtual ~FilterComponentTransfer(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); + virtual bool can_handle_affine(Geom::Matrix const &); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); FilterComponentTransferType type[4]; -- cgit v1.2.3 From 655828bf82f64de8feb9364044c3c8c1bd974170 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 18 Jul 2010 03:05:06 +0200 Subject: Fix type mismatch of std::min args in ColorMatrixMatrix constructor (bzr r9508.1.25) --- src/display/nr-filter-colormatrix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 94459e3aa..8b7956833 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -33,7 +33,7 @@ FilterColorMatrix::~FilterColorMatrix() struct ColorMatrixMatrix { ColorMatrixMatrix(std::vector const &values) { - unsigned limit = std::min(20ul, values.size()); + unsigned limit = std::min(static_cast(20), values.size()); for (unsigned i = 0; i < limit; ++i) { if (i % 5 == 4) { _v[i] = round(values[i]*255*255); -- cgit v1.2.3 From dd78fe909d51f28f7d2e42dcc17ffcb45eb39b23 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 21 Jul 2010 18:37:38 +0200 Subject: Add unpremul_alpha utility function. Some preparations (bzr r9508.1.26) --- src/display/cairo-templates.h | 104 ++++++++++++++++++++++++++++++ src/display/cairo-utils.h | 9 ++- src/display/nr-filter-colormatrix.cpp | 12 ++-- src/display/nr-filter-convolve-matrix.cpp | 7 ++ 4 files changed, 125 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index efbd9c094..871d5c867 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -268,6 +268,110 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter cairo_surface_mark_dirty(out); } +template +void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) +{ + // ASSUMPTIONS + // 1. Cairo ARGB32 surface strides are always divisible by 4 + // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces + + int w = cairo_image_surface_get_width(out); + int h = cairo_image_surface_get_height(out); + int strideout = cairo_image_surface_get_stride(out); + int bppout = cairo_image_surface_get_format(out) == CAIRO_FORMAT_A8 ? 1 : 4; + int limit = w * h; + // NOTE: fast path is not used, because we would need 2 divisions to get pixel indices + + guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); + + #if HAVE_OPENMP + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + #endif + + if (bppout == 4) { + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint32 *out_p = out_data + i * strideout/4; + for (int j = 0; j < w; ++j) { + *out_p = synth(j, i); + ++out_p; + } + } + } else { + // bppout == 1 + #if HAVE_OPENMP + #pragma omp parallel for num_threads(num_threads) + #endif + for (int i = 0; i < h; ++i) { + guint8 *out_p = reinterpret_cast(out_data) + i * strideout; + for (int j = 0; j < w; ++j) { + guint32 out_px = synth(j, i); + *out_p = out_px >> 24; + ++out_p; + } + } + } + cairo_surface_mark_dirty(out); +} + +// simple pixel accessor for image surface that handles different edge wrapping modes +class PixelAccessor { +public: + typedef PixelAccessor self; + enum EdgeMode { + EDGE_PAD, + EDGE_WRAP, + EDGE_ZERO + }; + + PixelAccessor(cairo_surface_t *s, EdgeMode e) + : _surface(s) + , _px(cairo_image_surface_get_data(s)) + , _x(0), _y(0) + , _w(cairo_image_surface_get_width(s)) + , _h(cairo_image_surface_get_height(s)) + , _stride(cairo_image_surface_get_stride(s)) + , _edge_mode(e) + , _alpha(cairo_image_surface_get_format(s) == CAIRO_FORMAT_A8) + {} + + guint32 pixelAt(int x, int y) { + // This is a lot of ifs for a single pixel access. However, branch prediction + // should help us a lot, as the result of ifs is always the same for a single image. + int real_x = x, real_y = y; + switch (_edge_mode) { + case EDGE_PAD: + real_x = CLAMP(x, 0, _w-1); + real_y = CLAMP(y, 0, _h-1); + break; + case EDGE_WRAP: + real_x %= _w; + real_y %= _h; + break; + case EDGE_ZERO: + default: + if (x < 0 || x >= _w || y < 0 || y >= _h) + return 0; + break; + } + if (_alpha) { + return *(_px + real_y*_stride + real_x) << 24; + } else { + guint32 *px = reinterpret_cast(_px +real_y*_stride + real_x*4); + return *px; + } + } +private: + cairo_surface_t *_surface; + guint8 *_px; + int _x, _y, _w, _h, _stride; + EdgeMode _edge_mode; + bool _alpha; +}; + // Some helpers for pixel manipulation G_GNUC_CONST inline gint32 diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 02bfe0f73..12fcd8b3d 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -98,11 +98,18 @@ void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); void convert_pixbuf_normal_to_argb32(GdkPixbuf *); void convert_pixbuf_argb32_to_normal(GdkPixbuf *); -inline guint32 premul_alpha(guint32 color, guint32 alpha) +G_GNUC_CONST inline guint32 +premul_alpha(guint32 color, guint32 alpha) { guint32 temp = alpha * color + 128; return (temp + (temp >> 8)) >> 8; } +G_GNUC_CONST inline guint32 +unpremul_alpha(guint32 color, guint32 alpha) +{ + // NOTE: you must check for alpha != 0 yourself. + return (255 * color + alpha/2) / alpha; +} // TODO: move those to 2Geom void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 8b7956833..7ab606182 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -51,9 +51,9 @@ struct ColorMatrixMatrix { // we need to un-premultiply alpha values for this type of matrix // TODO: unpremul can be ignored if there is an identity mapping on the alpha channel if (a != 0) { - r = (r * 255 + a/2) / a; - b = (b * 255 + a/2) / a; - g = (g * 255 + a/2) / a; + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); } gint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + a*_v[3] + _v[4]; @@ -141,9 +141,9 @@ struct ColorMatrixLuminanceToAlpha { EXTRACT_ARGB32(in, a, r, g, b) // unpremultiply color values if (a != 0) { - r = (r * 255 + a/2) / a; - b = (b * 255 + a/2) / a; - g = (g * 255 + a/2) / a; + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); } guint32 ao = r*54 + g*182 + b*18; return ((ao + 127) / 255) << 24; diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index fc88102d8..0119736cf 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -140,6 +140,13 @@ static void convolve2D(unsigned char *const out_data, unsigned char const *const } } +/* +void FilterConvolveMatrix::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = ink_cairo_surface_create_identical(input); +}*/ + int FilterConvolveMatrix::render(FilterSlot &slot, FilterUnits const &/*units*/) { NRPixBlock *in = slot.get(_input); if (!in) { -- cgit v1.2.3 From 0eb7874184c5c07107804128df1b68d3c777a609 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 21 Jul 2010 21:28:38 +0200 Subject: Matrix convolution filter (lazy version) (bzr r9508.1.27) --- src/display/cairo-templates.h | 4 + src/display/nr-filter-convolve-matrix.cpp | 201 +++++++++++++++++------------- src/display/nr-filter-convolve-matrix.h | 8 +- 3 files changed, 124 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 871d5c867..fabe62579 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -15,6 +15,7 @@ #ifdef HAVE_OPENMP #include #include "preferences.h" +#define OPENMP_THRESHOLD 4096 #endif #include @@ -66,6 +67,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif // The number of code paths here is evil. @@ -194,6 +196,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif if (bppin == 4) { @@ -287,6 +290,7 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); + if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif if (bppout == 4) { diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 0119736cf..267aae936 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -10,10 +10,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-filter-convolve-matrix.h" +#include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" -#include namespace Inkscape { namespace Filters { @@ -28,8 +31,8 @@ FilterPrimitive * FilterConvolveMatrix::create() { FilterConvolveMatrix::~FilterConvolveMatrix() {} -template -static inline void convolve2D_XY(unsigned int const x, unsigned int const y, unsigned char *const out_data, unsigned char const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const bias) { +template +static inline void convolve2D_XY(unsigned int const x, unsigned int const y, guint32 *const out_data, guint32 const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const bias) { double result_R = 0; double result_G = 0; double result_B = 0; @@ -42,41 +45,38 @@ static inline void convolve2D_XY(unsigned int const x, unsigned int const y, uns for (unsigned int i=iBegin; i> 24; } else { - out_data[out_index+3] = CLAMP_D_TO_U8(result_A + bias); - } - if (PREMULTIPLIED) { - out_data[out_index+0] = CLAMP_D_TO_U8_ALPHA(result_R + out_data[out_index+3]*bias, out_data[out_index+3]); // CLAMP includes rounding! - out_data[out_index+1] = CLAMP_D_TO_U8_ALPHA(result_G + out_data[out_index+3]*bias, out_data[out_index+3]); - out_data[out_index+2] = CLAMP_D_TO_U8_ALPHA(result_B + out_data[out_index+3]*bias, out_data[out_index+3]); - } else if (out_data[out_index+3]==0) { - out_data[out_index+0] = 0; // TODO: Is there a more sensible value that can be used here? - out_data[out_index+1] = 0; - out_data[out_index+2] = 0; - } else { - out_data[out_index+0] = CLAMP_D_TO_U8(result_R / out_data[out_index+3] + bias); // CLAMP includes rounding! - out_data[out_index+1] = CLAMP_D_TO_U8(result_G / out_data[out_index+3] + bias); - out_data[out_index+2] = CLAMP_D_TO_U8(result_B / out_data[out_index+3] + bias); + ao = CLAMP_D_TO_U8(result_A + 255*bias); } + + guint32 ro = CLAMP_D_TO_U8_ALPHA(result_R + ao*bias, ao); // CLAMP includes rounding! + guint32 go = CLAMP_D_TO_U8_ALPHA(result_G + ao*bias, ao); + guint32 bo = CLAMP_D_TO_U8_ALPHA(result_B + ao*bias, ao); + + ASSEMBLE_ARGB32(result, ao,ro,go,bo) + + out_data[out_index] = result; } -template -static inline void convolve2D_Y(unsigned int const y, unsigned char *const out_data, unsigned char const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const bias) { +template +static inline void convolve2D_Y(unsigned int const y, guint32 *const out_data, guint32 const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const bias) { // See convolve2D below for rationale. unsigned int const lowerEnd = std::min(targetX,width); @@ -85,29 +85,29 @@ static inline void convolve2D_Y(unsigned int const y, unsigned char *const out_d unsigned int const midXEnd = std::max(lowerEnd,upperBegin); for (unsigned int x=0; x(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_XY(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } if (lowerEnd==upperBegin) { // Do nothing, empty mid section } else if (lowerEnd(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_XY(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } } else { // In the middle both bounds have to be adjusted for (unsigned int x=midXBegin; x(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_XY(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } } for (unsigned int x=midXEnd; x(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_XY(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } } -template -static void convolve2D(unsigned char *const out_data, unsigned char const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const _bias) { - double const bias = PREMULTIPLIED ? _bias : 255*_bias; // If we're using non-premultiplied values the bias is always multiplied by 255. +template +static void convolve2D(guint32 *const out_data, guint32 const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const _bias) { + double const bias = _bias; // For the middle section it should hold that (for all i such that 0<=i(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_Y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } if (lowerEnd==upperBegin) { // Do nothing, empty mid section } else if (lowerEnd(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_Y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } } else { // In the middle both bounds have to be adjusted for (unsigned int y=midYBegin; y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_Y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } } for (unsigned int y=midYEnd; y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); + convolve2D_Y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); } } /* +struct ConvolveMatrix { + ConvolveMatrix(guint32 *px, int yskip, int targetX, int targetY, int orderX, int orderY, + double divisor, double bias, PixelAccessor::EdgeMode emode, + std::vector const &kernel) + : _kernel(kernel.size()) +// , _in(in, emode) + , _tx(targetX), _ty(targetY) + , _oX(orderX), _oY(orderY) + , _yskip(yskip) + , _bias(bias) + { + for (unsigned i = 0; i < kernel.size(); ++i) { + _kernel[i] = kernel[i] / divisor; + } + } + + guint32 operator()(int x, int y) { + int start_x = x - _tX; + int start_y = y - _tY; + + double ro = 0, go = 0, bo = 0, ao = 0; + + for (int i = 0; i < _oY; ++i) { + for (int j = 0; j < _oX; ++j) { + guint32 in = pixelAt(start_x + j, start_y + i); + EXTRACT_ARGB(in, a,r,g,b) + + unsigned kidx = i*_oY + j; + double k = kernel[] + + ro += r * + } + } + + } + +private: + inline guint32 pixelAt(int x, int y) { + return *(_px + y * _yskip + x); + } + + std::vector _kernel; + guint32 *_px; + // PixelAccessor _in; + double _bias; + int _tX, _tY, _oX, _oY, _yskip; +}; */ + void FilterConvolveMatrix::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); - cairo_surface_t *out = ink_cairo_surface_create_identical(input); -}*/ -int FilterConvolveMatrix::render(FilterSlot &slot, FilterUnits const &/*units*/) { - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feConvolveMatrix (in=%d)", _input); - return 1; - } if (orderX<=0 || orderY<=0) { g_warning("Empty kernel!"); - return 1; + return; } if (targetX<0 || targetX>=orderX || targetY<0 || targetY>=orderY) { g_warning("Invalid target!"); - return 1; + return; } if (kernelMatrix.size()!=(unsigned int)(orderX*orderY)) { g_warning("kernelMatrix does not have orderX*orderY elements!"); - return 1; + return; } + cairo_surface_t *out = ink_cairo_surface_create_identical(input); + if (bias!=0) { - g_warning("It is unknown whether Inkscape's implementation of bias in feConvolveMatrix is correct!"); - // The SVG specification implies that feConvolveMatrix is defined for premultiplied colors (which makes sense). - // It also says that bias should simply be added to the result for each color (without taking the alpha into account) - // However, it also says that one purpose of bias is "to have .5 gray value be the zero response of the filter". - // It seems sensible to indeed support the latter behaviour instead of the former, but this does appear to go against the standard. + g_warning("It is unknown whether Inkscape's implementation of bias in feConvolveMatrix " + "is correct!"); + // The SVG specification implies that feConvolveMatrix is defined for premultiplied + // colors (which makes sense). It also says that bias should simply be added to the result + // for each color (without taking the alpha into account). However, it also says that one + // purpose of bias is "to have .5 gray value be the zero response of the filter". + // It seems sensible to indeed support the latter behaviour instead of the former, + // but this does appear to go against the standard. // Note that Batik simply does not support bias!=0 } if (edgeMode!=CONVOLVEMATRIX_EDGEMODE_NONE) { g_warning("Inkscape only supports edgeMode=\"none\" (and a filter uses a different one)!"); - // Note that to properly support edgeMode the interaction with area_enlarge should be well understood (and probably something needs to change) - // area_enlarge should NOT let Inkscape enlarge the area beyond the filter area, it should only enlarge the rendered area if a part of the object is rendered to make it overlapping (enough) with adjacent parts. } - NRPixBlock *out = new NRPixBlock; - - nr_pixblock_setup_fast(out, in->mode, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); + guint32 *in_data = reinterpret_cast(cairo_image_surface_get_data(input)); + guint32 *out_data = reinterpret_cast(cairo_image_surface_get_data(out)); - unsigned char *in_data = NR_PIXBLOCK_PX(in); - unsigned char *out_data = NR_PIXBLOCK_PX(out); - - unsigned int const width = in->area.x1 - in->area.x0; - unsigned int const height = in->area.y1 - in->area.y0; + int width = cairo_image_surface_get_width(input); + int height = cairo_image_surface_get_height(input); // Set up predivided kernel matrix std::vector kernel(kernelMatrix); @@ -198,23 +235,21 @@ int FilterConvolveMatrix::render(FilterSlot &slot, FilterUnits const &/*units*/) kernel[i] /= divisor; // The code that creates this object makes sure that divisor != 0 } - if (in->mode==NR_PIXBLOCK_MODE_R8G8B8A8P) { - if (preserveAlpha) { - convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, targetX, targetY, bias); - } else { - convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, targetX, targetY, bias); - } + if (preserveAlpha) { + convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, + targetX, targetY, bias); } else { - if (preserveAlpha) { - convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, targetX, targetY, bias); - } else { - convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, targetX, targetY, bias); - } + convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, + targetX, targetY, bias); } - out->empty = FALSE; slot.set(_output, out); - return 0; + cairo_surface_destroy(out); +} + +bool FilterConvolveMatrix::can_handle_affine(Geom::Matrix const &) +{ + return false; } void FilterConvolveMatrix::set_targetX(int coord) { @@ -263,10 +298,6 @@ void FilterConvolveMatrix::area_enlarge(NRRectL &area, Geom::Matrix const &/*tra area.y1 += orderY - targetY - 1; } -FilterTraits FilterConvolveMatrix::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index e7416f9cc..904cb30e9 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -13,14 +13,14 @@ */ #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" #include "libnr/nr-rect-l.h" #include namespace Inkscape { namespace Filters { +class FilterSlot; + enum FilterConvolveMatrixEdgeMode { CONVOLVEMATRIX_EDGEMODE_DUPLICATE, CONVOLVEMATRIX_EDGEMODE_WRAP, @@ -34,9 +34,9 @@ public: static FilterPrimitive *create(); virtual ~FilterConvolveMatrix(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); + virtual bool can_handle_affine(Geom::Matrix const &); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); - virtual FilterTraits get_input_traits(); void set_targetY(int coord); void set_targetX(int coord); -- cgit v1.2.3 From 8446900929f553aa8956e2c1b85fdd3d05cd213f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 23 Jul 2010 16:44:54 +0200 Subject: Diffuse lighting filter (bzr r9508.1.28) --- src/display/cairo-templates.h | 223 +++++++++++++++++++++++++-- src/display/nr-3dutils.h | 16 +- src/display/nr-filter-convolve-matrix.cpp | 5 - src/display/nr-filter-convolve-matrix.h | 1 - src/display/nr-filter-diffuselighting.cpp | 244 +++++++++++++++--------------- src/display/nr-filter-diffuselighting.h | 21 ++- src/display/nr-filter-slot.h | 3 +- src/filters/diffuselighting.cpp | 3 + 8 files changed, 361 insertions(+), 155 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index fabe62579..8041d0229 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -15,12 +15,14 @@ #ifdef HAVE_OPENMP #include #include "preferences.h" +// single-threaded operation if the number of pixels is below this threshold #define OPENMP_THRESHOLD 4096 #endif #include #include #include +#include "display/nr-3dutils.h" /** * @brief Blend two surfaces using the supplied functor. @@ -271,23 +273,30 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter cairo_surface_mark_dirty(out); } + +/** + * @brief Synthesize surface pixels based on their position. + * This template accepts a functor that gets called with the x and y coordinates of the pixels, + * given as integers. + * @param out Output surface + * @param out_area The region of the output surface that should be synthesized */ template -void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) +void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const &out_area, Synth synth) { // ASSUMPTIONS // 1. Cairo ARGB32 surface strides are always divisible by 4 // 2. We can only receive CAIRO_FORMAT_ARGB32 or CAIRO_FORMAT_A8 surfaces - int w = cairo_image_surface_get_width(out); - int h = cairo_image_surface_get_height(out); + int w = out_area.width; + int h = out_area.height; int strideout = cairo_image_surface_get_stride(out); int bppout = cairo_image_surface_get_format(out) == CAIRO_FORMAT_A8 ? 1 : 4; - int limit = w * h; // NOTE: fast path is not used, because we would need 2 divisions to get pixel indices - guint32 *const out_data = (guint32*) cairo_image_surface_get_data(out); + unsigned char *out_data = cairo_image_surface_get_data(out); #if HAVE_OPENMP + int limit = w * h; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces @@ -297,9 +306,9 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) #if HAVE_OPENMP #pragma omp parallel for num_threads(num_threads) #endif - for (int i = 0; i < h; ++i) { - guint32 *out_p = out_data + i * strideout/4; - for (int j = 0; j < w; ++j) { + for (int i = out_area.y; i < h; ++i) { + guint32 *out_p = reinterpret_cast(out_data + i * strideout); + for (int j = out_area.x; j < w; ++j) { *out_p = synth(j, i); ++out_p; } @@ -309,9 +318,9 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) #if HAVE_OPENMP #pragma omp parallel for num_threads(num_threads) #endif - for (int i = 0; i < h; ++i) { - guint8 *out_p = reinterpret_cast(out_data) + i * strideout; - for (int j = 0; j < w; ++j) { + for (int i = out_area.y; i < h; ++i) { + guint8 *out_p = out_data + i * strideout; + for (int j = out_area.x; j < w; ++j) { guint32 out_px = synth(j, i); *out_p = out_px >> 24; ++out_p; @@ -321,6 +330,196 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) cairo_surface_mark_dirty(out); } +template +void ink_cairo_surface_synthesize(cairo_surface_t *out, Synth synth) +{ + int w = cairo_image_surface_get_width(out); + int h = cairo_image_surface_get_height(out); + + cairo_rectangle_t area; + area.x = 0; + area.y = 0; + area.width = w; + area.height = h; + + ink_cairo_surface_synthesize(out, area, synth); +} + +struct SurfaceSynth { + SurfaceSynth(cairo_surface_t *surface) + : _px(cairo_image_surface_get_data(surface)) + , _w(cairo_image_surface_get_width(surface)) + , _h(cairo_image_surface_get_height(surface)) + , _stride(cairo_image_surface_get_stride(surface)) + , _alpha(cairo_surface_get_content(surface) == CAIRO_CONTENT_ALPHA) + { + cairo_surface_flush(surface); + } +protected: + guint32 pixelAt(int x, int y) { + if (_alpha) { + unsigned char *px = _px + y*_stride + x; + return *px << 24; + } else { + unsigned char *px = _px + y*_stride + x*4; + return *reinterpret_cast(px); + } + } + guint32 alphaAt(int x, int y) { + if (_alpha) { + unsigned char *px = _px + y*_stride + x; + return *px; + } else { + unsigned char *px = _px + y*_stride + x*4; + guint32 p = *reinterpret_cast(px); + return (p & 0xff000000) >> 24; + } + } + NR::Fvector surfaceNormalAt(int x, int y, double scale) { + // Below there are some multiplies by zero. They will be optimized out. + // Do not remove them, because they improve readability. + NR::Fvector normal; + double fx = -scale/255.0, fy = -scale/255.0; + normal[Z_3D] = 1.0; + if (G_UNLIKELY(x == 0)) { + // leftmost column + if (G_UNLIKELY(y == 0)) { + // upper left corner + fx *= (2.0/3.0); + fy *= (2.0/3.0); + double p00 = alphaAt(x,y), p10 = alphaAt(x+1, y), + p01 = alphaAt(x,y+1), p11 = alphaAt(x+1, y+1); + normal[X_3D] = + -2.0 * p00 +2.0 * p10 + -1.0 * p01 +1.0 * p11; + normal[Y_3D] = + -2.0 * p00 -1.0 * p10 + +2.0 * p01 +1.0 * p11; + } else if (G_UNLIKELY(y == (_h - 1))) { + // lower left corner + fx *= (2.0/3.0); + fy *= (2.0/3.0); + double p00 = alphaAt(x,y-1), p10 = alphaAt(x+1, y-1), + p01 = alphaAt(x,y ), p11 = alphaAt(x+1, y); + normal[X_3D] = + -1.0 * p00 +1.0 * p10 + -2.0 * p01 +2.0 * p11; + normal[Y_3D] = + -2.0 * p00 -1.0 * p10 + +2.0 * p01 +1.0 * p11; + } else { + // leftmost column + fx *= (1.0/2.0); + fy *= (1.0/3.0); + double p00 = alphaAt(x, y-1), p10 = alphaAt(x+1, y-1), + p01 = alphaAt(x, y ), p11 = alphaAt(x+1, y ), + p02 = alphaAt(x, y+1), p12 = alphaAt(x+1, y+1); + normal[X_3D] = + -1.0 * p00 +1.0 * p10 + -2.0 * p01 +2.0 * p11 + -1.0 * p02 +1.0 * p12; + normal[Y_3D] = + -2.0 * p00 -1.0 * p10 + +0.0 * p01 +0.0 * p11 // this will be optimized out + +2.0 * p02 +1.0 * p12; + } + } else if (G_UNLIKELY(x == (_w - 1))) { + // rightmost column + if (G_UNLIKELY(y == 0)) { + // top right corner + fx *= (2.0/3.0); + fy *= (2.0/3.0); + double p00 = alphaAt(x-1,y), p10 = alphaAt(x, y), + p01 = alphaAt(x-1,y+1), p11 = alphaAt(x, y+1); + normal[X_3D] = + -2.0 * p00 +2.0 * p10 + -1.0 * p01 +1.0 * p11; + normal[Y_3D] = + -1.0 * p00 -2.0 * p10 + +1.0 * p01 +2.0 * p11; + } else if (G_UNLIKELY(y == (_h - 1))) { + // bottom right corner + fx *= (2.0/3.0); + fy *= (2.0/3.0); + double p00 = alphaAt(x-1,y-1), p10 = alphaAt(x, y-1), + p01 = alphaAt(x-1,y ), p11 = alphaAt(x, y); + normal[X_3D] = + -1.0 * p00 +1.0 * p10 + -2.0 * p01 +2.0 * p11; + normal[Y_3D] = + -1.0 * p00 -2.0 * p10 + +1.0 * p01 +2.0 * p11; + } else { + // rightmost column + fx *= (1.0/2.0); + fy *= (1.0/3.0); + double p00 = alphaAt(x-1, y-1), p10 = alphaAt(x, y-1), + p01 = alphaAt(x-1, y ), p11 = alphaAt(x, y ), + p02 = alphaAt(x-1, y+1), p12 = alphaAt(x, y+1); + normal[X_3D] = + -1.0 * p00 +1.0 * p10 + -2.0 * p01 +2.0 * p11 + -1.0 * p02 +1.0 * p12; + normal[Y_3D] = + -1.0 * p00 -2.0 * p10 + +0.0 * p01 +0.0 * p11 + +1.0 * p02 +2.0 * p12; + } + } else { + // interior + if (G_UNLIKELY(y == 0)) { + // top row + fx *= (1.0/3.0); + fy *= (1.0/2.0); + double p00 = alphaAt(x-1, y ), p10 = alphaAt(x, y ), p20 = alphaAt(x+1, y ), + p01 = alphaAt(x-1, y+1), p11 = alphaAt(x, y+1), p21 = alphaAt(x+1, y+1); + normal[X_3D] = + -2.0 * p00 +0.0 * p10 +2.0 * p20 + -1.0 * p01 +0.0 * p11 +1.0 * p21; + normal[Y_3D] = + -1.0 * p00 -2.0 * p10 -1.0 * p20 + +1.0 * p01 +2.0 * p11 +1.0 * p21; + } else if (G_UNLIKELY(y == (_h - 1))) { + // bottom row + fx *= (1.0/3.0); + fy *= (1.0/2.0); + double p00 = alphaAt(x-1, y-1), p10 = alphaAt(x, y-1), p20 = alphaAt(x+1, y-1), + p01 = alphaAt(x-1, y ), p11 = alphaAt(x, y ), p21 = alphaAt(x+1, y ); + normal[X_3D] = + -1.0 * p00 +0.0 * p10 +1.0 * p20 + -2.0 * p01 +0.0 * p11 +2.0 * p21; + normal[Y_3D] = + -1.0 * p00 -2.0 * p10 -1.0 * p20 + +1.0 * p01 +2.0 * p11 +1.0 * p21; + } else { + // interior pixels + fx *= (1.0/4.0); + fy *= (1.0/4.0); + double p00 = alphaAt(x-1, y-1), p10 = alphaAt(x, y-1), p20 = alphaAt(x+1, y-1), + p01 = alphaAt(x-1, y ), p11 = alphaAt(x, y ), p21 = alphaAt(x+1, y ), + p02 = alphaAt(x-1, y+1), p12 = alphaAt(x, y+1), p22 = alphaAt(x+1, y+1); + normal[X_3D] = + -1.0 * p00 +0.0 * p10 +1.0 * p20 + -2.0 * p01 +0.0 * p11 +2.0 * p21 + -1.0 * p02 +0.0 * p12 +1.0 * p22; + normal[Y_3D] = + -1.0 * p00 -2.0 * p10 -1.0 * p20 + +0.0 * p01 +0.0 * p11 +0.0 * p21 + +1.0 * p02 +2.0 * p12 +1.0 * p22; + } + } + normal[X_3D] *= fx; + normal[Y_3D] *= fy; + NR::normalize_vector(normal); + return normal; + } + + unsigned char *_px; + int _w, _h, _stride; + bool _alpha; +}; + +/* // simple pixel accessor for image surface that handles different edge wrapping modes class PixelAccessor { public: @@ -374,7 +573,7 @@ private: int _x, _y, _w, _h, _stride; EdgeMode _edge_mode; bool _alpha; -}; +};*/ // Some helpers for pixel manipulation diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h index dbbc7c9a4..42df36c82 100644 --- a/src/display/nr-3dutils.h +++ b/src/display/nr-3dutils.h @@ -28,12 +28,24 @@ namespace NR { /** * a type of 3 gdouble components vectors */ -typedef gdouble Fvector[3]; +struct Fvector { + Fvector() { + v[0] = v[1] = v[2] = 0.0; + } + Fvector(double x, double y, double z) { + v[0] = x; + v[1] = y; + v[2] = z; + } + double v[3]; + double &operator[](unsigned i) { return v[i]; } + double operator[](unsigned i) const { return v[i]; } +}; /** * The eye vector */ -const static Fvector EYE_VECTOR = {0, 0, 1}; +const static Fvector EYE_VECTOR(0, 0, 1); /** * returns the euclidian norm of the vector v diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 267aae936..fcb15ee98 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -247,11 +247,6 @@ void FilterConvolveMatrix::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -bool FilterConvolveMatrix::can_handle_affine(Geom::Matrix const &) -{ - return false; -} - void FilterConvolveMatrix::set_targetX(int coord) { targetX = coord; } diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index 904cb30e9..d1fc9c364 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -35,7 +35,6 @@ public: virtual ~FilterConvolveMatrix(); virtual void render_cairo(FilterSlot &slot); - virtual bool can_handle_affine(Geom::Matrix const &); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); void set_targetY(int coord); diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 0fe4c5947..04de6ebf9 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -12,6 +12,8 @@ #include +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-3dutils.h" #include "display/nr-arena-item.h" #include "display/nr-filter-diffuselighting.h" @@ -43,129 +45,131 @@ FilterPrimitive * FilterDiffuseLighting::create() { FilterDiffuseLighting::~FilterDiffuseLighting() {} -int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) { - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feDiffuseLighting (in=%d)", _input); - return 1; +struct DiffuseDistantLight : public SurfaceSynth { + DiffuseDistantLight(cairo_surface_t *bumpmap, SPFeDistantLight *light, guint32 color, + double scale, double diffuse_constant) + : SurfaceSynth(bumpmap) + , _scale(scale) + , _kd(diffuse_constant) + { + DistantLight dl(light, color); + dl.light_vector(_lightv); + dl.light_components(_light_components); } - NRPixBlock *out = new NRPixBlock; - - int w = in->area.x1 - in->area.x0; - int h = in->area.y1 - in->area.y0; - int x0 = in->area.x0; - int y0 = in->area.y0; - int i, j; - //As long as FilterRes and kernel unit is not supported we hardcode the - //default value - int dx = 1; //TODO setup - int dy = 1; //TODO setup - //surface scale - Geom::Matrix trans = units.get_matrix_primitiveunits2pb(); - gdouble ss = surfaceScale * trans[0]; - gdouble kd = diffuseConstant; //diffuse lighting constant - - NR::Fvector L, N, LC; - gdouble inter; - - nr_pixblock_setup_fast(out, in->mode, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - unsigned char *data_i = NR_PIXBLOCK_PX (in); - unsigned char *data_o = NR_PIXBLOCK_PX (out); - //No light, nothing to do + guint32 operator()(int x, int y) { + NR::Fvector normal = surfaceNormalAt(x, y, _scale); + double k = _kd * NR::scalar_product(normal, _lightv); + + guint32 r = CLAMP_D_TO_U8(k * _light_components[LIGHT_RED]); + guint32 g = CLAMP_D_TO_U8(k * _light_components[LIGHT_GREEN]); + guint32 b = CLAMP_D_TO_U8(k * _light_components[LIGHT_BLUE]); + + ASSEMBLE_ARGB32(pxout, 255,r,g,b) + return pxout; + } +private: + NR::Fvector _lightv, _light_components; + double _scale, _kd; +}; + +struct DiffusePointLight : public SurfaceSynth { + DiffusePointLight(cairo_surface_t *bumpmap, SPFePointLight *light, guint32 color, + Geom::Matrix const &trans, double scale, double diffuse_constant, double x0, double y0) + : SurfaceSynth(bumpmap) + , _light(light, color, trans) + , _scale(scale) + , _kd(diffuse_constant) + , _x0(x0) + , _y0(y0) + { + _light.light_components(_light_components); + } + + guint32 operator()(int x, int y) { + NR::Fvector normal = surfaceNormalAt(x, y, _scale); + NR::Fvector light; + _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + double k = _kd * NR::scalar_product(normal, light); + + guint32 r = CLAMP_D_TO_U8(k * _light_components[LIGHT_RED]); + guint32 g = CLAMP_D_TO_U8(k * _light_components[LIGHT_GREEN]); + guint32 b = CLAMP_D_TO_U8(k * _light_components[LIGHT_BLUE]); + + ASSEMBLE_ARGB32(pxout, 255,r,g,b) + return pxout; + } +private: + PointLight _light; + NR::Fvector _light_components; + double _scale, _kd, _x0, _y0; +}; + +struct DiffuseSpotLight : public SurfaceSynth { + DiffuseSpotLight(cairo_surface_t *bumpmap, SPFeSpotLight *light, guint32 color, + Geom::Matrix const &trans, double scale, double diffuse_constant, double x0, double y0) + : SurfaceSynth(bumpmap) + , _light(light, color, trans) + , _scale(scale) + , _kd(diffuse_constant) + , _x0(x0) + , _y0(y0) + {} + + guint32 operator()(int x, int y) { + NR::Fvector normal = surfaceNormalAt(x, y, _scale); + NR::Fvector light; + NR::Fvector light_components; + _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + _light.light_components(light_components, light); + double k = _kd * NR::scalar_product(normal, light); + + guint32 r = CLAMP_D_TO_U8(k * light_components[LIGHT_RED]); + guint32 g = CLAMP_D_TO_U8(k * light_components[LIGHT_GREEN]); + guint32 b = CLAMP_D_TO_U8(k * light_components[LIGHT_BLUE]); + + ASSEMBLE_ARGB32(pxout, 255,r,g,b) + return pxout; + } +private: + SpotLight _light; + double _scale, _kd, _x0, _y0; +}; + +void FilterDiffuseLighting::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + + NRRectL const &slot_area = slot.get_slot_area(); + Geom::Matrix trans = slot.get_units().get_matrix_primitiveunits2pb(); + double x0 = slot_area.x0, y0 = slot_area.y0; + double scale = surfaceScale * trans[0]; + switch (light_type) { - case DISTANT_LIGHT: - //the light vector is constant - { - DistantLight *dl = new DistantLight(light.distant, lighting_color); - dl->light_vector(L); - dl->light_components(LC); - //finish the work - for (i = 0, j = 0; i < w*h; i++) { - NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); - inter = kd * NR::scalar_product(N, L); - - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); // CLAMP includes rounding! - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]); - data_o[j++] = 255; - } - out->empty = FALSE; - delete dl; - } - break; - case POINT_LIGHT: - { - PointLight *pl = new PointLight(light.point, lighting_color, trans); - pl->light_components(LC); - //TODO we need a reference to the filter to determine primitiveUnits - //if objectBoundingBox is used, use a different matrix for light_vector - // UPDATE: trans is now correct matrix from primitiveUnits to - // pixblock coordinates - //finish the work - for (i = 0, j = 0; i < w*h; i++) { - NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); - pl->light_vector(L, - i % w + x0, - i / w + y0, - ss * (double) data_i[4*i+3]/ 255); - inter = kd * NR::scalar_product(N, L); - - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]); - data_o[j++] = 255; - } - out->empty = FALSE; - delete pl; - } - break; - case SPOT_LIGHT: - { - SpotLight *sl = new SpotLight(light.spot, lighting_color, trans); - //TODO we need a reference to the filter to determine primitiveUnits - //if objectBoundingBox is used, use a different matrix for light_vector - // UPDATE: trans is now correct matrix from primitiveUnits to - // pixblock coordinates - //finish the work - for (i = 0, j = 0; i < w*h; i++) { - NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); - sl->light_vector(L, - i % w + x0, - i / w + y0, - ss * (double) data_i[4*i+3]/ 255); - sl->light_components(LC, L); - inter = kd * NR::scalar_product(N, L); - - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]); - data_o[j++] = 255; - } - out->empty = FALSE; - delete sl; - } - break; - //else unknown light source, doing nothing - case NO_LIGHT: - default: - { - if (light_type != NO_LIGHT) - g_warning("unknown light source %d", light_type); - for (i = 0; i < w*h; i++) { - data_o[4*i+3] = 255; - } - out->empty = false; - } + case DISTANT_LIGHT: + ink_cairo_surface_synthesize(out, + DiffuseDistantLight(input, light.distant, lighting_color, scale, diffuseConstant)); + break; + case POINT_LIGHT: + ink_cairo_surface_synthesize(out, + DiffusePointLight(input, light.point, lighting_color, trans, scale, diffuseConstant, x0, y0)); + break; + case SPOT_LIGHT: + ink_cairo_surface_synthesize(out, + DiffuseSpotLight(input, light.spot, lighting_color, trans, scale, diffuseConstant, x0, y0)); + break; + default: { + cairo_t *ct = cairo_create(out); + cairo_set_source_rgba(ct, 0,0,0,1); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + } break; } - - //finishing + slot.set(_output, out); - //nr_pixblock_release(in); - //delete in; - return 0; + cairo_surface_destroy(out); } void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Matrix const &trans) @@ -181,10 +185,6 @@ void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Matrix const &tran area.y1 += (int)(scaley) + 2; } -FilterTraits FilterDiffuseLighting::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 708c7a0a2..6e46bc1e1 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -18,16 +18,22 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "filters/distantlight.h" -#include "filters/pointlight.h" -#include "filters/spotlight.h" -#include "color.h" + +class SPFeDistantLight; +class SPFePointLight; +class SPFeSpotLight; namespace Inkscape { namespace Filters { class FilterDiffuseLighting : public FilterPrimitive { public: + FilterDiffuseLighting(); + static FilterPrimitive *create(); + virtual ~FilterDiffuseLighting(); + virtual void render_cairo(FilterSlot &slot); + virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); + union { SPFeDistantLight *distant; SPFePointLight *point; @@ -37,13 +43,6 @@ public: gdouble diffuseConstant; gdouble surfaceScale; guint32 lighting_color; - - FilterDiffuseLighting(); - static FilterPrimitive *create(); - virtual ~FilterDiffuseLighting(); - virtual int render(FilterSlot &slot, FilterUnits const &units); - virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); - virtual FilterTraits get_input_traits(); private: }; diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 92f66ddf8..a9fac61d9 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -62,8 +62,6 @@ public: cairo_surface_t *get_result(int slot_nr); - NRRectL const *get_slot_area(); - /** Returns the number of slots in use. */ int get_slot_count(); @@ -80,6 +78,7 @@ public: int get_blurquality(void); FilterUnits const &get_units() const { return _units; } + NRRectL const &get_slot_area() const { return _slot_area; } private: typedef std::map SlotMap; diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 117b9d145..59b00d183 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -24,6 +24,9 @@ #include "sp-object.h" #include "svg/svg-color.h" #include "filters/diffuselighting.h" +#include "filters/distantlight.h" +#include "filters/pointlight.h" +#include "filters/spotlight.h" #include "display/nr-filter.h" #include "xml/repr.h" #include "display/nr-filter-diffuselighting.h" -- cgit v1.2.3 From 479779b784d886078444da59ee873a9c1a847a46 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 23 Jul 2010 20:12:24 +0200 Subject: Specular lighting filter (bzr r9508.1.29) --- src/display/cairo-templates.h | 6 +- src/display/nr-filter-diffuselighting.cpp | 102 ++++++++----------- src/display/nr-filter-specularlighting.cpp | 155 ++++++++++++++++++++++++++--- src/display/nr-filter-specularlighting.h | 22 ++-- src/filters/specularlighting.cpp | 5 +- 5 files changed, 201 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 8041d0229..9c2a8c782 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -279,7 +279,8 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter * This template accepts a functor that gets called with the x and y coordinates of the pixels, * given as integers. * @param out Output surface - * @param out_area The region of the output surface that should be synthesized */ + * @param out_area The region of the output surface that should be synthesized + * @param synth Synthesis functor */ template void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const &out_area, Synth synth) { @@ -493,10 +494,11 @@ protected: +1.0 * p01 +2.0 * p11 +1.0 * p21; } else { // interior pixels + // note: p11 is actually unused, so we don't fetch its value fx *= (1.0/4.0); fy *= (1.0/4.0); double p00 = alphaAt(x-1, y-1), p10 = alphaAt(x, y-1), p20 = alphaAt(x+1, y-1), - p01 = alphaAt(x-1, y ), p11 = alphaAt(x, y ), p21 = alphaAt(x+1, y ), + p01 = alphaAt(x-1, y ), p11 = 0.0, p21 = alphaAt(x+1, y ), p02 = alphaAt(x-1, y+1), p12 = alphaAt(x, y+1), p22 = alphaAt(x+1, y+1); normal[X_3D] = -1.0 * p00 +0.0 * p10 +1.0 * p20 diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 04de6ebf9..d48b6d690 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -4,8 +4,9 @@ * Authors: * Niko Kiirala * Jean-Rene Reinhard + * Krzysztof Kosiński * - * Copyright (C) 2007 authors + * Copyright (C) 2007-2010 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -17,15 +18,11 @@ #include "display/nr-3dutils.h" #include "display/nr-arena-item.h" #include "display/nr-filter-diffuselighting.h" -#include "display/nr-filter-getalpha.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" #include "libnr/nr-rect-l.h" -#include "color.h" namespace Inkscape { namespace Filters { @@ -45,12 +42,32 @@ FilterPrimitive * FilterDiffuseLighting::create() { FilterDiffuseLighting::~FilterDiffuseLighting() {} -struct DiffuseDistantLight : public SurfaceSynth { - DiffuseDistantLight(cairo_surface_t *bumpmap, SPFeDistantLight *light, guint32 color, - double scale, double diffuse_constant) +struct DiffuseLight : public SurfaceSynth { + DiffuseLight(cairo_surface_t *bumpmap, double scale, double kd) : SurfaceSynth(bumpmap) , _scale(scale) - , _kd(diffuse_constant) + , _kd(kd) + {} + +protected: + guint32 diffuseLighting(int x, int y, NR::Fvector const &light, NR::Fvector const &light_components) { + NR::Fvector normal = surfaceNormalAt(x, y, _scale); + double k = _kd * NR::scalar_product(normal, light); + + guint32 r = CLAMP_D_TO_U8(k * light_components[LIGHT_RED]); + guint32 g = CLAMP_D_TO_U8(k * light_components[LIGHT_GREEN]); + guint32 b = CLAMP_D_TO_U8(k * light_components[LIGHT_BLUE]); + + ASSEMBLE_ARGB32(pxout, 255,r,g,b) + return pxout; + } + double _scale, _kd; +}; + +struct DiffuseDistantLight : public DiffuseLight { + DiffuseDistantLight(cairo_surface_t *bumpmap, SPFeDistantLight *light, guint32 color, + double scale, double diffuse_constant) + : DiffuseLight(bumpmap, scale, diffuse_constant) { DistantLight dl(light, color); dl.light_vector(_lightv); @@ -58,28 +75,17 @@ struct DiffuseDistantLight : public SurfaceSynth { } guint32 operator()(int x, int y) { - NR::Fvector normal = surfaceNormalAt(x, y, _scale); - double k = _kd * NR::scalar_product(normal, _lightv); - - guint32 r = CLAMP_D_TO_U8(k * _light_components[LIGHT_RED]); - guint32 g = CLAMP_D_TO_U8(k * _light_components[LIGHT_GREEN]); - guint32 b = CLAMP_D_TO_U8(k * _light_components[LIGHT_BLUE]); - - ASSEMBLE_ARGB32(pxout, 255,r,g,b) - return pxout; + return diffuseLighting(x, y, _lightv, _light_components); } private: NR::Fvector _lightv, _light_components; - double _scale, _kd; }; -struct DiffusePointLight : public SurfaceSynth { +struct DiffusePointLight : public DiffuseLight { DiffusePointLight(cairo_surface_t *bumpmap, SPFePointLight *light, guint32 color, Geom::Matrix const &trans, double scale, double diffuse_constant, double x0, double y0) - : SurfaceSynth(bumpmap) + : DiffuseLight(bumpmap, scale, diffuse_constant) , _light(light, color, trans) - , _scale(scale) - , _kd(diffuse_constant) , _x0(x0) , _y0(y0) { @@ -87,53 +93,34 @@ struct DiffusePointLight : public SurfaceSynth { } guint32 operator()(int x, int y) { - NR::Fvector normal = surfaceNormalAt(x, y, _scale); NR::Fvector light; _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); - double k = _kd * NR::scalar_product(normal, light); - - guint32 r = CLAMP_D_TO_U8(k * _light_components[LIGHT_RED]); - guint32 g = CLAMP_D_TO_U8(k * _light_components[LIGHT_GREEN]); - guint32 b = CLAMP_D_TO_U8(k * _light_components[LIGHT_BLUE]); - - ASSEMBLE_ARGB32(pxout, 255,r,g,b) - return pxout; + return diffuseLighting(x, y, light, _light_components); } private: PointLight _light; NR::Fvector _light_components; - double _scale, _kd, _x0, _y0; + double _x0, _y0; }; -struct DiffuseSpotLight : public SurfaceSynth { +struct DiffuseSpotLight : public DiffuseLight { DiffuseSpotLight(cairo_surface_t *bumpmap, SPFeSpotLight *light, guint32 color, Geom::Matrix const &trans, double scale, double diffuse_constant, double x0, double y0) - : SurfaceSynth(bumpmap) + : DiffuseLight(bumpmap, scale, diffuse_constant) , _light(light, color, trans) - , _scale(scale) - , _kd(diffuse_constant) , _x0(x0) , _y0(y0) {} guint32 operator()(int x, int y) { - NR::Fvector normal = surfaceNormalAt(x, y, _scale); - NR::Fvector light; - NR::Fvector light_components; + NR::Fvector light, light_components; _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); _light.light_components(light_components, light); - double k = _kd * NR::scalar_product(normal, light); - - guint32 r = CLAMP_D_TO_U8(k * light_components[LIGHT_RED]); - guint32 g = CLAMP_D_TO_U8(k * light_components[LIGHT_GREEN]); - guint32 b = CLAMP_D_TO_U8(k * light_components[LIGHT_BLUE]); - - ASSEMBLE_ARGB32(pxout, 255,r,g,b) - return pxout; + return diffuseLighting(x, y, light, light_components); } private: SpotLight _light; - double _scale, _kd, _x0, _y0; + double _x0, _y0; }; void FilterDiffuseLighting::render_cairo(FilterSlot &slot) @@ -144,7 +131,7 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) NRRectL const &slot_area = slot.get_slot_area(); Geom::Matrix trans = slot.get_units().get_matrix_primitiveunits2pb(); double x0 = slot_area.x0, y0 = slot_area.y0; - double scale = surfaceScale * trans[0]; + double scale = surfaceScale * trans.descrim(); switch (light_type) { case DISTANT_LIGHT: @@ -175,14 +162,13 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { // TODO: support kernelUnitLength - double scalex = std::fabs(trans[0]) + std::fabs(trans[1]); - double scaley = std::fabs(trans[2]) + std::fabs(trans[3]); - - //FIXME: no +2 should be there!... (noticable only for big scales at big zoom factor) - area.x0 -= (int)(scalex) + 2; - area.x1 += (int)(scalex) + 2; - area.y0 -= (int)(scaley) + 2; - area.y1 += (int)(scaley) + 2; + + // We expand the area by 1 in every direction to avoid artifacts on tile edges. + // However, it means that edge pixels will be incorrect. + area.x0 -= 1; + area.x1 += 1; + area.y0 -= 1; + area.y1 += 1; } } /* namespace Filters */ diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 6a6ce38a8..23b9b20ac 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -13,18 +13,16 @@ #include #include +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-3dutils.h" -#include "display/nr-arena-item.h" #include "display/nr-filter-specularlighting.h" #include "display/nr-filter-getalpha.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" #include "libnr/nr-rect-l.h" -#include "color.h" namespace Inkscape { namespace Filters { @@ -59,6 +57,138 @@ do {\ (inter) = (ks) * std::pow(scal, (specularExponent));\ }while(0) +struct SpecularLight : public SurfaceSynth { + SpecularLight(cairo_surface_t *bumpmap, double scale, double specular_constant, + double specular_exponent) + : SurfaceSynth(bumpmap) + , _scale(scale) + , _ks(specular_constant) + , _exp(specular_exponent) + {} +protected: + guint32 specularLighting(int x, int y, NR::Fvector const &halfway, NR::Fvector const &light_components) { + NR::Fvector normal = surfaceNormalAt(x, y, _scale); + double sp = NR::scalar_product(normal, halfway); + double k = sp <= 0.0 ? 0.0 : _ks * pow(sp, _exp); + + guint32 r = CLAMP_D_TO_U8(k * light_components[LIGHT_RED]); + guint32 g = CLAMP_D_TO_U8(k * light_components[LIGHT_GREEN]); + guint32 b = CLAMP_D_TO_U8(k * light_components[LIGHT_BLUE]); + guint32 a = std::max(std::max(r, g), b); + + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + + ASSEMBLE_ARGB32(pxout, a,r,g,b) + return pxout; + } + double _scale, _ks, _exp; +}; + +struct SpecularDistantLight : public SpecularLight { + SpecularDistantLight(cairo_surface_t *bumpmap, SPFeDistantLight *light, guint32 color, + double scale, double specular_constant, double specular_exponent) + : SpecularLight(bumpmap, scale, specular_constant, specular_exponent) + { + DistantLight dl(light, color); + NR::Fvector lv; + dl.light_vector(lv); + dl.light_components(_light_components); + NR::normalized_sum(_halfway, lv, NR::EYE_VECTOR); + } + guint32 operator()(int x, int y) { + return specularLighting(x, y, _halfway, _light_components); + } +private: + NR::Fvector _halfway, _light_components; +}; + +struct SpecularPointLight : public SpecularLight { + SpecularPointLight(cairo_surface_t *bumpmap, SPFePointLight *light, guint32 color, + Geom::Matrix const &trans, double scale, double specular_constant, + double specular_exponent, double x0, double y0) + : SpecularLight(bumpmap, scale, specular_constant, specular_exponent) + , _light(light, color, trans) + , _x0(x0) + , _y0(y0) + { + _light.light_components(_light_components); + } + + guint32 operator()(int x, int y) { + NR::Fvector light, halfway; + _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + NR::normalized_sum(halfway, light, NR::EYE_VECTOR); + return specularLighting(x, y, halfway, _light_components); + } +private: + PointLight _light; + NR::Fvector _light_components; + double _x0, _y0; +}; + +struct SpecularSpotLight : public SpecularLight { + SpecularSpotLight(cairo_surface_t *bumpmap, SPFeSpotLight *light, guint32 color, + Geom::Matrix const &trans, double scale, double specular_constant, + double specular_exponent, double x0, double y0) + : SpecularLight(bumpmap, scale, specular_constant, specular_exponent) + , _light(light, color, trans) + , _x0(x0) + , _y0(y0) + {} + + guint32 operator()(int x, int y) { + NR::Fvector light, halfway, light_components; + _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + _light.light_components(light_components, light); + NR::normalized_sum(halfway, light, NR::EYE_VECTOR); + return specularLighting(x, y, halfway, light_components); + } +private: + SpotLight _light; + double _x0, _y0; +}; + +void FilterSpecularLighting::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + + NRRectL const &slot_area = slot.get_slot_area(); + Geom::Matrix trans = slot.get_units().get_matrix_primitiveunits2pb(); + double x0 = slot_area.x0, y0 = slot_area.y0; + double scale = surfaceScale * trans.descrim(); + double ks = specularConstant; + double se = specularExponent; + + switch (light_type) { + case DISTANT_LIGHT: + ink_cairo_surface_synthesize(out, + SpecularDistantLight(input, light.distant, lighting_color, scale, ks, se)); + break; + case POINT_LIGHT: + ink_cairo_surface_synthesize(out, + SpecularPointLight(input, light.point, lighting_color, trans, scale, ks, se, x0, y0)); + break; + case SPOT_LIGHT: + ink_cairo_surface_synthesize(out, + SpecularSpotLight(input, light.spot, lighting_color, trans, scale, ks, se, x0, y0)); + break; + default: { + cairo_t *ct = cairo_create(out); + cairo_set_source_rgba(ct, 0,0,0,1); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + } break; + } + + slot.set(_output, out); + cairo_surface_destroy(out); +} + +/* int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); if (!in) { @@ -186,23 +316,16 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { //nr_pixblock_release(in); //delete in; return 0; -} +}*/ void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { // TODO: support kernelUnitLength - double scalex = std::fabs(trans[0]) + std::fabs(trans[1]); - double scaley = std::fabs(trans[2]) + std::fabs(trans[3]); - - //FIXME: no +2 should be there!... (noticable only for big scales at big zoom factor) - area.x0 -= (int)(scalex) + 2; - area.x1 += (int)(scalex) + 2; - area.y0 -= (int)(scaley) + 2; - area.y1 += (int)(scaley) + 2; -} -FilterTraits FilterSpecularLighting::get_input_traits() { - return TRAIT_PARALLER; + area.x0 -= 1; + area.x1 += 1; + area.y0 -= 1; + area.y1 += 1; } } /* namespace Filters */ diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 0f9e6dfe9..a350c4b29 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -17,17 +17,22 @@ #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" -#include "filters/distantlight.h" -#include "filters/pointlight.h" -#include "filters/spotlight.h" -#include "color.h" + +class SPFeDistantLight; +class SPFePointLight; +class SPFeSpotLight; namespace Inkscape { namespace Filters { class FilterSpecularLighting : public FilterPrimitive { public: + FilterSpecularLighting(); + static FilterPrimitive *create(); + virtual ~FilterSpecularLighting(); + virtual void render_cairo(FilterSlot &slot); + virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); + union { SPFeDistantLight *distant; SPFePointLight *point; @@ -38,13 +43,6 @@ public: gdouble specularConstant; gdouble specularExponent; guint32 lighting_color; - - FilterSpecularLighting(); - static FilterPrimitive *create(); - virtual ~FilterSpecularLighting(); - virtual int render(FilterSlot &slot, FilterUnits const &units); - virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); - virtual FilterTraits get_input_traits(); private: }; diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 1b6000522..2c38d6bda 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -23,7 +23,10 @@ #include "svg/svg.h" #include "sp-object.h" #include "svg/svg-color.h" -#include "specularlighting.h" +#include "filters/specularlighting.h" +#include "filters/distantlight.h" +#include "filters/pointlight.h" +#include "filters/spotlight.h" #include "xml/repr.h" #include "display/nr-filter.h" #include "display/nr-filter-specularlighting.h" -- cgit v1.2.3 From f146c69978df15996df79962ee8110e10fc1617d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 23 Jul 2010 23:58:44 +0200 Subject: Displacement map filter (bzr r9508.1.30) --- src/display/cairo-templates.h | 68 +++++++++++++++++++++- src/display/nr-filter-convolve-matrix.cpp | 9 ++- src/display/nr-filter-displacement-map.cpp | 91 +++++++++++++++++++++++++++--- src/display/nr-filter-displacement-map.h | 6 +- src/display/nr-filter-specularlighting.cpp | 15 ----- src/display/nr-filter-specularlighting.h | 5 +- 6 files changed, 161 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 9c2a8c782..8855c65fc 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "display/nr-3dutils.h" /** @@ -356,7 +357,7 @@ struct SurfaceSynth { { cairo_surface_flush(surface); } -protected: + guint32 pixelAt(int x, int y) { if (_alpha) { unsigned char *px = _px + y*_stride + x; @@ -376,9 +377,74 @@ protected: return (p & 0xff000000) >> 24; } } + + // retrieve a pixel value with bilinear interpolation + guint32 pixelAt(double x, double y) { + if (_alpha) { + return alphaAt(x, y) << 24; + } + + double xf = floor(x), yf = floor(y); + int xi = xf, yi = yf; + guint32 xif = round((x - xf) * 255), yif = round((y - yf) * 255); + guint32 p00, p01, p10, p11; + + unsigned char *pxi = _px + yi*_stride + xi*4; + guint32 *pxu = reinterpret_cast(pxi); + guint32 *pxl = reinterpret_cast(pxi + _stride); + p00 = *pxu; p10 = *(pxu + 1); + p01 = *pxl; p11 = *(pxl + 1); + + guint32 comp[4]; + + for (unsigned i = 0; i < 4; ++i) { + guint32 shift = i*8; + guint32 mask = 0xff << shift; + guint32 c00 = (p00 & mask) >> shift; + guint32 c10 = (p10 & mask) >> shift; + guint32 c01 = (p01 & mask) >> shift; + guint32 c11 = (p11 & mask) >> shift; + + guint32 iu = (255-xif) * c00 + xif * c10; + guint32 il = (255-xif) * c01 + xif * c11; + comp[i] = (255-yif) * iu + yif * il; + comp[i] = (comp[i] + (255*255/2)) / (255*255); + } + + guint32 result = comp[0] | (comp[1] << 8) | (comp[2] << 16) | (comp[3] << 24); + return result; + } + + // retrieve an alpha value with bilinear interpolation + guint32 alphaAt(double x, double y) { + double xf = floor(x), yf = floor(y); + int xi = xf, yi = yf; + guint32 xif = round((x - xf) * 255), yif = round((y - yf) * 255); + guint32 p00, p01, p10, p11; + if (_alpha) { + unsigned char *pxu = _px + yi*_stride + xi; + unsigned char *pxl = pxu + _stride; + p00 = *pxu; p10 = *(pxu + 1); + p01 = *pxl; p11 = *(pxl + 1); + } else { + unsigned char *pxi = _px + yi*_stride + xi*4; + guint32 *pxu = reinterpret_cast(pxi); + guint32 *pxl = reinterpret_cast(pxi + _stride); + p00 = (*pxu & 0xff000000) >> 24; p10 = (*(pxu + 1) & 0xff000000) >> 24; + p01 = (*pxl & 0xff000000) >> 24; p11 = (*(pxl + 1) & 0xff000000) >> 24; + } + guint32 iu = (255-xif) * p00 + xif * p10; + guint32 il = (255-xif) * p01 + xif * p11; + guint32 result = (255-yif) * iu + yif * il; + result = (result + (255*255/2)) / (255*255); + return result; + } + + // compute surface normal at given coordinates using 3x3 Sobel gradient filter NR::Fvector surfaceNormalAt(int x, int y, double scale) { // Below there are some multiplies by zero. They will be optimized out. // Do not remove them, because they improve readability. + // NOTE: fetching using alphaAt is slightly lazy. NR::Fvector normal; double fx = -scale/255.0, fy = -scale/255.0; normal[Z_3D] = 1.0; diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index fcb15ee98..6647c6273 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -191,6 +191,9 @@ private: void FilterConvolveMatrix::render_cairo(FilterSlot &slot) { + static bool bias_warning = false; + static bool edge_warning = false; + cairo_surface_t *input = slot.getcairo(_input); if (orderX<=0 || orderY<=0) { @@ -208,9 +211,10 @@ void FilterConvolveMatrix::render_cairo(FilterSlot &slot) cairo_surface_t *out = ink_cairo_surface_create_identical(input); - if (bias!=0) { + if (bias!=0 && !bias_warning) { g_warning("It is unknown whether Inkscape's implementation of bias in feConvolveMatrix " "is correct!"); + bias_warning = true; // The SVG specification implies that feConvolveMatrix is defined for premultiplied // colors (which makes sense). It also says that bias should simply be added to the result // for each color (without taking the alpha into account). However, it also says that one @@ -219,8 +223,9 @@ void FilterConvolveMatrix::render_cairo(FilterSlot &slot) // but this does appear to go against the standard. // Note that Batik simply does not support bias!=0 } - if (edgeMode!=CONVOLVEMATRIX_EDGEMODE_NONE) { + if (edgeMode!=CONVOLVEMATRIX_EDGEMODE_NONE && !edge_warning) { g_warning("Inkscape only supports edgeMode=\"none\" (and a filter uses a different one)!"); + edge_warning = true; } guint32 *in_data = reinterpret_cast(cairo_image_surface_get_data(input)); diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index a983fb840..15d590444 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -9,11 +9,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-filter-displacement-map.h" #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixops.h" namespace Inkscape { namespace Filters { @@ -28,6 +28,7 @@ FilterPrimitive * FilterDisplacementMap::create() { FilterDisplacementMap::~FilterDisplacementMap() {} +#if 0 struct pixel_t { unsigned char channels[4]; inline unsigned char operator[](int c) const { return channels[c]; } @@ -147,7 +148,65 @@ static void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map } } } +#endif + +struct Displace { + Displace(cairo_surface_t *texture, cairo_surface_t *map, + unsigned xch, unsigned ych, double scalex, double scaley) + : _texture(texture) + , _map(map) + , _xch(xch) + , _ych(ych) + , _scalex(scalex/255.0) + , _scaley(scaley/255.0) + {} + guint32 operator()(int x, int y) { + guint32 mappx = _map.pixelAt(x, y); + guint32 a = (mappx & 0xff000000) >> 24; + guint32 xpx = 0, ypx = 0; + double xtex = x, ytex = y; + if (a) { + guint32 xshift = _xch * 8, yshift = _ych * 8; + xpx = (mappx & (0xff << xshift)) >> xshift; + ypx = (mappx & (0xff << yshift)) >> yshift; + if (_xch != 3) xpx = unpremul_alpha(xpx, a); + if (_ych != 3) ypx = unpremul_alpha(ypx, a); + xtex += _scalex * (xpx - 127.5); + ytex += _scaley * (ypx - 127.5); + } + + if (xtex >= 0 && xtex < (_texture._w - 1) && + ytex >= 0 && ytex < (_texture._h - 1)) + { + return _texture.pixelAt(xtex, ytex); + } else { + return 0; + } + } +private: + SurfaceSynth _texture; + SurfaceSynth _map; + unsigned _xch, _ych; + double _scalex, _scaley; +}; + +void FilterDisplacementMap::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *texture = slot.getcairo(_input); + cairo_surface_t *map = slot.getcairo(_input2); + cairo_surface_t *out = ink_cairo_surface_create_identical(texture); + + Geom::Matrix trans = slot.get_units().get_matrix_primitiveunits2pb(); + double scalex = scale * trans.expansionX(); + double scaley = scale * trans.expansionY(); + + ink_cairo_surface_synthesize(out, Displace(texture, map, Xchannel, Ychannel, scalex, scaley)); + + slot.set(_output, out); + cairo_surface_destroy(out); +} +/* int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *texture = slot.get(_input); NRPixBlock *map = slot.get(_input2); @@ -212,7 +271,7 @@ int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) { out->empty = FALSE; slot.set(_output, out); return 0; -} +}*/ void FilterDisplacementMap::set_input(int slot) { _input = slot; @@ -233,8 +292,26 @@ void FilterDisplacementMap::set_channel_selector(int s, FilterDisplacementMapCha return; } - if (s == 0) Xchannel = channel; - if (s == 1) Ychannel = channel; + // channel numbering: + // a = 3, r = 2, g = 1, b = 0 + // this way we can get the component value using: + // component = (color & (ch*8)) >> (ch*8) + unsigned ch = 4; + switch (channel) { + case DISPLACEMENTMAP_CHANNEL_ALPHA: + ch = 3; break; + case DISPLACEMENTMAP_CHANNEL_RED: + ch = 2; break; + case DISPLACEMENTMAP_CHANNEL_GREEN: + ch = 1; break; + case DISPLACEMENTMAP_CHANNEL_BLUE: + ch = 0; break; + default: break; + } + if (ch == 4) return; + + if (s == 0) Xchannel = ch; + if (s == 1) Ychannel = ch; } void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Matrix const &trans) @@ -252,10 +329,6 @@ void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Matrix const &tran area.y1 += (int)(scaley)+2; } -FilterTraits FilterDisplacementMap::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index bb15b77a3..29f38d604 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -31,15 +31,13 @@ public: virtual void set_input(int input, int slot); virtual void set_scale(double s); virtual void set_channel_selector(int s, FilterDisplacementMapChannelSelector channel); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); - virtual FilterTraits get_input_traits(); private: double scale; int _input2; - FilterDisplacementMapChannelSelector Xchannel; - FilterDisplacementMapChannelSelector Ychannel; + unsigned Xchannel, Ychannel; }; } /* namespace Filters */ diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 23b9b20ac..758b28979 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -17,7 +17,6 @@ #include "display/cairo-utils.h" #include "display/nr-3dutils.h" #include "display/nr-filter-specularlighting.h" -#include "display/nr-filter-getalpha.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" @@ -43,20 +42,6 @@ FilterPrimitive * FilterSpecularLighting::create() { FilterSpecularLighting::~FilterSpecularLighting() {} -//Investigating Phong Lighting model we should not take N.H but -//R.E which equals to 2*N.H^2 - 1 -//replace the second line by -//gdouble scal = scalar_product((N), (H)); scal = 2 * scal * scal - 1; -//to get the expected formula -#define COMPUTE_INTER(inter, H, N, ks, speculaExponent) \ -do {\ - gdouble scal = NR::scalar_product((N), (H)); \ - if (scal <= 0)\ - (inter) = 0;\ - else\ - (inter) = (ks) * std::pow(scal, (specularExponent));\ -}while(0) - struct SpecularLight : public SurfaceSynth { SpecularLight(cairo_surface_t *bumpmap, double scale, double specular_constant, double specular_exponent) diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index a350c4b29..6622b6add 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -16,7 +16,6 @@ #include #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" class SPFeDistantLight; class SPFePointLight; @@ -24,7 +23,9 @@ class SPFeSpotLight; namespace Inkscape { namespace Filters { - + +class FilterSlot; + class FilterSpecularLighting : public FilterPrimitive { public: FilterSpecularLighting(); -- cgit v1.2.3 From 703a0cb1d2ce00692c10f33a095a3b99c1e28554 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 24 Jul 2010 00:00:31 +0200 Subject: Remove nr-filter-getalpha.(h|cpp) - no longer needed (bzr r9508.1.31) --- src/display/Makefile_insert | 2 -- src/display/nr-filter-getalpha.cpp | 56 -------------------------------------- src/display/nr-filter-getalpha.h | 35 ------------------------ 3 files changed, 93 deletions(-) delete mode 100644 src/display/nr-filter-getalpha.cpp delete mode 100644 src/display/nr-filter-getalpha.h (limited to 'src') diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 621dc43d5..3e8b6ff91 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -62,8 +62,6 @@ ink_common_sources += \ display/nr-filter-flood.h \ display/nr-filter-gaussian.cpp \ display/nr-filter-gaussian.h \ - display/nr-filter-getalpha.cpp \ - display/nr-filter-getalpha.h \ display/nr-filter.h \ display/nr-filter-image.cpp \ display/nr-filter-image.h \ diff --git a/src/display/nr-filter-getalpha.cpp b/src/display/nr-filter-getalpha.cpp deleted file mode 100644 index 0b71e28c8..000000000 --- a/src/display/nr-filter-getalpha.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Functions for extracting alpha channel from NRPixBlocks. - * - * Author: - * Niko Kiirala - * - * Copyright (C) 2007 Niko Kiirala - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/nr-filter-getalpha.h" -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" - -namespace Inkscape { -namespace Filters { - -NRPixBlock *filter_get_alpha(NRPixBlock *src) -{ - NRPixBlock *dst = new NRPixBlock; - nr_pixblock_setup_fast(dst, NR_PIXBLOCK_MODE_R8G8B8A8P, - src->area.x0, src->area.y0, - src->area.x1, src->area.y1, false); - if (!dst || (dst->size != NR_PIXBLOCK_SIZE_TINY && dst->data.px == NULL)) { - g_warning("Memory allocation failed in filter_get_alpha"); - delete dst; - return NULL; - } - nr_blit_pixblock_pixblock(dst, src); - - unsigned char *data = NR_PIXBLOCK_PX(dst); - int end = dst->rs * (dst->area.y1 - dst->area.y0); - for (int i = 0 ; i < end ; i += 4) { - data[i + 0] = 0; - data[i + 1] = 0; - data[i + 2] = 0; - } - dst->empty = false; - - return dst; -} - -} /* namespace Filters */ -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-getalpha.h b/src/display/nr-filter-getalpha.h deleted file mode 100644 index fca645776..000000000 --- a/src/display/nr-filter-getalpha.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __NR_FILTER_GETALPHA_H__ -#define __NR_FILTER_GETALPHA_H__ - -/* - * Functions for extracting alpha channel from NRPixBlocks. - * - * Author: - * Niko Kiirala - * - * Copyright (C) 2007 Niko Kiirala - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "libnr/nr-pixblock.h" - -namespace Inkscape { -namespace Filters { - -NRPixBlock *filter_get_alpha(NRPixBlock *src); - -} /* namespace Filters */ -} /* namespace Inkscape */ - -#endif /* __NR_FILTER_GETALPHA_H__ */ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 3ea719985f6e9ab017dddb658251c34b40316828 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 24 Jul 2010 01:03:55 +0200 Subject: Morphology filter (bzr r9508.1.32) --- src/display/nr-filter-morphology.cpp | 139 +++++++++++++++++++++++++++++++++-- src/display/nr-filter-morphology.h | 7 +- 2 files changed, 136 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index 258298751..51433da14 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -10,9 +10,12 @@ */ #include +#include +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-filter-morphology.h" +#include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-blit.h" namespace Inkscape { namespace Filters { @@ -28,6 +31,134 @@ FilterPrimitive * FilterMorphology::create() { FilterMorphology::~FilterMorphology() {} +struct MorphologyErode : public SurfaceSynth { + MorphologyErode(cairo_surface_t *in, double xradius, double yradius) + : SurfaceSynth(in) + , _xr(round(xradius)) + , _yr(round(yradius)) + {} + guint32 operator()(int x, int y) { + int startx = std::max(x - _xr, 0), endx = std::min(x + _xr + 1, _w); + int starty = std::max(y - _yr, 0), endy = std::min(y + _yr + 1, _h); + + guint32 ao = 255; + guint32 ro = 255; + guint32 go = 255; + guint32 bo = 255; + + if (_alpha) { + ao = 0xff000000; + for (int i = starty; i < endy; ++i) { + for (int j = startx; j < endx; ++j) { + guint32 px = pixelAt(j, i); + ao = std::min(ao, px & 0xff000000); + } + } + return ao; + } else { + for (int i = starty; i < endy; ++i) { + for (int j = startx; j < endx; ++j) { + guint32 px = pixelAt(j, i); + EXTRACT_ARGB32(px, a,r,g,b); + if (a) { + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); + ao = std::min(ao, a); + ro = std::min(ro, r); + go = std::min(go, g); + bo = std::min(bo, b); + } else { + // zero pixel is guaranteed to be the minimum + ao = 0; ro = 0; go = 0; bo = 0; + goto end_loop; + } + } + } + end_loop: + + ro = premul_alpha(ro, ao); + go = premul_alpha(go, ao); + bo = premul_alpha(bo, ao); + ASSEMBLE_ARGB32(pxout, ao,ro,go,bo) + return pxout; + } + } +private: + int _xr, _yr; +}; + +struct MorphologyDilate : public SurfaceSynth { + MorphologyDilate(cairo_surface_t *in, double xradius, double yradius) + : SurfaceSynth(in) + , _xr(round(xradius)) + , _yr(round(yradius)) + {} + guint32 operator()(int x, int y) { + int startx = std::max(x - _xr, 0), endx = std::min(x + _xr + 1, _w); + int starty = std::max(y - _yr, 0), endy = std::min(y + _yr + 1, _h); + + guint32 ao = 0; + guint32 ro = 0; + guint32 go = 0; + guint32 bo = 0; + + if (_alpha) { + for (int i = starty; i < endy; ++i) { + for (int j = startx; j < endx; ++j) { + guint32 px = pixelAt(j, i); + ao = std::max(ao, px & 0xff000000); + } + } + return ao; + } else { + for (int i = starty; i < endy; ++i) { + for (int j = startx; j < endx; ++j) { + guint32 px = pixelAt(j, i); + EXTRACT_ARGB32(px, a,r,g,b) + if (a == 0) continue; // this cannot affect the maximum + + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); + ao = std::max(ao, a); + ro = std::max(ro, r); + go = std::max(go, g); + bo = std::max(bo, b); + } + } + + ro = premul_alpha(ro, ao); + go = premul_alpha(go, ao); + bo = premul_alpha(bo, ao); + ASSEMBLE_ARGB32(pxout, ao,ro,go,bo) + return pxout; + } + } +private: + int _xr, _yr; +}; + +void FilterMorphology::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = ink_cairo_surface_create_identical(input); + + Geom::Matrix p2pb = slot.get_units().get_matrix_primitiveunits2pb(); + double xr = xradius * p2pb.expansionX(); + double yr = yradius * p2pb.expansionY(); + + if (Operator == MORPHOLOGY_OPERATOR_DILATE) { + ink_cairo_surface_synthesize(out, MorphologyDilate(input, xr, yr)); + } else { + ink_cairo_surface_synthesize(out, MorphologyErode(input, xr, yr)); + } + + slot.set(_output, out); + cairo_surface_destroy(out); +} + +/* int FilterMorphology::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); if (!in) { @@ -110,7 +241,7 @@ int FilterMorphology::render(FilterSlot &slot, FilterUnits const &units) { out->empty = FALSE; slot.set(_output, out); return 0; -} +}*/ void FilterMorphology::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { @@ -135,10 +266,6 @@ void FilterMorphology::set_yradius(double y){ yradius = y; } -FilterTraits FilterMorphology::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index 16ccad5e6..fe729c94d 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -13,12 +13,12 @@ */ #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" namespace Inkscape { namespace Filters { +class FilterSlot; + enum FilterMorphologyOperator { MORPHOLOGY_OPERATOR_ERODE, MORPHOLOGY_OPERATOR_DILATE, @@ -31,9 +31,8 @@ public: static FilterPrimitive *create(); virtual ~FilterMorphology(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); - virtual FilterTraits get_input_traits(); void set_operator(FilterMorphologyOperator &o); void set_xradius(double x); void set_yradius(double y); -- cgit v1.2.3 From e91b9fe00d2fb1b824b6e16ba13b95b7f207a6e4 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 24 Jul 2010 01:50:03 +0200 Subject: Turbulence filter (lazy version) (bzr r9508.1.33) --- src/display/nr-filter-turbulence.cpp | 112 ++++++++++++++++++++++++++++++++--- src/display/nr-filter-turbulence.h | 31 ++-------- 2 files changed, 108 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 8d22b180d..de46b1565 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -17,7 +17,8 @@ * Released under GNU GPL version 2 (or later), read the file 'COPYING' for more information */ -#include "display/nr-arena-item.h" +#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-filter.h" #include "display/nr-filter-turbulence.h" #include "display/nr-filter-units.h" @@ -29,6 +30,33 @@ namespace Inkscape { namespace Filters{ +/* Produces results in the range [1, 2**31 - 2]. +Algorithm is: r = (a * r) mod m +where a = 16807 and m = 2**31 - 1 = 2147483647 +See [Park & Miller], CACM vol. 31 no. 10 p. 1195, Oct. 1988 +To test: the algorithm should produce the result 1043618065 +as the 10,000th generated number if the original seed is 1. +*/ +#define RAND_m 2147483647 /* 2**31 - 1 */ +#define RAND_a 16807 /* 7**5; primitive root of m */ +#define RAND_q 127773 /* m / a */ +#define RAND_r 2836 /* m % a */ +//#define BSize 0x100 // defined in the header +#define BM 0xff +#define PerlinN 0x1000 +#define NP 12 /* 2^PerlinN */ +#define NM 0xfff +#define s_curve(t) ( t * t * (3. - 2. * t) ) +#define turb_lerp(t, a, b) ( a + t * (b - a) ) + +struct StitchInfo +{ + int nWidth; // How much to subtract to wrap for stitching. + int nHeight; + int nWrapX; // Minimum value to wrap. + int nWrapY; +}; + FilterTurbulence::FilterTurbulence() : XbaseFrequency(0), YbaseFrequency(0), @@ -82,6 +110,7 @@ void FilterTurbulence::set_updated(bool u){ } void FilterTurbulence::render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units) { +#if 0 const int bbox_x0 = full_area.min()[NR::X]; const int bbox_y0 = full_area.min()[NR::Y]; const int bbox_x1 = full_area.max()[NR::X]; @@ -122,6 +151,7 @@ void FilterTurbulence::render_area(NRPixBlock *pix, NR::IRect &full_area, Filter } pix->empty = FALSE; +#endif } void FilterTurbulence::update_pixbuffer(NR::IRect &area, FilterUnits const &units) { @@ -162,6 +192,75 @@ void FilterTurbulence::update_pixbuffer(NR::IRect &area, FilterUnits const &unit updated_area = area; } +void FilterTurbulence::render_cairo(FilterSlot &slot) +{ + cairo_surface_t *input = slot.getcairo(_input); + cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + + if (!updated) { + TurbulenceInit((long)seed); + updated = true; + } + + // TODO: convert this to ink_cairo_surface_synthesize + Geom::Matrix unit_trans = slot.get_units().get_matrix_primitiveunits2pb().inverse(); + NRRectL const &slot_area = slot.get_slot_area(); + + int w = cairo_image_surface_get_width(out); + int h = cairo_image_surface_get_height(out); + int stride = cairo_image_surface_get_stride(out); + unsigned char *data = cairo_image_surface_get_data(out); + + if (type == TURBULENCE_TURBULENCE) { + for (int i = 0; i < h; ++i) { + guint32 *out_p = reinterpret_cast(data + i*stride); + for (int j = 0; j < w; ++j) { + Geom::Point pt(slot_area.x0 + j, slot_area.y0 + i); + pt *= unit_trans; + + guint32 r = CLAMP_D_TO_U8(turbulence(0, pt)*255); + guint32 g = CLAMP_D_TO_U8(turbulence(1, pt)*255); + guint32 b = CLAMP_D_TO_U8(turbulence(2, pt)*255); + guint32 a = CLAMP_D_TO_U8(turbulence(3, pt)*255); + + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + + ASSEMBLE_ARGB32(result, a,r,g,b) + *out_p++ = result; + } + } + } else { + // TURBULENCE_FRACTALNOISE + for (int i = 0; i < h; ++i) { + guint32 *out_p = reinterpret_cast(data + i*stride); + for (int j = 0; j < w; ++j) { + Geom::Point pt(slot_area.x0 + j, slot_area.y0 + i); + pt *= unit_trans; + + guint32 r = CLAMP_D_TO_U8((turbulence(0, pt)*255 + 255)/2); + guint32 g = CLAMP_D_TO_U8((turbulence(1, pt)*255 + 255)/2); + guint32 b = CLAMP_D_TO_U8((turbulence(2, pt)*255 + 255)/2); + guint32 a = CLAMP_D_TO_U8((turbulence(3, pt)*255 + 255)/2); + + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + + ASSEMBLE_ARGB32(result, a,r,g,b) + *out_p++ = result; + } + } + } + + cairo_surface_mark_dirty(out); + + slot.set(_output, out); + cairo_surface_destroy(out); +} + +#if 0 int FilterTurbulence::render(FilterSlot &slot, FilterUnits const &units) { NR::IRect area = units.get_pixblock_filterarea_paraller(); // TODO: could be faster - updated_area only has to be same size as area @@ -190,6 +289,7 @@ int FilterTurbulence::render(FilterSlot &slot, FilterUnits const &units) { slot.set(_output, out); return 0; } +#endif long FilterTurbulence::Turbulence_setup_seed(long lSeed) { @@ -286,7 +386,7 @@ double FilterTurbulence::TurbulenceNoise2(int nColorChannel, double vec[2], Stit return turb_lerp(sy, a, b); } -double FilterTurbulence::turbulence(int nColorChannel, double *point) +double FilterTurbulence::turbulence(int nColorChannel, Geom::Point const &point) { StitchInfo stitch; StitchInfo *pStitchInfo = NULL; // Not stitching when NULL. @@ -322,8 +422,8 @@ double FilterTurbulence::turbulence(int nColorChannel, double *point) } double fSum = 0.0f; double vec[2]; - vec[0] = point[0] * XbaseFrequency; - vec[1] = point[1] * YbaseFrequency; + vec[0] = point[Geom::X] * XbaseFrequency; + vec[1] = point[Geom::Y] * YbaseFrequency; double ratio = 1; for(int nOctave = 0; nOctave < numOctaves; nOctave++) { @@ -347,10 +447,6 @@ double FilterTurbulence::turbulence(int nColorChannel, double *point) return fSum; } -FilterTraits FilterTurbulence::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index b841cc37f..53ea5dd39 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -21,6 +21,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/point.h> #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" @@ -35,32 +36,9 @@ enum FilterTurbulenceType { TURBULENCE_ENDTYPE }; -struct StitchInfo -{ - int nWidth; // How much to subtract to wrap for stitching. - int nHeight; - int nWrapX; // Minimum value to wrap. - int nWrapY; -}; +struct StitchInfo; -/* Produces results in the range [1, 2**31 - 2]. -Algorithm is: r = (a * r) mod m -where a = 16807 and m = 2**31 - 1 = 2147483647 -See [Park & Miller], CACM vol. 31 no. 10 p. 1195, Oct. 1988 -To test: the algorithm should produce the result 1043618065 -as the 10,000th generated number if the original seed is 1. -*/ -#define RAND_m 2147483647 /* 2**31 - 1 */ -#define RAND_a 16807 /* 7**5; primitive root of m */ -#define RAND_q 127773 /* m / a */ -#define RAND_r 2836 /* m % a */ #define BSize 0x100 -#define BM 0xff -#define PerlinN 0x1000 -#define NP 12 /* 2^PerlinN */ -#define NM 0xfff -#define s_curve(t) ( t * t * (3. - 2. * t) ) -#define turb_lerp(t, a, b) ( a + t * (b - a) ) class FilterTurbulence : public FilterPrimitive { public: @@ -68,7 +46,7 @@ public: static FilterPrimitive *create(); virtual ~FilterTurbulence(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); void update_pixbuffer(NR::IRect &area, FilterUnits const &units); void render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units); @@ -78,14 +56,13 @@ public: void set_stitchTiles(bool st); void set_type(FilterTurbulenceType t); void set_updated(bool u); - virtual FilterTraits get_input_traits(); private: long Turbulence_setup_seed(long lSeed); long TurbulenceRandom(long lSeed); void TurbulenceInit(long lSeed); double TurbulenceNoise2(int nColorChannel, double vec[2], StitchInfo *pStitchInfo); - double turbulence(int nColorChannel, double *point); + double turbulence(int nColorChannel, Geom::Point const &point); double XbaseFrequency, YbaseFrequency; int numOctaves; -- cgit v1.2.3 From 262043cadcd2ef387623ad72ec4bf4268d0fc74d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 25 Jul 2010 01:50:24 +0200 Subject: Minor cleanups (bzr r9508.1.34) --- src/display/cairo-templates.h | 2 +- src/display/nr-filter-image.cpp | 62 ++++++++++++++++++++++++++++++++++++++++- src/display/nr-filter-slot.cpp | 10 +++++++ src/display/nr-filter-tile.cpp | 36 +++++++----------------- src/display/nr-filter-tile.h | 8 ++---- 5 files changed, 85 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 8855c65fc..e0b1bfd98 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -16,7 +16,7 @@ #include #include "preferences.h" // single-threaded operation if the number of pixels is below this threshold -#define OPENMP_THRESHOLD 4096 +#define OPENMP_THRESHOLD 2048 #endif #include diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 4ad6982f3..5dec64dc7 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -36,9 +36,69 @@ FilterPrimitive * FilterImage::create() { FilterImage::~FilterImage() { - if (feImageHref) g_free(feImageHref); + if (feImageHref) + g_free(feImageHref); } +/* +void FilterImage::render_cairo(FilterSlot &slot) +{ + if (!feImageHref) + return; + + cairo_surface_t *input = slot.getcairo(_input); + + if (from_element) { + if (!SVGElem) return; + + // prep the document + // TODO: do not recreate the rendering tree every time + sp_document_ensure_up_to_date(document); + NRArena* arena = NRArena::create(); + unsigned const key = sp_item_display_key_new(1); + NRArenaItem* ai = sp_item_invoke_show(SVGElem, arena, key, SP_ITEM_SHOW_DISPLAY); + if (!ai) { + g_warning("feImage renderer: error creating NRArenaItem for SVG Element"); + nr_object_unref((NRObject *) arena); + return; + } + + Geom::OptRect optarea = SVGElem->getBounds(Geom::identity()); + if (!optarea) return; + + Geom::Rect area = *optarea; + Geom::Matrix itrans = slot.get_units().get_matrix_display2pb(); + + NRRectL const &slot_area = slot.get_units().get_slot_area(); + NRRectL rect; + rect.x0 = floor(area->left()); + rect.x1 = ceil(area->right()); + rect.y0 = floor(area->top()); + rect.y1 = ceil(area->bottom()); + + cairo_surface_t *out = ink_cairo_surface_create_same_size(in, CAIRO_CONTENT_COLOR_ALPHA); + cairo_t *ct = cairo_create(out); + cairo_translate(ct, -slot_area.x0, -slot_area.y0); + ink_cairo_transform(ct, itrans); + cairo_translate(ct, rect.x0, rect.y0); + + // Update to renderable state + NRGC gc(NULL); + Geom::Matrix t = Geom::identity(); + nr_arena_item_set_transform(ai, &t); + gc.transform.setIdentity(); + nr_arena_item_invoke_update( ai, NULL, &gc, + NR_ARENA_ITEM_STATE_ALL, + NR_ARENA_ITEM_STATE_NONE ); + + nr_arena_item_invoke_render(ct, ai, &rect, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE); + + slot.set(_output, out); + cairo_surface_destroy(out); + return; + } +}*/ + int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { if (!feImageHref) return 0; diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 5371499e4..935751871 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -173,6 +173,11 @@ cairo_surface_t *FilterSlot::_get_transformed_source_graphic() { Geom::Matrix trans = _units.get_matrix_display2pb(); + if (trans.isIdentity()) { + cairo_surface_reference(_source_graphic); + return _source_graphic; + } + cairo_surface_t *tsg = cairo_surface_create_similar( _source_graphic, cairo_surface_get_content(_source_graphic), _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); @@ -213,6 +218,11 @@ cairo_surface_t *FilterSlot::_get_transformed_background() cairo_surface_t *FilterSlot::get_result(int res) { Geom::Matrix trans = _units.get_matrix_pb2display(); + if (trans.isIdentity()) { + cairo_surface_t *result = getcairo(res); + cairo_surface_reference(result); + return result; + } cairo_surface_t *r = cairo_surface_create_similar(_source_graphic, cairo_surface_get_content(_source_graphic), diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 898db9f53..60f39e3cd 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -10,6 +10,7 @@ */ #include "display/nr-filter-tile.h" +#include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" namespace Inkscape { @@ -17,7 +18,6 @@ namespace Filters { FilterTile::FilterTile() { - g_warning("FilterTile::render not implemented."); } FilterPrimitive * FilterTile::create() { @@ -27,40 +27,24 @@ FilterPrimitive * FilterTile::create() { FilterTile::~FilterTile() {} -int FilterTile::render(FilterSlot &slot, FilterUnits const &/*units*/) { - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feTile (in=%d)", _input); - return 1; - } - - NRPixBlock *out = new NRPixBlock; - - nr_pixblock_setup_fast(out, in->mode, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - - unsigned char *in_data = NR_PIXBLOCK_PX(in); - unsigned char *out_data = NR_PIXBLOCK_PX(out); +void FilterTile::render_cairo(FilterSlot &slot) +{ + static bool tile_warning = false; //IMPLEMENT ME! - g_warning("Renderer for feTile is not implemented."); - (void)in_data; - (void)out_data; + if (!tile_warning) { + g_warning("Renderer for feTile is not implemented."); + tile_warning = true; + } - out->empty = FALSE; - slot.set(_output, out); - return 0; + cairo_surface_t *in = slot.getcairo(_input); + slot.set(_output, in); } void FilterTile::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/) { } -FilterTraits FilterTile::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index 5a6a5a78c..faf40ec63 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -13,22 +13,20 @@ */ #include "display/nr-filter-primitive.h" -#include "display/nr-filter-slot.h" -#include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { +class FilterSlot; + class FilterTile : public FilterPrimitive { public: FilterTile(); static FilterPrimitive *create(); virtual ~FilterTile(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans); - virtual FilterTraits get_input_traits(); }; } /* namespace Filters */ -- cgit v1.2.3 From 0e1ae7c0cb32c76e6349249299cb794a8800d0c8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 25 Jul 2010 05:57:02 +0200 Subject: Improve turbulence renderer (bzr r9508.1.35) --- src/display/cairo-templates.h | 4 +- src/display/nr-filter-turbulence.cpp | 588 ++++++++++++++++++----------------- src/display/nr-filter-turbulence.h | 14 +- 3 files changed, 322 insertions(+), 284 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index e0b1bfd98..88f3bf41a 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -644,9 +644,11 @@ private: };*/ // Some helpers for pixel manipulation - G_GNUC_CONST inline gint32 pxclamp(gint32 v, gint32 low, gint32 high) { + // NOTE: it is possible to write a "branchless" clamping operation. + // However, it will be slower than this function, because the code below + // is compiled to conditional moves. if (v < low) return low; if (v > high) return high; return v; diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index de46b1565..d60c4f617 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -30,45 +30,282 @@ namespace Inkscape { namespace Filters{ -/* Produces results in the range [1, 2**31 - 2]. -Algorithm is: r = (a * r) mod m -where a = 16807 and m = 2**31 - 1 = 2147483647 -See [Park & Miller], CACM vol. 31 no. 10 p. 1195, Oct. 1988 -To test: the algorithm should produce the result 1043618065 -as the 10,000th generated number if the original seed is 1. -*/ -#define RAND_m 2147483647 /* 2**31 - 1 */ -#define RAND_a 16807 /* 7**5; primitive root of m */ -#define RAND_q 127773 /* m / a */ -#define RAND_r 2836 /* m % a */ -//#define BSize 0x100 // defined in the header -#define BM 0xff -#define PerlinN 0x1000 -#define NP 12 /* 2^PerlinN */ -#define NM 0xfff -#define s_curve(t) ( t * t * (3. - 2. * t) ) -#define turb_lerp(t, a, b) ( a + t * (b - a) ) - -struct StitchInfo -{ - int nWidth; // How much to subtract to wrap for stitching. - int nHeight; - int nWrapX; // Minimum value to wrap. - int nWrapY; +class TurbulenceGenerator { +public: + TurbulenceGenerator() + : _wrapx(0) + , _wrapy(0) + , _wrapw(0) + , _wraph(0) + , _inited(false) + {} + + void init(long seed, Geom::Rect const &tile, Geom::Point const &freq, bool stitch, + bool fractalnoise, int octaves) + { + // setup random number generator + _setupSeed(seed); + + // set values + _tile = tile; + _baseFreq = freq; + _stitchTiles = stitch; + _fractalnoise = fractalnoise; + _octaves = octaves; + + int i; + for (int k = 0; k < 4; ++k) { + for (i = 0; i < BSize; ++i) { + _latticeSelector[i] = i; + + _gradient[i][k][0] = static_cast(_random() % (BSize*2) - BSize) / BSize; + _gradient[i][k][1] = static_cast(_random() % (BSize*2) - BSize) / BSize; + + // normalize gradient + double s = hypot(_gradient[i][k][0], _gradient[i][k][1]); + _gradient[i][k][0] /= s; + _gradient[i][k][1] /= s; + } + } + while (--i) { + // shuffle lattice selectors + int j = _random() % BSize; + std::swap(_latticeSelector[i], _latticeSelector[j]); + } + + // fill out the remaining part of the gradient + for (i = 0; i < BSize + 2; ++i) + { + _latticeSelector[BSize + i] = _latticeSelector[i]; + + for(int k = 0; k < 4; ++k) { + _gradient[BSize + i][k][0] = _gradient[i][k][0]; + _gradient[BSize + i][k][1] = _gradient[i][k][1]; + } + } + + // When stitching tiled turbulence, the frequencies must be adjusted + // so that the tile borders will be continuous. + if (_stitchTiles) { + if (_baseFreq[Geom::X] != 0.0) + { + double freq = _baseFreq[Geom::X]; + double lo = floor(_tile.width() * freq) / _tile.width(); + double hi = ceil(_tile.width() * freq) / _tile.width(); + _baseFreq[Geom::X] = freq / lo < hi / freq ? lo : hi; + } + if (_baseFreq[Geom::Y] != 0.0) + { + double freq = _baseFreq[Geom::Y]; + double lo = floor(_tile.height() * freq) / _tile.height(); + double hi = ceil(_tile.height() * freq) / _tile.height(); + _baseFreq[Geom::Y] = freq / lo < hi / freq ? lo : hi; + } + + _wrapw = _tile.width() * _baseFreq[Geom::X] + 0.5; + _wraph = _tile.height() * _baseFreq[Geom::Y] + 0.5; + _wrapx = _tile.left() * _baseFreq[Geom::X] + PerlinOffset + _wrapw; + _wrapy = _tile.top() * _baseFreq[Geom::Y] + PerlinOffset + _wraph; + } + _inited = true; + } + + G_GNUC_PURE + guint32 turbulencePixel(Geom::Point const &p) const { + int wrapx = _wrapx, wrapy = _wrapy, wrapw = _wrapw, wraph = _wraph; + + double pixel[4]; + double x = p[Geom::X] * _baseFreq[Geom::X]; + double y = p[Geom::Y] * _baseFreq[Geom::Y]; + double ratio = 1.0; + + for (int k = 0; k < 4; ++k) + pixel[k] = 0.0; + + for(int octave = 0; octave < _octaves; ++octave) + { + double tx = x + PerlinOffset; + double bx = floor(tx); + double rx0 = tx - bx, rx1 = rx0 - 1.0; + int bx0 = bx, bx1 = bx0 + 1; + + double ty = y + PerlinOffset; + double by = floor(ty); + double ry0 = ty - by, ry1 = ry0 - 1.0; + int by0 = by, by1 = by0 + 1; + + if (_stitchTiles) { + if (bx0 >= wrapx) bx0 -= wrapw; + if (bx1 >= wrapx) bx1 -= wrapw; + if (by0 >= wrapy) by0 -= wraph; + if (by1 >= wrapy) by1 -= wraph; + } + bx0 &= BMask; + bx1 &= BMask; + by0 &= BMask; + by1 &= BMask; + + int i = _latticeSelector[bx0]; + int j = _latticeSelector[bx1]; + int b00 = _latticeSelector[i + by0]; + int b01 = _latticeSelector[i + by1]; + int b10 = _latticeSelector[j + by0]; + int b11 = _latticeSelector[j + by1]; + + double sx = _scurve(rx0); + double sy = _scurve(ry0); + + double result[4]; + // channel numbering: R=0, G=1, B=2, A=3 + for (int k = 0; k < 4; ++k) { + double const *qxa = _gradient[b00][k]; + double const *qxb = _gradient[b10][k]; + double a = _lerp(sx, rx0 * qxa[0] + ry0 * qxa[1], + rx1 * qxb[0] + ry0 * qxb[1]); + double const *qya = _gradient[b01][k]; + double const *qyb = _gradient[b11][k]; + double b = _lerp(sx, rx0 * qya[0] + ry1 * qya[1], + rx1 * qyb[0] + ry1 * qyb[1]); + result[k] = _lerp(sy, a, b); + } + + if (_fractalnoise) { + for (int k = 0; k < 4; ++k) + pixel[k] += result[k] / ratio; + } else { + for (int k = 0; k < 4; ++k) + pixel[k] += fabs(result[k]) / ratio; + } + + x *= 2; + y *= 2; + ratio *= 2; + + if(_stitchTiles) + { + // Update stitch values. Subtracting PerlinOffset before the multiplication and + // adding it afterward simplifies to subtracting it once. + wrapw *= 2; + wraph *= 2; + wrapx = wrapx*2 - PerlinOffset; + wrapy = wrapy*2 - PerlinOffset; + } + } + + if (_fractalnoise) { + guint32 r = CLAMP_D_TO_U8((pixel[0]*255.0 + 255.0) / 2); + guint32 g = CLAMP_D_TO_U8((pixel[1]*255.0 + 255.0) / 2); + guint32 b = CLAMP_D_TO_U8((pixel[2]*255.0 + 255.0) / 2); + guint32 a = CLAMP_D_TO_U8((pixel[3]*255.0 + 255.0) / 2); + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + ASSEMBLE_ARGB32(pxout, a,r,g,b); + return pxout; + } else { + guint32 r = CLAMP_D_TO_U8(pixel[0]*255.0); + guint32 g = CLAMP_D_TO_U8(pixel[1]*255.0); + guint32 b = CLAMP_D_TO_U8(pixel[2]*255.0); + guint32 a = CLAMP_D_TO_U8(pixel[3]*255.0); + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + ASSEMBLE_ARGB32(pxout, a,r,g,b); + return pxout; + } + } + + //G_GNUC_PURE + /*guint32 turbulencePixel(Geom::Point const &p) const { + if (!_fractalnoise) { + guint32 r = CLAMP_D_TO_U8(turbulence(0, p)*255.0); + guint32 g = CLAMP_D_TO_U8(turbulence(1, p)*255.0); + guint32 b = CLAMP_D_TO_U8(turbulence(2, p)*255.0); + guint32 a = CLAMP_D_TO_U8(turbulence(3, p)*255.0); + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + ASSEMBLE_ARGB32(pxout, a,r,g,b); + return pxout; + } else { + guint32 r = CLAMP_D_TO_U8((turbulence(0, p)*255.0 + 255.0) / 2); + guint32 g = CLAMP_D_TO_U8((turbulence(1, p)*255.0 + 255.0) / 2); + guint32 b = CLAMP_D_TO_U8((turbulence(2, p)*255.0 + 255.0) / 2); + guint32 a = CLAMP_D_TO_U8((turbulence(3, p)*255.0 + 255.0) / 2); + r = premul_alpha(r, a); + g = premul_alpha(g, a); + b = premul_alpha(b, a); + ASSEMBLE_ARGB32(pxout, a,r,g,b); + return pxout; + } + }*/ + + bool ready() const { return _inited; } + void dirty() { _inited = false; } + +private: + void _setupSeed(long seed) { + _seed = seed; + if (_seed <= 0) _seed = -(_seed % (RAND_m - 1)) + 1; + if (_seed > RAND_m - 1) _seed = RAND_m - 1; + } + long _random() { + /* Produces results in the range [1, 2**31 - 2]. + * Algorithm is: r = (a * r) mod m + * where a = 16807 and m = 2**31 - 1 = 2147483647 + * See [Park & Miller], CACM vol. 31 no. 10 p. 1195, Oct. 1988 + * To test: the algorithm should produce the result 1043618065 + * as the 10,000th generated number if the original seed is 1. */ + _seed = RAND_a * (_seed % RAND_q) - RAND_r * (_seed / RAND_q); + if (_seed <= 0) _seed += RAND_m; + return _seed; + } + static inline double _scurve(double t) { + return t * t * (3.0 - 2.0*t); + } + static inline double _lerp(double t, double a, double b) { + return a + t * (b-a); + } + + // random number generator constants + static long const + RAND_m = 2147483647, // 2**31 - 1 + RAND_a = 16807, // 7**5; primitive root of m + RAND_q = 127773, // m / a + RAND_r = 2836; // m % a + + // other constants + static int const + BSize = 0x100, + BMask = 0xff; + static double const + PerlinOffset = 4096.0; + + Geom::Rect _tile; + Geom::Point _baseFreq; + int _latticeSelector[2*BSize + 2]; + double _gradient[2*BSize + 2][4][2]; + long _seed; + int _octaves; + bool _stitchTiles; + int _wrapx, _wrapy, _wrapw, _wraph; + bool _inited; + bool _fractalnoise; }; FilterTurbulence::FilterTurbulence() -: XbaseFrequency(0), - YbaseFrequency(0), - numOctaves(1), - seed(0), - updated(false), - updated_area(NR::IPoint(), NR::IPoint()), - pix(NULL), - fTileWidth(10), //guessed - fTileHeight(10), //guessed - fTileX(1), //guessed - fTileY(1) //guessed + : gen(new TurbulenceGenerator()) + , XbaseFrequency(0) + , YbaseFrequency(0) + , numOctaves(1) + , seed(0) + , updated(false) + , updated_area(NR::IPoint(), NR::IPoint()) + , pix(NULL) + , fTileWidth(10) //guessed + , fTileHeight(10) //guessed + , fTileX(1) //guessed + , fTileY(1) //guessed { } @@ -78,6 +315,8 @@ FilterPrimitive * FilterTurbulence::create() { FilterTurbulence::~FilterTurbulence() { + delete gen; + if (pix) { nr_pixblock_release(pix); delete pix; @@ -87,26 +326,30 @@ FilterTurbulence::~FilterTurbulence() void FilterTurbulence::set_baseFrequency(int axis, double freq){ if (axis==0) XbaseFrequency=freq; if (axis==1) YbaseFrequency=freq; + gen->dirty(); } void FilterTurbulence::set_numOctaves(int num){ - numOctaves=num; + numOctaves = num; + gen->dirty(); } void FilterTurbulence::set_seed(double s){ - seed=s; + seed = s; + gen->dirty(); } void FilterTurbulence::set_stitchTiles(bool st){ - stitchTiles=st; + stitchTiles = st; + gen->dirty(); } void FilterTurbulence::set_type(FilterTurbulenceType t){ - type=t; + type = t; + gen->dirty(); } void FilterTurbulence::set_updated(bool u){ - updated=u; } void FilterTurbulence::render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units) { @@ -160,7 +403,7 @@ void FilterTurbulence::update_pixbuffer(NR::IRect &area, FilterUnits const &unit int bbox_x1 = area.max()[NR::X]; int bbox_y1 = area.max()[NR::Y]; - TurbulenceInit((long)seed); + //TurbulenceInit((long)seed); if (!pix){ pix = new NRPixBlock; @@ -192,67 +435,41 @@ void FilterTurbulence::update_pixbuffer(NR::IRect &area, FilterUnits const &unit updated_area = area; } +struct Turbulence { + Turbulence(TurbulenceGenerator const &gen, Geom::Matrix const &trans, int x0, int y0) + : _gen(gen) + , _trans(trans) + , _x0(x0), _y0(y0) + {} + guint32 operator()(int x, int y) { + Geom::Point point(x + _x0, y + _y0); + point *= _trans; + return _gen.turbulencePixel(point); + } +private: + TurbulenceGenerator const &_gen; + Geom::Matrix _trans; + int _x0, _y0; +}; + void FilterTurbulence::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); - if (!updated) { - TurbulenceInit((long)seed); - updated = true; + if (!gen->ready()) { + Geom::Point ta(fTileX, fTileY); + Geom::Point tb(fTileX + fTileWidth, fTileY + fTileHeight); + gen->init(seed, Geom::Rect(ta, tb), + Geom::Point(XbaseFrequency, YbaseFrequency), stitchTiles, + type == TURBULENCE_FRACTALNOISE, numOctaves); } // TODO: convert this to ink_cairo_surface_synthesize Geom::Matrix unit_trans = slot.get_units().get_matrix_primitiveunits2pb().inverse(); NRRectL const &slot_area = slot.get_slot_area(); - int w = cairo_image_surface_get_width(out); - int h = cairo_image_surface_get_height(out); - int stride = cairo_image_surface_get_stride(out); - unsigned char *data = cairo_image_surface_get_data(out); - - if (type == TURBULENCE_TURBULENCE) { - for (int i = 0; i < h; ++i) { - guint32 *out_p = reinterpret_cast(data + i*stride); - for (int j = 0; j < w; ++j) { - Geom::Point pt(slot_area.x0 + j, slot_area.y0 + i); - pt *= unit_trans; - - guint32 r = CLAMP_D_TO_U8(turbulence(0, pt)*255); - guint32 g = CLAMP_D_TO_U8(turbulence(1, pt)*255); - guint32 b = CLAMP_D_TO_U8(turbulence(2, pt)*255); - guint32 a = CLAMP_D_TO_U8(turbulence(3, pt)*255); - - r = premul_alpha(r, a); - g = premul_alpha(g, a); - b = premul_alpha(b, a); - - ASSEMBLE_ARGB32(result, a,r,g,b) - *out_p++ = result; - } - } - } else { - // TURBULENCE_FRACTALNOISE - for (int i = 0; i < h; ++i) { - guint32 *out_p = reinterpret_cast(data + i*stride); - for (int j = 0; j < w; ++j) { - Geom::Point pt(slot_area.x0 + j, slot_area.y0 + i); - pt *= unit_trans; - - guint32 r = CLAMP_D_TO_U8((turbulence(0, pt)*255 + 255)/2); - guint32 g = CLAMP_D_TO_U8((turbulence(1, pt)*255 + 255)/2); - guint32 b = CLAMP_D_TO_U8((turbulence(2, pt)*255 + 255)/2); - guint32 a = CLAMP_D_TO_U8((turbulence(3, pt)*255 + 255)/2); - - r = premul_alpha(r, a); - g = premul_alpha(g, a); - b = premul_alpha(b, a); - - ASSEMBLE_ARGB32(result, a,r,g,b) - *out_p++ = result; - } - } - } + ink_cairo_surface_synthesize(out, Turbulence(*gen, unit_trans, slot_area.x0, slot_area.y0)); cairo_surface_mark_dirty(out); @@ -260,193 +477,6 @@ void FilterTurbulence::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -#if 0 -int FilterTurbulence::render(FilterSlot &slot, FilterUnits const &units) { - NR::IRect area = units.get_pixblock_filterarea_paraller(); - // TODO: could be faster - updated_area only has to be same size as area - if (!updated || updated_area != area) update_pixbuffer(area, units); - - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feTurbulence (in=%d)", _input); - return 1; - } - - NRPixBlock *out = new NRPixBlock; - int x0 = in->area.x0, y0 = in->area.y0; - int x1 = in->area.x1, y1 = in->area.y1; - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, x0, y0, x1, y1, true); - - if (pix_data) { - /* If pre-rendered output of whole filter area exists, just copy it. */ - nr_blit_pixblock_pixblock(out, pix); - } else { - /* No pre-rendered output, render the required area here. */ - render_area(out, area, units); - } - - out->empty = FALSE; - slot.set(_output, out); - return 0; -} -#endif - -long FilterTurbulence::Turbulence_setup_seed(long lSeed) -{ - if (lSeed <= 0) lSeed = -(lSeed % (RAND_m - 1)) + 1; - if (lSeed > RAND_m - 1) lSeed = RAND_m - 1; - return lSeed; -} - -long FilterTurbulence::TurbulenceRandom(long lSeed) -{ - long result; - result = RAND_a * (lSeed % RAND_q) - RAND_r * (lSeed / RAND_q); - if (result <= 0) result += RAND_m; - return result; -} - -void FilterTurbulence::TurbulenceInit(long lSeed) -{ - double s; - int i, j, k; - lSeed = Turbulence_setup_seed(lSeed); - for(k = 0; k < 4; k++) - { - for(i = 0; i < BSize; i++) - { - uLatticeSelector[i] = i; - for (j = 0; j < 2; j++) - fGradient[k][i][j] = (double)(((lSeed = TurbulenceRandom(lSeed)) % (BSize + BSize)) - BSize) / BSize; - s = double(sqrt(fGradient[k][i][0] * fGradient[k][i][0] + fGradient[k][i][1] * fGradient[k][i][1])); - fGradient[k][i][0] /= s; - fGradient[k][i][1] /= s; - } - } - while(--i) - { - k = uLatticeSelector[i]; - uLatticeSelector[i] = uLatticeSelector[j = (lSeed = TurbulenceRandom(lSeed)) % BSize]; - uLatticeSelector[j] = k; - } - for(i = 0; i < BSize + 2; i++) - { - uLatticeSelector[BSize + i] = uLatticeSelector[i]; - for(k = 0; k < 4; k++) - for(j = 0; j < 2; j++) - fGradient[k][BSize + i][j] = fGradient[k][i][j]; - } -} - -double FilterTurbulence::TurbulenceNoise2(int nColorChannel, double vec[2], StitchInfo *pStitchInfo) -{ - int bx0, bx1, by0, by1, b00, b10, b01, b11; - double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v; - int i, j; - t = vec[0] + PerlinN; - bx0 = (int)t; - bx1 = bx0+1; - rx0 = t - (int)t; - rx1 = rx0 - 1.0f; - t = vec[1] + PerlinN; - by0 = (int)t; - by1 = by0+1; - ry0 = t - (int)t; - ry1 = ry0 - 1.0f; - // If stitching, adjust lattice points accordingly. - if(pStitchInfo != NULL) - { - if(bx0 >= pStitchInfo->nWrapX) - bx0 -= pStitchInfo->nWidth; - if(bx1 >= pStitchInfo->nWrapX) - bx1 -= pStitchInfo->nWidth; - if(by0 >= pStitchInfo->nWrapY) - by0 -= pStitchInfo->nHeight; - if(by1 >= pStitchInfo->nWrapY) - by1 -= pStitchInfo->nHeight; - } - bx0 &= BM; - bx1 &= BM; - by0 &= BM; - by1 &= BM; - i = uLatticeSelector[bx0]; - j = uLatticeSelector[bx1]; - b00 = uLatticeSelector[i + by0]; - b10 = uLatticeSelector[j + by0]; - b01 = uLatticeSelector[i + by1]; - b11 = uLatticeSelector[j + by1]; - sx = double(s_curve(rx0)); - sy = double(s_curve(ry0)); - q = fGradient[nColorChannel][b00]; u = rx0 * q[0] + ry0 * q[1]; - q = fGradient[nColorChannel][b10]; v = rx1 * q[0] + ry0 * q[1]; - a = turb_lerp(sx, u, v); - q = fGradient[nColorChannel][b01]; u = rx0 * q[0] + ry1 * q[1]; - q = fGradient[nColorChannel][b11]; v = rx1 * q[0] + ry1 * q[1]; - b = turb_lerp(sx, u, v); - return turb_lerp(sy, a, b); -} - -double FilterTurbulence::turbulence(int nColorChannel, Geom::Point const &point) -{ - StitchInfo stitch; - StitchInfo *pStitchInfo = NULL; // Not stitching when NULL. - // Adjust the base frequencies if necessary for stitching. - if(stitchTiles) - { - // When stitching tiled turbulence, the frequencies must be adjusted - // so that the tile borders will be continuous. - if(XbaseFrequency != 0.0) - { - double fLoFreq = double(floor(fTileWidth * XbaseFrequency)) / fTileWidth; - double fHiFreq = double(ceil(fTileWidth * XbaseFrequency)) / fTileWidth; - if(XbaseFrequency / fLoFreq < fHiFreq / XbaseFrequency) - XbaseFrequency = fLoFreq; - else - XbaseFrequency = fHiFreq; - } - if(YbaseFrequency != 0.0) - { - double fLoFreq = double(floor(fTileHeight * YbaseFrequency)) / fTileHeight; - double fHiFreq = double(ceil(fTileHeight * YbaseFrequency)) / fTileHeight; - if(YbaseFrequency / fLoFreq < fHiFreq / YbaseFrequency) - YbaseFrequency = fLoFreq; - else - YbaseFrequency = fHiFreq; - } - // Set up TurbulenceInitial stitch values. - pStitchInfo = &stitch; - stitch.nWidth = int(fTileWidth * XbaseFrequency + 0.5f); - stitch.nWrapX = int(fTileX * XbaseFrequency + PerlinN + stitch.nWidth); - stitch.nHeight = int(fTileHeight * YbaseFrequency + 0.5f); - stitch.nWrapY = int(fTileY * YbaseFrequency + PerlinN + stitch.nHeight); - } - double fSum = 0.0f; - double vec[2]; - vec[0] = point[Geom::X] * XbaseFrequency; - vec[1] = point[Geom::Y] * YbaseFrequency; - double ratio = 1; - for(int nOctave = 0; nOctave < numOctaves; nOctave++) - { - if(type==TURBULENCE_FRACTALNOISE) - fSum += double(TurbulenceNoise2(nColorChannel, vec, pStitchInfo) / ratio); - else - fSum += double(fabs(TurbulenceNoise2(nColorChannel, vec, pStitchInfo)) / ratio); - vec[0] *= 2; - vec[1] *= 2; - ratio *= 2; - if(pStitchInfo != NULL) - { - // Update stitch values. Subtracting PerlinN before the multiplication and - // adding it afterward simplifies to subtracting it once. - stitch.nWidth *= 2; - stitch.nWrapX = 2 * stitch.nWrapX - PerlinN; - stitch.nHeight *= 2; - stitch.nWrapY = 2 * stitch.nWrapY - PerlinN; - } - } - return fSum; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 53ea5dd39..b2bc3a185 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -38,7 +38,8 @@ enum FilterTurbulenceType { struct StitchInfo; -#define BSize 0x100 +//#define BSize 0x100 +class TurbulenceGenerator; class FilterTurbulence : public FilterPrimitive { public: @@ -58,12 +59,16 @@ public: void set_updated(bool u); private: + TurbulenceGenerator *gen; + + void turbulenceInit(long seed); +/* long Turbulence_setup_seed(long lSeed); long TurbulenceRandom(long lSeed); void TurbulenceInit(long lSeed); double TurbulenceNoise2(int nColorChannel, double vec[2], StitchInfo *pStitchInfo); double turbulence(int nColorChannel, Geom::Point const &point); - +*/ double XbaseFrequency, YbaseFrequency; int numOctaves; double seed; @@ -74,14 +79,15 @@ private: NRPixBlock *pix; unsigned char *pix_data; - int uLatticeSelector[BSize + BSize + 2]; - double fGradient[4][BSize + BSize + 2][2]; + //int uLatticeSelector[BSize + BSize + 2]; + //double fGradient[4][BSize + BSize + 2][2]; double fTileWidth; double fTileHeight; double fTileX; double fTileY; + }; } /* namespace Filters */ -- cgit v1.2.3 From 0bbec01020cbd44d08f955878c053815bc001423 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 27 Jul 2010 00:17:40 +0200 Subject: Separate morphology filter into X and Y processing phases. Gives a massive performance boost for large radii. (bzr r9508.1.36) --- src/display/cairo-templates.h | 10 +- src/display/nr-filter-morphology.cpp | 231 ++++++++++------------------------- 2 files changed, 70 insertions(+), 171 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 88f3bf41a..900ca2d54 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -358,7 +358,7 @@ struct SurfaceSynth { cairo_surface_flush(surface); } - guint32 pixelAt(int x, int y) { + guint32 pixelAt(int x, int y) const { if (_alpha) { unsigned char *px = _px + y*_stride + x; return *px << 24; @@ -367,7 +367,7 @@ struct SurfaceSynth { return *reinterpret_cast(px); } } - guint32 alphaAt(int x, int y) { + guint32 alphaAt(int x, int y) const { if (_alpha) { unsigned char *px = _px + y*_stride + x; return *px; @@ -379,7 +379,7 @@ struct SurfaceSynth { } // retrieve a pixel value with bilinear interpolation - guint32 pixelAt(double x, double y) { + guint32 pixelAt(double x, double y) const { if (_alpha) { return alphaAt(x, y) << 24; } @@ -416,7 +416,7 @@ struct SurfaceSynth { } // retrieve an alpha value with bilinear interpolation - guint32 alphaAt(double x, double y) { + guint32 alphaAt(double x, double y) const { double xf = floor(x), yf = floor(y); int xi = xf, yi = yf; guint32 xif = round((x - xf) * 255), yif = round((y - yf) * 255); @@ -441,7 +441,7 @@ struct SurfaceSynth { } // compute surface normal at given coordinates using 3x3 Sobel gradient filter - NR::Fvector surfaceNormalAt(int x, int y, double scale) { + NR::Fvector surfaceNormalAt(int x, int y, double scale) const { // Below there are some multiplies by zero. They will be optimized out. // Do not remove them, because they improve readability. // NOTE: fetching using alphaAt is slightly lazy. diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index 51433da14..5be2c8b29 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -31,100 +31,71 @@ FilterPrimitive * FilterMorphology::create() { FilterMorphology::~FilterMorphology() {} -struct MorphologyErode : public SurfaceSynth { - MorphologyErode(cairo_surface_t *in, double xradius, double yradius) - : SurfaceSynth(in) - , _xr(round(xradius)) - , _yr(round(yradius)) - {} - guint32 operator()(int x, int y) { - int startx = std::max(x - _xr, 0), endx = std::min(x + _xr + 1, _w); - int starty = std::max(y - _yr, 0), endy = std::min(y + _yr + 1, _h); +enum MorphologyOp { + ERODE, + DILATE +}; - guint32 ao = 255; - guint32 ro = 255; - guint32 go = 255; - guint32 bo = 255; +namespace { - if (_alpha) { - ao = 0xff000000; - for (int i = starty; i < endy; ++i) { - for (int j = startx; j < endx; ++j) { - guint32 px = pixelAt(j, i); - ao = std::min(ao, px & 0xff000000); - } - } - return ao; - } else { - for (int i = starty; i < endy; ++i) { - for (int j = startx; j < endx; ++j) { - guint32 px = pixelAt(j, i); - EXTRACT_ARGB32(px, a,r,g,b); - if (a) { - r = unpremul_alpha(r, a); - g = unpremul_alpha(g, a); - b = unpremul_alpha(b, a); - ao = std::min(ao, a); - ro = std::min(ro, r); - go = std::min(go, g); - bo = std::min(bo, b); - } else { - // zero pixel is guaranteed to be the minimum - ao = 0; ro = 0; go = 0; bo = 0; - goto end_loop; - } - } - } - end_loop: +template guint32 extreme(guint32 a, guint32 b); +template <> guint32 extreme(guint32 a, guint32 b) { return std::min(a, b); } +template <> guint32 extreme(guint32 a, guint32 b) { return std::max(a, b); } - ro = premul_alpha(ro, ao); - go = premul_alpha(go, ao); - bo = premul_alpha(bo, ao); - ASSEMBLE_ARGB32(pxout, ao,ro,go,bo) - return pxout; - } - } -private: - int _xr, _yr; -}; - -struct MorphologyDilate : public SurfaceSynth { - MorphologyDilate(cairo_surface_t *in, double xradius, double yradius) +/* This performs one "half" of the morphology operation by calculating + * the componentwise extreme in the specified axis with the given radius. + * Performing the operation one axis at a time gives us a MASSIVE performance boost + * at large morphology radii. We can do this, because the morphology operation + * is separable just like Gaussian blur. */ +template +struct Morphology : public SurfaceSynth { + Morphology(cairo_surface_t *in, double xradius) : SurfaceSynth(in) - , _xr(round(xradius)) - , _yr(round(yradius)) + , _radius(round(xradius)) {} guint32 operator()(int x, int y) { - int startx = std::max(x - _xr, 0), endx = std::min(x + _xr + 1, _w); - int starty = std::max(y - _yr, 0), endy = std::min(y + _yr + 1, _h); + int start, end; + if (axis == Geom::X) { + start = std::max(0, x - _radius); + end = std::min(x + _radius + 1, _w); + } else { + start = std::max(0, y - _radius); + end = std::min(y + _radius + 1, _h); + } - guint32 ao = 0; - guint32 ro = 0; - guint32 go = 0; - guint32 bo = 0; + guint32 ao = (OP == DILATE ? 0 : 255); + guint32 ro = (OP == DILATE ? 0 : 255); + guint32 go = (OP == DILATE ? 0 : 255); + guint32 bo = (OP == DILATE ? 0 : 255); if (_alpha) { - for (int i = starty; i < endy; ++i) { - for (int j = startx; j < endx; ++j) { - guint32 px = pixelAt(j, i); - ao = std::max(ao, px & 0xff000000); - } + ao = (OP == DILATE ? 0 : 0xff000000); + for (int i = start; i < end; ++i) { + guint32 px = (axis == Geom::X ? pixelAt(i, y) : pixelAt(x, i)); + ao = extreme(ao, px & 0xff000000); } return ao; } else { - for (int i = starty; i < endy; ++i) { - for (int j = startx; j < endx; ++j) { - guint32 px = pixelAt(j, i); - EXTRACT_ARGB32(px, a,r,g,b) - if (a == 0) continue; // this cannot affect the maximum - + for (int i = start; i < end; ++i) { + guint32 px = (axis == Geom::X ? pixelAt(i, y) : pixelAt(x, i)); + EXTRACT_ARGB32(px, a,r,g,b); + if (a) { r = unpremul_alpha(r, a); g = unpremul_alpha(g, a); b = unpremul_alpha(b, a); - ao = std::max(ao, a); - ro = std::max(ro, r); - go = std::max(go, g); - bo = std::max(bo, b); + + ao = extreme(ao, a); + ro = extreme(ro, r); + go = extreme(go, g); + bo = extreme(bo, b); + } else { + if (OP == DILATE) { + continue; // zero pixel will not affect the maximum + } else { + // zero pixel is guaranteed to be the minimum + ao = 0; ro = 0; go = 0; bo = 0; + break; + } } } @@ -136,112 +107,40 @@ struct MorphologyDilate : public SurfaceSynth { } } private: - int _xr, _yr; + int _radius; }; +} // end anonymous namespace + void FilterMorphology::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); - cairo_surface_t *out = ink_cairo_surface_create_identical(input); Geom::Matrix p2pb = slot.get_units().get_matrix_primitiveunits2pb(); double xr = xradius * p2pb.expansionX(); double yr = yradius * p2pb.expansionY(); + cairo_surface_t *interm = ink_cairo_surface_create_identical(input); + if (Operator == MORPHOLOGY_OPERATOR_DILATE) { - ink_cairo_surface_synthesize(out, MorphologyDilate(input, xr, yr)); + ink_cairo_surface_synthesize(interm, Morphology(input, xr)); } else { - ink_cairo_surface_synthesize(out, MorphologyErode(input, xr, yr)); - } - - slot.set(_output, out); - cairo_surface_destroy(out); -} - -/* -int FilterMorphology::render(FilterSlot &slot, FilterUnits const &units) { - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feMorphology (in=%d)", _input); - return 1; - } - - NRPixBlock *out = new NRPixBlock; - - // this primitive is defined for premultiplied RGBA values, - // thus convert them to that format - bool free_in_on_exit = false; - if (in->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - NRPixBlock *original_in = in; - in = new NRPixBlock; - nr_pixblock_setup_fast(in, NR_PIXBLOCK_MODE_R8G8B8A8P, - original_in->area.x0, original_in->area.y0, - original_in->area.x1, original_in->area.y1, - true); - nr_blit_pixblock_pixblock(in, original_in); - free_in_on_exit = true; + ink_cairo_surface_synthesize(interm, Morphology(input, xr)); } - Geom::Matrix p2pb = units.get_matrix_primitiveunits2pb(); - int const xradius = (int)round(this->xradius * p2pb.expansionX()); - int const yradius = (int)round(this->yradius * p2pb.expansionY()); - - int x0=in->area.x0; - int y0=in->area.y0; - int x1=in->area.x1; - int y1=in->area.y1; - int w=x1-x0, h=y1-y0; - int x, y, i, j; - int rmax,gmax,bmax,amax; - int rmin,gmin,bmin,amin; - - nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true); - - unsigned char *in_data = NR_PIXBLOCK_PX(in); - unsigned char *out_data = NR_PIXBLOCK_PX(out); - - for(x = 0 ; x < w ; x++){ - for(y = 0 ; y < h ; y++){ - rmin = gmin = bmin = amin = 255; - rmax = gmax = bmax = amax = 0; - for(i = x - xradius ; i < x + xradius ; i++){ - if (i < 0 || i >= w) continue; - for(j = y - yradius ; j < y + yradius ; j++){ - if (j < 0 || j >= h) continue; - if(in_data[4*(i + w*j)]>rmax) rmax = in_data[4*(i + w*j)]; - if(in_data[4*(i + w*j)+1]>gmax) gmax = in_data[4*(i + w*j)+1]; - if(in_data[4*(i + w*j)+2]>bmax) bmax = in_data[4*(i + w*j)+2]; - if(in_data[4*(i + w*j)+3]>amax) amax = in_data[4*(i + w*j)+3]; + cairo_surface_t *out = ink_cairo_surface_create_identical(input); - if(in_data[4*(i + w*j)](interm, yr)); + } else { + ink_cairo_surface_synthesize(out, Morphology(interm, yr)); } - if (free_in_on_exit) { - nr_pixblock_release(in); - delete in; - } + cairo_surface_destroy(interm); - out->empty = FALSE; slot.set(_output, out); - return 0; -}*/ + cairo_surface_destroy(out); +} void FilterMorphology::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { -- cgit v1.2.3 From 1a80d1aa528ac4afdf2663d4b640519e2ed85a37 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 27 Jul 2010 05:34:39 +0200 Subject: Add OpenMP IF clauses to filter templates, instead of modifying num_threads (bzr r9508.1.37) --- src/display/cairo-templates.h | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 900ca2d54..78fdff664 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -16,7 +16,7 @@ #include #include "preferences.h" // single-threaded operation if the number of pixels is below this threshold -#define OPENMP_THRESHOLD 2048 +static const int OPENMP_THRESHOLD = 2048; #endif #include @@ -70,7 +70,6 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif // The number of code paths here is evil. @@ -78,14 +77,14 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s if (bpp2 == 4) { if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { *(out_data + i) = blend(*(in1_data + i), *(in2_data + i)); } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in1_p = in1_data + i * stride1/4; @@ -100,7 +99,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s } else { // bpp2 == 1 #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in1_p = in1_data + i * stride1/4; @@ -118,7 +117,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s if (bpp2 == 4) { // bpp1 == 1 #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; @@ -135,7 +134,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s // bpp1 == 1 && bpp2 == 1 if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { guint8 *in1_p = reinterpret_cast(in1_data) + i; @@ -148,7 +147,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint8 *in1_p = reinterpret_cast(in1_data) + i * stride1; @@ -199,7 +198,6 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif if (bppin == 4) { @@ -207,14 +205,14 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter // bppin == 4, bppout == 4 if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { *(out_data + i) = filter(*(in_data + i)); } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in_p = in_data + i * stridein/4; @@ -229,7 +227,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter // bppin == 4, bppout == 1 // we use this path with COLORMATRIX_LUMINANCETOALPHA #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in_p = in_data + i * stridein/4; @@ -246,7 +244,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter // Note: there is no path for bppin == 1, bppout == 4 because it is useless if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { guint8 *in_p = reinterpret_cast(in_data) + i; @@ -257,7 +255,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint8 *in_p = reinterpret_cast(in_data) + i * stridein; @@ -301,12 +299,11 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const int limit = w * h; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif if (bppout == 4) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = out_area.y; i < h; ++i) { guint32 *out_p = reinterpret_cast(out_data + i * strideout); @@ -318,7 +315,7 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const } else { // bppout == 1 #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = out_area.y; i < h; ++i) { guint8 *out_p = out_data + i * strideout; -- cgit v1.2.3 From f014bfbb52135cfa486a22269e1a7770d0713a22 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 29 Jul 2010 02:56:18 +0200 Subject: First half of image filter (display from external image) (bzr r9508.1.38) --- src/display/nr-filter-image.cpp | 122 ++++++++++++++++++++++++++++++++++++---- src/display/nr-filter-image.h | 10 ++-- src/display/nr-filter-slot.h | 1 + 3 files changed, 118 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 5dec64dc7..eda19afcd 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -11,6 +11,7 @@ */ #include "document.h" #include "sp-item.h" +#include "display/cairo-utils.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "display/nr-filter.h" @@ -23,11 +24,12 @@ namespace Inkscape { namespace Filters { -FilterImage::FilterImage() : - SVGElem(0), - document(0), - feImageHref(0), - image_pixbuf(0) +FilterImage::FilterImage() + : SVGElem(0) + , document(0) + , feImageHref(0) + , image_surface(0) + , broken_ref(false) { } FilterPrimitive * FilterImage::create() { @@ -40,17 +42,18 @@ FilterImage::~FilterImage() g_free(feImageHref); } -/* void FilterImage::render_cairo(FilterSlot &slot) { if (!feImageHref) return; - cairo_surface_t *input = slot.getcairo(_input); + //cairo_surface_t *input = slot.getcairo(_input); if (from_element) { if (!SVGElem) return; + return; //not ready yet +/* // prep the document // TODO: do not recreate the rendering tree every time sp_document_ensure_up_to_date(document); @@ -69,7 +72,7 @@ void FilterImage::render_cairo(FilterSlot &slot) Geom::Rect area = *optarea; Geom::Matrix itrans = slot.get_units().get_matrix_display2pb(); - NRRectL const &slot_area = slot.get_units().get_slot_area(); + NRRectL const &slot_area = slot.get_slot_area(); NRRectL rect; rect.x0 = floor(area->left()); rect.x1 = ceil(area->right()); @@ -95,10 +98,103 @@ void FilterImage::render_cairo(FilterSlot &slot) slot.set(_output, out); cairo_surface_destroy(out); - return; + return;*/ + } + + if (!image && !broken_ref) { + broken_ref = true; + try { + /* TODO: If feImageHref is absolute, then use that (preferably handling the + * case that it's not a file URI). Otherwise, go up the tree looking + * for an xml:base attribute, and use that as the base URI for resolving + * the relative feImageHref URI. Otherwise, if document && document->base, + * then use that as the base URI. Otherwise, use feImageHref directly + * (i.e. interpreting it as relative to our current working directory). + * (See http://www.w3.org/TR/xmlbase/#resolution .) */ + gchar *fullname = feImageHref; + if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { + // Try to load from relative postion combined with document base + if( document ) { + fullname = g_build_filename( document->base, feImageHref, NULL ); + } + } + if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { + // Should display Broken Image png. + g_warning("FilterImage::render: Can not find: %s", feImageHref ); + } + image = Gdk::Pixbuf::create_from_file(fullname); + if( fullname != feImageHref ) g_free( fullname ); + } + catch (const Glib::FileError & e) + { + g_warning("caught Glib::FileError in FilterImage::render %i", e.code() ); + return; + } + catch (const Gdk::PixbufError & e) + { + g_warning("Gdk::PixbufError in FilterImage::render: %i", e.code() ); + return; + } + if ( !image ) return; + + broken_ref = false; + + bool has_alpha = image->get_has_alpha(); + if (!has_alpha) { + image = image->add_alpha(false, 0, 0, 0); + } + + // Native size of image + //width = image->get_width(); + //height = image->get_height(); + //rowstride = image->get_rowstride(); + + convert_pixbuf_normal_to_argb32(image->gobj()); + + image_surface = cairo_image_surface_create_for_data(image->get_pixels(), + CAIRO_FORMAT_ARGB32, image->get_width(), image->get_height(), image->get_rowstride()); } -}*/ + NRRectL const &sa = slot.get_slot_area(); + cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + sa.x1 - sa.x0, sa.y1 - sa.y0); + + cairo_t *ct = cairo_create(out); + cairo_translate(ct, -sa.x0, -sa.y0); + // now ct is in pb coordinates + ink_cairo_transform(ct, slot.get_units().get_matrix_primitiveunits2pb()); + // now ct is in the coordinates of feImageX etc. + + // Get the object bounding box in user coordinates. Image is placed with respect to box. + // Array values: 0: width; 3: height; 4: -x; 5: -y. + Geom::Matrix object_bbox = slot.get_units().get_matrix_user2filterunits(); + + // feImage is suppose to use the same parameters as a normal SVG image. + // If a width or height is set to zero, the image is not suppose to be displayed. + // This does not seem to be what Firefox or Opera does, nor does the W3C displacement + // filter test expect this behavior. If the width and/or height are zero, we use + // the width and height of the object bounding box. + if( feImageWidth == 0 ) feImageWidth = object_bbox[0]; + if( feImageHeight == 0 ) feImageHeight = object_bbox[3]; + + double scaleX = feImageWidth / image->get_width(); + double scaleY = feImageHeight / image->get_height(); + + cairo_translate(ct, feImageX, feImageY); + cairo_scale(ct, scaleX, scaleY); + cairo_set_source_surface(ct, image_surface, 0, 0); + cairo_paint(ct); + cairo_destroy(ct); + + slot.set(_output, out); +} + +bool FilterImage::can_handle_affine(Geom::Matrix const &) +{ + return true; +} + +#if 0 int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { if (!feImageHref) return 0; @@ -279,10 +375,16 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { slot.set(_output, out); return 0; } +#endif void FilterImage::set_href(const gchar *href){ if (feImageHref) g_free (feImageHref); feImageHref = (href) ? g_strdup (href) : NULL; + + if (image_surface) { + cairo_surface_destroy(image_surface); + } + image.reset(); } void FilterImage::set_document(SPDocument *doc){ diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index f3565ef9f..1f7064196 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -27,8 +27,8 @@ public: static FilterPrimitive *create(); virtual ~FilterImage(); - virtual int render(FilterSlot &slot, FilterUnits const &units); - virtual FilterTraits get_input_traits(); + virtual void render_cairo(FilterSlot &slot); + virtual bool can_handle_affine(Geom::Matrix const &); void set_document( SPDocument *document ); void set_href(const gchar *href); void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height); @@ -38,11 +38,11 @@ public: private: SPDocument *document; gchar *feImageHref; - guint8* image_pixbuf; Glib::RefPtr image; - int width, height, rowstride; + cairo_surface_t *image_surface; + //int width, height, rowstride; float feImageX,feImageY,feImageWidth,feImageHeight; - bool has_alpha; + bool broken_ref; }; } /* namespace Filters */ diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index a9fac61d9..57f3f1054 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -79,6 +79,7 @@ public: FilterUnits const &get_units() const { return _units; } NRRectL const &get_slot_area() const { return _slot_area; } + NRRectL const &get_sg_area() const { return *_source_graphic_area; } private: typedef std::map SlotMap; -- cgit v1.2.3 From d0f1ec68e47a0c41cf797e5ef8f8050bb61f45c5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 29 Jul 2010 03:00:47 +0200 Subject: Cruft removal (bzr r9508.1.39) --- src/display/nr-filter-image.cpp | 189 ---------------------------------------- src/display/nr-filter-image.h | 1 - 2 files changed, 190 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index eda19afcd..72b0e756f 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -17,9 +17,7 @@ #include "display/nr-filter.h" #include "display/nr-filter-image.h" #include "display/nr-filter-units.h" -#include "libnr/nr-compose-transform.h" #include "libnr/nr-rect-l.h" -#include "preferences.h" namespace Inkscape { namespace Filters { @@ -194,189 +192,6 @@ bool FilterImage::can_handle_affine(Geom::Matrix const &) return true; } -#if 0 -int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { - if (!feImageHref) return 0; - - NRPixBlock* pb = NULL; - bool free_pb_on_exit = false; - - if(from_element){ - if (!SVGElem) return 0; - - // prep the document - sp_document_ensure_up_to_date(document); - NRArena* arena = NRArena::create(); - unsigned const key = sp_item_display_key_new(1); - NRArenaItem* ai = sp_item_invoke_show(SVGElem, arena, key, SP_ITEM_SHOW_DISPLAY); - if (!ai) { - g_warning("feImage renderer: error creating NRArenaItem for SVG Element"); - nr_object_unref((NRObject *) arena); - return 0; - } - - pb = new NRPixBlock; - free_pb_on_exit = true; - - Geom::OptRect area = SVGElem->getBounds(Geom::identity()); - - NRRectL rect; - rect.x0=area->min()[Geom::X]; - rect.x1=area->max()[Geom::X]; - rect.y0=area->min()[Geom::Y]; - rect.y1=area->max()[Geom::Y]; - - width = (int)(rect.x1-rect.x0); - height = (int)(rect.y1-rect.y0); - rowstride = 4*width; - has_alpha = true; - - if (image_pixbuf) g_free(image_pixbuf); - image_pixbuf = g_try_new(unsigned char, 4L * width * height); - if(image_pixbuf != NULL) - { - memset(image_pixbuf, 0x00, 4 * width * height); - - NRGC gc(NULL); - /* Update to renderable state */ - double sf = 1.0; - Geom::Matrix t(Geom::Scale(sf, sf)); - nr_arena_item_set_transform(ai, &t); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( ai, NULL, &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); - nr_pixblock_setup_extern(pb, NR_PIXBLOCK_MODE_R8G8B8A8N, - (int)rect.x0, (int)rect.y0, (int)rect.x1, (int)rect.y1, - image_pixbuf, 4 * width, FALSE, FALSE ); - - nr_arena_item_invoke_render(NULL, ai, &rect, pb, NR_ARENA_ITEM_RENDER_NO_CACHE); - } - else - { - g_warning("FilterImage::render: not enough memory to create pixel buffer. Need %ld.", 4L * width * height); - } - sp_item_invoke_hide(SVGElem, key); - nr_object_unref((NRObject *) arena); - } - - - if (!image_pixbuf){ - try { - /* TODO: If feImageHref is absolute, then use that (preferably handling the - * case that it's not a file URI). Otherwise, go up the tree looking - * for an xml:base attribute, and use that as the base URI for resolving - * the relative feImageHref URI. Otherwise, if document && document->base, - * then use that as the base URI. Otherwise, use feImageHref directly - * (i.e. interpreting it as relative to our current working directory). - * (See http://www.w3.org/TR/xmlbase/#resolution .) */ - gchar *fullname = feImageHref; - if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { - // Try to load from relative postion combined with document base - if( document ) { - fullname = g_build_filename( document->base, feImageHref, NULL ); - } - } - if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { - // Should display Broken Image png. - g_warning("FilterImage::render: Can not find: %s", feImageHref ); - } - image = Gdk::Pixbuf::create_from_file(fullname); - if( fullname != feImageHref ) g_free( fullname ); - } - catch (const Glib::FileError & e) - { - g_warning("caught Glib::FileError in FilterImage::render %i", e.code() ); - return 0; - } - catch (const Gdk::PixbufError & e) - { - g_warning("Gdk::PixbufError in FilterImage::render: %i", e.code() ); - return 0; - } - if ( !image ) return 0; - - // Native size of image - width = image->get_width(); - height = image->get_height(); - rowstride = image->get_rowstride(); - image_pixbuf = image->get_pixels(); - has_alpha = image->get_has_alpha(); - } - int w,x,y; - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feImage (in=%d)", _input); - return 1; - } - - // This section needs to be fully tested!! - - // Region being drawn on screen - int x0 = in->area.x0, y0 = in->area.y0; - int x1 = in->area.x1, y1 = in->area.y1; - NRPixBlock *out = new NRPixBlock; - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8P, x0, y0, x1, y1, true); - w = x1 - x0; - - // Get the object bounding box. Image is placed with respect to box. - // Array values: 0: width; 3: height; 4: -x; 5: -y. - Geom::Matrix object_bbox = units.get_matrix_user2filterunits().inverse(); - - // feImage is suppose to use the same parameters as a normal SVG image. - // If a width or height is set to zero, the image is not suppose to be displayed. - // This does not seem to be what Firefox or Opera does, nor does the W3C displacement - // filter test expect this behavior. If the width and/or height are zero, we use - // the width and height of the object bounding box. - if( feImageWidth == 0 ) feImageWidth = object_bbox[0]; - if( feImageHeight == 0 ) feImageHeight = object_bbox[3]; - - double scaleX = width/feImageWidth; - double scaleY = height/feImageHeight; - - int coordx,coordy; - unsigned char *out_data = NR_PIXBLOCK_PX(out); - Geom::Matrix unit_trans = units.get_matrix_primitiveunits2pb().inverse(); - Geom::Matrix d2s = Geom::Translate(x0, y0) * unit_trans * Geom::Translate(object_bbox[4]-feImageX, object_bbox[5]-feImageY) * Geom::Scale(scaleX, scaleY); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int nr_arena_image_x_sample = prefs->getInt("/options/bitmapoversample/value", 1); - int nr_arena_image_y_sample = nr_arena_image_x_sample; - - if (has_alpha) { - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM(out_data, x1-x0, y1-y0, 4*w, image_pixbuf, width, height, rowstride, d2s, 255, nr_arena_image_x_sample, nr_arena_image_y_sample); - } else { - for (x=x0; x < x1; x++){ - for (y=y0; y < y1; y++){ - //TODO: use interpolation - // Temporarily add 0.5 so we sample center of "cell" - double indexX = scaleX * (((x+0.5) * unit_trans[0] + unit_trans[4]) - feImageX + object_bbox[4]); - double indexY = scaleY * (((y+0.5) * unit_trans[3] + unit_trans[5]) - feImageY + object_bbox[5]); - - // coordx == 0 and coordy == 0 must be included, but we protect - // against negative numbers which round up to 0 with (int). - coordx = ( indexX >= 0 ? int( indexX ) : -1 ); - coordy = ( indexY >= 0 ? int( indexY ) : -1 ); - if (coordx >= 0 && coordx < width && coordy >= 0 && coordy < height){ - out_data[4*((x - x0)+w*(y - y0)) ] = (unsigned char) image_pixbuf[3*coordx + rowstride*coordy ]; //Red - out_data[4*((x - x0)+w*(y - y0)) + 1] = (unsigned char) image_pixbuf[3*coordx + rowstride*coordy + 1]; //Green - out_data[4*((x - x0)+w*(y - y0)) + 2] = (unsigned char) image_pixbuf[3*coordx + rowstride*coordy + 2]; //Blue - out_data[4*((x - x0)+w*(y - y0)) + 3] = 255; //Alpha - } - } - } - } - if (free_pb_on_exit) { - nr_pixblock_release(pb); - delete pb; - } - - out->empty = FALSE; - slot.set(_output, out); - return 0; -} -#endif - void FilterImage::set_href(const gchar *href){ if (feImageHref) g_free (feImageHref); feImageHref = (href) ? g_strdup (href) : NULL; @@ -398,10 +213,6 @@ void FilterImage::set_region(SVGLength x, SVGLength y, SVGLength width, SVGLengt feImageHeight=height.computed; } -FilterTraits FilterImage::get_input_traits() { - return TRAIT_PARALLER; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index 1f7064196..a2aff0742 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -40,7 +40,6 @@ private: gchar *feImageHref; Glib::RefPtr image; cairo_surface_t *image_surface; - //int width, height, rowstride; float feImageX,feImageY,feImageWidth,feImageHeight; bool broken_ref; }; -- cgit v1.2.3 From c9a6247b9ac5db8e7c4e8c0f3689f60594324f6f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 30 Jul 2010 02:16:28 +0200 Subject: Second half of image filter, probably not 100% correct (bzr r9508.1.40) --- src/display/nr-filter-image.cpp | 85 ++++++++------- src/display/nr-filter-slot.cpp | 226 ---------------------------------------- src/display/nr-filter-slot.h | 15 +-- src/display/nr-filter-units.h | 12 +++ src/display/nr-filter.cpp | 9 ++ 5 files changed, 70 insertions(+), 277 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 72b0e756f..636f31187 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -47,15 +47,33 @@ void FilterImage::render_cairo(FilterSlot &slot) //cairo_surface_t *input = slot.getcairo(_input); + Geom::Matrix m = slot.get_units().get_matrix_user2filterunits().inverse(); + Geom::Point bbox_00 = Geom::Point(0,0) * m; + Geom::Point bbox_w0 = Geom::Point(1,0) * m; + Geom::Point bbox_0h = Geom::Point(0,1) * m; + double bbox_width = Geom::distance(bbox_00, bbox_w0); + double bbox_height = Geom::distance(bbox_00, bbox_0h); + + + // feImage is suppose to use the same parameters as a normal SVG image. + // If a width or height is set to zero, the image is not suppose to be displayed. + // This does not seem to be what Firefox or Opera does, nor does the W3C displacement + // filter test expect this behavior. If the width and/or height are zero, we use + // the width and height of the object bounding box. + if( feImageWidth == 0 ) feImageWidth = bbox_width; + if( feImageHeight == 0 ) feImageHeight = bbox_height; + if (from_element) { if (!SVGElem) return; - return; //not ready yet -/* - // prep the document // TODO: do not recreate the rendering tree every time + // TODO: the entire thing is a hack, we should give filter primitives an "update" method + // like the one for NRArenaItems sp_document_ensure_up_to_date(document); NRArena* arena = NRArena::create(); + Geom::OptRect optarea = SVGElem->getBounds(Geom::identity()); + if (!optarea) return; + unsigned const key = sp_item_display_key_new(1); NRArenaItem* ai = sp_item_invoke_show(SVGElem, arena, key, SP_ITEM_SHOW_DISPLAY); if (!ai) { @@ -64,39 +82,42 @@ void FilterImage::render_cairo(FilterSlot &slot) return; } - Geom::OptRect optarea = SVGElem->getBounds(Geom::identity()); - if (!optarea) return; - Geom::Rect area = *optarea; - Geom::Matrix itrans = slot.get_units().get_matrix_display2pb(); + Geom::Matrix pu2pb = slot.get_units().get_matrix_primitiveunits2pb(); - NRRectL const &slot_area = slot.get_slot_area(); - NRRectL rect; - rect.x0 = floor(area->left()); - rect.x1 = ceil(area->right()); - rect.y0 = floor(area->top()); - rect.y1 = ceil(area->bottom()); + double scaleX = feImageWidth / area.width(); + double scaleY = feImageHeight / area.height(); - cairo_surface_t *out = ink_cairo_surface_create_same_size(in, CAIRO_CONTENT_COLOR_ALPHA); + NRRectL const &sa = slot.get_slot_area(); + cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + sa.x1 - sa.x0, sa.y1 - sa.y0); cairo_t *ct = cairo_create(out); - cairo_translate(ct, -slot_area.x0, -slot_area.y0); - ink_cairo_transform(ct, itrans); - cairo_translate(ct, rect.x0, rect.y0); + cairo_translate(ct, -sa.x0, -sa.y0); + ink_cairo_transform(ct, pu2pb); // we are now in primitive units + cairo_translate(ct, feImageX, feImageY); + cairo_scale(ct, scaleX, scaleY); + + NRRectL render_rect; + render_rect.x0 = floor(area.left()); + render_rect.y0 = floor(area.top()); + render_rect.x1 = ceil(area.right()); + render_rect.y1 = ceil(area.bottom()); + cairo_translate(ct, render_rect.x0, render_rect.y0); // Update to renderable state NRGC gc(NULL); Geom::Matrix t = Geom::identity(); nr_arena_item_set_transform(ai, &t); gc.transform.setIdentity(); - nr_arena_item_invoke_update( ai, NULL, &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); - - nr_arena_item_invoke_render(ct, ai, &rect, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE); + nr_arena_item_invoke_update(ai, NULL, &gc, + NR_ARENA_ITEM_STATE_ALL, + NR_ARENA_ITEM_STATE_NONE); + nr_arena_item_invoke_render(ct, ai, &render_rect, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE); + nr_object_unref((NRObject*) arena); slot.set(_output, out); cairo_surface_destroy(out); - return;*/ + return; } if (!image && !broken_ref) { @@ -119,18 +140,19 @@ void FilterImage::render_cairo(FilterSlot &slot) if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { // Should display Broken Image png. g_warning("FilterImage::render: Can not find: %s", feImageHref ); + return; } image = Gdk::Pixbuf::create_from_file(fullname); if( fullname != feImageHref ) g_free( fullname ); } catch (const Glib::FileError & e) { - g_warning("caught Glib::FileError in FilterImage::render %i", e.code() ); + g_warning("caught Glib::FileError in FilterImage::render: %s", e.what().data() ); return; } catch (const Gdk::PixbufError & e) { - g_warning("Gdk::PixbufError in FilterImage::render: %i", e.code() ); + g_warning("Gdk::PixbufError in FilterImage::render: %s", e.what().data() ); return; } if ( !image ) return; @@ -163,18 +185,6 @@ void FilterImage::render_cairo(FilterSlot &slot) ink_cairo_transform(ct, slot.get_units().get_matrix_primitiveunits2pb()); // now ct is in the coordinates of feImageX etc. - // Get the object bounding box in user coordinates. Image is placed with respect to box. - // Array values: 0: width; 3: height; 4: -x; 5: -y. - Geom::Matrix object_bbox = slot.get_units().get_matrix_user2filterunits(); - - // feImage is suppose to use the same parameters as a normal SVG image. - // If a width or height is set to zero, the image is not suppose to be displayed. - // This does not seem to be what Firefox or Opera does, nor does the W3C displacement - // filter test expect this behavior. If the width and/or height are zero, we use - // the width and height of the object bounding box. - if( feImageWidth == 0 ) feImageWidth = object_bbox[0]; - if( feImageHeight == 0 ) feImageHeight = object_bbox[3]; - double scaleX = feImageWidth / image->get_width(); double scaleY = feImageHeight / image->get_height(); @@ -200,6 +210,7 @@ void FilterImage::set_href(const gchar *href){ cairo_surface_destroy(image_surface); } image.reset(); + broken_ref = false; } void FilterImage::set_document(SPDocument *doc){ diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 935751871..6cca0fc77 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -21,46 +21,6 @@ #include "display/nr-filter-gaussian.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "display/pixblock-scaler.h" -#include "display/pixblock-transform.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-blit.h" - -__attribute__ ((const)) -inline static int _max4(const double a, const double b, - const double c, const double d) { - double ret = a; - if (b > ret) ret = b; - if (c > ret) ret = c; - if (d > ret) ret = d; - return (int)round(ret); -} - -__attribute__ ((const)) -inline static int _min4(const double a, const double b, - const double c, const double d) { - double ret = a; - if (b < ret) ret = b; - if (c < ret) ret = c; - if (d < ret) ret = d; - return (int)round(ret); -} - -__attribute__ ((const)) -inline static int _max2(const double a, const double b) { - if (a > b) - return (int)round(a); - else - return (int)round(b); -} - -__attribute__ ((const)) -inline static int _min2(const double a, const double b) { - if (a > b) - return (int)round(b); - else - return (int)round(a); -} namespace Inkscape { namespace Filters { @@ -105,9 +65,6 @@ FilterSlot::~FilterSlot() cairo_surface_t *FilterSlot::getcairo(int slot_nr) { - //int index = _get_index(slot_nr); - //assert(index >= 0); - if (slot_nr == NR_FILTER_SLOT_NOT_SET) slot_nr = _last_out; @@ -240,28 +197,6 @@ cairo_surface_t *FilterSlot::get_result(int res) return r; } -/* -void FilterSlot::get_final(int slot_nr, NRPixBlock *result) { - NRPixBlock *final_usr = get(slot_nr); - Geom::Matrix trans = units.get_matrix_pb2display(); - - int size = (result->area.x1 - result->area.x0) - * (result->area.y1 - result->area.y0) - * NR_PIXBLOCK_BPP(result); - memset(NR_PIXBLOCK_PX(result), 0, size); - - if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) { - if (filterquality == FILTER_QUALITY_BEST) { - NR::transform_bicubic(result, final_usr, trans); - } else { - NR::transform_nearest(result, final_usr, trans); - } - } else if (fabs(trans[0] - 1) > 1e-6 || fabs(trans[3] - 1) > 1e-6) { - NR::scale_bicubic(result, final_usr, trans); - } else { - nr_blit_pixblock_pixblock(result, final_usr); - } -}*/ void FilterSlot::_set_internal(int slot_nr, cairo_surface_t *surface) { @@ -286,172 +221,11 @@ void FilterSlot::set(int slot_nr, cairo_surface_t *surface) _set_internal(slot_nr, surface); _last_out = slot_nr; - -#if 0 - /* Unnamed slot is for saving filter primitive results, when parameter - * 'result' is not set. Only the filter immediately after this one - * can access unnamed results, so we don't have to worry about overwriting - * previous results in filter chain. On the other hand, we may not - * overwrite any other image with this one, because they might be - * accessed later on. */ - int index = ((slot_nr != NR_FILTER_SLOT_NOT_SET) - ? _get_index(slot_nr) - : _get_index(NR_FILTER_UNNAMED_SLOT)); - assert(index >= 0); - // Unnamed slot is only for Inkscape::Filters::FilterSlot internal use. - assert(slot_nr != NR_FILTER_UNNAMED_SLOT); - assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr); - - if (slot_nr == NR_FILTER_SOURCEGRAPHIC || slot_nr == NR_FILTER_BACKGROUNDIMAGE) { - Geom::Matrix trans = units.get_matrix_display2pb(); - if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) { - NRPixBlock *trans_pb = new NRPixBlock; - int x0 = pb->area.x0; - int y0 = pb->area.y0; - int x1 = pb->area.x1; - int y1 = pb->area.y1; - int min_x = _min4(trans[0] * x0 + trans[2] * y0 + trans[4], - trans[0] * x0 + trans[2] * y1 + trans[4], - trans[0] * x1 + trans[2] * y0 + trans[4], - trans[0] * x1 + trans[2] * y1 + trans[4]); - int max_x = _max4(trans[0] * x0 + trans[2] * y0 + trans[4], - trans[0] * x0 + trans[2] * y1 + trans[4], - trans[0] * x1 + trans[2] * y0 + trans[4], - trans[0] * x1 + trans[2] * y1 + trans[4]); - int min_y = _min4(trans[1] * x0 + trans[3] * y0 + trans[5], - trans[1] * x0 + trans[3] * y1 + trans[5], - trans[1] * x1 + trans[3] * y0 + trans[5], - trans[1] * x1 + trans[3] * y1 + trans[5]); - int max_y = _max4(trans[1] * x0 + trans[3] * y0 + trans[5], - trans[1] * x0 + trans[3] * y1 + trans[5], - trans[1] * x1 + trans[3] * y0 + trans[5], - trans[1] * x1 + trans[3] * y1 + trans[5]); - - nr_pixblock_setup_fast(trans_pb, pb->mode, - min_x, min_y, - max_x, max_y, true); - if (trans_pb->size != NR_PIXBLOCK_SIZE_TINY && trans_pb->data.px == NULL) { - /* TODO: this gets hit occasionally. Worst case scenario: - * images are exported in horizontal stripes. One stripe - * is not too high, but can get thousands of pixels wide. - * Rotate this 45 degrees -> _huge_ image */ - g_warning("Memory allocation failed in Inkscape::Filters::FilterSlot::set (transform)"); - return; - } - if (filterquality == FILTER_QUALITY_BEST) { - NR::transform_bicubic(trans_pb, pb, trans); - } else { - NR::transform_nearest(trans_pb, pb, trans); - } - nr_pixblock_release(pb); - delete pb; - pb = trans_pb; - } else if (fabs(trans[0] - 1) > 1e-6 || fabs(trans[3] - 1) > 1e-6) { - NRPixBlock *trans_pb = new NRPixBlock; - - int x0 = pb->area.x0; - int y0 = pb->area.y0; - int x1 = pb->area.x1; - int y1 = pb->area.y1; - int min_x = _min2(trans[0] * x0 + trans[4], - trans[0] * x1 + trans[4]); - int max_x = _max2(trans[0] * x0 + trans[4], - trans[0] * x1 + trans[4]); - int min_y = _min2(trans[3] * y0 + trans[5], - trans[3] * y1 + trans[5]); - int max_y = _max2(trans[3] * y0 + trans[5], - trans[3] * y1 + trans[5]); - - nr_pixblock_setup_fast(trans_pb, pb->mode, - min_x, min_y, max_x, max_y, true); - if (trans_pb->size != NR_PIXBLOCK_SIZE_TINY && trans_pb->data.px == NULL) { - g_warning("Memory allocation failed in Inkscape::Filters::FilterSlot::set (scaling)"); - return; - } - NR::scale_bicubic(trans_pb, pb, trans); - nr_pixblock_release(pb); - delete pb; - pb = trans_pb; - } - } - - if(_slot[index]) { - nr_pixblock_release(_slot[index]); - delete _slot[index]; - } - _slot[index] = pb; - _last_out = index; -#endif } int FilterSlot::get_slot_count() { return _slots.size(); - /* - int seek = _slot_count; - do { - seek--; - } while (!_slot[seek] && _slot_number[seek] == NR_FILTER_SLOT_NOT_SET); - - return seek + 1;*/ -} - -int FilterSlot::_get_index(int slot_nr) -{ -#if 0 - assert(slot_nr >= 0 || - slot_nr == NR_FILTER_SLOT_NOT_SET || - slot_nr == NR_FILTER_SOURCEGRAPHIC || - slot_nr == NR_FILTER_SOURCEALPHA || - slot_nr == NR_FILTER_BACKGROUNDIMAGE || - slot_nr == NR_FILTER_BACKGROUNDALPHA || - slot_nr == NR_FILTER_FILLPAINT || - slot_nr == NR_FILTER_STROKEPAINT || - slot_nr == NR_FILTER_UNNAMED_SLOT); - - int index = -1; - if (slot_nr == NR_FILTER_SLOT_NOT_SET) { - return _last_out; - } - /* Search, if the slot already exists */ - for (int i = 0 ; i < _slot_count ; i++) { - if (_slot_number[i] == slot_nr) { - index = i; - break; - } - } - - /* If the slot doesn't already exist, create it */ - if (index == -1) { - int seek = _slot_count; - do { - seek--; - } while ((seek >= 0) && (_slot_number[seek] == NR_FILTER_SLOT_NOT_SET)); - /* If there is no space for more slots, create more space */ - if (seek == _slot_count - 1) { - NRPixBlock **new_slot = new NRPixBlock*[_slot_count * 2]; - int *new_number = new int[_slot_count * 2]; - for (int i = 0 ; i < _slot_count ; i++) { - new_slot[i] = _slot[i]; - new_number[i] = _slot_number[i]; - } - for (int i = _slot_count ; i < _slot_count * 2 ; i++) { - new_slot[i] = NULL; - new_number[i] = NR_FILTER_SLOT_NOT_SET; - } - delete[] _slot; - delete[] _slot_number; - _slot = new_slot; - _slot_number = new_number; - _slot_count *= 2; - } - /* Now that there is space, create the slot */ - _slot_number[seek + 1] = slot_nr; - index = seek + 1; - } - return index; -#endif - return 0; } void FilterSlot::set_quality(FilterQuality const q) { diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 57f3f1054..7b32f1210 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -27,10 +27,7 @@ namespace Filters { class FilterSlot { public: - /** Creates a new FilterSlot object. - * Parameter specifies the surface which should be used - * for background accesses from filters. - */ + /** Creates a new FilterSlot object. */ FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, cairo_surface_t *graphic, NRRectL const *graphicarea, FilterUnits const &u); /** Destroys the FilterSlot object and all its contents */ @@ -42,8 +39,6 @@ public: * NR_FILTER_SOURCEGRAPHIC, NR_FILTER_SOURCEALPHA, * NR_FILTER_BACKGROUNDIMAGE, NR_FILTER_BACKGROUNDALPHA, * NR_FILTER_FILLPAINT, NR_FILTER_SOURCEPAINT. - * If the defined filter slot is not set before, this function - * returns NULL. Also, that filter slot is created in process. */ cairo_surface_t *getcairo(int slot); NRPixBlock *get(int slot) { return NULL; } @@ -51,10 +46,6 @@ public: /** Sets or re-sets the pixblock associated with given slot. * If there was a pixblock already assigned with this slot, * that pixblock is destroyed. - * Pixblocks passed to this function should be considered - * managed by this FilterSlot object. - * Pixblocks passed to this function should be reserved with - * c++ -style new-operator. */ void set(int slot, cairo_surface_t *s); @@ -104,10 +95,6 @@ private: cairo_surface_t *_get_fill_paint(); cairo_surface_t *_get_stroke_paint(); - /** Returns the table index of given slot. If that slot does not exist, - * it is created. Table index can be used to read the correct - * pixblock from _slot */ - int _get_index(int slot); void _set_internal(int slot, cairo_surface_t *s); }; diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index d8489b42e..dcf7e5838 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -22,6 +22,18 @@ namespace Inkscape { namespace Filters { +/* Notes: + * - "filter units" is a coordinate system where the filter region is contained + * between (0,0) and (1,1). Do not confuse this with the filterUnits property + * - "primitive units" is the coordinate system in which all lengths and distances + * in the filter definition should be interpreted. They are affected by the value + * of the primitiveUnits attribute + * - "pb" is the coordinate system in which filter rendering happens. + * It might be aligned with user or screen coordinates depending on + * the filter primitives used in the filter. + * - "display" are world coordinates of the canvas - pixel grid coordinates + * of the drawing area translated so that (0,0) corresponds to the document origin + */ class FilterUnits { public: FilterUnits(); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 667a3cc14..8c638415d 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -269,9 +269,18 @@ void Filter::set_primitive_units(SPFilterUnits unit) { } void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { + NRRectL bbox_orig = bbox; for (int i = 0 ; i < _primitive_count ; i++) { if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm); } + + // HACK: due to some roundoff issue that I can't find at this time, + // some per-pixel filters show seams when rotated. + if (bbox_orig.x0 >= bbox.x0) bbox.x0 = bbox_orig.x0 - 1; + if (bbox_orig.y0 >= bbox.y0) bbox.y0 = bbox_orig.y0 - 1; + if (bbox_orig.x1 <= bbox.x1) bbox.x1 = bbox_orig.x1 + 1; + if (bbox_orig.y1 <= bbox.y1) bbox.y1 = bbox_orig.y1 + 1; + /* TODO: something. See images at the bottom of filters.svg with medium-low filtering quality. -- cgit v1.2.3 From 4b9f09e52f05a19f93546c075c7a3fb7be322ed7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 3 Aug 2010 04:05:53 +0200 Subject: Handle preserveAspectRatio for images (bzr r9508.1.41) --- src/display/cairo-utils.cpp | 17 +++- src/display/cairo-utils.h | 3 + src/display/nr-arena-image.cpp | 179 ++++++++++++++++++++++---------------- src/display/nr-arena-image.h | 18 ++-- src/sp-image.cpp | 189 ++++++++++++++++------------------------- src/sp-image.h | 8 +- 6 files changed, 209 insertions(+), 205 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index a05d28170..25a1e7988 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -288,8 +288,17 @@ ink_cairo_set_source_color(cairo_t *ct, SPColor const &c, double opacity) cairo_set_source_rgba(ct, c.v.c[0], c.v.c[1], c.v.c[2], opacity); } -static void -ink_cairo_convert_matrix(cairo_matrix_t &cm, Geom::Matrix const &m) +void ink_matrix_to_2geom(Geom::Matrix &m, cairo_matrix_t const &cm) +{ + m[0] = cm.xx; + m[2] = cm.xy; + m[4] = cm.x0; + m[1] = cm.yx; + m[3] = cm.yy; + m[5] = cm.y0; +} + +void ink_matrix_to_cairo(cairo_matrix_t &cm, Geom::Matrix const &m) { cm.xx = m[0]; cm.xy = m[2]; @@ -303,7 +312,7 @@ void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m) { cairo_matrix_t cm; - ink_cairo_convert_matrix(cm, m); + ink_matrix_to_cairo(cm, m); cairo_transform(ct, &cm); } @@ -311,7 +320,7 @@ void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m) { cairo_matrix_t cm; - ink_cairo_convert_matrix(cm, m); + ink_matrix_to_cairo(cm, m); cairo_pattern_set_matrix(cp, &cm); } diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 12fcd8b3d..5ac546067 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -84,6 +84,9 @@ void ink_cairo_transform(cairo_t *ct, Geom::Matrix const &m); void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m); void ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double y); +void ink_matrix_to_2geom(Geom::Matrix &, cairo_matrix_t const &); +void ink_matrix_to_cairo(cairo_matrix_t &, Geom::Matrix const &); + cairo_surface_t *ink_cairo_surface_copy(cairo_surface_t *s); cairo_surface_t *ink_cairo_surface_create_identical(cairo_surface_t *s); cairo_surface_t *ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 422b691b7..066133dde 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -39,6 +39,7 @@ static void nr_arena_image_finalize (NRObject *object); static unsigned int nr_arena_image_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); static unsigned int nr_arena_image_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); static NRArenaItem *nr_arena_image_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); +static Geom::Rect nr_arena_image_rect (NRArenaImage *image); static NRArenaItemClass *parent_class; @@ -80,12 +81,10 @@ static void nr_arena_image_init (NRArenaImage *image) { image->pixbuf = NULL; - image->x = image->y = 0.0; - image->width = 256.0; - image->height = 256.0; - - image->grid2px.setIdentity(); - image->px2grid.setIdentity(); + image->ctm.setIdentity(); + image->clipbox = Geom::Rect(); + image->ox = image->oy = 0.0; + image->sx = image->sy = 1.0; image->style = 0; image->render_opacity = TRUE; @@ -106,54 +105,24 @@ nr_arena_image_finalize (NRObject *object) static unsigned int nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned int /*state*/, unsigned int /*reset*/ ) { - Geom::Matrix grid2px; - // clear old bbox nr_arena_item_request_render(item); NRArenaImage *image = NR_ARENA_IMAGE (item); /* Copy affine */ - grid2px = gc->transform.inverse(); - double hscale, vscale; // todo: replace with Geom::Scale - if (image->pixbuf) { - hscale = gdk_pixbuf_get_width(image->pixbuf) / image->width; - vscale = gdk_pixbuf_get_height(image->pixbuf) / image->height; - } else { - hscale = 1.0; - vscale = 1.0; - } - - image->grid2px[0] = grid2px[0] * hscale; - image->grid2px[2] = grid2px[2] * hscale; - image->grid2px[4] = grid2px[4] * hscale; - image->grid2px[1] = grid2px[1] * vscale; - image->grid2px[3] = grid2px[3] * vscale; - image->grid2px[5] = grid2px[5] * vscale; - - image->grid2px[4] -= image->x * hscale; - image->grid2px[5] -= image->y * vscale; + image->ctm = gc->transform; /* Calculate bbox */ if (image->pixbuf) { NRRect bbox; - bbox.x0 = image->x; - bbox.y0 = image->y; - bbox.x1 = image->x + image->width; - bbox.y1 = image->y + image->height; + Geom::Rect r = nr_arena_image_rect(image) * gc->transform; - image->c00 = (Geom::Point(bbox.x0, bbox.y0) * gc->transform); - image->c01 = (Geom::Point(bbox.x0, bbox.y1) * gc->transform); - image->c10 = (Geom::Point(bbox.x1, bbox.y0) * gc->transform); - image->c11 = (Geom::Point(bbox.x1, bbox.y1) * gc->transform); - - nr_rect_d_matrix_transform (&bbox, &bbox, gc->transform); - - item->bbox.x0 = static_cast(floor(bbox.x0)); // Floor gives the coordinate in which the point resides - item->bbox.y0 = static_cast(floor(bbox.y0)); - item->bbox.x1 = static_cast(ceil (bbox.x1)); // Ceil gives the first coordinate beyond the point - item->bbox.y1 = static_cast(ceil (bbox.y1)); + item->bbox.x0 = floor(r.left()); // Floor gives the coordinate in which the point resides + item->bbox.y0 = floor(r.top()); + item->bbox.x1 = ceil(r.right()); // Ceil gives the first coordinate beyond the point + item->bbox.y1 = ceil(r.bottom()); } else { item->bbox.x0 = (int) gc->transform[4]; item->bbox.y0 = (int) gc->transform[5]; @@ -164,19 +133,12 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned return NR_ARENA_ITEM_STATE_ALL; } -#define FBITS 12 -#define b2i (image->grid2px) - static unsigned int nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int /*flags*/ ) { if (!ct) return item->state; -#if 0 - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - nr_arena_image_x_sample = prefs->getInt("/options/bitmapoversample/value", 1); - nr_arena_image_y_sample = nr_arena_image_x_sample; -#endif + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); NRArenaImage *image = NR_ARENA_IMAGE (item); @@ -188,13 +150,25 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock // of the pixbuf. Fix this in Cairo and/or GDK. cairo_save(ct); cairo_translate(ct, -area->x0, -area->y0); + ink_cairo_transform(ct, image->ctm); + + cairo_new_path(ct); + cairo_rectangle(ct, image->clipbox.left(), image->clipbox.top(), + image->clipbox.width(), image->clipbox.height()); + cairo_clip(ct); + + cairo_translate(ct, image->ox, image->oy); + cairo_scale(ct, image->sx, image->sy); + gdk_cairo_set_source_pixbuf(ct, image->pixbuf, 0, 0); - cairo_pattern_t *p = cairo_get_source(ct); - ink_cairo_pattern_set_matrix(p, image->grid2px); + cairo_matrix_t tt; + Geom::Matrix total; + cairo_get_matrix(ct, &tt); + ink_matrix_to_2geom(total, tt); - Geom::Matrix total = item->ctm * image->grid2px.inverse(); if (total.expansionX() > 1.0 || total.expansionY() > 1.0) { + cairo_pattern_t *p = cairo_get_source(ct); cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST); } @@ -202,6 +176,11 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_restore(ct); } else { // outline; draw a rect instead + + cairo_save(ct); + cairo_translate(ct, -area->x0, -area->y0); + ink_cairo_transform(ct, image->ctm); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); ink_cairo_set_source_rgba32(ct, rgba); @@ -209,11 +188,12 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_set_line_width(ct, 0.5); cairo_new_path(ct); - Geom::Point shift(area->x0, area->y0); - Geom::Point c00 = image->c00 - shift; - Geom::Point c01 = image->c01 - shift; - Geom::Point c11 = image->c11 - shift; - Geom::Point c10 = image->c10 - shift; + Geom::Rect r = nr_arena_image_rect (image); + + Geom::Point c00 = r.corner(0); + Geom::Point c01 = r.corner(3); + Geom::Point c11 = r.corner(2); + Geom::Point c10 = r.corner(1); cairo_move_to (ct, c00[Geom::X], c00[Geom::Y]); @@ -263,16 +243,22 @@ nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned in bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (outline) { + Geom::Rect r = nr_arena_image_rect (image); + + Geom::Point c00 = r.corner(0); + Geom::Point c01 = r.corner(3); + Geom::Point c11 = r.corner(2); + Geom::Point c10 = r.corner(1); // frame - if (distance_to_segment (p, image->c00, image->c10) < delta) return item; - if (distance_to_segment (p, image->c10, image->c11) < delta) return item; - if (distance_to_segment (p, image->c11, image->c01) < delta) return item; - if (distance_to_segment (p, image->c01, image->c00) < delta) return item; + if (distance_to_segment (p, c00, c10) < delta) return item; + if (distance_to_segment (p, c10, c11) < delta) return item; + if (distance_to_segment (p, c11, c01) < delta) return item; + if (distance_to_segment (p, c01, c00) < delta) return item; // diagonals - if (distance_to_segment (p, image->c00, image->c11) < delta) return item; - if (distance_to_segment (p, image->c10, image->c01) < delta) return item; + if (distance_to_segment (p, c00, c11) < delta) return item; + if (distance_to_segment (p, c10, c01) < delta) return item; return NULL; @@ -282,9 +268,17 @@ nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned in int const width = gdk_pixbuf_get_width(image->pixbuf); int const height = gdk_pixbuf_get_height(image->pixbuf); int const rowstride = gdk_pixbuf_get_rowstride(image->pixbuf); - Geom::Point tp = p * image->grid2px; - int const ix = (int)(tp[Geom::X]); - int const iy = (int)(tp[Geom::Y]); + + Geom::Point tp = p * image->ctm.inverse(); + Geom::Rect r = nr_arena_image_rect(image); + + if (!r.contains(tp)) + return NULL; + + double vw = width * image->sx; + double vh = height * image->sy; + int ix = floor((tp[Geom::X] - image->ox) / vw * width); + int iy = floor((tp[Geom::Y] - image->oy) / vh * height); if ((ix < 0) || (iy < 0) || (ix >= width) || (iy >= height)) return NULL; @@ -295,6 +289,26 @@ nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned in } } +Geom::Rect +nr_arena_image_rect (NRArenaImage *image) +{ + Geom::Rect r = image->clipbox; + + if (image->pixbuf) { + double pw = gdk_pixbuf_get_width(image->pixbuf); + double ph = gdk_pixbuf_get_height(image->pixbuf); + double vw = pw * image->sx; + double vh = ph * image->sy; + Geom::Point p(image->ox, image->oy); + Geom::Point wh(vw, vh); + Geom::Rect view(p, p+wh); + Geom::OptRect res = Geom::intersect(r, view); + r = res ? *res : r; + } + + return r; +} + /* Utility */ void @@ -316,15 +330,36 @@ nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb) } void -nr_arena_image_set_geometry (NRArenaImage *image, double x, double y, double width, double height) +nr_arena_image_set_clipbox (NRArenaImage *image, Geom::Rect const &clip) +{ + nr_return_if_fail (image != NULL); + nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); + + image->clipbox = clip; + + nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); +} + +void +nr_arena_image_set_origin (NRArenaImage *image, Geom::Point const &origin) +{ + nr_return_if_fail (image != NULL); + nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); + + image->ox = origin[Geom::X]; + image->oy = origin[Geom::Y]; + + nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); +} + +void +nr_arena_image_set_scale (NRArenaImage *image, double sx, double sy) { nr_return_if_fail (image != NULL); nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); - image->x = x; - image->y = y; - image->width = width; - image->height = height; + image->sx = sx; + image->sy = sy; nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-arena-image.h b/src/display/nr-arena-image.h index c2a3b805c..76ff23c29 100644 --- a/src/display/nr-arena-image.h +++ b/src/display/nr-arena-image.h @@ -14,6 +14,7 @@ */ #include +#include <2geom/rect.h> #include "nr-arena-item.h" #include "style.h" @@ -26,14 +27,10 @@ NRType nr_arena_image_get_type (void); struct NRArenaImage : public NRArenaItem { GdkPixbuf *pixbuf; - double x, y; - double width, height; - - Geom::Point c00, c01, c11, c10; // all 4 corners of the image, for outline mode rect - - /* From GRID to PIXELS */ - Geom::Matrix grid2px; - Geom::Matrix px2grid; + Geom::Matrix ctm; + Geom::Rect clipbox; + double ox, oy; + double sx, sy; SPStyle *style; @@ -49,9 +46,10 @@ struct NRArenaImageClass { }; void nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb); -void nr_arena_image_set_geometry (NRArenaImage *image, double x, double y, double width, double height); void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style); - +void nr_arena_image_set_clipbox (NRArenaImage *image, Geom::Rect const &clip); +void nr_arena_image_set_origin (NRArenaImage *image, Geom::Point const &origin); +void nr_arena_image_set_scale (NRArenaImage *image, double sx, double sy); #endif diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 32ba3f021..b383512f5 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -94,6 +95,7 @@ static void sp_image_set_curve(SPImage *image); static GdkPixbuf *sp_image_repr_read_image( time_t& modTime, gchar*& pixPath, const gchar *href, const gchar *absref, const gchar *base ); static GdkPixbuf *sp_image_pixbuf_force_rgba (GdkPixbuf * pixbuf); +static void sp_image_update_arenaitem (SPImage *img, NRArenaImage *ai); static void sp_image_update_canvas_image (SPImage *image); static GdkPixbuf * sp_image_repr_read_dataURI (const gchar * uri_data); static GdkPixbuf * sp_image_repr_read_b64 (const gchar * uri_data); @@ -609,15 +611,9 @@ static void sp_image_init( SPImage *image ) image->width.unset(); image->height.unset(); image->aspect_align = SP_ASPECT_NONE; - - image->trimx = 0; - image->trimy = 0; - image->trimwidth = 0; - image->trimheight = 0; - image->viewx = 0; - image->viewy = 0; - image->viewwidth = 0; - image->viewheight = 0; + image->clipbox = Geom::Rect(); + image->sx = image->sy = 1.0; + image->ox = image->oy = 0.0; image->curve = NULL; @@ -924,13 +920,33 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags) } } } + + if (image->pixbuf) { + /* fixme: We are slightly violating spec here (Lauris) */ + if (!image->width._set) { + image->width.computed = gdk_pixbuf_get_width(image->pixbuf); + } + if (!image->height._set) { + image->height.computed = gdk_pixbuf_get_height(image->pixbuf); + } + } + + Geom::Point p(image->x.computed, image->y.computed); + Geom::Point wh(image->width.computed, image->height.computed); + image->clipbox = Geom::Rect(p, p + wh); + + image->ox = image->x.computed; + image->oy = image->y.computed; + + int pixwidth = gdk_pixbuf_get_width (image->pixbuf); + int pixheight = gdk_pixbuf_get_height (image->pixbuf); + + image->sx = image->width.computed / pixwidth; + image->sy = image->height.computed / pixheight; + // preserveAspectRatio calculate bounds / clipping rectangle -- EAF if (image->pixbuf && (image->aspect_align != SP_ASPECT_NONE)) { - int imagewidth, imageheight; - double x,y; - - imagewidth = gdk_pixbuf_get_width (image->pixbuf); - imageheight = gdk_pixbuf_get_height (image->pixbuf); + double x, y; switch (image->aspect_align) { case SP_ASPECT_XMIN_YMIN: @@ -976,43 +992,19 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags) } if (image->aspect_clip == SP_ASPECT_SLICE) { - image->viewx = image->x.computed; - image->viewy = image->y.computed; - image->viewwidth = image->width.computed; - image->viewheight = image->height.computed; - if ((imagewidth*image->height.computed)>(image->width.computed*imageheight)) { - // Pixels aspect is wider than bounding box - image->trimheight = imageheight; - image->trimwidth = static_cast(static_cast(imageheight) * image->width.computed / image->height.computed); - image->trimy = 0; - image->trimx = static_cast(static_cast(imagewidth - image->trimwidth) * x); - } else { - // Pixels aspect is taller than bounding box - image->trimwidth = imagewidth; - image->trimheight = static_cast(static_cast(imagewidth) * image->height.computed / image->width.computed); - image->trimx = 0; - image->trimy = static_cast(static_cast(imageheight - image->trimheight) * y); - } + double scale = std::max(image->sx, image->sy); + image->sx = scale; + image->sy = scale; } else { - // Otherwise, assume SP_ASPECT_MEET - image->trimx = 0; - image->trimy = 0; - image->trimwidth = imagewidth; - image->trimheight = imageheight; - if ((imagewidth*image->height.computed)>(image->width.computed*imageheight)) { - // Pixels aspect is wider than bounding boz - image->viewwidth = image->width.computed; - image->viewheight = image->viewwidth * imageheight / imagewidth; - image->viewx=image->x.computed; - image->viewy=(image->height.computed - image->viewheight) * y + image->y.computed; - } else { - // Pixels aspect is taller than bounding box - image->viewheight = image->height.computed; - image->viewwidth = image->viewheight * imagewidth / imageheight; - image->viewy=image->y.computed; - image->viewx=(image->width.computed - image->viewwidth) * x + image->x.computed; - } + double scale = std::min(image->sx, image->sy); + image->sx = scale; + image->sy = scale; } + + double vw = pixwidth * image->sx; + double vh = pixheight * image->sy; + image->ox += x * (image->width.computed - vw); + image->oy += y * (image->height.computed - vh); } sp_image_update_canvas_image ((SPImage *) object); } @@ -1100,26 +1092,35 @@ sp_image_print (SPItem *item, SPPrintContext *ctx) int rs = gdk_pixbuf_get_rowstride(image->pixbuf); int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8; - Geom::Matrix t; if (image->aspect_align == SP_ASPECT_NONE) { - /* fixme: (Lauris) */ + Geom::Matrix t; Geom::Translate tp(image->x.computed, image->y.computed); Geom::Scale s(image->width.computed, -image->height.computed); Geom::Translate ti(0.0, -1.0); t = s * tp; t = ti * t; + sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, &t, SP_OBJECT_STYLE (item)); } else { // preserveAspectRatio - Geom::Translate tp(image->viewx, image->viewy); - Geom::Scale s(image->viewwidth, -image->viewheight); + double vw = image->width.computed / image->sx; + double vh = image->height.computed / image->sy; + + int trimwidth = std::min(w, ceil(image->width.computed / vw * w)); + int trimheight = std::min(h, ceil(image->height.computed / vh * h)); + int trimx = std::max(0, floor((image->x.computed - image->ox) / vw * w)); + int trimy = std::max(0, floor((image->y.computed - image->oy) / vh * h)); + + double vx = std::max(image->ox, image->x.computed); + double vy = std::max(image->oy, image->y.computed); + double vcw = std::min(image->width.computed, vw); + double vch = std::min(image->height.computed, vh); + + Geom::Matrix t; + Geom::Translate tp(vx, vy); + Geom::Scale s(vcw, -vch); Geom::Translate ti(0.0, -1.0); t = s * tp; t = ti * t; - } - - if (image->aspect_align == SP_ASPECT_NONE) { - sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, &t, SP_OBJECT_STYLE (item)); - } else { // preserveAspectRatio - sp_print_image_R8G8B8A8_N(ctx, px + image->trimx*pixskip + image->trimy*rs, image->trimwidth, image->trimheight, rs, &t, SP_OBJECT_STYLE(item)); + sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, &t, SP_OBJECT_STYLE(item)); } } } @@ -1154,36 +1155,7 @@ sp_image_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int SPImage * image = SP_IMAGE(item); NRArenaItem *ai = NRArenaImage::create(arena); - if (image->pixbuf) { - nr_arena_image_set_pixbuf(NR_ARENA_IMAGE(ai), image->pixbuf); -#if 0 - int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8; - int rs = gdk_pixbuf_get_rowstride(image->pixbuf); - nr_arena_image_set_style(NR_ARENA_IMAGE(ai), SP_OBJECT_STYLE(SP_OBJECT(item))); - if (image->aspect_align == SP_ASPECT_NONE) { - nr_arena_image_set_pixels(NR_ARENA_IMAGE(ai), - gdk_pixbuf_get_pixels(image->pixbuf), - gdk_pixbuf_get_width(image->pixbuf), - gdk_pixbuf_get_height(image->pixbuf), - rs); - } else { // preserveAspectRatio - nr_arena_image_set_pixels(NR_ARENA_IMAGE(ai), - gdk_pixbuf_get_pixels(image->pixbuf) + image->trimx*pixskip + image->trimy*rs, - image->trimwidth, - image->trimheight, - rs); - } -#endif - } else { - nr_arena_image_set_pixbuf(NR_ARENA_IMAGE(ai), NULL); - } - - // TODO: reenable preserveAspectRatio - //if (image->aspect_align == SP_ASPECT_NONE) { - nr_arena_image_set_geometry(NR_ARENA_IMAGE(ai), image->x.computed, image->y.computed, image->width.computed, image->height.computed); - //} else { // preserveAspectRatio - // nr_arena_image_set_geometry(NR_ARENA_IMAGE(ai), image->viewx, image->viewy, image->viewwidth, image->viewheight); - //} + sp_image_update_arenaitem(image, NR_ARENA_IMAGE(ai)); return ai; } @@ -1295,40 +1267,23 @@ sp_image_pixbuf_force_rgba (GdkPixbuf * pixbuf) /* We assert that realpixbuf is either NULL or identical size to pixbuf */ +static void +sp_image_update_arenaitem (SPImage *image, NRArenaImage *ai) +{ + nr_arena_image_set_style(ai, SP_OBJECT_STYLE(SP_OBJECT(image))); + nr_arena_image_set_pixbuf(ai, image->pixbuf); + nr_arena_image_set_origin(ai, Geom::Point(image->ox, image->oy)); + nr_arena_image_set_scale(ai, image->sx, image->sy); + nr_arena_image_set_clipbox(ai, image->clipbox); +} + static void sp_image_update_canvas_image (SPImage *image) { SPItem *item = SP_ITEM(image); - if (image->pixbuf) { - /* fixme: We are slightly violating spec here (Lauris) */ - if (!image->width._set) { - image->width.computed = gdk_pixbuf_get_width(image->pixbuf); - } - if (!image->height._set) { - image->height.computed = gdk_pixbuf_get_height(image->pixbuf); - } - } - for (SPItemView *v = item->display; v != NULL; v = v->next) { - nr_arena_image_set_style(NR_ARENA_IMAGE(v->arenaitem), SP_OBJECT_STYLE(SP_OBJECT(image))); - // TODO: reenable preserveAspectRatio - //if (image->aspect_align == SP_ASPECT_NONE) { - nr_arena_image_set_pixbuf(NR_ARENA_IMAGE(v->arenaitem), - image->pixbuf); - nr_arena_image_set_geometry(NR_ARENA_IMAGE(v->arenaitem), - image->x.computed, image->y.computed, - image->width.computed, image->height.computed); - /*} else { // preserveAspectRatio - nr_arena_image_set_pixels(NR_ARENA_IMAGE(v->arenaitem), - gdk_pixbuf_get_pixels(image->pixbuf) + image->trimx*pixskip + image->trimy*rs, - image->trimwidth, - image->trimheight, - rs); - nr_arena_image_set_geometry(NR_ARENA_IMAGE(v->arenaitem), - image->viewx, image->viewy, - image->viewwidth, image->viewheight); - }*/ + sp_image_update_arenaitem(image, NR_ARENA_IMAGE(v->arenaitem)); } } diff --git a/src/sp-image.h b/src/sp-image.h index 172cd7118..2d744fb12 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -39,12 +39,16 @@ struct SPImage : public SPItem { SVGLength width; SVGLength height; + Geom::Rect clipbox; + double sx, sy; + double ox, oy; + // Added by EAF /* preserveAspectRatio */ unsigned int aspect_align : 4; unsigned int aspect_clip : 1; - int trimx, trimy, trimwidth, trimheight; - double viewx, viewy, viewwidth, viewheight; + //int trimx, trimy, trimwidth, trimheight; + //double viewx, viewy, viewwidth, viewheight; SPCurve *curve; // This curve is at the image's boundary for snapping -- cgit v1.2.3 From 9df97c14c5c6bf51e1312190c02b8e408aa82ed7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 00:27:38 +0200 Subject: Fix catastrophic memory leak when rendering a pattern (bzr r9508.1.42) --- src/sp-pattern.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 5f0c4aebd..314eada01 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -1067,7 +1067,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, // for each item in pattern, show it on our arena, add to the group, // and connect to the release signal in case the item gets deleted NRArenaItem *cai; - cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_REFERENCE_FLAGS); + cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_append_child (root, cai); } } @@ -1109,15 +1109,11 @@ sp_pattern_create_pattern(SPPaintServer *ps, } // TODO: make sure there are no leaks. - NRPixBlock pb; - nr_pixblock_setup (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, one_tile.x0, one_tile.y0, - one_tile.x1, one_tile.y1, TRUE); NRGC gc(NULL); gc.transform = Geom::identity(); nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); - nr_arena_item_invoke_render (ct, root, &one_tile, &pb, 0); + nr_arena_item_invoke_render (ct, root, &one_tile, NULL, 0); nr_object_unref(arena); - nr_pixblock_release(&pb); if (needs_opacity) { cairo_pop_group_to_source(ct); // pop raw pattern @@ -1125,6 +1121,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, } cairo_pattern_t *cp = cairo_pattern_create_for_surface(temp); + cairo_destroy(ct); cairo_surface_destroy(temp); // Apply transformation to user space. Also compensate for oversampling. -- cgit v1.2.3 From 6e5865f22577b2aea99ec3f78d9b869bc367da28 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 00:39:37 +0200 Subject: Fix pattern viewBox (bzr r9508.1.43) --- src/sp-pattern.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 314eada01..074873d5b 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -1028,6 +1028,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, { SPPattern *pat = SP_PATTERN (ps); Geom::Matrix ps2user; + Geom::Matrix vb2ps = Geom::identity(); bool needs_opacity = (1.0 - opacity) >= 1e-3; bool visible = opacity >= 1e-3; @@ -1039,19 +1040,16 @@ sp_pattern_create_pattern(SPPaintServer *ps, gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0); // FIXME: preserveAspectRatio must be taken into account here too! - Geom::Matrix vb2ps (tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - pattern_viewBox(pat)->x0 * tmp_x, pattern_y(pat) - pattern_viewBox(pat)->y0 * tmp_y); - - ps2user = vb2ps * pattern_patternTransform(pat); - } else { - /* No viewbox, have to parse units */ - ps2user = pattern_patternTransform(pat); - if (pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - /* BBox to user coordinate system */ - Geom::Matrix bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); - ps2user *= bbox2user; - } - ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; + vb2ps = Geom::Matrix(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - pattern_viewBox(pat)->x0 * tmp_x, pattern_y(pat) - pattern_viewBox(pat)->y0 * tmp_y); + } + + ps2user = pattern_patternTransform(pat); + if (!pat->viewBox_set && pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { + /* BBox to user coordinate system */ + Geom::Matrix bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + ps2user *= bbox2user; } + ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; /* Create arena */ NRArena *arena = NRArena::create(); @@ -1110,7 +1108,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, // TODO: make sure there are no leaks. NRGC gc(NULL); - gc.transform = Geom::identity(); + gc.transform = vb2ps;//Geom::identity(); nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); nr_arena_item_invoke_render (ct, root, &one_tile, NULL, 0); nr_object_unref(arena); -- cgit v1.2.3 From 30884b9e814d7baaa2299803e8cb76cf203ca084 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 05:45:58 +0200 Subject: Wholesale cruft removal part 1 (bzr r9508.1.44) --- src/dialogs/clonetiler.cpp | 1 + src/display/Makefile_insert | 6 +- src/display/cairo-utils.cpp | 26 ++ src/display/cairo-utils.h | 2 + src/display/canvas-arena.cpp | 2 +- src/display/nr-3dutils.cpp | 125 +----- src/display/nr-3dutils.h | 16 - src/display/nr-arena-glyphs.cpp | 1 - src/display/nr-arena-image.cpp | 2 - src/display/nr-arena-item.cpp | 213 +--------- src/display/nr-arena-item.h | 5 +- src/display/nr-arena-shape.cpp | 2 - src/display/nr-arena.cpp | 36 -- src/display/nr-arena.h | 2 - src/display/nr-filter-skeleton.cpp | 1 - src/display/nr-filter-slot.h | 4 - src/display/nr-filter-turbulence.cpp | 90 ----- src/display/nr-filter-turbulence.h | 17 +- src/display/nr-filter-units.h | 2 - src/display/nr-filter.cpp | 56 +-- src/display/nr-filter.h | 2 - src/display/pixblock-scaler.cpp | 299 -------------- src/display/pixblock-scaler.h | 40 -- src/display/pixblock-transform.cpp | 279 ------------- src/display/pixblock-transform.h | 35 -- src/display/sp-canvas.cpp | 11 +- src/display/testnr.cpp | 24 -- src/dropper-context.cpp | 1 + src/dyna-draw-context.cpp | 1 + src/extension/internal/cairo-render-context.h | 1 + src/extension/internal/emf-win32-inout.cpp | 4 - src/flood-context.cpp | 7 +- src/helper/pixbuf-ops.cpp | 86 ++-- src/helper/png-write.cpp | 11 +- src/libnr/Makefile_insert | 9 - src/libnr/nr-convex-hull-ops.h | 29 -- src/libnr/nr-convex-hull.h | 59 --- src/libnr/nr-gradient.cpp | 554 -------------------------- src/libnr/nr-gradient.h | 81 ---- src/libnr/nr-matrix-div.cpp | 22 - src/libnr/nr-matrix-div.h | 21 - src/libnr/nr-pixblock-line.cpp | 92 ----- src/libnr/nr-pixblock-line.h | 28 -- src/libnr/nr-pixblock-pixel.cpp | 230 ----------- src/libnr/nr-pixblock-pixel.h | 28 -- src/livarot/PathConversion.cpp | 2 - src/livarot/PathCutting.cpp | 1 - src/livarot/PathSimplify.cpp | 1 - src/livarot/ShapeSweep.cpp | 4 +- src/livarot/path-description.cpp | 2 +- src/marker.cpp | 6 - src/selection-chemistry.cpp | 4 - src/selection.h | 2 - src/sp-gradient-fns.h | 6 +- src/sp-gradient.cpp | 521 +----------------------- src/sp-gradient.h | 6 +- src/sp-item.cpp | 5 - src/sp-paint-server.cpp | 92 ----- src/sp-paint-server.h | 30 +- src/sp-pattern.cpp | 447 +-------------------- src/sp-pattern.h | 1 - src/sp-root.cpp | 5 - src/sp-shape.cpp | 6 +- src/sp-symbol.h | 1 - src/ui/cache/svg_preview_cache.cpp | 1 + src/ui/dialog/color-item.cpp | 93 ++--- src/ui/dialog/color-item.h | 7 +- src/ui/dialog/swatches.cpp | 59 +-- src/widgets/gradient-image.cpp | 143 ++----- src/widgets/gradient-image.h | 2 - src/widgets/icon.cpp | 9 +- 71 files changed, 220 insertions(+), 3799 deletions(-) delete mode 100644 src/display/pixblock-scaler.cpp delete mode 100644 src/display/pixblock-scaler.h delete mode 100644 src/display/pixblock-transform.cpp delete mode 100644 src/display/pixblock-transform.h delete mode 100644 src/display/testnr.cpp delete mode 100644 src/libnr/nr-convex-hull-ops.h delete mode 100644 src/libnr/nr-convex-hull.h delete mode 100644 src/libnr/nr-gradient.cpp delete mode 100644 src/libnr/nr-gradient.h delete mode 100644 src/libnr/nr-matrix-div.cpp delete mode 100644 src/libnr/nr-matrix-div.h delete mode 100644 src/libnr/nr-pixblock-line.cpp delete mode 100644 src/libnr/nr-pixblock-line.h delete mode 100644 src/libnr/nr-pixblock-pixel.cpp delete mode 100644 src/libnr/nr-pixblock-pixel.h (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 55884fe4a..00557ad16 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -46,6 +46,7 @@ #include "../verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "libnr/nr-pixblock.h" #define MIN_ONSCREEN_DISTANCE 50 diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 3e8b6ff91..843f5aa8f 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -91,17 +91,13 @@ ink_common_sources += \ display/nr-light.h \ display/nr-light-types.h \ display/nr-plain-stuff.cpp \ + display/nr-plain-stuff.h \ display/nr-plain-stuff-gdk.cpp \ display/nr-plain-stuff-gdk.h \ - display/nr-plain-stuff.h \ display/nr-style.cpp \ display/nr-style.h \ display/nr-svgfonts.cpp \ display/nr-svgfonts.h \ - display/pixblock-scaler.cpp \ - display/pixblock-scaler.h \ - display/pixblock-transform.cpp \ - display/pixblock-transform.h \ display/rendermode.h \ display/snap-indicator.cpp \ display/snap-indicator.h \ diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 25a1e7988..15fceedae 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -457,6 +457,32 @@ ink_cairo_surface_get_height(cairo_surface_t *surface) return cairo_image_surface_get_height(surface); } +cairo_pattern_t * +ink_cairo_pattern_create_checkerboard() +{ + int const w = 8; + int const h = 8; + + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 2*w, 2*h); + + cairo_t *ct = cairo_create(s); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgb(ct, 0.75, 0.75, 0.75); + cairo_paint(ct); + cairo_set_source_rgb(ct, 0.5, 0.5, 0.5); + cairo_rectangle(ct, 0, 0, w, h); + cairo_rectangle(ct, w, h, w, h); + cairo_fill(ct); + cairo_destroy(ct); + + cairo_pattern_t *p = cairo_pattern_create_for_surface(s); + cairo_pattern_set_extend(p, CAIRO_EXTEND_REPEAT); + cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST); + + cairo_surface_destroy(s); + return p; +} + /** * @brief Convert pixel data from GdkPixbuf format to ARGB. * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 5ac546067..f74ceed14 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -96,6 +96,8 @@ void ink_cairo_surface_blit(cairo_surface_t *src, cairo_surface_t *dest); int ink_cairo_surface_get_width(cairo_surface_t *surface); int ink_cairo_surface_get_height(cairo_surface_t *surface); +cairo_pattern_t *ink_cairo_pattern_create_checkerboard(); + void convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int rs); void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); void convert_pixbuf_normal_to_argb32(GdkPixbuf *); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index db8e1757c..6f85573d1 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -14,7 +14,6 @@ #include -#include "libnr/nr-blit.h" #include "display/display-forward.h" #include "display/sp-canvas-util.h" #include "helper/sp-marshal.h" @@ -22,6 +21,7 @@ #include "display/nr-arena-group.h" #include "display/canvas-arena.h" #include "display/cairo-utils.h" +#include "libnr/nr-pixblock.h" enum { ARENA_EVENT, diff --git a/src/display/nr-3dutils.cpp b/src/display/nr-3dutils.cpp index 89c21940a..1d92d3ec9 100644 --- a/src/display/nr-3dutils.cpp +++ b/src/display/nr-3dutils.cpp @@ -11,134 +11,15 @@ #include -#include "libnr/nr-pixblock.h" #include "display/nr-3dutils.h" #include +#include <2geom/point.h> +#include <2geom/matrix.h> namespace NR { -#define BEGIN 0 // TOP or LEFT -#define MIDDLE 1 -#define END 2 // BOTTOM or RIGHT - -#define START(v) ((v)==BEGIN? 1 : 0) -#define FINISH(v) ((v)==END? 1 : 2) - -signed char K_X[3][3][3][3] = { - //K_X[TOP] - { - //K_X[TOP][LEFT] - { - { 0, 0, 0}, - { 0, -2, 2}, - { 0, -1, 1} - }, - { - { 0, 0, 0}, - {-2, 0, 2}, - {-1, 0, 1} - }, - { - { 0, 0, 0}, - {-2, 2, 0}, - {-1, 1, 0} - } - }, - //K_X[MIDDLE] - { - //K_X[MIDDLE][LEFT] - { - { 0, -1, 1}, - { 0, -2, 2}, - { 0, -1, 1} - }, - { - {-1, 0, 1}, - {-2, 0, 2}, - {-1, 0, 1} - }, - { - {-1, 1, 0}, - {-2, 2, 0}, - {-1, 1, 0} - } - }, - //K_X[BOTTOM] - { - //K_X[BOTTOM][LEFT] - { - { 0, -1, 1}, - { 0, -2, 2}, - { 0, 0, 0} - }, - { - {-1, 0, 1}, - {-2, 0, 2}, - { 0, 0, 0} - }, - { - {-1, 1, 0}, - {-2, 2, 0}, - { 0, 0, 0} - } - } -}; - -//K_Y is obtained by transposing K_X globally and each of its components - -gdouble FACTOR_X[3][3] = { - {2./3, 1./3, 2./3}, - {1./2, 1./4, 1./2}, - {2./3, 1./3, 2./3} -}; - -//FACTOR_Y is obtained by transposing FACTOR_X - -inline -int get_carac(int i, int len, int delta) { - if (i < delta) - return BEGIN; - else if (i > len - 1 - delta) - return END; - else - return MIDDLE; -} - -//assumes in is RGBA -//should be made more resistant -void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j, int dx, int dy) { - int w = in->area.x1 - in->area.x0; - int h = in->area.y1 - in->area.y0; - int k, l, alpha_idx, alpha_idx_y; - int x_carac, y_carac; - gdouble alpha; - gdouble accu_x; - gdouble accu_y; - unsigned char *data = NR_PIXBLOCK_PX (in); - g_assert(NR_PIXBLOCK_BPP(in) == 4); - x_carac = get_carac(j, w, dx); //LEFT, MIDDLE or RIGHT - y_carac = get_carac(i, h, dy); //TOP, MIDDLE or BOTTOM - alpha_idx = 4*(i*w + j); - accu_x = 0; - accu_y = 0; - for (k = START(y_carac); k <= FINISH(y_carac); k++) { - alpha_idx_y = alpha_idx + 4*(k-1)*dy*w; - for (l = START(x_carac); l <= FINISH(x_carac); l++) { - alpha = (data + alpha_idx_y + 4*dx*(l-1))[3]; - accu_x += K_X[y_carac][x_carac][k][l] * alpha; - accu_y += K_X[x_carac][y_carac][l][k] * alpha; - } - } - ss /= 255.0; // Correction for scale of pixel values - N[X_3D] = -ss * FACTOR_X[y_carac][x_carac] * accu_x / dx; - N[Y_3D] = -ss * FACTOR_X[x_carac][y_carac] * accu_y / dy; - N[Z_3D] = 1.0; - normalize_vector(N); - //std::cout << "(" << N[X_3D] << ", " << N[Y_3D] << ", " << N[Z_3D] << ")" << std::endl; -} - void convert_coord(gdouble &x, gdouble &y, gdouble &z, Geom::Matrix const &trans) { - Point p = Point(x, y); + Geom::Point p = Geom::Point(x, y); p *= trans; x = p[Geom::X]; y = p[Geom::Y]; diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h index 42df36c82..9a198a73d 100644 --- a/src/display/nr-3dutils.h +++ b/src/display/nr-3dutils.h @@ -80,22 +80,6 @@ gdouble scalar_product(const Fvector &a, const Fvector &b); */ void normalized_sum(Fvector &r, const Fvector &a, const Fvector &b); -/** - * Computes the unit suface normal vector of surface given by "in" at (i, j) - * and store it into N. "in" is a (NRPixBlock *) in mode RGBA but only the alpha - * channel is considered as a bump map. ss is the altitude when for the alpha - * value 255. dx and dy are the deltas used to compute in our discrete setting - * - * \param N a reference to a Fvector in which we store the unit surface normal - * \param ss the surface scale - * \param in a NRPixBlock * whose alpha channel codes the surface - * \param i the x coordinate of the point at which we compute the normal - * \param j the y coordinate of the point at which we compute the normal - * \param dx the delta used in the x coordinate - * \param dy the delta used in the y coordinate - */ -void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j, int dx, int dy); - /** * Applies the transformation matrix to (x, y, z). This function assumes that * trans[0] = trans[3]. x and y are transformed according to trans, z is diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index faf10bd38..d35489d70 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -16,7 +16,6 @@ #ifdef HAVE_CONFIG_H # include #endif -#include "libnr/nr-blit.h" #include "libnr/nr-convert2geom.h" #include <2geom/matrix.h> #include "style.h" diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 066133dde..5617bb084 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -12,9 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/transforms.h> -#include #include "../preferences.h" #include "nr-arena-image.h" #include "style.h" diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index e7cf08722..0bdbd12ae 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -19,8 +19,6 @@ #include #include -#include -#include #include "display/cairo-utils.h" #include "nr-arena.h" #include "nr-arena-item.h" @@ -317,7 +315,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); bool filter = (item->arena->rendermode != Inkscape::RENDERMODE_OUTLINE && item->arena->rendermode != Inkscape::RENDERMODE_NO_FILTERS); - bool print_colors = (item->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); + //bool print_colors = (item->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), @@ -375,193 +373,6 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area return item->state | NR_ARENA_ITEM_STATE_RENDER; } -#if 0 - NRPixBlock *dpb = pb; - - /* Determine, whether we need temporary buffer */ -/* if (item->clip || item->mask - || ((item->opacity != 255) && !item->render_opacity) - || (item->filter && filter) || item->background_new - || (item->parent && item->parent->background_pb))*/ - if (0) { - - /* Setup and render item buffer */ - NRPixBlock ipb; - nr_pixblock_setup_fast (&ipb, NR_PIXBLOCK_MODE_R8G8B8A8P, - carea.x0, carea.y0, carea.x1, carea.y1, - TRUE); - - // if memory allocation failed, abort render - if (ipb.size != NR_PIXBLOCK_SIZE_TINY && ipb.data.px == NULL) { - nr_pixblock_release (&ipb); - return (item->state); - } - - /* If background access is used, save the pixblock address. - * This address is set to NULL at the end of this block */ - if (item->background_new || - (item->parent && item->parent->background_pb)) { - item->background_pb = &ipb; - } - - ipb.visible_area = pb->visible_area; - if (item->filter && filter) { - item->filter->area_enlarge (ipb.visible_area, item); - } - - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, &ipb, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - nr_pixblock_release (&ipb); - if (dpb != pb) - nr_pixblock_release (dpb); - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - ipb.empty = FALSE; - - /* Run filtering, if a filter is set for this object */ - if (item->filter && filter) { - item->filter->render (item, &ipb); - } - - if (item->clip || item->mask) { - /* Setup mask pixblock */ - NRPixBlock mpb; - nr_pixblock_setup_fast (&mpb, NR_PIXBLOCK_MODE_A8, carea.x0, - carea.y0, carea.x1, carea.y1, TRUE); - - if (mpb.data.px != NULL) { // if memory allocation was successful - - mpb.visible_area = pb->visible_area; - /* Do clip if needed */ - if (item->clip) { - state = nr_arena_item_invoke_clip (item->clip, &carea, &mpb); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - nr_pixblock_release (&mpb); - nr_pixblock_release (&ipb); - if (dpb != pb) - nr_pixblock_release (dpb); - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - mpb.empty = FALSE; - } - /* Do mask if needed */ - if (item->mask) { - NRPixBlock tpb; - /* Set up yet another temporary pixblock */ - nr_pixblock_setup_fast (&tpb, NR_PIXBLOCK_MODE_R8G8B8A8N, - carea.x0, carea.y0, carea.x1, - carea.y1, TRUE); - - if (tpb.data.px != NULL) { // if memory allocation was successful - - tpb.visible_area = pb->visible_area; - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, &carea, &tpb, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - nr_pixblock_release (&tpb); - nr_pixblock_release (&mpb); - nr_pixblock_release (&ipb); - if (dpb != pb) - nr_pixblock_release (dpb); - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - /* Composite with clip */ - if (item->clip) { - int x, y; - for (y = carea.y0; y < carea.y1; y++) { - unsigned char *s, *d; - s = NR_PIXBLOCK_PX (&tpb) + (y - - carea.y0) * tpb.rs; - d = NR_PIXBLOCK_PX (&mpb) + (y - - carea.y0) * mpb.rs; - for (x = carea.x0; x < carea.x1; x++) { - unsigned int m; - m = NR_PREMUL_112 (s[0] + s[1] + s[2], s[3]); - d[0] = - FAST_DIV_ROUND < 3 * 255 * 255 > - (NR_PREMUL_123 (d[0], m)); - s += 4; - d += 1; - } - } - } else { - int x, y; - for (y = carea.y0; y < carea.y1; y++) { - unsigned char *s, *d; - s = NR_PIXBLOCK_PX (&tpb) + (y - - carea.y0) * tpb.rs; - d = NR_PIXBLOCK_PX (&mpb) + (y - - carea.y0) * mpb.rs; - for (x = carea.x0; x < carea.x1; x++) { - unsigned int m; - m = NR_PREMUL_112 (s[0] + s[1] + s[2], s[3]); - d[0] = FAST_DIV_ROUND < 3 * 255 > (m); - s += 4; - d += 1; - } - } - mpb.empty = FALSE; - } - } - nr_pixblock_release (&tpb); - } - /* Multiply with opacity if needed */ - if ((item->opacity != 255) && !item->render_opacity - ) { - int x, y; - unsigned int a; - a = item->opacity; - for (y = carea.y0; y < carea.y1; y++) { - unsigned char *d; - d = NR_PIXBLOCK_PX (&mpb) + (y - carea.y0) * mpb.rs; - for (x = carea.x0; x < carea.x1; x++) { - d[0] = NR_PREMUL_111 (d[0], a); - d += 1; - } - } - } - /* Compose rendering pixblock int destination */ - nr_blit_pixblock_pixblock_mask (dpb, &ipb, &mpb); - } - nr_pixblock_release (&mpb); - } else { - if (item->render_opacity) { // opacity was already rendered in, just copy to dpb here - nr_blit_pixblock_pixblock(dpb, &ipb); - } else { // copy while multiplying by opacity - nr_blit_pixblock_pixblock_alpha (dpb, &ipb, item->opacity); - } - } - nr_pixblock_release (&ipb); - dpb->empty = FALSE; - /* This pointer wouldn't be valid outside this block, so clear it */ - item->background_pb = NULL; - } else { - /* Just render */ - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, const_cast(area), dpb, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - if (dpb != pb) - nr_pixblock_release (dpb); - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - dpb->empty = FALSE; - } - - if (dpb != pb) { - /* Have to blit from cache */ - nr_blit_pixblock_pixblock (pb, dpb); - nr_pixblock_release (dpb); - pb->empty = FALSE; - item->state |= NR_ARENA_ITEM_STATE_IMAGE; - } -#endif - using namespace Inkscape; // clipping and masks @@ -947,27 +758,7 @@ nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect &bbox) NRPixBlock * nr_arena_item_get_background (NRArenaItem const *item, int depth) { - NRPixBlock *pb; - if (!item->background_pb) - return NULL; - if (item->background_new) { - pb = new NRPixBlock (); - nr_pixblock_setup_fast (pb, item->background_pb->mode, - item->background_pb->area.x0, - item->background_pb->area.y0, - item->background_pb->area.x1, - item->background_pb->area.y1, true); - if (pb->size != NR_PIXBLOCK_SIZE_TINY && pb->data.px == NULL) // allocation failed - return NULL; - } else if (item->parent) { - pb = nr_arena_item_get_background (item->parent, depth + 1); - } else - return NULL; - - if (depth > 0) - nr_blit_pixblock_pixblock (pb, item->background_pb); - - return pb; + return NULL; } /* Helpers */ diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 447307535..752390776 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -15,9 +15,8 @@ #include #include <2geom/matrix.h> -#include -#include -#include +#include "libnr/nr-rect-l.h" +#include "libnr/nr-object.h" #include "gc-soft-ptr.h" #include "nr-arena-forward.h" diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index b51f3a9cf..0f86db041 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -29,9 +29,7 @@ #include "display/nr-filter.h" #include "helper/geom-curves.h" #include "helper/geom.h" -#include "libnr/nr-blit.h" #include "libnr/nr-convert2geom.h" -#include "libnr/nr-pixops.h" #include "preferences.h" #include "sp-filter.h" #include "sp-filter-reference.h" diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index 33870a118..1339786bd 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -16,7 +16,6 @@ #include "nr-arena.h" #include "nr-filter-gaussian.h" #include "nr-filter-types.h" -#include #include "preferences.h" #include "color.h" @@ -131,41 +130,6 @@ nr_arena_request_render_rect (NRArena *arena, NRRectL *area) } } -void -nr_arena_render_paintserver_fill (NRPixBlock *pb, NRRectL *area, SPPainter *painter, float opacity, NRPixBlock *mask) -{ - NRPixBlock cb, cb_opa; - nr_pixblock_setup_fast (&cb, NR_PIXBLOCK_MODE_R8G8B8A8N, area->x0, area->y0, area->x1, area->y1, TRUE); - nr_pixblock_setup_fast (&cb_opa, NR_PIXBLOCK_MODE_R8G8B8A8N, area->x0, area->y0, area->x1, area->y1, TRUE); - - // if memory allocation failed, abort - if ((cb.size != NR_PIXBLOCK_SIZE_TINY && cb.data.px == NULL) || (cb_opa.size != NR_PIXBLOCK_SIZE_TINY && cb_opa.data.px == NULL)) { - return; - } - - cb.visible_area = pb->visible_area; - cb_opa.visible_area = pb->visible_area; - - /* Need separate gradient buffer (lauris)*/ - // do the filling - painter->fill (painter, &cb); - cb.empty = FALSE; - - // do the fill-opacity and mask composite - if (opacity < 1.0) { - nr_blit_pixblock_pixblock_alpha (&cb_opa, &cb, (int) floor (255 * opacity)); - cb_opa.empty = FALSE; - nr_blit_pixblock_pixblock_mask (pb, &cb_opa, mask); - } else { - nr_blit_pixblock_pixblock_mask (pb, &cb, mask); - } - - pb->empty = FALSE; - - nr_pixblock_release (&cb); - nr_pixblock_release (&cb_opa); -} - /** set arena to offscreen mode rendering will be exact diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index d2f9dc246..f4d86a2e6 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -62,8 +62,6 @@ void nr_arena_request_update (NRArena *arena, NRArenaItem *item); void nr_arena_request_render_rect (NRArena *arena, NRRectL *area); void nr_arena_set_renderoffscreen (NRArena *arena); -void nr_arena_render_paintserver_fill (NRPixBlock *pb, NRRectL *area, SPPainter *painter, float opacity, NRPixBlock *mask); - void nr_arena_separate_color_plates(guint32* rgba); #endif diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp index bdb993ed9..d5adedad9 100644 --- a/src/display/nr-filter-skeleton.cpp +++ b/src/display/nr-filter-skeleton.cpp @@ -24,7 +24,6 @@ #include "display/nr-filter-skeleton.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-pixblock.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 7b32f1210..93c8e2fe2 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -16,7 +16,6 @@ #include #include -#include "libnr/nr-pixblock.h" #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" @@ -41,7 +40,6 @@ public: * NR_FILTER_FILLPAINT, NR_FILTER_SOURCEPAINT. */ cairo_surface_t *getcairo(int slot); - NRPixBlock *get(int slot) { return NULL; } /** Sets or re-sets the pixblock associated with given slot. * If there was a pixblock already assigned with this slot, @@ -49,8 +47,6 @@ public: */ void set(int slot, cairo_surface_t *s); - void set(int, NRPixBlock*){} - cairo_surface_t *get_result(int slot_nr); /** Returns the number of slots in use. */ diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index d60c4f617..54b5cf7c6 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -24,7 +24,6 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "libnr/nr-rect-l.h" -#include "libnr/nr-blit.h" #include namespace Inkscape { @@ -301,7 +300,6 @@ FilterTurbulence::FilterTurbulence() , seed(0) , updated(false) , updated_area(NR::IPoint(), NR::IPoint()) - , pix(NULL) , fTileWidth(10) //guessed , fTileHeight(10) //guessed , fTileX(1) //guessed @@ -316,11 +314,6 @@ FilterPrimitive * FilterTurbulence::create() { FilterTurbulence::~FilterTurbulence() { delete gen; - - if (pix) { - nr_pixblock_release(pix); - delete pix; - } } void FilterTurbulence::set_baseFrequency(int axis, double freq){ @@ -352,89 +345,6 @@ void FilterTurbulence::set_type(FilterTurbulenceType t){ void FilterTurbulence::set_updated(bool u){ } -void FilterTurbulence::render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units) { -#if 0 - const int bbox_x0 = full_area.min()[NR::X]; - const int bbox_y0 = full_area.min()[NR::Y]; - const int bbox_x1 = full_area.max()[NR::X]; - const int bbox_y1 = full_area.max()[NR::Y]; - - Geom::Matrix unit_trans = units.get_matrix_primitiveunits2pb().inverse(); - - double point[2]; - - unsigned char *pb = NR_PIXBLOCK_PX(pix); - - if (type==TURBULENCE_TURBULENCE){ - for (int y = std::max(bbox_y0, pix->area.y0); y < std::min(bbox_y1, pix->area.y1); y++){ - int out_line = (y - pix->area.y0) * pix->rs; - point[1] = y * unit_trans[3] + unit_trans[5]; - for (int x = std::max(bbox_x0, pix->area.x0); x < std::min(bbox_x1, pix->area.x1); x++){ - int out_pos = out_line + 4 * (x - pix->area.x0); - point[0] = x * unit_trans[0] + unit_trans[4]; - pb[out_pos] = CLAMP_D_TO_U8( turbulence(0,point)*255 ); // CLAMP includes rounding! - pb[out_pos + 1] = CLAMP_D_TO_U8( turbulence(1,point)*255 ); - pb[out_pos + 2] = CLAMP_D_TO_U8( turbulence(2,point)*255 ); - pb[out_pos + 3] = CLAMP_D_TO_U8( turbulence(3,point)*255 ); - } - } - } else { - for (int y = std::max(bbox_y0, pix->area.y0); y < std::min(bbox_y1, pix->area.y1); y++){ - int out_line = (y - pix->area.y0) * pix->rs; - point[1] = y * unit_trans[3] + unit_trans[5]; - for (int x = std::max(bbox_x0, pix->area.x0); x < std::min(bbox_x1, pix->area.x1); x++){ - int out_pos = out_line + 4 * (x - pix->area.x0); - point[0] = x * unit_trans[0] + unit_trans[4]; - pb[out_pos] = CLAMP_D_TO_U8( ((turbulence(0,point)*255) +255)/2 ); - pb[out_pos + 1] = CLAMP_D_TO_U8( ((turbulence(1,point)*255)+255)/2 ); - pb[out_pos + 2] = CLAMP_D_TO_U8( ((turbulence(2,point)*255) +255)/2 ); - pb[out_pos + 3] = CLAMP_D_TO_U8( ((turbulence(3,point)*255) +255)/2 ); - } - } - } - - pix->empty = FALSE; -#endif -} - -void FilterTurbulence::update_pixbuffer(NR::IRect &area, FilterUnits const &units) { - int bbox_x0 = area.min()[NR::X]; - int bbox_y0 = area.min()[NR::Y]; - int bbox_x1 = area.max()[NR::X]; - int bbox_y1 = area.max()[NR::Y]; - - //TurbulenceInit((long)seed); - - if (!pix){ - pix = new NRPixBlock; - nr_pixblock_setup_fast(pix, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox_x0, bbox_y0, bbox_x1, bbox_y1, true); - } - else if (bbox_x0 != pix->area.x0 || bbox_y0 != pix->area.y0 || - bbox_x1 != pix->area.x1 || bbox_y1 != pix->area.y1) - { - /* TODO: release-setup cycle not actually needed, if pixblock - * width and height don't change */ - nr_pixblock_release(pix); - nr_pixblock_setup_fast(pix, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox_x0, bbox_y0, bbox_x1, bbox_y1, true); - } - - /* This limits pre-rendered turbulence to two megapixels. This is - * arbitary limit and could be something other, too. - * If bigger area is needed, visible area is rendered on demand. */ - if (!pix || (pix->size != NR_PIXBLOCK_SIZE_TINY && pix->data.px == NULL) || - ((bbox_x1 - bbox_x0) * (bbox_y1 - bbox_y0) > 2*1024*1024)) { - pix_data = NULL; - return; - } - - render_area(pix, area, units); - - pix_data = NR_PIXBLOCK_PX(pix); - - updated=true; - updated_area = area; -} - struct Turbulence { Turbulence(TurbulenceGenerator const &gen, Geom::Matrix const &trans, int x0, int y0) : _gen(gen) diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index b2bc3a185..fca6ebde3 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -36,9 +36,6 @@ enum FilterTurbulenceType { TURBULENCE_ENDTYPE }; -struct StitchInfo; - -//#define BSize 0x100 class TurbulenceGenerator; class FilterTurbulence : public FilterPrimitive { @@ -48,8 +45,6 @@ public: virtual ~FilterTurbulence(); virtual void render_cairo(FilterSlot &slot); - void update_pixbuffer(NR::IRect &area, FilterUnits const &units); - void render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units); void set_baseFrequency(int axis, double freq); void set_numOctaves(int num); @@ -62,13 +57,7 @@ private: TurbulenceGenerator *gen; void turbulenceInit(long seed); -/* - long Turbulence_setup_seed(long lSeed); - long TurbulenceRandom(long lSeed); - void TurbulenceInit(long lSeed); - double TurbulenceNoise2(int nColorChannel, double vec[2], StitchInfo *pStitchInfo); - double turbulence(int nColorChannel, Geom::Point const &point); -*/ + double XbaseFrequency, YbaseFrequency; int numOctaves; double seed; @@ -76,12 +65,8 @@ private: FilterTurbulenceType type; bool updated; NR::IRect updated_area; - NRPixBlock *pix; unsigned char *pix_data; - //int uLatticeSelector[BSize + BSize + 2]; - //double fGradient[4][BSize + BSize + 2][2]; - double fTileWidth; double fTileHeight; diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index dcf7e5838..12f0ca2ca 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -13,8 +13,6 @@ */ #include "sp-filter-units.h" -#include "libnr/nr-matrix.h" -#include "libnr/nr-rect.h" #include "libnr/nr-rect-l.h" #include <2geom/matrix.h> #include <2geom/rect.h> diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 8c638415d..8273cc591 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -42,8 +42,6 @@ #include "display/nr-arena.h" #include "display/nr-arena-item.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-blit.h" #include <2geom/matrix.h> #include <2geom/rect.h> #include "svg/svg-length.h" @@ -211,52 +209,6 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); cairo_surface_destroy(result); - //slot.set_units(units); - - /*cairo_surface_t *in = cairo_surface_create_similar( - cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, - area->x1 - area->x0, area->y1 - area->y0); - cairo_t *inct = cairo_create(in); - cairo_translate(inct, -area->x0, -area->y0); - cairo_set_source_surface(inct, cairo_get_target(ct), 0, 0); - cairo_paint(inct); - slot.set(NR_FILTER_SOURCEGRAPHIC, in); - cairo_destroy(inct); - cairo_surface_destroy(in);*/ - - /*NRPixBlock *in = new NRPixBlock; - nr_pixblock_setup_fast(in, pb->mode, pb->area.x0, pb->area.y0, - pb->area.x1, pb->area.y1, true); - if (in->size != NR_PIXBLOCK_SIZE_TINY && in->data.px == NULL) { - g_warning("Inkscape::Filters::Filter::render: failed to reserve temporary buffer"); - return 0; - } - nr_blit_pixblock_pixblock(in, pb); - in->empty = FALSE; - slot.set(NR_FILTER_SOURCEGRAPHIC, in);*/ - - // Check that we are rendering a non-empty area - /*in = slot.get(NR_FILTER_SOURCEGRAPHIC); - if (in->area.x1 - in->area.x0 <= 0 || in->area.y1 - in->area.y0 <= 0) { - if (in->area.x1 - in->area.x0 < 0 || in->area.y1 - in->area.y0 < 0) { - g_warning("Inkscape::Filters::Filter::render: negative area! (%d, %d) (%d, %d)", - in->area.x0, in->area.y0, in->area.x1, in->area.y1); - } - return 0; - } - in = NULL; // in is now handled by FilterSlot, we should not touch it - */ - - /*for (int i = 0 ; i < _primitive_count ; i++) { - _primitive[i]->render(slot, units); - }*/ - - //slot.get_final(_output_slot, ct, area); - - // Take note of the amount of used image slots - // -> next time this filter is rendered, we can reserve enough slots - // immediately - //_slot_count = slot.get_slot_count(); return 0; } @@ -327,10 +279,10 @@ void Filter::bbox_enlarge(NRRectL &bbox) { Geom::Rect enlarged = filter_effect_area(tmp_bbox); - bbox.x0 = (NR::ICoord)enlarged.min()[X]; - bbox.y0 = (NR::ICoord)enlarged.min()[Y]; - bbox.x1 = (NR::ICoord)enlarged.max()[X]; - bbox.y1 = (NR::ICoord)enlarged.max()[Y]; + bbox.x0 = (NR::ICoord) floor(enlarged.min()[X]); + bbox.y0 = (NR::ICoord) floor(enlarged.min()[Y]); + bbox.x1 = (NR::ICoord) ceil(enlarged.max()[X]); + bbox.y1 = (NR::ICoord) ceil(enlarged.max()[Y]); } Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index cd805043c..4db1ec988 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -16,8 +16,6 @@ #include #include "display/nr-filter-primitive.h" #include "display/nr-filter-types.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-matrix.h" #include "libnr/nr-rect.h" #include "svg/svg-length.h" #include "sp-filter-units.h" diff --git a/src/display/pixblock-scaler.cpp b/src/display/pixblock-scaler.cpp deleted file mode 100644 index 1f2b1db3f..000000000 --- a/src/display/pixblock-scaler.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#define __NR_PIXBLOCK_SCALER_CPP__ - -/* - * Functions for blitting pixblocks using scaling - * - * Author: - * Niko Kiirala - * - * Copyright (C) 2006,2009 Niko Kiirala - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include -#if defined (SOLARIS) && (SOLARIS == 8) -#include "round.h" -using Inkscape::round; -#endif -using std::floor; - -#include "display/nr-filter-utils.h" -#include "libnr/nr-pixblock.h" -#include "libnr/nr-blit.h" -#include <2geom/forward.h> - -namespace NR { - -struct RGBA { - double r, g, b, a; -}; - -/** Calculates cubically interpolated value of the four given pixel values. - * The pixel values should be from four adjacent pixels in source image or - * four adjacent interpolated values. len should be the x- or y-coordinate - * (depending on interpolation direction) of the center of the target pixel - * in source image coordinates. - */ -__attribute__ ((const)) -inline static double sample(double const a, double const b, - double const c, double const d, - double const len) -{ - double lena = 1.5 + (len - round(len)); - double lenb = 0.5 + (len - round(len)); - double lenc = 0.5 - (len - round(len)); - double lend = 1.5 - (len - round(len)); - double const f = -0.5; // corresponds to cubic Hermite spline - double sum = 0; - sum += ((((f * lena) - 5.0 * f) * lena + 8.0 * f) * lena - 4 * f) * a; - sum += (((f + 2.0) * lenb - (f + 3.0)) * lenb * lenb + 1.0) * b; - sum += (((f + 2.0) * lenc - (f + 3.0)) * lenc * lenc + 1.0) * c; - sum += ((((f * lend) - 5.0 * f) * lend + 8.0 * f) * lend - 4 * f) * d; - - return sum; -} - -/** - * Sanity check function for indexing pixblocks. - * Catches reading and writing outside the pixblock area. - * When enabled, decreases filter rendering speed massively. - */ -inline static void _check_index(NRPixBlock const * const pb, int const location, int const line) -{ - if(false) { - int max_loc = pb->rs * (pb->area.y1 - pb->area.y0); - if (location < 0 || (location + 4) > max_loc) - g_warning("Location %d out of bounds (0 ... %d) at line %d", location, max_loc, line); - } -} - -static void scale_bicubic_rgba(NRPixBlock *to, NRPixBlock *from, - Geom::Matrix const &trans) -{ - if (NR_PIXBLOCK_BPP(from) != 4 || NR_PIXBLOCK_BPP(to) != 4) { - g_warning("A non-32-bpp image passed to scale_bicubic_rgba: scaling aborted."); - return; - } - - bool free_from_on_exit = false; - if (from->mode != to->mode){ - NRPixBlock *o_from = from; - from = new NRPixBlock; - nr_pixblock_setup_fast(from, to->mode, o_from->area.x0, o_from->area.y0, o_from->area.x1, o_from->area.y1, false); - nr_blit_pixblock_pixblock(from, o_from); - free_from_on_exit = true; - } - - // Precalculate sizes of source and destination pixblocks - int from_width = from->area.x1 - from->area.x0; - int from_height = from->area.y1 - from->area.y0; - int to_width = to->area.x1 - to->area.x0; - int to_height = to->area.y1 - to->area.y0; - - // from_step: when advancing one pixel in destination image, - // how much we should advance in source image - double from_stepx = 1.0 / trans[0]; - double from_stepy = 1.0 / trans[3]; - double from_diffx = from_stepx * (-trans[4]); - double from_diffy = from_stepy * (-trans[5]); - from_diffx = (to->area.x0 * from_stepx + from_diffx) - from->area.x0; - from_diffy = (to->area.y0 * from_stepy + from_diffy) - from->area.y0; - - // Loop through every pixel of destination image, a line at a time - for (int to_y = 0 ; to_y < to_height ; to_y++) { - double from_y = (to_y + 0.5) * from_stepy + from_diffy; - // Pre-calculate beginning of the four horizontal lines, from - // which we should read - int from_line[4]; - for (int i = 0 ; i < 4 ; i++) { - int fy_line = (int)round(from_y) + i - 2; - if (fy_line >= 0) { - if (fy_line < from_height) { - from_line[i] = fy_line * from->rs; - } else { - from_line[i] = (from_height - 1) * from->rs; - } - } else { - from_line[i] = 0; - } - } - // Loop through this horizontal line in destination image - // For every pixel, calculate the color of pixel with - // bicubic interpolation and set the pixel value in destination image - for (int to_x = 0 ; to_x < to_width ; to_x++) { - double from_x = (to_x + 0.5) * from_stepx + from_diffx; - RGBA line[4]; - for (int i = 0 ; i < 4 ; i++) { - int k = (int)round(from_x) + i - 2; - if (k < 0) k = 0; - if (k >= from_width) k = from_width - 1; - k *= 4; - _check_index(from, from_line[0] + k, __LINE__); - _check_index(from, from_line[1] + k, __LINE__); - _check_index(from, from_line[2] + k, __LINE__); - _check_index(from, from_line[3] + k, __LINE__); - line[i].r = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k], - NR_PIXBLOCK_PX(from)[from_line[1] + k], - NR_PIXBLOCK_PX(from)[from_line[2] + k], - NR_PIXBLOCK_PX(from)[from_line[3] + k], - from_y); - line[i].g = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k + 1], - NR_PIXBLOCK_PX(from)[from_line[1] + k + 1], - NR_PIXBLOCK_PX(from)[from_line[2] + k + 1], - NR_PIXBLOCK_PX(from)[from_line[3] + k + 1], - from_y); - line[i].b = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k + 2], - NR_PIXBLOCK_PX(from)[from_line[1] + k + 2], - NR_PIXBLOCK_PX(from)[from_line[2] + k + 2], - NR_PIXBLOCK_PX(from)[from_line[3] + k + 2], - from_y); - line[i].a = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k + 3], - NR_PIXBLOCK_PX(from)[from_line[1] + k + 3], - NR_PIXBLOCK_PX(from)[from_line[2] + k + 3], - NR_PIXBLOCK_PX(from)[from_line[3] + k + 3], - from_y); - } - RGBA result; - result.r = round(sample(line[0].r, line[1].r, line[2].r, line[3].r, - from_x)); - result.g = round(sample(line[0].g, line[1].g, line[2].g, line[3].g, - from_x)); - result.b = round(sample(line[0].b, line[1].b, line[2].b, line[3].b, - from_x)); - result.a = round(sample(line[0].a, line[1].a, line[2].a, line[3].a, - from_x)); - - _check_index(to, to_y * to->rs + to_x * 4, __LINE__); - - using Inkscape::Filters::clamp; - using Inkscape::Filters::clamp_alpha; - if (to->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* Clamp the colour channels to range from 0 to result.a to - * make sure, we don't exceed 100% per colour channel with - * images that have premultiplied alpha */ - - int const alpha = clamp((int)result.a); - - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4] - = clamp_alpha((int)result.r, alpha); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 1] - = clamp_alpha((int)result.g, alpha); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 2] - = clamp_alpha((int)result.b, alpha); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 3] = alpha; - } else { - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4] - = clamp((int)result.r); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 1] - = clamp((int)result.g); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 2] - = clamp((int)result.b); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 3] - = clamp((int)result.a); - } - } - } - if (free_from_on_exit) { - nr_pixblock_release(from); - delete from; - } - -} - -void scale_bicubic_alpha(NRPixBlock *to, NRPixBlock *from, - Geom::Matrix const &trans) -{ - if (NR_PIXBLOCK_BPP(from) != 1 || NR_PIXBLOCK_BPP(to) != 1) { - g_warning("A non-8-bpp image passed to scale_bicubic_alpha: scaling aborted."); - return; - } - - // Precalculate sizes of source and destination pixblocks - int from_width = from->area.x1 - from->area.x0; - int from_height = from->area.y1 - from->area.y0; - int to_width = to->area.x1 - to->area.x0; - int to_height = to->area.y1 - to->area.y0; - - // from_step: when advancing one pixel in destination image, - // how much we should advance in source image - double from_stepx = 1.0 / trans[0]; - double from_stepy = 1.0 / trans[3]; - double from_diffx = from_stepx * (-trans[4]); - double from_diffy = from_stepy * (-trans[5]); - from_diffx = (to->area.x0 * from_stepx + from_diffx) - from->area.x0; - from_diffy = (to->area.y0 * from_stepy + from_diffy) - from->area.y0; - - // Loop through every pixel of destination image, a line at a time - for (int to_y = 0 ; to_y < to_height ; to_y++) { - double from_y = (to_y + 0.5) * from_stepy - from_diffy; - // Pre-calculate beginning of the four horizontal lines, from - // which we should read - int from_line[4]; - for (int i = 0 ; i < 4 ; i++) { - int fy_line = (int)round(from_y) + i - 2; - if (fy_line >= 0) { - if (fy_line < from_height) { - from_line[i] = fy_line * from->rs; - } else { - from_line[i] = (from_height - 1) * from->rs; - } - } else { - from_line[i] = 0; - } - } - // Loop through this horizontal line in destination image - // For every pixel, calculate the color of pixel with - // bicubic interpolation and set the pixel value in destination image - for (int to_x = 0 ; to_x < to_width ; to_x++) { - double from_x = (to_x + 0.5) * from_stepx - from_diffx; - double line[4]; - for (int i = 0 ; i < 4 ; i++) { - int k = (int)round(from_x) + i - 2; - if (k < 0) k = 0; - if (k >= from_width) k = from_width - 1; - _check_index(from, from_line[0] + k, __LINE__); - _check_index(from, from_line[1] + k, __LINE__); - _check_index(from, from_line[2] + k, __LINE__); - _check_index(from, from_line[3] + k, __LINE__); - line[i] = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k], - NR_PIXBLOCK_PX(from)[from_line[1] + k], - NR_PIXBLOCK_PX(from)[from_line[2] + k], - NR_PIXBLOCK_PX(from)[from_line[3] + k], - from_y); - } - int result; - result = (int)round(sample(line[0], line[1], line[2], line[3], - from_x)); - - _check_index(to, to_y * to->rs + to_x, __LINE__); - - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x] - = Inkscape::Filters::clamp(result); - } - } -} - -void scale_bicubic(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &trans) -{ - if (NR_PIXBLOCK_BPP(to) == 4 && NR_PIXBLOCK_BPP(from) == 4) { - scale_bicubic_rgba(to, from, trans); - } else if (NR_PIXBLOCK_BPP(to) == 1 && NR_PIXBLOCK_BPP(from) == 1) { - scale_bicubic_alpha(to, from, trans); - } else { - g_warning("NR::scale_bicubic: unsupported bitdepths for scaling: to %d, from %d", NR_PIXBLOCK_BPP(to), NR_PIXBLOCK_BPP(from)); - } -} - -} /* namespace NR */ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/pixblock-scaler.h b/src/display/pixblock-scaler.h deleted file mode 100644 index 8e9b1ec62..000000000 --- a/src/display/pixblock-scaler.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __NR_PIXBLOCK_SCALER_H__ -#define __NR_PIXBLOCK_SCALER_H__ - -/* - * Functions for blitting pixblocks using scaling - * - * Author: - * Niko Kiirala - * - * Copyright (C) 2006 Niko Kiirala - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "libnr/nr-pixblock.h" -#include <2geom/forward.h> - -namespace NR { - -/** Blits the second pixblock to the first. - * Image in source pixblock is scaled to the size of destination pixblock - * using bicubic interpolation. - * Source pixblock is not modified in process. - * Only works for 32-bpp images. - */ -void scale_bicubic(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &trans); - -} /* namespace NR */ - -#endif // __NR_PIXBLOCK_SCALER_H__ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/pixblock-transform.cpp b/src/display/pixblock-transform.cpp deleted file mode 100644 index af05a9b88..000000000 --- a/src/display/pixblock-transform.cpp +++ /dev/null @@ -1,279 +0,0 @@ -#define __NR_PIXBLOCK_SCALER_CPP__ - -/* - * Functions for blitting pixblocks using matrix transformation - * - * Author: - * Niko Kiirala - * - * Copyright (C) 2006,2009 Niko Kiirala - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include -#if defined (SOLARIS) && (SOLARIS == 8) -#include "round.h" -using Inkscape::round; -#endif -using std::floor; - -#include "display/nr-filter-utils.h" - -#include "libnr/nr-blit.h" -#include "libnr/nr-pixblock.h" -#include <2geom/matrix.h> - -namespace NR { - -struct RGBA { - double r, g, b, a; -}; -struct RGBAi { - int r, g, b, a; -}; - -/** - * Sanity check function for indexing pixblocks. - * Catches reading and writing outside the pixblock area. - * When enabled, decreases filter rendering speed massively. - */ -inline void _check_index(NRPixBlock const * const pb, int const location, int const line) -{ - if(false) { - int max_loc = pb->rs * (pb->area.y1 - pb->area.y0); - if (location < 0 || (location + 4) > max_loc) - g_warning("Location %d out of bounds (0 ... %d) at line %d", location, max_loc, line); - } -} - -void transform_nearest(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &trans) -{ - if (NR_PIXBLOCK_BPP(from) != 4 || NR_PIXBLOCK_BPP(to) != 4) { - g_warning("A non-32-bpp image passed to transform_nearest: scaling aborted."); - return; - } - - bool free_from_on_exit = false; - if (from->mode != to->mode){ - NRPixBlock *o_from = from; - from = new NRPixBlock; - nr_pixblock_setup_fast(from, to->mode, o_from->area.x0, o_from->area.y0, o_from->area.x1, o_from->area.y1, false); - nr_blit_pixblock_pixblock(from, o_from); - free_from_on_exit = true; - } - - // Precalculate sizes of source and destination pixblocks - int from_width = from->area.x1 - from->area.x0; - int from_height = from->area.y1 - from->area.y0; - int to_width = to->area.x1 - to->area.x0; - int to_height = to->area.y1 - to->area.y0; - - Geom::Matrix itrans = trans.inverse(); - - // Loop through every pixel of destination image, a line at a time - for (int to_y = 0 ; to_y < to_height ; to_y++) { - for (int to_x = 0 ; to_x < to_width ; to_x++) { - RGBAi result = {0,0,0,0}; - - int from_x = (int)floor(itrans[0] * (to_x + 0.5 + to->area.x0) - + itrans[2] * (to_y + 0.5 + to->area.y0) - + itrans[4]); - from_x -= from->area.x0; - int from_y = (int)floor(itrans[1] * (to_x + 0.5 + to->area.x0) - + itrans[3] * (to_y + 0.5 + to->area.y0) - + itrans[5]); - from_y -= from->area.y0; - - if (from_x >= 0 && from_x < from_width - && from_y >= 0 && from_y < from_height) { - _check_index(from, from_y * from->rs + from_x * 4, __LINE__); - result.r = NR_PIXBLOCK_PX(from)[from_y * from->rs + from_x * 4]; - result.g = NR_PIXBLOCK_PX(from)[from_y * from->rs + from_x * 4 + 1]; - result.b = NR_PIXBLOCK_PX(from)[from_y * from->rs + from_x * 4 + 2]; - result.a = NR_PIXBLOCK_PX(from)[from_y * from->rs + from_x * 4 + 3]; - } - - _check_index(to, to_y * to->rs + to_x * 4, __LINE__); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4] = result.r; - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 1] = result.g; - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 2] = result.b; - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 3] = result.a; - } - } - if (free_from_on_exit) { - nr_pixblock_release(from); - delete from; - } -} - -/** Calculates cubically interpolated value of the four given pixel values. - * The pixel values should be from four adjacent pixels in source image or - * four adjacent interpolated values. len should be the x- or y-coordinate - * (depending on interpolation direction) of the center of the target pixel - * in source image coordinates. - */ -__attribute__ ((const)) -inline static double sample(double const a, double const b, - double const c, double const d, - double const len) -{ - double lena = 1.5 + (len - round(len)); - double lenb = 0.5 + (len - round(len)); - double lenc = 0.5 - (len - round(len)); - double lend = 1.5 - (len - round(len)); - double const f = -0.5; // corresponds to cubic Hermite spline - double sum = 0; - sum += ((((f * lena) - 5.0 * f) * lena + 8.0 * f) * lena - 4 * f) * a; - sum += (((f + 2.0) * lenb - (f + 3.0)) * lenb * lenb + 1.0) * b; - sum += (((f + 2.0) * lenc - (f + 3.0)) * lenc * lenc + 1.0) * c; - sum += ((((f * lend) - 5.0 * f) * lend + 8.0 * f) * lend - 4 * f) * d; - - return sum; -} - -void transform_bicubic(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &trans) -{ - if (NR_PIXBLOCK_BPP(from) != 4 || NR_PIXBLOCK_BPP(to) != 4) { - g_warning("A non-32-bpp image passed to transform_bicubic: scaling aborted."); - return; - } - - bool free_from_on_exit = false; - if (from->mode != to->mode){ - NRPixBlock *o_from = from; - from = new NRPixBlock; - nr_pixblock_setup_fast(from, to->mode, o_from->area.x0, o_from->area.y0, o_from->area.x1, o_from->area.y1, false); - nr_blit_pixblock_pixblock(from, o_from); - free_from_on_exit = true; - } - - if (from->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - // TODO: Fix this... (The problem is that for interpolation non-premultiplied colors should be premultiplied...) - g_warning("transform_bicubic does not properly support non-premultiplied images"); - } - - // Precalculate sizes of source and destination pixblocks - int from_width = from->area.x1 - from->area.x0; - int from_height = from->area.y1 - from->area.y0; - int to_width = to->area.x1 - to->area.x0; - int to_height = to->area.y1 - to->area.y0; - - Geom::Matrix itrans = trans.inverse(); - - // Loop through every pixel of destination image, a line at a time - for (int to_y = 0 ; to_y < to_height ; to_y++) { - for (int to_x = 0 ; to_x < to_width ; to_x++) { - double from_x = itrans[0] * (to_x + 0.5 + to->area.x0) - + itrans[2] * (to_y + 0.5 + to->area.y0) - + itrans[4] - from->area.x0; - double from_y = itrans[1] * (to_x + 0.5 + to->area.x0) - + itrans[3] * (to_y + 0.5 + to->area.y0) - + itrans[5] - from->area.y0; - - if (from_x < 0 || from_x >= from_width || - from_y < 0 || from_y >= from_height) { - continue; - } - - RGBA line[4]; - - int from_line[4]; - for (int i = 0 ; i < 4 ; i++) { - int fy_line = (int)round(from_y) + i - 2; - if (fy_line >= 0) { - if (fy_line < from_height) { - from_line[i] = fy_line * from->rs; - } else { - from_line[i] = (from_height - 1) * from->rs; - } - } else { - from_line[i] = 0; - } - } - - for (int i = 0 ; i < 4 ; i++) { - int k = (int)round(from_x) + i - 2; - if (k < 0) k = 0; - if (k >= from_width) k = from_width - 1; - k *= 4; - _check_index(from, from_line[0] + k, __LINE__); - _check_index(from, from_line[1] + k, __LINE__); - _check_index(from, from_line[2] + k, __LINE__); - _check_index(from, from_line[3] + k, __LINE__); - line[i].r = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k], - NR_PIXBLOCK_PX(from)[from_line[1] + k], - NR_PIXBLOCK_PX(from)[from_line[2] + k], - NR_PIXBLOCK_PX(from)[from_line[3] + k], - from_y); - line[i].g = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k + 1], - NR_PIXBLOCK_PX(from)[from_line[1] + k + 1], - NR_PIXBLOCK_PX(from)[from_line[2] + k + 1], - NR_PIXBLOCK_PX(from)[from_line[3] + k + 1], - from_y); - line[i].b = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k + 2], - NR_PIXBLOCK_PX(from)[from_line[1] + k + 2], - NR_PIXBLOCK_PX(from)[from_line[2] + k + 2], - NR_PIXBLOCK_PX(from)[from_line[3] + k + 2], - from_y); - line[i].a = sample(NR_PIXBLOCK_PX(from)[from_line[0] + k + 3], - NR_PIXBLOCK_PX(from)[from_line[1] + k + 3], - NR_PIXBLOCK_PX(from)[from_line[2] + k + 3], - NR_PIXBLOCK_PX(from)[from_line[3] + k + 3], - from_y); - } - RGBA result; - result.r = round(sample(line[0].r, line[1].r, line[2].r, line[3].r, - from_x)); - result.g = round(sample(line[0].g, line[1].g, line[2].g, line[3].g, - from_x)); - result.b = round(sample(line[0].b, line[1].b, line[2].b, line[3].b, - from_x)); - result.a = round(sample(line[0].a, line[1].a, line[2].a, line[3].a, - from_x)); - - using Inkscape::Filters::clamp; - using Inkscape::Filters::clamp_alpha; - _check_index(to, to_y * to->rs + to_x * 4, __LINE__); - if (to->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* Make sure, none of the RGB channels exceeds 100% intensity - * in premultiplied output */ - int const alpha = clamp((int)result.a); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4] = - clamp_alpha((int)result.r, alpha); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 1] = - clamp_alpha((int)result.g, alpha); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 2] = - clamp_alpha((int)result.b, alpha); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 3] = alpha; - } else { - /* Clamp the output to unsigned char range */ - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4] - = clamp((int)result.r); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 1] - = clamp((int)result.g); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 2] - = clamp((int)result.b); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 3] - = clamp((int)result.a); - } - } - } - if (free_from_on_exit) { - nr_pixblock_release(from); - delete from; - } -} - -} /* namespace NR */ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/pixblock-transform.h b/src/display/pixblock-transform.h deleted file mode 100644 index 3ba00a08f..000000000 --- a/src/display/pixblock-transform.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __NR_PIXBLOCK_TRANSFORM_H__ -#define __NR_PIXBLOCK_TRANSFORM_H__ - -/* - * Functions for blitting pixblocks using matrix transfomation - * - * Author: - * Niko Kiirala - * - * Copyright (C) 2006 Niko Kiirala - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "libnr/nr-pixblock.h" -#include <2geom/forward.h> - -namespace NR { - -void transform_nearest(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &trans); -void transform_bicubic(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &trans); - -} /* namespace NR */ - -#endif // __NR_PIXBLOCK_TRANSFORM_H__ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 4c74af6d9..8be585a43 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -20,8 +20,6 @@ # include "config.h" #endif -#include - #include #include #include @@ -33,7 +31,6 @@ #include #include "display-forward.h" #include <2geom/matrix.h> -#include #include "preferences.h" #include "inkscape.h" #include "sodipodi-ctrlrect.h" @@ -41,7 +38,6 @@ #include "color-profile-fns.h" #endif // ENABLE_LCMS #include "display/rendermode.h" -#include "libnr/nr-blit.h" #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" @@ -1758,6 +1754,7 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } #endif + // output to X cairo_destroy(buf.ct); @@ -1775,12 +1772,6 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, //cairo_destroy (buf.ct); //cairo_surface_finish (cst); //cairo_surface_destroy (cst); - - if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { - nr_pixelstore_256K_free (buf.buf); - } else { - nr_pixelstore_1M_free (buf.buf); - } } struct PaintRectSetup { diff --git a/src/display/testnr.cpp b/src/display/testnr.cpp deleted file mode 100644 index 3a3478d28..000000000 --- a/src/display/testnr.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include "sp-arena.h" - -int -main (int argc, char ** argv) -{ - GtkWidget * w, * c; - - gtk_init (&argc, &argv); - - w = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - c = sp_arena_new (); - gtk_widget_show (c); - - gtk_container_add (GTK_CONTAINER (w), c); - - gtk_widget_show (w); - - gtk_main (); - - return 0; -} - diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 5415fdc80..85649186d 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -36,6 +36,7 @@ #include "desktop-handles.h" #include "selection.h" #include "document.h" +#include "libnr/nr-pixblock.h" #include "pixmaps/cursor-dropper.xpm" diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index bb8e69092..de6c151c3 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -62,6 +62,7 @@ #include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "livarot/Shape.h" +#include "libnr/nr-pixblock.h" #include "dyna-draw-context.h" diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index a1f902457..5ba92ffa0 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -22,6 +22,7 @@ #include #include <2geom/forward.h> +#include <2geom/matrix.h> #include "style.h" diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 9d25f3a7f..c88f09733 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -43,10 +43,6 @@ #include "display/nr-arena.h" #include "display/nr-arena-item.h" -//#include "libnr/nr-rect.h" -//#include "libnr/nr-matrix.h" -//#include "libnr/nr-pixblock.h" - //#include //#include diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 612ae1cfc..b67d180ff 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -53,12 +53,7 @@ #include "display/nr-arena-image.h" #include "display/canvas-arena.h" #include "libnr/nr-pixops.h" -#include "libnr/nr-matrix-translate-ops.h" -#include "libnr/nr-scale-ops.h" -#include "libnr/nr-scale-translate-ops.h" -#include "libnr/nr-translate-matrix-ops.h" -#include "libnr/nr-translate-scale-ops.h" -#include "libnr/nr-matrix-ops.h" +#include "libnr/nr-pixblock.h" #include <2geom/pathvector.h> #include "sp-item.h" #include "sp-root.h" diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 3be63aa68..8439115cb 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -15,28 +15,23 @@ # include "config.h" #endif -#include -#include #include #include #include -#include "png-write.h" -#include -#include -#include -#include -#include -#include -#include -#include "unit-constants.h" -#include "libnr/nr-matrix-translate-ops.h" -#include "libnr/nr-scale-ops.h" -#include "libnr/nr-scale-translate-ops.h" -#include "libnr/nr-translate-matrix-ops.h" -#include "libnr/nr-translate-scale-ops.h" +#include "interface.h" +#include "helper/png-write.h" +#include "display/cairo-utils.h" +#include "display/nr-arena-item.h" +#include "display/nr-arena.h" +#include "document.h" +#include "sp-item.h" +#include "sp-root.h" +#include "sp-use.h" +#include "sp-defs.h" +#include "unit-constants.h" -#include "pixbuf-ops.h" +#include "helper/pixbuf-ops.h" /** * Hide all items that are not listed in list, recursively, skipping groups and defs. @@ -142,49 +137,32 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, nr_arena_item_invoke_update(root, &final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); - guchar *px = NULL; - guint64 size = 4L * (guint64)width * (guint64)height; - if(size < (guint64)G_MAXSIZE) { - // g_try_new is limited to g_size type which is defined as unisgned int. Need to test for very large nubers - px = g_try_new(guchar, size); - } + cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - if(px != NULL) - { + if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) { + cairo_t *ct = cairo_create(surface); + + // clear to background + ink_cairo_set_source_rgba32(ct, bgcolor); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_OVER); + + // render items + nr_arena_item_invoke_render(ct, root, &final_bbox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); - NRPixBlock B; - //g_warning("sp_generate_internal_bitmap: nr_pixblock_setup_extern."); - nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, - final_bbox.x0, final_bbox.y0, final_bbox.x1, final_bbox.y1, - px, 4 * width, FALSE, FALSE ); - - unsigned char dtc[4]; - dtc[0] = NR_RGBA32_R(bgcolor); - dtc[1] = NR_RGBA32_G(bgcolor); - dtc[2] = NR_RGBA32_B(bgcolor); - dtc[3] = NR_RGBA32_A(bgcolor); - - for (gsize fy = 0; fy < height; fy++) { - guchar *p = NR_PIXBLOCK_PX(&B) + fy * (gsize)B.rs; - for (unsigned int fx = 0; fx < width; fx++) { - for (int i = 0; i < 4; i++) { - *p++ = dtc[i]; - } - } - } - - - nr_arena_item_invoke_render(NULL, root, &final_bbox, &B, NR_ARENA_ITEM_RENDER_NO_CACHE ); - - pixbuf = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB, - TRUE, - 8, width, height, width * 4, - (GdkPixbufDestroyNotify)g_free, - NULL); + pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(surface), + GDK_COLORSPACE_RGB, TRUE, + 8, width, height, cairo_image_surface_get_stride(surface), + (GdkPixbufDestroyNotify) cairo_surface_destroy, + NULL); + convert_pixbuf_argb32_to_normal(pixbuf); } else { + long long size = (long long) height * (long long) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %lld.", size); + cairo_surface_destroy(surface); } sp_item_invoke_hide (SP_ITEM(sp_document_root(doc)), dkey); nr_object_unref((NRObject *) arena); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 908b1fb20..437c39649 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -18,7 +18,7 @@ #include "interface.h" #include "libnr/nr-pixops.h" -#include "libnr/nr-translate-scale-ops.h" +#include "libnr/nr-pixblock.h" #include <2geom/rect.h> #include #include @@ -346,13 +346,8 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v cairo_paint(ct); cairo_set_operator(ct, CAIRO_OPERATOR_OVER); - NRPixBlock pb; - nr_pixblock_setup_extern(&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, - bbox.x0, bbox.y0, bbox.x1, bbox.y1, - ebp->px, 4 * ebp->width, FALSE, FALSE); - /* Render */ - nr_arena_item_invoke_render(ct, ebp->root, &bbox, &pb, 0); + nr_arena_item_invoke_render(ct, ebp->root, &bbox, NULL, 0); cairo_destroy(ct); cairo_surface_destroy(s); @@ -367,8 +362,6 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v rows[r] = px + r * stride; } - nr_pixblock_release(&pb); - return num_rows; } diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 8dd3c46e3..dc329c351 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -10,16 +10,11 @@ ink_common_sources += \ libnr/nr-compose.cpp \ libnr/nr-compose.h \ libnr/nr-convert2geom.h \ - libnr/nr-convex-hull.h \ libnr/nr-coord.h \ libnr/nr-dim2.h \ libnr/nr-forward.h \ - libnr/nr-gradient.cpp \ - libnr/nr-gradient.h \ libnr/nr-i-coord.h \ libnr/nr-macros.h \ - libnr/nr-matrix-div.cpp \ - libnr/nr-matrix-div.h \ libnr/nr-matrix-fns.cpp \ libnr/nr-matrix-fns.h \ libnr/nr-matrix-ops.h \ @@ -33,12 +28,8 @@ ink_common_sources += \ libnr/nr-object.cpp \ libnr/nr-object.h \ libnr/nr-path-code.h \ - libnr/nr-pixblock-line.cpp \ - libnr/nr-pixblock-line.h \ libnr/nr-pixblock-pattern.cpp \ libnr/nr-pixblock-pattern.h \ - libnr/nr-pixblock-pixel.cpp \ - libnr/nr-pixblock-pixel.h \ libnr/nr-pixblock.cpp \ libnr/nr-pixblock.h \ libnr/nr-pixops.h \ diff --git a/src/libnr/nr-convex-hull-ops.h b/src/libnr/nr-convex-hull-ops.h deleted file mode 100644 index 2e96bf367..000000000 --- a/src/libnr/nr-convex-hull-ops.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SEEN_NR_CONVEX_HULL_FNS_H -#define SEEN_NR_CONVEX_HULL_FNS_H - -/* ex:set et ts=4 sw=4: */ - -/* - * A class representing the convex hull of a set of points. - * - * Copyright 2004 MenTaLguY - * - * This code is licensed under the GNU GPL; see COPYING for more information. - */ - -#include -#include - -namespace NR { - -ConvexHull operator*(const Rect &r, const Matrix &m) { - ConvexHull points(r.corner(0)); - for ( unsigned i = 1 ; i < 4 ; i++ ) { - points.add(r.corner(i)); - } - return points; -} - -} /* namespace NR */ - -#endif diff --git a/src/libnr/nr-convex-hull.h b/src/libnr/nr-convex-hull.h deleted file mode 100644 index dafdd8840..000000000 --- a/src/libnr/nr-convex-hull.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef SEEN_NR_CONVEX_HULL_H -#define SEEN_NR_CONVEX_HULL_H - -/* ex:set et ts=4 sw=4: */ - -/* - * A class representing the convex hull of a set of points. - * - * Copyright 2004 MenTaLguY - * - * This code is licensed under the GNU GPL; see COPYING for more information. - */ - -#include - -namespace NR { - -class ConvexHull { -public: - ConvexHull() : _bounds() {} - explicit ConvexHull(Point const &p) : _bounds(Rect(p, p)) {} - - boost::optional midpoint() const { - if (_bounds) { - return _bounds->midpoint(); - } else { - return boost::optional(); - } - } - - void add(Point const &p) { - if (_bounds) { - _bounds->expandTo(p); - } else { - _bounds = Rect(p, p); - } - } - void add(Rect const &r) { - // Note that this is a hack. when convexhull actually works - // you will need to add all four points. - _bounds = union_bounds(_bounds, r); - } - void add(ConvexHull const &h) { - if (h._bounds) { - add(*h._bounds); - } - } - - boost::optional const &bounds() const { - return _bounds; - } - -private: - boost::optional _bounds; -}; - -} /* namespace NR */ - -#endif diff --git a/src/libnr/nr-gradient.cpp b/src/libnr/nr-gradient.cpp deleted file mode 100644 index e6eb9b79c..000000000 --- a/src/libnr/nr-gradient.cpp +++ /dev/null @@ -1,554 +0,0 @@ -#define __NR_GRADIENT_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * MenTaLguY - *...Jasper van de Gronde - * - * Copyright (C) 2009 Jasper van de Gronde - * Copyright (C) 2007 MenTaLguY - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001-2002 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -/* - * Derived in part from public domain code by Lauris Kaplinski - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Common */ - -#define NRG_MASK (NR_GRADIENT_VECTOR_LENGTH - 1) -#define NRG_2MASK ((long long) ((NR_GRADIENT_VECTOR_LENGTH << 1) - 1)) - -namespace { -inline unsigned char const *vector_index(int idx, - unsigned char const *vector) -{ - return vector + 4 * idx; -} - -template struct Spread; - -template <> -struct Spread { -static double index_at(NR::Coord r, double const unity = 1.0) { - return r<0.0?0.0:r>unity?unity:r; -} -static unsigned char const *color_at(NR::Coord r, - unsigned char const *vector) -{ - return vector_index((int)(index_at(r, NR_GRADIENT_VECTOR_LENGTH - 1)+.5), vector); - //return vector_index((int)CLAMP(r, 0, (double)(NR_GRADIENT_VECTOR_LENGTH - 1)), vector); -} -}; - -template <> -struct Spread { -static double index_at(NR::Coord r, double const unity = 1.0) { - return r<0.0?(unity+fmod(r,unity)):fmod(r,unity); -} -static unsigned char const *color_at(NR::Coord r, - unsigned char const *vector) -{ - return vector_index((int)(index_at(r, NR_GRADIENT_VECTOR_LENGTH - 1)+.5), vector); - //return vector_index((int)((long long)r & NRG_MASK), vector); -} -}; - -template <> -struct Spread { -static double index_at(NR::Coord r, double const unity = 1.0) { - r = r<0.0?(2*unity+fmod(r,2*unity)):fmod(r,2*unity); - if (r>unity) r=2*unity-r; - return r; -} -static unsigned char const *color_at(NR::Coord r, - unsigned char const *vector) -{ - return vector_index((int)(index_at(r, NR_GRADIENT_VECTOR_LENGTH - 1)+.5), vector); - //int idx = (int) ((long long)r & NRG_2MASK); - //if (idx > NRG_MASK) idx = NRG_2MASK - idx; - //return vector_index(idx, vector); -} -}; - -template struct ModeTraits; - -template <> -struct ModeTraits { -static const unsigned bpp=4; -}; - -template <> -struct ModeTraits { -static const unsigned bpp=4; -}; - -template <> -struct ModeTraits { -static const unsigned bpp=3; -}; - -template <> -struct ModeTraits { -static const unsigned bpp=1; -}; - -template -struct Compose { -static const unsigned bpp=ModeTraits::bpp; -static void compose(NRPixBlock *pb, unsigned char *dest, - NRPixBlock *spb, unsigned char const *src) -{ - nr_compose_pixblock_pixblock_pixel(pb, dest, spb, src); -} -}; - -template <> -struct Compose { -static const unsigned bpp=4; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - std::memcpy(dest, src, 4); -} -}; - -template <> -struct Compose { -static const unsigned bpp=4; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - dest[0] = NR_PREMUL_111(src[0], src[3]); - dest[1] = NR_PREMUL_111(src[1], src[3]); - dest[2] = NR_PREMUL_111(src[2], src[3]); - dest[3] = src[3]; -} -}; - -template <> -struct Compose { -static const unsigned bpp=3; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - dest[0] = NR_COMPOSEN11_1111(src[0], src[3], 255); - dest[1] = NR_COMPOSEN11_1111(src[1], src[3], 255); - dest[2] = NR_COMPOSEN11_1111(src[2], src[3], 255); -} -}; - -template <> -struct Compose { -static const unsigned bpp=1; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - dest[0] = src[3]; -} -}; - -template <> -struct Compose { -static const unsigned bpp=4; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - unsigned int ca; - ca = NR_COMPOSEA_112(src[3], dest[3]); - dest[0] = NR_COMPOSENNN_111121(src[0], src[3], dest[0], dest[3], ca); - dest[1] = NR_COMPOSENNN_111121(src[1], src[3], dest[1], dest[3], ca); - dest[2] = NR_COMPOSENNN_111121(src[2], src[3], dest[2], dest[3], ca); - dest[3] = NR_NORMALIZE_21(ca); -} -}; - -template <> -struct Compose { -static const unsigned bpp=4; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - dest[0] = NR_COMPOSENPP_1111(src[0], src[3], dest[0]); - dest[1] = NR_COMPOSENPP_1111(src[1], src[3], dest[1]); - dest[2] = NR_COMPOSENPP_1111(src[2], src[3], dest[2]); - dest[3] = NR_COMPOSEA_111(src[3], dest[3]); -} -}; - -template <> -struct Compose { -static const unsigned bpp=3; -static void compose(NRPixBlock */*pb*/, unsigned char *dest, - NRPixBlock */*spb*/, unsigned char const *src) -{ - dest[0] = NR_COMPOSEN11_1111(src[0], src[3], dest[0]); - dest[1] = NR_COMPOSEN11_1111(src[1], src[3], dest[1]); - dest[2] = NR_COMPOSEN11_1111(src[2], src[3], dest[2]); -} -}; - -template -static void -render_spread(NRGradientRenderer *gr, NRPixBlock *pb) -{ - switch (pb->mode) { - case NR_PIXBLOCK_MODE_R8G8B8A8N: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - case NR_PIXBLOCK_MODE_A8: - if (pb->empty) { - typedef Compose compose; - Subtype::template render(gr, pb); - } else { - typedef Compose compose; - Subtype::template render(gr, pb); - } - break; - } -} - -template -static void -render(NRRenderer *r, NRPixBlock *pb, NRPixBlock */*m*/) -{ - NRGradientRenderer *gr = static_cast(r); - - switch (gr->spread) { - case NR_GRADIENT_SPREAD_REPEAT: - render_spread >(gr, pb); - break; - case NR_GRADIENT_SPREAD_REFLECT: - render_spread >(gr, pb); - break; - case NR_GRADIENT_SPREAD_PAD: - default: - render_spread >(gr, pb); - } -} -} - -/* Linear */ - -namespace { - -struct Linear { -template -static void render(NRGradientRenderer *gr, NRPixBlock *pb) { - NRLGradientRenderer *lgr = static_cast(gr); - - int x, y; - unsigned char *d; - double pos; - NRPixBlock spb; - int x0, y0, width, height, rs; - - x0 = pb->area.x0; - y0 = pb->area.y0; - width = pb->area.x1 - pb->area.x0; - height = pb->area.y1 - pb->area.y0; - rs = pb->rs; - - nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N, - 0, 0, NR_GRADIENT_VECTOR_LENGTH, 1, - (unsigned char *) lgr->vector, - 4 * NR_GRADIENT_VECTOR_LENGTH, 0, 0); - - for (y = 0; y < height; y++) { - d = NR_PIXBLOCK_PX(pb) + y * rs; - pos = (y + y0 - lgr->y0) * lgr->dy + (0 + x0 - lgr->x0) * lgr->dx; - for (x = 0; x < width; x++) { - unsigned char const *s=spread::color_at(pos, lgr->vector); - compose::compose(pb, d, &spb, s); - d += compose::bpp; - pos += lgr->dx; - } - } - - nr_pixblock_release(&spb); -} -}; - -} - -NRRenderer * -nr_lgradient_renderer_setup (NRLGradientRenderer *lgr, - const unsigned char *cv, - unsigned int spread, - const NR::Matrix *gs2px, - float x0, float y0, - float x1, float y1) -{ - NR::Matrix n2gs, n2px, px2n; - - lgr->render = &render; - - lgr->vector = cv; - lgr->spread = spread; - - n2gs[0] = x1 - x0; - n2gs[1] = y1 - y0; - n2gs[2] = y1 - y0; - n2gs[3] = x0 - x1; - n2gs[4] = x0; - n2gs[5] = y0; - - n2px = n2gs * (*gs2px); - px2n = n2px.inverse(); - - lgr->x0 = n2px[4] - 0.5; // These -0.5 offsets make sure that the gradient is sampled in the MIDDLE of each pixel. - lgr->y0 = n2px[5] - 0.5; - lgr->dx = px2n[0] * (NR_GRADIENT_VECTOR_LENGTH-1); - lgr->dy = px2n[2] * (NR_GRADIENT_VECTOR_LENGTH-1); - - return (NRRenderer *) lgr; -} - -/* Radial */ - -/* - * The archetype is following - * - * gx gy - pixel coordinates - * Px Py - coordinates, where Fx Fy - gx gy line intersects with circle - * - * (1) (gx - fx) * (Py - fy) = (gy - fy) * (Px - fx) - * (2) (Px - cx) * (Px - cx) + (Py - cy) * (Py - cy) = r * r - * - * (3) Py = (Px - fx) * (gy - fy) / (gx - fx) + fy - * (4) (gy - fy) / (gx - fx) = D - * (5) Py = D * Px - D * fx + fy - * - * (6) D * fx - fy + cy = N - * (7) Px * Px - 2 * Px * cx + cx * cx + (D * Px) * (D * Px) - 2 * (D * Px) * N + N * N = r * r - * (8) (D * D + 1) * (Px * Px) - 2 * (cx + D * N) * Px + cx * cx + N * N = r * r - * - * (9) A = D * D + 1 - * (10) B = -2 * (cx + D * N) - * (11) C = cx * cx + N * N - r * r - * - * (12) Px = (-B +- SQRT(B * B - 4 * A * C)) / 2 * A - */ - -namespace { - -struct SymmetricRadial { -template -static void render(NRGradientRenderer *gr, NRPixBlock *pb) -{ - NRRGradientRenderer *rgr = static_cast(gr); - - NR::Coord const dx = rgr->px2gs[0]; - NR::Coord const dy = rgr->px2gs[1]; - - NRPixBlock spb; - nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N, - 0, 0, NR_GRADIENT_VECTOR_LENGTH, 1, - (unsigned char *) rgr->vector, - 4 * NR_GRADIENT_VECTOR_LENGTH, - 0, 0); - - for (int y = pb->area.y0; y < pb->area.y1; y++) { - unsigned char *d = NR_PIXBLOCK_PX(pb) + (y - pb->area.y0) * pb->rs; - NR::Coord gx = rgr->px2gs[0] * pb->area.x0 + rgr->px2gs[2] * y + rgr->px2gs[4]; - NR::Coord gy = rgr->px2gs[1] * pb->area.x0 + rgr->px2gs[3] * y + rgr->px2gs[5]; - for (int x = pb->area.x0; x < pb->area.x1; x++) { - NR::Coord const pos = sqrt(((gx*gx) + (gy*gy))); - unsigned char const *s=spread::color_at(pos, rgr->vector); - compose::compose(pb, d, &spb, s); - d += compose::bpp; - gx += dx; - gy += dy; - } - } - - nr_pixblock_release(&spb); -} -}; - -struct Radial { -template -static void render(NRGradientRenderer *gr, NRPixBlock *pb) -{ - NRRGradientRenderer *rgr = static_cast(gr); - int const x0 = pb->area.x0; - int const y0 = pb->area.y0; - int const x1 = pb->area.x1; - int const y1 = pb->area.y1; - int const rs = pb->rs; - - NRPixBlock spb; - nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N, - 0, 0, NR_GRADIENT_VECTOR_LENGTH, 1, - (unsigned char *) rgr->vector, - 4 * NR_GRADIENT_VECTOR_LENGTH, - 0, 0); - - for (int y = y0; y < y1; y++) { - unsigned char *d = NR_PIXBLOCK_PX(pb) + (y - y0) * rs; - NR::Coord gx = rgr->px2gs[0] * x0 + rgr->px2gs[2] * y + rgr->px2gs[4]; - NR::Coord gy = rgr->px2gs[1] * x0 + rgr->px2gs[3] * y + rgr->px2gs[5]; - NR::Coord const dx = rgr->px2gs[0]; - NR::Coord const dy = rgr->px2gs[1]; - for (int x = x0; x < x1; x++) { - NR::Coord const gx2 = gx * gx; - NR::Coord const gxy2 = gx2 + gy * gy; - NR::Coord const qgx2_4 = gx2 - rgr->C * gxy2; - /* INVARIANT: qgx2_4 >= 0.0 */ - /* qgx2_4 = MAX(qgx2_4, 0.0); */ - NR::Coord const pxgx = gx + sqrt(qgx2_4); - /* We can safely divide by 0 here */ - /* If we are sure pxgx cannot be -0 */ - NR::Coord const pos = gxy2 / pxgx * (NR_GRADIENT_VECTOR_LENGTH-1); - - unsigned char const *s; - if (pos < (1U << 31)) { - s = spread::color_at(pos, rgr->vector); - } else { - s = vector_index(NR_GRADIENT_VECTOR_LENGTH - 1, rgr->vector); - } - - compose::compose(pb, d, &spb, s); - d += compose::bpp; - - gx += dx; - gy += dy; - } - } - - nr_pixblock_release(&spb); -} -}; - -} - -static void nr_rgradient_render_block_end(NRRenderer *r, NRPixBlock *pb, NRPixBlock *m); - -NRRenderer * -nr_rgradient_renderer_setup(NRRGradientRenderer *rgr, - unsigned char const *cv, - unsigned spread, - NR::Matrix const *gs2px, - float cx, float cy, - float fx, float fy, - float r) -{ - rgr->vector = cv; - rgr->spread = spread; - - if (r < NR_EPSILON) { - rgr->render = nr_rgradient_render_block_end; - } else if (NR_DF_TEST_CLOSE(cx, fx, NR_EPSILON) && - NR_DF_TEST_CLOSE(cy, fy, NR_EPSILON)) { - rgr->render = render; - - rgr->px2gs = gs2px->inverse(); - rgr->px2gs[0] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r; - rgr->px2gs[1] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r; - rgr->px2gs[2] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r; - rgr->px2gs[3] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r; - rgr->px2gs[4] -= cx; - rgr->px2gs[5] -= cy; - rgr->px2gs[4] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r; - rgr->px2gs[5] *= (NR_GRADIENT_VECTOR_LENGTH-1) / r; - rgr->px2gs[4] += 0.5*(rgr->px2gs[0]+rgr->px2gs[2]); // These offsets make sure the gradient is sampled in the MIDDLE of each pixel - rgr->px2gs[5] += 0.5*(rgr->px2gs[1]+rgr->px2gs[3]); - - rgr->cx = 0.0; - rgr->cy = 0.0; - rgr->fx = rgr->cx; - rgr->fy = rgr->cy; - rgr->r = 1.0; - } else { - rgr->render = render; - - NR::Coord const df = hypot(fx - cx, fy - cy); - if (df >= r) { - fx = cx + (fx - cx ) * r / (float) df; - fy = cy + (fy - cy ) * r / (float) df; - } - - NR::Matrix n2gs; - n2gs[0] = cx - fx; - n2gs[1] = cy - fy; - n2gs[2] = cy - fy; - n2gs[3] = fx - cx; - n2gs[4] = fx; - n2gs[5] = fy; - - NR::Matrix n2px; - n2px = n2gs * (*gs2px); - rgr->px2gs = n2px.inverse(); - rgr->px2gs[4] += 0.5*(rgr->px2gs[0]+rgr->px2gs[2]); // These offsets make sure the gradient is sampled in the MIDDLE of each pixel - rgr->px2gs[5] += 0.5*(rgr->px2gs[1]+rgr->px2gs[3]); - - rgr->cx = 1.0; - rgr->cy = 0.0; - rgr->fx = 0.0; - rgr->fy = 0.0; - rgr->r = r / (float) hypot(fx - cx, fy - cy); - rgr->C = 1.0F - rgr->r * rgr->r; - /* INVARIANT: C < 0 */ - rgr->C = MIN(rgr->C, -NR_EPSILON); - } - - return (NRRenderer *) rgr; -} - -static void -nr_rgradient_render_block_end(NRRenderer *r, NRPixBlock *pb, NRPixBlock *m) -{ - unsigned char const *c = ((NRRGradientRenderer *) r)->vector + 4 * (NR_GRADIENT_VECTOR_LENGTH - 1); - - nr_blit_pixblock_mask_rgba32(pb, m, (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-gradient.h b/src/libnr/nr-gradient.h deleted file mode 100644 index 1073f36ae..000000000 --- a/src/libnr/nr-gradient.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef __NR_GRADIENT_H__ -#define __NR_GRADIENT_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001-2002 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -/* - * Derived in part from public domain code by Lauris Kaplinski - */ - -#include -#include - -#define NR_GRADIENT_VECTOR_BITS 10 -#define NR_GRADIENT_VECTOR_LENGTH (1< - * - * This code is in public domain - */ - -#include -#include - -void -nr_pixblock_draw_line_rgba32 (NRPixBlock *d, long x0, long y0, long x1, long y1, short /*first*/, unsigned long rgba) -{ - long deltax, deltay, xinc1, xinc2, yinc1, yinc2; - long den, num, numadd, numpixels; - long x, y, curpixel; - /* Pixblock */ - int dbpp; - NRPixBlock spb; - unsigned char *spx; - - if (x1 >= x0) { - deltax = x1 - x0; - xinc1 = 1; - xinc2 = 1; - } else { - deltax = x0 - x1; - xinc1 = -1; - xinc2 = -1; - } - - if (y1 >= y0) { - deltay = y1 - y0; - yinc1 = 1; - yinc2 = 1; - } else { - deltay = y0 - y1; - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) { - xinc1 = 0; - yinc2 = 0; - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; - } else { - xinc2 = 0; - yinc1 = 0; - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; - } - - /* We can be quite sure 1x1 pixblock is TINY */ - nr_pixblock_setup_fast (&spb, NR_PIXBLOCK_MODE_R8G8B8A8N, 0, 0, 1, 1, 0); - spb.empty = 0; - spx = NR_PIXBLOCK_PX (&spb); - spx[0] = NR_RGBA32_R (rgba); - spx[1] = NR_RGBA32_G (rgba); - spx[2] = NR_RGBA32_B (rgba); - spx[3] = NR_RGBA32_A (rgba); - - dbpp = NR_PIXBLOCK_BPP (d); - - x = x0; - y = y0; - - for (curpixel = 0; curpixel <= numpixels; curpixel++) { - if ((x >= d->area.x0) && (y >= d->area.y0) && (x < d->area.x1) && (y < d->area.y1)) { - nr_compose_pixblock_pixblock_pixel (d, NR_PIXBLOCK_PX (d) + (y - d->area.y0) * d->rs + (x - d->area.x0) * dbpp, &spb, spx); - } - num += numadd; - if (num >= den) { - num -= den; - x += xinc1; - y += yinc1; - } - x += xinc2; - y += yinc2; - } - - nr_pixblock_release (&spb); -} - diff --git a/src/libnr/nr-pixblock-line.h b/src/libnr/nr-pixblock-line.h deleted file mode 100644 index 7fd58a0ab..000000000 --- a/src/libnr/nr-pixblock-line.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __NR_PIXBLOCK_LINE_H__ -#define __NR_PIXBLOCK_LINE_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -void nr_pixblock_draw_line_rgba32 (NRPixBlock *d, long x0, long y0, long x1, long y1, short first, unsigned long rgba); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-pixblock-pixel.cpp b/src/libnr/nr-pixblock-pixel.cpp deleted file mode 100644 index 109ed69dc..000000000 --- a/src/libnr/nr-pixblock-pixel.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#define __NR_PIXBLOCK_PIXEL_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include "nr-pixops.h" -#include "nr-pixblock-pixel.h" - -void -nr_compose_pixblock_pixblock_pixel (NRPixBlock *dpb, unsigned char *d, const NRPixBlock *spb, const unsigned char *s) -{ - if (spb->empty) return; - - if (dpb->empty) { - /* Empty destination */ - switch (dpb->mode) { - case NR_PIXBLOCK_MODE_A8: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = 255; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = s[3]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = s[3]; - break; - default: - break; - } - break; - case NR_PIXBLOCK_MODE_R8G8B8: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = NR_COMPOSEN11_1111 (s[0], s[3], 255); - d[1] = NR_COMPOSEN11_1111 (s[1], s[3], 255); - d[2] = NR_COMPOSEN11_1111 (s[2], s[3], 255); - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = NR_COMPOSEP11_1111 (s[0], s[3], 255); - d[1] = NR_COMPOSEP11_1111 (s[1], s[3], 255); - d[2] = NR_COMPOSEP11_1111 (s[2], s[3], 255); - break; - default: - break; - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = 255; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = s[3]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - if (s[3] == 0) { - d[0] = 255; - d[1] = 255; - d[2] = 255; - } else { - d[0] = NR_DEMUL_111(s[0], s[3]); - d[1] = NR_DEMUL_111(s[0], s[3]); - d[2] = NR_DEMUL_111(s[0], s[3]); - } - d[3] = s[3]; - break; - default: - break; - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = 255; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = NR_PREMUL_111 (s[0], s[3]); - d[1] = NR_PREMUL_111 (s[1], s[3]); - d[2] = NR_PREMUL_111 (s[2], s[3]); - d[3] = s[3]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = s[3]; - break; - default: - break; - } - break; - default: - break; - } - } else { - /* Image destination */ - switch (dpb->mode) { - case NR_PIXBLOCK_MODE_A8: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = 255; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = NR_COMPOSEA_111(s[3], d[0]); - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = NR_COMPOSEA_111(s[3], d[0]); - break; - default: - break; - } - break; - case NR_PIXBLOCK_MODE_R8G8B8: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = NR_COMPOSEN11_1111 (s[0], s[3], d[0]); - d[1] = NR_COMPOSEN11_1111 (s[1], s[3], d[1]); - d[2] = NR_COMPOSEN11_1111 (s[2], s[3], d[2]); - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = NR_COMPOSEP11_1111 (s[0], s[3], d[0]); - d[1] = NR_COMPOSEP11_1111 (s[1], s[3], d[1]); - d[2] = NR_COMPOSEP11_1111 (s[2], s[3], d[2]); - break; - default: - break; - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - if (s[3] != 0) { - unsigned int ca; - ca = NR_COMPOSEA_112(s[3], d[3]); - d[0] = NR_COMPOSENNN_111121 (s[0], s[3], d[0], d[3], ca); - d[1] = NR_COMPOSENNN_111121 (s[1], s[3], d[1], d[3], ca); - d[2] = NR_COMPOSENNN_111121 (s[2], s[3], d[2], d[3], ca); - d[3] = NR_NORMALIZE_21(ca); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - if (s[3] != 0) { - unsigned int ca; - ca = NR_COMPOSEA_112(s[3], d[3]); - d[0] = NR_COMPOSEPNN_111121 (s[0], s[3], d[0], d[3], ca); - d[1] = NR_COMPOSEPNN_111121 (s[1], s[3], d[0], d[3], ca); - d[2] = NR_COMPOSEPNN_111121 (s[2], s[3], d[0], d[3], ca); - d[3] = NR_NORMALIZE_21(ca); - } - break; - default: - break; - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - switch (spb->mode) { - case NR_PIXBLOCK_MODE_A8: - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - d[0] = NR_COMPOSENPP_1111 (s[0], s[3], d[0]); - d[1] = NR_COMPOSENPP_1111 (s[1], s[3], d[1]); - d[2] = NR_COMPOSENPP_1111 (s[2], s[3], d[2]); - d[3] = NR_COMPOSEA_111(s[3], d[3]); - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = NR_COMPOSEPPP_1111 (s[0], s[3], d[0]); - d[1] = NR_COMPOSEPPP_1111 (s[1], s[3], d[1]); - d[2] = NR_COMPOSEPPP_1111 (s[2], s[3], d[2]); - d[3] = NR_COMPOSEA_111(s[3], d[3]); - break; - default: - break; - } - break; - default: - break; - } - } -} - diff --git a/src/libnr/nr-pixblock-pixel.h b/src/libnr/nr-pixblock-pixel.h deleted file mode 100644 index d989f53cf..000000000 --- a/src/libnr/nr-pixblock-pixel.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __NR_PIXBLOCK_PIXEL_H__ -#define __NR_PIXBLOCK_PIXEL_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -void nr_compose_pixblock_pixblock_pixel (NRPixBlock *dpb, unsigned char *d, const NRPixBlock *spb, const unsigned char *s); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index bf1e9c5c9..57609d1a2 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -9,8 +9,6 @@ #include "Path.h" #include "Shape.h" #include "livarot/path-description.h" - -#include #include <2geom/transforms.h> /* diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 4a5aec0f5..91f6f9ec4 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -20,7 +20,6 @@ #include "Path.h" #include "style.h" #include "livarot/path-description.h" -#include "libnr/nr-point-matrix-ops.h" #include "libnr/nr-convert2geom.h" #include <2geom/pathvector.h> #include <2geom/point.h> diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index 0f440de24..917bcbe7c 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -7,7 +7,6 @@ */ #include -#include #include "livarot/Path.h" #include "livarot/path-description.h" diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index 00a0dd9a0..9ff633f1d 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -9,14 +9,14 @@ #include #include #include +#include #include +#include <2geom/matrix.h> #include "Shape.h" #include "livarot/sweep-event-queue.h" #include "livarot/sweep-tree-list.h" #include "livarot/sweep-tree.h" -#include "libnr/nr-matrix.h" - //int doDebug=0; /* diff --git a/src/livarot/path-description.cpp b/src/livarot/path-description.cpp index 9ecfb99d6..fd91cb447 100644 --- a/src/livarot/path-description.cpp +++ b/src/livarot/path-description.cpp @@ -1,5 +1,5 @@ -#include "libnr/nr-point-matrix-ops.h" #include "livarot/path-description.h" +#include <2geom/matrix.h> PathDescr *PathDescrMoveTo::clone() const { diff --git a/src/marker.cpp b/src/marker.cpp index e4c2e0c30..6917c0b71 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -18,12 +18,6 @@ #include #include "config.h" - -#include "libnr/nr-matrix-fns.h" -#include "libnr/nr-matrix-ops.h" -#include "libnr/nr-matrix-translate-ops.h" -#include "libnr/nr-scale-matrix-ops.h" -#include "libnr/nr-translate-matrix-ops.h" #include "libnr/nr-convert2geom.h" #include <2geom/matrix.h> #include "svg/svg.h" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index cc153aa71..42cfc0a5f 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -52,10 +52,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-conn-end.h" #include "dropper-context.h" #include -#include "libnr/nr-matrix-rotate-ops.h" -#include "libnr/nr-matrix-translate-ops.h" -#include "libnr/nr-scale-ops.h" -#include #include <2geom/transforms.h> #include "xml/repr.h" #include "xml/rebase-hrefs.h" diff --git a/src/selection.h b/src/selection.h index b5a511e96..a79892eb5 100644 --- a/src/selection.h +++ b/src/selection.h @@ -21,8 +21,6 @@ #include #include -//#include "libnr/nr-rect.h" -#include "libnr/nr-convex-hull.h" #include "forward.h" #include "gc-managed.h" #include "gc-finalized.h" diff --git a/src/sp-gradient-fns.h b/src/sp-gradient-fns.h index dafa1646f..0fe10a5a1 100644 --- a/src/sp-gradient-fns.h +++ b/src/sp-gradient-fns.h @@ -23,9 +23,6 @@ class SPGradient; /** Forces vector to be built, if not present (i.e. changed) */ void sp_gradient_ensure_vector(SPGradient *gradient); -/** Ensures that color array is populated */ -void sp_gradient_ensure_colors(SPGradient *gradient); - void sp_gradient_set_units(SPGradient *gr, SPGradientUnits units); void sp_gradient_set_spread(SPGradient *gr, SPGradientSpread spread); @@ -35,8 +32,7 @@ SPGradientSpread sp_gradient_get_spread (SPGradient *gradient); void sp_gradient_repr_write_vector(SPGradient *gr); void sp_gradient_repr_clear_vector(SPGradient *gr); -void sp_gradient_render_vector_block_rgba(SPGradient *gr, guchar *px, gint w, gint h, gint rs, gint pos, gint span, bool horizontal); -void sp_gradient_render_vector_block_rgb(SPGradient *gr, guchar *px, gint w, gint h, gint rs, gint pos, gint span, bool horizontal); +cairo_pattern_t *sp_gradient_create_preview_pattern(SPGradient *gradient, double width); /** Transforms to/from gradient position space in given environment */ Geom::Matrix sp_gradient_get_g2d_matrix(SPGradient const *gr, Geom::Matrix const &ctm, diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index ba15f2651..982ce0d0e 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -32,8 +32,6 @@ #include #include "display/cairo-utils.h" -#include "libnr/nr-gradient.h" -#include "libnr/nr-pixops.h" #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" @@ -390,8 +388,6 @@ sp_gradient_init(SPGradient *gr) gr->vector.built = false; gr->vector.stops.clear(); - gr->color = NULL; - new (&gr->modified_connection) sigc::connection(); } @@ -447,11 +443,6 @@ sp_gradient_release(SPObject *object) gradient->ref = NULL; } - if (gradient->color) { - g_free(gradient->color); - gradient->color = NULL; - } - gradient->modified_connection.~connection(); if (((SPObjectClass *) gradient_parent_class)->release) @@ -616,7 +607,7 @@ sp_gradient_modified(SPObject *object, guint flags) } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - sp_gradient_ensure_colors(gr); + sp_gradient_ensure_vector(gr); } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -966,12 +957,6 @@ sp_gradient_invalidate_vector(SPGradient *gr) { bool ret = false; - if (gr->color != NULL) { - g_free(gr->color); - gr->color = NULL; - ret = true; - } - if (gr->vector.built) { gr->vector.built = false; gr->vector.stops.clear(); @@ -1084,279 +1069,6 @@ sp_gradient_rebuild_vector(SPGradient *gr) gr->vector.built = true; } -/** - * The gradient's color array is newly created and set up from vector. - */ -void -sp_gradient_ensure_colors(SPGradient *gr) -{ - if (!gr->vector.built) { - sp_gradient_rebuild_vector(gr); - } - g_return_if_fail(!gr->vector.stops.empty()); - - /// \todo Where is the memory freed? - if (!gr->color) { - gr->color = g_new(guchar, 4 * NCOLORS); - } - - // This assumes that gr->vector is a zero-order B-spline (box function) approximation of the "true" gradient. - // This means that the "true" gradient must be prefiltered using a zero order B-spline and then sampled. - // Furthermore, the first element corresponds to offset="0" and the last element to offset="1". - - double remainder[4] = {0,0,0,0}; - double remainder_for_end[4] = {0,0,0,0}; // Used at the end - switch(gr->spread) { - case SP_GRADIENT_SPREAD_PAD: - remainder[0] = 0.5*gr->vector.stops[0].color.v.c[0]; // Half of the first cell uses the color of the first stop - remainder[1] = 0.5*gr->vector.stops[0].color.v.c[1]; - remainder[2] = 0.5*gr->vector.stops[0].color.v.c[2]; - remainder[3] = 0.5*gr->vector.stops[0].opacity; - remainder_for_end[0] = 0.5*gr->vector.stops[gr->vector.stops.size() - 1].color.v.c[0]; // Half of the first cell uses the color of the last stop - remainder_for_end[1] = 0.5*gr->vector.stops[gr->vector.stops.size() - 1].color.v.c[1]; - remainder_for_end[2] = 0.5*gr->vector.stops[gr->vector.stops.size() - 1].color.v.c[2]; - remainder_for_end[3] = 0.5*gr->vector.stops[gr->vector.stops.size() - 1].opacity; - break; - case SP_GRADIENT_SPREAD_REFLECT: - case SP_GRADIENT_SPREAD_REPEAT: - // These two are handled differently, see below. - break; - default: - g_error("Spread type not supported!"); - }; - for (unsigned int i = 0; i < gr->vector.stops.size() - 1; i++) { - double r0 = gr->vector.stops[i].color.v.c[0]; - double g0 = gr->vector.stops[i].color.v.c[1]; - double b0 = gr->vector.stops[i].color.v.c[2]; - double a0 = gr->vector.stops[i].opacity; - double r1 = gr->vector.stops[i+1].color.v.c[0]; - double g1 = gr->vector.stops[i+1].color.v.c[1]; - double b1 = gr->vector.stops[i+1].color.v.c[2]; - double a1 = gr->vector.stops[i+1].opacity; - double o0 = gr->vector.stops[i].offset * (NCOLORS-1); - double o1 = gr->vector.stops[i + 1].offset * (NCOLORS-1); - unsigned int ob = (unsigned int) floor(o0+.5); // These are the first and last element that might be affected by this interval. - unsigned int oe = (unsigned int) floor(o1+.5); // These need to be computed the same to ensure that ob will be covered by the next interval if oe==ob - - if (oe == ob) { - // Simple case, this interval starts and stops within one cell - // The contribution of this interval is: - // (o1-o0)*(c(o0)+c(o1))/2 - // = (o1-o0)*(c0+c1)/2 - double dt = 0.5*(o1-o0); - remainder[0] += dt*(r0 + r1); - remainder[1] += dt*(g0 + g1); - remainder[2] += dt*(b0 + b1); - remainder[3] += dt*(a0 + a1); - } else { - // First compute colors for the cells which are fully covered by the current interval. - // The prefiltered values are equal to the midpoint of each cell here. - // f = (j-o0)/(o1-o0) - // = j*(1/(o1-o0)) - o0/(o1-o0) - double f = (ob-o0) / (o1-o0); - double df = 1. / (o1-o0); - for (unsigned int j = ob+1; j < oe; j++) { - f += df; - gr->color[4 * j + 0] = (unsigned char) floor(255*(r0 + f*(r1-r0)) + .5); - gr->color[4 * j + 1] = (unsigned char) floor(255*(g0 + f*(g1-g0)) + .5); - gr->color[4 * j + 2] = (unsigned char) floor(255*(b0 + f*(b1-b0)) + .5); - gr->color[4 * j + 3] = (unsigned char) floor(255*(a0 + f*(a1-a0)) + .5); - } - - // Now handle the beginning - // The contribution of the last point is already in remainder. - // The contribution of this point is: - // (ob+.5-o0)*(c(o0)+c(ob+.5))/2 - // = (ob+.5-o0)*c((o0+ob+.5)/2) - // = (ob+.5-o0)*(c0+((o0+ob+.5)/2-o0)*df*(c1-c0)) - // = (ob+.5-o0)*(c0+(ob+.5-o0)*df*(c1-c0)/2) - double dt = ob+.5-o0; - f = 0.5*dt*df; - if (ob==0 && gr->spread==SP_GRADIENT_SPREAD_REFLECT) { - // The first half of the first cell is just a mirror image of the second half, so simply multiply it by 2. - gr->color[4 * ob + 0] = (unsigned char) floor(2*255*(remainder[0] + dt*(r0 + f*(r1-r0))) + .5); - gr->color[4 * ob + 1] = (unsigned char) floor(2*255*(remainder[1] + dt*(g0 + f*(g1-g0))) + .5); - gr->color[4 * ob + 2] = (unsigned char) floor(2*255*(remainder[2] + dt*(b0 + f*(b1-b0))) + .5); - gr->color[4 * ob + 3] = (unsigned char) floor(2*255*(remainder[3] + dt*(a0 + f*(a1-a0))) + .5); - } else if (ob==0 && gr->spread==SP_GRADIENT_SPREAD_REPEAT) { - // The first cell is the same as the last cell, so save whatever is in the second half here and deal with the rest later. - remainder_for_end[0] = remainder[0] + dt*(r0 + f*(r1-r0)); - remainder_for_end[1] = remainder[1] + dt*(g0 + f*(g1-g0)); - remainder_for_end[2] = remainder[2] + dt*(b0 + f*(b1-b0)); - remainder_for_end[3] = remainder[3] + dt*(a0 + f*(a1-a0)); - } else { - // The first half of the cell was already in remainder. - gr->color[4 * ob + 0] = (unsigned char) floor(255*(remainder[0] + dt*(r0 + f*(r1-r0))) + .5); - gr->color[4 * ob + 1] = (unsigned char) floor(255*(remainder[1] + dt*(g0 + f*(g1-g0))) + .5); - gr->color[4 * ob + 2] = (unsigned char) floor(255*(remainder[2] + dt*(b0 + f*(b1-b0))) + .5); - gr->color[4 * ob + 3] = (unsigned char) floor(255*(remainder[3] + dt*(a0 + f*(a1-a0))) + .5); - } - - // Now handle the end, which should end up in remainder - // The contribution of this point is: - // (o1-oe+.5)*(c(o1)+c(oe-.5))/2 - // = (o1-oe+.5)*c((o1+oe-.5)/2) - // = (o1-oe+.5)*(c0+((o1+oe-.5)/2-o0)*df*(c1-c0)) - dt = o1-oe+.5; - f = (0.5*(o1+oe-.5)-o0)*df; - remainder[0] = dt*(r0 + f*(r1-r0)); - remainder[1] = dt*(g0 + f*(g1-g0)); - remainder[2] = dt*(b0 + f*(b1-b0)); - remainder[3] = dt*(a0 + f*(a1-a0)); - } - } - switch(gr->spread) { - case SP_GRADIENT_SPREAD_PAD: - gr->color[4 * (NCOLORS-1) + 0] = (unsigned char) floor(255*(remainder[0]+remainder_for_end[0]) + .5); - gr->color[4 * (NCOLORS-1) + 1] = (unsigned char) floor(255*(remainder[1]+remainder_for_end[1]) + .5); - gr->color[4 * (NCOLORS-1) + 2] = (unsigned char) floor(255*(remainder[2]+remainder_for_end[2]) + .5); - gr->color[4 * (NCOLORS-1) + 3] = (unsigned char) floor(255*(remainder[3]+remainder_for_end[3]) + .5); - break; - case SP_GRADIENT_SPREAD_REFLECT: - // The second half is the same as the first half, so multiply by 2. - gr->color[4 * (NCOLORS-1) + 0] = (unsigned char) floor(2*255*remainder[0] + .5); - gr->color[4 * (NCOLORS-1) + 1] = (unsigned char) floor(2*255*remainder[1] + .5); - gr->color[4 * (NCOLORS-1) + 2] = (unsigned char) floor(2*255*remainder[2] + .5); - gr->color[4 * (NCOLORS-1) + 3] = (unsigned char) floor(2*255*remainder[3] + .5); - break; - case SP_GRADIENT_SPREAD_REPEAT: - // The second half is the same as the second half of the first cell (which was saved in remainder_for_end). - gr->color[0] = gr->color[4 * (NCOLORS-1) + 0] = (unsigned char) floor(255*(remainder[0]+remainder_for_end[0]) + .5); - gr->color[1] = gr->color[4 * (NCOLORS-1) + 1] = (unsigned char) floor(255*(remainder[1]+remainder_for_end[1]) + .5); - gr->color[2] = gr->color[4 * (NCOLORS-1) + 2] = (unsigned char) floor(255*(remainder[2]+remainder_for_end[2]) + .5); - gr->color[3] = gr->color[4 * (NCOLORS-1) + 3] = (unsigned char) floor(255*(remainder[3]+remainder_for_end[3]) + .5); - break; - } -} - -/** - * Renders gradient vector to buffer as line. - * - * RGB buffer background should be set up beforehand. - * - * @param len,width,height,rowstride Buffer parameters (1 or 2 dimensional). - * @param span Full integer width of requested gradient. - * @param pos Buffer starting position in span. - */ -static void -sp_gradient_render_vector_line_rgba(SPGradient *const gradient, guchar *buf, - gint const len, gint const pos, gint const span) -{ - g_return_if_fail(gradient != NULL); - g_return_if_fail(SP_IS_GRADIENT(gradient)); - g_return_if_fail(buf != NULL); - g_return_if_fail(len > 0); - g_return_if_fail(pos >= 0); - g_return_if_fail(pos + len <= span); - g_return_if_fail(span > 0); - - if (!gradient->color) { - sp_gradient_ensure_colors(gradient); - } - - gint idx = (pos * 1024 << 8) / span; - gint didx = (1024 << 8) / span; - - for (gint x = 0; x < len; x++) { - /// \todo Can this be done with 4 byte copies? - *buf++ = gradient->color[4 * (idx >> 8)]; - *buf++ = gradient->color[4 * (idx >> 8) + 1]; - *buf++ = gradient->color[4 * (idx >> 8) + 2]; - *buf++ = gradient->color[4 * (idx >> 8) + 3]; - idx += didx; - } -} - -/** - * Render rectangular RGBA area from gradient vector. - */ -void -sp_gradient_render_vector_block_rgba(SPGradient *const gradient, guchar *buf, - gint const width, gint const height, gint const rowstride, - gint const pos, gint const span, bool const horizontal) -{ - g_return_if_fail(gradient != NULL); - g_return_if_fail(SP_IS_GRADIENT(gradient)); - g_return_if_fail(buf != NULL); - g_return_if_fail(width > 0); - g_return_if_fail(height > 0); - g_return_if_fail(pos >= 0); - g_return_if_fail((horizontal && (pos + width <= span)) || (!horizontal && (pos + height <= span))); - g_return_if_fail(span > 0); - - if (horizontal) { - sp_gradient_render_vector_line_rgba(gradient, buf, width, pos, span); - for (gint y = 1; y < height; y++) { - memcpy(buf + y * rowstride, buf, 4 * width); - } - } else { - guchar *tmp = (guchar *)alloca(4 * height); - sp_gradient_render_vector_line_rgba(gradient, tmp, height, pos, span); - for (gint y = 0; y < height; y++) { - guchar *b = buf + y * rowstride; - for (gint x = 0; x < width; x++) { - *b++ = tmp[0]; - *b++ = tmp[1]; - *b++ = tmp[2]; - *b++ = tmp[3]; - } - tmp += 4; - } - } -} - -/** - * Render rectangular RGB area from gradient vector. - */ -void -sp_gradient_render_vector_block_rgb(SPGradient *gradient, guchar *buf, - gint const width, gint const height, gint const /*rowstride*/, - gint const pos, gint const span, bool const horizontal) -{ - g_return_if_fail(gradient != NULL); - g_return_if_fail(SP_IS_GRADIENT(gradient)); - g_return_if_fail(buf != NULL); - g_return_if_fail(width > 0); - g_return_if_fail(height > 0); - g_return_if_fail(pos >= 0); - g_return_if_fail((horizontal && (pos + width <= span)) || (!horizontal && (pos + height <= span))); - g_return_if_fail(span > 0); - - if (horizontal) { - guchar *tmp = (guchar*)alloca(4 * width); - sp_gradient_render_vector_line_rgba(gradient, tmp, width, pos, span); - for (gint y = 0; y < height; y++) { - guchar *t = tmp; - for (gint x = 0; x < width; x++) { - gint a = t[3]; - gint fc = (t[0] - buf[0]) * a; - buf[0] = buf[0] + ((fc + (fc >> 8) + 0x80) >> 8); - fc = (t[1] - buf[1]) * a; - buf[1] = buf[1] + ((fc + (fc >> 8) + 0x80) >> 8); - fc = (t[2] - buf[2]) * a; - buf[2] = buf[2] + ((fc + (fc >> 8) + 0x80) >> 8); - buf += 3; - t += 4; - } - } - } else { - guchar *tmp = (guchar*)alloca(4 * height); - sp_gradient_render_vector_line_rgba(gradient, tmp, height, pos, span); - for (gint y = 0; y < height; y++) { - guchar *t = tmp + 4 * y; - for (gint x = 0; x < width; x++) { - gint a = t[3]; - gint fc = (t[0] - buf[0]) * a; - buf[0] = buf[0] + ((fc + (fc >> 8) + 0x80) >> 8); - fc = (t[1] - buf[1]) * a; - buf[1] = buf[1] + ((fc + (fc >> 8) + 0x80) >> 8); - fc = (t[2] - buf[2]) * a; - buf[2] = buf[2] + ((fc + (fc >> 8) + 0x80) >> 8); - } - } - } -} - Geom::Matrix sp_gradient_get_g2d_matrix(SPGradient const *gr, Geom::Matrix const &ctm, Geom::Rect const &bbox) { @@ -1401,16 +1113,6 @@ sp_gradient_set_gs2d_matrix(SPGradient *gr, Geom::Matrix const &ctm, * Linear Gradient */ -class SPLGPainter; - -/// A context with linear gradient, painter, and gradient renderer. -struct SPLGPainter { - SPPainter painter; - SPLinearGradient *lg; - - NRLGradientRenderer lgr; -}; - static void sp_lineargradient_class_init(SPLinearGradientClass *klass); static void sp_lineargradient_init(SPLinearGradient *lg); @@ -1420,14 +1122,7 @@ static void sp_lineargradient_build(SPObject *object, static void sp_lineargradient_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -static SPPainter *sp_lineargradient_painter_new(SPPaintServer *ps, - Geom::Matrix const &full_transform, - Geom::Matrix const &parent_transform, - NRRect const *bbox); -static void sp_lineargradient_painter_free(SPPaintServer *ps, SPPainter *painter); static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); -static void sp_lg_fill(SPPainter *painter, NRPixBlock *pb); static SPGradientClass *lg_parent_class; @@ -1468,8 +1163,6 @@ static void sp_lineargradient_class_init(SPLinearGradientClass *klass) sp_object_class->set = sp_lineargradient_set; sp_object_class->write = sp_lineargradient_write; - ps_class->painter_new = sp_lineargradient_painter_new; - ps_class->painter_free = sp_lineargradient_painter_free; ps_class->pattern_new = sp_lineargradient_create_pattern; } @@ -1559,85 +1252,6 @@ sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inks return repr; } -/** - * Create linear gradient context. - * - * Basically we have to deal with transformations - * - * 1) color2norm - maps point in (0,NCOLORS) vector to (0,1) vector - * 2) norm2pos - maps (0,1) vector to x1,y1 - x2,y2 - * 2) gradientTransform - * 3) bbox2user - * 4) ctm == userspace to pixel grid - * - * See also (*) in sp-pattern about why we may need parent_transform. - * - * \todo (point 1 above) fixme: I do not know how to deal with start > 0 - * and end < 1. - */ -static SPPainter * -sp_lineargradient_painter_new(SPPaintServer *ps, - Geom::Matrix const &full_transform, - Geom::Matrix const &/*parent_transform*/, - NRRect const *bbox) -{ - SPLinearGradient *lg = SP_LINEARGRADIENT(ps); - SPGradient *gr = SP_GRADIENT(ps); - - if (!gr->color) sp_gradient_ensure_colors(gr); - - SPLGPainter *lgp = g_new(SPLGPainter, 1); - - lgp->painter.type = SP_PAINTER_IND; - lgp->painter.fill = sp_lg_fill; - - lgp->lg = lg; - - /** \todo - * Technically speaking, we map NCOLORS on line [start,end] onto line - * [0,1]. I almost think we should fill color array start and end in - * that case. The alternative would be to leave these just empty garbage - * or something similar. Originally I had 1023.9999 here - not sure - * whether we have really to cut out ceil int (Lauris). - */ - Geom::Matrix color2norm(Geom::identity()); - Geom::Matrix color2px; - if (gr->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Matrix norm2pos(Geom::identity()); - - /* BBox to user coordinate system */ - Geom::Matrix bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); - - Geom::Matrix color2pos = color2norm * norm2pos; - Geom::Matrix color2tpos = color2pos * gr->gradientTransform; - Geom::Matrix color2user = color2tpos * bbox2user; - color2px = color2user * full_transform; - - } else { - /* Problem: What to do, if we have mixed lengths and percentages? */ - /* Currently we do ignore percentages at all, but that is not good (lauris) */ - - Geom::Matrix norm2pos(Geom::identity()); - Geom::Matrix color2pos = color2norm * norm2pos; - Geom::Matrix color2tpos = color2pos * gr->gradientTransform; - color2px = color2tpos * full_transform; - - } - // TODO: remove color2px_nr after converting to 2geom - NR::Matrix color2px_nr = from_2geom(color2px); - nr_lgradient_renderer_setup(&lgp->lgr, gr->color, sp_gradient_get_spread(gr), &color2px_nr, - lg->x1.computed, lg->y1.computed, - lg->x2.computed, lg->y2.computed); - - return (SPPainter *) lgp; -} - -static void -sp_lineargradient_painter_free(SPPaintServer */*ps*/, SPPainter *painter) -{ - g_free(painter); -} - /** * Directly set properties of linear gradient and request modified. */ @@ -1658,35 +1272,10 @@ sp_lineargradient_set_position(SPLinearGradient *lg, SP_OBJECT(lg)->requestModified(SP_OBJECT_MODIFIED_FLAG); } -/** - * Callback when linear gradient object is rendered. - */ -static void -sp_lg_fill(SPPainter *painter, NRPixBlock *pb) -{ - SPLGPainter *lgp = (SPLGPainter *) painter; - - if (lgp->lg->color == NULL) { - sp_gradient_ensure_colors (lgp->lg); - lgp->lgr.vector = lgp->lg->color; - } - - nr_render((NRRenderer *) &lgp->lgr, pb, NULL); -} - /* * Radial Gradient */ -class SPRGPainter; - -/// A context with radial gradient, painter, and gradient renderer. -struct SPRGPainter { - SPPainter painter; - SPRadialGradient *rg; - NRRGradientRenderer rgr; -}; - static void sp_radialgradient_class_init(SPRadialGradientClass *klass); static void sp_radialgradient_init(SPRadialGradient *rg); @@ -1696,16 +1285,8 @@ static void sp_radialgradient_build(SPObject *object, static void sp_radialgradient_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -static SPPainter *sp_radialgradient_painter_new(SPPaintServer *ps, - Geom::Matrix const &full_transform, - Geom::Matrix const &parent_transform, - NRRect const *bbox); -static void sp_radialgradient_painter_free(SPPaintServer *ps, SPPainter *painter); static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); -static void sp_rg_fill(SPPainter *painter, NRPixBlock *pb); - static SPGradientClass *rg_parent_class; /** @@ -1745,8 +1326,6 @@ static void sp_radialgradient_class_init(SPRadialGradientClass *klass) sp_object_class->set = sp_radialgradient_set; sp_object_class->write = sp_radialgradient_write; - ps_class->painter_new = sp_radialgradient_painter_new; - ps_class->painter_free = sp_radialgradient_painter_free; ps_class->pattern_new = sp_radialgradient_create_pattern; } @@ -1857,67 +1436,6 @@ sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inks return repr; } -/** - * Create radial gradient context. - */ -static SPPainter * -sp_radialgradient_painter_new(SPPaintServer *ps, - Geom::Matrix const &full_transform, - Geom::Matrix const &/*parent_transform*/, - NRRect const *bbox) -{ - SPRadialGradient *rg = SP_RADIALGRADIENT(ps); - SPGradient *gr = SP_GRADIENT(ps); - - if (!gr->color) sp_gradient_ensure_colors(gr); - - SPRGPainter *rgp = g_new(SPRGPainter, 1); - - rgp->painter.type = SP_PAINTER_IND; - rgp->painter.fill = sp_rg_fill; - - rgp->rg = rg; - - Geom::Matrix gs2px; - - if (gr->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - /** \todo - * fixme: We may try to normalize here too, look at - * linearGradient (Lauris) - */ - - /* BBox to user coordinate system */ - Geom::Matrix bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); - - Geom::Matrix gs2user = gr->gradientTransform * bbox2user; - - gs2px = gs2user * full_transform; - } else { - /** \todo - * Problem: What to do, if we have mixed lengths and percentages? - * Currently we do ignore percentages at all, but that is not - * good (lauris) - */ - - gs2px = gr->gradientTransform * full_transform; - } - // TODO: remove gs2px_nr after converting to 2geom - NR::Matrix gs2px_nr = from_2geom(gs2px); - nr_rgradient_renderer_setup(&rgp->rgr, gr->color, sp_gradient_get_spread(gr), - &gs2px_nr, - rg->cx.computed, rg->cy.computed, - rg->fx.computed, rg->fy.computed, - rg->r.computed); - - return (SPPainter *) rgp; -} - -static void -sp_radialgradient_painter_free(SPPaintServer */*ps*/, SPPainter *painter) -{ - g_free(painter); -} - /** * Directly set properties of radial gradient and request modified. */ @@ -1938,22 +1456,6 @@ sp_radialgradient_set_position(SPRadialGradient *rg, SP_OBJECT(rg)->requestModified(SP_OBJECT_MODIFIED_FLAG); } -/** - * Callback when radial gradient object is rendered. - */ -static void -sp_rg_fill(SPPainter *painter, NRPixBlock *pb) -{ - SPRGPainter *rgp = (SPRGPainter *) painter; - - if (rgp->rg->color == NULL) { - sp_gradient_ensure_colors (rgp->rg); - rgp->rgr.vector = rgp->rg->color; - } - - nr_render((NRRenderer *) &rgp->rgr, pb, NULL); -} - /* CAIRO RENDERING STUFF */ static void @@ -2003,7 +1505,7 @@ sp_radialgradient_create_pattern(SPPaintServer *ps, SPRadialGradient *rg = SP_RADIALGRADIENT(ps); SPGradient *gr = SP_GRADIENT(ps); - if (!gr->color) sp_gradient_ensure_colors(gr); + sp_gradient_ensure_vector(gr); cairo_pattern_t *cp = cairo_pattern_create_radial( rg->fx.computed, rg->fy.computed, 0, @@ -2023,7 +1525,7 @@ sp_lineargradient_create_pattern(SPPaintServer *ps, SPLinearGradient *lg = SP_LINEARGRADIENT(ps); SPGradient *gr = SP_GRADIENT(ps); - if (!gr->color) sp_gradient_ensure_colors(gr); + sp_gradient_ensure_vector(gr); cairo_pattern_t *cp = cairo_pattern_create_linear( lg->x1.computed, lg->y1.computed, @@ -2034,6 +1536,23 @@ sp_lineargradient_create_pattern(SPPaintServer *ps, return cp; } +cairo_pattern_t * +sp_gradient_create_preview_pattern(SPGradient *gr, double width) +{ + sp_gradient_ensure_vector(gr); + + cairo_pattern_t *pat = cairo_pattern_create_linear(0, 0, width, 0); + + for (std::vector::iterator i = gr->vector.stops.begin(); + i != gr->vector.stops.end(); ++i) + { + cairo_pattern_add_color_stop_rgba(pat, i->offset, + i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity); + } + + return pat; +} + /* Local Variables: mode:c++ diff --git a/src/sp-gradient.h b/src/sp-gradient.h index e7488673d..28099961d 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -18,7 +18,7 @@ */ #include -#include "libnr/nr-matrix.h" +#include <2geom/matrix.h> #include "sp-paint-server.h" #include "sp-gradient-spread.h" #include "sp-gradient-units.h" @@ -96,12 +96,8 @@ struct SPGradient : public SPPaintServer { /** Composed vector */ SPGradientVector vector; - /** Rendered color array (4 * 1024 bytes) */ - guchar *color; - sigc::connection modified_connection; - SPStop* getFirstStop(); int getStopCount() const; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5a2dfb2f0..10a5fbc59 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -58,11 +58,6 @@ #include "sp-title.h" #include "sp-desc.h" -#include "libnr/nr-matrix-fns.h" -#include "libnr/nr-matrix-scale-ops.h" -#include "libnr/nr-matrix-translate-ops.h" -#include "libnr/nr-scale-translate-ops.h" -#include "libnr/nr-translate-scale-ops.h" #include "libnr/nr-convert2geom.h" #include "util/find-last-if.h" #include "util/reverse-list.h" diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index e49e6a378..35a5ff1f1 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -14,7 +14,6 @@ */ #include -#include "libnr/nr-pixblock-pattern.h" #include "sp-paint-server.h" #include "sp-gradient.h" @@ -25,11 +24,9 @@ static void sp_paint_server_init(SPPaintServer *ps); static void sp_paint_server_release(SPObject *object); -static void sp_painter_stale_fill(SPPainter *painter, NRPixBlock *pb); static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); static SPObjectClass *parent_class; -static GSList *stale_painters = NULL; GType sp_paint_server_get_type (void) { @@ -62,52 +59,15 @@ static void sp_paint_server_class_init(SPPaintServerClass *psc) static void sp_paint_server_init(SPPaintServer *ps) { - ps->painters = NULL; } static void sp_paint_server_release(SPObject *object) { - SPPaintServer *ps = SP_PAINT_SERVER(object); - - while (ps->painters) { - SPPainter *painter = ps->painters; - ps->painters = painter->next; - stale_painters = g_slist_prepend(stale_painters, painter); - painter->next = NULL; - painter->server = NULL; - painter->fill = sp_painter_stale_fill; - } - if (((SPObjectClass *) parent_class)->release) { ((SPObjectClass *) parent_class)->release(object); } } -SPPainter *sp_paint_server_painter_new(SPPaintServer *ps, - Geom::Matrix const &full_transform, - Geom::Matrix const &parent_transform, - const NRRect *bbox) -{ - g_return_val_if_fail(ps != NULL, NULL); - g_return_val_if_fail(SP_IS_PAINT_SERVER(ps), NULL); - g_return_val_if_fail(bbox != NULL, NULL); - - SPPainter *painter = NULL; - SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps); - if ( psc->painter_new ) { - painter = (*psc->painter_new)(ps, full_transform, parent_transform, bbox); - } - - if (painter) { - painter->next = ps->painters; - painter->server = ps; - painter->type = (SPPainterType) G_OBJECT_TYPE(ps); - ps->painters = painter; - } - - return painter; -} - cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, @@ -138,55 +98,6 @@ sp_paint_server_create_dummy_pattern(SPPaintServer */*ps*/, return cp; } -static void sp_paint_server_painter_free(SPPaintServer *ps, SPPainter *painter) -{ - g_return_if_fail(ps != NULL); - g_return_if_fail(SP_IS_PAINT_SERVER(ps)); - g_return_if_fail(painter != NULL); - - SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps); - - SPPainter *r = NULL; - for (SPPainter *p = ps->painters; p != NULL; p = p->next) { - if (p == painter) { - if (r) { - r->next = p->next; - } else { - ps->painters = p->next; - } - p->next = NULL; - if (psc->painter_free) { - (*psc->painter_free) (ps, painter); - } - return; - } - r = p; - } - - g_assert_not_reached(); -} - -SPPainter *sp_painter_free(SPPainter *painter) -{ - g_return_val_if_fail(painter != NULL, NULL); - - if (painter->server) { - sp_paint_server_painter_free(painter->server, painter); - } else { - SPPaintServerClass *psc = (SPPaintServerClass *) g_type_class_ref(painter->type); - if (psc->painter_free) - (*psc->painter_free)(NULL, painter); - stale_painters = g_slist_remove(stale_painters, painter); - } - - return NULL; -} - -static void sp_painter_stale_fill(SPPainter */*painter*/, NRPixBlock *pb) -{ - nr_pixblock_render_gray_noise(pb, NULL); -} - bool SPPaintServer::isSwatch() const { bool swatch = false; @@ -217,9 +128,6 @@ bool SPPaintServer::isSolid() const return solid; } - - - /* Local Variables: mode:c++ diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index d1fc9b7ac..8c9af9f55 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -16,11 +16,11 @@ */ #include -#include #include "sp-object.h" #include "uri-references.h" -class SPPainter; +struct NRPixBlock; +struct NRRect; #define SP_TYPE_PAINT_SERVER (sp_paint_server_get_type ()) #define SP_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PAINT_SERVER, SPPaintServer)) @@ -28,26 +28,7 @@ class SPPainter; #define SP_IS_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_PAINT_SERVER)) #define SP_IS_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_PAINT_SERVER)) -typedef enum { - SP_PAINTER_IND, - SP_PAINTER_DEP -} SPPainterType; - -typedef void (* SPPainterFillFunc) (SPPainter *painter, NRPixBlock *pb); - -/* fixme: I do not like that class thingie (Lauris) */ -struct SPPainter { - SPPainter *next; - SPPaintServer *server; - GType server_type; - SPPainterType type; - SPPainterFillFunc fill; -}; - struct SPPaintServer : public SPObject { - /** List of paints */ - SPPainter *painters; - bool isSwatch() const; bool isSolid() const; }; @@ -55,20 +36,13 @@ struct SPPaintServer : public SPObject { struct SPPaintServerClass { SPObjectClass sp_object_class; /** Get SPPaint instance. */ - SPPainter * (* painter_new) (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &parent_transform, const NRRect *bbox); - /** Free SPPaint instance. */ - void (* painter_free) (SPPaintServer *ps, SPPainter *painter); - cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, const NRRect *bbox, double opacity); }; GType sp_paint_server_get_type (void); -SPPainter *sp_paint_server_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &parent_transform, const NRRect *bbox); cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); -SPPainter *sp_painter_free (SPPainter *painter); - class SPPaintServerReference : public Inkscape::URIReference { public: SPPaintServerReference (SPObject *obj) : URIReference(obj) {} diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 074873d5b..b2c718e3b 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -39,44 +39,18 @@ * Pattern */ -class SPPatPainter; - -struct SPPatPainter { - SPPainter painter; - SPPattern *pat; - - Geom::Matrix ps2px; - Geom::Matrix px2ps; - Geom::Matrix pcs2px; - - NRArena *arena; - unsigned int dkey; - NRArenaItem *root; - - bool use_cached_tile; - Geom::Matrix ca2pa; - Geom::Matrix pa2ca; - NRRectL cached_bbox; - NRPixBlock cached_tile; - - std::map *_release_connections; -}; - static void sp_pattern_class_init (SPPatternClass *klass); static void sp_pattern_init (SPPattern *gr); static void sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_pattern_release (SPObject *object); static void sp_pattern_set (SPObject *object, unsigned int key, const gchar *value); -static void sp_pattern_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); static void sp_pattern_update (SPObject *object, SPCtx *ctx, unsigned int flags); static void sp_pattern_modified (SPObject *object, unsigned int flags); static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); -static SPPainter *sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &parent_transform, const NRRect *bbox); -static void sp_pattern_painter_free (SPPaintServer *ps, SPPainter *painter); static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); static SPPaintServerClass * pattern_parent_class; @@ -117,14 +91,11 @@ sp_pattern_class_init (SPPatternClass *klass) sp_object_class->build = sp_pattern_build; sp_object_class->release = sp_pattern_release; sp_object_class->set = sp_pattern_set; - sp_object_class->child_added = sp_pattern_child_added; sp_object_class->update = sp_pattern_update; sp_object_class->modified = sp_pattern_modified; // do we need _write? seems to work without it - ps_class->painter_new = sp_pattern_painter_new; - ps_class->painter_free = sp_pattern_painter_free; ps_class->pattern_new = sp_pattern_create_pattern; } @@ -318,34 +289,6 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value) } } -static void -sp_pattern_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) -{ - SPPattern *pat = SP_PATTERN (object); - - if (((SPObjectClass *) (pattern_parent_class))->child_added) - (* ((SPObjectClass *) (pattern_parent_class))->child_added) (object, child, ref); - - SPObject *ochild = sp_object_get_child_by_repr(object, child); - if (SP_IS_ITEM (ochild)) { - - SPPaintServer *ps = SP_PAINT_SERVER (pat); - unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild)); - - for (SPPainter *p = ps->painters; p != NULL; p = p->next) { - - SPPatPainter *pp = (SPPatPainter *) p; - NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (ochild), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); - - if (ai) { - nr_arena_item_add_child (pp->root, ai, NULL); - nr_arena_item_set_order (ai, position); - nr_arena_item_unref (ai); - } - } - } -} - /* TODO: do we need a ::remove_child handler? */ /* fixme: We need ::order_changed handler too (Lauris) */ @@ -632,394 +575,6 @@ bool pattern_hasItemChildren (SPPattern *pat) return false; } - - -/* Painter */ - -static void sp_pat_fill (SPPainter *painter, NRPixBlock *pb); - -// item in this pattern is about to be deleted, hide it on our arena and disconnect -void -sp_pattern_painter_release (SPObject *obj, SPPatPainter *painter) -{ - std::map::iterator iter = painter->_release_connections->find(obj); - if (iter != painter->_release_connections->end()) { - iter->second.disconnect(); - painter->_release_connections->erase(obj); - } - - sp_item_invoke_hide(SP_ITEM(obj), painter->dkey); -} - -/** -Creates a painter (i.e. the thing that does actual filling at the given zoom). -See (*) below for why the parent_transform may be necessary. -*/ -static SPPainter * -sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, Geom::Matrix const &/*parent_transform*/, const NRRect *bbox) -{ - SPPattern *pat = SP_PATTERN (ps); - SPPatPainter *pp = g_new (SPPatPainter, 1); - - pp->painter.type = SP_PAINTER_IND; - pp->painter.fill = sp_pat_fill; - - pp->pat = pat; - - if (pattern_patternUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - /* BBox to user coordinate system */ - Geom::Matrix bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); - - // the final patternTransform, taking into account bbox - Geom::Matrix const ps2user(pattern_patternTransform(pat) * bbox2user); - - // see (*) comment below - pp->ps2px = ps2user * full_transform; - } else { - /* Problem: What to do, if we have mixed lengths and percentages? */ - /* Currently we do ignore percentages at all, but that is not good (lauris) */ - - /* fixme: We may try to normalize here too, look at linearGradient (Lauris) */ - - // (*) The spec says, "This additional transformation matrix [patternTransform] is - // post-multiplied to (i.e., inserted to the right of) any previously defined - // transformations, including the implicit transformation necessary to convert from - // object bounding box units to user space." To me, this means that the order should be: - // item_transform * patternTransform * parent_transform - // However both Batik and Adobe plugin use: - // patternTransform * item_transform * parent_transform - // So here I comply with the majority opinion, but leave my interpretation commented out below. - // (To get item_transform, I subtract parent from full.) - - //pp->ps2px = (full_transform / parent_transform) * pattern_patternTransform(pat) * parent_transform; - pp->ps2px = pattern_patternTransform(pat) * full_transform; - } - - pp->px2ps = pp->ps2px.inverse(); - - if (pat->viewBox_set) { - gdouble tmp_x = pattern_width (pat) / (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0); - gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0); - - // FIXME: preserveAspectRatio must be taken into account here too! - Geom::Matrix vb2ps (tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - pattern_viewBox(pat)->x0 * tmp_x, pattern_y(pat) - pattern_viewBox(pat)->y0 * tmp_y); - - Geom::Matrix vb2us = vb2ps * pattern_patternTransform(pat); - - // see (*) - pp->pcs2px = vb2us * full_transform; - } else { - /* No viewbox, have to parse units */ - if (pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - /* BBox to user coordinate system */ - Geom::Matrix bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); - - Geom::Matrix pcs2user = pattern_patternTransform(pat) * bbox2user; - - // see (*) - pp->pcs2px = pcs2user * full_transform; - } else { - // see (*) - //pcs2px = (full_transform / parent_transform) * pattern_patternTransform(pat) * parent_transform; - pp->pcs2px = pattern_patternTransform(pat) * full_transform; - } - - pp->pcs2px = Geom::Translate (pattern_x (pat), pattern_y (pat)) * pp->pcs2px; - } - - /* Create arena */ - pp->arena = NRArena::create(); - - pp->dkey = sp_item_display_key_new (1); - - /* Create group */ - pp->root = NRArenaGroup::create(pp->arena); - - /* Show items */ - pp->_release_connections = new std::map; - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - if (SP_IS_ITEM (child)) { - // for each item in pattern, - NRArenaItem *cai; - // show it on our arena, - cai = sp_item_invoke_show (SP_ITEM (child), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); - // add to the group, - nr_arena_item_append_child (pp->root, cai); - // and connect to the release signal in case the item gets deleted - pp->_release_connections->insert(std::make_pair(child, child->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_pattern_painter_release), pp)))); - } - } - break; // do not go further up the chain if children are found - } - } - - { - NRRect one_tile,tr_tile; - one_tile.x0=pattern_x(pp->pat); - one_tile.y0=pattern_y(pp->pat); - one_tile.x1=one_tile.x0+pattern_width (pp->pat); - one_tile.y1=one_tile.y0+pattern_height (pp->pat); - // TODO: remove ps2px_nr after converting to 2geom - NR::Matrix ps2px_nr = from_2geom(pp->ps2px); - nr_rect_d_matrix_transform (&tr_tile, &one_tile, &ps2px_nr); - int tr_width=(int)ceil(1.3*(tr_tile.x1-tr_tile.x0)); - int tr_height=(int)ceil(1.3*(tr_tile.y1-tr_tile.y0)); -// if ( tr_width < 10000 && tr_height < 10000 && tr_width*tr_height < 1000000 ) { - pp->use_cached_tile=false;//true; - if ( tr_width > 1000 ) tr_width=1000; - if ( tr_height > 1000 ) tr_height=1000; - pp->cached_bbox.x0=0; - pp->cached_bbox.y0=0; - pp->cached_bbox.x1=tr_width; - pp->cached_bbox.y1=tr_height; - - if (pp->use_cached_tile) { - nr_pixblock_setup (&pp->cached_tile,NR_PIXBLOCK_MODE_R8G8B8A8N, pp->cached_bbox.x0, pp->cached_bbox.y0, pp->cached_bbox.x1, pp->cached_bbox.y1,TRUE); - } - - pp->pa2ca[0]=((double)tr_width)/(one_tile.x1-one_tile.x0); - pp->pa2ca[1]=0; - pp->pa2ca[2]=0; - pp->pa2ca[3]=((double)tr_height)/(one_tile.y1-one_tile.y0); - pp->pa2ca[4]=-one_tile.x0*pp->pa2ca[0]; - pp->pa2ca[5]=-one_tile.y0*pp->pa2ca[1]; - pp->ca2pa[0]=(one_tile.x1-one_tile.x0)/((double)tr_width); - pp->ca2pa[1]=0; - pp->ca2pa[2]=0; - pp->ca2pa[3]=(one_tile.y1-one_tile.y0)/((double)tr_height); - pp->ca2pa[4]=one_tile.x0; - pp->ca2pa[5]=one_tile.y0; -// } else { -// pp->use_cached_tile=false; -// } - } - - NRGC gc(NULL); - if ( pp->use_cached_tile ) { - gc.transform=pp->pa2ca; - } else { - gc.transform = pp->pcs2px; - } - nr_arena_item_invoke_update (pp->root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); - if ( pp->use_cached_tile ) { - nr_arena_item_invoke_render (NULL, pp->root, &pp->cached_bbox, &pp->cached_tile, 0); - } else { - // nothing to do now - } - - return (SPPainter *) pp; -} - - -static void -sp_pattern_painter_free (SPPaintServer */*ps*/, SPPainter *painter) -{ - SPPatPainter *pp = (SPPatPainter *) painter; - // free our arena - if (pp->arena) { - ((NRObject *) pp->arena)->unreference(); - pp->arena = NULL; - } - - // disconnect all connections - std::map::iterator iter; - for (iter = pp->_release_connections->begin() ; iter!=pp->_release_connections->end() ; iter++) { - iter->second.disconnect(); - } - pp->_release_connections->clear(); - delete pp->_release_connections; - - if ( pp->use_cached_tile ) nr_pixblock_release(&pp->cached_tile); - g_free (pp); -} - -void -get_cached_tile_pixel(SPPatPainter* pp,double x,double y,unsigned char &r,unsigned char &g,unsigned char &b,unsigned char &a) -{ - int ca_h=(int)floor(x); - int ca_v=(int)floor(y); - int r_x=(int)floor(16*(x-floor(x))); - int r_y=(int)floor(16*(y-floor(y))); - unsigned int tl_m=(16-r_x)*(16-r_y); - unsigned int bl_m=(16-r_x)*r_y; - unsigned int tr_m=r_x*(16-r_y); - unsigned int br_m=r_x*r_y; - int cb_h=ca_h+1; - int cb_v=ca_v+1; - if ( cb_h >= pp->cached_bbox.x1 ) cb_h=0; - if ( cb_v >= pp->cached_bbox.y1 ) cb_v=0; - - unsigned char* tlx=NR_PIXBLOCK_PX(&pp->cached_tile)+(ca_v*pp->cached_tile.rs)+4*ca_h; - unsigned char* trx=NR_PIXBLOCK_PX(&pp->cached_tile)+(ca_v*pp->cached_tile.rs)+4*cb_h; - unsigned char* blx=NR_PIXBLOCK_PX(&pp->cached_tile)+(cb_v*pp->cached_tile.rs)+4*ca_h; - unsigned char* brx=NR_PIXBLOCK_PX(&pp->cached_tile)+(cb_v*pp->cached_tile.rs)+4*cb_h; - - unsigned int tl_c=tlx[0]; - unsigned int tr_c=trx[0]; - unsigned int bl_c=blx[0]; - unsigned int br_c=brx[0]; - unsigned int f_c=(tl_m*tl_c+tr_m*tr_c+bl_m*bl_c+br_m*br_c)>>8; - r=f_c; - tl_c=tlx[1]; - tr_c=trx[1]; - bl_c=blx[1]; - br_c=brx[1]; - f_c=(tl_m*tl_c+tr_m*tr_c+bl_m*bl_c+br_m*br_c)>>8; - g=f_c; - tl_c=tlx[2]; - tr_c=trx[2]; - bl_c=blx[2]; - br_c=brx[2]; - f_c=(tl_m*tl_c+tr_m*tr_c+bl_m*bl_c+br_m*br_c)>>8; - b=f_c; - tl_c=tlx[3]; - tr_c=trx[3]; - bl_c=blx[3]; - br_c=brx[3]; - f_c=(tl_m*tl_c+tr_m*tr_c+bl_m*bl_c+br_m*br_c)>>8; - a=f_c; -} - -static void -sp_pat_fill (SPPainter *painter, NRPixBlock *pb) -{ - SPPatPainter *pp; - NRRect ba, psa; - NRRectL area; - double x, y; - - pp = (SPPatPainter *) painter; - - if (pattern_width (pp->pat) < NR_EPSILON) return; - if (pattern_height (pp->pat) < NR_EPSILON) return; - - /* Find buffer area in gradient space */ - /* fixme: This is suboptimal (Lauris) */ - - if ( pp->use_cached_tile ) { - double pat_w=pattern_width (pp->pat); - double pat_h=pattern_height (pp->pat); - if ( pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8N || pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8P ) { // same thing because it's filling an empty pixblock - unsigned char* lpx=NR_PIXBLOCK_PX(pb); - double px_y=pb->area.y0; - for (int j=pb->area.y0;jarea.y1;j++) { - unsigned char* cpx=lpx; - double px_x = pb->area.x0; - - double ps_x=pp->px2ps[0]*px_x+pp->px2ps[2]*px_y+pp->px2ps[4]; - double ps_y=pp->px2ps[1]*px_x+pp->px2ps[3]*px_y+pp->px2ps[5]; - for (int i=pb->area.x0;iarea.x1;i++) { - while ( ps_x > pat_w ) ps_x-=pat_w; - while ( ps_x < 0 ) ps_x+=pat_w; - while ( ps_y > pat_h ) ps_y-=pat_h; - while ( ps_y < 0 ) ps_y+=pat_h; - double ca_x=pp->pa2ca[0]*ps_x+pp->pa2ca[2]*ps_y+pp->pa2ca[4]; - double ca_y=pp->pa2ca[1]*ps_x+pp->pa2ca[3]*ps_y+pp->pa2ca[5]; - unsigned char n_a,n_r,n_g,n_b; - get_cached_tile_pixel(pp,ca_x,ca_y,n_r,n_g,n_b,n_a); - cpx[0]=n_r; - cpx[1]=n_g; - cpx[2]=n_b; - cpx[3]=n_a; - - px_x+=1.0; - ps_x+=pp->px2ps[0]; - ps_y+=pp->px2ps[1]; - cpx+=4; - } - px_y+=1.0; - lpx+=pb->rs; - } - } else if ( pb->mode == NR_PIXBLOCK_MODE_R8G8B8 ) { - unsigned char* lpx=NR_PIXBLOCK_PX(pb); - double px_y=pb->area.y0; - for (int j=pb->area.y0;jarea.y1;j++) { - unsigned char* cpx=lpx; - double px_x = pb->area.x0; - - double ps_x=pp->px2ps[0]*px_x+pp->px2ps[2]*px_y+pp->px2ps[4]; - double ps_y=pp->px2ps[1]*px_x+pp->px2ps[3]*px_y+pp->px2ps[5]; - for (int i=pb->area.x0;iarea.x1;i++) { - while ( ps_x > pat_w ) ps_x-=pat_w; - while ( ps_x < 0 ) ps_x+=pat_w; - while ( ps_y > pat_h ) ps_y-=pat_h; - while ( ps_y < 0 ) ps_y+=pat_h; - double ca_x=pp->pa2ca[0]*ps_x+pp->pa2ca[2]*ps_y+pp->pa2ca[4]; - double ca_y=pp->pa2ca[1]*ps_x+pp->pa2ca[3]*ps_y+pp->pa2ca[5]; - unsigned char n_a,n_r,n_g,n_b; - get_cached_tile_pixel(pp,ca_x,ca_y,n_r,n_g,n_b,n_a); - cpx[0]=n_r; - cpx[1]=n_g; - cpx[2]=n_b; - - px_x+=1.0; - ps_x+=pp->px2ps[0]; - ps_y+=pp->px2ps[1]; - cpx+=4; - } - px_y+=1.0; - lpx+=pb->rs; - } - } - } else { - ba.x0 = pb->area.x0; - ba.y0 = pb->area.y0; - ba.x1 = pb->area.x1; - ba.y1 = pb->area.y1; - - // Trying to solve this bug: https://bugs.launchpad.net/inkscape/+bug/167416 - // Bail out if the transformation matrix has extreme values. If we bail out - // however, then something (which was meaningless anyway) won't be rendered, - // which is better than getting stuck in a virtually infinite loop - if (fabs(pp->px2ps[0]) < 1e6 && - fabs(pp->px2ps[3]) < 1e6 && - fabs(pp->px2ps[4]) < 1e6 && - fabs(pp->px2ps[5]) < 1e6) - { - // TODO: remove px2ps_nr after converting to 2geom - NR::Matrix px2ps_nr = from_2geom(pp->px2ps); - nr_rect_d_matrix_transform (&psa, &ba, &px2ps_nr); - - psa.x0 = floor ((psa.x0 - pattern_x (pp->pat)) / pattern_width (pp->pat)) -1; - psa.y0 = floor ((psa.y0 - pattern_y (pp->pat)) / pattern_height (pp->pat)) -1; - psa.x1 = ceil ((psa.x1 - pattern_x (pp->pat)) / pattern_width (pp->pat)) +1; - psa.y1 = ceil ((psa.y1 - pattern_y (pp->pat)) / pattern_height (pp->pat)) +1; - - // If psa is too wide or tall, then something must be wrong! This is due to - // nr_rect_d_matrix_transform (&psa, &ba, &pp->px2ps) using a weird transformation matrix pp->px2ps. - g_assert(std::abs(psa.x1 - psa.x0) < 1e6); - g_assert(std::abs(psa.y1 - psa.y0) < 1e6); - - for (y = psa.y0; y < psa.y1; y++) { - for (x = psa.x0; x < psa.x1; x++) { - NRPixBlock ppb; - double psx, psy; - - psx = x * pattern_width (pp->pat); - psy = y * pattern_height (pp->pat); - - area.x0 = (gint32)(pb->area.x0 - (pp->ps2px[0] * psx + pp->ps2px[2] * psy)); - area.y0 = (gint32)(pb->area.y0 - (pp->ps2px[1] * psx + pp->ps2px[3] * psy)); - area.x1 = area.x0 + pb->area.x1 - pb->area.x0; - area.y1 = area.y0 + pb->area.y1 - pb->area.y0; - - // We do not update here anymore - - // Set up buffer - // fixme: (Lauris) - nr_pixblock_setup_extern (&ppb, pb->mode, area.x0, area.y0, area.x1, area.y1, NR_PIXBLOCK_PX (pb), pb->rs, FALSE, FALSE); - - nr_arena_item_invoke_render (NULL, pp->root, &area, &ppb, 0); - - nr_pixblock_release (&ppb); - } - } - } - } -} - static cairo_pattern_t * sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *base_ct, @@ -1108,7 +663,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, // TODO: make sure there are no leaks. NRGC gc(NULL); - gc.transform = vb2ps;//Geom::identity(); + gc.transform = vb2ps; nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); nr_arena_item_invoke_render (ct, root, &one_tile, NULL, 0); nr_object_unref(arena); diff --git a/src/sp-pattern.h b/src/sp-pattern.h index f15285e27..8ca97e0a7 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -27,7 +27,6 @@ GType sp_pattern_get_type (void); class SPPatternClass; #include -#include #include "svg/svg-length.h" #include "sp-paint-server.h" #include "uri-references.h" diff --git a/src/sp-root.cpp b/src/sp-root.cpp index bd935074d..adcad5ebb 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -27,11 +27,6 @@ #include "document.h" #include "sp-defs.h" #include "sp-root.h" -#include -#include -#include -#include -#include #include #include "svg/stringstream.h" #include "inkscape-version.h" diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 3064341b6..30a94302e 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -16,10 +16,6 @@ # include "config.h" #endif -#include -#include -#include -#include #include <2geom/rect.h> #include <2geom/transforms.h> #include <2geom/pathvector.h> @@ -270,7 +266,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) style = SP_OBJECT_STYLE (object); if (style->stroke_width.unit == SP_CSS_UNIT_PERCENT) { SPItemCtx *ictx = (SPItemCtx *) ctx; - double const aw = 1.0 / NR::expansion(ictx->i2vp); + double const aw = 1.0 / ictx->i2vp.descrim(); style->stroke_width.computed = style->stroke_width.value * aw; for (SPItemView *v = ((SPItem *) (shape))->display; v != NULL; v = v->next) { nr_arena_shape_set_style ((NRArenaShape *) v->arenaitem, style); diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 61951cf64..eb0b144c6 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -24,7 +24,6 @@ class SPSymbol; class SPSymbolClass; -#include #include <2geom/matrix.h> #include #include "svg/svg-length.h" diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 6e05f6c03..d4c8d0d0c 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -28,6 +28,7 @@ #include "document-private.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" +#include "libnr/nr-pixblock.h" #include "ui/cache/svg_preview_cache.h" diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index cb6cfbbbe..a71f0789f 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -13,13 +13,14 @@ #include #include #include +#include #include "color-item.h" #include "desktop.h" #include "desktop-handles.h" #include "desktop-style.h" -#include "display/nr-plain-stuff.h" +#include "display/cairo-utils.h" #include "document.h" #include "inkscape.h" // for SP_ACTIVE_DESKTOP #include "io/resource.h" @@ -211,17 +212,20 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin } else { GdkPixbuf* pixbuf = 0; if ( item->getGradient() ){ - guchar* px = g_new( guchar, 3 * height * width ); - nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 ); - - sp_gradient_render_vector_block_rgb( item->getGradient(), - px, width, height, 3 * width, - 0, width, TRUE ); - - pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8, - width, height, width * 3, - 0, // add delete function - 0 ); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + cairo_pattern_t *gradient = sp_gradient_create_preview_pattern(item->getGradient(), width); + cairo_t *ct = cairo_create(s); + cairo_set_source(ct, gradient); + cairo_paint(ct); + cairo_destroy(ct); + cairo_pattern_destroy(gradient); + cairo_surface_flush(s); + + pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), + GDK_COLORSPACE_RGB, TRUE, 8, + width, height, cairo_image_surface_get_stride(s), + (GdkPixbufDestroyNotify) cairo_surface_destroy, NULL); + convert_pixbuf_argb32_to_normal(pixbuf); } else { Glib::RefPtr thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height ); guint32 fillWith = (0xff000000 & (item->def.getR() << 24)) @@ -251,10 +255,8 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin // } -SwatchPage::SwatchPage() : - _name(), - _prefWidth(0), - _colors() +SwatchPage::SwatchPage() + : _prefWidth(0) { } @@ -264,10 +266,7 @@ SwatchPage::~SwatchPage() ColorItem::ColorItem(ege::PaintDef::ColorType type) : - Previewable(), def(type), - tips(), - _previews(), _isFill(false), _isStroke(false), _isLive(false), @@ -276,18 +275,12 @@ ColorItem::ColorItem(ege::PaintDef::ColorType type) : _linkGray(0), _linkSrc(0), _grad(0), - _pixData(0), - _pixWidth(0), - _pixHeight(0), - _listeners() + _pattern(0) { } ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) : - Previewable(), def( r, g, b, name ), - tips(), - _previews(), _isFill(false), _isStroke(false), _isLive(false), @@ -296,15 +289,15 @@ ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustr _linkGray(0), _linkSrc(0), _grad(0), - _pixData(0), - _pixWidth(0), - _pixHeight(0), - _listeners() + _pattern(0) { } ColorItem::~ColorItem() { + if (_pattern != NULL) { + cairo_pattern_destroy(_pattern); + } } ColorItem::ColorItem(ColorItem const &other) : @@ -360,18 +353,16 @@ void ColorItem::setGradient(SPGradient *grad) } } -void ColorItem::setPixData(guchar* px, int width, int height) +void ColorItem::setPattern(cairo_pattern_t *pattern) { - if (px != _pixData) { - if (_pixData) { - g_free(_pixData); - } - _pixData = px; - _pixWidth = width; - _pixHeight = height; - - _updatePreviews(); + if (pattern) { + cairo_pattern_reference(pattern); + } + if (_pattern) { + cairo_pattern_destroy(_pattern); } + _pattern = pattern; + _updatePreviews(); } void ColorItem::_dragGetColorData( GtkWidget */*widget*/, @@ -519,16 +510,28 @@ void ColorItem::_regenPreview(EekPreview * preview) eek_preview_set_pixbuf( preview, pixbuf ); } - else if ( !_pixData ){ + else if ( !_pattern ){ eek_preview_set_color( preview, (def.getR() << 8) | def.getR(), (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB() ); } else { - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( _pixData, GDK_COLORSPACE_RGB, FALSE, 8, - _pixWidth, _pixHeight, _pixWidth * 3, - 0, // add delete function - 0 ); + double w; + cairo_pattern_get_linear_points(_pattern, NULL, NULL, &w, NULL); + int width = ceil(w); + + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, 1); + cairo_t *ct = cairo_create(s); + cairo_set_source(ct, _pattern); + cairo_paint(ct); + cairo_destroy(ct); + cairo_surface_flush(s); + + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), + GDK_COLORSPACE_RGB, TRUE, 8, + width, 1, cairo_image_surface_get_stride(s), + (GdkPixbufDestroyNotify) cairo_surface_destroy, NULL); + convert_pixbuf_argb32_to_normal(pixbuf); eek_preview_set_pixbuf( preview, pixbuf ); } diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h index 4aac86a30..de4618bc0 100644 --- a/src/ui/dialog/color-item.h +++ b/src/ui/dialog/color-item.h @@ -58,8 +58,7 @@ public: void setGradient(SPGradient *grad); SPGradient * getGradient() const { return _grad; } - - void setPixData(guchar* px, int width, int height); + void setPattern(cairo_pattern_t *pattern); void setState( bool fill, bool stroke ); bool isFill() { return _isFill; } @@ -104,9 +103,7 @@ private: int _linkGray; ColorItem* _linkSrc; SPGradient* _grad; - guchar *_pixData; - int _pixWidth; - int _pixHeight; + cairo_pattern_t *_pattern; std::vector _listeners; }; diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 6f013f4f3..163b49867 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -46,7 +46,7 @@ #include "ui/previewholder.h" #include "widgets/gradient-vector.h" #include "widgets/eek-preview.h" -#include "display/nr-plain-stuff.h" +#include "display/cairo-utils.h" #include "sp-gradient-reference.h" @@ -714,7 +714,7 @@ void SwatchesPanel::_setDocument( SPDocument *document ) static void recalcSwatchContents(SPDocument* doc, std::vector &tmpColors, - std::map &previewMappings, + std::map &previewMappings, std::map &gradMappings) { std::vector newList; @@ -731,30 +731,28 @@ static void recalcSwatchContents(SPDocument* doc, for ( std::vector::iterator it = newList.begin(); it != newList.end(); ++it ) { SPGradient* grad = *it; - sp_gradient_ensure_vector( grad ); - SPGradientStop first = grad->vector.stops[0]; - SPColor color = first.color; - guint32 together = color.toRGBA32(first.opacity); - - SPGradientStop second = (*it)->vector.stops[1]; - SPColor color2 = second.color; + cairo_surface_t *preview = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + PREVIEW_PIXBUF_WIDTH, VBLOCK); + cairo_t *ct = cairo_create(preview); Glib::ustring name( grad->getId() ); - unsigned int r = SP_RGBA32_R_U(together); - unsigned int g = SP_RGBA32_G_U(together); - unsigned int b = SP_RGBA32_B_U(together); - ColorItem* item = new ColorItem( r, g, b, name ); + ColorItem* item = new ColorItem( 0, 0, 0, name ); + + cairo_pattern_t *check = ink_cairo_pattern_create_checkerboard(); + cairo_pattern_t *gradient = sp_gradient_create_preview_pattern(grad, PREVIEW_PIXBUF_WIDTH); + cairo_set_source(ct, check); + cairo_paint(ct); + cairo_set_source(ct, gradient); + cairo_paint(ct); - gint width = PREVIEW_PIXBUF_WIDTH; - gint height = VBLOCK; - guchar* px = g_new( guchar, 3 * height * width ); - nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 ); + cairo_destroy(ct); + cairo_pattern_destroy(gradient); + cairo_pattern_destroy(check); - sp_gradient_render_vector_block_rgb( grad, - px, width, height, 3 * width, - 0, width, TRUE ); + cairo_pattern_t *prevpat = cairo_pattern_create_for_surface(preview); + cairo_surface_destroy(preview); - previewMappings[item] = px; + previewMappings[item] = prevpat; tmpColors.push_back(item); gradMappings[item] = grad; @@ -767,12 +765,13 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette) { std::vector tmpColors; - std::map tmpPrevs; + std::map tmpPrevs; std::map tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); - for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { - it->first->setPixData(it->second, PREVIEW_PIXBUF_WIDTH, VBLOCK); + for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { + it->first->setPattern(it->second); + cairo_pattern_destroy(it->second); } for (std::map::iterator it = tmpGrads.begin(); it != tmpGrads.end(); ++it) { @@ -784,7 +783,6 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) delete *it; } - // Figure out which SwatchesPanel instances are affected and update them. for (std::map::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) { @@ -805,7 +803,7 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette) { std::vector tmpColors; - std::map tmpPrevs; + std::map tmpPrevs; std::map tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); @@ -823,9 +821,16 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) oldColor->setGradient(tmpGrads[newColor]); } if ( tmpPrevs.find(newColor) != tmpPrevs.end() ) { - oldColor->setPixData(tmpPrevs[newColor], PREVIEW_PIXBUF_WIDTH, VBLOCK); + oldColor->setPattern(tmpPrevs[newColor]); } } + + for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { + cairo_pattern_destroy(it->second); + } + for (std::vector::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) { + delete *it; + } } } diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 11d2d528a..c4b7216c6 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -14,8 +14,7 @@ #include #include "macros.h" -#include "../display/nr-plain-stuff.h" -#include "../display/nr-plain-stuff-gdk.h" +#include "display/cairo-utils.h" #include "gradient-image.h" #include "sp-gradient.h" #include "sp-gradient-fns.h" @@ -29,10 +28,7 @@ static void sp_gradient_image_class_init (SPGradientImageClass *klass); static void sp_gradient_image_init (SPGradientImage *image); static void sp_gradient_image_destroy (GtkObject *object); -static void sp_gradient_image_realize (GtkWidget *widget); -static void sp_gradient_image_unrealize (GtkWidget *widget); static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void sp_gradient_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gint sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event); static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im); @@ -76,10 +72,7 @@ sp_gradient_image_class_init (SPGradientImageClass *klass) object_class->destroy = sp_gradient_image_destroy; - widget_class->realize = sp_gradient_image_realize; - widget_class->unrealize = sp_gradient_image_unrealize; widget_class->size_request = sp_gradient_image_size_request; - widget_class->size_allocate = sp_gradient_image_size_allocate; widget_class->expose_event = sp_gradient_image_expose; } @@ -89,7 +82,6 @@ sp_gradient_image_init (SPGradientImage *image) GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW); image->gradient = NULL; - image->px = NULL; new (&image->release_connection) sigc::connection(); new (&image->modified_connection) sigc::connection(); @@ -115,105 +107,40 @@ sp_gradient_image_destroy (GtkObject *object) (* ((GtkObjectClass *) (parent_class))->destroy) (object); } -static void -sp_gradient_image_realize (GtkWidget *widget) -{ - SPGradientImage *image; - - image = SP_GRADIENT_IMAGE (widget); - - if (((GtkWidgetClass *) parent_class)->realize) - (* ((GtkWidgetClass *) parent_class)->realize) (widget); - - g_assert (!image->px); - image->px = g_new (guchar, 3 * VBLOCK * widget->allocation.width); - sp_gradient_image_update (image); -} - -static void -sp_gradient_image_unrealize (GtkWidget *widget) -{ - SPGradientImage *image; - - image = SP_GRADIENT_IMAGE (widget); - - if (((GtkWidgetClass *) parent_class)->unrealize) - (* ((GtkWidgetClass *) parent_class)->unrealize) (widget); - - g_assert (image->px); - g_free (image->px); - image->px = NULL; -} - static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition) { - SPGradientImage *slider; - - slider = SP_GRADIENT_IMAGE (widget); - requisition->width = 64; requisition->height = 12; } -static void -sp_gradient_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - SPGradientImage *image; - - image = SP_GRADIENT_IMAGE (widget); - - widget->allocation = *allocation; - - if (GTK_WIDGET_REALIZED (widget)) { - g_free (image->px); - image->px = g_new (guchar, 3 * VBLOCK * allocation->width); - } - - sp_gradient_image_update (image); -} - static gint sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event) { - SPGradientImage *image; - - image = SP_GRADIENT_IMAGE (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) { - gint x0, y0, x1, y1; - x0 = MAX (event->area.x, widget->allocation.x); - y0 = MAX (event->area.y, widget->allocation.y); - x1 = MIN (event->area.x + event->area.width, widget->allocation.x + widget->allocation.width); - y1 = MIN (event->area.y + event->area.height, widget->allocation.y + widget->allocation.height); - if ((x1 > x0) && (y1 > y0)) { - if (image->px) { - if (image->gradient) { - gint y; - guchar *p; - p = image->px + 3 * (x0 - widget->allocation.x); - for (y = y0; y < y1; y += VBLOCK) { - gdk_draw_rgb_image (widget->window, widget->style->black_gc, - x0, y, - (x1 - x0), MIN (VBLOCK, y1 - y), - GDK_RGB_DITHER_MAX, - p, widget->allocation.width * 3); - } - } else { - nr_gdk_draw_gray_garbage (widget->window, widget->style->black_gc, - x0, y0, - x1 - x0, y1 - y0); - } - } else { - gdk_draw_rectangle (widget->window, widget->style->black_gc, - x0, y0, - (x1 - x0), (y1 - x0), - TRUE); - } - } - } - - return TRUE; + SPGradientImage *image = SP_GRADIENT_IMAGE (widget); + SPGradient *gr = image->gradient; + + cairo_t *ct = gdk_cairo_create(widget->window); + + cairo_rectangle(ct, event->area.x, event->area.y, + event->area.width, event->area.height); + cairo_clip(ct); + cairo_translate(ct, widget->allocation.x, widget->allocation.y); + + cairo_pattern_t *check = ink_cairo_pattern_create_checkerboard(); + cairo_set_source(ct, check); + cairo_paint(ct); + cairo_pattern_destroy(check); + + if (gr) { + cairo_pattern_t *p = sp_gradient_create_preview_pattern(gr, widget->allocation.width); + cairo_set_source(ct, p); + cairo_paint(ct); + cairo_pattern_destroy(p); + } + cairo_destroy(ct); + + return TRUE; } GtkWidget * @@ -268,26 +195,6 @@ sp_gradient_image_gradient_modified (SPObject *, guint /*flags*/, SPGradientImag static void sp_gradient_image_update (SPGradientImage *image) { - GtkAllocation *allocation; - - if (!image->px) return; - - allocation = &((GtkWidget *) image)->allocation; - - if (image->gradient) { - nr_render_checkerboard_rgb (image->px, allocation->width, VBLOCK, 3 * allocation->width, 0, 0); - sp_gradient_render_vector_block_rgb (image->gradient, - image->px, allocation->width, VBLOCK, 3 * allocation->width, - 0, allocation->width, TRUE); - } else { - NRPixBlock pb; - nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8, - 0, 0, allocation->width, VBLOCK, - image->px, 3 * allocation->width, TRUE, FALSE); - nr_pixblock_render_gray_noise (&pb, NULL); - nr_pixblock_release (&pb); - } - if (GTK_WIDGET_DRAWABLE (image)) { gtk_widget_queue_draw (GTK_WIDGET (image)); } diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h index d0864b6e8..3ddd14e35 100644 --- a/src/widgets/gradient-image.h +++ b/src/widgets/gradient-image.h @@ -14,7 +14,6 @@ */ #include -#include "../libnr/nr-matrix.h" class SPGradient; #include @@ -30,7 +29,6 @@ class SPGradient; struct SPGradientImage { GtkWidget widget; SPGradient *gradient; - guchar *px; sigc::connection release_connection; sigc::connection modified_connection; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 1eb3ef0ab..4ba86b295 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1024,15 +1024,8 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, CAIRO_FORMAT_ARGB32, psize, psize, stride); cairo_t *ct = cairo_create(s); - NRPixBlock B; - nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, - ua.x0, ua.y0, ua.x1, ua.y1, - px + stride * (ua.y0 - area.y0) + - 4 * (ua.x0 - area.x0), - stride, FALSE, FALSE ); - nr_arena_item_invoke_render(ct, root, &ua, &B, + nr_arena_item_invoke_render(ct, root, &ua, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); - nr_pixblock_release(&B); cairo_destroy(ct); cairo_surface_destroy(s); -- cgit v1.2.3 From 57a6fee4d17b6049b95ccf2ef445ed18c8a2a841 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 23:08:41 +0200 Subject: Wholesale cruft removal part 2 (bzr r9508.1.45) --- src/filter-chemistry.cpp | 1 - src/gradient-chemistry.cpp | 4 ---- src/knot-holder-entity.cpp | 1 - src/libnrtype/Layout-TNG-Output.cpp | 5 +---- src/libnrtype/Layout-TNG.h | 2 -- src/livarot/Path.cpp | 1 - src/livarot/ShapeMisc.cpp | 4 ++-- src/sp-clippath.cpp | 1 - src/sp-conn-end.cpp | 1 - src/sp-ellipse.cpp | 2 -- src/sp-flowdiv.cpp | 1 - src/sp-gradient.cpp | 3 --- src/sp-image.cpp | 19 +++++-------------- src/sp-item-group.cpp | 2 -- src/sp-line.cpp | 5 ++--- src/sp-mask.cpp | 1 - src/sp-offset.cpp | 2 +- src/sp-path.cpp | 3 +-- src/sp-pattern.cpp | 6 ++---- src/sp-rect.cpp | 4 +--- src/sp-symbol.cpp | 2 -- src/sp-text.cpp | 1 - src/sp-tref.cpp | 1 - src/sp-tspan.cpp | 1 - src/sp-use.cpp | 2 -- src/spray-context.cpp | 2 -- src/svg/svg-affine.cpp | 3 --- src/text-chemistry.cpp | 13 ++++++------- src/trace/trace.cpp | 27 +++++++++++++-------------- src/tweak-context.cpp | 2 -- src/ui/dialog/transformation.cpp | 1 - 31 files changed, 34 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 298531db0..0361f9276 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -26,7 +26,6 @@ #include "sp-filter.h" #include "sp-filter-reference.h" #include "svg/css-ostringstream.h" -#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index c95c1b2c5..88aab0c38 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -29,10 +29,6 @@ #include "sp-text.h" #include "sp-tspan.h" -#include -#include -#include -#include #include <2geom/transforms.h> #include "xml/repr.h" #include "svg/svg.h" diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 2d0d5eb02..71d2c8235 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -21,7 +21,6 @@ #include "style.h" #include "preferences.h" #include "macros.h" -#include #include "sp-pattern.h" #include "snap.h" #include "desktop.h" diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index f34b93d6e..836b86939 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -15,9 +15,6 @@ #include "print.h" #include "extension/print.h" #include "livarot/Path.h" -#include "libnr/nr-matrix-fns.h" -#include "libnr/nr-scale-matrix-ops.h" -#include "libnr/nr-convert2geom.h" #include "font-instance.h" #include "svg/svg-length.h" #include "extension/internal/cairo-render-context.h" @@ -288,7 +285,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const } } while (glyph_index < _glyphs.size() && _path_fitted == NULL - && NR::transform_equalp(font_matrix, glyph_matrix, NR_EPSILON) + && (font_matrix * glyph_matrix.inverse()).isIdentity() && _characters[_glyphs[glyph_index].in_character].in_span == this_span_index); // remove vertical flip diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 0a2463a56..1f82aab97 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -14,8 +14,6 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include #include #include <2geom/d2.h> #include <2geom/matrix.h> diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp index 66ec87274..2a1851cfe 100644 --- a/src/livarot/Path.cpp +++ b/src/livarot/Path.cpp @@ -9,7 +9,6 @@ #include #include "Path.h" #include "livarot/path-description.h" -#include /* * manipulation of the path data: path description and polyline diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index d6ca8c533..a82da4c8a 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -7,14 +7,14 @@ */ #include "livarot/Shape.h" -#include -#include #include "livarot/Path.h" #include "livarot/path-description.h" #include #include #include #include +#include <2geom/point.h> +#include <2geom/matrix.h> /* * polygon offset and polyline to path reassembling (when using back data) diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 4bbabc965..2d42f37f4 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -25,7 +25,6 @@ #include "document-private.h" #include "sp-item.h" -#include "libnr/nr-matrix-ops.h" #include <2geom/transforms.h> #include "sp-clippath.h" diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 3ad6954a2..33ef98b76 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -4,7 +4,6 @@ #include #include "display/curve.h" -#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" #include "sp-conn-end.h" #include "sp-path.h" diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 88fc59f17..100be187a 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -18,8 +18,6 @@ # include "config.h" #endif - -#include "libnr/nr-matrix-fns.h" #include "svg/svg.h" #include "svg/path-string.h" #include "xml/repr.h" diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 6d679701f..1b0a395e0 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -7,7 +7,6 @@ # include "config.h" #endif -#include "libnr/nr-matrix-ops.h" #include "xml/repr.h" //#include "svg/svg.h" diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 982ce0d0e..1b168c5e6 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -23,9 +23,6 @@ #include #include -#include -#include -#include #include <2geom/transforms.h> #include diff --git a/src/sp-image.cpp b/src/sp-image.cpp index b383512f5..596090846 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -21,32 +21,23 @@ #include #include #include -#include -#include -#include -#include -#include -#include <2geom/rect.h> -//#define GDK_PIXBUF_ENABLE_BACKEND 1 -//#include -#include "display/nr-arena-image.h" -#include #include +#include <2geom/rect.h> +#include +#include "display/nr-arena-image.h" +#include "display/curve.h" //Added for preserveAspectRatio support -- EAF #include "enums.h" #include "attributes.h" - #include "print.h" #include "brokenimage.xpm" #include "document.h" #include "sp-image.h" #include "sp-clippath.h" -#include #include "xml/quote.h" -#include +#include "xml/repr.h" #include "snap-candidate.h" -#include "libnr/nr-matrix-fns.h" #include "io/sys.h" #if ENABLE_LCMS diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 588427752..67a0c8b63 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -24,8 +24,6 @@ #include "display/nr-arena-group.h" #include "display/curve.h" -#include "libnr/nr-matrix-ops.h" -#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" #include "svg/svg.h" #include "document.h" diff --git a/src/sp-line.cpp b/src/sp-line.cpp index d0ce32397..f489da2f1 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif #include "attributes.h" #include "style.h" @@ -20,8 +20,7 @@ #include "sp-guide.h" #include "display/curve.h" #include -#include -#include +#include "xml/repr.h" #include "document.h" #include "inkscape.h" diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 20cb38297..4c9e4aa99 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -16,7 +16,6 @@ #include "display/nr-arena.h" #include "display/nr-arena-group.h" -#include "libnr/nr-matrix-ops.h" #include #include "enums.h" diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 556778676..2b6f535a4 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -37,7 +37,7 @@ #include "sp-use-reference.h" #include "uri.h" -#include +#include <2geom/matrix.h> #include <2geom/pathvector.h> #include "xml/repr.h" diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 54d2a201a..dd6f60eb7 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -25,8 +25,7 @@ #include "live_effects/lpeobject-reference.h" #include "sp-lpe-item.h" -#include -#include +#include "display/curve.h" #include <2geom/pathvector.h> #include <2geom/bezier-curve.h> #include <2geom/hvlinesegment.h> diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index b2c718e3b..a559a4a50 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -18,8 +18,6 @@ #include #include -#include -#include "libnr/nr-matrix-fns.h" #include <2geom/transforms.h> #include "macros.h" #include "svg/svg.h" @@ -111,7 +109,7 @@ sp_pattern_init (SPPattern *pat) pat->patternContentUnits = SP_PATTERN_UNITS_USERSPACEONUSE; pat->patternContentUnits_set = FALSE; - pat->patternTransform = NR::identity(); + pat->patternTransform = Geom::identity(); pat->patternTransform_set = FALSE; pat->x.unset(); @@ -207,7 +205,7 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value) pat->patternTransform = t; pat->patternTransform_set = TRUE; } else { - pat->patternTransform = NR::identity(); + pat->patternTransform = Geom::identity(); pat->patternTransform_set = FALSE; } object->requestModified(SP_OBJECT_MODIFIED_FLAG); diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index bdfae7c99..54f4ceea5 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -16,9 +16,7 @@ #endif -#include -#include -#include +#include "display/curve.h" #include <2geom/rect.h> #include "inkscape.h" diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 41004db6e..5b4f24cb8 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -18,8 +18,6 @@ #include #include -#include "libnr/nr-matrix-fns.h" -#include "libnr/nr-matrix-ops.h" #include <2geom/transforms.h> #include "display/nr-arena-group.h" #include "xml/repr.h" diff --git a/src/sp-text.cpp b/src/sp-text.cpp index bae625f58..dd9856080 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -26,7 +26,6 @@ #endif #include <2geom/matrix.h> -#include #include #include #include diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 83f9ecfa6..3bc5e286b 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -33,7 +33,6 @@ #include "uri.h" #include "display/nr-arena-group.h" -#include "libnr/nr-matrix-fns.h" #include "xml/node.h" #include "xml/repr.h" diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 89a86218e..cf1990900 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -40,7 +40,6 @@ #include "sp-textpath.h" #include "text-editing.h" #include "style.h" -#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" #include "document.h" diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 9cd38e4b3..9efc442a9 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -20,8 +20,6 @@ #include #include -#include -#include #include <2geom/transforms.h> #include #include "display/nr-arena-group.h" diff --git a/src/spray-context.cpp b/src/spray-context.cpp index ee168f136..150d93c1e 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -38,8 +38,6 @@ #include "message-context.h" #include "pixmaps/cursor-spray.xpm" #include -#include "libnr/nr-matrix-ops.h" -#include "libnr/nr-scale-translate-ops.h" #include "xml/repr.h" #include "context-fns.h" #include "sp-item.h" diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index 91a9fa7e5..b6dbd6d6a 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -20,11 +20,8 @@ #include #include #include -#include -#include #include <2geom/transforms.h> #include <2geom/angle.h> -#include #include "svg.h" #include "preferences.h" diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index f574b69fb..e9a543596 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -19,7 +19,6 @@ #include #include -#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" #include "sp-rect.h" #include "sp-textpath.h" @@ -150,7 +149,7 @@ text_put_on_path() Inkscape::Text::Layout::Alignment text_alignment = layout->paragraphAlignment(layout->begin()); // remove transform from text, but recursively scale text's fontsize by the expansion - SP_TEXT(text)->_adjustFontsizeRecursive (text, NR::expansion(SP_ITEM(text)->transform)); + SP_TEXT(text)->_adjustFontsizeRecursive (text, SP_ITEM(text)->transform.descrim()); SP_OBJECT_REPR(text)->setAttribute("transform", NULL); // make a list of text children @@ -316,7 +315,7 @@ text_flow_into_shape() if (SP_IS_TEXT(text)) { // remove transform from text, but recursively scale text's fontsize by the expansion - SP_TEXT(text)->_adjustFontsizeRecursive(text, NR::expansion(SP_ITEM(text)->transform)); + SP_TEXT(text)->_adjustFontsizeRecursive(text, SP_ITEM(text)->transform.descrim()); SP_OBJECT_REPR(text)->setAttribute("transform", NULL); } @@ -432,10 +431,10 @@ text_unflow () /* Set style */ rtext->setAttribute("style", SP_OBJECT_REPR(flowtext)->attribute("style")); // fixme: transfer style attrs too; and from descendants - NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(flowtext), &bbox, sp_item_i2doc_affine(SP_ITEM(flowtext)), TRUE); - Geom::Point xy(bbox.x0, bbox.y0); - if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) { + Geom::OptRect bbox; + sp_item_invoke_bbox(SP_ITEM(flowtext), bbox, sp_item_i2doc_affine(SP_ITEM(flowtext)), TRUE); + if (bbox) { + Geom::Point xy = bbox->min(); sp_repr_set_svg_double(rtext, "x", xy[Geom::X]); sp_repr_set_svg_double(rtext, "y", xy[Geom::Y]); } diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index e2bd0e9f5..198ffdfb2 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -14,24 +14,23 @@ #include "trace/potrace/inkscape-potrace.h" -#include -#include -#include -#include -#include +#include "inkscape.h" +#include "desktop.h" +#include "desktop-handles.h" +#include "document.h" +#include "message-stack.h" #include #include -#include -#include -#include -#include -#include -#include -#include +#include "selection.h" +#include "xml/repr.h" +#include "xml/attribute-record.h" +#include "sp-item.h" +#include "sp-shape.h" +#include "sp-image.h" #include <2geom/transforms.h> -#include -#include +#include "display/nr-arena.h" +#include "display/nr-arena-shape.h" #include "siox.h" #include "imagemap-gdk.h" diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 36357ab84..6e9ec6fb4 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -40,8 +40,6 @@ #include "pixmaps/cursor-roughen.xpm" #include "pixmaps/cursor-color.xpm" #include -#include "libnr/nr-matrix-ops.h" -#include "libnr/nr-scale-translate-ops.h" #include "xml/repr.h" #include "context-fns.h" #include "sp-item.h" diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 1cab38d98..c11801fcf 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -20,7 +20,6 @@ #include "desktop-handles.h" #include "transformation.h" #include "align-and-distribute.h" -#include "libnr/nr-matrix-ops.h" #include "inkscape.h" #include "selection.h" #include "selection-chemistry.h" -- cgit v1.2.3 From 4f8192cb094a677d36ed83f1db1a2b01604c8a68 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 23:45:24 +0200 Subject: Fix artifacts in Gaussian blur and other filters inadvertently introduced when fixing seams in per-pixel filters (bzr r9508.1.46) --- src/display/nr-filter.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 8273cc591..1484235dc 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -192,7 +192,6 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea break; } } - units.set_paraller(true); FilterSlot slot(const_cast(item), bgct, bgarea, cairo_get_target(graphic), area, units); slot.set_quality(filterquality); @@ -221,18 +220,10 @@ void Filter::set_primitive_units(SPFilterUnits unit) { } void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { - NRRectL bbox_orig = bbox; for (int i = 0 ; i < _primitive_count ; i++) { if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm); } - // HACK: due to some roundoff issue that I can't find at this time, - // some per-pixel filters show seams when rotated. - if (bbox_orig.x0 >= bbox.x0) bbox.x0 = bbox_orig.x0 - 1; - if (bbox_orig.y0 >= bbox.y0) bbox.y0 = bbox_orig.y0 - 1; - if (bbox_orig.x1 <= bbox.x1) bbox.x1 = bbox_orig.x1 + 1; - if (bbox_orig.y1 <= bbox.y1) bbox.y1 = bbox_orig.y1 + 1; - /* TODO: something. See images at the bottom of filters.svg with medium-low filtering quality. -- cgit v1.2.3 From 498629f82d9453cb7222ab642b867c183fdf1666 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 01:56:47 +0200 Subject: Wholesale cruft removal part 3 (bzr r9508.1.47) --- src/desktop.cpp | 2 +- src/dropper-context.cpp | 1 - src/extension/internal/emf-win32-inout.cpp | 18 -- src/gradient-chemistry.cpp | 1 + src/gradient-context.cpp | 2 +- src/interface.cpp | 4 +- src/libnr/Makefile_insert | 37 --- src/libnr/nr-compose-transform.cpp | 367 ----------------------------- src/libnr/nr-compose-transform.h | 43 ---- src/libnr/nr-convert2geom.h | 21 -- src/libnr/nr-matrix-fns.cpp | 55 ----- src/libnr/nr-matrix-fns.h | 53 ----- src/libnr/nr-matrix-ops.h | 41 ---- src/libnr/nr-matrix-rotate-ops.cpp | 18 -- src/libnr/nr-matrix-rotate-ops.h | 20 -- src/libnr/nr-matrix-scale-ops.h | 31 --- src/libnr/nr-matrix-test.h | 191 --------------- src/libnr/nr-matrix-translate-ops.h | 37 --- src/libnr/nr-matrix.cpp | 291 ----------------------- src/libnr/nr-matrix.h | 313 ------------------------ src/libnr/nr-point-matrix-ops.h | 49 ---- src/libnr/nr-rect.cpp | 5 +- src/libnr/nr-rect.h | 11 +- src/libnr/nr-rotate-fns-test.h | 54 ----- src/libnr/nr-rotate-fns.cpp | 66 ------ src/libnr/nr-rotate-fns.h | 29 --- src/libnr/nr-rotate-matrix-ops.cpp | 19 -- src/libnr/nr-rotate-matrix-ops.h | 21 -- src/libnr/nr-rotate-ops.h | 43 ---- src/libnr/nr-rotate-test.h | 110 --------- src/libnr/nr-rotate.h | 66 ------ src/libnr/nr-scale-matrix-ops.cpp | 25 -- src/libnr/nr-scale-matrix-ops.h | 13 - src/libnr/nr-scale-ops.h | 40 ---- src/libnr/nr-scale-test.h | 90 ------- src/libnr/nr-scale-translate-ops.cpp | 19 -- src/libnr/nr-scale-translate-ops.h | 20 -- src/libnr/nr-scale.h | 55 ----- src/libnr/nr-translate-matrix-ops.cpp | 26 -- src/libnr/nr-translate-matrix-ops.h | 22 -- src/libnr/nr-translate-ops.h | 43 ---- src/libnr/nr-translate-rotate-ops.cpp | 20 -- src/libnr/nr-translate-rotate-ops.h | 21 -- src/libnr/nr-translate-scale-ops.cpp | 24 -- src/libnr/nr-translate-scale-ops.h | 20 -- src/libnr/nr-translate-test.h | 85 ------- src/libnr/nr-translate.h | 34 --- src/libnr/nr-types.h | 1 - src/libnr/nr-values.cpp | 4 +- src/libnr/nr-values.h | 1 - src/livarot/PathCutting.cpp | 4 +- src/livarot/PathSimplify.cpp | 2 +- src/object-edit.cpp | 7 - src/selection-chemistry.cpp | 32 +-- src/sp-clippath.cpp | 8 +- src/sp-item-group.cpp | 2 +- src/sp-item.cpp | 2 +- src/sp-mask.cpp | 8 +- src/sp-shape.cpp | 6 +- src/sp-star.cpp | 9 +- src/sp-text.cpp | 2 +- src/sp-tspan.cpp | 7 +- src/splivarot.cpp | 1 - src/star-context.cpp | 4 +- src/text-editing.cpp | 2 +- src/ui/dialog/filedialogimpl-win32.cpp | 17 +- src/widgets/sp-color-wheel.cpp | 1 - 67 files changed, 68 insertions(+), 2628 deletions(-) delete mode 100644 src/libnr/nr-compose-transform.cpp delete mode 100644 src/libnr/nr-compose-transform.h delete mode 100644 src/libnr/nr-matrix-fns.cpp delete mode 100644 src/libnr/nr-matrix-fns.h delete mode 100644 src/libnr/nr-matrix-ops.h delete mode 100644 src/libnr/nr-matrix-rotate-ops.cpp delete mode 100644 src/libnr/nr-matrix-rotate-ops.h delete mode 100644 src/libnr/nr-matrix-scale-ops.h delete mode 100644 src/libnr/nr-matrix-test.h delete mode 100644 src/libnr/nr-matrix-translate-ops.h delete mode 100644 src/libnr/nr-matrix.cpp delete mode 100644 src/libnr/nr-matrix.h delete mode 100644 src/libnr/nr-point-matrix-ops.h delete mode 100644 src/libnr/nr-rotate-fns-test.h delete mode 100644 src/libnr/nr-rotate-fns.cpp delete mode 100644 src/libnr/nr-rotate-fns.h delete mode 100644 src/libnr/nr-rotate-matrix-ops.cpp delete mode 100644 src/libnr/nr-rotate-matrix-ops.h delete mode 100644 src/libnr/nr-rotate-ops.h delete mode 100644 src/libnr/nr-rotate-test.h delete mode 100644 src/libnr/nr-rotate.h delete mode 100644 src/libnr/nr-scale-matrix-ops.cpp delete mode 100644 src/libnr/nr-scale-matrix-ops.h delete mode 100644 src/libnr/nr-scale-ops.h delete mode 100644 src/libnr/nr-scale-test.h delete mode 100644 src/libnr/nr-scale-translate-ops.cpp delete mode 100644 src/libnr/nr-scale-translate-ops.h delete mode 100644 src/libnr/nr-scale.h delete mode 100644 src/libnr/nr-translate-matrix-ops.cpp delete mode 100644 src/libnr/nr-translate-matrix-ops.h delete mode 100644 src/libnr/nr-translate-ops.h delete mode 100644 src/libnr/nr-translate-rotate-ops.cpp delete mode 100644 src/libnr/nr-translate-rotate-ops.h delete mode 100644 src/libnr/nr-translate-scale-ops.cpp delete mode 100644 src/libnr/nr-translate-scale-ops.h delete mode 100644 src/libnr/nr-translate-test.h delete mode 100644 src/libnr/nr-translate.h (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index 52f172577..74bf0033a 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -791,7 +791,7 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double newscale = CLAMP(newscale, SP_DESKTOP_ZOOM_MIN, SP_DESKTOP_ZOOM_MAX); // unit: 'screen pixels' per 'document pixels' int clear = FALSE; - if (!NR_DF_TEST_CLOSE (newscale, scale, 1e-4 * scale)) { + if (!Geom::are_near(newscale, scale, Geom::EPSILON * scale)) { // zoom changed - set new zoom factors _d2w = Geom::Scale(newscale, -newscale); _w2d = Geom::Scale(1/newscale, 1/-newscale); diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 85649186d..3898cd169 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -42,7 +42,6 @@ #include "dropper-context.h" #include "message-context.h" -//#include "libnr/nr-scale-translate-ops.h" static void sp_dropper_context_class_init(SPDropperContextClass *klass); static void sp_dropper_context_init(SPDropperContext *dc); diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index c88f09733..7ed1a9d66 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -25,34 +25,16 @@ # include "config.h" #endif -//#include "inkscape.h" #include "sp-path.h" #include "style.h" -//#include "color.h" -//#include "display/curve.h" -//#include "libnr/nr-point-matrix-ops.h" -//#include "gtk/gtk.h" #include "print.h" -//#include "glibmm/i18n.h" -//#include "extension/extension.h" #include "extension/system.h" #include "extension/print.h" #include "extension/db.h" #include "extension/output.h" -//#include "document.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" - -//#include -//#include - -//#include -//#include - -//#include "io/sys.h" - #include "unit-constants.h" - #include "clear-n_.h" #define WIN32_LEAN_AND_MEAN diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 88aab0c38..bf71253ff 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -36,6 +36,7 @@ #include "svg/css-ostringstream.h" #include "preferences.h" +#include "libnr/nr-point-fns.h" // Terminology: // diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index ddb153ffd..f8117ed5b 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -47,7 +47,7 @@ #include "sp-namedview.h" #include "rubberband.h" - +#include "libnr/nr-point-fns.h" static void sp_gradient_context_class_init(SPGradientContextClass *klass); static void sp_gradient_context_init(SPGradientContext *gr_context); diff --git a/src/interface.cpp b/src/interface.cpp index 47563238a..085eca6bd 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1318,7 +1318,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * - to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5 + sp_item_i2d_affine(item).descrim() * 0.5 : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); @@ -1421,7 +1421,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * - to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5 + sp_item_i2d_affine(item).descrim() * 0.5 : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index dc329c351..6afef39ef 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -4,8 +4,6 @@ ink_common_sources += \ libnr/in-svg-plane.h \ libnr/nr-blit.cpp \ libnr/nr-blit.h \ - libnr/nr-compose-transform.cpp \ - libnr/nr-compose-transform.h \ libnr/nr-compose-reference.h \ libnr/nr-compose.cpp \ libnr/nr-compose.h \ @@ -15,15 +13,6 @@ ink_common_sources += \ libnr/nr-forward.h \ libnr/nr-i-coord.h \ libnr/nr-macros.h \ - libnr/nr-matrix-fns.cpp \ - libnr/nr-matrix-fns.h \ - libnr/nr-matrix-ops.h \ - libnr/nr-matrix-rotate-ops.cpp \ - libnr/nr-matrix-rotate-ops.h \ - libnr/nr-matrix-scale-ops.h \ - libnr/nr-matrix-translate-ops.h \ - libnr/nr-matrix.cpp \ - libnr/nr-matrix.h \ libnr/nr-maybe.h \ libnr/nr-object.cpp \ libnr/nr-object.h \ @@ -36,7 +25,6 @@ ink_common_sources += \ libnr/nr-point-fns.cpp \ libnr/nr-point-fns.h \ libnr/nr-point-l.h \ - libnr/nr-point-matrix-ops.h \ libnr/nr-point-ops.h \ libnr/nr-point.h \ libnr/nr-rect-l.cpp \ @@ -45,26 +33,6 @@ ink_common_sources += \ libnr/nr-rect.h \ libnr/nr-rect-ops.h \ libnr/nr-render.h \ - libnr/nr-rotate-fns.cpp \ - libnr/nr-rotate-fns.h \ - libnr/nr-rotate-ops.h \ - libnr/nr-rotate-matrix-ops.cpp \ - libnr/nr-rotate-matrix-ops.h \ - libnr/nr-rotate.h \ - libnr/nr-scale-matrix-ops.cpp \ - libnr/nr-scale-matrix-ops.h \ - libnr/nr-scale-translate-ops.cpp \ - libnr/nr-scale-translate-ops.h \ - libnr/nr-scale-ops.h \ - libnr/nr-scale.h \ - libnr/nr-translate-matrix-ops.cpp \ - libnr/nr-translate-matrix-ops.h \ - libnr/nr-translate-scale-ops.cpp \ - libnr/nr-translate-scale-ops.h \ - libnr/nr-translate-ops.h \ - libnr/nr-translate.h \ - libnr/nr-translate-rotate-ops.cpp \ - libnr/nr-translate-rotate-ops.h \ libnr/nr-types.cpp \ libnr/nr-types.h \ libnr/nr-values.cpp \ @@ -86,10 +54,5 @@ ink_common_sources += \ CXXTEST_TESTSUITES += \ $(srcdir)/libnr/in-svg-plane-test.h \ $(srcdir)/libnr/nr-compose-test.h \ - $(srcdir)/libnr/nr-matrix-test.h \ $(srcdir)/libnr/nr-point-fns-test.h \ - $(srcdir)/libnr/nr-rotate-test.h \ - $(srcdir)/libnr/nr-rotate-fns-test.h \ - $(srcdir)/libnr/nr-scale-test.h \ - $(srcdir)/libnr/nr-translate-test.h \ $(srcdir)/libnr/nr-types-test.h diff --git a/src/libnr/nr-compose-transform.cpp b/src/libnr/nr-compose-transform.cpp deleted file mode 100644 index 05852bf07..000000000 --- a/src/libnr/nr-compose-transform.cpp +++ /dev/null @@ -1,367 +0,0 @@ -#define __NR_COMPOSE_TRANSFORM_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "nr-pixops.h" -#include "nr-matrix.h" - -/*#ifdef WITH_MMX -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus -/ * fixme: * / -/ *int nr_have_mmx (void); -#define NR_PIXOPS_MMX (1 && nr_have_mmx ()) -#ifdef __cplusplus -} -#endif //__cplusplus -#endif -*/ - -/* fixme: Implement missing (Lauris) */ -/* fixme: PREMUL colors before calculating average (Lauris) */ - -/* Fixed point precision */ -#define FBITS 12 -#define FBITS_HP 18 // In some places we need a higher precision - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); - -void -nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd) -{ - int xsize, ysize, size, dbits; - long FFs_x_x, FFs_x_y, FFs_y_x, FFs_y_y, FFs__x, FFs__y; - long FFs_x_x_S, FFs_x_y_S, FFs_y_x_S, FFs_y_y_S; - /* Subpixel positions */ - int FF_sx_S[256]; - int FF_sy_S[256]; - unsigned char *d0; - int FFsx0, FFsy0; - int x, y; - - if (alpha == 0) return; - if (alpha>255) { - g_warning("In transform PPN alpha=%u>255",alpha); - } - - // The color component is stored temporarily with a range of [0,255^3], so more supersampling and we get an overflow (fortunately Inkscape's preferences also doesn't allow a higher setting) - if (xd+yd>8) { - xd = 4; - yd = 4; - } - - xsize = (1 << xd); - ysize = (1 << yd); - size = xsize * ysize; - dbits = xd + yd; - unsigned int rounding_fix = size/2; - - /* Set up fixed point matrix */ - FFs_x_x = (long) floor(d2s[0] * (1 << FBITS) + 0.5); - FFs_x_y = (long) floor(d2s[1] * (1 << FBITS) + 0.5); - FFs_y_x = (long) floor(d2s[2] * (1 << FBITS) + 0.5); - FFs_y_y = (long) floor(d2s[3] * (1 << FBITS) + 0.5); - FFs__x = (long) floor(d2s[4] * (1 << FBITS) + 0.5); - FFs__y = (long) floor(d2s[5] * (1 << FBITS) + 0.5); - - FFs_x_x_S = FFs_x_x >> xd; - FFs_x_y_S = FFs_x_y >> xd; - FFs_y_x_S = FFs_y_x >> yd; - FFs_y_y_S = FFs_y_y >> yd; - - /* Set up subpixel matrix */ - /* fixme: We can calculate that in floating point (Lauris) */ - for (y = 0; y < ysize; y++) { - for (x = 0; x < xsize; x++) { - FF_sx_S[y * xsize + x] = FFs_x_x_S * x + FFs_y_x_S * y; - FF_sy_S[y * xsize + x] = FFs_x_y_S * x + FFs_y_y_S * y; - } - } - - d0 = px; - FFsx0 = FFs__x; - FFsy0 = FFs__y; - - for (y = 0; y < h; y++) { - unsigned char *d; - long FFsx, FFsy; - d = d0; - FFsx = FFsx0; - FFsy = FFsy0; - for (x = 0; x < w; x++) { - unsigned int r, g, b, a; - long sx, sy; - int i; - r = g = b = a = 0; - for (i = 0; i < size; i++) { - sx = (FFsx + FF_sx_S[i]) >> FBITS; - if ((sx >= 0) && (sx < sw)) { - sy = (FFsy + FF_sy_S[i]) >> FBITS; - if ((sy >= 0) && (sy < sh)) { - const unsigned char *s; - s = spx + sy * srs + sx * 4; - r += NR_PREMUL_112 (s[0], s[3]); // s in [0,255] - g += NR_PREMUL_112 (s[1], s[3]); - b += NR_PREMUL_112 (s[2], s[3]); - a += s[3]; - // a=sum(s3) - // r,g,b in [0,sum(s3)*255] - } - } - } - a = (a*alpha + rounding_fix) >> dbits; - // a=sum(s3)*alpha/size=avg(s3)*alpha - // Compare to nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P - if (a != 0) { - r = (r*alpha + rounding_fix) >> dbits; - g = (g*alpha + rounding_fix) >> dbits; - b = (b*alpha + rounding_fix) >> dbits; - // r,g,b in [0,avg(s3)*alpha*255]=[0,a*255] - if (a == 255*255) { - /* Full coverage, demul src */ - d[0] = NR_NORMALIZE_31(r); - d[1] = NR_NORMALIZE_31(g); - d[2] = NR_NORMALIZE_31(b); - d[3] = NR_NORMALIZE_21(a); - } else if (d[3] == 0) { - /* Only foreground, demul src */ - d[0] = NR_DEMUL_321(r,a); - d[1] = NR_DEMUL_321(g,a); - d[2] = NR_DEMUL_321(b,a); - d[3] = NR_NORMALIZE_21(a); - } else { - unsigned int ca; - /* Full composition */ - ca = NR_COMPOSEA_213(a, d[3]); - d[0] = NR_COMPOSEPNN_321131 (r, a, d[0], d[3], ca); - d[1] = NR_COMPOSEPNN_321131 (g, a, d[1], d[3], ca); - d[2] = NR_COMPOSEPNN_321131 (b, a, d[2], d[3], ca); - d[3] = NR_NORMALIZE_31(ca); - } - } - /* Advance pointers */ - FFsx += FFs_x_x; - FFsy += FFs_x_y; - d += 4; - } - FFsx0 += FFs_y_x; - FFsy0 += FFs_y_y; - d0 += rs; - } -} - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); - -static void -nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_0 (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const long long *FFd2s, unsigned int alpha) -{ - unsigned char *d0; - long long FFsx0, FFsy0; - int x, y; - - d0 = px; - FFsx0 = FFd2s[4]; - FFsy0 = FFd2s[5]; - - for (y = 0; y < h; y++) { - unsigned char *d; - long long FFsx, FFsy; - d = d0; - FFsx = FFsx0; - FFsy = FFsy0; - for (x = 0; x < w; x++) { - long sx, sy; - sx = long(FFsx >> FBITS_HP); - if ((sx >= 0) && (sx < sw)) { - sy = long(FFsy >> FBITS_HP); - if ((sy >= 0) && (sy < sh)) { - const unsigned char *s; - unsigned int a; - s = spx + sy * srs + sx * 4; - a = NR_PREMUL_112 (s[3], alpha); - if (a != 0) { - if ((a == 255*255) || (d[3] == 0)) { - /* Transparent BG, premul src */ - d[0] = NR_PREMUL_121 (s[0], a); - d[1] = NR_PREMUL_121 (s[1], a); - d[2] = NR_PREMUL_121 (s[2], a); - d[3] = NR_NORMALIZE_21(a); - } else { - d[0] = NR_COMPOSENPP_1211 (s[0], a, d[0]); - d[1] = NR_COMPOSENPP_1211 (s[1], a, d[1]); - d[2] = NR_COMPOSENPP_1211 (s[2], a, d[2]); - d[3] = NR_COMPOSEA_211(a, d[3]); - } - } - } - } - /* Advance pointers */ - FFsx += FFd2s[0]; - FFsy += FFd2s[1]; - d += 4; - } - FFsx0 += FFd2s[2]; - FFsy0 += FFd2s[3]; - d0 += rs; - } -} - -static void -nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_n (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const long long *FFd2s, const long *FF_S, unsigned int alpha, int dbits) -{ - int size; - unsigned char *d0; - long long FFsx0, FFsy0; - int x, y; - - size = (1 << dbits); - unsigned int rounding_fix = size/2; - - d0 = px; - FFsx0 = FFd2s[4]; - FFsy0 = FFd2s[5]; - - for (y = 0; y < h; y++) { - unsigned char *d; - long long FFsx, FFsy; - d = d0; - FFsx = FFsx0; - FFsy = FFsy0; - for (x = 0; x < w; x++) { - unsigned int r, g, b, a; - int i; - r = g = b = a = 0; - for (i = 0; i < size; i++) { - long sx, sy; - sx = (long (FFsx >> (FBITS_HP - FBITS)) + FF_S[2 * i]) >> FBITS; - if ((sx >= 0) && (sx < sw)) { - sy = (long (FFsy >> (FBITS_HP - FBITS)) + FF_S[2 * i + 1]) >> FBITS; - if ((sy >= 0) && (sy < sh)) { - const unsigned char *s; - s = spx + sy * srs + sx * 4; - r += NR_PREMUL_112(s[0], s[3]); - g += NR_PREMUL_112(s[1], s[3]); - b += NR_PREMUL_112(s[2], s[3]); - a += s[3]; - } - } - } - a = (a*alpha + rounding_fix) >> dbits; - if (a != 0) { - r = (r*alpha + rounding_fix) >> dbits; - g = (g*alpha + rounding_fix) >> dbits; - b = (b*alpha + rounding_fix) >> dbits; - if ((a == 255*255) || (d[3] == 0)) { - /* Transparent BG, premul src */ - d[0] = NR_NORMALIZE_31(r); - d[1] = NR_NORMALIZE_31(g); - d[2] = NR_NORMALIZE_31(b); - d[3] = NR_NORMALIZE_21(a); - } else { - d[0] = NR_COMPOSEPPP_3211 (r, a, d[0]); - d[1] = NR_COMPOSEPPP_3211 (g, a, d[1]); - d[2] = NR_COMPOSEPPP_3211 (b, a, d[2]); - d[3] = NR_COMPOSEA_211(a, d[3]); - } - } - /* Advance pointers */ - FFsx += FFd2s[0]; - FFsy += FFd2s[1]; - d += 4; - } - FFsx0 += FFd2s[2]; - FFsy0 += FFd2s[3]; - d0 += rs; - } -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd) -{ - int dbits; - long FFd2s[6]; - long long FFd2s_HP[6]; // with higher precision - int i; - - if (alpha == 0) return; - if (alpha>255) { - g_warning("In transform PPN alpha=%u>255",alpha); - } - - // The color component is stored temporarily with a range of [0,255^3], so more supersampling and we get an overflow (fortunately Inkscape's preferences also doesn't allow a higher setting) - if (xd+yd>8) { - xd = 4; - yd = 4; - } - - dbits = xd + yd; - - for (i = 0; i < 6; i++) { - FFd2s[i] = (long) floor(d2s[i] * (1 << FBITS) + 0.5); - FFd2s_HP[i] = (long long) floor(d2s[i] * (1 << FBITS_HP) + 0.5);; - } - - if (dbits == 0) { - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_0 (px, w, h, rs, spx, sw, sh, srs, FFd2s_HP, alpha); - } else { - int xsize, ysize; - long FFs_x_x_S, FFs_x_y_S, FFs_y_x_S, FFs_y_y_S; - long FF_S[2 * 256]; - int x, y; - - xsize = (1 << xd); - ysize = (1 << yd); - - FFs_x_x_S = FFd2s[0] >> xd; - FFs_x_y_S = FFd2s[1] >> xd; - FFs_y_x_S = FFd2s[2] >> yd; - FFs_y_y_S = FFd2s[3] >> yd; - - /* Set up subpixel matrix */ - /* fixme: We can calculate that in floating point (Lauris) */ - for (y = 0; y < ysize; y++) { - for (x = 0; x < xsize; x++) { - FF_S[2 * (y * xsize + x)] = FFs_x_x_S * x + FFs_y_x_S * y; - FF_S[2 * (y * xsize + x) + 1] = FFs_x_y_S * x + FFs_y_y_S * y; - } - } - - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM_n (px, w, h, rs, spx, sw, sh, srs, FFd2s_HP, FF_S, alpha, dbits); - } -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); diff --git a/src/libnr/nr-compose-transform.h b/src/libnr/nr-compose-transform.h deleted file mode 100644 index 7ffb20074..000000000 --- a/src/libnr/nr-compose-transform.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __NR_COMPOSE_TRANSFORM_H__ -#define __NR_COMPOSE_TRANSFORM_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -/* FINAL DST SRC */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_TRANSFORM (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int sw, int sh, int srs, - const NR::Matrix &d2s, unsigned int alpha, int xd, int yd); - -#endif diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h index b7cbd7ee8..b0ce18c90 100644 --- a/src/libnr/nr-convert2geom.h +++ b/src/libnr/nr-convert2geom.h @@ -9,7 +9,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include #include #include <2geom/matrix.h> @@ -24,19 +23,6 @@ inline NR::Point from_2geom(Geom::Point const & _pt) { return NR::Point(_pt[0], _pt[1]); } -inline Geom::Matrix to_2geom(NR::Matrix const & mat) { - Geom::Matrix mat2geom(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - return mat2geom; -} -inline NR::Matrix from_2geom(Geom::Matrix const & mat) { - NR::Matrix mat2geom(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); - return mat2geom; -} - -inline Geom::Translate to_2geom(NR::translate const & mat) { - return Geom::Translate( mat.offset[0], mat.offset[1] ); -} - inline Geom::Rect to_2geom(NR::Rect const & rect) { Geom::Rect rect2geom(to_2geom(rect.min()), to_2geom(rect.max())); return rect2geom; @@ -54,13 +40,6 @@ inline Geom::OptRect to_2geom(boost::optional const & rect) { return rect2geom; } -inline NR::scale from_2geom(Geom::Scale const & in) { - return NR::scale(in[Geom::X], in[Geom::Y]); -} -inline Geom::Scale to_2geom(NR::scale const & in) { - return Geom::Scale(in[NR::X], in[NR::Y]); -} - #endif /* diff --git a/src/libnr/nr-matrix-fns.cpp b/src/libnr/nr-matrix-fns.cpp deleted file mode 100644 index c8eb986fa..000000000 --- a/src/libnr/nr-matrix-fns.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include - -namespace NR { - -Matrix elliptic_quadratic_form(Matrix const &m) { - double const od = m[0] * m[1] + m[2] * m[3]; - return Matrix((m[0]*m[0] + m[1]*m[1]), od, - od, (m[2]*m[2] + m[3]*m[3]), - 0, 0); -/* def quadratic_form((a, b), (c, d)): - return ((a*a + c*c), a*c+b*d),(a*c+b*d, (b*b + d*d)) */ -} - -Eigen::Eigen(Matrix const &m) { - double const B = -m[0] - m[3]; - double const C = m[0]*m[3] - m[1]*m[2]; - double const center = -B/2.0; - double const delta = sqrt(B*B-4*C)/2.0; - values = Point(center + delta, center - delta); - for (int i = 0; i < 2; i++) { - vectors[i] = unit_vector(rot90(Point(m[0]-values[i], m[1]))); - } -} - -/** Returns just the scale/rotate/skew part of the matrix without the translation part. */ -Matrix transform(Matrix const &m) { - Matrix const ret(m[0], m[1], - m[2], m[3], - 0, 0); - return ret; -} - -translate get_translation(Matrix const &m) { - return translate(m[4], m[5]); -} - -void matrix_print(const gchar *say, Matrix const &m) -{ - printf ("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]); -} - -} // namespace NR - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-matrix-fns.h b/src/libnr/nr-matrix-fns.h deleted file mode 100644 index a46aca909..000000000 --- a/src/libnr/nr-matrix-fns.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef SEEN_NR_MATRIX_FNS_H -#define SEEN_NR_MATRIX_FNS_H - -#include "nr-matrix.h" -#include - -namespace NR { - -/** Given a matrix m such that unit_circle = m*x, this returns the - * quadratic form x*A*x = 1. */ -Matrix elliptic_quadratic_form(Matrix const &m); - -/** Given a matrix (ignoring the translation) this returns the eigen - * values and vectors. */ -class Eigen{ -public: - Point vectors[2]; - Point values; - Eigen(Matrix const &m); -}; - -// Matrix factories -Matrix from_basis(const Point x_basis, const Point y_basis, const Point offset=Point(0,0)); - -Matrix identity(); - -double expansion(Matrix const &m); -inline double expansionX(Matrix const &m) { return hypot(m[0], m[1]); } -inline double expansionY(Matrix const &m) { return hypot(m[2], m[3]); } - -bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon); -bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon); -bool matrix_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon); - -Matrix transform(Matrix const &m); -translate get_translation(Matrix const &m); - -void matrix_print(const gchar *say, Matrix const &m); - -} // namespace NR - -#endif /* !SEEN_NR_MATRIX_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-matrix-ops.h b/src/libnr/nr-matrix-ops.h deleted file mode 100644 index e534f9cf6..000000000 --- a/src/libnr/nr-matrix-ops.h +++ /dev/null @@ -1,41 +0,0 @@ -/* operator functions for NR::Matrix. */ -#ifndef SEEN_NR_MATRIX_OPS_H -#define SEEN_NR_MATRIX_OPS_H - -#include - -namespace NR { - -inline bool operator==(Matrix const &a, Matrix const &b) -{ - for(unsigned i = 0; i < 6; ++i) { - if ( a[i] != b[i] ) { - return false; - } - } - return true; -} - -inline bool operator!=(Matrix const &a, Matrix const &b) -{ - return !( a == b ); -} - -Matrix operator*(Matrix const &a, Matrix const &b); - -inline Matrix &operator*=(Matrix &a, Matrix const &b) { a = a * b; return a; } - -} /* namespace NR */ - -#endif /* !SEEN_NR_MATRIX_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix-rotate-ops.cpp b/src/libnr/nr-matrix-rotate-ops.cpp deleted file mode 100644 index 625291575..000000000 --- a/src/libnr/nr-matrix-rotate-ops.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "libnr/nr-matrix-ops.h" - -NR::Matrix operator*(NR::Matrix const &m, NR::rotate const &r) -{ - return m * NR::Matrix(r); -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix-rotate-ops.h b/src/libnr/nr-matrix-rotate-ops.h deleted file mode 100644 index 44d9c8726..000000000 --- a/src/libnr/nr-matrix-rotate-ops.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SEEN_LIBNR_NR_MATRIX_ROTATE_OPS_H -#define SEEN_LIBNR_NR_MATRIX_ROTATE_OPS_H - -#include "libnr/nr-forward.h" - -NR::Matrix operator*(NR::Matrix const &m, NR::rotate const &r); - - -#endif /* !SEEN_LIBNR_NR_MATRIX_ROTATE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix-scale-ops.h b/src/libnr/nr-matrix-scale-ops.h deleted file mode 100644 index d030bb66c..000000000 --- a/src/libnr/nr-matrix-scale-ops.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H -#define SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H -/** \file - * Declarations (and definition if inline) of operator blah (NR::Matrix, NR::scale). - */ - -#include "libnr/nr-forward.h" - -namespace NR { - -inline Matrix &operator/=(Matrix &m, scale const &s) { - m[0] /= s[X]; m[1] /= s[Y]; - m[2] /= s[X]; m[3] /= s[Y]; - m[4] /= s[X]; m[5] /= s[Y]; - return m; -} - -inline Matrix &operator*=(Matrix &m, scale const &s) { - m[0] *= s[X]; m[1] *= s[Y]; - m[2] *= s[X]; m[3] *= s[Y]; - m[4] *= s[X]; m[5] *= s[Y]; - return m; -} - -inline Matrix operator/(Matrix const &m, scale const &s) { Matrix ret(m); ret /= s; return ret; } - -inline Matrix operator*(Matrix const &m, scale const &s) { Matrix ret(m); ret *= s; return ret; } - -} - -#endif /* !SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H */ diff --git a/src/libnr/nr-matrix-test.h b/src/libnr/nr-matrix-test.h deleted file mode 100644 index d4267ffa5..000000000 --- a/src/libnr/nr-matrix-test.h +++ /dev/null @@ -1,191 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -inline bool point_equalp(NR::Point const &a, NR::Point const &b) -{ - return ( NR_DF_TEST_CLOSE(a[NR::X], b[NR::X], 1e-5) && - NR_DF_TEST_CLOSE(a[NR::Y], b[NR::Y], 1e-5) ); -} - -class NrMatrixTest : public CxxTest::TestSuite -{ -public: - - NrMatrixTest() : - m_id( NR::identity() ), - r_id( NR::Point(1, 0) ), - t_id( 0, 0 ), - c16( 1.0, 2.0, - 3.0, 4.0, - 5.0, 6.0), - r86( NR::Point(.8, .6) ), - mr86( r86 ), - t23( 2.0, 3.0 ), - s_id( 1.0, 1.0 ) - { - } - virtual ~NrMatrixTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrMatrixTest *createSuite() { return new NrMatrixTest(); } - static void destroySuite( NrMatrixTest *suite ) { delete suite; } - - NR::Matrix const m_id; - NR::rotate const r_id; - NR::translate const t_id; - NR::Matrix const c16; - NR::rotate const r86; - NR::Matrix const mr86; - NR::translate const t23; - NR::scale const s_id; - - - - - void testCtorsAssignmentOp(void) - { - NR::Matrix const c16_copy(c16); - NR::Matrix c16_eq(m_id); - c16_eq = c16; - for(unsigned i = 0; i < 6; ++i) { - TS_ASSERT_EQUALS( c16[i], 1.0 + i ); - TS_ASSERT_EQUALS( c16[i], c16_copy[i] ); - TS_ASSERT_EQUALS( c16[i], c16_eq[i] ); - TS_ASSERT_EQUALS( m_id[i], double( i == 0 || i == 3 ) ); - } - } - - void testScaleCtor(void) - { - NR::scale const s(2.0, 3.0); - NR::Matrix const ms(s); - NR::Point const p(5.0, 7.0); - TS_ASSERT_EQUALS( p * s, NR::Point(10.0, 21.0) ); - TS_ASSERT_EQUALS( p * ms, NR::Point(10.0, 21.0) ); - } - - void testRotateCtor(void) - { - NR::Point const p0(1.0, 0.0); - NR::Point const p90(0.0, 1.0); - TS_ASSERT_EQUALS( p0 * r86, NR::Point(.8, .6) ); - TS_ASSERT_EQUALS( p0 * mr86, NR::Point(.8, .6) ); - TS_ASSERT_EQUALS( p90 * r86, NR::Point(-.6, .8) ); - TS_ASSERT_EQUALS( p90 * mr86, NR::Point(-.6, .8) ); - TS_ASSERT( matrix_equalp(NR::Matrix( r86 * r86 ), - mr86 * mr86, - 1e-14) ); - } - - void testTranslateCtor(void) - { - NR::Matrix const mt23(t23); - NR::Point const b(-2.0, 3.0); - TS_ASSERT_EQUALS( b * t23, b * mt23 ); - } - - void testIdentity(void) - { - TS_ASSERT( m_id.test_identity() ); - TS_ASSERT( NR::Matrix(t_id).test_identity() ); - TS_ASSERT( !(NR::Matrix(NR::translate(-2, 3)).test_identity()) ); - TS_ASSERT( NR::Matrix(r_id).test_identity() ); - NR::rotate const rot180(NR::Point(-1, 0)); - TS_ASSERT( !(NR::Matrix(rot180).test_identity()) ); - TS_ASSERT( NR::Matrix(s_id).test_identity() ); - TS_ASSERT( !(NR::Matrix(NR::scale(1.0, 0.0)).test_identity()) ); - TS_ASSERT( !(NR::Matrix(NR::scale(0.0, 1.0)).test_identity()) ); - TS_ASSERT( !(NR::Matrix(NR::scale(1.0, -1.0)).test_identity()) ); - TS_ASSERT( !(NR::Matrix(NR::scale(-1.0, -1.0)).test_identity()) ); - } - - void testInverse(void) - { - TS_ASSERT_EQUALS( m_id.inverse(), m_id ); - TS_ASSERT_EQUALS( NR::Matrix(t23).inverse(), NR::Matrix(NR::translate(-2.0, -3.0)) ); - NR::scale const s2(-4.0, 2.0); - NR::scale const sp5(-.25, .5); - TS_ASSERT_EQUALS( NR::Matrix(s2).inverse(), NR::Matrix(sp5) ); - TS_ASSERT_EQUALS( NR::Matrix(sp5).inverse(), NR::Matrix(s2) ); - } - - void testEllipticQuadraticForm(void) - { - NR::Matrix const aff(1.0, 1.0, - 0.0, 1.0, - 5.0, 6.0); - NR::Matrix const invaff = aff.inverse(); - TS_ASSERT_EQUALS( invaff[1], -1.0 ); - - NR::Matrix const ef(elliptic_quadratic_form(invaff)); - NR::Matrix const exp_ef(2, -1, - -1, 1, - 0, 0); - TS_ASSERT_EQUALS( ef, exp_ef ); - } - - void testMatrixStarRotate(void) - { - NR::Matrix const ma(2.0, -1.0, - 4.0, 4.0, - -0.5, 2.0); - NR::Matrix const a_r86( ma * r86 ); - NR::Matrix const ma1( a_r86 * r86.inverse() ); - TS_ASSERT( matrix_equalp(ma1, ma, 1e-12) ); - NR::Matrix const exp_a_r86( 2*.8 + -1*-.6, 2*.6 + -1*.8, - 4*.8 + 4*-.6, 4*.6 + 4*.8, - -.5*.8 + 2*-.6, -.5*.6 + 2*.8 ); - TS_ASSERT( matrix_equalp(a_r86, exp_a_r86, 1e-12) ); - } - - void testTranslateStarScale_ScaleStarTranslate(void) - { - NR::translate const t2n4(2, -4); - NR::scale const sn2_8(-2, 8); - NR::Matrix const exp_ts(-2, 0, - 0, 8, - -4, -32); - NR::Matrix const exp_st(-2, 0, - 0, 8, - 2, -4); - TS_ASSERT_EQUALS( exp_ts, t2n4 * sn2_8 ); - TS_ASSERT_EQUALS( exp_st, sn2_8 * t2n4 ); - } - - void testMatrixStarScale(void) - { - NR::Matrix const ma(2.0, -1.0, - 4.0, 4.0, - -0.5, 2.0); - NR::scale const sn2_8(-2, 8); - NR::Matrix const exp_as(-4, -8, - -8, 32, - 1, 16); - TS_ASSERT_EQUALS( ma * sn2_8, exp_as ); - } -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix-translate-ops.h b/src/libnr/nr-matrix-translate-ops.h deleted file mode 100644 index 6e5607759..000000000 --- a/src/libnr/nr-matrix-translate-ops.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_H -#define SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_H - -/** \file - * Declarations (and definition if inline) of operator - * blah (NR::Matrix, NR::translate). - */ - -#include "libnr/nr-matrix.h" -#include "libnr/nr-translate.h" - -namespace NR { - -inline Matrix &operator*=(Matrix &m, translate const &t) { - m[4] += t[X]; - m[5] += t[Y]; - return m; -} - -inline Matrix operator*(Matrix const &m, translate const &t) { Matrix ret(m); ret *= t; return ret; } - -inline Matrix operator/(Matrix const &numer, translate const &denom) { return numer * translate(-denom.offset); } - -} - -#endif /* !SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix.cpp b/src/libnr/nr-matrix.cpp deleted file mode 100644 index c7948a96e..000000000 --- a/src/libnr/nr-matrix.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#define __NR_MATRIX_C__ - -/** \file - * Various matrix routines. Currently includes some NR::rotate etc. routines too. - */ - -/* - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include -#include "nr-matrix.h" -#include "nr-matrix-fns.h" - - - -/** - * Implement NR functions and methods - */ -namespace NR { - - - - - -/** - * Multiply two matrices together - */ -Matrix operator*(Matrix const &m0, Matrix const &m1) -{ - NR::Coord const d0 = m0[0] * m1[0] + m0[1] * m1[2]; - NR::Coord const d1 = m0[0] * m1[1] + m0[1] * m1[3]; - NR::Coord const d2 = m0[2] * m1[0] + m0[3] * m1[2]; - NR::Coord const d3 = m0[2] * m1[1] + m0[3] * m1[3]; - NR::Coord const d4 = m0[4] * m1[0] + m0[5] * m1[2] + m1[4]; - NR::Coord const d5 = m0[4] * m1[1] + m0[5] * m1[3] + m1[5]; - - Matrix ret( d0, d1, d2, d3, d4, d5 ); - - return ret; -} - - - - - -/** - * Return the inverse of this matrix. If an inverse is not defined, - * then return the identity matrix. - */ -Matrix Matrix::inverse() const -{ - Matrix d(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - - NR::Coord const det = _c[0] * _c[3] - _c[1] * _c[2]; - if (!NR_DF_TEST_CLOSE(det, 0.0, NR_EPSILON)) { - - NR::Coord const idet = 1.0 / det; - NR::Coord *dest = d._c; - - /*0*/ *dest++ = _c[3] * idet; - /*1*/ *dest++ = -_c[1] * idet; - /*2*/ *dest++ = -_c[2] * idet; - /*3*/ *dest++ = _c[0] * idet; - /*4*/ *dest++ = -_c[4] * d._c[0] - _c[5] * d._c[2]; - /*5*/ *dest = -_c[4] * d._c[1] - _c[5] * d._c[3]; - - } else { - d.set_identity(); - } - - return d; -} - - - - - -/** - * Set this matrix to Identity - */ -void Matrix::set_identity() -{ - NR::Coord *dest = _c; - - *dest++ = 1.0; //0 - *dest++ = 0.0; //1 - *dest++ = 0.0; //2 - *dest++ = 1.0; //3 - // translation - *dest++ = 0.0; //4 - *dest = 0.0; //5 -} - - - - - -/** - * return an Identity matrix - */ -Matrix identity() -{ - Matrix ret(1.0, 0.0, - 0.0, 1.0, - 0.0, 0.0); - return ret; -} - - - - - -/** - * - */ -Matrix from_basis(Point const x_basis, Point const y_basis, Point const offset) -{ - Matrix const ret(x_basis[X], y_basis[X], - x_basis[Y], y_basis[Y], - offset[X], offset[Y]); - return ret; -} - - - - -/** - * Returns a rotation matrix corresponding by the specified angle (in radians) about the origin. - * - * \see NR::rotate_degrees - * - * Angle direction in Inkscape code: If you use the traditional mathematics convention that y - * increases upwards, then positive angles are anticlockwise as per the mathematics convention. If - * you take the common non-mathematical convention that y increases downwards, then positive angles - * are clockwise, as is common outside of mathematics. - */ -rotate::rotate(NR::Coord const theta) : - vec(cos(theta), - sin(theta)) -{ -} - - - - - -/** - * Return the determinant of the Matrix - */ -NR::Coord Matrix::det() const -{ - return _c[0] * _c[3] - _c[1] * _c[2]; -} - - - - - -/** - * Return the scalar of the descriminant of the Matrix - */ -NR::Coord Matrix::descrim2() const -{ - return fabs(det()); -} - - - - - -/** - * Return the descriminant of the Matrix - */ -NR::Coord Matrix::descrim() const -{ - return sqrt(descrim2()); -} - - - - - -/** - * - */ -bool Matrix::is_translation(Coord const eps) const { - return ( fabs(_c[0] - 1.0) < eps && - fabs(_c[3] - 1.0) < eps && - fabs(_c[1]) < eps && - fabs(_c[2]) < eps ); -} - - -/** - * - */ -bool Matrix::is_scale(Coord const eps) const { - return ( (fabs(_c[0] - 1.0) > eps || fabs(_c[3] - 1.0) > eps) && - fabs(_c[1]) < eps && - fabs(_c[2]) < eps ); -} - - -/** - * - */ -bool Matrix::is_rotation(Coord const eps) const { - return ( fabs(_c[1]) > eps && - fabs(_c[2]) > eps && - fabs(_c[1] + _c[2]) < 2 * eps); -} - - - - - -/** - * test whether the matrix is the identity matrix (true). (2geom's Matrix::isIdentity() does the same) - */ -bool Matrix::test_identity() const { - return matrix_equalp(*this, NR_MATRIX_IDENTITY, NR_EPSILON); -} - - - - - -/** - * calculates the descriminant of the matrix. (Geom::Coord Matrix::descrim() does the same) - */ -double expansion(Matrix const &m) { - return sqrt(fabs(m.det())); -} - - - - - -/** - * - */ -bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) { - return - NR_DF_TEST_CLOSE(m0[0], m1[0], epsilon) && - NR_DF_TEST_CLOSE(m0[1], m1[1], epsilon) && - NR_DF_TEST_CLOSE(m0[2], m1[2], epsilon) && - NR_DF_TEST_CLOSE(m0[3], m1[3], epsilon); -} - - - - - -/** - * - */ -bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) { - return NR_DF_TEST_CLOSE(m0[4], m1[4], epsilon) && NR_DF_TEST_CLOSE(m0[5], m1[5], epsilon); -} - - - - - -/** - * - */ -bool matrix_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) { - return transform_equalp(m0, m1, epsilon) && translate_equalp(m0, m1, epsilon); -} - - - -} //namespace NR - - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix.h b/src/libnr/nr-matrix.h deleted file mode 100644 index b1f9d589a..000000000 --- a/src/libnr/nr-matrix.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef __NR_MATRIX_H__ -#define __NR_MATRIX_H__ - -/** \file - * Definition of NR::Matrix type. - * - * \note Operator functions (e.g. Matrix * Matrix etc.) are mostly in - * libnr/nr-matrix-ops.h. See end of file for discussion. - * - * Main authors: - * Lauris Kaplinski : - * Original NRMatrix definition and related macros. - * - * Nathan Hurst : - * NR::Matrix class version of the above. - * - * This code is in public domain. - */ - -#include // g_assert() -#include - -#include "libnr/nr-coord.h" -#include "libnr/nr-values.h" -#include -#include -#include -#include <2geom/matrix.h> - -namespace NR { - -/** - * The Matrix class. - * - * For purposes of multiplication, points should be thought of as row vectors - * - * p = ( p[X] p[Y] 1 ) - * - * to be right-multiplied by transformation matrices - * \verbatim - c[] = | c[0] c[1] 0 | - | c[2] c[3] 0 | - | c[4] c[5] 1 | \endverbatim - * - * (so the columns of the matrix correspond to the columns (elements) of the result, - * and the rows of the matrix correspond to columns (elements) of the "input"). - */ -class Matrix { - - - public: - - /** - * Various forms of constructor - */ - - /** - * - */ - explicit Matrix() { } - - - /** - * - */ - Matrix(Matrix const &m) { - - NR::Coord const *src = m._c; - NR::Coord *dest = _c; - - *dest++ = *src++; //0 - *dest++ = *src++; //1 - *dest++ = *src++; //2 - *dest++ = *src++; //3 - *dest++ = *src++; //4 - *dest = *src ; //5 - - } - - - Matrix(Geom::Matrix const &m) { - NR::Coord *dest = _c; - - *dest++ = m[0]; - *dest++ = m[1]; - *dest++ = m[2]; - *dest++ = m[3]; - *dest++ = m[4]; - *dest = m[5]; - } - - /** - * - */ - Matrix(double c0, double c1, - double c2, double c3, - double c4, double c5) { - - NR::Coord *dest = _c; - - *dest++ = c0; //0 - *dest++ = c1; //1 - *dest++ = c2; //2 - *dest++ = c3; //3 - *dest++ = c4; //4 - *dest = c5; //5 - - } - - - - /** - * - */ - Matrix &operator=(Matrix const &m) { - - NR::Coord const *src = m._c; - NR::Coord *dest = _c; - - *dest++ = *src++; //0 - *dest++ = *src++; //1 - *dest++ = *src++; //2 - *dest++ = *src++; //3 - *dest++ = *src++; //4 - *dest = *src ; //5 - - return *this; - } - - - - - /** - * - */ - explicit Matrix(scale const &sm) { - - NR::Coord *dest = _c; - - *dest++ = sm[X]; //0 - *dest++ = 0.0; //1 - *dest++ = 0.0; //2 - *dest++ = sm[Y]; //3 - *dest++ = 0.0; //4 - *dest = 0.0; //5 - - } - - - - - - - /** - * - */ - explicit Matrix(rotate const &r) { - - NR::Coord *dest = _c; - - *dest++ = r.vec[X]; //0 - *dest++ = r.vec[Y]; //1 - *dest++ = -r.vec[Y]; //2 - *dest++ = r.vec[X]; //3 - *dest++ = 0.0; //4 - *dest = 0.0; //5 - - } - - - - - /** - * - */ - explicit Matrix(translate const &tm) { - - NR::Coord *dest = _c; - - *dest++ = 1.0; //0 - *dest++ = 0.0; //1 - *dest++ = 0.0; //2 - *dest++ = 1.0; //3 - *dest++ = tm[X]; //4 - *dest = tm[Y]; //5 - } - - - /** - * - */ - bool test_identity() const; - - - /** - * - */ - bool is_translation(Coord const eps = 1e-6) const; - - /** - * - */ - bool is_scale(Coord const eps = 1e-6) const; - - /** - * - */ - bool is_rotation(Coord const eps = 1e-6) const; - - - /** - * - */ - Matrix inverse() const; - - - - /** - * - */ - inline Coord &operator[](int const i) { - return _c[i]; - } - - - - /** - * - */ - inline Coord operator[](int const i) const { - return _c[i]; - } - - inline operator Geom::Matrix() const { - return Geom::Matrix(_c[0], _c[1], _c[2], _c[3], _c[4], _c[5]); - } - - /** - * - */ - void set_identity(); - - /** - * - */ - Coord det() const; - - - /** - * - */ - Coord descrim2() const; - - - /** - * - */ - Coord descrim() const; - - - private: - - - NR::Coord _c[6]; -}; - -/** A function to print out the Matrix (for debugging) */ -inline std::ostream &operator<< (std::ostream &out_file, const NR::Matrix &m) { - out_file << "A: " << m[0] << " C: " << m[2] << " E: " << m[4] << "\n"; - out_file << "B: " << m[1] << " D: " << m[3] << " F: " << m[5] << "\n"; - return out_file; -} - -} /* namespace NR */ - - - - - - - -/** \note - * Discussion of splitting up nr-matrix.h into lots of little files: - * - * Advantages: - * - * - Reducing amount of recompilation necessary when anything changes. - * - * - Hopefully also reducing compilation time by reducing the number of inline - * function definitions encountered by the compiler for a given .o file. - * (No timing comparisons done yet. On systems without much memory available - * for caching, this may be outweighed by additional I/O costs.) - * - * Disadvantages: - * - * - More #include lines necessary per file. If a compile fails due to - * not having all the necessary #include lines, then the developer needs - * to spend some time working out what #include to add. - */ - -#endif /* !__NR_MATRIX_H__ */ - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-point-matrix-ops.h b/src/libnr/nr-point-matrix-ops.h deleted file mode 100644 index 81e351103..000000000 --- a/src/libnr/nr-point-matrix-ops.h +++ /dev/null @@ -1,49 +0,0 @@ -/** @file - * @brief Operator functions over (NR::Point, NR::Matrix) - */ -#ifndef SEEN_NR_POINT_MATRIX_OPS_H -#define SEEN_NR_POINT_MATRIX_OPS_H - -#include "libnr/nr-point.h" -#include "libnr/nr-matrix.h" - -namespace NR { - -inline Point operator*(Point const &v, Matrix const &m) -{ -#if 1 /* Which code makes it easier to see what's happening? */ - NR::Point const xform_col0(m[0], - m[2]); - NR::Point const xform_col1(m[1], - m[3]); - NR::Point const xlate(m[4], m[5]); - return ( Point(dot(v, xform_col0), - dot(v, xform_col1)) - + xlate ); -#else - return Point(v[X] * m[0] + v[Y] * m[2] + m[4], - v[X] * m[1] + v[Y] * m[3] + m[5]); -#endif -} - -inline Point &Point::operator*=(Matrix const &m) -{ - *this = *this * m; - return *this; -} - -} /* namespace NR */ - - -#endif /* !SEEN_NR_POINT_MATRIX_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp index 1e1f36104..58e16e963 100644 --- a/src/libnr/nr-rect.cpp +++ b/src/libnr/nr-rect.cpp @@ -11,6 +11,7 @@ #include "nr-rect-l.h" #include +#include "nr-point-ops.h" NRRect::NRRect(NR::Rect const &rect) : x0(rect.min()[NR::X]), y0(rect.min()[NR::Y]), @@ -220,6 +221,8 @@ nr_rect_d_union_xy (NRRect *d, NR::Coord x, NR::Coord y) NRRect * nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m) { + // defunct + /* using NR::X; using NR::Y; @@ -238,7 +241,7 @@ nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m std::max(c10[X], c11[X])); d->y1 = std::max(std::max(c00[Y], c01[Y]), std::max(c10[Y], c11[Y])); - } + }*/ return d; } diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h index c074b0034..f64b04f72 100644 --- a/src/libnr/nr-rect.h +++ b/src/libnr/nr-rect.h @@ -16,19 +16,23 @@ #include #include +#include #include "libnr/nr-values.h" #include #include #include #include +#include "libnr/nr-point-ops.h" +#include "libnr/nr-macros.h" #include -#include #include #include <2geom/rect.h> namespace NR { +class Matrix; + /** A rectangle is always aligned to the X and Y axis. This means it * can be defined using only 4 coordinates, and determining * intersection is very efficient. The points inside a rectangle are @@ -136,11 +140,6 @@ public: return Rect(s * min(), s * max()); } - /** Transforms the rect by m. Note that it gives correct results only for scales and translates */ - inline Rect operator*(Matrix const m) const { - return Rect(_min * m, _max * m); - } - inline bool operator==(Rect const &in_rect) { return ((this->min() == in_rect.min()) && (this->max() == in_rect.max())); } diff --git a/src/libnr/nr-rotate-fns-test.h b/src/libnr/nr-rotate-fns-test.h deleted file mode 100644 index e3bfe3043..000000000 --- a/src/libnr/nr-rotate-fns-test.h +++ /dev/null @@ -1,54 +0,0 @@ -#include - -#include -#include - -#include - -class NrRotateFnsTest : public CxxTest::TestSuite -{ -public: - - NrRotateFnsTest() - { - } - virtual ~NrRotateFnsTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrRotateFnsTest *createSuite() { return new NrRotateFnsTest(); } - static void destroySuite( NrRotateFnsTest *suite ) { delete suite; } - - - - void testRotateDegrees(void) - { - double const d[] = { - 0, 90, 180, 270, 360, 45, 45.01, 44.99, 134, 135, 136, 314, 315, 317, 359, 361 - }; - for ( unsigned i = 0; i < G_N_ELEMENTS(d); ++i ) { - double const degrees = d[i]; - NR::rotate const rot(rotate_degrees(degrees)); - NR::rotate const rot_approx( M_PI * ( degrees / 180. ) ); - TS_ASSERT( rotate_equalp(rot, rot_approx, 1e-12) ); - - NR::rotate const rot_inv(rotate_degrees(-degrees)); - NR::rotate const rot_compl(rotate_degrees(360 - degrees)); - TS_ASSERT( rotate_equalp(rot_inv, rot_compl, 1e-12) ); - - TS_ASSERT( !rotate_equalp(rot, rotate_degrees(degrees + 1), 1e-5) ); - } - } - -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rotate-fns.cpp b/src/libnr/nr-rotate-fns.cpp deleted file mode 100644 index f2669c20c..000000000 --- a/src/libnr/nr-rotate-fns.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/** \file - * Functions to/from NR::rotate. - */ -#include -#include "libnr/nr-rotate-ops.h" -#include "libnr/nr-rotate-fns.h" - -/** - * Returns a rotation matrix corresponding by the specified angle about the origin. - * - * Angle direction in Inkscape code: If you use the traditional mathematics convention that y - * increases upwards, then positive angles are anticlockwise as per the mathematics convention. If - * you take the common non-mathematical convention that y increases downwards, then positive angles - * are clockwise, as is common outside of mathematics. - */ -NR::rotate -rotate_degrees(double degrees) -{ - if (degrees < 0) { - return rotate_degrees(-degrees).inverse(); - } - - double const degrees0 = degrees; - if (degrees >= 360) { - degrees = fmod(degrees, 360); - } - - NR::rotate ret(1., 0.); - - if (degrees >= 180) { - NR::rotate const rot180(-1., 0.); - degrees -= 180; - ret = rot180; - } - - if (degrees >= 90) { - NR::rotate const rot90(0., 1.); - degrees -= 90; - ret *= rot90; - } - - if (degrees == 45) { - NR::rotate const rot45(M_SQRT1_2, M_SQRT1_2); - ret *= rot45; - } else { - double const radians = M_PI * ( degrees / 180 ); - ret *= NR::rotate(cos(radians), sin(radians)); - } - - NR::rotate const raw_ret( M_PI * ( degrees0 / 180 ) ); - g_return_val_if_fail(rotate_equalp(ret, raw_ret, 1e-8), - raw_ret); - return ret; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-rotate-fns.h b/src/libnr/nr-rotate-fns.h deleted file mode 100644 index bd075114c..000000000 --- a/src/libnr/nr-rotate-fns.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SEEN_NR_ROTATE_FNS_H -#define SEEN_NR_ROTATE_FNS_H - -/** \file - * Declarations for rotation functions. - */ - -#include -#include - -inline bool rotate_equalp(NR::rotate const &a, NR::rotate const &b, double const eps) -{ - return point_equalp(a.vec, b.vec, eps); -} - -NR::rotate rotate_degrees(double degrees); - -#endif /* !SEEN_NR_ROTATE_FNS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-rotate-matrix-ops.cpp b/src/libnr/nr-rotate-matrix-ops.cpp deleted file mode 100644 index dd3851643..000000000 --- a/src/libnr/nr-rotate-matrix-ops.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include - -NR::Matrix -operator*(NR::rotate const &a, NR::Matrix const &b) -{ - return NR::Matrix(a) * b; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rotate-matrix-ops.h b/src/libnr/nr-rotate-matrix-ops.h deleted file mode 100644 index d2f0eadba..000000000 --- a/src/libnr/nr-rotate-matrix-ops.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SEEN_LIBNR_NR_ROTATE_MATRIX_OPS_H -#define SEEN_LIBNR_NR_ROTATE_MATRIX_OPS_H - -#include - - -NR::Matrix operator*(NR::rotate const &a, NR::Matrix const &b); - - -#endif /* !SEEN_LIBNR_NR_ROTATE_MATRIX_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rotate-ops.h b/src/libnr/nr-rotate-ops.h deleted file mode 100644 index 4b60b9d0c..000000000 --- a/src/libnr/nr-rotate-ops.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef SEEN_NR_ROTATE_OPS_H -#define SEEN_NR_ROTATE_OPS_H -#include - -namespace NR { - -inline Point operator*(Point const &v, rotate const &r) -{ - return Point(r.vec[X] * v[X] - r.vec[Y] * v[Y], - r.vec[Y] * v[X] + r.vec[X] * v[Y]); -} - -inline rotate operator*(rotate const &a, rotate const &b) -{ - return rotate( a.vec * b ); -} - -inline rotate &rotate::operator*=(rotate const &b) -{ - *this = *this * b; - return *this; -} - -inline rotate operator/(rotate const &numer, rotate const &denom) -{ - return numer * denom.inverse(); -} - -} /* namespace NR */ - - -#endif /* !SEEN_NR_ROTATE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rotate-test.h b/src/libnr/nr-rotate-test.h deleted file mode 100644 index 5514d09d1..000000000 --- a/src/libnr/nr-rotate-test.h +++ /dev/null @@ -1,110 +0,0 @@ -#include - -#include -#include -#include -#include /* identity, matrix_equalp */ -#include -#include -#include -#include - - -class NrRotateTest : public CxxTest::TestSuite -{ -public: - - NrRotateTest() : - m_id( NR::identity() ), - r_id( 0.0 ), - rot234( .234 ), - b( -2.0, 3.0 ), - rot180( NR::Point(-1.0, 0.0) ) - { - } - virtual ~NrRotateTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrRotateTest *createSuite() { return new NrRotateTest(); } - static void destroySuite( NrRotateTest *suite ) { delete suite; } - - NR::Matrix const m_id; - NR::rotate const r_id; - NR::rotate const rot234; - NR::Point const b; - NR::rotate const rot180; - - - - - void testCtorsCompares(void) - { - TS_ASSERT_EQUALS( r_id, r_id ); - TS_ASSERT_EQUALS( rot234, rot234 ); - TS_ASSERT_DIFFERS( rot234, r_id ); - TS_ASSERT_EQUALS( r_id, NR::rotate(NR::Point(1.0, 0.0)) ); - TS_ASSERT_EQUALS( NR::Matrix(r_id), m_id ); - TS_ASSERT( NR::Matrix(r_id).test_identity() ); - - TS_ASSERT(rotate_equalp(rot234, NR::rotate(NR::Point(cos(.234), sin(.234))), 1e-12)); - } - - void testAssignmentOp(void) - { - NR::rotate rot234_eq(r_id); - rot234_eq = rot234; - TS_ASSERT_EQUALS( rot234, rot234_eq ); - TS_ASSERT_DIFFERS( rot234_eq, r_id ); - } - - void testInverse(void) - { - TS_ASSERT_EQUALS( r_id.inverse(), r_id ); - TS_ASSERT_EQUALS( rot234.inverse(), NR::rotate(-.234) ); - } - - void testOpStarPointRotate(void) - { - TS_ASSERT_EQUALS( b * r_id, b ); - TS_ASSERT_EQUALS( b * rot180, -b ); - TS_ASSERT_EQUALS( b * rot234, b * NR::Matrix(rot234) ); - TS_ASSERT(point_equalp(b * NR::rotate(M_PI / 2), - NR::rot90(b), - 1e-14)); - TS_ASSERT_EQUALS( b * rotate_degrees(90.), NR::rot90(b) ); - } - - void testOpStarRotateRotate(void) - { - TS_ASSERT_EQUALS( r_id * r_id, r_id ); - TS_ASSERT_EQUALS( rot180 * rot180, r_id ); - TS_ASSERT_EQUALS( rot234 * r_id, rot234 ); - TS_ASSERT_EQUALS( r_id * rot234, rot234 ); - TS_ASSERT( rotate_equalp(rot234 * rot234.inverse(), r_id, 1e-14) ); - TS_ASSERT( rotate_equalp(rot234.inverse() * rot234, r_id, 1e-14) ); - TS_ASSERT( rotate_equalp(( NR::rotate(0.25) * NR::rotate(.5) ), - NR::rotate(.75), - 1e-10) ); - } - - void testOpDivRotateRotate(void) - { - TS_ASSERT_EQUALS( rot234 / r_id, rot234 ); - TS_ASSERT_EQUALS( rot234 / rot180, rot234 * rot180 ); - TS_ASSERT( rotate_equalp(rot234 / rot234, r_id, 1e-14) ); - TS_ASSERT( rotate_equalp(r_id / rot234, rot234.inverse(), 1e-14) ); - } - -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rotate.h b/src/libnr/nr-rotate.h deleted file mode 100644 index 051372ce6..000000000 --- a/src/libnr/nr-rotate.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef SEEN_NR_ROTATE_H -#define SEEN_NR_ROTATE_H - -/** \file - * Rotation about the origin. - */ - -#include -#include -#include - -namespace NR { - -/** Notionally an NR::Matrix corresponding to rotation about the origin. - Behaves like NR::Matrix for multiplication. -**/ -class rotate { -public: - Point vec; - -private: - rotate(); - -public: - explicit rotate(Coord theta); - explicit rotate(Point const &p) : vec(p) {} - explicit rotate(Coord const x, Coord const y) : vec(x, y) {} - - bool operator==(rotate const &o) const { - return vec == o.vec; - } - - bool operator!=(rotate const &o) const { - return vec != o.vec; - } - - inline rotate &operator*=(rotate const &b); - /* Defined in nr-rotate-ops.h. */ - - rotate inverse() const { - /** \todo - * In the usual case that vec is a unit vector (within rounding error), - * dividing by len_sq is either a noop or numerically harmful. - * Make a unit_rotate class (or the like) that knows its length is 1. - */ - double const len_sq = dot(vec, vec); - return rotate( Point(vec[X], -vec[Y]) - / len_sq ); - } -}; - -} /* namespace NR */ - - -#endif /* !SEEN_NR_ROTATE_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-scale-matrix-ops.cpp b/src/libnr/nr-scale-matrix-ops.cpp deleted file mode 100644 index 5b19efaea..000000000 --- a/src/libnr/nr-scale-matrix-ops.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "libnr/nr-matrix-ops.h" - -NR::Matrix -operator*(NR::scale const &s, NR::Matrix const &m) -{ - using NR::X; using NR::Y; - NR::Matrix ret(m); - ret[0] *= s[X]; - ret[1] *= s[X]; - ret[2] *= s[Y]; - ret[3] *= s[Y]; - return ret; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-scale-matrix-ops.h b/src/libnr/nr-scale-matrix-ops.h deleted file mode 100644 index bf1b498c9..000000000 --- a/src/libnr/nr-scale-matrix-ops.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef SEEN_LIBNR_NR_SCALE_MATRIX_OPS_H -#define SEEN_LIBNR_NR_SCALE_MATRIX_OPS_H -/** \file - * Declarations (and definition if inline) of operator - * blah (NR::scale, NR::Matrix). - */ - -#include "libnr/nr-forward.h" - -NR::Matrix operator*(NR::scale const &s, NR::Matrix const &m); - - -#endif /* !SEEN_LIBNR_NR_SCALE_MATRIX_OPS_H */ diff --git a/src/libnr/nr-scale-ops.h b/src/libnr/nr-scale-ops.h deleted file mode 100644 index da1fea64c..000000000 --- a/src/libnr/nr-scale-ops.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef SEEN_NR_SCALE_OPS_H -#define SEEN_NR_SCALE_OPS_H - -#include - -namespace NR { - -inline Point operator*(Point const &p, scale const &s) -{ - return Point(p[X] * s[X], - p[Y] * s[Y]); -} - -inline scale operator*(scale const &a, scale const &b) -{ - return scale(a[X] * b[X], - a[Y] * b[Y]); -} - -inline scale operator/(scale const &numer, scale const &denom) -{ - return scale(numer[X] / denom[X], - numer[Y] / denom[Y]); -} - -} /* namespace NR */ - - -#endif /* !SEEN_NR_SCALE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-scale-test.h b/src/libnr/nr-scale-test.h deleted file mode 100644 index 938e8e14d..000000000 --- a/src/libnr/nr-scale-test.h +++ /dev/null @@ -1,90 +0,0 @@ -#include - -#include -#include - -class NrScaleTest : public CxxTest::TestSuite -{ -public: - - NrScaleTest() : - sa( 1.5, 2.0 ), - b( -2.0, 3.0 ), - sb( b ) - { - } - virtual ~NrScaleTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrScaleTest *createSuite() { return new NrScaleTest(); } - static void destroySuite( NrScaleTest *suite ) { delete suite; } - - NR::scale const sa; - NR::Point const b; - NR::scale const sb; - - - - void testXY_CtorArrayOperator(void) - { - TS_ASSERT_EQUALS( sa[NR::X], 1.5 ); - TS_ASSERT_EQUALS( sa[NR::Y], 2.0 ); - TS_ASSERT_EQUALS( sa[0u], 1.5 ); - TS_ASSERT_EQUALS( sa[1u], 2.0 ); - } - - - void testCopyCtor_AssignmentOp_NotEquals(void) - { - NR::scale const sa_copy(sa); - TS_ASSERT_EQUALS( sa, sa_copy ); - TS_ASSERT(!( sa != sa_copy )); - TS_ASSERT( sa != sb ); - } - - void testAssignmentOp(void) - { - NR::scale sa_eq(sb); - sa_eq = sa; - TS_ASSERT_EQUALS( sa, sa_eq ); - } - - void testPointCtor(void) - { - TS_ASSERT_EQUALS( sb[NR::X], b[NR::X] ); - TS_ASSERT_EQUALS( sb[NR::Y], b[NR::Y] ); - } - - void testOpStarPointScale(void) - { - NR::Point const ab( b * sa ); - TS_ASSERT_EQUALS( ab, NR::Point(-3.0, 6.0) ); - } - - void testOpStarScaleScale(void) - { - NR::scale const sab( sa * sb ); - TS_ASSERT_EQUALS( sab, NR::scale(-3.0, 6.0) ); - } - - void testOpDivScaleScale(void) - { - NR::scale const sa_b( sa / sb ); - NR::scale const exp_sa_b(-0.75, 2./3.); - TS_ASSERT_EQUALS( sa_b[0], exp_sa_b[0] ); -// TS_ASSERT_EQUALS( fabs( sa_b[1] - exp_sa_b[1] ) < 1e-10 ); - TS_ASSERT_DELTA( sa_b[1], exp_sa_b[1], 1e-10 ); - } -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-scale-translate-ops.cpp b/src/libnr/nr-scale-translate-ops.cpp deleted file mode 100644 index 911c92e5b..000000000 --- a/src/libnr/nr-scale-translate-ops.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "libnr/nr-matrix-translate-ops.h" - -NR::Matrix -operator*(NR::scale const &s, NR::translate const &t) -{ - return NR::Matrix(s) * t; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-scale-translate-ops.h b/src/libnr/nr-scale-translate-ops.h deleted file mode 100644 index 2f6f23c2c..000000000 --- a/src/libnr/nr-scale-translate-ops.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SEEN_LIBNR_NR_SCALE_TRANSLATE_OPS_H -#define SEEN_LIBNR_NR_SCALE_TRANSLATE_OPS_H - -#include "libnr/nr-forward.h" - -NR::Matrix operator*(NR::scale const &s, NR::translate const &t); - - -#endif /* !SEEN_LIBNR_NR_SCALE_TRANSLATE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-scale.h b/src/libnr/nr-scale.h deleted file mode 100644 index b4dbd1fb5..000000000 --- a/src/libnr/nr-scale.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SEEN_NR_SCALE_H -#define SEEN_NR_SCALE_H -#include -#include - -namespace NR { - -class scale { -private: - Point _p; - -private: - scale(); - -public: - explicit scale(Point const &p) : _p(p) {} - scale(double const x, double const y) : _p(x, y) {} - explicit scale(double const s) : _p(s, s) {} - inline Coord operator[](Dim2 const d) const { return _p[d]; } - inline Coord operator[](unsigned const d) const { return _p[d]; } - inline Coord &operator[](Dim2 const d) { return _p[d]; } - inline Coord &operator[](unsigned const d) { return _p[d]; } - - bool operator==(scale const &o) const { - return _p == o._p; - } - - bool operator!=(scale const &o) const { - return _p != o._p; - } - - scale inverse() const { - return scale(1/_p[0], 1/_p[1]); - } - - NR::Point point() const { - return _p; - } -}; - -} /* namespace NR */ - - -#endif /* !SEEN_NR_SCALE_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-matrix-ops.cpp b/src/libnr/nr-translate-matrix-ops.cpp deleted file mode 100644 index 47f362f9f..000000000 --- a/src/libnr/nr-translate-matrix-ops.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "libnr/nr-matrix-ops.h" - -namespace NR { - -Matrix -operator*(translate const &t, Matrix const &m) -{ - Matrix ret(m); - ret[4] += m[0] * t[X] + m[2] * t[Y]; - ret[5] += m[1] * t[X] + m[3] * t[Y]; - return ret; -} - -} /* namespace NR */ - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-matrix-ops.h b/src/libnr/nr-translate-matrix-ops.h deleted file mode 100644 index aceb123d1..000000000 --- a/src/libnr/nr-translate-matrix-ops.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SEEN_LIBNR_NR_TRANSLATE_MATRIX_OPS_H -#define SEEN_LIBNR_NR_TRANSLATE_MATRIX_OPS_H - -#include "libnr/nr-forward.h" - -namespace NR { -Matrix operator*(translate const &t, Matrix const &m); -} - - -#endif /* !SEEN_LIBNR_NR_TRANSLATE_MATRIX_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-ops.h b/src/libnr/nr-translate-ops.h deleted file mode 100644 index 14ab6d1ed..000000000 --- a/src/libnr/nr-translate-ops.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef SEEN_NR_TRANSLATE_OPS_H -#define SEEN_NR_TRANSLATE_OPS_H - -#include -#include - -namespace NR { - -inline bool operator==(translate const &a, translate const &b) -{ - return a.offset == b.offset; -} - -inline bool operator!=(translate const &a, translate const &b) -{ - return !( a == b ); -} - -inline translate operator*(translate const &a, translate const &b) -{ - return translate( a.offset + b.offset ); -} - -inline Point operator*(Point const &v, translate const &t) -{ - return t.offset + v; -} - -} /* namespace NR */ - - -#endif /* !SEEN_NR_TRANSLATE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-rotate-ops.cpp b/src/libnr/nr-translate-rotate-ops.cpp deleted file mode 100644 index 35f60c10d..000000000 --- a/src/libnr/nr-translate-rotate-ops.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -NR::Matrix -operator*(NR::translate const &a, NR::rotate const &b) -{ - return NR::Matrix(b) * NR::translate(a.offset * b); -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-rotate-ops.h b/src/libnr/nr-translate-rotate-ops.h deleted file mode 100644 index 0716f21cc..000000000 --- a/src/libnr/nr-translate-rotate-ops.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SEEN_LIBNR_NR_TRANSLATE_ROTATE_OPS_H -#define SEEN_LIBNR_NR_TRANSLATE_ROTATE_OPS_H - -#include - - -NR::Matrix operator*(NR::translate const &a, NR::rotate const &b); - - -#endif /* !SEEN_LIBNR_NR_TRANSLATE_ROTATE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-scale-ops.cpp b/src/libnr/nr-translate-scale-ops.cpp deleted file mode 100644 index 83e5e8e65..000000000 --- a/src/libnr/nr-translate-scale-ops.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "libnr/nr-matrix-ops.h" - -NR::Matrix -operator*(NR::translate const &t, NR::scale const &s) -{ - using NR::X; using NR::Y; - - NR::Matrix ret(s); - ret[4] = t[X] * s[X]; - ret[5] = t[Y] * s[Y]; - return ret; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-scale-ops.h b/src/libnr/nr-translate-scale-ops.h deleted file mode 100644 index c72665857..000000000 --- a/src/libnr/nr-translate-scale-ops.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SEEN_LIBNR_NR_TRANSLATE_SCALE_OPS_H -#define SEEN_LIBNR_NR_TRANSLATE_SCALE_OPS_H - -#include "libnr/nr-forward.h" - -NR::Matrix operator*(NR::translate const &t, NR::scale const &s); - - -#endif /* !SEEN_LIBNR_NR_TRANSLATE_SCALE_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate-test.h b/src/libnr/nr-translate-test.h deleted file mode 100644 index 630f43523..000000000 --- a/src/libnr/nr-translate-test.h +++ /dev/null @@ -1,85 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include -#include - -class NrTranslateTest : public CxxTest::TestSuite -{ -public: - - NrTranslateTest() : - b( -2.0, 3.0 ), - tb( b ), - tc( -3.0, -2.0 ), - tbc( tb * tc ), - t_id( 0.0, 0.0 ), - m_id( NR::identity() ) - { - } - virtual ~NrTranslateTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrTranslateTest *createSuite() { return new NrTranslateTest(); } - static void destroySuite( NrTranslateTest *suite ) { delete suite; } - - NR::Point const b; - NR::translate const tb; - NR::translate const tc; - NR::translate const tbc; - NR::translate const t_id; - NR::Matrix const m_id; - - - void testCtorsArrayOperator(void) - { - TS_ASSERT_EQUALS( tc[NR::X], -3.0 ); - TS_ASSERT_EQUALS( tc[NR::Y], -2.0 ); - - TS_ASSERT_EQUALS( tb[0], b[NR::X] ); - TS_ASSERT_EQUALS( tb[1], b[NR::Y] ); - } - - void testAssignmentOperator(void) - { - NR::translate tb_eq(tc); - tb_eq = tb; - TS_ASSERT_EQUALS( tb, tb_eq ); - TS_ASSERT_DIFFERS( tb_eq, tc ); - } - - void testOpStarTranslateTranslate(void) - { - TS_ASSERT_EQUALS( tbc.offset, NR::Point(-5.0, 1.0) ); - TS_ASSERT_EQUALS( tbc.offset, ( tc * tb ).offset ); - TS_ASSERT_EQUALS( NR::Matrix(tbc), NR::Matrix(tb) * NR::Matrix(tc) ); - } - - void testOpStarPointTranslate(void) - { - TS_ASSERT_EQUALS( tbc.offset, b * tc ); - TS_ASSERT_EQUALS( b * tc, b * NR::Matrix(tc) ); - } - - void testIdentity(void) - { - TS_ASSERT_EQUALS( b * t_id, b ); - TS_ASSERT_EQUALS( NR::Matrix(t_id), m_id ); - } -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-translate.h b/src/libnr/nr-translate.h deleted file mode 100644 index c1ea927e0..000000000 --- a/src/libnr/nr-translate.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SEEN_NR_TRANSLATE_H -#define SEEN_NR_TRANSLATE_H - -#include - -namespace NR { - -class translate { -public: - Point offset; -private: - translate(); -public: - explicit translate(Point const &p) : offset(p) {} - explicit translate(Coord const x, Coord const y) : offset(x, y) {} - Coord operator[](Dim2 const dim) const { return offset[dim]; } - Coord operator[](unsigned const dim) const { return offset[dim]; } -}; - -} /* namespace NR */ - - -#endif /* !SEEN_NR_TRANSLATE_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-types.h b/src/libnr/nr-types.h index bf499e7ff..3aff62d4a 100644 --- a/src/libnr/nr-types.h +++ b/src/libnr/nr-types.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/src/libnr/nr-values.cpp b/src/libnr/nr-values.cpp index f828c1396..9193eff3b 100644 --- a/src/libnr/nr-values.cpp +++ b/src/libnr/nr-values.cpp @@ -1,14 +1,12 @@ #define __NR_VALUES_C__ #include -#include - +#include "libnr/nr-rect.h" /* The following predefined objects are for reference and comparison. */ -NR::Matrix NR_MATRIX_IDENTITY = NR::identity(); NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE); NRRectL NR_RECT_L_EMPTY = {NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L}; diff --git a/src/libnr/nr-values.h b/src/libnr/nr-values.h index fb3c574a6..93b66b3a7 100644 --- a/src/libnr/nr-values.h +++ b/src/libnr/nr-values.h @@ -22,7 +22,6 @@ The following predefined objects are for reference and comparison. They are defined in nr-values.cpp */ -extern NR::Matrix NR_MATRIX_IDENTITY; extern NRRect NR_RECT_EMPTY; extern NRRectL NR_RECT_L_EMPTY; extern NRRectL NR_RECT_S_EMPTY; diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 91f6f9ec4..35e9cb687 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -510,10 +510,10 @@ double Path::Surface() for (std::vector::const_iterator i = pts.begin(); i != pts.end(); i++) { if ( i->isMoveTo == polyline_moveto ) { - surf += NR::cross(lastM - lastP, lastM); + surf += Geom::cross(lastM - lastP, lastM); lastP = lastM = i->p; } else { - surf += NR::cross(i->p - lastP, i->p); + surf += Geom::cross(i->p - lastP, i->p); lastP = i->p; } diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index 917bcbe7c..c53dfa029 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -126,7 +126,7 @@ double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Geom::Poi } Geom::Point seg = res.p - start; - nnle = NR::cross(seg, sp); + nnle = Geom::cross(seg, sp); nnle *= nnle; nnle /= Geom::dot(seg, seg); if ( nnle < nle ) { diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 1d81aa7f5..6bbcda93c 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -31,18 +31,11 @@ #include "desktop-handles.h" #include "sp-namedview.h" #include "live_effects/effect.h" - #include "sp-pattern.h" #include "sp-path.h" - #include - #include "object-edit.h" - -#include - #include "xml/repr.h" - #include "2geom/isnan.h" #define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 42cfc0a5f..de2860c8d 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1043,7 +1043,7 @@ take_style_from_item(SPItem *item) } // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive - double ex = to_2geom(sp_item_i2doc_affine(item)).descrim(); + double ex = sp_item_i2doc_affine(item).descrim(); if (ex != 1.0) { css = sp_css_attr_scale(css, ex); } @@ -2437,7 +2437,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) gchar const *pat_id = pattern_tile(repr_copies, bounds, doc, ( Geom::Matrix(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], r->max()[Geom::Y])))) - * to_2geom(parent_transform.inverse()) ), + * parent_transform.inverse() ), parent_transform * move); // restore compensation setting @@ -2447,8 +2447,8 @@ sp_selection_tile(SPDesktop *desktop, bool apply) Inkscape::XML::Node *rect = xml_doc->createElement("svg:rect"); rect->setAttribute("style", g_strdup_printf("stroke:none;fill:url(#%s)", pat_id)); - Geom::Point min = bounds.min() * to_2geom(parent_transform.inverse()); - Geom::Point max = bounds.max() * to_2geom(parent_transform.inverse()); + Geom::Point min = bounds.min() * parent_transform.inverse(); + Geom::Point max = bounds.max() * parent_transform.inverse(); sp_repr_set_svg_double(rect, "width", max[Geom::X] - min[Geom::X]); sp_repr_set_svg_double(rect, "height", max[Geom::Y] - min[Geom::Y]); @@ -2513,7 +2513,7 @@ sp_selection_untile(SPDesktop *desktop) SPPattern *pattern = pattern_getroot(SP_PATTERN(server)); - Geom::Matrix pat_transform = to_2geom(pattern_patternTransform(SP_PATTERN(server))); + Geom::Matrix pat_transform = pattern_patternTransform(SP_PATTERN(server)); pat_transform *= item->transform; for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { @@ -2635,10 +2635,9 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) desktop->setWaitingCursor(); // Get the bounding box of the selection - NRRect bbox; sp_document_ensure_up_to_date(document); - selection->bounds(&bbox); - if (NR_RECT_DFLS_TEST_EMPTY(&bbox)) { + Geom::OptRect bbox = selection->bounds(); + if (!bbox) { desktop->clearWaitingCursor(); return; // exceptional situation, so not bother with a translatable error message, just quit quietly } @@ -2691,7 +2690,7 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) res = prefs_res; } else if (0 < prefs_min) { // If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it - res = PX_PER_IN * prefs_min / MIN((bbox.x1 - bbox.x0), (bbox.y1 - bbox.y0)); + res = PX_PER_IN * prefs_min / MIN(bbox->width(), bbox->height()); } else { float hint_xdpi = 0, hint_ydpi = 0; char const *hint_filename; @@ -2712,8 +2711,8 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) } // The width and height of the bitmap in pixels - unsigned width = (unsigned) floor((bbox.x1 - bbox.x0) * res / PX_PER_IN); - unsigned height =(unsigned) floor((bbox.y1 - bbox.y0) * res / PX_PER_IN); + unsigned width = (unsigned) floor(bbox->width() * res / PX_PER_IN); + unsigned height =(unsigned) floor(bbox->height() * res / PX_PER_IN); // Find out if we have to run an external filter gchar const *run = NULL; @@ -2743,8 +2742,8 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) Geom::Matrix eek(sp_item_i2d_affine(SP_ITEM(parent_object))); Geom::Matrix t; - double shift_x = bbox.x0; - double shift_y = bbox.y1; + double shift_x = bbox->min()[Geom::X]; + double shift_y = bbox->max()[Geom::Y]; if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid shift_x = round(shift_x); shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone @@ -2753,7 +2752,8 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) // Do the export sp_export_png_file(document, filepath, - bbox.x0, bbox.y0, bbox.x1, bbox.y1, + bbox->min()[Geom::X], bbox->min()[Geom::Y], + bbox->max()[Geom::X], bbox->max()[Geom::Y], width, height, res, res, (guint32) 0xffffff00, NULL, NULL, @@ -2779,8 +2779,8 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) sp_repr_set_svg_double(repr, "width", width); sp_repr_set_svg_double(repr, "height", height); } else { - sp_repr_set_svg_double(repr, "width", (bbox.x1 - bbox.x0)); - sp_repr_set_svg_double(repr, "height", (bbox.y1 - bbox.y0)); + sp_repr_set_svg_double(repr, "width", bbox->width()); + sp_repr_set_svg_double(repr, "height", bbox->height()); } // Write transform diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 2d42f37f4..f429933a7 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -312,10 +312,10 @@ sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox) { for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { if (v->key == key) { - if (!NR_DF_TEST_CLOSE(v->bbox.x0, bbox->x0, NR_EPSILON) || - !NR_DF_TEST_CLOSE(v->bbox.y0, bbox->y0, NR_EPSILON) || - !NR_DF_TEST_CLOSE(v->bbox.x1, bbox->x1, NR_EPSILON) || - !NR_DF_TEST_CLOSE(v->bbox.y1, bbox->y1, NR_EPSILON)) { + if (!Geom::are_near(v->bbox.x0, bbox->x0) || + !Geom::are_near(v->bbox.y0, bbox->y0) || + !Geom::are_near(v->bbox.x1, bbox->x1) || + !Geom::are_near(v->bbox.y1, bbox->y1)) { v->bbox = *bbox; } break; diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 67a0c8b63..beca62d7b 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -706,7 +706,7 @@ void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { SPItem *child = SP_ITEM(o); - Geom::Matrix const ct(to_2geom(child->transform) * transform); + Geom::Matrix const ct(child->transform * transform); sp_item_invoke_bbox_full(child, dummy_bbox, ct, flags, FALSE); } l = g_slist_remove (l, o); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 10a5fbc59..a778c3d79 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1257,7 +1257,7 @@ sp_item_adjust_stroke (SPItem *item, gdouble ex) { SPStyle *style = SP_OBJECT_STYLE (item); - if (style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) { + if (style && !style->stroke.isNone() && !Geom::are_near(ex, 1.0, Geom::EPSILON)) { style->stroke_width.computed *= ex; style->stroke_width.set = TRUE; diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 4c9e4aa99..cc4d72936 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -358,10 +358,10 @@ sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox) { for (SPMaskView *v = mask->display; v != NULL; v = v->next) { if (v->key == key) { - if (!NR_DF_TEST_CLOSE (v->bbox.x0, bbox->x0, NR_EPSILON) || - !NR_DF_TEST_CLOSE (v->bbox.y0, bbox->y0, NR_EPSILON) || - !NR_DF_TEST_CLOSE (v->bbox.x1, bbox->x1, NR_EPSILON) || - !NR_DF_TEST_CLOSE (v->bbox.y1, bbox->y1, NR_EPSILON)) { + if (!Geom::are_near(v->bbox.x0, bbox->x0) || + !Geom::are_near(v->bbox.y0, bbox->y0) || + !Geom::are_near(v->bbox.x1, bbox->x1) || + !Geom::are_near(v->bbox.y1, bbox->y1)) { v->bbox = *bbox; } break; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 30a94302e..c6826bfb1 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -605,7 +605,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & // get bbox of the marker with that transform NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); // union it with the shape bbox nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } @@ -633,7 +633,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } // MID position @@ -660,7 +660,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 16c71d030..76a6618e5 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include "svg/svg.h" @@ -176,7 +177,7 @@ sp_star_set (SPObject *object, unsigned int key, const gchar *value) case SP_ATTR_SODIPODI_SIDES: if (value) { star->sides = atoi (value); - star->sides = NR_CLAMP(star->sides, 3, 1024); + star->sides = CLAMP(star->sides, 3, 1024); } else { star->sides = 5; } @@ -527,13 +528,13 @@ sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, g_return_if_fail (star != NULL); g_return_if_fail (SP_IS_STAR (star)); - star->sides = NR_CLAMP(sides, 3, 1024); + star->sides = CLAMP(sides, 3, 1024); star->center = center; star->r[0] = MAX (r1, 0.001); if (isflat == false) { - star->r[1] = NR_CLAMP(r2, 0.0, star->r[0]); + star->r[1] = CLAMP(r2, 0.0, star->r[0]); } else { - star->r[1] = NR_CLAMP( r1*cos(M_PI/sides) ,0.0, star->r[0] ); + star->r[1] = CLAMP( r1*cos(M_PI/sides) ,0.0, star->r[0] ); } star->arg[0] = arg1; star->arg[1] = arg2; diff --git a/src/sp-text.cpp b/src/sp-text.cpp index dd9856080..dd0225ac4 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -611,7 +611,7 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root) { SPStyle *style = SP_OBJECT_STYLE (item); - if (style && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) { + if (style && !Geom::are_near(ex, 1.0)) { if (!style->font_size.set && is_root) { style->font_size.set = 1; } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index cf1990900..463a64aee 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -576,9 +576,10 @@ sp_textpath_to_text(SPObject *tp) { SPObject *text = SP_OBJECT_PARENT(tp); - NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); - Geom::Point xy(bbox.x0, bbox.y0); + Geom::OptRect bbox; + sp_item_invoke_bbox(SP_ITEM(text), bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); + if (!bbox) return; + Geom::Point xy = bbox->min(); // make a list of textpath children GSList *tp_reprs = NULL; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db9f72975..a58e3aa88 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -46,7 +46,6 @@ #include "xml/repr.h" #include "xml/repr-sorting.h" #include <2geom/pathvector.h> -#include #include "helper/geom.h" #include "livarot/Path.h" diff --git a/src/star-context.cpp b/src/star-context.cpp index 63a15545f..4e9e883ce 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -452,14 +452,14 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state) double const sides = (gdouble) sc->magnitude; Geom::Point const d = p1 - p0; Geom::Coord const r1 = Geom::L2(d); - double arg1 = atan2(from_2geom(d)); + double arg1 = atan2(d); if (state & GDK_CONTROL_MASK) { /* Snap angle */ arg1 = sp_round(arg1, M_PI / snaps); } - sp_star_position_set(star, sc->magnitude, from_2geom(p0), r1, r1 * sc->proportion, + sp_star_position_set(star, sc->magnitude, p0, r1, r1 * sc->proportion, arg1, arg1 + M_PI / sides, sc->isflatsided, sc->rounded, sc->randomized); /* status text */ diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 372f5026d..f52f9483b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1112,7 +1112,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it gdouble const zoom = desktop->current_zoom(); gdouble const zby = (by / (zoom * (nb_let > 1 ? nb_let - 1 : 1)) - / to_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj))).descrim()); + / sp_item_i2doc_affine(SP_ITEM(source_obj)).descrim()); val += zby; if (start == end) { diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 0f3672f25..7b96f2a9e 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -28,15 +28,14 @@ //Inkscape includes #include "inkscape.h" -#include -#include -#include -#include - -#include -#include -#include -#include +#include "dialogs/dialog-events.h" +#include "extension/input.h" +#include "extension/output.h" +#include "extension/db.h" + +#include "libnr/nr-pixops.h" +#include "display/nr-arena-item.h" +#include "display/nr-arena.h" #include "sp-item.h" #include "display/canvas-arena.h" diff --git a/src/widgets/sp-color-wheel.cpp b/src/widgets/sp-color-wheel.cpp index b565bd485..5e1547e10 100644 --- a/src/widgets/sp-color-wheel.cpp +++ b/src/widgets/sp-color-wheel.cpp @@ -20,7 +20,6 @@ #include #include "sp-color-wheel.h" -#include "libnr/nr-rotate-ops.h" #include <2geom/transforms.h> #define WHEEL_SIZE 96 -- cgit v1.2.3 From 77dc5f1acd4a6b66b2d6fc5c81f7e5c61ef95785 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 02:49:51 +0200 Subject: Wholesale cruft removal part 4; fix crash when rendering guides (bzr r9508.1.48) --- src/box3d.cpp | 6 +- src/desktop-style.cpp | 4 +- src/display/canvas-bpath.cpp | 4 +- src/display/guideline.cpp | 138 ++++---------------- src/display/nr-arena-shape.cpp | 2 +- src/display/sp-canvas.cpp | 2 +- src/draw-context.cpp | 2 +- src/helper/geom.cpp | 4 +- src/libnr/Makefile_insert | 2 - src/libnr/nr-maybe.h | 201 ------------------------------ src/libnr/nr-path-code.h | 28 ----- src/live_effects/lpe-curvestitch.cpp | 2 +- src/live_effects/lpe-dynastroke.cpp | 6 +- src/live_effects/lpe-interpolate.cpp | 2 +- src/live_effects/lpe-patternalongpath.cpp | 4 +- src/live_effects/lpe-rough-hatches.cpp | 12 +- src/live_effects/lpe-sketch.cpp | 12 +- src/live_effects/lpe-vonkoch.cpp | 4 +- src/live_effects/parameter/parameter.cpp | 4 +- src/live_effects/parameter/random.cpp | 4 +- src/proj_pt.cpp | 2 +- src/proj_pt.h | 9 +- src/seltrans.cpp | 12 +- src/shape-editor.h | 1 - src/snap.cpp | 30 ++--- src/snapped-curve.cpp | 12 +- src/snapped-line.cpp | 16 +-- src/snapped-point.cpp | 26 ++-- src/snapped-point.h | 3 +- src/sp-item-transform.cpp | 6 +- src/sp-item.cpp | 6 +- src/transf_mat_3x4.h | 2 +- src/vanishing-point.h | 2 +- src/widgets/stroke-style.cpp | 2 +- src/widgets/toolbox.cpp | 2 +- 35 files changed, 121 insertions(+), 453 deletions(-) delete mode 100644 src/libnr/nr-maybe.h delete mode 100644 src/libnr/nr-path-code.h (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index aa2dc55e3..2c932b87c 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -391,7 +391,7 @@ Geom::Point box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) { Proj::Pt3 proj_corner (box3d_get_proj_corner (box, id)); if (!box3d_get_perspective(box)) { - return Geom::Point (NR_HUGE, NR_HUGE); + return Geom::Point (Geom::infinity(), Geom::infinity()); } Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); if (item_coords) { @@ -415,7 +415,7 @@ Geom::Point box3d_get_center_screen (SPBox3D *box) { Proj::Pt3 proj_center (box3d_get_proj_center (box)); if (!box3d_get_perspective(box)) { - return Geom::Point (NR_HUGE, NR_HUGE); + return Geom::Point (Geom::infinity(), Geom::infinity()); } Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_center).affine() * i2d.inverse(); @@ -489,7 +489,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta // find the closest snapping point int snap_index = -1; - double snap_dist = NR_HUGE; + double snap_dist = Geom::infinity(); for (int i = 0; i < num_snap_lines; ++i) { if (snap_dists[i] < snap_dist) { snap_index = i; diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 1b277a381..f68797d80 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -406,7 +406,7 @@ gdouble stroke_average_width (GSList const *objects) { if (g_slist_length ((GSList *) objects) == 0) - return NR_HUGE; + return Geom::infinity(); gdouble avgwidth = 0.0; bool notstroked = true; @@ -431,7 +431,7 @@ stroke_average_width (GSList const *objects) } if (notstroked) - return NR_HUGE; + return Geom::infinity(); return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked); } diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index cf9127352..ac2980de5 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -195,12 +195,12 @@ sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ if ( !cbp->curve || ((cbp->stroke_rgba & 0xff) == 0 && (cbp->fill_rgba & 0xff) == 0 ) || cbp->curve->get_segment_count() < 1) - return NR_HUGE; + return Geom::infinity(); double width = 0.5; Geom::Rect viewbox = item->canvas->getViewbox(); viewbox.expandBy (width); - double dist = NR_HUGE; + double dist = Geom::infinity(); pathv_matrix_point_bbox_wind_distance(cbp->curve->get_pathvector(), cbp->affine, p, NULL, NULL, &dist, 0.5, &viewbox); if (dist <= 1.0) { diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index f1b85b556..9c68cd8af 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -15,13 +15,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - -#include #include <2geom/transforms.h> #include "display-forward.h" #include "sp-canvas-util.h" #include "sp-ctrlpoint.h" #include "guideline.h" +#include "display/cairo-utils.h" static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); @@ -104,47 +103,20 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) { SPGuideLine const *gl = SP_GUIDELINE (item); - sp_canvas_prepare_buffer(buf); - - unsigned int const r = NR_RGBA32_R (gl->rgba); - unsigned int const g = NR_RGBA32_G (gl->rgba); - unsigned int const b = NR_RGBA32_B (gl->rgba); - unsigned int const a = NR_RGBA32_A (gl->rgba); + cairo_save(buf->ct); + cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + ink_cairo_set_source_rgba32(buf->ct, gl->rgba); if (gl->is_vertical()) { int position = (int) Inkscape::round(gl->point_on_line[Geom::X]); - if (position < buf->rect.x0 || position >= buf->rect.x1) { - return; - } - - int p0 = buf->rect.y0; - int p1 = buf->rect.y1; - int step = buf->buf_rowstride; - unsigned char *d = buf->buf + 4 * (position - buf->rect.x0); - - for (int p = p0; p < p1; p++) { - d[0] = NR_COMPOSEN11_1111(r, a, d[0]); - d[1] = NR_COMPOSEN11_1111(g, a, d[1]); - d[2] = NR_COMPOSEN11_1111(b, a, d[2]); - d += step; - } + cairo_move_to(buf->ct, position + 0.5, buf->rect.y0 + 0.5); + cairo_line_to(buf->ct, position + 0.5, buf->rect.y1 - 0.5); + cairo_stroke(buf->ct); } else if (gl->is_horizontal()) { int position = (int) Inkscape::round(gl->point_on_line[Geom::Y]); - if (position < buf->rect.y0 || position >= buf->rect.y1) { - return; - } - - int p0 = buf->rect.x0; - int p1 = buf->rect.x1; - int step = 4; - unsigned char *d = buf->buf + (position - buf->rect.y0) * buf->buf_rowstride; - - for (int p = p0; p < p1; p++) { - d[0] = NR_COMPOSEN11_1111(r, a, d[0]); - d[1] = NR_COMPOSEN11_1111(g, a, d[1]); - d[2] = NR_COMPOSEN11_1111(b, a, d[2]); - d += step; - } + cairo_move_to(buf->ct, buf->rect.x0 + 0.5, position + 0.5); + cairo_line_to(buf->ct, buf->rect.x1 - 0.5, position + 0.5); + cairo_stroke(buf->ct); } else { // render angled line, once intersection has been detected, draw from there. Geom::Point parallel_to_line( gl->normal_to_line[Geom::Y], @@ -156,7 +128,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) // intersects with left vertical! double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; sp_guideline_drawline (buf, buf->rect.x0, static_cast(round(y_intersect_left)), buf->rect.x1, static_cast(round(y_intersect_right)), gl->rgba); - return; + goto end; } //try to intersect with right vertical of rect @@ -164,7 +136,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) if ( (y_intersect_right >= buf->rect.y0) && (y_intersect_right <= buf->rect.y1) ) { // intersects with right vertical! sp_guideline_drawline (buf, buf->rect.x1, static_cast(round(y_intersect_right)), buf->rect.x0, static_cast(round(y_intersect_left)), gl->rgba); - return; + goto end; } //try to intersect with top horizontal of rect @@ -173,7 +145,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) // intersects with top horizontal! double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; sp_guideline_drawline (buf, static_cast(round(x_intersect_top)), buf->rect.y0, static_cast(round(x_intersect_bottom)), buf->rect.y1, gl->rgba); - return; + goto end; } //try to intersect with bottom horizontal of rect @@ -181,9 +153,11 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { // intersects with bottom horizontal! sp_guideline_drawline (buf, static_cast(round(x_intersect_bottom)), buf->rect.y1, static_cast(round(x_intersect_top)), buf->rect.y0, gl->rgba); - return; + goto end; } } + end: + cairo_restore(buf->ct); } static void sp_guideline_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) @@ -215,7 +189,7 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem SPGuideLine *gl = SP_GUIDELINE (item); if (!gl->sensitive) { - return NR_HUGE; + return Geom::infinity(); } *actual_item = item; @@ -277,82 +251,12 @@ void sp_guideline_delete(SPGuideLine *gl) gtk_object_destroy(GTK_OBJECT(gl)); } -//########################################################## -// Line rendering -#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params - -/** - \brief This function renders a pixel on a particular buffer. - - The topleft of the buffer equals - ( rect.x0 , rect.y0 ) in screen coordinates - ( 0 , 0 ) in setpixel coordinates - The bottomright of the buffer equals - ( rect.x1 , rect,y1 ) in screen coordinates - ( rect.x1 - rect.x0 , rect.y1 - rect.y0 ) in setpixel coordinates -*/ static void -sp_guideline_setpixel (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) +sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 /*rgba*/) { -#ifdef SAFE_SETPIXEL - if ( (x >= buf->rect.x0) && (x < buf->rect.x1) && (y >= buf->rect.y0) && (y < buf->rect.y1) ) { -#endif - guint r, g, b, a; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - guchar * p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); -#ifdef SAFE_SETPIXEL - } -#endif -} - -/** - \brief This function renders a line on a particular canvas buffer, - using Bresenham's line drawing function. - http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html - Coordinates are interpreted as SCREENcoordinates -*/ -static void -sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba) -{ - int dy = y1 - y0; - int dx = x1 - x0; - int stepx, stepy; - - if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } - if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } - dy <<= 1; // dy is now 2*dy - dx <<= 1; // dx is now 2*dx - - sp_guideline_setpixel(buf, x0, y0, rgba); - if (dx > dy) { - int fraction = dy - (dx >> 1); // same as 2*dy - dx - while (x0 != x1) { - if (fraction >= 0) { - y0 += stepy; - fraction -= dx; // same as fraction -= 2*dx - } - x0 += stepx; - fraction += dy; // same as fraction -= 2*dy - sp_guideline_setpixel(buf, x0, y0, rgba); - } - } else { - int fraction = dx - (dy >> 1); - while (y0 != y1) { - if (fraction >= 0) { - x0 += stepx; - fraction -= dy; - } - y0 += stepy; - fraction += dx; - sp_guideline_setpixel(buf, x0, y0, rgba); - } - } + cairo_move_to(buf->ct, x0 + 0.5, y0 + 0.5); + cairo_line_to(buf->ct, x1 - 0.5, y1 - 0.5); + cairo_stroke(buf->ct); } /* diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 0f86db041..5b5000c60 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -446,7 +446,7 @@ nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int width = 0; } - double dist = NR_HUGE; + double dist = Geom::infinity(); int wind = 0; bool needfill = (shape->nrstyle.fill.type != NRStyle::PAINT_NONE && shape->nrstyle.fill.opacity > 1e-3 && !outline); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 8be585a43..bfd007cfe 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -318,7 +318,7 @@ sp_canvas_item_invoke_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **a if (SP_CANVAS_ITEM_GET_CLASS (item)->point) return SP_CANVAS_ITEM_GET_CLASS (item)->point (item, p, actual_item); - return NR_HUGE; + return Geom::infinity(); } /** diff --git a/src/draw-context.cpp b/src/draw-context.cpp index da22c8a7a..4c1c775df 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -480,7 +480,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, /* mirrored by fabs, so this corresponds to 15 degrees */ Geom::Point best; /* best solution */ - double bn = NR_HUGE; /* best normal */ + double bn = Geom::infinity(); /* best normal */ double bdot = 0; Geom::Point v = Geom::Point(0, 1); double const r00 = cos(M_PI / snaps), r01 = sin(M_PI / snaps); diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index c79cd829a..da5d09436 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -28,8 +28,6 @@ using Geom::X; using Geom::Y; -#define NR_HUGE 1e18 - //################################################################################# // BOUNDING BOX CALCULATIONS @@ -423,7 +421,7 @@ pathv_matrix_point_bbox_wind_distance (Geom::PathVector const & pathv, Geom::Mat { if (pathv.empty()) { if (wind) *wind = 0; - if (dist) *dist = NR_HUGE; + if (dist) *dist = Geom::infinity(); return; } diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 6afef39ef..0a9b99e1e 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -13,10 +13,8 @@ ink_common_sources += \ libnr/nr-forward.h \ libnr/nr-i-coord.h \ libnr/nr-macros.h \ - libnr/nr-maybe.h \ libnr/nr-object.cpp \ libnr/nr-object.h \ - libnr/nr-path-code.h \ libnr/nr-pixblock-pattern.cpp \ libnr/nr-pixblock-pattern.h \ libnr/nr-pixblock.cpp \ diff --git a/src/libnr/nr-maybe.h b/src/libnr/nr-maybe.h deleted file mode 100644 index 6071a60ad..000000000 --- a/src/libnr/nr-maybe.h +++ /dev/null @@ -1,201 +0,0 @@ -#ifndef __NR_MAYBE_H__ -#define __NR_MAYBE_H__ - -/* - * Nullable values for C++ - * - * Copyright 2004, 2007 MenTaLguY - * - * This code is licensed under the GNU GPL; see COPYING for more information. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -namespace NR { - -class IsNothing : public std::domain_error { -public: - IsNothing() : domain_error(std::string("Is nothing")) {} -}; - -struct Nothing {}; - -template -class MaybeStorage { -public: - MaybeStorage() : _is_nothing(true) {} - MaybeStorage(T const &value) - : _value(value), _is_nothing(false) {} - - bool is_nothing() const { return _is_nothing; } - T &value() { return _value; } - T const &value() const { return _value; } - -private: - T _value; - bool _is_nothing; -}; - -template -class Maybe { -public: - Maybe() {} - Maybe(Nothing) {} - Maybe(T const &t) : _storage(t) {} - Maybe(Maybe const &m) : _storage(m._storage) {} - - template - Maybe(Maybe const &m) { - if (m) { - _storage = *m; - } - } - - template - Maybe(Maybe m) { - if (m) { - _storage = *m; - } - } - - operator bool() const { return !_storage.is_nothing(); } - - T const &operator*() const throw(IsNothing) { - if (_storage.is_nothing()) { - throw IsNothing(); - } else { - return _storage.value(); - } - } - T &operator*() throw(IsNothing) { - if (_storage.is_nothing()) { - throw IsNothing(); - } else { - return _storage.value(); - } - } - - T const *operator->() const throw(IsNothing) { - if (_storage.is_nothing()) { - throw IsNothing(); - } else { - return &_storage.value(); - } - } - T *operator->() throw(IsNothing) { - if (_storage.is_nothing()) { - throw IsNothing(); - } else { - return &_storage.value(); - } - } - - template - bool operator==(Maybe const &other) const { - bool is_nothing = _storage.is_nothing(); - if ( is_nothing || !other ) { - return is_nothing && !other; - } else { - return _storage.value() == *other; - } - } - template - bool operator!=(Maybe const &other) const { - bool is_nothing = _storage.is_nothing(); - if ( is_nothing || !other ) { - return !is_nothing || other; - } else { - return _storage.value() != *other; - } - } - -private: - MaybeStorage _storage; -}; - -template -class Maybe { -public: - Maybe() : _ref(NULL) {} - Maybe(Nothing) : _ref(NULL) {} - Maybe(T &t) : _ref(&t) {} - - template - Maybe(Maybe const &m) { - if (m) { - _ref = &*m; - } - } - - template - Maybe(Maybe m) { - if (m) { - _ref = *m; - } - } - - template - Maybe(Maybe m) { - if (m) { - _ref = *m; - } - } - - operator bool() const { return _ref; } - - T &operator*() const throw(IsNothing) { - if (!_ref) { - throw IsNothing(); - } else { - return *_ref; - } - } - T *operator->() const throw(IsNothing) { - if (!_ref) { - throw IsNothing(); - } else { - return _ref; - } - } - - template - bool operator==(Maybe const &other) const { - if ( !_ref || !other ) { - return !_ref && !other; - } else { - return *_ref == *other; - } - } - template - bool operator!=(Maybe const &other) const { - if ( !_ref || !other ) { - return _ref || other; - } else { - return *_ref != *other; - } - } - -private: - T *_ref; -}; - -} /* namespace NR */ - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-path-code.h b/src/libnr/nr-path-code.h deleted file mode 100644 index cc174d73b..000000000 --- a/src/libnr/nr-path-code.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SEEN_LIBNR_NR_PATH_CODE_H -#define SEEN_LIBNR_NR_PATH_CODE_H - -/** \file - * NRPathcode enum definition - */ - -typedef enum { - NR_MOVETO, ///< Start of closed subpath - NR_MOVETO_OPEN, ///< Start of open subpath - NR_CURVETO, ///< Bezier curve segment - NR_LINETO, ///< Line segment - NR_END ///< End record -} NRPathcode; - - -#endif /* !SEEN_LIBNR_NR_PATH_CODE_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index e1e21107c..9e02a3975 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -58,7 +58,7 @@ LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&scale_y_rel) ); nrofpaths.param_make_integer(); - nrofpaths.param_set_range(2, NR_HUGE); + nrofpaths.param_set_range(2, Geom::infinity()); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 0c97d50f0..a9f9202e9 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -97,11 +97,11 @@ LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(& round_ends) ); registerParameter( dynamic_cast(& capping) ); - width.param_set_range(0, NR_HUGE); + width.param_set_range(0, Geom::infinity()); roundness.param_set_range(0.01, 1); angle.param_set_range(-360, 360); - growfor.param_set_range(0, NR_HUGE); - fadefor.param_set_range(0, NR_HUGE); + growfor.param_set_range(0, Geom::infinity()); + fadefor.param_set_range(0, Geom::infinity()); show_orig_path = true; } diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index e77a392e9..4eb86ccf0 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -38,7 +38,7 @@ LPEInterpolate::LPEInterpolate(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&number_of_steps) ); number_of_steps.param_make_integer(); - number_of_steps.param_set_range(2, NR_HUGE); + number_of_steps.param_set_range(2, Geom::infinity()); } LPEInterpolate::~LPEInterpolate() diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 45b2b67b4..6e1738db8 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -139,9 +139,9 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise > con } //TODO: dynamical update of parameter ranges? //if (prop_units.get_value()){ - // spacing.param_set_range(-.9, NR_HUGE); + // spacing.param_set_range(-.9, Geom::infinity()); // }else{ - // spacing.param_set_range(-pattBndsX.extent()*.9, NR_HUGE); + // spacing.param_set_range(-pattBndsX.extent()*.9, Geom::infinity()); // } y0+=noffset; diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index f110aa743..eebac299a 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -271,13 +271,13 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&front_thickness) ); registerParameter( dynamic_cast(&back_thickness) ); - //hatch_dist.param_set_range(0.1, NR_HUGE); - growth.param_set_range(0, NR_HUGE); + //hatch_dist.param_set_range(0.1, Geom::infinity()); + growth.param_set_range(0, Geom::infinity()); dist_rdm.param_set_range(0, 99.); - stroke_width_top.param_set_range(0, NR_HUGE); - stroke_width_bot.param_set_range(0, NR_HUGE); - front_thickness.param_set_range(0, NR_HUGE); - back_thickness.param_set_range(0, NR_HUGE); + stroke_width_top.param_set_range(0, Geom::infinity()); + stroke_width_bot.param_set_range(0, Geom::infinity()); + front_thickness.param_set_range(0, Geom::infinity()); + back_thickness.param_set_range(0, Geom::infinity()); // hide the widgets for direction and bender vectorparams direction.widget_is_visible = false; diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e3354bff9..4d0212576 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -89,24 +89,24 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : #endif nbiter_approxstrokes.param_make_integer(); - nbiter_approxstrokes.param_set_range(0, NR_HUGE); - strokelength.param_set_range(1, NR_HUGE); + nbiter_approxstrokes.param_set_range(0, Geom::infinity()); + strokelength.param_set_range(1, Geom::infinity()); strokelength.param_set_increments(1., 5.); strokelength_rdm.param_set_range(0, 1.); strokeoverlap.param_set_range(0, 1.); strokeoverlap.param_set_increments(0.1, 0.30); ends_tolerance.param_set_range(0., 1.); - parallel_offset.param_set_range(0, NR_HUGE); + parallel_offset.param_set_range(0, Geom::infinity()); tremble_frequency.param_set_range(0.01, 100.); tremble_frequency.param_set_increments(.5, 1.5); strokeoverlap_rdm.param_set_range(0, 1.); #ifdef LPE_SKETCH_USE_CONSTRUCTION_LINES nbtangents.param_make_integer(); - nbtangents.param_set_range(0, NR_HUGE); - tgtscale.param_set_range(0, NR_HUGE); + nbtangents.param_set_range(0, Geom::infinity()); + tgtscale.param_set_range(0, Geom::infinity()); tgtscale.param_set_increments(.1, .5); - tgtlength.param_set_range(0, NR_HUGE); + tgtlength.param_set_range(0, Geom::infinity()); tgtlength.param_set_increments(1., 5.); tgtlength_rdm.param_set_range(0, 1.); tgt_places_rdmness.param_set_range(0, 1.); diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 85f8cde0c..23e76fe39 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -66,9 +66,9 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) : //registerParameter( dynamic_cast(&draw_boxes) ); nbgenerations.param_make_integer(); - nbgenerations.param_set_range(0, NR_HUGE); + nbgenerations.param_set_range(0, Geom::infinity()); maxComplexity.param_make_integer(); - maxComplexity.param_set_range(0, NR_HUGE); + maxComplexity.param_set_range(0, Geom::infinity()); } LPEVonKoch::~LPEVonKoch() diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 57d583ba6..fc15ce1f5 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -53,8 +53,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, Effect* effect, gdouble default_value) : Parameter(label, tip, key, wr, effect), value(default_value), - min(-NR_HUGE), - max(NR_HUGE), + min(-Geom::infinity()), + max(Geom::infinity()), integer(false), defvalue(default_value), digits(2), diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 889e5375b..cdfb1fb50 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -32,8 +32,8 @@ RandomParam::RandomParam( const Glib::ustring& label, const Glib::ustring& tip, { defvalue = default_value; value = defvalue; - min = -NR_HUGE; - max = NR_HUGE; + min = -Geom::infinity(); + max = Geom::infinity(); integer = false; defseed = default_seed; diff --git a/src/proj_pt.cpp b/src/proj_pt.cpp index 9294046ab..55f896a1a 100644 --- a/src/proj_pt.cpp +++ b/src/proj_pt.cpp @@ -48,7 +48,7 @@ Pt2::normalize() { Geom::Point Pt2::affine() { if (fabs(pt[2]) < epsilon) { - return Geom::Point (NR_HUGE, NR_HUGE); + return Geom::Point (Geom::infinity(), Geom::infinity()); } return Geom::Point (pt[0]/pt[2], pt[1]/pt[2]); } diff --git a/src/proj_pt.h b/src/proj_pt.h index 844cbb2c4..cc56f1aa8 100644 --- a/src/proj_pt.h +++ b/src/proj_pt.h @@ -13,7 +13,6 @@ */ #include <2geom/point.h> -#include "libnr/nr-values.h" #include namespace Proj { @@ -29,12 +28,12 @@ public: Pt2 (const gchar *coord_str); inline double operator[] (unsigned int index) const { - if (index > 2) { return NR_HUGE; } + if (index > 2) { return Geom::infinity(); } return pt[index]; } inline double &operator[] (unsigned int index) { // FIXME: How should we handle wrong indices? - //if (index > 2) { return NR_HUGE; } + //if (index > 2) { return Geom::infinity(); } return pt[index]; } inline bool operator== (Pt2 &rhs) { @@ -137,12 +136,12 @@ public: } inline double operator[] (unsigned int index) const { - if (index > 3) { return NR_HUGE; } + if (index > 3) { return Geom::infinity(); } return pt[index]; } inline double &operator[] (unsigned int index) { // FIXME: How should we handle wrong indices? - //if (index > 3) { return NR_HUGE; } + //if (index > 3) { return Geom::infinity(); } return pt[index]; } void normalize(); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 05f47d4ab..64c41ea23 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -377,9 +377,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s } // Now let's reduce this to a single closest snappoint - Geom::Coord dsp = _snap_points.size() == 1 ? Geom::L2((_snap_points.at(0)).getPoint() - p) : NR_HUGE; - Geom::Coord dbbp = _bbox_points.size() == 1 ? Geom::L2((_bbox_points.at(0)).getPoint() - p) : NR_HUGE; - Geom::Coord dbbpft = _bbox_points_for_translating.size() == 1 ? Geom::L2((_bbox_points_for_translating.at(0)).getPoint() - p) : NR_HUGE; + Geom::Coord dsp = _snap_points.size() == 1 ? Geom::L2((_snap_points.at(0)).getPoint() - p) : Geom::infinity(); + Geom::Coord dbbp = _bbox_points.size() == 1 ? Geom::L2((_bbox_points.at(0)).getPoint() - p) : Geom::infinity(); + Geom::Coord dbbpft = _bbox_points_for_translating.size() == 1 ? Geom::L2((_bbox_points_for_translating.at(0)).getPoint() - p) : Geom::infinity(); if (translating) { _bbox_points.clear(); @@ -1216,7 +1216,7 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P if (sn.getSnapped()) { // We snapped something, so change the skew to reflect it - Geom::Coord const sd = sn.getSnapped() ? sn.getTransformation()[0] : NR_HUGE; + Geom::Coord const sd = sn.getSnapped() ? sn.getTransformation()[0] : Geom::infinity(); _desktop->snapindicator->set_new_snaptarget(sn); skew[dim_a] = sd; } else { @@ -1630,8 +1630,8 @@ void Inkscape::SelTrans::_keepClosestPointOnly(std::vector::const_iterator i = points.begin(); i != points.end(); i++) { Geom::Coord dist = Geom::L2((*i).getPoint() - reference); diff --git a/src/shape-editor.h b/src/shape-editor.h index f400244b3..1f0958a3e 100644 --- a/src/shape-editor.h +++ b/src/shape-editor.h @@ -24,7 +24,6 @@ class SPNodeContext; class ShapeEditorsCollective; class LivePathEffectObject; -#include "libnr/nr-path-code.h" #include <2geom/point.h> #include #include diff --git a/src/snap.cpp b/src/snap.cpp index c47f93ff1..718700103 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -201,7 +201,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const Geom::OptRect const &bbox_to_snap) const { if (!someSnapperMightSnap()) { - return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false); + return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false); } SnappedConstraints sc; @@ -257,7 +257,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c if (_desktop && _desktop->gridsEnabled()) { bool success = false; Geom::Point nearest_multiple; - Geom::Coord nearest_distance = NR_HUGE; + Geom::Coord nearest_distance = Geom::infinity(); Inkscape::SnappedPoint bestSnappedPoint(t); // It will snap to the grid for which we find the closest snap. This might be a different @@ -551,10 +551,10 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( /* The current best transformation */ Geom::Point best_transformation = transformation; - /* The current best metric for the best transformation; lower is better, NR_HUGE + /* The current best metric for the best transformation; lower is better, Geom::infinity() ** means that we haven't snapped anything. */ - Geom::Point best_scale_metric(NR_HUGE, NR_HUGE); + Geom::Point best_scale_metric(Geom::infinity(), Geom::infinity()); Inkscape::SnappedPoint best_snapped_point; g_assert(best_snapped_point.getAlwaysSnap() == false); // Check initialization of snapped point g_assert(best_snapped_point.getAtIntersection() == false); @@ -643,7 +643,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( break; case SCALE: { - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); // If this point *i is horizontally or vertically aligned with // the origin of the scaling, then it will scale purely in X or Y // We can therefore only calculate the scaling in this direction @@ -654,7 +654,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (fabs(fabs(a[index]/b[index]) - fabs(transformation[index])) > 1e-12) { // if SNAPPING DID occur in this direction result[index] = a[index] / b[index]; // then calculate it! } - // we might leave result[1-index] = NR_HUGE + // we might leave result[1-index] = Geom::infinity() // if scaling didn't occur in the other direction } } @@ -666,13 +666,13 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } } // Compare the resulting scaling with the desired scaling - Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE + Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be Geom::infinity() snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1])); snapped_point.setSecondSnapDistance(std::max(scale_metric[0], scale_metric[1])); break; } case STRETCH: - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); if (fabs(b[dim]) > 1e-6) { // if STRETCHING will occur for this point result[dim] = a[dim] / b[dim]; result[1-dim] = uniform ? result[dim] : 1; @@ -684,14 +684,14 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[dim] - transformation[dim])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; case SKEW: result[0] = (snapped_point.getPoint()[dim] - ((*i).getPoint())[dim]) / (((*i).getPoint())[1 - dim] - origin[1 - dim]); // skew factor result[1] = transformation[1]; // scale factor // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; default: g_assert_not_reached(); @@ -708,10 +708,10 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( Geom::Coord best_metric; if (transformation_type == SCALE) { - // When scaling, don't ever exit with one of scaling components set to NR_HUGE + // When scaling, don't ever exit with one of scaling components set to Geom::infinity() for (int index = 0; index < 2; index++) { - if (best_transformation[index] == NR_HUGE) { - if (uniform && best_transformation[1-index] < NR_HUGE) { + if (best_transformation[index] == Geom::infinity()) { + if (uniform && best_transformation[1-index] < Geom::infinity()) { best_transformation[index] = best_transformation[1-index]; } else { best_transformation[index] = transformation[index]; @@ -722,9 +722,9 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( best_metric = best_snapped_point.getSnapDistance(); best_snapped_point.setTransformation(best_transformation); - // Using " < 1e6" instead of " < NR_HUGE" for catching some rounding errors + // Using " < 1e6" instead of " < Geom::infinity()" for catching some rounding errors // These rounding errors might be caused by NRRects, see bug #1584301 - best_snapped_point.setSnapDistance(best_metric < 1e6 ? best_metric : NR_HUGE); + best_snapped_point.setSnapDistance(best_metric < 1e6 ? best_metric : Geom::infinity()); return best_snapped_point; } diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index 77bc8280c..894e49f9a 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -20,7 +20,7 @@ Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, int num_p _tolerance = std::max(snapped_tolerance, 1.0); _always_snap = always_snap; _curve = curve; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _point = snapped_point; @@ -36,11 +36,11 @@ Inkscape::SnappedCurve::SnappedCurve() { _num_path = 0; _num_segm = 0; - _distance = NR_HUGE; + _distance = Geom::infinity(); _tolerance = 1; _always_snap = false; _curve = NULL; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _point = Geom::Point(0,0); @@ -67,8 +67,8 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur if (cs.size() > 0) { // There might be multiple intersections: find the closest - Geom::Coord best_dist = NR_HUGE; - Geom::Point best_p = Geom::Point(NR_HUGE, NR_HUGE); + Geom::Coord best_dist = Geom::infinity(); + Geom::Point best_p = Geom::Point(Geom::infinity(), Geom::infinity()); for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { Geom::Point p_ix = this->_curve->pointAt((*i).ta); Geom::Coord dist = Geom::distance(p_ix, p); @@ -106,7 +106,7 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur } // No intersection - return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, false, NR_HUGE, 0, false); + return SnappedPoint(Geom::Point(Geom::infinity(), Geom::infinity()), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false, false, Geom::infinity(), 0, false); } // search for the closest snapped line diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index da17ff81a..4b6a25929 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -22,7 +22,7 @@ Inkscape::SnappedLineSegment::SnappedLineSegment(Geom::Point const &snapped_poin _tolerance = std::max(snapped_tolerance, 1.0); _always_snap = always_snap; _at_intersection = false; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; } @@ -35,11 +35,11 @@ Inkscape::SnappedLineSegment::SnappedLineSegment() _source = SNAPSOURCE_UNDEFINED; _source_num = 0; _target = SNAPTARGET_UNDEFINED; - _distance = NR_HUGE; + _distance = Geom::infinity(); _tolerance = 1; _always_snap = false; _at_intersection = false; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; } @@ -85,7 +85,7 @@ Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegmen } // No intersection - return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, false, NR_HUGE, 0, false); + return SnappedPoint(Geom::Point(Geom::infinity(), Geom::infinity()), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false, false, Geom::infinity(), 0, false); }; @@ -99,7 +99,7 @@ Inkscape::SnappedLine::SnappedLine(Geom::Point const &snapped_point, Geom::Coord _distance = snapped_distance; _tolerance = std::max(snapped_tolerance, 1.0); _always_snap = always_snap; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _point = snapped_point; @@ -113,10 +113,10 @@ Inkscape::SnappedLine::SnappedLine() _source = SNAPSOURCE_UNDEFINED; _source_num = 0; _target = SNAPTARGET_UNDEFINED; - _distance = NR_HUGE; + _distance = Geom::infinity(); _tolerance = 1; _always_snap = false; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _point = Geom::Point(0,0); @@ -168,7 +168,7 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) } // No intersection - return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, false, NR_HUGE, 0, false); + return SnappedPoint(Geom::Point(Geom::infinity(), Geom::infinity()), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false, false, Geom::infinity(), 0, false); } // search for the closest snapped line segment diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index 48efa10e6..29e094a7c 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -21,11 +21,11 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const _at_intersection = false; _constrained_snap = constrained_snap; _fully_constrained = fully_constrained; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _transformation = Geom::Point(1,1); - _pointer_distance = NR_HUGE; + _pointer_distance = Geom::infinity(); } Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained) @@ -37,11 +37,11 @@ Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, Snap _at_intersection = false; _constrained_snap = constrained_snap; _fully_constrained = fully_constrained; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _transformation = Geom::Point(1,1); - _pointer_distance = NR_HUGE; + _pointer_distance = Geom::infinity(); _target_bbox = p.getTargetBBox(); } @@ -53,7 +53,7 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const // tolerance should never be smaller than 1 px, as it is used for normalization in // isOtherSnapBetter. We don't want a division by zero. _transformation = Geom::Point(1,1); - _pointer_distance = NR_HUGE; + _pointer_distance = Geom::infinity(); _target_bbox = Geom::OptRect(); } @@ -66,14 +66,14 @@ Inkscape::SnappedPoint::SnappedPoint() _at_intersection = false; _constrained_snap = false; _fully_constrained = false; - _distance = NR_HUGE; + _distance = Geom::infinity(); _tolerance = 1; _always_snap = false; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _transformation = Geom::Point(1,1); - _pointer_distance = NR_HUGE; + _pointer_distance = Geom::infinity(); _target_bbox = Geom::OptRect(); } @@ -85,14 +85,14 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p) _target = SNAPTARGET_UNDEFINED, _at_intersection = false; _fully_constrained = false; - _distance = NR_HUGE; + _distance = Geom::infinity(); _tolerance = 1; _always_snap = false; - _second_distance = NR_HUGE; + _second_distance = Geom::infinity(); _second_tolerance = 1; _second_always_snap = false; _transformation = Geom::Point(1,1); - _pointer_distance = NR_HUGE; + _pointer_distance = Geom::infinity(); _target_bbox = Geom::OptRect(); } @@ -152,7 +152,7 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth // When accounting for the distance to the mouse pointer, then at least one of the snapped points should // have that distance set. If not, then this is a bug. Either "weighted" must be set to false, or the // mouse pointer distance must be set. - g_assert(dist_pointer_this != NR_HUGE || dist_pointer_other != NR_HUGE); + g_assert(dist_pointer_this != Geom::infinity() || dist_pointer_other != Geom::infinity()); // The snap distance will always be smaller than the tolerance set for the snapper. The pointer distance can // however be very large. To compare these in a fair way, we will have to normalize these metrics first // The closest pointer distance will be normalized to 1.0; the other one will be > 1.0 @@ -195,7 +195,7 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth // or, if it's just as close then consider the second distance ... bool c5a = (dist_other == dist_this); - bool c5b = (other_one.getSecondSnapDistance() < getSecondSnapDistance()) && (getSecondSnapDistance() < NR_HUGE); + bool c5b = (other_one.getSecondSnapDistance() < getSecondSnapDistance()) && (getSecondSnapDistance() < Geom::infinity()); // ... or prefer free snaps over constrained snaps bool c5c = !other_one.getConstrainedSnap() && getConstrainedSnap(); diff --git a/src/snapped-point.h b/src/snapped-point.h index 05e954e1e..d0bcd324d 100644 --- a/src/snapped-point.h +++ b/src/snapped-point.h @@ -14,7 +14,6 @@ #include #include -#include //Because of NR_HUGE #include <2geom/geom.h> #include @@ -62,7 +61,7 @@ public: bool getAtIntersection() const {return _at_intersection;} bool getFullyConstrained() const {return _fully_constrained;} bool getConstrainedSnap() const {return _constrained_snap;} - bool getSnapped() const {return _distance < NR_HUGE;} + bool getSnapped() const {return _distance < Geom::infinity();} Geom::Point getTransformation() const {return _transformation;} void setTransformation(Geom::Point const t) {_transformation = t;} void setTarget(SnapTargetType const target) {_target = target;} diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 23c0bdf33..aefd6603a 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -123,7 +123,7 @@ get_scale_transform_with_stroke (Geom::Rect const &bbox_param, gdouble strokewid Geom::Matrix direct_constant_r = Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); - if (transform_stroke && r0 != 0 && r0 != NR_HUGE) { // there's stroke, and we need to scale it + if (transform_stroke && r0 != 0 && r0 != Geom::infinity()) { // there's stroke, and we need to scale it // These coefficients are obtained from the assumption that scaling applies to the // non-stroked "shape proper" and that stroke scale is scaled by the expansion of that // matrix. We're trying to solve this equation: @@ -148,7 +148,7 @@ get_scale_transform_with_stroke (Geom::Rect const &bbox_param, gdouble strokewid scale *= direct; } } else { - if (r0 == 0 || r0 == NR_HUGE) { // no stroke to scale + if (r0 == 0 || r0 == Geom::infinity()) { // no stroke to scale scale *= direct; } else {// nonscaling strokewidth scale *= direct_constant_r; @@ -175,7 +175,7 @@ get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Matrix const &abs } Geom::Rect new_visual_bbox = new_geom_bbox; - if (initial_strokewidth > 0 && initial_strokewidth < NR_HUGE) { + if (initial_strokewidth > 0 && initial_strokewidth < Geom::infinity()) { if (transform_stroke) { // scale stroke by: sqrt (((w1-r0)/(w0-r0))*((h1-r0)/(h0-r0))) (for visual bboxes, see get_scale_transform_with_stroke) // equals scaling by: sqrt ((w1/w0)*(h1/h0)) for geometrical bboxes diff --git a/src/sp-item.cpp b/src/sp-item.cpp index a778c3d79..a5510f203 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -773,8 +773,8 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c // TODO: replace NRRect by Geom::Rect, for all SPItemClasses, and for SP_CLIPPATH NRRect temp_bbox; - temp_bbox.x0 = temp_bbox.y0 = NR_HUGE; - temp_bbox.x1 = temp_bbox.y1 = -NR_HUGE; + temp_bbox.x0 = temp_bbox.y0 = Geom::infinity(); + temp_bbox.x1 = temp_bbox.y1 = -Geom::infinity(); // call the subclass method if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) { @@ -846,7 +846,7 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c if (temp_bbox.x0 > temp_bbox.x1 || temp_bbox.y0 > temp_bbox.y1) { // Either the bbox hasn't been touched by the SPItemClass' bbox method - // (it still has its initial values, see above: x0 = y0 = NR_HUGE and x1 = y1 = -NR_HUGE) + // (it still has its initial values, see above: x0 = y0 = Geom::infinity() and x1 = y1 = -Geom::infinity()) // or it has explicitely been set to be like this (e.g. in sp_shape_bbox) // When x0 > x1 or y0 > y1, the bbox is considered to be "nothing", although it has not been diff --git a/src/transf_mat_3x4.h b/src/transf_mat_3x4.h index 53c9ffa81..4b61c0951 100644 --- a/src/transf_mat_3x4.h +++ b/src/transf_mat_3x4.h @@ -29,7 +29,7 @@ public: void toggle_finite (Proj::Axis axis); double get_infinite_angle (Proj::Axis axis) { if (has_finite_image(axis)) { - return 1e18; //this used to be NR_HUGE before 2geom conversion + return Geom::infinity(); } Pt2 vp(column(axis)); return Geom::atan2(Geom::Point(vp[0], vp[1])) * 180.0/M_PI; diff --git a/src/vanishing-point.h b/src/vanishing-point.h index 9fcb6bb46..0551c87ba 100644 --- a/src/vanishing-point.h +++ b/src/vanishing-point.h @@ -67,7 +67,7 @@ public: return persp3d_get_VP (_persp, _axis).is_finite(); } inline Geom::Point get_pos() const { - g_return_val_if_fail (_persp, Geom::Point (NR_HUGE, NR_HUGE)); + g_return_val_if_fail (_persp, Geom::Point (Geom::infinity(), Geom::infinity())); return persp3d_get_VP (_persp,_axis).affine(); } inline Persp3D * get_perspective() const { diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index f020b0c3a..3e628c2cf 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -608,7 +608,7 @@ static gboolean stroke_width_set_unit(SPUnitSelector *, gdouble average = stroke_average_width (objects); - if (average == NR_HUGE || average == 0) + if (average == Geom::infinity() || average == 0) return FALSE; a->set_value (100.0 * w / average); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index c255e087b..e2f85a627 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -3360,7 +3360,7 @@ static void box3d_set_button_and_adjustment(Persp3D *persp, gtk_action_set_sensitive(act, TRUE); double angle = persp3d_get_infinite_angle(persp, axis); - if (angle != NR_HUGE) { // FIXME: We should catch this error earlier (don't show the spinbutton at all) + if (angle != Geom::infinity()) { // FIXME: We should catch this error earlier (don't show the spinbutton at all) gtk_adjustment_set_value(adj, box3d_normalize_angle(angle)); } } else { -- cgit v1.2.3 From 1b0dd0634095b71205407ec9e85ab39d7607cca5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 03:18:22 +0200 Subject: Fix mask rendering to use luminance-to-alpha (bzr r9508.1.49) --- src/display/cairo-templates.h | 41 +++++++++++++++++++++++++++++++++++ src/display/nr-arena-item.cpp | 12 +++++----- src/display/nr-filter-colormatrix.cpp | 15 ------------- 3 files changed, 48 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 78fdff664..3c8a6fea3 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -24,6 +24,7 @@ static const int OPENMP_THRESHOLD = 2048; #include #include #include "display/nr-3dutils.h" +#include "display/cairo-utils.h" /** * @brief Blend two surfaces using the supplied functor. @@ -200,6 +201,30 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); #endif + // this is provided just in case, to avoid problems with strict aliasing rules + if (in == out) { + if (bppin == 4) { + #if HAVE_OPENMP + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) + #endif + for (int i = 0; i < limit; ++i) { + *(in_data + i) = filter(*(in_data + i)); + } + } else { + #if HAVE_OPENMP + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) + #endif + for (int i = 0; i < limit; ++i) { + guint8 *in_p = reinterpret_cast(in_data) + i; + guint32 in_px = *in_p; in_px <<= 24; + guint32 out_px = filter(in_px); + *in_p = out_px >> 24; + } + } + cairo_surface_mark_dirty(out); + return; + } + if (bppin == 4) { if (bppout == 4) { // bppin == 4, bppout == 4 @@ -661,6 +686,22 @@ pxclamp(gint32 v, gint32 low, gint32 high) { #define ASSEMBLE_ARGB32(px,a,r,g,b) \ guint32 px = (a << 24) | (r << 16) | (g << 8) | b; +// this is also used for masks, so it resides in this header +struct ColorMatrixLuminanceToAlpha { + guint32 operator()(guint32 in) { + // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 + EXTRACT_ARGB32(in, a, r, g, b) + // unpremultiply color values + if (a != 0) { + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); + } + guint32 ao = r*54 + g*182 + b*18; + return ((ao + 127) / 255) << 24; + } +}; + #endif /* Local Variables: diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 0bdbd12ae..9b76c4ff7 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -20,6 +20,7 @@ #include #include "display/cairo-utils.h" +#include "display/cairo-templates.h" #include "nr-arena.h" #include "nr-arena-item.h" #include "gc-core.h" @@ -433,7 +434,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // render mask on the intermediate context and store it if (item->mask) { - maskgroup.push_with_content(CAIRO_CONTENT_ALPHA); + maskgroup.push_with_content(CAIRO_CONTENT_COLOR_ALPHA); // handle opacity of a masked object by composing it with the mask // this uses 1/4 the memory of composing it with full rendering if (needs_opacity) { @@ -449,12 +450,13 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area cct.paint_with_alpha(opacity); } mask = maskgroup.popmm(); + // convert luminance to alpha + cairo_pattern_t *p = mask->cobj(); + cairo_surface_t *s; + cairo_pattern_get_surface(p, &s); + ink_cairo_surface_filter(s, s, ColorMatrixLuminanceToAlpha()); } - /*if (mask) { - drawgroup.push(); - }*/ - // render the object (possibly to the intermediate surface) state = NR_ARENA_ITEM_VIRTUAL (item, render) (this_ct, item, this_area, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 7ab606182..d77898180 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -135,21 +135,6 @@ private: gint32 _v[9]; }; -struct ColorMatrixLuminanceToAlpha { - guint32 operator()(guint32 in) { - // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 - EXTRACT_ARGB32(in, a, r, g, b) - // unpremultiply color values - if (a != 0) { - r = unpremul_alpha(r, a); - g = unpremul_alpha(g, a); - b = unpremul_alpha(b, a); - } - guint32 ao = r*54 + g*182 + b*18; - return ((ao + 127) / 255) << 24; - } -}; - void FilterColorMatrix::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); -- cgit v1.2.3 From 13e643c744ca21ea6f5a50d404bec8aac886a808 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 06:01:01 +0200 Subject: Wholesale cruft removal part 5; completely remove RasterFont (bzr r9508.1.50) --- src/Makefile.am | 2 +- src/dialogs/text-edit.cpp | 74 ++- src/display/Makefile_insert | 1 - src/display/nr-filter-pixops.h | 152 ----- src/libnr/Makefile_insert | 19 +- src/libnr/nr-blit.cpp | 300 --------- src/libnr/nr-blit.h | 32 - src/libnr/nr-compose-reference.cpp | 266 -------- src/libnr/nr-compose-reference.h | 69 --- src/libnr/nr-compose-test.h | 457 -------------- src/libnr/nr-compose.cpp | 1197 ------------------------------------ src/libnr/nr-compose.h | 69 --- src/libnr/testnr.cpp | 92 --- src/libnrtype/FontInstance.cpp | 76 --- src/libnrtype/Makefile_insert | 4 - src/libnrtype/RasterFont.cpp | 435 ------------- src/libnrtype/RasterFont.h | 66 -- src/libnrtype/font-instance.h | 12 - src/libnrtype/font-lister.cpp | 3 - src/libnrtype/nrtype-forward.h | 3 - src/libnrtype/raster-glyph.h | 49 -- src/libnrtype/raster-position.h | 46 -- src/widgets/font-selector.cpp | 326 +--------- src/widgets/font-selector.h | 15 - 24 files changed, 61 insertions(+), 3704 deletions(-) delete mode 100644 src/display/nr-filter-pixops.h delete mode 100644 src/libnr/nr-blit.cpp delete mode 100644 src/libnr/nr-blit.h delete mode 100644 src/libnr/nr-compose-reference.cpp delete mode 100644 src/libnr/nr-compose-reference.h delete mode 100644 src/libnr/nr-compose-test.h delete mode 100644 src/libnr/nr-compose.cpp delete mode 100644 src/libnr/nr-compose.h delete mode 100644 src/libnr/testnr.cpp delete mode 100644 src/libnrtype/RasterFont.cpp delete mode 100644 src/libnrtype/RasterFont.h delete mode 100644 src/libnrtype/raster-glyph.h delete mode 100644 src/libnrtype/raster-position.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 03b58c610..3845823f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -259,7 +259,7 @@ TESTS = $(check_PROGRAMS) ../share/extensions/test/run-all-extension-tests XFAIL_TESTS = $(check_PROGRAMS) ../share/extensions/test/run-all-extension-tests # including the the testsuites here ensures that they get distributed -cxxtests_SOURCES = cxxtests.cpp libnr/nr-compose-reference.cpp $(CXXTEST_TESTSUITES) +cxxtests_SOURCES = cxxtests.cpp $(CXXTEST_TESTSUITES) cxxtests_LDADD = $(all_libs) cxxtests.cpp: $(CXXTEST_TESTSUITES) $(CXXTEST_TEMPLATE) diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index dc71de7c3..957a3c63c 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -364,8 +364,11 @@ sp_text_edit_dialog (void) } /* Font preview */ - GtkWidget *preview = sp_font_preview_new (); - gtk_box_pack_start (GTK_BOX (vb), preview, TRUE, TRUE, 4); + GtkLabel *preview = (GtkLabel*) gtk_label_new(NULL); + gtk_label_set_ellipsize(preview, PANGO_ELLIPSIZE_END); + gtk_label_set_justify(preview, GTK_JUSTIFY_CENTER); + gtk_label_set_line_wrap(preview, FALSE); + gtk_box_pack_start (GTK_BOX (vb), (GtkWidget*) preview, TRUE, TRUE, 4); g_object_set_data (G_OBJECT (dlg), "preview", preview); } @@ -684,7 +687,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); - GtkWidget *notebook = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "notebook"); + //GtkWidget *notebook = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "notebook"); GtkWidget *textw = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "textw"); GtkWidget *fontsel = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "fontsel"); GtkWidget *preview = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "preview"); @@ -695,6 +698,12 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, SPItem *text = sp_ted_get_selected_text_item (); + /* TRANSLATORS: Test string used in text and font dialog (when no + * text has been entered) to get a preview of the font. Choose + * some representative characters that users of your locale will be + * interested in. */ + gchar *phrase = g_strdup(_("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()")); + Inkscape::XML::Node *repr; if (text) { @@ -719,12 +728,10 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, gtk_text_buffer_set_text (tb, str, strlen (str)); gtk_text_buffer_set_modified (tb, FALSE); } - sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), str); - g_free (str); + phrase = str; } else { gtk_text_buffer_set_text (tb, "", 0); - sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), NULL); } } // end of if (docontent) repr = SP_OBJECT_REPR (text); @@ -761,7 +768,13 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, if (font) { // the font is oversized, so we need to pass the true size separately sp_font_selector_set_font (SP_FONT_SELECTOR (fontsel), font, query->font_size.computed); - sp_font_preview_set_font (SP_FONT_PREVIEW (preview), font, SP_FONT_SELECTOR(fontsel)); + char *desc = pango_font_description_to_string(font->descr); + double size = sp_font_selector_get_size(SP_FONT_SELECTOR(fontsel)); + gchar *markup = g_strdup_printf("%s", + desc, (int) size * PANGO_SCALE, phrase); + gtk_label_set_markup(GTK_LABEL(preview), markup); + g_free(desc); + g_free(markup); font->Unref(); font=NULL; } @@ -799,7 +812,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, sp_style_unref(query); } - + g_free(phrase); g_object_set_data (G_OBJECT (dlg), "blocked", NULL); } @@ -807,7 +820,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, static void sp_text_edit_dialog_text_changed (GtkTextBuffer *tb, GtkWidget *dlg) { - GtkWidget *textw, *preview, *apply, *def; + GtkWidget *textw, *preview, *apply, *def, *fontsel; GtkTextIter start, end; gchar *str; @@ -820,14 +833,23 @@ sp_text_edit_dialog_text_changed (GtkTextBuffer *tb, GtkWidget *dlg) preview = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "preview"); apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); + fontsel = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "fontsel"); gtk_text_buffer_get_bounds (tb, &start, &end); str = gtk_text_buffer_get_text (tb, &start, &end, TRUE); - - if (str && *str) { - sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), str); + font_instance *font = sp_font_selector_get_font(SP_FONT_SELECTOR(fontsel)); + + if (font) { + gchar *phrase = str && *str ? str : _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()"); + char *desc = pango_font_description_to_string(font->descr); + double size = sp_font_selector_get_size(SP_FONT_SELECTOR(fontsel)); + gchar *markup = g_strdup_printf("%s", + desc, (int) size * PANGO_SCALE, phrase); + gtk_label_set_markup(GTK_LABEL(preview), markup); + g_free(desc); + g_free(markup); } else { - sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), NULL); + gtk_label_set_markup(GTK_LABEL(preview), NULL); } g_free (str); @@ -852,7 +874,9 @@ sp_text_edit_dialog_font_changed ( SPFontSelector *fsel, font_instance *font, GtkWidget *dlg ) { - GtkWidget *preview, *apply, *def; + GtkWidget *preview, *apply, *def, *fontsel; + GtkTextIter start, end; + gchar *str; if (g_object_get_data (G_OBJECT (dlg), "blocked")) return; @@ -862,11 +886,27 @@ sp_text_edit_dialog_font_changed ( SPFontSelector *fsel, preview = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "preview"); apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); + fontsel = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "fontsel"); + + GtkTextBuffer *tb = (GtkTextBuffer*)g_object_get_data (G_OBJECT (dlg), "text"); + gtk_text_buffer_get_bounds (tb, &start, &end); + str = gtk_text_buffer_get_text (tb, &start, &end, TRUE); - sp_font_preview_set_font (SP_FONT_PREVIEW (preview), font, SP_FONT_SELECTOR(fsel)); + if (font) { + gchar *phrase = str && *str ? str : _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()"); + char *desc = pango_font_description_to_string(font->descr); + double size = sp_font_selector_get_size(SP_FONT_SELECTOR(fontsel)); + gchar *markup = g_strdup_printf("%s", + desc, (int) size * PANGO_SCALE, phrase); + gtk_label_set_markup(GTK_LABEL(preview), markup); + g_free(desc); + g_free(markup); + } else { + gtk_label_set_markup(GTK_LABEL(preview), NULL); + } + g_free(str); - if (text) - { + if (text) { gtk_widget_set_sensitive (apply, TRUE); } gtk_widget_set_sensitive (def, TRUE); diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 843f5aa8f..a860c6a44 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -71,7 +71,6 @@ ink_common_sources += \ display/nr-filter-morphology.h \ display/nr-filter-offset.cpp \ display/nr-filter-offset.h \ - display/nr-filter-pixops.h \ display/nr-filter-primitive.cpp \ display/nr-filter-primitive.h \ display/nr-filter-slot.cpp \ diff --git a/src/display/nr-filter-pixops.h b/src/display/nr-filter-pixops.h deleted file mode 100644 index b2db7067a..000000000 --- a/src/display/nr-filter-pixops.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef __NR_FILTER_PIXOPS_H__ -#define __NR_FILTER_PIXOPS_H__ - -#include "libnr/nr-pixblock.h" - -/* - * Per-pixel image manipulation functions. - * These can be used by all filter primitives, which combine two images on - * per-pixel basis. These are at least feBlend, feComposite and feMerge. - * - * Authors: - * Niko Kiirala - * - * Copyright (C) 2007 authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -namespace Inkscape { -namespace Filters { - -/** - * Mixes the two input images using the function given as template. - * The result is placed in out. - * The mixing function should have the following type: - * void mix(unsigned char *result, unsigned char const *in1, - * unsigned char const *in2); - * Each of the parameters for mix-function is a pointer to four bytes of data, - * giving the RGBA values for that pixel. The mix function must only access - * the four bytes beginning at a pointer given as parameter. - */ -/* - * The implementation is in a header file because of the template. It has to - * be in the same compilation unit as the code using it. Otherwise, linking - * the program will not succeed. - */ -template -void pixops_mix(NRPixBlock &out, NRPixBlock &in1, NRPixBlock &in2) { - unsigned char *in1_data = NR_PIXBLOCK_PX(&in1); - unsigned char *in2_data = NR_PIXBLOCK_PX(&in2); - unsigned char *out_data = NR_PIXBLOCK_PX(&out); - unsigned char zero_rgba[4] = {0, 0, 0, 0}; - - if (in1.area.y0 < in2.area.y0) { - // in1 begins before in2 on y-axis - for (int y = in1.area.y0 ; y < in2.area.y0 ; y++) { - int out_line = (y - out.area.y0) * out.rs; - int in_line = (y - in1.area.y0) * in1.rs; - for (int x = in1.area.x0 ; x < in1.area.x1 ; x++) { - blend(out_data + out_line + 4 * (x - out.area.x0), - in1_data + in_line + 4 * (x - in1.area.x0), - zero_rgba); - } - } - } else if (in1.area.y0 > in2.area.y0) { - // in2 begins before in1 on y-axis - for (int y = in2.area.y0 ; y < in1.area.y0 ; y++) { - int out_line = (y - out.area.y0) * out.rs; - int in_line = (y - in2.area.y0) * in2.rs; - for (int x = in2.area.x0 ; x < in2.area.x1 ; x++) { - blend(out_data + out_line + 4 * (x - out.area.x0), - zero_rgba, - in2_data + in_line + 4 * (x - in2.area.x0)); - } - } - } - - for (int y = std::max(in1.area.y0, in2.area.y0) ; - y < std::min(in1.area.y1, in2.area.y1) ; ++y) { - int out_line = (y - out.area.y0) * out.rs; - int in1_line = (y - in1.area.y0) * in1.rs; - int in2_line = (y - in2.area.y0) * in2.rs; - - if (in1.area.x0 < in2.area.x0) { - // in1 begins before in2 on x-axis - for (int x = in1.area.x0 ; x < in2.area.x0 ; ++x) { - blend(out_data + out_line + 4 * (x - out.area.x0), - in1_data + in1_line + 4 * (x - in1.area.x0), - zero_rgba); - } - } else if (in1.area.x0 > in2.area.x0) { - // in2 begins before in1 on x-axis - for (int x = in2.area.x0 ; x < in1.area.x0 ; ++x) { - blend(out_data + out_line + 4 * (x - out.area.x0), - zero_rgba, - in2_data + in2_line + 4 * (x - in2.area.x0)); - } - } - - for (int x = std::max(in1.area.x0, in2.area.x0) ; - x < std::min(in1.area.x1, in2.area.x1) ; ++x) { - blend(out_data + out_line + 4 * (x - out.area.x0), - in1_data + in1_line + 4 * (x - in1.area.x0), - in2_data + in2_line + 4 * (x - in2.area.x0)); - } - - if (in1.area.x1 > in2.area.x1) { - // in1 ends after in2 on x-axis - for (int x = in2.area.x1 ; x < in1.area.x1 ; ++x) { - blend(out_data + out_line + 4 * (x - out.area.x0), - in1_data + in1_line + 4 * (x - in1.area.x0), - zero_rgba); - } - } else if (in1.area.x1 < in2.area.x1) { - // in2 ends after in1 on x-axis - for (int x = in1.area.x1 ; x < in2.area.x1 ; ++x) { - blend(out_data + out_line + 4 * (x - out.area.x0), - zero_rgba, - in2_data + in2_line + 4 * (x - in2.area.x0)); - } - } - } - - if (in1.area.y1 > in2.area.y1) { - // in1 ends after in2 on y-axis - for (int y = in2.area.y1 ; y < in1.area.y1 ; y++) { - int out_line = (y - out.area.y0) * out.rs; - int in_line = (y - in1.area.y0) * in1.rs; - for (int x = in1.area.x0 ; x < in1.area.x1 ; x++) { - blend(out_data + out_line + 4 * (x - out.area.x0), - in1_data + in_line + 4 * (x - in1.area.x0), - zero_rgba); - } - } - } else if (in1.area.y1 < in2.area.y1) { - // in2 ends after in1 on y-axis - for (int y = in1.area.y1 ; y < in2.area.y1 ; y++) { - int out_line = (y - out.area.y0) * out.rs; - int in_line = (y - in2.area.y0) * in2.rs; - for (int x = in2.area.x0 ; x < in2.area.x1 ; x++) { - blend(out_data + out_line + 4 * (x - out.area.x0), - zero_rgba, - in2_data + in_line + 4 * (x - in2.area.x0)); - } - } - } -} - -} /* namespace Filters */ -} /* namespace Inkscape */ - -#endif // __NR_FILTER_PIXOPS_H_ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 0a9b99e1e..2da8e36fb 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -2,11 +2,6 @@ ink_common_sources += \ libnr/in-svg-plane.h \ - libnr/nr-blit.cpp \ - libnr/nr-blit.h \ - libnr/nr-compose-reference.h \ - libnr/nr-compose.cpp \ - libnr/nr-compose.h \ libnr/nr-convert2geom.h \ libnr/nr-coord.h \ libnr/nr-dim2.h \ @@ -30,27 +25,15 @@ ink_common_sources += \ libnr/nr-rect.cpp \ libnr/nr-rect.h \ libnr/nr-rect-ops.h \ - libnr/nr-render.h \ libnr/nr-types.cpp \ libnr/nr-types.h \ libnr/nr-values.cpp \ - libnr/nr-values.h \ - $(libnr_mmx_sources) - -# Ancient performance test (?) -# Won't work anymore. -#libnr_testnr_SOURCES = \ -# libnr/testnr.cpp - -#libnr_testnr_LDADD = \ -# libnr/libnr.a \ -# -lglib-2.0 + libnr/nr-values.h # ###################### # ### CxxTest stuff #### # ###################### CXXTEST_TESTSUITES += \ $(srcdir)/libnr/in-svg-plane-test.h \ - $(srcdir)/libnr/nr-compose-test.h \ $(srcdir)/libnr/nr-point-fns-test.h \ $(srcdir)/libnr/nr-types-test.h diff --git a/src/libnr/nr-blit.cpp b/src/libnr/nr-blit.cpp deleted file mode 100644 index 144caa597..000000000 --- a/src/libnr/nr-blit.cpp +++ /dev/null @@ -1,300 +0,0 @@ -#define __NR_BLIT_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include "nr-pixops.h" -#include "nr-compose.h" -#include "nr-blit.h" - -void -nr_blit_pixblock_pixblock_alpha (NRPixBlock *d, NRPixBlock *s, unsigned int alpha) -{ - NRRectL clip; - unsigned char *dpx, *spx; - int dbpp, sbpp; - int w, h; - - if (alpha == 0) return; - if (s->empty) return; - /* fixme: */ - if (s->mode == NR_PIXBLOCK_MODE_A8) return; - /* fixme: */ - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8) return; - - /* - * Possible variants as of now: - * - * 0. SRC EP - DST EP * - * 1. SRC EP - DST EN * - * 2. SRC EP - DST P * - * 3. SRC EP - DST N * - * 4. SRC EN - DST EP * - * 5. SRC EN - DST EN * - * 6. SRC EN - DST P * - * 7. SRC EN - DST N * - * 8. SRC P - DST EP * - * 9. SRC P - DST EN * - * A. SRC P - DST P * - * B. SRC P - DST N * - * C. SRC N - DST EP * - * D. SRC N - DST EN * - * E. SRC N - DST P * - * F. SRC N - DST N * - * - */ - - nr_rect_l_intersect (&clip, &d->area, &s->area); - - if (nr_rect_l_test_empty(clip)) return; - - /* Pointers */ - dbpp = NR_PIXBLOCK_BPP (d); - dpx = NR_PIXBLOCK_PX (d) + (clip.y0 - d->area.y0) * d->rs + dbpp * (clip.x0 - d->area.x0); - sbpp = NR_PIXBLOCK_BPP (s); - spx = NR_PIXBLOCK_PX (s) + (clip.y0 - s->area.y0) * s->rs + sbpp * (clip.x0 - s->area.x0); - w = clip.x1 - clip.x0; - h = clip.y1 - clip.y0; - - switch (d->mode) { - case NR_PIXBLOCK_MODE_A8: - /* No rendering into alpha at moment */ - break; - case NR_PIXBLOCK_MODE_R8G8B8: - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - nr_R8G8B8_R8G8B8_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha); - } else { - nr_R8G8B8_R8G8B8_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - if (d->empty) { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* Case 8 */ - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha); - } else { - /* Case C */ - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha); - } - } else { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* case A */ - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha); - } else { - /* case E */ - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha); - } - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - if (d->empty) { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* Case 9 */ - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha); - } else { - /* Case D */ - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha); - } - } else { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* case B */ - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P (dpx, w, h, d->rs, spx, s->rs, alpha); - } else { - /* case F */ - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N (dpx, w, h, d->rs, spx, s->rs, alpha); - } - } - break; - } -} - -void -nr_blit_pixblock_pixblock_mask (NRPixBlock *d, NRPixBlock *s, NRPixBlock *m) -{ - NRRectL clip; - unsigned char *dpx, *spx, *mpx; - int dbpp, sbpp; - int w, h; - - if (s->empty) return; - /* fixme: */ - if (s->mode == NR_PIXBLOCK_MODE_A8) return; - /* fixme: */ - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8) return; - - /* - * Possible variants as of now: - * - * 0. SRC EP - DST EP * - * 1. SRC EP - DST EN * - * 2. SRC EP - DST P * - * 3. SRC EP - DST N * - * 4. SRC EN - DST EP * - * 5. SRC EN - DST EN * - * 6. SRC EN - DST P * - * 7. SRC EN - DST N * - * 8. SRC P - DST EP * - * 9. SRC P - DST EN * - * A. SRC P - DST P * - * B. SRC P - DST N * - * C. SRC N - DST EP * - * D. SRC N - DST EN * - * E. SRC N - DST P * - * F. SRC N - DST N * - * - */ - - nr_rect_l_intersect (&clip, &d->area, &s->area); - nr_rect_l_intersect (&clip, &clip, &m->area); - - if (nr_rect_l_test_empty(clip)) return; - - /* Pointers */ - dbpp = NR_PIXBLOCK_BPP (d); - dpx = NR_PIXBLOCK_PX (d) + (clip.y0 - d->area.y0) * d->rs + dbpp * (clip.x0 - d->area.x0); - sbpp = NR_PIXBLOCK_BPP (s); - spx = NR_PIXBLOCK_PX (s) + (clip.y0 - s->area.y0) * s->rs + sbpp * (clip.x0 - s->area.x0); - mpx = NR_PIXBLOCK_PX (m) + (clip.y0 - m->area.y0) * m->rs + 1 * (clip.x0 - m->area.x0); - w = clip.x1 - clip.x0; - h = clip.y1 - clip.y0; - - switch (d->mode) { - case NR_PIXBLOCK_MODE_A8: - /* No rendering into alpha at moment */ - break; - case NR_PIXBLOCK_MODE_R8G8B8: - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } else { - nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - if (d->empty) { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* Case 8 */ - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } else { - /* Case C */ - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } - } else { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* case A */ - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } else { - /* case E */ - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - if (d->empty) { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* Case 9 */ - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } else { - /* Case D */ - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } - } else { - if (s->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - /* case B */ - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } else { - /* case F */ - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 (dpx, w, h, d->rs, spx, s->rs, mpx, m->rs); - } - } - break; - } -} - -void -nr_blit_pixblock_mask_rgba32 (NRPixBlock *d, NRPixBlock *m, unsigned long rgba) -{ - if (!(rgba & 0xff)) return; - - if (m) { - NRRectL clip; - unsigned char *dpx, *mpx; - int w, h; - - if (m->mode != NR_PIXBLOCK_MODE_A8) return; - - if (!nr_rect_l_test_intersect(d->area, m->area)) return; - - nr_rect_l_intersect (&clip, &d->area, &m->area); - - /* Pointers */ - dpx = NR_PIXBLOCK_PX (d) + (clip.y0 - d->area.y0) * d->rs + NR_PIXBLOCK_BPP (d) * (clip.x0 - d->area.x0); - mpx = NR_PIXBLOCK_PX (m) + (clip.y0 - m->area.y0) * m->rs + (clip.x0 - m->area.x0); - w = clip.x1 - clip.x0; - h = clip.y1 - clip.y0; - - if (d->empty) { - if (d->mode == NR_PIXBLOCK_MODE_R8G8B8) { - nr_R8G8B8_R8G8B8_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba); - } else if (d->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - nr_R8G8B8A8_P_EMPTY_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba); - } else { - nr_R8G8B8A8_N_EMPTY_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba); - } - d->empty = 0; - } else { - if (d->mode == NR_PIXBLOCK_MODE_R8G8B8) { - nr_R8G8B8_R8G8B8_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba); - } else if (d->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { - nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba); - } else { - nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 (dpx, w, h, d->rs, mpx, m->rs, rgba); - } - } - } else { - unsigned int r, g, b, a; - int x, y; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - for (y = d->area.y0; y < d->area.y1; y++) { - unsigned char *p; - p = NR_PIXBLOCK_PX (d) + (y - d->area.y0) * d->rs; - for (x = d->area.x0; x < d->area.x1; x++) { - unsigned int da; - switch (d->mode) { - case NR_PIXBLOCK_MODE_R8G8B8: - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += 3; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - p[0] = NR_COMPOSENPP_1111 (r, a, p[0]); - p[1] = NR_COMPOSENPP_1111 (g, a, p[1]); - p[2] = NR_COMPOSENPP_1111 (b, a, p[2]); - p[3] = NR_COMPOSEA_111(a, p[3]); - p += 4; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - da = NR_COMPOSEA_112(a, p[3]); - p[0] = NR_COMPOSENNN_111121 (r, a, p[0], p[3], da); - p[1] = NR_COMPOSENNN_111121 (g, a, p[1], p[3], da); - p[2] = NR_COMPOSENNN_111121 (b, a, p[2], p[3], da); - p[3] = NR_NORMALIZE_21(da); - p += 4; - break; - default: - break; - } - } - } - } -} - diff --git a/src/libnr/nr-blit.h b/src/libnr/nr-blit.h deleted file mode 100644 index 3221c8187..000000000 --- a/src/libnr/nr-blit.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __NR_BLIT_H__ -#define __NR_BLIT_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -#define nr_blit_pixblock_pixblock(d,s) nr_blit_pixblock_pixblock_alpha (d, s, 255) - -void nr_blit_pixblock_pixblock_alpha (NRPixBlock *d, NRPixBlock *s, unsigned int alpha); -void nr_blit_pixblock_pixblock_mask (NRPixBlock *d, NRPixBlock *s, NRPixBlock *m); -void nr_blit_pixblock_mask_rgba32 (NRPixBlock *d, NRPixBlock *m, unsigned long rgba32); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-compose-reference.cpp b/src/libnr/nr-compose-reference.cpp deleted file mode 100644 index b4ff5851a..000000000 --- a/src/libnr/nr-compose-reference.cpp +++ /dev/null @@ -1,266 +0,0 @@ - -// This is a reference implementation of the compositing functions in nr-compose.cpp. - -#include "nr-compose-reference.h" - -#define NR_RGBA32_R(v) (unsigned char) (((v) >> 24) & 0xff) -#define NR_RGBA32_G(v) (unsigned char) (((v) >> 16) & 0xff) -#define NR_RGBA32_B(v) (unsigned char) (((v) >> 8) & 0xff) -#define NR_RGBA32_A(v) (unsigned char) ((v) & 0xff) - -static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; } - -static unsigned int pixelSize[] = { 1, 3, 4, 4 }; - -// Computes : -// dc' = (1 - alpha*sa) * dc + alpha*sc -// da' = 1 - (1 - alpha*sa) * (1 - da) -// Assuming premultiplied color values -template -static void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha); - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + alpha*s[3]*s[0], 255*255); - d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + alpha*s[3]*s[1], 255*255); - d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + alpha*s[3]*s[2], 255*255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + 255*alpha*s[0], 255*255); - d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + 255*alpha*s[1], 255*255); - d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + 255*alpha*s[2], 255*255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - unsigned int newa = 255*255 - (255*255 - alpha*s[3]); - d[0] = s[0];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[0], newa); - d[1] = s[1];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[1], newa); - d[2] = s[2];//newa == 0 ? 0 : DIV_ROUND(alpha*s[3]*s[2], newa); - d[3] = DIV_ROUND(newa, 255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - unsigned int newa = 255*255 - (255*255 - alpha*s[3]); - d[0] = s[3] == 0 ? 0 : DIV_ROUND(255*s[0], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[0], newa); - d[1] = s[3] == 0 ? 0 : DIV_ROUND(255*s[1], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[1], newa); - d[2] = s[3] == 0 ? 0 : DIV_ROUND(255*s[2], s[3]);//newa == 0 ? 0 : DIV_ROUND(255*alpha*s[2], newa); - d[3] = DIV_ROUND(newa, 255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - if ( d[3] == 0 ) { - composePixel(d, s, alpha); - } else if ( alpha*s[3] == 0 ) { - /* NOP */ - } else { - unsigned int newa = 255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]); - d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[0] + 255 * alpha*s[3]*s[0], newa); - d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[1] + 255 * alpha*s[3]*s[1], newa); - d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[2] + 255 * alpha*s[3]*s[2], newa); - d[3] = DIV_ROUND(newa, 255*255); - } -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - if ( d[3] == 0 ) { - composePixel(d, s, alpha); - } else if ( alpha*s[3] == 0 ) { - /* NOP */ - } else { - unsigned int newa = 255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]); - d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[0] + 255*255 * alpha*s[0], newa); - d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[1] + 255*255 * alpha*s[1], newa); - d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[3]*d[2] + 255*255 * alpha*s[2], newa); - d[3] = DIV_ROUND(newa, 255*255); - } -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - d[0] = DIV_ROUND(alpha*s[3]*s[0], 255*255); - d[1] = DIV_ROUND(alpha*s[3]*s[1], 255*255); - d[2] = DIV_ROUND(alpha*s[3]*s[2], 255*255); - d[3] = DIV_ROUND(255*255 - (255*255 - alpha*s[3]), 255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - d[0] = DIV_ROUND(alpha*s[0], 255); - d[1] = DIV_ROUND(alpha*s[1], 255); - d[2] = DIV_ROUND(alpha*s[2], 255); - d[3] = DIV_ROUND(255*255 - (255*255 - alpha*s[3]), 255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + alpha*s[3]*s[0], 255*255); - d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + alpha*s[3]*s[1], 255*255); - d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + alpha*s[3]*s[2], 255*255); - d[3] = DIV_ROUND(255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]), 255*255); -} - -template<> void composePixel(unsigned char *d, const unsigned char *s, unsigned int alpha) { - d[0] = DIV_ROUND((255*255 - alpha*s[3]) * d[0] + 255 * alpha*s[0], 255*255); - d[1] = DIV_ROUND((255*255 - alpha*s[3]) * d[1] + 255 * alpha*s[1], 255*255); - d[2] = DIV_ROUND((255*255 - alpha*s[3]) * d[2] + 255 * alpha*s[2], 255*255); - d[3] = DIV_ROUND(255*255*255 - (255*255 - alpha*s[3]) * (255 - d[3]), 255*255); -} - - -// composeAlpha, iterates over all pixels and applies composePixel to each of them -template -static void composeAlpha(unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - for(int y=0; y(d, s, alpha); - d += pixelSize[resultFormat]; - s += pixelSize[foregroundFormat]; - } - px += rs; - spx += srs; - } -} - -template -static void composeMask(unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - for(int y=0; y(d, s, *m); - d += pixelSize[resultFormat]; - s += pixelSize[foregroundFormat]; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -template -static void composeColor(unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) { - const unsigned char rgba_array[4] = {NR_RGBA32_R(rgba), NR_RGBA32_G(rgba), NR_RGBA32_B(rgba), NR_RGBA32_A(rgba)}; - for(int y=0; y(d, rgba_array, *m); - d += pixelSize[resultFormat]; - m += 1; - } - px += rs; - mpx += mrs; - } -} - -/* FINAL DST SRC */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -/* FINAL DST SRC MASK */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - composeMask(px, w, h, rs, spx, srs, mpx, mrs); -} - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - composeMask(px, w, h, rs, spx, srs, mpx, mrs); -} - -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - composeMask(px, w, h, rs, spx, srs, mpx, mrs); -} - -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - composeMask(px, w, h, rs, spx, srs, mpx, mrs); -} - - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) { - composeMask(p, w, h, rs, s, srs, m, mrs); -} - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) { - composeMask(p, w, h, rs, s, srs, m, mrs); -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) { - composeMask(p, w, h, rs, s, srs, m, mrs); -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs, const unsigned char *s, int srs, const unsigned char *m, int mrs) { - composeMask(p, w, h, rs, s, srs, m, mrs); -} - -/* FINAL DST MASK COLOR */ - -void nr_R8G8B8A8_N_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) { - composeColor(px, w, h, rs, mpx, mrs, rgba); -} - -void nr_R8G8B8A8_P_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) { - composeColor(px, w, h, rs, mpx, mrs, rgba); -} - - -void nr_R8G8B8_R8G8B8_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) { - composeColor(px, w, h, rs, spx, srs, rgba); -} - -void nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) { - composeColor(px, w, h, rs, spx, srs, rgba); -} - -void nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) { - composeColor(px, w, h, rs, spx, srs, rgba); -} - -/* RGB */ - -void nr_R8G8B8_R8G8B8_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8_R8G8B8_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) { - composeAlpha(px, w, h, rs, spx, srs, alpha); -} - -void nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - composeMask(px, w, h, rs, spx, srs, mpx, mrs); -} - -void nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) { - composeMask(px, w, h, rs, spx, srs, mpx, mrs); -} diff --git a/src/libnr/nr-compose-reference.h b/src/libnr/nr-compose-reference.h deleted file mode 100644 index 8d004a135..000000000 --- a/src/libnr/nr-compose-reference.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __NR_COMPOSE_REFERENCE_H__ -#define __NR_COMPOSE_REFERENCE_H__ - -// Based on nr-pixblock.h -typedef enum { - A8 = 0, - R8G8B8, - R8G8B8A8N, - R8G8B8A8P, - EMPTY = -1 -} PIXEL_FORMAT; - -/* FINAL DST SRC */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); - -/* FINAL DST SRC MASK */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8_ref (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8_ref (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); - -/* FINAL DST MASK COLOR */ - -void nr_R8G8B8A8_N_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); -void nr_R8G8B8A8_P_EMPTY_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); - -void nr_R8G8B8_R8G8B8_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba); -void nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba); -void nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba); - -/* RGB */ - -void nr_R8G8B8_R8G8B8_R8G8B8A8_P_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8_R8G8B8_R8G8B8A8_N_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs); -void nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8_ref (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs); - -#endif//__NR_COMPOSE_REFERENCE_H__ diff --git a/src/libnr/nr-compose-test.h b/src/libnr/nr-compose-test.h deleted file mode 100644 index fe3ccd61f..000000000 --- a/src/libnr/nr-compose-test.h +++ /dev/null @@ -1,457 +0,0 @@ - -#include - -#include "nr-compose.h" -#include "nr-compose-reference.h" -#include -#include -#include -#include - -static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; } -static inline unsigned char NR_PREMUL_111(unsigned int c, unsigned int a) { return static_cast(DIV_ROUND(c*a, 255)); } - -template -int IMGCMP(const unsigned char* a, const unsigned char* b, size_t n) { return memcmp(a, b, n); } - -template<> -int IMGCMP(const unsigned char* a, const unsigned char* b, size_t n) -{ - // If two pixels each have their alpha channel set to zero they're equivalent - // Note that this doesn't work for premultiplied values, as their color values should - // be zero when alpha is zero. - int cr = 0; - while(n && cr == 0) { - if ( a[3] != 0 || b[3] != 0 ) { - cr = memcmp(a, b, 4); - } - a+=4; - b+=4; - n-=4; - } - return cr; -} - -class NrComposeTest : public CxxTest::TestSuite { -private: - int const w, h; - - unsigned char* const dst_rgba_n_org; - unsigned char* const dst_rgba_p_org; - unsigned char* const dst_rgb_org; - - unsigned char* const dst1_rgba; - unsigned char* const dst2_rgba; - unsigned char* const src_rgba_n; - unsigned char* const src_rgba_p; - unsigned char* const dst1_rgb; - unsigned char* const dst2_rgb; - unsigned char* const src_rgb; - unsigned char* const mask; - - static unsigned int const alpha_vals[7]; - static unsigned int const rgb_vals[3]; - -public: - NrComposeTest() : - w(13), - h(5), - - dst_rgba_n_org(new unsigned char[w*h*4]), - dst_rgba_p_org(new unsigned char[w*h*4]), - dst_rgb_org(new unsigned char[w*h*3]), - - dst1_rgba(new unsigned char[w*h*4]), - dst2_rgba(new unsigned char[w*h*4]), - src_rgba_n(new unsigned char[w*h*4]), - src_rgba_p(new unsigned char[w*h*4]), - dst1_rgb(new unsigned char[w*h*3]), - dst2_rgb(new unsigned char[w*h*3]), - src_rgb(new unsigned char[w*h*3]), - mask(new unsigned char[w*h]) - { - srand(23874683); // It shouldn't really matter what this is, as long as it's always the same (to be reproducible) - - for(int y=0; y(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_P() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_N() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_P() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P() - { - for(size_t i=0; i(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - - // FINAL DST SRC MASK - - void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8() - { - memcpy(dst1_rgba, dst_rgba_n_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_n_org, w*h*4); - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8() - { - memcpy(dst1_rgba, dst_rgba_n_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_n_org, w*h*4); - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8() - { - memcpy(dst1_rgba, dst_rgba_p_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_p_org, w*h*4); - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8() - { - memcpy(dst1_rgba, dst_rgba_p_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_p_org, w*h*4); - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8() - { - memcpy(dst1_rgba, dst_rgba_n_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_n_org, w*h*4); - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8() - { - memcpy(dst1_rgba, dst_rgba_n_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_n_org, w*h*4); - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8() - { - memcpy(dst1_rgba, dst_rgba_p_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_p_org, w*h*4); - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8(dst1_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8_ref(dst2_rgba, w, h, w*4, src_rgba_n, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - void testnr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8() - { - memcpy(dst1_rgba, dst_rgba_p_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_p_org, w*h*4); - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8(dst1_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8_ref(dst2_rgba, w, h, w*4, src_rgba_p, w*4, mask, w); - TS_ASSERT( IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - - // FINAL DST MASK COLOR - - void testnr_R8G8B8A8_N_EMPTY_A8_RGBA32() - { - for(size_t j=0; j>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff); - memcpy(dst1_rgba, dst_rgba_n_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_n_org, w*h*4); - nr_R8G8B8A8_N_EMPTY_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba); - nr_R8G8B8A8_N_EMPTY_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba); - TSM_ASSERT(msg, IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - } - - void testnr_R8G8B8A8_P_EMPTY_A8_RGBA32() - { - for(size_t j=0; j>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff); - memcpy(dst1_rgba, dst_rgba_p_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_p_org, w*h*4); - nr_R8G8B8A8_P_EMPTY_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba); - nr_R8G8B8A8_P_EMPTY_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba); - TSM_ASSERT(msg, IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - } - - void testnr_R8G8B8_R8G8B8_A8_RGBA32() - { - for(size_t j=0; j>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff); - memcpy(dst1_rgb, dst_rgb_org, w*h*3); - memcpy(dst2_rgb, dst_rgb_org, w*h*3); - nr_R8G8B8_R8G8B8_A8_RGBA32(dst1_rgb, w, h, w*3, mask, w, rgba); - nr_R8G8B8_R8G8B8_A8_RGBA32_ref(dst2_rgb, w, h, w*3, mask, w, rgba); - TSM_ASSERT(msg, IMGCMP(dst1_rgb, dst2_rgb, w*h*3) == 0 ); - } - } - } - - void testnr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32() - { - for(size_t j=0; j>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff); - memcpy(dst1_rgba, dst_rgba_n_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_n_org, w*h*4); - nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba); - nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba); - TSM_ASSERT(msg, IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - } - - void testnr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32() - { - for(size_t j=0; j>24u)&0xff, (rgba>>16u)&0xff, (rgba>>8u)&0xff, rgba&0xff); - memcpy(dst1_rgba, dst_rgba_p_org, w*h*4); - memcpy(dst2_rgba, dst_rgba_p_org, w*h*4); - nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32(dst1_rgba, w, h, w*4, mask, w, rgba); - nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32_ref(dst2_rgba, w, h, w*4, mask, w, rgba); - TSM_ASSERT(msg, IMGCMP(dst1_rgba, dst2_rgba, w*h*4) == 0 ); - } - } - } - - // RGB - - void testnr_R8G8B8_R8G8B8_R8G8B8A8_N() - { - for(size_t i=0; i(dst1_rgb, dst2_rgb, w*h*3) == 0 ); - } - } - - void testnr_R8G8B8_R8G8B8_R8G8B8A8_P() - { - for(size_t i=0; i(dst1_rgb, dst2_rgb, w*h*3) == 0 ); - } - } - - void testnr_R8G8B8_R8G8B8_R8G8B8A8_N_A8() - { - for(size_t i=0; i(dst1_rgb, dst2_rgb, w*h*3) == 0 ); - } - } - - void testnr_R8G8B8_R8G8B8_R8G8B8A8_P_A8() - { - for(size_t i=0; i(dst1_rgb, dst2_rgb, w*h*3) == 0 ); - } - } -}; - -unsigned int const NrComposeTest::alpha_vals[7] = {0, 1, 127, 128, 129, 254, 255}; -unsigned int const NrComposeTest::rgb_vals[3] = { - ( 0u<<24u)+( 1u<<16u)+( 92u<<8u), - (127u<<24u)+(128u<<16u)+(129u<<8u), - (163u<<24u)+(254u<<16u)+(255u<<8u)}; - -/* -Local Variables: -mode:c++ -c-file-style:"stroustrup" -c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) -indent-tabs-mode:nil -fill-column:99 -End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-compose.cpp b/src/libnr/nr-compose.cpp deleted file mode 100644 index 74f9d036b..000000000 --- a/src/libnr/nr-compose.cpp +++ /dev/null @@ -1,1197 +0,0 @@ -#define __NR_COMPOSE_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include "nr-pixops.h" - -#ifdef WITH_MMX -/* fixme: */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ -int nr_have_mmx (void); -void nr_mmx_R8G8B8A8_P_EMPTY_A8_RGBAP (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned char *c); -void nr_mmx_R8G8B8A8_P_R8G8B8A8_P_A8_RGBAP (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned char *c); -void nr_mmx_R8G8B8_R8G8B8_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -#define NR_PIXOPS_MMX nr_have_mmx () -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif - -// Naming: nr_RESULT_BACKGROUND_FOREGROUND_extra - -void -nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - if (alpha == 0) { - memset(px, 0x0, 4 * w); - } else if (alpha == 255) { - memcpy(px, spx, 4 * w); - } else { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - *d++ = NR_PREMUL_111(*s, alpha); - s++; - } - } - px += rs; - spx += srs; - } -} - -void -nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - if (alpha == 0) { - memset(px, 0x0, 4 * w); - } else { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - if (s[3] == 0) { - d[3] = 0; - } else if (s[3] == 255) { - memcpy(d, s, 4); - } else { - d[0] = NR_DEMUL_111(s[0], s[3]); - d[1] = NR_DEMUL_111(s[1], s[3]); - d[2] = NR_DEMUL_111(s[2], s[3]); - d[3] = NR_PREMUL_111(s[3], alpha); - } - d += 4; - s += 4; - } - } - px += rs; - spx += srs; - } -} - -void -nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - if (alpha == 0) { - memset(px, 0x0, 4 * w); - } else if (alpha == 255) { - for (c = w; c > 0; c--) { - d[0] = NR_PREMUL_111(s[0], s[3]); - d[1] = NR_PREMUL_111(s[1], s[3]); - d[2] = NR_PREMUL_111(s[2], s[3]); - d[3] = s[3]; - d += 4; - s += 4; - } - } else { - for (c = w; c > 0; c--) { - if (s[3] == 0) { - memset(d, 0, 4); - } else { - unsigned int a; - a = NR_PREMUL_112(s[3], alpha); - d[0] = NR_PREMUL_121(s[0], a); - d[1] = NR_PREMUL_121(s[1], a); - d[2] = NR_PREMUL_121(s[2], a); - d[3] = NR_NORMALIZE_21(a); - } - d += 4; - s += 4; - } - } - px += rs; - spx += srs; - } -} - -void -nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - if (alpha == 0) { - memset(px, 0x0, 4 * w); - } else if (alpha == 255) { - memcpy(px, spx, 4 * w); - } else { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - d[0] = NR_PREMUL_111(s[0], alpha); - d[1] = NR_PREMUL_111(s[1], alpha); - d[2] = NR_PREMUL_111(s[2], alpha); - d[3] = NR_PREMUL_111(s[3], alpha); - d += 4; - s += 4; - } - } - px += rs; - spx += srs; - } -} - -void -nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - if (alpha == 0) { - /* NOP */ - } else if (alpha == 255) { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - if (s[3] == 0) { - /* Transparent FG, NOP */ - } else if ((s[3] == 255) || (d[3] == 0)) { - /* Full coverage, COPY */ - memcpy(d, s, 4); - } else { - /* Full composition */ - unsigned int ca; - ca = NR_COMPOSEA_112(s[3], d[3]); - d[0] = NR_COMPOSENNN_111121(s[0], s[3], d[0], d[3], ca); - d[1] = NR_COMPOSENNN_111121(s[1], s[3], d[1], d[3], ca); - d[2] = NR_COMPOSENNN_111121(s[2], s[3], d[2], d[3], ca); - d[3] = NR_NORMALIZE_21(ca); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } else { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], alpha); - if (a == 0) { - /* Transparent FG, NOP */ - } else if ((a == 255*255) || (d[3] == 0)) { - /* Full coverage, COPY */ - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = NR_NORMALIZE_21(a); - } else { - /* Full composition */ - unsigned int ca; - ca = NR_COMPOSEA_213(a, d[3]); - d[0] = NR_COMPOSENNN_121131(s[0], a, d[0], d[3], ca); - d[1] = NR_COMPOSENNN_121131(s[1], a, d[1], d[3], ca); - d[2] = NR_COMPOSENNN_121131(s[2], a, d[2], d[3], ca); - d[3] = NR_NORMALIZE_31(ca); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } -} - -void -nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - if (alpha == 0) { - /* NOP */ - } else if (alpha == 255) { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - if (s[3] == 0) { - /* Transparent FG, NOP */ - } else if (s[3] == 255) { - /* Full coverage, demul src */ - // dc' = ((1 - sa) * da*dc + sc)/da' = sc/da' = sc - // da' = 1 - (1 - sa) * (1 - da) = 1 - 0 * (1 - da) = 1 - memcpy(d, s, 4); - } else if (d[3] == 0) { - /* Full coverage, demul src */ - // dc' = ((1 - sa) * da*dc + sc)/da' = sc/da' = sc/sa = sc/sa - // da' = 1 - (1 - sa) * (1 - da) = 1 - (1 - sa) = sa - d[0] = NR_DEMUL_111(s[0], s[3]); - d[1] = NR_DEMUL_111(s[1], s[3]); - d[2] = NR_DEMUL_111(s[2], s[3]); - d[3] = s[3]; - } else { - /* Full composition */ - // dc' = ((1 - sa) * da*dc + sc)/da' = ((1 - sa) * da*dc + sc)/da' - // da' = 1 - (1 - sa) * (1 - da) = 1 - (1 - sa) * (1 - da) - unsigned int da = NR_COMPOSEA_112(s[3], d[3]); - d[0] = NR_COMPOSEPNN_111121(s[0], s[3], d[0], d[3], da); - d[1] = NR_COMPOSEPNN_111121(s[1], s[3], d[1], d[3], da); - d[2] = NR_COMPOSEPNN_111121(s[2], s[3], d[2], d[3], da); - d[3] = NR_NORMALIZE_21(da); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } else { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], alpha); - if (a == 0) { - /* Transparent FG, NOP */ - } else if (d[3] == 0) { - /* Full coverage, demul src */ - // dc' = ((1 - alpha*sa) * da*dc + alpha*sc)/da' = alpha*sc/da' = alpha*sc/(alpha*sa) = sc/sa - // da' = 1 - (1 - alpha*sa) * (1 - da) = 1 - (1 - alpha*sa) = alpha*sa - d[0] = NR_DEMUL_111(s[0], s[3]); - d[1] = NR_DEMUL_111(s[1], s[3]); - d[2] = NR_DEMUL_111(s[2], s[3]); - d[3] = NR_NORMALIZE_21(a); - } else { - // dc' = ((1 - alpha*sa) * da*dc + alpha*sc)/da' - // da' = 1 - (1 - alpha*sa) * (1 - da) - unsigned int da = NR_COMPOSEA_213(a, d[3]); - d[0] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[0], alpha), a, d[0], d[3], da); - d[1] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[1], alpha), a, d[1], d[3], da); - d[2] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[2], alpha), a, d[2], d[3], da); - d[3] = NR_NORMALIZE_31(da); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } -} - -void -nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - if (alpha == 0) { - /* NOP */ - } else if (alpha == 255) { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - if (s[3] == 0) { - /* Transparent FG, NOP */ - } else if (s[3] == 255) { - /* Opaque FG, COPY */ - // dc' = (1 - sa) * dc + sa*sc = sa*sc = sc - // da' = 1 - (1 - sa) * (1 - da) = 1 - 0 * (1 - da) = 1 (= sa) - memcpy(d, s, 4); - } else if (d[3] == 0) { - /* Transparent BG, premul src */ - // dc' = (1 - sa) * dc + sa*sc = sa*sc - // da' = 1 - (1 - sa) * (1 - da) = 1 - (1 - sa) = sa - d[0] = NR_PREMUL_111(s[0], s[3]); - d[1] = NR_PREMUL_111(s[1], s[3]); - d[2] = NR_PREMUL_111(s[2], s[3]); - d[3] = s[3]; - } else { - // dc' = (1 - sa) * dc + sa*sc - // da' = 1 - (1 - sa) * (1 - da) - d[0] = NR_COMPOSENPP_1111(s[0], s[3], d[0]); - d[1] = NR_COMPOSENPP_1111(s[1], s[3], d[1]); - d[2] = NR_COMPOSENPP_1111(s[2], s[3], d[2]); - d[3] = NR_COMPOSEA_111(s[3], d[3]); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } else { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112 (s[3], alpha); - if (a == 0) { - /* Transparent FG, NOP */ - } else if (d[3] == 0) { - /* Transparent BG, premul src */ - // dc' = (1 - alpha*sa) * dc + alpha*sa*sc = alpha*sa*sc - // da' = 1 - (1 - alpha*sa) * (1 - da) = 1 - (1 - alpha*sa) = alpha*sa - d[0] = NR_PREMUL_121(s[0], a); - d[1] = NR_PREMUL_121(s[1], a); - d[2] = NR_PREMUL_121(s[2], a); - d[3] = NR_NORMALIZE_21(a); - } else { - // dc' = (1 - alpha*sa) * dc + alpha*sa*sc - // da' = 1 - (1 - alpha*sa) * (1 - da) - d[0] = NR_COMPOSENPP_1211(s[0], a, d[0]); - d[1] = NR_COMPOSENPP_1211(s[1], a, d[1]); - d[2] = NR_COMPOSENPP_1211(s[2], a, d[2]); - d[3] = NR_COMPOSEA_211(a, d[3]); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } -} - -void -nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - if (alpha == 0) { - /* Transparent FG, NOP */ - } else if (alpha == 255) { - /* Simple */ - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - if (s[3] == 0) { - /* Transparent FG, NOP */ - } else if ((s[3] == 255) || (d[3] == 0)) { - /* Transparent BG, COPY */ - memcpy(d, s, 4); - } else { - d[0] = NR_COMPOSEPPP_1111(s[0], s[3], d[0]); - d[1] = NR_COMPOSEPPP_1111(s[1], s[3], d[1]); - d[2] = NR_COMPOSEPPP_1111(s[2], s[3], d[2]); - d[3] = NR_COMPOSEA_111(s[3], d[3]); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } else { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - if (s[3] == 0) { - /* Transparent FG, NOP */ - } else if (d[3] == 0) { - /* Transparent BG, COPY */ - d[0] = NR_PREMUL_111(s[0], alpha); - d[1] = NR_PREMUL_111(s[1], alpha); - d[2] = NR_PREMUL_111(s[2], alpha); - d[3] = NR_PREMUL_111(s[3], alpha); - } else { - // dc' = (1 - alpha*sa) * dc + alpha*sc - // da' = 1 - (1 - alpha*sa) * (1 - da) - unsigned int a; - a = NR_PREMUL_112(s[3], alpha); - d[0] = NR_COMPOSEPPP_2211(NR_PREMUL_112(alpha, s[0]), a, d[0]); - d[1] = NR_COMPOSEPPP_2211(NR_PREMUL_112(alpha, s[1]), a, d[1]); - d[2] = NR_COMPOSEPPP_2211(NR_PREMUL_112(alpha, s[2]), a, d[2]); - d[3] = NR_COMPOSEA_211(a, d[3]); - } - d += 4; - s += 4; - } - px += rs; - spx += srs; - } - } -} - -/* Masked operations */ - -void -nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = NR_PREMUL_111(s[3], m[0]); - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112 (s[3], m[0]); - if (a == 0) { - d[3] = 0; - } else if (a == 255*255) { - memcpy(d, s, 4); - } else { - // dc' = ((1 - m*sa) * da*dc + m*sc)/da' = m*sc/da' = m*sc/(m*sa) = sc/sa - // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - m*sa) = m*sa - d[0] = NR_DEMUL_111(s[0], s[3]); - d[1] = NR_DEMUL_111(s[1], s[3]); - d[2] = NR_DEMUL_111(s[2], s[3]); - d[3] = NR_NORMALIZE_21(a); - } - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], m[0]); - if (a == 0) { - memset(d, 0, 4); - } else if (a == 255*255) { - memcpy(d, s, 4); - } else { - d[0] = NR_PREMUL_121(s[0], a); - d[1] = NR_PREMUL_121(s[1], a); - d[2] = NR_PREMUL_121(s[2], a); - d[3] = NR_NORMALIZE_21(a); - } - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - d[0] = NR_PREMUL_111(s[0], m[0]); - d[1] = NR_PREMUL_111(s[1], m[0]); - d[2] = NR_PREMUL_111(s[2], m[0]); - d[3] = NR_PREMUL_111(s[3], m[0]); - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], m[0]); - if (a == 0) { - /* Transparent FG, NOP */ - } else if ((a == 255*255) || (d[3] == 0)) { - /* Full coverage, COPY */ - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - d[3] = NR_NORMALIZE_21(a); - } else { - /* Full composition */ - unsigned int ca; - ca = NR_COMPOSEA_213(a, d[3]); - d[0] = NR_COMPOSENNN_121131(s[0], a, d[0], d[3], ca); - d[1] = NR_COMPOSENNN_121131(s[1], a, d[1], d[3], ca); - d[2] = NR_COMPOSENNN_121131(s[2], a, d[2], d[3], ca); - d[3] = NR_NORMALIZE_31(ca); - } - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], m[0]); - if (a == 0) { - /* Transparent FG, NOP */ - } else if (a == 255*255) { - /* Opaque FG, COPY */ - memcpy(d, s, 4); - } else if (d[3] == 0) { - /* Full coverage, demul src */ - // dc' = ((1 - m*sa) * da*dc + m*sc)/da' = m*sc/da' = m*sc/(m*sa) = sc/sa - // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - m*sa) = m*sa - d[0] = NR_DEMUL_111(s[0], s[3]); - d[1] = NR_DEMUL_111(s[1], s[3]); - d[2] = NR_DEMUL_111(s[2], s[3]); - d[3] = NR_NORMALIZE_21(a); - } else if (m[0] == 255) { - /* Full composition */ - // dc' = ((1 - m*sa) * da*dc + m*sc)/da' = ((1 - sa) * da*dc + sc)/da' - // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - sa) * (1 - da) - unsigned int da = NR_COMPOSEA_112(s[3], d[3]); - d[0] = NR_COMPOSEPNN_111121(s[0], s[3], d[0], d[3], da); - d[1] = NR_COMPOSEPNN_111121(s[1], s[3], d[1], d[3], da); - d[2] = NR_COMPOSEPNN_111121(s[2], s[3], d[2], d[3], da); - d[3] = NR_NORMALIZE_21(da); - } else { - // dc' = ((1 - m*sa) * da*dc + m*sc)/da' - // da' = 1 - (1 - m*sa) * (1 - da) - unsigned int da = NR_COMPOSEA_213(a, d[3]); - d[0] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[0], m[0]), a, d[0], d[3], da); - d[1] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[1], m[0]), a, d[1], d[3], da); - d[2] = NR_COMPOSEPNN_221131(NR_PREMUL_112(s[2], m[0]), a, d[2], d[3], da); - d[3] = NR_NORMALIZE_31(da); - } - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r>0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c>0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], m[0]); - if (a == 0) { - /* Transparent FG, NOP */ - } else if (a == 255*255) { - memcpy(d, s, 4); - } else { - d[0] = NR_COMPOSENPP_1211(s[0], a, d[0]); - d[1] = NR_COMPOSENPP_1211(s[1], a, d[1]); - d[2] = NR_COMPOSENPP_1211(s[2], a, d[2]); - d[3] = NR_COMPOSEA_211(a, d[3]); - } - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int r, c; - - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - const unsigned char *m = mpx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112 (s[3], m[0]); - if (a == 0) { - /* Transparent FG, NOP */ - } else if (a == 255*255) { - /* Opaque FG, COPY */ - memcpy(d, s, 4); - } else if (d[3] == 0) { - /* Transparent BG, COPY */ - // dc' = (1 - m*sa) * dc + m*sc = m*sc - // da' = 1 - (1 - m*sa) * (1 - da) = 1 - (1 - m*sa) = m*sa - d[0] = NR_PREMUL_111 (s[0], m[0]); - d[1] = NR_PREMUL_111 (s[1], m[0]); - d[2] = NR_PREMUL_111 (s[2], m[0]); - d[3] = NR_NORMALIZE_21(a); - } else { - // dc' = (1 - m*sa) * dc + m*sc - // da' = 1 - (1 - m*sa) * (1 - da) - d[0] = NR_COMPOSEPPP_2211 (NR_PREMUL_112 (s[0], m[0]), a, d[0]); - d[1] = NR_COMPOSEPPP_2211 (NR_PREMUL_112 (s[1], m[0]), a, d[1]); - d[2] = NR_COMPOSEPPP_2211 (NR_PREMUL_112 (s[2], m[0]), a, d[2]); - d[3] = NR_COMPOSEA_211(a, d[3]); - } - d += 4; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -/* FINAL DST MASK COLOR */ - -void -nr_R8G8B8A8_N_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) -{ - unsigned int r, g, b, a; - unsigned int x, y; - - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - - for (y = h; y > 0; y--) { - if (a == 0) { - memset(px, 0, w*4); - } else { - unsigned char *d = px; - const unsigned char *m = mpx; - for (x = w; x > 0; x--) { - d[0] = r; - d[1] = g; - d[2] = b; - d[3] = NR_PREMUL_111 (m[0], a); - d += 4; - m += 1; - } - } - px += rs; - mpx += mrs; - } -} - -void -nr_R8G8B8A8_P_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) -{ - unsigned int r, g, b, a; - unsigned int x, y; - - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - -#ifdef WITH_MMX - if (NR_PIXOPS_MMX) { - unsigned char c[4]; - c[0] = NR_PREMUL_111 (r, a); - c[1] = NR_PREMUL_111 (g, a); - c[2] = NR_PREMUL_111 (b, a); - c[3] = a; - /* WARNING: MMX composer REQUIRES w > 0 and h > 0 */ - nr_mmx_R8G8B8A8_P_EMPTY_A8_RGBAP (px, w, h, rs, mpx, mrs, c); - // This mmx optimized code is approx. 2x faster than the non-optimized code below (Measured by Diederik van Lierop, 2009-12-17) - return; - } -#endif - - if ( a != 255 ){ - // Pre-premultiply color values - r *= a; - g *= a; - b *= a; - } - - for (y = h; y > 0; y--) { - unsigned char *d = px; - const unsigned char *m = mpx; - if (a == 0) { - memset(px, 0, w*4); - } else if (a == 255) { - for (x = w; x > 0; x--) { - d[0] = NR_PREMUL_111(m[0], r); - d[1] = NR_PREMUL_111(m[0], g); - d[2] = NR_PREMUL_111(m[0], b); - d[3] = m[0]; - d += 4; - m += 1; - } - } else { - for (x = w; x > 0; x--) { - // Color values are already premultiplied with a - d[0] = NR_PREMUL_121(m[0], r); - d[1] = NR_PREMUL_121(m[0], g); - d[2] = NR_PREMUL_121(m[0], b); - d[3] = NR_PREMUL_111(m[0], a); - d += 4; - m += 1; - } - } - px += rs; - mpx += mrs; - } -} - -void -nr_R8G8B8_R8G8B8_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) -{ - unsigned int r, g, b, a; - unsigned int x, y; - - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - - if (a == 0) { - /* NOP */ - } else if (a == 255) { - for (y = h; y > 0; y--) { - unsigned char *d = px; - const unsigned char *m = mpx; - for (x = w; x > 0; x--) { - d[0] = NR_COMPOSEN11_1111 (r, m[0], d[0]); - d[1] = NR_COMPOSEN11_1111 (g, m[0], d[1]); - d[2] = NR_COMPOSEN11_1111 (b, m[0], d[2]); - d += 3; - m += 1; - } - px += rs; - mpx += mrs; - } - } else { - for (y = h; y > 0; y--) { - unsigned char *d = px; - const unsigned char *m = mpx; - for (x = w; x > 0; x--) { - // dc' = (1 - m*sa) * dc + m*sa*sc - unsigned int alpha; - alpha = NR_PREMUL_112 (a, m[0]); - d[0] = NR_COMPOSEN11_1211 (r, alpha, d[0]); - d[1] = NR_COMPOSEN11_1211 (g, alpha, d[1]); - d[2] = NR_COMPOSEN11_1211 (b, alpha, d[2]); - d += 3; - m += 1; - } - px += rs; - mpx += mrs; - } - } -} - -void -nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba) -{ - unsigned int r, g, b, a; - unsigned int x, y; - - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - - if (a == 0) { - /* NOP */ - } else if (a == 255) { - for (y = h; y > 0; y--) { - unsigned char *d = px; - const unsigned char *m = mpx; - for (x = w; x > 0; x--) { - if (m[0] == 0) { - /* Transparent FG, NOP */ - } else if (m[0] == 255 || d[3] == 0) { - /* Full coverage, COPY */ - d[0] = r; - d[1] = g; - d[2] = b; - d[3] = m[0]; - } else { - /* Full composition */ - unsigned int da = NR_COMPOSEA_112(m[0], d[3]); - d[0] = NR_COMPOSENNN_111121(r, m[0], d[0], d[3], da); - d[1] = NR_COMPOSENNN_111121(g, m[0], d[1], d[3], da); - d[2] = NR_COMPOSENNN_111121(b, m[0], d[2], d[3], da); - d[3] = NR_NORMALIZE_21(da); - } - d += 4; - m += 1; - } - px += rs; - mpx += mrs; - } - } else { - for (y = h; y > 0; y--) { - unsigned char *d = px; - const unsigned char *m = mpx; - for (x = w; x > 0; x--) { - unsigned int ca; - ca = NR_PREMUL_112 (m[0], a); - if (ca == 0) { - /* Transparent FG, NOP */ - } else if (d[3] == 0) { - /* Full coverage, COPY */ - d[0] = r; - d[1] = g; - d[2] = b; - d[3] = NR_NORMALIZE_21(ca); - } else { - /* Full composition */ - unsigned int da = NR_COMPOSEA_213(ca, d[3]); - d[0] = NR_COMPOSENNN_121131(r, ca, d[0], d[3], da); - d[1] = NR_COMPOSENNN_121131(g, ca, d[1], d[3], da); - d[2] = NR_COMPOSENNN_121131(b, ca, d[2], d[3], da); - d[3] = NR_NORMALIZE_31(da); - } - d += 4; - m += 1; - } - px += rs; - mpx += mrs; - } - } -} - -void -nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned long rgba) -{ - unsigned int r, g, b, a; - unsigned int x, y; - - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - -#ifdef WITH_MMX - if (NR_PIXOPS_MMX && a != 0) { - unsigned char c[4]; - c[0] = NR_PREMUL_111 (r, a); - c[1] = NR_PREMUL_111 (g, a); - c[2] = NR_PREMUL_111 (b, a); - c[3] = a; - /* WARNING: MMX composer REQUIRES w > 0 and h > 0 */ - nr_mmx_R8G8B8A8_P_R8G8B8A8_P_A8_RGBAP (px, w, h, rs, spx, srs, c); - return; - } -#endif - - if (a == 0) { - /* Transparent FG, NOP */ - } else if (a == 255) { - /* Simple */ - for (y = h; y > 0; y--) { - unsigned char *d, *s; - d = (unsigned char *) px; - s = (unsigned char *) spx; - for (x = w; x > 0; x--) { - if (s[0] == 0) { - /* Transparent FG, NOP */ - } else { - /* Full composition */ - unsigned int invca = 255-s[0]; // By swapping the arguments GCC can better optimize these calls - d[0] = NR_COMPOSENPP_1111(d[0], invca, r); - d[1] = NR_COMPOSENPP_1111(d[1], invca, g); - d[2] = NR_COMPOSENPP_1111(d[2], invca, b); - d[3] = NR_COMPOSEA_111(s[0], d[3]); - } - d += 4; - s += 1; - } - px += rs; - spx += srs; - } - } else { - for (y = h; y > 0; y--) { - unsigned char *d, *s; - d = (unsigned char *) px; - s = (unsigned char *) spx; - for (x = w; x > 0; x--) { - unsigned int ca; - ca = NR_PREMUL_112 (s[0], a); - if (ca == 0) { - /* Transparent FG, NOP */ - } else { - /* Full composition */ - unsigned int invca = 255*255-ca; // By swapping the arguments GCC can better optimize these calls - d[0] = NR_COMPOSENPP_1211(d[0], invca, r); - d[1] = NR_COMPOSENPP_1211(d[1], invca, g); - d[2] = NR_COMPOSENPP_1211(d[2], invca, b); - d[3] = NR_COMPOSEA_211(ca, d[3]); - } - d += 4; - s += 1; - } - px += rs; - spx += srs; - } - } -} - -/* RGB */ - -void -nr_R8G8B8_R8G8B8_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - -#ifdef WITH_MMX - if (NR_PIXOPS_MMX && alpha != 0) { - /* WARNING: MMX composer REQUIRES w > 0 and h > 0 */ - nr_mmx_R8G8B8_R8G8B8_R8G8B8A8_P (px, w, h, rs, spx, srs, alpha); - return; - } -#endif - - if (alpha == 0) { - /* NOP */ - } else if (alpha == 255) { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - // dc' = (1 - alpha*sa) * dc + alpha*sc = (1 - sa) * dc + sc - if (s[3] == 0) { - /* NOP */ - } else if (s[3] == 255) { - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - } else { - d[0] = NR_COMPOSEP11_1111(s[0], s[3], d[0]); - d[1] = NR_COMPOSEP11_1111(s[1], s[3], d[1]); - d[2] = NR_COMPOSEP11_1111(s[2], s[3], d[2]); - } - d += 3; - s += 4; - } - px += rs; - spx += srs; - } - } else { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], alpha); - // dc' = (1 - alpha*sa) * dc + alpha*sc - if (a == 0) { - /* NOP */ - } else { - d[0] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[0], alpha), a, d[0]); - d[1] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[1], alpha), a, d[1]); - d[2] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[2], alpha), a, d[2]); - } - /* a == 255 is impossible, because alpha < 255 */ - d += 3; - s += 4; - } - px += rs; - spx += srs; - } - } -} - -void -nr_R8G8B8_R8G8B8_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha) -{ - unsigned int r, c; - - if (alpha == 0) { - /* NOP */ - } else if (alpha == 255) { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - // dc' = (1 - alpha*sa) * dc + alpha*sa*sc = (1 - sa) * dc + sa*sc - if (s[3] == 0) { - /* NOP */ - } else if (s[3] == 255) { - d[0] = s[0]; - d[1] = s[1]; - d[2] = s[2]; - } else { - d[0] = NR_COMPOSEN11_1111(s[0], s[3], d[0]); - d[1] = NR_COMPOSEN11_1111(s[1], s[3], d[1]); - d[2] = NR_COMPOSEN11_1111(s[2], s[3], d[2]); - } - d += 3; - s += 4; - } - px += rs; - spx += srs; - } - } else { - for (r = h; r > 0; r--) { - unsigned char *d = px; - const unsigned char *s = spx; - for (c = w; c > 0; c--) { - unsigned int a; - a = NR_PREMUL_112(s[3], alpha); - // dc' = (1 - alpha*sa) * dc + alpha*sa*sc - if (a == 0) { - /* NOP */ - } else { - d[0] = NR_COMPOSEN11_1211(s[0], a, d[0]); - d[1] = NR_COMPOSEN11_1211(s[1], a, d[1]); - d[2] = NR_COMPOSEN11_1211(s[2], a, d[2]); - } - /* a == 255 is impossible, because alpha < 255 */ - d += 3; - s += 4; - } - px += rs; - spx += srs; - } - } -} - -void -nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int x, y; - - for (y = h; y > 0; y--) { - unsigned char* d = px; - const unsigned char* s = spx; - const unsigned char* m = mpx; - for (x = w; x > 0; x--) { - unsigned int a; - a = NR_PREMUL_112(s[3], m[0]); - if (a == 0) { - /* NOP */ - } else if (a == 255*255) { - memcpy(d, s, 3); - } else { - // dc' = (1 - m*sa) * dc + m*sc - d[0] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[0], m[0]), a, d[0]); - d[1] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[1], m[0]), a, d[1]); - d[2] = NR_COMPOSEP11_2211(NR_PREMUL_112(s[2], m[0]), a, d[2]); - } - d += 3; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - -void -nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs) -{ - unsigned int x, y; - - for (y = h; y > 0; y--) { - unsigned char* d = px; - const unsigned char* s = spx; - const unsigned char* m = mpx; - for (x = w; x > 0; x--) { - unsigned int a; - a = NR_PREMUL_112(s[3], m[0]); - if (a == 0) { - /* NOP */ - } else if (a == 255*255) { - memcpy(d, s, 3); - } else { - // dc' = (1 - m*sa) * dc + m*sa*sc - d[0] = NR_COMPOSEN11_1211(s[0], a, d[0]); - d[1] = NR_COMPOSEN11_1211(s[1], a, d[1]); - d[2] = NR_COMPOSEN11_1211(s[2], a, d[2]); - } - d += 3; - s += 4; - m += 1; - } - px += rs; - spx += srs; - mpx += mrs; - } -} - - diff --git a/src/libnr/nr-compose.h b/src/libnr/nr-compose.h deleted file mode 100644 index 4cecfac60..000000000 --- a/src/libnr/nr-compose.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __NR_COMPOSE_H__ -#define __NR_COMPOSE_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -/* FINAL DST SRC */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); - -/* FINAL DST SRC MASK */ - -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); -void nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); -void nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, - const unsigned char *spx, int srs, - const unsigned char *mpx, int mrs); - -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); -void nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); -void nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 (unsigned char *p, int w, int h, int rs, - const unsigned char *s, int srs, - const unsigned char *m, int mrs); - -/* FINAL DST MASK COLOR */ - -void nr_R8G8B8A8_N_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); -void nr_R8G8B8A8_P_EMPTY_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); - -void nr_R8G8B8_R8G8B8_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); -void nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); -void nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 (unsigned char *px, int w, int h, int rs, const unsigned char *mpx, int mrs, unsigned long rgba); - -/* RGB */ - -void nr_R8G8B8_R8G8B8_R8G8B8A8_P (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8_R8G8B8_R8G8B8A8_N (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, unsigned int alpha); -void nr_R8G8B8_R8G8B8_R8G8B8A8_P_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs); -void nr_R8G8B8_R8G8B8_R8G8B8A8_N_A8 (unsigned char *px, int w, int h, int rs, const unsigned char *spx, int srs, const unsigned char *mpx, int mrs); - -#endif diff --git a/src/libnr/testnr.cpp b/src/libnr/testnr.cpp deleted file mode 100644 index 12dce4c52..000000000 --- a/src/libnr/testnr.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#define __TESTNR_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#if defined (_WIN32) || defined (__WIN32__) -# include -#include -#endif - - -#include "nr-blit.h" - -static double -get_time (void) -{ - GTimeVal tv; - g_get_current_time (&tv); - return tv.tv_sec + 1e-6 * tv.tv_usec; -} - -static unsigned int -rand_byte (void) -{ - return (int) (256.0 * rand () / (RAND_MAX + 1.0)); -} - -int -main (int argc, const char **argv) -{ - double start, end; - NRPixBlock d, m[16]; - int count, i; - - srand (time (NULL)); - - printf ("Initializing buffers\n"); - - /* Destination */ - nr_pixblock_setup_fast (&d, NR_PIXBLOCK_MODE_R8G8B8A8P, 0, 0, 64, 64, 1); - d.empty = 0; - - /* Masks */ - for (i = 0; i < 16; i++) { - int r, b, c; - nr_pixblock_setup_fast (&m[i], NR_PIXBLOCK_MODE_A8, 0, 0, 64, 64, 0); - for (r = 0; r < 64; r++) { - unsigned int q; - unsigned char *p; - p = NR_PIXBLOCK_PX (&m[i]) + r * m[i].rs; - for (b = 0; b < 8; b++) { - q = rand_byte (); - if (q < 120) { - for (c = 0; c < 8; c++) *p++ = 0; - } else if (q < 240) { - for (c = 0; c < 8; c++) *p++ = 255; - } else { - for (c = 0; c < 8; c++) *p++ = rand_byte (); - } - } - } - m[i].empty = 0; - } - - printf ("Random transparency\n"); - count = 0; - start = end = get_time (); - while ((end - start) < 5.0) { - unsigned char r, g, b, a; - r = rand_byte (); - g = rand_byte (); - b = rand_byte (); - a = rand_byte (); - - for (i = 0; i < 16; i++) { - nr_blit_pixblock_mask_rgba32 (&d, &m[i], (a << 24) | (g << 16) | (b << 8) | a); - count += 1; - } - end = get_time (); - } - printf ("Did %d [64x64] random buffers in %f sec\n", count, end - start); // localizing ok - printf ("%f buffers per second\n", count / (end - start)); // localizing ok - printf ("%f pixels per second\n", count * (64 * 64) / (end - start)); // localizing ok - - return 0; -} diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index bdf700346..a41f7d370 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -24,7 +24,6 @@ #include "libnr/nr-rect.h" #include "libnrtype/font-glyph.h" #include "libnrtype/font-instance.h" -#include "libnrtype/RasterFont.h" #include "livarot/Path.h" #include "util/unordered-containers.h" @@ -44,8 +43,6 @@ struct font_style_equal : public std::binary_function StyleMap; - static const double STROKE_WIDTH_THREASHOLD = 0.01; @@ -182,7 +179,6 @@ font_instance::font_instance(void) : nbGlyph(0), maxGlyph(0), glyphs(0), - loadedPtr(new StyleMap()), theFace(0) { //printf("font instance born\n"); @@ -190,12 +186,6 @@ font_instance::font_instance(void) : font_instance::~font_instance(void) { - if ( loadedPtr ) { - StyleMap* tmp = static_cast(loadedPtr); - delete tmp; - loadedPtr = 0; - } - if ( daddy ) { daddy->UnrefFace(this); daddy = 0; @@ -793,72 +783,6 @@ double font_instance::Advance(int glyph_id,bool vertical) return 0; } - -raster_font* font_instance::RasterFont(const Geom::Matrix &trs, double stroke_width, bool vertical, JoinType stroke_join, ButtType stroke_cap, float /*miter_limit*/) -{ - font_style nStyle; - nStyle.transform=trs; - nStyle.vertical=vertical; - nStyle.stroke_width=stroke_width; - nStyle.stroke_cap=stroke_cap; - nStyle.stroke_join=stroke_join; - nStyle.nbDash=0; - nStyle.dash_offset=0; - nStyle.dashes=NULL; - return RasterFont(nStyle); -} - -raster_font* font_instance::RasterFont(const font_style &inStyle) -{ - raster_font *res=NULL; - double *savDashes=NULL; - font_style nStyle=inStyle; - // for some evil reason font_style doesn't have a copy ctor, so the - // stuff that should be done there is done here instead (because the - // raster_font ctor copies nStyle). - if ( (nStyle.stroke_width > 0) && (nStyle.nbDash > 0) && nStyle.dashes ) { - savDashes=nStyle.dashes; - nStyle.dashes=(double*)malloc(nStyle.nbDash*sizeof(double)); - memcpy(nStyle.dashes,savDashes,nStyle.nbDash*sizeof(double)); - } - StyleMap& loadedStyles = *static_cast(loadedPtr); - if ( loadedStyles.find(nStyle) == loadedStyles.end() ) { - raster_font *nR = new raster_font(nStyle); - nR->Ref(); - nR->daddy=this; - loadedStyles[nStyle]=nR; - res=nR; - if ( res ) { - Ref(); - } - } else { - res=loadedStyles[nStyle]; - res->Ref(); - if ( nStyle.dashes ) { - free(nStyle.dashes); // since they're not taken by a new rasterfont - } - } - nStyle.dashes=savDashes; - return res; -} - -void font_instance::RemoveRasterFont(raster_font* who) -{ - if ( who ) { - StyleMap& loadedStyles = *static_cast(loadedPtr); - if ( loadedStyles.find(who->style) == loadedStyles.end() ) { - //g_print("RemoveRasterFont failed \n"); - // not found - } else { - loadedStyles.erase(loadedStyles.find(who->style)); - //g_print("RemoveRasterFont\n"); - Unref(); - } - } -} - - - /* Local Variables: mode:c++ diff --git a/src/libnrtype/Makefile_insert b/src/libnrtype/Makefile_insert index 8f45dc94d..7cd99e1a8 100644 --- a/src/libnrtype/Makefile_insert +++ b/src/libnrtype/Makefile_insert @@ -20,10 +20,6 @@ ink_common_sources += \ libnrtype/one-box.h \ libnrtype/one-glyph.h \ libnrtype/one-para.h \ - libnrtype/RasterFont.cpp \ - libnrtype/RasterFont.h \ - libnrtype/raster-glyph.h \ - libnrtype/raster-position.h \ libnrtype/text-boundary.h \ libnrtype/TextWrapper.cpp \ libnrtype/TextWrapper.h \ diff --git a/src/libnrtype/RasterFont.cpp b/src/libnrtype/RasterFont.cpp deleted file mode 100644 index 14f6c7afa..000000000 --- a/src/libnrtype/RasterFont.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/* - * RasterFont.cpp - * testICU - * - */ - -#ifdef HAVE_CONFIG_H -# include -#endif -#include "RasterFont.h" - -#include -#include -#include -#include -#include -#include -#include -#include - - -static void glyph_run_A8_OR (raster_info &dest,void */*data*/,int st,float vst,int en,float ven); - -void font_style::Apply(Path* src,Shape* dest) { - src->Convert(1); - if ( stroke_width > 0 ) { - if ( nbDash > 0 ) { - double dlen = 0.0; - const float scale = 1/*Geom::expansion(transform)*/; - for (int i = 0; i < nbDash; i++) dlen += dashes[i] * scale; - if (dlen >= 0.01) { - float sc_offset = dash_offset * scale; - float *tdashs=(float*)malloc((nbDash+1)*sizeof(float)); - while ( sc_offset >= dlen ) sc_offset-=dlen; - tdashs[0]=dashes[0] * scale; - for (int i=1;iDashPolyline(0.0,0.0,dlen,nbDash,tdashs,true,sc_offset); - free(tdashs); - } - } - src->Stroke(dest, false, 0.5*stroke_width, stroke_join, stroke_cap, 0.5*stroke_width*stroke_miter_limit); - } else { - src->Fill(dest,0); - } -} - -raster_font::raster_font(font_style const &fstyle) : - daddy(NULL), - refCount(0), - style(fstyle), - glyph_id_to_raster_glyph_no(), - nbBase(0), - maxBase(0), - bases(NULL) -{ - // printf("raster font born\n"); -} - -raster_font::~raster_font(void) -{ -// printf("raster font death\n"); - if ( daddy ) daddy->RemoveRasterFont(this); - daddy=NULL; - if ( style.dashes ) free(style.dashes); - style.dashes=NULL; - for (int i=0;iRemoveRasterFont(this); - daddy=NULL; - delete this; - } -} -void raster_font::Ref(void) -{ - refCount++; -// printf("raster %x ref'd %i\n",this,refCount); -} -raster_glyph* raster_font::GetGlyph(int glyph_id) -{ - raster_glyph *res=NULL; - if ( glyph_id_to_raster_glyph_no.find(glyph_id) == glyph_id_to_raster_glyph_no.end() ) { - LoadRasterGlyph(glyph_id); - if ( glyph_id_to_raster_glyph_no.find(glyph_id) == glyph_id_to_raster_glyph_no.end() ) { // recheck - } else { - res=bases[glyph_id_to_raster_glyph_no[glyph_id]]; - } - } else { - res=bases[glyph_id_to_raster_glyph_no[glyph_id]]; - } - return res; -} -Geom::Point raster_font::Advance(int glyph_id) -{ - if ( daddy == NULL ) return Geom::Point(0,0); - double a=daddy->Advance(glyph_id,style.vertical); - Geom::Point f_a=(style.vertical)?Geom::Point(0,a):Geom::Point(a,0); - return f_a*style.transform; -} -void raster_font::BBox(int glyph_id,NRRect *area) -{ - area->x0=area->y0=area->x1=area->y1=0; - if ( daddy == NULL ) return; - Geom::OptRect res=daddy->BBox(glyph_id); - if (res) { - Geom::Point bmi=res->min(),bma=res->max(); - Geom::Point tlp(bmi[0],bmi[1]),trp(bma[0],bmi[1]),blp(bmi[0],bma[1]),brp(bma[0],bma[1]); - tlp=tlp*style.transform; - trp=trp*style.transform; - blp=blp*style.transform; - brp=brp*style.transform; - *res=Geom::Rect(tlp,trp); - res->expandTo(blp); - res->expandTo(brp); - area->x0=(res->min())[0]; - area->y0=(res->min())[1]; - area->x1=(res->max())[0]; - area->y1=(res->max())[1]; - } else { - nr_rect_d_set_empty(area); - } -} - -void raster_font::LoadRasterGlyph(int glyph_id) -{ - raster_glyph *res=NULL; - if ( glyph_id_to_raster_glyph_no.find(glyph_id) == glyph_id_to_raster_glyph_no.end() ) { - res=new raster_glyph(); - res->daddy=this; - res->glyph_id=glyph_id; - if ( nbBase >= maxBase ) { - maxBase=2*nbBase+1; - bases=(raster_glyph**)realloc(bases,maxBase*sizeof(raster_glyph*)); - } - bases[nbBase]=res; - glyph_id_to_raster_glyph_no[glyph_id]=nbBase; - nbBase++; - } else { - res=bases[glyph_id_to_raster_glyph_no[glyph_id]]; - } - if ( res == NULL ) return; - if ( res->polygon ) return; - if ( res->outline == NULL ) { - if ( daddy == NULL ) return; - Path* outline=daddy->Outline(glyph_id,NULL); - res->outline=new Path; - if ( outline ) { - res->outline->Copy(outline); - } - res->outline->Transform(style.transform); - } - Shape* temp=new Shape; - res->polygon=new Shape; - style.Apply(res->outline,temp); - if ( style.stroke_width > 0 ) { - res->polygon->ConvertToShape(temp,fill_nonZero); - } else { - res->polygon->ConvertToShape(temp,fill_oddEven); - } - delete temp; - - res->SetSubPixelPositionning(4); -} -void raster_font::RemoveRasterGlyph(raster_glyph* who) -{ - if ( who == NULL ) return; - int glyph_id=who->glyph_id; - if ( glyph_id_to_raster_glyph_no.find(glyph_id) == glyph_id_to_raster_glyph_no.end() ) { - int no=glyph_id_to_raster_glyph_no[glyph_id]; - if ( no >= nbBase-1 ) { - } else { - bases[no]=bases[--nbBase]; - glyph_id_to_raster_glyph_no[bases[no]->glyph_id]=no; - } - glyph_id_to_raster_glyph_no.erase(glyph_id_to_raster_glyph_no.find(glyph_id)); - } else { - // not here - } -} - -/*int top,bottom; // baseline is y=0 - int* run_on_line; // array of size (bottom-top+1): run_on_line[i] gives the number of runs on line top+i - int nbRun; - float_ligne_run* runs;*/ - -raster_position::raster_position(void) -{ - top=0; - bottom=-1; - run_on_line=NULL; - nbRun=0; - runs=NULL; -} -raster_position::~raster_position(void) -{ - if ( run_on_line ) free(run_on_line); - if ( runs ) free(runs); -} - -void raster_position::AppendRuns(std::vector const &r,int y) -{ - if ( top > bottom ) { - top=bottom=y; - if ( run_on_line ) free(run_on_line); - run_on_line=(int*)malloc(sizeof(int)); - run_on_line[0]=0; - } else { - if ( y < top ) { - // printf("wtf?\n"); - return; - } else if ( y > bottom ) { - int ob=bottom; - bottom=y; - run_on_line=(int*)realloc(run_on_line,(bottom-top+1)*sizeof(int)); - for (int i=ob+1;i<=bottom;i++) run_on_line[i-top]=0; - } - } - - if ( r.empty() == false) { - run_on_line[y - top] = r.size(); - runs = (float_ligne_run *) realloc(runs, (nbRun + r.size()) * sizeof(float_ligne_run)); - - for (int i = 0; i < int(r.size()); i++) { - runs[nbRun + i] = r[i]; - } - - nbRun += r.size(); - } -} -void raster_position::Blit(float ph,int pv,NRPixBlock &over) -{ - int base_y=top+pv; - int first_y=top+pv,last_y=bottom+pv; - if ( first_y < over.area.y0 ) first_y=over.area.y0; - if ( last_y >= over.area.y1 ) last_y=over.area.y1-1; - if ( first_y > last_y ) return; - IntLigne *theIL=new IntLigne(); - FloatLigne *theI=new FloatLigne(); - - char* mdata=(char*)over.data.px; - if ( over.size == NR_PIXBLOCK_SIZE_TINY ) mdata=(char*)over.data.p; - - for (int y=first_y;y<=last_y;y++) { - int first_r=0,last_r=0; - for (int i=base_y;iReset(); - for (int i=first_r;i<=last_r;i++) theI->AddRun(runs[i].st+ph,runs[i].en+ph,runs[i].vst,runs[i].ven,runs[i].pente); -// for (int i=first_r;i<=last_r;i++) {runs[i].st+=ph;runs[i].en+=ph;} -// theI->nbRun=theI->maxRun=last_r-first_r+1; -// theI->runs=runs+first_r; - - theIL->Copy(theI); - raster_info dest; - dest.startPix=over.area.x0; - dest.endPix=over.area.x1; - dest.sth=over.area.x0; - dest.stv=y; - dest.buffer=((uint32_t*)(mdata+(over.rs*(y-over.area.y0)))); - theIL->Raster(dest,NULL,glyph_run_A8_OR); - -// theI->nbRun=theI->maxRun=0; -// theI->runs=NULL; -// for (int i=first_r;i<=last_r;i++) {runs[i].st-=ph;runs[i].en-=ph;} - } - } - delete theIL; - delete theI; -} - - -/* raster_font* daddy; - int glyph_id; - - Path* outline; - Shape* polygon; - - int nb_sub_pixel; - raster_position* sub_pixel;*/ - -raster_glyph::raster_glyph(void) -{ - daddy=NULL; - glyph_id=0; - outline=NULL; - polygon=NULL; - nb_sub_pixel=0; - sub_pixel=NULL; -} -raster_glyph::~raster_glyph(void) -{ - if ( outline ) delete outline; - if ( polygon ) delete polygon; - if ( sub_pixel ) delete [] sub_pixel; -} - - -void raster_glyph::SetSubPixelPositionning(int nb_pos) -{ - nb_sub_pixel=nb_pos; - if ( nb_sub_pixel <= 0 ) nb_sub_pixel=0; - if ( sub_pixel ) delete [] sub_pixel; - sub_pixel=NULL; - if ( nb_sub_pixel > 0 ) { - sub_pixel=new raster_position[nb_pos]; - if ( polygon ) { - for (int i=0;i= nb_sub_pixel ) return; - if ( sub_pixel[no].top <= sub_pixel[no].bottom ) return; - if ( polygon == NULL ) { - if ( daddy == NULL ) return; - daddy->LoadRasterGlyph(glyph_id); - if ( polygon == NULL ) return; - } - - float sub_delta=((float)no)/((float)nb_sub_pixel); - - polygon->CalcBBox(); - - float l=polygon->leftX,r=polygon->rightX,t=polygon->topY,b=polygon->bottomY; - int il,ir,it,ib; - il=(int)floor(l); - ir=(int)ceil(r); - it=(int)floor(t); - ib=(int)ceil(b); - - // version par FloatLigne - int curPt; - float curY; - polygon->BeginQuickRaster(curY, curPt); - - FloatLigne* theI=new FloatLigne(); - - polygon->DirectQuickScan(curY,curPt,(float)(it-1)+sub_delta,true,1.0); - - for (int y=it-1;yReset(); - polygon->QuickScan(curY,curPt,((float)(y+1))+sub_delta,theI,1.0); - theI->Flatten(); - - sub_pixel[no].AppendRuns(theI->runs, y); - } - polygon->EndQuickRaster(); - delete theI; -} - -void raster_glyph::Blit(const Geom::Point &at,NRPixBlock &over) -{ - if ( nb_sub_pixel <= 0 ) return; - int pv=(int)ceil(at[1]); - double dec=4*(ceil(at[1])-at[1]); - int no=(int)floor(dec); - sub_pixel[no].Blit(at[0],pv,over); -} - - - -static void -glyph_run_A8_OR (raster_info &dest,void */*data*/,int st,float vst,int en,float ven) -{ - if ( st >= en ) return; - if ( vst < 0 ) vst=0; - if ( vst > 1 ) vst=1; - if ( ven < 0 ) ven=0; - if ( ven > 1 ) ven=1; - float sv=vst; - float dv=ven-vst; - int len=en-st; - unsigned char* d=(unsigned char*)dest.buffer; - d+=(st-dest.startPix); - if ( fabs(dv) < 0.001 ) { - if ( vst > 0.999 ) { - /* Simple copy */ - while (len > 0) { - d[0] = 255; - d += 1; - len -= 1; - } - } else { - sv*=256; - unsigned int c0_24=(int)sv; - c0_24&=0xFF; - while (len > 0) { - unsigned int da; - /* Draw */ - da = 65025 - (255 - c0_24) * (255 - d[0]); - d[0] = (da + 127) / 255; - d += 1; - len -= 1; - } - } - } else { - if ( en <= st+1 ) { - sv=0.5*(vst+ven); - sv*=256; - unsigned int c0_24=(int)sv; - c0_24&=0xFF; - unsigned int da; - /* Draw */ - da = 65025 - (255 - c0_24) * (255 - d[0]); - d[0] = (da + 127) / 255; - } else { - dv/=len; - sv+=0.5*dv; // correction trapezoidale - sv*=16777216; - dv*=16777216; - int c0_24 = static_cast(CLAMP(sv, 0, 16777216)); - int s0_24 = static_cast(dv); - while (len > 0) { - unsigned int ca, da; - /* Draw */ - ca = c0_24 >> 16; - if ( ca > 255 ) ca=255; - da = 65025 - (255 - ca) * (255 - d[0]); - d[0] = (da + 127) / 255; - d += 1; - c0_24 += s0_24; - c0_24 = CLAMP (c0_24, 0, 16777216); - len -= 1; - } - } - } -} diff --git a/src/libnrtype/RasterFont.h b/src/libnrtype/RasterFont.h deleted file mode 100644 index 015121b42..000000000 --- a/src/libnrtype/RasterFont.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * RasterFont.h - * testICU - * - */ - -#ifndef my_raster_font -#define my_raster_font - -#include - -#include -#include -#include - -// one rasterfont is one way to draw a font on the screen -// the way it's drawn is stored in style -class raster_font { -public: - font_instance* daddy; - int refCount; - - font_style style; - - std::map glyph_id_to_raster_glyph_no; - // an array of glyphs in this rasterfont. - // it's a bit redundant with the one in the daddy font_instance, but these glyphs - // contains the real rasterization data - int nbBase,maxBase; - raster_glyph** bases; - - explicit raster_font(font_style const &fstyle); - virtual ~raster_font(void); - - void Unref(void); - void Ref(void); - - // utility functions - Geom::Point Advance(int glyph_id); - void BBox(int glyph_id,NRRect *area); - - // attempts to load a glyph and return a raster_glyph on which you can call Blit - raster_glyph* GetGlyph(int glyph_id); - // utility - void LoadRasterGlyph(int glyph_id); // refreshes outline/polygon if needed - void RemoveRasterGlyph(raster_glyph* who); - -private: - /* Disable the default copy constructor and operator=: they do the wrong thing for refCount. */ - raster_font(raster_font const &); - raster_font &operator=(raster_font const &); -}; - -#endif - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index d52bd723f..e9bd291d2 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -67,15 +67,6 @@ public: // for generating slanted cursors for oblique fonts Geom::OptRect BBox(int glyph_id); - // creates a rasterfont for the given style - raster_font* RasterFont(Geom::Matrix const &trs, double stroke_width, - bool vertical = false, JoinType stroke_join = join_straight, - ButtType stroke_cap = butt_straight, float miter_limit = 4.0); - // the dashes array in iStyle is copied - raster_font* RasterFont(font_style const &iStyle); - // private use: tells the font_instance that the raster_font 'who' has died - void RemoveRasterFont(raster_font *who); - // attribute queries unsigned Name(gchar *str, unsigned size); unsigned PSName(gchar *str, unsigned size); @@ -85,9 +76,6 @@ public: private: void FreeTheFace(); - // hashmap to get the raster_font for a given style - void* loadedPtr; - #ifdef USE_PANGO_WIN32 HFONT theFace; #else diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index a7160f5f0..bbed89b55 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -2,10 +2,7 @@ # include #endif -#include #include -#include -#include #include #include diff --git a/src/libnrtype/nrtype-forward.h b/src/libnrtype/nrtype-forward.h index f3344f2fd..6050ffa6b 100644 --- a/src/libnrtype/nrtype-forward.h +++ b/src/libnrtype/nrtype-forward.h @@ -5,9 +5,6 @@ class font_factory; struct font_glyph; class font_instance; struct font_style; -class raster_font; -class raster_glyph; -class raster_position; #endif /* !SEEN_LIBNRTYPE_NRTYPE_FORWARD_H */ diff --git a/src/libnrtype/raster-glyph.h b/src/libnrtype/raster-glyph.h deleted file mode 100644 index 82a0b3f8e..000000000 --- a/src/libnrtype/raster-glyph.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef SEEN_LIBNRTYPE_RASTER_GLYPH_H -#define SEEN_LIBNRTYPE_RASTER_GLYPH_H - -#include -#include -#include - -// a little utility class that holds data to render a styled glyph -// ie. it's like a polygon. its function is to wrap the subpixel positionning -class raster_glyph { -public: - // raster_font that created me - raster_font* daddy; - // the glyph i am (the style is in daddy) - int glyph_id; - // internal structure: the styled path, and the associated uncrossed polygon - // they could be removed after the raster_position have been computed - Path* outline; // transformed by the matrix in style (may be factorized, but is small) - Shape* polygon; - // subpixel positions - // nb_sub_pixel is set to 4 when the glyph is created (it's hardcoded) - int nb_sub_pixel; - raster_position* sub_pixel; - - raster_glyph(void); - virtual ~raster_glyph(void); - - // utility - void SetSubPixelPositionning(int nb_pos); - void LoadSubPixelPosition(int no); - - // the interesting function: blits the glyph onto over - // over should be a mask, ie a NRPixBlock with one 8bit plane - void Blit(Geom::Point const &at, NRPixBlock &over); // alpha only -}; - - -#endif /* !SEEN_LIBNRTYPE_RASTER_GLYPH_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnrtype/raster-position.h b/src/libnrtype/raster-position.h deleted file mode 100644 index 744b6dddd..000000000 --- a/src/libnrtype/raster-position.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef SEEN_LIBNRTYPE_RASTER_POSITION_H -#define SEEN_LIBNRTYPE_RASTER_POSITION_H - -#include - -#include -#include -#include - -// one subpixel position -// it's basically a set of trapezoids (=float_ligne_run) representing the black areas of the glyph -// all trapezoids are in the same array, hence the run_on_line array to give the number of -// trapezoids on each line -// trapezoids store the x-positions as float, and are shifted to the x blit position -// so it's "exact" in the x direction and subpixel in the y direction -class raster_position { -public: - int top, bottom; // baseline is y=0 - // top is the first pixel, bottom is the last - int* run_on_line; // array of size (bottom-top+1): run_on_line[i] gives the number of runs on line top+i - int nbRun; - float_ligne_run* runs; - -public: - raster_position(); - virtual ~raster_position(); - - // stuff runs into the structure - void AppendRuns(std::vector const &r, int y); - // blits the trapezoids. - void Blit(float ph, int pv, NRPixBlock &over); -}; - - -#endif /* !SEEN_LIBNRTYPE_RASTER_POSITION_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index ce0893430..cac4caee0 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -20,13 +20,7 @@ # include "config.h" #endif -#include -#include #include -#include -#include -#include -#include #include #include <2geom/transforms.h> @@ -40,11 +34,10 @@ #include #include -#include "../display/nr-plain-stuff-gdk.h" #include -#include "../desktop.h" -#include "font-selector.h" +#include "desktop.h" +#include "widgets/font-selector.h" /* SPFontSelector */ @@ -521,321 +514,6 @@ double sp_font_selector_get_size(SPFontSelector *fsel) return fsel->fontsize; } -/* SPFontPreview */ - -struct SPFontPreview -{ - GtkDrawingArea darea; - - font_instance *font; - raster_font *rfont; - gchar *phrase; - unsigned long rgba; -}; - -struct SPFontPreviewClass -{ - GtkDrawingAreaClass parent_class; -}; - -static void sp_font_preview_class_init(SPFontPreviewClass *c); -static void sp_font_preview_init(SPFontPreview *fsel); -static void sp_font_preview_destroy(GtkObject *object); - -void sp_font_preview_size_request(GtkWidget *widget, GtkRequisition *req); -static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event); - -static GtkDrawingAreaClass *fp_parent_class = NULL; - -GType sp_font_preview_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPFontPreviewClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_font_preview_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPFontPreview), - 0, // n_preallocs - (GInstanceInitFunc)sp_font_preview_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_DRAWING_AREA, "SPFontPreview", &info, static_cast(0)); - } - return type; -} - -static void sp_font_preview_class_init (SPFontPreviewClass *c) -{ - GtkObjectClass *object_class = (GtkObjectClass *) c; - GtkWidgetClass *widget_class = (GtkWidgetClass *) c; - - fp_parent_class = (GtkDrawingAreaClass*) gtk_type_class(GTK_TYPE_DRAWING_AREA); - - object_class->destroy = sp_font_preview_destroy; - - widget_class->size_request = sp_font_preview_size_request; - widget_class->expose_event = sp_font_preview_expose; -} - -static void sp_font_preview_init(SPFontPreview *fprev) -{ - fprev->rgba = 0x000000ff; -} - -static void sp_font_preview_destroy(GtkObject *object) -{ - SPFontPreview *fprev = SP_FONT_PREVIEW (object); - - if (fprev->rfont) { - fprev->rfont->Unref(); - fprev->rfont = NULL; - } - - if (fprev->font) { - fprev->font->Unref(); - fprev->font = NULL; - } - - g_free(fprev->phrase); - fprev->phrase = NULL; - - if (GTK_OBJECT_CLASS (fp_parent_class)->destroy) { - GTK_OBJECT_CLASS (fp_parent_class)->destroy(object); - } -} - -void sp_font_preview_size_request(GtkWidget */*widget*/, GtkRequisition *req) -{ - req->width = 256; - req->height = 32; -} - -#define SPFP_MAX_LEN 64 - -static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) -{ - SPFontPreview *fprev = SP_FONT_PREVIEW(widget); - - if (GTK_WIDGET_DRAWABLE (widget)) { - if (fprev->rfont) { - - int glyphs[SPFP_MAX_LEN]; - double hpos[SPFP_MAX_LEN]; - - font_instance *tface = fprev->rfont->daddy; - - double theSize = fprev->rfont->style.transform.descrim(); - - gchar const *p; - if (fprev->phrase) { - p = fprev->phrase; - } else { - /* TRANSLATORS: Test string used in text and font dialog (when no - * text has been entered) to get a preview of the font. Choose - * some representative characters that users of your locale will be - * interested in. */ - p = _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()"); - } - int len = 0; - - NRRect bbox; - bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0; - - text_wrapper* str_text=new text_wrapper; - str_text->SetDefaultFont(tface); - str_text->AppendUTF8(p,-1); - if ( str_text->uni32_length > 0 ) { - str_text->DoLayout(); - if ( str_text->glyph_length > 0 ) { - PangoFont *curPF = NULL; - font_instance *curF = NULL; - for (int i = 0; i < str_text->glyph_length && i < SPFP_MAX_LEN; i++) { - if ( str_text->glyph_text[i].font != curPF ) { - curPF = str_text->glyph_text[i].font; - if (curF) { - curF->Unref(); - } - curF = NULL; - if ( curPF ) { - PangoFontDescription* pfd = pango_font_describe(curPF); - curF = (font_factory::Default())->Face(pfd); - pango_font_description_free(pfd); - } - } - Geom::Point base_pt(str_text->glyph_text[i].x, str_text->glyph_text[i].y); - base_pt *= theSize; - - glyphs[len] = str_text->glyph_text[i].gl; - hpos[len] = base_pt[0]; - len++; - if ( curF ) { - Geom::OptRect nbbox = curF->BBox(str_text->glyph_text[i].gl); - if (nbbox) { - bbox.x0 = MIN(bbox.x0, base_pt[Geom::X] + theSize * (nbbox->min())[0]); - bbox.y0 = MIN(bbox.y0, base_pt[Geom::Y] - theSize * (nbbox->max())[1]); - bbox.x1 = MAX(bbox.x1, base_pt[Geom::X] + theSize * (nbbox->max())[0]); - bbox.y1 = MAX(bbox.y1, base_pt[Geom::Y] - theSize * (nbbox->min())[1]); - } - } - } - if ( curF ) { - curF->Unref(); - } - } - } - - // XXX: FIXME: why does this code ignore adv.y - /* while (p && *p && (len < SPFP_MAX_LEN)) { - unsigned int unival; - NRRect gbox; - unival = g_utf8_get_char (p); - glyphs[len] = tface->MapUnicodeChar( unival); - hpos[len] = (int)px; - Geom::Point adv = fprev->rfont->Advance(glyphs[len]); - fprev->rfont->BBox( glyphs[len], &gbox); - bbox.x0 = MIN (px + gbox.x0, bbox.x0); - bbox.y0 = MIN (py + gbox.y0, bbox.y0); - bbox.x1 = MAX (px + gbox.x1, bbox.x1); - bbox.y1 = MAX (py + gbox.y1, bbox.y1); - px += adv[Geom::X]; - len += 1; - p = g_utf8_next_char (p); - }*/ - - float startx = (widget->allocation.width - (bbox.x1 - bbox.x0)) / 2; - float starty = widget->allocation.height - (widget->allocation.height - (bbox.y1 - bbox.y0)) / 2 - bbox.y1; - - for (int y = event->area.y; y < event->area.y + event->area.height; y += 64) { - for (int x = event->area.x; x < event->area.x + event->area.width; x += 64) { - NRPixBlock pb, m; - int x0 = x; - int y0 = y; - int x1 = MIN(x0 + 64, event->area.x + event->area.width); - int y1 = MIN(y0 + 64, event->area.y + event->area.height); - guchar *ps = nr_pixelstore_16K_new (TRUE, 0xff); - nr_pixblock_setup_extern(&pb, NR_PIXBLOCK_MODE_R8G8B8, x0, y0, x1, y1, ps, 3 * (x1 - x0), FALSE, FALSE); - nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, x0, y0, x1, y1, TRUE); - pb.empty = FALSE; - - PangoFont *curPF = NULL; - font_instance *curF = NULL; - raster_font *curRF = NULL; - for (int i=0; i < len; i++) { - if ( str_text->glyph_text[i].font != curPF ) { - curPF=str_text->glyph_text[i].font; - if ( curF ) { - curF->Unref(); - } - curF = NULL; - if ( curPF ) { - PangoFontDescription* pfd = pango_font_describe(curPF); - curF=(font_factory::Default())->Face(pfd); - pango_font_description_free(pfd); - } - if ( curF ) { - if ( curRF ) { - curRF->Unref(); - } - curRF = NULL; - curRF = curF->RasterFont(fprev->rfont->style); - } - } - raster_glyph *g = (curRF) ? curRF->GetGlyph(glyphs[i]) : NULL; - if ( g ) { - g->Blit(Geom::Point(hpos[i] + startx, starty), m); - } - } - if (curRF) { - curRF->Unref(); - } - if (curF) { - curF->Unref(); - } - - nr_blit_pixblock_mask_rgba32(&pb, &m, fprev->rgba); - gdk_draw_rgb_image(widget->window, widget->style->black_gc, - x0, y0, x1 - x0, y1 - y0, - GDK_RGB_DITHER_NONE, NR_PIXBLOCK_PX (&pb), pb.rs); - nr_pixblock_release(&m); - nr_pixblock_release(&pb); - nr_pixelstore_16K_free(ps); - } - } - - delete str_text; - - } else { - nr_gdk_draw_gray_garbage(widget->window, widget->style->black_gc, - event->area.x, event->area.y, - event->area.width, event->area.height); - } - } - - return TRUE; -} - -GtkWidget * sp_font_preview_new() -{ - GtkWidget *w = (GtkWidget*) gtk_type_new(SP_TYPE_FONT_PREVIEW); - - return w; -} - -void sp_font_preview_set_font(SPFontPreview *fprev, font_instance *font, SPFontSelector *fsel) -{ - if (font) - { - font->Ref(); - } - - if (fprev->font) - { - fprev->font->Unref(); - } - - fprev->font = font; - - if (fprev->rfont) - { - fprev->rfont->Unref(); - fprev->rfont=NULL; - } - - if (fprev->font) - { - Geom::Matrix flip(Geom::Scale(fsel->fontsize, -fsel->fontsize)); - fprev->rfont = fprev->font->RasterFont(flip, 0); - } - - if (GTK_WIDGET_DRAWABLE (fprev)) gtk_widget_queue_draw (GTK_WIDGET (fprev)); -} - -void sp_font_preview_set_rgba32(SPFontPreview *fprev, guint32 rgba) -{ - fprev->rgba = rgba; - if (GTK_WIDGET_DRAWABLE (fprev)) { - gtk_widget_queue_draw (GTK_WIDGET (fprev)); - } -} - -void sp_font_preview_set_phrase(SPFontPreview *fprev, const gchar *phrase) -{ - g_free (fprev->phrase); - if (phrase) { - fprev->phrase = g_strdup (phrase); - } else { - fprev->phrase = NULL; - } - if (GTK_WIDGET_DRAWABLE(fprev)) { - gtk_widget_queue_draw (GTK_WIDGET (fprev)); - } -} - - /* Local Variables: mode:c++ diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 094db0343..2c4e26610 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -17,16 +17,11 @@ #include struct SPFontSelector; -struct SPFontPreview; #define SP_TYPE_FONT_SELECTOR (sp_font_selector_get_type ()) #define SP_FONT_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector)) #define SP_IS_FONT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_SELECTOR)) -#define SP_TYPE_FONT_PREVIEW (sp_font_preview_get_type ()) -#define SP_FONT_PREVIEW(o) (GTK_CHECK_CAST ((o), SP_TYPE_FONT_PREVIEW, SPFontPreview)) -#define SP_IS_FONT_PREVIEW(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_PREVIEW)) - #include #include @@ -41,16 +36,6 @@ void sp_font_selector_set_font (SPFontSelector *fsel, font_instance *font, doubl font_instance *sp_font_selector_get_font (SPFontSelector *fsel); double sp_font_selector_get_size (SPFontSelector *fsel); -/* SPFontPreview */ - -GtkType sp_font_preview_get_type (void); - -GtkWidget *sp_font_preview_new (void); - -void sp_font_preview_set_font (SPFontPreview *fprev, font_instance *font, SPFontSelector *fsel); -void sp_font_preview_set_rgba32 (SPFontPreview *fprev, guint32 rgba); -void sp_font_preview_set_phrase (SPFontPreview *fprev, const gchar *phrase); - #endif -- cgit v1.2.3 From 267b81d9fd0d1254a80b008c26237fbe4bd93610 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 6 Aug 2010 01:23:28 +0200 Subject: Minor cleanups (bzr r9508.1.51) --- src/display/nr-arena-image.cpp | 3 +- src/display/nr-arena-item.cpp | 5 +++ src/display/nr-arena-shape.cpp | 1 + src/display/nr-filter-image.cpp | 1 + src/display/nr-filter-slot.cpp | 3 -- src/display/nr-filter.cpp | 69 +++++++---------------------------------- src/display/nr-filter.h | 7 +---- src/display/nr-style.cpp | 6 ++-- src/sp-pattern.cpp | 8 +++++ 9 files changed, 33 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 5617bb084..d32b6efe0 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -93,9 +93,10 @@ nr_arena_image_finalize (NRObject *object) { NRArenaImage *image = NR_ARENA_IMAGE (object); - image->px = NULL; if (image->pixbuf != NULL) g_object_unref(image->pixbuf); + if (image->style) + sp_style_unref(image->style); ((NRObjectClass *) parent_class)->finalize (object); } diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 9b76c4ff7..9f3863f4d 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -106,6 +106,11 @@ nr_arena_item_private_finalize (NRObject *object) item->px = NULL; item->transform = NULL; + if (item->clip) + nr_arena_item_detach(item, item->clip); + if (item->mask) + nr_arena_item_detach(item, item->mask); + ((NRObjectClass *) (parent_class))->finalize (object); } diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 5b5000c60..8a2b27f4f 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -121,6 +121,7 @@ nr_arena_shape_finalize(NRObject *object) if (shape->path) cairo_path_destroy(shape->path); if (shape->style) sp_style_unref(shape->style); if (shape->curve) shape->curve->unref(); + shape->last_pick = NULL; ((NRObjectClass *) shape_parent_class)->finalize(object); } diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 636f31187..28b2aa5c1 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -113,6 +113,7 @@ void FilterImage::render_cairo(FilterSlot &slot) NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); nr_arena_item_invoke_render(ct, ai, &render_rect, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE); + sp_item_invoke_hide(SVGElem, key); nr_object_unref((NRObject*) arena); slot.set(_output, out); diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 6cca0fc77..c02f47b26 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -121,9 +121,6 @@ cairo_surface_t *FilterSlot::getcairo(int slot_nr) s = _slots.find(slot_nr); } return s->second; - - //assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr); - //return _slot[index]; } cairo_surface_t *FilterSlot::_get_transformed_source_graphic() diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 1484235dc..e163b6346 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -79,23 +79,12 @@ static Geom::OptRect get_item_bbox(NRArenaItem const *item) { Filter::Filter() { - _primitive_count = 0; - _primitive_table_size = 1; - _primitive = new FilterPrimitive*[1]; - _primitive[0] = NULL; - //_primitive_count = 1; - //_primitive[0] = new FilterGaussian; _common_init(); } Filter::Filter(int n) { - _primitive_count = 0; - _primitive_table_size = (n > 0) ? n : 1; // we guarantee there is at least 1(one) filter slot - _primitive = new FilterPrimitive*[_primitive_table_size]; - for ( int i = 0 ; i < _primitive_table_size ; i++ ) { - _primitive[i] = NULL; - } + if (n > 0) _primitive.reserve(n); _common_init(); } @@ -124,13 +113,12 @@ void Filter::_common_init() { Filter::~Filter() { clear_primitives(); - delete[] _primitive; } int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea, cairo_t *graphic, NRRectL const *area) { - if (!_primitive[0]) { + if (_primitive.empty()) { // when no primitives are defined, clear source graphic cairo_set_source_rgba(graphic, 0,0,0,0); cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); @@ -186,7 +174,7 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea units.set_paraller(false); Geom::Matrix pbtrans = units.get_matrix_display2pb(); - for (int i = 0 ; i < _primitive_count ; i++) { + for (unsigned i = 0 ; i < _primitive.size() ; i++) { if (!_primitive[i]->can_handle_affine(pbtrans)) { units.set_paraller(true); break; @@ -197,7 +185,7 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea slot.set_quality(filterquality); slot.set_blurquality(blurquality); - for (int i = 0 ; i < _primitive_count ; i++) { + for (unsigned i = 0 ; i < _primitive.size() ; i++) { _primitive[i]->render_cairo(slot); } @@ -220,7 +208,7 @@ void Filter::set_primitive_units(SPFilterUnits unit) { } void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { - for (int i = 0 ; i < _primitive_count ; i++) { + for (unsigned i = 0 ; i < _primitive.size() ; i++) { if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm); } @@ -356,27 +344,6 @@ void Filter::_create_constructor_table() created = true; } -/** Helper method for enlarging table of filter primitives. When new - * primitives are added, but we have no space for them, this function - * makes some more space. - */ -void Filter::_enlarge_primitive_table() { - FilterPrimitive **new_tbl = new FilterPrimitive*[_primitive_table_size * 2]; - for (int i = 0 ; i < _primitive_count ; i++) { - new_tbl[i] = _primitive[i]; - } - _primitive_table_size *= 2; - for (int i = _primitive_count ; i < _primitive_table_size ; i++) { - new_tbl[i] = NULL; - } - if(_primitive != NULL) { - delete[] _primitive; - } else { - g_warning("oh oh"); - } - _primitive = new_tbl; -} - int Filter::add_primitive(FilterPrimitiveType type) { _create_constructor_table(); @@ -387,14 +354,8 @@ int Filter::add_primitive(FilterPrimitiveType type) if (!_constructor[type]) return -1; FilterPrimitive *created = _constructor[type](); - // If there is no space for new filter primitive, enlarge the table - if (_primitive_count >= _primitive_table_size) { - _enlarge_primitive_table(); - } - - _primitive[_primitive_count] = created; - int handle = _primitive_count; - _primitive_count++; + int handle = _primitive.size(); + _primitive.push_back(created); return handle; } @@ -404,8 +365,7 @@ int Filter::replace_primitive(int target, FilterPrimitiveType type) // Check that target is valid primitive inside this filter if (target < 0) return -1; - if (target >= _primitive_count) return -1; - if (!_primitive[target]) return -1; + if (static_cast(target) >= _primitive.size()) return -1; // Check that we can create a new filter of specified type if (type < 0 || type >= NR_FILTER_ENDPRIMITIVETYPE) @@ -413,27 +373,22 @@ int Filter::replace_primitive(int target, FilterPrimitiveType type) if (!_constructor[type]) return -1; FilterPrimitive *created = _constructor[type](); - // If there is no space for new filter primitive, enlarge the table - if (_primitive_count >= _primitive_table_size) { - _enlarge_primitive_table(); - } - delete _primitive[target]; _primitive[target] = created; return target; } FilterPrimitive *Filter::get_primitive(int handle) { - if (handle < 0 || handle >= _primitive_count) return NULL; + if (handle < 0 || handle >= static_cast(_primitive.size())) return NULL; return _primitive[handle]; } void Filter::clear_primitives() { - for (int i = 0 ; i < _primitive_count ; i++) { - if (_primitive[i]) delete _primitive[i]; + for (unsigned i = 0 ; i < _primitive.size() ; i++) { + delete _primitive[i]; } - _primitive_count = 0; + _primitive.clear(); } void Filter::set_x(SVGLength const &length) diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 4db1ec988..9349ba9c6 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -174,9 +174,7 @@ public: virtual ~Filter(); private: - int _primitive_count; - int _primitive_table_size; - + std::vector _primitive; /** Amount of image slots used, when this filter was rendered last time */ int _slot_count; @@ -198,10 +196,7 @@ private: SPFilterUnits _filter_units; SPFilterUnits _primitive_units; - FilterPrimitive ** _primitive; - void _create_constructor_table(); - void _enlarge_primitive_table(); void _common_init(); int _resolution_limit(FilterQuality const quality) const; std::pair _filter_resolution(Geom::Rect const &area, diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index bf2f2d305..40366f5d3 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -55,8 +55,8 @@ NRStyle::NRStyle() NRStyle::~NRStyle() { - cairo_pattern_destroy(fill_pattern); - cairo_pattern_destroy(stroke_pattern); + if (fill_pattern) cairo_pattern_destroy(fill_pattern); + if (stroke_pattern) cairo_pattern_destroy(stroke_pattern); if (dash) delete dash; } @@ -123,7 +123,7 @@ void NRStyle::set(SPStyle *style) } miter_limit = style->stroke_miterlimit.value; - delete [] dash; + if (dash) delete [] dash; n_dash = style->stroke_dash.n_dash; if (n_dash != 0) { diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index a559a4a50..8d156bc77 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -610,9 +610,11 @@ sp_pattern_create_pattern(SPPaintServer *ps, NRArenaGroup *root = NRArenaGroup::create(arena); /* Show items */ + SPPattern *shown = NULL; for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { // find the first one with item children if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { + shown = pat_i; for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { // for each item in pattern, show it on our arena, add to the group, @@ -664,6 +666,12 @@ sp_pattern_create_pattern(SPPaintServer *ps, gc.transform = vb2ps; nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); nr_arena_item_invoke_render (ct, root, &one_tile, NULL, 0); + for (SPObject *child = sp_object_first_child(SP_OBJECT(shown)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_ITEM (child)) { + sp_item_invoke_hide(SP_ITEM (child), dkey); + } + } + nr_object_unref(root); nr_object_unref(arena); if (needs_opacity) { -- cgit v1.2.3 From 05cc14034e5ba3803148e76d7fd6088f2bacb1d5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 9 Aug 2010 22:27:13 +0200 Subject: OpenMP-enabled matrix convolution (bzr r9508.1.53) --- src/display/nr-filter-convolve-matrix.cpp | 228 ++++++++++-------------------- 1 file changed, 71 insertions(+), 157 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 6647c6273..44e3c2290 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -31,163 +31,73 @@ FilterPrimitive * FilterConvolveMatrix::create() { FilterConvolveMatrix::~FilterConvolveMatrix() {} -template -static inline void convolve2D_XY(unsigned int const x, unsigned int const y, guint32 *const out_data, guint32 const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const bias) { - double result_R = 0; - double result_G = 0; - double result_B = 0; - double result_A = 0; - - unsigned int iBegin = Y_LOWER ? targetY-y : 0; // Note that to prevent signed/unsigned problems this requires that y<=targetY (which is true) - unsigned int iEnd = Y_UPPER ? height+targetY-y : orderY; // And this requires that y<=height+targetY (which is trivially true), in addition it should be true that height+targetY-y<=orderY (or equivalently y>=height+targetY-orderY, which is true) - unsigned int jBegin = X_LOWER ? targetX-x : 0; - unsigned int jEnd = X_UPPER ? width+targetX-x : orderX; - - for (unsigned int i=iBegin; i> 24; - } else { - ao = CLAMP_D_TO_U8(result_A + 255*bias); - } - - guint32 ro = CLAMP_D_TO_U8_ALPHA(result_R + ao*bias, ao); // CLAMP includes rounding! - guint32 go = CLAMP_D_TO_U8_ALPHA(result_G + ao*bias, ao); - guint32 bo = CLAMP_D_TO_U8_ALPHA(result_B + ao*bias, ao); - - ASSEMBLE_ARGB32(result, ao,ro,go,bo) - - out_data[out_index] = result; -} - -template -static inline void convolve2D_Y(unsigned int const y, guint32 *const out_data, guint32 const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const bias) { - // See convolve2D below for rationale. - - unsigned int const lowerEnd = std::min(targetX,width); - unsigned int const upperBegin = width - std::min(width,orderX - 1u - targetX); - unsigned int const midXBegin = std::min(lowerEnd,upperBegin); - unsigned int const midXEnd = std::max(lowerEnd,upperBegin); - - for (unsigned int x=0; x(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } - if (lowerEnd==upperBegin) { - // Do nothing, empty mid section - } else if (lowerEnd(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } - } else { - // In the middle both bounds have to be adjusted - for (unsigned int x=midXBegin; x(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } - } - for (unsigned int x=midXEnd; x(x, y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } -} - -template -static void convolve2D(guint32 *const out_data, guint32 const *const in_data, unsigned int const width, unsigned int const height, double const *const kernel, unsigned int const orderX, unsigned int const orderY, unsigned int const targetX, unsigned int const targetY, double const _bias) { - double const bias = _bias; - - // For the middle section it should hold that (for all i such that 0<=i=height+targetY-orderY+1 i's upper bound needs to be adjusted. - - unsigned int const lowerEnd = std::min(targetY,height); - unsigned int const upperBegin = height - std::min(height,orderY - 1u - targetY); - unsigned int const midYBegin = std::min(lowerEnd,upperBegin); - unsigned int const midYEnd = std::max(lowerEnd,upperBegin); - - for (unsigned int y=0; y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } - if (lowerEnd==upperBegin) { - // Do nothing, empty mid section - } else if (lowerEnd(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } - } else { - // In the middle both bounds have to be adjusted - for (unsigned int y=midYBegin; y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } - } - for (unsigned int y=midYEnd; y(y, out_data, in_data, width, height, kernel, orderX, orderY, targetX, targetY, bias); - } -} - -/* -struct ConvolveMatrix { - ConvolveMatrix(guint32 *px, int yskip, int targetX, int targetY, int orderX, int orderY, - double divisor, double bias, PixelAccessor::EdgeMode emode, - std::vector const &kernel) - : _kernel(kernel.size()) -// , _in(in, emode) - , _tx(targetX), _ty(targetY) - , _oX(orderX), _oY(orderY) - , _yskip(yskip) +enum PreserveAlphaMode { + PRESERVE_ALPHA, + NO_PRESERVE_ALPHA +}; + +template +struct ConvolveMatrix : public SurfaceSynth { + ConvolveMatrix(cairo_surface_t *s, int targetX, int targetY, int orderX, int orderY, + double divisor, double bias, std::vector const &kernel) + : SurfaceSynth(s) + , _kernel(kernel.size()) + , _targetX(targetX) + , _targetY(targetY) + , _orderX(orderX) + , _orderY(orderY) , _bias(bias) { - for (unsigned i = 0; i < kernel.size(); ++i) { + for (unsigned i = 0; i < _kernel.size(); ++i) { _kernel[i] = kernel[i] / divisor; } - } - - guint32 operator()(int x, int y) { - int start_x = x - _tX; - int start_y = y - _tY; - - double ro = 0, go = 0, bo = 0, ao = 0; - - for (int i = 0; i < _oY; ++i) { - for (int j = 0; j < _oX; ++j) { - guint32 in = pixelAt(start_x + j, start_y + i); - EXTRACT_ARGB(in, a,r,g,b) - - unsigned kidx = i*_oY + j; - double k = kernel[] - - ro += r * + // the matrix is given rotated 180 degrees + // which corresponds to reverse element order + std::reverse(_kernel.begin(), _kernel.end()); + } + + guint32 operator()(int x, int y) const { + int startx = std::max(0, x - _targetX); + int starty = std::max(0, y - _targetY); + int endx = std::min(_w, startx + _orderX); + int endy = std::min(_h, starty + _orderY); + int limitx = endx - startx; + int limity = endy - starty; + double suma = 0.0, sumr = 0.0, sumg = 0.0, sumb = 0.0; + + for (int i = 0; i < limity; ++i) { + for (int j = 0; j < limitx; ++j) { + guint32 px = pixelAt(startx + j, starty + i); + double coeff = _kernel[i * _orderX + j]; + EXTRACT_ARGB32(px, a,r,g,b) + + sumr += r * coeff; + sumg += g * coeff; + sumb += b * coeff; + if (preserve_alpha == NO_PRESERVE_ALPHA) { + suma += a * coeff; + } } } - - } + if (preserve_alpha == PRESERVE_ALPHA) { + suma = alphaAt(x, y); + } else { + suma += _bias * 255; + } -private: - inline guint32 pixelAt(int x, int y) { - return *(_px + y * _yskip + x); + guint32 ao = pxclamp(round(suma), 0, 255); + guint32 ro = pxclamp(round(sumr + ao * _bias), 0, ao); + guint32 go = pxclamp(round(sumg + ao * _bias), 0, ao); + guint32 bo = pxclamp(round(sumb + ao * _bias), 0, ao); + ASSEMBLE_ARGB32(pxout, ao,ro,go,bo); + return pxout; } +private: std::vector _kernel; - guint32 *_px; - // PixelAccessor _in; + int _targetX, _targetY, _orderX, _orderY; double _bias; - int _tX, _tY, _oX, _oY, _yskip; -}; */ +}; void FilterConvolveMatrix::render_cairo(FilterSlot &slot) { @@ -205,7 +115,7 @@ void FilterConvolveMatrix::render_cairo(FilterSlot &slot) return; } if (kernelMatrix.size()!=(unsigned int)(orderX*orderY)) { - g_warning("kernelMatrix does not have orderX*orderY elements!"); + //g_warning("kernelMatrix does not have orderX*orderY elements!"); return; } @@ -228,24 +138,28 @@ void FilterConvolveMatrix::render_cairo(FilterSlot &slot) edge_warning = true; } - guint32 *in_data = reinterpret_cast(cairo_image_surface_get_data(input)); - guint32 *out_data = reinterpret_cast(cairo_image_surface_get_data(out)); + //guint32 *in_data = reinterpret_cast(cairo_image_surface_get_data(input)); + //guint32 *out_data = reinterpret_cast(cairo_image_surface_get_data(out)); - int width = cairo_image_surface_get_width(input); - int height = cairo_image_surface_get_height(input); + //int width = cairo_image_surface_get_width(input); + //int height = cairo_image_surface_get_height(input); // Set up predivided kernel matrix - std::vector kernel(kernelMatrix); + /*std::vector kernel(kernelMatrix); for(size_t i=0; i(out_data, in_data, width, height, &kernel.front(), orderX, orderY, - targetX, targetY, bias); + //convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, + // targetX, targetY, bias); + ink_cairo_surface_synthesize(out, ConvolveMatrix(input, + targetX, targetY, orderX, orderY, divisor, bias, kernelMatrix)); } else { - convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, - targetX, targetY, bias); + //convolve2D(out_data, in_data, width, height, &kernel.front(), orderX, orderY, + // targetX, targetY, bias); + ink_cairo_surface_synthesize(out, ConvolveMatrix(input, + targetX, targetY, orderX, orderY, divisor, bias, kernelMatrix)); } slot.set(_output, out); -- cgit v1.2.3 From 2cfc657521d2c22e9238ce1904a6a4a90d3b4517 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 9 Aug 2010 22:45:22 +0200 Subject: Fix performance regression when displaying large images (bzr r9508.1.54) --- src/display/cairo-utils.cpp | 11 +++++++++-- src/display/cairo-utils.h | 1 + src/display/nr-arena-image.cpp | 10 +++++++--- src/display/nr-arena-image.h | 3 ++- src/sp-image.cpp | 18 ++++++++++++------ 5 files changed, 31 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 15fceedae..96219e834 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -326,6 +326,14 @@ ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Matrix const &m) void ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double y) +{ + cairo_surface_t *pbs = ink_cairo_surface_create_for_argb32_pixbuf(pb); + cairo_set_source_surface(ct, pbs, x, y); + cairo_surface_destroy(pbs); +} + +cairo_surface_t * +ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb) { guchar *data = gdk_pixbuf_get_pixels(pb); int w = gdk_pixbuf_get_width(pb); @@ -334,8 +342,7 @@ ink_cairo_set_source_argb32_pixbuf(cairo_t *ct, GdkPixbuf *pb, double x, double cairo_surface_t *pbs = cairo_image_surface_create_for_data( data, CAIRO_FORMAT_ARGB32, w, h, stride); - cairo_set_source_surface(ct, pbs, x, y); - cairo_surface_destroy(pbs); + return pbs; } /** @brief Create an exact copy of a surface. diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index f74ceed14..0acdcb46a 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -102,6 +102,7 @@ void convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int rs); void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); void convert_pixbuf_normal_to_argb32(GdkPixbuf *); void convert_pixbuf_argb32_to_normal(GdkPixbuf *); +cairo_surface_t *ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb); G_GNUC_CONST inline guint32 premul_alpha(guint32 color, guint32 alpha) diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index d32b6efe0..5f30e0560 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -93,8 +93,10 @@ nr_arena_image_finalize (NRObject *object) { NRArenaImage *image = NR_ARENA_IMAGE (object); - if (image->pixbuf != NULL) + if (image->pixbuf != NULL) { g_object_unref(image->pixbuf); + cairo_surface_destroy(image->surface); + } if (image->style) sp_style_unref(image->style); @@ -159,7 +161,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_translate(ct, image->ox, image->oy); cairo_scale(ct, image->sx, image->sy); - gdk_cairo_set_source_pixbuf(ct, image->pixbuf, 0, 0); + cairo_set_source_surface(ct, image->surface, 0, 0); cairo_matrix_t tt; Geom::Matrix total; @@ -311,7 +313,7 @@ nr_arena_image_rect (NRArenaImage *image) /* Utility */ void -nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb) +nr_arena_image_set_argb32_pixbuf (NRArenaImage *image, GdkPixbuf *pb) { nr_return_if_fail (image != NULL); nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); @@ -322,8 +324,10 @@ nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb) } if (image->pixbuf != NULL) { g_object_unref(image->pixbuf); + cairo_surface_destroy(image->surface); } image->pixbuf = pb; + image->surface = pb ? ink_cairo_surface_create_for_argb32_pixbuf(pb) : NULL; nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-arena-image.h b/src/display/nr-arena-image.h index 76ff23c29..bde0d41bd 100644 --- a/src/display/nr-arena-image.h +++ b/src/display/nr-arena-image.h @@ -26,6 +26,7 @@ NRType nr_arena_image_get_type (void); struct NRArenaImage : public NRArenaItem { GdkPixbuf *pixbuf; + cairo_surface_t *surface; Geom::Matrix ctm; Geom::Rect clipbox; @@ -45,7 +46,7 @@ struct NRArenaImageClass { NRArenaItemClass parent_class; }; -void nr_arena_image_set_pixbuf (NRArenaImage *image, GdkPixbuf *pb); +void nr_arena_image_set_argb32_pixbuf (NRArenaImage *image, GdkPixbuf *pb); void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style); void nr_arena_image_set_clipbox (NRArenaImage *image, Geom::Rect const &clip); void nr_arena_image_set_origin (NRArenaImage *image, Geom::Point const &origin); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 596090846..22392e635 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -26,6 +26,7 @@ #include #include "display/nr-arena-image.h" +#include "display/cairo-utils.h" #include "display/curve.h" //Added for preserveAspectRatio support -- EAF #include "enums.h" @@ -908,6 +909,8 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags) } #endif // ENABLE_LCMS image->pixbuf = pixbuf; + // convert to premultiplied native-endian ARGB for display with Cairo + convert_pixbuf_normal_to_argb32(image->pixbuf); } } } @@ -1077,11 +1080,14 @@ sp_image_print (SPItem *item, SPPrintContext *ctx) SPImage *image = SP_IMAGE(item); if (image->pixbuf && (image->width.computed > 0.0) && (image->height.computed > 0.0) ) { - guchar *px = gdk_pixbuf_get_pixels(image->pixbuf); - int w = gdk_pixbuf_get_width(image->pixbuf); - int h = gdk_pixbuf_get_height(image->pixbuf); - int rs = gdk_pixbuf_get_rowstride(image->pixbuf); - int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8; + GdkPixbuf *pb = gdk_pixbuf_copy(image->pixbuf); + convert_pixbuf_argb32_to_normal(pb); + + guchar *px = gdk_pixbuf_get_pixels(pb); + int w = gdk_pixbuf_get_width(pb); + int h = gdk_pixbuf_get_height(pb); + int rs = gdk_pixbuf_get_rowstride(pb); + int pixskip = gdk_pixbuf_get_n_channels(pb) * gdk_pixbuf_get_bits_per_sample(pb) / 8; if (image->aspect_align == SP_ASPECT_NONE) { Geom::Matrix t; @@ -1262,7 +1268,7 @@ static void sp_image_update_arenaitem (SPImage *image, NRArenaImage *ai) { nr_arena_image_set_style(ai, SP_OBJECT_STYLE(SP_OBJECT(image))); - nr_arena_image_set_pixbuf(ai, image->pixbuf); + nr_arena_image_set_argb32_pixbuf(ai, image->pixbuf); nr_arena_image_set_origin(ai, Geom::Point(image->ox, image->oy)); nr_arena_image_set_scale(ai, image->sx, image->sy); nr_arena_image_set_clipbox(ai, image->clipbox); -- cgit v1.2.3 From ec6081bc21bacd807d6e5869182a439623466181 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 10 Aug 2010 23:54:29 +0200 Subject: Fix rendering of masks with non-opaque alpha channel (bzr r9508.1.55) --- src/display/cairo-templates.h | 16 ---------------- src/display/nr-arena-item.cpp | 21 +++++++++++++++------ src/display/nr-filter-colormatrix.cpp | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 3c8a6fea3..2b97dd6d6 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -686,22 +686,6 @@ pxclamp(gint32 v, gint32 low, gint32 high) { #define ASSEMBLE_ARGB32(px,a,r,g,b) \ guint32 px = (a << 24) | (r << 16) | (g << 8) | b; -// this is also used for masks, so it resides in this header -struct ColorMatrixLuminanceToAlpha { - guint32 operator()(guint32 in) { - // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 - EXTRACT_ARGB32(in, a, r, g, b) - // unpremultiply color values - if (a != 0) { - r = unpremul_alpha(r, a); - g = unpremul_alpha(g, a); - b = unpremul_alpha(b, a); - } - guint32 ao = r*54 + g*182 + b*18; - return ((ao + 127) / 255) << 24; - } -}; - #endif /* Local Variables: diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index d9c04ae95..fe50f7753 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -308,11 +308,20 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, return item->state; } -/** - * Render item to pixblock. - * - * \return Has NR_ARENA_ITEM_STATE_RENDER set on success. - */ +struct MaskLuminanceToAlpha { + guint32 operator()(guint32 in) { + // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 + EXTRACT_ARGB32(in, a, r, g, b) + // unpremultiply color values + if (a != 0) { + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); + } + guint32 ao = r*54 + g*182 + b*18; + return premul_alpha((ao + 127) / 255, a) << 24; + } +}; unsigned int nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area, @@ -462,7 +471,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area cairo_pattern_t *p = mask->cobj(); cairo_surface_t *s; cairo_pattern_get_surface(p, &s); - ink_cairo_surface_filter(s, s, ColorMatrixLuminanceToAlpha()); + ink_cairo_surface_filter(s, s, MaskLuminanceToAlpha()); } // render the object (possibly to the intermediate surface) diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index d77898180..7ab606182 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -135,6 +135,21 @@ private: gint32 _v[9]; }; +struct ColorMatrixLuminanceToAlpha { + guint32 operator()(guint32 in) { + // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 + EXTRACT_ARGB32(in, a, r, g, b) + // unpremultiply color values + if (a != 0) { + r = unpremul_alpha(r, a); + g = unpremul_alpha(g, a); + b = unpremul_alpha(b, a); + } + guint32 ao = r*54 + g*182 + b*18; + return ((ao + 127) / 255) << 24; + } +}; + void FilterColorMatrix::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); -- cgit v1.2.3 From 2eceacbf55b5796e4449fb3efc85cffdf5b6303c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 12 Aug 2010 00:40:33 +0200 Subject: Fix rendering failures caused by markers with markerUnits="strokeWidth" on shapes with zero stroke width (bzr r9508.1.56) --- src/display/nr-arena-shape.cpp | 3 ++- src/marker.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 8a2b27f4f..550195c7c 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -370,6 +370,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock // to render svg:pattern has_fill = shape->nrstyle.prepareFill(ct, &shape->paintbox); has_stroke = shape->nrstyle.prepareStroke(ct, &shape->paintbox); + has_stroke &= (shape->nrstyle.stroke_width != 0); if (has_fill || has_stroke) { // TODO: remove segments outside of bbox when no dashes present @@ -387,7 +388,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_restore(ct); } - /* Render markers into parent buffer */ + // marker rendering for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { unsigned int ret = nr_arena_item_invoke_render(ct, child, area, pb, flags); if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; diff --git a/src/marker.cpp b/src/marker.cpp index 6917c0b71..f89dd2bc0 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -614,6 +614,13 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, unsigned int key, unsigned int pos, Geom::Matrix const &base, float linewidth) { + // do not show marker if linewidth == 0 and markerUnits == strokeWidth + // otherwise Cairo will fail to render anything on the tile + // that contains the "degenerate" marker + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH && linewidth == 0) { + return NULL; + } + for (SPMarkerView *v = marker->views; v != NULL; v = v->next) { if (v->key == key) { if (pos >= v->items.size()) { -- cgit v1.2.3 From 7fc2ee7a7a6b09b4445da334af403872b41a9f63 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 12 Aug 2010 01:05:19 +0200 Subject: Fix light vector computation for lighting filters (bzr r9508.1.57) --- src/display/nr-filter-diffuselighting.cpp | 4 ++-- src/display/nr-filter-specularlighting.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index d48b6d690..fa925ceae 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -94,7 +94,7 @@ struct DiffusePointLight : public DiffuseLight { guint32 operator()(int x, int y) { NR::Fvector light; - _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + _light.light_vector(light, _x0 + x, _y0 + y, _scale * alphaAt(x, y)/255.0); return diffuseLighting(x, y, light, _light_components); } private: @@ -114,7 +114,7 @@ struct DiffuseSpotLight : public DiffuseLight { guint32 operator()(int x, int y) { NR::Fvector light, light_components; - _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + _light.light_vector(light, _x0 + x, _y0 + y, _scale * alphaAt(x, y)/255.0); _light.light_components(light_components, light); return diffuseLighting(x, y, light, light_components); } diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 758b28979..8ea99562e 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -103,7 +103,7 @@ struct SpecularPointLight : public SpecularLight { guint32 operator()(int x, int y) { NR::Fvector light, halfway; - _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + _light.light_vector(light, _x0 + x, _y0 + y, _scale * alphaAt(x, y)/255.0); NR::normalized_sum(halfway, light, NR::EYE_VECTOR); return specularLighting(x, y, halfway, _light_components); } @@ -125,7 +125,7 @@ struct SpecularSpotLight : public SpecularLight { guint32 operator()(int x, int y) { NR::Fvector light, halfway, light_components; - _light.light_vector(light, _x0 + x, _y0 + y, alphaAt(x, y)/255.0); + _light.light_vector(light, _x0 + x, _y0 + y, _scale * alphaAt(x, y)/255.0); _light.light_components(light_components, light); NR::normalized_sum(halfway, light, NR::EYE_VECTOR); return specularLighting(x, y, halfway, light_components); -- cgit v1.2.3 From b8b12192de28fabc232bcbedf9ab660a212956ab Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 12 Aug 2010 01:34:47 +0200 Subject: Fix bitmap opacity (bzr r9508.1.58) --- src/display/nr-arena-item.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index fe50f7753..adbf772bc 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -401,7 +401,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area bool needs_intermediate_rendering = false; bool &nir = needs_intermediate_rendering; - bool needs_opacity = (item->opacity != 255); + bool needs_opacity = (item->opacity != 255 && !item->render_opacity); // this item needs an intermediate rendering if: nir |= (item->mask != NULL); // 1. it has a mask @@ -453,7 +453,6 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area if (item->mask) { maskgroup.push_with_content(CAIRO_CONTENT_COLOR_ALPHA); // handle opacity of a masked object by composing it with the mask - // this uses 1/4 the memory of composing it with full rendering if (needs_opacity) { maskopacitygroup.push(); } -- cgit v1.2.3 From edd55c1c6905227f04900d3b257b5ae5ef6a3d9c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 12 Aug 2010 02:27:11 +0200 Subject: Fix the morphology filter (work on premultiplied colors) (bzr r9508.1.59) --- src/display/nr-filter-morphology.cpp | 61 +++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index 5be2c8b29..138674c27 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -38,15 +38,11 @@ enum MorphologyOp { namespace { -template guint32 extreme(guint32 a, guint32 b); -template <> guint32 extreme(guint32 a, guint32 b) { return std::min(a, b); } -template <> guint32 extreme(guint32 a, guint32 b) { return std::max(a, b); } - /* This performs one "half" of the morphology operation by calculating * the componentwise extreme in the specified axis with the given radius. * Performing the operation one axis at a time gives us a MASSIVE performance boost - * at large morphology radii. We can do this, because the morphology operation - * is separable just like Gaussian blur. */ + * at large morphology radii. Extreme of row extremes is equal to the extreme + * of components, so this doesn't change the result. */ template struct Morphology : public SurfaceSynth { Morphology(cairo_surface_t *in, double xradius) @@ -72,36 +68,37 @@ struct Morphology : public SurfaceSynth { ao = (OP == DILATE ? 0 : 0xff000000); for (int i = start; i < end; ++i) { guint32 px = (axis == Geom::X ? pixelAt(i, y) : pixelAt(x, i)); - ao = extreme(ao, px & 0xff000000); + if (OP == DILATE) { + if (px > ao) ao = px; + } else { + if (px < ao) ao = px; + } } return ao; } else { for (int i = start; i < end; ++i) { guint32 px = (axis == Geom::X ? pixelAt(i, y) : pixelAt(x, i)); EXTRACT_ARGB32(px, a,r,g,b); - if (a) { - r = unpremul_alpha(r, a); - g = unpremul_alpha(g, a); - b = unpremul_alpha(b, a); - - ao = extreme(ao, a); - ro = extreme(ro, r); - go = extreme(go, g); - bo = extreme(bo, b); + + // this will be compiled to conditional moves; + // the operator comparison will be evaluated at compile time. + // therefore there will be no branching in this loop + if (OP == DILATE) { + if (a > ao) ao = a; + if (r > ro) ro = r; + if (g > go) go = g; + if (b > bo) bo = b; } else { - if (OP == DILATE) { - continue; // zero pixel will not affect the maximum - } else { - // zero pixel is guaranteed to be the minimum - ao = 0; ro = 0; go = 0; bo = 0; - break; - } + if (a < ao) ao = a; + if (r < ro) ro = r; + if (g < go) go = g; + if (b < bo) bo = b; } + + // TODO: verify whether this check gives any speedup. + if (OP == ERODE && a == 0) break; } - ro = premul_alpha(ro, ao); - go = premul_alpha(go, ao); - bo = premul_alpha(bo, ao); ASSEMBLE_ARGB32(pxout, ao,ro,go,bo) return pxout; } @@ -116,6 +113,14 @@ void FilterMorphology::render_cairo(FilterSlot &slot) { cairo_surface_t *input = slot.getcairo(_input); + if (xradius == 0.0 || yradius == 0.0) { + // output is transparent black + cairo_surface_t *out = ink_cairo_surface_create_identical(input); + slot.set(_output, out); + cairo_surface_destroy(out); + return; + } + Geom::Matrix p2pb = slot.get_units().get_matrix_primitiveunits2pb(); double xr = xradius * p2pb.expansionX(); double yr = yradius * p2pb.expansionY(); @@ -144,8 +149,8 @@ void FilterMorphology::render_cairo(FilterSlot &slot) void FilterMorphology::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { - int const enlarge_x = (int)std::ceil(this->xradius * (std::fabs(trans[0]) + std::fabs(trans[1]))); - int const enlarge_y = (int)std::ceil(this->yradius * (std::fabs(trans[2]) + std::fabs(trans[3]))); + int enlarge_x = ceil(xradius * trans.expansionX()); + int enlarge_y = ceil(yradius * trans.expansionY()); area.x0 -= enlarge_x; area.x1 += enlarge_x; -- cgit v1.2.3 From baa16f58cf5472eaea112b9234b0324c8ca6ff7b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 12 Aug 2010 17:04:05 +0200 Subject: Fix computation of drawbox for filtered, rotated items (bzr r9508.1.60) --- src/display/nr-arena-item.cpp | 16 ++++++++----- src/display/nr-filter-gaussian.cpp | 13 +++++------ src/display/nr-filter.cpp | 48 +++++++++++--------------------------- src/display/nr-filter.h | 7 +++--- 4 files changed, 34 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index adbf772bc..ea162ca3d 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -265,12 +265,15 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, if (item->state & NR_ARENA_ITEM_STATE_INVALID) return item->state; - // get a copy of bbox - memcpy(&item->drawbox, &item->bbox, sizeof(item->bbox)); - /* Enlarge the drawbox to contain filter effects */ - if (item->filter && filter) { - item->filter->bbox_enlarge (item->drawbox); + if (item->filter && filter && item->item_bbox) { + item->drawbox.x0 = item->item_bbox->min()[Geom::X]; + item->drawbox.y0 = item->item_bbox->min()[Geom::Y]; + item->drawbox.x1 = item->item_bbox->max()[Geom::X]; + item->drawbox.y1 = item->item_bbox->max()[Geom::Y]; + item->filter->compute_drawbox (item, item->drawbox); + } else { + memcpy(&item->drawbox, &item->bbox, sizeof(item->bbox)); } // fixme: to fix the display glitches, in outline mode bbox must be a combination of // full item bbox and its clip and mask (after we have the API to get these) @@ -568,7 +571,8 @@ nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, if (((x + delta) >= item->bbox.x0) && ((x - delta) < item->bbox.x1) && - ((y + delta) >= item->bbox.y0) && ((y - delta) < item->bbox.y1)) { + ((y + delta) >= item->bbox.y0) && ((y - delta) < item->bbox.y1)) + { if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->pick) return ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> pick (item, p, delta, sticky); diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index f8a483acb..ba6f0bbe7 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -648,14 +648,13 @@ void FilterGaussian::area_enlarge(NRRectL &area, Geom::Matrix const &trans) area.y1 += area_max; } -bool FilterGaussian::can_handle_affine(Geom::Matrix const &m) +bool FilterGaussian::can_handle_affine(Geom::Matrix const &) { - if (Geom::are_near(_deviation_x, _deviation_y)) { - // TODO after 2Geom sync, change this to m.preservesAngles() - return Geom::are_near(m[0], m[3]) && Geom::are_near(m[1], -m[2]); - } else { - return false; - } + // Previously we tried to be smart and return true for rotations. + // However, the transform passed here is NOT the total transform + // from filter user space to screen. + // TODO: fix this, or replace can_handle_affine() with isotropic(). + return false; } void FilterGaussian::set_deviation(double deviation) diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index e163b6346..148b14f53 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -59,24 +59,6 @@ namespace Filters { using Geom::X; using Geom::Y; -static Geom::OptRect get_item_bbox(NRArenaItem const *item) { - Geom::Rect item_bbox; - if (item->item_bbox) { - item_bbox = *(item->item_bbox); - } else { - // Bounding box might not exist, so create a dummy one. - Geom::Point zero(0, 0); - item_bbox = Geom::Rect(zero, zero); - } - if (item_bbox.min()[X] > item_bbox.max()[X] - || item_bbox.min()[Y] > item_bbox.max()[Y]) - { - // In case of negative-size bbox, return an empty OptRect - return Geom::OptRect(); - } - return Geom::OptRect(item_bbox); -} - Filter::Filter() { _common_init(); @@ -134,19 +116,18 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea Geom::Rect item_bbox; { - Geom::OptRect maybe_bbox = get_item_bbox(item); + Geom::OptRect maybe_bbox = item->item_bbox; if (maybe_bbox.isEmpty()) { // Code below needs a bounding box return 1; } item_bbox = *maybe_bbox; } - - Geom::Rect filter_area = filter_effect_area(item_bbox); if (item_bbox.hasZeroArea()) { // It's no use to try and filter an empty object. return 1; } + Geom::Rect filter_area = filter_effect_area(item_bbox); FilterUnits units(_filter_units, _primitive_units); units.set_ctm(trans); @@ -225,7 +206,7 @@ void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { } Geom::Rect item_bbox; - Geom::OptRect maybe_bbox = get_item_bbox(item); + Geom::OptRect maybe_bbox = item->item_bbox; if (maybe_bbox.isEmpty()) { // Code below needs a bounding box return; @@ -245,30 +226,29 @@ void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { */ } -void Filter::bbox_enlarge(NRRectL &bbox) { +void Filter::compute_drawbox(NRArenaItem const *item, NRRectL &item_bbox) { // Modifying empty bounding boxes confuses rest of the renderer, so // let's not do that. - if (bbox.x0 > bbox.x1 || bbox.y0 > bbox.y1) return; + if (item_bbox.x0 > item_bbox.x1 || item_bbox.y0 > item_bbox.y1) return; - /* TODO: this is wrong. Should use bounding box in user coordinates - * and find its extents in display coordinates. */ - Geom::Point min(bbox.x0, bbox.y0); - Geom::Point max(bbox.x1, bbox.y1); + Geom::Point min(item_bbox.x0, item_bbox.y0); + Geom::Point max(item_bbox.x1, item_bbox.y1); Geom::Rect tmp_bbox(min, max); Geom::Rect enlarged = filter_effect_area(tmp_bbox); + enlarged = enlarged * item->ctm; - bbox.x0 = (NR::ICoord) floor(enlarged.min()[X]); - bbox.y0 = (NR::ICoord) floor(enlarged.min()[Y]); - bbox.x1 = (NR::ICoord) ceil(enlarged.max()[X]); - bbox.y1 = (NR::ICoord) ceil(enlarged.max()[Y]); + item_bbox.x0 = (NR::ICoord) floor(enlarged.min()[X]); + item_bbox.y0 = (NR::ICoord) floor(enlarged.min()[Y]); + item_bbox.x1 = (NR::ICoord) ceil(enlarged.max()[X]); + item_bbox.y1 = (NR::ICoord) ceil(enlarged.max()[Y]); } Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) { Geom::Point minp, maxp; - double len_x = bbox.max()[X] - bbox.min()[X]; - double len_y = bbox.max()[Y] - bbox.min()[Y]; + double len_x = bbox.width(); + double len_y = bbox.height(); /* TODO: fetch somehow the object ex and em lengths */ _region_x.update(12, 6, len_x); _region_y.update(12, 6, len_y); diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 9349ba9c6..b266ba053 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -151,10 +151,11 @@ public: */ void area_enlarge(NRRectL &area, NRArenaItem const *item) const; /** - * Given an object bounding box, this function enlarges it so that - * it contains the filter effect area. + * Given an item bounding box (in user coords), this function enlarges it + * to contain the filter effects region and transforms it to screen + * coordinates */ - void bbox_enlarge(NRRectL &bbox); + void compute_drawbox(NRArenaItem const *item, NRRectL &item_bbox); /** * Returns the filter effects area in user coordinate system. * The given bounding box should be a bounding box as specified in -- cgit v1.2.3 From e635a6a095e02eac6888e325fbe8ea22c41b541a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 12 Aug 2010 17:20:14 +0200 Subject: Do not un-premultiply alpha when computing mask luminance (bzr r9508.1.61) --- src/display/nr-arena-item.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index ea162ca3d..2aae21bf1 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -313,16 +313,12 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, struct MaskLuminanceToAlpha { guint32 operator()(guint32 in) { - // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 EXTRACT_ARGB32(in, a, r, g, b) - // unpremultiply color values - if (a != 0) { - r = unpremul_alpha(r, a); - g = unpremul_alpha(g, a); - b = unpremul_alpha(b, a); - } + // the operation of unpremul -> luminance-to-alpha -> multiply by alpha + // is equivalent to luminance-to-alpha on premultiplied color values + // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 guint32 ao = r*54 + g*182 + b*18; - return premul_alpha((ao + 127) / 255, a) << 24; + return ((ao + 127) / 255) << 24; } }; -- cgit v1.2.3 From 67a9706d3aff71597ac1d6d72e329b1a88d1d70e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 13 Aug 2010 00:13:20 +0200 Subject: Fix crash on empty patterns (bzr r9508.1.62) --- src/sp-pattern.cpp | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 8d156bc77..e211203d4 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -588,6 +588,35 @@ sp_pattern_create_pattern(SPPaintServer *ps, if (!visible) return NULL; + /* Show items */ + SPPattern *shown = NULL; + for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + // find the first one with item children + if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { + shown = pat_i; + break; // do not go further up the chain if children are found + } + } + + if (!shown) { + return cairo_pattern_create_rgba(0,0,0,0); + } + + /* Create arena */ + NRArena *arena = NRArena::create(); + unsigned int dkey = sp_item_display_key_new (1); + NRArenaGroup *root = NRArenaGroup::create(arena); + + for (SPObject *child = sp_object_first_child(SP_OBJECT(shown)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_ITEM (child)) { + // for each item in pattern, show it on our arena, add to the group, + // and connect to the release signal in case the item gets deleted + NRArenaItem *cai; + cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_SHOW_DISPLAY); + nr_arena_item_append_child (root, cai); + } + } + if (pat->viewBox_set) { gdouble tmp_x = pattern_width (pat) / (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0); gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0); @@ -604,30 +633,6 @@ sp_pattern_create_pattern(SPPaintServer *ps, } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; - /* Create arena */ - NRArena *arena = NRArena::create(); - unsigned int dkey = sp_item_display_key_new (1); - NRArenaGroup *root = NRArenaGroup::create(arena); - - /* Show items */ - SPPattern *shown = NULL; - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - // find the first one with item children - if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { - shown = pat_i; - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - if (SP_IS_ITEM (child)) { - // for each item in pattern, show it on our arena, add to the group, - // and connect to the release signal in case the item gets deleted - NRArenaItem *cai; - cai = sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_SHOW_DISPLAY); - nr_arena_item_append_child (root, cai); - } - } - break; // do not go further up the chain if children are found - } - } - double x = pattern_x(pat); double y = pattern_y(pat); double w = pattern_width(pat); -- cgit v1.2.3 From d1dbd5e4ca7917b5734a5cd011907176b311d158 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 14 Aug 2010 16:32:13 +0200 Subject: Fix glyph outlines to always consist of closed paths (bzr r9508.1.63) --- src/libnrtype/FontInstance.cpp | 175 +++++++++++++++++++---------------------- src/libnrtype/font-glyph.h | 1 - src/libnrtype/font-instance.h | 3 - 3 files changed, 79 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index a41f7d370..085cc6c88 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -21,6 +21,7 @@ #include FT_TRUETYPE_TABLES_H #include #include <2geom/pathvector.h> +#include <2geom/svg-path.h> #include "libnr/nr-rect.h" #include "libnrtype/font-glyph.h" #include "libnrtype/font-instance.h" @@ -102,11 +103,17 @@ bool font_style_equal::operator()(const font_style &a,const font_style &b) const /* * Outline extraction */ -typedef struct ft2_to_liv { - Path* theP; - double scale; - Geom::Point last; -} ft2_to_liv; + +struct FT2GeomData { + FT2GeomData(Geom::PathBuilder &b, double s) + : builder(b) + , last(0, 0) + , scale(s) + {} + Geom::PathBuilder &builder; + Geom::Point last; + double scale; +}; // Note: Freetype 2.2.1 redefined function signatures for functions to be placed in an // FT_Outline_Funcs structure. This is needed to keep backwards compatibility with the @@ -121,46 +128,46 @@ typedef FT_Vector FREETYPE_VECTOR; // outline as returned by freetype -> livarot Path // see nr-type-ft2.cpp for the freetype -> artBPath on which this code is based -static int ft2_move_to(FREETYPE_VECTOR *to, void * i_user) { - ft2_to_liv* user=(ft2_to_liv*)i_user; - Geom::Point p(user->scale*to->x,user->scale*to->y); +static int ft2_move_to(FREETYPE_VECTOR *to, void * i_user) +{ + FT2GeomData *user = (FT2GeomData*)i_user; + Geom::Point p(to->x, to->y); // printf("m t=%f %f\n",p[0],p[1]); - user->theP->MoveTo(p); - user->last=p; + user->builder.moveTo(p * user->scale); + user->last = p; return 0; } static int ft2_line_to(FREETYPE_VECTOR *to, void *i_user) { - ft2_to_liv* user=(ft2_to_liv*)i_user; - Geom::Point p(user->scale*to->x,user->scale*to->y); + FT2GeomData *user = (FT2GeomData*)i_user; + Geom::Point p(to->x, to->y); // printf("l t=%f %f\n",p[0],p[1]); - user->theP->LineTo(p); - user->last=p; + user->builder.lineTo(p * user->scale); + user->last = p; return 0; } static int ft2_conic_to(FREETYPE_VECTOR *control, FREETYPE_VECTOR *to, void *i_user) { - ft2_to_liv* user=(ft2_to_liv*)i_user; - Geom::Point p(user->scale*to->x,user->scale*to->y),c(user->scale*control->x,user->scale*control->y); + FT2GeomData *user = (FT2GeomData*)i_user; + Geom::Point p(to->x, to->y), c(control->x, control->y); + user->builder.quadTo(c * user->scale, p * user->scale); // printf("b c=%f %f t=%f %f\n",c[0],c[1],p[0],p[1]); - user->theP->BezierTo(p); - user->theP->IntermBezierTo(c); - user->theP->EndBezierTo(); - user->last=p; + user->last = p; return 0; } static int ft2_cubic_to(FREETYPE_VECTOR *control1, FREETYPE_VECTOR *control2, FREETYPE_VECTOR *to, void *i_user) { - ft2_to_liv* user=(ft2_to_liv*)i_user; - Geom::Point p(user->scale*to->x,user->scale*to->y); - Geom::Point c1(user->scale*control1->x,user->scale*control1->y); - Geom::Point c2(user->scale*control2->x,user->scale*control2->y); + FT2GeomData *user = (FT2GeomData*)i_user; + Geom::Point p(to->x, to->y); + Geom::Point c1(control1->x, control1->y); + Geom::Point c2(control2->x, control2->y); // printf("c c1=%f %f c2=%f %f t=%f %f\n",c1[0],c1[1],c2[0],c2[1],p[0],p[1]); - user->theP->CubicTo(p,3*(c1-user->last),3*(p-c2)); - user->last=p; + //user->theP->CubicTo(p,3*(c1-user->last),3*(p-c2)); + user->builder.curveTo(c1 * user->scale, c2 * user->scale, p * user->scale); + user->last = p; return 0; } #endif @@ -206,9 +213,6 @@ font_instance::~font_instance(void) theFace = 0; for (int i=0;i= maxGlyph ) { maxGlyph=2*nbGlyph+1; glyphs=(font_glyph*)realloc(glyphs,maxGlyph*sizeof(font_glyph)); } font_glyph n_g; - n_g.outline=NULL; n_g.pathvector=NULL; n_g.bbox[0]=n_g.bbox[1]=n_g.bbox[2]=n_g.bbox[3]=0; + n_g.h_advance = 0; + n_g.v_advance = 0; + n_g.h_width = 0; + n_g.v_width = 0; bool doAdd=false; #ifdef USE_PANGO_WIN32 @@ -516,7 +525,6 @@ void font_instance::LoadGlyph(int glyph_id) n_g.v_advance=otm.otmTextMetrics.tmHeight*scale; n_g.h_width=metrics.gmBlackBoxX*scale; n_g.v_width=metrics.gmBlackBoxY*scale; - n_g.outline=NULL; if ( bufferSize == GDI_ERROR) { // shit happened } else if ( bufferSize == 0) { @@ -528,14 +536,13 @@ void font_instance::LoadGlyph(int glyph_id) // shit happened } else { // Platform SDK is rubbish, read KB87115 instead - n_g.outline=new Path; DWORD polyOffset=0; while ( polyOffset < bufferSize ) { TTPOLYGONHEADER const *polyHeader=(TTPOLYGONHEADER const *)(buffer+polyOffset); if (polyOffset+polyHeader->cb > bufferSize) break; if (polyHeader->dwType == TT_POLYGON_TYPE) { - n_g.outline->MoveTo(pointfx_to_nrpoint(polyHeader->pfxStart, scale)); + path_builder.moveTo(pointfx_to_nrpoint(polyHeader->pfxStart, scale)); DWORD curveOffset=polyOffset+sizeof(TTPOLYGONHEADER); while ( curveOffset < polyOffset+polyHeader->cb ) { @@ -544,41 +551,32 @@ void font_instance::LoadGlyph(int glyph_id) POINTFX const *endp=p+polyCurve->cpfx; switch (polyCurve->wType) { - case TT_PRIM_LINE: - while ( p != endp ) - n_g.outline->LineTo(pointfx_to_nrpoint(*p++, scale)); - break; - - case TT_PRIM_QSPLINE: - { - g_assert(polyCurve->cpfx >= 2); - endp -= 2; - Geom::Point this_mid=pointfx_to_nrpoint(p[0], scale); - while ( p != endp ) { - Geom::Point next_mid=pointfx_to_nrpoint(p[1], scale); - n_g.outline->BezierTo((next_mid+this_mid)/2); - n_g.outline->IntermBezierTo(this_mid); - n_g.outline->EndBezierTo(); - ++p; - this_mid=next_mid; - } - n_g.outline->BezierTo(pointfx_to_nrpoint(p[1], scale)); - n_g.outline->IntermBezierTo(this_mid); - n_g.outline->EndBezierTo(); - break; + case TT_PRIM_LINE: + while ( p != endp ) + path_builder.lineTo(pointfx_to_nrpoint(*p++, scale)); + break; + + case TT_PRIM_QSPLINE: + g_assert(polyCurve->cpfx % 2 == 0); + while ( p != endp ) { + path_builder.quadTo(pointfx_to_nrpoint(p[0], scale), + pointfx_to_nrpoint(p[1], scale)); + p += 2; } - - case 3: // TT_PRIM_CSPLINE - g_assert(polyCurve->cpfx % 3 == 0); - while ( p != endp ) { - n_g.outline->CubicTo(pointfx_to_nrpoint(p[2], scale), pointfx_to_nrpoint(p[0], scale), pointfx_to_nrpoint(p[1], scale)); - p += 3; - } - break; + break; + + case 3: // TT_PRIM_CSPLINE + g_assert(polyCurve->cpfx % 3 == 0); + while ( p != endp ) { + path_builder.curveTo(pointfx_to_nrpoint(p[0], scale), + pointfx_to_nrpoint(p[1], scale), + pointfx_to_nrpoint(p[2], scale)); + p += 3; + } + break; } curveOffset += sizeof(TTPOLYCURVE)+sizeof(POINTFX)*(polyCurve->cpfx-1); } - n_g.outline->Close(); } polyOffset += polyHeader->cb; } @@ -610,21 +608,29 @@ void font_instance::LoadGlyph(int glyph_id) ft2_cubic_to, 0, 0 }; - n_g.outline=new Path; - ft2_to_liv tData; - tData.theP=n_g.outline; - tData.scale=1.0/((double)theFace->units_per_EM); - tData.last=Geom::Point(0,0); - FT_Outline_Decompose (&theFace->glyph->outline, &ft2_outline_funcs, &tData); + FT2GeomData user(path_builder, 1.0/((double)theFace->units_per_EM)); + FT_Outline_Decompose (&theFace->glyph->outline, &ft2_outline_funcs, &user); } doAdd=true; } #endif + path_builder.finish(); if ( doAdd ) { - if ( n_g.outline ) { - n_g.outline->FastBBox(n_g.bbox[0],n_g.bbox[1],n_g.bbox[2],n_g.bbox[3]); - n_g.pathvector=n_g.outline->MakePathVector(); + Geom::PathVector pv = path_builder.peek(); + // close all paths + for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { + i->close(); + } + if ( !pv.empty() ) { + n_g.pathvector = new Geom::PathVector(pv); + Geom::OptRect bounds = bounds_exact(*n_g.pathvector); + if (bounds) { + n_g.bbox[0] = bounds->left(); + n_g.bbox[1] = bounds->top(); + n_g.bbox[2] = bounds->right(); + n_g.bbox[3] = bounds->bottom(); + } } glyphs[nbGlyph]=n_g; id_to_no[glyph_id]=nbGlyph; @@ -720,29 +726,6 @@ Geom::OptRect font_instance::BBox(int glyph_id) } } -Path* font_instance::Outline(int glyph_id,Path* copyInto) -{ - int no = -1; - if ( id_to_no.find(glyph_id) == id_to_no.end() ) { - LoadGlyph(glyph_id); - if ( id_to_no.find(glyph_id) == id_to_no.end() ) { - // didn't load - } else { - no = id_to_no[glyph_id]; - } - } else { - no = id_to_no[glyph_id]; - } - if ( no < 0 ) return NULL; - Path *src_o = glyphs[no].outline; - if ( copyInto ) { - copyInto->Reset(); - copyInto->Copy(src_o); - return copyInto; - } - return src_o; -} - Geom::PathVector* font_instance::PathVector(int glyph_id) { int no = -1; diff --git a/src/libnrtype/font-glyph.h b/src/libnrtype/font-glyph.h index 234502f9d..14da5025b 100644 --- a/src/libnrtype/font-glyph.h +++ b/src/libnrtype/font-glyph.h @@ -11,7 +11,6 @@ struct font_glyph { double v_advance, v_width; double bbox[4]; // bbox of the path (and the artbpath), not the bbox of the glyph // as the fonts sometimes contain - Path* outline; // outline as a livarot Path Geom::PathVector* pathvector; // outline as 2geom pathvector, for text->curve stuff (should be unified with livarot) }; diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index e9bd291d2..392ac20bf 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -55,9 +55,6 @@ public: // nota: all coordinates returned by these functions are on a [0..1] scale; you need to multiply // by the fontsize to get the real sizes - Path* Outline(int glyph_id, Path *copyInto=NULL); - // queries the outline of the glyph (in livarot Path form), and copies it into copyInto instead - // of allocating a new Path if copyInto != NULL Geom::PathVector* PathVector(int glyph_id); // returns the 2geom-type pathvector for this glyph. no refcounting needed, it's deallocated when the font_instance dies double Advance(int glyph_id, bool vertical); -- cgit v1.2.3 From 5563199fbe57f3197b064acea2aac91d11f10544 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 14 Aug 2010 16:56:59 +0200 Subject: Fixes for guideline rendering (bzr r9508.1.64) --- src/display/guideline.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 9c68cd8af..6a9bebe1e 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -106,6 +106,8 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) cairo_save(buf->ct); cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); ink_cairo_set_source_rgba32(buf->ct, gl->rgba); + cairo_set_line_width(buf->ct, 1); + cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); if (gl->is_vertical()) { int position = (int) Inkscape::round(gl->point_on_line[Geom::X]); @@ -255,7 +257,7 @@ static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 /*rgba*/) { cairo_move_to(buf->ct, x0 + 0.5, y0 + 0.5); - cairo_line_to(buf->ct, x1 - 0.5, y1 - 0.5); + cairo_line_to(buf->ct, x1 + 0.5, y1 + 0.5); cairo_stroke(buf->ct); } -- cgit v1.2.3 From cdf48798b97e44f18d9fad2ef6bea70738da87f5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 14 Aug 2010 17:55:51 +0200 Subject: Fix background tracing in clone tiler dialog (bzr r9508.1.65) --- src/dialogs/clonetiler.cpp | 90 +++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 00557ad16..52832934c 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -18,35 +18,35 @@ #include "application/application.h" #include "application/editor.h" -#include "../desktop.h" -#include "../desktop-handles.h" +#include "desktop.h" +#include "desktop-handles.h" #include "dialog-events.h" +#include "display/cairo-templates.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" -#include "../document.h" -#include "../filter-chemistry.h" +#include "document.h" +#include "filter-chemistry.h" #include "helper/unit-menu.h" #include "helper/units.h" #include "helper/window.h" -#include "../inkscape.h" -#include "../interface.h" -#include "../macros.h" -#include "../message-stack.h" +#include "inkscape.h" +#include "interface.h" +#include "macros.h" +#include "message-stack.h" #include "preferences.h" -#include "../selection.h" -#include "../sp-filter.h" -#include "../sp-namedview.h" -#include "../sp-use.h" -#include "../style.h" +#include "selection.h" +#include "sp-filter.h" +#include "sp-namedview.h" +#include "sp-use.h" +#include "style.h" #include "svg/svg-color.h" #include "svg/svg.h" #include "ui/icon-names.h" #include "ui/widget/color-picker.h" #include "unclump.h" -#include "../verbs.h" +#include "verbs.h" #include "widgets/icon.h" #include "xml/repr.h" -#include "libnr/nr-pixblock.h" #define MIN_ONSCREEN_DISTANCE 50 @@ -893,54 +893,46 @@ clonetiler_trace_pick (Geom::Rect box) /* Item integer bbox in points */ NRRectL ibox; - ibox.x0 = (int) floor(trace_zoom * box[Geom::X].min() + 0.5); - ibox.y0 = (int) floor(trace_zoom * box[Geom::Y].min() + 0.5); - ibox.x1 = (int) floor(trace_zoom * box[Geom::X].max() + 0.5); - ibox.y1 = (int) floor(trace_zoom * box[Geom::Y].max() + 0.5); + ibox.x0 = floor(trace_zoom * box[Geom::X].min()); + ibox.y0 = floor(trace_zoom * box[Geom::Y].min()); + ibox.x1 = ceil(trace_zoom * box[Geom::X].max()); + ibox.y1 = ceil(trace_zoom * box[Geom::Y].max()); /* Find visible area */ int width = ibox.x1 - ibox.x0; int height = ibox.y1 - ibox.y0; - /* Set up pixblock */ - guchar *px = g_new(guchar, 4 * width * height); - - if (px == NULL) { - return 0; // buffer is too big or too small, cannot pick, so return 0 - } - - memset(px, 0x00, 4 * width * height); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + cairo_t *ct = cairo_create(s); /* Render */ - NRPixBlock pb; - nr_pixblock_setup_extern( &pb, NR_PIXBLOCK_MODE_R8G8B8A8N, - ibox.x0, ibox.y0, ibox.x1, ibox.y1, - px, 4 * width, FALSE, FALSE ); - nr_arena_item_invoke_render(NULL, trace_root, &ibox, &pb, + nr_arena_item_invoke_render(ct, trace_root, &ibox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); + cairo_surface_flush(s); + cairo_destroy(ct); double R = 0, G = 0, B = 0, A = 0; double count = 0; - double weight = 0; - - for (int y = ibox.y0; y < ibox.y1; y++) { - const unsigned char *s = NR_PIXBLOCK_PX (&pb) + (y - ibox.y0) * pb.rs; - for (int x = ibox.x0; x < ibox.x1; x++) { - count += 1; - weight += s[3] / 255.0; - R += s[0] / 255.0; - G += s[1] / 255.0; - B += s[2] / 255.0; - A += s[3] / 255.0; - s += 4; + + /* TODO convert this to OpenMP somehow */ + unsigned char *data = cairo_image_surface_get_data(s); + int stride = cairo_image_surface_get_stride(s); + for (int y=0; y < height; ++y, data += stride) { + for (int x=0; x < width; ++x) { + guint32 px = *reinterpret_cast(data + 4*x); + EXTRACT_ARGB32(px, a,r,g,b) + count += 1.0; + R += r / 255.0; + G += g / 255.0; + B += b / 255.0; + A += a / 255.0; } } + cairo_surface_destroy(s); - nr_pixblock_release(&pb); - - R = R / weight; - G = G / weight; - B = B / weight; + R = R / A; + G = G / A; + B = B / A; A = A / count; R = CLAMP (R, 0.0, 1.0); -- cgit v1.2.3 From 01fd769e29aa1738b1326d4a50a8f09a6665f242 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 14 Aug 2010 19:02:47 +0200 Subject: Fix paint bucket tool (bzr r9508.1.66) --- src/dialogs/clonetiler.cpp | 2 +- src/display/cairo-templates.h | 10 --- src/display/cairo-utils.h | 10 +++ src/flood-context.cpp | 150 ++++++++++++++++++++---------------------- 4 files changed, 84 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 52832934c..2be5b2ddc 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -21,7 +21,7 @@ #include "desktop.h" #include "desktop-handles.h" #include "dialog-events.h" -#include "display/cairo-templates.h" +#include "display/cairo-utils.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "document.h" diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 2b97dd6d6..a79f58548 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -676,16 +676,6 @@ pxclamp(gint32 v, gint32 low, gint32 high) { return v; } -#define EXTRACT_ARGB32(px,a,r,g,b) \ - guint32 a, r, g, b; \ - a = (px & 0xff000000) >> 24; \ - r = (px & 0x00ff0000) >> 16; \ - g = (px & 0x0000ff00) >> 8; \ - b = (px & 0x000000ff); - -#define ASSEMBLE_ARGB32(px,a,r,g,b) \ - guint32 px = (a << 24) | (r << 16) | (g << 8) | b; - #endif /* Local Variables: diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 0acdcb46a..aa441f0c5 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -121,6 +121,16 @@ unpremul_alpha(guint32 color, guint32 alpha) void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); +#define EXTRACT_ARGB32(px,a,r,g,b) \ + guint32 a, r, g, b; \ + a = (px & 0xff000000) >> 24; \ + r = (px & 0x00ff0000) >> 16; \ + g = (px & 0x0000ff00) >> 8; \ + b = (px & 0x000000ff); + +#define ASSEMBLE_ARGB32(px,a,r,g,b) \ + guint32 px = (a << 24) | (r << 16) | (g << 8) | b; + #endif /* Local Variables: diff --git a/src/flood-context.cpp b/src/flood-context.cpp index b67d180ff..dab0a33fa 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -52,8 +52,7 @@ #include "display/nr-arena.h" #include "display/nr-arena-image.h" #include "display/canvas-arena.h" -#include "libnr/nr-pixops.h" -#include "libnr/nr-pixblock.h" +#include "display/cairo-utils.h" #include <2geom/pathvector.h> #include "sp-item.h" #include "sp-root.h" @@ -199,22 +198,20 @@ static void sp_flood_context_setup(SPEventContext *ec) } } -/** - * \brief Merge a pixel with the background color. - * \param orig The pixel to merge with the background. - * \param bg The background color. - * \param base The pixel to merge the original and background into. - */ -inline static void -merge_pixel_with_background (unsigned char *orig, unsigned char *bg, - unsigned char *base) +inline static guint32 +compose_onto (guint32 px, guint32 bg) { - int precalc_bg_alpha = (255 * (255 - bg[3])) / 255; - - for (int i = 0; i < 3; i++) { - base[i] = precalc_bg_alpha + (bg[i] * bg[3]) / 255; - base[i] = (base[i] * (255 - orig[3])) / 255 + (orig[i] * orig[3]) / 255; - } + EXTRACT_ARGB32(px, ap,rp,gp,bp) + EXTRACT_ARGB32(bg, ab,rb,gb,bb) + guint32 ao,ro,bo,go; + + ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255; + ro = (255-ap)*rb + rp; ro = (ro + 127) / 255; + go = (255-ap)*gb + gp; go = (go + 127) / 255; + bo = (255-ap)*bb + bp; bo = (bo + 127) / 255; + + ASSEMBLE_ARGB32(pxout, ao,ro,go,bo) + return pxout; } /** @@ -222,10 +219,10 @@ merge_pixel_with_background (unsigned char *orig, unsigned char *bg, * \param px The pixel buffer. * \param x The X coordinate. * \param y The Y coordinate. - * \param width The width of the pixel buffer. + * \param stride The rowstride of the pixel buffer. */ -inline unsigned char * get_pixel(guchar *px, int x, int y, int width) { - return px + (x + y * width) * 4; +inline guint32 get_pixel(guchar *px, int x, int y, int stride) { + return *reinterpret_cast(px + y * stride + x * 4); } inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width) { @@ -273,34 +270,44 @@ GList * flood_autogap_dropdown_items_list() { * \param threshold The fill threshold. * \param method The fill method to use as defined in PaintBucketChannels. */ -static bool compare_pixels(unsigned char *check, unsigned char *orig, unsigned char *merged_orig_pixel, unsigned char *dtc, int threshold, PaintBucketChannels method) { +static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixel, guint32 dtc, int threshold, PaintBucketChannels method) +{ int diff = 0; - float hsl_check[3], hsl_orig[3]; - + float hsl_check[3] = {0,0,0}, hsl_orig[3] = {0,0,0}; + + EXTRACT_ARGB32(check, ac,rc,gc,bc) + EXTRACT_ARGB32(orig, ao,ro,go,bo) + EXTRACT_ARGB32(dtc, ad,rd,gd,bd) + EXTRACT_ARGB32(merged_orig_pixel, amop,rmop,gmop,bmop) + if ((method == FLOOD_CHANNELS_H) || (method == FLOOD_CHANNELS_S) || (method == FLOOD_CHANNELS_L)) { - sp_color_rgb_to_hsl_floatv(hsl_check, check[0] / 255.0, check[1] / 255.0, check[2] / 255.0); - sp_color_rgb_to_hsl_floatv(hsl_orig, orig[0] / 255.0, orig[1] / 255.0, orig[2] / 255.0); + double dac = ac; + double dao = ao; + sp_color_rgb_to_hsl_floatv(hsl_check, rc / dac, gc / dac, bc / dac); + sp_color_rgb_to_hsl_floatv(hsl_orig, ro / dao, go / dao, bo / dao); } switch (method) { case FLOOD_CHANNELS_ALPHA: - return ((int)abs(check[3] - orig[3]) <= threshold); + return abs(static_cast(ac) - ao) <= threshold; case FLOOD_CHANNELS_R: - return ((int)abs(check[0] - orig[0]) <= threshold); + return abs(static_cast(ac ? unpremul_alpha(rc, ac) : 0) - (ao ? unpremul_alpha(ro, ao) : 0)) <= threshold; case FLOOD_CHANNELS_G: - return ((int)abs(check[1] - orig[1]) <= threshold); + return abs(static_cast(ac ? unpremul_alpha(gc, ac) : 0) - (ao ? unpremul_alpha(go, ao) : 0)) <= threshold; case FLOOD_CHANNELS_B: - return ((int)abs(check[2] - orig[2]) <= threshold); + return abs(static_cast(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; case FLOOD_CHANNELS_RGB: - unsigned char merged_check[3]; - - merge_pixel_with_background(check, dtc, merged_check); - - for (int i = 0; i < 3; i++) { - diff += (int)abs(merged_check[i] - merged_orig_pixel[i]); - } + guint32 amc, rmc, bmc, gmc; + amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; + rmc = (255-ac)*rd + rc; rmc = (rmc + 127) / 255; + gmc = (255-ac)*gd + gc; gmc = (gmc + 127) / 255; + bmc = (255-ac)*bd + bc; bmc = (bmc + 127) / 255; + + diff += abs(static_cast(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0)); + diff += abs(static_cast(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0)); + diff += abs(static_cast(amc ? unpremul_alpha(bmc, amc) : 0) - (amop ? unpremul_alpha(bmop, amop) : 0)); return ((diff / 3) <= ((threshold * 3) / 4)); case FLOOD_CHANNELS_H: @@ -346,11 +353,12 @@ struct bitmap_coords_info { int y_limit; unsigned int width; unsigned int height; + unsigned int stride; unsigned int threshold; unsigned int radius; PaintBucketChannels method; - unsigned char *dtc; - unsigned char *merged_orig_pixel; + guint32 dtc; + guint32 merged_orig_pixel; Geom::Rect bbox; Geom::Rect screen; unsigned int max_queue_size; @@ -366,12 +374,12 @@ struct bitmap_coords_info { * \param orig_color The original selected pixel to use as the fill target color. * \param bci The bitmap_coords_info structure. */ -inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_t, int x, int y, unsigned char *orig_color, bitmap_coords_info bci) { +inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_t, int x, int y, guint32 orig_color, bitmap_coords_info bci) { if (is_pixel_paintability_checked(trace_t)) { return is_pixel_paintable(trace_t); } else { - unsigned char *t = get_pixel(px, x, y, bci.width); - if (compare_pixels(t, orig_color, bci.merged_orig_pixel, bci.dtc, bci.threshold, bci.method)) { + guint32 pixel = get_pixel(px, x, y, bci.stride); + if (compare_pixels(pixel, orig_color, bci.merged_orig_pixel, bci.dtc, bci.threshold, bci.method)) { mark_pixel_paintable(trace_t); return true; } else { @@ -550,7 +558,7 @@ inline static bool coords_in_range(unsigned int x, unsigned int y, bitmap_coords * \param bci The bitmap_coords_info structure. * \param original_point_trace_t The original pixel in the trace pixel buffer to check. */ -inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned char *original_point_trace_t) { +inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, guint32 orig_color, bitmap_coords_info bci, unsigned char *original_point_trace_t) { if (bci.radius == 0) { mark_pixel_colored(original_point_trace_t); return PAINT_DIRECTION_ALL; @@ -632,7 +640,7 @@ static void shift_point_onto_queue(std::deque *fill_queue, unsigned * \param orig_color The original selected pixel to use as the fill target color. * \param bci The bitmap_coords_info structure. */ -static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { +static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, guint32 orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { bool aborted = false; bool reached_screen_boundary = false; bool ok; @@ -816,37 +824,31 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even nr_arena_item_invoke_update(root, &final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); - guchar *px = g_new(guchar, 4 * width * height); - - NRPixBlock B; - nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, - final_bbox.x0, final_bbox.y0, final_bbox.x1, final_bbox.y1, - px, 4 * width, FALSE, FALSE ); + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); + guchar *px = g_new(guchar, stride * height); + cairo_surface_t *s = cairo_image_surface_create_for_data( + px, CAIRO_FORMAT_ARGB32, width, height, stride); + cairo_t *ct = cairo_create(s); + SPNamedView *nv = sp_desktop_namedview(desktop); - unsigned long bgcolor = nv->pagecolor; - - unsigned char dtc[4]; - dtc[0] = NR_RGBA32_R(bgcolor); - dtc[1] = NR_RGBA32_G(bgcolor); - dtc[2] = NR_RGBA32_B(bgcolor); - dtc[3] = NR_RGBA32_A(bgcolor); - - for (unsigned int fy = 0; fy < height; fy++) { - guchar *p = NR_PIXBLOCK_PX(&B) + fy * B.rs; - for (unsigned int fx = 0; fx < width; fx++) { - for (int i = 0; i < 4; i++) { - *p++ = dtc[i]; - } - } - } + guint32 bgcolor = nv->pagecolor; + // bgcolor is 0xrrggbbaa, we need 0xaarrggbb + guint32 dtc = (bgcolor >> 8) | (bgcolor << 24); - nr_arena_item_invoke_render(NULL, root, &final_bbox, &B, NR_ARENA_ITEM_RENDER_NO_CACHE ); - nr_pixblock_release(&B); + ink_cairo_set_source_rgba32(ct, bgcolor); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_OVER); + + nr_arena_item_invoke_render(ct, root, &final_bbox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); + + cairo_surface_flush(s); + cairo_destroy(ct); + cairo_surface_destroy(s); // Hide items sp_item_invoke_hide(SP_ITEM(sp_document_root(document)), dkey); - nr_object_unref((NRObject *) arena); guchar *trace_px = g_new(guchar, width * height); @@ -883,6 +885,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even bci.y_limit = y_limit; bci.width = width; bci.height = height; + bci.stride = stride; bci.threshold = threshold; bci.method = method; bci.bbox = *bbox; @@ -935,15 +938,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even int cx = (int)color_point[Geom::X]; int cy = (int)color_point[Geom::Y]; - unsigned char *orig_px = get_pixel(px, cx, cy, width); - unsigned char orig_color[4]; - for (int i = 0; i < 4; i++) { orig_color[i] = orig_px[i]; } - - unsigned char merged_orig[3]; - - merge_pixel_with_background(orig_color, dtc, merged_orig); - - bci.merged_orig_pixel = merged_orig; + guint32 orig_color = get_pixel(px, cx, cy, stride); + bci.merged_orig_pixel = compose_onto(orig_color, dtc); unsigned char *trace_t = get_trace_pixel(trace_px, cx, cy, width); if (!is_pixel_checked(trace_t) && !is_pixel_colored(trace_t)) { -- cgit v1.2.3 From aa844be794b36b44b624e579db7f0945b5d3927b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 14 Aug 2010 21:22:11 +0200 Subject: Completely remove NRPixBlock (bzr r9508.1.67) --- src/color-rgba.h | 11 +- src/dialogs/clonetiler.cpp | 32 +-- src/display/Makefile_insert | 4 - src/display/cairo-utils.cpp | 69 ++++- src/display/cairo-utils.h | 3 + src/display/canvas-arena.cpp | 17 +- src/display/canvas-arena.h | 8 +- src/display/canvas-axonomgrid.cpp | 1 - src/display/canvas-bpath.cpp | 10 - src/display/canvas-grid.cpp | 1 - src/display/canvas-text.cpp | 23 +- src/display/nr-light.cpp | 20 +- src/display/nr-plain-stuff-gdk.cpp | 46 ---- src/display/nr-plain-stuff-gdk.h | 32 --- src/display/nr-plain-stuff.cpp | 94 ------- src/display/nr-plain-stuff.h | 33 --- src/display/sodipodi-ctrl.cpp | 1 - src/display/sp-canvas-util.cpp | 1 - src/dropper-context.cpp | 74 ++---- src/dyna-draw-context.cpp | 22 +- src/file.cpp | 1 - src/helper/png-write.cpp | 17 +- src/libnr/Makefile_insert | 5 - src/libnr/nr-pixblock-pattern.cpp | 127 --------- src/libnr/nr-pixblock-pattern.h | 28 -- src/libnr/nr-pixblock.cpp | 457 --------------------------------- src/libnr/nr-pixblock.h | 103 -------- src/libnr/nr-pixops.h | 148 ----------- src/ui/cache/svg_preview_cache.cpp | 43 ++-- src/ui/dialog/filedialogimpl-win32.cpp | 6 +- src/ui/widget/color-preview.cpp | 31 ++- src/widgets/Makefile_insert | 2 - src/widgets/gradient-image.cpp | 1 - src/widgets/gradient-vector.cpp | 9 +- src/widgets/sp-color-preview.cpp | 211 --------------- src/widgets/sp-color-preview.h | 55 ---- 36 files changed, 193 insertions(+), 1553 deletions(-) delete mode 100644 src/display/nr-plain-stuff-gdk.cpp delete mode 100644 src/display/nr-plain-stuff-gdk.h delete mode 100644 src/display/nr-plain-stuff.cpp delete mode 100644 src/display/nr-plain-stuff.h delete mode 100644 src/libnr/nr-pixblock-pattern.cpp delete mode 100644 src/libnr/nr-pixblock-pattern.h delete mode 100644 src/libnr/nr-pixblock.cpp delete mode 100644 src/libnr/nr-pixblock.h delete mode 100644 src/libnr/nr-pixops.h delete mode 100644 src/widgets/sp-color-preview.cpp delete mode 100644 src/widgets/sp-color-preview.h (limited to 'src') diff --git a/src/color-rgba.h b/src/color-rgba.h index fc52b193d..8c21d5e52 100644 --- a/src/color-rgba.h +++ b/src/color-rgba.h @@ -14,7 +14,6 @@ #include // g_assert() #include -#include "libnr/nr-pixops.h" #include "decimal-round.h" /** @@ -56,12 +55,12 @@ public: TODO : maybe get rid of the NR_RGBA32_x C-style functions and replace the calls with the bitshifting they do */ - ColorRGBA(unsigned int intcolor) + ColorRGBA(guint32 intcolor) { - _c[0] = NR_RGBA32_R(intcolor)/255.0; - _c[1] = NR_RGBA32_G(intcolor)/255.0; - _c[2] = NR_RGBA32_B(intcolor)/255.0; - _c[3] = NR_RGBA32_A(intcolor)/255.0; + _c[0] = ((intcolor & 0xff000000) >> 24) / 255.0; + _c[1] = ((intcolor & 0x00ff0000) >> 16) / 255.0; + _c[2] = ((intcolor & 0x0000ff00) >> 8) / 255.0; + _c[3] = ((intcolor & 0x000000ff) >> 0) / 255.0; } diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 2be5b2ddc..3fe6b59e3 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -901,45 +901,17 @@ clonetiler_trace_pick (Geom::Rect box) /* Find visible area */ int width = ibox.x1 - ibox.x0; int height = ibox.y1 - ibox.y0; + double R = 0, G = 0, B = 0, A = 0; cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); cairo_t *ct = cairo_create(s); - /* Render */ nr_arena_item_invoke_render(ct, trace_root, &ibox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); - cairo_surface_flush(s); cairo_destroy(ct); - - double R = 0, G = 0, B = 0, A = 0; - double count = 0; - - /* TODO convert this to OpenMP somehow */ - unsigned char *data = cairo_image_surface_get_data(s); - int stride = cairo_image_surface_get_stride(s); - for (int y=0; y < height; ++y, data += stride) { - for (int x=0; x < width; ++x) { - guint32 px = *reinterpret_cast(data + 4*x); - EXTRACT_ARGB32(px, a,r,g,b) - count += 1.0; - R += r / 255.0; - G += g / 255.0; - B += b / 255.0; - A += a / 255.0; - } - } + ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); - R = R / A; - G = G / A; - B = B / A; - A = A / count; - - R = CLAMP (R, 0.0, 1.0); - G = CLAMP (G, 0.0, 1.0); - B = CLAMP (B, 0.0, 1.0); - A = CLAMP (A, 0.0, 1.0); - return SP_RGBA32_F_COMPOSE (R, G, B, A); } diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index a860c6a44..916dd6dc3 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -89,10 +89,6 @@ ink_common_sources += \ display/nr-light.cpp \ display/nr-light.h \ display/nr-light-types.h \ - display/nr-plain-stuff.cpp \ - display/nr-plain-stuff.h \ - display/nr-plain-stuff-gdk.cpp \ - display/nr-plain-stuff-gdk.h \ display/nr-style.cpp \ display/nr-style.h \ display/nr-svgfonts.cpp \ diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 96219e834..ed4de8afc 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -464,11 +464,76 @@ ink_cairo_surface_get_height(cairo_surface_t *surface) return cairo_image_surface_get_height(surface); } +static int ink_cairo_surface_average_color_internal(cairo_surface_t *surface, double &rf, double &gf, double &bf, double &af) +{ + rf = gf = bf = af = 0.0; + cairo_surface_flush(surface); + int width = cairo_image_surface_get_width(surface); + int height = cairo_image_surface_get_height(surface); + int stride = cairo_image_surface_get_stride(surface); + unsigned char *data = cairo_image_surface_get_data(surface); + + /* TODO convert this to OpenMP somehow */ + for (int y = 0; y < height; ++y, data += stride) { + for (int x = 0; x < width; ++x) { + guint32 px = *reinterpret_cast(data + 4*x); + EXTRACT_ARGB32(px, a,r,g,b) + rf += r / 255.0; + gf += g / 255.0; + bf += b / 255.0; + af += a / 255.0; + } + } + return width * height; +} + +guint32 ink_cairo_surface_average_color(cairo_surface_t *surface) +{ + double rf,gf,bf,af; + ink_cairo_surface_average_color_premul(surface, rf,gf,bf,af); + guint32 r = round(rf * 255); + guint32 g = round(gf * 255); + guint32 b = round(bf * 255); + guint32 a = round(af * 255); + ASSEMBLE_ARGB32(px, a,r,g,b); + return px; +} + +void ink_cairo_surface_average_color(cairo_surface_t *surface, double &r, double &g, double &b, double &a) +{ + int count = ink_cairo_surface_average_color_internal(surface, r,g,b,a); + + r /= a; + g /= a; + b /= a; + a /= count; + + r = CLAMP(r, 0.0, 1.0); + g = CLAMP(g, 0.0, 1.0); + b = CLAMP(b, 0.0, 1.0); + a = CLAMP(a, 0.0, 1.0); +} + +void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, double &g, double &b, double &a) +{ + int count = ink_cairo_surface_average_color_internal(surface, r,g,b,a); + + r /= count; + g /= count; + b /= count; + a /= count; + + r = CLAMP(r, 0.0, 1.0); + g = CLAMP(g, 0.0, 1.0); + b = CLAMP(b, 0.0, 1.0); + a = CLAMP(a, 0.0, 1.0); +} + cairo_pattern_t * ink_cairo_pattern_create_checkerboard() { - int const w = 8; - int const h = 8; + int const w = 6; + int const h = 6; cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 2*w, 2*h); diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index aa441f0c5..d563cfb75 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -95,6 +95,9 @@ cairo_surface_t *ink_cairo_surface_create_output(cairo_surface_t *image, cairo_s void ink_cairo_surface_blit(cairo_surface_t *src, cairo_surface_t *dest); int ink_cairo_surface_get_width(cairo_surface_t *surface); int ink_cairo_surface_get_height(cairo_surface_t *surface); +guint32 ink_cairo_surface_average_color(cairo_surface_t *surface); +void ink_cairo_surface_average_color(cairo_surface_t *surface, double &r, double &g, double &b, double &a); +void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, double &g, double &b, double &a); cairo_pattern_t *ink_cairo_pattern_create_checkerboard(); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 6f85573d1..f1355b9c4 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -21,7 +21,6 @@ #include "display/nr-arena-group.h" #include "display/canvas-arena.h" #include "display/cairo-utils.h" -#include "libnr/nr-pixblock.h" enum { ARENA_EVENT, @@ -358,22 +357,14 @@ sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky) } void -sp_canvas_arena_render_pixblock (SPCanvasArena *ca, NRPixBlock *pb) +sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRRectL const &r) { - NRRectL area; - g_return_if_fail (ca != NULL); g_return_if_fail (SP_IS_CANVAS_ARENA (ca)); - /* fixme: */ - pb->empty = FALSE; - - area.x0 = pb->area.x0; - area.y0 = pb->area.y0; - area.x1 = pb->area.x1; - area.y1 = pb->area.y1; - - nr_arena_item_invoke_render (NULL, ca->root, &area, pb, 0); + cairo_t *ct = cairo_create(surface); + nr_arena_item_invoke_render (ct, ca->root, &r, NULL, 0); + cairo_destroy(ct); } diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 34bc19946..df484197a 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -13,8 +13,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "../display/sp-canvas.h" -#include "nr-arena-item.h" +#include +#include <2geom/rect.h> +#include "display/sp-canvas.h" +#include "display/nr-arena-item.h" G_BEGIN_DECLS @@ -55,7 +57,7 @@ GtkType sp_canvas_arena_get_type (void); void sp_canvas_arena_set_pick_delta (SPCanvasArena *ca, gdouble delta); void sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky); -void sp_canvas_arena_render_pixblock (SPCanvasArena *ca, NRPixBlock *pb); +void sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRRectL const &area); G_END_DECLS diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 1383f7f4e..00a577635 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -28,7 +28,6 @@ #include "document.h" #include "helper/units.h" #include "inkscape.h" -#include "libnr/nr-pixops.h" #include "preferences.h" #include "sp-namedview.h" #include "sp-object.h" diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index ac2980de5..bd24881f7 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -21,22 +21,12 @@ #include "display/display-forward.h" #include "display/curve.h" #include "display/cairo-utils.h" -#include #include "helper/geom.h" #include #include #include -/** -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include - -#include -**/ - void nr_pixblock_render_bpath_rgba (Shape* theS,uint32_t color,NRRectL &area,char* destBuf,int stride); static void sp_canvas_bpath_class_init (SPCanvasBPathClass *klass); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 5dae228b4..b04dc4483 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -23,7 +23,6 @@ #include "document.h" #include "helper/units.h" #include "inkscape.h" -#include "libnr/nr-pixops.h" #include "preferences.h" #include "sp-namedview.h" #include "sp-object.h" diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 90f7c47c6..ab49d1fe3 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -13,20 +13,19 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + #include "display-forward.h" #include "sp-canvas-util.h" #include "canvas-text.h" #include "display/cairo-utils.h" -#include -#include #include "desktop.h" - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include - -#include +#include "color.h" static void sp_canvastext_class_init (SPCanvasTextClass *klass); static void sp_canvastext_init (SPCanvasText *canvastext); @@ -124,13 +123,11 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_font_size(buf->ct, cl->fontsize); cairo_text_path(buf->ct, cl->text); - cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(cl->rgba_stroke), SP_RGBA32_G_F(cl->rgba_stroke), SP_RGBA32_R_F(cl->rgba_stroke), SP_RGBA32_A_F(cl->rgba_stroke)); + ink_cairo_set_source_rgba32(buf->ct, cl->rgba_stroke); cairo_set_line_width (buf->ct, 2.0); cairo_stroke_preserve(buf->ct); - cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(cl->rgba), SP_RGBA32_G_F(cl->rgba), SP_RGBA32_R_F(cl->rgba), SP_RGBA32_A_F(cl->rgba)); + ink_cairo_set_source_rgba32(buf->ct, cl->rgba); cairo_fill(buf->ct); - - cairo_new_path(buf->ct); } static void diff --git a/src/display/nr-light.cpp b/src/display/nr-light.cpp index a3373aadb..3d441a8ec 100644 --- a/src/display/nr-light.cpp +++ b/src/display/nr-light.cpp @@ -13,12 +13,12 @@ #include -#include "libnr/nr-pixops.h" #include "display/nr-light.h" #include "display/nr-3dutils.h" #include "filters/distantlight.h" #include "filters/pointlight.h" #include "filters/spotlight.h" +#include "color.h" namespace Inkscape { namespace Filters { @@ -38,9 +38,9 @@ void DistantLight::light_vector(NR::Fvector &v) { } void DistantLight::light_components(NR::Fvector &lc) { - lc[LIGHT_RED] = NR_RGBA32_R(color); - lc[LIGHT_GREEN] = NR_RGBA32_G(color); - lc[LIGHT_BLUE] = NR_RGBA32_B(color); + lc[LIGHT_RED] = SP_RGBA32_R_U(color); + lc[LIGHT_GREEN] = SP_RGBA32_G_U(color); + lc[LIGHT_BLUE] = SP_RGBA32_B_U(color); } PointLight::PointLight(SPFePointLight *light, guint32 lighting_color, const Geom::Matrix &trans) { @@ -61,9 +61,9 @@ void PointLight::light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z) { } void PointLight::light_components(NR::Fvector &lc) { - lc[LIGHT_RED] = NR_RGBA32_R(color); - lc[LIGHT_GREEN] = NR_RGBA32_G(color); - lc[LIGHT_BLUE] = NR_RGBA32_B(color); + lc[LIGHT_RED] = SP_RGBA32_R_U(color); + lc[LIGHT_GREEN] = SP_RGBA32_G_U(color); + lc[LIGHT_BLUE] = SP_RGBA32_B_U(color); } SpotLight::SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Geom::Matrix &trans) { @@ -101,9 +101,9 @@ void SpotLight::light_components(NR::Fvector &lc, const NR::Fvector &L) { spmod = 0; else spmod = std::pow(spmod, speExp); - lc[LIGHT_RED] = spmod * NR_RGBA32_R(color); - lc[LIGHT_GREEN] = spmod * NR_RGBA32_G(color); - lc[LIGHT_BLUE] = spmod * NR_RGBA32_B(color); + lc[LIGHT_RED] = spmod * SP_RGBA32_R_U(color); + lc[LIGHT_GREEN] = spmod * SP_RGBA32_G_U(color); + lc[LIGHT_BLUE] = spmod * SP_RGBA32_B_U(color); } } /* namespace Filters */ diff --git a/src/display/nr-plain-stuff-gdk.cpp b/src/display/nr-plain-stuff-gdk.cpp deleted file mode 100644 index d5b43f4ea..000000000 --- a/src/display/nr-plain-stuff-gdk.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#define __NR_PLAIN_STUFF_GDK_C__ - -/* - * Miscellaneous simple rendering utilities - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001 Lauris Kaplinski and Ximian, Inc. - * - * Released under GNU GPL - */ - -#include -#include "nr-plain-stuff.h" -#include "nr-plain-stuff-gdk.h" - -void -nr_gdk_draw_rgba32_solid (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint w, gint h, guint32 rgba) -{ - NRPixBlock pb; - - nr_pixblock_setup_fast (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, 0, 0, w, h, FALSE); - - nr_render_rgba32_rgb (NR_PIXBLOCK_PX (&pb), w, h, pb.rs, x, y, rgba); - gdk_draw_rgb_image (drawable, gc, x, y, w, h, GDK_RGB_DITHER_MAX, NR_PIXBLOCK_PX (&pb), pb.rs); - - nr_pixblock_release (&pb); -} - -void -nr_gdk_draw_gray_garbage (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint w, gint h) -{ - for (gint yy = y; yy < y + h; yy += 64) { - for (gint xx = x; xx < x + w; xx += 64) { - NRPixBlock pb; - gint ex = MIN (xx + 64, x + w); - gint ey = MIN (yy + 64, y + h); - nr_pixblock_setup_fast (&pb, NR_PIXBLOCK_MODE_R8G8B8, xx, yy, ex, ey, FALSE); - nr_pixblock_render_gray_noise (&pb, NULL); - gdk_draw_rgb_image (drawable, gc, xx, yy, ex - xx, ey - yy, GDK_RGB_DITHER_NONE, NR_PIXBLOCK_PX (&pb), pb.rs); - nr_pixblock_release (&pb); - } - } -} - diff --git a/src/display/nr-plain-stuff-gdk.h b/src/display/nr-plain-stuff-gdk.h deleted file mode 100644 index 7c83792a8..000000000 --- a/src/display/nr-plain-stuff-gdk.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __NR_PLAIN_STUFF_GDK_H__ -#define __NR_PLAIN_STUFF_GDK_H__ - -/* - * Miscellaneous simple rendering utilities - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001 Lauris Kaplinski and Ximian, Inc. - * - * Released under GNU GPL - */ - -#include - -void nr_gdk_draw_rgba32_solid (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint w, gint h, guint32 rgba); - -void nr_gdk_draw_gray_garbage (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint w, gint h); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-plain-stuff.cpp b/src/display/nr-plain-stuff.cpp deleted file mode 100644 index 62a61102e..000000000 --- a/src/display/nr-plain-stuff.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#define __NR_PLAIN_STUFF_C__ - -/* - * Miscellaneous simple rendering utilities - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001 Lauris Kaplinski and Ximian, Inc. - * - * Released under GNU GPL - */ - -#include -#include -#include "nr-plain-stuff.h" - -#define NR_DEFAULT_CHECKERSIZEP2 2 -#define NR_DEFAULT_CHECKERCOLOR0 0xbfbfbfff -#define NR_DEFAULT_CHECKERCOLOR1 0x808080ff - -void -nr_render_checkerboard_rgb (guchar *px, gint w, gint h, gint rs, gint xoff, gint yoff) -{ - g_return_if_fail (px != NULL); - - nr_render_checkerboard_rgb_custom (px, w, h, rs, xoff, yoff, NR_DEFAULT_CHECKERCOLOR0, NR_DEFAULT_CHECKERCOLOR1, NR_DEFAULT_CHECKERSIZEP2); -} - -void -nr_render_checkerboard_rgb_custom (guchar *px, gint w, gint h, gint rs, gint xoff, gint yoff, guint32 c0, guint32 c1, gint sizep2) -{ - gint x, y, m; - guint r0, g0, b0; - guint r1, g1, b1; - - g_return_if_fail (px != NULL); - g_return_if_fail (sizep2 >= 0); - g_return_if_fail (sizep2 <= 8); - - xoff &= 0x1ff; - yoff &= 0x1ff; - m = 0x1 << sizep2; - r0 = NR_RGBA32_R (c0); - g0 = NR_RGBA32_G (c0); - b0 = NR_RGBA32_B (c0); - r1 = NR_RGBA32_R (c1); - g1 = NR_RGBA32_G (c1); - b1 = NR_RGBA32_B (c1); - - for (y = 0; y < h; y++) { - guchar *p; - p = px; - for (x = 0; x < w; x++) { - if (((x + xoff) ^ (y + yoff)) & m) { - *p++ = r0; - *p++ = g0; - *p++ = b0; - } else { - *p++ = r1; - *p++ = g1; - *p++ = b1; - } - } - px += rs; - } -} - -void -nr_render_rgba32_rgb (guchar *px, gint w, gint h, gint rs, gint xoff, gint yoff, guint32 c) -{ - guint32 c0, c1; - gint a, r, g, b, cr, cg, cb; - - g_return_if_fail (px != NULL); - - r = NR_RGBA32_R (c); - g = NR_RGBA32_G (c); - b = NR_RGBA32_B (c); - a = NR_RGBA32_A (c); - - cr = NR_COMPOSEN11_1111 (r, a, NR_RGBA32_R (NR_DEFAULT_CHECKERCOLOR0)); - cg = NR_COMPOSEN11_1111 (g, a, NR_RGBA32_G (NR_DEFAULT_CHECKERCOLOR0)); - cb = NR_COMPOSEN11_1111 (b, a, NR_RGBA32_B (NR_DEFAULT_CHECKERCOLOR0)); - c0 = (cr << 24) | (cg << 16) | (cb << 8) | 0xff; - - cr = NR_COMPOSEN11_1111 (r, a, NR_RGBA32_R (NR_DEFAULT_CHECKERCOLOR1)); - cg = NR_COMPOSEN11_1111 (g, a, NR_RGBA32_G (NR_DEFAULT_CHECKERCOLOR1)); - cb = NR_COMPOSEN11_1111 (b, a, NR_RGBA32_B (NR_DEFAULT_CHECKERCOLOR1)); - c1 = (cr << 24) | (cg << 16) | (cb << 8) | 0xff; - - nr_render_checkerboard_rgb_custom (px, w, h, rs, xoff, yoff, c0, c1, NR_DEFAULT_CHECKERSIZEP2); -} - diff --git a/src/display/nr-plain-stuff.h b/src/display/nr-plain-stuff.h deleted file mode 100644 index c568f38a6..000000000 --- a/src/display/nr-plain-stuff.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __NR_PLAIN_STUFF_H__ -#define __NR_PLAIN_STUFF_H__ - -/* - * Miscellaneous simple rendering utilities - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001 Lauris Kaplinski and Ximian, Inc. - * - * Released under GNU GPL - */ - -#include - -void nr_render_checkerboard_rgb (guchar *px, gint w, gint h, gint rs, gint xoff, gint yoff); -void nr_render_checkerboard_rgb_custom (guchar *px, gint w, gint h, gint rs, gint xoff, gint yoff, guint32 c0, guint32 c1, gint sizep2); - -void nr_render_rgba32_rgb (guchar *px, gint w, gint h, gint rs, gint xoff, gint yoff, guint32 c); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 37685c5da..28488e7c3 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -12,7 +12,6 @@ #include "sp-canvas-util.h" #include "display-forward.h" #include "sodipodi-ctrl.h" -#include "libnr/nr-pixops.h" #include "display/cairo-utils.h" enum { diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index 83604a1bf..1e7ba49ac 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -14,7 +14,6 @@ #include <2geom/matrix.h> -#include "libnr/nr-pixops.h" #include "sp-canvas-util.h" #include /* for memset */ diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 3898cd169..88d1c4561 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -26,6 +26,7 @@ #include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "display/curve.h" +#include "display/cairo-utils.h" #include "svg/svg-color.h" #include "color.h" #include "color-rgba.h" @@ -36,7 +37,6 @@ #include "desktop-handles.h" #include "selection.h" #include "document.h" -#include "libnr/nr-pixblock.h" #include "pixmaps/cursor-dropper.xpm" @@ -202,7 +202,7 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv // otherwise, constantly calculate color no matter is any button pressed or not double rw = 0.0; - double W(0), R(0), G(0), B(0), A(0); + double R(0), G(0), B(0), A(0); if (dc->dragging) { // calculate average @@ -222,56 +222,32 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv sp_canvas_item_show(dc->area); /* Get buffer */ - const int x0 = (int) floor(dc->centre[Geom::X] - rw); - const int y0 = (int) floor(dc->centre[Geom::Y] - rw); - const int x1 = (int) ceil(dc->centre[Geom::X] + rw); - const int y1 = (int) ceil(dc->centre[Geom::Y] + rw); - - if ((x1 > x0) && (y1 > y0)) { - NRPixBlock pb; - nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x0, y0, x1, y1, TRUE); - /* fixme: (Lauris) */ - sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), &pb); - for (int y = y0; y < y1; y++) { - const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs; - for (int x = x0; x < x1; x++) { - const double dx = x - dc->centre[Geom::X]; - const double dy = y - dc->centre[Geom::Y]; - const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw)); - W += w; - R += w * s[0]; - G += w * s[1]; - B += w * s[2]; - A += w * s[3]; - s += 4; - } - } - nr_pixblock_release(&pb); - - R = (R + 0.001) / (255.0 * W); - G = (G + 0.001) / (255.0 * W); - B = (B + 0.001) / (255.0 * W); - A = (A + 0.001) / (255.0 * W); - - R = CLAMP(R, 0.0, 1.0); - G = CLAMP(G, 0.0, 1.0); - B = CLAMP(B, 0.0, 1.0); - A = CLAMP(A, 0.0, 1.0); + Geom::Rect r(dc->centre, dc->centre); + r.expandBy(rw); + if (!r.hasZeroArea()) { + NRRectL area; + area.x0 = r[Geom::X].min(); + area.y0 = r[Geom::Y].min(); + area.x1 = r[Geom::X].max(); + area.y1 = r[Geom::Y].max(); + int w = area.x1 - area.x0; + int h = area.y1 - area.y0; + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); + ink_cairo_surface_average_color_premul(s, R, G, B, A); + cairo_surface_destroy(s); } - } else { // pick single pixel - NRPixBlock pb; - int x = (int) floor(event->button.x); - int y = (int) floor(event->button.y); - nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x, y, x+1, y+1, TRUE); - sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), &pb); - const unsigned char *s = NR_PIXBLOCK_PX(&pb); - - R = s[0] / 255.0; - G = s[1] / 255.0; - B = s[2] / 255.0; - A = s[3] / 255.0; + NRRectL area; + area.x0 = floor(event->button.x); + area.y0 = floor(event->button.y); + area.x1 = area.x0 + 1; + area.y1 = area.y0 + 1; + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); + sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); + ink_cairo_surface_average_color_premul(s, R, G, B, A); + cairo_surface_destroy(s); } if (pick == SP_DROPPER_PICK_VISIBLE) { diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index de6c151c3..468124bb7 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -34,6 +34,7 @@ #include "svg/svg.h" #include "display/canvas-bpath.h" +#include "display/cairo-utils.h" #include <2geom/isnan.h> #include <2geom/pathvector.h> #include <2geom/bezier-utils.h> @@ -62,7 +63,6 @@ #include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "livarot/Shape.h" -#include "libnr/nr-pixblock.h" #include "dyna-draw-context.h" @@ -438,16 +438,16 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc) double trace_thick = 1; if (dc->trace_bg) { // pick single pixel - NRPixBlock pb; - int x = (int) floor(brush_w[Geom::X]); - int y = (int) floor(brush_w[Geom::Y]); - nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x, y, x+1, y+1, TRUE); - sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(SP_EVENT_CONTEXT(dc)->desktop)), &pb); - const unsigned char *s = NR_PIXBLOCK_PX(&pb); - double R = s[0] / 255.0; - double G = s[1] / 255.0; - double B = s[2] / 255.0; - double A = s[3] / 255.0; + double R, G, B, A; + NRRectL area; + area.x0 = floor(brush_w[Geom::X]); + area.y0 = floor(brush_w[Geom::Y]); + area.x1 = area.x0 + 1; + area.y1 = area.y0 + 1; + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); + sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(SP_EVENT_CONTEXT(dc)->desktop)), s, area); + ink_cairo_surface_average_color_premul(s, R, G, B, A); + cairo_surface_destroy(s); double max = MAX (MAX (R, G), B); double min = MIN (MIN (R, G), B); double L = A * (max + min)/2 + (1 - A); // blend with white bg diff --git a/src/file.cpp b/src/file.cpp index 50fcd3642..b6bc4c876 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "application/application.h" #include "application/editor.h" diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 437c39649..20870086a 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -17,8 +17,6 @@ #endif #include "interface.h" -#include "libnr/nr-pixops.h" -#include "libnr/nr-pixblock.h" #include <2geom/rect.h> #include #include @@ -479,15 +477,12 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, ebp.status = status; ebp.data = data; - bool write_status; - if ((width < 256) || ((width * height) < 32768)) { - ebp.px = nr_pixelstore_64K_new(FALSE, 0); - ebp.sheight = 65536 / (4 * width); - write_status = sp_png_write_rgba_striped(doc, filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp); - nr_pixelstore_64K_free(ebp.px); - } else { - ebp.sheight = 64; - ebp.px = g_try_new(guchar, 4 * ebp.sheight * width); + bool write_status = false;; + + ebp.sheight = 64; + ebp.px = g_try_new(guchar, 4 * ebp.sheight * width); + + if (ebp.px) { write_status = sp_png_write_rgba_striped(doc, filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp); g_free(ebp.px); } diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 2da8e36fb..1027e0600 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -10,11 +10,6 @@ ink_common_sources += \ libnr/nr-macros.h \ libnr/nr-object.cpp \ libnr/nr-object.h \ - libnr/nr-pixblock-pattern.cpp \ - libnr/nr-pixblock-pattern.h \ - libnr/nr-pixblock.cpp \ - libnr/nr-pixblock.h \ - libnr/nr-pixops.h \ libnr/nr-point-fns.cpp \ libnr/nr-point-fns.h \ libnr/nr-point-l.h \ diff --git a/src/libnr/nr-pixblock-pattern.cpp b/src/libnr/nr-pixblock-pattern.cpp deleted file mode 100644 index aa3246297..000000000 --- a/src/libnr/nr-pixblock-pattern.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#define __NR_PIXBLOCK_PATTERN_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - - -#include -#include "nr-pixops.h" -#include "nr-pixblock-pattern.h" - -#define NR_NOISE_SIZE 1024 - -void -nr_pixblock_render_gray_noise (NRPixBlock *pb, NRPixBlock *mask) -{ - static unsigned char *noise = NULL; - static unsigned int seed = 0; - unsigned int v; - NRRectL clip; - int x, y, bpp; - - if (mask) { - if (mask->empty) return; - nr_rect_l_intersect (&clip, &pb->area, &mask->area); - if (nr_rect_l_test_empty(clip)) return; - } else { - clip = pb->area; - } - - if (!noise) { - int i; - noise = g_new (unsigned char, NR_NOISE_SIZE); - for (i = 0; i < NR_NOISE_SIZE; i++) noise[i] = (rand () / (RAND_MAX >> 8)) & 0xff; - } - - bpp = NR_PIXBLOCK_BPP (pb); - - v = (rand () / (RAND_MAX >> 8)) & 0xff; - - if (mask) { - for (y = clip.y0; y < clip.y1; y++) { - unsigned char *d, *m; - d = NR_PIXBLOCK_PX (pb) + (y - pb->area.y0) * pb->rs + (clip.x0 - pb->area.x0) * bpp; - m = NR_PIXBLOCK_PX (mask) + (y - mask->area.y0) * pb->rs + (clip.x0 - mask->area.x0); - for (x = clip.x0; x < clip.x1; x++) { - v = v ^ noise[seed]; - switch (pb->mode) { - case NR_PIXBLOCK_MODE_A8: - d[0] = NR_COMPOSEA_111(m[0], d[0]); - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = NR_COMPOSEN11_1111 (v, m[0], d[0]); - d[1] = NR_COMPOSEN11_1111 (v, m[0], d[1]); - d[2] = NR_COMPOSEN11_1111 (v, m[0], d[2]); - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - if (m[0] != 0) { - unsigned int ca; - ca = NR_COMPOSEA_112(m[0], d[3]); - d[0] = NR_COMPOSENNN_111121 (v, m[0], d[0], d[3], ca); - d[1] = NR_COMPOSENNN_111121 (v, m[0], d[1], d[3], ca); - d[2] = NR_COMPOSENNN_111121 (v, m[0], d[2], d[3], ca); - d[3] = NR_NORMALIZE_21(ca); - } - break; - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = NR_COMPOSENPP_1111 (v, m[0], d[0]); - d[1] = NR_COMPOSENPP_1111 (v, m[0], d[1]); - d[2] = NR_COMPOSENPP_1111 (v, m[0], d[2]); - d[3] = NR_COMPOSEA_111(d[3], m[0]); - break; - default: - break; - } - d += bpp; - m += 1; - if (++seed >= NR_NOISE_SIZE) { - int i; - i = (rand () / (RAND_MAX / NR_NOISE_SIZE)) % NR_NOISE_SIZE; - noise[i] ^= v; - seed = i % (NR_NOISE_SIZE >> 2); - } - } - } - } else { - for (y = clip.y0; y < clip.y1; y++) { - unsigned char *d; - d = NR_PIXBLOCK_PX (pb) + (y - pb->area.y0) * pb->rs + (clip.x0 - pb->area.x0) * bpp; - for (x = clip.x0; x < clip.x1; x++) { - v = v ^ noise[seed]; - switch (pb->mode) { - case NR_PIXBLOCK_MODE_A8: - d[0] = 255; - break; - case NR_PIXBLOCK_MODE_R8G8B8: - d[0] = v; - d[1] = v; - d[2] = v; - break; - case NR_PIXBLOCK_MODE_R8G8B8A8N: - case NR_PIXBLOCK_MODE_R8G8B8A8P: - d[0] = v; - d[1] = v; - d[2] = v; - d[3] = 255; - default: - break; - } - d += bpp; - if (++seed >= NR_NOISE_SIZE) { - int i; - i = (rand () / (RAND_MAX / NR_NOISE_SIZE)) % NR_NOISE_SIZE; - noise[i] ^= v; - seed = i % (NR_NOISE_SIZE >> 2); - } - } - } - } - - pb->empty = 0; -} diff --git a/src/libnr/nr-pixblock-pattern.h b/src/libnr/nr-pixblock-pattern.h deleted file mode 100644 index 463a24379..000000000 --- a/src/libnr/nr-pixblock-pattern.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __NR_PIXBLOCK_PATTERN_H__ -#define __NR_PIXBLOCK_PATTERN_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -void nr_pixblock_render_gray_noise (NRPixBlock *pb, NRPixBlock *mask); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-pixblock.cpp b/src/libnr/nr-pixblock.cpp deleted file mode 100644 index 6b2b12b7b..000000000 --- a/src/libnr/nr-pixblock.cpp +++ /dev/null @@ -1,457 +0,0 @@ -#define __NR_PIXBLOCK_C__ - -/** \file - * \brief Allocation/Setup of NRPixBlock objects. Pixel store functions. - * - * Authors: - * (C) 1999-2002 Lauris Kaplinski - * 2008, Jasper van de Gronde - * - * This code is in the Public Domain - */ - -#include -#include -#include -#include -#include "nr-pixblock.h" - -/// Size of buffer that needs no allocation (default 4). -#define NR_TINY_MAX sizeof (unsigned char *) - -/** - * Pixbuf initialisation using homegrown memory handling ("pixelstore"). - * - * Pixbuf sizes are differentiated into tiny, <4K, <16K, <64K, and more, - * with each type having its own method of memory handling. After allocating - * memory, the buffer is cleared if the clear flag is set. Intended to - * reduce memory fragmentation. - * \param pb Pointer to the pixbuf struct. - * \param mode Indicates grayscale/RGB/RGBA. - * \param clear True if buffer should be cleared. - * \pre x1>=x0 && y1>=y0 && pb!=NULL - */ -void -nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) -{ - int w, h, bpp; - size_t size; - - w = x1 - x0; - h = y1 - y0; - bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4; - - size = bpp * w * h; - - if (size <= NR_TINY_MAX) { - pb->size = NR_PIXBLOCK_SIZE_TINY; - if (clear) memset (pb->data.p, 0x0, size); - } else if (size <= 4096) { - pb->size = NR_PIXBLOCK_SIZE_4K; - pb->data.px = nr_pixelstore_4K_new (clear, 0x0); - } else if (size <= 16384) { - pb->size = NR_PIXBLOCK_SIZE_16K; - pb->data.px = nr_pixelstore_16K_new (clear, 0x0); - } else if (size <= 65536) { - pb->size = NR_PIXBLOCK_SIZE_64K; - pb->data.px = nr_pixelstore_64K_new (clear, 0x0); - } else if (size <= 262144) { - pb->size = NR_PIXBLOCK_SIZE_256K; - pb->data.px = nr_pixelstore_256K_new (clear, 0x0); - } else if (size <= 1048576) { - pb->size = NR_PIXBLOCK_SIZE_1M; - pb->data.px = nr_pixelstore_1M_new (clear, 0x0); - } else { - pb->size = NR_PIXBLOCK_SIZE_BIG; - pb->data.px = NULL; - if (size > 100000000) { // Don't even try to allocate more than 100Mb (5000x5000 RGBA - // pixels). It'll just bog the system down even if successful. FIXME: - // Can anyone suggest something better than the magic number? - g_warning ("%lu bytes requested for pixel buffer, I won't try to allocate that.", (long unsigned) size); - return; - } - pb->data.px = g_try_new (unsigned char, size); - if (pb->data.px == NULL) { // memory allocation failed - g_warning ("Could not allocate %lu bytes for pixel buffer!", (long unsigned) size); - return; - } - if (clear) memset (pb->data.px, 0x0, size); - } - - pb->mode = mode; - pb->empty = 1; - pb->visible_area.x0 = pb->area.x0 = x0; - pb->visible_area.y0 = pb->area.y0 = y0; - pb->visible_area.x1 = pb->area.x1 = x1; - pb->visible_area.y1 = pb->area.y1 = y1; - pb->rs = bpp * w; -} - -/** - * Pixbuf initialisation using g_new. - * - * After allocating memory, the buffer is cleared if the clear flag is set. - * \param pb Pointer to the pixbuf struct. - * \param mode Indicates grayscale/RGB/RGBA. - * \param clear True if buffer should be cleared. - * \pre x1>=x0 && y1>=y0 && pb!=NULL - FIXME: currently unused except for nr_pixblock_new and pattern tiles, replace with _fast and delete? - */ -void -nr_pixblock_setup (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) -{ - int w, h, bpp; - size_t size; - - w = x1 - x0; - h = y1 - y0; - bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4; - - size = bpp * w * h; - - if (size <= NR_TINY_MAX) { - pb->size = NR_PIXBLOCK_SIZE_TINY; - if (clear) memset (pb->data.p, 0x0, size); - } else { - pb->size = NR_PIXBLOCK_SIZE_BIG; - pb->data.px = g_new (unsigned char, size); - if (clear) memset (pb->data.px, 0x0, size); - } - - pb->mode = mode; - pb->empty = 1; - pb->visible_area.x0 = pb->area.x0 = x0; - pb->visible_area.y0 = pb->area.y0 = y0; - pb->visible_area.x1 = pb->area.x1 = x1; - pb->visible_area.y1 = pb->area.y1 = y1; - pb->rs = bpp * w; -} - -/** - * Pixbuf initialisation with preset values. - * - * After copying all parameters into the NRPixBlock struct, the pixel buffer is cleared if the clear flag is set. - * \param pb Pointer to the pixbuf struct. - * \param mode Indicates grayscale/RGB/RGBA. - * \param clear True if buffer should be cleared. - * \pre x1>=x0 && y1>=y0 && pb!=NULL - */ -void -nr_pixblock_setup_extern (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, unsigned char *px, int rs, bool empty, bool clear) -{ - int w, bpp; - - w = x1 - x0; - bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4; - - pb->size = NR_PIXBLOCK_SIZE_STATIC; - pb->mode = mode; - pb->empty = empty; - pb->visible_area.x0 = pb->area.x0 = x0; - pb->visible_area.y0 = pb->area.y0 = y0; - pb->visible_area.x1 = pb->area.x1 = x1; - pb->visible_area.y1 = pb->area.y1 = y1; - pb->data.px = px; - pb->rs = rs; - - g_assert (pb->data.px != NULL); - if (clear) { - if (rs == bpp * w) { - /// \todo How do you recognise if - /// px was an uncleared tiny buffer? - if (pb->data.px) - memset (pb->data.px, 0x0, bpp * (y1 - y0) * w); - } else { - int y; - for (y = y0; y < y1; y++) { - memset (pb->data.px + (y - y0) * rs, 0x0, bpp * w); - } - } - } -} - -/** - * Frees memory taken by pixel data in NRPixBlock. - * \param pb Pointer to pixblock. - * \pre pb and pb->data.px point to valid addresses. - * - * According to pb->size, one of the functions for freeing the pixelstore - * is called. May be called regardless of how pixbuf was set up. - */ -void -nr_pixblock_release (NRPixBlock *pb) -{ - switch (pb->size) { - case NR_PIXBLOCK_SIZE_TINY: - break; - case NR_PIXBLOCK_SIZE_4K: - nr_pixelstore_4K_free (pb->data.px); - break; - case NR_PIXBLOCK_SIZE_16K: - nr_pixelstore_16K_free (pb->data.px); - break; - case NR_PIXBLOCK_SIZE_64K: - nr_pixelstore_64K_free (pb->data.px); - break; - case NR_PIXBLOCK_SIZE_256K: - nr_pixelstore_256K_free (pb->data.px); - break; - case NR_PIXBLOCK_SIZE_1M: - nr_pixelstore_1M_free (pb->data.px); - break; - case NR_PIXBLOCK_SIZE_BIG: - g_free (pb->data.px); - break; - case NR_PIXBLOCK_SIZE_STATIC: - break; - default: - break; - } -} - -/** - * Allocates NRPixBlock and sets it up. - * - * \return Pointer to fresh pixblock. - * Calls g_new() and nr_pixblock_setup(). -FIXME: currently unused, delete? JG: Should be used more often! (To simplify memory management.) - */ -NRPixBlock * -nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) -{ - NRPixBlock *pb; - - pb = g_new (NRPixBlock, 1); - if (!pb) return 0; - - nr_pixblock_setup (pb, mode, x0, y0, x1, y1, clear); - if (pb->size!=NR_PIXBLOCK_SIZE_TINY && !pb->data.px) { - g_free(pb); - return 0; - } - - return pb; -} - -/** - * Allocates NRPixBlock and sets it up. - * - * \return Pointer to fresh pixblock. - * Calls g_new() and nr_pixblock_setup(). - */ -NRPixBlock * -nr_pixblock_new_fast (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) -{ - NRPixBlock *pb; - - pb = g_new (NRPixBlock, 1); - if (!pb) return 0; - - nr_pixblock_setup_fast (pb, mode, x0, y0, x1, y1, clear); - if (pb->size!=NR_PIXBLOCK_SIZE_TINY && !pb->data.px) { - g_free(pb); - return 0; - } - - return pb; -} - -/** - * Frees all memory taken by pixblock. - * - * \return NULL - */ -NRPixBlock * -nr_pixblock_free (NRPixBlock *pb) -{ - nr_pixblock_release (pb); - - g_free (pb); - - return NULL; -} - -/* PixelStore operations */ - -#define NR_4K_BLOCK 32 -static unsigned char **nr_4K_px = NULL; -static unsigned int nr_4K_len = 0; -static unsigned int nr_4K_size = 0; - -unsigned char * -nr_pixelstore_4K_new (bool clear, unsigned char val) -{ - unsigned char *px; - - if (nr_4K_len != 0) { - nr_4K_len -= 1; - px = nr_4K_px[nr_4K_len]; - } else { - px = g_new (unsigned char, 4096); - } - - if (clear) memset (px, val, 4096); - - return px; -} - -void -nr_pixelstore_4K_free (unsigned char *px) -{ - if (nr_4K_len == nr_4K_size) { - nr_4K_size += NR_4K_BLOCK; - nr_4K_px = g_renew (unsigned char *, nr_4K_px, nr_4K_size); - } - - nr_4K_px[nr_4K_len] = px; - nr_4K_len += 1; -} - -#define NR_16K_BLOCK 32 -static unsigned char **nr_16K_px = NULL; -static unsigned int nr_16K_len = 0; -static unsigned int nr_16K_size = 0; - -unsigned char * -nr_pixelstore_16K_new (bool clear, unsigned char val) -{ - unsigned char *px; - - if (nr_16K_len != 0) { - nr_16K_len -= 1; - px = nr_16K_px[nr_16K_len]; - } else { - px = g_new (unsigned char, 16384); - } - - if (clear) memset (px, val, 16384); - - return px; -} - -void -nr_pixelstore_16K_free (unsigned char *px) -{ - if (nr_16K_len == nr_16K_size) { - nr_16K_size += NR_16K_BLOCK; - nr_16K_px = g_renew (unsigned char *, nr_16K_px, nr_16K_size); - } - - nr_16K_px[nr_16K_len] = px; - nr_16K_len += 1; -} - -#define NR_64K_BLOCK 32 -static unsigned char **nr_64K_px = NULL; -static unsigned int nr_64K_len = 0; -static unsigned int nr_64K_size = 0; - -unsigned char * -nr_pixelstore_64K_new (bool clear, unsigned char val) -{ - unsigned char *px; - - if (nr_64K_len != 0) { - nr_64K_len -= 1; - px = nr_64K_px[nr_64K_len]; - } else { - px = g_new (unsigned char, 65536); - } - - if (clear) memset (px, val, 65536); - - return px; -} - -void -nr_pixelstore_64K_free (unsigned char *px) -{ - if (nr_64K_len == nr_64K_size) { - nr_64K_size += NR_64K_BLOCK; - nr_64K_px = g_renew (unsigned char *, nr_64K_px, nr_64K_size); - } - - nr_64K_px[nr_64K_len] = px; - nr_64K_len += 1; -} - -#define NR_256K_BLOCK 32 -#define NR_256K 262144 -static unsigned char **nr_256K_px = NULL; -static unsigned int nr_256K_len = 0; -static unsigned int nr_256K_size = 0; - -unsigned char * -nr_pixelstore_256K_new (bool clear, unsigned char val) -{ - unsigned char *px; - - if (nr_256K_len != 0) { - nr_256K_len -= 1; - px = nr_256K_px[nr_256K_len]; - } else { - px = g_new (unsigned char, NR_256K); - } - - if (clear) memset (px, val, NR_256K); - - return px; -} - -void -nr_pixelstore_256K_free (unsigned char *px) -{ - if (nr_256K_len == nr_256K_size) { - nr_256K_size += NR_256K_BLOCK; - nr_256K_px = g_renew (unsigned char *, nr_256K_px, nr_256K_size); - } - - nr_256K_px[nr_256K_len] = px; - nr_256K_len += 1; -} - -#define NR_1M_BLOCK 32 -#define NR_1M 1048576 -static unsigned char **nr_1M_px = NULL; -static unsigned int nr_1M_len = 0; -static unsigned int nr_1M_size = 0; - -unsigned char * -nr_pixelstore_1M_new (bool clear, unsigned char val) -{ - unsigned char *px; - - if (nr_1M_len != 0) { - nr_1M_len -= 1; - px = nr_1M_px[nr_1M_len]; - } else { - px = g_new (unsigned char, NR_1M); - } - - if (clear) memset (px, val, NR_1M); - - return px; -} - -void -nr_pixelstore_1M_free (unsigned char *px) -{ - if (nr_1M_len == nr_1M_size) { - nr_1M_size += NR_1M_BLOCK; - nr_1M_px = g_renew (unsigned char *, nr_1M_px, nr_1M_size); - } - - nr_1M_px[nr_1M_len] = px; - nr_1M_len += 1; -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-pixblock.h b/src/libnr/nr-pixblock.h deleted file mode 100644 index cedc2ad3d..000000000 --- a/src/libnr/nr-pixblock.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __NR_PIXBLOCK_H__ -#define __NR_PIXBLOCK_H__ - -/** \file - * \brief Pixel block structure. Used for low-level rendering. - * - * Authors: - * (C) 1999-2002 Lauris Kaplinski - * (C) 2005 Ralf Stephan (some cleanup) - * - * This code is in the Public Domain. - */ - -#include -#include - -/// Size indicator. Hardcoded to max. 3 bits. -typedef enum { - NR_PIXBLOCK_SIZE_TINY, ///< Fits in (unsigned char *) - NR_PIXBLOCK_SIZE_4K, ///< Pixelstore - NR_PIXBLOCK_SIZE_16K, ///< Pixelstore - NR_PIXBLOCK_SIZE_64K, ///< Pixelstore - NR_PIXBLOCK_SIZE_256K, ///< Pixelstore - NR_PIXBLOCK_SIZE_1M, ///< Pixelstore - NR_PIXBLOCK_SIZE_BIG, ///< Normally allocated - NR_PIXBLOCK_SIZE_STATIC ///< Externally managed -} NR_PIXBLOCK_SIZE; - -/// Mode indicator. Hardcoded to max. 2 bits. -typedef enum { - NR_PIXBLOCK_MODE_A8, ///< Grayscale - NR_PIXBLOCK_MODE_R8G8B8, ///< 8 bit RGB - NR_PIXBLOCK_MODE_R8G8B8A8N, ///< Normal 8 bit RGBA - NR_PIXBLOCK_MODE_R8G8B8A8P ///< Premultiplied 8 bit RGBA -} NR_PIXBLOCK_MODE; - -/// The pixel block struct. -struct NRPixBlock { - NR_PIXBLOCK_SIZE size : 3; ///< Size indicator - NR_PIXBLOCK_MODE mode : 2; ///< Mode indicator - bool empty : 1; ///< Empty flag - unsigned int rs; ///< Size of line in bytes - NRRectL area; - NRRectL visible_area; - union { - unsigned char *px; ///< Pointer to buffer - unsigned char p[sizeof (unsigned char *)]; ///< Tiny buffer - } data; -}; - -/// Returns number of bytes per pixel (1, 3, or 4). -inline int -NR_PIXBLOCK_BPP (NRPixBlock *pb) -{ - return ((pb->mode == NR_PIXBLOCK_MODE_A8) ? 1 : - (pb->mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4); -} - -/// Returns pointer to pixel data. -inline unsigned char* -NR_PIXBLOCK_PX (NRPixBlock *pb) -{ - return ((pb->size == NR_PIXBLOCK_SIZE_TINY) ? - pb->data.p : pb->data.px); -} -inline unsigned char const* -NR_PIXBLOCK_PX (NRPixBlock const *pb) -{ - return ((pb->size == NR_PIXBLOCK_SIZE_TINY) ? - pb->data.p : pb->data.px); -} - -void nr_pixblock_setup (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear); -void nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear); -void nr_pixblock_setup_extern (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, unsigned char *px, int rs, bool empty, bool clear); -void nr_pixblock_release (NRPixBlock *pb); - -NRPixBlock *nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear); -NRPixBlock *nr_pixblock_new_fast (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear); -NRPixBlock *nr_pixblock_free (NRPixBlock *pb); - -unsigned char *nr_pixelstore_4K_new (bool clear, unsigned char val); -void nr_pixelstore_4K_free (unsigned char *px); -unsigned char *nr_pixelstore_16K_new (bool clear, unsigned char val); -void nr_pixelstore_16K_free (unsigned char *px); -unsigned char *nr_pixelstore_64K_new (bool clear, unsigned char val); -void nr_pixelstore_64K_free (unsigned char *px); -unsigned char *nr_pixelstore_256K_new (bool clear, unsigned char val); -void nr_pixelstore_256K_free (unsigned char *px); -unsigned char *nr_pixelstore_1M_new (bool clear, unsigned char val); -void nr_pixelstore_1M_free (unsigned char *px); - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-pixops.h b/src/libnr/nr-pixops.h deleted file mode 100644 index 7eafd1a9d..000000000 --- a/src/libnr/nr-pixops.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef __NR_PIXOPS_H__ -#define __NR_PIXOPS_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * bulia byak - * - * This code is in public domain - */ - -#define NR_RGBA32_R(v) (unsigned char) (((v) >> 24) & 0xff) -#define NR_RGBA32_G(v) (unsigned char) (((v) >> 16) & 0xff) -#define NR_RGBA32_B(v) (unsigned char) (((v) >> 8) & 0xff) -#define NR_RGBA32_A(v) (unsigned char) ((v) & 0xff) - -// FAST_DIVIDE assumes that 0<=num<=256*denom -// (this covers the case that num=255*denom+denom/2, which is used by DIV_ROUND) -template static inline unsigned int FAST_DIVIDE(unsigned int v) { return v/divisor; } -template<> inline unsigned int FAST_DIVIDE<255>(unsigned int v) { return ((v+1)*0x101) >> 16; } -template<> inline unsigned int FAST_DIVIDE<255*255>(unsigned int v) { v=(v+1)<<1; v=v+(v>>7)+((v*0x3)>>16)+(v>>22); return (v>>16)>>1; } -// FAST_DIV_ROUND assumes that 0<=num<=255*denom (DIV_ROUND should work upto num=2^32-1-(denom/2), -// but FAST_DIVIDE_BY_255 already fails at num=65790=258*255, which is not too far above 255.5*255) -template static inline unsigned int FAST_DIV_ROUND(unsigned int v) { return FAST_DIVIDE(v+(divisor)/2); } -static inline unsigned int DIV_ROUND(unsigned int v, unsigned int divisor) { return (v+divisor/2)/divisor; } - -#define INK_COMPOSE(f,a,b) ( ( ((guchar) (b)) * ((guchar) (0xff - (a))) + ((guchar) (((b) ^ ~(f)) + (b)/4 - ((b)>127? 63 : 0))) * ((guchar) (a)) ) >>8) - -// Naming: OPb_i+o -// OP = operation, for example: NORMALIZE, COMPOSEA, COMPOSENNN, PREMUL, etc. -// i+o = range of input/output as powers of 2^8-1 -// for example, 213 means 0<=a<=255^2, 0<=b<=255, 0<=output<=255^3 - -// Normalize -static inline unsigned int NR_NORMALIZE_11(unsigned int v) { return v; } -static inline unsigned int NR_NORMALIZE_21(unsigned int v) { return FAST_DIV_ROUND<255>(v); } -static inline unsigned int NR_NORMALIZE_31(unsigned int v) { return FAST_DIV_ROUND<255*255>(v); } -static inline unsigned int NR_NORMALIZE_41(unsigned int v) { return FAST_DIV_ROUND<255*255*255>(v); } - -// Compose alpha channel using (1 - (1-a)*(1-b)) -// Note that these can also be rewritten to NR_COMPOSENPP(255, a, b), slightly slower, but could help if someone -// decides to use SSE or something similar (for allowing the four components to be treated the same way). -static inline unsigned int NR_COMPOSEA_213(unsigned int a, unsigned int b) { return 255*255*255 - (255*255-a)*(255-b); } -static inline unsigned int NR_COMPOSEA_112(unsigned int a, unsigned int b) { return 255*255 - (255-a)*(255-b); } -static inline unsigned int NR_COMPOSEA_211(unsigned int a, unsigned int b) { return NR_NORMALIZE_31(NR_COMPOSEA_213(a, b)); } -static inline unsigned int NR_COMPOSEA_111(unsigned int a, unsigned int b) { return NR_NORMALIZE_21(NR_COMPOSEA_112(a, b)); } - -// Operation: (1 - fa) * bc * ba + fa * fc -static inline unsigned int NR_COMPOSENNP_12114(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255*255 - fa) * ba * bc + 255 * fa * fc; } -static inline unsigned int NR_COMPOSENNP_11113(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255 - fa) * ba * bc + 255 * fa * fc; } -static inline unsigned int NR_COMPOSENNP_11111(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return NR_NORMALIZE_31(NR_COMPOSENNP_11113(fc, fa, bc, ba)); } - -// Operation: (1 - fa) * bc * ba + fc -static inline unsigned int NR_COMPOSEPNP_32114(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255*255 - fa) * ba * bc + 255 * fc; } -static inline unsigned int NR_COMPOSEPNP_22114(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255*255 - fa) * ba * bc + 255*255 * fc; } -static inline unsigned int NR_COMPOSEPNP_11113(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return (255 - fa) * ba * bc + 255*255 * fc; } -static inline unsigned int NR_COMPOSEPNP_22111(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return NR_NORMALIZE_41(NR_COMPOSEPNP_22114(fc, fa, bc, ba)); } -static inline unsigned int NR_COMPOSEPNP_11111(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba) { return NR_NORMALIZE_31(NR_COMPOSEPNP_11113(fc, fa, bc, ba)); } - -// Operation: ((1 - fa) * bc * ba + fa * fc)/a -// Reuses non-normalized versions of NR_COMPOSENNP -static inline unsigned int NR_COMPOSENNN_121131(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSENNP_12114(fc, fa, bc, ba), a); } -static inline unsigned int NR_COMPOSENNN_111121(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSENNP_11113(fc, fa, bc, ba), a); } - -// Operation: ((1 - fa) * bc * ba + fc)/a -// Reuses non-normalized versions of NR_COMPOSEPNP -static inline unsigned int NR_COMPOSEPNN_321131(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSEPNP_32114(fc, fa, bc, ba), a); } -static inline unsigned int NR_COMPOSEPNN_221131(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSEPNP_22114(fc, fa, bc, ba), a); } -static inline unsigned int NR_COMPOSEPNN_111121(unsigned int fc, unsigned int fa, unsigned int bc, unsigned int ba, unsigned int a) { return DIV_ROUND(NR_COMPOSEPNP_11113(fc, fa, bc, ba), a); } - -// Operation: (1 - fa) * bc + fa * fc -// (1-fa)*bc+fa*fc = bc-fa*bc+fa*fc = bc+fa*(fc-bc) -// For some reason it's faster to leave the initial 255*bc term in the non-normalized version instead of factoring it out... -static inline unsigned int NR_COMPOSENPP_1213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*bc + fa*(fc-bc); } -static inline unsigned int NR_COMPOSENPP_1123(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*bc + fa*(255*fc-bc); } -static inline unsigned int NR_COMPOSENPP_1112(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*bc + fa*(fc-bc); } -static inline unsigned int NR_COMPOSENPP_1211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSENPP_1213(fc, fa, bc)); } -static inline unsigned int NR_COMPOSENPP_1121(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSENPP_1123(fc, fa, bc)); } -static inline unsigned int NR_COMPOSENPP_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21(NR_COMPOSENPP_1112(fc, fa, bc)); } - -// Operation: (1 - fa) * bc + fc -// (1-fa)*bc+fc = bc-fa*bc+fc = (bc+fc)-fa*bc -// This rewritten form results in faster code (found out through testing) -static inline unsigned int NR_COMPOSEPPP_2224(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*(bc+fc) - fa*bc; } // Note that this can temporarily overflow (but it probably doesn't cause problems) - // NR_COMPOSEPPP_2224 assumes that fa and fc have a common component (fa=a*x and fc=c*x), because then the maximum value is: - // (255*255-255*x)*255*255 + 255*x*255*255 = 255*255*( (255*255-255*x) + 255*x ) = 255*255*255*( (255-x)+x ) = 255*255*255*255 -static inline unsigned int NR_COMPOSEPPP_3213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*bc + fc - fa*bc; } -static inline unsigned int NR_COMPOSEPPP_2213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*(255*bc+fc) - fa*bc; } -static inline unsigned int NR_COMPOSEPPP_1213(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*255*(bc+fc) - fa*bc; } -static inline unsigned int NR_COMPOSEPPP_1112(unsigned int fc, unsigned int fa, unsigned int bc) { return 255*(bc+fc) - fa*bc; } -static inline unsigned int NR_COMPOSEPPP_2221(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_41(NR_COMPOSEPPP_2224(fc, fa, bc)); } -static inline unsigned int NR_COMPOSEPPP_3211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSEPPP_3213(fc, fa, bc)); } -static inline unsigned int NR_COMPOSEPPP_2211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_31(NR_COMPOSEPPP_2213(fc, fa, bc)); } -static inline unsigned int NR_COMPOSEPPP_1211(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21(NR_COMPOSEPPP_1213(fc, fa, bc)); } -static inline unsigned int NR_COMPOSEPPP_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21(NR_COMPOSEPPP_1112(fc, fa, bc)); } - -#define NR_COMPOSEN11_1211 NR_COMPOSENPP_1211 -#define NR_COMPOSEN11_1111 NR_COMPOSENPP_1111 -//inline unsigned int NR_COMPOSEN11_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21((255 - fa) * bc + fa * fc ); } - -#define NR_COMPOSEP11_2211 NR_COMPOSEPPP_2211 -#define NR_COMPOSEP11_1211 NR_COMPOSEPPP_1211 -#define NR_COMPOSEP11_1111 NR_COMPOSEPPP_1111 -//inline unsigned int NR_COMPOSEP11_1111(unsigned int fc, unsigned int fa, unsigned int bc) { return NR_NORMALIZE_21((255 - fa) * bc + fc * 255); } - -// Premultiply using c*a -static inline unsigned int NR_PREMUL_134(unsigned int c, unsigned int a) { return c * a; } -static inline unsigned int NR_PREMUL_224(unsigned int c, unsigned int a) { return c * a; } -static inline unsigned int NR_PREMUL_123(unsigned int c, unsigned int a) { return c * a; } -static inline unsigned int NR_PREMUL_112(unsigned int c, unsigned int a) { return c * a; } -static inline unsigned int NR_PREMUL_314(unsigned int c, unsigned int a) { return NR_PREMUL_134(c, a); } -static inline unsigned int NR_PREMUL_213(unsigned int c, unsigned int a) { return NR_PREMUL_123(c, a); } -static inline unsigned int NR_PREMUL_131(unsigned int c, unsigned int a) { return NR_NORMALIZE_41(NR_PREMUL_134(c, a)); } -static inline unsigned int NR_PREMUL_221(unsigned int c, unsigned int a) { return NR_NORMALIZE_41(NR_PREMUL_224(c, a)); } -static inline unsigned int NR_PREMUL_121(unsigned int c, unsigned int a) { return NR_NORMALIZE_31(NR_PREMUL_123(c, a)); } -static inline unsigned int NR_PREMUL_111(unsigned int c, unsigned int a) { return NR_NORMALIZE_21(NR_PREMUL_112(c, a)); } -static inline unsigned int NR_PREMUL_311(unsigned int c, unsigned int a) { return NR_NORMALIZE_41(NR_PREMUL_314(c, a)); } -static inline unsigned int NR_PREMUL_211(unsigned int c, unsigned int a) { return NR_NORMALIZE_31(NR_PREMUL_213(c, a)); } - -// Demultiply using c/a -static inline unsigned int NR_DEMUL_131(unsigned int c, unsigned int a) { return DIV_ROUND(255 * 255 * 255 * c, a); } -static inline unsigned int NR_DEMUL_231(unsigned int c, unsigned int a) { return DIV_ROUND(255 * 255 * c, a); } -static inline unsigned int NR_DEMUL_121(unsigned int c, unsigned int a) { return DIV_ROUND(255 * 255 * c, a); } -static inline unsigned int NR_DEMUL_331(unsigned int c, unsigned int a) { return DIV_ROUND(255 * c, a); } -static inline unsigned int NR_DEMUL_221(unsigned int c, unsigned int a) { return DIV_ROUND(255 * c, a); } -static inline unsigned int NR_DEMUL_111(unsigned int c, unsigned int a) { return DIV_ROUND(255 * c, a); } -static inline unsigned int NR_DEMUL_431(unsigned int c, unsigned int a) { return DIV_ROUND(c, a); } -static inline unsigned int NR_DEMUL_321(unsigned int c, unsigned int a) { return DIV_ROUND(c, a); } -static inline unsigned int NR_DEMUL_211(unsigned int c, unsigned int a) { return DIV_ROUND(c, a); } -static inline unsigned int NR_DEMUL_421(unsigned int c, unsigned int a) { return DIV_ROUND(c, 255 * a); } -static inline unsigned int NR_DEMUL_311(unsigned int c, unsigned int a) { return DIV_ROUND(c, 255 * a); } -static inline unsigned int NR_DEMUL_411(unsigned int c, unsigned int a) { return DIV_ROUND(c, 255 * 255 * a); } - - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index d4c8d0d0c..aead24236 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -28,7 +28,7 @@ #include "document-private.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" -#include "libnr/nr-pixblock.h" +#include "display/cairo-utils.h" #include "ui/cache/svg_preview_cache.h" @@ -45,10 +45,10 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rec /* Item integer bbox in points */ NRRectL ibox; - ibox.x0 = (int) floor(scale_factor * dbox.min()[Geom::X] + 0.5); - ibox.y0 = (int) floor(scale_factor * dbox.min()[Geom::Y] + 0.5); - ibox.x1 = (int) floor(scale_factor * dbox.max()[Geom::X] + 0.5); - ibox.y1 = (int) floor(scale_factor * dbox.max()[Geom::Y] + 0.5); + ibox.x0 = floor(scale_factor * dbox.min()[Geom::X]); + ibox.y0 = floor(scale_factor * dbox.min()[Geom::Y]); + ibox.x1 = ceil(scale_factor * dbox.max()[Geom::X]); + ibox.y1 = ceil(scale_factor * dbox.max()[Geom::Y]); /* Find visible area */ int width = ibox.x1 - ibox.x0; @@ -64,34 +64,23 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rec area.x1 = area.x0 + psize; area.y1 = area.y0 + psize; - /* Actual renderable area */ - NRRectL ua; - ua.x0 = std::max(ibox.x0, area.x0); - ua.y0 = std::max(ibox.y0, area.y0); - ua.x1 = std::min(ibox.x1, area.x1); - ua.y1 = std::min(ibox.y1, area.y1); - - /* Set up pixblock */ - guchar *px = g_new(guchar, 4 * psize * psize); - memset(px, 0x00, 4 * psize * psize); - /* Render */ - NRPixBlock B; - nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, - ua.x0, ua.y0, ua.x1, ua.y1, - px + 4 * psize * (ua.y0 - area.y0) + - 4 * (ua.x0 - area.x0), - 4 * psize, FALSE, FALSE ); - nr_arena_item_invoke_render(NULL, root, &ua, &B, + cairo_surface_t *s = cairo_image_surface_create( + CAIRO_FORMAT_ARGB32, psize, psize); + cairo_t *ct = cairo_create(s); + + nr_arena_item_invoke_render(ct, root, &area, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); - nr_pixblock_release(&B); + cairo_surface_flush(s); + cairo_destroy(ct); - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(px, + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, TRUE, - 8, psize, psize, psize * 4, - (GdkPixbufDestroyNotify)g_free, + 8, psize, psize, cairo_image_surface_get_stride(s), + (GdkPixbufDestroyNotify)cairo_surface_destroy, NULL); + convert_pixbuf_argb32_to_normal(pixbuf); return pixbuf; } diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 7b96f2a9e..cd9db2fac 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -33,7 +33,6 @@ #include "extension/output.h" #include "extension/db.h" -#include "libnr/nr-pixops.h" #include "display/nr-arena-item.h" #include "display/nr-arena.h" #include "sp-item.h" @@ -882,6 +881,10 @@ void FileOpenDialogImplWin32::free_preview() bool FileOpenDialogImplWin32::set_svg_preview() { + return false; + // NOTE: it's not worth the effort to fix this to use Cairo. + // Native file dialogs are unmaintainable and should be removed anyway. + #if 0 const int PreviewSize = 512; gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string, @@ -980,6 +983,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() _mutex->unlock(); return true; + #endif } void FileOpenDialogImplWin32::destroy_svg_rendering(const guint8 *buffer) diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index add596444..a4212c7ba 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -11,8 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-plain-stuff-gdk.h" -#include "color-preview.h" +#include "ui/widget/color-preview.h" +#include "display/cairo-utils.h" #define SPCP_DEFAULT_WIDTH 32 #define SPCP_DEFAULT_HEIGHT 12 @@ -76,6 +76,9 @@ ColorPreview::paint (GdkRectangle *area) if (!gdk_rectangle_intersect (area, &warea, &wpaint)) return; + GtkWidget *widget = GTK_WIDGET(this->gobj()); + cairo_t *ct = gdk_cairo_create(widget->window); + /* Transparent area */ w2 = warea.width / 2; @@ -86,11 +89,15 @@ ColorPreview::paint (GdkRectangle *area) carea.height = warea.height; if (gdk_rectangle_intersect (area, &carea, &cpaint)) { - nr_gdk_draw_rgba32_solid (get_window()->gobj(), - get_style()->get_black_gc()->gobj(), - cpaint.x, cpaint.y, - cpaint.width, cpaint.height, - _rgba); + cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard(); + + cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height); + cairo_set_source(ct, checkers); + cairo_fill_preserve(ct); + ink_cairo_set_source_rgba32(ct, _rgba); + cairo_fill(ct); + + cairo_pattern_destroy(checkers); } /* Solid area */ @@ -101,12 +108,12 @@ ColorPreview::paint (GdkRectangle *area) carea.height = warea.height; if (gdk_rectangle_intersect (area, &carea, &cpaint)) { - nr_gdk_draw_rgba32_solid (get_window()->gobj(), - get_style()->get_black_gc()->gobj(), - cpaint.x, cpaint.y, - cpaint.width, cpaint.height, - _rgba | 0xff); + cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height); + ink_cairo_set_source_rgba32(ct, _rgba | 0xff); + cairo_fill(ct); } + + cairo_destroy(ct); } }}} diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert index 313e27528..968bbf073 100644 --- a/src/widgets/Makefile_insert +++ b/src/widgets/Makefile_insert @@ -42,8 +42,6 @@ ink_common_sources += \ widgets/sp-color-icc-selector.h \ widgets/sp-color-notebook.cpp \ widgets/sp-color-notebook.h \ - widgets/sp-color-preview.cpp \ - widgets/sp-color-preview.h \ widgets/sp-color-scales.cpp \ widgets/sp-color-scales.h \ widgets/sp-color-selector.cpp \ diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index c4b7216c6..ef05ad381 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -12,7 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "macros.h" #include "display/cairo-utils.h" #include "gradient-image.h" diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 7f0256665..f37158eec 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -420,7 +420,7 @@ void SPGradientVectorSelector::setSwatched() ##################################################################*/ #include "../widgets/sp-color-notebook.h" -#include "../widgets/sp-color-preview.h" +#include "ui/widget/color-preview.h" #include "../widgets/widget-sizes.h" #include "../xml/node-event-vector.h" #include "../svg/svg-color.h" @@ -558,7 +558,8 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_ gtk_widget_show(i); g_object_set_data(G_OBJECT(i), "stop", stop); GtkWidget *hb = gtk_hbox_new(FALSE, 4); - GtkWidget *cpv = sp_color_preview_new(sp_stop_get_rgba32(stop)); + GtkWidget *cpv = GTK_WIDGET(Gtk::manage( + new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)))->gobj()); gtk_widget_show(cpv); gtk_container_add( GTK_CONTAINER(hb), cpv ); g_object_set_data( G_OBJECT(i), "preview", cpv ); @@ -1190,8 +1191,8 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o blocked = FALSE; - SPColorPreview *cpv = static_cast(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "preview")); - sp_color_preview_set_rgba32(cpv, sp_stop_get_rgba32(stop)); + Inkscape::UI::Widget::ColorPreview *cpv = static_cast(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "preview")); + cpv->setRgba32(sp_stop_get_rgba32(stop)); } /* diff --git a/src/widgets/sp-color-preview.cpp b/src/widgets/sp-color-preview.cpp deleted file mode 100644 index ddeb5d123..000000000 --- a/src/widgets/sp-color-preview.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * A simple color preview widget - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "../display/nr-plain-stuff-gdk.h" -#include "sp-color-preview.h" - -#define SPCP_DEFAULT_WIDTH 32 -#define SPCP_DEFAULT_HEIGHT 11 - -static void sp_color_preview_class_init (SPColorPreviewClass *klass); -static void sp_color_preview_init (SPColorPreview *image); -static void sp_color_preview_destroy (GtkObject *object); - -static void sp_color_preview_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void sp_color_preview_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gint sp_color_preview_expose (GtkWidget *widget, GdkEventExpose *event); - -static void sp_color_preview_paint (SPColorPreview *cp, GdkRectangle *area); - -static GtkWidgetClass *parent_class; - -GType sp_color_preview_get_type(void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof(SPColorPreviewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_color_preview_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPColorPreview), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_color_preview_init, - 0, /* value_table */ - }; - - type = g_type_register_static( GTK_TYPE_WIDGET, - "SPColorPreview", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; -} - -static void -sp_color_preview_class_init (SPColorPreviewClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET); - - object_class->destroy = sp_color_preview_destroy; - - widget_class->size_request = sp_color_preview_size_request; - widget_class->size_allocate = sp_color_preview_size_allocate; - widget_class->expose_event = sp_color_preview_expose; -} - -static void -sp_color_preview_init (SPColorPreview *image) -{ - GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW); - - image->rgba = 0xffffffff; -} - -static void -sp_color_preview_destroy (GtkObject *object) -{ - SPColorPreview *image; - - image = SP_COLOR_PREVIEW (object); - - if (((GtkObjectClass *) (parent_class))->destroy) - (* ((GtkObjectClass *) (parent_class))->destroy) (object); -} - -static void -sp_color_preview_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - SPColorPreview *slider; - - slider = SP_COLOR_PREVIEW (widget); - - requisition->width = SPCP_DEFAULT_WIDTH; - requisition->height = SPCP_DEFAULT_HEIGHT; -} - -static void -sp_color_preview_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - SPColorPreview *image; - - image = SP_COLOR_PREVIEW (widget); - - widget->allocation = *allocation; - - if (GTK_WIDGET_DRAWABLE (image)) { - gtk_widget_queue_draw (GTK_WIDGET (image)); - } -} - -static gint -sp_color_preview_expose (GtkWidget *widget, GdkEventExpose *event) -{ - SPColorPreview *cp; - - cp = SP_COLOR_PREVIEW (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) { - sp_color_preview_paint (cp, &event->area); - } - - return TRUE; -} - -GtkWidget * -sp_color_preview_new (guint32 rgba) -{ - SPColorPreview *image; - - image = (SPColorPreview*)gtk_type_new (SP_TYPE_COLOR_PREVIEW); - - sp_color_preview_set_rgba32 (image, rgba); - - return (GtkWidget *) image; -} - -void -sp_color_preview_set_rgba32 (SPColorPreview *cp, guint32 rgba) -{ - cp->rgba = rgba; - - if (GTK_WIDGET_DRAWABLE (cp)) { - gtk_widget_queue_draw (GTK_WIDGET (cp)); - } -} - -static void -sp_color_preview_paint (SPColorPreview *cp, GdkRectangle *area) -{ - GtkWidget *widget; - GdkRectangle warea, carea; - GdkRectangle wpaint, cpaint; - gint w2; - - widget = GTK_WIDGET (cp); - - warea.x = widget->allocation.x; - warea.y = widget->allocation.y; - warea.width = widget->allocation.width; - warea.height = widget->allocation.height; - - if (!gdk_rectangle_intersect (area, &warea, &wpaint)) return; - - /* Transparent area */ - - w2 = warea.width / 2; - - carea.x = warea.x; - carea.y = warea.y; - carea.width = w2; - carea.height = warea.height; - - if (gdk_rectangle_intersect (area, &carea, &cpaint)) { - nr_gdk_draw_rgba32_solid (widget->window, widget->style->black_gc, - cpaint.x, cpaint.y, - cpaint.width, cpaint.height, - cp->rgba); - } - - /* Solid area */ - - carea.x = warea.x + w2; - carea.y = warea.y; - carea.width = warea.width - w2; - carea.height = warea.height; - - if (gdk_rectangle_intersect (area, &carea, &cpaint)) { - nr_gdk_draw_rgba32_solid (widget->window, widget->style->black_gc, - cpaint.x, cpaint.y, - cpaint.width, cpaint.height, - cp->rgba | 0xff); - } -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-preview.h b/src/widgets/sp-color-preview.h deleted file mode 100644 index 873e59d80..000000000 --- a/src/widgets/sp-color-preview.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SEEN_COLOR_PREVIEW_H -#define SEEN_COLOR_PREVIEW_H - -/* - * A simple color preview widget - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include - -#include - - - -#define SP_TYPE_COLOR_PREVIEW (sp_color_preview_get_type ()) -#define SP_COLOR_PREVIEW(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_PREVIEW, SPColorPreview)) -#define SP_COLOR_PREVIEW_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_PREVIEW, SPColorPreviewClass)) -#define SP_IS_COLOR_PREVIEW(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_PREVIEW)) -#define SP_IS_COLOR_PREVIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_PREVIEW)) - -struct SPColorPreview { - GtkWidget widget; - - guint32 rgba; -}; - -struct SPColorPreviewClass { - GtkWidgetClass parent_class; -}; - -GType sp_color_preview_get_type(void); - -GtkWidget *sp_color_preview_new(guint32 rgba); - -void sp_color_preview_set_rgba32(SPColorPreview *cp, guint32 color); - - -#endif // SEEN_COLOR_PREVIEW_H -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 2f3d79db2fad212c8aa1bff7bb13132a34541aff Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 15 Aug 2010 03:19:33 +0200 Subject: Make nr_arena_invoke_render expect an already transformed context, to remove a limitation to integer translations imposed by NRRectL (bzr r9508.1.68) --- src/dialogs/clonetiler.cpp | 1 + src/display/canvas-arena.cpp | 5 ++++- src/display/nr-arena-glyphs.cpp | 10 ++++------ src/display/nr-arena-image.cpp | 1 - src/display/nr-arena-item.cpp | 11 +++-------- src/display/nr-arena-shape.cpp | 16 ++++++---------- src/display/nr-filter.cpp | 2 +- src/flood-context.cpp | 1 + src/helper/png-write.cpp | 2 ++ src/sp-pattern.cpp | 1 + src/ui/cache/svg_preview_cache.cpp | 1 + src/widgets/icon.cpp | 1 + 12 files changed, 25 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 3fe6b59e3..24a1682fe 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -905,6 +905,7 @@ clonetiler_trace_pick (Geom::Rect box) cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); cairo_t *ct = cairo_create(s); + cairo_translate(ct, -ibox.x0, -ibox.y0); /* Render */ nr_arena_item_invoke_render(ct, trace_root, &ibox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index f1355b9c4..ac5e68379 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -209,8 +209,10 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) area.y1 = buf->rect.y1; sp_canvas_prepare_buffer(buf); - + cairo_save(buf->ct); + cairo_translate(buf->ct, -area.x0, -area.y0); nr_arena_item_invoke_render (buf->ct, arena->root, &area, NULL, 0); + cairo_restore(buf->ct); } static double @@ -363,6 +365,7 @@ sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRR g_return_if_fail (SP_IS_CANVAS_ARENA (ca)); cairo_t *ct = cairo_create(surface); + cairo_translate(ct, -r.x0, -r.y0); nr_arena_item_invoke_render (ct, ca->root, &r, NULL, 0); cairo_destroy(ct); } diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index d35489d70..a56b37406 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -298,9 +298,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { guint32 rgba = item->arena->outlinecolor; - // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat - // by setting color channels in the "wrong" order - cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); + ink_cairo_set_source_rgba32(ct, rgba); cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode NRRect temp(area->x0, area->y0, area->x1, area->y1); @@ -310,10 +308,11 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); Geom::PathVector const * pathv = g->font->PathVector(g->glyph); + Geom::Matrix transform = g->g_transform * group->ctm; cairo_new_path(ct); - Geom::Matrix transform = g->g_transform * group->ctm; - feed_pathvector_to_cairo (ct, *pathv, transform, area_2geom, false, 0); + ink_cairo_transform(ct, transform); + feed_pathvector_to_cairo (ct, *pathv); cairo_fill(ct); } @@ -324,7 +323,6 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi bool has_stroke, has_fill; cairo_save(ct); - cairo_translate(ct, -area->x0, -area->y0); ink_cairo_transform(ct, ggroup->ctm); has_fill = ggroup->nrstyle.prepareFill(ct, &ggroup->paintbox); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 5f30e0560..fd75c8ff6 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -150,7 +150,6 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock // FIXME: at the moment gdk_cairo_set_source_pixbuf creates an ARGB copy // of the pixbuf. Fix this in Cairo and/or GDK. cairo_save(ct); - cairo_translate(ct, -area->x0, -area->y0); ink_cairo_transform(ct, image->ctm); cairo_new_path(ct); diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 2aae21bf1..91c4391f6 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -414,6 +414,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, carea.x1 - carea.x0, carea.y1 - carea.y0); this_ct = cairo_create(intermediate); + cairo_translate(this_ct, -carea.x0, -carea.y0); this_area = &carea; cairo_surface_destroy(intermediate); // the surface will be held in memory by this_ct } else { @@ -487,15 +488,9 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area if (needs_intermediate_rendering) { cairo_surface_t *intermediate = cairo_get_target(this_ct); - cairo_set_source_surface(ct, intermediate, carea.x0 - area->x0, carea.y0 - area->y0); + cairo_set_source_surface(ct, intermediate, carea.x0, carea.y0); if (mask) { - // bring mask into the coordinate system of ct - cairo_pattern_t *cmask = mask->cobj(); - cairo_matrix_t m; - cairo_pattern_get_matrix(cmask, &m); - cairo_matrix_translate(&m, area->x0 - carea.x0, area->y0 - carea.y0); - cairo_pattern_set_matrix(cmask, &m); - cairo_mask(ct, cmask); + cairo_mask(ct, mask->cobj()); // opacity of masked objects is handled by premultiplying the mask } else { diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 550195c7c..a39e9e6fc 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -309,7 +309,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g // cairo outline rendering: static unsigned int -cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect area) +cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect /*area*/) { NRArenaShape *shape = NR_ARENA_SHAPE(item); @@ -317,16 +317,14 @@ cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect a return item->state; guint32 rgba = NR_ARENA_ITEM(shape)->arena->outlinecolor; - // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat - // by setting color channels in the "wrong" order - cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); + cairo_save(ct); + ink_cairo_set_source_rgba32(ct, rgba); + ink_cairo_transform(ct, shape->ctm); + feed_pathvector_to_cairo (ct, shape->curve->get_pathvector()); + cairo_restore(ct); cairo_set_line_width(ct, 0.5); cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode - cairo_new_path(ct); - - feed_pathvector_to_cairo (ct, shape->curve->get_pathvector(), shape->ctm, area, true, 0); - cairo_stroke(ct); return item->state; @@ -362,7 +360,6 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock bool has_stroke, has_fill; // we assume the context has no path cairo_save(ct); - cairo_translate(ct, -area->x0, -area->y0); ink_cairo_transform(ct, shape->ctm); // update fill and stroke paints. @@ -407,7 +404,6 @@ nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area) if (!shape->curve) return item->state; cairo_save(ct); - cairo_translate(ct, -area->x0, -area->y0); ink_cairo_transform(ct, shape->ctm); feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); cairo_restore(ct); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 148b14f53..eda6eaf8e 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -171,7 +171,7 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea } cairo_surface_t *result = slot.get_result(_output_slot); - cairo_set_source_surface(graphic, result, 0, 0); + cairo_set_source_surface(graphic, result, area->x0, area->y0); cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); cairo_paint(graphic); cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); diff --git a/src/flood-context.cpp b/src/flood-context.cpp index dab0a33fa..9e78c8d52 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -830,6 +830,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, width, height, stride); cairo_t *ct = cairo_create(s); + // cairo_translate not necessary here - surface origin is at 0,0 SPNamedView *nv = sp_desktop_namedview(desktop); guint32 bgcolor = nv->pagecolor; diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 20870086a..fe7017d3e 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -339,6 +339,8 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, ebp->width, num_rows, stride); cairo_t *ct = cairo_create(s); + cairo_translate(ct, -bbox.x0, -bbox.y0); + ink_cairo_set_source_rgba32(ct, ebp->background); cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); cairo_paint(ct); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index e211203d4..2f8c141bf 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -660,6 +660,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, c[Geom::X], c[Geom::Y]); cairo_t *ct = cairo_create(temp); ink_cairo_transform(ct, t); + cairo_translate(ct, -x, -y); // render pattern. if (needs_opacity) { diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index aead24236..5a03366fc 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -68,6 +68,7 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rec cairo_surface_t *s = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, psize, psize); cairo_t *ct = cairo_create(s); + cairo_translate(ct, -area.x0, -area.y0); nr_arena_item_invoke_render(ct, root, &area, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 4ba86b295..d8f451ed7 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1023,6 +1023,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, cairo_surface_t *s = cairo_image_surface_create_for_data(px, CAIRO_FORMAT_ARGB32, psize, psize, stride); cairo_t *ct = cairo_create(s); + cairo_translate(ct, -ua.x0, -ua.y0); nr_arena_item_invoke_render(ct, root, &ua, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); -- cgit v1.2.3 From aa244fa35a3801b2fb11ec03ce4a2c51a9db1838 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 15 Aug 2010 04:15:10 +0200 Subject: Fix handling of x and y attributes of patterns (bzr r9508.1.69) --- src/sp-pattern.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 2f8c141bf..7fc4cb3f5 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -633,34 +633,39 @@ sp_pattern_create_pattern(SPPaintServer *ps, } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; - double x = pattern_x(pat); - double y = pattern_y(pat); - double w = pattern_width(pat); - double h = pattern_height(pat); + Geom::Point p(pattern_x(pat), pattern_y(pat)); + Geom::Point pd(pattern_width(pat), pattern_height(pat)); + Geom::Rect pattern_tile(p, p + pd); + + if (pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { + // interpret x, y, width, height in relation to bbox + Geom::Matrix bbox2user(bbox->x1 - bbox->x0, 0,0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + pattern_tile = pattern_tile * bbox2user; + } cairo_matrix_t cm; cairo_get_matrix(base_ct, &cm); Geom::Matrix full(cm.xx, cm.yx, cm.xy, cm.yy, 0, 0); // oversample the pattern slightly - // TODO: find optimum value. Maybe sqrt(2)? - Geom::Point c(Geom::Point(w, h)*ps2user.descrim()*full.descrim()*1.2); + // TODO: find optimum value + Geom::Point c(pattern_tile.dimensions()*ps2user.descrim()*full.descrim()*1.2); c[Geom::X] = ceil(c[Geom::X]); c[Geom::Y] = ceil(c[Geom::Y]); - Geom::Matrix t = Geom::Scale(c[Geom::X]/w, c[Geom::Y]/h); + Geom::Matrix t = Geom::Scale(c) * Geom::Scale(pattern_tile.dimensions()).inverse(); NRRectL one_tile; - one_tile.x0 = (int) floor(x); - one_tile.y0 = (int) floor(y); - one_tile.x1 = (int) ceil(x+w); - one_tile.y1 = (int) ceil(y+h); + one_tile.x0 = (int) floor(pattern_tile[Geom::X].min()); + one_tile.y0 = (int) floor(pattern_tile[Geom::Y].min()); + one_tile.x1 = (int) ceil(pattern_tile[Geom::X].max()); + one_tile.y1 = (int) ceil(pattern_tile[Geom::Y].max()); cairo_surface_t *target = cairo_get_target(base_ct); cairo_surface_t *temp = cairo_surface_create_similar(target, CAIRO_CONTENT_COLOR_ALPHA, c[Geom::X], c[Geom::Y]); cairo_t *ct = cairo_create(temp); + // scale into a coord system where the surface w,h are equal to tile w,h ink_cairo_transform(ct, t); - cairo_translate(ct, -x, -y); // render pattern. if (needs_opacity) { -- cgit v1.2.3 From c547f0ac8e54073711df679b5ebca7614eb27b31 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 26 Nov 2010 01:19:58 +0100 Subject: Fix mask luminance calculation, so the coeffs add up to 1 (bzr r9508.1.71) --- src/display/nr-arena-item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index e6b98e78e..c4c42b8b5 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -317,8 +317,8 @@ struct MaskLuminanceToAlpha { // the operation of unpremul -> luminance-to-alpha -> multiply by alpha // is equivalent to luminance-to-alpha on premultiplied color values // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 - guint32 ao = r*54 + g*182 + b*18; - return ((ao + 127) / 255) << 24; + guint32 ao = r*109 + g*366 + b*37; // coeffs add up to 512 + return ((ao + 256) << 15) & 0xff000000; // equivalent to ((ao + 256) / 512) << 24 } }; -- cgit v1.2.3 From 795d604aaf9c1c8146d513fbdcf21ac442a0d1a0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 12 Mar 2011 00:01:04 +0100 Subject: Snap while rotating: fix removal of points too close to the rotation center (bzr r10093) --- src/snap.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/snap.cpp b/src/snap.cpp index f13b02b46..fb8f70c49 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -760,16 +760,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b); } else if (transformation_type == ROTATE) { Geom::Coord r = Geom::L2(b); // the radius of the circular constraint - if (r < 1e-9) { // points too close to the rotation center will not move. Don't try to snap these - // as they will always yield a perfect snap result if they're already snapped beforehand (e.g. - // when the transformation center has been snapped to a grid intersection in the selector tool) - continue; // skip this SnapCandidate and continue with the next one - // PS1: Apparently we don't have to do this for skewing, but why? - // PS2: We cannot easily filter these points upstream, e.g. in the grab() method (seltrans.cpp) - // because the rotation center will change when pressing shift, and grab() won't be recalled. - // Filtering could be done in handleRequest() (again in seltrans.cpp), by iterating through - // the snap candidates. But hey, we're iterating here anyway. - } dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b, r); } else if (transformation_type == STRETCH) { // when non-uniform stretching { dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), component_vectors[dim]); @@ -895,8 +885,18 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // a is vector to snapped point; b is vector to original point; now lets calculate angle between a and b result[0] = atan2(Geom::dot(Geom::rot90(b), a), Geom::dot(b, a)); result[1] = result[1]; // how else should we store an angle in a point ;-) - // Store the metric for this transformation as a virtual distance (we're storing an angle) - snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); + if (Geom::L2(b) < 1e-9) { // points too close to the rotation center will not move. Don't try to snap these + // as they will always yield a perfect snap result if they're already snapped beforehand (e.g. + // when the transformation center has been snapped to a grid intersection in the selector tool) + snapped_point.setSnapDistance(NR_HUGE); + // PS1: Apparently we don't have to do this for skewing, but why? + // PS2: We cannot easily filter these points upstream, e.g. in the grab() method (seltrans.cpp) + // because the rotation center will change when pressing shift, and grab() won't be recalled. + // Filtering could be done in handleRequest() (again in seltrans.cpp), by iterating through + // the snap candidates. But hey, we're iterating here anyway. + } else { + snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); + } snapped_point.setSecondSnapDistance(NR_HUGE); break; default: -- cgit v1.2.3 From ac8b01693af4588db21cc219baa8c5d0fd3d5826 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 12 Mar 2011 09:23:09 +0100 Subject: Use filter primitive subregion for feFlood per SVG standard. (bzr r10094) --- src/display/nr-filter-flood.cpp | 68 ++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index ca073cfd8..eb1cf13a6 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -3,8 +3,9 @@ * * Authors: * Felipe Corrêa da Silva Sanches + * Tavmjong Bah (use primitive filter region) * - * Copyright (C) 2007 authors + * Copyright (C) 2007, 2011 authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -31,7 +32,7 @@ FilterPrimitive * FilterFlood::create() { FilterFlood::~FilterFlood() {} -int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) { +int FilterFlood::render(FilterSlot &slot, FilterUnits const &units) { //g_message("rendering feflood"); NRPixBlock *in = slot.get(_input); if (!in) { @@ -39,35 +40,54 @@ int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) { return 1; } - int i; - int in_w = in->area.x1 - in->area.x0; - int in_h = in->area.y1 - in->area.y0; - - NRPixBlock *out = new NRPixBlock; - - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); + // Region being drawn on screen in screen coordinates. + int x0 = in->area.x0, y0 = in->area.y0; + int x1 = in->area.x1, y1 = in->area.y1; + int w = x1 - x0; + // Set up pix block + NRPixBlock *out = new NRPixBlock; + nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, x0, y0, x1, y1, true); unsigned char *out_data = NR_PIXBLOCK_PX(out); - unsigned char r,g,b,a; - - r = CLAMP_D_TO_U8((color >> 24) % 256); - g = CLAMP_D_TO_U8((color >> 16) % 256); - b = CLAMP_D_TO_U8((color >> 8) % 256); - a = CLAMP_D_TO_U8(opacity*255); + // Get RGBA values. + unsigned char r,g,b,a; + r = CLAMP_D_TO_U8((color >> 24) % 256); + g = CLAMP_D_TO_U8((color >> 16) % 256); + b = CLAMP_D_TO_U8((color >> 8) % 256); + a = CLAMP_D_TO_U8(opacity*255); #if ENABLE_LCMS - icc_color_to_sRGB(icc, &r, &g, &b); -//g_message("result: r:%d g:%d b:%d", r, g, b); + icc_color_to_sRGB(icc, &r, &g, &b); + //g_message("result: r:%d g:%d b:%d", r, g, b); #endif //ENABLE_LCMS - for(i=0; i < 4*in_h*in_w; i+=4){ - out_data[i]=r; - out_data[i+1]=g; - out_data[i+2]=b; - out_data[i+3]=a; + // Only fill primitive subregion + + // Get subregion in user units + Geom::Rect fp = filter_primitive_area( units ); + + // Need to convert to pixbuff units + Geom::Rect fp_pb = fp * units.get_matrix_user2pb(); + + // Make sure we are in pixbuff area + int fp_x0 = fp_pb.min()[Geom::X]; + int fp_x1 = fp_pb.max()[Geom::X]; + int fp_y0 = fp_pb.min()[Geom::Y]; + int fp_y1 = fp_pb.max()[Geom::Y]; + if( fp_x0 < x0 ) fp_x0 = x0; + if( fp_x1 > x1 ) fp_x1 = x1; + if( fp_y0 < y0 ) fp_y0 = y0; + if( fp_y1 > y1 ) fp_y1 = y1; + + // Do fill + for (int x=fp_x0; x < fp_x1; x++){ + for (int y=fp_y0; y < fp_y1; y++){ + out_data[ 4*((x - x0) + w*(y - y0)) ] = r; + out_data[ 4*((x - x0) + w*(y - y0)) + 1 ] = g; + out_data[ 4*((x - x0) + w*(y - y0)) + 2 ] = b; + out_data[ 4*((x - x0) + w*(y - y0)) + 3 ] = a; + } } out->empty = FALSE; -- cgit v1.2.3 From 031979e174264335dde5eaab74cde11c75d46cda Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 12 Mar 2011 22:24:16 +0100 Subject: Hope to fix a really dumb earlier commit by me... Fixed bugs: - https://launchpad.net/bugs/380501 (bzr r10096) --- src/extension/internal/cairo-render-context.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 4a09d56c0..503fb8b31 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -58,6 +58,8 @@ #include "io/sys.h" +#include "svg/stringstream.h" + #include // include support for only the compiled-in surface types @@ -785,6 +787,13 @@ CairoRenderContext::setupSurface(double width, double height) _width = width; _height = height; + Inkscape::SVGOStringStream os_bbox; + Inkscape::SVGOStringStream os_pagebbox; + os_bbox.setf(std::ios::fixed); // don't use scientific notation + os_pagebbox.setf(std::ios::fixed); // don't use scientific notation + os_bbox << "%%BoundingBox: 0 0 " << width << height; + os_pagebbox << "%%PageBoundingBox: 0 0 " << width << height; + cairo_surface_t *surface = NULL; cairo_matrix_t ctm; cairo_matrix_init_identity (&ctm); @@ -812,11 +821,9 @@ CairoRenderContext::setupSurface(double width, double height) #endif // Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501 #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)) -// This is only a template, override_bbox and the bounding box values must be defned. -// if (override_bbox) { -// cairo_ps_dsc_comment(surface, "%%BoundingBox: 100 100 200 200"); -// cairo_ps_dsc_comment(surface, "%%PageBoundingBox: 100 100 200 200"); -// } +// cairo_ps_dsc_comment(surface, os_bbox.str().c_str()); +// cairo_ps_dsc_begin_page(surface); +// cairo_ps_dsc_comment(surface, os_pagebbox.str().c_str()); #endif break; #endif -- cgit v1.2.3 From 263b88617ed6ffbf0d87bb084338cc05e22213aa Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 12 Mar 2011 22:37:15 +0100 Subject: Fix part of bug 733010, where fit page to drawing did not work the same as fit page to selection when all is selected. Fixes page resizing for arrow markers. Infinite line dots markers are still not correctly fit to. Fixed bugs: - https://launchpad.net/bugs/733010 (bzr r10097) --- src/selection-chemistry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 5ae4205bb..082c447d0 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3222,7 +3222,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) doc->ensureUpToDate(); SPItem const *const root = SP_ITEM(doc->root); - Geom::OptRect const bbox(root->getBounds(root->i2d_affine())); + Geom::OptRect const bbox(root->getBounds(root->i2d_affine(), SPItem::RENDERING_BBOX)); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; -- cgit v1.2.3 From c870e60f611ffd2dacde5b315c8a1995282eac56 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 12 Mar 2011 23:39:03 +0100 Subject: Allow for item groups in marker definitions when calculating the path outline. Fixed bugs: - https://launchpad.net/bugs/733010 (bzr r10098) --- src/splivarot.cpp | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index fe8d8a894..c01296b0e 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -625,33 +625,52 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine } } +static +void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_transform, Geom::PathVector* pathv_in ) +{ + Geom::Affine tr(marker_transform); + tr = item->transform * tr; + + // note: a marker child item can be an item group! + if (SP_IS_GROUP(item)) { + // recurse through all childs: + for (SPObject const *o = item->firstChild() ; o ; o = o->getNext() ) { + if ( SP_IS_ITEM(o) ) { + item_outline_add_marker_child(SP_ITEM(o), tr, pathv_in); + } + } + } else { + Geom::PathVector* marker_pathv = item_outline(item); + + if (marker_pathv) { + for (unsigned int j=0; j < marker_pathv->size(); j++) { + pathv_in->push_back((*marker_pathv)[j] * tr); + } + delete marker_pathv; + } + } +} + static void item_outline_add_marker( SPObject const *marker_object, Geom::Affine marker_transform, Geom::Scale stroke_scale, Geom::PathVector* pathv_in ) { SPMarker const * marker = SP_MARKER(marker_object); - SPItem const * marker_item = sp_item_first_item_child(marker_object); Geom::Affine tr(marker_transform); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { tr = stroke_scale * tr; } // total marker transform - tr = marker_item->transform * marker->c2p * tr; + tr = marker->c2p * tr; - Geom::PathVector* marker_pathv = item_outline(marker_item); - - if (marker_pathv) { - for (unsigned int j=0; j < marker_pathv->size(); j++) { - pathv_in->push_back((*marker_pathv)[j] * tr); - } - delete marker_pathv; - } + SPItem const * marker_item = sp_item_first_item_child(marker_object); // why only consider the first item? can a marker only consist of a single item (that may be a group)? + item_outline_add_marker_child(marker_item, tr, pathv_in); } /** * Returns a pathvector that is the outline of the stroked item, with markers. - * item must be SPShape of SPText. + * item must be SPShape or SPText. */ Geom::PathVector* item_outline(SPItem const *item) { -- cgit v1.2.3 From f0248694a09ea6ab18400ac97f5a6ea53dc17d01 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sun, 13 Mar 2011 12:08:22 +0100 Subject: remove wrong format indication in lossy format warning (was always org.inkscape.output.svg.inkscape) (bzr r10099) --- src/widgets/desktop-widget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 323a5b08b..63fdc5930 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -943,10 +943,9 @@ SPDesktopWidget::shutdown() GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, - _("The file \"%s\" was saved with a format (%s) that may cause data loss!\n\n" + _("The file \"%s\" was saved with a format that may cause data loss!\n\n" "Do you want to save this file as Inkscape SVG?"), - doc->getName() ? doc->getName() : "Unnamed", - SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE); + doc->getName() ? doc->getName() : "Unnamed"); // fix for bug 1767940: GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS); -- cgit v1.2.3 From 2783846e2676f2458d01b29bf0a56a31d5b3594a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Mar 2011 15:15:25 +0100 Subject: apparently bbox numbers in PS should be integers. Fixed bugs: - https://launchpad.net/bugs/380501 (bzr r10100) --- src/extension/internal/cairo-render-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 503fb8b31..9a612549d 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -791,8 +791,8 @@ CairoRenderContext::setupSurface(double width, double height) Inkscape::SVGOStringStream os_pagebbox; os_bbox.setf(std::ios::fixed); // don't use scientific notation os_pagebbox.setf(std::ios::fixed); // don't use scientific notation - os_bbox << "%%BoundingBox: 0 0 " << width << height; - os_pagebbox << "%%PageBoundingBox: 0 0 " << width << height; + os_bbox << "%%BoundingBox: 0 0 " << (int)ceil(width) << (int)ceil(height); // apparently, the numbers should be integers. (see bug 380501) + os_pagebbox << "%%PageBoundingBox: 0 0 " << (int)ceil(width) << (int)ceil(height); cairo_surface_t *surface = NULL; cairo_matrix_t ctm; -- cgit v1.2.3 From e49d12a439484bead7cf99456d7b8ccb76055f50 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Mar 2011 15:25:50 +0100 Subject: make a strange cast more obvious (bzr r10101) --- src/sp-shape.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index d9a47f76a..e9b0909ed 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -508,6 +508,8 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) { SPShape const *shape = SP_SHAPE (item); + SPItem::BBoxType bboxtype = (SPItem::BBoxType) flags; + if (shape->curve) { Geom::OptRect geombbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform); if (geombbox) { @@ -517,7 +519,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const cbbox.x1 = (*geombbox)[0][1]; cbbox.y1 = (*geombbox)[1][1]; - switch ((SPItem::BBoxType) flags) { + switch (bboxtype) { case SPItem::GEOMETRIC_BBOX: { // do nothing break; -- cgit v1.2.3 From 686ef068710b5d2c2c7be5282a68fa7d74e88eee Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 14 Mar 2011 17:30:42 +0100 Subject: Filters. Drawing CPF improvement. (bzr r10102) --- src/extension/internal/filter/experimental.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 9dd188bd3..bca3fe874 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -301,7 +301,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) * Dilatation (1.->50., default 6) -> color2 (n-1th value) * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) - * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->composite7) + * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) @@ -404,7 +404,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) if (ext->get_param_bool("transluscent")) transluscent << "merge1"; else - transluscent << "composite7"; + transluscent << "color5"; offset << ext->get_param_int("offset"); blur << ext->get_param_float("blur"); @@ -460,8 +460,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" - "\n" + "\n" "\n" "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), transluscent.str().c_str()); -- cgit v1.2.3 From e3ad9bfc9912ee6ab8d29245450e911b9fbba176 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 14 Mar 2011 18:03:26 +0100 Subject: Extensions. Slider in Float and Int extension widgets. (bzr r10103) --- src/extension/param/float.cpp | 23 +++++++++++++++++++++-- src/extension/param/float.h | 26 +++++++++++++++++++------- src/extension/param/int.cpp | 23 +++++++++++++++++++++-- src/extension/param/int.h | 24 ++++++++++++++++++------ src/extension/param/parameter.cpp | 12 ++++++++++-- 5 files changed, 89 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 62762b3bb..9a677a1f9 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "xml/node.h" @@ -23,8 +24,17 @@ namespace Extension { /** \brief Use the superclass' allocator and set the \c _value */ -ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0.0), _min(0.0), _max(10.0) +ParamFloat::ParamFloat (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(0.0), _mode(mode), _min(0.0), _max(10.0) { const gchar * defaultval = NULL; if (sp_repr_children(xml) != NULL) @@ -153,6 +163,15 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign hbox->pack_start(*label, true, true); ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); + + if (_mode == FULL) { + Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); + scale->set_draw_value(false); + scale->set_size_request(200, -1); + scale->show(); + hbox->pack_start(*scale, false, false); + } + Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, _precision)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/param/float.h b/src/extension/param/float.h index f105d8f0e..d3e2517f7 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -17,14 +17,19 @@ namespace Inkscape { namespace Extension { class ParamFloat : public Parameter { -private: - /** \brief Internal value. */ - float _value; - float _min; - float _max; - int _precision; public: - ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); + enum AppearanceMode { + FULL, MINIMAL + }; + ParamFloat (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); /** \brief Returns \c _value */ float get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } float set (float in, SPDocument * doc, Inkscape::XML::Node * node); @@ -33,6 +38,13 @@ public: float precision (void) { return _precision; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); void string (std::string &string); +private: + /** \brief Internal value. */ + float _value; + float _min; + float _max; + int _precision; + AppearanceMode _mode; }; } /* namespace Extension */ diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index ae69d0661..bd89c971d 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "xml/node.h" @@ -23,8 +24,17 @@ namespace Extension { /** \brief Use the superclass' allocator and set the \c _value */ -ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0), _min(0), _max(10) +ParamInt::ParamInt (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(0), _mode(mode), _min(0), _max(10) { const char * defaultval = NULL; if (sp_repr_children(xml) != NULL) @@ -138,6 +148,15 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal hbox->pack_start(*label, true, true); ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); + + if (_mode == FULL) { + Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); + scale->set_draw_value(false); + scale->set_size_request(200, -1); + scale->show(); + hbox->pack_start(*scale, false, false); + } + Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/param/int.h b/src/extension/param/int.h index a4eb54c81..01e208c46 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -17,13 +17,19 @@ namespace Inkscape { namespace Extension { class ParamInt : public Parameter { -private: - /** \brief Internal value. */ - int _value; - int _min; - int _max; public: - ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); + enum AppearanceMode { + FULL, MINIMAL + }; + ParamInt (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); /** \brief Returns \c _value */ int get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } int set (int in, SPDocument * doc, Inkscape::XML::Node * node); @@ -31,6 +37,12 @@ public: int min (void) { return _min; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); void string (std::string &string); +private: + /** \brief Internal value. */ + int _value; + int _min; + int _max; + AppearanceMode _mode; }; } /* namespace Extension */ diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 529d5a775..4abfeb231 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -124,9 +124,17 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * if (!strcmp(type, "boolean")) { param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "int")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "minimal")) { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); + } else { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL); + } } else if (!strcmp(type, "float")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "minimal")) { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL); + } else { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL); + } } else if (!strcmp(type, "string")) { param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); const gchar * max_length = in_repr->attribute("max_length"); -- cgit v1.2.3 From 861f06b2338b396878a679471d63a890febfc73b Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 14 Mar 2011 20:50:25 +0100 Subject: Import. Patch for Bug #716362 (Invalid result when drag and drop svg file), by Johannes Lipp. Fixed bugs: - https://launchpad.net/bugs/716362 (bzr r10104) --- src/file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 2816b0434..c93188358 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -978,7 +978,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Create a new group if necessary. Inkscape::XML::Node *newgroup = NULL; - if ((style && style->firstChild()) || items_count > 1) { + if ((style && style->attributeList()) || items_count > 1) { newgroup = xml_in_doc->createElement("svg:g"); sp_repr_css_set(newgroup, style, "style"); } -- cgit v1.2.3 From ee7e83a07ad3aec222f70de2b15bb92ca575117b Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 14 Mar 2011 21:04:42 +0100 Subject: Extensions. Warnings (introduced in recent float and int changes) cleanup. (bzr r10105) --- src/extension/param/float.h | 2 +- src/extension/param/int.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/param/float.h b/src/extension/param/float.h index d3e2517f7..2e816d4dc 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -41,10 +41,10 @@ public: private: /** \brief Internal value. */ float _value; + AppearanceMode _mode; float _min; float _max; int _precision; - AppearanceMode _mode; }; } /* namespace Extension */ diff --git a/src/extension/param/int.h b/src/extension/param/int.h index 01e208c46..fce085378 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -40,9 +40,9 @@ public: private: /** \brief Internal value. */ int _value; + AppearanceMode _mode; int _min; int _max; - AppearanceMode _mode; }; } /* namespace Extension */ -- cgit v1.2.3 From 88a617b7c8709c1e5f39967abf003ac1cf4f982d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 15 Mar 2011 18:04:49 +0100 Subject: Extensions. Float and Int default mode set to minimal. Filters' mode changed to full. (bzr r10106) --- src/extension/internal/filter/abc.h | 76 ++++++++++++++-------------- src/extension/internal/filter/color.h | 46 ++++++++--------- src/extension/internal/filter/drop-shadow.h | 16 +++--- src/extension/internal/filter/experimental.h | 70 ++++++++++++------------- src/extension/internal/filter/morphology.h | 6 +-- src/extension/internal/filter/shadows.h | 6 +-- src/extension/internal/filter/snow.h | 2 +- src/extension/param/parameter.cpp | 12 ++--- 8 files changed, 117 insertions(+), 117 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h index 41a3c5af9..e66aedd8c 100755 --- a/src/extension/internal/filter/abc.h +++ b/src/extension/internal/filter/abc.h @@ -58,8 +58,8 @@ public: "\n" "" N_("Blur, custom (ABCs)") "\n" "org.inkscape.effect.filter.Blur\n" - "2\n" - "2\n" + "2\n" + "2\n" "\n" "all\n" "\n" @@ -99,7 +99,7 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) Removes or decreases glows and jaggeries around objects edges after applying some filters Filter's parameters: - * Strength (0.01->100., default 0.4) -> blur (stdDeviation) + * Strength (0.01->2., default 0.4) -> blur (stdDeviation) */ class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { @@ -115,7 +115,7 @@ public: "\n" "" N_("Clean edges, custom (ABCs)") "\n" "org.inkscape.effect.filter.CleanEdges\n" - "0.4\n" + "0.4\n" "\n" "all\n" "\n" @@ -173,8 +173,8 @@ public: "\n" "" N_("Color shift, custom (ABCs)") "\n" "org.inkscape.effect.filter.ColorShift\n" - "330\n" - "6\n" + "330\n" + "6\n" "\n" "all\n" "\n" @@ -234,9 +234,9 @@ public: "\n" "" N_("Diffuse light, custom (ABCs)") "\n" "org.inkscape.effect.filter.DiffuseLight\n" - "6\n" - "25\n" - "235\n" + "6\n" + "25\n" + "235\n" "-1\n" "\n" "all\n" @@ -310,7 +310,7 @@ public: "\n" "" N_("Feather, custom (ABCs)") "\n" "org.inkscape.effect.filter.Feather\n" - "5\n" + "5\n" "\n" "all\n" "\n" @@ -371,10 +371,10 @@ public: "\n" "" N_("Matte jelly, custom (ABCs)") "\n" "org.inkscape.effect.filter.MatteJelly\n" - "7\n" - "0.9\n" - "60\n" - "225\n" + "7\n" + "0.9\n" + "60\n" + "225\n" "-1\n" "\n" "all\n" @@ -462,15 +462,15 @@ public: "\n" "\n" "\n" - "<_item value=\"fractalNoise\">" N_("Fractal noise") "\n" - "<_item value=\"turbulence\">" N_("Turbulence") "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" "\n" - "2\n" - "4\n" - "5\n" - "0\n" - "3\n" - "1\n" + "2\n" + "4\n" + "5\n" + "0\n" + "3\n" + "1\n" "false\n" "\n" "\n" @@ -571,10 +571,10 @@ public: "org.inkscape.effect.filter.Outline\n" "\n" "\n" - "5\n" - "2\n" - "8\n" - "5\n" + "5\n" + "2\n" + "8\n" + "5\n" "\n" "\n" "1029214207\n" @@ -661,14 +661,14 @@ public: "" N_("Roughen, custom (ABCs)") "\n" "org.inkscape.effect.filter.Roughen\n" "\n" - "<_item value=\"fractalNoise\">" N_("Fractal noise") "\n" - "<_item value=\"turbulence\">" N_("Turbulence") "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" "\n" - "1.3\n" - "1.3\n" - "5\n" - "0\n" - "6.6\n" + "1.3\n" + "1.3\n" + "5\n" + "0\n" + "6.6\n" "\n" "all\n" "\n" @@ -735,7 +735,7 @@ public: "\n" "" N_("Silhouette, custom (ABCs)") "\n" "org.inkscape.effect.filter.Silhouette\n" - "0.01\n" + "0.01\n" "false\n" "255\n" "\n" @@ -811,10 +811,10 @@ public: "\n" "" N_("Specular light, custom (ABCs)") "\n" "org.inkscape.effect.filter.SpecularLight\n" - "6\n" - "1\n" - "45\n" - "235\n" + "6\n" + "1\n" + "45\n" + "235\n" "-1\n" "\n" "all\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index cdf8ffe90..4713a5f1a 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -62,9 +62,9 @@ public: "\n" "" N_("Brightness, custom (Color)") "\n" "org.inkscape.effect.filter.Brightness\n" - "10\n" - "0\n" - "0\n" + "10\n" + "0\n" + "0\n" "\n" "all\n" "\n" @@ -131,8 +131,8 @@ public: "org.inkscape.effect.filter.Colorize\n" "\n" "\n" - "0\n" - "1\n" + "0\n" + "1\n" "false\n" "\n" "<_item value=\"multiply\">" N_("Multiply") "\n" @@ -239,7 +239,7 @@ public: "org.inkscape.effect.filter.Duochrome\n" "\n" "\n" - "0\n" + "0\n" "\n" "<_item value=\"none\">" N_("No swap") "\n" "<_item value=\"full\">" N_("Color and alpha") "\n" @@ -360,12 +360,12 @@ public: "\n" "" N_("Electrize, custom (Color)") "\n" "org.inkscape.effect.filter.Electrize\n" - "2.0\n" + "2.0\n" "\n" "<_item value=\"table\">" N_("Table") "\n" "<_item value=\"discrete\">" N_("Discrete") "\n" "\n" - "3\n" + "3\n" "false\n" "\n" "all\n" @@ -453,10 +453,10 @@ public: "\n" "" N_("Greyscale, custom (Color)") "\n" "org.inkscape.effect.filter.Greyscale\n" - "2.1\n" - "7.2\n" - "0.72\n" - "0\n" + "2.1\n" + "7.2\n" + "0.72\n" + "0\n" "false\n" "\n" "all\n" @@ -535,9 +535,9 @@ public: "\n" "" N_("Lightness, custom (Color)") "\n" "org.inkscape.effect.filter.Lightness\n" - "10.0\n" - "10.0\n" - "0.0\n" + "10.0\n" + "10.0\n" + "0.0\n" "\n" "all\n" "\n" @@ -604,14 +604,14 @@ public: "\n" "" N_("Quadritone fantasy, custom (Color)") "\n" "org.inkscape.effect.filter.Quadritone\n" - "280\n" - "100\n" + "280\n" + "100\n" "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"screen\">" N_("Screen") "\n" "\n" - "0\n" + "0\n" "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"screen\">" N_("Screen") "\n" @@ -691,7 +691,7 @@ public: "\n" "" N_("Solarize, custom (Color)") "\n" "org.inkscape.effect.filter.Solarize\n" - "0\n" + "0\n" "\n" "<_item value=\"solarize\">" N_("Solarize") "\n" "<_item value=\"moonarize\">" N_("Moonarize") "\n" @@ -792,17 +792,17 @@ public: "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"darken\">" N_("Darken") "\n" "\n" - "0.01\n" + "0.01\n" "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"darken\">" N_("Darken") "\n" "\n" - "0\n" - "1\n" + "0\n" + "1\n" "\n" "\n" - "0\n" + "0\n" "-73203457\n" "\n" "\n" diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h index 12f0c6055..c80571d67 100644 --- a/src/extension/internal/filter/drop-shadow.h +++ b/src/extension/internal/filter/drop-shadow.h @@ -34,10 +34,10 @@ public: "\n" "" N_("Drop Shadow") "\n" "org.inkscape.effect.filter.drop-shadow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" + "2.0\n" + "50\n" + "4.0\n" + "4.0\n" "\n" "all\n" "\n" @@ -94,10 +94,10 @@ public: "\n" "" N_("Drop Glow") "\n" "org.inkscape.effect.filter.drop-glow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" + "2.0\n" + "50\n" + "4.0\n" + "4.0\n" "\n" "all\n" "\n" diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index bca3fe874..696216a71 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -81,19 +81,19 @@ public: "false\n" "false\n" "false\n" - "0\n" - "1\n" - "10\n" - "1\n" + "0\n" + "1\n" + "10\n" + "1\n" "\n" "\n" "true\n" - "100\n" - "100\n" - "1\n" - "0\n" - "1\n" - "0\n" + "100\n" + "100\n" + "1\n" + "0\n" + "1\n" + "0\n" "true\n" "\n" "<_item value=\"normal\">Normal\n" @@ -230,11 +230,11 @@ public: "\n" "" N_("Cross engraving, custom") "\n" "org.inkscape.effect.filter.CrossEngraving\n" - "30\n" - "1\n" - "0\n" - "0.5\n" - "4\n" + "30\n" + "1\n" + "0\n" + "0.5\n" + "4\n" "false\n" "\n" "all\n" @@ -332,18 +332,18 @@ public: "\n" "\n" "<_param name=\"simplifyheader\" type=\"groupheader\">Simplify\n" - "0.6\n" - "10\n" - "0\n" + "0.6\n" + "10\n" + "0\n" "false\n" "<_param name=\"smoothheader\" type=\"groupheader\">Smoothness\n" - "0.6\n" - "6\n" - "2\n" + "0.6\n" + "6\n" + "2\n" "<_param name=\"meltheader\" type=\"groupheader\">Melt\n" - "1\n" - "6\n" - "2\n" + "1\n" + "6\n" + "2\n" "\n" "\n" "-1515870721\n" @@ -352,7 +352,7 @@ public: "\n" "589505535\n" "false\n" - "0\n" + "0\n" "\n" "\n" "\n" @@ -500,9 +500,9 @@ public: "<_item value=\"table\">Smoothed\n" "<_item value=\"discrete\">Contrasted\n" "\n" - "1.5\n" - "1.5\n" - "0.5\n" + "1.5\n" + "1.5\n" + "0.5\n" "\n" "<_item value=\"normal\">Normal\n" "<_item value=\"multiply\">Multiply\n" @@ -609,16 +609,16 @@ public: "<_item value=\"discrete\">Poster\n" "<_item value=\"table\">Painting\n" "\n" - "5\n" + "5\n" "\n" "<_item value=\"lighten\">Lighten\n" "<_item value=\"normal\">Normal\n" "<_item value=\"darken\">Darken\n" "\n" - "4.0\n" - "0.5\n" - "1.00\n" - "1.00\n" + "4.0\n" + "0.5\n" + "1.00\n" + "1.00\n" "false\n" "\n" "all\n" @@ -715,8 +715,8 @@ public: "\n" "" N_("Posterize basic, custom") "\n" "org.inkscape.effect.filter.PosterizeBasic\n" - "5\n" - "4.0\n" + "5\n" + "4.0\n" "\n" "all\n" "\n" diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 0a844c937..bd127eb68 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -51,10 +51,10 @@ public: "" N_("Cross-smooth, custom (Morphology)") "\n" "org.inkscape.effect.filter.crosssmooth\n" "\n" - "<_item value=\"edges\">" N_("Smooth edges") "\n" - "<_item value=\"all\">" N_("Smooth all") "\n" + "<_item value=\"edges\">Smooth edges\n" + "<_item value=\"all\">Smooth all\n" "\n" - "5\n" + "5\n" "\n" "all\n" "\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 1924c5bb3..e29092ae9 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -49,9 +49,9 @@ public: "\n" "" N_("Drop shadow, custom (Shadows and Glows)") "\n" "org.inkscape.effect.filter.ColorDropShadow\n" - "3.0\n" - "6.0\n" - "6.0\n" + "3.0\n" + "6.0\n" + "6.0\n" "127\n" "\n" "all\n" diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h index aac07fe62..9a88ab9d2 100644 --- a/src/extension/internal/filter/snow.h +++ b/src/extension/internal/filter/snow.h @@ -31,7 +31,7 @@ public: "\n" "" N_("Snow crest") "\n" "org.inkscape.effect.filter.snow\n" - "3.5\n" + "3.5\n" "\n" "all\n" "\n" diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 4abfeb231..d35fb3d3c 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -124,16 +124,16 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * if (!strcmp(type, "boolean")) { param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "int")) { - if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); - } else { + if (appearance && !strcmp(appearance, "full")) { param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL); + } else { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); } } else if (!strcmp(type, "float")) { - if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL); - } else { + if (appearance && !strcmp(appearance, "full")) { param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL); + } else { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL); } } else if (!strcmp(type, "string")) { param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); -- cgit v1.2.3 From c540f51dc3ff636b8d3688140e3e4221925d7780 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 16 Mar 2011 00:04:21 +0100 Subject: automatically enter current filename in windows save as dialog. Fixed bugs: - https://launchpad.net/bugs/530957 (bzr r10107) --- src/ui/dialog/filedialogimpl-win32.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index b18d5a1bc..4f0978c05 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1577,6 +1577,17 @@ FileSaveDialogImplWin32::FileSaveDialogImplWin32(Gtk::Window &parent, { FileSaveDialog::myDocTitle = docTitle; createFilterMenu(); + + /* The code below sets the default file name */ + myFilename = ""; + if (dir.size() > 0) { + Glib::ustring udir(dir); + Glib::ustring::size_type len = udir.length(); + // leaving a trailing backslash on the directory name leads to the infamous + // double-directory bug on win32 + if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); + myFilename = udir.substr(0, udir.find_last_of( '.' ) ); // this removes the extension, or actually, removes everything past the last dot (hopefully this is what most people want) + } } FileSaveDialogImplWin32::~FileSaveDialogImplWin32() -- cgit v1.2.3 From fec61fd39f3ca6c3b562b68179b0716e84e64d0e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 16 Mar 2011 19:45:15 +0100 Subject: Filters. Custom predefined filters fine tuning (precision and UI labels). (bzr r10108) --- src/extension/internal/filter/abc.h | 70 ++++++++++++------------- src/extension/internal/filter/color.h | 76 ++++++++++++++-------------- src/extension/internal/filter/experimental.h | 48 +++++++++--------- src/extension/internal/filter/morphology.h | 2 +- 4 files changed, 98 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h index e66aedd8c..8368d3f3b 100755 --- a/src/extension/internal/filter/abc.h +++ b/src/extension/internal/filter/abc.h @@ -58,8 +58,8 @@ public: "\n" "" N_("Blur, custom (ABCs)") "\n" "org.inkscape.effect.filter.Blur\n" - "2\n" - "2\n" + "2\n" + "2\n" "\n" "all\n" "\n" @@ -115,7 +115,7 @@ public: "\n" "" N_("Clean edges, custom (ABCs)") "\n" "org.inkscape.effect.filter.CleanEdges\n" - "0.4\n" + "0.4\n" "\n" "all\n" "\n" @@ -157,7 +157,7 @@ CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Shift (0->360, default 330) -> color1 (values) - * Saturation (0.->10., default 6) -> color2 (values [/10]) + * Saturation (0.->1., default 0.6) -> color2 (values) */ class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { @@ -173,8 +173,8 @@ public: "\n" "" N_("Color shift, custom (ABCs)") "\n" "org.inkscape.effect.filter.ColorShift\n" - "330\n" - "6\n" + "330\n" + "0.6\n" "\n" "all\n" "\n" @@ -198,7 +198,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream sat; shift << ext->get_param_int("shift"); - sat << (ext->get_param_float("sat") / 10); + sat << ext->get_param_float("sat"); _filter = g_strdup_printf( "\n" @@ -235,8 +235,8 @@ public: "" N_("Diffuse light, custom (ABCs)") "\n" "org.inkscape.effect.filter.DiffuseLight\n" "6\n" - "25\n" - "235\n" + "25\n" + "235\n" "-1\n" "\n" "all\n" @@ -310,7 +310,7 @@ public: "\n" "" N_("Feather, custom (ABCs)") "\n" "org.inkscape.effect.filter.Feather\n" - "5\n" + "5\n" "\n" "all\n" "\n" @@ -371,10 +371,10 @@ public: "\n" "" N_("Matte jelly, custom (ABCs)") "\n" "org.inkscape.effect.filter.MatteJelly\n" - "7\n" - "0.9\n" - "60\n" - "225\n" + "7\n" + "0.9\n" + "60\n" + "225\n" "-1\n" "\n" "all\n" @@ -436,8 +436,8 @@ MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*100) (0.001->1000., default 2) -> turbulence (baseFrequency [/100]) - * Vertical frequency (*100) (0.001->1000., default 4) -> turbulence (baseFrequency [/100]) + * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) * Complexity (1->5, default 5) -> turbulence (numOctaves) * Variation (1->360, default 1) -> turbulence (seed) * Dilatation (1.->50., default 3) -> color (n-1th value) @@ -465,12 +465,12 @@ public: "<_item value=\"fractalNoise\">Fractal noise\n" "<_item value=\"turbulence\">Turbulence\n" "\n" - "2\n" - "4\n" + "20\n" + "40\n" "5\n" "0\n" - "3\n" - "1\n" + "3\n" + "1\n" "false\n" "\n" "\n" @@ -510,8 +510,8 @@ NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream inverted; type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 100); - vfreq << (ext->get_param_float("vfreq") / 100); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); dilat << ext->get_param_float("dilat"); @@ -571,10 +571,10 @@ public: "org.inkscape.effect.filter.Outline\n" "\n" "\n" - "5\n" - "2\n" - "8\n" - "5\n" + "5\n" + "2\n" + "8\n" + "5\n" "\n" "\n" "1029214207\n" @@ -640,8 +640,8 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*100) (0.001->1000., default 1.3) -> turbulence (baseFrequency) - * Vertical frequency (*100) (0.001->1000., default 1.3) -> turbulence (baseFrequency) + * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) * Complexity (1->5, default 5) -> turbulence (numOctaves) * Variation (1->360, default 1) -> turbulence (seed) * Intensity (0.0->50., default 6.6) -> displacement (scale) @@ -664,8 +664,8 @@ public: "<_item value=\"fractalNoise\">Fractal noise\n" "<_item value=\"turbulence\">Turbulence\n" "\n" - "1.3\n" - "1.3\n" + "13\n" + "13\n" "5\n" "0\n" "6.6\n" @@ -696,8 +696,8 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream intensity; type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 100); - vfreq << (ext->get_param_float("vfreq") / 100); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); intensity << ext->get_param_float("intensity"); @@ -735,7 +735,7 @@ public: "\n" "" N_("Silhouette, custom (ABCs)") "\n" "org.inkscape.effect.filter.Silhouette\n" - "0.01\n" + "0.01\n" "false\n" "255\n" "\n" @@ -813,8 +813,8 @@ public: "org.inkscape.effect.filter.SpecularLight\n" "6\n" "1\n" - "45\n" - "235\n" + "45\n" + "235\n" "-1\n" "\n" "all\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 4713a5f1a..27b1fdda9 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -39,9 +39,9 @@ namespace Filter { Brightness filter. Filter's parameters: - * Strength (-10.->10., default 10) -> colorMatrix (RVB entries [/10]) - * Vibration (-10.->10., default 0.) -> colorMatrix (6 other entries [/10]) - * Lightness (-10.->10., default 0.) -> colorMatrix (last column [/10]) + * Strength (-10.->10., default 1) -> colorMatrix (RVB entries) + * Vibration (-10.->10., default 0.) -> colorMatrix (6 other entries) + * Lightness (-10.->10., default 0.) -> colorMatrix (last column) Matrix: St Vi Vi 0 Li @@ -62,9 +62,9 @@ public: "\n" "" N_("Brightness, custom (Color)") "\n" "org.inkscape.effect.filter.Brightness\n" - "10\n" - "0\n" - "0\n" + "1\n" + "0\n" + "0\n" "\n" "all\n" "\n" @@ -87,9 +87,9 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream vibration; std::ostringstream lightness; - strength << (ext->get_param_float("strength") / 10); - vibration << (ext->get_param_float("vibration") / 10); - lightness << (ext->get_param_float("lightness") / 10); + strength << ext->get_param_float("strength"); + vibration << ext->get_param_float("vibration"); + lightness << ext->get_param_float("lightness"); _filter = g_strdup_printf( "\n" @@ -427,10 +427,10 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) Customize greyscale components. Filter's parameters: - * Red (-100.->100., default 2.1) -> colorMatrix (values [/10]) - * Green (-100.->100., default 7.2) -> colorMatrix (values [/10]) - * Blue (-100.->100., default 0.72) -> colorMatrix (values [/10]) - * Lightness (-100.->100., default 0.) -> colorMatrix (values [/10]) + * Red (-10.->10., default .21) -> colorMatrix (values) + * Green (-10.->10., default .72) -> colorMatrix (values) + * Blue (-10.->10., default .072) -> colorMatrix (values) + * Lightness (-10.->10., default 0.) -> colorMatrix (values) * Transparent (boolean, default false) -> matrix structure Matrix: @@ -453,10 +453,10 @@ public: "\n" "" N_("Greyscale, custom (Color)") "\n" "org.inkscape.effect.filter.Greyscale\n" - "2.1\n" - "7.2\n" - "0.72\n" - "0\n" + "0.21\n" + "0.72\n" + "0.072\n" + "0\n" "false\n" "\n" "all\n" @@ -487,15 +487,15 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream transparency; std::ostringstream line; - red << (ext->get_param_float("red") / 10); - green << (ext->get_param_float("green") / 10); - blue << (ext->get_param_float("blue") / 10); - strength << (ext->get_param_float("strength") / 10); + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + strength << ext->get_param_float("strength"); - redt << - (ext->get_param_float("red") / 10); - greent << - (ext->get_param_float("green") / 10); - bluet << - (ext->get_param_float("blue") / 10); - strengtht << 1 - (ext->get_param_float("strength") / 10); + redt << - ext->get_param_float("red"); + greent << - ext->get_param_float("green"); + bluet << - ext->get_param_float("blue"); + strengtht << 1 - ext->get_param_float("strength"); if (ext->get_param_bool("transparent")) { line << "0 0 0 0"; @@ -518,9 +518,9 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) Modify lights and shadows separately. Filter's parameters: - * Lightness (0.->200., default 10.) -> component (amplitude [/10]) - * Shadow (0.->200., default 10.) -> component (exponent [/10]) - * Offset (-10.->10., default 0.) -> component (offset [/10]) + * Lightness (0.->20., default 1.) -> component (amplitude) + * Shadow (0.->20., default 1.) -> component (exponent) + * Offset (-1.->1., default 0.) -> component (offset) */ class Lightness : public Inkscape::Extension::Internal::Filter::Filter { protected: @@ -535,9 +535,9 @@ public: "\n" "" N_("Lightness, custom (Color)") "\n" "org.inkscape.effect.filter.Lightness\n" - "10.0\n" - "10.0\n" - "0.0\n" + "1\n" + "1\n" + "0\n" "\n" "all\n" "\n" @@ -560,9 +560,9 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream exponent; std::ostringstream offset; - amplitude << (ext->get_param_float("amplitude") / 10); - exponent << (ext->get_param_float("exponent") / 10); - offset << (ext->get_param_float("offset") / 10); + amplitude << ext->get_param_float("amplitude"); + exponent << ext->get_param_float("exponent"); + offset << ext->get_param_float("offset"); _filter = g_strdup_printf( "\n" @@ -604,14 +604,14 @@ public: "\n" "" N_("Quadritone fantasy, custom (Color)") "\n" "org.inkscape.effect.filter.Quadritone\n" - "280\n" + "280\n" "100\n" "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"screen\">" N_("Screen") "\n" "\n" - "0\n" + "0\n" "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"screen\">" N_("Screen") "\n" @@ -691,7 +691,7 @@ public: "\n" "" N_("Solarize, custom (Color)") "\n" "org.inkscape.effect.filter.Solarize\n" - "0\n" + "0\n" "\n" "<_item value=\"solarize\">" N_("Solarize") "\n" "<_item value=\"moonarize\">" N_("Moonarize") "\n" @@ -802,7 +802,7 @@ public: "1\n" "\n" "\n" - "0\n" + "0\n" "-73203457\n" "\n" "\n" diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 696216a71..01bce4b61 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -46,8 +46,8 @@ namespace Filter { * Drawing blend (enum, default Normal) -> blend1 (mode) * Smoothness (0.01->10, default 1) -> blur1 (stdDeviation) * Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1") - * Grain x frequency (0.->100, default 100) -> turbulence1 (baseFrequency, first value) - * Grain y frequency (0.->100, default 100) -> turbulence1 (baseFrequency, second value) + * Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value) + * Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value) * Grain complexity (1->5, default 1) -> turbulence1 (numOctaves) * Grain variation (0->1000, default 0) -> turbulence1 (seed) * Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value) @@ -81,19 +81,19 @@ public: "false\n" "false\n" "false\n" - "0\n" - "1\n" + "0\n" + "1\n" "10\n" - "1\n" + "1\n" "\n" "\n" "true\n" - "100\n" - "100\n" + "1000\n" + "1000\n" "1\n" "0\n" - "1\n" - "0\n" + "1\n" + "0\n" "true\n" "\n" "<_item value=\"normal\">Normal\n" @@ -168,8 +168,8 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) b2in << "colormatrix2"; else b2in << "blur1"; - grainxf << (ext->get_param_float("grainxf") / 100); - grainyf << (ext->get_param_float("grainyf") / 100); + grainxf << (ext->get_param_float("grainxf") / 1000); + grainyf << (ext->get_param_float("grainyf") / 1000); grainc << ext->get_param_int("grainc"); grainv << ext->get_param_int("grainv"); gblend << ext->get_param_enum("gblend"); @@ -332,16 +332,16 @@ public: "\n" "\n" "<_param name=\"simplifyheader\" type=\"groupheader\">Simplify\n" - "0.6\n" + "0.6\n" "10\n" "0\n" "false\n" "<_param name=\"smoothheader\" type=\"groupheader\">Smoothness\n" - "0.6\n" + "0.6\n" "6\n" "2\n" "<_param name=\"meltheader\" type=\"groupheader\">Melt\n" - "1\n" + "1\n" "6\n" "2\n" "\n" @@ -500,9 +500,9 @@ public: "<_item value=\"table\">Smoothed\n" "<_item value=\"discrete\">Contrasted\n" "\n" - "1.5\n" - "1.5\n" - "0.5\n" + "1.5\n" + "1.5\n" + "0.5\n" "\n" "<_item value=\"normal\">Normal\n" "<_item value=\"multiply\">Multiply\n" @@ -582,8 +582,8 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) * Transfer type (enum, default "descrete") -> component (type) * Levels (1->15, default 5) -> component (tableValues) * Blend mode (enum, default "Lighten") -> blend (mode) - * Primary blur (0.01->100., default 4.) -> blur1 (stdDeviation) - * Secondary blur (0.01->100., default 0.5) -> blur2 (stdDeviation) + * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) + * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) * Pre-saturation (0.->1., default 1.) -> color1 (values) * Post-saturation (0.->1., default 1.) -> color2 (values) * Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01) @@ -615,10 +615,10 @@ public: "<_item value=\"normal\">Normal\n" "<_item value=\"darken\">Darken\n" "\n" - "4.0\n" - "0.5\n" - "1.00\n" - "1.00\n" + "4.0\n" + "0.5\n" + "1.00\n" + "1.00\n" "false\n" "\n" "all\n" @@ -716,7 +716,7 @@ public: "" N_("Posterize basic, custom") "\n" "org.inkscape.effect.filter.PosterizeBasic\n" "5\n" - "4.0\n" + "4.0\n" "\n" "all\n" "\n" diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index bd127eb68..f52920158 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -54,7 +54,7 @@ public: "<_item value=\"edges\">Smooth edges\n" "<_item value=\"all\">Smooth all\n" "\n" - "5\n" + "5\n" "\n" "all\n" "\n" -- cgit v1.2.3 From ab5c39d6151762215e0fa7e1bbd159e40bc751ab Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 17 Mar 2011 20:13:06 +0100 Subject: Linked Offset. Merge branch lp:~ado-papas/inkscape/bug_167419 (Bug #167419, Bug #184341, Bug #239430). (bzr r10109) --- src/selection-chemistry.cpp | 19 ++++++++++++++++--- src/sp-offset.cpp | 45 +++++++++++++++++++++++++++++++-------------- src/splivarot.cpp | 7 ++----- 3 files changed, 49 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 082c447d0..67aba5218 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1379,7 +1379,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons * Same for textpath if we are also doing ANY transform to its path: do not touch textpath, * letters cannot be squeezed or rotated anyway, they only refill the changed path. * Same for linked offset if we are also moving its source: do not move it. */ - if (transform_textpath_with_path || transform_offset_with_source) { + if (transform_textpath_with_path) { // Restore item->transform field from the repr, in case it was changed by seltrans. item->readAttr( "transform" ); } else if (transform_flowtext_with_frame) { @@ -1394,7 +1394,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } } } - } else if (transform_clone_with_original) { + } else if (transform_clone_with_original || transform_offset_with_source) { // We are transforming a clone along with its original. The below matrix juggling is // necessary to ensure that they transform as a whole, i.e. the clone's induced // transform and its move compensation are both cancelled out. @@ -1408,7 +1408,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons Geom::Affine t_inv = t.inverse(); Geom::Affine result = t_inv * item->transform * t; - if ((prefs_parallel || prefs_unmoved) && affine.isTranslation()) { + if (transform_clone_with_original && (prefs_parallel || prefs_unmoved) && affine.isTranslation()) { // we need to cancel out the move compensation, too // find out the clone move, same as in sp_use_move_compensate @@ -1426,6 +1426,19 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons item->doWriteTransform(item->getRepr(), move, &t, compensate); } + } else if (transform_offset_with_source && (prefs_parallel || prefs_unmoved) && affine.isTranslation()){ + Geom::Affine parent = item->transform; + Geom::Affine offset_move = parent.inverse() * t * parent; + + if (prefs_parallel) { + Geom::Affine move = result * offset_move * t_inv; + item->doWriteTransform(item->getRepr(), move, &move, compensate); + + } else if (prefs_unmoved) { + Geom::Affine move = result * offset_move; + item->doWriteTransform(item->getRepr(), move, &t, compensate); + } + } else { // just apply the result item->doWriteTransform(item->getRepr(), result, &t, compensate); diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 5cad7540d..57c04f31f 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -1029,30 +1029,37 @@ sp_offset_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPOffset { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL); - if (mode == SP_CLONE_COMPENSATION_NONE) return; + + SPItem *item = SP_ITEM(self); Geom::Affine m(*mp); - if (!(m.isTranslation())) return; + if (!(m.isTranslation()) || mode == SP_CLONE_COMPENSATION_NONE) { + self->sourceDirty=true; + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + return; + } // calculate the compensation matrix and the advertized movement matrix - SPItem *item = SP_ITEM(self); + item->readAttr("transform"); - Geom::Affine compensate; - Geom::Affine advertized_move; + Geom::Affine t = self->transform; + Geom::Affine offset_move = t.inverse() * m * t; - if (mode == SP_CLONE_COMPENSATION_UNMOVED) { - compensate = Geom::identity(); - advertized_move.setIdentity(); - } else if (mode == SP_CLONE_COMPENSATION_PARALLEL) { - compensate = m; + Geom::Affine advertized_move; + if (mode == SP_CLONE_COMPENSATION_PARALLEL) { + offset_move = offset_move.inverse() * m; advertized_move = m; + } else if (mode == SP_CLONE_COMPENSATION_UNMOVED) { + offset_move = offset_move.inverse(); + advertized_move.setIdentity(); } else { g_assert_not_reached(); } - item->transform *= compensate; + self->sourceDirty=true; // commit the compensation + item->transform *= offset_move; item->doWriteTransform(item->getRepr(), item->transform, &advertized_move); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -1075,12 +1082,13 @@ sp_offset_delete_self(SPObject */*deleted*/, SPOffset *offset) } static void -sp_offset_source_modified (SPObject */*iSource*/, guint /*flags*/, SPItem *item) +sp_offset_source_modified (SPObject */*iSource*/, guint flags, SPItem *item) { SPOffset *offset = SP_OFFSET(item); offset->sourceDirty=true; - refresh_offset_source(offset); - ((SPShape *) offset)->setShape (); + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG)) { + offset->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } } static void @@ -1111,6 +1119,15 @@ refresh_offset_source(SPOffset* offset) orig->LoadPathVector(curve->get_pathvector()); curve->unref(); + if (!item->transform.isIdentity()) { + gchar const *t_attr = item->getRepr()->attribute("transform"); + if (t_attr) { + Geom::Affine t; + if (sp_svg_transform_read(t_attr, &t)) { + orig->Transform(t); + } + } + } // Finish up. { diff --git a/src/splivarot.cpp b/src/splivarot.cpp index c01296b0e..9c2fc8ff9 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1487,6 +1487,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat if ( updating ) { //XML Tree being used directly here while it shouldn't be + item->doWriteTransform(item->getRepr(), transform); char const *id = item->getRepr()->attribute("id"); char const *uri = g_strdup_printf("#%s", id); repr->setAttribute("xlink:href", uri); @@ -1505,11 +1506,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat SPItem *nitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); - if ( updating ) { - // on conserve l'original - // we reapply the transform to the original (offset will feel it) - item->doWriteTransform(item->getRepr(), transform); - } else { + if ( !updating ) { // delete original, apply the transform to the offset item->deleteObject(false); nitem->doWriteTransform(repr, transform); -- cgit v1.2.3 From beeff0c9a0e6a90676a9bcdfe5e3246845d5e775 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 17 Mar 2011 20:27:32 +0100 Subject: Preferences. Fix for Bug #686193 (Make linked offsets respect Relink duplicated clones settings). Fixed bugs: - https://launchpad.net/bugs/686193 (bzr r10110) --- src/ui/dialog/inkscape-preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index d10902722..e365dcde7 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -659,7 +659,7 @@ void InkscapePreferences::initPageClones() _page_clones.add_line( true, "", _clone_option_delete, "", _("Orphaned clones are deleted along with their original")); - _page_clones.add_group_header( _("When duplicating original+clones:")); + _page_clones.add_group_header( _("When duplicating original+clones/linked offset:")); _clone_relink_on_duplicate.init ( _("Relink duplicated clones"), "/options/relinkclonesonduplicate/value", false); _page_clones.add_line(true, "", _clone_relink_on_duplicate, "", -- cgit v1.2.3 From 0e9b99912c3aaa712303c851b7ba22b8f6671775 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 17 Mar 2011 20:52:31 +0100 Subject: Last renamings of headers in Inkscape preferences (Bug #560751) (bzr r10111) --- src/ui/dialog/inkscape-preferences.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index e365dcde7..8681ed98f 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -393,7 +393,7 @@ void InkscapePreferences::initPageTools() Gtk::TreeModel::iterator iter_tools = this->AddPage(_page_tools, _("Tools"), PREFS_PAGE_TOOLS); _path_tools = _page_list.get_model()->get_path(iter_tools); - _page_tools.add_group_header( _("Bounding box to use:")); + _page_tools.add_group_header( _("Bounding box to use")); _t_bbox_visual.init ( _("Visual bounding box"), "/tools/bounding_box", 0, false, 0); // 0 means visual _page_tools.add_line( true, "", _t_bbox_visual, "", _("This bounding box includes stroke width, markers, filter margins, etc.")); @@ -401,7 +401,7 @@ void InkscapePreferences::initPageTools() _page_tools.add_line( true, "", _t_bbox_geometric, "", _("This bounding box includes only the bare path")); - _page_tools.add_group_header( _("Conversion to guides:")); + _page_tools.add_group_header( _("Conversion to guides")); _t_cvg_keep_objects.init ( _("Keep objects after conversion to guides"), "/tools/cvg_keep_objects", false); _page_tools.add_line( true, "", _t_cvg_keep_objects, "", _("When converting an object to guides, don't delete the object after the conversion")); @@ -418,14 +418,14 @@ void InkscapePreferences::initPageTools() this->AddPage(_page_selector, _("Selector"), iter_tools, PREFS_PAGE_TOOLS_SELECTOR); AddSelcueCheckbox(_page_selector, "/tools/select", false); - _page_selector.add_group_header( _("When transforming, show:")); + _page_selector.add_group_header( _("When transforming, show")); _t_sel_trans_obj.init ( _("Objects"), "/tools/select/show", "content", true, 0); _page_selector.add_line( true, "", _t_sel_trans_obj, "", _("Show the actual objects when moving or transforming")); _t_sel_trans_outl.init ( _("Box outline"), "/tools/select/show", "outline", false, &_t_sel_trans_obj); _page_selector.add_line( true, "", _t_sel_trans_outl, "", _("Show only a box outline of the objects when moving or transforming")); - _page_selector.add_group_header( _("Per-object selection cue:")); + _page_selector.add_group_header( _("Per-object selection cue")); _t_sel_cue_none.init ( _("None"), "/options/selcue/value", Inkscape::SelCue::NONE, false, 0); _page_selector.add_line( true, "", _t_sel_cue_none, "", _("No per-object selection indication")); @@ -646,20 +646,20 @@ void InkscapePreferences::initPageClones() _clone_option_delete.init ( _("Are deleted"), "/options/cloneorphans/value", SP_CLONE_ORPHANS_DELETE, false, &_clone_option_unlink); - _page_clones.add_group_header( _("When the original moves, its clones and linked offsets:")); + _page_clones.add_group_header( _("Moving original: clones and linked offsets")); _page_clones.add_line( true, "", _clone_option_parallel, "", _("Clones are translated by the same vector as their original")); _page_clones.add_line( true, "", _clone_option_stay, "", _("Clones preserve their positions when their original is moved")); _page_clones.add_line( true, "", _clone_option_transform, "", _("Each clone moves according to the value of its transform= attribute; for example, a rotated clone will move in a different direction than its original")); - _page_clones.add_group_header( _("When the original is deleted, its clones:")); + _page_clones.add_group_header( _("Deleting original: clones")); _page_clones.add_line( true, "", _clone_option_unlink, "", _("Orphaned clones are converted to regular objects")); _page_clones.add_line( true, "", _clone_option_delete, "", _("Orphaned clones are deleted along with their original")); - _page_clones.add_group_header( _("When duplicating original+clones/linked offset:")); + _page_clones.add_group_header( _("Duplicating original+clones/linked offset")); _clone_relink_on_duplicate.init ( _("Relink duplicated clones"), "/options/relinkclonesonduplicate/value", false); _page_clones.add_line(true, "", _clone_relink_on_duplicate, "", -- cgit v1.2.3 From 13616aaa0cbfcbc1386574e108d716bb4fccefc9 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 17 Mar 2011 21:45:52 +0100 Subject: Added some mnemonics for filter path effects (Bug #170765) (bzr r10112) --- src/live_effects/lpe-interpolate.cpp | 4 ++-- src/live_effects/lpe-knot.cpp | 10 +++++----- src/live_effects/lpe-patternalongpath.cpp | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index 47965749e..b8ce721a1 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -28,8 +28,8 @@ namespace LivePathEffect { LPEInterpolate::LPEInterpolate(LivePathEffectObject *lpeobject) : Effect(lpeobject), trajectory_path(_("Trajectory:"), _("Path along which intermediate steps are created."), "trajectory", &wr, this, "M0,0 L0,0"), - number_of_steps(_("Steps:"), _("Determines the number of steps from start to end path."), "steps", &wr, this, 5), - equidistant_spacing(_("Equidistant spacing"), _("If true, the spacing between intermediates is constant along the length of the path. If false, the distance depends on the location of the nodes of the trajectory path."), "equidistant_spacing", &wr, this, true) + number_of_steps(_("Steps_:"), _("Determines the number of steps from start to end path."), "steps", &wr, this, 5), + equidistant_spacing(_("E_quidistant spacing"), _("If true, the spacing between intermediates is constant along the length of the path. If false, the distance depends on the location of the nodes of the trajectory path."), "equidistant_spacing", &wr, this, true) { show_orig_path = true; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index e45515a8e..522b3cdc6 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -340,11 +340,11 @@ CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - interruption_width(_("Fixed width:"), _("Size of hidden region of lower string"), "interruption_width", &wr, this, 3), - prop_to_stroke_width(_("In units of stroke width"), _("Consider 'Interruption width' as a ratio of stroke width"), "prop_to_stroke_width", &wr, this, true), - add_stroke_width(_("Stroke width"), _("Add the stroke width to the interruption size"), "add_stroke_width", &wr, this, true), - add_other_stroke_width(_("Crossing path stroke width"), _("Add crossed stroke width to the interruption size"), "add_other_stroke_width", &wr, this, true), - switcher_size(_("Switcher size:"), _("Orientation indicator/switcher size"), "switcher_size", &wr, this, 15), + interruption_width(_("Fi_xed width:"), _("Size of hidden region of lower string"), "interruption_width", &wr, this, 3), + prop_to_stroke_width(_("_In units of stroke width"), _("Consider 'Interruption width' as a ratio of stroke width"), "prop_to_stroke_width", &wr, this, true), + add_stroke_width(_("St_roke width"), _("Add the stroke width to the interruption size"), "add_stroke_width", &wr, this, true), + add_other_stroke_width(_("_Crossing path stroke width"), _("Add crossed stroke width to the interruption size"), "add_other_stroke_width", &wr, this, true), + switcher_size(_("S_witcher size:"), _("Orientation indicator/switcher size"), "switcher_size", &wr, this, 15), crossing_points_vector(_("Crossing Signs"), _("Crossings signs"), "crossing_points_vector", &wr, this), gpaths(),gstroke_widths() { diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index bbcf9b1c3..b1af4c149 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -61,22 +61,22 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : pattern(_("Pattern source:"), _("Path to put along the skeleton path"), "pattern", &wr, this, "M0,0 L1,0"), copytype(_("Pattern copies:"), _("How many pattern copies to place along the skeleton path"), "copytype", PAPCopyTypeConverter, &wr, this, PAPCT_SINGLE_STRETCHED), - prop_scale(_("Width:"), _("Width of the pattern"), "prop_scale", &wr, this, 1), - scale_y_rel(_("Width in units of length"), + prop_scale(_("_Width:"), _("Width of the pattern"), "prop_scale", &wr, this, 1), + scale_y_rel(_("Wid_th in units of length"), _("Scale the width of the pattern in units of its length"), "scale_y_rel", &wr, this, false), - spacing(_("Spacing:"), + spacing(_("Spa_cing:"), // xgettext:no-c-format _("Space between copies of the pattern. Negative values allowed, but are limited to -90% of pattern width."), "spacing", &wr, this, 0), - normal_offset(_("Normal offset:"), "", "normal_offset", &wr, this, 0), - tang_offset(_("Tangential offset:"), "", "tang_offset", &wr, this, 0), - prop_units(_("Offsets in unit of pattern size"), + normal_offset(_("No_rmal offset:"), "", "normal_offset", &wr, this, 0), + tang_offset(_("Tan_gential offset:"), "", "tang_offset", &wr, this, 0), + prop_units(_("Offsets in _unit of pattern size"), _("Spacing, tangential and normal offset are expressed as a ratio of width/height"), "prop_units", &wr, this, false), - vertical_pattern(_("Pattern is vertical"), _("Rotate pattern 90 deg before applying"), + vertical_pattern(_("Pattern is _vertical"), _("Rotate pattern 90 deg before applying"), "vertical_pattern", &wr, this, false), - fuse_tolerance(_("Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), + fuse_tolerance(_("_Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), "fuse_tolerance", &wr, this, 0) { registerParameter( dynamic_cast(&pattern) ); -- cgit v1.2.3 From 8c030bdedb7897361e44e2be67e462bde0292f67 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 18 Mar 2011 07:49:03 +0100 Subject: Layers. Fix for Bug #249035: Undo crash when executing extensions. Fixed bugs: - https://launchpad.net/bugs/249035 (bzr r10113) --- src/ui/widget/layer-selector.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 7111e17be..ba4629c82 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -236,6 +236,8 @@ void LayerSelector::_selectLayer(SPObject *layer) { using Inkscape::Util::reverse_list; _selection_changed_connection.block(); + _visibility_toggled_connection.block(); + _lock_toggled_connection.block(); while (!_layer_model->children().empty()) { Gtk::ListStore::iterator first_row(_layer_model->children().begin()); @@ -285,6 +287,8 @@ void LayerSelector::_selectLayer(SPObject *layer) { _lock_toggle.set_active(( SP_IS_ITEM(layer) ? SP_ITEM(layer)->isLocked() : false )); } + _lock_toggled_connection.unblock(); + _visibility_toggled_connection.unblock(); _selection_changed_connection.unblock(); } -- cgit v1.2.3 From 2de761f0c46b4f3164d0dc008320da3ad0f35316 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 18 Mar 2011 21:29:06 +0100 Subject: D-Bus. Merging branch lp:~joakim-verona/inkscape/dbus-fixes (Bug #666986, Bug #707054 and Bug #707364). (bzr r10114) --- src/display/canvas-text.h | 1 + src/document.cpp | 6 ++- src/extension/dbus/dbus-init.cpp | 3 -- src/extension/dbus/document-interface.cpp | 52 +++++++++++++++++----- src/extension/dbus/document-interface.h | 7 ++- src/extension/dbus/document-interface.xml | 29 ++++++++++++ src/extension/dbus/wrapper/inkscape-dbus-wrapper.c | 6 ++- src/extension/dbus/wrapper/inkscape-dbus-wrapper.h | 2 +- 8 files changed, 87 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index d8bd86b7d..9a6a93eb4 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -53,6 +53,7 @@ void sp_canvastext_set_anchor (SPCanvasText *ct, double anchor_x, double anchor_ #endif // SEEN_SP_CANVASTEXT_H + /* Local Variables: mode:c++ diff --git a/src/document.cpp b/src/document.cpp index 2a9ad9144..67ce3e26a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -848,7 +848,11 @@ SPObject *SPDocument::getObjectById(gchar const *id) const g_return_val_if_fail(id != NULL, NULL); GQuark idq = g_quark_from_string(id); - return (SPObject*)g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); + gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); + if(rv != NULL) + return (SPObject*)rv; + else + return NULL; } sigc::connection SPDocument::connectIdChanged(gchar const *id, diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index 9c562d169..3e453d048 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -86,7 +86,6 @@ init (void) GError *error = NULL; DBusGConnection *connection; DBusGProxy *proxy; - DocumentInterface *obj; connection = dbus_get_connection(); proxy = dbus_get_proxy(connection); org_freedesktop_DBus_request_name (proxy, @@ -102,8 +101,6 @@ init (void) gchar * init_document (void) { - guint result; - GError *error = NULL; DBusGConnection *connection; DBusGProxy *proxy; SPDocument *doc; diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 0e5d8de50..8e22849b5 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -36,6 +36,20 @@ #include "sp-ellipse.h" #include "sp-object.h" #include "style.h" //style_write + +#include "file.h" //IO + +#include "extension/system.h" //IO + +#include "extension/output.h" //IO + +#include "print.h" //IO + +#include "live_effects/parameter/text.h" //text +#include "display/canvas-text.h" //text + +#include "display/sp-canvas.h" //text +#include "text-editing.h" #include "verbs.h" #include "xml/repr.h" //sp_repr_document_new @@ -61,13 +75,13 @@ get_repr_by_name (SPDesktop *desk, gchar *name, GError **error) /* ALTERNATIVE (is this faster if only repr is needed?) Inkscape::XML::Node *node = sp_repr_lookup_name((doc->root)->repr, name); */ - Inkscape::XML::Node * node = sp_desktop_document(desk)->getObjectById(name)->getRepr(); - if (!node) + SPObject * obj = sp_desktop_document(desk)->getObjectById(name); + if (!obj) { g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name); return NULL; } - return node; + return obj->getRepr(); } /* @@ -346,6 +360,7 @@ document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError * if (object->updates) { Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); } + return TRUE; } } } @@ -470,17 +485,20 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy, return retval; } -gboolean +gchar* document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error) { - //FIXME: Not selectable (aka broken). Needs to be rewritten completely. - SPDesktop *desktop = object->desk; - SPCanvasText * canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), ""); - sp_canvastext_set_text (canvas_text, text); - sp_canvastext_set_coords (canvas_text, x, y); + Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "svg:text"); + sp_repr_set_int(text_node, "x", x); + sp_repr_set_int(text_node, "y", y); + //just a workaround so i can get an spitem from the name + gchar *name = finish_create_shape (object, error, text_node, (gchar *)"create text"); + + SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + sp_te_set_repr_text_multiline(text_obj, text); - return TRUE; + return name; } gchar * @@ -809,6 +827,20 @@ document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape } +gboolean +document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error) +{ + + SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + //TODO verify object type + if (!text_obj) + return FALSE; + sp_te_set_repr_text_multiline(text_obj, text); + return TRUE; + +} + + /**************************************************************************** FILE I/O FUNCTIONS ****************************************************************************/ diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index 12e033918..0283d987e 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -115,10 +115,13 @@ gchar* document_interface_line (DocumentInterface *object, int x, int y, int x2, int y2, GError **error); -gboolean +gchar* document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error); - +gboolean +document_interface_set_text (DocumentInterface *object, gchar *name, + gchar *text, GError **error); + gchar * document_interface_image (DocumentInterface *object, int x, int y, gchar *filename, GError **error); diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml index 8b0252765..94f39ae7e 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -310,6 +310,12 @@ The text you want. + + + + The name of the new text. + + This method creates some text in the current layer. @@ -472,6 +478,29 @@ + + + + + The id of an object. + + + + + + The text you want. + + + + + set text of text object. + + + + + + + diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c index b59ee746b..7a33d4f38 100644 --- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c +++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c @@ -198,11 +198,13 @@ inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const g } //static -gboolean +char * inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error) { + char * OUT_object_name; DBusGProxy *proxy = doc->proxy; - return org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, error); + org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, &OUT_object_name, error); + return OUT_object_name; } //static diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h index c314bf6f8..684f1b142 100644 --- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h +++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h @@ -72,7 +72,7 @@ char * inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_x2, const gint IN_y2, GError **error); //static -gboolean +char * inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error); //static -- cgit v1.2.3 From 4d22a9f26c863dcb99bf1a6f72c3b4a2d33eeb64 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 19 Mar 2011 00:34:21 +0100 Subject: add spiro interpolator to powerstroke (bzr r10115) --- src/live_effects/lpe-powerstroke.cpp | 165 +++++++++++++++++++++++++++++++++-- src/live_effects/lpe-powerstroke.h | 2 + 2 files changed, 161 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 5dc170e84..3556be61f 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -21,18 +21,31 @@ #include <2geom/transforms.h> #include <2geom/bezier-utils.h> +#include "live_effects/bezctx.h" +#include "live_effects/bezctx_intf.h" +#include "live_effects/spiro.h" + /// @TODO Move this to 2geom namespace Geom { namespace Interpolate { +enum InterpolatorType { + INTERP_LINEAR, + INTERP_CUBICBEZIER, + INTERP_CUBICBEZIER_JOHAN, + INTERP_SPIRO +}; + class Interpolator { public: Interpolator() {}; virtual ~Interpolator() {}; + static Interpolator* create(InterpolatorType type); + // virtual Piecewise > interpolateToPwD2Sb(std::vector points) = 0; - virtual Path interpolateToPath(std::vector points) = 0; + virtual Geom::Path interpolateToPath(std::vector points) = 0; private: Interpolator(const Interpolator&); @@ -120,16 +133,153 @@ private: CubicBezierJohan& operator=(const CubicBezierJohan&); }; + +#define SPIRO_SHOW_INFINITE_COORDINATE_CALLS +class SpiroInterpolator : public Interpolator { +public: + SpiroInterpolator() {}; + virtual ~SpiroInterpolator() {}; + + virtual Path interpolateToPath(std::vector points) { + Path fit; + + Coord scale_y = 100.; + + guint len = points.size(); + bezctx *bc = new_bezctx_ink(&fit); + spiro_cp *controlpoints = g_new (spiro_cp, len); + for (unsigned int i = 0; i < len; ++i) { + controlpoints[i].x = points[i][X]; + controlpoints[i].y = points[i][Y] / scale_y; + controlpoints[i].ty = 'c'; + } + controlpoints[0].ty = '{'; + controlpoints[1].ty = 'v'; + controlpoints[len-2].ty = 'v'; + controlpoints[len-1].ty = '}'; + + spiro_seg *s = run_spiro(controlpoints, len); + spiro_to_bpath(s, len, bc); + free(s); + free(bc); + + fit *= Scale(1,scale_y); + return fit; + }; + +private: + typedef struct { + bezctx base; + Path *path; + int is_open; + } bezctx_ink; + + static void bezctx_ink_moveto(bezctx *bc, double x, double y, int /*is_open*/) + { + bezctx_ink *bi = (bezctx_ink *) bc; + if ( IS_FINITE(x) && IS_FINITE(y) ) { + bi->path->start(Point(x, y)); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro moveto not finite"); + } + #endif + } + + static void bezctx_ink_lineto(bezctx *bc, double x, double y) + { + bezctx_ink *bi = (bezctx_ink *) bc; + if ( IS_FINITE(x) && IS_FINITE(y) ) { + bi->path->appendNew( Point(x, y) ); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro lineto not finite"); + } + #endif + } + + static void bezctx_ink_quadto(bezctx *bc, double xm, double ym, double x3, double y3) + { + bezctx_ink *bi = (bezctx_ink *) bc; + + if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) { + bi->path->appendNew(Point(xm, ym), Point(x3, y3)); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro quadto not finite"); + } + #endif + } + + static void bezctx_ink_curveto(bezctx *bc, double x1, double y1, double x2, double y2, + double x3, double y3) + { + bezctx_ink *bi = (bezctx_ink *) bc; + if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) { + bi->path->appendNew(Point(x1, y1), Point(x2, y2), Point(x3, y3)); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro curveto not finite"); + } + #endif + } + + bezctx * + new_bezctx_ink(Geom::Path *path) { + bezctx_ink *result = g_new(bezctx_ink, 1); + result->base.moveto = bezctx_ink_moveto; + result->base.lineto = bezctx_ink_lineto; + result->base.quadto = bezctx_ink_quadto; + result->base.curveto = bezctx_ink_curveto; + result->base.mark_knot = NULL; + result->path = path; + return &result->base; + } + + SpiroInterpolator(const SpiroInterpolator&); + SpiroInterpolator& operator=(const SpiroInterpolator&); +}; + + +Interpolator* +Interpolator::create(InterpolatorType type) { + switch (type) { + case INTERP_LINEAR: + return new Geom::Interpolate::Linear(); + case INTERP_CUBICBEZIER: + return new Geom::Interpolate::CubicBezierFit(); + case INTERP_CUBICBEZIER_JOHAN: + return new Geom::Interpolate::CubicBezierJohan(); + case INTERP_SPIRO: + return new Geom::Interpolate::SpiroInterpolator(); + default: + return new Geom::Interpolate::Linear(); + } +} + } //namespace Interpolate } //namespace Geom namespace Inkscape { namespace LivePathEffect { +static const Util::EnumData InterpolatorTypeData[] = { + {Geom::Interpolate::INTERP_LINEAR , N_("Linear"), "Linear"}, + {Geom::Interpolate::INTERP_CUBICBEZIER , N_("CubicBezierFit"), "CubicBezierFit"}, + {Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN , N_("CubicBezierJohan"), "CubicBezierJohan"}, + {Geom::Interpolate::INTERP_SPIRO , N_("SpiroInterpolator"), "SpiroInterpolator"} +}; +static const Util::EnumDataConverter InterpolatorTypeConverter(InterpolatorTypeData, sizeof(InterpolatorTypeData)/sizeof(*InterpolatorTypeData)); + LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), - sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true) + sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true), + interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN) { show_orig_path = true; @@ -137,6 +287,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&offset_points) ); registerParameter( dynamic_cast(&sort_points) ); + registerParameter( dynamic_cast(&interpolator_type) ); } LPEPowerStroke::~LPEPowerStroke() @@ -195,9 +346,11 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & } // create stroke path where points (x,y) := (t, offset) - Geom::Interpolate::CubicBezierJohan interpolator; - Path strokepath = interpolator.interpolateToPath(ts); - Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); + //Geom::Interpolate::CubicBezierJohan interpolator; + Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); + Geom::Path strokepath = interpolator->interpolateToPath(ts); + Geom::Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); + delete interpolator; strokepath.append(mirroredpath, Geom::Path::STITCH_DISCONTINUOUS); strokepath.close(); @@ -222,7 +375,7 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & ts.push_back( first_point + Point(pwd2_in.domain().extent() ,0) ); // create stroke path where points (x,y) := (t, offset) Geom::Interpolate::CubicBezierJohan interpolator; - Path strokepath = interpolator.interpolateToPath(ts); + Geom::Path strokepath = interpolator.interpolateToPath(ts); // output 2 separate paths D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 667c94f53..7a1f3829a 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -15,6 +15,7 @@ #include "live_effects/effect.h" #include "live_effects/parameter/bool.h" #include "live_effects/parameter/powerstrokepointarray.h" +#include "live_effects/parameter/enum.h" namespace Inkscape { namespace LivePathEffect { @@ -31,6 +32,7 @@ public: private: PowerStrokePointArrayParam offset_points; BoolParam sort_points; + EnumParam interpolator_type; LPEPowerStroke(const LPEPowerStroke&); LPEPowerStroke& operator=(const LPEPowerStroke&); -- cgit v1.2.3 From 4e01c64b6094fa1f4bf63ec8a8f77cf21696b711 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 19 Mar 2011 23:42:59 -0700 Subject: Cleaned up memory patch. Fixes bug #737298. Fixed bugs: - https://launchpad.net/bugs/737298 (bzr r10118) --- src/desktop.cpp | 3 +++ src/ege-adjustment-action.cpp | 25 ++++++++++++------------ src/ege-output-action.cpp | 2 ++ src/ege-select-one-action.cpp | 26 ++++++++++++++----------- src/extension/internal/filter/filter-file.cpp | 10 ++++++---- src/ink-action.cpp | 6 ++++-- src/inkscape.cpp | 28 +++++++++++++++++---------- src/interface.cpp | 16 +++++++++++---- src/libnrtype/FontFactory.cpp | 14 ++++++++++++-- src/preferences.cpp | 3 +++ 10 files changed, 87 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index f132ec897..a6224a71c 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -779,6 +779,9 @@ SPDesktop::push_current_zoom (GList **history) ( ((NRRect *) ((*history)->data))->y1 == old_zoom->y1 ) ) ) { *history = g_list_prepend (*history, old_zoom); + } else { + g_free(old_zoom); + old_zoom = 0; } } diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 17e11db2d..c075d67e7 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -770,20 +770,18 @@ static GtkWidget* create_menu_item( GtkAction* action ) if ( IS_EGE_ADJUSTMENT_ACTION(action) ) { EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action ); GValue value; - const gchar* sss = 0; GtkWidget* subby = 0; memset( &value, 0, sizeof(value) ); g_value_init( &value, G_TYPE_STRING ); g_object_get_property( G_OBJECT(action), "label", &value ); - sss = g_value_get_string( &value ); - - item = gtk_menu_item_new_with_label( sss ); + item = gtk_menu_item_new_with_label( g_value_get_string( &value ) ); subby = create_popup_number_menu( act ); gtk_menu_item_set_submenu( GTK_MENU_ITEM(item), subby ); gtk_widget_show_all( subby ); + g_value_unset( &value ); } else { item = gParentClass->create_menu_item( action ); } @@ -816,8 +814,7 @@ static gboolean event_cb( EgeAdjustmentAction* act, GdkEvent* evt ) return handled; } -static gchar* -slider_format_falue (GtkScale* scale, gdouble value, gchar *label) +static gchar *slider_format_falue( GtkScale* scale, gdouble value, gchar *label ) { (void)scale; return g_strdup_printf("%s %d", label, (int) round(value)); @@ -831,19 +828,18 @@ static GtkWidget* create_tool_item( GtkAction* action ) EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action ); GtkWidget* spinbutton = 0; GtkWidget* hb = gtk_hbox_new( FALSE, 5 ); - GValue value; memset( &value, 0, sizeof(value) ); g_value_init( &value, G_TYPE_STRING ); g_object_get_property( G_OBJECT(action), "short_label", &value ); - const gchar* sss = g_value_get_string( &value ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { - // Slider - spinbutton = gtk_hscale_new( act->private_data->adj); + // Slider + gchar *leakyForNow = g_value_dup_string( &value ); + spinbutton = gtk_hscale_new( act->private_data->adj); gtk_widget_set_size_request(spinbutton, 100, -1); - gtk_scale_set_digits (GTK_SCALE(spinbutton), 0); - gtk_signal_connect(GTK_OBJECT(spinbutton), "format-value", GTK_SIGNAL_FUNC(slider_format_falue), (void *) sss); + gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); + g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); #if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { @@ -869,6 +865,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) } gtk_tooltips_set_tip( act->private_data->toolTips, spinbutton, tipstr, 0 ); } + g_value_unset( &tooltip ); } if ( act->private_data->appearanceMode != APPEARANCE_FULL ) { @@ -880,7 +877,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) GtkWidget* icon = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 ); } else { - GtkWidget* lbl = gtk_label_new( sss ? sss : "wwww" ); + GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" ); gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); } @@ -921,6 +918,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( act->private_data->toolPost ) { act->private_data->toolPost( item ); } + + g_value_unset( &value ); } else { item = gParentClass->create_tool_item( action ); } diff --git a/src/ege-output-action.cpp b/src/ege-output-action.cpp index 62878eb16..72616ce18 100644 --- a/src/ege-output-action.cpp +++ b/src/ege-output-action.cpp @@ -222,6 +222,8 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_container_add( GTK_CONTAINER(item), hb ); gtk_widget_show_all( item ); + + g_value_unset( &value ); } else { item = gParentClass->create_tool_item( action ); } diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 664ffd13d..83a083425 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -663,15 +663,18 @@ GtkWidget* create_tool_item( GtkAction* action ) gint index = 0; GtkTooltips* tooltips = gtk_tooltips_new(); - gchar* sss = 0; - g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); - // If short_label not defined, g_object_get will return label. - // This hack allows a label to be used with a drop-down menu when - // no label is used with a set of icons that are self-explanatory. - if (sss && strcmp( sss, "NotUsed" ) != 0 ) { - GtkWidget* lbl; - lbl = gtk_label_new(sss); - gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); + { + gchar* sss = 0; + g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); + // If short_label not defined, g_object_get will return label. + // This hack allows a label to be used with a drop-down menu when + // no label is used with a set of icons that are self-explanatory. + if (sss && strcmp( sss, "NotUsed" ) != 0 ) { + GtkWidget* lbl = gtk_label_new(sss); + gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); + } + g_free( sss ); + sss = 0; } valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter ); @@ -813,9 +816,10 @@ GtkWidget* create_tool_item( GtkAction* action ) gchar* sss = 0; g_object_get( G_OBJECT(action), "short_label", &sss, NULL ); if (sss) { - GtkWidget* lbl; - lbl = gtk_label_new(sss); + GtkWidget* lbl = gtk_label_new(sss); gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 ); + g_free( sss ); + sss = 0; } } diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index 89afca133..d129f590c 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -26,13 +26,15 @@ namespace Extension { namespace Internal { namespace Filter { -void -Filter::filters_all_files (void) +void Filter::filters_all_files(void) { + gchar *filtersProfilePath = profile_path("filters"); + filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled")); - filters_load_dir(profile_path("filters"), _("Personal")); + filters_load_dir(filtersProfilePath, _("Personal")); - return; + g_free(filtersProfilePath); + filtersProfilePath = 0; } #define INKSCAPE_FILTER_FILE ".svg" diff --git a/src/ink-action.cpp b/src/ink-action.cpp index d8673a3ab..587efdff0 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -441,9 +441,11 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ) gtk_container_add( GTK_CONTAINER(align), child ); gtk_tool_button_set_icon_widget( button, align ); } else { - gchar *label; - g_object_get (G_OBJECT(action), "short_label", &label, NULL); + gchar *label = 0; + g_object_get( G_OBJECT(action), "short_label", &label, NULL ); gtk_tool_button_set_label( button, label ); + g_free( label ); + label = 0; } } else { // For now trigger a warning but don't do anything else diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 430977567..1007c315a 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -875,23 +875,31 @@ gboolean inkscape_use_gui() * Menus management * */ -bool inkscape_load_menus (Inkscape::Application */*inkscape*/) +bool inkscape_load_menus( Inkscape::Application * inkscape ) { - // TODO fix that fn is being leaked gchar *fn = profile_path(MENUS_FILE); - gchar *menus_xml = NULL; + gchar *menus_xml = 0; gsize len = 0; - if (g_file_get_contents(fn, &menus_xml, &len, NULL)) { + if ( inkscape != inkscape_get_instance() ) { + g_warning("BAD BAD BAD THINGS"); + } + + if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) { // load the menus_xml file - INKSCAPE->menus = sp_repr_read_mem(menus_xml, len, NULL); + inkscape->menus = sp_repr_read_mem(menus_xml, len, NULL); + g_free(menus_xml); - if (INKSCAPE->menus) { - return true; - } + menus_xml = 0; } - INKSCAPE->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); - return (INKSCAPE->menus != 0); + g_free(fn); + fn = 0; + + if ( !inkscape->menus ) { + inkscape->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); + } + + return (inkscape->menus != 0); } diff --git a/src/interface.cpp b/src/interface.cpp index f69cd5673..4ac82a509 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -776,12 +776,20 @@ sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) if (dir) { for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) { - if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) + if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) { continue; // skip non-svg files + } - gchar *basename = g_path_get_basename(file); - if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) - continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already + { + gchar *basename = g_path_get_basename(file); + if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) { + g_free(basename); + basename = 0; + continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already + } + g_free(basename); + basename = 0; + } gchar const *filepath = g_build_filename(dirname, file, NULL); gchar *dupfile = g_strndup(file, strlen(file) - 4); diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 41533e0ab..7fc0a9715 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -371,7 +371,10 @@ Glib::ustring font_factory::ConstructFontSpecification(PangoFontDescription *fon PangoFontDescription *copy = pango_font_description_copy(font); pango_font_description_unset_fields (copy, PANGO_FONT_MASK_SIZE); - pangoString = Glib::ustring(pango_font_description_to_string(copy)); + char * copyAsString = pango_font_description_to_string(copy); + pangoString = copyAsString; + g_free(copyAsString); + copyAsString = 0; pango_font_description_free(copy); @@ -420,8 +423,11 @@ Glib::ustring font_factory::GetUIStyleString(PangoFontDescription const *fontDes pango_font_description_unset_fields(fontDescrCopy, PANGO_FONT_MASK_SIZE); // For now, keep it as style name taken from pango - style = pango_font_description_to_string(fontDescrCopy); + char *fontDescrAsString = pango_font_description_to_string(fontDescrCopy); + style = fontDescrAsString; + g_free(fontDescrAsString); + fontDescrAsString = 0; pango_font_description_free(fontDescrCopy); } @@ -745,7 +751,11 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) } } } + g_free(faces); + faces = 0; } + g_free(families); + families = 0; // Sort the style lists for (FamilyToStylesMap::iterator iter = map->begin() ; iter != map->end(); iter++) { diff --git a/src/preferences.cpp b/src/preferences.cpp index 3815d44c5..4a9944140 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -660,8 +660,11 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c node = child; } g_strfreev(splits); + splits = 0; return node; } else { + g_strfreev(splits); + splits = 0; return NULL; } } -- cgit v1.2.3 From 3a0572a2ac5a9a6cfbfc87325dc5ce5dda21c53e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 20 Mar 2011 11:58:41 +0100 Subject: Added some mnemonics for filter path effects (Bug #170765) (bzr r10119) --- src/live_effects/lpe-curvestitch.cpp | 14 +++++++------- src/live_effects/lpe-ruler.cpp | 12 ++++++------ src/live_effects/lpe-vonkoch.cpp | 8 ++++---- src/ui/widget/filter-effect-chooser.cpp | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index febe33208..a2b4a591a 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -40,13 +40,13 @@ using namespace Geom; LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : Effect(lpeobject), strokepath(_("Stitch path:"), _("The path that will be used as stitch."), "strokepath", &wr, this, "M0,0 L1,0"), - nrofpaths(_("Number of paths:"), _("The number of paths that will be generated."), "count", &wr, this, 5), - startpoint_edge_variation(_("Start edge variance:"), _("The amount of random jitter to move the start points of the stitches inside & outside the guide path"), "startpoint_edge_variation", &wr, this, 0), - startpoint_spacing_variation(_("Start spacing variance:"), _("The amount of random shifting to move the start points of the stitches back & forth along the guide path"), "startpoint_spacing_variation", &wr, this, 0), - endpoint_edge_variation(_("End edge variance:"), _("The amount of randomness that moves the end points of the stitches inside & outside the guide path"), "endpoint_edge_variation", &wr, this, 0), - endpoint_spacing_variation(_("End spacing variance:"), _("The amount of random shifting to move the end points of the stitches back & forth along the guide path"), "endpoint_spacing_variation", &wr, this, 0), - prop_scale(_("Scale width:"), _("Scale the width of the stitch path"), "prop_scale", &wr, this, 1), - scale_y_rel(_("Scale width relative to length"), _("Scale the width of the stitch path relative to its length"), "scale_y_rel", &wr, this, false) + nrofpaths(_("N_umber of paths:"), _("The number of paths that will be generated."), "count", &wr, this, 5), + startpoint_edge_variation(_("Sta_rt edge variance:"), _("The amount of random jitter to move the start points of the stitches inside & outside the guide path"), "startpoint_edge_variation", &wr, this, 0), + startpoint_spacing_variation(_("Sta_rt spacing variance:"), _("The amount of random shifting to move the start points of the stitches back & forth along the guide path"), "startpoint_spacing_variation", &wr, this, 0), + endpoint_edge_variation(_("End ed_ge variance:"), _("The amount of randomness that moves the end points of the stitches inside & outside the guide path"), "endpoint_edge_variation", &wr, this, 0), + endpoint_spacing_variation(_("End spa_cing variance:"), _("The amount of random shifting to move the end points of the stitches back & forth along the guide path"), "endpoint_spacing_variation", &wr, this, 0), + prop_scale(_("Scale _width:"), _("Scale the width of the stitch path"), "prop_scale", &wr, this, 1), + scale_y_rel(_("Scale _width relative to length"), _("Scale the width of the stitch path relative to its length"), "scale_y_rel", &wr, this, false) { registerParameter( dynamic_cast(&nrofpaths) ); registerParameter( dynamic_cast(&startpoint_edge_variation) ); diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index e51b03d15..d7a393197 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -40,14 +40,14 @@ static const Util::EnumDataConverter BorderMarkTypeConverter(Bor LPERuler::LPERuler(LivePathEffectObject *lpeobject) : Effect(lpeobject), - mark_distance(_("Mark distance:"), _("Distance between successive ruler marks"), "mark_distance", &wr, this, 20.0), + mark_distance(_("_Mark distance:"), _("Distance between successive ruler marks"), "mark_distance", &wr, this, 20.0), unit(_("Unit:"), _("Unit"), "unit", &wr, this), - mark_length(_("Major length:"), _("Length of major ruler marks"), "mark_length", &wr, this, 14.0), - minor_mark_length(_("Minor length:"), _("Length of minor ruler marks"), "minor_mark_length", &wr, this, 7.0), - major_mark_steps(_("Major steps:"), _("Draw a major mark every ... steps"), "major_mark_steps", &wr, this, 5), - shift(_("Shift marks by:"), _("Shift marks by this many steps"), "shift", &wr, this, 0), + mark_length(_("Ma_jor length:"), _("Length of major ruler marks"), "mark_length", &wr, this, 14.0), + minor_mark_length(_("Mino_r length:"), _("Length of minor ruler marks"), "minor_mark_length", &wr, this, 7.0), + major_mark_steps(_("Major steps_:"), _("Draw a major mark every ... steps"), "major_mark_steps", &wr, this, 5), + shift(_("Shift marks _by:"), _("Shift marks by this many steps"), "shift", &wr, this, 0), mark_dir(_("Mark direction:"), _("Direction of marks (when viewing along the path from start to end)"), "mark_dir", MarkDirTypeConverter, &wr, this, MARKDIR_LEFT), - offset(_("Offset:"), _("Offset of first mark"), "offset", &wr, this, 0.0), + offset(_("_Offset:"), _("Offset of first mark"), "offset", &wr, this, 0.0), border_marks(_("Border marks:"), _("Choose whether to draw marks at the beginning and end of the path"), "border_marks", BorderMarkTypeConverter, &wr, this, BORDERMARK_BOTH) { registerParameter(dynamic_cast(&unit)); diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 56d66d137..050e4adc2 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -43,16 +43,16 @@ VonKochRefPathParam::param_readSVGValue(const gchar * strvalue) LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) : Effect(lpeobject), - nbgenerations(_("Nb of generations:"), _("Depth of the recursion --- keep low!!"), "nbgenerations", &wr, this, 1), + nbgenerations(_("N_r of generations:"), _("Depth of the recursion --- keep low!!"), "nbgenerations", &wr, this, 1), generator(_("Generating path:"), _("Path whose segments define the iterated transforms"), "generator", &wr, this, "M0,0 L30,0 M0,10 L10,10 M 20,10 L30,10"), - similar_only(_("Use uniform transforms only"), _("2 consecutive segments are used to reverse/preserve orientation only (otherwise, they define a general transform)."), "similar_only", &wr, this, false), - drawall(_("Draw all generations"), _("If unchecked, draw only the last generation"), "drawall", &wr, this, true), + similar_only(_("_Use uniform transforms only"), _("2 consecutive segments are used to reverse/preserve orientation only (otherwise, they define a general transform)."), "similar_only", &wr, this, false), + drawall(_("Dra_w all generations"), _("If unchecked, draw only the last generation"), "drawall", &wr, this, true), //,draw_boxes(_("Display boxes"), _("Display boxes instead of paths only"), "draw_boxes", &wr, this, true) ref_path(_("Reference segment:"), _("The reference segment. Defaults to the horizontal midline of the bbox."), "ref_path", &wr, this, "M0,0 L10,0"), //refA(_("Ref Start"), _("Left side middle of the reference box"), "refA", &wr, this), //refB(_("Ref End"), _("Right side middle of the reference box"), "refB", &wr, this), //FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug. - maxComplexity(_("Max complexity:"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000) + maxComplexity(_("_Max complexity:"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000) { //FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug. registerParameter( dynamic_cast(&ref_path) ); diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index aba3a18e8..37202c8b4 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -22,7 +22,7 @@ namespace UI { namespace Widget { SimpleFilterModifier::SimpleFilterModifier(int flags) - : _lb_blend(_("_Blend mode:")), + : _lb_blend(_("Blend mode:")), _lb_blur(_("_Blur:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, true), _blend(BlendModeConverter, SP_ATTR_INVALID, false), _blur(0, 0, 100, 1, 0.01, 1) -- cgit v1.2.3 From 65e3d06306390fd96707c03a82f1bf0fee0823e3 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 20 Mar 2011 22:56:22 -0700 Subject: Doc comment cleanup of '@brief'. (bzr r10120) --- src/preferences.cpp | 67 ++++++++++++----------- src/preferences.h | 152 ++++++++++++++++++++++++++++------------------------ 2 files changed, 119 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/preferences.cpp b/src/preferences.cpp index 4a9944140..94fbc7257 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -1,5 +1,5 @@ /** @file - * @brief Singleton class to access the preferences file - implementation + * Singleton class to access the preferences file - implementation. */ /* Authors: * Krzysztof Kosiński @@ -59,7 +59,7 @@ static void file_add_recent(gchar const *uri) // private inner class definition /** - * @brief XML - prefs observer bridge + * XML - prefs observer bridge. * * This is an XML node observer that watches for changes in the XML document storing the preferences. * It is used to implement preference observers. @@ -110,7 +110,7 @@ Preferences::~Preferences() } /** - * @brief Load internal defaults + * Load internal defaults. * * In the future this will try to load the system-wide file before falling * back to the internal defaults. @@ -121,7 +121,7 @@ void Preferences::_loadDefaults() } /** - * @brief Load the user's customized preferences + * Load the user's customized preferences. * * Tries to load the user's preferences.xml file. If there is none, creates it. */ @@ -255,7 +255,7 @@ static void migrateDetails( Inkscape::XML::Document *from, Inkscape::XML::Docume } /** - * @brief Flush all pref changes to the XML file + * Flush all pref changes to the XML file. */ void Preferences::save() { @@ -364,9 +364,10 @@ void Preferences::migrate( std::string const& legacyDir, std::string const& pref // Now for the meat. /** - * @brief Get names of all entries in the specified path - * @param path Preference path to query - * @return A vector containing all entries in the given directory + * Get names of all entries in the specified path. + * + * @param path Preference path to query. + * @return A vector containing all entries in the given directory. */ std::vector Preferences::getAllEntries(Glib::ustring const &path) { @@ -383,9 +384,10 @@ std::vector Preferences::getAllEntries(Glib::ustring const & } /** - * @brief Get the paths to all subdirectories of the specified path - * @param path Preference path to query - * @return A vector containing absolute paths to all subdirectories in the given path + * Get the paths to all subdirectories of the specified path. + * + * @param path Preference path to query. + * @return A vector containing absolute paths to all subdirectories in the given path. */ std::vector Preferences::getAllDirs(Glib::ustring const &path) { @@ -411,9 +413,10 @@ Preferences::Entry const Preferences::getEntry(Glib::ustring const &pref_path) // setter methods /** - * @brief Set a boolean attribute of a preference - * @param pref_path Path of the preference to modify - * @param value The new value of the pref attribute + * Set a boolean attribute of a preference. + * + * @param pref_path Path of the preference to modify. + * @param value The new value of the pref attribute. */ void Preferences::setBool(Glib::ustring const &pref_path, bool value) { @@ -424,9 +427,10 @@ void Preferences::setBool(Glib::ustring const &pref_path, bool value) } /** - * @brief Set an integer attribute of a preference - * @param pref_path Path of the preference to modify - * @param value The new value of the pref attribute + * Set an integer attribute of a preference. + * + * @param pref_path Path of the preference to modify. + * @param value The new value of the pref attribute. */ void Preferences::setInt(Glib::ustring const &pref_path, int value) { @@ -436,9 +440,10 @@ void Preferences::setInt(Glib::ustring const &pref_path, int value) } /** - * @brief Set a floating point attribute of a preference - * @param pref_path Path of the preference to modify - * @param value The new value of the pref attribute + * Set a floating point attribute of a preference. + * + * @param pref_path Path of the preference to modify. + * @param value The new value of the pref attribute. */ void Preferences::setDouble(Glib::ustring const &pref_path, double value) { @@ -455,9 +460,10 @@ void Preferences::setColor(Glib::ustring const &pref_path, guint32 value) } /** - * @brief Set a string attribute of a preference - * @param pref_path Path of the preference to modify - * @param value The new value of the pref attribute + * Set a string attribute of a preference. + * + * @param pref_path Path of the preference to modify. + * @param value The new value of the pref attribute. */ void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value) { @@ -486,7 +492,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) namespace { /** - * @brief Structure that holds additional information for registered Observers + * Structure that holds additional information for registered Observers. */ struct _ObserverData { Inkscape::XML::Node *_node; ///< Node at which the wrapping PrefNodeObserver is registered @@ -542,7 +548,7 @@ void Preferences::PrefNodeObserver::notifyAttributeChanged(XML::Node &node, GQua } /** - * @brief Find the XML node to observe + * Find the XML node to observe. */ XML::Node *Preferences::_findObserverNode(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key, bool create) { @@ -613,11 +619,12 @@ void Preferences::removeObserver(Observer &o) /** - * @brief Get the XML node corresponding to the given pref key - * @param pref_key Preference key (path) to get - * @param create Whether to create the corresponding node if it doesn't exist - * @param separator The character used to separate parts of the pref key - * @return XML node corresponding to the specified key + * Get the XML node corresponding to the given pref key. + * + * @param pref_key Preference key (path) to get. + * @param create Whether to create the corresponding node if it doesn't exist. + * @param separator The character used to separate parts of the pref key. + * @return XML node corresponding to the specified key. * * Derived from former inkscape_get_repr(). Private because it assumes that the backend is * a flat XML file, which may not be the case e.g. if we are using GConf (in future). diff --git a/src/preferences.h b/src/preferences.h index 5e1ccf9d6..c79a7377d 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -1,5 +1,5 @@ /** @file - * @brief Singleton class to access the preferences file in a convenient way. + * Singleton class to access the preferences file in a convenient way. */ /* Authors: * Krzysztof Kosi_ski @@ -33,7 +33,7 @@ public: }; /** - * @brief Preference storage class. + * Preference storage class. * * This is a singleton that allows one to access the user preferences stored in * the preferences.xml file. The preferences are stored in a file system-like @@ -63,7 +63,7 @@ public: class Observer; /** - * @brief Base class for preference observers + * Base class for preference observers. * * If you want to watch for changes in the preferences, you'll have to * derive a class from this one and override the notify() method. @@ -73,7 +73,7 @@ public: public: /** - * @brief Constructor. + * Constructor. * * Since each Observer is assigned to a single path, the base * constructor takes this path as an argument. This prevents one from @@ -88,15 +88,16 @@ public: * Watching the preference "/options/some_group/some_option" will only * generate notifications when this single preference changes. * - * @param path Preference path the observer should watch + * @param path Preference path the observer should watch. */ Observer(Glib::ustring const &path); virtual ~Observer(); /** - * @brief Notification about a preference change + * Notification about a preference change. + * * @param new_val Entry object containing information about - * the modified preference + * the modified preference. */ virtual void notify(Preferences::Entry const &new_val) = 0; @@ -107,7 +108,7 @@ public: /** - * @brief Data type representing a typeless value of a preference + * Data type representing a typeless value of a preference. * * This is passed to the observer in the notify() method. * To retrieve useful data from it, use its member functions. Setting @@ -122,75 +123,80 @@ public: Entry(Entry const &other) : _pref_path(other._pref_path), _value(other._value) {} /** - * @brief Check whether the received entry is valid. + * Check whether the received entry is valid. + * * @return If false, the default value will be returned by the getters. */ bool isValid() const { return _value != NULL; } /** - * @brief Interpret the preference as a Boolean value. - * @param def Default value if the preference is not set + * Interpret the preference as a Boolean value. + * + * @param def Default value if the preference is not set. */ inline bool getBool(bool def=false) const; /** - * @brief Interpret the preference as an integer. - * @param def Default value if the preference is not set + * Interpret the preference as an integer. + * + * @param def Default value if the preference is not set. */ inline int getInt(int def=0) const; /** - * @brief Interpret the preference as a limited integer. + * Interpret the preference as a limited integer. * * This method will return the default value if the interpreted value is * larger than @c max or smaller than @c min. Do not use to store * Boolean values as integers. * - * @param def Default value if the preference is not set - * @param min Minimum value allowed to return - * @param max Maximum value allowed to return + * @param def Default value if the preference is not set. + * @param min Minimum value allowed to return. + * @param max Maximum value allowed to return. */ inline int getIntLimited(int def=0, int min=INT_MIN, int max=INT_MAX) const; /** - * @brief Interpret the preference as a floating point value. - * @param def Default value if the preference is not set + * Interpret the preference as a floating point value. + * + * @param def Default value if the preference is not set. */ inline double getDouble(double def=0.0) const; /** - * @brief Interpret the preference as a limited floating point value. + * Interpret the preference as a limited floating point value. * * This method will return the default value if the interpreted value is * larger than @c max or smaller than @c min. * - * @param def Default value if the preference is not set - * @param min Minimum value allowed to return - * @param max Maximum value allowed to return + * @param def Default value if the preference is not set. + * @param min Minimum value allowed to return. + * @param max Maximum value allowed to return. */ inline double getDoubleLimited(double def=0.0, double min=DBL_MIN, double max=DBL_MAX) const; /** - * @brief Interpret the preference as an UTF-8 string. + * Interpret the preference as an UTF-8 string. * * To store a filename, convert it using Glib::filename_to_utf8(). */ inline Glib::ustring getString() const; /** - * @brief Interpret the preference as an RGBA color value. + * Interpret the preference as an RGBA color value. */ inline guint32 getColor(guint32 def) const; /** - * @brief Interpret the preference as a CSS style. + * Interpret the preference as a CSS style. + * * @return A CSS style that has to be unrefed when no longer necessary. Never NULL. */ inline SPCSSAttr *getStyle() const; /** - * @brief Interpret the preference as a CSS style with directory-based - * inheritance + * Interpret the preference as a CSS style with directory-based + * inheritance. * * This function will look up the preferences with the same entry name * in ancestor directories and return the inherited CSS style. @@ -200,12 +206,12 @@ public: inline SPCSSAttr *getInheritedStyle() const; /** - * @brief Get the full path of the preference described by this Entry. + * Get the full path of the preference described by this Entry. */ Glib::ustring const &getPath() const { return _pref_path; } /** - * @brief Get the last component of the preference's path + * Get the last component of the preference's path. * * E.g. For "/options/some_group/some_option" it will return "some_option". */ @@ -220,7 +226,7 @@ public: // utility methods /** - * @brief Save all preferences to the hard disk. + * Save all preferences to the hard disk. * * For some backends, the preferences may be saved as they are modified. * Not calling this method doesn't guarantee the preferences are unmodified @@ -229,13 +235,13 @@ public: void save(); /** - * @brief Check whether saving the preferences will have any effect. + * Check whether saving the preferences will have any effect. */ bool isWritable() { return _writable; } /*@}*/ /** - * @brief Return details of the last encountered error, if any. + * Return details of the last encountered error, if any. * * This method will return true if an error has been encountered, and fill * in the primary and secondary error strings of the last error. If an error @@ -254,7 +260,7 @@ public: */ /** - * @brief Get all entries from the specified directory + * Get all entries from the specified directory. * * This method will return a vector populated with preference entries * from the specified directory. Subdirectories will not be represented. @@ -262,7 +268,7 @@ public: std::vector getAllEntries(Glib::ustring const &path); /** - * @brief Get all subdirectories of the specified directory + * Get all subdirectories of the specified directory. * * This will return a vector populated with full paths to the subdirectories * present in the specified @c path. @@ -276,59 +282,63 @@ public: */ /** - * @brief Retrieve a Boolean value - * @param pref_path Path to the retrieved preference - * @param def The default value to return if the preference is not set + * Retrieve a Boolean value. + * + * @param pref_path Path to the retrieved preference. + * @param def The default value to return if the preference is not set. */ bool getBool(Glib::ustring const &pref_path, bool def=false) { return getEntry(pref_path).getBool(def); } /** - * @brief Retrieve an integer - * @param pref_path Path to the retrieved preference - * @param def The default value to return if the preference is not set + * Retrieve an integer. + * + * @param pref_path Path to the retrieved preference. + * @param def The default value to return if the preference is not set. */ int getInt(Glib::ustring const &pref_path, int def=0) { return getEntry(pref_path).getInt(def); } /** - * @brief Retrieve a limited integer + * Retrieve a limited integer. * * The default value is returned if the actual value is larger than @c max * or smaller than @c min. Do not use to store Boolean values. * - * @param pref_path Path to the retrieved preference - * @param def The default value to return if the preference is not set - * @param min Minimum value to return - * @param max Maximum value to return + * @param pref_path Path to the retrieved preference. + * @param def The default value to return if the preference is not set. + * @param min Minimum value to return. + * @param max Maximum value to return. */ int getIntLimited(Glib::ustring const &pref_path, int def=0, int min=INT_MIN, int max=INT_MAX) { return getEntry(pref_path).getIntLimited(def, min, max); } + double getDouble(Glib::ustring const &pref_path, double def=0.0) { return getEntry(pref_path).getDouble(def); } /** - * @brief Retrieve a limited floating point value + * Retrieve a limited floating point value. * * The default value is returned if the actual value is larger than @c max * or smaller than @c min. * - * @param pref_path Path to the retrieved preference - * @param def The default value to return if the preference is not set - * @param min Minimum value to return - * @param max Maximum value to return + * @param pref_path Path to the retrieved preference. + * @param def The default value to return if the preference is not set. + * @param min Minimum value to return. + * @param max Maximum value to return. */ double getDoubleLimited(Glib::ustring const &pref_path, double def=0.0, double min=DBL_MIN, double max=DBL_MAX) { return getEntry(pref_path).getDoubleLimited(def, min, max); } /** - * @brief Retrieve an UTF-8 string - * @param pref_path Path to the retrieved preference + * Retrieve an UTF-8 string. + * + * @param pref_path Path to the retrieved preference. */ Glib::ustring getString(Glib::ustring const &pref_path) { return getEntry(pref_path).getString(); @@ -339,8 +349,9 @@ public: } /** - * @brief Retrieve a CSS style - * @param pref_path Path to the retrieved preference + * Retrieve a CSS style. + * + * @param pref_path Path to the retrieved preference. * @return A CSS style that has to be unrefed after use. */ SPCSSAttr *getStyle(Glib::ustring const &pref_path) { @@ -348,13 +359,13 @@ public: } /** - * @brief Retrieve an inherited CSS style + * Retrieve an inherited CSS style. * * This method will look up preferences with the same entry name in ancestor * directories and return a style obtained by inheriting properties from * ancestor styles. * - * @param pref_path Path to the retrieved preference + * @param pref_path Path to the retrieved preference. * @return An inherited CSS style that has to be unrefed after use. */ SPCSSAttr *getInheritedStyle(Glib::ustring const &pref_path) { @@ -362,7 +373,7 @@ public: } /** - * @brief Retrieve a preference entry without specifying its type + * Retrieve a preference entry without specifying its type. */ Entry const getEntry(Glib::ustring const &pref_path); /*@}*/ @@ -373,37 +384,37 @@ public: */ /** - * @brief Set a Boolean value + * Set a Boolean value. */ void setBool(Glib::ustring const &pref_path, bool value); /** - * @brief Set an integer value + * Set an integer value. */ void setInt(Glib::ustring const &pref_path, int value); /** - * @brief Set a floating point value + * Set a floating point value. */ void setDouble(Glib::ustring const &pref_path, double value); /** - * @brief Set an UTF-8 string value + * Set an UTF-8 string value. */ void setString(Glib::ustring const &pref_path, Glib::ustring const &value); /** - * @brief Set an RGBA color value + * Set an RGBA color value. */ void setColor(Glib::ustring const &pref_path, guint32 value); /** - * @brief Set a CSS style + * Set a CSS style. */ void setStyle(Glib::ustring const &pref_path, SPCSSAttr *style); /** - * @brief Merge a CSS style with the current preference value + * Merge a CSS style with the current preference value. * * This method is similar to setStyle(), except that it merges the style * rather than replacing it. This means that if @c style doesn't have @@ -419,12 +430,12 @@ public: */ /** - * @brief Register a preference observer + * Register a preference observer. */ void addObserver(Observer &); /** - * @brief Remove an observer an prevent further notifications to it. + * Remove an observer an prevent further notifications to it. */ void removeObserver(Observer &); /*@}*/ @@ -441,7 +452,7 @@ public: static void migrate( std::string const& legacyDir, std::string const& prefdir ); /** - * @brief Access the singleton Preferences object. + * Access the singleton Preferences object. */ static Preferences *get() { if (!_instance) { @@ -453,8 +464,9 @@ public: void setErrorHandler(ErrorReporter* handler); /** - * @brief Unload all preferences - * @param save Whether to save the preferences; defaults to true + * Unload all preferences. + * + * @param save Whether to save the preferences; defaults to true. * * This deletes the singleton object. Calling get() after this function * will reinstate it, so you shouldn't. Pass false as the parameter -- cgit v1.2.3 From 16bfe76a9062d4c0ca4b69618e5ae0d1c2beecbc Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 21 Mar 2011 21:49:21 +0100 Subject: powerstroke: apply interpolator combobox to closed paths too (bzr r10123) --- src/live_effects/lpe-powerstroke.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 3556be61f..82f4ccdea 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -346,7 +346,6 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & } // create stroke path where points (x,y) := (t, offset) - //Geom::Interpolate::CubicBezierJohan interpolator; Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); Geom::Path strokepath = interpolator->interpolateToPath(ts); Geom::Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); @@ -374,8 +373,9 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & ts.insert(ts.begin(), last_point - Point(pwd2_in.domain().extent() ,0)); ts.push_back( first_point + Point(pwd2_in.domain().extent() ,0) ); // create stroke path where points (x,y) := (t, offset) - Geom::Interpolate::CubicBezierJohan interpolator; - Geom::Path strokepath = interpolator.interpolateToPath(ts); + Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); + Geom::Path strokepath = interpolator->interpolateToPath(ts); + delete interpolator; // output 2 separate paths D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); -- cgit v1.2.3 From 8394ba9d482a5a09bcfbe855c4b7b3a3bc528603 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 22 Mar 2011 19:13:39 +0100 Subject: Path. Fix for Bug #170225 (relative image paths instead of absolute). Fixed bugs: - https://launchpad.net/bugs/170225 (bzr r10124) --- src/xml/rebase-hrefs.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index b2efd7ee6..33b31685d 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -232,13 +232,40 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b for (GSList const *l = images; l != NULL; l = l->next) { Inkscape::XML::Node *ir = static_cast(l->data)->getRepr(); - gchar const *const href = ir->attribute("xlink:href"); + gchar * uri = g_strdup(ir->attribute("xlink:href")); + if (!uri) { + continue; + } + if (!strncmp(uri, "file://", 7)) { + uri = g_strdup(g_filename_from_uri(ir->attribute("xlink:href"), NULL, NULL)); + } + // The following two cases are for absolute hrefs that can be converted to relative. + // Imported images, first time rebased, need an old base. + gchar * href = uri; + if (g_path_is_absolute(href)) { + href = (gchar *) sp_relative_path_from_path(uri, old_abs_base); + } + // Files moved from a absolute path need a new one. + if (g_path_is_absolute(href)) { + href = (gchar *) sp_relative_path_from_path(uri, new_abs_base); + } + // Other bitmaps are either really absolute, or already relative. + +#ifdef WIN32 + /* Windows relative path needs their native separators before we + * compare it to native baserefs. */ + if (!g_path_is_absolute(href)) { + g_strdelimit(href, "/", '\\'); + } +#endif + /* TODO: Most of this function currently treats href as if it were a simple filename * (e.g. passing it to g_path_is_absolute, g_build_filename or IO::file_test, or avoiding * changing non-file hrefs), which breaks if href starts with a scheme or if href contains * any escaping. */ if (!href || !href_needs_rebasing(href)) { + g_free(uri); continue; } @@ -253,10 +280,21 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b * of file hrefs. */ gchar const *const new_href = sp_relative_path_from_path(abs_href, new_abs_base); - ir->setAttribute("xlink:href", new_href); ir->setAttribute("sodipodi:absref", ( spns ? abs_href : NULL )); + if (!g_path_is_absolute(new_href)) { +#ifdef WIN32 + /* Native Windows path separators are replaced with / so that the href + * also works on Gnu/Linux and OSX */ + ir->setAttribute("xlink:href", g_strdelimit((gchar *) new_href, "\\", '/')); +#else + ir->setAttribute("xlink:href", new_href); +#endif + } else { + ir->setAttribute("xlink:href", g_filename_to_uri((gchar *) new_href, NULL, NULL)); + } + /* impl: I assume that if !spns then any existing sodipodi:absref is about to get * cleared (or is already cleared) anyway, in which case it doesn't matter whether we * clear or leave any existing sodipodi:absref value. If that assumption turns out to @@ -264,8 +302,10 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b * referred to a different file than sodipodi:absref) while clearing it means risking * losing information. */ + g_free(uri); + // (No need to free href, it's guaranteed to point into uri.) g_free(abs_href); - /* (No need to free new_href, it's guaranteed to point into used_abs_href.) */ + // (No need to free new_href, it's guaranteed to point into abs_href.) } g_free(new_abs_base); -- cgit v1.2.3 From 4551234fbfbc5ab5c2ca14a7b56f93775855f6d9 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 23 Mar 2011 19:18:54 +0100 Subject: Filters. Posterize basic tweaks. Extensions. Int and Float adjustment widgets adjustment. (bzr r10125) --- src/extension/internal/filter/experimental.h | 4 ++-- src/extension/param/float.cpp | 2 +- src/extension/param/int.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 01bce4b61..6617866f5 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -699,7 +699,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) Simple posterizing effect Filter's parameters: - * Levels (1->20, default 5) -> component1 (tableValues) + * Levels (0->20, default 5) -> component1 (tableValues) * Blur (0.01->20., default 4.) -> blur1 (stdDeviation) */ class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter { @@ -715,7 +715,7 @@ public: "\n" "" N_("Posterize basic, custom") "\n" "org.inkscape.effect.filter.PosterizeBasic\n" - "5\n" + "5\n" "4.0\n" "\n" "all\n" diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 9a677a1f9..d94463a5b 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -120,7 +120,7 @@ public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { + Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); return; diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index bd89c971d..69849c656 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -105,7 +105,7 @@ public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { + Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); return; -- cgit v1.2.3 From 94ae08b4efa7d31d995348604e0b7500e2365a41 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Thu, 24 Mar 2011 18:23:59 -0400 Subject: emf import. create dummy object CREATEDIBPATTERNBRUSHPT (Bug 382420) Fixed bugs: - https://launchpad.net/bugs/382420 (bzr r10128) --- src/extension/internal/emf-win32-inout.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index baeb992f7..607827943 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -2119,8 +2119,17 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * dbg_str << "\n"; break; case EMR_CREATEDIBPATTERNBRUSHPT: + { dbg_str << "\n"; + + PEMRCREATEDIBPATTERNBRUSHPT pEmr = (PEMRCREATEDIBPATTERNBRUSHPT) lpEMFR; + int index = pEmr->ihBrush; + + EMRCREATEDIBPATTERNBRUSHPT *pBrush = + (EMRCREATEDIBPATTERNBRUSHPT *) malloc( sizeof(EMRCREATEDIBPATTERNBRUSHPT) ); + insert_object(d, index, EMR_CREATEDIBPATTERNBRUSHPT, (ENHMETARECORD *) pBrush); break; + } case EMR_EXTCREATEPEN: { dbg_str << "\n"; -- cgit v1.2.3 From 939f84facd2f8beb4f5a1601c09bf7b71f1274a0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 25 Mar 2011 16:09:55 +0100 Subject: Extensions. Replacing the groupheader element with an appearance mode in the description element. (bzr r10129) --- src/extension/Makefile_insert | 2 - src/extension/internal/filter/experimental.h | 6 +-- src/extension/param/description.cpp | 26 ++++++++-- src/extension/param/description.h | 18 +++++-- src/extension/param/groupheader.cpp | 78 ---------------------------- src/extension/param/groupheader.h | 45 ---------------- src/extension/param/parameter.cpp | 9 ++-- 7 files changed, 44 insertions(+), 140 deletions(-) delete mode 100755 src/extension/param/groupheader.cpp delete mode 100755 src/extension/param/groupheader.h (limited to 'src') diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert index b9ce224ca..ffcee5f9a 100644 --- a/src/extension/Makefile_insert +++ b/src/extension/Makefile_insert @@ -24,8 +24,6 @@ ink_common_sources += \ extension/param/color.cpp \ extension/param/description.h \ extension/param/description.cpp \ - extension/param/groupheader.h \ - extension/param/groupheader.cpp \ extension/param/enum.h \ extension/param/enum.cpp \ extension/param/float.h \ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 6617866f5..efc35b418 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -331,16 +331,16 @@ public: "org.inkscape.effect.filter.Drawing\n" "\n" "\n" - "<_param name=\"simplifyheader\" type=\"groupheader\">Simplify\n" + "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" "0.6\n" "10\n" "0\n" "false\n" - "<_param name=\"smoothheader\" type=\"groupheader\">Smoothness\n" + "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" "0.6\n" "6\n" "2\n" - "<_param name=\"meltheader\" type=\"groupheader\">Melt\n" + "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" "1\n" "6\n" "2\n" diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index f17b45b4b..049b7d5a3 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -30,8 +30,16 @@ namespace Extension { /** \brief Initialize the object, to do that, copy the data. */ -ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL) +ParamDescription::ParamDescription (const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL), _mode(mode) { // printf("Building Description\n"); const char * defaultval = NULL; @@ -60,13 +68,21 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node newguitext = _(_value); } - Gtk::Label * label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT)); - + Gtk::Label * label; + int padding = 12; + if (_mode == HEADER) { + label = Gtk::manage(new Gtk::Label(Glib::ustring("") +newguitext + Glib::ustring(""), Gtk::ALIGN_LEFT)); + label->set_padding(0,5); + label->set_use_markup(true); + padding = 0; + } else { + label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT)); + } label->set_line_wrap(); label->show(); Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - hbox->pack_start(*label, true, true, 12); + hbox->pack_start(*label, true, true, padding); hbox->show(); return hbox; diff --git a/src/extension/param/description.h b/src/extension/param/description.h index c56b5c21d..c34e4ee38 100644 --- a/src/extension/param/description.h +++ b/src/extension/param/description.h @@ -18,13 +18,25 @@ namespace Extension { /** \brief A description parameter */ class ParamDescription : public Parameter { +public: + enum AppearanceMode { + DESC, HEADER + }; + ParamDescription(const gchar * name, + const gchar * guitext, + const gchar * desc, + const Parameter::_scope_t scope, + bool gui_hidden, + const gchar * gui_tip, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); private: /** \brief Internal value. */ gchar * _value; + AppearanceMode _mode; const gchar* _context; -public: - ParamDescription(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); }; } /* namespace Extension */ diff --git a/src/extension/param/groupheader.cpp b/src/extension/param/groupheader.cpp deleted file mode 100755 index abf5f8beb..000000000 --- a/src/extension/param/groupheader.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2005-2010 Authors: - * Ted Gould - * Johan Engelen * - * Nicolas Dufour - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef linux // does the dollar sign need escaping when passed as string parameter? -# define ESCAPE_DOLLAR_COMMANDLINE -#endif - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - - -#include "groupheader.h" - -#include -#include -#include -#include -#include - -#include "xml/node.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { - - -/** \brief Initialize the object, to do that, copy the data. */ -ParamGroupHeader::ParamGroupHeader (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL) -{ - // printf("Building GroupHeader\n"); - const char * defaultval = NULL; - if (sp_repr_children(xml) != NULL) - defaultval = sp_repr_children(xml)->content(); - - if (defaultval != NULL) - _value = g_strdup(defaultval); - - _context = xml->attribute("msgctxt"); - - return; -} - -/** \brief Create a label for the GroupHeader */ -Gtk::Widget * -ParamGroupHeader::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal * /*changeSignal*/) -{ - if (_gui_hidden) return NULL; - - Glib::ustring newguitext; - - if (_context != NULL) { - newguitext = g_dpgettext2(NULL, _context, _value); - } else { - newguitext = _(_value); - } - - Gtk::Label * label = Gtk::manage(new Gtk::Label(Glib::ustring("") +newguitext + Glib::ustring(""), Gtk::ALIGN_LEFT)); - label->set_line_wrap(); - label->set_padding(0,5); - label->set_use_markup(true); - label->show(); - - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - hbox->pack_start(*label, true, true); - hbox->show(); - - return hbox; -} - -} /* namespace Extension */ -} /* namespace Inkscape */ diff --git a/src/extension/param/groupheader.h b/src/extension/param/groupheader.h deleted file mode 100755 index 94fe880f9..000000000 --- a/src/extension/param/groupheader.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __INK_EXTENSION_PARAMGROUPHEADER_H__ -#define __INK_EXTENSION_PARAMGROUPHEADER_H__ - -/* - * Copyright (C) 2005-2010 Authors: - * Ted Gould - * Johan Engelen * - * Nicolas Dufour - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include -#include -#include "parameter.h" - -namespace Inkscape { -namespace Extension { - -/** \brief A GroupLabel parameter */ -class ParamGroupHeader : public Parameter { -private: - /** \brief Internal value. */ - gchar * _value; - const gchar* _context; -public: - ParamGroupHeader(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); -}; - -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif /* __INK_EXTENSION_PARAMGROUPHEADER_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index d35fb3d3c..a9935cfe6 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -36,7 +36,6 @@ #include "bool.h" #include "color.h" #include "description.h" -#include "groupheader.h" #include "enum.h" #include "float.h" #include "int.h" @@ -143,9 +142,11 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * ps->setMaxLength(atoi(max_length)); } } else if (!strcmp(type, "description")) { - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); - } else if (!strcmp(type, "groupheader")) { - param = new ParamGroupHeader(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "header")) { + param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamDescription::HEADER); + } else { + param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamDescription::DESC); + } } else if (!strcmp(type, "enum")) { param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { -- cgit v1.2.3 From 4e9fcca4f83f765ab147790d04e251a2bdbd9879 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 29 Mar 2011 19:30:25 +0200 Subject: Spray: * Spray context code clean-up (coding style and unused code removal). * Shift+k and Shift+l shortcuts inverted to reflect the mode order on azerty and qwerty keyboards. * Up and down keys now modify the population parameter. * Tooltips and status messages consistency fixes. * Old Q_() context replaced with C_() context macro. * Fix default values error in the parameters sliders. * Initial fix for duplicate window parameters update (the pressure button now updates as expected). * Fix a bug when spraying with GDK_SCROLL_DOWN (population value was reset to 100). * Default selcue set to 1, default gradient drag set to 0. Eraser: * Reodering the eraser tool parameters for UI consistency. * Default mode set to Cut out a path, default width set to 10. (bzr r10132) --- src/preferences-skeleton.h | 6 +- src/spray-context.cpp | 693 +++++++++++++++++++-------------------------- src/spray-context.h | 5 - src/widgets/toolbox.cpp | 87 +++--- 4 files changed, 332 insertions(+), 459 deletions(-) (limited to 'src') diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 0acb3c9e2..124a2ae51 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -106,8 +106,8 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" -" \n" " \n" " \n" @@ -118,7 +118,7 @@ static char const preferences_skeleton[] = " style=\"fill:black;fill-opacity:1;stroke:none;font-family:Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" diff --git a/src/spray-context.cpp b/src/spray-context.cpp index e7ef9d317..ae74b09da 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -36,7 +36,6 @@ #include "desktop-events.h" #include "desktop-handles.h" #include "unistd.h" -#include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-spray.xpm" #include @@ -46,19 +45,13 @@ #include "context-fns.h" #include "sp-item.h" #include "inkscape.h" -#include "color.h" -#include "svg/svg-color.h" + #include "splivarot.h" #include "sp-item-group.h" #include "sp-shape.h" #include "sp-path.h" #include "path-chemistry.h" -#include "sp-gradient.h" -#include "sp-stop.h" -#include "sp-gradient-reference.h" -#include "sp-linear-gradient.h" -#include "sp-radial-gradient.h" -#include "gradient-chemistry.h" + #include "sp-text.h" #include "sp-flowtext.h" #include "display/sp-canvas.h" @@ -73,8 +66,6 @@ #include "box3d.h" #include "sp-item-transform.h" #include "filter-chemistry.h" -#include "sp-gaussian-blur-fns.h" -#include "sp-gaussian-blur.h" #include "spray-context.h" #include "ui/dialog/dialog-manager.h" @@ -85,9 +76,7 @@ using Inkscape::DocumentUndo; using namespace std; - #define DDC_RED_RGBA 0xff0000ff - #define DYNA_MIN_WIDTH 1.0e-6 static void sp_spray_context_class_init(SPSprayContextClass *klass); @@ -106,13 +95,12 @@ static SPEventContextClass *parent_class = 0; * @param mu : mean * @param sigma : standard deviation ( > 0 ) */ -inline double NormalDistribution(double mu,double sigma) +inline double NormalDistribution(double mu, double sigma) { // use Box Muller's algorithm return mu + sigma * sqrt( -2.0 * log(g_random_double_range(0, 1)) ) * cos( 2.0*M_PI*g_random_double_range(0, 1) ); } - GtkType sp_spray_context_get_type(void) { static GType type = 0; @@ -147,7 +135,7 @@ static void sp_spray_context_class_init(SPSprayContextClass *klass) } /* Method to rotate items */ -void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom::Rotate const &rotation) +void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation) { Geom::Point center = c; Geom::Translate const s(c); @@ -164,10 +152,10 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom } /* Method to scale items */ -void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) +void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) { Geom::Translate const s(c); - item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s ); + item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s); item->doWriteTransform(item->getRepr(), item->transform); } @@ -185,22 +173,17 @@ static void sp_spray_context_init(SPSprayContext *tc) tc->width = 0.2; tc->force = 0.2; tc->ratio = 0; - tc->tilt=0; + tc->tilt = 0; tc->mean = 0.2; - tc->rotation_variation=0; - tc->standard_deviation=0.2; - tc->scale=1; + tc->rotation_variation = 0; + tc->standard_deviation = 0.2; + tc->scale = 1; tc->scale_variation = 1; tc->pressure = TC_DEFAULT_PRESSURE; tc->is_dilating = false; tc->has_dilated = false; - tc->do_h = true; - tc->do_s = true; - tc->do_l = true; - tc->do_o = false; - new (&tc->style_set_connection) sigc::connection(); } @@ -233,8 +216,8 @@ bool is_transform_modes(gint mode) void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) { - SPEventContext *event_context = SP_EVENT_CONTEXT(tc); - SPDesktop *desktop = event_context->desktop; + SPEventContext *event_context = SP_EVENT_CONTEXT(tc); + SPDesktop *desktop = event_context->desktop; guint num = 0; gchar *sel_message = NULL; @@ -248,13 +231,13 @@ void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) switch (tc->mode) { case SPRAY_MODE_COPY: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray copies of the initial selection"), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray copies of the initial selection."), sel_message); break; case SPRAY_MODE_CLONE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray clones of the initial selection"), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray clones of the initial selection."), sel_message); break; case SPRAY_MODE_SINGLE_PATH: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a single path of the initial selection"), sel_message); + tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a single path of the initial selection."), sel_message); break; default: break; @@ -267,8 +250,9 @@ static void sp_spray_context_setup(SPEventContext *ec) { SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) + if (((SPEventContextClass *) parent_class)->setup) { ((SPEventContextClass *) parent_class)->setup(ec); + } { /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */ @@ -304,18 +288,11 @@ static void sp_spray_context_setup(SPEventContext *ec) sp_event_context_read(ec, "standard_deviation"); sp_event_context_read(ec, "usepressure"); sp_event_context_read(ec, "Scale"); - sp_event_context_read(ec, "doh"); - sp_event_context_read(ec, "dol"); - sp_event_context_read(ec, "dos"); - sp_event_context_read(ec, "doo"); - - ; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/spray/selcue")) { ec->enableSelectionCue(); } - if (prefs->getBool("/tools/spray/gradientdrag")) { ec->enableGrDrag(); } @@ -326,56 +303,47 @@ static void sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entr SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); Glib::ustring path = val->getEntryName(); - if (path == "width") { - tc->width = 0.01 * CLAMP(val->getInt(10), 1, 100); - } else if (path == "mode") { + if (path == "mode") { tc->mode = val->getInt(); sp_spray_update_cursor(tc, false); - } else if (path == "distribution") { - tc->distrib = val->getInt(1); + } else if (path == "width") { + tc->width = 0.01 * CLAMP(val->getInt(10), 1, 100); + } else if (path == "usepressure") { + tc->usepressure = val->getBool(); } else if (path == "population") { tc->population = 0.01 * CLAMP(val->getInt(10), 1, 100); - } else if (path == "tilt") { - tc->tilt = CLAMP(val->getDouble(0.1), 0, 1000.0); - } else if (path == "ratio") { - tc->ratio = CLAMP(val->getDouble(), 0.0, 0.9); - } else if (path == "force") { - tc->force = CLAMP(val->getDouble(1.0), 0, 1.0); } else if (path == "rotation_variation") { tc->rotation_variation = CLAMP(val->getDouble(0.0), 0, 100.0); } else if (path == "scale_variation") { tc->scale_variation = CLAMP(val->getDouble(1.0), 0, 100.0); - } else if (path == "mean") { - tc->mean = 0.01 * CLAMP(val->getInt(10), 1, 100); } else if (path == "standard_deviation") { tc->standard_deviation = 0.01 * CLAMP(val->getInt(10), 1, 100); - } else if (path == "usepressure") { - tc->usepressure = val->getBool(); - } else if (path == "doh") { - tc->do_h = val->getBool(); - } else if (path == "dos") { - tc->do_s = val->getBool(); - } else if (path == "dol") { - tc->do_l = val->getBool(); - } else if (path == "doo") { - tc->do_o = val->getBool(); - } + } else if (path == "mean") { + tc->mean = 0.01 * CLAMP(val->getInt(10), 1, 100); +// Not implemented in the toolbar and preferences yet + } else if (path == "distribution") { + tc->distrib = val->getInt(1); + } else if (path == "tilt") { + tc->tilt = CLAMP(val->getDouble(0.1), 0, 1000.0); + } else if (path == "ratio") { + tc->ratio = CLAMP(val->getDouble(), 0.0, 0.9); + } else if (path == "force") { + tc->force = CLAMP(val->getDouble(1.0), 0, 1.0); + } } static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event) { - if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &tc->pressure)) - tc->pressure = CLAMP (tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE); - else + if (gdk_event_get_axis(event, GDK_AXIS_PRESSURE, &tc->pressure)) { + tc->pressure = CLAMP(tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE); + } else { tc->pressure = TC_DEFAULT_PRESSURE; + } } double get_dilate_radius(SPSprayContext *tc) { - return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom(); - - } double get_path_force(SPSprayContext *tc) @@ -423,29 +391,25 @@ double get_move_standard_deviation(SPSprayContext *tc) * @param[in] choice : */ -void random_position( double &radius, double &angle, double &a, double &s, int /*choice*/) +void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/) { // angle is taken from an uniform distribution angle = g_random_double_range(0, M_PI*2.0); // radius is taken from a Normal Distribution double radius_temp =-1; - while(!((radius_temp>=0)&&(radius_temp<=1))) + while(!((radius_temp >= 0) && (radius_temp <=1 ))) { - radius_temp = NormalDistribution( a, s ); + radius_temp = NormalDistribution(a, s); } // Because we are in polar coordinates, a special treatment has to be done to the radius. // Otherwise, positions taken from an uniform repartition on radius and angle will not seam to // be uniformily distributed on the disk (more at the center and less at the boundary). // We counter this effect with a 0.5 exponent. This is empiric. - radius = pow( radius_temp, 0.5); + radius = pow(radius_temp, 0.5); } - - - - bool sp_spray_recursive(SPDesktop *desktop, Inkscape::Selection *selection, SPItem *item, @@ -463,7 +427,7 @@ bool sp_spray_recursive(SPDesktop *desktop, double ratio, double tilt, double rotation_variation, - gint _distrib ) + gint _distrib) { bool did = false; @@ -473,7 +437,7 @@ bool sp_spray_recursive(SPDesktop *desktop, selection->add(item); } - double _fid = g_random_double_range(0,1); + double _fid = g_random_double_range(0, 1); double angle = g_random_double_range( - rotation_variation / 100.0 * M_PI , rotation_variation / 100.0 * M_PI ); double _scale = g_random_double_range( 1.0 - scale_variation / 100.0, 1.0 + scale_variation / 100.0 ); double dr; double dp; @@ -484,7 +448,7 @@ bool sp_spray_recursive(SPDesktop *desktop, Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { SPItem *item_copied; - if(_fid<=population) + if(_fid <= population) { // duplicate SPDocument *doc = item->document; @@ -497,12 +461,12 @@ bool sp_spray_recursive(SPDesktop *desktop, SPObject *new_obj = doc->getObjectByRepr(copy); item_copied = (SPItem *) new_obj; //convertion object->item Geom::Point center=item->getCenter(); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); + sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale)); + sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale)); sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); //Move the cursor p - Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); + Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); did = true; } @@ -520,11 +484,11 @@ bool sp_spray_recursive(SPDesktop *desktop, items = items->next) { SPItem *item1 = (SPItem *) items->data; - if (i==1) { - father=item1; + if (i == 1) { + father = item1; } - if (i==2) { - unionResult=item1; + if (i == 2) { + unionResult = item1; } i++; } @@ -535,16 +499,16 @@ bool sp_spray_recursive(SPDesktop *desktop, Geom::OptRect a = father->getBounds(father->i2doc_affine()); if (a) { - if (i==2) { + if (i == 2) { Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); parent->appendChild(copy1); SPObject *new_obj1 = doc->getObjectByRepr(copy1); son = (SPItem *) new_obj1; // conversion object->item - unionResult=son; + unionResult = son; Inkscape::GC::release(copy1); - } + } - if (_fid<=population) { // Rules the population of objects sprayed + if (_fid <= population) { // Rules the population of objects sprayed // duplicates the father Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc); parent->appendChild(copy2); @@ -552,12 +516,12 @@ bool sp_spray_recursive(SPDesktop *desktop, item_copied = (SPItem *) new_obj2; // Move around the cursor - Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); + Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); Geom::Point center=father->getCenter(); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); - sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); + sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); + sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale)); + sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); // union and duplication @@ -573,7 +537,7 @@ bool sp_spray_recursive(SPDesktop *desktop, } else if (mode == SPRAY_MODE_CLONE) { Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { - if(_fid<=population) { + if(_fid <= population) { SPItem *item_copied; SPDocument *doc = item->document; Inkscape::XML::Document* xml_doc = doc->getReprDoc(); @@ -590,11 +554,11 @@ bool sp_spray_recursive(SPDesktop *desktop, SPObject *clone_object = doc->getObjectByRepr(clone); // conversion object->item item_copied = (SPItem *) clone_object; - Geom::Point center=item->getCenter(); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); - sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); - Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); + Geom::Point center = item->getCenter(); + sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); + sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale)); + sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); + Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); Inkscape::GC::release(clone); @@ -612,35 +576,12 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop); SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop; - if (selection->isEmpty()) { return false; } bool did = false; double radius = get_dilate_radius(tc); - - - - bool do_fill = false, do_stroke = false, do_opacity = false; - guint32 fill_goal = sp_desktop_get_color_tool(desktop, "/tools/spray", true, &do_fill); - guint32 stroke_goal = sp_desktop_get_color_tool(desktop, "/tools/spray", false, &do_stroke); - double opacity_goal = sp_desktop_get_master_opacity_tool(desktop, "/tools/spray", &do_opacity); - if (reverse) { - // RGB inversion - fill_goal = SP_RGBA32_U_COMPOSE( - (255 - SP_RGBA32_R_U(fill_goal)), - (255 - SP_RGBA32_G_U(fill_goal)), - (255 - SP_RGBA32_B_U(fill_goal)), - (255 - SP_RGBA32_A_U(fill_goal))); - stroke_goal = SP_RGBA32_U_COMPOSE( - (255 - SP_RGBA32_R_U(stroke_goal)), - (255 - SP_RGBA32_G_U(stroke_goal)), - (255 - SP_RGBA32_B_U(stroke_goal)), - (255 - SP_RGBA32_A_U(stroke_goal))); - opacity_goal = 1 - opacity_goal; - } - double path_force = get_path_force(tc); if (radius == 0 || path_force == 0) { return false; @@ -657,7 +598,6 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, double move_mean = get_move_mean(tc); double move_standard_deviation = get_move_standard_deviation(tc); - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); items != NULL; items = items->next) { @@ -665,10 +605,10 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, SPItem *item = (SPItem *) items->data; if (is_transform_modes(tc->mode)) { - if (sp_spray_recursive (desktop,selection, item, p, vector, tc->mode, radius, move_force, tc->population,tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation,tc->ratio,tc->tilt, tc->rotation_variation, tc->distrib)) + if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) did = true; } else { - if (sp_spray_recursive (desktop,selection, item, p, vector, tc->mode, radius, path_force, tc->population,tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation,tc->ratio,tc->tilt, tc->rotation_variation, tc->distrib)) + if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, path_force, tc->population, tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) did = true; } } @@ -678,36 +618,35 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, void sp_spray_update_area(SPSprayContext *tc) { - double radius = get_dilate_radius(tc); - Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); - sp_canvas_item_affine_absolute(tc->dilate_area, (sm* Geom::Rotate(tc->tilt))* Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point())); - sp_canvas_item_show(tc->dilate_area); + double radius = get_dilate_radius(tc); + Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); + sp_canvas_item_affine_absolute(tc->dilate_area, (sm* Geom::Rotate(tc->tilt))* Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point())); + sp_canvas_item_show(tc->dilate_area); } void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) { // select the button mode - SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("spray_tool_mode", mode); + SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); // need to set explicitly, because the prefs may not have changed by the previous tc->mode = mode; - sp_spray_update_cursor (tc, with_shift); + sp_spray_update_cursor(tc, with_shift); } void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // Juggling about so that prefs have the old value but tc->mode and the button show new mode: - gint now_mode = prefs->getInt("/tools/spray/mode", 0); - SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("spray_tool_mode", mode); - // button has changed prefs, restore - prefs->setInt("/tools/spray/mode", now_mode); - // changing prefs changed tc->mode, restore back :) - tc->mode = mode; - sp_spray_update_cursor (tc, with_shift); + // Juggling about so that prefs have the old value but tc->mode and the button show new mode: + gint now_mode = prefs->getInt("/tools/spray/mode", 0); + SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); + // button has changed prefs, restore + prefs->setInt("/tools/spray/mode", now_mode); + // changing prefs changed tc->mode, restore back :) + tc->mode = mode; + sp_spray_update_cursor(tc, with_shift); } -gint sp_spray_context_root_handler(SPEventContext *event_context, - GdkEvent *event) +gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *event) { SPSprayContext *tc = SP_SPRAY_CONTEXT(event_context); SPDesktop *desktop = event_context->desktop; @@ -723,13 +662,11 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, break; case GDK_BUTTON_PRESS: if (event->button.button == 1 && !event_context->space_panning) { - if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) { return TRUE; } - Geom::Point const motion_w(event->button.x, - event->button.y); + Geom::Point const motion_w(event->button.x, event->button.y); Geom::Point const motion_dt(desktop->w2d(motion_w)); tc->last_push = desktop->dt2doc(motion_dt); @@ -738,23 +675,17 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3); tc->is_drawing = true; tc->is_dilating = true; - tc->has_dilated = false; - - - - if(tc->is_dilating && event->button.button == 1 && !event_context->space_panning) - - sp_spray_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + tc->has_dilated = false; + if(tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { + sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + } - - tc->has_dilated=true; - + tc->has_dilated = true; ret = TRUE; } break; - case GDK_MOTION_NOTIFY: - { + case GDK_MOTION_NOTIFY: { Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point motion_dt(desktop->w2d(motion_w)); @@ -762,22 +693,22 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, sp_spray_extinput(tc, event); // draw the dilating cursor - double radius = get_dilate_radius(tc); - Geom::Affine const sm (Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); - sp_canvas_item_affine_absolute(tc->dilate_area, (sm*Geom::Rotate(tc->tilt))*Geom::Translate(desktop->w2d(motion_w))); - sp_canvas_item_show(tc->dilate_area); - - guint num = 0; - if (!desktop->selection->isEmpty()) { - num = g_slist_length((GSList *) desktop->selection->itemList()); - } - if (num == 0) { - tc->_message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); - } + double radius = get_dilate_radius(tc); + Geom::Affine const sm (Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); + sp_canvas_item_affine_absolute(tc->dilate_area, (sm*Geom::Rotate(tc->tilt))*Geom::Translate(desktop->w2d(motion_w))); + sp_canvas_item_show(tc->dilate_area); + + guint num = 0; + if (!desktop->selection->isEmpty()) { + num = g_slist_length((GSList *) desktop->selection->itemList()); + } + if (num == 0) { + tc->_message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); + } // dilating: if (tc->is_drawing && ( event->motion.state & GDK_BUTTON1_MASK )) { - sp_spray_dilate (tc, motion_w, motion_doc, motion_doc - tc->last_push, event->button.state & GDK_SHIFT_MASK? true : false); + sp_spray_dilate(tc, motion_w, motion_doc, motion_doc - tc->last_push, event->button.state & GDK_SHIFT_MASK? true : false); //tc->last_push = motion_doc; tc->has_dilated = true; @@ -785,254 +716,206 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, gobble_motion_events(GDK_BUTTON1_MASK); return TRUE; } - } break; -/*Spray with the scroll*/ - case GDK_SCROLL: - { - if (event->scroll.state & GDK_BUTTON1_MASK) - { - double temp ; - temp=tc->population; - tc->population=1.0; - desktop->setToolboxAdjustmentValue ("population", tc->population * 100); - Geom::Point const scroll_w(event->button.x,event->button.y); - Geom::Point const scroll_dt = desktop->point();; - Geom::Point motion_doc(desktop->dt2doc(scroll_dt)); - switch (event->scroll.direction) - { - case GDK_SCROLL_UP: - { - if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) - { - return TRUE; - } - tc->last_push = desktop->dt2doc(scroll_dt); - sp_spray_extinput(tc, event); - sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3); - tc->is_drawing = true; - tc->is_dilating = true; - tc->has_dilated = false; - if(tc->is_dilating && !event_context->space_panning) - - sp_spray_dilate (tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0),false); - - - - tc->has_dilated=true; - tc->population=temp; - - desktop->setToolboxAdjustmentValue ("population", tc->population * 100); - - ret = TRUE; - } - break; - case GDK_SCROLL_DOWN: - { - if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) - { - return TRUE; - } - tc->last_push = desktop->dt2doc(scroll_dt); - sp_spray_extinput(tc, event); - sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3); - tc->is_drawing = true; - tc->is_dilating = true; - tc->has_dilated = false; - if(tc->is_dilating && !event_context->space_panning) - sp_spray_dilate (tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0), false); - - tc->has_dilated=true; - - ret = TRUE; - - - } - break; -case GDK_SCROLL_RIGHT: - {} break; -case GDK_SCROLL_LEFT: - {} break; - } - } - - - break; - - } - case GDK_BUTTON_RELEASE: - { - Geom::Point const motion_w(event->button.x, event->button.y); - Geom::Point const motion_dt(desktop->w2d(motion_w)); - - sp_canvas_end_forced_full_redraws(desktop->canvas); - tc->is_drawing = false; - - if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { - if (!tc->has_dilated) { - // if we did not rub, do a light tap - tc->pressure = 0.03; - sp_spray_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); - } - tc->is_dilating = false; - tc->has_dilated = false; - switch (tc->mode) { - case SPRAY_MODE_COPY: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_SPRAY, _("Spray with copies")); - break; - case SPRAY_MODE_CLONE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); + /*Spray with the scroll*/ + case GDK_SCROLL: { + if (event->scroll.state & GDK_BUTTON1_MASK) { + double temp ; + temp = tc->population; + tc->population = 1.0; + desktop->setToolboxAdjustmentValue("population", tc->population * 100); + Geom::Point const scroll_w(event->button.x, event->button.y); + Geom::Point const scroll_dt = desktop->point();; + Geom::Point motion_doc(desktop->dt2doc(scroll_dt)); + switch (event->scroll.direction) { + case GDK_SCROLL_DOWN: + case GDK_SCROLL_UP: { + if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) { + return TRUE; + } + tc->last_push = desktop->dt2doc(scroll_dt); + sp_spray_extinput(tc, event); + sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3); + tc->is_drawing = true; + tc->is_dilating = true; + tc->has_dilated = false; + if(tc->is_dilating && !event_context->space_panning) { + sp_spray_dilate(tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0), false); + } + tc->has_dilated = true; + + tc->population = temp; + desktop->setToolboxAdjustmentValue("population", tc->population * 100); + + ret = TRUE; + } break; - case SPRAY_MODE_SINGLE_PATH: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); - break; - } - } - break; - } - - case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { -case GDK_j: if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); - ret = TRUE; - } -case GDK_J: if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); - ret = TRUE; - } - -break; - case GDK_m: - case GDK_M: - case GDK_0: - - break; - case GDK_i: - case GDK_I: - case GDK_k: if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT); - ret = TRUE; - } - case GDK_K:if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT); - ret = TRUE; - } -break; - - case GDK_l: if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); - ret = TRUE; - } - - case GDK_L: - if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); - ret = TRUE; + case GDK_SCROLL_RIGHT: + {} break; + case GDK_SCROLL_LEFT: + {} break; + } } break; - case GDK_Up: - case GDK_KP_Up: - if (!MOD__CTRL_ONLY) { - tc->scale += 0.05; - - //desktop->setToolboxAdjustmentValue ("spray-force", tc->force * 100); - ret = TRUE; + } + + case GDK_BUTTON_RELEASE: { + Geom::Point const motion_w(event->button.x, event->button.y); + Geom::Point const motion_dt(desktop->w2d(motion_w)); + + sp_canvas_end_forced_full_redraws(desktop->canvas); + tc->is_drawing = false; + + if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { + if (!tc->has_dilated) { + // if we did not rub, do a light tap + tc->pressure = 0.03; + sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + } + tc->is_dilating = false; + tc->has_dilated = false; + switch (tc->mode) { + case SPRAY_MODE_COPY: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_SPRAY, _("Spray with copies")); + break; + case SPRAY_MODE_CLONE: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); + break; + case SPRAY_MODE_SINGLE_PATH: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); + break; + } } break; - case GDK_Down: - case GDK_KP_Down: - if (!MOD__CTRL_ONLY) { - - tc->scale -= 0.05; - if (tc->scale < 0.0) - tc->scale = 0.0; - //desktop->setToolboxAdjustmentValue ("spray-force", tc->force * 100); - - ret = TRUE; + } - } - break; - case GDK_Right: - case GDK_KP_Right: - if (!MOD__CTRL_ONLY) { - tc->width += 0.01; - if (tc->width > 1.0) - tc->width = 1.0; - desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100); // the same spinbutton is for alt+x - sp_spray_update_area(tc); - ret = TRUE; - } - break; - case GDK_Left: - case GDK_KP_Left: - if (!MOD__CTRL_ONLY) { - tc->width -= 0.01; - if (tc->width < 0.01) + case GDK_KEY_PRESS: + switch (get_group0_keyval (&event->key)) { + case GDK_j: + case GDK_J: + if (MOD__SHIFT_ONLY) { + sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); + ret = TRUE; + } + break; + case GDK_k: + case GDK_K: + if (MOD__SHIFT_ONLY) { + sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); + ret = TRUE; + } + break; + case GDK_l: + case GDK_L: + if (MOD__SHIFT_ONLY) { + sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT); + ret = TRUE; + } + break; + case GDK_Up: + case GDK_KP_Up: + if (!MOD__CTRL_ONLY) { + tc->population += 0.01; + if (tc->population > 1.0) { + tc->population = 1.0; + } + desktop->setToolboxAdjustmentValue("spray-population", tc->population * 100); + ret = TRUE; + } + break; + case GDK_Down: + case GDK_KP_Down: + if (!MOD__CTRL_ONLY) { + tc->population -= 0.01; + if (tc->population < 0.0) { + tc->population = 0.0; + } + desktop->setToolboxAdjustmentValue("spray-population", tc->population * 100); + ret = TRUE; + } + break; + case GDK_Right: + case GDK_KP_Right: + if (!MOD__CTRL_ONLY) { + tc->width += 0.01; + if (tc->width > 1.0) { + tc->width = 1.0; + } + // the same spinbutton is for alt+x + desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100); + sp_spray_update_area(tc); + ret = TRUE; + } + break; + case GDK_Left: + case GDK_KP_Left: + if (!MOD__CTRL_ONLY) { + tc->width -= 0.01; + if (tc->width < 0.01) { + tc->width = 0.01; + } + desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100); + sp_spray_update_area(tc); + ret = TRUE; + } + break; + case GDK_Home: + case GDK_KP_Home: tc->width = 0.01; - desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100); - sp_spray_update_area(tc); - ret = TRUE; + desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100); + sp_spray_update_area(tc); + ret = TRUE; + break; + case GDK_End: + case GDK_KP_End: + tc->width = 1.0; + desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100); + sp_spray_update_area(tc); + ret = TRUE; + break; + case GDK_x: + case GDK_X: + if (MOD__ALT_ONLY) { + desktop->setToolboxFocusTo("altx-spray"); + ret = TRUE; + } + break; + case GDK_Shift_L: + case GDK_Shift_R: + sp_spray_update_cursor(tc, true); + break; + case GDK_Control_L: + case GDK_Control_R: + break; + default: + break; } break; - case GDK_Home: - case GDK_KP_Home: - tc->width = 0.01; - desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100); - sp_spray_update_area(tc); - ret = TRUE; - break; - case GDK_End: - case GDK_KP_End: - tc->width = 1.0; - desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100); - sp_spray_update_area(tc); - ret = TRUE; - break; - case GDK_x: - case GDK_X: - if (MOD__ALT_ONLY) { - desktop->setToolboxFocusTo ("altx-spray"); - ret = TRUE; + + case GDK_KEY_RELEASE: { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + switch (get_group0_keyval(&event->key)) { + case GDK_Shift_L: + case GDK_Shift_R: + sp_spray_update_cursor(tc, false); + break; + case GDK_Control_L: + case GDK_Control_R: + sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); + tc->_message_context->clear(); + break; + default: + sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); + break; } - break; + } - case GDK_Shift_L: - case GDK_Shift_R: - sp_spray_update_cursor(tc, true); - break; -/*Set the scale to 1*/ - case GDK_Control_L: - tc->scale=1; default: break; - } - break; - - case GDK_KEY_RELEASE: { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - switch (get_group0_keyval(&event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: - sp_spray_update_cursor(tc, false); - break; - case GDK_Control_L: - case GDK_Control_R: - sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); - tc->_message_context->clear(); - break; - default: - sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); - break; - } - } - - default: - break; } if (!ret) { diff --git a/src/spray-context.h b/src/spray-context.h index edb872117..c485a6a96 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -91,11 +91,6 @@ struct SPSprayContext Geom::Point last_push; SPCanvasItem *dilate_area; - bool do_h; - bool do_s; - bool do_l; - bool do_o; - sigc::connection style_set_connection; }; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 7ef864383..fe87bc4e2 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -332,7 +332,6 @@ static gchar const * ui_descr = " " " " " " - " " " " " " " " @@ -469,9 +468,9 @@ static gchar const * ui_descr = " " " " - " " - " " " " + " " + " " " " " " @@ -4609,10 +4608,10 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { /* Mean */ - gchar const* labels[] = {_("(minimum mean)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum mean)")}; - gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100}; + gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(maximum mean)")}; + gdouble values[] = {0, 5, 10, 20, 30, 50, 70, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayMeanAction", - _("Focus"), _("Focus:"), _("0 to spray a spot. Increase to enlarge the ring radius."), + _("Focus"), _("Focus:"), _("0 to spray a spot; increase to enlarge the ring radius"), "/tools/spray/mean", 0, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-mean", 0, 100, 1.0, 10.0, @@ -4625,13 +4624,10 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { /* Standard_deviation */ - gchar const* labels[] = {_("(minimum scatter)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum scatter)")}; + gchar const* labels[] = {_("(minimum scatter)"), 0, 0, 0, 0, 0, _("(default)"), _("(maximum scatter)")}; gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100}; - - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction", - Q_("Toolbox|Scatter"), Q_("Toolbox|Scatter:"), _("Increase to scatter sprayed objects."), + C_("Spray tool", "Scatter"), C_("Spray tool", "Scatter:"), _("Increase to scatter sprayed objects"), "/tools/spray/standard_deviation", 70, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation", 1, 100, 1.0, 10.0, @@ -4688,11 +4684,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction } { /* Population */ - gchar const* labels[] = {_("(low population)"), 0, 0, _("(default)"), 0, 0, _("(high population)")}; - gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; + gchar const* labels[] = {_("(low population)"), 0, 0, 0, _("(default)"), 0, _("(high population)")}; + gdouble values[] = {5, 20, 35, 50, 70, 85, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayPopulationAction", _("Amount"), _("Amount:"), - _("Adjusts the number of items sprayed per clic."), + _("Adjusts the number of items sprayed per clic"), "/tools/spray/population", 70, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-population", 1, 100, 1.0, 10.0, @@ -4708,21 +4704,22 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction", _("Pressure"), - _("Use the pressure of the input device to alter the amount of sprayed objects."), + _("Use the pressure of the input device to alter the amount of sprayed objects"), "use_pressure", Inkscape::ICON_SIZE_DECORATION ); - gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); - g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_spray_pressure_state_changed), NULL); - gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressure", true) ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure"); + g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } { /* Rotation */ - gchar const* labels[] = {_("(low rotation variation)"), 0, 0, _("(default)"), 0, 0, _("(high rotation variation)")}; - gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; + gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(high rotation variation)")}; + gdouble values[] = {0, 10, 25, 35, 50, 60, 80, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayRotationAction", _("Rotation"), _("Rotation:"), // xgettext:no-c-format - _("Variation of the rotation of the sprayed objects. 0% for the same rotation than the original object."), + _("Variation of the rotation of the sprayed objects; 0% for the same rotation than the original object"), "/tools/spray/rotation_variation", 0, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-rotation", 0, 100, 1.0, 10.0, @@ -4735,15 +4732,12 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction } { /* Scale */ - gchar const* labels[] = {_("(low scale variation)"), 0, 0, _("(default)"), 0, 0, _("(high scale variation)")}; - gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; - - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS + gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(high scale variation)")}; + gdouble values[] = {0, 10, 25, 35, 50, 60, 80, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayScaleAction", - Q_("Toolbox|Scale"), Q_("Toolbox|Scale:"), + C_("Spray tool", "Scale"), C_("Spray tool", "Scale:"), // xgettext:no-c-format - _("Variation in the scale of the sprayed objects. 0% for the same scale than the original object."), + _("Variation in the scale of the sprayed objects; 0% for the same scale than the original object"), "/tools/spray/scale_variation", 0, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-scale", 0, 100, 1.0, 10.0, @@ -6117,23 +6111,6 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { - { - /* Width */ - gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")}; - gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100}; - EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction", - _("Pen Width"), _("Width:"), - _("The width of the eraser pen (relative to the visible canvas area)"), - "/tools/eraser/width", 15, - GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser", - 1, 100, 1.0, 10.0, - labels, values, G_N_ELEMENTS(labels), - sp_erc_width_value_changed, 1, 0); - ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); - gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); - gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); - } - { GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); @@ -6153,9 +6130,10 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); + g_object_set( act, "short_label", _("Mode:"), NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); g_object_set_data( holder, "eraser_mode_action", act ); - + ege_select_one_action_set_appearance( act, "full" ); ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); @@ -6169,6 +6147,23 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder ); } + { + /* Width */ + gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")}; + gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100}; + EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction", + _("Pen Width"), _("Width:"), + _("The width of the eraser pen (relative to the visible canvas area)"), + "/tools/eraser/width", 15, + GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser", + 1, 100, 1.0, 10.0, + labels, values, G_N_ELEMENTS(labels), + sp_erc_width_value_changed, 1, 0); + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } + } //######################## -- cgit v1.2.3 From 5159eab4b1501a05071b412844753337974f1962 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 30 Mar 2011 23:12:13 +0200 Subject: Extensions: * New isometric grid. * All grids are now grouped in Render>Grids. Translations: * inkscape.pot update. (bzr r10135) --- src/extension/internal/grid.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 2e743d32a..6436624fd 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -207,7 +207,9 @@ Grid::init (void) "\n" "all\n" "\n" - "\n" + "\n" + "\n" + "\n" "\n" "" N_("Draw a path which is a grid") "\n" "\n" -- cgit v1.2.3 From be2a3a1b134772cbff37f3906ab3d1b8673000ec Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 30 Mar 2011 20:37:39 -0400 Subject: emf import. limited support for EMR_BITBLT (Bug 382421) Fixed bugs: - https://launchpad.net/bugs/382421 (bzr r10136) --- src/extension/internal/emf-win32-inout.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 607827943..cea68c6da 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -75,6 +75,7 @@ #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND) #endif +#define DPA 0x00A000C9 // TernaryRasterOperation namespace Inkscape { namespace Extension { @@ -1761,8 +1762,36 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * dbg_str << "\n"; break; case EMR_BITBLT: + { dbg_str << "\n"; + + PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR; + if (pEmr->dwRop == DPA) { + // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest); + double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest); + double r = pix_to_x_point( d, pEmr->xDest + pEmr->cxDest, pEmr->yDest + pEmr->cyDest); + double b = pix_to_y_point( d, pEmr->xDest + pEmr->cxDest, pEmr->yDest + pEmr->cyDest); + + SVGOStringStream tmp_rectangle; + tmp_rectangle << "d=\""; + tmp_rectangle << "\n\tM " << l << " " << t << " "; + tmp_rectangle << "\n\tL " << r << " " << t << " "; + tmp_rectangle << "\n\tL " << r << " " << b << " "; + tmp_rectangle << "\n\tL " << l << " " << b << " "; + tmp_rectangle << "\n\tz"; + + assert_empty_path(d, "EMR_BITBLT"); + + *(d->outsvg) += " iType); + *(d->outsvg) += "\n\t"; + *(d->outsvg) += tmp_rectangle.str().c_str(); + *(d->outsvg) += " \" /> \n"; + *(d->path) = ""; + } break; + } case EMR_STRETCHBLT: dbg_str << "\n"; break; -- cgit v1.2.3 From 0ff79849c34ee1a5120b70968ccc4b418877f8e1 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 1 Apr 2011 14:52:41 +0200 Subject: Tweak and spray: * Fix for Bug #745652 (Gradient handles persistence with Tweak and Spray). * Fix for Bug #490225 (Tweak Tool : Opacity doesn't change in Paint/Jitter modes). * Tweak tool code consistency fix. * Spray tool default status message modified. (bzr r10139) --- src/desktop-style.cpp | 2 +- src/spray-context.cpp | 4 + src/tools-switch.cpp | 2 +- src/tweak-context.cpp | 833 +++++++++++++++++++++++++------------------------- 4 files changed, 428 insertions(+), 413 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index d2ec093fc..2c20964aa 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -288,7 +288,7 @@ sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool value = 1.0; // things failed. set back to the default } else { if (has_opacity) - *has_opacity = false; + *has_opacity = true; } } diff --git a/src/spray-context.cpp b/src/spray-context.cpp index ae74b09da..553edf69b 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -36,6 +36,7 @@ #include "desktop-events.h" #include "desktop-handles.h" #include "unistd.h" +//#include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-spray.xpm" #include @@ -190,6 +191,9 @@ static void sp_spray_context_init(SPSprayContext *tc) static void sp_spray_context_dispose(GObject *object) { SPSprayContext *tc = SP_SPRAY_CONTEXT(object); + SPEventContext *ec = SP_EVENT_CONTEXT(object); + + ec->enableGrDrag(false); tc->style_set_connection.disconnect(); tc->style_set_connection.~connection(); diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index e9fca952e..1f624cc35 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -140,7 +140,7 @@ tools_switch(SPDesktop *dt, int num) dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]); dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("To spray a path by pushing, select it and drag over it.")); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag, click or scroll to spray the selected objects.")); break; case TOOLS_SHAPES_RECT: dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index c1ab82af8..aef7dfba9 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -159,7 +159,10 @@ static void sp_tweak_context_dispose(GObject *object) { SPTweakContext *tc = SP_TWEAK_CONTEXT(object); + SPEventContext *ec = SP_EVENT_CONTEXT(object); + ec->enableGrDrag(false); + tc->style_set_connection.disconnect(); tc->style_set_connection.~connection(); @@ -193,18 +196,17 @@ bool is_color_mode (gint mode) void sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) { - SPEventContext *event_context = SP_EVENT_CONTEXT(tc); - SPDesktop *desktop = event_context->desktop; - - guint num = 0; - gchar *sel_message = NULL; - if (!desktop->selection->isEmpty()) { - num = g_slist_length((GSList *) desktop->selection->itemList()); - sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); - } else { - sel_message = g_strdup_printf(_("Nothing selected")); - } + SPEventContext *event_context = SP_EVENT_CONTEXT(tc); + SPDesktop *desktop = event_context->desktop; + guint num = 0; + gchar *sel_message = NULL; + if (!desktop->selection->isEmpty()) { + num = g_slist_length((GSList *) desktop->selection->itemList()); + sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); + } else { + sel_message = g_strdup_printf(_("Nothing selected")); + } switch (tc->mode) { case TWEAK_MODE_MOVE: @@ -285,14 +287,14 @@ sp_tweak_context_style_set(SPCSSAttr const *css, SPTweakContext *tc) return false; } - static void sp_tweak_context_setup(SPEventContext *ec) { SPTweakContext *tc = SP_TWEAK_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) + if (((SPEventContextClass *) parent_class)->setup) { ((SPEventContextClass *) parent_class)->setup(ec); + } { /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */ @@ -333,7 +335,6 @@ sp_tweak_context_setup(SPEventContext *ec) if (prefs->getBool("/tools/tweak/selcue")) { ec->enableSelectionCue(); } - if (prefs->getBool("/tools/tweak/gradientdrag")) { ec->enableGrDrag(); } @@ -370,10 +371,11 @@ sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) static void sp_tweak_extinput(SPTweakContext *tc, GdkEvent *event) { - if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &tc->pressure)) + if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &tc->pressure)) { tc->pressure = CLAMP (tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE); - else + } else { tc->pressure = TC_DEFAULT_PRESSURE; + } } double @@ -545,154 +547,152 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (SP_IS_PATH(item) || SP_IS_SHAPE(item)) { - Inkscape::XML::Node *newrepr = NULL; - gint pos = 0; - Inkscape::XML::Node *parent = NULL; - char const *id = NULL; - if (!SP_IS_PATH(item)) { - newrepr = sp_selected_item_to_curved_repr(item, 0); - if (!newrepr) - return false; + Inkscape::XML::Node *newrepr = NULL; + gint pos = 0; + Inkscape::XML::Node *parent = NULL; + char const *id = NULL; + if (!SP_IS_PATH(item)) { + newrepr = sp_selected_item_to_curved_repr(item, 0); + if (!newrepr) { + return false; + } - // remember the position of the item - pos = item->getRepr()->position(); - // remember parent - parent = item->getRepr()->parent(); - // remember id - id = item->getRepr()->attribute("id"); - } + // remember the position of the item + pos = item->getRepr()->position(); + // remember parent + parent = item->getRepr()->parent(); + // remember id + id = item->getRepr()->attribute("id"); + } + // skip those paths whose bboxes are entirely out of reach with our radius + Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); + if (bbox) { + bbox->expandBy(radius); + if (!bbox->contains(p)) { + return false; + } + } - // skip those paths whose bboxes are entirely out of reach with our radius - Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); - if (bbox) { - bbox->expandBy(radius); - if (!bbox->contains(p)) { + Path *orig = Path_for_item(item, false); + if (orig == NULL) { return false; } - } - Path *orig = Path_for_item(item, false); - if (orig == NULL) { - return false; - } + Path *res = new Path; + res->SetBackData(false); - Path *res = new Path; - res->SetBackData(false); + Shape *theShape = new Shape; + Shape *theRes = new Shape; + Geom::Affine i2doc(item->i2doc_affine()); - Shape *theShape = new Shape; - Shape *theRes = new Shape; - Geom::Affine i2doc(item->i2doc_affine()); + orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059 + orig->Fill(theShape, 0); - orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059 - orig->Fill(theShape, 0); + SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); + gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); + if (val && strcmp(val, "nonzero") == 0) { + theRes->ConvertToShape(theShape, fill_nonZero); + } else if (val && strcmp(val, "evenodd") == 0) { + theRes->ConvertToShape(theShape, fill_oddEven); + } else { + theRes->ConvertToShape(theShape, fill_nonZero); + } - SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); - gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); - if (val && strcmp(val, "nonzero") == 0) - { - theRes->ConvertToShape(theShape, fill_nonZero); - } - else if (val && strcmp(val, "evenodd") == 0) - { - theRes->ConvertToShape(theShape, fill_oddEven); - } - else - { - theRes->ConvertToShape(theShape, fill_nonZero); - } + if (Geom::L2(vector) != 0) { + vector = 1/Geom::L2(vector) * vector; + } - if (Geom::L2(vector) != 0) - vector = 1/Geom::L2(vector) * vector; - - bool did_this = false; - if (mode == TWEAK_MODE_SHRINK_GROW) { - if (theShape->MakeTweak(tweak_mode_grow, theRes, - reverse? force : -force, - join_straight, 4.0, - true, p, Geom::Point(0,0), radius, &i2doc) == 0) // 0 means the shape was actually changed - did_this = true; - } else if (mode == TWEAK_MODE_ATTRACT_REPEL) { - if (theShape->MakeTweak(tweak_mode_repel, theRes, - reverse? force : -force, - join_straight, 4.0, - true, p, Geom::Point(0,0), radius, &i2doc) == 0) - did_this = true; - } else if (mode == TWEAK_MODE_PUSH) { - if (theShape->MakeTweak(tweak_mode_push, theRes, - 1.0, - join_straight, 4.0, - true, p, force*2*vector, radius, &i2doc) == 0) - did_this = true; - } else if (mode == TWEAK_MODE_ROUGHEN) { - if (theShape->MakeTweak(tweak_mode_roughen, theRes, - force, - join_straight, 4.0, - true, p, Geom::Point(0,0), radius, &i2doc) == 0) - did_this = true; - } + bool did_this = false; + if (mode == TWEAK_MODE_SHRINK_GROW) { + if (theShape->MakeTweak(tweak_mode_grow, theRes, + reverse? force : -force, + join_straight, 4.0, + true, p, Geom::Point(0,0), radius, &i2doc) == 0) // 0 means the shape was actually changed + did_this = true; + } else if (mode == TWEAK_MODE_ATTRACT_REPEL) { + if (theShape->MakeTweak(tweak_mode_repel, theRes, + reverse? force : -force, + join_straight, 4.0, + true, p, Geom::Point(0,0), radius, &i2doc) == 0) + did_this = true; + } else if (mode == TWEAK_MODE_PUSH) { + if (theShape->MakeTweak(tweak_mode_push, theRes, + 1.0, + join_straight, 4.0, + true, p, force*2*vector, radius, &i2doc) == 0) + did_this = true; + } else if (mode == TWEAK_MODE_ROUGHEN) { + if (theShape->MakeTweak(tweak_mode_roughen, theRes, + force, + join_straight, 4.0, + true, p, Geom::Point(0,0), radius, &i2doc) == 0) + did_this = true; + } - // the rest only makes sense if we actually changed the path - if (did_this) { - theRes->ConvertToShape(theShape, fill_positive); + // the rest only makes sense if we actually changed the path + if (did_this) { + theRes->ConvertToShape(theShape, fill_positive); - res->Reset(); - theRes->ConvertToForme(res); + res->Reset(); + theRes->ConvertToForme(res); - double th_max = (0.6 - 0.59*sqrt(fidelity)) / i2doc.descrim(); - double threshold = MAX(th_max, th_max*force); - res->ConvertEvenLines(threshold); - res->Simplify(threshold / (selection->desktop()->current_zoom())); + double th_max = (0.6 - 0.59*sqrt(fidelity)) / i2doc.descrim(); + double threshold = MAX(th_max, th_max*force); + res->ConvertEvenLines(threshold); + res->Simplify(threshold / (selection->desktop()->current_zoom())); - if (newrepr) { // converting to path, need to replace the repr - bool is_selected = selection->includes(item); - if (is_selected) - selection->remove(item); + if (newrepr) { // converting to path, need to replace the repr + bool is_selected = selection->includes(item); + if (is_selected) { + selection->remove(item); + } - // It's going to resurrect, so we delete without notifying listeners. - item->deleteObject(false); + // It's going to resurrect, so we delete without notifying listeners. + item->deleteObject(false); - // restore id - newrepr->setAttribute("id", id); - // add the new repr to the parent - parent->appendChild(newrepr); - // move to the saved position - newrepr->setPosition(pos > 0 ? pos : 0); + // restore id + newrepr->setAttribute("id", id); + // add the new repr to the parent + parent->appendChild(newrepr); + // move to the saved position + newrepr->setPosition(pos > 0 ? pos : 0); - if (is_selected) - selection->add(newrepr); - } + if (is_selected) + selection->add(newrepr); + } - if (res->descr_cmd.size() > 1) { - gchar *str = res->svg_dump_path(); - if (newrepr) { - newrepr->setAttribute("d", str); - } else { - if (SP_IS_LPE_ITEM(item) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(item))) { - item->getRepr()->setAttribute("inkscape:original-d", str); + if (res->descr_cmd.size() > 1) { + gchar *str = res->svg_dump_path(); + if (newrepr) { + newrepr->setAttribute("d", str); } else { - item->getRepr()->setAttribute("d", str); + if (SP_IS_LPE_ITEM(item) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(item))) { + item->getRepr()->setAttribute("inkscape:original-d", str); + } else { + item->getRepr()->setAttribute("d", str); + } } + g_free(str); + } else { + // TODO: if there's 0 or 1 node left, delete this path altogether } - g_free(str); - } else { - // TODO: if there's 0 or 1 node left, delete this path altogether - } - if (newrepr) { - Inkscape::GC::release(newrepr); - newrepr = NULL; + if (newrepr) { + Inkscape::GC::release(newrepr); + newrepr = NULL; + } } - } - delete theShape; - delete theRes; - delete orig; - delete res; + delete theShape; + delete theRes; + delete orig; + delete res; - if (did_this) - did = true; - } + if (did_this) { + did = true; + } + } } @@ -709,12 +709,15 @@ tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s sp_color_rgb_to_hsl_floatv (hsl_g, SP_RGBA32_R_F(goal), SP_RGBA32_G_F(goal), SP_RGBA32_B_F(goal)); float hsl_c[3]; sp_color_rgb_to_hsl_floatv (hsl_c, color[0], color[1], color[2]); - if (!do_h) + if (!do_h) { hsl_g[0] = hsl_c[0]; - if (!do_s) + } + if (!do_s) { hsl_g[1] = hsl_c[1]; - if (!do_l) + } + if (!do_l) { hsl_g[2] = hsl_c[2]; + } sp_color_hsl_to_rgb_floatv (rgb_g, hsl_g[0], hsl_g[1], hsl_g[2]); } else { rgb_g[0] = SP_RGBA32_R_F(goal); @@ -736,10 +739,12 @@ tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l) if (do_h) { hsl_c[0] += g_random_double_range(-0.5, 0.5) * force; - if (hsl_c[0] > 1) + if (hsl_c[0] > 1) { hsl_c[0] -= 1; - if (hsl_c[0] < 0) + } + if (hsl_c[0] < 0) { hsl_c[0] += 1; + } } if (do_s) { hsl_c[1] += g_random_double_range(-hsl_c[1], 1 - hsl_c[1]) * force; @@ -780,8 +785,9 @@ tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, doubl double tweak_profile (double dist, double radius) { - if (radius == 0) + if (radius == 0) { return 0; + } double x = dist / radius; double alpha = 1; if (x >= 1) { @@ -800,8 +806,9 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke, { SPGradient *gradient = sp_item_gradient (item, fill_or_stroke); - if (!gradient || !SP_IS_GRADIENT(gradient)) + if (!gradient || !SP_IS_GRADIENT(gradient)) { return; + } Geom::Affine i2d (item->i2doc_affine ()); Geom::Point p = p_w * i2d.inverse(); @@ -932,8 +939,9 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, stroke_goal, do_stroke, opacity_goal, do_opacity, do_blur, reverse, - p, radius, force, do_h, do_s, do_l, do_o)) + p, radius, force, do_h, do_s, do_l, do_o)) { did = true; + } } } @@ -1000,20 +1008,19 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, blur_now = blur_now / perimeter; double blur_new; - if (reverse) + if (reverse) { blur_new = blur_now - 0.06 * force; - else + } else { blur_new = blur_now + 0.06 * force; + } if (blur_new < 0.0005 && blur_new < blur_now) { blur_new = 0; } - if (blur_new == 0) { remove_filter(item, false); } else { double radius = blur_new * perimeter; SPFilter *filter = modify_filter_gaussian_blur_from_item(item->document, item, radius); - sp_style_set_property_url(item, "filter", filter, false); } return true; // do not do colors, blur is a separate mode @@ -1121,15 +1128,18 @@ sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::P stroke_goal, do_stroke, opacity_goal, do_opacity, tc->mode == TWEAK_MODE_BLUR, reverse, - p, radius, color_force, tc->do_h, tc->do_s, tc->do_l, tc->do_o)) - did = true; + p, radius, color_force, tc->do_h, tc->do_s, tc->do_l, tc->do_o)) { + did = true; + } } } else if (is_transform_mode(tc->mode)) { - if (sp_tweak_dilate_recursive (selection, item, p, vector, tc->mode, radius, move_force, tc->fidelity, reverse)) + if (sp_tweak_dilate_recursive (selection, item, p, vector, tc->mode, radius, move_force, tc->fidelity, reverse)) { did = true; + } } else { - if (sp_tweak_dilate_recursive (selection, item, p, vector, tc->mode, radius, path_force, tc->fidelity, reverse)) + if (sp_tweak_dilate_recursive (selection, item, p, vector, tc->mode, radius, path_force, tc->fidelity, reverse)) { did = true; + } } } @@ -1240,286 +1250,287 @@ sp_tweak_context_root_handler(SPEventContext *event_context, } break; + case GDK_BUTTON_RELEASE: + { + Geom::Point const motion_w(event->button.x, event->button.y); + Geom::Point const motion_dt(desktop->w2d(motion_w)); + sp_canvas_end_forced_full_redraws(desktop->canvas); + tc->is_drawing = false; - case GDK_BUTTON_RELEASE: - { - Geom::Point const motion_w(event->button.x, event->button.y); - Geom::Point const motion_dt(desktop->w2d(motion_w)); - - sp_canvas_end_forced_full_redraws(desktop->canvas); - tc->is_drawing = false; - - if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { - if (!tc->has_dilated) { - // if we did not rub, do a light tap - tc->pressure = 0.03; - sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { + if (!tc->has_dilated) { + // if we did not rub, do a light tap + tc->pressure = 0.03; + sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + } + tc->is_dilating = false; + tc->has_dilated = false; + switch (tc->mode) { + case TWEAK_MODE_MOVE: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Move tweak")); + break; + case TWEAK_MODE_MOVE_IN_OUT: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak")); + break; + case TWEAK_MODE_MOVE_JITTER: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak")); + break; + case TWEAK_MODE_SCALE: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Scale tweak")); + break; + case TWEAK_MODE_ROTATE: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Rotate tweak")); + break; + case TWEAK_MODE_MORELESS: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak")); + break; + case TWEAK_MODE_PUSH: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Push path tweak")); + break; + case TWEAK_MODE_SHRINK_GROW: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak")); + break; + case TWEAK_MODE_ATTRACT_REPEL: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak")); + break; + case TWEAK_MODE_ROUGHEN: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak")); + break; + case TWEAK_MODE_COLORPAINT: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Color paint tweak")); + break; + case TWEAK_MODE_COLORJITTER: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak")); + break; + case TWEAK_MODE_BLUR: + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SP_VERB_CONTEXT_TWEAK, _("Blur tweak")); + break; + } } - tc->is_dilating = false; - tc->has_dilated = false; - switch (tc->mode) { - case TWEAK_MODE_MOVE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Move tweak")); + break; + } + case GDK_KEY_PRESS: + { + switch (get_group0_keyval (&event->key)) { + case GDK_m: + case GDK_M: + case GDK_0: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_MOVE_IN_OUT: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak")); + case GDK_i: + case GDK_I: + case GDK_1: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_MOVE_JITTER: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak")); + case GDK_z: + case GDK_Z: + case GDK_2: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_SCALE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Scale tweak")); + case GDK_less: + case GDK_comma: + case GDK_greater: + case GDK_period: + case GDK_3: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_SCALE, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_ROTATE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Rotate tweak")); + case GDK_bracketright: + case GDK_bracketleft: + case GDK_4: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_ROTATE, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_MORELESS: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak")); + case GDK_d: + case GDK_D: + case GDK_5: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_MORELESS, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_PUSH: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Push path tweak")); + case GDK_p: + case GDK_P: + case GDK_6: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_PUSH, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_SHRINK_GROW: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak")); + case GDK_s: + case GDK_S: + case GDK_7: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_ATTRACT_REPEL: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak")); + case GDK_a: + case GDK_A: + case GDK_8: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_ROUGHEN: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak")); + case GDK_r: + case GDK_R: + case GDK_9: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_ROUGHEN, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_COLORPAINT: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Color paint tweak")); + case GDK_c: + case GDK_C: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_COLORPAINT, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_COLORJITTER: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak")); + case GDK_j: + case GDK_J: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_COLORJITTER, MOD__SHIFT); + ret = TRUE; + } break; - case TWEAK_MODE_BLUR: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SP_VERB_CONTEXT_TWEAK, _("Blur tweak")); + case GDK_b: + case GDK_B: + if (MOD__SHIFT_ONLY) { + sp_tweak_switch_mode(tc, TWEAK_MODE_BLUR, MOD__SHIFT); + ret = TRUE; + } break; - } - } - break; - } - case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { - case GDK_m: - case GDK_M: - case GDK_0: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_i: - case GDK_I: - case GDK_1: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_z: - case GDK_Z: - case GDK_2: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_less: - case GDK_comma: - case GDK_greater: - case GDK_period: - case GDK_3: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_SCALE, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_bracketright: - case GDK_bracketleft: - case GDK_4: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_ROTATE, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_d: - case GDK_D: - case GDK_5: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MORELESS, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_p: - case GDK_P: - case GDK_6: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_PUSH, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_s: - case GDK_S: - case GDK_7: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_a: - case GDK_A: - case GDK_8: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_r: - case GDK_R: - case GDK_9: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_ROUGHEN, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_c: - case GDK_C: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_COLORPAINT, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_j: - case GDK_J: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_COLORJITTER, MOD__SHIFT); - ret = TRUE; - } - break; - case GDK_b: - case GDK_B: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(tc, TWEAK_MODE_BLUR, MOD__SHIFT); - ret = TRUE; - } - break; - - case GDK_Up: - case GDK_KP_Up: - if (!MOD__CTRL_ONLY) { - tc->force += 0.05; - if (tc->force > 1.0) - tc->force = 1.0; - desktop->setToolboxAdjustmentValue ("tweak-force", tc->force * 100); - ret = TRUE; - } - break; - case GDK_Down: - case GDK_KP_Down: - if (!MOD__CTRL_ONLY) { - tc->force -= 0.05; - if (tc->force < 0.0) - tc->force = 0.0; - desktop->setToolboxAdjustmentValue ("tweak-force", tc->force * 100); - ret = TRUE; - } - break; - case GDK_Right: - case GDK_KP_Right: - if (!MOD__CTRL_ONLY) { - tc->width += 0.01; - if (tc->width > 1.0) - tc->width = 1.0; - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); // the same spinbutton is for alt+x - sp_tweak_update_area(tc); - ret = TRUE; - } - break; - case GDK_Left: - case GDK_KP_Left: - if (!MOD__CTRL_ONLY) { - tc->width -= 0.01; - if (tc->width < 0.01) + case GDK_Up: + case GDK_KP_Up: + if (!MOD__CTRL_ONLY) { + tc->force += 0.05; + if (tc->force > 1.0) { + tc->force = 1.0; + } + desktop->setToolboxAdjustmentValue ("tweak-force", tc->force * 100); + ret = TRUE; + } + break; + case GDK_Down: + case GDK_KP_Down: + if (!MOD__CTRL_ONLY) { + tc->force -= 0.05; + if (tc->force < 0.0) { + tc->force = 0.0; + } + desktop->setToolboxAdjustmentValue ("tweak-force", tc->force * 100); + ret = TRUE; + } + break; + case GDK_Right: + case GDK_KP_Right: + if (!MOD__CTRL_ONLY) { + tc->width += 0.01; + if (tc->width > 1.0) { + tc->width = 1.0; + } + desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); // the same spinbutton is for alt+x + sp_tweak_update_area(tc); + ret = TRUE; + } + break; + case GDK_Left: + case GDK_KP_Left: + if (!MOD__CTRL_ONLY) { + tc->width -= 0.01; + if (tc->width < 0.01) { + tc->width = 0.01; + } + desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); + sp_tweak_update_area(tc); + ret = TRUE; + } + break; + case GDK_Home: + case GDK_KP_Home: tc->width = 0.01; - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); - sp_tweak_update_area(tc); - ret = TRUE; - } - break; - case GDK_Home: - case GDK_KP_Home: - tc->width = 0.01; - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); - sp_tweak_update_area(tc); - ret = TRUE; - break; - case GDK_End: - case GDK_KP_End: - tc->width = 1.0; - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); - sp_tweak_update_area(tc); - ret = TRUE; - break; - case GDK_x: - case GDK_X: - if (MOD__ALT_ONLY) { - desktop->setToolboxFocusTo ("altx-tweak"); - ret = TRUE; - } - break; + desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); + sp_tweak_update_area(tc); + ret = TRUE; + break; + case GDK_End: + case GDK_KP_End: + tc->width = 1.0; + desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); + sp_tweak_update_area(tc); + ret = TRUE; + break; + case GDK_x: + case GDK_X: + if (MOD__ALT_ONLY) { + desktop->setToolboxFocusTo ("altx-tweak"); + ret = TRUE; + } + break; - case GDK_Shift_L: - case GDK_Shift_R: - sp_tweak_update_cursor(tc, true); - break; + case GDK_Shift_L: + case GDK_Shift_R: + sp_tweak_update_cursor(tc, true); + break; - case GDK_Control_L: - case GDK_Control_R: - sp_tweak_switch_mode_temporarily(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); - break; - default: + case GDK_Control_L: + case GDK_Control_R: + sp_tweak_switch_mode_temporarily(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); + break; + default: + break; + } break; } - break; - - case GDK_KEY_RELEASE: { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - switch (get_group0_keyval(&event->key)) { - case GDK_Shift_L: - case GDK_Shift_R: - sp_tweak_update_cursor(tc, false); - break; - case GDK_Control_L: - case GDK_Control_R: - sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); - tc->_message_context->clear(); - break; - default: - sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); - break; + case GDK_KEY_RELEASE: { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + switch (get_group0_keyval(&event->key)) { + case GDK_Shift_L: + case GDK_Shift_R: + sp_tweak_update_cursor(tc, false); + break; + case GDK_Control_L: + case GDK_Control_R: + sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); + tc->_message_context->clear(); + break; + default: + sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); + break; + } } - } - - default: - break; + default: + break; } if (!ret) { -- cgit v1.2.3 From 43e0e5c6b637e2e18862b5c1649214d8791f73a9 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 1 Apr 2011 15:22:37 +0200 Subject: Filters: labels consistency fix. Translations: inkscape.pot and French translation update. Constributors: authors and translators lists update. (bzr r10140) --- src/extension/internal/filter/experimental.h | 4 ++-- src/ui/dialog/aboutbox.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index efc35b418..8d260f62e 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -88,8 +88,8 @@ public: "\n" "\n" "true\n" - "1000\n" - "1000\n" + "1000\n" + "1000\n" "1\n" "0\n" "1\n" diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 30ed62a4b..d1bc255b0 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -458,6 +458,7 @@ void AboutBox::initStrings() { "Francisco Xosé Vázquez Grandal , 2001.\n" "Frederic Rodrigo , 2004-2005.\n" "Ge'ez Frontier Foundation , 2002.\n" +"George Boukeas , 2011.\n" "Hleb Valoshka <375gnu@gmail.com>, 2008-2009.\n" "Hizkuntza Politikarako Sailburuordetza , 2005.\n" "Ilia Penev , 2006.\n" @@ -514,8 +515,8 @@ void AboutBox::initStrings() { "Serdar Soytetir , 2005.\n" "shivaken , 2004.\n" "Shyam Krishna Bal , 2006.\n" -"Simos Xenitellis , 2001.\n" -"Spyros Blanas , 2006.\n" +"Simos Xenitellis , 2001, 2011.\n" +"Spyros Blanas , 2006, 2011.\n" "Stefan Graubner , 2005.\n" "Supranee Thirawatthanasuk , 2006.\n" "Takeshi Aihana , 2000, 2001.\n" -- cgit v1.2.3 From d6978fcea4a2ccd2d9cccefabc6558a74f332a6d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 2 Apr 2011 00:59:01 +0200 Subject: add curve before LPE to SPShape. this is useful for helperpath display. It was inspired from fixing bug 407008 Fixed bugs: - https://launchpad.net/bugs/407008 (bzr r10142) --- src/sp-ellipse.cpp | 4 ++- src/sp-line.cpp | 3 +++ src/sp-offset.cpp | 2 ++ src/sp-path.cpp | 1 + src/sp-rect.cpp | 5 ++++ src/sp-shape.cpp | 36 ++++++++++++++++++++++++++ src/sp-shape.h | 5 ++++ src/sp-spiral.cpp | 2 ++ src/sp-star.cpp | 2 ++ src/splivarot.cpp | 75 +++++++++++++++++++++++++++++++++++++++--------------- src/splivarot.h | 2 ++ 11 files changed, 115 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 4ebbe6287..cb8c1699b 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -256,9 +256,11 @@ static void sp_genericellipse_set_shape(SPShape *shape) Geom::Affine aff = Geom::Scale(rx, ry) * Geom::Translate(ellipse->cx.computed, ellipse->cy.computed); curve->transform(aff); - /* Reset the shape'scurve to the "original_curve" + /* Reset the shape's curve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ shape->setCurveInsync( curve, TRUE); + shape->setCurveBeforeLPE(curve); + if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) { SPCurve *c_lpe = curve->copy(); bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe); diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 100eefe87..72fe2cfa2 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -221,6 +221,9 @@ void SPLine::setShape(SPShape *shape) c->lineto(line->x2.computed, line->y2.computed); shape->setCurveInsync(c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update + shape->setCurveBeforeLPE(c); + + // LPE's cannot be applied to lines. (the result can (generally) not be represented as SPLine) c->unref(); } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 57c04f31f..3fb9441a3 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -463,6 +463,7 @@ sp_offset_set_shape(SPShape *shape) SPCurve *c = new SPCurve(pv); g_assert(c != NULL); ((SPShape *) offset)->setCurveInsync (c, TRUE); + ((SPShape *) offset)->setCurveBeforeLPE(c); c->unref(); } return; @@ -712,6 +713,7 @@ sp_offset_set_shape(SPShape *shape) SPCurve *c = new SPCurve(pv); g_assert(c != NULL); ((SPShape *) offset)->setCurveInsync (c, TRUE); + ((SPShape *) offset)->setCurveBeforeLPE(c); c->unref(); free (res_d); diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 16e2fcc1b..9a27af2f0 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -425,6 +425,7 @@ g_message("sp_path_update_patheffect"); /* if a path does not have an lpeitem applied, then reset the curve to the original_curve. * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ shape->setCurveInsync(curve, TRUE); + shape->setCurveBeforeLPE(path->original_curve); bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve); if (success && write) { diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index fd44f64df..e8f79e6ed 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -232,6 +232,7 @@ sp_rect_set_shape(SPShape *shape) if ((rect->height.computed < 1e-18) || (rect->width.computed < 1e-18)) { SP_SHAPE(rect)->setCurveInsync( NULL, TRUE); + SP_SHAPE(rect)->setCurveBeforeLPE( NULL ); return; } @@ -282,6 +283,10 @@ sp_rect_set_shape(SPShape *shape) c->closepath(); SP_SHAPE(rect)->setCurveInsync( c, TRUE); + SP_SHAPE(rect)->setCurveBeforeLPE( c ); + + // LPE is not applied because result can generally not be represented as SPRect + c->unref(); } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index e9b0909ed..72559c63f 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -126,6 +126,7 @@ void SPShape::sp_shape_init(SPShape *shape) shape->marker[i] = NULL; } shape->curve = NULL; + shape->curve_before_lpe = NULL; } void SPShape::sp_shape_finalize(GObject *object) @@ -195,6 +196,9 @@ void SPShape::sp_shape_release(SPObject *object) if (shape->curve) { shape->curve = shape->curve->unref(); } + if (shape->curve_before_lpe) { + shape->curve_before_lpe = shape->curve_before_lpe->unref(); + } if (((SPObjectClass *) SPShapeClass::parent_class)->release) { ((SPObjectClass *) SPShapeClass::parent_class)->release (object); @@ -1114,6 +1118,20 @@ void SPShape::setCurve(SPCurve *curve, unsigned int owner) this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +/** + * Sets curve_before_lpe to refer to the curve. + */ +void +SPShape::setCurveBeforeLPE (SPCurve *curve) +{ + if (this->curve_before_lpe) { + this->curve_before_lpe = this->curve_before_lpe->unref(); + } + if (curve) { + this->curve_before_lpe = curve->ref(); + } +} + /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ @@ -1125,6 +1143,24 @@ SPCurve * SPShape::getCurve() return NULL; } +/** + * Return duplicate of curve *before* LPE (if any exists) or NULL if there is no curve + */ +SPCurve * +SPShape::getCurveBeforeLPE() +{ + if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(this))) { + if (this->curve_before_lpe) { + return this->curve_before_lpe->copy(); + } + } else { + if (this->curve) { + return this->curve->copy(); + } + } + return NULL; +} + /** * Same as sp_shape_set_curve but without updating the display */ diff --git a/src/sp-shape.h b/src/sp-shape.h index b29b0c50b..b91850d1f 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -44,11 +44,16 @@ public: static GType getType (void); void setShape (); SPCurve * getCurve (); + SPCurve * getCurveBeforeLPE (); void setCurve (SPCurve *curve, unsigned int owner); void setCurveInsync (SPCurve *curve, unsigned int owner); + void setCurveBeforeLPE (SPCurve *curve); int hasMarkers () const; int numberOfMarkers (int type); +protected: + SPCurve *curve_before_lpe; + private: static void sp_shape_init (SPShape *shape); static void sp_shape_finalize (GObject *object); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index e4bd0fa21..05c6bc9cd 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -427,6 +427,7 @@ sp_spiral_set_shape (SPShape *shape) Geom::PathVector pv = sp_svg_read_pathv(shape->getRepr()->attribute("d")); SPCurve *cold = new SPCurve(pv); shape->setCurveInsync( cold, TRUE); + shape->setCurveBeforeLPE( cold ); cold->unref(); } return; @@ -470,6 +471,7 @@ sp_spiral_set_shape (SPShape *shape) /* Reset the shape'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ shape->setCurveInsync( c, TRUE); + shape->setCurveBeforeLPE( c ); if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) { SPCurve *c_lpe = c->copy(); bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 200217ba2..92d8cd7a5 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -439,6 +439,7 @@ sp_star_set_shape (SPShape *shape) Geom::PathVector pv = sp_svg_read_pathv(shape->getRepr()->attribute("d")); SPCurve *cold = new SPCurve(pv); shape->setCurveInsync( cold, TRUE); + shape->setCurveBeforeLPE(cold); cold->unref(); } return; @@ -509,6 +510,7 @@ sp_star_set_shape (SPShape *shape) /* Reset the shape'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ shape->setCurveInsync( c, TRUE); + shape->setCurveBeforeLPE( c ); if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) { SPCurve *c_lpe = c->copy(); bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 9c2fc8ff9..0e27ce26d 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1804,19 +1804,10 @@ sp_selected_path_simplify_item(SPDesktop *desktop, false); } - - SPCurve *curve = NULL; - - if (SP_IS_SHAPE(item)) { - curve = SP_SHAPE(item)->getCurve(); - if (!curve) - return false; - } - - if (SP_IS_TEXT(item)) { - curve = SP_TEXT(item)->getNormalizedBpath(); - if (!curve) - return false; + // get path to simplify (note that the path *before* LPE calculation is needed) + Path *orig = Path_for_item_before_LPE(item, false); + if (orig == NULL) { + return false; } // correct virtual size by full transform (bug #166937) @@ -1836,14 +1827,6 @@ sp_selected_path_simplify_item(SPDesktop *desktop, gchar *mask = g_strdup(item->getRepr()->attribute("mask")); gchar *clip_path = g_strdup(item->getRepr()->attribute("clip-path")); - Path *orig = Path_for_item(item, false); - if (orig == NULL) { - g_free(style); - curve->unref(); - return false; - } - - curve->unref(); // remember the position of the item gint pos = item->getRepr()->position(); // remember parent @@ -2106,6 +2089,27 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull) return dest; } +/** + * Obtains an item's Path before the LPE stack has been applied. + */ +Path * +Path_for_item_before_LPE(SPItem *item, bool doTransformation, bool transformFull) +{ + SPCurve *curve = curve_for_item_before_LPE(item); + + if (curve == NULL) + return NULL; + + Geom::PathVector *pathv = pathvector_for_curve(item, curve, doTransformation, transformFull, Geom::identity(), Geom::identity()); + curve->unref(); + + Path *dest = new Path; + dest->LoadPathVector(*pathv); + delete pathv; + + return dest; +} + /* * NOTE: Returns empty pathvector if curve == NULL * TODO: see if calling this method can be optimized. All the pathvector copying might be slow. @@ -2132,6 +2136,10 @@ pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool t return dest; } +/** + * Obtains an item's curve. For SPPath, it is the path *before* LPE. For SPShapes other than path, it is the path *after* LPE. + * So the result is somewhat ill-defined, and probably this method should not be used... See curve_for_item_before_LPE. + */ SPCurve* curve_for_item(SPItem *item) { if (!item) @@ -2157,6 +2165,31 @@ SPCurve* curve_for_item(SPItem *item) return curve; // do not forget to unref the curve at some point! } +/** + * Obtains an item's curve *before* LPE. + * The returned SPCurve should be unreffed by the caller. + */ +SPCurve* curve_for_item_before_LPE(SPItem *item) +{ + if (!item) + return NULL; + + SPCurve *curve = NULL; + if (SP_IS_SHAPE(item)) { + curve = SP_SHAPE(item)->getCurveBeforeLPE(); + } + else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) + { + curve = te_get_layout(item)->convertToCurves(); + } + else if (SP_IS_IMAGE(item)) + { + curve = sp_image_get_curve(SP_IMAGE(item)); + } + + return curve; // do not forget to unref the curve at some point! +} + boost::optional get_nearest_position_on_Path(Path *path, Geom::Point p, unsigned seg) { //get nearest position on path diff --git a/src/splivarot.h b/src/splivarot.h index ea8183b67..40089ad71 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -49,8 +49,10 @@ Geom::PathVector* item_outline(SPItem const *item); void sp_selected_path_simplify (SPDesktop *desktop); Path *Path_for_item(SPItem *item, bool doTransformation, bool transformFull = true); +Path *Path_for_item_before_LPE(SPItem *item, bool doTransformation, bool transformFull = true); Geom::PathVector* pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull, Geom::Affine extraPreAffine, Geom::Affine extraPostAffine); SPCurve *curve_for_item(SPItem *item); +SPCurve *curve_for_item_before_LPE(SPItem *item); boost::optional get_nearest_position_on_Path(Path *path, Geom::Point p, unsigned seg = 0); Geom::Point get_point_on_Path(Path *path, int piece, double t); -- cgit v1.2.3 From 434ac15158aec9c65c8d61c936788d8358ed3157 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 2 Apr 2011 01:02:33 +0200 Subject: use shape's curve before LPE as flash path in node tool. so now, you should see a flashing path for all shapes now (bzr r10143) --- src/ui/tool/node-tool.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e75f31370..f83f8c473 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -480,10 +480,11 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) nt->flash_tempitem = NULL; nt->flashed_item = NULL; } - if (!SP_IS_PATH(over_item)) break; // for now, handle only paths + if (!SP_IS_SHAPE(over_item)) break; // for now, handle only shapes nt->flashed_item = over_item; - SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(over_item)); + SPCurve *c = SP_SHAPE(over_item)->getCurveBeforeLPE(); + if (!c) break; // break out when curve doesn't exist c->transform(over_item->i2d_affine()); SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), -- cgit v1.2.3 From 33ab199838791c9b3b7a29a342014ea4716fdd27 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Sat, 2 Apr 2011 17:31:36 +0200 Subject: Faster rounding for Gaussian blur (bzr r10144) --- src/display/nr-filter-gaussian.cpp | 43 ++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 3f7bea35d..9b83c8647 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -78,15 +78,46 @@ template static inline T clip(T const& v, T const& a, T const& b) { } template -static inline Tt round_cast(Ts const& v) { +static inline Tt round_cast(Ts v) { static Ts const rndoffset(.5); return static_cast(v+rndoffset); } +template<> +inline unsigned char round_cast(double v) { + // This (fast) rounding method is based on: + // http://stereopsis.com/sree/fpu2006.html +#if G_BYTE_ORDER==G_LITTLE_ENDIAN + double const dmr = 6755399441055744.0; + v = v + dmr; + return ((unsigned char*)&v)[0]; +#elif G_BYTE_ORDER==G_BIG_ENDIAN + double const dmr = 6755399441055744.0; + v = v + dmr; + return ((unsigned char*)&v)[7]; +#else + static double const rndoffset(.5); + return static_cast(v+rndoffset); +#endif +} + +template +static inline Tt clip_round_cast(Ts const v) { + Ts const minval = std::numeric_limits::min(); + Ts const maxval = std::numeric_limits::max(); + Tt const minval_rounded = std::numeric_limits::min(); + Ts const maxval_rounded = std::numeric_limits::max(); + if ( v < minval ) return minval_rounded; + if ( v > maxval ) return maxval_rounded; + return round_cast(v); +} + template -static inline Tt clip_round_cast(Ts const& v, Tt const minval=std::numeric_limits::min(), Tt const maxval=std::numeric_limits::max()) { - if ( v < minval ) return minval; - if ( v > maxval ) return maxval; +static inline Tt clip_round_cast_varmax(Ts const v, Ts const maxval, Tt const maxval_rounded) { + Ts const minval = std::numeric_limits::min(); + Tt const minval_rounded = std::numeric_limits::min(); + if ( v < minval ) return minval_rounded; + if ( v > maxval ) return maxval_rounded; return round_cast(v); } @@ -320,7 +351,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { dstimg[PC-1] = clip_round_cast(v[0][PC-1]); - for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[PC-1]); + for(unsigned int c=0; c(v[0][c], v[0][PC-1], dstimg[PC-1]); } else { for(unsigned int c=0; c(v[0][c]); } @@ -335,7 +366,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2, dstimg -= dstr1; if ( PREMULTIPLIED_ALPHA ) { dstimg[PC-1] = clip_round_cast(v[0][PC-1]); - for(unsigned int c=0; c(v[0][c], std::numeric_limits::min(), dstimg[PC-1]); + for(unsigned int c=0; c(v[0][c], v[0][PC-1], dstimg[PC-1]); } else { for(unsigned int c=0; c(v[0][c]); } -- cgit v1.2.3 From 47df2f918a30880162874991c71bd9bc6368906c Mon Sep 17 00:00:00 2001 From: Martin Sucha Date: Sun, 3 Apr 2011 00:24:03 +0200 Subject: Fix setting canvas margins when using "Resize page to drawing or selection" (bzr r10145) --- src/document.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 67ce3e26a..c9b822ce6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -632,9 +632,9 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) margin_units = &px; } margin_top = nv->getMarginLength("fit-margin-top",margin_units, &px, w, h, false); - margin_top = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true); - margin_top = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true); - margin_top = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false); + margin_left = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true); + margin_right = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true); + margin_bottom = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false); } } -- cgit v1.2.3 From 88b520a809dea1e5a6ca21bcbad962bc58deb0c3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 8 Apr 2011 04:42:29 +0200 Subject: Fix color-managed view (bzr r9508.1.74) --- src/color-profile-fns.h | 1 + src/color-profile.cpp | 73 ++++++++++++++++--------------- src/display/sp-canvas.cpp | 107 +++++++++------------------------------------- 3 files changed, 60 insertions(+), 121 deletions(-) (limited to 'src') diff --git a/src/color-profile-fns.h b/src/color-profile-fns.h index 3d22417f6..defc58f2c 100644 --- a/src/color-profile-fns.h +++ b/src/color-profile-fns.h @@ -38,6 +38,7 @@ std::vector colorprofile_get_display_names(); std::vector colorprofile_get_softproof_names(); Glib::ustring get_path_for_profile(Glib::ustring const& name); +void colorprofile_load_profiles(bool force_refresh = false); #endif diff --git a/src/color-profile.cpp b/src/color-profile.cpp index f06ebab88..d1897ab19 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -86,6 +86,9 @@ extern guint update_in_progress; g_message( __VA_ARGS__ );\ } +#else +#define DEBUG_MESSAGE_SCISLAC(key, ...) +#define DEBUG_MESSAGE(key, ...) #endif // DEBUG_LCMS static SPObjectClass *cprof_parent_class; @@ -312,9 +315,7 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) cprof->_profileSpace = cmsGetColorSpace( cprof->profHandle ); cprof->_profileClass = cmsGetDeviceClass( cprof->profHandle ); } -#ifdef DEBUG_LCMS DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->profHandle ); -#endif // DEBUG_LCMS g_free(escaped); escaped = 0; g_free(fullname); @@ -339,9 +340,7 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) cprof->name = 0; } cprof->name = g_strdup( value ); -#ifdef DEBUG_LCMS DEBUG_MESSAGE( lcmsTwo, " name set to '%s'", cprof->name ); -#endif // DEBUG_LCMS object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@ -506,9 +505,7 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte *intent = thing ? COLORPROFILE(thing)->rendering_intent : (guint)RENDERING_INTENT_UNKNOWN; } -#ifdef DEBUG_LCMS DEBUG_MESSAGE( lcmsThree, " queried for profile of '%s'. Returning %p with intent of %d", name, prof, (intent? *intent:0) ); -#endif // DEBUG_LCMS return prof; } @@ -517,7 +514,7 @@ cmsHTRANSFORM ColorProfile::getTransfToSRGB8() { if ( !_transf && profHandle ) { int intent = getLcmsIntent(rendering_intent); - _transf = cmsCreateTransform( profHandle, _getInputFormat(_profileSpace), getSRGBProfile(), TYPE_RGBA_8, intent, 0 ); + _transf = cmsCreateTransform( profHandle, _getInputFormat(_profileSpace), getSRGBProfile(), TYPE_BGRA_8, intent, 0 ); } return _transf; } @@ -526,7 +523,7 @@ cmsHTRANSFORM ColorProfile::getTransfFromSRGB8() { if ( !_revTransf && profHandle ) { int intent = getLcmsIntent(rendering_intent); - _revTransf = cmsCreateTransform( getSRGBProfile(), TYPE_RGBA_8, profHandle, _getInputFormat(_profileSpace), intent, 0 ); + _revTransf = cmsCreateTransform( getSRGBProfile(), TYPE_BGRA_8, profHandle, _getInputFormat(_profileSpace), intent, 0 ); } return _revTransf; } @@ -534,7 +531,7 @@ cmsHTRANSFORM ColorProfile::getTransfFromSRGB8() cmsHTRANSFORM ColorProfile::getTransfGamutCheck() { if ( !_gamutTransf ) { - _gamutTransf = cmsCreateProofingTransform(getSRGBProfile(), TYPE_RGBA_8, getNULLProfile(), TYPE_GRAY_8, profHandle, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING)); + _gamutTransf = cmsCreateProofingTransform(getSRGBProfile(), TYPE_BGRA_8, getNULLProfile(), TYPE_GRAY_8, profHandle, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING)); } return _gamutTransf; } @@ -589,6 +586,7 @@ static std::vector knownProfiles; std::vector Inkscape::colorprofile_get_display_names() { + colorprofile_load_profiles(); std::vector result; for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { @@ -602,6 +600,7 @@ std::vector Inkscape::colorprofile_get_display_names() std::vector Inkscape::colorprofile_get_softproof_names() { + colorprofile_load_profiles(); std::vector result; for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { @@ -615,6 +614,7 @@ std::vector Inkscape::colorprofile_get_softproof_names() Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name) { + colorprofile_load_profiles(); Glib::ustring result; for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { @@ -775,7 +775,28 @@ std::list ColorProfile::getProfileFiles() } #if ENABLE_LCMS -static void findThings() { + +int errorHandlerCB(int ErrorCode, const char *ErrorText) +{ + g_message("lcms: Error %d; %s", ErrorCode, ErrorText); + + return 1; +} + +/* This function loads or refreshes data in knownProfiles. + * Call it at the start of every call that requires this data. */ +void Inkscape::colorprofile_load_profiles(bool force_refresh) +{ + static bool error_handler_set = false; + if (!error_handler_set) { + cmsSetErrorHandler(errorHandlerCB); + error_handler_set = true; + } + + static bool profiles_searched = false; + if (profiles_searched && !force_refresh) return; + + knownProfiles.clear(); std::list files = ColorProfile::getProfileFiles(); for ( std::list::const_iterator it = files.begin(); it != files.end(); ++it ) { @@ -797,13 +818,7 @@ static void findThings() { } } } -} - -int errorHandlerCB(int ErrorCode, const char *ErrorText) -{ - g_message("lcms: Error %d; %s", ErrorCode, ErrorText); - - return 1; + profiles_searched = true; } static bool gamutWarn = false; @@ -821,13 +836,7 @@ cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle() static cmsHPROFILE theOne = 0; static Glib::ustring lastURI; - static bool init = false; - if ( !init ) { - cmsSetErrorHandler(errorHandlerCB); - - findThings(); - init = true; - } + colorprofile_load_profiles(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring uri = prefs->getString("/options/displayprofile/uri"); @@ -880,13 +889,7 @@ cmsHPROFILE Inkscape::colorprofile_get_proof_profile_handle() static cmsHPROFILE theOne = 0; static Glib::ustring lastURI; - static bool init = false; - if ( !init ) { - cmsSetErrorHandler(errorHandlerCB); - - findThings(); - init = true; - } + colorprofile_load_profiles(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool which = prefs->getBool( "/options/softproof/enable"); @@ -1003,9 +1006,9 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_transform() dwFlags |= cmsFLAGS_PRESERVEBLACK; } #endif // defined(cmsFLAGS_PRESERVEBLACK) - transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, hprof, TYPE_RGBA_8, proofProf, intent, proofIntent, dwFlags ); + transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags ); } else if ( hprof ) { - transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, hprof, TYPE_RGBA_8, intent, 0 ); + transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, hprof, TYPE_BGRA_8, intent, 0 ); } } @@ -1163,9 +1166,9 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_per( Glib::ustring const& id ) dwFlags |= cmsFLAGS_PRESERVEBLACK; } #endif // defined(cmsFLAGS_PRESERVEBLACK) - item.transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, item.hprof, TYPE_RGBA_8, proofProf, intent, proofIntent, dwFlags ); + item.transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags ); } else if ( item.hprof ) { - item.transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, item.hprof, TYPE_RGBA_8, intent, 0 ); + item.transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, intent, 0 ); } } diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 43f33b74e..a67a0fed8 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +# include #endif #include @@ -1651,6 +1651,8 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, //buf.ct = gdk_cairo_create(widget->window); // create temporary surface + int w = x1 - x0; + int h = y1 - y0; cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0); buf.ct = cairo_create(imgs); //cairo_translate(buf.ct, -x0, -y0); @@ -1673,97 +1675,30 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf); } -#if 0 -#if ENABLE_LCMS - cmsHTRANSFORM transf = 0; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); - if ( fromDisplay ) { - transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" ); - } else { - transf = Inkscape::colorprofile_get_display_transform(); - } -#endif // ENABLE_LCMS + // output to X + cairo_destroy(buf.ct); - if (buf.is_empty) { #if ENABLE_LCMS - if ( transf && canvas->enable_cms_display_adj ) { - cmsDoTransform( transf, &buf.bg_color, &buf.bg_color, 1 ); + if (canvas->enable_cms_display_adj) { + cmsHTRANSFORM transf = 0; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); + if ( fromDisplay ) { + transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" ); + } else { + transf = Inkscape::colorprofile_get_display_transform(); } -#endif // ENABLE_LCMS - gdk_rgb_gc_set_foreground (canvas->pixmap_gc, buf.bg_color); - gdk_draw_rectangle (SP_CANVAS_WINDOW (canvas), - canvas->pixmap_gc, - TRUE, - x0 - canvas->x0, y0 - canvas->y0, - x1 - x0, y1 - y0); - } else { - -#if ENABLE_LCMS - if ( transf && canvas->enable_cms_display_adj ) { - for ( gint yy = 0; yy < (y1 - y0); yy++ ) { - guchar* p = buf.buf + (buf.buf_rowstride * yy); - cmsDoTransform( transf, p, p, (x1 - x0) ); + + if (transf) { + unsigned char *px = cairo_image_surface_get_data(imgs); + int stride = cairo_image_surface_get_stride(imgs); + for (int i=0; ix0, y0 - canvas->y0); - cairo_paint (window_ct); - cairo_destroy (window_ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); - -#else - - NRPixBlock b3; - nr_pixblock_setup_fast (&b3, NR_PIXBLOCK_MODE_R8G8B8, x0, y0, x1, y1, TRUE); - - NRPixBlock b4; - nr_pixblock_setup_extern (&b4, NR_PIXBLOCK_MODE_R8G8B8A8P, x0, y0, x1, y1, - buf.buf, - buf.buf_rowstride, - FALSE, FALSE); - - // this does the 32->24 squishing, using an assembler routine: - nr_blit_pixblock_pixblock (&b3, &b4); - - gdk_draw_rgb_image_dithalign (SP_CANVAS_WINDOW (canvas), - canvas->pixmap_gc, - x0 - canvas->x0, y0 - canvas->y0, - x1 - x0, y1 - y0, - GDK_RGB_DITHER_MAX, - NR_PIXBLOCK_PX(&b3), - sw * 3, - x0 - canvas->x0, y0 - canvas->y0); - - nr_pixblock_release (&b3); - nr_pixblock_release (&b4); -#endif } -#endif - - - // output to X - cairo_destroy(buf.ct); +#endif // ENABLE_LCMS cairo_t *xct = gdk_cairo_create(widget->window); cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0); -- cgit v1.2.3 From 4f42f4c32b6d26e7af28c46901ff5fef8b6280b7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 8 Apr 2011 22:25:52 +0200 Subject: Add missing flush() / mark_dirty() calls around CMS transform (bzr r9508.1.75) --- src/display/sp-canvas.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index a67a0fed8..105a9a0ff 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1690,12 +1690,14 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } if (transf) { + cairo_surface_flush(imgs); unsigned char *px = cairo_image_surface_get_data(imgs); int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i Date: Fri, 8 Apr 2011 23:18:50 +0200 Subject: remember status of relative checkbox for guideline dialog Fixed bugs: - https://launchpad.net/bugs/484187 (bzr r10147) --- src/ui/dialog/guides.cpp | 6 +++++- src/ui/dialog/guides.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index bd9777048..e7d8b3a7b 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -52,6 +52,8 @@ GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop * { } +bool GuidelinePropertiesDialog::_relative_toggle_status = false; // initialize relative checkbox status for when this dialog is opened for first time + GuidelinePropertiesDialog::~GuidelinePropertiesDialog() { } @@ -64,6 +66,7 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); + _relative_toggle_status = _relative_toggle.get_active(); if (!_mode) { // relative _spin_angle.set_value(0); @@ -149,7 +152,7 @@ void GuidelinePropertiesDialog::_response(gint response) } void GuidelinePropertiesDialog::_setup() { - set_title(_("Guideline")); + set_title(_("Guidelinea")); add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); add_button(Gtk::Stock::DELETE, -12); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); @@ -179,6 +182,7 @@ void GuidelinePropertiesDialog::_setup() { _layout_table.attach(_relative_toggle, 1, 3, 9, 10, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); + _relative_toggle.set_active(_relative_toggle_status); // unitmenu /* fixme: We should allow percents here too, as percents of the canvas size */ diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 2817e2644..5c74d3618 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -60,6 +60,7 @@ private: Gtk::Label _label_Y; Gtk::Label _label_degrees; Inkscape::UI::Widget::CheckButton _relative_toggle; + static bool _relative_toggle_status; // remember the status of the _relative_toggle_status button across instances Gtk::Adjustment _adjustment_x; Gtk::SpinButton _spin_button_x; Gtk::Adjustment _adjustment_y; -- cgit v1.2.3 From c4a45aa8008c2bfe48a794bbcc4200ad07b12cc9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 8 Apr 2011 23:29:23 +0200 Subject: automatically apply and close guideline dialog when pressing enter in X, Y and angle entry boxes Fixed bugs: - https://launchpad.net/bugs/484187 (bzr r10148) --- src/ui/dialog/guides.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index e7d8b3a7b..1ac1e5d82 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -205,9 +205,6 @@ void GuidelinePropertiesDialog::_setup() { 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_y, 2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.gobj()), "activate", - GTK_SIGNAL_FUNC(gtk_window_activate_default), - gobj()); _layout_table.attach(_label_units, 1, 2, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); @@ -223,6 +220,14 @@ void GuidelinePropertiesDialog::_setup() { _layout_table.attach(_spin_angle, 2, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + // don't know what this exactly does, but it results in that the dialog closes when entering a value and pressing enter (see LP bug 484187) + gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.gobj()), "activate", + GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); + gtk_signal_connect_object(GTK_OBJECT(_spin_button_y.gobj()), "activate", + GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); + gtk_signal_connect_object(GTK_OBJECT(_spin_angle.gobj()), "activate", + GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); + // dialog set_default_response(Gtk::RESPONSE_OK); -- cgit v1.2.3 From 327420ccbf4d61fb3fc5231aa13689f866090ad0 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 8 Apr 2011 23:40:32 +0200 Subject: 2geom has "multiplatform" sincos function (bzr r9508.1.76) --- src/display/nr-filter-colormatrix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 5f308da6a..7eb2fa2e9 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -16,6 +16,7 @@ #include "display/cairo-utils.h" #include "display/nr-filter-colormatrix.h" #include "display/nr-filter-slot.h" +#include <2geom/math-utils.h> namespace Inkscape { namespace Filters { @@ -104,7 +105,7 @@ private: struct ColorMatrixHueRotate { ColorMatrixHueRotate(double v) { double sinhue, coshue; - sincos(v * M_PI/180.0, &sinhue, &coshue); + Geom::sincos(v * M_PI/180.0, sinhue, coshue); _v[0] = round((0.213 +0.787*coshue -0.213*sinhue)*255); _v[1] = round((0.715 -0.715*coshue -0.715*sinhue)*255); -- cgit v1.2.3 From 41774c74bfeb253bbf93addb4be9cee6f8c2c2a0 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 8 Apr 2011 23:41:43 +0200 Subject: nr-filter-skeleton is compiled on windows (good to keep it up-to-date I think!), fixes part of Windows build (bzr r9508.1.77) --- src/display/nr-filter-skeleton.cpp | 17 +++++++++-------- src/display/nr-filter-skeleton.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp index 4924b8807..0c455a818 100644 --- a/src/display/nr-filter-skeleton.cpp +++ b/src/display/nr-filter-skeleton.cpp @@ -22,6 +22,7 @@ */ #include "display/nr-filter-skeleton.h" +#include "display/cairo-utils.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" @@ -38,17 +39,17 @@ FilterPrimitive * FilterSkeleton::create() { FilterSkeleton::~FilterSkeleton() {} -int FilterSkeleton::render(FilterSlot &slot, - FilterUnits const &/*units*/) { - //NRPixBlock *in = slot.get(_input); - NRPixBlock *out = new NRPixBlock(); +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); - /* Insert rendering code here */ +// cairo_set_source_surface(ct, in, offset[X], offset[Y]); +// cairo_paint(ct); +// cairo_destroy(ct); - out->empty = FALSE; slot.set(_output, out); - - return 0; + cairo_surface_destroy(out); } } /* namespace Filters */ diff --git a/src/display/nr-filter-skeleton.h b/src/display/nr-filter-skeleton.h index a03004be1..049c0df80 100644 --- a/src/display/nr-filter-skeleton.h +++ b/src/display/nr-filter-skeleton.h @@ -37,7 +37,7 @@ public: static FilterPrimitive *create(); virtual ~FilterSkeleton(); - virtual int render(FilterSlot &slot, FilterUnits const &units); + virtual void render_cairo(FilterSlot &slot); private: -- cgit v1.2.3 From f4242fed222ef0e27215db5e7a9edb1d7600d3d6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 8 Apr 2011 23:43:15 +0200 Subject: work around an assert, to fix a crash at startup on windows (bzr r9508.1.78) --- src/libnrtype/FontInstance.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 085cc6c88..7dc8bb859 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -557,7 +557,9 @@ void font_instance::LoadGlyph(int glyph_id) break; case TT_PRIM_QSPLINE: - g_assert(polyCurve->cpfx % 2 == 0); + //g_assert(polyCurve->cpfx % 2 == 0); + if (polyCurve->cpfx % 2 != 0) return; + while ( p != endp ) { path_builder.quadTo(pointfx_to_nrpoint(p[0], scale), pointfx_to_nrpoint(p[1], scale)); -- cgit v1.2.3 From 7e1f9b0ff682eb03394692fbe7b38a2838fbd29a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 9 Apr 2011 00:16:53 +0200 Subject: allow other than numeric characters in guideline dialog Fixed bugs: - https://launchpad.net/bugs/484187 (bzr r10149) --- src/ui/dialog/guides.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 1ac1e5d82..b0b4705b1 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -194,9 +194,9 @@ void GuidelinePropertiesDialog::_setup() { sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj())); sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj())); _spin_button_x.configure(_adjustment_x, 1.0 , 3); - _spin_button_x.set_numeric(); + // _spin_button_x.set_numeric(); // not setting numeric enables writing '.' instead of ',' for decimal _spin_button_y.configure(_adjustment_y, 1.0 , 3); - _spin_button_y.set_numeric(); + //_spin_button_y.set_numeric(); // not setting numeric enables writing '.' instead of ',' for decimal _layout_table.attach(_label_X, 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_x, @@ -213,7 +213,7 @@ void GuidelinePropertiesDialog::_setup() { // angle spinbutton _spin_angle.configure(_adj_angle, 5.0 , 3); - _spin_angle.set_numeric(); + //_spin_angle.set_numeric(); // not setting numeric enables writing '.' instead of ',' for decimal _spin_angle.show(); _layout_table.attach(_label_degrees, 1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); -- cgit v1.2.3 From cba60dd473848d5e980894dd4a48fdeb9890a8ac Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 9 Apr 2011 01:19:48 +0200 Subject: add a subclassed spinbutton class. this numeric entry box accepts both ',' and '.' as the decimal point when in numeric mode. (bzr r10150) --- src/ui/dialog/guides.cpp | 6 ++--- src/ui/dialog/guides.h | 7 ++--- src/ui/widget/Makefile_insert | 2 ++ src/ui/widget/spinbutton.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++ src/ui/widget/spinbutton.h | 57 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 src/ui/widget/spinbutton.cpp create mode 100644 src/ui/widget/spinbutton.h (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index b0b4705b1..1ac1e5d82 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -194,9 +194,9 @@ void GuidelinePropertiesDialog::_setup() { sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj())); sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj())); _spin_button_x.configure(_adjustment_x, 1.0 , 3); - // _spin_button_x.set_numeric(); // not setting numeric enables writing '.' instead of ',' for decimal + _spin_button_x.set_numeric(); _spin_button_y.configure(_adjustment_y, 1.0 , 3); - //_spin_button_y.set_numeric(); // not setting numeric enables writing '.' instead of ',' for decimal + _spin_button_y.set_numeric(); _layout_table.attach(_label_X, 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_x, @@ -213,7 +213,7 @@ void GuidelinePropertiesDialog::_setup() { // angle spinbutton _spin_angle.configure(_adj_angle, 5.0 , 3); - //_spin_angle.set_numeric(); // not setting numeric enables writing '.' instead of ',' for decimal + _spin_angle.set_numeric(); _spin_angle.show(); _layout_table.attach(_label_degrees, 1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 5c74d3618..8485c78a7 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -21,6 +21,7 @@ #include #include #include "ui/widget/button.h" +#include "ui/widget/spinbutton.h" #include <2geom/point.h> namespace Inkscape { @@ -62,12 +63,12 @@ private: Inkscape::UI::Widget::CheckButton _relative_toggle; static bool _relative_toggle_status; // remember the status of the _relative_toggle_status button across instances Gtk::Adjustment _adjustment_x; - Gtk::SpinButton _spin_button_x; + Inkscape::UI::Widget::SpinButton _spin_button_x; Gtk::Adjustment _adjustment_y; - Gtk::SpinButton _spin_button_y; + Inkscape::UI::Widget::SpinButton _spin_button_y; Gtk::Adjustment _adj_angle; - Gtk::SpinButton _spin_angle; + Inkscape::UI::Widget::SpinButton _spin_angle; Gtk::Widget *_unit_selector; bool _mode; diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index b6069631b..bd23b6782 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -66,6 +66,8 @@ ink_common_sources += \ ui/widget/scalar.h \ ui/widget/selected-style.h \ ui/widget/selected-style.cpp \ + ui/widget/spinbutton.h \ + ui/widget/spinbutton.cpp \ ui/widget/spin-slider.h \ ui/widget/spin-slider.cpp \ ui/widget/style-subject.h \ diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp new file mode 100644 index 000000000..55c2d877f --- /dev/null +++ b/src/ui/widget/spinbutton.cpp @@ -0,0 +1,60 @@ +/** + * \brief SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + */ +/* + * Author: + * Johan B. C. Engelen + * + * Copyright (C) 2011 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "spinbutton.h" + +#include + +namespace Inkscape { +namespace UI { +namespace Widget { + +void +SpinButton::on_insert_text(const Glib::ustring& text, int* position) +{ + Glib::ustring newtext = text; + + // if in numeric mode: replace '.' or ',' with the locale's decimal point + if (get_numeric()) { + size_t found = newtext.find('.'); + if (found != Glib::ustring::npos) { + newtext.replace(found, 1, localeconv()->decimal_point); + } else { + found = newtext.find(','); + if (found != Glib::ustring::npos) { + newtext.replace(found, 1, localeconv()->decimal_point); + } + } + } + + // call parent function with replaced text: + Gtk::SpinButton::on_insert_text(newtext, position); +} + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h new file mode 100644 index 000000000..d9b382b08 --- /dev/null +++ b/src/ui/widget/spinbutton.h @@ -0,0 +1,57 @@ +/** + * \brief SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + */ +/* + * Author: + * Johan B. C. Engelen + * + * Copyright (C) 2011 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_SPINBUTTON_H +#define INKSCAPE_UI_WIDGET_SPINBUTTON_H + +#include + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + */ +class SpinButton : public Gtk::SpinButton +{ +public: + SpinButton() : Gtk::SpinButton() {}; + /// @todo perhaps more constructors should be added here + + virtual ~SpinButton() {}; + +protected: + virtual void on_insert_text(const Glib::ustring& text, int* position); + +private: + // noncopyable + SpinButton(const SpinButton&); + SpinButton& operator=(const SpinButton&); +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_SPINBUTTON_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 47bf1147322ba30a1e13aa9bdbe0cf0fe36dc29d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 9 Apr 2011 03:44:07 +0200 Subject: Slightly improve EXTRACT_ARGB32 macro (bzr r9508.1.79) --- src/display/cairo-utils.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index d5c84810c..1ad3c0b46 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -126,10 +126,10 @@ void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); #define EXTRACT_ARGB32(px,a,r,g,b) \ guint32 a, r, g, b; \ - a = (px & 0xff000000) >> 24; \ - r = (px & 0x00ff0000) >> 16; \ - g = (px & 0x0000ff00) >> 8; \ - b = (px & 0x000000ff); + a = ((px) & 0xff000000) >> 24; \ + r = ((px) & 0x00ff0000) >> 16; \ + g = ((px) & 0x0000ff00) >> 8; \ + b = ((px) & 0x000000ff); #define ASSEMBLE_ARGB32(px,a,r,g,b) \ guint32 px = (a << 24) | (r << 16) | (g << 8) | b; -- cgit v1.2.3 From 3e80b896214d68d84a475b0c780f6770ad6ae397 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 9 Apr 2011 03:46:06 +0200 Subject: Initialize cached patterns to NULL in NRStyle, should fix crashes (bzr r9508.1.80) --- src/display/nr-arena-shape.cpp | 3 ++- src/display/nr-style.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 227b49526..9055045f4 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -535,8 +535,9 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) { g_return_if_fail(shape != NULL); g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); + g_return_if_fail(style != NULL); - if (style) sp_style_ref(style); + sp_style_ref(style); if (shape->style) sp_style_unref(shape->style); shape->style = style; diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 40366f5d3..72fa0c444 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -51,6 +51,8 @@ NRStyle::NRStyle() , fill_rule(CAIRO_FILL_RULE_EVEN_ODD) , line_cap(CAIRO_LINE_CAP_BUTT) , line_join(CAIRO_LINE_JOIN_MITER) + , fill_pattern(NULL) + , stroke_pattern(NULL) {} NRStyle::~NRStyle() @@ -198,8 +200,8 @@ void NRStyle::applyStroke(cairo_t *ct) void NRStyle::update() { // force pattern update - cairo_pattern_destroy(fill_pattern); - cairo_pattern_destroy(stroke_pattern); + if (fill_pattern) cairo_pattern_destroy(fill_pattern); + if (stroke_pattern) cairo_pattern_destroy(stroke_pattern); fill_pattern = NULL; stroke_pattern = NULL; } -- cgit v1.2.3 From 05ec291fd2cd12474c33ee65f3fec03f18322527 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 10 Apr 2011 03:49:27 +0200 Subject: Fix a rounding error that resulted in seams at some zoom levels when rendering filters that use BackgroundImage. (bzr r9508.1.81) --- src/display/nr-filter-diffuselighting.cpp | 5 ++-- src/display/nr-filter-gaussian.cpp | 6 ++--- src/display/nr-filter-image.cpp | 12 +++++----- src/display/nr-filter-slot.cpp | 37 +++++++++++++++++++----------- src/display/nr-filter-slot.h | 6 +++-- src/display/nr-filter-specularlighting.cpp | 5 ++-- src/display/nr-filter-turbulence.cpp | 6 +++-- 7 files changed, 47 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index e2954c3b1..0a46a5c86 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -128,9 +128,10 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); - NRRectL const &slot_area = slot.get_slot_area(); + Geom::Rect slot_area = slot.get_slot_area(); + Geom::Point p = slot_area.min(); Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); - double x0 = slot_area.x0, y0 = slot_area.y0; + double x0 = p[Geom::X], y0 = p[Geom::Y]; double scale = surfaceScale * trans.descrim(); switch (light_type) { diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index fdffabfeb..326c37160 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -82,7 +82,7 @@ static inline Tt round_cast(Ts v) { static Ts const rndoffset(.5); return static_cast(v+rndoffset); } - +/* template<> inline unsigned char round_cast(double v) { // This (fast) rounding method is based on: @@ -99,7 +99,7 @@ inline unsigned char round_cast(double v) { static double const rndoffset(.5); return static_cast(v+rndoffset); #endif -} +}*/ template static inline Tt clip_round_cast(Ts const v) { @@ -142,7 +142,7 @@ FilterGaussian::~FilterGaussian() static int _effect_area_scr(double const deviation) { - return (int)std::ceil(deviation * 3.0); + return (int)std::ceil(std::fabs(deviation) * 3.0); } static void diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index eea4f9781..0cb7901b3 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -91,11 +91,11 @@ void FilterImage::render_cairo(FilterSlot &slot) double scaleX = feImageWidth / area.width(); double scaleY = feImageHeight / area.height(); - NRRectL const &sa = slot.get_slot_area(); + Geom::Rect sa = slot.get_slot_area(); cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - sa.x1 - sa.x0, sa.y1 - sa.y0); + sa.width(), sa.height()); cairo_t *ct = cairo_create(out); - cairo_translate(ct, -sa.x0, -sa.y0); + cairo_translate(ct, -sa.min()[Geom::X], -sa.min()[Geom::Y]); ink_cairo_transform(ct, pu2pb); // we are now in primitive units cairo_translate(ct, feImageX, feImageY); cairo_scale(ct, scaleX, scaleY); @@ -179,12 +179,12 @@ void FilterImage::render_cairo(FilterSlot &slot) CAIRO_FORMAT_ARGB32, image->get_width(), image->get_height(), image->get_rowstride()); } - NRRectL const &sa = slot.get_slot_area(); + Geom::Rect sa = slot.get_slot_area(); cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - sa.x1 - sa.x0, sa.y1 - sa.y0); + sa.width(), sa.height()); cairo_t *ct = cairo_create(out); - cairo_translate(ct, -sa.x0, -sa.y0); + cairo_translate(ct, -sa.min()[Geom::X], -sa.min()[Geom::Y]); // now ct is in pb coordinates ink_cairo_transform(ct, slot.get_units().get_matrix_primitiveunits2pb()); // now ct is in the coordinates of feImageX etc. diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 63f9dc1a6..ce07ff086 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -46,14 +46,18 @@ FilterSlot::FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, Geom::Point(_source_graphic_area->x1, _source_graphic_area->y1)); Geom::Affine trans = _units.get_matrix_display2pb(); - Geom::Rect bbox_trans = bbox * trans; Geom::Point min = bbox_trans.min(); - Geom::Point max = bbox_trans.max(); - _slot_area.x0 = floor(min[X]); - _slot_area.y0 = floor(min[Y]); - _slot_area.x1 = ceil(max[X]); - _slot_area.y1 = ceil(max[Y]); + _slot_x = min[X]; + _slot_y = min[Y]; + + if (trans.isTranslation()) { + _slot_w = _source_graphic_area->x1 - _source_graphic_area->x0; + _slot_h = _source_graphic_area->y1 - _source_graphic_area->y0; + } else { + _slot_w = ceil(bbox_trans.width()); + _slot_h = ceil(bbox_trans.height()); + } } FilterSlot::~FilterSlot() @@ -115,7 +119,7 @@ cairo_surface_t *FilterSlot::getcairo(int slot_nr) // create empty surface cairo_surface_t *empty = cairo_surface_create_similar( _source_graphic, cairo_surface_get_content(_source_graphic), - _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); + _slot_w, _slot_h); _set_internal(slot_nr, empty); cairo_surface_destroy(empty); s = _slots.find(slot_nr); @@ -127,17 +131,17 @@ cairo_surface_t *FilterSlot::_get_transformed_source_graphic() { Geom::Affine trans = _units.get_matrix_display2pb(); - if (trans.isIdentity()) { + if (trans.isTranslation()) { cairo_surface_reference(_source_graphic); return _source_graphic; } cairo_surface_t *tsg = cairo_surface_create_similar( _source_graphic, cairo_surface_get_content(_source_graphic), - _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); + _slot_w, _slot_h); cairo_t *tsg_ct = cairo_create(tsg); - cairo_translate(tsg_ct, -_slot_area.x0, -_slot_area.y0); + cairo_translate(tsg_ct, -_slot_x, -_slot_y); ink_cairo_transform(tsg_ct, trans); cairo_translate(tsg_ct, _source_graphic_area->x0, _source_graphic_area->y0); cairo_set_source_surface(tsg_ct, _source_graphic, 0, 0); @@ -155,10 +159,10 @@ cairo_surface_t *FilterSlot::_get_transformed_background() cairo_surface_t *bg = cairo_get_target(_background_ct); cairo_surface_t *tbg = cairo_surface_create_similar( bg, cairo_surface_get_content(bg), - _slot_area.x1 - _slot_area.x0, _slot_area.y1 - _slot_area.y0); + _slot_w, _slot_h); cairo_t *tbg_ct = cairo_create(tbg); - cairo_translate(tbg_ct, -_slot_area.x0, -_slot_area.y0); + cairo_translate(tbg_ct, -_slot_x, -_slot_y); ink_cairo_transform(tbg_ct, trans); cairo_translate(tbg_ct, _background_area->x0, _background_area->y0); cairo_set_source_surface(tbg_ct, bg, 0, 0); @@ -186,7 +190,7 @@ cairo_surface_t *FilterSlot::get_result(int res) cairo_translate(r_ct, -_source_graphic_area->x0, -_source_graphic_area->y0); ink_cairo_transform(r_ct, trans); - cairo_translate(r_ct, _slot_area.x0, _slot_area.y0); + cairo_translate(r_ct, _slot_x, _slot_y); cairo_set_source_surface(r_ct, getcairo(res), 0, 0); cairo_set_operator(r_ct, CAIRO_OPERATOR_SOURCE); cairo_paint(r_ct); @@ -237,6 +241,13 @@ int FilterSlot::get_blurquality(void) { return blurquality; } +Geom::Rect FilterSlot::get_slot_area() const { + Geom::Point p(_slot_x, _slot_y); + Geom::Point dim(_slot_w, _slot_h); + Geom::Rect r(p, p+dim); + return r; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index f477b7b73..3b08743ed 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -65,7 +65,7 @@ public: int get_blurquality(void); FilterUnits const &get_units() const { return _units; } - NRRectL const &get_slot_area() const { return _slot_area; } + Geom::Rect get_slot_area() const; NRRectL const &get_sg_area() const { return *_source_graphic_area; } private: @@ -76,7 +76,9 @@ private: //Geom::Rect _source_bbox; ///< bounding box of source graphic surface //Geom::Rect _intermediate_bbox; ///< bounding box of intermediate surfaces - NRRectL _slot_area; +// NRRectL _slot_area; + int _slot_w, _slot_h; + double _slot_x, _slot_y; cairo_surface_t *_source_graphic; cairo_t *_background_ct; NRRectL const *_source_graphic_area; diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index e9e3f2b28..eddab36a1 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -140,9 +140,10 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); - NRRectL const &slot_area = slot.get_slot_area(); Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); - double x0 = slot_area.x0, y0 = slot_area.y0; + Geom::Point p = slot.get_slot_area().min(); + double x0 = p[Geom::X]; + double y0 = p[Geom::Y]; double scale = surfaceScale * trans.descrim(); double ks = specularConstant; double se = specularExponent; diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index c1a3abd45..6aa435715 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -376,9 +376,11 @@ void FilterTurbulence::render_cairo(FilterSlot &slot) } Geom::Affine unit_trans = slot.get_units().get_matrix_primitiveunits2pb().inverse(); - NRRectL const &slot_area = slot.get_slot_area(); + Geom::Rect slot_area = slot.get_slot_area(); + double x0 = slot_area.min()[Geom::X]; + double y0 = slot_area.min()[Geom::Y]; - ink_cairo_surface_synthesize(out, Turbulence(*gen, unit_trans, slot_area.x0, slot_area.y0)); + ink_cairo_surface_synthesize(out, Turbulence(*gen, unit_trans, x0, y0)); cairo_surface_mark_dirty(out); -- cgit v1.2.3 From 47086e74dc63803678f9f67b5b38d3fcc2a31fca Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 10 Apr 2011 22:53:12 +0200 Subject: go wild adding % at the end of each latex line (pdf+latex output) Fixed bugs: - https://launchpad.net/bugs/643849 - https://launchpad.net/bugs/687344 (bzr r10154) --- src/extension/internal/latex-text-renderer.cpp | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 1f9bdfef1..a443a905a 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -196,22 +196,22 @@ static char const preamble[] = "%% \n" "%% For more information, please see info/svg-inkscape on CTAN:\n" "%% http://tug.ctan.org/tex-archive/info/svg-inkscape\n" -"\n" -"\\begingroup\n" -" \\makeatletter\n" +"%%\n" +"\\begingroup%\n" +" \\makeatletter%\n" " \\providecommand\\color[2][]{%\n" -" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}\n" +" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}%\n" " \\renewcommand\\color[2][]{}%\n" -" }\n" +" }%\n" " \\providecommand\\transparent[1]{%\n" -" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}\n" +" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}%\n" " \\renewcommand\\transparent[1]{}%\n" -" }\n" -" \\providecommand\\rotatebox[2]{#2}\n"; +" }%\n" +" \\providecommand\\rotatebox[2]{#2}%\n"; static char const postamble[] = " \\end{picture}%\n" -"\\endgroup\n"; +"\\endgroup%\n"; void LaTeXTextRenderer::writePreamble() @@ -598,19 +598,19 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * // scaling of the image when including it in LaTeX - os << " \\ifx\\svgwidth\\undefined\n"; - os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "pt}\n"; - os << " \\ifx\\svgscale\\undefined\n"; - os << " \\relax\n"; - os << " \\else\n"; - os << " \\setlength{\\unitlength}{\\unitlength * \\real{\\svgscale}}\n"; - os << " \\fi\n"; - os << " \\else\n"; - os << " \\setlength{\\unitlength}{\\svgwidth}\n"; - os << " \\fi\n"; - os << " \\global\\let\\svgwidth\\undefined\n"; - os << " \\global\\let\\svgscale\\undefined\n"; - os << " \\makeatother\n"; + os << " \\ifx\\svgwidth\\undefined%\n"; + os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "pt}%\n"; + os << " \\ifx\\svgscale\\undefined%\n"; + os << " \\relax%\n"; + os << " \\else%\n"; + os << " \\setlength{\\unitlength}{\\unitlength * \\real{\\svgscale}}%\n"; + os << " \\fi%\n"; + os << " \\else%\n"; + os << " \\setlength{\\unitlength}{\\svgwidth}%\n"; + os << " \\fi%\n"; + os << " \\global\\let\\svgwidth\\undefined%\n"; + os << " \\global\\let\\svgscale\\undefined%\n"; + os << " \\makeatother%\n"; os << " \\begin{picture}(" << _width << "," << _height << ")%\n"; // strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient. -- cgit v1.2.3 From 28ad8dcc8291ea4fecf59fd27c6d67e2778c540a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 10 Apr 2011 23:23:11 +0200 Subject: pdf+latex: fix newline bug due to changes in r10089 (bzr r10155) --- src/extension/internal/latex-text-renderer.cpp | 45 +++++++++++++++++--------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index a443a905a..417dbb9ff 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -266,10 +266,15 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) SPText *textobj = SP_TEXT (item); SPStyle *style = item->style; - gchar *str = sp_te_get_string_multiline(item); - if (!str) { + gchar *strtext = sp_te_get_string_multiline(item); + if (!strtext) { return; } + // replace carriage return with double slash + gchar ** splitstr = g_strsplit(strtext, "\n", -1); + gchar *str = g_strjoinv("\\\\ ", splitstr); + g_free(strtext); + g_strfreev(splitstr); // get position and alignment // Align vertically on the baseline of the font (retreived from the anchor point) @@ -361,8 +366,17 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) Inkscape::Text::Layout::iterator ln = li; ln.nextStartOfSpan(); - Glib::ustring spanstr = sp_te_get_string_multiline (item, li, ln); - os << spanstr; + Glib::ustring uspanstr = sp_te_get_string_multiline (item, li, ln); + const gchar *spanstr = uspanstr.c_str(); + if (!spanstr) { + continue; + } + // replace carriage return with double slash + gchar ** splitstr = g_strsplit(spanstr, "\n", -1); + gchar *spanstr_new = g_strjoinv("\\\\ ", splitstr); + os << spanstr_new; + g_strfreev(splitstr); + g_free(spanstr_new); if (is_italic) { os << "}"; } // italic end if (is_bold) { os << "}"; } // bold end @@ -389,16 +403,6 @@ Flowing in rectangle is possible, not in arb shape. SPFlowtext *flowtext = SP_FLOWTEXT(item); SPStyle *style = item->style; - gchar *strtext = sp_te_get_string_multiline(item); - if (!strtext) { - return; - } - // replace carriage return with double slash - gchar ** splitstr = g_strsplit(strtext, "\n", -1); - gchar *str = g_strjoinv("\\\\ ", splitstr); - g_free(strtext); - g_strfreev(splitstr); - SPItem *frame_item = flowtext->get_frame(NULL); if (!frame_item || !SP_IS_RECT(frame_item)) { g_warning("LaTeX export: non-rectangular flowed text shapes are not supported, skipping text."); @@ -500,8 +504,17 @@ Flowing in rectangle is possible, not in arb shape. Inkscape::Text::Layout::iterator ln = li; ln.nextStartOfSpan(); - Glib::ustring spanstr = sp_te_get_string_multiline (item, li, ln); - os << spanstr; + Glib::ustring uspanstr = sp_te_get_string_multiline (item, li, ln); + const gchar *spanstr = uspanstr.c_str(); + if (!spanstr) { + continue; + } + // replace carriage return with double slash + gchar ** splitstr = g_strsplit(spanstr, "\n", -1); + gchar *spanstr_new = g_strjoinv("\\\\ ", splitstr); + os << spanstr_new; + g_strfreev(splitstr); + g_free(spanstr_new); if (is_italic) { os << "}"; } // italic end if (is_bold) { os << "}"; } // bold end -- cgit v1.2.3 From 102bcf0bf771f0fc40d8f63ee9c727256b2d70f1 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 10 Apr 2011 23:55:40 +0200 Subject: pdf+latex: * use textit instead of itshape, use textbf instead of bfseries; this improves kerning * add textsl (slanted) for oblique font shapes (e.g. Arial) (bzr r10156) --- src/extension/internal/latex-text-renderer.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 417dbb9ff..98142632d 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -345,7 +345,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) li != le; li.nextStartOfSpan()) { SPStyle const &spanstyle = *(sp_te_style_at_position (item, li)); - bool is_bold = false, is_italic = false; + bool is_bold = false, is_italic = false, is_oblique = false; if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 || spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 || @@ -356,12 +356,17 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER) { is_bold = true; - os << "{\\bfseries{}"; + os << "\\textbf{"; } if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC) { is_italic = true; - os << "{\\itshape{}"; + os << "\\textit{"; + } + if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE) + { + is_oblique = true; + os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so... } Inkscape::Text::Layout::iterator ln = li; @@ -378,6 +383,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) g_strfreev(splitstr); g_free(spanstr_new); + if (is_oblique) { os << "}"; } // oblique end if (is_italic) { os << "}"; } // italic end if (is_bold) { os << "}"; } // bold end } @@ -483,7 +489,7 @@ Flowing in rectangle is possible, not in arb shape. li != le; li.nextStartOfSpan()) { SPStyle const &spanstyle = *(sp_te_style_at_position (item, li)); - bool is_bold = false, is_italic = false; + bool is_bold = false, is_italic = false, is_oblique = false; if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 || spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 || @@ -494,12 +500,17 @@ Flowing in rectangle is possible, not in arb shape. spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER) { is_bold = true; - os << "{\\bfseries{}"; + os << "\\textbf{"; } if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC) { is_italic = true; - os << "{\\itshape{}"; + os << "\\textit{"; + } + if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE) + { + is_oblique = true; + os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so... } Inkscape::Text::Layout::iterator ln = li; @@ -516,6 +527,7 @@ Flowing in rectangle is possible, not in arb shape. g_strfreev(splitstr); g_free(spanstr_new); + if (is_oblique) { os << "}"; } // oblique end if (is_italic) { os << "}"; } // italic end if (is_bold) { os << "}"; } // bold end } -- cgit v1.2.3 From c10590daa8606b1afcbe29e054523ce95cbdca74 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 11 Apr 2011 17:58:35 +0200 Subject: Guides and clonetiler. Fix for bug #477649 (GTK warning about an adjustment with non-zero page in the guide editor dialog). Clonetiler. Code consistency fix. (bzr r10157) --- src/dialogs/clonetiler.cpp | 179 ++++++++++++++++++++------------------------- src/ui/dialog/guides.cpp | 6 +- 2 files changed, 81 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 2a78cf5a1..40b5f601e 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -82,8 +82,7 @@ static sigc::connection _color_changed_connection; static Inkscape::UI::Widget::ColorPicker *color_picker; -static void -clonetiler_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ ) +static void clonetiler_dialog_destroy(GtkObject */*object*/, gpointer /*data*/) { sp_signal_disconnect_by_data (INKSCAPE, dlg); _color_changed_connection.disconnect(); @@ -95,14 +94,17 @@ clonetiler_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ ) } -static gboolean -clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer /*data*/) +static gboolean clonetiler_dialog_delete(GtkObject */*object*/, GdkEvent * /*event*/, gpointer /*data*/) { gtk_window_get_position ((GtkWindow *) dlg, &x, &y); gtk_window_get_size ((GtkWindow *) dlg, &w, &h); - if (x<0) x=0; - if (y<0) y=0; + if (x < 0) { + x = 0; + } + if (y < 0) { + y = 0; + } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt(prefs_path + "x", x); @@ -114,8 +116,7 @@ clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer } -static void -on_picker_color_changed (guint rgba) +static void on_picker_color_changed(guint rgba) { static bool is_updating = false; if (is_updating || !SP_ACTIVE_DESKTOP) @@ -131,10 +132,9 @@ on_picker_color_changed (guint rgba) is_updating = false; } -static guint clonetiler_number_of_clones (SPObject *obj); +static guint clonetiler_number_of_clones(SPObject *obj); -static void -clonetiler_change_selection (Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg) +static void clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg) { GtkWidget *buttons = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles"); GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status"); @@ -163,15 +163,16 @@ clonetiler_change_selection (Inkscape::Application * /*inkscape*/, Inkscape::Sel } } -static void -clonetiler_external_change (Inkscape::Application * /*inkscape*/, GtkWidget *dlg) +static void clonetiler_external_change(Inkscape::Application * /*inkscape*/, GtkWidget *dlg) { clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); } -static void clonetiler_disconnect_gsignal (GObject *widget, gpointer source) { - if (source && G_IS_OBJECT(source)) +static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source) +{ + if (source && G_IS_OBJECT(source)) { sp_signal_disconnect_by_data (source, widget); + } } @@ -196,9 +197,7 @@ enum { }; -static Geom::Affine -clonetiler_get_transform ( - +static Geom::Affine clonetiler_get_transform( // symmetry group int type, @@ -800,8 +799,7 @@ clonetiler_get_transform ( return Geom::identity(); } -static bool -clonetiler_is_a_clone_of (SPObject *tile, SPObject *obj) +static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) { bool result = false; char *id_href = NULL; @@ -834,8 +832,7 @@ static NRArenaItem *trace_root; static gdouble trace_zoom; static SPDocument *trace_doc; -static void -clonetiler_trace_hide_tiled_clones_recursively (SPObject *from) +static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) { if (!trace_arena) return; @@ -847,8 +844,7 @@ clonetiler_trace_hide_tiled_clones_recursively (SPObject *from) } } -static void -clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original) +static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { trace_arena = NRArena::create(); /* Create ArenaItem and set transform */ @@ -866,11 +862,11 @@ clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original) trace_zoom = zoom; } -static guint32 -clonetiler_trace_pick (Geom::Rect box) +static guint32 clonetiler_trace_pick(Geom::Rect box) { - if (!trace_arena) + if (!trace_arena) { return 0; + } Geom::Affine t(Geom::Scale(trace_zoom, trace_zoom)); nr_arena_item_set_transform(trace_root, &t); @@ -940,8 +936,7 @@ clonetiler_trace_pick (Geom::Rect box) return SP_RGBA32_F_COMPOSE (R, G, B, A); } -static void -clonetiler_trace_finish () +static void clonetiler_trace_finish() { if (trace_doc) { SP_ITEM(trace_doc->getRoot())->invoke_hide(trace_visionkey); @@ -952,12 +947,12 @@ clonetiler_trace_finish () } } -static void -clonetiler_unclump( GtkWidget */*widget*/, void * ) +static void clonetiler_unclump(GtkWidget */*widget*/, void *) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop == NULL) + if (desktop == NULL) { return; + } Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -988,8 +983,7 @@ clonetiler_unclump( GtkWidget */*widget*/, void * ) _("Unclump tiled clones")); } -static guint -clonetiler_number_of_clones (SPObject *obj) +static guint clonetiler_number_of_clones(SPObject *obj) { SPObject *parent = obj->parent; @@ -1004,12 +998,12 @@ clonetiler_number_of_clones (SPObject *obj) return n; } -static void -clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true ) +static void clonetiler_remove(GtkWidget */*widget*/, void *, bool do_undo = true) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop == NULL) + if (desktop == NULL) { return; + } Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -1042,8 +1036,7 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true ) } } -static Geom::Rect -transform_rect( Geom::Rect const &r, Geom::Affine const &m) +static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m) { using Geom::X; using Geom::Y; @@ -1064,22 +1057,23 @@ transform_rect( Geom::Rect const &r, Geom::Affine const &m) Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same probability of being displaced. */ -static double -randomize01 (double val, double rand) +static double randomize01(double val, double rand) { double base = MIN (val - rand, 1 - 2*rand); - if (base < 0) base = 0; + if (base < 0) { + base = 0; + } val = base + g_random_double_range (0, MIN (2 * rand, 1 - base)); return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case... } -static void -clonetiler_apply( GtkWidget */*widget*/, void * ) +static void clonetiler_apply(GtkWidget */*widget*/, void *) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop == NULL) + if (desktop == NULL) { return; + } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -1429,11 +1423,11 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) } if (opacity < 1e-6) { // invisibly transparent, skip - continue; + continue; } if (fabs(t[0]) + fabs (t[1]) + fabs(t[2]) + fabs(t[3]) < 1e-6) { // too small, skip - continue; + continue; } // Create the clone @@ -1506,8 +1500,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) _("Create tiled clones")); } -static GtkWidget * -clonetiler_new_tab (GtkWidget *nb, const gchar *label) +static GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); @@ -1516,16 +1509,14 @@ clonetiler_new_tab (GtkWidget *nb, const gchar *label) return vb; } -static void -clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data) +static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) { const gchar *attr = (const gchar *) data; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); } -static GtkWidget * -clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr) +static GtkWidget * clonetiler_checkbox(GtkTooltips *tt, const char *tip, const char *attr) { GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); @@ -1545,32 +1536,31 @@ clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr) return hb; } - -static void -clonetiler_value_changed (GtkAdjustment *adj, gpointer data) +static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setDouble(prefs_path + pref, adj->value); } -static GtkWidget * -clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false) +static GtkWidget * clonetiler_spinbox(GtkTooltips *tt, const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false) { GtkWidget *hb = gtk_hbox_new(FALSE, 0); { GtkObject *a; - if (exponent) - a = gtk_adjustment_new(1.0, lower, upper, 0.01, 0.05, 0.1); - else - a = gtk_adjustment_new(0.0, lower, upper, 0.1, 0.5, 2); + if (exponent) { + a = gtk_adjustment_new(1.0, lower, upper, 0.01, 0.05, 0); + } else { + a = gtk_adjustment_new(0.0, lower, upper, 0.1, 0.5, 0); + } GtkWidget *sb; - if (exponent) + if (exponent) { sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 2); - else + } else { sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.1, 1); + } gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, tip, NULL); gtk_entry_set_width_chars (GTK_ENTRY (sb), 4); @@ -1582,10 +1572,11 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l gtk_signal_connect(GTK_OBJECT(a), "value_changed", GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr); - if (exponent) + if (exponent) { g_object_set_data (G_OBJECT(sb), "oneable", GINT_TO_POINTER(TRUE)); - else + } else { g_object_set_data (G_OBJECT(sb), "zeroable", GINT_TO_POINTER(TRUE)); + } } { @@ -1598,31 +1589,27 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l return hb; } -static void -clonetiler_symgroup_changed( GtkMenuItem */*item*/, gpointer data ) +static void clonetiler_symgroup_changed(GtkMenuItem */*item*/, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint group_new = GPOINTER_TO_INT (data); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -static void -clonetiler_xy_changed (GtkAdjustment *adj, gpointer data) +static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setInt(prefs_path + pref, (int) floor(adj->value + 0.5)); } -static void -clonetiler_keep_bbox_toggled( GtkToggleButton *tb, gpointer /*data*/ ) +static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); } -static void -clonetiler_pick_to (GtkToggleButton *tb, gpointer data) +static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; @@ -1630,8 +1617,7 @@ clonetiler_pick_to (GtkToggleButton *tb, gpointer data) } -static void -clonetiler_reset_recursive (GtkWidget *w) +static void clonetiler_reset_recursive(GtkWidget *w) { if (w && GTK_IS_OBJECT(w)) { { @@ -1665,22 +1651,19 @@ clonetiler_reset_recursive (GtkWidget *w) } } -static void -clonetiler_reset( GtkWidget */*widget*/, void * ) +static void clonetiler_reset(GtkWidget */*widget*/, void *) { clonetiler_reset_recursive (dlg); } -static void -clonetiler_table_attach (GtkWidget *table, GtkWidget *widget, float align, int row, int col) +static void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); gtk_container_add(GTK_CONTAINER(a), widget); gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 ); } -static GtkWidget * -clonetiler_table_x_y_rand (int values) +static GtkWidget * clonetiler_table_x_y_rand(int values) { GtkWidget *table = gtk_table_new (values + 2, 5, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); @@ -1722,8 +1705,7 @@ clonetiler_table_x_y_rand (int values) return table; } -static void -clonetiler_pick_switched( GtkToggleButton */*tb*/, gpointer data ) +static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint v = GPOINTER_TO_INT (data); @@ -1731,8 +1713,7 @@ clonetiler_pick_switched( GtkToggleButton */*tb*/, gpointer data ) } -static void -clonetiler_switch_to_create( GtkToggleButton */*tb*/, GtkWidget *dlg ) +static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols"); GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight"); @@ -1749,8 +1730,7 @@ clonetiler_switch_to_create( GtkToggleButton */*tb*/, GtkWidget *dlg ) } -static void -clonetiler_switch_to_fill( GtkToggleButton */*tb*/, GtkWidget *dlg ) +static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols"); GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight"); @@ -1769,8 +1749,7 @@ clonetiler_switch_to_fill( GtkToggleButton */*tb*/, GtkWidget *dlg ) -static void -clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u) +static void clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u) { gdouble const raw_dist = adj->value; SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); @@ -1780,8 +1759,7 @@ clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u) prefs->setDouble(prefs_path + "fillwidth", pixels); } -static void -clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u) +static void clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u) { gdouble const raw_dist = adj->value; SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); @@ -1792,23 +1770,22 @@ clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u) } -static void -clonetiler_do_pick_toggled( GtkToggleButton *tb, gpointer /*data*/ ) +static void clonetiler_do_pick_toggled(GtkToggleButton *tb, gpointer /*data*/) { GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb)); - if (vvb) + if (vvb) { gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb)); + } } -void -clonetiler_dialog (void) +void clonetiler_dialog(void) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!dlg) @@ -2764,7 +2741,7 @@ clonetiler_dialog (void) g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); { - GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10); + GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "jmax", 2); gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0); @@ -2784,7 +2761,7 @@ clonetiler_dialog (void) } { - GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10); + GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "imax", 2); gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0); @@ -2809,7 +2786,7 @@ clonetiler_dialog (void) { // Width spinbutton - GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0); + GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 0); sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a)); double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); @@ -2833,7 +2810,7 @@ clonetiler_dialog (void) { // Height spinbutton - GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0); + GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 0); sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a)); double value = prefs->getDouble(prefs_path + "fillheight", 50.0); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 1ac1e5d82..910b4ac39 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -45,9 +45,9 @@ GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop * _label_Y(_("Y:")), _label_degrees(_("Angle (degrees):")), _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), - _adjustment_x(0.0, -1e6, 1e6, 1.0, 10.0, 10.0), - _adjustment_y(0.0, -1e6, 1e6, 1.0, 10.0, 10.0), - _adj_angle(0.0, -360, 360, 1.0, 10.0, 10.0), + _adjustment_x(0.0, -1e6, 1e6, 1.0, 10.0, 0), + _adjustment_y(0.0, -1e6, 1e6, 1.0, 10.0, 0), + _adj_angle(0.0, -360, 360, 1.0, 10.0, 0), _unit_selector(NULL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) { } -- cgit v1.2.3 From a23c64310e23a948aaeed4a47b4a2cd65f5d9201 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 11 Apr 2011 20:45:22 +0200 Subject: revert silly error in r10147 (bzr r10158) --- src/ui/dialog/guides.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 910b4ac39..619b6fb16 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -152,7 +152,7 @@ void GuidelinePropertiesDialog::_response(gint response) } void GuidelinePropertiesDialog::_setup() { - set_title(_("Guidelinea")); + set_title(_("Guideline")); add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); add_button(Gtk::Stock::DELETE, -12); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); -- cgit v1.2.3 From ae45a98ae609d27cf5cf8471c2cea685bde5da70 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 11 Apr 2011 21:20:20 +0200 Subject: Use the subclassed SpinButton class for numeric inputs, such that '.' and ',' both can be used as decimal point. (related to bug 484187) (bzr r10159) --- src/ui/dialog/session-player.h | 2 +- src/ui/widget/preferences-widget.h | 3 ++- src/ui/widget/scalar.cpp | 39 +++++++++++++++++++------------------- src/ui/widget/scalar.h | 3 --- src/ui/widget/spinbutton.h | 6 ++++-- 5 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/session-player.h b/src/ui/dialog/session-player.h index 9c10f264f..2d235cd25 100644 --- a/src/ui/dialog/session-player.h +++ b/src/ui/dialog/session-player.h @@ -75,7 +75,7 @@ private: Gtk::Tooltips _tooltips; Gtk::Toolbar _playbackcontrols; Gtk::Adjustment _delay; - Gtk::SpinButton _delayentry; + Widget::SpinButton _delayentry; Gtk::Frame _filemanager; Gtk::VBox _fm; diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 6c7f9ce4a..4cd2ff569 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -32,6 +32,7 @@ #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" +#include "ui/widget/spinbutton.h" namespace Inkscape { namespace UI { @@ -68,7 +69,7 @@ protected: void on_toggled(); }; -class PrefSpinButton : public Gtk::SpinButton +class PrefSpinButton : public SpinButton { public: void init(Glib::ustring const &prefs_path, diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 26a1f6541..eda8cd2cc 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -18,6 +18,7 @@ #include "scalar.h" +#include "spinbutton.h" namespace Inkscape { namespace UI { @@ -37,10 +38,10 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast(_widget)->set_numeric(); + static_cast(_widget)->set_numeric(); } /** @@ -59,10 +60,10 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast(_widget)->set_numeric(); + static_cast(_widget)->set_numeric(); } /** @@ -83,10 +84,10 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast(_widget)->set_numeric(); + static_cast(_widget)->set_numeric(); } /** Fetches the precision of the spin buton */ @@ -94,7 +95,7 @@ unsigned Scalar::getDigits() const { g_assert(_widget != NULL); - return static_cast(_widget)->get_digits(); + return static_cast(_widget)->get_digits(); } /** Gets the current step ingrement used by the spin button */ @@ -103,7 +104,7 @@ Scalar::getStep() const { g_assert(_widget != NULL); double step, page; - static_cast(_widget)->get_increments(step, page); + static_cast(_widget)->get_increments(step, page); return step; } @@ -113,7 +114,7 @@ Scalar::getPage() const { g_assert(_widget != NULL); double step, page; - static_cast(_widget)->get_increments(step, page); + static_cast(_widget)->get_increments(step, page); return page; } @@ -123,7 +124,7 @@ Scalar::getRangeMin() const { g_assert(_widget != NULL); double min, max; - static_cast(_widget)->get_range(min, max); + static_cast(_widget)->get_range(min, max); return min; } @@ -133,7 +134,7 @@ Scalar::getRangeMax() const { g_assert(_widget != NULL); double min, max; - static_cast(_widget)->get_range(min, max); + static_cast(_widget)->get_range(min, max); return max; } @@ -142,7 +143,7 @@ double Scalar::getValue() const { g_assert(_widget != NULL); - return static_cast(_widget)->get_value(); + return static_cast(_widget)->get_value(); } /** Get the value spin_button represented as an integer. */ @@ -150,7 +151,7 @@ int Scalar::getValueAsInt() const { g_assert(_widget != NULL); - return static_cast(_widget)->get_value_as_int(); + return static_cast(_widget)->get_value_as_int(); } @@ -159,7 +160,7 @@ void Scalar::setDigits(unsigned digits) { g_assert(_widget != NULL); - static_cast(_widget)->set_digits(digits); + static_cast(_widget)->set_digits(digits); } /** Sets the step and page increments for the spin button @@ -169,7 +170,7 @@ void Scalar::setIncrements(double step, double /*page*/) { g_assert(_widget != NULL); - static_cast(_widget)->set_increments(step, 0); + static_cast(_widget)->set_increments(step, 0); } /** Sets the minimum and maximum range allowed for the spin button */ @@ -177,7 +178,7 @@ void Scalar::setRange(double min, double max) { g_assert(_widget != NULL); - static_cast(_widget)->set_range(min, max); + static_cast(_widget)->set_range(min, max); } /** Sets the value of the spin button */ @@ -186,14 +187,14 @@ Scalar::setValue(double value) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares - static_cast(_widget)->set_value(value); + static_cast(_widget)->set_value(value); } /** Manually forces an update of the spin button */ void Scalar::update() { g_assert(_widget != NULL); - static_cast(_widget)->update(); + static_cast(_widget)->update(); } @@ -202,7 +203,7 @@ Scalar::update() { Glib::SignalProxy0 Scalar::signal_value_changed() { - return static_cast(_widget)->signal_value_changed(); + return static_cast(_widget)->signal_value_changed(); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 6de128edb..7142ba93f 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -15,9 +15,6 @@ #ifndef INKSCAPE_UI_WIDGET_SCALAR_H #define INKSCAPE_UI_WIDGET_SCALAR_H -#include -#include - #include "labelled.h" namespace Inkscape { diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index d9b382b08..408310d09 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -25,8 +25,10 @@ namespace Widget { class SpinButton : public Gtk::SpinButton { public: - SpinButton() : Gtk::SpinButton() {}; - /// @todo perhaps more constructors should be added here + SpinButton(double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(climb_rate, digits) {}; + explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(adjustment, climb_rate, digits) {}; virtual ~SpinButton() {}; -- cgit v1.2.3 From ccc2ac21c121259c9400d547d53fde6da2093e84 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 12 Apr 2011 21:13:24 +0200 Subject: fix build (bzr r10160) --- src/ui/widget/random.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 02201be12..3dcf09cb5 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -25,6 +25,8 @@ #include +#include + namespace Inkscape { namespace UI { namespace Widget { -- cgit v1.2.3 From fe875852760883dd20b6a57b57be50de83e37fc2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 14 Apr 2011 00:04:49 +0200 Subject: add expression evaluator for spinbox input boxes. also knows a little about units. needs more work to fully integrate it in all of inkscape spinboxes also needs documentation rework (bzr r10162) --- src/ui/dialog/guides.cpp | 3 - src/ui/widget/preferences-widget.cpp | 1 - src/ui/widget/scalar-unit.cpp | 3 + src/ui/widget/scalar.cpp | 3 - src/ui/widget/spinbutton.cpp | 41 +-- src/ui/widget/spinbutton.h | 24 +- src/util/Makefile_insert | 2 + src/util/expression-evaluator.cpp | 571 +++++++++++++++++++++++++++++++++++ src/util/expression-evaluator.h | 80 +++++ 9 files changed, 700 insertions(+), 28 deletions(-) create mode 100644 src/util/expression-evaluator.cpp create mode 100644 src/util/expression-evaluator.h (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 619b6fb16..fd64a713f 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -194,9 +194,7 @@ void GuidelinePropertiesDialog::_setup() { sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj())); sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj())); _spin_button_x.configure(_adjustment_x, 1.0 , 3); - _spin_button_x.set_numeric(); _spin_button_y.configure(_adjustment_y, 1.0 , 3); - _spin_button_y.set_numeric(); _layout_table.attach(_label_X, 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_x, @@ -213,7 +211,6 @@ void GuidelinePropertiesDialog::_setup() { // angle spinbutton _spin_angle.configure(_adj_angle, 5.0 , 3); - _spin_angle.set_numeric(); _spin_angle.show(); _layout_table.attach(_label_degrees, 1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index afcaa338e..f92e2518d 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -227,7 +227,6 @@ void PrefSpinButton::init(Glib::ustring const &prefs_path, this->set_range (lower, upper); this->set_increments (step_increment, 0); - this->set_numeric(); this->set_value (value); this->set_width_chars(6); if (is_int) diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 6209d40e0..e00e82198 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -27,6 +27,7 @@ #endif #include "scalar-unit.h" +#include "spinbutton.h" namespace Inkscape { namespace UI { @@ -65,6 +66,8 @@ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, } _unit_menu->signal_changed() .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); + + static_cast(_widget)->setUnitMenu(_unit_menu); } /** diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index eda8cd2cc..6ada379fb 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -41,7 +41,6 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, : Labelled(label, tooltip, new SpinButton(), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast(_widget)->set_numeric(); } /** @@ -63,7 +62,6 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, : Labelled(label, tooltip, new SpinButton(0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast(_widget)->set_numeric(); } /** @@ -87,7 +85,6 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, : Labelled(label, tooltip, new SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast(_widget)->set_numeric(); } /** Fetches the precision of the spin buton */ diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 55c2d877f..22bc30bb2 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -16,32 +16,39 @@ #include "spinbutton.h" -#include +#include "unit-menu.h" +#include "util/expression-evaluator.h" namespace Inkscape { namespace UI { namespace Widget { -void -SpinButton::on_insert_text(const Glib::ustring& text, int* position) +/** + * This callback function should try to convert the entered text to a number and write it to newvalue. + * It calls a method to evaluate the (potential) mathematical expression. + * + * @retval false No conversion done, continue with default handler. + * @retval true Conversion successful, don't call default handler. + */ +int +SpinButton::on_input(double* newvalue) { - Glib::ustring newtext = text; - - // if in numeric mode: replace '.' or ',' with the locale's decimal point - if (get_numeric()) { - size_t found = newtext.find('.'); - if (found != Glib::ustring::npos) { - newtext.replace(found, 1, localeconv()->decimal_point); - } else { - found = newtext.find(','); - if (found != Glib::ustring::npos) { - newtext.replace(found, 1, localeconv()->decimal_point); - } + try { + Inkscape::Util::GimpEevlQuantity result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), _unit_menu ? &_unit_menu->getUnit() : NULL); + // check if output dimension corresponds to input unit + if (_unit_menu && result.dimension != (_unit_menu->getUnit().isAbsolute() ? 1 : 0) ) { + throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); } + + *newvalue = result.value; + } + catch(Inkscape::Util::EvaluatorException &e) { + g_message ("%s", e.what()); + + return false; } - // call parent function with replaced text: - Gtk::SpinButton::on_insert_text(newtext, position); + return true; } } // namespace Widget diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 408310d09..0eb58bb9e 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -19,21 +19,37 @@ namespace Inkscape { namespace UI { namespace Widget { +class UnitMenu; + /** - * SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu). + * + * Calling "set_numeric()" effectively disables the expression parsing. If no unit menu is linked, all unitlike characters are ignored. */ class SpinButton : public Gtk::SpinButton { public: SpinButton(double climb_rate = 0.0, guint digits = 0) - : Gtk::SpinButton(climb_rate, digits) {}; + : Gtk::SpinButton(climb_rate, digits), + _unit_menu(NULL) + { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + }; explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) - : Gtk::SpinButton(adjustment, climb_rate, digits) {}; + : Gtk::SpinButton(adjustment, climb_rate, digits), + _unit_menu(NULL) + { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + }; virtual ~SpinButton() {}; + void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + protected: - virtual void on_insert_text(const Glib::ustring& text, int* position); + UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + + int on_input(double* newvalue); private: // noncopyable diff --git a/src/util/Makefile_insert b/src/util/Makefile_insert index deff951d4..4066ffd5d 100644 --- a/src/util/Makefile_insert +++ b/src/util/Makefile_insert @@ -9,6 +9,8 @@ ink_common_sources += \ util/ege-appear-time-tracker.h \ util/ege-tags.h \ util/ege-tags.cpp \ + util/expression-evaluator.h \ + util/expression-evaluator.cpp \ util/filter-list.h \ util/find-if-before.h \ util/find-last-if.h \ diff --git a/src/util/expression-evaluator.cpp b/src/util/expression-evaluator.cpp new file mode 100644 index 000000000..b43a61a6d --- /dev/null +++ b/src/util/expression-evaluator.cpp @@ -0,0 +1,571 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * Original file from libgimpwidgets: gimpeevl.c + * Copyright (C) 2008 Fredrik Alstromer + * Copyright (C) 2008 Martin Nordholts + * Modified for Inkscape by Johan Engelen + * Copyright (C) 2011 Johan Engelen + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +/** Introducing eevl eva, the evaluator. A straightforward recursive + * descent parser, no fuss, no new dependencies. The lexer is hand + * coded, tedious, not extremely fast but works. It evaluates the + * expression as it goes along, and does not create a parse tree or + * anything, and will not optimize anything. It uses doubles for + * precision, with the given use case, that's enough to combat any + * rounding errors (as opposed to optimizing the evalutation). + * + * It relies on external unit resolving through a callback and does + * elementary dimensionality constraint check (e.g. "2 mm + 3 px * 4 + * in" is an error, as L + L^2 is a missmatch). It uses g_strtod() for numeric + * conversions and it's non-destructive in terms of the paramters, and + * it's reentrant. + * + * EBNF: + * + * expression ::= term { ('+' | '-') term }* | + * ; + * + * term ::= signed factor { ( '*' | '/' ) signed factor }* ; + * + * signed factor ::= ( '+' | '-' )? factor ; + * + * unit factor ::= factor unit? ; + * + * factor ::= number | '(' expression ')' ; + * + * number ::= ? what g_strtod() consumes ? ; + * + * unit ::= ? what not g_strtod() consumes and not whitespace ? ; + * + * The code should match the EBNF rather closely (except for the + * non-terminal unit factor, which is inlined into factor) for + * maintainability reasons. + * + * It will allow 1++1 and 1+-1 (resulting in 2 and 0, respectively), + * but I figured one might want that, and I don't think it's going to + * throw anyone off. + */ + +#include "config.h" + +#include "util/expression-evaluator.h" +#include "util/units.h" + +#include + +#include + +namespace Inkscape { +namespace Util { + +enum +{ + GIMP_EEVL_TOKEN_NUM = 30000, + GIMP_EEVL_TOKEN_IDENTIFIER = 30001, + + GIMP_EEVL_TOKEN_ANY = 40000, + + GIMP_EEVL_TOKEN_END = 50000 +} GimpEevlTokenTypeEnum; + +typedef int GimpEevlTokenType; + + +typedef struct +{ + GimpEevlTokenType type; + + union + { + gdouble fl; + + struct + { + const gchar *c; + gint size; + }; + + } value; + +} GimpEevlToken; + +typedef struct +{ + const gchar *string; + GimpEevlUnitResolverProc unit_resolver_proc; + Unit *unit; + + GimpEevlToken current_token; + const gchar *start_of_current_token; +} GimpEevl; + +/** Unit Resolver... + */ +bool unitresolverproc (const gchar* identifier, GimpEevlQuantity *result, Unit* unit) +{ + static UnitTable unit_table; + + if (!unit) { + result->value = 1; + result->dimension = 1; + return true; + }else if (!identifier) { + result->value = 1; + result->dimension = unit->isAbsolute() ? 1 : 0; + return true; + } else if (unit_table.hasUnit(identifier)) { + Unit identifier_unit = unit_table.getUnit(identifier); + + // Catch the case of zero or negative unit factors (error!) + if (identifier_unit.factor < 0.0000001) { + return false; + } + + result->value = unit->factor / identifier_unit.factor; + result->dimension = identifier_unit.isAbsolute() ? 1 : 0; + return true; + } else { + return false; + } +} + +static void gimp_eevl_init (GimpEevl *eva, + const gchar *string, + GimpEevlUnitResolverProc unit_resolver_proc, + Unit *unit); +static GimpEevlQuantity gimp_eevl_complete (GimpEevl *eva); +static GimpEevlQuantity gimp_eevl_expression (GimpEevl *eva); +static GimpEevlQuantity gimp_eevl_term (GimpEevl *eva); +static GimpEevlQuantity gimp_eevl_signed_factor (GimpEevl *eva); +static GimpEevlQuantity gimp_eevl_factor (GimpEevl *eva); +static gboolean gimp_eevl_accept (GimpEevl *eva, + GimpEevlTokenType token_type, + GimpEevlToken *consumed_token); +static void gimp_eevl_lex (GimpEevl *eva); +static void gimp_eevl_lex_accept_count (GimpEevl *eva, + gint count, + GimpEevlTokenType token_type); +static void gimp_eevl_lex_accept_to (GimpEevl *eva, + gchar *to, + GimpEevlTokenType token_type); +static void gimp_eevl_move_past_whitespace (GimpEevl *eva); +static gboolean gimp_eevl_unit_identifier_start (gunichar c); +static gboolean gimp_eevl_unit_identifier_continue (gunichar c); +static gint gimp_eevl_unit_identifier_size (const gchar *s, + gint start); +static void gimp_eevl_expect (GimpEevl *eva, + GimpEevlTokenType token_type, + GimpEevlToken *value); +static void gimp_eevl_error (GimpEevl *eva, + const char *msg); + + +/** + * Evaluates the given arithmetic expression, along with an optional dimension + * analysis, and basic unit conversions. + * + * @param string The NULL-terminated string to be evaluated. + * @param unit_resolver_proc Unit resolver callback. + * + * All units conversions factors are relative to some implicit + * base-unit (which in GIMP is inches). This is also the unit of the + * returned value. + * + * Returns: A #GimpEevlQuantity with a value given in the base unit along with + * the order of the dimension (i.e. if the base unit is inches, a dimension + * order of two menas in^2). + * + * @return Result of evaluation. + * @throws Inkscape::Util::EvaluatorException There was a parse error. + **/ +GimpEevlQuantity +gimp_eevl_evaluate (const gchar* string, Unit* unit) +{ + if (! g_utf8_validate (string, -1, NULL)) { + throw EvaluatorException("Invalid UTF8 string", NULL); + } + + GimpEevl eva; + gimp_eevl_init (&eva, string, unitresolverproc, unit); + + return gimp_eevl_complete(&eva); +} + +static void +gimp_eevl_init (GimpEevl *eva, + const gchar *string, + GimpEevlUnitResolverProc unit_resolver_proc, + Unit *unit) +{ + eva->string = string; + eva->unit_resolver_proc = unit_resolver_proc; + eva->unit = unit; + + eva->current_token.type = GIMP_EEVL_TOKEN_END; + + /* Preload symbol... */ + gimp_eevl_lex (eva); +} + +static GimpEevlQuantity +gimp_eevl_complete (GimpEevl *eva) +{ + GimpEevlQuantity result = {0, 0}; + GimpEevlQuantity default_unit_factor; + + /* Empty expression evaluates to 0 */ + if (gimp_eevl_accept (eva, GIMP_EEVL_TOKEN_END, NULL)) + return result; + + result = gimp_eevl_expression (eva); + + /* There should be nothing left to parse by now */ + gimp_eevl_expect (eva, GIMP_EEVL_TOKEN_END, 0); + + eva->unit_resolver_proc (NULL, &default_unit_factor, eva->unit); + + /* Entire expression is dimensionless, apply default unit if + * applicable + */ + if (result.dimension == 0 && default_unit_factor.dimension != 0) + { + result.value /= default_unit_factor.value; + result.dimension = default_unit_factor.dimension; + } + return result; +} + +static GimpEevlQuantity +gimp_eevl_expression (GimpEevl *eva) +{ + gboolean subtract; + GimpEevlQuantity evaluated_terms; + + evaluated_terms = gimp_eevl_term (eva); + + /* continue evaluating terms, chained with + or -. */ + for (subtract = FALSE; + gimp_eevl_accept (eva, '+', NULL) || + (subtract = gimp_eevl_accept (eva, '-', NULL)); + subtract = FALSE) + { + GimpEevlQuantity new_term = gimp_eevl_term (eva); + + /* If dimensions missmatch, attempt default unit assignent */ + if (new_term.dimension != evaluated_terms.dimension) + { + GimpEevlQuantity default_unit_factor; + + eva->unit_resolver_proc (NULL, + &default_unit_factor, + eva->unit); + + if (new_term.dimension == 0 && + evaluated_terms.dimension == default_unit_factor.dimension) + { + new_term.value /= default_unit_factor.value; + new_term.dimension = default_unit_factor.dimension; + } + else if (evaluated_terms.dimension == 0 && + new_term.dimension == default_unit_factor.dimension) + { + evaluated_terms.value /= default_unit_factor.value; + evaluated_terms.dimension = default_unit_factor.dimension; + } + else + { + gimp_eevl_error (eva, "Dimension missmatch during addition"); + } + } + + evaluated_terms.value += (subtract ? -new_term.value : new_term.value); + } + + return evaluated_terms; +} + +static GimpEevlQuantity +gimp_eevl_term (GimpEevl *eva) +{ + gboolean division; + GimpEevlQuantity evaluated_signed_factors; + + evaluated_signed_factors = gimp_eevl_signed_factor (eva); + + for (division = FALSE; + gimp_eevl_accept (eva, '*', NULL) || + (division = gimp_eevl_accept (eva, '/', NULL)); + division = FALSE) + { + GimpEevlQuantity new_signed_factor = gimp_eevl_signed_factor (eva); + + if (division) + { + evaluated_signed_factors.value /= new_signed_factor.value; + evaluated_signed_factors.dimension -= new_signed_factor.dimension; + + } + else + { + evaluated_signed_factors.value *= new_signed_factor.value; + evaluated_signed_factors.dimension += new_signed_factor.dimension; + } + } + + return evaluated_signed_factors; +} + +static GimpEevlQuantity +gimp_eevl_signed_factor (GimpEevl *eva) +{ + GimpEevlQuantity result; + gboolean negate = FALSE; + + if (! gimp_eevl_accept (eva, '+', NULL)) + negate = gimp_eevl_accept (eva, '-', NULL); + + result = gimp_eevl_factor (eva); + + if (negate) result.value = -result.value; + + return result; +} + +static GimpEevlQuantity +gimp_eevl_factor (GimpEevl *eva) +{ + GimpEevlQuantity evaluated_factor = { 0, 0 }; + GimpEevlToken consumed_token; + + if (gimp_eevl_accept (eva, + GIMP_EEVL_TOKEN_NUM, + &consumed_token)) + { + evaluated_factor.value = consumed_token.value.fl; + } + else if (gimp_eevl_accept (eva, '(', NULL)) + { + evaluated_factor = gimp_eevl_expression (eva); + gimp_eevl_expect (eva, ')', 0); + } + else + { + gimp_eevl_error (eva, "Expected number or '('"); + } + + if (eva->current_token.type == GIMP_EEVL_TOKEN_IDENTIFIER) + { + gchar *identifier; + GimpEevlQuantity result; + + gimp_eevl_accept (eva, + GIMP_EEVL_TOKEN_ANY, + &consumed_token); + + identifier = g_newa (gchar, consumed_token.value.size + 1); + + strncpy (identifier, consumed_token.value.c, consumed_token.value.size); + identifier[consumed_token.value.size] = '\0'; + + if (eva->unit_resolver_proc (identifier, + &result, + eva->unit)) + { + evaluated_factor.value /= result.value; + evaluated_factor.dimension += result.dimension; + } + else + { + gimp_eevl_error (eva, "Unit was not resolved"); + } + } + + return evaluated_factor; +} + +static gboolean +gimp_eevl_accept (GimpEevl *eva, + GimpEevlTokenType token_type, + GimpEevlToken *consumed_token) +{ + gboolean existed = FALSE; + + if (token_type == eva->current_token.type || + token_type == GIMP_EEVL_TOKEN_ANY) + { + existed = TRUE; + + if (consumed_token) + *consumed_token = eva->current_token; + + /* Parse next token */ + gimp_eevl_lex (eva); + } + + return existed; +} + +static void +gimp_eevl_lex (GimpEevl *eva) +{ + const gchar *s; + + gimp_eevl_move_past_whitespace (eva); + s = eva->string; + eva->start_of_current_token = s; + + if (! s || s[0] == '\0') + { + /* We're all done */ + eva->current_token.type = GIMP_EEVL_TOKEN_END; + } + else if (s[0] == '+' || s[0] == '-') + { + /* Snatch these before the g_strtod() does, othewise they might + * be used in a numeric conversion. + */ + gimp_eevl_lex_accept_count (eva, 1, s[0]); + } + else + + { + /* Attempt to parse a numeric value */ + gchar *endptr = NULL; + gdouble value = g_strtod (s, &endptr); + + if (endptr && endptr != s) + { + /* A numeric could be parsed, use it */ + eva->current_token.value.fl = value; + + gimp_eevl_lex_accept_to (eva, endptr, GIMP_EEVL_TOKEN_NUM); + } + else if (gimp_eevl_unit_identifier_start (s[0])) + { + /* Unit identifier */ + eva->current_token.value.c = s; + eva->current_token.value.size = gimp_eevl_unit_identifier_size (s, 0); + + gimp_eevl_lex_accept_count (eva, + eva->current_token.value.size, + GIMP_EEVL_TOKEN_IDENTIFIER); + } + else + { + /* Everything else is a single character token */ + gimp_eevl_lex_accept_count (eva, 1, s[0]); + } + } +} + +static void +gimp_eevl_lex_accept_count (GimpEevl *eva, + gint count, + GimpEevlTokenType token_type) +{ + eva->current_token.type = token_type; + eva->string += count; +} + +static void +gimp_eevl_lex_accept_to (GimpEevl *eva, + gchar *to, + GimpEevlTokenType token_type) +{ + eva->current_token.type = token_type; + eva->string = to; +} + +static void +gimp_eevl_move_past_whitespace (GimpEevl *eva) +{ + if (! eva->string) + return; + + while (g_ascii_isspace (*eva->string)) + eva->string++; +} + +static gboolean +gimp_eevl_unit_identifier_start (gunichar c) +{ + return (g_unichar_isalpha (c) || + c == (gunichar) '%' || + c == (gunichar) '\''); +} + +static gboolean +gimp_eevl_unit_identifier_continue (gunichar c) +{ + return (gimp_eevl_unit_identifier_start (c) || + g_unichar_isdigit (c)); +} + +/** + * gimp_eevl_unit_identifier_size: + * @s: + * @start: + * + * Returns: Size of identifier in bytes (not including NULL + * terminator). + **/ +static gint +gimp_eevl_unit_identifier_size (const gchar *string, + gint start_offset) +{ + const gchar *start = g_utf8_offset_to_pointer (string, start_offset); + const gchar *s = start; + gunichar c = g_utf8_get_char (s); + gint length = 0; + + if (gimp_eevl_unit_identifier_start (c)) + { + s = g_utf8_next_char (s); + c = g_utf8_get_char (s); + length++; + + while (gimp_eevl_unit_identifier_continue (c)) + { + s = g_utf8_next_char (s); + c = g_utf8_get_char (s); + length++; + } + } + + return g_utf8_offset_to_pointer (start, length) - start; +} + +static void +gimp_eevl_expect (GimpEevl *eva, + GimpEevlTokenType token_type, + GimpEevlToken *value) +{ + if (! gimp_eevl_accept (eva, token_type, value)) + gimp_eevl_error (eva, "Unexpected token"); +} + +static void +gimp_eevl_error (GimpEevl *eva, + const char *msg) +{ + throw EvaluatorException(msg, eva->start_of_current_token); +} + +} // namespace Util +} // namespace Inkscape diff --git a/src/util/expression-evaluator.h b/src/util/expression-evaluator.h new file mode 100644 index 000000000..90789a25f --- /dev/null +++ b/src/util/expression-evaluator.h @@ -0,0 +1,80 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * Original file from libgimpwidgets: gimpeevl.h + * Copyright (C) 2008-2009 Fredrik Alstromer + * Copyright (C) 2008-2009 Martin Nordholts + * Modified for Inkscape by Johan Engelen + * Copyright (C) 2011 Johan Engelen + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __GIMP_EEVL_H__ +#define __GIMP_EEVL_H__ + +#include "util/units.h" + +#include +#include +#include + +namespace Inkscape { +namespace Util { + +class Unit; + +/** +* GimpEevlQuantity: +* @value: In reference units. +* @dimension: in has a dimension of 1, in^2 has a dimension of 2 etc +*/ +typedef struct +{ + double value; + gint dimension; +} GimpEevlQuantity; + +typedef bool (* GimpEevlUnitResolverProc) (const gchar *identifier, + GimpEevlQuantity *result, + Unit* unit); + +GimpEevlQuantity gimp_eevl_evaluate (const gchar* string, Unit* unit = NULL); + +/** + * Special exception class for the expression evaluator. + */ +class EvaluatorException : public std::exception { +public: + EvaluatorException(const char * message, const char *at_position) { + std::ostringstream os; + const char* token = at_position ? at_position : ""; + os << "Expression evaluator error: " << message << " at '" << token << "'"; + msgstr = os.str(); + } + + virtual ~EvaluatorException() throw() {} // necessary to destroy the string object!!! + + virtual const char* what() const throw () { + return msgstr.c_str(); + } +protected: + std::string msgstr; +}; + +} +} + +#endif /* __GIMP_EEVL_H__ */ -- cgit v1.2.3 From de76d854317e700b1f0297c83f6a1cacc2ffa533 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 14 Apr 2011 08:29:21 +0200 Subject: Tracing. Potrace 1.9 update (see http://potrace.sourceforge.net/ChangeLog). (bzr r10163) --- src/trace/potrace/auxiliary.h | 29 ++++++++++++- src/trace/potrace/bitmap.h | 6 +-- src/trace/potrace/curve.cpp | 4 +- src/trace/potrace/curve.h | 2 +- src/trace/potrace/decompose.cpp | 50 +++++++--------------- src/trace/potrace/decompose.h | 5 ++- src/trace/potrace/greymap.cpp | 52 +++++++++++++---------- src/trace/potrace/greymap.h | 10 ++--- src/trace/potrace/lists.h | 4 +- src/trace/potrace/potracelib.cpp | 9 ++-- src/trace/potrace/potracelib.h | 12 +++++- src/trace/potrace/progress.h | 8 ++-- src/trace/potrace/render.cpp | 4 +- src/trace/potrace/render.h | 4 +- src/trace/potrace/trace.cpp | 90 +++++++++++++++++++++++----------------- src/trace/potrace/trace.h | 5 ++- 16 files changed, 166 insertions(+), 128 deletions(-) (limited to 'src') diff --git a/src/trace/potrace/auxiliary.h b/src/trace/potrace/auxiliary.h index 7baab851c..1c2765816 100644 --- a/src/trace/potrace/auxiliary.h +++ b/src/trace/potrace/auxiliary.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ @@ -75,4 +75,31 @@ static inline int floordiv(int a, int n) { #define sq(a) ((a)*(a)) #define cu(a) ((a)*(a)*(a)) +/* ---------------------------------------------------------------------- */ +/* deterministically and efficiently hash (x,y) into a pseudo-random bit */ +static inline int detrand(int x, int y) { + unsigned int z; + static const unsigned char t[256] = { + /* non-linear sequence: constant term of inverse in GF(8), + mod x^8+x^4+x^3+x+1 */ + 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, + 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, + 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, + 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, + 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, + 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + }; + + /* 0x04b3e375 and 0x05a8ef93 are chosen to contain every possible + 5-bit sequence */ + z = ((0x04b3e375 * x) ^ y) * 0x05a8ef93; + z = t[z & 0xff] ^ t[(z>>8) & 0xff] ^ t[(z>>16) & 0xff] ^ t[(z>>24) & 0xff]; + return z; +} + #endif /* AUXILIARY_H */ diff --git a/src/trace/potrace/bitmap.h b/src/trace/potrace/bitmap.h index 2a172b1ad..671382dc2 100644 --- a/src/trace/potrace/bitmap.h +++ b/src/trace/potrace/bitmap.h @@ -1,14 +1,10 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ #ifndef BITMAP_H #define BITMAP_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include diff --git a/src/trace/potrace/curve.cpp b/src/trace/potrace/curve.cpp index c9a6fbe04..00d7bd2db 100644 --- a/src/trace/potrace/curve.cpp +++ b/src/trace/potrace/curve.cpp @@ -1,8 +1,8 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: curve.c 227 2010-12-16 05:47:19Z selinger $ */ /* private part of the path and curve data structures */ #include diff --git a/src/trace/potrace/curve.h b/src/trace/potrace/curve.h index 45c0790be..bfde0af1a 100644 --- a/src/trace/potrace/curve.h +++ b/src/trace/potrace/curve.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ diff --git a/src/trace/potrace/decompose.cpp b/src/trace/potrace/decompose.cpp index 15c39825e..8219234c4 100644 --- a/src/trace/potrace/decompose.cpp +++ b/src/trace/potrace/decompose.cpp @@ -1,8 +1,8 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: decompose.c 227 2010-12-16 05:47:19Z selinger $ */ #include #include @@ -55,32 +55,6 @@ static void clear_bm_with_bbox(potrace_bitmap_t *bm, bbox_t *bbox) { /* ---------------------------------------------------------------------- */ /* auxiliary functions */ -/* deterministically and efficiently hash (x,y) into a pseudo-random bit */ -static inline int detrand(int x, int y) { - unsigned int z; - static const unsigned char t[256] = { - /* non-linear sequence: constant term of inverse in GF(8), - mod x^8+x^4+x^3+x+1 */ - 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, - 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, - 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, - 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, - 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, - 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, - 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, - 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - }; - - /* 0x04b3e375 and 0x05a8ef93 are chosen to contain every possible - 5-bit sequence */ - z = ((0x04b3e375 * x) ^ y) * 0x05a8ef93; - z = t[z & 0xff] ^ t[(z>>8) & 0xff] ^ t[(z>>16) & 0xff] ^ t[(z>>24) & 0xff]; - return z & 1; -} - /* return the "majority" value of bitmap bm at intersection (x,y). We assume that the bitmap is balanced at "radius" 1. */ static int majority(potrace_bitmap_t *bm, int x, int y) { @@ -304,7 +278,8 @@ static void pathlist_to_tree(path_t *plist, potrace_bitmap_t *bm) { path_t *heap, *heap1; path_t *cur; path_t *head; - path_t **hook, **hook_in, **hook_out; /* for fast appending to linked list */ + path_t **plist_hook; /* for fast appending to linked list */ + path_t **hook_in, **hook_out; /* for fast appending to linked list */ bbox_t bbox; bm_clear(bm, 0); @@ -391,18 +366,18 @@ static void pathlist_to_tree(path_t *plist, potrace_bitmap_t *bm) { heap->next = NULL; /* heap is a linked list of childlists */ } plist = NULL; - hook = &plist; + plist_hook = &plist; while (heap) { heap1 = heap->next; for (p=heap; p; p=p->sibling) { /* p is a positive path */ /* append to linked list */ - list_insert_beforehook(p, hook); + list_insert_beforehook(p, plist_hook); /* go through its children */ for (p1=p->childlist; p1; p1=p1->sibling) { /* append to linked list */ - list_insert_beforehook(p1, hook); + list_insert_beforehook(p1, plist_hook); /* append its childlist to heap, if non-empty */ if (p1->childlist) { list_append(path_t, heap1, p1->childlist); @@ -423,9 +398,12 @@ static void pathlist_to_tree(path_t *plist, potrace_bitmap_t *bm) { static int findnext(potrace_bitmap_t *bm, int *xp, int *yp) { int x; int y; + int x0; + + x0 = (*xp) & ~(BM_WORDBITS-1); for (y=*yp; y>=0; y--) { - for (x=0; xw; x+=BM_WORDBITS) { + for (x=x0; xw; x+=BM_WORDBITS) { if (*bm_index(bm, x, y)) { while (!BM_GET(bm, x, y)) { x++; @@ -436,6 +414,7 @@ static int findnext(potrace_bitmap_t *bm, int *xp, int *yp) { return 0; } } + x0 = 0; } /* not found */ return 1; @@ -451,7 +430,7 @@ int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_pa int y; path_t *p; path_t *plist = NULL; /* linked list of path objects */ - path_t **hook = &plist; /* used to speed up appending to linked list */ + path_t **plist_hook = &plist; /* used to speed up appending to linked list */ potrace_bitmap_t *bm1 = NULL; int sign; @@ -465,6 +444,7 @@ int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_pa bm_clearexcess(bm1); /* iterate through components */ + x = 0; y = bm1->h - 1; while (findnext(bm1, &x, &y) == 0) { /* calculate the sign by looking at the original */ @@ -483,7 +463,7 @@ int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_pa if (p->area <= param->turdsize) { path_free(p); } else { - list_insert_beforehook(p, hook); + list_insert_beforehook(p, plist_hook); } if (bm1->h > 0) { /* to be sure */ diff --git a/src/trace/potrace/decompose.h b/src/trace/potrace/decompose.h index 5552fa0a1..409439c62 100644 --- a/src/trace/potrace/decompose.h +++ b/src/trace/potrace/decompose.h @@ -1,14 +1,15 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: decompose.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef DECOMPOSE_H #define DECOMPOSE_H #include "potracelib.h" #include "progress.h" +#include "curve.h" int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_param_t *param, progress_t *progress); diff --git a/src/trace/potrace/greymap.cpp b/src/trace/potrace/greymap.cpp index 646ecc3a5..770dd72e6 100644 --- a/src/trace/potrace/greymap.cpp +++ b/src/trace/potrace/greymap.cpp @@ -1,14 +1,13 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: greymap.c 227 2010-12-16 05:47:19Z selinger $ */ /* Routines for manipulating greymaps, including reading pgm files. We only deal with greymaps of depth 8 bits. */ #include -#include #include #include @@ -28,7 +27,6 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp); greymap_t *gm_new(int w, int h) { greymap_t *gm; - int errno_save; gm = (greymap_t *) malloc(sizeof(greymap_t)); if (!gm) { @@ -38,9 +36,7 @@ greymap_t *gm_new(int w, int h) { gm->h = h; gm->map = (signed short int *) malloc(w*h*sizeof(signed short int)); if (!gm->map) { - errno_save = errno; free(gm); - errno = errno_save; return NULL; } return gm; @@ -60,7 +56,7 @@ greymap_t *gm_dup(greymap_t *gm) { if (!gm1) { return NULL; } - memcpy(gm1->map, gm->map, gm->w*gm->h*2); + memcpy(gm1->map, gm->map, gm->w*gm->h*sizeof(signed short int)); return gm1; } @@ -69,7 +65,7 @@ void gm_clear(greymap_t *gm, int b) { int i; if (b==0) { - memset(gm->map, 0, gm->w*gm->h*2); + memset(gm->map, 0, gm->w*gm->h*sizeof(signed short int)); } else { for (i=0; iw*gm->h; i++) { gm->map[i] = b; @@ -161,16 +157,16 @@ static int readbit(FILE *f) { /* ---------------------------------------------------------------------- */ -char const *gm_read_error = NULL; - -/** Read a PNM stream: P1-P6 format (see pnm(5)), or a BMP stream, and +/* read a PNM stream: P1-P6 format (see pnm(5)), or a BMP stream, and convert the output to a greymap. Return greymap in *gmp. Return 0 on success, -1 on error with errno set, -2 on bad file format (with error message in gm_read_error), and 1 on premature end of file, -3 on empty file (including files with only whitespace and comments), -4 if wrong magic number. If the return value is >=0, *gmp is - valid. - */ + valid. */ + +char const *gm_read_error = NULL; + int gm_read(FILE *f, greymap_t **gmp) { int magic[2]; @@ -413,6 +409,7 @@ struct bmp_info_s { unsigned int ncolors; /* number of colors in palette */ unsigned int ColorsImportant; unsigned int ctbits; /* sample size for color table */ + int topdown; /* top-down mode? */ }; typedef struct bmp_info_s bmp_info_t; @@ -481,6 +478,9 @@ static int bmp_forward(FILE *f, int pos) { #define TRY(x) if (x) goto try_error #define TRY_EOF(x) if (x) goto eof +/* correct y-coordinate for top-down format */ +#define ycorr(y) (bmpinfo.topdown ? bmpinfo.h-1-y : y) + /* read BMP stream after magic number. Return values as for gm_read. We choose to be as permissive as possible, since there are many programs out there which produce BMP. For instance, ppmtobmp can @@ -512,7 +512,8 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { /* info header */ TRY(bmp_readint(f, 4, &bmpinfo.InfoSize)); - if (bmpinfo.InfoSize == 40 || bmpinfo.InfoSize == 64) { + if (bmpinfo.InfoSize == 40 || bmpinfo.InfoSize == 64 + || bmpinfo.InfoSize == 108 || bmpinfo.InfoSize == 124) { /* Windows or new OS/2 format */ bmpinfo.ctbits = 32; /* sample size in color table */ TRY(bmp_readint(f, 4, &bmpinfo.w)); @@ -525,6 +526,12 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { TRY(bmp_readint(f, 4, &bmpinfo.YpixelsPerM)); TRY(bmp_readint(f, 4, &bmpinfo.ncolors)); TRY(bmp_readint(f, 4, &bmpinfo.ColorsImportant)); + if ((signed int)bmpinfo.h < 0) { + bmpinfo.h = -bmpinfo.h; + bmpinfo.topdown = 1; + } else { + bmpinfo.topdown = 0; + } } else if (bmpinfo.InfoSize == 12) { /* old OS/2 format */ bmpinfo.ctbits = 24; /* sample size in color table */ @@ -534,11 +541,12 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { TRY(bmp_readint(f, 2, &bmpinfo.bits)); bmpinfo.comp = 0; bmpinfo.ncolors = 0; + bmpinfo.topdown = 0; } else { goto format_error; } - /* forward to color table (i.e., if bmpinfo.InfoSize == 64) */ + /* forward to color table (e.g., if bmpinfo.InfoSize == 64) */ TRY(bmp_forward(f, 14+bmpinfo.InfoSize)); if (bmpinfo.Planes != 1) { @@ -593,7 +601,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { for (i=0; 8*i> j) ? coltable[1] : coltable[0]); + GM_PUT(gm, i*8+j, ycorr(y), b & (0x80 >> j) ? coltable[1] : coltable[0]); } } TRY(bmp_pad(f)); @@ -620,7 +628,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { b = bitbuf >> (INTBITS - bmpinfo.bits); bitbuf <<= bmpinfo.bits; n -= bmpinfo.bits; - GM_UPUT(gm, x, y, coltable[b]); + GM_UPUT(gm, x, ycorr(y), coltable[b]); } TRY(bmp_pad(f)); } @@ -640,7 +648,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { for (x=0; x>16) & 0xff) + ((c>>8) & 0xff) + (c & 0xff); - GM_UPUT(gm, x, y, c/3); + GM_UPUT(gm, x, ycorr(y), c/3); } TRY(bmp_pad(f)); } @@ -664,7 +672,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { if (y>=bmpinfo.h) { break; } - GM_UPUT(gm, x, y, col[i&1]); + GM_UPUT(gm, x, ycorr(y), col[i&1]); x++; } } else if (c == 0) { @@ -693,7 +701,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { if (y>=bmpinfo.h) { break; } - GM_PUT(gm, x, y, coltable[(b>>(4-4*(i&1))) & 0xf]); + GM_PUT(gm, x, ycorr(y), coltable[(b>>(4-4*(i&1))) & 0xf]); x++; } if ((c+1) & 2) { @@ -720,7 +728,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { if (y>=bmpinfo.h) { break; } - GM_UPUT(gm, x, y, coltable[c]); + GM_UPUT(gm, x, ycorr(y), coltable[c]); x++; } } else if (c == 0) { @@ -747,7 +755,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { if (y>=bmpinfo.h) { break; } - GM_PUT(gm, x, y, coltable[b]); + GM_PUT(gm, x, ycorr(y), coltable[b]); x++; } if (c & 1) { diff --git a/src/trace/potrace/greymap.h b/src/trace/potrace/greymap.h index 059fec4e4..0736232a7 100644 --- a/src/trace/potrace/greymap.h +++ b/src/trace/potrace/greymap.h @@ -1,11 +1,11 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: greymap.h 227 2010-12-16 05:47:19Z selinger $ */ -#ifndef PGM_H -#define PGM_H +#ifndef GREYMAP_H +#define GREYMAP_H #include @@ -55,4 +55,4 @@ int gm_read(FILE *f, greymap_t **gmp); int gm_writepgm(FILE *f, greymap_t *gm, char *comment, int raw, int mode, double gamma); int gm_print(FILE *f, greymap_t *gm); -#endif /* PGM_H */ +#endif /* GREYMAP_H */ diff --git a/src/trace/potrace/lists.h b/src/trace/potrace/lists.h index fc853398a..4f78bf20f 100644 --- a/src/trace/potrace/lists.h +++ b/src/trace/potrace/lists.h @@ -1,8 +1,8 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: lists.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef _PS_LISTS_H #define _PS_LISTS_H diff --git a/src/trace/potrace/potracelib.cpp b/src/trace/potrace/potracelib.cpp index 17e04cabb..3dbf3230b 100644 --- a/src/trace/potrace/potracelib.cpp +++ b/src/trace/potrace/potracelib.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ @@ -48,15 +48,16 @@ potrace_param_t *potrace_param_default(void) { /* On success, returns a Potrace state st with st->status == POTRACE_STATUS_OK. On failure, returns NULL if no Potrace state could be created (with errno set), or returns an incomplete Potrace - state (with st->status == POTRACE_STATUS_INCOMPLETE). Complete or - incomplete Potrace state can be freed with potrace_state_free(). */ + state (with st->status == POTRACE_STATUS_INCOMPLETE, and with errno + set). Complete or incomplete Potrace state can be freed with + potrace_state_free(). */ potrace_state_t *potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm) { int r; path_t *plist = NULL; potrace_state_t *st; progress_t prog; progress_t subprog; - + /* prepare private progress bar state */ prog.callback = param->progress.callback; prog.data = param->progress.data; diff --git a/src/trace/potrace/potracelib.h b/src/trace/potrace/potracelib.h index 0b93d65de..d15b05e5c 100644 --- a/src/trace/potrace/potracelib.h +++ b/src/trace/potrace/potracelib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ @@ -6,7 +6,11 @@ #define POTRACELIB_H /* this file defines the API for the core Potrace library. For a more - detailed description of the API, see doc/potracelib.txt */ + detailed description of the API, see potracelib.pdf */ + +#ifdef __cplusplus +extern "C" { +#endif /* ---------------------------------------------------------------------- */ /* tracing parameters */ @@ -128,4 +132,8 @@ void potrace_state_free(potrace_state_t *st); of potracelib */ char *potrace_version(void); +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + #endif /* POTRACELIB_H */ diff --git a/src/trace/potrace/progress.h b/src/trace/potrace/progress.h index 0e077430d..220639c6e 100644 --- a/src/trace/potrace/progress.h +++ b/src/trace/potrace/progress.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ @@ -28,7 +28,7 @@ typedef struct progress_s progress_t; static inline void progress_update(double d, progress_t *prog) { double d_scaled; - if (prog->callback != NULL) { + if (prog != NULL && prog->callback != NULL) { d_scaled = prog->min * (1-d) + prog->max * d; if (d == 1.0 || d_scaled >= prog->d_prev + prog->epsilon) { prog->callback(prog->min * (1-d) + prog->max * d, prog->data); @@ -43,7 +43,7 @@ static inline void progress_update(double d, progress_t *prog) { static inline void progress_subrange_start(double a, double b, const progress_t *prog, progress_t *sub) { double min, max; - if (prog->callback == NULL) { + if (prog == NULL || prog->callback == NULL) { sub->callback = NULL; return; } @@ -66,7 +66,7 @@ static inline void progress_subrange_start(double a, double b, const progress_t } static inline void progress_subrange_end(progress_t *prog, progress_t *sub) { - if (prog->callback != NULL) { + if (prog != NULL && prog->callback != NULL) { if (sub->callback == NULL) { progress_update(sub->b, prog); } else { diff --git a/src/trace/potrace/render.cpp b/src/trace/potrace/render.cpp index f9183b931..39bec0684 100644 --- a/src/trace/potrace/render.cpp +++ b/src/trace/potrace/render.cpp @@ -1,8 +1,8 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: render.c 227 2010-12-16 05:47:19Z selinger $ */ #include #include diff --git a/src/trace/potrace/render.h b/src/trace/potrace/render.h index 9c9d921d2..6cfbe0964 100644 --- a/src/trace/potrace/render.h +++ b/src/trace/potrace/render.h @@ -1,8 +1,8 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: render.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef RENDER_H #define RENDER_H diff --git a/src/trace/potrace/trace.cpp b/src/trace/potrace/trace.cpp index 909ffb712..8fe1a1bc4 100644 --- a/src/trace/potrace/trace.cpp +++ b/src/trace/potrace/trace.cpp @@ -1,8 +1,8 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: trace.c 227 2010-12-16 05:47:19Z selinger $ */ /* transform jaggy paths into smooth curves */ #include @@ -483,28 +483,38 @@ static double penalty3(privpath_t *pp, int i, int j) { double a, b, c, s; double px, py, ex, ey; - int r=0; /* rotations from i to j */ + int r = 0; /* rotations from i to j */ if (j>=n) { - j-=n; - r+=1; + j -= n; + r = 1; } - x = sums[j+1].x-sums[i].x+r*sums[n].x; - y = sums[j+1].y-sums[i].y+r*sums[n].y; - x2 = sums[j+1].x2-sums[i].x2+r*sums[n].x2; - xy = sums[j+1].xy-sums[i].xy+r*sums[n].xy; - y2 = sums[j+1].y2-sums[i].y2+r*sums[n].y2; - k = j+1-i+r*n; - - px = (pt[i].x+pt[j].x)/2.0-pt[0].x; - py = (pt[i].y+pt[j].y)/2.0-pt[0].y; - ey = (pt[j].x-pt[i].x); - ex = -(pt[j].y-pt[i].y); - - a = ((x2-2*x*px)/k+px*px); - b = ((xy-x*py-y*px)/k+px*py); - c = ((y2-2*y*py)/k+py*py); + /* critical inner loop: the "if" gives a 4.6 percent speedup */ + if (r == 0) { + x = sums[j+1].x - sums[i].x; + y = sums[j+1].y - sums[i].y; + x2 = sums[j+1].x2 - sums[i].x2; + xy = sums[j+1].xy - sums[i].xy; + y2 = sums[j+1].y2 - sums[i].y2; + k = j+1 - i; + } else { + x = sums[j+1].x - sums[i].x + sums[n].x; + y = sums[j+1].y - sums[i].y + sums[n].y; + x2 = sums[j+1].x2 - sums[i].x2 + sums[n].x2; + xy = sums[j+1].xy - sums[i].xy + sums[n].xy; + y2 = sums[j+1].y2 - sums[i].y2 + sums[n].y2; + k = j+1 - i + n; + } + + px = (pt[i].x + pt[j].x) / 2.0 - pt[0].x; + py = (pt[i].y + pt[j].y) / 2.0 - pt[0].y; + ey = (pt[j].x - pt[i].x); + ex = -(pt[j].y - pt[i].y); + + a = ((x2 - 2*x*px) / k + px*px); + b = ((xy - x*py - y*px) / k + px*py); + c = ((y2 - 2*y*py) / k + py*py); s = ex*ex*a + 2*ex*ey*b + ey*ey*c; @@ -513,7 +523,7 @@ static double penalty3(privpath_t *pp, int i, int j) { /* find the optimal polygon. Fill in the m and po components. Return 1 on failure with errno set, else 0. Non-cyclic version: assumes i=0 - is in the polygon. Fixme: ### implement cyclic version. */ + is in the polygon. Fixme: implement cyclic version. */ static int bestpolygon(privpath_t *pp) { int i, j, m, k; @@ -576,7 +586,7 @@ static int bestpolygon(privpath_t *pp) seg1[0] = 0; /* now find the shortest path with m segments, based on penalty3 */ - /* note: the outer 2 loops jointly have at most n interations, thus + /* note: the outer 2 loops jointly have at most n iterations, thus the worst-case behavior here is quadratic. In practice, it is close to linear since the inner loop tends to be short. */ pen[0]=0; @@ -828,24 +838,27 @@ static int adjust_vertices(privpath_t *pp) { /* ---------------------------------------------------------------------- */ /* Stage 4: smoothing and corner analysis (Sec. 2.3.3) */ -/* Always succeeds and returns 0 */ -static int smooth(privcurve_t *curve, int sign, double alphamax) { +/* reverse orientation of a path */ +static void reverse(privcurve_t *curve) { + int m = curve->n; + int i, j; + dpoint_t tmp; + + for (i=0, j=m-1; ivertex[i]; + curve->vertex[i] = curve->vertex[j]; + curve->vertex[j] = tmp; + } +} + +/* Always succeeds */ +static void smooth(privcurve_t *curve, double alphamax) { int m = curve->n; int i, j, k; double dd, denom, alpha; dpoint_t p2, p3, p4; - if (sign == '-') { - /* reverse orientation of negative paths */ - for (i=0, j=m-1; ivertex[i]; - curve->vertex[i] = curve->vertex[j]; - curve->vertex[j] = tmp; - } - } - /* examine each vertex and find its best fit */ for (i=0; ialphacurve = 1; - return 0; + return; } /* ---------------------------------------------------------------------- */ @@ -1098,7 +1111,7 @@ static int opticurve(privpath_t *pp, double opttolerance) { len[0] = 0; /* Fixme: we always start from a fixed point -- should find the best - curve cyclically ### */ + curve cyclically */ for (j=1; j<=m; j++) { /* calculate best path from 0 to j */ @@ -1206,7 +1219,10 @@ int process_path(path_t *plist, const potrace_param_t *param, progress_t *progre TRY(calc_lon(p->priv)); TRY(bestpolygon(p->priv)); TRY(adjust_vertices(p->priv)); - TRY(smooth(&p->priv->curve, p->sign, param->alphamax)); + if (p->sign == '-') { /* reverse orientation of negative paths */ + reverse(&p->priv->curve); + } + smooth(&p->priv->curve, param->alphamax); if (param->opticurve) { TRY(opticurve(p->priv, param->opttolerance)); p->priv->fcurve = &p->priv->ocurve; diff --git a/src/trace/potrace/trace.h b/src/trace/potrace/trace.h index b33f8ba4d..72d1a3696 100644 --- a/src/trace/potrace/trace.h +++ b/src/trace/potrace/trace.h @@ -1,14 +1,15 @@ -/* Copyright (C) 2001-2007 Peter Selinger. +/* Copyright (C) 2001-2010 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id$ */ +/* $Id: trace.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef TRACE_H #define TRACE_H #include "potracelib.h" #include "progress.h" +#include "curve.h" int process_path(path_t *plist, const potrace_param_t *param, progress_t *progress); -- cgit v1.2.3 From fb49f01264d072beec29a8f40b0e52d9c04f47ce Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 14 Apr 2011 22:51:50 +0200 Subject: small tweaks (bzr r10164) --- src/util/expression-evaluator.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/util/expression-evaluator.cpp b/src/util/expression-evaluator.cpp index b43a61a6d..87937be9a 100644 --- a/src/util/expression-evaluator.cpp +++ b/src/util/expression-evaluator.cpp @@ -69,8 +69,6 @@ #include -#include - namespace Inkscape { namespace Util { @@ -82,7 +80,7 @@ enum GIMP_EEVL_TOKEN_ANY = 40000, GIMP_EEVL_TOKEN_END = 50000 -} GimpEevlTokenTypeEnum; +}; typedef int GimpEevlTokenType; -- cgit v1.2.3 From 91d5bb754933ec128238a3a570d59e4d74c5c349 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 15 Apr 2011 01:02:53 +0200 Subject: ScalarUnit: add functionality to grab focus and select the entry text. and add setValueKeepUnit (bzr r10165) --- src/ui/widget/scalar-unit.cpp | 22 ++++++++++++++++++++++ src/ui/widget/scalar-unit.h | 3 +++ 2 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index e00e82198..533f0a200 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -118,6 +118,19 @@ ScalarUnit::setValue(double number, Glib::ustring const &units) { Scalar::setValue(number); } +/** Convert and sets the number only and keeps the current unit. */ +void +ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) { + g_assert(_unit_menu != NULL); + if (units == "") { + // set the value in the default units + Scalar::setValue(number); + } else { + double conversion = _unit_menu->getConversion(units); + Scalar::setValue(number / conversion); + } +} + /** Sets the number only */ void ScalarUnit::setValue(double number) { @@ -137,6 +150,15 @@ ScalarUnit::getValue(Glib::ustring const &unit_name) const { } } +/** Grab focus, and select the text that is in the entry field. + */ +void +ScalarUnit::grabFocusAndSelectEntry() { + _widget->grab_focus(); + static_cast(_widget)->select_region(0, 20); +} + + void ScalarUnit::setHundredPercent(double number) { diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index d8b2edbd5..8f6c8e210 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -41,8 +41,11 @@ public: bool setUnit(Glib::ustring const &units); void setValue(double number, Glib::ustring const &units); + void setValueKeepUnit(double number, Glib::ustring const &units); void setValue(double number); + void grabFocusAndSelectEntry(); + void setHundredPercent(double number); void setAbsoluteIsIncrement(bool value); void setPercentageIsIncrement(bool value); -- cgit v1.2.3 From 384adc13f591fc200e9be292ced829ef8734cba0 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 15 Apr 2011 01:03:50 +0200 Subject: convert guideline dialog to ui/widget/... newer widgets. add unit to guideline angle. save angle unit status when closing dialog (bzr r10166) --- src/ui/dialog/guides.cpp | 119 +++++++++++++++++++++-------------------------- src/ui/dialog/guides.h | 26 ++++++----- 2 files changed, 68 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index fd64a713f..60038cab0 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -15,9 +15,9 @@ #ifdef HAVE_CONFIG_H # include #endif +#include "guides.h" + #include "display/guideline.h" -#include "helper/unit-menu.h" -#include "helper/units.h" #include "desktop.h" #include "document.h" #include "sp-guide.h" @@ -25,14 +25,13 @@ #include "desktop-handles.h" #include "event-context.h" #include "widgets/desktop-widget.h" -#include "sp-metrics.h" #include #include "dialogs/dialog-events.h" #include "message-context.h" #include "xml/repr.h" + #include <2geom/point.h> #include <2geom/angle.h> -#include "guides.h" namespace Inkscape { namespace UI { @@ -40,21 +39,21 @@ namespace Dialogs { GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop) : _desktop(desktop), _guide(guide), - _label_units(_("Unit:")), - _label_X(_("X:")), - _label_Y(_("Y:")), - _label_degrees(_("Angle (degrees):")), _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), - _adjustment_x(0.0, -1e6, 1e6, 1.0, 10.0, 0), - _adjustment_y(0.0, -1e6, 1e6, 1.0, 10.0, 0), - _adj_angle(0.0, -360, 360, 1.0, 10.0, 0), - _unit_selector(NULL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) + _spin_button_x(_("X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _spin_button_y(_("Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _spin_angle(_("Angle:"), "", UNIT_TYPE_RADIAL), + _mode(true), _oldpos(0.,0.), _oldangle(0.0) { } bool GuidelinePropertiesDialog::_relative_toggle_status = false; // initialize relative checkbox status for when this dialog is opened for first time +Glib::ustring GuidelinePropertiesDialog::_angle_unit_status = "deg"; // initialize angle unit status GuidelinePropertiesDialog::~GuidelinePropertiesDialog() { + // save current status + _relative_toggle_status = _relative_toggle.get_active(); + _angle_unit_status = _spin_angle.getUnit().abbr; } void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { @@ -66,28 +65,24 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); - _relative_toggle_status = _relative_toggle.get_active(); if (!_mode) { // relative - _spin_angle.set_value(0); + _spin_angle.setValue(0); - _spin_button_y.set_value(0); - _spin_button_x.set_value(0); + _spin_button_y.setValue(0); + _spin_button_x.setValue(0); } else { // absolute - _spin_angle.set_value(_oldangle); + _spin_angle.setValueKeepUnit(_oldangle, "deg"); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); - gdouble const val_y = sp_pixels_get_units(_oldpos[Geom::Y], unit); - _spin_button_y.set_value(val_y); - gdouble const val_x = sp_pixels_get_units(_oldpos[Geom::X], unit); - _spin_button_x.set_value(val_x); + _spin_button_x.setValueKeepUnit(_oldpos[Geom::X], "px"); + _spin_button_y.setValueKeepUnit(_oldpos[Geom::Y], "px"); } } void GuidelinePropertiesDialog::_onApply() { - double deg_angle = _spin_angle.get_value(); + double deg_angle = _spin_angle.getValue("deg"); if (!_mode) deg_angle += _oldangle; Geom::Point normal; @@ -101,11 +96,8 @@ void GuidelinePropertiesDialog::_onApply() } sp_guide_set_normal(*_guide, normal, true); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); - gdouble const raw_dist_x = _spin_button_x.get_value(); - gdouble const points_x = sp_units_get_pixels(raw_dist_x, unit); - gdouble const raw_dist_y = _spin_button_y.get_value(); - gdouble const points_y = sp_units_get_pixels(raw_dist_y, unit); + double const points_x = _spin_button_x.getValue("px"); + double const points_y = _spin_button_y.getValue("px"); Geom::Point newpos(points_x, points_y); if (!_mode) newpos += _oldpos; @@ -178,51 +170,49 @@ void GuidelinePropertiesDialog::_setup() { _layout_table.attach(*manage(new Gtk::Label(" ")), 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); - // mode radio button - _layout_table.attach(_relative_toggle, - 1, 3, 9, 10, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); - _relative_toggle.set_active(_relative_toggle_status); - - // unitmenu + // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ - GtkWidget *unit_selector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unit_selector), _desktop->namedview->doc_units); - _unit_selector = Gtk::manage(Glib::wrap(unit_selector)); + _unit_menu.setUnitType(UNIT_TYPE_LINEAR); + _unit_menu.setUnit("px"); + if (_desktop->namedview->doc_units) { + _unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); + } + _spin_angle.setUnit(_angle_unit_status); // position spinbuttons - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj())); - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj())); - _spin_button_x.configure(_adjustment_x, 1.0 , 3); - _spin_button_y.configure(_adjustment_y, 1.0 , 3); - _layout_table.attach(_label_X, - 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _spin_button_x.setDigits(3); + _spin_button_x.setIncrements(1.0, 10.0); + _spin_button_x.setRange(-1e6, 1e6); + _spin_button_y.setDigits(3); + _spin_button_y.setIncrements(1.0, 10.0); + _spin_button_y.setRange(-1e6, 1e6); _layout_table.attach(_spin_button_x, - 2, 3, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_label_Y, - 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_y, - 2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_label_units, - 1, 2, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(*_unit_selector, - 2, 3, 6, 7, Gtk::FILL, Gtk::FILL); + _layout_table.attach(_unit_menu, + 2, 3, 4, 5, Gtk::FILL, Gtk::FILL); // angle spinbutton - _spin_angle.configure(_adj_angle, 5.0 , 3); - _spin_angle.show(); - _layout_table.attach(_label_degrees, - 1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _spin_angle.setDigits(3); + _spin_angle.setIncrements(1.0, 10.0); + _spin_angle.setRange(-3600., 3600.); _layout_table.attach(_spin_angle, - 2, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + + // mode radio button + _layout_table.attach(_relative_toggle, + 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); + _relative_toggle.set_active(_relative_toggle_status); // don't know what this exactly does, but it results in that the dialog closes when entering a value and pressing enter (see LP bug 484187) - gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.gobj()), "activate", + gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.getWidget()->gobj()), "activate", GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); - gtk_signal_connect_object(GTK_OBJECT(_spin_button_y.gobj()), "activate", + gtk_signal_connect_object(GTK_OBJECT(_spin_button_y.getWidget()->gobj()), "activate", GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); - gtk_signal_connect_object(GTK_OBJECT(_spin_angle.gobj()), "activate", + gtk_signal_connect_object(GTK_OBJECT(_spin_angle.getWidget()->gobj()), "activate", GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); @@ -258,14 +248,11 @@ void GuidelinePropertiesDialog::_setup() { _modeChanged(); // sets values of spinboxes. if ( _oldangle == 90. || _oldangle == 270. || _oldangle == -90. || _oldangle == -270.) { - _spin_button_x.grab_focus(); - _spin_button_x.select_region(0, 20); + _spin_button_x.grabFocusAndSelectEntry(); } else if ( _oldangle == 0. || _oldangle == 180. || _oldangle == -180.) { - _spin_button_y.grab_focus(); - _spin_button_y.select_region(0, 20); + _spin_button_y.grabFocusAndSelectEntry(); } else { - _spin_angle.grab_focus(); - _spin_angle.select_region(0, 20); + _spin_angle.grabFocusAndSelectEntry(); } set_position(Gtk::WIN_POS_MOUSE); diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 8485c78a7..f015c49ff 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -22,10 +22,20 @@ #include #include "ui/widget/button.h" #include "ui/widget/spinbutton.h" +#include "ui/widget/unit-menu.h" +#include "ui/widget/scalar-unit.h" #include <2geom/point.h> +class SPGuide; +class SPDesktop; + namespace Inkscape { namespace UI { + +namespace Widget { + class UnitMenu; +}; + namespace Dialogs { class GuidelinePropertiesDialog : public Gtk::Dialog { @@ -56,21 +66,15 @@ private: Gtk::Table _layout_table; Gtk::Label _label_name; Gtk::Label _label_descr; - Gtk::Label _label_units; - Gtk::Label _label_X; - Gtk::Label _label_Y; - Gtk::Label _label_degrees; Inkscape::UI::Widget::CheckButton _relative_toggle; static bool _relative_toggle_status; // remember the status of the _relative_toggle_status button across instances - Gtk::Adjustment _adjustment_x; - Inkscape::UI::Widget::SpinButton _spin_button_x; - Gtk::Adjustment _adjustment_y; - Inkscape::UI::Widget::SpinButton _spin_button_y; + Inkscape::UI::Widget::UnitMenu _unit_menu; + Inkscape::UI::Widget::ScalarUnit _spin_button_x; + Inkscape::UI::Widget::ScalarUnit _spin_button_y; - Gtk::Adjustment _adj_angle; - Inkscape::UI::Widget::SpinButton _spin_angle; + Inkscape::UI::Widget::ScalarUnit _spin_angle; + static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances - Gtk::Widget *_unit_selector; bool _mode; Geom::Point _oldpos; gdouble _oldangle; -- cgit v1.2.3 From c260fcd615791615b33f55459dabe38e64ee3471 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Fri, 15 Apr 2011 09:17:08 +0200 Subject: No more PrintWin32, including no special cases for non-Unicode Windows anymore. (bzr r9508.1.82) --- src/extension/extension.h | 9 - src/extension/init.cpp | 2 - src/extension/internal/emf-win32-inout.cpp | 40 +-- src/extension/internal/emf-win32-print.cpp | 118 ++----- src/extension/internal/emf-win32-print.h | 3 + src/extension/internal/win32.cpp | 510 ----------------------------- src/extension/internal/win32.h | 96 ------ src/file.cpp | 14 - src/file.h | 5 - src/inkscape.cpp | 14 +- src/io/sys.cpp | 6 - src/io/uristream.cpp | 17 +- src/main.cpp | 6 +- src/print.cpp | 37 --- src/print.h | 1 - src/verbs.cpp | 5 - src/verbs.h | 1 - 17 files changed, 51 insertions(+), 833 deletions(-) delete mode 100644 src/extension/internal/win32.cpp delete mode 100644 src/extension/internal/win32.h (limited to 'src') diff --git a/src/extension/extension.h b/src/extension/extension.h index 936d2a907..63981522e 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -51,15 +51,6 @@ #define SP_MODULE_KEY_PRINT_LATEX "org.inkscape.print.latex" /** Defines the key for printing with GNOME Print */ #define SP_MODULE_KEY_PRINT_GNOME "org.inkscape.print.gnome" -/** Defines the key for printing under Win32 */ -#define SP_MODULE_KEY_PRINT_WIN32 "org.inkscape.print.win32" -#ifdef WIN32 -/** Defines the default printing to use */ -#define SP_MODULE_KEY_PRINT_DEFAULT SP_MODULE_KEY_PRINT_WIN32 -#else -/** Defines the default printing to use */ -#define SP_MODULE_KEY_PRINT_DEFAULT SP_MODULE_KEY_PRINT_PS -#endif /** Mime type for SVG */ #define MIME_SVG "image/svg+xml" diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 230d4b50f..355922bc5 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -26,7 +26,6 @@ #include "db.h" #include "internal/svgz.h" #ifdef WIN32 -# include "internal/win32.h" # include "internal/emf-win32-inout.h" # include "internal/emf-win32-print.h" #endif @@ -171,7 +170,6 @@ init() } #endif #ifdef WIN32 - Internal::PrintWin32::init(); Internal::PrintEmfWin32::init(); Internal::EmfWin32::init(); #endif diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 979be1b63..2716faee2 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -42,7 +42,6 @@ #define WIN32_LEAN_AND_MEAN #include -#include "win32.h" #include "emf-win32-print.h" #include "emf-win32-inout.h" @@ -2262,12 +2261,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) HMETAFILE hmf; HENHMETAFILE hemf; - if (PrintWin32::is_os_wide()) { - fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - } - else { - fp = CreateFileA(ansi_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - } + fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if ( fp != INVALID_HANDLE_VALUE ) { filesize = GetFileSize(fp, NULL); @@ -2275,36 +2269,21 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) } // Try open as Enhanced Metafile - if (PrintWin32::is_os_wide()) - hemf = GetEnhMetaFileW(unicode_uri); - else - hemf = GetEnhMetaFileA(ansi_uri); + hemf = GetEnhMetaFileW(unicode_uri); if (!hemf) { // Try open as Windows Metafile - if (PrintWin32::is_os_wide()) - hmf = GetMetaFileW(unicode_uri); - else - hmf = GetMetaFileA(ansi_uri); + hmf = GetMetaFileW(unicode_uri); METAFILEPICT mp; HDC hDC; if (!hmf) { - if (PrintWin32::is_os_wide()) { - WCHAR szTemp[MAX_PATH]; + WCHAR szTemp[MAX_PATH]; - DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH ); - if (dw) { - hmf = GetMetaFileW( szTemp ); - } - } else { - CHAR szTemp[MAX_PATH]; - - DWORD dw = GetShortPathNameA( ansi_uri, szTemp, MAX_PATH ); - if (dw) { - hmf = GetMetaFileA( szTemp ); - } + DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH ); + if (dw) { + hmf = GetMetaFileW( szTemp ); } } @@ -2351,10 +2330,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) else { // Try open as Aldus Placeable Metafile HANDLE hFile; - if (PrintWin32::is_os_wide()) - hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - else - hFile = CreateFileA( ansi_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if (hFile != INVALID_HANDLE_VALUE) { DWORD nSize = GetFileSize( hFile, NULL ); diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 503a13d09..eb6abeaca 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -57,10 +57,6 @@ //#include "libnrtype/font-instance.h" //#include "libnrtype/font-style-to-pos.h" -#define WIN32_LEAN_AND_MEAN -#include - -#include "win32.h" #include "emf-win32-print.h" #include "unit-constants.h" @@ -186,15 +182,12 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) snprintf(buff+len+1, sizeof(buff)-len-2, "%s", p); // Create the Metafile - if (PrintWin32::is_os_wide()) { + { WCHAR wbuff[1024]; ZeroMemory(wbuff, sizeof(wbuff)); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buff, sizeof(buff)/sizeof(buff[0]), wbuff, sizeof(wbuff)/sizeof(wbuff[0])); hdc = CreateEnhMetaFileW( hScreenDC, unicode_uri, &rc, wbuff ); } - else { - hdc = CreateEnhMetaFileA( hScreenDC, ansi_uri, &rc, buff ); - } // Release the reference DC ReleaseDC( NULL, hScreenDC ); @@ -879,76 +872,40 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom #endif if (!hfont) { - if (PrintWin32::is_os_wide()) { - LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); - g_assert(lf != NULL); - - lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI; - lf->lfWidth = 0; - lf->lfEscapement = rot; - lf->lfOrientation = rot; - lf->lfWeight = - style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY : - FW_NORMAL; - lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC); - lf->lfUnderline = style->text_decoration.underline; - lf->lfStrikeOut = style->text_decoration.line_through; - lf->lfCharSet = DEFAULT_CHARSET; - lf->lfOutPrecision = OUT_DEFAULT_PRECIS; - lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf->lfQuality = DEFAULT_QUALITY; - lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - - gunichar2 *unicode_name = g_utf8_to_utf16( style->text->font_family.value, -1, NULL, NULL, NULL ); - wcsncpy(lf->lfFaceName, (wchar_t*) unicode_name, LF_FACESIZE-1); - g_free(unicode_name); - - hfont = CreateFontIndirectW(lf); - - g_free(lf); - } - else { - LOGFONTA *lf = (LOGFONTA*)g_malloc(sizeof(LOGFONTA)); - g_assert(lf != NULL); - - lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI; - lf->lfWidth = 0; - lf->lfEscapement = rot; - lf->lfOrientation = rot; - lf->lfWeight = - style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD : - style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY : - FW_NORMAL; - lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC); - lf->lfUnderline = style->text_decoration.underline; - lf->lfStrikeOut = style->text_decoration.line_through; - lf->lfCharSet = DEFAULT_CHARSET; - lf->lfOutPrecision = OUT_DEFAULT_PRECIS; - lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf->lfQuality = DEFAULT_QUALITY; - lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - - strncpy(lf->lfFaceName, (char*) style->text->font_family.value, LF_FACESIZE-1); - - hfont = CreateFontIndirectA(lf); - - g_free(lf); - } + LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); + g_assert(lf != NULL); + + lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI; + lf->lfWidth = 0; + lf->lfEscapement = rot; + lf->lfOrientation = rot; + lf->lfWeight = + style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD : + style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY : + FW_NORMAL; + lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC); + lf->lfUnderline = style->text_decoration.underline; + lf->lfStrikeOut = style->text_decoration.line_through; + lf->lfCharSet = DEFAULT_CHARSET; + lf->lfOutPrecision = OUT_DEFAULT_PRECIS; + lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf->lfQuality = DEFAULT_QUALITY; + lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + + gunichar2 *unicode_name = g_utf8_to_utf16( style->text->font_family.value, -1, NULL, NULL, NULL ); + wcsncpy(lf->lfFaceName, (wchar_t*) unicode_name, LF_FACESIZE-1); + g_free(unicode_name); + + hfont = CreateFontIndirectW(lf); + + g_free(lf); } HFONT hfontOld = (HFONT) SelectObject(hdc, hfont); @@ -973,13 +930,10 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom LONG const xpos = (LONG) round(p[Geom::X]); LONG const ypos = (LONG) round(rc.bottom-p[Geom::Y]); - if (PrintWin32::is_os_wide()) { + { gunichar2 *unicode_text = g_utf8_to_utf16( text, -1, NULL, NULL, NULL ); TextOutW(hdc, xpos, ypos, (WCHAR*)unicode_text, wcslen((wchar_t*)unicode_text)); } - else { - TextOutA(hdc, xpos, ypos, (CHAR*)text, strlen((char*)text)); - } SelectObject(hdc, hfontOld); DeleteObject(hfont); diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index a9f639bcd..44327d35e 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -17,6 +17,9 @@ # include "config.h" #endif +#define WIN32_LEAN_AND_MEAN +#include + #include "extension/implementation/implementation.h" //#include "extension/extension.h" diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp deleted file mode 100644 index 537c91a2c..000000000 --- a/src/extension/internal/win32.cpp +++ /dev/null @@ -1,510 +0,0 @@ -/** @file - * @brief Windows-specific stuff - */ -/* Author: - * Lauris Kaplinski - * Abhishek Sharma - * - * This code is in public domain - */ - -#ifdef WIN32 - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include <2geom/transforms.h> - -#include "display/nr-arena-item.h" -#include "display/nr-arena.h" -#include "document.h" - -#include "win32.h" -#include "extension/system.h" -#include "extension/print.h" -#include - -/* Initialization */ - -namespace Inkscape { -namespace Extension { -namespace Internal { - -static unsigned int SPWin32Modal = FALSE; - -/** - * Callback function.. not a method - */ -static void -my_gdk_event_handler (GdkEvent *event) -{ - if (SPWin32Modal) { - /* Win32 widget is modal, filter events */ - switch (event->type) { - case GDK_NOTHING: - case GDK_DELETE: - case GDK_SCROLL: - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - case GDK_DRAG_STATUS: - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - return; - break; - default: - break; - } - } - gtk_main_do_event (event); -} - -void -PrintWin32::main_init (int argc, char **argv, const char *name) -{ - gdk_event_handler_set ((GdkEventFunc) my_gdk_event_handler, NULL, NULL); -} - -void -PrintWin32::finish (void) -{ -} - -#define SP_FOREIGN_MAX_ITER 10 - - -/** - * Callback function.. not a method - */ -static VOID CALLBACK -my_timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) -{ - int cdown = 0; - while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { - gtk_main_iteration_do (FALSE); - } - gtk_main_iteration_do (FALSE); -} - - -/* Platform detection */ - -gboolean -PrintWin32::is_os_wide() -{ - static gboolean initialized = FALSE; - static gboolean is_wide = FALSE; - static OSVERSIONINFOA osver; - - if ( !initialized ) - { - BOOL result; - - initialized = TRUE; - - memset (&osver, 0, sizeof(OSVERSIONINFOA)); - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - result = GetVersionExA (&osver); - if (result) - { - if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) - is_wide = TRUE; - } - // If we can't even call to get the version, fall back to ANSI API - } - - return is_wide; -} - - -/* Printing */ - -PrintWin32::PrintWin32 (void) -{ - /* Nothing here */ -} - - -PrintWin32::~PrintWin32 (void) -{ - DeleteDC (_hDC); -} - - -/** - * Callback function.. not a method - */ -static UINT_PTR CALLBACK -print_hook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ -#if 0 - int cdown = 0; - while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) { - gtk_main_iteration_do (FALSE); - } - gtk_main_iteration_do (FALSE); -#endif - return 0; -} - -unsigned int -PrintWin32::setup (Inkscape::Extension::Print *mod) -{ - HRESULT res; - PRINTDLG pd = { - sizeof (PRINTDLG), - NULL, /* hwndOwner */ - NULL, /* hDevMode */ - NULL, /* hDevNames */ - NULL, /* hDC */ - PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */ - 1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */ - 1, /* nCoies */ - NULL, /* hInstance */ - 0, /* lCustData */ - NULL, NULL, NULL, NULL, NULL, NULL - }; - UINT_PTR timer; - - SPWin32Modal = TRUE; - pd.Flags |= PD_ENABLEPRINTHOOK; - pd.lpfnPrintHook = print_hook; - timer = SetTimer (NULL, 0, 40, my_timer); - - res = PrintDlg (&pd); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!res) return FALSE; - - _hDC = pd.hDC; - -#if 0 - caps = GetDeviceCaps (_hDC, RASTERCAPS); - if (caps & RC_BANDING) { - printf ("needs banding\n"); - } - if (caps & RC_BITBLT) { - printf ("does bitblt\n"); - } - if (caps & RC_DIBTODEV) { - printf ("does dibtodev\n"); - } - if (caps & RC_STRETCHDIB) { - printf ("does stretchdib\n"); - } -#endif - if (pd.hDevMode) { - DEVMODE *devmodep; - devmodep = (DEVMODE *)pd.hDevMode; - if (devmodep->dmFields & DM_ORIENTATION) { - _landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE); - } - } - - return TRUE; -} - -unsigned int -PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) -{ - DOCINFO di = { - sizeof (DOCINFO), - NULL, /* lpszDocName */ - NULL, /* lpszOutput */ - NULL, /* lpszDatatype */ - 0 /* DI_APPBANDING */ /* fwType */ - }; - int res; - - _PageWidth = doc->getWidth (); - _PageHeight = doc->getHeight (); - - di.lpszDocName = doc->getName(); - - SPWin32Modal = TRUE; - - res = StartDoc (_hDC, &di); - res = StartPage (_hDC); - - SPWin32Modal = FALSE; - - return 0; -} - -unsigned int -PrintWin32::finish (Inkscape::Extension::Print *mod) -{ - int dpiX, dpiY; - int pPhysicalWidth, pPhysicalHeight; - int pPhysicalOffsetX, pPhysicalOffsetY; - int pPrintableWidth, pPrintableHeight; - float scalex, scaley; - int x0, y0, x1, y1; - int width, height; - unsigned char *px; - int sheight, row; - BITMAPINFO bmInfo = { - { - sizeof (BITMAPINFOHEADER), // bV4Size - 64, // biWidth - 64, // biHeight - 1, // biPlanes - 32, // biBitCount - BI_RGB, // biCompression - 0, // biSizeImage - 2835, // biXPelsPerMeter - 2835, // biYPelsPerMeter - 0, // biClrUsed - 0 // biClrImportant - }, - { { 0, 0, 0, 0 } } // bmiColors - }; - //RECT wrect; - int res; - - SPWin32Modal = TRUE; - - // Number of pixels per logical inch - dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX); - dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY); - // Size in pixels of the printable area - pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH); - pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT); - // Top left corner of prontable area - pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX); - pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY); - // Size in pixels of the printable area - pPrintableWidth = GetDeviceCaps (_hDC, HORZRES); - pPrintableHeight = GetDeviceCaps (_hDC, VERTRES); - - // Scaling from document to device - scalex = dpiX / 72.0; - scaley = dpiY / 72.0; - - // We simply map document 0,0 to physical page 0,0 - Geom::Affine affine = Geom::Scale(scalex / 1.25, scaley / 1.25); - - nr_arena_item_set_transform (mod->root, affine); - - // Calculate printable area in device coordinates - x0 = pPhysicalOffsetX; - y0 = pPhysicalOffsetY; - x1 = x0 + pPrintableWidth; - y1 = y0 + pPrintableHeight; - x1 = MIN (x1, (int) (_PageWidth * scalex)); - y1 = MIN (y1, (int) (_PageHeight * scaley)); - - width = x1 - x0; - height = y1 - y0; - - px = g_new (unsigned char, 4 * 64 * width); - sheight = 64; - - /* Printing goes here */ - for (row = 0; row < height; row += 64) { - NRPixBlock pb; - NRRectL bbox; - NRGC gc(NULL); - int num_rows; - int i; - - num_rows = sheight; - if ((row + num_rows) > height) num_rows = height - row; - - /* Set area of interest */ - bbox.x0 = x0; - bbox.y0 = y0 + row; - bbox.x1 = bbox.x0 + width; - bbox.y1 = bbox.y0 + num_rows; - /* Update to renderable state */ - gc.transform.setIdentity(); - nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); - - nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE); - - /* Blitter goes here */ - bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0; - bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0); - - memset (px, 0xff, 4 * num_rows * width); - /* Render */ - nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0); - - /* Swap red and blue channels; we use RGBA, whereas - * the Win32 GDI uses BGRx. - */ - for ( i = 0 ; i < num_rows * width ; i++ ) { - unsigned char temp=px[i*4]; - px[i*4] = px[i*4+2]; - px[i*4+2] = temp; - } - - SetStretchBltMode(_hDC, COLORONCOLOR); - res = StretchDIBits (_hDC, - bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, - 0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, - px, - &bmInfo, - DIB_RGB_COLORS, - SRCCOPY); - - /* Blitter ends here */ - - nr_pixblock_release (&pb); - } - - g_free (px); - - res = EndPage (_hDC); - res = EndDoc (_hDC); - - SPWin32Modal = FALSE; - - return 0; -} - -/* File dialogs */ - -char * -PrintWin32::get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title) -{ - char fnbuf[4096] = {0}; - OPENFILENAME ofn = { - sizeof (OPENFILENAME), - NULL, /* hwndOwner */ - NULL, /* hInstance */ - (const CHAR *)filter, /* lpstrFilter */ - NULL, /* lpstrCustomFilter */ - 0, /* nMaxCustFilter */ - 1, /* nFilterIndex */ - fnbuf, /* lpstrFile */ - sizeof (fnbuf), /* nMaxFile */ - NULL, /* lpstrFileTitle */ - 0, /* nMaxFileTitle */ - (const CHAR *)dir, /* lpstrInitialDir */ - (const CHAR *)title, /* lpstrTitle */ - OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */ - 0, /* nFileOffset */ - 0, /* nFileExtension */ - NULL, /* lpstrDefExt */ - 0, /* lCustData */ - NULL, /* lpfnHook */ - NULL /* lpTemplateName */ - }; - int retval; - UINT_PTR timer; - - SPWin32Modal = TRUE; - timer = SetTimer (NULL, 0, 40, my_timer); - - retval = GetOpenFileName (&ofn); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!retval) { - int errcode; - errcode = CommDlgExtendedError(); - return NULL; - } - return g_strdup (fnbuf); -} - -char * -PrintWin32::get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title) -{ - return NULL; -} - -char * -PrintWin32::get_save_filename (unsigned char *dir, unsigned int *spns) -{ - char fnbuf[4096] = {0}; - OPENFILENAME ofn = { - sizeof (OPENFILENAME), - NULL, /* hwndOwner */ - NULL, /* hInstance */ - "Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */ - NULL, /* lpstrCustomFilter */ - 0, /* nMaxCustFilter */ - 1, /* nFilterIndex */ - fnbuf, /* lpstrFile */ - sizeof (fnbuf), /* nMaxFile */ - NULL, /* lpstrFileTitle */ - 0, /* nMaxFileTitle */ - (const CHAR *)dir, /* lpstrInitialDir */ - "Save document to file", /* lpstrTitle */ - OFN_HIDEREADONLY, /* Flags */ - 0, /* nFileOffset */ - 0, /* nFileExtension */ - NULL, /* lpstrDefExt */ - 0, /* lCustData */ - NULL, /* lpfnHook */ - NULL /* lpTemplateName */ - }; - int retval; - UINT_PTR timer; - - SPWin32Modal = TRUE; - timer = SetTimer (NULL, 0, 40, my_timer); - - retval = GetSaveFileName (&ofn); - - KillTimer (NULL, timer); - SPWin32Modal = FALSE; - - if (!retval) { - int errcode; - errcode = CommDlgExtendedError(); - return NULL; - } - *spns = (ofn.nFilterIndex != 2); - return g_strdup (fnbuf); -} - -#include "clear-n_.h" - -void -PrintWin32::init (void) -{ - Inkscape::Extension::Extension * ext; - - /* SVG in */ - ext = Inkscape::Extension::build_from_mem( - "\n" - "" N_("Windows 32-bit Print") "\n" - "" SP_MODULE_KEY_PRINT_WIN32 "\n" - "true\n" - "\n" - "", new PrintWin32()); - - return; -} - -} /* namespace Internal */ -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif // ifdef WIN32 - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/internal/win32.h b/src/extension/internal/win32.h deleted file mode 100644 index 4a913bb05..000000000 --- a/src/extension/internal/win32.h +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - * @brief Windows-specific stuff - */ -/* Author: - * Lauris Kaplinski - * Ted Gould - * - * Lauris: This code is in public domain - * Ted: This code is released under the GNU GPL - */ - -#ifndef __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__ -#ifdef WIN32 - -#ifdef HAVE_CONFIG_H - #include -#endif - -#ifdef DATADIR -#undef DATADIR -#endif -#include - -#include "extension/extension.h" -#include "extension/implementation/implementation.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { - -/* Initialization */ - -class PrintWin32 : public Inkscape::Extension::Implementation::Implementation { - /* Document dimensions */ - float _PageWidth; - float _PageHeight; - - HDC _hDC; - - unsigned int _landscape; - - void main_init (int argc, char **argv, const char *name); - void finish (void); - - /* File dialogs */ - char *get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title); - char *get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title); - char *get_save_filename (unsigned char *dir, unsigned int *spns); - - VOID CALLBACK timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); - - -public: - PrintWin32 (void); - virtual ~PrintWin32 (void); - - /* Tell modules about me */ - static void init (void); - - /* Platform detection */ - static gboolean is_os_wide(); - - /* Print functions */ - virtual unsigned int setup (Inkscape::Extension::Print * module); - //virtual unsigned int set_preview (Inkscape::Extension::Print * module); - - virtual unsigned int begin (Inkscape::Extension::Print * module, SPDocument *doc); - virtual unsigned int finish (Inkscape::Extension::Print * module); - - /* Rendering methods */ - /* - virtual unsigned int bind (Inkscape::Extension::Print * module, const Geom::Affine *transform, float opacity); - virtual unsigned int release (Inkscape::Extension::Print * module); - virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment); - virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const Geom::Affine *transform, const SPStyle *style); - */ -}; - -} /* namespace Internal */ -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif // ifdef WIN32 -#endif /* __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__ */ -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/file.cpp b/src/file.cpp index ae774bb52..86df2ed44 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1510,20 +1510,6 @@ sp_file_print(Gtk::Window& parentWindow) sp_print_document(parentWindow, doc); } -/** - * Display what the drawing would look like, if - * printed. - */ -void -sp_file_print_preview(gpointer /*object*/, gpointer /*data*/) -{ - - SPDocument *doc = SP_ACTIVE_DOCUMENT; - if (doc) - sp_print_preview_document(doc); - -} - /* Local Variables: diff --git a/src/file.h b/src/file.h index 97d1bd5f8..65d561adc 100644 --- a/src/file.h +++ b/src/file.h @@ -183,11 +183,6 @@ would be useful as instance methods */ void sp_file_print (Gtk::Window& parentWindow); -/** - * - */ -void sp_file_print_preview (gpointer object, gpointer data); - /*##################### ## U T I L I T Y #####################*/ diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1007c315a..b063b909d 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -25,10 +25,6 @@ # define HAS_PROC_SELF_EXE //to get path of executable #else -// For now to get at is_os_wide(). -# include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; - #define _WIN32_IE 0x0400 //#define HAS_SHGetSpecialFolderPath #define HAS_SHGetSpecialFolderLocation @@ -1354,24 +1350,18 @@ profile_path(const char *filename) if ( SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA, &pidl ) == NOERROR ) { gchar * utf8Path = NULL; - if ( PrintWin32::is_os_wide() ) { + { wchar_t pathBuf[MAX_PATH+1]; g_assert(sizeof(wchar_t) == sizeof(gunichar2)); if ( SHGetPathFromIDListW( pidl, pathBuf ) ) { utf8Path = g_utf16_to_utf8( (gunichar2*)(&pathBuf[0]), -1, NULL, NULL, NULL ); } - } else { - char pathBuf[MAX_PATH+1]; - - if ( SHGetPathFromIDListA( pidl, pathBuf ) ) { - utf8Path = g_filename_to_utf8( pathBuf, -1, NULL, NULL, NULL ); - } } if ( utf8Path ) { if (!g_utf8_validate(utf8Path, -1, NULL)) { - g_warning( "SHGetPathFromIDList%c() resulted in invalid UTF-8", (PrintWin32::is_os_wide() ? 'W' : 'A') ); + g_warning( "SHGetPathFromIDListW() resulted in invalid UTF-8"); g_free( utf8Path ); utf8Path = 0; } else { diff --git a/src/io/sys.cpp b/src/io/sys.cpp index a68d02707..198be94e6 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -28,12 +28,6 @@ #include "preferences.h" #include "sys.h" -#ifdef WIN32 -// For now to get at is_os_wide(). -#include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; -#endif // WIN32 - //#define INK_DUMP_FILENAME_CONV 1 #undef INK_DUMP_FILENAME_CONV diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp index 05d7f020a..b5f884b29 100644 --- a/src/io/uristream.cpp +++ b/src/io/uristream.cpp @@ -16,12 +16,6 @@ #include #include -#ifdef WIN32 -// For now to get at is_os_wide(). -# include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; -#endif - namespace Inkscape { @@ -65,7 +59,7 @@ static FILE *fopen_utf8name( char const *utf8name, int mode ) g_free(filename); } #else - if ( PrintWin32::is_os_wide() ) { + { gunichar2 *wideName = g_utf8_to_utf16( utf8name, -1, NULL, NULL, NULL ); if ( wideName ) { if (mode == FILE_READ) @@ -78,15 +72,6 @@ static FILE *fopen_utf8name( char const *utf8name, int mode ) g_message("Unable to convert filename from UTF-8 to UTF-16 [%s]", safe); g_free(safe); } - } else { - gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL ); - if ( filename ) { - if (mode == FILE_READ) - fp = std::fopen(filename, "rb"); - else - fp = std::fopen(filename, "wb"); - g_free(filename); - } } #endif diff --git a/src/main.cpp b/src/main.cpp index ac0994be6..b510f6902 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,9 +100,8 @@ #include #ifdef WIN32 +#include #include "registrytool.h" -#include "extension/internal/win32.h" -using Inkscape::Extension::Internal::PrintWin32; #endif // WIN32 #include "extension/init.h" @@ -702,9 +701,6 @@ main(int argc, char **argv) } #ifdef WIN32 -#ifndef REPLACEARGS_ANSI - if ( PrintWin32::is_os_wide() ) -#endif // REPLACEARGS_ANSI { // If the call fails, we'll need to convert charsets needToRecodeParams = !replaceArgs( argc, argv ); diff --git a/src/print.cpp b/src/print.cpp index fe52ea6dd..0774f5751 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -84,43 +84,6 @@ unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, /* UI */ -void -sp_print_preview_document(SPDocument *doc) -{ - Inkscape::Extension::Print *mod; - unsigned int ret; - - doc->ensureUpToDate(); - - mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT); - - ret = mod->set_preview(); - - if (ret) { - SPPrintContext context; - context.module = mod; - - /* fixme: This has to go into module constructor somehow */ - /* Create new arena */ - mod->base = SP_ITEM(doc->getRoot()); - mod->arena = NRArena::create(); - mod->dkey = SPItem::display_key_new(1); - mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); - /* Print document */ - ret = mod->begin(doc); - (mod->base)->invoke_print(&context); - ret = mod->finish(); - /* Release arena */ - (mod->base)->invoke_hide(mod->dkey); - mod->base = NULL; - mod->root = NULL; - nr_object_unref((NRObject *) mod->arena); - mod->arena = NULL; - } - - return; -} - void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) { diff --git a/src/print.h b/src/print.h index 70361fb14..caea6ae3a 100644 --- a/src/print.h +++ b/src/print.h @@ -41,7 +41,6 @@ void sp_print_get_param(SPPrintContext *ctx, gchar *name, bool *value); /* UI */ -void sp_print_preview_document(SPDocument *doc); void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc); void sp_print_document_to_file(SPDocument *doc, gchar const *filename); diff --git a/src/verbs.cpp b/src/verbs.cpp index 1ad68b792..3e0dbf98c 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -824,9 +824,6 @@ FileVerb::perform(SPAction *action, void *data, void */*pdata*/) case SP_VERB_FILE_VACUUM: sp_file_vacuum(); break; - case SP_VERB_FILE_PRINT_PREVIEW: - sp_file_print_preview(NULL, NULL); - break; case SP_VERB_FILE_IMPORT: sp_file_import(*parent); break; @@ -2251,8 +2248,6 @@ Verb *Verb::_base_verbs[] = { // TRANSLATORS: "Vacuum Defs" means "Clean up defs" (so as to remove unused definitions) new FileVerb(SP_VERB_FILE_VACUUM, "FileVacuum", N_("Vac_uum Defs"), N_("Remove unused definitions (such as gradients or clipping paths) from the <defs> of the document"), INKSCAPE_ICON_DOCUMENT_CLEANUP ), - new FileVerb(SP_VERB_FILE_PRINT_PREVIEW, "FilePrintPreview", N_("Print Previe_w"), - N_("Preview document printout"), GTK_STOCK_PRINT_PREVIEW ), new FileVerb(SP_VERB_FILE_IMPORT, "FileImport", N_("_Import..."), N_("Import a bitmap or SVG image into this document"), INKSCAPE_ICON_DOCUMENT_IMPORT), new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."), diff --git a/src/verbs.h b/src/verbs.h index 0c781f0b6..91e00c307 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -41,7 +41,6 @@ enum { SP_VERB_FILE_SAVE_A_COPY, /**< Save a copy of the current file */ SP_VERB_FILE_PRINT, SP_VERB_FILE_VACUUM, - SP_VERB_FILE_PRINT_PREVIEW, SP_VERB_FILE_IMPORT, SP_VERB_FILE_EXPORT, SP_VERB_FILE_IMPORT_FROM_OCAL, /**< Import the file from Open Clip Art Library */ -- cgit v1.2.3 From c19367e94afe56c85c80400617efae7b97a3d59a Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Fri, 15 Apr 2011 09:46:13 -0700 Subject: Update Makefile as necessary to build again on Linux (bzr r9508.1.83) --- src/Makefile.am | 2 -- src/extension/internal/Makefile_insert | 2 -- 2 files changed, 4 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index c7381546b..40ecc1ec7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -185,8 +185,6 @@ EXTRA_DIST += \ widgets/makefile.in \ xml/makefile.in \ 2geom/makefile.in \ - extension/internal/win32.cpp \ - extension/internal/win32.h \ extension/internal/emf-win32-inout.cpp \ extension/internal/emf-win32-inout.h \ extension/internal/emf-win32-print.cpp \ diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 3c1ce7f43..36a80712d 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -131,8 +131,6 @@ ink_common_sources += \ extension/internal/filter/filter.h \ extension/internal/filter/drop-shadow.h \ extension/internal/filter/snow.h \ - extension/internal/win32.h \ - extension/internal/win32.cpp \ extension/internal/emf-win32-print.h \ extension/internal/emf-win32-print.cpp \ extension/internal/emf-win32-inout.h \ -- cgit v1.2.3 From ba0656ed825139624f4726c2e9d4389e2a8c2f37 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 15 Apr 2011 21:38:27 +0200 Subject: add undo to SpinButton (bzr r10167) --- src/ui/widget/spinbutton.cpp | 70 +++++++++++++++++++++++++++++++++++++++++--- src/ui/widget/spinbutton.h | 10 +++++-- 2 files changed, 74 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 22bc30bb2..32090f96c 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -18,11 +18,20 @@ #include "unit-menu.h" #include "util/expression-evaluator.h" +#include "event-context.h" namespace Inkscape { namespace UI { namespace Widget { + +void +SpinButton::connect_signals() { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + signal_focus_in_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_focus_in_event)); + signal_key_press_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_key_press_event)); +}; + /** * This callback function should try to convert the entered text to a number and write it to newvalue. * It calls a method to evaluate the (potential) mathematical expression. @@ -34,10 +43,16 @@ int SpinButton::on_input(double* newvalue) { try { - Inkscape::Util::GimpEevlQuantity result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), _unit_menu ? &_unit_menu->getUnit() : NULL); - // check if output dimension corresponds to input unit - if (_unit_menu && result.dimension != (_unit_menu->getUnit().isAbsolute() ? 1 : 0) ) { - throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); + Inkscape::Util::GimpEevlQuantity result; + if (_unit_menu) { + Unit unit = _unit_menu->getUnit(); + result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); + // check if output dimension corresponds to input unit + if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { + throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); + } + } else { + result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), NULL); } *newvalue = result.value; @@ -51,6 +66,53 @@ SpinButton::on_input(double* newvalue) return true; } +/** When focus is obtained, save the value to enable undo later. + * @retval false continue with default handler. + * @retval true don't call default handler. +*/ +bool +SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) +{ + on_focus_in_value = get_value(); + return false; // do not consume the event +} + +/** Handle specific keypress events, like Ctrl+Z + * @retval false continue with default handler. + * @retval true don't call default handler. +*/ +bool +SpinButton::on_my_key_press_event(GdkEventKey* event) +{ + switch (get_group0_keyval (event)) { + case GDK_Escape: + undo(); + return true; // I consumed the event + break; + case GDK_z: + case GDK_Z: + if (event->state & GDK_CONTROL_MASK) { + undo(); + return true; // I consumed the event + } + break; + default: + break; + } + + return false; // do not consume the event +} + +/** + * Undo the editing, by resetting the value upon when the spinbutton got focus. + */ +void +SpinButton::undo() +{ + set_value(on_focus_in_value); +} + + } // namespace Widget } // namespace UI } // namespace Inkscape diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 0eb58bb9e..df913553d 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -33,13 +33,13 @@ public: : Gtk::SpinButton(climb_rate, digits), _unit_menu(NULL) { - signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + connect_signals(); }; explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) : Gtk::SpinButton(adjustment, climb_rate, digits), _unit_menu(NULL) { - signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + connect_signals(); }; virtual ~SpinButton() {}; @@ -49,7 +49,13 @@ public: protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + void connect_signals(); int on_input(double* newvalue); + bool on_my_focus_in_event(GdkEventFocus* event); + bool on_my_key_press_event(GdkEventKey* event); + void undo(); + + double on_focus_in_value; private: // noncopyable -- cgit v1.2.3 From f61973f0c721f0546c5f9946fc084ba50680efce Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 15 Apr 2011 21:51:57 +0200 Subject: remove ridiculous comment (bzr r10168) --- src/ege-adjustment-action.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index c075d67e7..de8814f55 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -39,8 +39,6 @@ * * ***** END LICENSE BLOCK ***** */ -/* Note: this file should be kept compilable as both .cpp and .c */ - #include #include -- cgit v1.2.3 From 12f44c4f342837bd36dbd0f9b269d36edb2e41c6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 15 Apr 2011 22:09:36 +0200 Subject: hack C++ spinbuttons into toolbars. unit conversion does not work, and will probably be a huge pain to add (bzr r10169) --- src/ege-adjustment-action.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index de8814f55..bfab201f4 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -62,6 +62,8 @@ #include "icon-size.h" #include "ege-adjustment-action.h" +#include "ui/widget/spinbutton.h" + static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ); static void ege_adjustment_action_init( EgeAdjustmentAction* action ); @@ -846,7 +848,9 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_scale_button_set_icons( GTK_SCALE_BUTTON(spinbutton), floogles ); #endif /* GTK_CHECK_VERSION(2,12,0) */ } else { - spinbutton = gtk_spin_button_new( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); + //spinbutton = gtk_spin_button_new( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); + Inkscape::UI::Widget::SpinButton *inkscape_spinbutton = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(act->private_data->adj, true), act->private_data->climbRate, act->private_data->digits); + spinbutton = GTK_WIDGET( inkscape_spinbutton->gobj() ); } item = GTK_WIDGET( gtk_tool_item_new() ); -- cgit v1.2.3 From a0d74348937bf217b073311936e5aefc6105a1b9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 16 Apr 2011 23:09:31 +0200 Subject: ScalarUnit widget: fix initialization bug. add constructor which takes another scalarunit's unitmenu. (bzr r10171) --- src/ui/widget/scalar-unit.cpp | 34 ++++++++++++++++++++++++++++++++++ src/ui/widget/scalar-unit.h | 5 +++++ 2 files changed, 39 insertions(+) (limited to 'src') diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 533f0a200..e713f3e06 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -68,8 +68,42 @@ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); static_cast(_widget)->setUnitMenu(_unit_menu); + + lastUnits = _unit_menu->getUnitAbbr(); +} + +/** + * Construct a ScalarUnit + * + * \param label Label. + * \param tooltip Tooltip text. + * \param take_unitmenu Use the unitmenu from this parameter. + * \param suffix Suffix, placed after the widget (defaults to ""). + * \param icon Icon filename, placed before the label (defaults to ""). + * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ +ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, + ScalarUnit &take_unitmenu, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + : Scalar(label, tooltip, suffix, icon, mnemonic), + _unit_menu(take_unitmenu._unit_menu), + _hundred_percent(0), + _absolute_is_increment(false), + _percentage_is_increment(false) +{ + _unit_menu->signal_changed() + .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); + + static_cast(_widget)->setUnitMenu(_unit_menu); + + lastUnits = _unit_menu->getUnitAbbr(); } + /** * Initializes the scalar based on the settings in _unit_menu. * Requires that _unit_menu has already been initialized. diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index 8f6c8e210..4e08d63f4 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -32,6 +32,11 @@ public: Glib::ustring const &icon = "", UnitMenu *unit_menu = NULL, bool mnemonic = true); + ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, + ScalarUnit &take_unitmenu, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); void initScalar(double min_value, double max_value); -- cgit v1.2.3 From 7f1598badb821e086ee9e34865389844bd9ddd70 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 16 Apr 2011 23:48:59 +0200 Subject: upgrade the spinboxes in tile dialog. (alignment is a bit awkward, have tried to fix it, but didnt work out) (bzr r10172) --- src/ui/dialog/tile.cpp | 74 ++++++++++++++++++-------------------------------- src/ui/dialog/tile.h | 20 ++++---------- 2 files changed, 32 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index b0a39bd0e..3510503d3 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -136,8 +136,8 @@ void TileDialog::Grid_Arrange () on_row_spinbutton_changed(); // set padding to manual values - paddingx = XPadSpinner.get_value(); - paddingy = YPadSpinner.get_value(); + paddingx = XPadding.getValue("px"); + paddingy = YPadding.getValue("px"); std::vector row_heights; std::vector col_widths; @@ -422,7 +422,7 @@ void TileDialog::on_col_spinbutton_changed() void TileDialog::on_xpad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/XPad", XPadSpinner.get_value()); + prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); } @@ -432,7 +432,7 @@ void TileDialog::on_xpad_spinbutton_changed() void TileDialog::on_ypad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/YPad", YPadSpinner.get_value()); + prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); } @@ -512,7 +512,8 @@ void TileDialog::Spacing_button_changed() prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); } - SizesHBox.set_sensitive ( SpaceManualRadioButton.get_active()); + XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); + YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); } /** @@ -614,7 +615,9 @@ static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscap * Constructor */ TileDialog::TileDialog() - : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE) + : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), + XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), + YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") { // bool used by spin button callbacks to stop loops where they change each other. updating = false; @@ -814,51 +817,25 @@ TileDialog::TileDialog() } { - /*#### Y Padding ####*/ + /*#### Padding ####*/ - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-rows"); - YPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN); + YPadding.setDigits(1); + YPadding.setIncrements(0.2, 0); + YPadding.setRange(-10000, 10000); + double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); + YPadding.setValue(yPad, "px"); + YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - YPadSpinner.set_digits(1); - YPadSpinner.set_increments(0.2, 0); - YPadSpinner.set_range(-10000, 10000); - double YPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); - YPadSpinner.set_value(YPad); - YPadBox.pack_start(YPadSpinner, true, true, MARGIN); - tips.set_tip(YPadSpinner, _("Vertical spacing between rows (px units)")); - YPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - gtk_size_group_add_widget(_col1, (GtkWidget *) YPadBox.gobj()); + XPadding.setDigits(1); + XPadding.setIncrements(0.2, 0); + XPadding.setRange(-10000, 10000); + double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); + XPadding.setValue(xPad, "px"); - SizesHBox.pack_start(YPadBox, false, false, MARGIN); + XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); } - - { - Gtk::HBox *spacer = new Gtk::HBox; - SizesHBox.pack_start(*spacer, false, false, 0); - gtk_size_group_add_widget(_col2, (GtkWidget *) spacer->gobj()); - } - - { - /*#### X padding ####*/ - - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-columns"); - XPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN); - - XPadSpinner.set_digits(1); - XPadSpinner.set_increments(0.2, 0); - XPadSpinner.set_range(-10000, 10000); - double XPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); - XPadSpinner.set_value(XPad); - XPadBox.pack_start(XPadSpinner, true, true, MARGIN); - tips.set_tip(XPadSpinner, _("Horizontal spacing between columns (px units)")); - XPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); - gtk_size_group_add_widget(_col3, (GtkWidget *) XPadBox.gobj()); - - SizesHBox.pack_start(XPadBox, false, false, MARGIN); - } - - - TileBox.pack_start(SizesHBox, false, false, MARGIN); + TileBox.pack_start(XPadding, false, false, MARGIN); + TileBox.pack_start(YPadding, false, false, MARGIN); contents->pack_start(TileBox); @@ -870,7 +847,8 @@ TileDialog::TileDialog() } SpaceManualRadioButton.set_active(ManualSpacing); SpaceByBBoxRadioButton.set_active(!ManualSpacing); - SizesHBox.set_sensitive (ManualSpacing); + XPadding.set_sensitive (ManualSpacing); + YPadding.set_sensitive (ManualSpacing); //## The OK button TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 16ae3e4f8..09a648e1f 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -24,6 +24,8 @@ #include #include "ui/widget/panel.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/scalar-unit.h" namespace Inkscape { namespace UI { @@ -88,12 +90,11 @@ private: Gtk::HBox AlignHBox; Gtk::HBox SpinsHBox; - Gtk::HBox SizesHBox; // Number per Row Gtk::VBox NoOfColsBox; Gtk::Label NoOfColsLabel; - Gtk::SpinButton NoOfColsSpinner; + Inkscape::UI::Widget::SpinButton NoOfColsSpinner; bool AutoRowSize; Gtk::CheckButton RowHeightButton; @@ -104,7 +105,7 @@ private: // Number per Column Gtk::VBox NoOfRowsBox; Gtk::Label NoOfRowsLabel; - Gtk::SpinButton NoOfRowsSpinner; + Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; bool AutoColSize; Gtk::CheckButton ColumnWidthButton; @@ -128,15 +129,8 @@ private: Gtk::RadioButton HorizRightRadioButton; double HorizAlign; - // padding in x - Gtk::VBox XPadBox; - Gtk::Label XPadLabel; - Gtk::SpinButton XPadSpinner; - - // padding in y - Gtk::VBox YPadBox; - Gtk::Label YPadLabel; - Gtk::SpinButton YPadSpinner; + Inkscape::UI::Widget::ScalarUnit XPadding; + Inkscape::UI::Widget::ScalarUnit YPadding; // BBox or manual spacing Gtk::VBox SpacingVBox; @@ -145,8 +139,6 @@ private: Gtk::RadioButton SpaceManualRadioButton; bool ManualSpacing; - - // Row height Gtk::VBox RowHeightVBox; Gtk::HBox RowHeightBox; -- cgit v1.2.3 From cc5c699ce54696232000ab14a64351d696b4b1a9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 16 Apr 2011 23:55:46 +0200 Subject: extensions: use improved spinbutton with math expression evaluation (bzr r10173) --- src/extension/param/float.cpp | 4 ++-- src/extension/param/int.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index d94463a5b..4ef816d61 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include "xml/node.h" #include "extension/extension.h" @@ -172,7 +172,7 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign hbox->pack_start(*scale, false, false); } - Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, _precision)); + Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index 69849c656..3ed8addd9 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include "xml/node.h" #include "extension/extension.h" @@ -157,7 +157,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal hbox->pack_start(*scale, false, false); } - Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0)); + Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0)); spin->show(); hbox->pack_start(*spin, false, false); -- cgit v1.2.3 From 5bce9c92692548162b10aa06370f1e28806572f7 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 16 Apr 2011 23:57:13 +0200 Subject: remove unnecessary includes. (bzr r10174) --- src/extension/param/parameter.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index a9935cfe6..fb53035a1 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -19,10 +19,6 @@ # define ESCAPE_DOLLAR_COMMANDLINE #endif -#include -#include -#include - #include #include -- cgit v1.2.3 From 21d73e3319ea07a5323a318a376a8c664640265d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Apr 2011 00:14:34 +0200 Subject: remove superfluous includes (bzr r10175) --- src/ui/dialog/fill-and-stroke.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index fe72aa31c..b4be9ce59 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -15,11 +15,9 @@ #ifndef INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H #define INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H -#include #include #include #include -#include #include #include "ui/widget/panel.h" -- cgit v1.2.3 From b1b23e8d5eed247d2603a5a83b8e8a9a969793ed Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Apr 2011 00:56:19 +0200 Subject: change spinbox to new one in many places. (bzr r10176) --- src/extension/internal/pdf-input-cairo.cpp | 4 +++- src/extension/internal/pdf-input-cairo.h | 10 ++++++++-- src/extension/internal/pdfinput/pdf-input.cpp | 3 ++- src/extension/internal/pdfinput/pdf-input.h | 10 ++++++++-- src/jabber_whiteboard/pedrogui.h | 3 ++- src/pedro/pedrogui.h | 3 ++- src/ui/dialog/align-and-distribute.cpp | 6 +++--- src/ui/dialog/filter-effects-dialog.cpp | 12 ++++++------ src/ui/dialog/inkscape-preferences.cpp | 3 ++- src/ui/dialog/layers.h | 4 ++-- src/ui/dialog/svg-fonts-dialog.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.h | 3 ++- src/ui/dialog/tile.h | 4 ++-- src/ui/dialog/tracedialog.cpp | 18 +++++++++--------- src/ui/widget/object-composite-settings.h | 4 ++-- src/ui/widget/preferences-widget.h | 6 +++--- src/ui/widget/selected-style.h | 4 ++-- src/ui/widget/spin-slider.cpp | 4 ++-- src/ui/widget/spin-slider.h | 8 ++++---- src/ui/widget/zoom-status.h | 4 ++-- src/widgets/dash-selector.cpp | 4 ++-- src/widgets/stroke-style.cpp | 11 ++++++----- 22 files changed, 75 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index 048b26bed..daa185268 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -31,6 +31,8 @@ #include #include +#include "ui/widget/spinbutton.h" + namespace Inkscape { namespace Extension { namespace Internal { @@ -67,7 +69,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc) // Page number int num_pages = poppler_document_get_n_pages(_poppler_doc); Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, num_pages, 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1)); + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); _labelTotalPages = Gtk::manage(new class Gtk::Label()); hbox2 = Gtk::manage(new class Gtk::HBox(false, 0)); // Disable the page selector when there's only one page diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h index ad7c884cb..7581cb0a5 100644 --- a/src/extension/internal/pdf-input-cairo.h +++ b/src/extension/internal/pdf-input-cairo.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -39,6 +38,13 @@ #include "../implementation/implementation.h" namespace Inkscape { + +namespace UI { +namespace Widget { + class SpinButton; +} +} + namespace Extension { namespace Internal { @@ -64,7 +70,7 @@ private: class Gtk::Button * cancelbutton; class Gtk::Button * okbutton; class Gtk::Label * _labelSelect; - class Gtk::SpinButton * _pageNumberSpin; + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin; class Gtk::Label * _labelTotalPages; class Gtk::HBox * hbox2; class Gtk::CheckButton * _cropCheck; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index ae3e473a5..fc2db7e69 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -41,6 +41,7 @@ #include "dialogs/dialog-events.h" #include +#include "ui/widget/spinbutton.h" namespace Inkscape { namespace Extension { @@ -75,7 +76,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri) // Page number Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( new class Gtk::Adjustment(1, 1, _pdf_doc->getNumPages(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1)); + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); _labelTotalPages = Gtk::manage(new class Gtk::Label()); hbox2 = Gtk::manage(new class Gtk::HBox(false, 0)); // Disable the page selector when there's only one page diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 6bf0f11a2..c2fd0b6d8 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -41,6 +40,13 @@ #endif namespace Inkscape { + +namespace UI { +namespace Widget { + class SpinButton; +} +} + namespace Extension { namespace Internal { @@ -66,7 +72,7 @@ private: class Gtk::Button * cancelbutton; class Gtk::Button * okbutton; class Gtk::Label * _labelSelect; - class Gtk::SpinButton * _pageNumberSpin; + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin; class Gtk::Label * _labelTotalPages; class Gtk::HBox * hbox2; class Gtk::CheckButton * _cropCheck; diff --git a/src/jabber_whiteboard/pedrogui.h b/src/jabber_whiteboard/pedrogui.h index d9a66a5e5..f4ebb4544 100644 --- a/src/jabber_whiteboard/pedrogui.h +++ b/src/jabber_whiteboard/pedrogui.h @@ -26,6 +26,7 @@ #include +#include "ui/widget/spinbutton.h" #include "pedro/pedroxmpp.h" #include "pedro/pedroconfig.h" @@ -595,7 +596,7 @@ private: Gtk::Label hostLabel; Gtk::Entry hostField; Gtk::Label portLabel; - Gtk::SpinButton portSpinner; + Inkscape::UI::Widget::SpinButton portSpinner; Gtk::Label userLabel; Gtk::Entry userField; Gtk::Label passLabel; diff --git a/src/pedro/pedrogui.h b/src/pedro/pedrogui.h index 4af4f1aac..2898da118 100644 --- a/src/pedro/pedrogui.h +++ b/src/pedro/pedrogui.h @@ -26,6 +26,7 @@ #include +#include "ui/widget/spinbutton.h" #include "pedroxmpp.h" #include "pedroconfig.h" @@ -590,7 +591,7 @@ private: Gtk::Label hostLabel; Gtk::Entry hostField; Gtk::Label portLabel; - Gtk::SpinButton portSpinner; + Inkscape::UI::Widget::SpinButton portSpinner; Gtk::Label userLabel; Gtk::Entry userField; Gtk::Label passLabel; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index f974ec6ce..81e2b64a9 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -20,7 +20,7 @@ # include #endif -#include +#include "ui/widget/spinbutton.h" #include "desktop-handles.h" #include "unclump.h" @@ -445,8 +445,8 @@ class ActionRemoveOverlaps : public Action { private: Gtk::Label removeOverlapXGapLabel; Gtk::Label removeOverlapYGapLabel; - Gtk::SpinButton removeOverlapXGap; - Gtk::SpinButton removeOverlapYGap; + Inkscape::UI::Widget::SpinButton removeOverlapXGap; + Inkscape::UI::Widget::SpinButton removeOverlapYGap; public: ActionRemoveOverlaps(Glib::ustring const &id, diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 2699d9201..2e17daa11 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include #include #include @@ -133,12 +133,12 @@ private: const Glib::ustring _true_val, _false_val; }; -class SpinButtonAttr : public Gtk::SpinButton, public AttrWidget +class SpinButtonAttr : public Inkscape::UI::Widget::SpinButton, public AttrWidget { public: SpinButtonAttr(double lower, double upper, double step_inc, double climb_rate, int digits, const SPAttributeEnum a, double def, char* tip_text) - : Gtk::SpinButton(climb_rate, digits), + : Inkscape::UI::Widget::SpinButton(climb_rate, digits), AttrWidget(a, def) { if (tip_text) _tt.set_tip(*this, tip_text); @@ -248,12 +248,12 @@ public: pack_start(_s2, false, false); } - Gtk::SpinButton& get_spinbutton1() + Inkscape::UI::Widget::SpinButton& get_spinbutton1() { return _s1; } - Gtk::SpinButton& get_spinbutton2() + Inkscape::UI::Widget::SpinButton& get_spinbutton2() { return _s2; } @@ -285,7 +285,7 @@ public: } private: - Gtk::SpinButton _s1, _s2; + Inkscape::UI::Widget::SpinButton _s1, _s2; }; class ColorButton : public Gtk::ColorButton, public AttrWidget diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 8681ed98f..7963dd512 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -38,6 +38,7 @@ #include "selection-chemistry.h" #include "xml/repr.h" #include "ui/widget/style-swatch.h" +#include "ui/widget/spinbutton.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" #include "color-profile-fns.h" @@ -70,7 +71,7 @@ InkscapePreferences::InkscapePreferences() _current_page(0) { //get the width of a spinbutton - Gtk::SpinButton* sb = new Gtk::SpinButton; + Inkscape::UI::Widget::SpinButton* sb = new Inkscape::UI::Widget::SpinButton; sb->set_width_chars(6); _getContents()->add(*sb); show_all_children(); diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index b7e81480c..018357425 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include //#include "ui/previewholder.h" @@ -117,7 +117,7 @@ private: Gtk::HButtonBox _buttonsRow; Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; - Gtk::SpinButton _spinBtn; + Inkscape::UI::Widget::SpinButton _spinBtn; Gtk::VBox _layersPage; UI::Widget::StyleSubject::CurrentLayer _subject; diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 2d1b5ae39..d836bfa22 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -137,7 +137,7 @@ Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum /*attr*/) Gtk::HBox* SvgFontsDialog::AttrSpin(gchar* lbl){ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); hbox->add(* Gtk::manage(new Gtk::Label(lbl)) ); - hbox->add(* Gtk::manage(new Gtk::SpinBox()) ); + hbox->add(* Gtk::manage(new Inkscape::UI::Widget::SpinBox()) ); hbox->show_all(); return hbox; }*/ diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index e819187a1..50821cc6c 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -12,6 +12,7 @@ #define INKSCAPE_UI_DIALOG_SVG_FONTS_H #include "ui/widget/panel.h" +#include "ui/widget/spinbutton.h" #include "sp-font.h" #include "sp-font-face.h" #include "verbs.h" @@ -206,7 +207,7 @@ private: SvgFontDrawingArea _font_da, kerning_preview; GlyphComboBox first_glyph, second_glyph; SPGlyphKerning* kerning_pair; - Gtk::SpinButton setwidth_spin; + Inkscape::UI::Widget::SpinButton setwidth_spin; Gtk::HScale kerning_slider; class EntryWidget : public Gtk::HBox diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 09a648e1f..fe77a9098 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -143,13 +143,13 @@ private: Gtk::VBox RowHeightVBox; Gtk::HBox RowHeightBox; Gtk::Label RowHeightLabel; - Gtk::SpinButton RowHeightSpinner; + Inkscape::UI::Widget::SpinButton RowHeightSpinner; // Column width Gtk::VBox ColumnWidthVBox; Gtk::HBox ColumnWidthBox; Gtk::Label ColumnWidthLabel; - Gtk::SpinButton ColumnWidthSpinner; + Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; }; diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index f6dd6cb28..083cd0077 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include "ui/widget/spinbutton.h" #include #include //for GTK_RESPONSE* types @@ -109,7 +109,7 @@ class TraceDialogImpl : public TraceDialog Gtk::HBox modeBrightnessBox; Gtk::RadioButton modeBrightnessRadioButton; Gtk::Label modeBrightnessSpinnerLabel; - Gtk::SpinButton modeBrightnessSpinner; + Inkscape::UI::Widget::SpinButton modeBrightnessSpinner; //edge detection Gtk::Frame modeCannyFrame; Gtk::HBox modeCannyBox; @@ -117,16 +117,16 @@ class TraceDialogImpl : public TraceDialog Gtk::RadioButton modeCannyRadioButton; //Gtk::HSeparator modeCannySeparator; //Gtk::Label modeCannyLoSpinnerLabel; - //Gtk::SpinButton modeCannyLoSpinner; + //Inkscape::UI::Widget::SpinButton modeCannyLoSpinner; Gtk::Label modeCannyHiSpinnerLabel; - Gtk::SpinButton modeCannyHiSpinner; + Inkscape::UI::Widget::SpinButton modeCannyHiSpinner; //quantization Gtk::Frame modeQuantFrame; Gtk::HBox modeQuantBox; Gtk::VBox modeQuantVBox; Gtk::RadioButton modeQuantRadioButton; Gtk::Label modeQuantNrColorLabel; - Gtk::SpinButton modeQuantNrColorSpinner; + Inkscape::UI::Widget::SpinButton modeQuantNrColorSpinner; //params Gtk::CheckButton modeInvertButton; Gtk::HBox modeInvertBox; @@ -137,7 +137,7 @@ class TraceDialogImpl : public TraceDialog //brightness Gtk::HBox modeMultiScanHBox1; Gtk::RadioButton modeMultiScanBrightnessRadioButton; - Gtk::SpinButton modeMultiScanNrColorSpinner; + Inkscape::UI::Widget::SpinButton modeMultiScanNrColorSpinner; //colors Gtk::HBox modeMultiScanHBox2; Gtk::RadioButton modeMultiScanColorRadioButton; @@ -162,15 +162,15 @@ class TraceDialogImpl : public TraceDialog Gtk::HBox optionsSpecklesBox; Gtk::CheckButton optionsSpecklesButton; Gtk::Label optionsSpecklesSizeLabel; - Gtk::SpinButton optionsSpecklesSizeSpinner; + Inkscape::UI::Widget::SpinButton optionsSpecklesSizeSpinner; Gtk::HBox optionsCornersBox; Gtk::CheckButton optionsCornersButton; Gtk::Label optionsCornersThresholdLabel; - Gtk::SpinButton optionsCornersThresholdSpinner; + Inkscape::UI::Widget::SpinButton optionsCornersThresholdSpinner; Gtk::HBox optionsOptimBox; Gtk::CheckButton optionsOptimButton; Gtk::Label optionsOptimToleranceLabel; - Gtk::SpinButton optionsOptimToleranceSpinner; + Inkscape::UI::Widget::SpinButton optionsOptimToleranceSpinner; //#### Credits diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index 76538d6a7..8ef31a889 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include #include @@ -47,7 +47,7 @@ private: Gtk::Label _opacity_label; Gtk::Adjustment _opacity_adjustment; Gtk::HScale _opacity_hscale; - Gtk::SpinButton _opacity_spin_button; + Inkscape::UI::Widget::SpinButton _opacity_spin_button; StyleSubject *_subject; diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 4cd2ff569..758ab38cd 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include #include #include @@ -117,7 +117,7 @@ private: void on_spinbutton_value_changed(); void on_unit_changed(); - Gtk::SpinButton _sb; + Inkscape::UI::Widget::SpinButton _sb; UnitMenu _unit; Gtk::HScale _slider; ZoomCorrRuler _ruler; @@ -135,7 +135,7 @@ private: void on_spinbutton_value_changed(); Glib::ustring _prefs_path; - Gtk::SpinButton _sb; + Inkscape::UI::Widget::SpinButton _sb; Gtk::HScale _slider; bool freeze; // used to block recursive updates of slider and spinbutton }; diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index e74d5b1ae..0caa7fe4c 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include "ui/widget/spinbutton.h" #include #include @@ -138,7 +138,7 @@ protected: Gtk::EventBox _opacity_place; Gtk::Adjustment _opacity_adjustment; - Gtk::SpinButton _opacity_sb; + Inkscape::UI::Widget::SpinButton _opacity_sb; Gtk::Label _na[2]; Glib::ustring __na[2]; diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index faafc63b4..259b057aa 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -90,11 +90,11 @@ Gtk::HScale& SpinSlider::get_scale() return _scale; } -const Gtk::SpinButton& SpinSlider::get_spin_button() const +const Inkscape::UI::Widget::SpinButton& SpinSlider::get_spin_button() const { return _spin; } -Gtk::SpinButton& SpinSlider::get_spin_button() +Inkscape::UI::Widget::SpinButton& SpinSlider::get_spin_button() { return _spin; } diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index a4d0aa9d6..703c5d896 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include "spinbutton.h" #include "attr-widget.h" namespace Inkscape { @@ -42,8 +42,8 @@ public: const Gtk::HScale& get_scale() const; Gtk::HScale& get_scale(); - const Gtk::SpinButton& get_spin_button() const; - Gtk::SpinButton& get_spin_button(); + const Inkscape::UI::Widget::SpinButton& get_spin_button() const; + Inkscape::UI::Widget::SpinButton& get_spin_button(); void set_update_policy(const Gtk::UpdateType); @@ -52,7 +52,7 @@ public: private: Gtk::Adjustment _adjustment; Gtk::HScale _scale; - Gtk::SpinButton _spin; + Inkscape::UI::Widget::SpinButton _spin; }; // Contains two SpinSliders for controlling number-opt-number attributes diff --git a/src/ui/widget/zoom-status.h b/src/ui/widget/zoom-status.h index 58d595329..85c3eeee1 100644 --- a/src/ui/widget/zoom-status.h +++ b/src/ui/widget/zoom-status.h @@ -13,7 +13,7 @@ */ #include -#include +#include "ui/widget/spinbutton.h" struct SPDesktop; @@ -22,7 +22,7 @@ namespace Inkscape { namespace UI { namespace Widget { -class ZoomStatus : public Gtk::SpinButton +class ZoomStatus : public Inkscape::UI::Widget::SpinButton { public: ZoomStatus(); diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp index e7e029334..dead653de 100644 --- a/src/widgets/dash-selector.cpp +++ b/src/widgets/dash-selector.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include "ui/widget/spinbutton.h" #include "dash-selector.h" @@ -73,7 +73,7 @@ SPDashSelector::SPDashSelector() { dash->set_menu(*m); offset = new Gtk::Adjustment(0.0, 0.0, 10.0, 0.1, 1.0, 0.0); - Gtk::SpinButton *sb = new Gtk::SpinButton(*offset, 0.1, 2); + Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(*offset, 0.1, 2); tt->set_tip(*sb, _("Pattern offset")); sp_dialog_defocus_on_enter_cpp(sb); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 555418269..99d8228c8 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -55,6 +55,7 @@ #include "widgets/paint-selector.h" #include "widgets/sp-widget.h" #include "widgets/spw-utilities.h" +#include "ui/widget/spinbutton.h" #include "xml/repr.h" #include "stroke-style.h" @@ -653,7 +654,7 @@ sp_stroke_style_line_widget_new(void) Gtk::Container *spw; Gtk::Table *t; Gtk::Adjustment *a; - Gtk::SpinButton *sb; + Inkscape::UI::Widget::SpinButton *sb; Gtk::RadioButton *tb; Gtk::HBox *f, *hb; @@ -688,7 +689,7 @@ sp_stroke_style_line_widget_new(void) a = new Gtk::Adjustment(1.0, 0.0, 1000.0, 0.1, 10.0, 0.0); spw->set_data("width", a); - sb = new Gtk::SpinButton(*a, 0.1, 3); + sb = new Inkscape::UI::Widget::SpinButton(*a, 0.1, 3); tt->set_tip(*sb, _("Stroke width")); sb->show(); spw_label(t, C_("Stroke width", "_Width:"), 0, i, sb); @@ -765,7 +766,7 @@ sp_stroke_style_line_widget_new(void) a = new Gtk::Adjustment(4.0, 0.0, 100.0, 0.1, 10.0, 0.0); spw->set_data("miterlimit", a); - sb = new Gtk::SpinButton(*a, 0.1, 2); + sb = new Inkscape::UI::Widget::SpinButton(*a, 0.1, 2); tt->set_tip(*sb, _("Maximum length of the miter (in units of stroke width)")); sb->show(); spw_label(t, _("Miter _limit:"), 0, i, sb); @@ -1057,8 +1058,8 @@ sp_stroke_style_line_update(Gtk::Container *spw, Inkscape::Selection *sel) tb = static_cast(spw->get_data("bevel join")); tb->set_sensitive(enabled); - Gtk::SpinButton* sb = NULL; - sb = static_cast(spw->get_data("miterlimit_sb")); + Inkscape::UI::Widget::SpinButton* sb = NULL; + sb = static_cast(spw->get_data("miterlimit_sb")); sb->set_sensitive(enabled); tb = static_cast(spw->get_data("cap butt")); -- cgit v1.2.3 From 70829da1b189d6d8f07f12d97b9273d56dbd789e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Apr 2011 14:51:06 +0200 Subject: add new preference widget for a number with a unit. change Preferences > Steps to this new widget (bzr r10177) --- src/extension/internal/bluredge.cpp | 8 ++--- src/gradient-context.cpp | 2 +- src/pen-context.cpp | 2 +- src/preferences-skeleton.h | 6 ++-- src/preferences.cpp | 44 +++++++++++++++++++++++ src/preferences.h | 62 +++++++++++++++++++++++++++------ src/select-context.cpp | 4 +-- src/splivarot.cpp | 6 ++-- src/ui/dialog/inkscape-preferences.cpp | 18 +++++----- src/ui/dialog/inkscape-preferences.h | 8 ++--- src/ui/tool/control-point-selection.cpp | 4 +-- src/ui/tool/path-manipulator.cpp | 2 +- src/ui/widget/preferences-widget.cpp | 39 +++++++++++++++++++++ src/ui/widget/preferences-widget.h | 16 +++++++++ src/ui/widget/scalar-unit.cpp | 16 +++++++++ src/ui/widget/scalar-unit.h | 2 ++ src/ui/widget/unit-menu.cpp | 13 +++++++ src/ui/widget/unit-menu.h | 1 + 18 files changed, 212 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 8ec09d11e..76582ab05 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -59,7 +59,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View int steps = module->get_param_int("num-steps"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least @@ -97,10 +97,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View if (offset < 0.0) { /* Doing an inset here folks */ offset *= -1.0; - prefs->setDouble("/options/defaultoffsetwidth/value", offset); + prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px"); sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL); } else if (offset > 0.0) { - prefs->setDouble("/options/defaultoffsetwidth/value", offset); + prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px"); sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL); } @@ -110,7 +110,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View Inkscape::GC::release(new_group); } - prefs->setDouble("/options/defaultoffsetwidth/value", old_offset); + prefs->setDoubleUnit("/options/defaultoffsetwidth/value", old_offset, "px"); selection->clear(); selection->add(items.begin(), items.end()); diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index b98ae09fc..007fa549a 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -497,7 +497,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) SPGradientContext *rc = SP_GRADIENT_CONTEXT(event_context); event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - double const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px + double const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px GrDrag *drag = event_context->_grdrag; g_assert (drag); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 607bdaedc..64137d56f 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -989,7 +989,7 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) gint ret = FALSE; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px + gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px switch (get_group0_keyval (&event->key)) { diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 124a2ae51..62744bd53 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -238,7 +238,7 @@ static char const preferences_skeleton[] = " " " " " " -" \n" +" \n" " \n" " \n" " \n" @@ -258,8 +258,8 @@ static char const preferences_skeleton[] = " preserveblack=\"0\"\n" " uri=\"\" />\n" " \n" -" \n" -" \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/preferences.cpp b/src/preferences.cpp index 94fbc7257..444acfcac 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -23,6 +23,7 @@ #include "xml/node-observer.h" #include "xml/node-iterators.h" #include "xml/attribute-record.h" +#include "util/units.h" #define PREFERENCES_FILE_NAME "preferences.xml" @@ -452,6 +453,22 @@ void Preferences::setDouble(Glib::ustring const &pref_path, double value) _setRawValue(pref_path, buf); } +/** + * Set a floating point attribute of a preference. + * + * @param pref_path Path of the preference to modify. + * @param value The new value of the pref attribute. + * @param unit_abbr The string of the unit (abbreviated). + */ +void Preferences::setDoubleUnit(Glib::ustring const &pref_path, double value, Glib::ustring const &unit_abbr) +{ + gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; + g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); + Glib::ustring str(buf); + str += unit_abbr; + _setRawValue(pref_path, str.c_str()); +} + void Preferences::setColor(Glib::ustring const &pref_path, guint32 value) { gchar buf[16]; @@ -745,11 +762,38 @@ double Preferences::_extractDouble(Entry const &v) return g_ascii_strtod(s, NULL); } +double Preferences::_extractDouble(Entry const &v, Glib::ustring const &requested_unit) +{ + static Inkscape::Util::UnitTable unit_table; // load the unit_table once by making it static + + double val = _extractDouble(v); + Glib::ustring unit = _extractUnit(v); + + return val * (unit_table.getUnit(unit).factor / unit_table.getUnit(requested_unit).factor); +} + Glib::ustring Preferences::_extractString(Entry const &v) { return Glib::ustring(static_cast(v._value)); } +Glib::ustring Preferences::_extractUnit(Entry const &v) +{ + gchar const *str = static_cast(v._value); + gchar const *e; + g_ascii_strtod(str, (char **) &e); + if (e == str) { + return ""; + } + + if (e[0] == 0) { + /* Unitless */ + return ""; + } else { + return Glib::ustring(e); + } +} + guint32 Preferences::_extractColor(Entry const &v) { gchar const *s = static_cast(v._value); diff --git a/src/preferences.h b/src/preferences.h index c79a7377d..64bb6ac4f 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -159,9 +159,10 @@ public: /** * Interpret the preference as a floating point value. * - * @param def Default value if the preference is not set. + * @param def Default value if the preference is not set. + * @param unit Specifies the unit of the returned result. Will be ignored when equal to "". If the preference has no unit set, the default unit will be assumed. */ - inline double getDouble(double def=0.0) const; + inline double getDouble(double def=0.0, Glib::ustring const &unit = "") const; /** * Interpret the preference as a limited floating point value. @@ -172,8 +173,9 @@ public: * @param def Default value if the preference is not set. * @param min Minimum value allowed to return. * @param max Maximum value allowed to return. + * @param unit Specifies the unit of the returned result. Will be ignored when equal to "". If the preference has no unit set, the default unit will be assumed. */ - inline double getDoubleLimited(double def=0.0, double min=DBL_MIN, double max=DBL_MAX) const; + inline double getDoubleLimited(double def=0.0, double min=DBL_MIN, double max=DBL_MAX, Glib::ustring const &unit = "") const; /** * Interpret the preference as an UTF-8 string. @@ -182,6 +184,11 @@ public: */ inline Glib::ustring getString() const; + /** + * Interpret the preference as a number followed by a unit (without space), and return this unit string. + */ + inline Glib::ustring getUnit() const; + /** * Interpret the preference as an RGBA color value. */ @@ -316,8 +323,8 @@ public: return getEntry(pref_path).getIntLimited(def, min, max); } - double getDouble(Glib::ustring const &pref_path, double def=0.0) { - return getEntry(pref_path).getDouble(def); + double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit = "") { + return getEntry(pref_path).getDouble(def, unit); } /** @@ -330,9 +337,10 @@ public: * @param def The default value to return if the preference is not set. * @param min Minimum value to return. * @param max Maximum value to return. + * @param unit Specifies the unit of the returned result. Will be ignored when equal to "". If the preference has no unit set, the default unit will be assumed. */ - double getDoubleLimited(Glib::ustring const &pref_path, double def=0.0, double min=DBL_MIN, double max=DBL_MAX) { - return getEntry(pref_path).getDoubleLimited(def, min, max); + double getDoubleLimited(Glib::ustring const &pref_path, double def=0.0, double min=DBL_MIN, double max=DBL_MAX, Glib::ustring const &unit = "") { + return getEntry(pref_path).getDoubleLimited(def, min, max, unit); } /** @@ -344,6 +352,15 @@ public: return getEntry(pref_path).getString(); } + /** + * Retrieve the unit string. + * + * @param pref_path Path to the retrieved preference. + */ + Glib::ustring getUnit(Glib::ustring const &pref_path) { + return getEntry(pref_path).getUnit(); + } + guint32 getColor(Glib::ustring const &pref_path, guint32 def=0x000000ff) { return getEntry(pref_path).getColor(def); } @@ -398,6 +415,11 @@ public: */ void setDouble(Glib::ustring const &pref_path, double value); + /** + * Set a floating point value with unit. + */ + void setDoubleUnit(Glib::ustring const &pref_path, double value, Glib::ustring const &unit_abbr); + /** * Set an UTF-8 string value. */ @@ -484,7 +506,9 @@ protected: bool _extractBool(Entry const &v); int _extractInt(Entry const &v); double _extractDouble(Entry const &v); + double _extractDouble(Entry const &v, Glib::ustring const &requested_unit); Glib::ustring _extractString(Entry const &v); + Glib::ustring _extractUnit(Entry const &v); guint32 _extractColor(Entry const &v); SPCSSAttr *_extractStyle(Entry const &v); SPCSSAttr *_extractInheritedStyle(Entry const &v); @@ -566,21 +590,28 @@ inline int Preferences::Entry::getIntLimited(int def, int min, int max) const } } -inline double Preferences::Entry::getDouble(double def) const +inline double Preferences::Entry::getDouble(double def, Glib::ustring const &unit) const { if (!this->isValid()) { return def; - } else { + } else if (unit.length() == 0) { return Inkscape::Preferences::get()->_extractDouble(*this); + } else { + return Inkscape::Preferences::get()->_extractDouble(*this, unit); } } -inline double Preferences::Entry::getDoubleLimited(double def, double min, double max) const +inline double Preferences::Entry::getDoubleLimited(double def, double min, double max, Glib::ustring const &unit) const { if (!this->isValid()) { return def; } else { - double val = Inkscape::Preferences::get()->_extractDouble(*this); + double val = def; + if (unit.length() == 0) { + val = Inkscape::Preferences::get()->_extractDouble(*this); + } else { + val = Inkscape::Preferences::get()->_extractDouble(*this, unit); + } return ( val >= min && val <= max ? val : def ); } } @@ -594,6 +625,15 @@ inline Glib::ustring Preferences::Entry::getString() const } } +inline Glib::ustring Preferences::Entry::getUnit() const +{ + if (!this->isValid()) { + return ""; + } else { + return Inkscape::Preferences::get()->_extractUnit(*this); + } +} + inline guint32 Preferences::Entry::getColor(guint32 def) const { if (!this->isValid()) { diff --git a/src/select-context.cpp b/src/select-context.cpp index e6d78975b..640aae9ee 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -867,8 +867,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } } - gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px - gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000); + gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px + gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000, "px"); int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); switch (get_group0_keyval (&event->key)) { diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 0e27ce26d..ac2acf330 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1264,7 +1264,7 @@ void sp_selected_path_offset(SPDesktop *desktop) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); sp_selected_path_do_offset(desktop, true, prefOffset); } @@ -1272,7 +1272,7 @@ void sp_selected_path_inset(SPDesktop *desktop) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); sp_selected_path_do_offset(desktop, false, prefOffset); } @@ -1398,7 +1398,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); } if (o_width < 0.01) diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 7963dd512..81bd4dba0 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -249,17 +249,17 @@ void InkscapePreferences::initPageSteps() { this->AddPage(_page_steps, _("Steps"), PREFS_PAGE_STEPS); - _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false); + _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); //nudgedistance is limited to 1000 in select-context.cpp: use the same limit here - _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, _("px"), - _("Pressing an arrow key moves selected object(s) or node(s) by this distance (in px units)"), false); - _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false); + _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, "", + _("Pressing an arrow key moves selected object(s) or node(s) by this distance"), false); + _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); //defaultscale is limited to 1000 in select-context.cpp: use the same limit here - _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, _("px"), - _("Pressing > or < scales selection up or down by this increment (in px units)"), false); - _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 1.0, 2.0, false, false); - _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, _("px"), - _("Inset and Outset commands displace the path by this distance (in px units)"), false); + _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, "", + _("Pressing > or < scales selection up or down by this increment"), false); + _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); + _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, "", + _("Inset and Outset commands displace the path by this distance"), false); _steps_compass.init ( _("Compass-like display of angles"), "/options/compassangledisplay/value", true); _page_steps.add_line( false, "", _steps_compass, "", _("When on, angles are displayed with 0 at north, 0 to 360 range, positive clockwise; otherwise with 0 at east, -180 to 180 range, positive counterclockwise")); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index a20278551..eede9eafe 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -178,10 +178,10 @@ protected: UI::Widget::PrefCombo _steps_rot_snap; UI::Widget::PrefCheckButton _steps_compass; - UI::Widget::PrefSpinButton _steps_arrow; - UI::Widget::PrefSpinButton _steps_scale; - UI::Widget::PrefSpinButton _steps_inset; - UI::Widget::PrefSpinButton _steps_zoom; + UI::Widget::PrefSpinUnit _steps_arrow; + UI::Widget::PrefSpinUnit _steps_scale; + UI::Widget::PrefSpinUnit _steps_inset; + UI::Widget::PrefSpinButton _steps_zoom; UI::Widget::PrefRadioButton _t_sel_trans_obj; UI::Widget::PrefRadioButton _t_sel_trans_outl; diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 1fb98d78f..13da4a712 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -432,7 +432,7 @@ bool ControlPointSelection::_keyboardMove(GdkEventKey const &event, Geom::Point delta /= _desktop->current_zoom(); } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); + double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); delta *= nudge; } @@ -533,7 +533,7 @@ bool ControlPointSelection::_keyboardScale(GdkEventKey const &event, int dir) length_change = 1.0 / _desktop->current_zoom() * dir; } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000); + length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000, "px"); length_change *= dir; } double scale = (maxext + length_change) / maxext; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 7c2013872..52286c6cc 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -727,7 +727,7 @@ void PathManipulator::scaleHandle(Node *n, int which, int dir, bool pixel) length_change = 1.0 / _desktop->current_zoom() * dir; } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000); + length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000, "px"); length_change *= dir; } diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index f92e2518d..9cf80153a 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -255,6 +255,45 @@ void PrefSpinButton::on_value_changed() } } +void PrefSpinUnit::init(Glib::ustring const &prefs_path, + double lower, double upper, double step_increment, + double default_value, UnitType unit_type, Glib::ustring const &default_unit) +{ + _prefs_path = prefs_path; + _is_percent = (unit_type == UNIT_TYPE_DIMENSIONLESS); + + setUnitType(unit_type); + setUnit(default_unit); + setRange (lower, upper); /// @fixme this disregards changes of units + setIncrements (step_increment, 0); + if (step_increment < 0.1) { + setDigits(4); + } else { + setDigits(2); + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper); + Glib::ustring unitstr = prefs->getUnit(prefs_path); + if (unitstr.length() == 0) { + unitstr = default_unit; + // write the assumed unit to preferences: + prefs->setDoubleUnit(_prefs_path, value, unitstr); + } + setValue(value, unitstr); + + signal_value_changed().connect_notify(sigc::mem_fun(*this, &PrefSpinUnit::on_my_value_changed)); +} + +void PrefSpinUnit::on_my_value_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (getWidget()->is_visible()) //only take action if user changed value + { + prefs->setDoubleUnit(_prefs_path, getValue(getUnit().abbr), getUnit().abbr); + } +} + const double ZoomCorrRuler::textsize = 7; const double ZoomCorrRuler::textpadding = 5; diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 758ab38cd..6caab11ae 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -33,6 +33,7 @@ #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" #include "ui/widget/spinbutton.h" +#include "ui/widget/scalar-unit.h" namespace Inkscape { namespace UI { @@ -82,6 +83,21 @@ protected: void on_value_changed(); }; +class PrefSpinUnit : public ScalarUnit +{ +public: + PrefSpinUnit() : ScalarUnit("", "") {}; + + void init(Glib::ustring const &prefs_path, + double lower, double upper, double step_increment, + double default_value, + UnitType unit_type, Glib::ustring const &default_unit); +protected: + Glib::ustring _prefs_path; + bool _is_percent; + void on_my_value_changed(); +}; + class ZoomCorrRuler : public Gtk::DrawingArea { public: ZoomCorrRuler(int width = 100, int height = 20); diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index e713f3e06..1c0fdff68 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -130,6 +130,22 @@ ScalarUnit::setUnit(Glib::ustring const &unit) { return true; } +/** Adds the unit type to the ScalarUnit widget */ +void +ScalarUnit::setUnitType(UnitType unit_type) { + g_assert(_unit_menu != NULL); + _unit_menu->setUnitType(unit_type); + lastUnits = _unit_menu->getUnitAbbr(); +} + +/** Resets the unit type for the ScalarUnit widget */ +void +ScalarUnit::resetUnitType(UnitType unit_type) { + g_assert(_unit_menu != NULL); + _unit_menu->resetUnitType(unit_type); + lastUnits = _unit_menu->getUnitAbbr(); +} + /** Gets the object for the currently selected unit */ Unit ScalarUnit::getUnit() const { diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index 4e08d63f4..ed3728e69 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -45,6 +45,8 @@ public: double getValue(Glib::ustring const &units) const; bool setUnit(Glib::ustring const &units); + void setUnitType(UnitType unit_type); + void resetUnitType(UnitType unit_type); void setValue(double number, Glib::ustring const &units); void setValueKeepUnit(double number, Glib::ustring const &units); void setValue(double number); diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index b4271762c..5c68f7196 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -54,6 +54,19 @@ UnitMenu::setUnitType(UnitType unit_type) return true; } +/** Removes all unit entries, then adds the unit type to the widget. + This extracts the corresponding + units from the unit map matching the given type, and appends them + to the dropdown widget. It causes the primary unit for the given + unit_type to be selected. */ +bool +UnitMenu::resetUnitType(UnitType unit_type) +{ + clear_text(); + + return setUnitType(unit_type); +} + /** Returns the Unit object corresponding to the current selection in the dropdown widget */ Unit diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 60a9702b4..efeb10ead 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -28,6 +28,7 @@ public: virtual ~UnitMenu(); bool setUnitType(UnitType unit_type); + bool resetUnitType(UnitType unit_type); bool setUnit(Glib::ustring const &unit); -- cgit v1.2.3 From 6d0280ef0e02c447a9dfb5c91a1a506cee2333b6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Apr 2011 15:31:32 +0200 Subject: fix duplicate units in Preferences > Steps (bzr r10178) --- src/ui/widget/preferences-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 9cf80153a..68faa3c66 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -262,7 +262,7 @@ void PrefSpinUnit::init(Glib::ustring const &prefs_path, _prefs_path = prefs_path; _is_percent = (unit_type == UNIT_TYPE_DIMENSIONLESS); - setUnitType(unit_type); + resetUnitType(unit_type); setUnit(default_unit); setRange (lower, upper); /// @fixme this disregards changes of units setIncrements (step_increment, 0); -- cgit v1.2.3 From 899a64ccd59dfede80a93501e5ef13b5f0a724d0 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 17 Apr 2011 16:32:40 -0700 Subject: Restore comment needed in *shared* code file. (bzr r10179) --- src/ege-adjustment-action.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index bfab201f4..0a4dde320 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -39,6 +39,8 @@ * * ***** END LICENSE BLOCK ***** */ +/* Note: this file should be kept compilable as both .cpp and .c */ + #include #include -- cgit v1.2.3 From 1feebda40c5bcd8890794fb271989e8673875460 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 18 Apr 2011 23:36:02 +0200 Subject: Added mnemonics for font dialog (Bug #170765) (bzr r10182) --- src/dialogs/text-edit.cpp | 11 +++++------ src/widgets/font-selector.cpp | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index d741e2de0..d46f62d17 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -203,7 +203,7 @@ sp_text_edit_dialog (void) // Font tab { - GtkWidget *l = gtk_label_new (_("Font")); + GtkWidget *l = gtk_label_new_with_mnemonic (_("_Font")); GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN); gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l); @@ -330,7 +330,7 @@ sp_text_edit_dialog (void) gtk_box_pack_start (GTK_BOX (l_vb), row, FALSE, FALSE, 0); } - + { GtkWidget *row = gtk_hbox_new (FALSE, VB_MARGIN); @@ -343,7 +343,6 @@ sp_text_edit_dialog (void) { GtkWidget *row = gtk_hbox_new (FALSE, VB_MARGIN); - GtkWidget *c = gtk_combo_new (); gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE); gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE); @@ -359,7 +358,7 @@ sp_text_edit_dialog (void) gtk_combo_set_popdown_strings ((GtkCombo *) c, sl); g_list_free (sl); } - + g_signal_connect ( (GObject *) ((GtkCombo *) c)->entry, "changed", (GCallback) sp_text_edit_dialog_line_spacing_changed, @@ -380,7 +379,7 @@ sp_text_edit_dialog (void) // Text tab { - GtkWidget *l = gtk_label_new (_("Text")); + GtkWidget *l = gtk_label_new_with_mnemonic (_("_Text")); GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN); gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l); @@ -427,7 +426,7 @@ sp_text_edit_dialog (void) gtk_box_pack_start (GTK_BOX (mainvb), hb, FALSE, FALSE, 0); { - GtkWidget *b = gtk_button_new_with_label (_("Set as default")); + GtkWidget *b = gtk_button_new_with_mnemonic (_("Set as _default")); g_signal_connect ( G_OBJECT (b), "clicked", G_CALLBACK (sp_text_edit_dialog_set_default), dlg ); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 71e9563cd..6cc73e42f 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -154,7 +154,10 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_box_set_spacing(GTK_BOX(fsel), 4); /* Family frame */ - GtkWidget *f = gtk_frame_new(_("Font family")); + GtkWidget *ft = gtk_label_new_with_mnemonic(_("F_ont family")); + GtkWidget *f = gtk_frame_new(NULL); + gtk_frame_set_label_widget ((GtkFrame*)f, ft); + gtk_widget_show (f); gtk_box_pack_start (GTK_BOX(fsel), f, TRUE, TRUE, 0); @@ -178,6 +181,7 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_tree_view_set_model (GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL (Glib::unwrap (store))); gtk_container_add(GTK_CONTAINER(sw), fsel->family_treeview); gtk_widget_show_all (sw); + gtk_label_set_mnemonic_widget((GtkLabel*)ft, fsel->family_treeview); GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->family_treeview)); g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_family_select_row), fsel); @@ -185,7 +189,9 @@ static void sp_font_selector_init(SPFontSelector *fsel) /* Style frame */ - f = gtk_frame_new(C_("Font selector", "Style")); + ft = gtk_label_new_with_mnemonic(C_("Font selector", "_Style")); + f = gtk_frame_new(NULL); + gtk_frame_set_label_widget ((GtkFrame*)f, ft); gtk_widget_show(f); gtk_box_pack_start(GTK_BOX (fsel), f, TRUE, TRUE, 0); @@ -210,6 +216,7 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(fsel->style_treeview), FALSE); gtk_container_add(GTK_CONTAINER(sw), fsel->style_treeview); gtk_widget_show_all (sw); + gtk_label_set_mnemonic_widget((GtkLabel*)ft, fsel->style_treeview); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->style_treeview)); g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel); @@ -223,13 +230,14 @@ static void sp_font_selector_init(SPFontSelector *fsel) g_signal_connect (G_OBJECT(fsel->size), "changed", G_CALLBACK (sp_font_selector_size_changed), fsel); gtk_box_pack_end (GTK_BOX(hb), fsel->size, FALSE, FALSE, 0); - GtkWidget *l = gtk_label_new(_("Font size:")); + GtkWidget *l = gtk_label_new_with_mnemonic(_("Font si_ze:")); gtk_widget_show_all (l); gtk_box_pack_end(GTK_BOX (hb), l, FALSE, FALSE, 0); + gtk_label_set_mnemonic_widget((GtkLabel*)l, fsel->size); for (unsigned int n = 0; sizes[n]; ++n) { - gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), sizes[n]); + gtk_combo_box_append_text ((GtkComboBox *)fsel->size, sizes[n]); } gtk_widget_show_all (fsel->size); -- cgit v1.2.3 From 84766315ff4f59563bc8e6e100b6fc1d435df6f7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 18 Apr 2011 23:14:35 -0700 Subject: Restore modularity to adjustment action. (bzr r10184) --- src/ege-adjustment-action.cpp | 47 +++++++++++++++++++++++------------------- src/ege-adjustment-action.h | 18 ++++++++++++++++ src/widgets/select-toolbar.cpp | 17 +++++++++++++++ src/widgets/toolbox.cpp | 15 ++++++++++++++ 4 files changed, 76 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 0a4dde320..9c01b4c7c 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -1,5 +1,3 @@ - - /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * */ @@ -64,8 +62,6 @@ #include "icon-size.h" #include "ege-adjustment-action.h" -#include "ui/widget/spinbutton.h" - static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ); static void ege_adjustment_action_init( EgeAdjustmentAction* action ); @@ -89,14 +85,15 @@ static void egeAct_free_all_descriptions( EgeAdjustmentAction* action ); static GtkActionClass* gParentClass = 0; +static EgeCreateAdjWidgetCB gFactoryCb = 0; static GQuark gDataName = 0; enum { APPEARANCE_UNKNOWN = -1, APPEARANCE_NONE = 0, - APPEARANCE_FULL, // label, then all choices represented by separate buttons - APPEARANCE_COMPACT, // label, then choices in a drop-down menu - APPEARANCE_MINIMAL, // no label, just choices in a drop-down menu + APPEARANCE_FULL, /* label, then all choices represented by separate buttons */ + APPEARANCE_COMPACT, /* label, then choices in a drop-down menu */ + APPEARANCE_MINIMAL, /* no label, just choices in a drop-down menu */ }; #if GTK_CHECK_VERSION(2,12,0) @@ -197,6 +194,7 @@ static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ) gDataName = g_quark_from_string("ege-adj-action"); + objClass->finalize = ege_adjustment_action_finalize; objClass->get_property = ege_adjustment_action_get_property; @@ -283,6 +281,11 @@ static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ) } } +void ege_adjustment_action_set_compact_tool_factory( EgeCreateAdjWidgetCB factoryCb ) +{ + gFactoryCb = factoryCb; +} + static void ege_adjustment_action_init( EgeAdjustmentAction* action ) { action->private_data = EGE_ADJUSTMENT_ACTION_GET_PRIVATE( action ); @@ -383,11 +386,11 @@ static void ege_adjustment_action_get_property( GObject* obj, guint propId, GVal case PROP_ICON_ID: g_value_set_string( value, action->private_data->iconId ); - break; + break; case PROP_ICON_SIZE: g_value_set_int( value, action->private_data->iconSize ); - break; + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); @@ -836,7 +839,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_object_get_property( G_OBJECT(action), "short_label", &value ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { - // Slider + /* Slider */ gchar *leakyForNow = g_value_dup_string( &value ); spinbutton = gtk_hscale_new( act->private_data->adj); gtk_widget_set_size_request(spinbutton, 100, -1); @@ -850,9 +853,11 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_scale_button_set_icons( GTK_SCALE_BUTTON(spinbutton), floogles ); #endif /* GTK_CHECK_VERSION(2,12,0) */ } else { - //spinbutton = gtk_spin_button_new( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); - Inkscape::UI::Widget::SpinButton *inkscape_spinbutton = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(act->private_data->adj, true), act->private_data->climbRate, act->private_data->digits); - spinbutton = GTK_WIDGET( inkscape_spinbutton->gobj() ); + if ( gFactoryCb ) { + spinbutton = gFactoryCb( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); + } else { + spinbutton = gtk_spin_button_new( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); + } } item = GTK_WIDGET( gtk_tool_item_new() ); @@ -869,22 +874,22 @@ static GtkWidget* create_tool_item( GtkAction* action ) } gtk_tooltips_set_tip( act->private_data->toolTips, spinbutton, tipstr, 0 ); } - g_value_unset( &tooltip ); + g_value_unset( &tooltip ); } if ( act->private_data->appearanceMode != APPEARANCE_FULL ) { - GtkWidget* filler1 = gtk_label_new(" "); - gtk_box_pack_start( GTK_BOX(hb), filler1, FALSE, FALSE, 0 ); + GtkWidget* filler1 = gtk_label_new(" "); + gtk_box_pack_start( GTK_BOX(hb), filler1, FALSE, FALSE, 0 ); - // Use an icon if available or use short-label - if ( act->private_data->iconId && strcmp( act->private_data->iconId, "" ) != 0 ) { + /* Use an icon if available or use short-label */ + if ( act->private_data->iconId && strcmp( act->private_data->iconId, "" ) != 0 ) { GtkWidget* icon = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 ); - } else { + } else { GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" ); gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); - } + } } if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { @@ -923,7 +928,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) act->private_data->toolPost( item ); } - g_value_unset( &value ); + g_value_unset( &value ); } else { item = gParentClass->create_tool_item( action ); } diff --git a/src/ege-adjustment-action.h b/src/ege-adjustment-action.h index 4a8a172e2..b7da6a499 100644 --- a/src/ege-adjustment-action.h +++ b/src/ege-adjustment-action.h @@ -87,6 +87,24 @@ struct _EgeAdjustmentActionClass /** Standard Gtk type function */ GType ege_adjustment_action_get_type( void ); + +/* + * Note: This normally could be implemented via a GType property for the class to construct, + * but gtkmm classes implemented in C++ only will often not funciton properly. + * + */ + +/** Callback type for widgets creation factory */ +typedef GtkWidget* (*EgeCreateAdjWidgetCB)( GtkAdjustment *adjustment, gdouble climb_rate, guint digits ); + +/** + * Sets a factory callback to be used to create the specific widget. + * + * @param factoryCb the callback to use to create custom widgets, NULL to use the default. + */ +void ege_adjustment_action_set_compact_tool_factory( EgeCreateAdjWidgetCB factoryCb ); + + /** * Creates a new EgeAdjustmentAction instance. * This is a GtkAction subclass that manages a value stored in a diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 89253983b..e08b4ac61 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -23,6 +23,7 @@ #include "widgets/spw-utilities.h" #include "widgets/widget-sizes.h" #include "widgets/spinbutton-events.h" +#include "ui/widget/spinbutton.h" #include "widgets/icon.h" #include "widgets/sp-widget.h" @@ -255,6 +256,16 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE)); } +static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits ) +{ + Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits); + inkSpinner = Gtk::manage( inkSpinner ); + GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() ); + return widget; +} + +// TODO create_adjustment_action appears to be a rogue tile copy from toolbox.cpp. Resolve it to be unified: + static EgeAdjustmentAction * create_adjustment_action( gchar const *name, gchar const *label, gchar const *shortLabel, @@ -266,6 +277,12 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name, gchar const *tooltip, gboolean altx ) { + static bool init = false; + if ( !init ) { + init = true; + ege_adjustment_action_set_compact_tool_factory( createCustomSlider ); + } + GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, lower, 1e6, SPIN_STEP, SPIN_PAGE_STEP, 0 ) ); if (tracker) { tracker->addAdjustment(adj); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index fe87bc4e2..8496ec0d0 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -100,6 +100,7 @@ #include "../verbs.h" #include "../widgets/button.h" #include "../widgets/spinbutton-events.h" +#include "ui/widget/spinbutton.h" #include "../widgets/spw-utilities.h" #include "../widgets/widget-sizes.h" #include "../xml/attribute-record.h" @@ -1052,6 +1053,14 @@ GtkWidget *ToolboxFactory::createSnapToolbox() return toolboxNewCommon( tb, BAR_SNAP, GTK_POS_LEFT ); } +static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits ) +{ + Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits); + inkSpinner = Gtk::manage( inkSpinner ); + GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() ); + return widget; +} + static EgeAdjustmentAction * create_adjustment_action( gchar const *name, gchar const *label, gchar const *shortLabel, gchar const *tooltip, Glib::ustring const &path, gdouble def, @@ -1064,6 +1073,12 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name, void (*callback)(GtkAdjustment *, GObject *), gdouble climb = 0.1, guint digits = 3, double factor = 1.0 ) { + static bool init = false; + if ( !init ) { + init = true; + ege_adjustment_action_set_compact_tool_factory( createCustomSlider ); + } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs->getDouble(path, def) * factor, lower, upper, step, page, 0 ) ); -- cgit v1.2.3 From 6b38df080f453bfade2625985d2e6753e9a3f196 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 21 Apr 2011 17:14:10 +0200 Subject: UI. New mnemonics (see Bug #768277 , Add mnemonics for menu items without verbs / default key mapping). Fixed bugs: - https://launchpad.net/bugs/768277 (bzr r10187) --- src/interface.cpp | 6 +++--- src/menus-skeleton.h | 2 +- src/verbs.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 4ac82a509..f27700c25 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -829,11 +829,11 @@ sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) { //sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu", // checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands", + sp_ui_menu_append_check_item_from_verb(m, view, _("_Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands", checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("Snap Controls Bar"), _("Show or hide the snapping controls"), "snaptoolbox", + sp_ui_menu_append_check_item_from_verb(m, view, _("Sn_ap Controls Bar"), _("Show or hide the snapping controls"), "snaptoolbox", checkitem_toggled, checkitem_update, 0); - sp_ui_menu_append_check_item_from_verb(m, view, _("Tool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel", + sp_ui_menu_append_check_item_from_verb(m, view, _("T_ool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel", checkitem_toggled, checkitem_update, 0); sp_ui_menu_append_check_item_from_verb(m, view, _("_Toolbox"), _("Show or hide the main toolbox (on the left)"), "toolbox", checkitem_toggled, checkitem_update, 0); diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index f1b633865..080163d48 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -126,7 +126,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" diff --git a/src/verbs.cpp b/src/verbs.cpp index 1ad68b792..4dbe15a03 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2298,7 +2298,7 @@ Verb *Verb::_base_verbs[] = { N_("Apply the path effect of the copied object to selection"), NULL), new EditVerb(SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, "RemoveLivePathEffect", N_("Remove Path _Effect"), N_("Remove any path effects from selected objects"), NULL), - new EditVerb(SP_VERB_EDIT_REMOVE_FILTER, "RemoveFilter", N_("Remove Filters"), + new EditVerb(SP_VERB_EDIT_REMOVE_FILTER, "RemoveFilter", N_("_Remove Filters"), N_("Remove any filters from selected objects"), NULL), new EditVerb(SP_VERB_EDIT_DELETE, "EditDelete", N_("_Delete"), N_("Delete selection"), GTK_STOCK_DELETE), @@ -2645,7 +2645,7 @@ Verb *Verb::_base_verbs[] = { N_("Edit document metadata (to be saved with the document)"), INKSCAPE_ICON_DOCUMENT_METADATA ), new DialogVerb(SP_VERB_DIALOG_FILL_STROKE, "DialogFillStroke", N_("_Fill and Stroke..."), N_("Edit objects' colors, gradients, arrowheads, and other fill and stroke properties..."), INKSCAPE_ICON_DIALOG_FILL_AND_STROKE), - new DialogVerb(SP_VERB_DIALOG_GLYPHS, "DialogGlyphs", N_("Glyphs..."), + new DialogVerb(SP_VERB_DIALOG_GLYPHS, "DialogGlyphs", N_("Gl_yphs..."), N_("Select characters from a glyphs palette"), GTK_STOCK_SELECT_FONT), // TRANSLATORS: "Swatches" means: color samples new DialogVerb(SP_VERB_DIALOG_SWATCHES, "DialogSwatches", N_("S_watches..."), @@ -2690,7 +2690,7 @@ Verb *Verb::_base_verbs[] = { N_("View Layers"), INKSCAPE_ICON_DIALOG_LAYERS), new DialogVerb(SP_VERB_DIALOG_LIVE_PATH_EFFECT, "DialogLivePathEffect", N_("Path E_ffect Editor..."), N_("Manage, edit, and apply path effects"), NULL), - new DialogVerb(SP_VERB_DIALOG_FILTER_EFFECTS, "DialogFilterEffects", N_("Filter Editor..."), + new DialogVerb(SP_VERB_DIALOG_FILTER_EFFECTS, "DialogFilterEffects", N_("Filter _Editor..."), N_("Manage, edit, and apply SVG filters"), NULL), new DialogVerb(SP_VERB_DIALOG_SVG_FONTS, "DialogSVGFonts", N_("SVG Font Editor..."), N_("Edit SVG fonts"), NULL), @@ -2727,9 +2727,9 @@ Verb *Verb::_base_verbs[] = { N_("Miscellaneous tips and tricks"), NULL/*"tutorial_tips"*/), /* Effect -- renamed Extension */ - new EffectLastVerb(SP_VERB_EFFECT_LAST, "EffectLast", N_("Previous Extension"), + new EffectLastVerb(SP_VERB_EFFECT_LAST, "EffectLast", N_("Previous Exte_nsion"), N_("Repeat the last extension with the same settings"), NULL), - new EffectLastVerb(SP_VERB_EFFECT_LAST_PREF, "EffectLastPref", N_("Previous Extension Settings..."), + new EffectLastVerb(SP_VERB_EFFECT_LAST_PREF, "EffectLastPref", N_("_Previous Extension Settings..."), N_("Repeat the last extension with new settings"), NULL), /* Fit Page */ -- cgit v1.2.3 From 51b899c859afdc3b0d7743e20b558bfc0e54c340 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 21 Apr 2011 20:04:14 +0200 Subject: Font Editor. Fix for Bug #706506 (Crash when kerning an empty pair). Fixed bugs: - https://launchpad.net/bugs/706506 (bzr r10189) --- src/ui/dialog/svg-fonts-dialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index d836bfa22..667d01de7 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -162,7 +162,10 @@ void GlyphComboBox::update(SPFont* spfont){ } void SvgFontsDialog::on_kerning_value_changed(){ - if (!this->kerning_pair) return; + if (!get_selected_kerning_pair()) { + return; + } + SPDocument* document = sp_desktop_document(this->getDesktop()); //TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done -- cgit v1.2.3 From fb8198311fa62b09e3fdad9546e92420825ebcd2 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 23 Apr 2011 15:18:35 -0700 Subject: Fixed warning to use GUI when appropriate. (bzr r10191) --- src/extension/system.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/extension/system.cpp b/src/extension/system.cpp index cf58f2733..aa5731985 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -35,6 +35,8 @@ #include "implementation/xslt.h" #include "xml/rebase-hrefs.h" #include "io/sys.h" +#include "inkscape.h" + /* #include "implementation/plugin.h" */ namespace Inkscape { @@ -64,8 +66,7 @@ static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementatio * * Lastly, the open function is called in the module itself. */ -SPDocument * -open(Extension *key, gchar const *filename) +SPDocument *open(Extension *key, gchar const *filename) { Input *imod = NULL; if (key == NULL) { @@ -93,8 +94,9 @@ open(Extension *key, gchar const *filename) throw Input::open_failed(); } - if (!imod->prefs(filename)) + if (!imod->prefs(filename)) { return NULL; + } SPDocument *doc = imod->open(filename); if (!doc) { @@ -102,11 +104,11 @@ open(Extension *key, gchar const *filename) } if (last_chance_svg) { - /* We can't call sp_ui_error_dialog because we may be - running from the console, in which case calling sp_ui - routines will cause a segfault. See bug 1000350 - bryce */ - // sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG.")); - g_warning(_("Format autodetect failed. The file is being opened as SVG.")); + if ( inkscape_use_gui() ) { + sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG.")); + } else { + g_warning(_("Format autodetect failed. The file is being opened as SVG.")); + } } /* This kinda overkill as most of these are already set, but I want -- cgit v1.2.3 From 8362c4e0211ba58423d6f43de68d18bcc2454e40 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 27 Apr 2011 19:18:49 -0400 Subject: emf import. support for clip rectangle (Bug 383180) Fixed bugs: - https://launchpad.net/bugs/383180 (bzr r10193) --- src/extension/internal/emf-win32-inout.cpp | 67 +++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index cea68c6da..8aa26a213 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -82,6 +82,8 @@ namespace Extension { namespace Internal { static float device_scale = DEVICESCALE; +static RECTL rc_old; +static bool clipset = false; EmfWin32::EmfWin32 (void) // The null constructor { @@ -205,6 +207,7 @@ typedef struct emf_device_context { typedef struct emf_callback_data { Glib::ustring *outsvg; Glib::ustring *path; + Glib::ustring *outdef; EMF_DEVICE_CONTEXT dc[EMF_MAX_DC+1]; // FIXME: This should be dynamic.. int level; @@ -311,6 +314,9 @@ output_style(PEMF_CALLBACK_DATA d, int iType) tmp_style << "stroke-opacity:1;"; } tmp_style << "\" "; + if (clipset) + tmp_style << "\n\tclip-path=\"url(#clipEmfPath" << d->id << ")\" "; + clipset = false; *(d->outsvg) += tmp_style.str().c_str(); } @@ -770,19 +776,20 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * { dbg_str << "\n"; - *(d->outsvg) += "\n"; + *(d->outdef) += "\n"; if (d->pDesc) { - *(d->outsvg) += "\n"; + *(d->outdef) += "\n"; } ENHMETAHEADER *pEmr = (ENHMETAHEADER *) lpEMFR; - tmp_outsvg << "xDPI = 2540; d->yDPI = 2540; @@ -800,15 +807,13 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx) device_scale = PX_PER_MM*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx; - tmp_outsvg << + tmp_outdef << " width=\"" << d->MMX << "mm\"\n" << " height=\"" << d->MMY << "mm\">\n"; -// tmp_outsvg << -// " id=\"" << (d->id++) << "\">\n"; + *(d->outdef) += tmp_outdef.str().c_str(); + *(d->outdef) += ""; // temporary end of header - tmp_outsvg << "\n"; -// "id++) << "\">\n"; + tmp_outsvg << "\n\n\n"; // start of main body if (pEmr->nHandles) { d->n_obj = pEmr->nHandles; @@ -1152,6 +1157,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * assert_empty_path(d, "EMR_EOF"); tmp_outsvg << "\n"; tmp_outsvg << "\n"; + *(d->outsvg) = *(d->outdef) + *(d->outsvg); break; } case EMR_SETPIXELV: @@ -1234,8 +1240,37 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * dbg_str << "\n"; break; case EMR_INTERSECTCLIPRECT: + { dbg_str << "\n"; + + PEMRINTERSECTCLIPRECT pEmr = (PEMRINTERSECTCLIPRECT) lpEMFR; + RECTL rc = pEmr->rclClip; + clipset = true; + if ((rc.left == rc_old.left) && (rc.top == rc_old.top) && (rc.right == rc_old.right) && (rc.bottom == rc_old.bottom)) + break; + rc_old = rc; + + double l = pix_to_x_point( d, rc.left, rc.top ); + double t = pix_to_y_point( d, rc.left, rc.top ); + double r = pix_to_x_point( d, rc.right, rc.bottom ); + double b = pix_to_y_point( d, rc.right, rc.bottom ); + + SVGOStringStream tmp_rectangle; + tmp_rectangle << "\nid) << "\" >"; + tmp_rectangle << "\n"; + tmp_rectangle << "\n"; + + assert_empty_path(d, "EMR_RECTANGLE"); + + *(d->outdef) += tmp_rectangle.str().c_str(); + *(d->path) = ""; break; + } case EMR_SCALEVIEWPORTEXTEX: dbg_str << "\n"; break; @@ -2273,6 +2308,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.outsvg = new Glib::ustring(""); d.path = new Glib::ustring(""); + d.outdef = new Glib::ustring(""); CHAR *ansi_uri = (CHAR *) local_fn; gunichar2 *unicode_fn = g_utf8_to_utf16( local_fn, -1, NULL, NULL, NULL ); @@ -2414,6 +2450,8 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) delete d.outsvg; if (d.path) delete d.path; + if (d.outdef) + delete d.outdef; if (local_fn) g_free(local_fn); if (unicode_fn) @@ -2455,6 +2493,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) delete d.outsvg; delete d.path; + delete d.outdef; if (d.emf_obj) { int i; -- cgit v1.2.3 From 7f81932011c4ad87db74d62a2843949f4a5a3ffe Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 1 May 2011 16:27:28 +0200 Subject: Fix crashes on empty marker definitions. Fixed bugs: - https://launchpad.net/bugs/774834 (bzr r10195) --- src/extension/internal/cairo-renderer.cpp | 12 +++++++----- src/sp-shape.cpp | 12 +++++++----- src/splivarot.cpp | 7 ++++++- 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index dbda82c28..c7c9d3a61 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -170,11 +170,13 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi if (render) { SPItem* marker_item = sp_item_first_item_child(marker); - tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr; - Geom::Affine old_tr = marker_item->transform; - marker_item->transform = tr; - ctx->getRenderer()->renderItem (ctx, marker_item); - marker_item->transform = old_tr; + if (marker_item) { + tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr; + Geom::Affine old_tr = marker_item->transform; + marker_item->transform = tr; + ctx->getRenderer()->renderItem (ctx, marker_item); + marker_item->transform = old_tr; + } } } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 72559c63f..358e2a595 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -725,12 +725,14 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* s } SPItem* marker_item = sp_item_first_item_child( marker ); - tr = marker_item->transform * marker->c2p * tr; + if (marker_item) { + tr = marker_item->transform * marker->c2p * tr; - Geom::Affine old_tr = marker_item->transform; - marker_item->transform = tr; - marker_item->invoke_print (ctx); - marker_item->transform = old_tr; + Geom::Affine old_tr = marker_item->transform; + marker_item->transform = tr; + marker_item->invoke_print (ctx); + marker_item->transform = old_tr; + } } /** * Prepares shape for printing. Handles printing of comments for printing diff --git a/src/splivarot.cpp b/src/splivarot.cpp index ac2acf330..5ff394782 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -607,6 +607,9 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine { SPMarker* marker = SP_MARKER (marker_object); SPItem* marker_item = sp_item_first_item_child(marker_object); + if (!marker_item) { + return; + } Geom::Affine tr(marker_transform); @@ -665,7 +668,9 @@ void item_outline_add_marker( SPObject const *marker_object, Geom::Affine marker tr = marker->c2p * tr; SPItem const * marker_item = sp_item_first_item_child(marker_object); // why only consider the first item? can a marker only consist of a single item (that may be a group)? - item_outline_add_marker_child(marker_item, tr, pathv_in); + if (marker_item) { + item_outline_add_marker_child(marker_item, tr, pathv_in); + } } /** -- cgit v1.2.3 From 58889caa38b152f64fa2968a121edbce44971838 Mon Sep 17 00:00:00 2001 From: Adib Taraben Date: Wed, 4 May 2011 22:45:08 +0200 Subject: more 63734242, missing fraction of patch for gcc 4.6 compatibility (bzr r10196) --- src/2geom/utils.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/2geom/utils.h b/src/2geom/utils.h index ecd1b7283..e90a4623b 100644 --- a/src/2geom/utils.h +++ b/src/2geom/utils.h @@ -33,6 +33,7 @@ * */ +#include #include namespace Geom { -- cgit v1.2.3 From b4a47c1fac39951baab9c209bcdae5914ff4bb3a Mon Sep 17 00:00:00 2001 From: Adib Taraben Date: Thu, 5 May 2011 23:42:21 +0200 Subject: symbol rendering fix for bug:705345 (bzr r10196.1.1) --- src/extension/internal/cairo-renderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index c7c9d3a61..f5504d755 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -544,6 +544,9 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) if (SP_IS_ROOT(item)) { TRACE(("root\n")); return sp_root_render(item, ctx); + } else if (SP_IS_SYMBOL(item)) { + TRACE(("symbol\n")); + return sp_symbol_render(item, ctx); } else if (SP_IS_GROUP(item)) { TRACE(("group\n")); return sp_group_render(item, ctx); @@ -554,9 +557,6 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) TRACE(("use begin---\n")); sp_use_render(item, ctx); TRACE(("---use end\n")); - } else if (SP_IS_SYMBOL(item)) { - TRACE(("symbol\n")); - return sp_symbol_render(item, ctx); } else if (SP_IS_TEXT(item)) { TRACE(("text\n")); return sp_text_render(item, ctx); -- cgit v1.2.3 From a4d0a358424440128cd4c4fb2915ccc4b86f4587 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 5 May 2011 23:21:51 -0700 Subject: Adding initial cut of resource manager. (bzr r10198) --- src/Makefile_insert | 1 + src/desktop.cpp | 7 + src/desktop.h | 1 + src/dir-util.cpp | 218 +++++++++++++---------------- src/dir-util.h | 37 ++++- src/display/curve-test.h | 2 +- src/document-undo.h | 6 +- src/file.cpp | 28 ++-- src/inkscape.cpp | 2 + src/resource-manager.cpp | 272 ++++++++++++++++++++++++++++++++++++ src/resource-manager.h | 49 +++++++ src/sp-image.cpp | 71 ++++------ src/ui/view/edit-widget-interface.h | 4 + src/widgets/desktop-widget.cpp | 19 +++ src/widgets/desktop-widget.h | 7 + src/xml/Makefile_insert | 1 + src/xml/rebase-hrefs-test.h | 126 +++++++++++++++++ src/xml/rebase-hrefs.cpp | 231 +++++++++++++++--------------- src/xml/rebase-hrefs.h | 27 +++- src/xml/repr-action-test.h | 1 - src/xml/repr-io.cpp | 47 +++++-- src/xml/repr.h | 3 + 22 files changed, 840 insertions(+), 320 deletions(-) create mode 100644 src/resource-manager.cpp create mode 100644 src/resource-manager.h create mode 100644 src/xml/rebase-hrefs-test.h (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index 36c9de34f..3a3862437 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -123,6 +123,7 @@ ink_common_sources += \ removeoverlap.cpp removeoverlap.h \ rdf.cpp rdf.h \ rect-context.cpp rect-context.h \ + resource-manager.cpp resource-manager.h \ require-config.h \ round.h \ rubberband.cpp rubberband.h \ diff --git a/src/desktop.cpp b/src/desktop.cpp index a6224a71c..361ed7fea 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -87,6 +87,7 @@ #include "device-manager.h" #include "layer-fns.h" #include "layer-manager.h" +#include "resource-manager.h" #include "event-log.h" #include "display/canvas-grid.h" #include "widgets/desktop-widget.h" @@ -177,6 +178,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid // Temporary workaround for link order issues: Inkscape::DeviceManager::getManager().getDevices(); + Inkscape::ResourceManager::getManager(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _guides_message_context = new Inkscape::MessageContext(const_cast(messageStack())); @@ -1320,6 +1322,11 @@ SPDesktop::presentWindow() _widget->present(); } +bool SPDesktop::showInfoDialog( Glib::ustring const & message ) +{ + return _widget->showInfoDialog( message ); +} + bool SPDesktop::warnDialog (gchar *text) { diff --git a/src/desktop.h b/src/desktop.h index 947e92fe7..6d1bcd194 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -288,6 +288,7 @@ public: void setWindowTransient (void* p, int transient_policy=1); Gtk::Window* getToplevel(); void presentWindow(); + bool showInfoDialog( Glib::ustring const &message ); bool warnDialog (gchar *text); void toggleRulers(); void toggleScrollbars(); diff --git a/src/dir-util.cpp b/src/dir-util.cpp index 67db03628..acec39953 100644 --- a/src/dir-util.cpp +++ b/src/dir-util.cpp @@ -1,9 +1,8 @@ -/** @file - * @brief Utility functions for filenames +/** + * @file + * Utility functions for filenames. */ -#define DIR_UTIL_C - #include #include #include @@ -13,49 +12,37 @@ #include #include -/** Returns a form of \a path relative to \a base if that is easy to construct (e.g. if \a path - appears to be in the directory specified by \a base), otherwise returns \a path. - - N.B. The return value is a pointer into the \a path string. - - \a base is expected to be either NULL or the absolute path of a directory. - - \a path is expected to be an absolute path. - - \see inkscape_abs2rel for a more sophisticated version. - \see prepend_current_dir_if_relative. -*/ -char const * -sp_relative_path_from_path(char const *const path, char const *const base) +std::string sp_relative_path_from_path( std::string const &path, std::string const &base) { - if (base == NULL || path == NULL) { - return path; - } + std::string result; + if ( !base.empty() && !path.empty() ) { + size_t base_len = base.length(); + while (base_len != 0 + && (base[base_len - 1] == G_DIR_SEPARATOR)) + { + --base_len; + } - size_t base_len = strlen(base); - while (base_len != 0 - && (base[base_len - 1] == G_DIR_SEPARATOR)) - { - --base_len; - } + if ( (path.substr(0, base_len) == base.substr(0, base_len)) + && (path[base_len] == G_DIR_SEPARATOR)) + { + size_t retPos = base_len + 1; + while ( (retPos < path.length()) && (path[retPos] == G_DIR_SEPARATOR) ) { + retPos++; + } + if ( (retPos + 1) < path.length() ) { + result = path.substr(retPos); + } + } - if ((memcmp(path, base, base_len) == 0) - && (path[base_len] == G_DIR_SEPARATOR)) - { - char const *ret = path + base_len + 1; - while (*ret == G_DIR_SEPARATOR) { - ++ret; - } - if (*ret != '\0') { - return ret; - } - } - - return path; + } + if ( result.empty() ) { + result = path; + } + return result; } -char const * -sp_extension_from_path(char const *const path) +char const *sp_extension_from_path(char const *const path) { if (path == NULL) { return NULL; @@ -77,25 +64,7 @@ static char const dots[] = {'.', '.', G_DIR_SEPARATOR, '\0'}; static char const *const parent = dots; static char const *const current = dots + 1; -/** - * \brief Convert a relative path name into absolute. If path is already absolute, does nothing except copying path to result. - * - * \param path relative path - * \param base base directory (must be absolute path) - * \param result result buffer - * \param size size of result buffer - * \return != NULL: absolute path - * == NULL: error - -\comment - based on functions by Shigio Yamaguchi. - FIXME:TODO: force it to also do path normalization of the entire resulting path, - i.e. get rid of any .. and . in any place, even if 'path' is already absolute - (now it returns it unchanged in this case) - - */ -char * -inkscape_rel2abs (const char *path, const char *base, char *result, const size_t size) +char *inkscape_rel2abs(const char *path, const char *base, char *result, const size_t size) { const char *pp, *bp; /* endp points the last position which is safe in the result buffer. */ @@ -181,79 +150,77 @@ erange: return (NULL); } -char * -inkscape_abs2rel (const char *path, const char *base, char *result, const size_t size) +char *inkscape_abs2rel(const char *path, const char *base, char *result, const size_t size) { - const char *pp, *bp, *branch; - /* endp points the last position which is safe in the result buffer. */ - const char *endp = result + size - 1; - char *rp; + const char *pp, *bp, *branch; + // endp points the last position which is safe in the result buffer. + const char *endp = result + size - 1; + char *rp; - if (*path != G_DIR_SEPARATOR) + if (*path != G_DIR_SEPARATOR) { - if (strlen (path) >= size) - goto erange; - strcpy (result, path); - goto finish; + if (strlen (path) >= size) + goto erange; + strcpy (result, path); + goto finish; } - else if (*base != G_DIR_SEPARATOR || !size) + else if (*base != G_DIR_SEPARATOR || !size) { - errno = EINVAL; - return (NULL); + errno = EINVAL; + return (NULL); } - else if (size == 1) - goto erange; - /* seek to branched point. */ - branch = path; - for (pp = path, bp = base; *pp && *bp && *pp == *bp; pp++, bp++) - if (*pp == G_DIR_SEPARATOR) - branch = pp; - if (((*pp == 0) || ((*pp == G_DIR_SEPARATOR) && (*(pp + 1) == 0))) && - ((*bp == 0) || ((*bp == G_DIR_SEPARATOR) && (*(bp + 1) == 0)))) + else if (size == 1) + goto erange; + /* seek to branched point. */ + branch = path; + for (pp = path, bp = base; *pp && *bp && *pp == *bp; pp++, bp++) + if (*pp == G_DIR_SEPARATOR) + branch = pp; + if (((*pp == 0) || ((*pp == G_DIR_SEPARATOR) && (*(pp + 1) == 0))) && + ((*bp == 0) || ((*bp == G_DIR_SEPARATOR) && (*(bp + 1) == 0)))) { - rp = result; - *rp++ = '.'; - if (*pp == G_DIR_SEPARATOR || *(pp - 1) == G_DIR_SEPARATOR) - *rp++ = G_DIR_SEPARATOR; - if (rp > endp) - goto erange; - *rp = 0; - goto finish; + rp = result; + *rp++ = '.'; + if (*pp == G_DIR_SEPARATOR || *(pp - 1) == G_DIR_SEPARATOR) + *rp++ = G_DIR_SEPARATOR; + if (rp > endp) + goto erange; + *rp = 0; + goto finish; } - if (((*pp == 0) && (*bp == G_DIR_SEPARATOR)) || ((*pp == G_DIR_SEPARATOR) && (*bp == 0))) - branch = pp; - /* up to root. */ - rp = result; - for (bp = base + (branch - path); *bp; bp++) - if (*bp == G_DIR_SEPARATOR && *(bp + 1) != 0) - { - if (rp + 3 > endp) - goto erange; - *rp++ = '.'; - *rp++ = '.'; - *rp++ = G_DIR_SEPARATOR; - } - if (rp > endp) - goto erange; - *rp = 0; - /* down to leaf. */ - if (*branch) + if (((*pp == 0) && (*bp == G_DIR_SEPARATOR)) || ((*pp == G_DIR_SEPARATOR) && (*bp == 0))) + branch = pp; + /* up to root. */ + rp = result; + for (bp = base + (branch - path); *bp; bp++) + if (*bp == G_DIR_SEPARATOR && *(bp + 1) != 0) + { + if (rp + 3 > endp) + goto erange; + *rp++ = '.'; + *rp++ = '.'; + *rp++ = G_DIR_SEPARATOR; + } + if (rp > endp) + goto erange; + *rp = 0; + /* down to leaf. */ + if (*branch) { - if (rp + strlen (branch + 1) > endp) - goto erange; - strcpy (rp, branch + 1); + if (rp + strlen (branch + 1) > endp) + goto erange; + strcpy (rp, branch + 1); } - else - *--rp = 0; + else + *--rp = 0; finish: - return result; + return result; erange: - errno = ERANGE; - return (NULL); + errno = ERANGE; + return (NULL); } -gchar * -prepend_current_dir_if_relative(gchar const *uri) +gchar *prepend_current_dir_if_relative(gchar const *uri) { if (!uri) { return NULL; @@ -278,4 +245,13 @@ prepend_current_dir_if_relative(gchar const *uri) return ret; } - +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vi: set autoindent shiftwidth=4 tabstop=8 filetype=cpp expandtab softtabstop=4 encoding=utf-8 textwidth=99 : diff --git a/src/dir-util.h b/src/dir-util.h index 7d04b3007..f7700cfa3 100644 --- a/src/dir-util.h +++ b/src/dir-util.h @@ -12,14 +12,47 @@ #include #include -char const *sp_relative_path_from_path(char const *path, char const *base); +/** + * Returns a form of \a path relative to \a base if that is easy to construct (eg if \a path + * appears to be in the directory specified by \a base), otherwise returns \a path. + * + * @param path is expected to be an absolute path. + * @param base is expected to be either empty or the absolute path of a directory. + * + * @return a relative version of the path, if reasonable. + * + * @see inkscape_abs2rel for a more sophisticated version. + * @see prepend_current_dir_if_relative. +*/ +std::string sp_relative_path_from_path(std::string const &path, std::string const &base); + char const *sp_extension_from_path(char const *path); + +/** + * Convert a relative path name into absolute. If path is already absolute, does nothing except copying path to result. + * + * @param path relative path. + * @param base base directory (must be absolute path). + * @param result result buffer. + * @param size size of result buffer. + * + * @return != NULL: absolute path + * == NULL: error + * + * based on functions by Shigio Yamaguchi. + * FIXME:TODO: force it to also do path normalization of the entire resulting path, + * i.e. get rid of any .. and . in any place, even if 'path' is already absolute + * (now it returns it unchanged in this case) + * + */ char *inkscape_rel2abs(char const *path, char const *base, char *result, size_t const size); + char *inkscape_abs2rel(char const *path, char const *base, char *result, size_t const size); + gchar *prepend_current_dir_if_relative(gchar const *filename); -#endif /* !SEEN_DIR_UTIL_H */ +#endif // !SEEN_DIR_UTIL_H /* Local Variables: diff --git a/src/display/curve-test.h b/src/display/curve-test.h index d89cb4c99..3d698ca07 100644 --- a/src/display/curve-test.h +++ b/src/display/curve-test.h @@ -21,7 +21,7 @@ public: path1.close(); // Closed path (ClosingSegment is zero length) path2.append(Geom::LineSegment(Geom::Point(2,0),Geom::Point(3,0))); - path2.append(Geom::BezierCurve<3>(Geom::Point(3,0),Geom::Point(2,1),Geom::Point(1,1),Geom::Point(2,0))); + // TODO fix path2.append(Geom::BezierCurve<3>(Geom::Point(3,0),Geom::Point(2,1),Geom::Point(1,1),Geom::Point(2,0))); path2.close(); // Open path path3.append(Geom::SVGEllipticalArc(Geom::Point(4,0),1,2,M_PI,false,false,Geom::Point(5,1))); diff --git a/src/document-undo.h b/src/document-undo.h index 9be260fa2..e4f0d15a8 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -15,10 +15,10 @@ public: * Since undo sensitivity needs to be nested, setting undo sensitivity * should be done like this: *\verbatim - bool saved = sp_document_get_undo_sensitive(document); - sp_document_set_undo_sensitive(document, false); + bool saved = DocumentUndo::getUndoSensitive(document); + DocumentUndo::setUndoSensitive(document, false); ... do stuff ... - sp_document_set_undo_sensitive(document, saved); \endverbatim + DocumentUndo::setUndoSensitive(document, saved); \endverbatim */ static void setUndoSensitive(SPDocument *doc, bool sensitive); diff --git a/src/file.cpp b/src/file.cpp index c93188358..a1fc23117 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -54,6 +54,7 @@ #include "path-prefix.h" #include "preferences.h" #include "print.h" +#include "resource-manager.h" #include "rdf.h" #include "selection-chemistry.h" #include "selection.h" @@ -209,14 +210,14 @@ sp_file_exit() * \param replace_empty if true, and the current desktop is empty, this document * will replace the empty one. */ -bool -sp_file_open(const Glib::ustring &uri, - Inkscape::Extension::Extension *key, - bool add_to_recent, bool replace_empty) +bool sp_file_open(const Glib::ustring &uri, + Inkscape::Extension::Extension *key, + bool add_to_recent, bool replace_empty) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) + if (desktop) { desktop->setWaitingCursor(); + } SPDocument *doc = NULL; try { @@ -227,27 +228,30 @@ sp_file_open(const Glib::ustring &uri, doc = NULL; } - if (desktop) + if (desktop) { desktop->clearWaitingCursor(); + } if (doc) { SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; if (existing && existing->virgin && replace_empty) { // If the current desktop is empty, open the document there - doc->ensureUpToDate(); + doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. desktop->change_document(doc); doc->emitResizedSignal(doc->getWidth(), doc->getHeight()); } else { // create a whole new desktop and window - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); + SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. sp_create_window(dtw, TRUE); desktop = static_cast(dtw->view); } doc->virgin = FALSE; + // everyone who cares now has a reference, get rid of ours doc->doUnref(); + // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); @@ -256,6 +260,14 @@ sp_file_open(const Glib::ustring &uri, sp_file_add_recent( doc->getURI() ); } + if ( inkscape_use_gui() ) { + // Perform a fixup pass for hrefs. + if ( Inkscape::ResourceManager::getManager().fixupBrokenLinks(doc) ) { + Glib::ustring msg = _("Broken links have been changed to point to existing files."); + desktop->showInfoDialog(msg); + } + } + return TRUE; } else { gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str()); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1007c315a..91e3b0c5f 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -59,6 +59,7 @@ using Inkscape::Extension::Internal::PrintWin32; #include "io/sys.h" #include "message-stack.h" #include "preferences.h" +#include "resource-manager.h" #include "selection.h" #include "ui/dialog/debug.h" #include "xml/repr.h" @@ -820,6 +821,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) inkscape_load_menus(inkscape); Inkscape::DeviceManager::getManager().loadConfig(); } + Inkscape::ResourceManager::getManager(); /* set language for user interface according setting in preferences */ Glib::ustring ui_language = prefs->getString("/ui/language"); diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp new file mode 100644 index 000000000..a68b2c7ae --- /dev/null +++ b/src/resource-manager.cpp @@ -0,0 +1,272 @@ +/* + * Inkscape::ResourceManager - tracks external resources such as image and css files. + * + * Copyright 2011 Jon A. Cruz + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "resource-manager.h" + +#include "document.h" +#include "sp-object.h" +#include "xml/node.h" +#include "document-undo.h" + +namespace Inkscape { + + + +class ResourceManagerImpl : public ResourceManager { +public: + ResourceManagerImpl(); + virtual ~ResourceManagerImpl(); + + virtual bool fixupBrokenLinks(SPDocument *doc); + + + /** + * Walk all links in a document and create a listing of unique broken links. + * + * @return a list of all broken links. + */ + std::vector findBrokenLinks(SPDocument *doc); + + /** + * Resolve broken links as a whole and return a map for those that can be found. + * + * Note: this will allow for future enhancements including relinking to new locations + * with the most broken files found, etc. + * + * @return a map of found links. + */ + std::map locateLinks(Glib::ustring const & docbase, std::vector const & brokenLinks); + + bool extractFilepath( Glib::ustring const &href, std::string &uri ); + +protected: +}; + + +ResourceManagerImpl::ResourceManagerImpl() + : ResourceManager() +{ +} + +ResourceManagerImpl::~ResourceManagerImpl() +{ +} + +bool ResourceManagerImpl::extractFilepath( Glib::ustring const &href, std::string &uri ) +{ + bool isFile = false; + + uri.clear(); + + std::string scheme = Glib::uri_parse_scheme(href); + if ( !scheme.empty() ) { + // TODO debug g_message("Scheme is now [%s]", scheme.c_str()); + if ( scheme == "file" ) { + // TODO debug g_message("--- is a file URI [%s]", href.c_str()); + + // throws Glib::ConvertError: + uri = Glib::filename_from_uri(href); // TODO see if we can get this to throw + // TODO debug g_message(" [%s]", uri.c_str()); + isFile = true; + } + } else { + // No scheme. Assuming it is a file path (absolute or relative). + // throws Glib::ConvertError: + uri = Glib::filename_from_utf8( href ); + isFile = true; + } + + return isFile; +} + + +std::vector ResourceManagerImpl::findBrokenLinks( SPDocument *doc ) +{ + std::vector result; + std::set uniques; + + if ( doc ) { + GSList const *images = doc->getResourceList("image"); + for (GSList const *it = images; it; it = it->next) { + Inkscape::XML::Node *ir = static_cast(it->data)->getRepr(); + + gchar const *href = ir->attribute("xlink:href"); + if ( href && ( uniques.find(href) == uniques.end() ) ) { + std::string uri; + if ( extractFilepath( href, uri ) ) { + if ( Glib::path_is_absolute(uri) ) { + if ( !Glib::file_test(uri, Glib::FILE_TEST_EXISTS) ) { + result.push_back(href); + uniques.insert(href); + } + } else { + std::string combined = Glib::build_filename(doc->getBase(), uri); + if ( !Glib::file_test(uri, Glib::FILE_TEST_EXISTS) ) { + result.push_back(href); + uniques.insert(href); + } + } + } + } + } + } + + return result; +} + + +std::map ResourceManagerImpl::locateLinks(Glib::ustring const & docbase, std::vector const & brokenLinks) +{ + std::map result; + + // At the moment we expect this list to contain file:// references, or simple relative or absolute paths. + for ( std::vector::const_iterator it = brokenLinks.begin(); it != brokenLinks.end(); ++it ) { + // TODO debug g_message("========{%s}", it->c_str()); + + std::string uri; + if ( extractFilepath( *it, uri ) ) { + // We were able to get some path. Check it + + if ( !Glib::path_is_absolute(uri) ) { + uri = Glib::build_filename(docbase, uri); + // TODO debug g_message(" not absolute. Fixing up as [%s]", uri.c_str()); + } + + if ( !Glib::file_test(uri, Glib::FILE_TEST_EXISTS) ) { + // TODO debug g_message(" DOES NOT EXIST."); + std::string tmp = uri; + std::string prior; + std::string remainder; + bool exists = false; + while ( (tmp != prior) && !exists) { + prior = tmp; + std::string basename = Glib::path_get_basename(tmp); + tmp = Glib::path_get_dirname(tmp); + if ( remainder.empty() ) { + remainder = basename; + } else { + remainder = Glib::build_filename(basename, remainder); + } + + std::string rebuild = Glib::build_filename(docbase, remainder); + exists = Glib::file_test(rebuild, Glib::FILE_TEST_EXISTS); + + // TODO debug g_message(" [%s] [%s]%s", tmp.c_str(), remainder.c_str(), exists ? " XXXX" : ""); + if ( exists ) { + Glib::ustring replacement = Glib::filename_to_utf8( remainder ); + result[*it] = replacement; + } + } + } + } + } + + return result; +} + +bool ResourceManagerImpl::fixupBrokenLinks(SPDocument *doc) +{ + bool changed = false; + if ( doc ) { + // TODO debug g_message("FIXUP FIXUP FIXUP FIXUP FIXUP FIXUP FIXUP FIXUP FIXUP FIXUP"); + // TODO debug g_message(" base is [%s]", doc->getBase()); + + std::vector brokenHrefs = findBrokenLinks(doc); + if ( !brokenHrefs.empty() ) { + // TODO debug g_message(" FOUND SOME LINKS %d", brokenHrefs.size()); + for ( std::vector::iterator it = brokenHrefs.begin(); it != brokenHrefs.end(); ++it ) { + // TODO debug g_message(" [%s]", it->c_str()); + } + } + + std::map mapping = locateLinks(doc->getBase(), brokenHrefs); + for ( std::map::iterator it = mapping.begin(); it != mapping.end(); ++it ) + { + // TODO debug g_message(" [%s] ==> {%s}", it->first.c_str(), it->second.c_str()); + } + + bool savedUndoState = DocumentUndo::getUndoSensitive(doc); + DocumentUndo::setUndoSensitive(doc, true); + + GSList const *images = doc->getResourceList("image"); + for (GSList const *it = images; it; it = it->next) { + Inkscape::XML::Node *ir = static_cast(it->data)->getRepr(); + + gchar const *href = ir->attribute("xlink:href"); + if ( href ) { + // TODO debug g_message(" consider [%s]", href); + + if ( mapping.find(href) != mapping.end() ) { + // TODO debug g_message(" Found a replacement"); + + ir->setAttribute( "xlink:href", mapping[href].c_str() ); + if ( ir->attribute( "sodipodi:absref" ) ) { + ir->setAttribute( "sodipodi:absref", 0 ); // Remove this attribute + } + + SPObject *updated = doc->getObjectByRepr(ir); + if (updated) { + // force immediate update of dependant attributes + updated->updateRepr(); + } + + changed = true; + } + } + } + if ( changed ) { + DocumentUndo::done( doc, SP_VERB_DIALOG_XML_EDITOR, _("Fixup broken links") ); + } + DocumentUndo::setUndoSensitive(doc, savedUndoState); + } + + return changed; +} + + + + +static ResourceManagerImpl* theInstance = 0; + +ResourceManager::ResourceManager() + : Glib::Object() +{ +} + +ResourceManager::~ResourceManager() { +} + +ResourceManager& ResourceManager::getManager() { + if ( !theInstance ) { + theInstance = new ResourceManagerImpl(); + } + + return *theInstance; +} + + +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/resource-manager.h b/src/resource-manager.h new file mode 100644 index 000000000..8f01c23a0 --- /dev/null +++ b/src/resource-manager.h @@ -0,0 +1,49 @@ +/* + * Inkscape::ResourceManager - Manages external resources such as image and css files. + * + * Copyright 2011 Jon A. Cruz + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_RESOURCE_MANAGER_H +#define SEEN_INKSCAPE_RESOURCE_MANAGER_H + +#include + +class SPDocument; + +namespace Inkscape { + +class ResourceManager : public Glib::Object { + +public: + static ResourceManager& getManager(); + + virtual bool fixupBrokenLinks(SPDocument *doc) = 0; + +protected: + ResourceManager(); + virtual ~ResourceManager(); + +private: + ResourceManager(ResourceManager const &); // no copy + void operator=(ResourceManager const &); // no assign +}; + + + +} // namespace Inkscape + +#endif // SEEN_INKSCAPE_RESOURCE_MANAGER_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 8bd1bfadd..746cd97d9 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -5,6 +5,7 @@ * Lauris Kaplinski * Edward Flick (EAF) * Abhishek Sharma + * Jon A. Cruz * * Copyright (C) 1999-2005 Authors * Copyright (C) 2000-2001 Ximian, Inc. @@ -107,7 +108,6 @@ extern "C" void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length ); void user_write_data( png_structp png_ptr, png_bytep data, png_size_t length ); void user_flush_data( png_structp png_ptr ); - } @@ -557,8 +557,7 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, GError **error ) } } -GType -sp_image_get_type (void) +GType sp_image_get_type(void) { static GType image_type = 0; if (!image_type) { @@ -579,8 +578,7 @@ sp_image_get_type (void) return image_type; } -static void -sp_image_class_init (SPImageClass * klass) +static void sp_image_class_init( SPImageClass * klass ) { GObjectClass * gobject_class; SPObjectClass * sp_object_class; @@ -635,8 +633,7 @@ static void sp_image_init( SPImage *image ) image->lastMod = 0; } -static void -sp_image_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_image_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ) { if (((SPObjectClass *) parent_class)->build) { ((SPObjectClass *) parent_class)->build (object, document, repr); @@ -654,8 +651,7 @@ sp_image_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep document->addResource("image", object); } -static void -sp_image_release (SPObject *object) +static void sp_image_release( SPObject *object ) { SPImage *image = SP_IMAGE(object); @@ -695,8 +691,7 @@ sp_image_release (SPObject *object) } } -static void -sp_image_set (SPObject *object, unsigned int key, const gchar *value) +static void sp_image_set( SPObject *object, unsigned int key, const gchar *value ) { SPImage *image = SP_IMAGE (object); @@ -818,8 +813,7 @@ sp_image_set (SPObject *object, unsigned int key, const gchar *value) sp_image_set_curve(image); //creates a curve at the image's boundary for snapping } -static void -sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags) +static void sp_image_update( SPObject *object, SPCtx *ctx, unsigned int flags ) { SPImage *image = SP_IMAGE(object); SPDocument *doc = object->document; @@ -1026,8 +1020,7 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags) sp_image_update_canvas_image ((SPImage *) object); } -static void -sp_image_modified (SPObject *object, unsigned int flags) +static void sp_image_modified( SPObject *object, unsigned int flags ) { SPImage *image = SP_IMAGE (object); @@ -1042,8 +1035,7 @@ sp_image_modified (SPObject *object, unsigned int flags) } } -static Inkscape::XML::Node * -sp_image_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node *sp_image_write( SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags ) { SPImage *image = SP_IMAGE (object); @@ -1081,8 +1073,7 @@ sp_image_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM return repr; } -static void -sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static void sp_image_bbox( SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/ ) { SPImage const &image = *SP_IMAGE(item); @@ -1099,8 +1090,7 @@ sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, u } } -static void -sp_image_print (SPItem *item, SPPrintContext *ctx) +static void sp_image_print( SPItem *item, SPPrintContext *ctx ) { SPImage *image = SP_IMAGE(item); @@ -1135,8 +1125,7 @@ sp_image_print (SPItem *item, SPPrintContext *ctx) } } -static gchar * -sp_image_description(SPItem *item) +static gchar *sp_image_description( SPItem *item ) { SPImage *image = SP_IMAGE(item); char *href_desc; @@ -1159,8 +1148,7 @@ sp_image_description(SPItem *item) return ret; } -static NRArenaItem * -sp_image_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) +static NRArenaItem *sp_image_show( SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/ ) { SPImage * image = SP_IMAGE(item); NRArenaItem *ai = NRArenaImage::create(arena); @@ -1286,8 +1274,7 @@ GdkPixbuf *sp_image_repr_read_image( time_t& modTime, char*& pixPath, const gcha return pixbuf; } -static GdkPixbuf * -sp_image_pixbuf_force_rgba (GdkPixbuf * pixbuf) +static GdkPixbuf *sp_image_pixbuf_force_rgba( GdkPixbuf * pixbuf ) { GdkPixbuf* result; if (gdk_pixbuf_get_has_alpha(pixbuf)) { @@ -1301,8 +1288,7 @@ sp_image_pixbuf_force_rgba (GdkPixbuf * pixbuf) /* We assert that realpixbuf is either NULL or identical size to pixbuf */ -static void -sp_image_update_canvas_image (SPImage *image) +static void sp_image_update_canvas_image( SPImage *image ) { SPItem *item = SP_ITEM(image); @@ -1342,7 +1328,7 @@ sp_image_update_canvas_image (SPImage *image) } } -static void sp_image_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +static void sp_image_snappoints( SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/ ) { /* An image doesn't have any nodes to snap, but still we want to be able snap one image to another. Therefore we will create some snappoints at the corner, similar to a rect. If @@ -1376,8 +1362,7 @@ static void sp_image_snappoints(SPItem const *item, std::vectorheight.computed < MAGIC_EPSILON_TOO) || (image->width.computed < MAGIC_EPSILON_TOO) || (image->clip_ref->getObject())) { @@ -1580,8 +1562,7 @@ sp_image_set_curve(SPImage *image) /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ -SPCurve * -sp_image_get_curve (SPImage *image) +SPCurve *sp_image_get_curve( SPImage *image ) { SPCurve *result = 0; if (image->curve) { @@ -1590,8 +1571,7 @@ sp_image_get_curve (SPImage *image) return result; } -void -sp_embed_image(Inkscape::XML::Node *image_node, GdkPixbuf *pb, Glib::ustring const &mime_in) +void sp_embed_image( Inkscape::XML::Node *image_node, GdkPixbuf *pb, Glib::ustring const &mime_in ) { Glib::ustring format, mime; if (mime_in == "image/jpeg") { @@ -1602,8 +1582,8 @@ sp_embed_image(Inkscape::XML::Node *image_node, GdkPixbuf *pb, Glib::ustring con format = "png"; } - gchar *data; - gsize length; + gchar *data = 0; + gsize length = 0; gdk_pixbuf_save_to_buffer(pb, &data, &length, format.data(), NULL, NULL); // Save base64 encoded data in image node @@ -1614,7 +1594,8 @@ sp_embed_image(Inkscape::XML::Node *image_node, GdkPixbuf *pb, Glib::ustring con gchar *buffer = (gchar *) g_malloc(needed_size), *buf_work = buffer; buf_work += g_sprintf(buffer, "data:%s;base64,", mime.data()); - gint state = 0, save = 0; + gint state = 0; + gint save = 0; gsize written = 0; written += g_base64_encode_step((guchar*) data, length, TRUE, buf_work, &state, &save); written += g_base64_encode_close(TRUE, buf_work + written, &state, &save); diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 919b570dd..4ff4f92f9 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -137,6 +137,10 @@ struct EditWidgetInterface /// Message widget will get no content virtual void setMessage (Inkscape::MessageType type, gchar const* msg) = 0; + + /** Show an info dialog with the given message */ + virtual bool showInfoDialog( Glib::ustring const &message ) = 0; + /// Open yes/no dialog with warning text and confirmation question. virtual bool warnDialog (gchar*) = 0; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 63fdc5930..87ce9053f 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1150,6 +1150,25 @@ SPDesktopWidget::presentWindow() gtk_window_present (w); } +bool SPDesktopWidget::showInfoDialog( Glib::ustring const &message ) +{ + bool result = false; + GtkWindow *window = GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET(this) ) ); + if (window) + { + GtkWidget *dialog = gtk_message_dialog_new( + window, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "%s", message.c_str()); + gtk_window_set_title( GTK_WINDOW(dialog), _("Note:")); // probably want to take this as a parameter. + gint response = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + } + return result; +} + bool SPDesktopWidget::warnDialog (gchar* text) { diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 0102897e5..53d9dd1bc 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -200,8 +200,14 @@ struct SPDesktopWidget { { _dtw->setCoordinateStatus (p); } virtual void setMessage (Inkscape::MessageType type, gchar const* msg) { _dtw->setMessage (type, msg); } + + virtual bool showInfoDialog( Glib::ustring const &message ) { + return _dtw->showInfoDialog( message ); + } + virtual bool warnDialog (gchar* text) { return _dtw->warnDialog (text); } + virtual Inkscape::UI::Widget::Dock* getDock () { return _dtw->getDock(); } }; @@ -218,6 +224,7 @@ struct SPDesktopWidget { void setWindowSize (gint w, gint h); void setWindowTransient (void *p, int transient_policy); void presentWindow(); + bool showInfoDialog( Glib::ustring const &message ); bool warnDialog (gchar *text); void setToolboxFocusTo (gchar const *); void setToolboxAdjustmentValue (gchar const * id, double value); diff --git a/src/xml/Makefile_insert b/src/xml/Makefile_insert index 7190b7948..b10f2448b 100644 --- a/src/xml/Makefile_insert +++ b/src/xml/Makefile_insert @@ -47,5 +47,6 @@ ink_common_sources += \ # ### CxxTest stuff #### # ###################### CXXTEST_TESTSUITES += \ + $(srcdir)/xml/rebase-hrefs-test.h \ $(srcdir)/xml/repr-action-test.h \ $(srcdir)/xml/quote-test.h diff --git a/src/xml/rebase-hrefs-test.h b/src/xml/rebase-hrefs-test.h new file mode 100644 index 000000000..e00337836 --- /dev/null +++ b/src/xml/rebase-hrefs-test.h @@ -0,0 +1,126 @@ +#include + +#include +#include + +#include "uri.h" + + +class RebaseHrefsTest : public CxxTest::TestSuite +{ + Inkscape::XML::Document *document; + Inkscape::XML::Node *a, *b, *c, *root; + +public: + + RebaseHrefsTest() + { + Inkscape::GC::init(); + + document = sp_repr_document_new("test"); + root = document->root(); + + a = document->createElement("a"); + b = document->createElement("b"); + c = document->createElement("c"); + } + virtual ~RebaseHrefsTest() {} + +// createSuite and destroySuite get us per-suite setup and teardown +// without us having to worry about static initialization order, etc. + static RebaseHrefsTest *createSuite() { return new RebaseHrefsTest(); } + static void destroySuite( RebaseHrefsTest *suite ) { delete suite; } + + + void dump_str(gchar const *str, gchar const *prefix) + { + Glib::ustring tmp; + tmp = prefix; + tmp += " ["; + size_t const total = strlen(str); + for (unsigned i = 0; i < total; i++) { + gchar *const tmp2 = g_strdup_printf(" %02x", (0x0ff & str[i])); + tmp += tmp2; + g_free(tmp2); + } + + tmp += "]"; + g_message("%s", tmp.c_str()); + } + + void testFlipples() + { + using Inkscape::URI; + using Inkscape::MalformedURIException; + + gchar const* things[] = { + "data:foo,bar", + "http://www.google.com/image.png", + "ftp://ssd.com/doo", + "/foo/dee/bar.svg", + "foo.svg", + "file:/foo/dee/bar.svg", + "file:///foo/dee/bar.svg", + "file:foo.svg", + "/foo/bar\xe1\x84\x92.svg", + "file:///foo/bar\xe1\x84\x92.svg", + "file:///foo/bar%e1%84%92.svg", + "/foo/bar%e1%84%92.svg", + "bar\xe1\x84\x92.svg", + "bar%e1%84%92.svg", + NULL + }; + g_message("+------"); + for ( int i = 0; things[i]; i++ ) + { + try + { + URI uri(things[i]); + gboolean isAbs = g_path_is_absolute( things[i] ); + gchar *str = uri.toString(); + g_message( "abs:%d isRel:%d scheme:[%s] path:[%s][%s] uri[%s] / [%s]", (int)isAbs, + (int)uri.isRelative(), + uri.getScheme(), + uri.getPath(), + uri.getOpaque(), + things[i], + str ); + g_free(str); + } + catch ( MalformedURIException err ) + { + dump_str( things[i], "MalformedURIException" ); + xmlChar *redo = xmlURIEscape((xmlChar const *)things[i]); + g_message(" gone from [%s] to [%s]", things[i], redo ); + if ( redo == NULL ) + { + URI again = URI::fromUtf8( things[i] ); + g_message(" uri from [%s] to [%s]", things[i], again.toString() ); + gboolean isAbs = g_path_is_absolute( things[i] ); + gchar *str = again.toString(); + g_message( "abs:%d isRel:%d scheme:[%s] path:[%s][%s] uri[%s] / [%s]", (int)isAbs, + (int)again.isRelative(), + again.getScheme(), + again.getPath(), + again.getOpaque(), + things[i], + str ); + g_free(str); + g_message(" ----"); + } + } + } + g_message("+------"); + } +}; + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index 33b31685d..71e1cfb87 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -10,68 +10,64 @@ #include #include #include -using Inkscape::XML::AttributeRecord; +#include +#include +#include +using Inkscape::XML::AttributeRecord; /** - * \pre href. + * Determine if a href needs rebasing. */ -static bool -href_needs_rebasing(char const *const href) +static bool href_needs_rebasing(std::string const &href) { - g_return_val_if_fail(href, false); + bool ret = true; - if (!*href || *href == '#') { - return false; + if ( href.empty() || (href[0] == '#') ) { + ret = false; /* False (no change) is the right behaviour even when the base URI differs from the * document URI: RFC 3986 defines empty string relative URL as referring to the containing * document, rather than referring to the base URI. */ - } - - /* Don't change data or http hrefs. */ - { - char *const scheme = g_uri_parse_scheme(href); - if (scheme) { + } else { + /* Don't change data or http hrefs. */ + std::string scheme = Glib::uri_parse_scheme(href); + if ( !scheme.empty() ) { /* Assume it shouldn't be changed. This is probably wrong if the scheme is `file' * (or if the scheme of the new base is non-file, though I believe that never * happens at the time of writing), but that's rare, and we won't try too hard to * handle this now: wait until after the freeze, then add liburiparser (or similar) * as a dependency and do it properly. For now we'll just try to be simple (while * at least still correctly handling data hrefs). */ - free(scheme); - return false; + ret = false; + } else if (Glib::path_is_absolute(href)) { + /* If absolute then keep it as is. + * + * Even in the following borderline cases: + * + * - We keep it absolute even if it is in new_base (directly or indirectly). + * + * - We assume that if xlink:href is absolute then we honour it in preference to + * sodipodi:absref even if sodipodi:absref points to an existing file while xlink:href + * doesn't. This is because we aren't aware of any bugs in xlink:href handling when + * it's absolute, so we assume that it's the best value to use even in this case.) + */ + /* No strong preference on what we do for sodipodi:absref. Once we're + * confident of our handling of xlink:href and xlink:base, we should clear it. + * Though for the moment we do the simple thing: neither clear nor set it. */ + ret = false; } } - /* If absolute then keep it as is. - * - * Even in the following borderline cases: - * - * - We keep it absolute even if it is in new_base (directly or indirectly). - * - * - We assume that if xlink:href is absolute then we honour it in preference to - * sodipodi:absref even if sodipodi:absref points to an existing file while xlink:href - * doesn't. This is because we aren't aware of any bugs in xlink:href handling when - * it's absolute, so we assume that it's the best value to use even in this case.) - */ - if (g_path_is_absolute(href)) { - /* No strong preference on what we do for sodipodi:absref. Once we're - * confident of our handling of xlink:href and xlink:base, we should clear it. - * Though for the moment we do the simple thing: neither clear nor set it. */ - return false; - } - - return true; + return ret; } -static gchar * -calc_abs_href(gchar const *const abs_base_dir, gchar const *const href, - gchar const *const sp_absref) +static std::string calc_abs_href(std::string const &abs_base_dir, std::string const &href, + gchar const *const sp_absref) { - gchar *ret = g_build_filename(abs_base_dir, href, NULL); + std::string ret = Glib::build_filename(abs_base_dir, href); if ( sp_absref - && !Inkscape::IO::file_test(ret, G_FILE_TEST_EXISTS) + && !Inkscape::IO::file_test(ret.c_str(), G_FILE_TEST_EXISTS) && Inkscape::IO::file_test(sp_absref, G_FILE_TEST_EXISTS) ) { /* sodipodi:absref points to an existing file while xlink:href doesn't. @@ -93,18 +89,12 @@ calc_abs_href(gchar const *const abs_base_dir, gchar const *const href, * effic: Once we no longer consult sodipodi:absref, we can do * `if (base unchanged) { return; }' at the start of rebase_hrefs. */ - g_free(ret); - ret = g_strdup(sp_absref); + ret = sp_absref; } return ret; } -/** - * Change relative xlink:href attributes to be relative to \a new_abs_base instead of old_abs_base. - * - * Note that old_abs_base and new_abs_base must each be non-NULL, absolute directory paths. - */ Inkscape::Util::List Inkscape::XML::rebase_href_attrs(gchar const *const old_abs_base, gchar const *const new_abs_base, @@ -115,6 +105,7 @@ Inkscape::XML::rebase_href_attrs(gchar const *const old_abs_base, using Inkscape::Util::ptr_shared; using Inkscape::Util::share_string; + if (old_abs_base == new_abs_base) { return attributes; } @@ -133,7 +124,7 @@ Inkscape::XML::rebase_href_attrs(gchar const *const old_abs_base, for (List ai(attributes); ai; ++ai) { if (ai->key == href_key) { old_href = ai->value; - if (!href_needs_rebasing(old_href)) { + if (!href_needs_rebasing(static_cast(old_href))) { return attributes; } } else if (ai->key == absref_key) { @@ -153,23 +144,33 @@ Inkscape::XML::rebase_href_attrs(gchar const *const old_abs_base, * reversed.) */ } - gchar *const abs_href(calc_abs_href(old_abs_base, old_href, sp_absref)); - gchar const *const new_href = sp_relative_path_from_path(abs_href, new_abs_base); - ret = cons(AttributeRecord(href_key, share_string(new_href)), ret); + std::string abs_href = calc_abs_href(old_abs_base, static_cast(old_href), sp_absref); + std::string new_href = sp_relative_path_from_path(abs_href, new_abs_base); + ret = cons(AttributeRecord(href_key, share_string(new_href.c_str())), ret); // Check if this is safe/copied or if it is only held. if (sp_absref) { /* We assume that if there wasn't previously a sodipodi:absref attribute * then we shouldn't create one. */ - ret = cons(AttributeRecord(absref_key, ( streq(abs_href, sp_absref) + ret = cons(AttributeRecord(absref_key, ( streq(abs_href.c_str(), sp_absref) ? sp_absref - : share_string(abs_href) )), + : share_string(abs_href.c_str()) )), ret); } - g_free(abs_href); + return ret; } -gchar * -Inkscape::XML::calc_abs_doc_base(gchar const *const doc_base) +// std::string Inkscape::XML::rebase_href_attrs( std::string const &oldAbsBase, std::string const &newAbsBase, gchar const * /*href*/, gchar const */*absref*/ ) +// { +// std::string ret; +// //g_message( "XX need to flip from [%s] to [%s]", oldAbsBase.c_str(), newAbsBase.c_str() ); + +// if ( oldAbsBase != newAbsBase ) { +// } + +// return ret; +// } + +std::string Inkscape::XML::calc_abs_doc_base(gchar const *doc_base) { /* Note that we don't currently try to handle the case of doc_base containing * `..' or `.' path components. This non-handling means that sometimes @@ -179,34 +180,27 @@ Inkscape::XML::calc_abs_doc_base(gchar const *const doc_base) * relative URL/IRI href processing (with liburiparser). * * (Note that one possibile difficulty with `..' is symlinks.) */ + std::string ret; if (!doc_base) { - return g_get_current_dir(); - } else if (g_path_is_absolute(doc_base)) { - return g_strdup(doc_base); + ret = Glib::get_current_dir(); + } else if (Glib::path_is_absolute(doc_base)) { + ret = doc_base; } else { - gchar *const cwd = g_get_current_dir(); - gchar *const ret = g_build_filename(cwd, doc_base, NULL); - g_free(cwd); - return ret; + ret = Glib::build_filename( Glib::get_current_dir(), doc_base ); } + + return ret; } -/** - * Change relative hrefs in doc to be relative to \a new_base instead of doc.base. - * - * (NULL doc base or new_base is interpreted as current working directory.) - * - * \param spns True iff doc should contain sodipodi:absref attributes. - */ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_base, bool const spns) { if (!doc->getBase()) { return; } - gchar *const old_abs_base = calc_abs_doc_base(doc->getBase()); - gchar *const new_abs_base = calc_abs_doc_base(new_base); + std::string old_abs_base = calc_abs_doc_base(doc->getBase()); + std::string new_abs_base = calc_abs_doc_base(new_base); /* TODO: Should handle not just image but also: * @@ -232,22 +226,26 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b for (GSList const *l = images; l != NULL; l = l->next) { Inkscape::XML::Node *ir = static_cast(l->data)->getRepr(); - gchar * uri = g_strdup(ir->attribute("xlink:href")); - if (!uri) { - continue; + std::string uri; + { + gchar const *tmp = ir->attribute("xlink:href"); + if ( !tmp ) { + continue; + } + uri = tmp; } - if (!strncmp(uri, "file://", 7)) { - uri = g_strdup(g_filename_from_uri(ir->attribute("xlink:href"), NULL, NULL)); + if ( uri.substr(0, 7) == "file://" ) { + uri = Glib::filename_from_uri(uri); } // The following two cases are for absolute hrefs that can be converted to relative. // Imported images, first time rebased, need an old base. - gchar * href = uri; - if (g_path_is_absolute(href)) { - href = (gchar *) sp_relative_path_from_path(uri, old_abs_base); + std::string href = uri; + if ( Glib::path_is_absolute(href) ) { + href = sp_relative_path_from_path(uri, old_abs_base); } // Files moved from a absolute path need a new one. - if (g_path_is_absolute(href)) { - href = (gchar *) sp_relative_path_from_path(uri, new_abs_base); + if ( Glib::path_is_absolute(href) ) { + href = sp_relative_path_from_path(uri, new_abs_base); } // Other bitmaps are either really absolute, or already relative. @@ -264,52 +262,41 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b * changing non-file hrefs), which breaks if href starts with a scheme or if href contains * any escaping. */ - if (!href || !href_needs_rebasing(href)) { - g_free(uri); - continue; - } - - gchar *const abs_href(calc_abs_href(old_abs_base, href, ir->attribute("sodipodi:absref"))); - - /* todo: One difficult case once we support writing to non-file locations is where - * existing hrefs in the document point to local files. In this case, we should - * probably copy those referenced files to the new location at the same time. It's - * less clear what to do when copying from one non-file location to another. We may - * need to ask the user in some way (even if it's as a checkbox), but we'd like to - * bother the user as little as possible yet also want to warn the user about the case - * of file hrefs. */ - - gchar const *const new_href = sp_relative_path_from_path(abs_href, new_abs_base); - ir->setAttribute("sodipodi:absref", ( spns - ? abs_href - : NULL )); - if (!g_path_is_absolute(new_href)) { + if ( href_needs_rebasing(href) ) { + std::string abs_href = calc_abs_href(old_abs_base, href, ir->attribute("sodipodi:absref")); + + /* todo: One difficult case once we support writing to non-file locations is where + * existing hrefs in the document point to local files. In this case, we should + * probably copy those referenced files to the new location at the same time. It's + * less clear what to do when copying from one non-file location to another. We may + * need to ask the user in some way (even if it's as a checkbox), but we'd like to + * bother the user as little as possible yet also want to warn the user about the case + * of file hrefs. */ + + std::string new_href = sp_relative_path_from_path(abs_href, new_abs_base); + ir->setAttribute("sodipodi:absref", ( spns + ? abs_href.c_str() + : NULL )); + if (!Glib::path_is_absolute(new_href)) { #ifdef WIN32 - /* Native Windows path separators are replaced with / so that the href - * also works on Gnu/Linux and OSX */ - ir->setAttribute("xlink:href", g_strdelimit((gchar *) new_href, "\\", '/')); + /* Native Windows path separators are replaced with / so that the href + * also works on Gnu/Linux and OSX */ + ir->setAttribute("xlink:href", g_strdelimit(new_href.c_str(), "\\", '/')); #else - ir->setAttribute("xlink:href", new_href); + ir->setAttribute("xlink:href", new_href.c_str()); #endif - } else { - ir->setAttribute("xlink:href", g_filename_to_uri((gchar *) new_href, NULL, NULL)); - } + } else { + ir->setAttribute("xlink:href", g_filename_to_uri(new_href.c_str(), NULL, NULL)); + } - /* impl: I assume that if !spns then any existing sodipodi:absref is about to get - * cleared (or is already cleared) anyway, in which case it doesn't matter whether we - * clear or leave any existing sodipodi:absref value. If that assumption turns out to - * be wrong, then leaving it means risking leaving the wrong value (if xlink:href - * referred to a different file than sodipodi:absref) while clearing it means risking - * losing information. */ - - g_free(uri); - // (No need to free href, it's guaranteed to point into uri.) - g_free(abs_href); - // (No need to free new_href, it's guaranteed to point into abs_href.) + /* impl: I assume that if !spns then any existing sodipodi:absref is about to get + * cleared (or is already cleared) anyway, in which case it doesn't matter whether we + * clear or leave any existing sodipodi:absref value. If that assumption turns out to + * be wrong, then leaving it means risking leaving the wrong value (if xlink:href + * referred to a different file than sodipodi:absref) while clearing it means risking + * losing information. */ + } } - - g_free(new_abs_base); - g_free(old_abs_base); } diff --git a/src/xml/rebase-hrefs.h b/src/xml/rebase-hrefs.h index b4f288c4d..4cbdec9a5 100644 --- a/src/xml/rebase-hrefs.h +++ b/src/xml/rebase-hrefs.h @@ -9,17 +9,36 @@ struct SPDocument; namespace Inkscape { namespace XML { -gchar *calc_abs_doc_base(gchar const *doc_base); - +std::string calc_abs_doc_base(gchar const *doc_base); + +/** + * Change relative hrefs in doc to be relative to \a new_base instead of doc.base. + * + * (NULL doc base or new_base is interpreted as current working directory.) + * + * @param spns True if doc should contain sodipodi:absref attributes. + */ void rebase_hrefs(SPDocument *doc, gchar const *new_base, bool spns); +/** + * Change relative xlink:href attributes to be relative to \a new_abs_base instead of old_abs_base. + * + * Note that old_abs_base and new_abs_base must each be non-NULL, absolute directory paths. + */ Inkscape::Util::List rebase_href_attrs( gchar const *old_abs_base, gchar const *new_abs_base, Inkscape::Util::List attributes); -} -} + +// /** +// * . +// * @return a non-empty replacement href if needed, empty otherwise. +// */ +// std::string rebase_href_attrs( std::string const &oldAbsBase, std::string const &newAbsBase, gchar const *href, gchar const *absref = 0 ); + +} // namespace XML +} // namespace Inkscape #endif /* !REBASE_HREFS_H_SEEN */ diff --git a/src/xml/repr-action-test.h b/src/xml/repr-action-test.h index afc9b2c46..ae4291397 100644 --- a/src/xml/repr-action-test.h +++ b/src/xml/repr-action-test.h @@ -88,7 +88,6 @@ public: } /* lots more tests needed ... */ - }; /* diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 5f7654ba8..2a0bb6ce8 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -52,6 +52,7 @@ static void sp_repr_write_stream_root_element(Node *repr, Writer &out, int inlineattrs, int indent, gchar const *old_href_abs_base, gchar const *new_href_abs_base); + static void sp_repr_write_stream_element(Node *repr, Writer &out, gint indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix, @@ -644,7 +645,7 @@ sp_repr_save_rebased_file(Document *doc, gchar const *const filename, gchar cons return false; } - gchar *old_href_abs_base = NULL; + std::string old_href_abs_base; gchar *new_href_abs_base = NULL; if (for_filename) { old_href_abs_base = calc_abs_doc_base(old_base); @@ -662,9 +663,8 @@ sp_repr_save_rebased_file(Document *doc, gchar const *const filename, gchar cons * to using sodipodi:absref instead of the xlink:href value, * then we should do `if streq() { free them and set both to NULL; }'. */ } - sp_repr_save_stream(doc, file, default_ns, compress, old_href_abs_base, new_href_abs_base); + sp_repr_save_stream(doc, file, default_ns, compress, old_href_abs_base.c_str(), new_href_abs_base); - g_free(old_href_abs_base); g_free(new_href_abs_base); if (fclose (file) != 0) { @@ -879,17 +879,16 @@ void sp_repr_write_stream( Node *repr, Writer &out, gint indent_level, } -static void -sp_repr_write_stream_element (Node * repr, Writer & out, gint indent_level, - bool add_whitespace, - Glib::QueryQuark elide_prefix, - List attributes, - int inlineattrs, int indent, - gchar const *const old_href_base, - gchar const *const new_href_base) +void sp_repr_write_stream_element( Node * repr, Writer & out, + gint indent_level, bool add_whitespace, + Glib::QueryQuark elide_prefix, + List attributes, + int inlineattrs, int indent, + gchar const *old_href_base, + gchar const *new_href_base ) { - Node *child; - bool loose; + Node *child = 0; + bool loose = false; g_return_if_fail (repr != NULL); @@ -921,6 +920,28 @@ sp_repr_write_stream_element (Node * repr, Writer & out, gint indent_level, add_whitespace = false; } + + { + GQuark const href_key = g_quark_from_static_string("xlink:href"); + GQuark const absref_key = g_quark_from_static_string("sodipodi:absref"); + + gchar const *xxHref = 0; + gchar const *xxAbsref = 0; + for ( List ai(attributes); ai; ++ai ) { + if ( ai->key == href_key ) { + xxHref = ai->value; + } else if ( ai->key == absref_key ) { + xxAbsref = ai->value; + } + } + + // Might add a special case for absref but no href. + if ( old_href_base && new_href_base && xxHref ) { + //g_message("href rebase test with [%s] and [%s]", xxHref, xxAbsref); + //std::string newOne = rebase_href_attrs( old_href_base, new_href_base, xxHref, xxAbsref ); + } + } + for ( List iter = rebase_href_attrs(old_href_base, new_href_base, attributes); iter ; ++iter ) diff --git a/src/xml/repr.h b/src/xml/repr.h index bde3e533f..5fa9387c7 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -79,10 +79,13 @@ void sp_repr_write_stream(Inkscape::XML::Node *repr, Inkscape::IO::Writer &out, gchar const *new_href_base = NULL); Inkscape::XML::Document *sp_repr_read_buf (const Glib::ustring &buf, const gchar *default_ns); Glib::ustring sp_repr_save_buf(Inkscape::XML::Document *doc); + +// TODO convert to std::string void sp_repr_save_stream(Inkscape::XML::Document *doc, FILE *to_file, gchar const *default_ns = NULL, bool compress = false, gchar const *old_href_base = NULL, gchar const *new_href_base = NULL); + bool sp_repr_save_file(Inkscape::XML::Document *doc, gchar const *filename, gchar const *default_ns=NULL); bool sp_repr_save_rebased_file(Inkscape::XML::Document *doc, gchar const *filename_utf8, gchar const *default_ns, -- cgit v1.2.3 From 433bde5f59b67c04fdbb82d484e823a2cfd8624c Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 6 May 2011 21:49:50 -0700 Subject: Fix windows build. (bzr r10199) --- src/xml/rebase-hrefs.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index 71e1cfb87..4a7e050fa 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -252,8 +252,8 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b #ifdef WIN32 /* Windows relative path needs their native separators before we * compare it to native baserefs. */ - if (!g_path_is_absolute(href)) { - g_strdelimit(href, "/", '\\'); + if ( !Glib::path_is_absolute(href) ) { + std::replace(href.begin(), href.end(), '/', '\\'); } #endif @@ -281,10 +281,9 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b #ifdef WIN32 /* Native Windows path separators are replaced with / so that the href * also works on Gnu/Linux and OSX */ - ir->setAttribute("xlink:href", g_strdelimit(new_href.c_str(), "\\", '/')); -#else - ir->setAttribute("xlink:href", new_href.c_str()); + std::replace(href.begin(), href.end(), '\\', '/'); #endif + ir->setAttribute("xlink:href", new_href.c_str()); } else { ir->setAttribute("xlink:href", g_filename_to_uri(new_href.c_str(), NULL, NULL)); } -- cgit v1.2.3 From 9263246258064eb68a501eb9d260cf050953dad6 Mon Sep 17 00:00:00 2001 From: Adib Taraben Date: Sat, 7 May 2011 13:11:57 +0200 Subject: corrected fill-rule handling in pdf export, fixes bug:436962 (bzr r10198.1.1) --- src/extension/internal/cairo-render-context.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 9a612549d..4eecb5ecc 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1361,7 +1361,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con addClipPath(pathv, &style->fill_rule); } else { setPathVector(pathv); - if (style->fill_rule.value == SP_WIND_RULE_EVENODD) { + if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) { cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD); } else { cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING); @@ -1391,7 +1391,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con _setFillStyle(style, pbox); setPathVector(pathv); - if (style->fill_rule.value == SP_WIND_RULE_EVENODD) { + if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) { cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD); } else { cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING); @@ -1606,7 +1606,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma if (_render_mode == RENDER_MODE_CLIP) { if (_clip_mode == CLIP_MODE_MASK) { - if (style->fill_rule.value == SP_WIND_RULE_EVENODD) { + if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) { cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD); } else { cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING); -- cgit v1.2.3 From c35d732013f71fd9096a464ab53953129fb919cb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 9 May 2011 00:43:56 +0200 Subject: Fix compilation on GCC 4.6 (bzr r10202) --- src/2geom/transforms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 1c965eb9f..48d4b1dba 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -209,7 +209,7 @@ protected: public: Coord factor() const { return f; } void setFactor(Coord nf) { f = nf; } - S &operator*=(S const &s) { f += s.f; return *static_cast(this); } + S &operator*=(S const &s) { f += s.f; return static_cast(*this); } bool operator==(S const &s) const { return f == s.f; } S inverse() const { return S(-f); } static S identity() { return S(0); } -- cgit v1.2.3 From f365062bdb05d23dbf33073af566f98002ada583 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 9 May 2011 23:49:35 -0700 Subject: Added simple usage of most recent file locations. (bzr r10204) --- src/resource-manager.cpp | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index a68b2c7ae..0ccc05d49 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -8,11 +8,13 @@ #include #include +#include #include #include #include #include #include +#include #include "resource-manager.h" @@ -132,6 +134,25 @@ std::map ResourceManagerImpl::locateLinks(Glib::us { std::map result; + + // Note: we use a vector because we want them to stay in order: + std::vector priorLocations; + + Glib::RefPtr recentMgr = Gtk::RecentManager::get_default(); + std::vector< Glib::RefPtr > recentItems = recentMgr->get_items(); + for ( std::vector< Glib::RefPtr >::iterator it = recentItems.begin(); it != recentItems.end(); ++it ) { + Glib::ustring uri = (*it)->get_uri(); + std::string scheme = Glib::uri_parse_scheme(uri); + if ( scheme == "file" ) { + std::string path = Glib::filename_from_uri(uri); + path = Glib::path_get_dirname(path); + if ( std::find(priorLocations.begin(), priorLocations.end(), path) == priorLocations.end() ) { + // TODO debug g_message(" ==>[%s]", path.c_str()); + priorLocations.push_back(path); + } + } + } + // At the moment we expect this list to contain file:// references, or simple relative or absolute paths. for ( std::vector::const_iterator it = brokenLinks.begin(); it != brokenLinks.end(); ++it ) { // TODO debug g_message("========{%s}", it->c_str()); @@ -139,6 +160,7 @@ std::map ResourceManagerImpl::locateLinks(Glib::us std::string uri; if ( extractFilepath( *it, uri ) ) { // We were able to get some path. Check it + std::string origPath = uri; if ( !Glib::path_is_absolute(uri) ) { uri = Glib::build_filename(docbase, uri); @@ -165,11 +187,25 @@ std::map ResourceManagerImpl::locateLinks(Glib::us exists = Glib::file_test(rebuild, Glib::FILE_TEST_EXISTS); // TODO debug g_message(" [%s] [%s]%s", tmp.c_str(), remainder.c_str(), exists ? " XXXX" : ""); - if ( exists ) { - Glib::ustring replacement = Glib::filename_to_utf8( remainder ); - result[*it] = replacement; + } + + if ( !exists ) { + // TODO debug g_message("Expanding the search..."); + + // Check if the MRU bases point us to it. + if ( !Glib::path_is_absolute(origPath) ) { + for ( std::vector::iterator it = priorLocations.begin(); !exists && (it != priorLocations.end()); ++it ) { + remainder = Glib::build_filename( *it, origPath ); + exists = Glib::file_test( remainder, Glib::FILE_TEST_EXISTS ); + } } } + + if ( exists ) { + bool isAbsolute = Glib::path_is_absolute( remainder ); + Glib::ustring replacement = isAbsolute ? Glib::filename_to_uri( remainder ) : Glib::filename_to_utf8( remainder ); + result[*it] = replacement; + } } } } @@ -186,7 +222,7 @@ bool ResourceManagerImpl::fixupBrokenLinks(SPDocument *doc) std::vector brokenHrefs = findBrokenLinks(doc); if ( !brokenHrefs.empty() ) { - // TODO debug g_message(" FOUND SOME LINKS %d", brokenHrefs.size()); + // TODO debug g_message(" FOUND SOME LINKS %d", static_cast(brokenHrefs.size())); for ( std::vector::iterator it = brokenHrefs.begin(); it != brokenHrefs.end(); ++it ) { // TODO debug g_message(" [%s]", it->c_str()); } -- cgit v1.2.3 From 010da2dbdf05c0fa2ea791cb9d75a558551c8413 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 10 May 2011 00:48:37 -0700 Subject: Convert fixed paths to relative, including .. (bzr r10205) --- src/resource-manager.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'src') diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index 0ccc05d49..14a5ccfb8 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -25,6 +25,76 @@ namespace Inkscape { +std::vector splitPath( std::string const &path ) +{ + std::vector parts; + + std::string prior; + std::string tmp = path; + while ( !tmp.empty() && (tmp != prior) ) { + prior = tmp; + + parts.push_back( Glib::path_get_basename(tmp) ); + tmp = Glib::path_get_dirname(tmp); + } + if ( !parts.empty() ) { + std::reverse(parts.begin(), parts.end()); + } + + return parts; +} + +std::string convertPathToRelative( std::string const &path, std::string const &docbase ) +{ + std::string result = path; + + if ( !path.empty() && Glib::path_is_absolute(path) ) { + // Whack the parts into pieces + + std::vector parts = splitPath(path); + std::vector baseParts = splitPath(docbase); + + // TODO debug g_message("+++++++++++++++++++++++++"); + for ( std::vector::iterator it = parts.begin(); it != parts.end(); ++it ) { + // TODO debug g_message(" [%s]", it->c_str()); + } + // TODO debug g_message(" - - - - - - - - - - - - - - - "); + for ( std::vector::iterator it = baseParts.begin(); it != baseParts.end(); ++it ) { + // TODO debug g_message(" [%s]", it->c_str()); + } + // TODO debug g_message("+++++++++++++++++++++++++"); + + if ( !parts.empty() && !baseParts.empty() && (parts[0] == baseParts[0]) ) { + // Both paths have the same root. We can proceed. + while ( !parts.empty() && !baseParts.empty() && (parts[0] == baseParts[0]) ) { + parts.erase( parts.begin() ); + baseParts.erase( baseParts.begin() ); + } + + // TODO debug g_message("+++++++++++++++++++++++++"); + for ( std::vector::iterator it = parts.begin(); it != parts.end(); ++it ) { + // TODO debug g_message(" [%s]", it->c_str()); + } + // TODO debug g_message(" - - - - - - - - - - - - - - - "); + for ( std::vector::iterator it = baseParts.begin(); it != baseParts.end(); ++it ) { + // TODO debug g_message(" [%s]", it->c_str()); + } + // TODO debug g_message("+++++++++++++++++++++++++"); + + if ( !parts.empty() ) { + result.clear(); + + for ( size_t i = 0; i < baseParts.size(); ++i ) { + parts.insert(parts.begin(), ".."); + } + result = Glib::build_filename( parts ); + // TODO debug g_message("----> [%s]", result.c_str()); + } + } + } + + return result; +} class ResourceManagerImpl : public ResourceManager { @@ -202,6 +272,11 @@ std::map ResourceManagerImpl::locateLinks(Glib::us } if ( exists ) { + if ( Glib::path_is_absolute( remainder ) ) { + // TODO debug g_message("Need to convert to relative if possible [%s]", remainder.c_str()); + remainder = convertPathToRelative( remainder, docbase ); + } + bool isAbsolute = Glib::path_is_absolute( remainder ); Glib::ustring replacement = isAbsolute ? Glib::filename_to_uri( remainder ) : Glib::filename_to_utf8( remainder ); result[*it] = replacement; -- cgit v1.2.3 From 61495157884d4282f8539935f664c2453b5fb08e Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 10 May 2011 07:48:19 -0700 Subject: Fix test case to compile. (bzr r10203.1.1) --- src/dir-util-test.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/dir-util-test.h b/src/dir-util-test.h index 8f8475873..cc3bc20b8 100644 --- a/src/dir-util-test.h +++ b/src/dir-util-test.h @@ -17,17 +17,17 @@ public: {"/foo/bar/baz", "/foo/", "bar/baz"}, {"/foo/bar/baz", "/", "foo/bar/baz"}, {"/foo/bar/baz", "/foo/qux", "/foo/bar/baz"}, - {"/foo", NULL, "/foo"} }; for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { - char const* result = sp_relative_path_from_path( cases[i][0], cases[i][1] ); - TS_ASSERT( result ); - TS_ASSERT( cases[i][2] ); - if ( result && cases[i][2] ) - { - TS_ASSERT_EQUALS( std::string(result), std::string(cases[i][2]) ); + if ( cases[i][0] && cases[i][1] ) { // std::string can't use null. + std::string result = sp_relative_path_from_path( cases[i][0], cases[i][1] ); + TS_ASSERT( !result.empty() ); + if ( !result.empty() ) + { + TS_ASSERT_EQUALS( result, std::string(cases[i][2]) ); + } } } } -- cgit v1.2.3 From 30b576108f09306c301c3f1ec2ea1a1a31d450e3 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 11 May 2011 11:49:37 -0400 Subject: Fix fallback to MRU locations. (bzr r10207) --- src/resource-manager.cpp | 56 +++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index 14a5ccfb8..b5cf67f91 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -39,6 +39,9 @@ std::vector splitPath( std::string const &path ) } if ( !parts.empty() ) { std::reverse(parts.begin(), parts.end()); + if ( (parts[0] == ".") && (path[0] != '.') ) { + parts.erase(parts.begin()); + } } return parts; @@ -124,6 +127,8 @@ public: bool extractFilepath( Glib::ustring const &href, std::string &uri ); + bool searchUpwards( std::string const &base, std::string const &subpath, std::string &dest ); + protected: }; @@ -239,25 +244,8 @@ std::map ResourceManagerImpl::locateLinks(Glib::us if ( !Glib::file_test(uri, Glib::FILE_TEST_EXISTS) ) { // TODO debug g_message(" DOES NOT EXIST."); - std::string tmp = uri; - std::string prior; std::string remainder; - bool exists = false; - while ( (tmp != prior) && !exists) { - prior = tmp; - std::string basename = Glib::path_get_basename(tmp); - tmp = Glib::path_get_dirname(tmp); - if ( remainder.empty() ) { - remainder = basename; - } else { - remainder = Glib::build_filename(basename, remainder); - } - - std::string rebuild = Glib::build_filename(docbase, remainder); - exists = Glib::file_test(rebuild, Glib::FILE_TEST_EXISTS); - - // TODO debug g_message(" [%s] [%s]%s", tmp.c_str(), remainder.c_str(), exists ? " XXXX" : ""); - } + bool exists = searchUpwards( docbase, origPath, remainder ); if ( !exists ) { // TODO debug g_message("Expanding the search..."); @@ -265,8 +253,7 @@ std::map ResourceManagerImpl::locateLinks(Glib::us // Check if the MRU bases point us to it. if ( !Glib::path_is_absolute(origPath) ) { for ( std::vector::iterator it = priorLocations.begin(); !exists && (it != priorLocations.end()); ++it ) { - remainder = Glib::build_filename( *it, origPath ); - exists = Glib::file_test( remainder, Glib::FILE_TEST_EXISTS ); + exists = searchUpwards( *it, origPath, remainder ); } } } @@ -348,6 +335,35 @@ bool ResourceManagerImpl::fixupBrokenLinks(SPDocument *doc) } +bool ResourceManagerImpl::searchUpwards( std::string const &base, std::string const &subpath, std::string &dest ) +{ + bool exists = false; + // TODO debug g_message("............"); + + std::vector parts = splitPath(subpath); + std::vector baseParts = splitPath(base); + + while ( !exists && !baseParts.empty() ) { + std::vector current; + current.insert(current.begin(), parts.begin(), parts.end()); + // TODO debug g_message(" ---{%s}", Glib::build_filename( baseParts ).c_str()); + while ( !exists && !current.empty() ) { + std::vector combined; + combined.insert( combined.end(), baseParts.begin(), baseParts.end() ); + combined.insert( combined.end(), current.begin(), current.end() ); + std::string filepath = Glib::build_filename( combined ); + exists = Glib::file_test(filepath, Glib::FILE_TEST_EXISTS); + // TODO debug g_message(" ...[%s] %s", filepath.c_str(), (exists ? "XXX" : "")); + if ( exists ) { + dest = filepath; + } + current.erase( current.begin() ); + } + baseParts.pop_back(); + } + + return exists; +} static ResourceManagerImpl* theInstance = 0; -- cgit v1.2.3 From bb2e451ada0bbd3a04dddd7732a44c83f135af04 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 11 May 2011 13:50:57 -0400 Subject: Don't adjust the shink/grow value because we're saving the units. Fixed bugs: - https://launchpad.net/bugs/781244 (bzr r10207.1.1) --- src/widgets/toolbox.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 8496ec0d0..0dcecfcb1 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -8377,7 +8377,9 @@ static void paintbucket_offset_changed(GtkAdjustment *adj, GObject *tbl) SPUnit const *unit = tracker->getActiveUnit(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/tools/paintbucket/offset", (gdouble)sp_units_get_pixels(adj->value, *unit)); + // Don't adjust the offset value because we're saving the + // unit and it'll be correctly handled on load. + prefs->setDouble("/tools/paintbucket/offset", (gdouble)adj->value); prefs->setString("/tools/paintbucket/offsetunits", sp_unit_get_abbreviation(unit)); } -- cgit v1.2.3 From 08eedb1441005f836d223b6143dc15c8009a3535 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 17 May 2011 23:25:49 -0700 Subject: Made dependencies explicit and bumped versions. (bzr r10208) --- src/display/sp-canvas.cpp | 7 +------ src/ege-adjustment-action.cpp | 10 ---------- src/ege-select-one-action.cpp | 3 --- src/ink-comboboxentry-action.cpp | 27 --------------------------- src/ink-comboboxentry-action.h | 2 -- src/inkscape.cpp | 4 ---- src/io/sys.cpp | 4 +--- src/ui/dialog/glyphs.cpp | 20 -------------------- src/ui/dialog/glyphs.h | 2 -- src/widgets/sp-color-slider.cpp | 18 ++++++------------ src/widgets/sp-color-wheel-selector.cpp | 4 ---- 11 files changed, 8 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 2d1e57092..0d450362a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -47,12 +47,9 @@ using Inkscape::Debug::GdkEventLatencyTracker; -// GTK_CHECK_VERSION returns false on failure -#define HAS_GDK_EVENT_REQUEST_MOTIONS GTK_CHECK_VERSION(2, 12, 0) - // gtk_check_version returns non-NULL on failure static bool const HAS_BROKEN_MOTION_HINTS = - true || gtk_check_version(2, 12, 0) != NULL || !HAS_GDK_EVENT_REQUEST_MOTIONS; + true || gtk_check_version(2, 12, 0) != NULL; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -1599,9 +1596,7 @@ sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event) static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_window_get_pointer(w, NULL, NULL, NULL); -#if HAS_GDK_EVENT_REQUEST_MOTIONS gdk_event_request_motions(event); -#endif } /** diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 9c01b4c7c..b8ee66f08 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -47,10 +47,8 @@ #include #include #include -#if GTK_CHECK_VERSION(2,12,0) #include #include -#endif /* GTK_CHECK_VERSION(2,12,0) */ #include #include #include @@ -96,7 +94,6 @@ enum { APPEARANCE_MINIMAL, /* no label, just choices in a drop-down menu */ }; -#if GTK_CHECK_VERSION(2,12,0) /* TODO need to have appropriate icons setup for these: */ static const gchar *floogles[] = { GTK_STOCK_REMOVE, @@ -105,7 +102,6 @@ static const gchar *floogles[] = { GTK_STOCK_ABOUT, GTK_STOCK_GO_UP, 0}; -#endif /* GTK_CHECK_VERSION(2,12,0) */ typedef struct _EgeAdjustmentDescr EgeAdjustmentDescr; @@ -846,12 +842,10 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); -#if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { spinbutton = gtk_scale_button_new( GTK_ICON_SIZE_MENU, 0, 100, 2, 0 ); gtk_scale_button_set_adjustment( GTK_SCALE_BUTTON(spinbutton), act->private_data->adj ); gtk_scale_button_set_icons( GTK_SCALE_BUTTON(spinbutton), floogles ); -#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { if ( gFactoryCb ) { spinbutton = gFactoryCb( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); @@ -913,10 +907,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_signal_connect_swapped( G_OBJECT(spinbutton), "event", G_CALLBACK(event_cb), action ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { /* */ -#if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { /* */ -#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { gtk_entry_set_width_chars( GTK_ENTRY(spinbutton), act->private_data->digits + 3 ); } @@ -962,10 +954,8 @@ gboolean focus_in_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) EgeAdjustmentAction* action = EGE_ADJUSTMENT_ACTION( data ); if ( GTK_IS_SPIN_BUTTON(widget) ) { action->private_data->lastVal = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); -#if GTK_CHECK_VERSION(2,12,0) } else if ( GTK_IS_SCALE_BUTTON(widget) ) { action->private_data->lastVal = gtk_scale_button_get_value( GTK_SCALE_BUTTON(widget) ); -#endif /* GTK_CHECK_VERSION(2,12,0) */ } else if (GTK_IS_RANGE(widget) ) { action->private_data->lastVal = gtk_range_get_value( GTK_RANGE(widget) ); } diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 83a083425..1c3ec1ff5 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -935,7 +935,6 @@ void resync_sensitive( EgeSelectOneAction* act ) GSList* group = (GSList*)data; // List is backwards in group as compared to GtkTreeModel, we better do matching. while ( group ) { -#if GTK_CHECK_VERSION(2,16,0) GtkRadioAction* ract = GTK_RADIO_ACTION(group->data); const gchar* label = gtk_action_get_label( GTK_ACTION( ract ) ); @@ -964,8 +963,6 @@ void resync_sensitive( EgeSelectOneAction* act ) } gtk_action_set_sensitive( GTK_ACTION(ract), sens ); -#endif - group = g_slist_next(group); } } diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 74034e537..eaaf62113 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -266,9 +266,7 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) action->active = -1; action->text = NULL; action->entry_completion = NULL; -#if !GTK_CHECK_VERSION(2,16,0) action->indicator = NULL; -#endif action->popup = false; action->warning = NULL; action->altx_name = NULL; @@ -348,15 +346,7 @@ GtkWidget* create_tool_item( GtkAction* action ) { GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); -#if GTK_CHECK_VERSION(2,16,0) gtk_container_add( GTK_CONTAINER(align), comboBoxEntry ); -#else // GTK_CHECK_VERSION(2,16,0) - GtkWidget *hbox = gtk_hbox_new( FALSE, 0 ); - ink_comboboxentry_action->indicator = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_box_pack_start( GTK_BOX(hbox), comboBoxEntry, TRUE, TRUE, 0 ); - gtk_box_pack_start( GTK_BOX(hbox), ink_comboboxentry_action->indicator, FALSE, FALSE, 0 ); - gtk_container_add( GTK_CONTAINER(align), hbox ); -#endif // GTK_CHECK_VERSION(2,16,0) gtk_container_add( GTK_CONTAINER(item), align ); } @@ -415,10 +405,7 @@ GtkWidget* create_tool_item( GtkAction* action ) } -#if GTK_CHECK_VERSION(2,16,0) gtk_action_connect_proxy( GTK_ACTION( action ), item ); -#endif - gtk_widget_show_all( item ); } else { @@ -480,7 +467,6 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink // Show or hide warning if( ink_comboboxentry_action->active == -1 && ink_comboboxentry_action->warning != NULL ) { -#if GTK_CHECK_VERSION(2,16,0) { GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); @@ -498,22 +484,13 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, GTK_ENTRY_ICON_SECONDARY, ink_comboboxentry_action->warning ); -#else // GTK_CHECK_VERSION(2,16,0) - gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, ink_comboboxentry_action->warning ); -#endif // GTK_CHECK_VERSION(2,16,0) } else { -#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); gtk_entry_set_icon_from_stock( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); -#else // GTK_CHECK_VERSION(2,16,0) - gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), NULL, GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, NULL ); -#endif // GTK_CHECK_VERSION(2,16,0) } } @@ -585,13 +562,9 @@ void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, // Widget may not have been created.... if( action->entry ) { -#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_tooltip_text( GTK_ENTRY(action->entry), GTK_ENTRY_ICON_SECONDARY, action->warning ); -#else // GTK_CHECK_VERSION(2,16,0) - gtk_image_set_from_stock( GTK_IMAGE(action->indicator), action->warning ? GTK_STOCK_DIALOG_WARNING : 0, GTK_ICON_SIZE_SMALL_TOOLBAR ); -#endif // GTK_CHECK_VERSION(2,16,0) } } diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index e080e6cdf..1a83cb053 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -49,9 +49,7 @@ struct _Ink_ComboBoxEntry_Action { GtkComboBoxEntry *combobox; GtkEntry *entry; GtkEntryCompletion *entry_completion; -#if !GTK_CHECK_VERSION(2,16,0) GtkWidget *indicator; -#endif gpointer cell_data_func; // drop-down menu format diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 91e3b0c5f..1b0893c0b 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -442,11 +442,7 @@ void inkscape_autosave_init() // Turn on autosave guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60; // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10)); -#if GLIB_CHECK_VERSION(2,14,0) autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL); -#else - autosave_timeout_id = g_timeout_add(timeout * 1000, inkscape_autosave, NULL); -#endif } } diff --git a/src/io/sys.cpp b/src/io/sys.cpp index a68d02707..e6c512be2 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -19,9 +19,7 @@ #include #include #include -#if GLIB_CHECK_VERSION(2,6,0) - #include -#endif +#include #include #include diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index f3d7ed971..8eef5d89b 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -48,7 +48,6 @@ GlyphsPanel &GlyphsPanel::getInstance() } -#if GLIB_CHECK_VERSION(2,14,0) static std::map & getScriptToName() { static bool init = false; @@ -123,8 +122,6 @@ static std::map & getScriptToName() mappings[G_UNICODE_SCRIPT_PHOENICIAN] = _("Phoenician"); mappings[G_UNICODE_SCRIPT_PHAGS_PA] = _("Phags-pa"); mappings[G_UNICODE_SCRIPT_NKO] = _("N'Ko"); - -#if GLIB_CHECK_VERSION(2,14,0) mappings[G_UNICODE_SCRIPT_KAYAH_LI] = _("Kayah Li"); mappings[G_UNICODE_SCRIPT_LEPCHA] = _("Lepcha"); mappings[G_UNICODE_SCRIPT_REJANG] = _("Rejang"); @@ -136,11 +133,9 @@ static std::map & getScriptToName() mappings[G_UNICODE_SCRIPT_CARIAN] = _("Carian"); mappings[G_UNICODE_SCRIPT_LYCIAN] = _("Lycian"); mappings[G_UNICODE_SCRIPT_LYDIAN] = _("Lydian"); -#endif // GLIB_CHECK_VERSION(2,14,0) } return mappings; } -#endif // GLIB_CHECK_VERSION(2,14,0) typedef std::pair Range; typedef std::pair NamedRange; @@ -337,9 +332,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : entry(0), label(0), insertBtn(0), -#if GLIB_CHECK_VERSION(2,14,0) scriptCombo(0), -#endif // GLIB_CHECK_VERSION(2,14,0) fsel(0), targetDesktop(0), deskTrack(), @@ -366,7 +359,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- -#if GLIB_CHECK_VERSION(2,14,0) { Gtk::Label *label = new Gtk::Label(_("Script: ")); table->attach( *Gtk::manage(label), @@ -391,7 +383,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : } row++; -#endif // GLIB_CHECK_VERSION(2,14,0) // ------------------------------- @@ -464,10 +455,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : insertBtn = new Gtk::Button(_("Append")); conn = insertBtn->signal_clicked().connect(sigc::mem_fun(*this, &GlyphsPanel::insertText)); instanceConns.push_back(conn); -#if GTK_CHECK_VERSION(2,18,0) - //gtkmm 2.18 insertBtn->set_can_default(); -#endif insertBtn->set_sensitive(false); box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); @@ -607,13 +595,11 @@ void GlyphsPanel::glyphSelectionChanged() Glib::ustring scriptName; -#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = g_unichar_get_script(ch); std::map mappings = getScriptToName(); if (mappings.find(script) != mappings.end()) { scriptName = mappings[script]; } -#endif gchar * tmp = g_strdup_printf("U+%04X %s", ch, scriptName.c_str()); label->set_text(tmp); } @@ -680,7 +666,6 @@ void GlyphsPanel::rebuild() if (font) { //double sp_font_selector_get_size (SPFontSelector *fsel); -#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; Glib::ustring scriptName = scriptCombo->get_active_text(); std::map items = getScriptToName(); @@ -690,7 +675,6 @@ void GlyphsPanel::rebuild() break; } } -#endif // GLIB_CHECK_VERSION(2,14,0) // Disconnect the model while we update it. Simple work-around for 5x+ performance boost. Glib::RefPtr tmp = Gtk::ListStore::create(*getColumns()); @@ -707,13 +691,9 @@ void GlyphsPanel::rebuild() for (gunichar ch = lower; ch <= upper; ch++) { int glyphId = font->MapUnicodeChar(ch); if (glyphId > 0) { -#if GLIB_CHECK_VERSION(2,14,0) if ((script == G_UNICODE_SCRIPT_INVALID_CODE) || (script == g_unichar_get_script(ch))) { present.push_back(ch); } -#else - present.push_back(ch); -#endif } } diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index d6c731dda..1440a693f 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -77,9 +77,7 @@ private: Gtk::Entry *entry; Gtk::Label *label; Gtk::Button *insertBtn; -#if GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *scriptCombo; -#endif //GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *rangeCombo; SPFontSelector *fsel; SPDesktop *targetDesktop; diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 0e30b1ce6..0690caaab 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -1,5 +1,3 @@ -#define __SP_COLOR_SLIDER_C__ - /* * A slider with colored background * @@ -329,21 +327,17 @@ sp_color_slider_new (GtkAdjustment *adjustment) return GTK_WIDGET (slider); } -void -sp_color_slider_set_adjustment (SPColorSlider *slider, GtkAdjustment *adjustment) +void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjustment) { - g_return_if_fail (slider != NULL); - g_return_if_fail (SP_IS_COLOR_SLIDER (slider)); + g_return_if_fail (slider != NULL); + g_return_if_fail (SP_IS_COLOR_SLIDER (slider)); - if (!adjustment) { - adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0); - } -#if GTK_CHECK_VERSION (2,14,0) - else { + if (!adjustment) { + adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0); + } else { gtk_adjustment_set_page_increment(adjustment, 0.0); gtk_adjustment_set_page_size(adjustment, 0.0); } -#endif if (slider->adjustment != adjustment) { if (slider->adjustment) { diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 2e36a024e..784dd23ad 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -135,14 +135,12 @@ static void resizeHSVWheel( GtkHSV *hsv, GtkAllocation *allocation ) gtk_hsv_set_metrics( hsv, diam, ring ); } -#if GTK_CHECK_VERSION(2,18,0) static void handleWheelStyleSet(GtkHSV *hsv, GtkStyle* /*previous*/, gpointer /*userData*/) { GtkAllocation allocation = {0, 0, 0, 0}; gtk_widget_get_allocation( GTK_WIDGET(hsv), &allocation ); resizeHSVWheel( hsv, &allocation ); } -#endif // GTK_CHECK_VERSION(2,18,0) static void handleWheelAllocation(GtkHSV *hsv, GtkAllocation *allocation, gpointer /*userData*/) { @@ -220,10 +218,8 @@ void ColorWheelSelector::init() // GTK does not automatically scale the color wheel, so we have to add that in: gtk_signal_connect( GTK_OBJECT(_wheel), "size-allocate", GTK_SIGNAL_FUNC(handleWheelAllocation), _csel ); -#if GTK_CHECK_VERSION(2,18,0) gtk_signal_connect( GTK_OBJECT(_wheel), "style-set", GTK_SIGNAL_FUNC(handleWheelStyleSet), _csel ); -#endif // GTK_CHECK_VERSION(2,18,0) } static void -- cgit v1.2.3 From 7239afff554c14388dd6e930d903beb7bbd8b2ca Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Wed, 18 May 2011 17:04:33 -0300 Subject: Adding inkscape:label parameter to guidelines so that our guidelanes can display labels (we still dont have a user interface, but files with that parameter will render correctly) (bzr r10209) --- src/desktop-events.cpp | 2 +- src/display/guideline.cpp | 58 +++++++++++++++++++++++++++++++++++++++-------- src/display/guideline.h | 4 +++- src/sp-guide.cpp | 25 +++++++++++++++++++- src/sp-guide.h | 2 ++ src/ui/widget/ruler.cpp | 2 +- 6 files changed, 80 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index b458827f0..b7b7529a1 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -131,7 +131,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge } } - guide = sp_guideline_new(desktop->guides, event_dt, normal); + guide = sp_guideline_new(desktop->guides, NULL, event_dt, normal); sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor); gdk_pointer_grab(widget->window, FALSE, (GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ), diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index bebec2852..f0e1c7724 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -19,6 +19,8 @@ #include "sp-canvas-util.h" #include "sp-ctrlpoint.h" #include "guideline.h" +#include "cairo.h" +#include "inkscape-cairo.h" static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); @@ -78,6 +80,7 @@ static void sp_guideline_init(SPGuideLine *gl) gl->sensitive = 0; gl->origin = NULL; + gl->label = NULL; } static void sp_guideline_destroy(GtkObject *object) @@ -99,25 +102,35 @@ static void sp_guideline_destroy(GtkObject *object) static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) { + //TODO: the routine that renders the label of a specific guideline sometimes + // ends up erasing the labels of the other guidelines. + // Maybe we should render all labels everytime. + SPGuideLine const *gl = SP_GUIDELINE (item); sp_canvas_prepare_buffer(buf); + cairo_t* ctx = nr_create_cairo_context_canvasbuf (NULL /*area*/, buf); //this function ignores the "area" parameter + cairo_set_font_size (ctx, 10); + cairo_set_line_width (ctx, 10); + cairo_set_source_rgb (ctx, 0, 0, 0); unsigned int const r = NR_RGBA32_R (gl->rgba); unsigned int const g = NR_RGBA32_G (gl->rgba); unsigned int const b = NR_RGBA32_B (gl->rgba); unsigned int const a = NR_RGBA32_A (gl->rgba); + int px = (int) Inkscape::round(gl->point_on_line[Geom::X]); + int py = (int) Inkscape::round(gl->point_on_line[Geom::Y]); + if (gl->is_vertical()) { - int position = (int) Inkscape::round(gl->point_on_line[Geom::X]); - if (position < buf->rect.x0 || position >= buf->rect.x1) { + if (px < buf->rect.x0 || px >= buf->rect.x1) { return; } int p0 = buf->rect.y0; int p1 = buf->rect.y1; int step = buf->buf_rowstride; - unsigned char *d = buf->buf + 4 * (position - buf->rect.x0); + unsigned char *d = buf->buf + 4 * (px - buf->rect.x0); for (int p = p0; p < p1; p++) { d[0] = NR_COMPOSEN11_1111(r, a, d[0]); @@ -125,16 +138,22 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) d[2] = NR_COMPOSEN11_1111(b, a, d[2]); d += step; } + + if (gl->label){ + cairo_move_to(ctx, px - buf->rect.x0 + 5, py - buf->rect.y0); + cairo_rotate(ctx, 3.1415/2); + cairo_show_text(ctx, gl->label); + } + } else if (gl->is_horizontal()) { - int position = (int) Inkscape::round(gl->point_on_line[Geom::Y]); - if (position < buf->rect.y0 || position >= buf->rect.y1) { + if (py < buf->rect.y0 || py >= buf->rect.y1) { return; } int p0 = buf->rect.x0; int p1 = buf->rect.x1; int step = 4; - unsigned char *d = buf->buf + (position - buf->rect.y0) * buf->buf_rowstride; + unsigned char *d = buf->buf + (py - buf->rect.y0) * buf->buf_rowstride; for (int p = p0; p < p1; p++) { d[0] = NR_COMPOSEN11_1111(r, a, d[0]); @@ -142,6 +161,12 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) d[2] = NR_COMPOSEN11_1111(b, a, d[2]); d += step; } + + if (gl->label){ + cairo_move_to(ctx, px - buf->rect.x0, py - buf->rect.y0 - 5); + cairo_show_text(ctx, gl->label); + } + } else { // render angled line, once intersection has been detected, draw from there. Geom::Point parallel_to_line( gl->normal_to_line[Geom::Y], @@ -180,6 +205,12 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) sp_guideline_drawline (buf, static_cast(round(x_intersect_bottom)), buf->rect.y1, static_cast(round(x_intersect_top)), buf->rect.y0, gl->rgba); return; } + + if (gl->label){ + cairo_move_to(ctx, px - buf->rect.x0 + 5, py - buf->rect.y0); + cairo_rotate(ctx, atan2(gl->normal_to_line[Geom::X], gl->normal_to_line[Geom::Y])); + cairo_show_text(ctx, gl->label); + } } } @@ -198,10 +229,11 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, sp_canvas_item_request_update(SP_CANVAS_ITEM (gl->origin)); if (gl->is_horizontal()) { - sp_canvas_update_bbox (item, -1000000, (int) Inkscape::round(gl->point_on_line[Geom::Y]), 1000000, (int) Inkscape::round(gl->point_on_line[Geom::Y] + 1)); + sp_canvas_update_bbox (item, -1000000, (int) Inkscape::round(gl->point_on_line[Geom::Y] - 16), 1000000, (int) Inkscape::round(gl->point_on_line[Geom::Y] + 1)); } else if (gl->is_vertical()) { - sp_canvas_update_bbox (item, (int) Inkscape::round(gl->point_on_line[Geom::X]), -1000000, (int) Inkscape::round(gl->point_on_line[Geom::X] + 1), 1000000); + sp_canvas_update_bbox (item, (int) Inkscape::round(gl->point_on_line[Geom::X]), -1000000, (int) Inkscape::round(gl->point_on_line[Geom::X] + 16), 1000000); } else { + //TODO: labels in angled guidelines are not showing up for some reason. sp_canvas_update_bbox (item, -1000000, -1000000, 1000000, 1000000); } } @@ -222,7 +254,7 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem return MAX(fabs(distance)-1, 0); } -SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, Geom::Point normal) +SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point point_on_line, Geom::Point normal) { SPCanvasItem *item = sp_canvas_item_new(parent, SP_TYPE_GUIDELINE, NULL); SPCanvasItem *origin = sp_canvas_item_new(parent, SP_TYPE_CTRLPOINT, NULL); @@ -232,6 +264,7 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, gl->origin = cp; normal.normalize(); + gl->label = label; gl->normal_to_line = normal; gl->angle = tan( -gl->normal_to_line[Geom::X] / gl->normal_to_line[Geom::Y]); sp_guideline_set_position(gl, point_on_line); @@ -241,6 +274,13 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, return item; } +void sp_guideline_set_label(SPGuideLine *gl, char* label) +{ + gl->label = label; + + sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); +} + void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line) { sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl), Geom::Affine(Geom::Translate(point_on_line))); diff --git a/src/display/guideline.h b/src/display/guideline.h index 9654d04a1..dbf990d1f 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -29,6 +29,7 @@ struct SPGuideLine { guint32 rgba; + char* label; Geom::Point normal_to_line; Geom::Point point_on_line; double angle; @@ -45,8 +46,9 @@ struct SPGuideLineClass { GType sp_guideline_get_type(); -SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, Geom::Point normal); +SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point point_on_line, Geom::Point normal); +void sp_guideline_set_label(SPGuideLine *gl, char* label); void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line); void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line); void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba); diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 7d36df4a3..1e51ee4d5 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -160,6 +160,7 @@ static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } + object->readAttr( "inkscape:label" ); object->readAttr( "orientation" ); object->readAttr( "position" ); } @@ -183,6 +184,15 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) SPGuide *guide = SP_GUIDE(object); switch (key) { + case SP_ATTR_INKSCAPE_LABEL: + if (value) { + guide->label = g_strdup(value); + } else { + guide->label = NULL; + } + + sp_guide_set_label(*guide, guide->label, false); + break; case SP_ATTR_ORIENTATION: { if (value && !strcmp(value, "horizontal")) { @@ -291,7 +301,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { - SPCanvasItem *item = sp_guideline_new(group, point_on_line, normal_to_line); + SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line); sp_guideline_set_color(SP_GUIDELINE(item), color); g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); @@ -402,6 +412,19 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool */ } +void sp_guide_set_label(SPGuide &guide, char* label, bool const commit) +{ + g_assert(SP_IS_GUIDE(&guide)); + if (guide.views){ + sp_guideline_set_label(SP_GUIDELINE(guide.views->data), label); + } + + if (commit){ + //XML Tree being used directly while it shouldn't be + guide.getRepr()->setAttribute("label", label); + } +} + /** * Returns a human-readable description of the guideline for use in dialog boxes and status bar. * If verbose is false, only positioning information is included (useful for dialogs). diff --git a/src/sp-guide.h b/src/sp-guide.h index c53042da5..1dcdbc662 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -31,6 +31,7 @@ struct SPCanvasGroup; /* Represents the constraint on p that dot(g.direction, p) == g.position. */ class SPGuide : public SPObject { public: + char* label; Geom::Point normal_to_line; Geom::Point point_on_line; @@ -62,6 +63,7 @@ void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); +void sp_guide_set_label(SPGuide &guide, char* const label, bool const commit); void sp_guide_remove(SPGuide *guide); char *sp_guide_description(SPGuide const *guide, const bool verbose = true); diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index a220a54ad..c6ac3a381 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -108,7 +108,7 @@ Ruler::on_button_press_event(GdkEventButton *evb) _dragging = true; sp_repr_set_boolean(repr, "showguides", TRUE); sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE); - _guide = sp_guideline_new(_dt->guides, event_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.)); + _guide = sp_guideline_new(_dt->guides, NULL, event_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.)); sp_guideline_set_color(SP_GUIDELINE(_guide), _dt->namedview->guidehicolor); (void) get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK | -- cgit v1.2.3 From a622000f4859173bb7ac484b86cefe9fa4f169e4 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 18 May 2011 21:43:01 -0700 Subject: Revert version bump so win devlibs can catch up. (bzr r10210) --- src/display/sp-canvas.cpp | 7 ++++++- src/ege-adjustment-action.cpp | 10 ++++++++++ src/ege-select-one-action.cpp | 3 +++ src/ink-comboboxentry-action.cpp | 27 +++++++++++++++++++++++++++ src/ink-comboboxentry-action.h | 2 ++ src/inkscape.cpp | 4 ++++ src/io/sys.cpp | 4 +++- src/ui/dialog/glyphs.cpp | 20 ++++++++++++++++++++ src/ui/dialog/glyphs.h | 2 ++ src/widgets/sp-color-slider.cpp | 18 ++++++++++++------ src/widgets/sp-color-wheel-selector.cpp | 4 ++++ 11 files changed, 93 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0d450362a..2d1e57092 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -47,9 +47,12 @@ using Inkscape::Debug::GdkEventLatencyTracker; +// GTK_CHECK_VERSION returns false on failure +#define HAS_GDK_EVENT_REQUEST_MOTIONS GTK_CHECK_VERSION(2, 12, 0) + // gtk_check_version returns non-NULL on failure static bool const HAS_BROKEN_MOTION_HINTS = - true || gtk_check_version(2, 12, 0) != NULL; + true || gtk_check_version(2, 12, 0) != NULL || !HAS_GDK_EVENT_REQUEST_MOTIONS; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -1596,7 +1599,9 @@ sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event) static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_window_get_pointer(w, NULL, NULL, NULL); +#if HAS_GDK_EVENT_REQUEST_MOTIONS gdk_event_request_motions(event); +#endif } /** diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index b8ee66f08..9c01b4c7c 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -47,8 +47,10 @@ #include #include #include +#if GTK_CHECK_VERSION(2,12,0) #include #include +#endif /* GTK_CHECK_VERSION(2,12,0) */ #include #include #include @@ -94,6 +96,7 @@ enum { APPEARANCE_MINIMAL, /* no label, just choices in a drop-down menu */ }; +#if GTK_CHECK_VERSION(2,12,0) /* TODO need to have appropriate icons setup for these: */ static const gchar *floogles[] = { GTK_STOCK_REMOVE, @@ -102,6 +105,7 @@ static const gchar *floogles[] = { GTK_STOCK_ABOUT, GTK_STOCK_GO_UP, 0}; +#endif /* GTK_CHECK_VERSION(2,12,0) */ typedef struct _EgeAdjustmentDescr EgeAdjustmentDescr; @@ -842,10 +846,12 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); +#if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { spinbutton = gtk_scale_button_new( GTK_ICON_SIZE_MENU, 0, 100, 2, 0 ); gtk_scale_button_set_adjustment( GTK_SCALE_BUTTON(spinbutton), act->private_data->adj ); gtk_scale_button_set_icons( GTK_SCALE_BUTTON(spinbutton), floogles ); +#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { if ( gFactoryCb ) { spinbutton = gFactoryCb( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); @@ -907,8 +913,10 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_signal_connect_swapped( G_OBJECT(spinbutton), "event", G_CALLBACK(event_cb), action ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { /* */ +#if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { /* */ +#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { gtk_entry_set_width_chars( GTK_ENTRY(spinbutton), act->private_data->digits + 3 ); } @@ -954,8 +962,10 @@ gboolean focus_in_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) EgeAdjustmentAction* action = EGE_ADJUSTMENT_ACTION( data ); if ( GTK_IS_SPIN_BUTTON(widget) ) { action->private_data->lastVal = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); +#if GTK_CHECK_VERSION(2,12,0) } else if ( GTK_IS_SCALE_BUTTON(widget) ) { action->private_data->lastVal = gtk_scale_button_get_value( GTK_SCALE_BUTTON(widget) ); +#endif /* GTK_CHECK_VERSION(2,12,0) */ } else if (GTK_IS_RANGE(widget) ) { action->private_data->lastVal = gtk_range_get_value( GTK_RANGE(widget) ); } diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 1c3ec1ff5..83a083425 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -935,6 +935,7 @@ void resync_sensitive( EgeSelectOneAction* act ) GSList* group = (GSList*)data; // List is backwards in group as compared to GtkTreeModel, we better do matching. while ( group ) { +#if GTK_CHECK_VERSION(2,16,0) GtkRadioAction* ract = GTK_RADIO_ACTION(group->data); const gchar* label = gtk_action_get_label( GTK_ACTION( ract ) ); @@ -963,6 +964,8 @@ void resync_sensitive( EgeSelectOneAction* act ) } gtk_action_set_sensitive( GTK_ACTION(ract), sens ); +#endif + group = g_slist_next(group); } } diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index eaaf62113..74034e537 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -266,7 +266,9 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) action->active = -1; action->text = NULL; action->entry_completion = NULL; +#if !GTK_CHECK_VERSION(2,16,0) action->indicator = NULL; +#endif action->popup = false; action->warning = NULL; action->altx_name = NULL; @@ -346,7 +348,15 @@ GtkWidget* create_tool_item( GtkAction* action ) { GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); +#if GTK_CHECK_VERSION(2,16,0) gtk_container_add( GTK_CONTAINER(align), comboBoxEntry ); +#else // GTK_CHECK_VERSION(2,16,0) + GtkWidget *hbox = gtk_hbox_new( FALSE, 0 ); + ink_comboboxentry_action->indicator = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_box_pack_start( GTK_BOX(hbox), comboBoxEntry, TRUE, TRUE, 0 ); + gtk_box_pack_start( GTK_BOX(hbox), ink_comboboxentry_action->indicator, FALSE, FALSE, 0 ); + gtk_container_add( GTK_CONTAINER(align), hbox ); +#endif // GTK_CHECK_VERSION(2,16,0) gtk_container_add( GTK_CONTAINER(item), align ); } @@ -405,7 +415,10 @@ GtkWidget* create_tool_item( GtkAction* action ) } +#if GTK_CHECK_VERSION(2,16,0) gtk_action_connect_proxy( GTK_ACTION( action ), item ); +#endif + gtk_widget_show_all( item ); } else { @@ -467,6 +480,7 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink // Show or hide warning if( ink_comboboxentry_action->active == -1 && ink_comboboxentry_action->warning != NULL ) { +#if GTK_CHECK_VERSION(2,16,0) { GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); @@ -484,13 +498,22 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, GTK_ENTRY_ICON_SECONDARY, ink_comboboxentry_action->warning ); +#else // GTK_CHECK_VERSION(2,16,0) + gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, ink_comboboxentry_action->warning ); +#endif // GTK_CHECK_VERSION(2,16,0) } else { +#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); gtk_entry_set_icon_from_stock( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); +#else // GTK_CHECK_VERSION(2,16,0) + gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), NULL, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, NULL ); +#endif // GTK_CHECK_VERSION(2,16,0) } } @@ -562,9 +585,13 @@ void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, // Widget may not have been created.... if( action->entry ) { +#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_tooltip_text( GTK_ENTRY(action->entry), GTK_ENTRY_ICON_SECONDARY, action->warning ); +#else // GTK_CHECK_VERSION(2,16,0) + gtk_image_set_from_stock( GTK_IMAGE(action->indicator), action->warning ? GTK_STOCK_DIALOG_WARNING : 0, GTK_ICON_SIZE_SMALL_TOOLBAR ); +#endif // GTK_CHECK_VERSION(2,16,0) } } diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index 1a83cb053..e080e6cdf 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -49,7 +49,9 @@ struct _Ink_ComboBoxEntry_Action { GtkComboBoxEntry *combobox; GtkEntry *entry; GtkEntryCompletion *entry_completion; +#if !GTK_CHECK_VERSION(2,16,0) GtkWidget *indicator; +#endif gpointer cell_data_func; // drop-down menu format diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1b0893c0b..91e3b0c5f 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -442,7 +442,11 @@ void inkscape_autosave_init() // Turn on autosave guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60; // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10)); +#if GLIB_CHECK_VERSION(2,14,0) autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL); +#else + autosave_timeout_id = g_timeout_add(timeout * 1000, inkscape_autosave, NULL); +#endif } } diff --git a/src/io/sys.cpp b/src/io/sys.cpp index e6c512be2..a68d02707 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -19,7 +19,9 @@ #include #include #include -#include +#if GLIB_CHECK_VERSION(2,6,0) + #include +#endif #include #include diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 8eef5d89b..f3d7ed971 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -48,6 +48,7 @@ GlyphsPanel &GlyphsPanel::getInstance() } +#if GLIB_CHECK_VERSION(2,14,0) static std::map & getScriptToName() { static bool init = false; @@ -122,6 +123,8 @@ static std::map & getScriptToName() mappings[G_UNICODE_SCRIPT_PHOENICIAN] = _("Phoenician"); mappings[G_UNICODE_SCRIPT_PHAGS_PA] = _("Phags-pa"); mappings[G_UNICODE_SCRIPT_NKO] = _("N'Ko"); + +#if GLIB_CHECK_VERSION(2,14,0) mappings[G_UNICODE_SCRIPT_KAYAH_LI] = _("Kayah Li"); mappings[G_UNICODE_SCRIPT_LEPCHA] = _("Lepcha"); mappings[G_UNICODE_SCRIPT_REJANG] = _("Rejang"); @@ -133,9 +136,11 @@ static std::map & getScriptToName() mappings[G_UNICODE_SCRIPT_CARIAN] = _("Carian"); mappings[G_UNICODE_SCRIPT_LYCIAN] = _("Lycian"); mappings[G_UNICODE_SCRIPT_LYDIAN] = _("Lydian"); +#endif // GLIB_CHECK_VERSION(2,14,0) } return mappings; } +#endif // GLIB_CHECK_VERSION(2,14,0) typedef std::pair Range; typedef std::pair NamedRange; @@ -332,7 +337,9 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : entry(0), label(0), insertBtn(0), +#if GLIB_CHECK_VERSION(2,14,0) scriptCombo(0), +#endif // GLIB_CHECK_VERSION(2,14,0) fsel(0), targetDesktop(0), deskTrack(), @@ -359,6 +366,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- +#if GLIB_CHECK_VERSION(2,14,0) { Gtk::Label *label = new Gtk::Label(_("Script: ")); table->attach( *Gtk::manage(label), @@ -383,6 +391,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : } row++; +#endif // GLIB_CHECK_VERSION(2,14,0) // ------------------------------- @@ -455,7 +464,10 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : insertBtn = new Gtk::Button(_("Append")); conn = insertBtn->signal_clicked().connect(sigc::mem_fun(*this, &GlyphsPanel::insertText)); instanceConns.push_back(conn); +#if GTK_CHECK_VERSION(2,18,0) + //gtkmm 2.18 insertBtn->set_can_default(); +#endif insertBtn->set_sensitive(false); box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); @@ -595,11 +607,13 @@ void GlyphsPanel::glyphSelectionChanged() Glib::ustring scriptName; +#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = g_unichar_get_script(ch); std::map mappings = getScriptToName(); if (mappings.find(script) != mappings.end()) { scriptName = mappings[script]; } +#endif gchar * tmp = g_strdup_printf("U+%04X %s", ch, scriptName.c_str()); label->set_text(tmp); } @@ -666,6 +680,7 @@ void GlyphsPanel::rebuild() if (font) { //double sp_font_selector_get_size (SPFontSelector *fsel); +#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; Glib::ustring scriptName = scriptCombo->get_active_text(); std::map items = getScriptToName(); @@ -675,6 +690,7 @@ void GlyphsPanel::rebuild() break; } } +#endif // GLIB_CHECK_VERSION(2,14,0) // Disconnect the model while we update it. Simple work-around for 5x+ performance boost. Glib::RefPtr tmp = Gtk::ListStore::create(*getColumns()); @@ -691,9 +707,13 @@ void GlyphsPanel::rebuild() for (gunichar ch = lower; ch <= upper; ch++) { int glyphId = font->MapUnicodeChar(ch); if (glyphId > 0) { +#if GLIB_CHECK_VERSION(2,14,0) if ((script == G_UNICODE_SCRIPT_INVALID_CODE) || (script == g_unichar_get_script(ch))) { present.push_back(ch); } +#else + present.push_back(ch); +#endif } } diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 1440a693f..d6c731dda 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -77,7 +77,9 @@ private: Gtk::Entry *entry; Gtk::Label *label; Gtk::Button *insertBtn; +#if GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *scriptCombo; +#endif //GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *rangeCombo; SPFontSelector *fsel; SPDesktop *targetDesktop; diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 0690caaab..0e30b1ce6 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -1,3 +1,5 @@ +#define __SP_COLOR_SLIDER_C__ + /* * A slider with colored background * @@ -327,17 +329,21 @@ sp_color_slider_new (GtkAdjustment *adjustment) return GTK_WIDGET (slider); } -void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjustment) +void +sp_color_slider_set_adjustment (SPColorSlider *slider, GtkAdjustment *adjustment) { - g_return_if_fail (slider != NULL); - g_return_if_fail (SP_IS_COLOR_SLIDER (slider)); + g_return_if_fail (slider != NULL); + g_return_if_fail (SP_IS_COLOR_SLIDER (slider)); - if (!adjustment) { - adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0); - } else { + if (!adjustment) { + adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0); + } +#if GTK_CHECK_VERSION (2,14,0) + else { gtk_adjustment_set_page_increment(adjustment, 0.0); gtk_adjustment_set_page_size(adjustment, 0.0); } +#endif if (slider->adjustment != adjustment) { if (slider->adjustment) { diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 784dd23ad..2e36a024e 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -135,12 +135,14 @@ static void resizeHSVWheel( GtkHSV *hsv, GtkAllocation *allocation ) gtk_hsv_set_metrics( hsv, diam, ring ); } +#if GTK_CHECK_VERSION(2,18,0) static void handleWheelStyleSet(GtkHSV *hsv, GtkStyle* /*previous*/, gpointer /*userData*/) { GtkAllocation allocation = {0, 0, 0, 0}; gtk_widget_get_allocation( GTK_WIDGET(hsv), &allocation ); resizeHSVWheel( hsv, &allocation ); } +#endif // GTK_CHECK_VERSION(2,18,0) static void handleWheelAllocation(GtkHSV *hsv, GtkAllocation *allocation, gpointer /*userData*/) { @@ -218,8 +220,10 @@ void ColorWheelSelector::init() // GTK does not automatically scale the color wheel, so we have to add that in: gtk_signal_connect( GTK_OBJECT(_wheel), "size-allocate", GTK_SIGNAL_FUNC(handleWheelAllocation), _csel ); +#if GTK_CHECK_VERSION(2,18,0) gtk_signal_connect( GTK_OBJECT(_wheel), "style-set", GTK_SIGNAL_FUNC(handleWheelStyleSet), _csel ); +#endif // GTK_CHECK_VERSION(2,18,0) } static void -- cgit v1.2.3 From cdddf155baf531b9783c8c5a02ec491a9cde3afc Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Thu, 19 May 2011 15:36:51 -0300 Subject: fix rendering of SVG Fonts. Apparently the glyphs were wrongly rendered upside-down since I was trying to make it compatible with fontforge rendering. Now, reading again the SVG spec, it seems to me that it is fontforge that renders it incorrectly. I have also added support for rendering path tags that are children of glyph and missing-glyph nodes. And also use tags. But fontforge does not seem to understand use tags in glyph descriptions... compatibility issues that we have to figure out how to solve. (bzr r10211) --- src/display/nr-svgfonts.cpp | 71 +++++++++++++++++++++++++++++++++------------ src/display/nr-svgfonts.h | 4 +++ 2 files changed, 57 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 62d52b04b..b071ba21b 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -20,6 +20,11 @@ #include "svg/svg.h" #include "inkscape-cairo.h" #include "nr-svgfonts.h" +#include "../sp-path.h" +#include "../sp-object-group.h" +#include "../sp-use.h" +#include "../sp-use-reference.h" +#include "curve.h" //*************************// // UserFont Implementation // @@ -212,6 +217,29 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, return CAIRO_STATUS_SUCCESS; } +void +SvgFont::render_glyph_path(cairo_t* cr, Geom::PathVector* pathv){ + if (!pathv->empty()){ + //This glyph has a path description on its d attribute, so we render it: + cairo_new_path(cr); + + //adjust scale of the glyph +// Geom::Scale s(1.0/((SPFont*) node->parent)->horiz_adv_x); + Geom::Scale s(1.0/1000);//TODO: use here the units-per-em attribute? + + Geom::Rect area( Geom::Point(0,0), Geom::Point(1,1) ); //I need help here! (reaction: note that the 'area' parameter is an *optional* rect, so you can pass an empty Geom::OptRect() ) + + feed_pathvector_to_cairo (cr, *pathv, s, area, false, 0); + cairo_fill(cr); + } +} + +void +SvgFont::glyph_modified(SPObject* /* blah */, unsigned int /* bleh */){ + this->refresh(); + //TODO: update rendering on svgfonts preview widget (in the svg fonts dialog) +} + cairo_status_t SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, unsigned long glyph, @@ -234,37 +262,44 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, node = (SPObject*) 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? + } + //glyphs can be described by arbitrary SVG declared in the childnodes of a glyph node // 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); + 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 { - return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return? + this->render_glyph_path(cr, &pathv); } - if (!pathv.empty()){ - //This glyph has a path description on its d attribute, so we render it: - cairo_new_path(cr); - //adjust scale of the glyph -// Geom::Scale s(1.0/((SPFont*) node->parent)->horiz_adv_x); - Geom::Scale s(1.0/1000);//TODO: use here the units-per-em attribute? - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - //then we offset it -// pathv += Geom::Point(Geom::Coord(0),Geom::Coord(-((SPFont*) node->parent)->horiz_adv_x)); - pathv += Geom::Point(Geom::Coord(0),Geom::Coord(-1000));//TODO: use here the units-per-em attribute? - - Geom::Rect area( Geom::Point(0,0), Geom::Point(1,1) ); //I need help here! (reaction: note that the 'area' parameter is an *optional* rect, so you can pass an empty Geom::OptRect() ) + if (node->hasChildren()){ + //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(); + this->render_glyph_path(cr, &pathv); + } + if (SP_IS_OBJECTGROUP(node)){ + g_warning("TODO: svgfonts: render OBJECTGROUP"); + } + if (SP_IS_USE(node)){ + SPItem* item = SP_USE(node)->ref->getObject(); + if (SP_IS_PATH(item)){ + pathv = ((SPShape*)item)->curve->get_pathvector(); + this->render_glyph_path(cr, &pathv); + } - feed_pathvector_to_cairo (cr, pathv, s*m, area, false, 0); - cairo_fill(cr); + glyph_modified_connection = ((SPObject*) item)->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified)); + } + } } - //TODO: render the SVG described on this glyph's child nodes. return CAIRO_STATUS_SUCCESS; } diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index ddf4ba327..b6eaf449d 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -19,6 +19,7 @@ #include "../sp-missing-glyph.h" #include "../sp-font.h" #include "../sp-glyph-kerning.h" +#include class SvgFont; struct SPFont; @@ -37,12 +38,15 @@ cairo_font_face_t* get_font_face(); cairo_status_t scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *metrics); cairo_status_t scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *flags); cairo_status_t scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics); +void render_glyph_path(cairo_t* cr, Geom::PathVector* pathv); +void glyph_modified(SPObject *, unsigned int); private: SPFont* font; UserFont* userfont; std::vector glyphs; SPMissingGlyph* missingglyph; +sigc::connection glyph_modified_connection; bool drawing_expose_cb (Gtk::Widget *widget, GdkEventExpose *event, gpointer data); }; -- cgit v1.2.3 From 9865291b790f185d7ec2271c58e8653c9d4bb295 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 19 May 2011 22:01:27 -0700 Subject: Reinstating version bump. (bzr r10215) --- src/display/sp-canvas.cpp | 7 +------ src/ege-adjustment-action.cpp | 10 ---------- src/ege-select-one-action.cpp | 3 --- src/ink-comboboxentry-action.cpp | 27 --------------------------- src/ink-comboboxentry-action.h | 2 -- src/inkscape.cpp | 4 ---- src/io/sys.cpp | 4 +--- src/ui/dialog/glyphs.cpp | 20 -------------------- src/ui/dialog/glyphs.h | 2 -- src/widgets/sp-color-slider.cpp | 18 ++++++------------ src/widgets/sp-color-wheel-selector.cpp | 4 ---- 11 files changed, 8 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 2d1e57092..0d450362a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -47,12 +47,9 @@ using Inkscape::Debug::GdkEventLatencyTracker; -// GTK_CHECK_VERSION returns false on failure -#define HAS_GDK_EVENT_REQUEST_MOTIONS GTK_CHECK_VERSION(2, 12, 0) - // gtk_check_version returns non-NULL on failure static bool const HAS_BROKEN_MOTION_HINTS = - true || gtk_check_version(2, 12, 0) != NULL || !HAS_GDK_EVENT_REQUEST_MOTIONS; + true || gtk_check_version(2, 12, 0) != NULL; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -1599,9 +1596,7 @@ sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event) static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_window_get_pointer(w, NULL, NULL, NULL); -#if HAS_GDK_EVENT_REQUEST_MOTIONS gdk_event_request_motions(event); -#endif } /** diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 9c01b4c7c..b8ee66f08 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -47,10 +47,8 @@ #include #include #include -#if GTK_CHECK_VERSION(2,12,0) #include #include -#endif /* GTK_CHECK_VERSION(2,12,0) */ #include #include #include @@ -96,7 +94,6 @@ enum { APPEARANCE_MINIMAL, /* no label, just choices in a drop-down menu */ }; -#if GTK_CHECK_VERSION(2,12,0) /* TODO need to have appropriate icons setup for these: */ static const gchar *floogles[] = { GTK_STOCK_REMOVE, @@ -105,7 +102,6 @@ static const gchar *floogles[] = { GTK_STOCK_ABOUT, GTK_STOCK_GO_UP, 0}; -#endif /* GTK_CHECK_VERSION(2,12,0) */ typedef struct _EgeAdjustmentDescr EgeAdjustmentDescr; @@ -846,12 +842,10 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 ); g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow ); -#if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { spinbutton = gtk_scale_button_new( GTK_ICON_SIZE_MENU, 0, 100, 2, 0 ); gtk_scale_button_set_adjustment( GTK_SCALE_BUTTON(spinbutton), act->private_data->adj ); gtk_scale_button_set_icons( GTK_SCALE_BUTTON(spinbutton), floogles ); -#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { if ( gFactoryCb ) { spinbutton = gFactoryCb( act->private_data->adj, act->private_data->climbRate, act->private_data->digits ); @@ -913,10 +907,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_signal_connect_swapped( G_OBJECT(spinbutton), "event", G_CALLBACK(event_cb), action ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { /* */ -#if GTK_CHECK_VERSION(2,12,0) } else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) { /* */ -#endif /* GTK_CHECK_VERSION(2,12,0) */ } else { gtk_entry_set_width_chars( GTK_ENTRY(spinbutton), act->private_data->digits + 3 ); } @@ -962,10 +954,8 @@ gboolean focus_in_cb( GtkWidget *widget, GdkEventKey *event, gpointer data ) EgeAdjustmentAction* action = EGE_ADJUSTMENT_ACTION( data ); if ( GTK_IS_SPIN_BUTTON(widget) ) { action->private_data->lastVal = gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); -#if GTK_CHECK_VERSION(2,12,0) } else if ( GTK_IS_SCALE_BUTTON(widget) ) { action->private_data->lastVal = gtk_scale_button_get_value( GTK_SCALE_BUTTON(widget) ); -#endif /* GTK_CHECK_VERSION(2,12,0) */ } else if (GTK_IS_RANGE(widget) ) { action->private_data->lastVal = gtk_range_get_value( GTK_RANGE(widget) ); } diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 83a083425..1c3ec1ff5 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -935,7 +935,6 @@ void resync_sensitive( EgeSelectOneAction* act ) GSList* group = (GSList*)data; // List is backwards in group as compared to GtkTreeModel, we better do matching. while ( group ) { -#if GTK_CHECK_VERSION(2,16,0) GtkRadioAction* ract = GTK_RADIO_ACTION(group->data); const gchar* label = gtk_action_get_label( GTK_ACTION( ract ) ); @@ -964,8 +963,6 @@ void resync_sensitive( EgeSelectOneAction* act ) } gtk_action_set_sensitive( GTK_ACTION(ract), sens ); -#endif - group = g_slist_next(group); } } diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 74034e537..eaaf62113 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -266,9 +266,7 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) action->active = -1; action->text = NULL; action->entry_completion = NULL; -#if !GTK_CHECK_VERSION(2,16,0) action->indicator = NULL; -#endif action->popup = false; action->warning = NULL; action->altx_name = NULL; @@ -348,15 +346,7 @@ GtkWidget* create_tool_item( GtkAction* action ) { GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); -#if GTK_CHECK_VERSION(2,16,0) gtk_container_add( GTK_CONTAINER(align), comboBoxEntry ); -#else // GTK_CHECK_VERSION(2,16,0) - GtkWidget *hbox = gtk_hbox_new( FALSE, 0 ); - ink_comboboxentry_action->indicator = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_box_pack_start( GTK_BOX(hbox), comboBoxEntry, TRUE, TRUE, 0 ); - gtk_box_pack_start( GTK_BOX(hbox), ink_comboboxentry_action->indicator, FALSE, FALSE, 0 ); - gtk_container_add( GTK_CONTAINER(align), hbox ); -#endif // GTK_CHECK_VERSION(2,16,0) gtk_container_add( GTK_CONTAINER(item), align ); } @@ -415,10 +405,7 @@ GtkWidget* create_tool_item( GtkAction* action ) } -#if GTK_CHECK_VERSION(2,16,0) gtk_action_connect_proxy( GTK_ACTION( action ), item ); -#endif - gtk_widget_show_all( item ); } else { @@ -480,7 +467,6 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink // Show or hide warning if( ink_comboboxentry_action->active == -1 && ink_comboboxentry_action->warning != NULL ) { -#if GTK_CHECK_VERSION(2,16,0) { GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); @@ -498,22 +484,13 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, GTK_ENTRY_ICON_SECONDARY, ink_comboboxentry_action->warning ); -#else // GTK_CHECK_VERSION(2,16,0) - gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, ink_comboboxentry_action->warning ); -#endif // GTK_CHECK_VERSION(2,16,0) } else { -#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); gtk_entry_set_icon_from_stock( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); -#else // GTK_CHECK_VERSION(2,16,0) - gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), NULL, GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, NULL ); -#endif // GTK_CHECK_VERSION(2,16,0) } } @@ -585,13 +562,9 @@ void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, // Widget may not have been created.... if( action->entry ) { -#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_tooltip_text( GTK_ENTRY(action->entry), GTK_ENTRY_ICON_SECONDARY, action->warning ); -#else // GTK_CHECK_VERSION(2,16,0) - gtk_image_set_from_stock( GTK_IMAGE(action->indicator), action->warning ? GTK_STOCK_DIALOG_WARNING : 0, GTK_ICON_SIZE_SMALL_TOOLBAR ); -#endif // GTK_CHECK_VERSION(2,16,0) } } diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index e080e6cdf..1a83cb053 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -49,9 +49,7 @@ struct _Ink_ComboBoxEntry_Action { GtkComboBoxEntry *combobox; GtkEntry *entry; GtkEntryCompletion *entry_completion; -#if !GTK_CHECK_VERSION(2,16,0) GtkWidget *indicator; -#endif gpointer cell_data_func; // drop-down menu format diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 91e3b0c5f..1b0893c0b 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -442,11 +442,7 @@ void inkscape_autosave_init() // Turn on autosave guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60; // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10)); -#if GLIB_CHECK_VERSION(2,14,0) autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL); -#else - autosave_timeout_id = g_timeout_add(timeout * 1000, inkscape_autosave, NULL); -#endif } } diff --git a/src/io/sys.cpp b/src/io/sys.cpp index a68d02707..e6c512be2 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -19,9 +19,7 @@ #include #include #include -#if GLIB_CHECK_VERSION(2,6,0) - #include -#endif +#include #include #include diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index f3d7ed971..8eef5d89b 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -48,7 +48,6 @@ GlyphsPanel &GlyphsPanel::getInstance() } -#if GLIB_CHECK_VERSION(2,14,0) static std::map & getScriptToName() { static bool init = false; @@ -123,8 +122,6 @@ static std::map & getScriptToName() mappings[G_UNICODE_SCRIPT_PHOENICIAN] = _("Phoenician"); mappings[G_UNICODE_SCRIPT_PHAGS_PA] = _("Phags-pa"); mappings[G_UNICODE_SCRIPT_NKO] = _("N'Ko"); - -#if GLIB_CHECK_VERSION(2,14,0) mappings[G_UNICODE_SCRIPT_KAYAH_LI] = _("Kayah Li"); mappings[G_UNICODE_SCRIPT_LEPCHA] = _("Lepcha"); mappings[G_UNICODE_SCRIPT_REJANG] = _("Rejang"); @@ -136,11 +133,9 @@ static std::map & getScriptToName() mappings[G_UNICODE_SCRIPT_CARIAN] = _("Carian"); mappings[G_UNICODE_SCRIPT_LYCIAN] = _("Lycian"); mappings[G_UNICODE_SCRIPT_LYDIAN] = _("Lydian"); -#endif // GLIB_CHECK_VERSION(2,14,0) } return mappings; } -#endif // GLIB_CHECK_VERSION(2,14,0) typedef std::pair Range; typedef std::pair NamedRange; @@ -337,9 +332,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : entry(0), label(0), insertBtn(0), -#if GLIB_CHECK_VERSION(2,14,0) scriptCombo(0), -#endif // GLIB_CHECK_VERSION(2,14,0) fsel(0), targetDesktop(0), deskTrack(), @@ -366,7 +359,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- -#if GLIB_CHECK_VERSION(2,14,0) { Gtk::Label *label = new Gtk::Label(_("Script: ")); table->attach( *Gtk::manage(label), @@ -391,7 +383,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : } row++; -#endif // GLIB_CHECK_VERSION(2,14,0) // ------------------------------- @@ -464,10 +455,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : insertBtn = new Gtk::Button(_("Append")); conn = insertBtn->signal_clicked().connect(sigc::mem_fun(*this, &GlyphsPanel::insertText)); instanceConns.push_back(conn); -#if GTK_CHECK_VERSION(2,18,0) - //gtkmm 2.18 insertBtn->set_can_default(); -#endif insertBtn->set_sensitive(false); box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); @@ -607,13 +595,11 @@ void GlyphsPanel::glyphSelectionChanged() Glib::ustring scriptName; -#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = g_unichar_get_script(ch); std::map mappings = getScriptToName(); if (mappings.find(script) != mappings.end()) { scriptName = mappings[script]; } -#endif gchar * tmp = g_strdup_printf("U+%04X %s", ch, scriptName.c_str()); label->set_text(tmp); } @@ -680,7 +666,6 @@ void GlyphsPanel::rebuild() if (font) { //double sp_font_selector_get_size (SPFontSelector *fsel); -#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; Glib::ustring scriptName = scriptCombo->get_active_text(); std::map items = getScriptToName(); @@ -690,7 +675,6 @@ void GlyphsPanel::rebuild() break; } } -#endif // GLIB_CHECK_VERSION(2,14,0) // Disconnect the model while we update it. Simple work-around for 5x+ performance boost. Glib::RefPtr tmp = Gtk::ListStore::create(*getColumns()); @@ -707,13 +691,9 @@ void GlyphsPanel::rebuild() for (gunichar ch = lower; ch <= upper; ch++) { int glyphId = font->MapUnicodeChar(ch); if (glyphId > 0) { -#if GLIB_CHECK_VERSION(2,14,0) if ((script == G_UNICODE_SCRIPT_INVALID_CODE) || (script == g_unichar_get_script(ch))) { present.push_back(ch); } -#else - present.push_back(ch); -#endif } } diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index d6c731dda..1440a693f 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -77,9 +77,7 @@ private: Gtk::Entry *entry; Gtk::Label *label; Gtk::Button *insertBtn; -#if GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *scriptCombo; -#endif //GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *rangeCombo; SPFontSelector *fsel; SPDesktop *targetDesktop; diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 0e30b1ce6..0690caaab 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -1,5 +1,3 @@ -#define __SP_COLOR_SLIDER_C__ - /* * A slider with colored background * @@ -329,21 +327,17 @@ sp_color_slider_new (GtkAdjustment *adjustment) return GTK_WIDGET (slider); } -void -sp_color_slider_set_adjustment (SPColorSlider *slider, GtkAdjustment *adjustment) +void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjustment) { - g_return_if_fail (slider != NULL); - g_return_if_fail (SP_IS_COLOR_SLIDER (slider)); + g_return_if_fail (slider != NULL); + g_return_if_fail (SP_IS_COLOR_SLIDER (slider)); - if (!adjustment) { - adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0); - } -#if GTK_CHECK_VERSION (2,14,0) - else { + if (!adjustment) { + adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0); + } else { gtk_adjustment_set_page_increment(adjustment, 0.0); gtk_adjustment_set_page_size(adjustment, 0.0); } -#endif if (slider->adjustment != adjustment) { if (slider->adjustment) { diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 2e36a024e..784dd23ad 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -135,14 +135,12 @@ static void resizeHSVWheel( GtkHSV *hsv, GtkAllocation *allocation ) gtk_hsv_set_metrics( hsv, diam, ring ); } -#if GTK_CHECK_VERSION(2,18,0) static void handleWheelStyleSet(GtkHSV *hsv, GtkStyle* /*previous*/, gpointer /*userData*/) { GtkAllocation allocation = {0, 0, 0, 0}; gtk_widget_get_allocation( GTK_WIDGET(hsv), &allocation ); resizeHSVWheel( hsv, &allocation ); } -#endif // GTK_CHECK_VERSION(2,18,0) static void handleWheelAllocation(GtkHSV *hsv, GtkAllocation *allocation, gpointer /*userData*/) { @@ -220,10 +218,8 @@ void ColorWheelSelector::init() // GTK does not automatically scale the color wheel, so we have to add that in: gtk_signal_connect( GTK_OBJECT(_wheel), "size-allocate", GTK_SIGNAL_FUNC(handleWheelAllocation), _csel ); -#if GTK_CHECK_VERSION(2,18,0) gtk_signal_connect( GTK_OBJECT(_wheel), "style-set", GTK_SIGNAL_FUNC(handleWheelStyleSet), _csel ); -#endif // GTK_CHECK_VERSION(2,18,0) } static void -- cgit v1.2.3 From d0d22ef1d26069adc5dcf4e2ce9e25d0d4331958 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Fri, 20 May 2011 17:06:41 -0300 Subject: Remove flipping of y-axis from methods that get curves from selection in the svg fonts dialog. This flipping of y-axis seems to be a fontforge bug. (bzr r10216) --- src/ui/dialog/svg-fonts-dialog.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 667d01de7..6bcd5d898 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -500,12 +500,6 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - pathv*=m; - //then we offset it - pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x)); - SPGlyph* glyph = get_selected_glyph(); if (!glyph){ char *msg = _("No glyph selected in the SVGFonts dialog."); @@ -545,13 +539,6 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - pathv*=m; - //then we offset it -// pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x)); - pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(1000));//TODO: use here the units-per-em attribute? - SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ -- cgit v1.2.3 From 3adbef99b318bd361c429b470a5f38cf21e8000a Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Sun, 22 May 2011 18:11:19 -0300 Subject: actually fontforge flipping of y-axis for svgfont glyphs is compliant with the svg spec. So we need to do it also. (bzr r10218) --- src/display/nr-svgfonts.cpp | 30 ++++++++++++++++++++++++++++++ src/display/nr-svgfonts.h | 2 ++ src/ui/dialog/svg-fonts-dialog.cpp | 28 +++++++++++++++++++++++----- src/ui/dialog/svg-fonts-dialog.h | 2 ++ 4 files changed, 57 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index b071ba21b..cf23ee5d5 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -25,6 +25,9 @@ #include "../sp-use.h" #include "../sp-use-reference.h" #include "curve.h" +#include "xml/repr.h" +#include "sp-font-face.h" + //*************************// // UserFont Implementation // @@ -240,6 +243,24 @@ SvgFont::glyph_modified(SPObject* /* blah */, unsigned int /* bleh */){ //TODO: update rendering on svgfonts preview widget (in the svg fonts dialog) } +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){ + 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); + } + } + + double baseline_offset = units_per_em - spfont->horiz_origin_y; + + //This matrix flips y-axis and places the origin at baseline + Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset)); + return pathv*m; +} + cairo_status_t SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, unsigned long glyph, @@ -266,15 +287,22 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return? } + SPFont* spfont = (SPFont*) node->parent; + if (!spfont) { + return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return? + } + //glyphs can be described by arbitrary SVG declared in the childnodes of a glyph node // 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); + 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); + pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); } @@ -283,6 +311,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, for(node = node->children; node; node=node->next){ if (SP_IS_PATH(node)){ pathv = ((SPShape*)node)->curve->get_pathvector(); + pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); } if (SP_IS_OBJECTGROUP(node)){ @@ -292,6 +321,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, SPItem* item = SP_USE(node)->ref->getObject(); if (SP_IS_PATH(item)){ pathv = ((SPShape*)item)->curve->get_pathvector(); + pathv = flip_coordinate_system(spfont, pathv); this->render_glyph_path(cr, &pathv); } diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index b6eaf449d..3cfcbaa72 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -38,6 +38,8 @@ cairo_font_face_t* get_font_face(); cairo_status_t scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *metrics); cairo_status_t scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *flags); cairo_status_t scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics); + +Geom::PathVector flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv); void render_glyph_path(cairo_t* cr, Geom::PathVector* pathv); void glyph_modified(SPObject *, unsigned int); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 6bcd5d898..4d53154d8 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -16,7 +16,6 @@ #ifdef ENABLE_SVG_FONTS -#include <2geom/pathvector.h> #include "document-private.h" #include #include @@ -474,6 +473,24 @@ void SvgFontsDialog::add_glyph(){ update_glyphs(); } +Geom::PathVector +SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ + double units_per_em = 1000; + SPObject* obj; + for (obj = get_selected_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); + } + } + + double baseline_offset = units_per_em - get_selected_spfont()->horiz_origin_y; + + //This matrix flips y-axis and places the origin at baseline + Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset)); + return pathv*m; +} + void SvgFontsDialog::set_glyph_description_from_selected_path(){ SPDesktop* desktop = this->getDesktop(); if (!desktop) { @@ -498,16 +515,17 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } //TODO: //Is there a better way to tell it to to the user? - Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - SPGlyph* glyph = get_selected_glyph(); if (!glyph){ char *msg = _("No glyph selected in the SVGFonts dialog."); msgStack->flash(Inkscape::ERROR_MESSAGE, msg); return; } + + Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); + //XML Tree being directly used here while it shouldn't be. - glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); @@ -544,7 +562,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ if (SP_IS_MISSING_GLYPH(obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 50821cc6c..8c2bdc1a4 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -11,6 +11,7 @@ #ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H #define INKSCAPE_UI_DIALOG_SVG_FONTS_H +#include <2geom/pathvector.h> #include "ui/widget/panel.h" #include "ui/widget/spinbutton.h" #include "sp-font.h" @@ -78,6 +79,7 @@ public: void on_kerning_value_changed(); void on_setwidth_changed(); void add_font(); + Geom::PathVector flip_coordinate_system(Geom::PathVector pathv); //TODO: AttrEntry is currently unused. Should we remove it? class AttrEntry : public Gtk::HBox -- cgit v1.2.3 From bea49afe6164373f27a08c947087bc25c783b5b4 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Sun, 22 May 2011 22:21:27 -0300 Subject: Fixing bug 600267: "Languages are not sorted alphabetically in Inkscape preferences" https://bugs.launchpad.net/inkscape/+bug/600267 Patch submitted by Fernando Lucchesi Bastos Jurema Applied with minor changes to use Glib::ustring instead of Glib::ustring* (bzr r10219) --- src/ui/dialog/inkscape-preferences.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 81bd4dba0..28c59c321 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1124,6 +1124,31 @@ void InkscapePreferences::initPageUI() "gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "mk", "mn", "ne", "nb", "nn", "pa", "pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te_IN", "th", "tr", "uk", "vi" }; + { + // sorting languages according to translated name + int i = 0; + int j = 0; + int n = sizeof( languages ) / sizeof( Glib::ustring ); + Glib::ustring key_language; + Glib::ustring key_langValue; + for ( j = 1 ; j < n ; j++ ) { + key_language = languages[j]; + key_langValue = langValues[j]; + i = j-1; + while ( i >= 0 + && ( ( languages[i] > key_language + && langValues[i] != "" ) + || key_langValue == "" ) ) + { + languages[i+1] = languages[i]; + langValues[i+1] = langValues[i]; + i--; + } + languages[i+1] = key_language; + langValues[i+1] = key_langValue; + } + } + _ui_languages.init( "/ui/language", languages, langValues, G_N_ELEMENTS(languages), languages[0]); _page_ui.add_line( false, _("Language (requires restart):"), _ui_languages, "", _("Set the language for menus and number formats"), false); -- cgit v1.2.3 From e221cd716d74e63d1f27ddedd598f23b0fce611d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 26 May 2011 22:04:59 +0200 Subject: unitmenu: add method to add a unit (bzr r10232) --- src/ui/widget/unit-menu.cpp | 8 ++++++++ src/ui/widget/unit-menu.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 5c68f7196..362f5d90f 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -67,6 +67,14 @@ UnitMenu::resetUnitType(UnitType unit_type) return setUnitType(unit_type); } +/** Adds a unit, possibly user-defined, to the menu. */ +void +UnitMenu::addUnit(Unit const& u) +{ + _unit_table.addUnit(u, false); + append_text(u.abbr); +} + /** Returns the Unit object corresponding to the current selection in the dropdown widget */ Unit diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index efeb10ead..cf42231ba 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -29,6 +29,7 @@ public: bool setUnitType(UnitType unit_type); bool resetUnitType(UnitType unit_type); + void addUnit(Unit const& u); bool setUnit(Glib::ustring const &unit); -- cgit v1.2.3 From d08f8e9ed468767cc64766eb80ea134bb5edb197 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 26 May 2011 23:17:37 +0200 Subject: add entry widget to guideline dialog to change guide's label (and fix some label xml writing and rendering bugs) (bzr r10234) --- src/display/guideline.cpp | 11 ++++++++--- src/display/guideline.h | 2 +- src/sp-guide.cpp | 4 ++-- src/sp-guide.h | 2 +- src/ui/dialog/guides.cpp | 14 ++++++++++++-- src/ui/dialog/guides.h | 2 ++ 6 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index f0e1c7724..dddf1f30e 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -21,6 +21,7 @@ #include "guideline.h" #include "cairo.h" #include "inkscape-cairo.h" +#include "color.h" static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); @@ -112,7 +113,8 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) cairo_t* ctx = nr_create_cairo_context_canvasbuf (NULL /*area*/, buf); //this function ignores the "area" parameter cairo_set_font_size (ctx, 10); cairo_set_line_width (ctx, 10); - cairo_set_source_rgb (ctx, 0, 0, 0); + /// @todo uh??! why must the order of these arguments be reversed? bgra instead of rgba! + cairo_set_source_rgba (ctx, SP_RGBA32_B_F(gl->rgba), SP_RGBA32_G_F(gl->rgba), SP_RGBA32_R_F(gl->rgba), SP_RGBA32_A_F(gl->rgba)); unsigned int const r = NR_RGBA32_R (gl->rgba); unsigned int const g = NR_RGBA32_G (gl->rgba); @@ -274,9 +276,12 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point p return item; } -void sp_guideline_set_label(SPGuideLine *gl, char* label) +void sp_guideline_set_label(SPGuideLine *gl, const char* label) { - gl->label = label; + if (gl->label) { + g_free(gl->label); + } + gl->label = g_strdup(label); sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); } diff --git a/src/display/guideline.h b/src/display/guideline.h index dbf990d1f..dfc3b7007 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -48,7 +48,7 @@ GType sp_guideline_get_type(); SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point point_on_line, Geom::Point normal); -void sp_guideline_set_label(SPGuideLine *gl, char* label); +void sp_guideline_set_label(SPGuideLine *gl, const char* label); void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line); void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line); void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba); diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 1e51ee4d5..584a6a366 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -412,7 +412,7 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool */ } -void sp_guide_set_label(SPGuide &guide, char* label, bool const commit) +void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit) { g_assert(SP_IS_GUIDE(&guide)); if (guide.views){ @@ -421,7 +421,7 @@ void sp_guide_set_label(SPGuide &guide, char* label, bool const commit) if (commit){ //XML Tree being used directly while it shouldn't be - guide.getRepr()->setAttribute("label", label); + guide.getRepr()->setAttribute("inkscape:label", label); } } diff --git a/src/sp-guide.h b/src/sp-guide.h index 1dcdbc662..a164fda84 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -63,7 +63,7 @@ void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); -void sp_guide_set_label(SPGuide &guide, char* const label, bool const commit); +void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit); void sp_guide_remove(SPGuide *guide); char *sp_guide_description(SPGuide const *guide, const bool verbose = true); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 60038cab0..12aeddecc 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -42,6 +42,7 @@ GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop * _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), _spin_button_x(_("X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), _spin_button_y(_("Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _label_entry(_("Label:"), _("Optionally give this guideline a name")), _spin_angle(_("Angle:"), "", UNIT_TYPE_RADIAL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) { @@ -104,6 +105,9 @@ void GuidelinePropertiesDialog::_onApply() sp_guide_moveto(*_guide, newpos, true); + const gchar* name = _label_entry.getEntry()->get_text().c_str(); + sp_guide_set_label(*_guide, name, true); + DocumentUndo::done(_guide->document, SP_VERB_NONE, _("Set guide properties")); } @@ -167,8 +171,11 @@ void GuidelinePropertiesDialog::_setup() { _label_descr.set_alignment(0, 0.5); // indent - _layout_table.attach(*manage(new Gtk::Label(" ")), - 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); +// _layout_table.attach(*manage(new Gtk::Label(" ")), +// 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); + + _layout_table.attach(_label_entry, + 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ @@ -245,6 +252,9 @@ void GuidelinePropertiesDialog::_setup() { g_free(label); } + // init name entry + _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + _modeChanged(); // sets values of spinboxes. if ( _oldangle == 90. || _oldangle == 270. || _oldangle == -90. || _oldangle == -270.) { diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index f015c49ff..efef0142b 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -24,6 +24,7 @@ #include "ui/widget/spinbutton.h" #include "ui/widget/unit-menu.h" #include "ui/widget/scalar-unit.h" +#include "ui/widget/entry.h" #include <2geom/point.h> class SPGuide; @@ -71,6 +72,7 @@ private: Inkscape::UI::Widget::UnitMenu _unit_menu; Inkscape::UI::Widget::ScalarUnit _spin_button_x; Inkscape::UI::Widget::ScalarUnit _spin_button_y; + Inkscape::UI::Widget::Entry _label_entry; Inkscape::UI::Widget::ScalarUnit _spin_angle; static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances -- cgit v1.2.3 From 8dffb2e7a2725a77d3af74bc984e48ac940f2679 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 26 May 2011 20:28:44 -0700 Subject: Applying patch from Gellule Xg to fix crash on 64-bit. Fixed bugs: - https://launchpad.net/bugs/629363 (bzr r10237) --- src/inkscape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1b0893c0b..b794138ca 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -190,7 +190,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, modify_selection), NULL, NULL, - g_cclosure_marshal_VOID__UINT_POINTER, + gtk_marshal_VOID__POINTER_UINT, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT); inkscape_signals[CHANGE_SELECTION] = g_signal_new ("change_selection", -- cgit v1.2.3 From 3d6053d862638f21a5028cbf9f6eb77c9b4bc791 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Fri, 27 May 2011 20:37:38 -0300 Subject: Add "silent" option to extension inx file so that extension authors can opt-out of displaying the "working, please wait" dialog. Extensions that are tipically slow can still have the dialog show up by simply not adding this attribute to the inx file. (bzr r10240) --- src/extension/execution-env.cpp | 5 ++++- src/extension/extension.cpp | 14 ++++++++++++++ src/extension/extension.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index f9e099c26..a2550024a 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -141,7 +141,10 @@ ExecutionEnv::createWorkingDialog (void) { true); // modal _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::workingCanceled)); g_free(dlgmessage); - _visibleDialog->show(); + + if (!_effect->is_silent()){ + _visibleDialog->show(); + } return; } diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index e67a4b95f..a70c79943 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -59,6 +59,7 @@ Parameter * get_param (const gchar * name); */ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : _help(NULL) + , silent(false) , _gui(true) { repr = in_repr; @@ -105,6 +106,9 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat if (!strcmp(chname, "dependency")) { _deps.push_back(new Dependency(child_repr)); } /* dependency */ + if (!strcmp(chname, "options")) { + silent = !strcmp( child_repr->attribute("silent"), "true" ); + } child_repr = sp_repr_next(child_repr); } @@ -309,6 +313,16 @@ Extension::get_repr (void) return repr; } +/** + \return bool + \brief Whether this extension should hide the "working, please wait" dialog +*/ +bool +Extension::is_silent (void) +{ + return silent; +} + /** \return The textual id of this extension \brief Get the ID of this extension - not a copy don't delete! diff --git a/src/extension/extension.h b/src/extension/extension.h index 936d2a907..dba8eeb45 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -99,6 +99,7 @@ private: state_t _state; /**< Which state the Extension is currently in */ std::vector _deps; /**< Dependencies for this extension */ static std::ofstream error_file; /**< This is the place where errors get reported */ + bool silent; bool _gui; protected: @@ -120,6 +121,7 @@ public: gchar * get_name (void); /** \brief Gets the help string for this extension */ gchar const * get_help (void) { return _help; } + bool is_silent (void); void deactivate (void); bool deactivated (void); void printFailure (Glib::ustring reason); -- cgit v1.2.3 From aabb5bb05a97e7414fd6f0204178788800871151 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 28 May 2011 03:36:31 -0700 Subject: Port of 0.48.x branch revision 9781. Cleanup of legacy code and casting that was breaking 64-bit gradient use. Fixes bug #743530 and bug #778441. Fixed bugs: - https://launchpad.net/bugs/743530 - https://launchpad.net/bugs/778441 (bzr r10242) --- src/Makefile_insert | 1 + src/display/nr-arena-glyphs.cpp | 1 + src/display/nr-arena-glyphs.h | 2 +- src/display/nr-arena.cpp | 1 + src/display/nr-arena.h | 3 ++- src/forward.h | 3 --- src/id-clash.cpp | 1 + src/sp-gradient.cpp | 10 +++++----- src/sp-object.cpp | 1 + src/sp-paint-server-reference.h | 43 +++++++++++++++++++++++++++++++++++++++++ src/sp-paint-server.cpp | 23 +++++++++++++++++----- src/sp-paint-server.h | 23 ++++------------------ src/sp-pattern.cpp | 13 +++++-------- src/style.h | 2 +- 14 files changed, 84 insertions(+), 43 deletions(-) create mode 100644 src/sp-paint-server-reference.h (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index 3a3862437..e7bf9715a 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -200,6 +200,7 @@ ink_common_sources += \ sp-object-repr.cpp sp-object-repr.h \ sp-offset.cpp sp-offset.h \ sp-paint-server.cpp sp-paint-server.h \ + sp-paint-server-reference.h \ sp-path.cpp sp-path.h \ sp-pattern.cpp sp-pattern.h \ sp-polygon.cpp sp-polygon.h \ diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 42bca7d94..a67812d8f 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -25,6 +25,7 @@ #include #include "inkscape-cairo.h" #include "display/grayscale.h" +#include "sp-paint-server.h" #ifdef test_glyph_liv #include "../display/canvas-bpath.h" diff --git a/src/display/nr-arena-glyphs.h b/src/display/nr-arena-glyphs.h index d04fdb4dc..b56a9f56c 100644 --- a/src/display/nr-arena-glyphs.h +++ b/src/display/nr-arena-glyphs.h @@ -20,13 +20,13 @@ #include "libnrtype/nrtype-forward.h" #include "forward.h" -#include "sp-paint-server.h" #include "display/nr-arena-item.h" #define test_glyph_liv struct SPCurve; class Shape; +class SPPainter; NRType nr_arena_glyphs_get_type (void); diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index 837bc0d86..147269727 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -17,6 +17,7 @@ #include "nr-filter-gaussian.h" #include "nr-filter-types.h" #include +#include "sp-paint-server.h" #include "preferences.h" #include "color.h" diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index bd6c3029d..402bc198f 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -30,7 +30,8 @@ G_END_DECLS #include #include #include "nr-arena-forward.h" -#include "sp-paint-server.h" + +class SPPainter; NRType nr_arena_get_type (void); diff --git a/src/forward.h b/src/forward.h index 97d2c15ed..897f3fe48 100644 --- a/src/forward.h +++ b/src/forward.h @@ -101,9 +101,6 @@ class SPTSpanClass; class SPString; class SPStringClass; -class SPPaintServer; -class SPPaintServerClass; - class SPStop; class SPStopClass; diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 67e27e2f0..d305b5a9f 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -22,6 +22,7 @@ #include "id-clash.h" #include "sp-object.h" #include "style.h" +#include "sp-paint-server.h" #include "xml/node.h" #include "xml/repr.h" diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 830e12f53..82d62547a 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -360,7 +360,7 @@ void SPGradientImpl::classInit(SPGradientClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - gradient_parent_class = (SPPaintServerClass *)g_type_class_ref(SP_TYPE_PAINT_SERVER); + gradient_parent_class = SP_PAINT_SERVER_CLASS( g_type_class_ref(SP_TYPE_PAINT_SERVER) ); sp_object_class->build = SPGradientImpl::build; sp_object_class->release = SPGradientImpl::release; @@ -1520,7 +1520,7 @@ sp_lineargradient_get_type() static void sp_lineargradient_class_init(SPLinearGradientClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - SPPaintServerClass *ps_class = (SPPaintServerClass *) klass; + SPPaintServerClass *ps_class = SP_PAINT_SERVER_CLASS( klass ); lg_parent_class = (SPGradientClass*)g_type_class_ref(SP_TYPE_GRADIENT); @@ -1648,7 +1648,7 @@ SPPainter * SPLGPainter::painter_new(SPPaintServer *ps, SPLGPainter *lgp = g_new(SPLGPainter, 1); - lgp->painter.type = SP_PAINTER_IND; + lgp->painter.server_type = G_OBJECT_TYPE(ps); lgp->painter.fill = sp_lg_fill; lgp->lg = lg; @@ -1801,7 +1801,7 @@ sp_radialgradient_get_type() static void sp_radialgradient_class_init(SPRadialGradientClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - SPPaintServerClass *ps_class = (SPPaintServerClass *) klass; + SPPaintServerClass *ps_class = SP_PAINT_SERVER_CLASS( klass ); rg_parent_class = (SPGradientClass*)g_type_class_ref(SP_TYPE_GRADIENT); @@ -1937,7 +1937,7 @@ SPPainter *SPRGPainter::painter_new(SPPaintServer *ps, SPRGPainter *rgp = g_new(SPRGPainter, 1); - rgp->painter.type = SP_PAINTER_IND; + rgp->painter.server_type = G_OBJECT_TYPE(ps); rgp->painter.fill = sp_rg_fill; rgp->rg = rg; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 17def7f15..c37e48983 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -43,6 +43,7 @@ #include "document.h" #include "style.h" #include "sp-object-repr.h" +#include "sp-paint-server.h" #include "sp-root.h" #include "sp-style-elem.h" #include "sp-script.h" diff --git a/src/sp-paint-server-reference.h b/src/sp-paint-server-reference.h new file mode 100644 index 000000000..90d8979f8 --- /dev/null +++ b/src/sp-paint-server-reference.h @@ -0,0 +1,43 @@ +#ifndef SEEN_SP_PAINT_SERVER_REFERENCE_H +#define SEEN_SP_PAINT_SERVER_REFERENCE_H + +/* + * Reference class for gradients and patterns. + * + * Author: + * Lauris Kaplinski + * Jon A. Cruz + * + * Copyright (C) 1999-2002 Lauris Kaplinski + * Copyright (C) 2000-2001 Ximian, Inc. + * Copyright (C) 2010 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-object.h" +#include "uri-references.h" + +struct SPPaintServer; + +class SPPaintServerReference : public Inkscape::URIReference { +public: + SPPaintServerReference (SPObject *obj) : URIReference(obj) {} + SPPaintServerReference (SPDocument *doc) : URIReference(doc) {} + SPPaintServer *getObject() const; + +protected: + virtual bool _acceptObject(SPObject *obj) const; +}; + +#endif // SEEN_SP_PAINT_SERVER_REFERENCE_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index b672e4480..18b1eea7d 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -15,6 +15,7 @@ #include #include "libnr/nr-pixblock-pattern.h" +#include "sp-paint-server-reference.h" #include "sp-paint-server.h" #include "sp-gradient.h" @@ -29,6 +30,17 @@ static void sp_painter_stale_fill(SPPainter *painter, NRPixBlock *pb); static SPObjectClass *parent_class; static GSList *stale_painters = NULL; + +SPPaintServer *SPPaintServerReference::getObject() const +{ + return static_cast(URIReference::getObject()); +} + +bool SPPaintServerReference::_acceptObject(SPObject *obj) const +{ + return SP_IS_PAINT_SERVER(obj); +} + GType SPPaintServer::getType(void) { static GType type = 0; @@ -91,7 +103,7 @@ SPPainter *sp_paint_server_painter_new(SPPaintServer *ps, g_return_val_if_fail(bbox != NULL, NULL); SPPainter *painter = NULL; - SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps); + SPPaintServerClass *psc = SP_PAINT_SERVER_CLASS( G_OBJECT_GET_CLASS(ps) ); if ( psc->painter_new ) { painter = (*psc->painter_new)(ps, full_transform, parent_transform, bbox); } @@ -99,7 +111,7 @@ SPPainter *sp_paint_server_painter_new(SPPaintServer *ps, if (painter) { painter->next = ps->painters; painter->server = ps; - painter->type = (SPPainterType) G_OBJECT_TYPE(ps); + painter->server_type = G_OBJECT_TYPE(ps); ps->painters = painter; } @@ -112,7 +124,7 @@ static void sp_paint_server_painter_free(SPPaintServer *ps, SPPainter *painter) g_return_if_fail(SP_IS_PAINT_SERVER(ps)); g_return_if_fail(painter != NULL); - SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps); + SPPaintServerClass *psc = SP_PAINT_SERVER_CLASS( G_OBJECT_GET_CLASS(ps) ); SPPainter *r = NULL; for (SPPainter *p = ps->painters; p != NULL; p = p->next) { @@ -141,9 +153,10 @@ SPPainter *sp_painter_free(SPPainter *painter) if (painter->server) { sp_paint_server_painter_free(painter->server, painter); } else { - SPPaintServerClass *psc = (SPPaintServerClass *) g_type_class_ref(painter->type); - if (psc->painter_free) + SPPaintServerClass *psc = SP_PAINT_SERVER_CLASS( g_type_class_ref(painter->server_type) ); + if (psc->painter_free) { (*psc->painter_free)(NULL, painter); + } stale_painters = g_slist_remove(stale_painters, painter); } diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index 05f5b7bad..c77aad694 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -19,7 +19,8 @@ #include "sp-object.h" #include "uri-references.h" -class SPPainter; +struct SPPainter; +struct SPPaintServer; #define SP_TYPE_PAINT_SERVER (SPPaintServer::getType()) #define SP_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PAINT_SERVER, SPPaintServer)) @@ -27,19 +28,15 @@ class SPPainter; #define SP_IS_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_PAINT_SERVER)) #define SP_IS_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_PAINT_SERVER)) -typedef enum { - SP_PAINTER_IND, - SP_PAINTER_DEP -} SPPainterType; - typedef void (* SPPainterFillFunc) (SPPainter *painter, NRPixBlock *pb); + /* fixme: I do not like that class thingie (Lauris) */ struct SPPainter { SPPainter *next; SPPaintServer *server; GType server_type; - SPPainterType type; +// SPPainterType type; SPPainterFillFunc fill; }; @@ -72,18 +69,6 @@ SPPainter *sp_paint_server_painter_new (SPPaintServer *ps, Geom::Affine const &f SPPainter *sp_painter_free (SPPainter *painter); -class SPPaintServerReference : public Inkscape::URIReference { -public: - SPPaintServerReference (SPObject *obj) : URIReference(obj) {} - SPPaintServerReference (SPDocument *doc) : URIReference(doc) {} - SPPaintServer *getObject() const { - return static_cast(URIReference::getObject()); - } -protected: - virtual bool _acceptObject(SPObject *obj) const { - return SP_IS_PAINT_SERVER (obj); - } -}; #endif // SEEN_SP_PAINT_SERVER_H /* diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9ea0ef891..0b2fe8389 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -78,7 +78,7 @@ static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern static SPPainter *sp_pattern_painter_new (SPPaintServer *ps, Geom::Affine const &full_transform, Geom::Affine const &parent_transform, const NRRect *bbox); static void sp_pattern_painter_free (SPPaintServer *ps, SPPainter *painter); -static SPPaintServerClass * pattern_parent_class; +static SPPaintServerClass * pattern_parent_class = 0; GType sp_pattern_get_type (void) @@ -105,13 +105,10 @@ sp_pattern_get_type (void) static void sp_pattern_class_init (SPPatternClass *klass) { - SPObjectClass *sp_object_class; - SPPaintServerClass *ps_class; + SPObjectClass *sp_object_class = SP_OBJECT_CLASS( klass ); + SPPaintServerClass *ps_class = SP_PAINT_SERVER_CLASS( klass ); - sp_object_class = (SPObjectClass *) klass; - ps_class = (SPPaintServerClass *) klass; - - pattern_parent_class = (SPPaintServerClass*)g_type_class_ref (SP_TYPE_PAINT_SERVER); + pattern_parent_class = SP_PAINT_SERVER_CLASS( g_type_class_ref(SP_TYPE_PAINT_SERVER) ); sp_object_class->build = sp_pattern_build; sp_object_class->release = sp_pattern_release; @@ -683,7 +680,7 @@ sp_pattern_painter_new (SPPaintServer *ps, Geom::Affine const &full_transform, G SPPattern *pat = SP_PATTERN (ps); SPPatPainter *pp = g_new (SPPatPainter, 1); - pp->painter.type = SP_PAINTER_IND; + pp->painter.server_type = G_OBJECT_TYPE(ps); pp->painter.fill = sp_pat_fill; pp->pat = pat; diff --git a/src/style.h b/src/style.h index 70e84ab42..a12db388a 100644 --- a/src/style.h +++ b/src/style.h @@ -22,7 +22,7 @@ #include "sp-filter-reference.h" #include "uri-references.h" #include "uri.h" -#include "sp-paint-server.h" +#include "sp-paint-server-reference.h" #include #include -- cgit v1.2.3 From 961baa0d3d2691ebeabc3f51fdab8d816b32c563 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 30 May 2011 00:36:58 -0700 Subject: Queue swatch updates during periods of high UI usage, such as dragging gradient handles. Fixes bug #734981. Fixed bugs: - https://launchpad.net/bugs/734981 (bzr r10244) --- src/ui/dialog/swatches.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++-- src/ui/dialog/swatches.h | 3 ++ 2 files changed, 89 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index b2b1b26da..935fe9806 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "color-item.h" @@ -63,8 +64,6 @@ namespace Dialogs { void _loadPaletteFile( gchar const *filename ); -class DocTrack; - std::vector possible; static std::map docPalettes; static std::vector docTrackings; @@ -715,14 +714,31 @@ class DocTrack public: DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) : doc(doc), + updatePending(false), + lastGradientUpdate(0.0), gradientRsrcChanged(gradientRsrcChanged), defsChanged(defsChanged), defsModified(defsModified) { + if ( !timer ) { + timer = new Glib::Timer(); + refreshTimer = Glib::signal_timeout().connect( sigc::ptr_fun(handleTimerCB), 33 ); + } + timerRefCount++; } ~DocTrack() { + timerRefCount--; + if ( timerRefCount <= 0 ) { + refreshTimer.disconnect(); + timerRefCount = 0; + if ( timer ) { + timer->stop(); + delete timer; + timer = 0; + } + } if (doc) { gradientRsrcChanged.disconnect(); defsChanged.disconnect(); @@ -730,7 +746,22 @@ public: } } + static bool handleTimerCB(); + + /** + * Checks if update should be queued or executed immediately. + * + * @return true if the update was queued and should not be immediately executed. + */ + static bool queueUpdateIfNeeded(SPDocument *doc); + + static Glib::Timer *timer; + static int timerRefCount; + static sigc::connection refreshTimer; + SPDocument *doc; + bool updatePending; + double lastGradientUpdate; sigc::connection gradientRsrcChanged; sigc::connection defsChanged; sigc::connection defsModified; @@ -740,6 +771,58 @@ private: DocTrack &operator=(DocTrack const &); // no assign }; +Glib::Timer *DocTrack::timer = 0; +int DocTrack::timerRefCount = 0; +sigc::connection DocTrack::refreshTimer; + +static const double DOC_UPDATE_THREASHOLD = 0.090; + +bool DocTrack::handleTimerCB() +{ + double now = timer->elapsed(); + + std::vector needCallback; + for (std::vector::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { + DocTrack *track = *it; + if ( track->updatePending && ( (now - track->lastGradientUpdate) >= DOC_UPDATE_THREASHOLD) ) { + needCallback.push_back(track); + } + } + + for (std::vector::iterator it = needCallback.begin(); it != needCallback.end(); ++it) { + DocTrack *track = *it; + if ( std::find(docTrackings.begin(), docTrackings.end(), track) != docTrackings.end() ) { // Just in case one gets deleted while we are looping + // Note: calling handleDefsModified will call queueUpdateIfNeeded and thus update the time and flag. + SwatchesPanel::handleDefsModified(track->doc); + } + } + + return true; +} + +bool DocTrack::queueUpdateIfNeeded( SPDocument *doc ) +{ + bool deferProcessing = false; + for (std::vector::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { + DocTrack *track = *it; + if ( track->doc == doc ) { + double now = timer->elapsed(); + double elapsed = now - track->lastGradientUpdate; + + if ( elapsed < DOC_UPDATE_THREASHOLD ) { + deferProcessing = true; + track->updatePending = true; + } else { + track->lastGradientUpdate = now; + track->updatePending = false; + } + + break; + } + } + return deferProcessing; +} + void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) { SPDocument *oldDoc = 0; @@ -897,7 +980,7 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) void SwatchesPanel::handleDefsModified(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; - if (docPalette) { + if (docPalette && !DocTrack::queueUpdateIfNeeded(document) ) { std::vector tmpColors; std::map tmpPrevs; std::map tmpGrads; diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h index f9f3daf91..95d7acb00 100644 --- a/src/ui/dialog/swatches.h +++ b/src/ui/dialog/swatches.h @@ -23,6 +23,7 @@ namespace Dialogs { class ColorItem; class SwatchPage; +class DocTrack; /** * A panel that displays paint swatches. @@ -68,6 +69,8 @@ private: sigc::connection _documentConnection; sigc::connection _selChanged; + + friend class DocTrack; }; } //namespace Dialogs -- cgit v1.2.3 From 50f0c3735473690f71df9862c5d9675f9efcfa8c Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Tue, 31 May 2011 19:15:11 -0500 Subject: fix rendering of angled guidelines (bzr r10246) --- src/display/guideline.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index dddf1f30e..abfec250f 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -170,6 +170,13 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) } } else { + + if (gl->label){ + cairo_move_to(ctx, px - buf->rect.x0 + 5, py - buf->rect.y0); + cairo_rotate(ctx, atan2(gl->normal_to_line[Geom::X], gl->normal_to_line[Geom::Y])); + cairo_show_text(ctx, gl->label); + } + // render angled line, once intersection has been detected, draw from there. Geom::Point parallel_to_line( gl->normal_to_line[Geom::Y], /*should be minus, but inverted y axis*/ gl->normal_to_line[Geom::X]); @@ -207,12 +214,6 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) sp_guideline_drawline (buf, static_cast(round(x_intersect_bottom)), buf->rect.y1, static_cast(round(x_intersect_top)), buf->rect.y0, gl->rgba); return; } - - if (gl->label){ - cairo_move_to(ctx, px - buf->rect.x0 + 5, py - buf->rect.y0); - cairo_rotate(ctx, atan2(gl->normal_to_line[Geom::X], gl->normal_to_line[Geom::Y])); - cairo_show_text(ctx, gl->label); - } } } -- cgit v1.2.3 From 2d87b4c8eb4eaaf67c9e92356368a8ab86a19454 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 1 Jun 2011 22:45:16 +0200 Subject: improve explanation of lpe parameter (bzr r10250) --- src/live_effects/effect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 7fe4e9348..91d09fef6 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -157,7 +157,7 @@ protected: LivePathEffectObject *lpeobj; // this boolean defaults to false, it concatenates the input path to one pwd2, - // instead of normally 'splitting' the path into continuous pwd2 paths. + // instead of normally 'splitting' the path into continuous pwd2 paths and calling doEffect_pwd2 for each. bool concatenate_before_pwd2; private: -- cgit v1.2.3 From f3756ff85a32f4b2a0771d0ac3bd78a69535395f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 3 Jun 2011 11:44:52 +0100 Subject: Use generic headers in preparation for GTK+ 3 transition Fixed bugs: - https://launchpad.net/bugs/792263 (bzr r10252.1.1) --- src/color.h | 2 +- src/context-fns.h | 2 +- src/debug/gdk-event-latency-tracker.h | 2 +- src/debug/log-display-config.cpp | 3 +-- src/desktop-events.h | 4 ++-- src/desktop.h | 4 ++-- src/device-manager.cpp | 2 +- src/dialogs/clonetiler.h | 2 +- src/dialogs/dialog-events.h | 3 +-- src/dialogs/find.h | 2 +- src/dialogs/item-properties.cpp | 9 --------- src/dialogs/item-properties.h | 2 +- src/dialogs/object-attributes.h | 2 +- src/dialogs/spellcheck.h | 2 +- src/display/canvas-temporary-item.cpp | 2 +- src/display/grayscale.h | 2 +- src/display/nr-3dutils.h | 2 +- src/display/nr-filter-diffuselighting.h | 2 +- src/display/nr-filter-specularlighting.h | 2 +- src/display/nr-light.h | 2 +- src/display/sodipodi-ctrl.h | 2 +- src/display/sp-canvas-item.h | 4 ++-- src/display/sp-canvas.cpp | 4 +--- src/display/sp-canvas.h | 6 ++---- src/document.cpp | 2 +- src/ege-adjustment-action.cpp | 11 ----------- src/ege-adjustment-action.h | 2 +- src/ege-color-prof-tracker.cpp | 4 +--- src/ege-output-action.cpp | 4 +--- src/ege-output-action.h | 2 +- src/ege-select-one-action.cpp | 9 --------- src/ege-select-one-action.h | 3 +-- src/event-context.cpp | 3 +-- src/event-context.h | 3 +-- src/extension/effect.h | 2 +- src/extension/implementation/implementation.h | 2 +- src/extension/input.h | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/output.h | 2 +- src/file.h | 2 +- src/help.h | 2 +- src/helper/unit-menu.cpp | 5 +---- src/helper/unit-menu.h | 2 +- src/helper/unit-tracker.cpp | 2 +- src/helper/unit-tracker.h | 3 +-- src/helper/window.cpp | 2 +- src/helper/window.h | 2 +- src/icon-size.h | 2 +- src/ink-action.cpp | 9 ++------- src/ink-action.h | 4 +--- src/ink-comboboxentry-action.cpp | 3 --- src/ink-comboboxentry-action.h | 3 +-- src/inkscape.cpp | 3 +-- src/inkview.cpp | 6 +----- src/interface.h | 2 +- src/io/sys.cpp | 2 +- src/knot.h | 2 +- src/libgdl/gdl-dock-bar.h | 2 +- src/libgdl/gdl-dock-item-grip.c | 4 +--- src/libgdl/gdl-dock-item-grip.h | 2 +- src/libgdl/gdl-dock-master.h | 2 +- src/libgdl/gdl-dock-object.h | 2 +- src/libgdl/gdl-dock-paned.c | 3 +-- src/libgdl/gdl-stock.c | 1 - src/libgdl/gdl-switcher.c | 4 ---- src/libgdl/gdl-switcher.h | 2 +- src/libgdl/gdl-tools.h | 2 +- src/libnrtype/Layout-TNG-Input.cpp | 2 +- src/live_effects/parameter/path.cpp | 2 +- src/main.cpp | 6 +----- src/modifier-fns.h | 2 +- src/select-context.h | 2 +- src/seltrans-handles.h | 2 +- src/shortcuts.cpp | 2 +- src/sp-gradient.h | 2 +- src/sp-pattern.h | 2 +- src/spiral-context.h | 2 +- src/svg-view-widget.cpp | 2 +- src/text-context.cpp | 3 +-- src/text-context.h | 2 +- src/ui/context-menu.cpp | 2 +- src/ui/context-menu.h | 2 +- src/ui/dialog/color-item.cpp | 2 +- src/ui/dialog/extensions.cpp | 2 +- src/ui/dialog/filedialogimpl-gtkmm.h | 6 +----- src/ui/dialog/glyphs.cpp | 4 +--- src/ui/dialog/inkscape-preferences.cpp | 2 +- src/ui/dialog/layers.cpp | 3 +-- src/ui/dialog/ocaldialogs.h | 4 +--- src/ui/dialog/print.h | 2 +- src/ui/dialog/swatches.cpp | 6 +----- src/ui/dialog/tile.cpp | 3 +-- src/ui/dialog/tracedialog.cpp | 2 +- src/ui/dialog/undo-history.cpp | 2 +- src/ui/view/view-widget.h | 2 +- src/ui/view/view.h | 2 +- src/ui/widget/combo-text.cpp | 2 +- src/ui/widget/panel.cpp | 2 +- src/ui/widget/selected-style.cpp | 2 +- src/ui/widget/toolbox.cpp | 2 +- src/verbs.cpp | 2 +- src/widgets/button.h | 4 +--- src/widgets/desktop-widget.h | 3 +-- src/widgets/eek-preview.h | 4 ++-- src/widgets/fill-style.cpp | 2 +- src/widgets/font-selector.cpp | 7 ------- src/widgets/font-selector.h | 2 +- src/widgets/gradient-image.h | 2 +- src/widgets/gradient-selector.cpp | 6 +----- src/widgets/gradient-selector.h | 2 +- src/widgets/gradient-toolbar.h | 2 +- src/widgets/gradient-vector.h | 2 +- src/widgets/icon.h | 2 +- src/widgets/paint-selector.cpp | 9 +-------- src/widgets/paint-selector.h | 2 +- src/widgets/ruler.h | 2 +- src/widgets/select-toolbar.cpp | 1 - src/widgets/select-toolbar.h | 3 +-- src/widgets/shrink-wrap-button.cpp | 2 +- src/widgets/sp-attribute-widget.cpp | 3 +-- src/widgets/sp-attribute-widget.h | 3 +-- src/widgets/sp-color-gtkselector.h | 2 +- src/widgets/sp-color-icc-selector.cpp | 5 ----- src/widgets/sp-color-icc-selector.h | 3 +-- src/widgets/sp-color-notebook.h | 4 +--- src/widgets/sp-color-preview.h | 2 +- src/widgets/sp-color-scales.h | 3 +-- src/widgets/sp-color-selector.h | 2 +- src/widgets/sp-color-slider.cpp | 3 +-- src/widgets/sp-color-slider.h | 2 +- src/widgets/sp-color-wheel-selector.cpp | 5 +---- src/widgets/sp-color-wheel-selector.h | 3 +-- src/widgets/sp-widget.h | 2 +- src/widgets/sp-xmlview-attr-list.h | 1 - src/widgets/sp-xmlview-content.h | 2 +- src/widgets/sp-xmlview-tree.h | 2 +- src/widgets/spinbutton-events.h | 3 +-- src/widgets/spw-utilities.h | 2 +- src/widgets/toolbox.h | 3 +-- 139 files changed, 135 insertions(+), 266 deletions(-) (limited to 'src') diff --git a/src/color.h b/src/color.h index bebeaec60..8e6b54dd1 100644 --- a/src/color.h +++ b/src/color.h @@ -15,7 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include /* Useful composition macros */ diff --git a/src/context-fns.h b/src/context-fns.h index be8b4dfd5..c86640aba 100644 --- a/src/context-fns.h +++ b/src/context-fns.h @@ -11,7 +11,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include <2geom/forward.h> struct SPDesktop; diff --git a/src/debug/gdk-event-latency-tracker.h b/src/debug/gdk-event-latency-tracker.h index 12ebb6570..c3624e74f 100644 --- a/src/debug/gdk-event-latency-tracker.h +++ b/src/debug/gdk-event-latency-tracker.h @@ -12,7 +12,7 @@ #ifndef SEEN_INKSCAPE_DEBUG_GDK_EVENT_LATENCY_TRACKER_H #define SEEN_INKSCAPE_DEBUG_GDK_EVENT_LATENCY_TRACKER_H -#include +#include #include #include diff --git a/src/debug/log-display-config.cpp b/src/debug/log-display-config.cpp index d2821cc53..07380b3ad 100644 --- a/src/debug/log-display-config.cpp +++ b/src/debug/log-display-config.cpp @@ -10,8 +10,7 @@ */ #include -#include -#include +#include #include "debug/event-tracker.h" #include "debug/logger.h" #include "debug/simple-event.h" diff --git a/src/desktop-events.h b/src/desktop-events.h index e720cf7a0..e573fc878 100644 --- a/src/desktop-events.h +++ b/src/desktop-events.h @@ -13,8 +13,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include +#include +#include class SPDesktop; class SPDesktopWidget; diff --git a/src/desktop.h b/src/desktop.h index 6d1bcd194..2581f2859 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -27,8 +27,8 @@ #include "config.h" #endif -#include -#include +#include +#include #include #include diff --git a/src/device-manager.cpp b/src/device-manager.cpp index 2b44a8d51..5cf376cc4 100644 --- a/src/device-manager.cpp +++ b/src/device-manager.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "device-manager.h" #include "preferences.h" diff --git a/src/dialogs/clonetiler.h b/src/dialogs/clonetiler.h index bfb35cd96..899181346 100644 --- a/src/dialogs/clonetiler.h +++ b/src/dialogs/clonetiler.h @@ -12,7 +12,7 @@ #include -#include +#include void clonetiler_dialog ( void ); diff --git a/src/dialogs/dialog-events.h b/src/dialogs/dialog-events.h index 7b04d0f69..9c0a82f23 100644 --- a/src/dialogs/dialog-events.h +++ b/src/dialogs/dialog-events.h @@ -12,8 +12,7 @@ #ifndef __DIALOG_EVENTS_H__ #define __DIALOG_EVENTS_H__ -#include -#include +#include #include /* diff --git a/src/dialogs/find.h b/src/dialogs/find.h index fe5861a73..219c36bf2 100644 --- a/src/dialogs/find.h +++ b/src/dialogs/find.h @@ -12,7 +12,7 @@ #ifndef SEEN_FIND_H #define SEEN_FIND_H -#include +#include void sp_find_dialog(); diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 94b8b1e98..54707c0aa 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -16,16 +16,7 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include -#include -#include #include -#include -#include -#include -#include -#include #include "../desktop-handles.h" #include "dialog-events.h" diff --git a/src/dialogs/item-properties.h b/src/dialogs/item-properties.h index bc04608bc..7d57ae5e8 100644 --- a/src/dialogs/item-properties.h +++ b/src/dialogs/item-properties.h @@ -12,7 +12,7 @@ #define SEEN_DIALOGS_ITEM_PROPERTIES_H #include -#include +#include #include "../forward.h" GtkWidget *sp_item_widget_new (void); diff --git a/src/dialogs/object-attributes.h b/src/dialogs/object-attributes.h index ef84708c0..b490ebfa1 100644 --- a/src/dialogs/object-attributes.h +++ b/src/dialogs/object-attributes.h @@ -13,7 +13,7 @@ #define SEEN_DIALOGS_OBJECT_ATTRIBUTES_H #include -#include +#include #include "../forward.h" void sp_object_attributes_dialog (SPObject *object, const gchar *tag); diff --git a/src/dialogs/spellcheck.h b/src/dialogs/spellcheck.h index b941788ca..fe80be2cb 100644 --- a/src/dialogs/spellcheck.h +++ b/src/dialogs/spellcheck.h @@ -12,7 +12,7 @@ #ifndef SEEN_SPELLCHECK_H #define SEEN_SPELLCHECK_H -#include +#include void sp_spellcheck_dialog(); diff --git a/src/display/canvas-temporary-item.cpp b/src/display/canvas-temporary-item.cpp index ccef4d0cb..8d336f0ff 100644 --- a/src/display/canvas-temporary-item.cpp +++ b/src/display/canvas-temporary-item.cpp @@ -16,7 +16,7 @@ #include "display/canvas-temporary-item.h" -#include +#include namespace Inkscape { namespace Display { diff --git a/src/display/grayscale.h b/src/display/grayscale.h index 855c9e465..d7092687c 100644 --- a/src/display/grayscale.h +++ b/src/display/grayscale.h @@ -12,7 +12,7 @@ * Released under GNU GPL */ -#include +#include namespace Grayscale { guint32 process(guint32 rgba); diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h index 56bed6ba2..e19651ac8 100644 --- a/src/display/nr-3dutils.h +++ b/src/display/nr-3dutils.h @@ -14,7 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include <2geom/forward.h> struct NRPixBlock; diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 8dc7a1818..f540bf4a5 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index a5d29588a..7c278df89 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" diff --git a/src/display/nr-light.h b/src/display/nr-light.h index 49130cc4e..022243bfc 100644 --- a/src/display/nr-light.h +++ b/src/display/nr-light.h @@ -8,7 +8,7 @@ * light color components (at a given point). */ -#include +#include #include "display/nr-3dutils.h" #include "display/nr-light-types.h" #include <2geom/forward.h> diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index a708ad41b..c3b97cbe0 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -7,7 +7,7 @@ * */ -#include +#include #include #include #include "sp-canvas-item.h" diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index cc0bdfc77..26e5aa1f6 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -22,8 +22,8 @@ #endif #include -#include -#include +#include +#include #include "2geom/rect.h" diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0d450362a..ff1bf32c6 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -20,9 +20,7 @@ #include -#include -#include -#include +#include #include diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 3a0b56585..a6ddafb1e 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -28,10 +28,8 @@ #endif #include -#include -#include -#include -#include +#include +#include #include diff --git a/src/document.cpp b/src/document.cpp index c9b822ce6..b9c3fe9ff 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -37,7 +37,7 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include +#include #include #include diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index b8ee66f08..f6df395b9 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -43,18 +43,7 @@ #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "widgets/icon.h" #include "icon-size.h" diff --git a/src/ege-adjustment-action.h b/src/ege-adjustment-action.h index b7da6a499..f63d4ed3e 100644 --- a/src/ege-adjustment-action.h +++ b/src/ege-adjustment-action.h @@ -46,7 +46,7 @@ /* Note: this file should be kept compilable as both .cpp and .c */ #include -#include +#include #include G_BEGIN_DECLS diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp index 900246595..a6fcaa126 100644 --- a/src/ege-color-prof-tracker.cpp +++ b/src/ege-color-prof-tracker.cpp @@ -41,9 +41,7 @@ #include -#include -#include -#include +#include #ifdef GDK_WINDOWING_X11 #include diff --git a/src/ege-output-action.cpp b/src/ege-output-action.cpp index 72616ce18..c1a5be694 100644 --- a/src/ege-output-action.cpp +++ b/src/ege-output-action.cpp @@ -41,9 +41,7 @@ #include -#include -#include -#include +#include #include "ege-output-action.h" diff --git a/src/ege-output-action.h b/src/ege-output-action.h index e626ccd8c..fc21c2f27 100644 --- a/src/ege-output-action.h +++ b/src/ege-output-action.h @@ -46,7 +46,7 @@ /* Note: this file should be kept compilable as both .cpp and .c */ #include -#include +#include #include G_BEGIN_DECLS diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 1c3ec1ff5..2fd45e268 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -41,16 +41,7 @@ #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include "ege-select-one-action.h" diff --git a/src/ege-select-one-action.h b/src/ege-select-one-action.h index 36943b978..d605f4a67 100644 --- a/src/ege-select-one-action.h +++ b/src/ege-select-one-action.h @@ -49,8 +49,7 @@ /* Note: this file should be kept compilable as both .cpp and .c */ #include -#include -#include +#include #include G_BEGIN_DECLS diff --git a/src/event-context.cpp b/src/event-context.cpp index 828ce3d5b..5a1c7130a 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include #include #include diff --git a/src/event-context.h b/src/event-context.h index 71084cb5f..b0772c23a 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -18,8 +18,7 @@ */ #include -#include -#include +#include #include "knot.h" #include "2geom/forward.h" diff --git a/src/extension/effect.h b/src/extension/effect.h index c02ce542b..28ebc5d96 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -15,7 +15,7 @@ #include #include -#include +#include #include "verbs.h" #include "prefdialog.h" diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index bf584b401..b9e417feb 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -12,7 +12,7 @@ #ifndef __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ #define __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ -#include +#include #include #include diff --git a/src/extension/input.h b/src/extension/input.h index 24cbc4896..8b198495e 100644 --- a/src/extension/input.h +++ b/src/extension/input.h @@ -16,7 +16,7 @@ #include "extension.h" #include "xml/repr.h" #include "document.h" -#include +#include namespace Inkscape { namespace Extension { diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index fc2db7e69..186f337c4 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -40,7 +40,7 @@ #include "inkscape.h" #include "dialogs/dialog-events.h" -#include +#include #include "ui/widget/spinbutton.h" namespace Inkscape { diff --git a/src/extension/output.h b/src/extension/output.h index 584fafda8..5f6785b8b 100644 --- a/src/extension/output.h +++ b/src/extension/output.h @@ -13,7 +13,7 @@ #ifndef INKSCAPE_EXTENSION_OUTPUT_H__ #define INKSCAPE_EXTENSION_OUTPUT_H__ -#include +#include #include "extension.h" struct SPDocument; diff --git a/src/file.h b/src/file.h index 97d1bd5f8..dec7e3f14 100644 --- a/src/file.h +++ b/src/file.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include "extension/extension-forward.h" #include "extension/system.h" diff --git a/src/help.h b/src/help.h index 35f67a714..b6c82fb51 100644 --- a/src/help.h +++ b/src/help.h @@ -14,7 +14,7 @@ */ #include -#include +#include void sp_help_about(void); void sp_help_open_tutorial(GtkMenuItem *menuitem, gpointer data); diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index e4ff09829..5494aaaeb 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -17,10 +17,7 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include -#include -#include +#include #include "helper/sp-marshal.h" #include "helper/units.h" #include "helper/unit-menu.h" diff --git a/src/helper/unit-menu.h b/src/helper/unit-menu.h index b3ab8836c..795dda7b7 100644 --- a/src/helper/unit-menu.h +++ b/src/helper/unit-menu.h @@ -11,7 +11,7 @@ */ #include -#include +#include #include diff --git a/src/helper/unit-tracker.cpp b/src/helper/unit-tracker.cpp index 3f5a72e6a..609c2f292 100644 --- a/src/helper/unit-tracker.cpp +++ b/src/helper/unit-tracker.cpp @@ -10,7 +10,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "unit-tracker.h" #include "ege-select-one-action.h" diff --git a/src/helper/unit-tracker.h b/src/helper/unit-tracker.h index 0f333b2ec..a15a0a6ca 100644 --- a/src/helper/unit-tracker.h +++ b/src/helper/unit-tracker.h @@ -15,8 +15,7 @@ #include -#include -#include +#include #include "helper/units.h" diff --git a/src/helper/window.cpp b/src/helper/window.cpp index b814424e5..f4640203d 100644 --- a/src/helper/window.cpp +++ b/src/helper/window.cpp @@ -12,7 +12,7 @@ #ifdef HAVE_CONFIG_H # include #endif -#include +#include #include #include "inkscape.h" diff --git a/src/helper/window.h b/src/helper/window.h index 36b91a813..dc2c48bc0 100644 --- a/src/helper/window.h +++ b/src/helper/window.h @@ -10,7 +10,7 @@ * This code is in public domain */ -#include +#include #include /* diff --git a/src/icon-size.h b/src/icon-size.h index da2b3854d..4bb4f1df6 100644 --- a/src/icon-size.h +++ b/src/icon-size.h @@ -14,7 +14,7 @@ #include -#include +#include namespace Inkscape { diff --git a/src/ink-action.cpp b/src/ink-action.cpp index 587efdff0..d26b038f8 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -2,12 +2,7 @@ #include -#include -#include -#include -#include -#include -#include +#include #include "icon-size.h" #include "ink-action.h" @@ -183,7 +178,7 @@ void ink_action_set_property( GObject* obj, guint propId, const GValue *value, G } } -#include +#include static GtkWidget* ink_action_create_menu_item( GtkAction* action ) { diff --git a/src/ink-action.h b/src/ink-action.h index 7b48d40af..c957f0f5c 100644 --- a/src/ink-action.h +++ b/src/ink-action.h @@ -3,9 +3,7 @@ #include -#include -#include -#include +#include #include #include "icon-size.h" #include "attributes.h" diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index eaaf62113..49ab343c2 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -26,9 +26,6 @@ #include #include -#include -#include -#include #include "ink-comboboxentry-action.h" diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index 1a83cb053..aade3a89f 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -22,8 +22,7 @@ #include #include -#include -#include +#include #define INK_COMBOBOXENTRY_TYPE_ACTION (ink_comboboxentry_action_get_type()) diff --git a/src/inkscape.cpp b/src/inkscape.cpp index b794138ca..e90c44c82 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -40,8 +40,7 @@ using Inkscape::Extension::Internal::PrintWin32; #include #include #include -#include -#include +#include #include #include #include diff --git a/src/inkview.cpp b/src/inkview.cpp index 448aa77f1..173427aae 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -45,11 +45,7 @@ #include #include -#include -#include -#include -#include -#include +#include #include diff --git a/src/interface.h b/src/interface.h index 01732e911..a39769632 100644 --- a/src/interface.h +++ b/src/interface.h @@ -15,7 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "forward.h" #include "sp-item.h" diff --git a/src/io/sys.cpp b/src/io/sys.cpp index e6c512be2..85857c2f0 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include "preferences.h" #include "sys.h" diff --git a/src/knot.h b/src/knot.h index 1af2548e1..250165f79 100644 --- a/src/knot.h +++ b/src/knot.h @@ -15,7 +15,7 @@ */ #include -#include +#include #include "forward.h" #include <2geom/point.h> #include "knot-enums.h" diff --git a/src/libgdl/gdl-dock-bar.h b/src/libgdl/gdl-dock-bar.h index 22b99edd4..c6697a47c 100644 --- a/src/libgdl/gdl-dock-bar.h +++ b/src/libgdl/gdl-dock-bar.h @@ -22,7 +22,7 @@ #ifndef __GDL_DOCK_BAR_H__ #define __GDL_DOCK_BAR_H__ -#include +#include #include "libgdl/gdl-dock.h" G_BEGIN_DECLS diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 86e7bc14c..6457016de 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -17,9 +17,7 @@ #include "gdl-i18n.h" #include #include -#include -#include -#include +#include #include "gdl-dock-item.h" #include "gdl-dock-item-grip.h" #include "gdl-stock.h" diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h index 377ea1470..495e9381d 100644 --- a/src/libgdl/gdl-dock-item-grip.h +++ b/src/libgdl/gdl-dock-item-grip.h @@ -13,7 +13,7 @@ #ifndef _GDL_DOCK_ITEM_GRIP_H_ #define _GDL_DOCK_ITEM_GRIP_H_ -#include +#include #include "libgdl/gdl-dock-item.h" G_BEGIN_DECLS diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h index 72697b484..1a10405b6 100644 --- a/src/libgdl/gdl-dock-master.h +++ b/src/libgdl/gdl-dock-master.h @@ -25,7 +25,7 @@ #define __GDL_DOCK_MASTER_H__ #include -#include +#include #include "libgdl/gdl-dock-object.h" diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h index 84e5eb9a7..684bd043f 100644 --- a/src/libgdl/gdl-dock-object.h +++ b/src/libgdl/gdl-dock-object.h @@ -24,7 +24,7 @@ #ifndef __GDL_DOCK_OBJECT_H__ #define __GDL_DOCK_OBJECT_H__ -#include +#include G_BEGIN_DECLS diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c index 268a9f673..70273c886 100644 --- a/src/libgdl/gdl-dock-paned.c +++ b/src/libgdl/gdl-dock-paned.c @@ -27,8 +27,7 @@ #include "gdl-i18n.h" #include -#include -#include +#include #include "gdl-tools.h" #include "gdl-dock-paned.h" diff --git a/src/libgdl/gdl-stock.c b/src/libgdl/gdl-stock.c index 94f825678..dc86e523b 100644 --- a/src/libgdl/gdl-stock.c +++ b/src/libgdl/gdl-stock.c @@ -24,7 +24,6 @@ #endif #include -#include #include "gdl-stock.h" #include "gdl-stock-icons.h" diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 43768bbdf..c5e139e70 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -35,10 +35,6 @@ #include "libgdltypebuiltins.h" #include -#include -#include -#include -#include #if HAVE_GNOME #include diff --git a/src/libgdl/gdl-switcher.h b/src/libgdl/gdl-switcher.h index be4b179bf..9c33f8bbf 100644 --- a/src/libgdl/gdl-switcher.h +++ b/src/libgdl/gdl-switcher.h @@ -25,7 +25,7 @@ #ifndef _GDL_SWITCHER_H_ #define _GDL_SWITCHER_H_ -#include +#include G_BEGIN_DECLS diff --git a/src/libgdl/gdl-tools.h b/src/libgdl/gdl-tools.h index 32c2e4a41..0cfc9fb95 100644 --- a/src/libgdl/gdl-tools.h +++ b/src/libgdl/gdl-tools.h @@ -25,7 +25,7 @@ #define __GDL_TOOLS_H__ #include -#include +#include /* FIXME: Toggle this */ diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index d16c6457d..45bc0c89b 100644 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -11,7 +11,7 @@ #define PANGO_ENABLE_ENGINE -#include +#include #include "Layout-TNG.h" #include "style.h" #include "svg/svg-length.h" diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index d652dfd0c..bd9748fd6 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -15,7 +15,7 @@ #include "ui/widget/point.h" #include "widgets/icon.h" -#include +#include #include "selection-chemistry.h" #include "xml/repr.h" #include "desktop.h" diff --git a/src/main.cpp b/src/main.cpp index ac0994be6..657e4c07e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ // This has to be included prior to anything that includes setjmp.h, it croaks otherwise #include -#include +#include #ifdef HAVE_IEEEFP_H #include @@ -51,10 +51,6 @@ #include #include #include -#include -#include -#include -#include #include "gc-core.h" diff --git a/src/modifier-fns.h b/src/modifier-fns.h index 8d78455e1..c1b35e948 100644 --- a/src/modifier-fns.h +++ b/src/modifier-fns.h @@ -11,7 +11,7 @@ * Hereby placed in public domain. */ -#include +#include #include inline bool diff --git a/src/select-context.h b/src/select-context.h index 377e07275..6d12558ca 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -13,7 +13,7 @@ */ #include "event-context.h" -#include +#include #define SP_TYPE_SELECT_CONTEXT (sp_select_context_get_type ()) #define SP_SELECT_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_SELECT_CONTEXT, SPSelectContext)) diff --git a/src/seltrans-handles.h b/src/seltrans-handles.h index f796a1007..53dbd3cda 100644 --- a/src/seltrans-handles.h +++ b/src/seltrans-handles.h @@ -14,7 +14,7 @@ #include "display/sodipodi-ctrl.h" #include <2geom/forward.h> -#include +#include namespace Inkscape { diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index d647d30b3..fe1d31331 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 2adb085c1..217b9f3ee 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -17,7 +17,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include #include "libnr/nr-matrix.h" #include "sp-paint-server.h" diff --git a/src/sp-pattern.h b/src/sp-pattern.h index fa0541698..141474277 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "forward.h" #include "sp-item.h" diff --git a/src/spiral-context.h b/src/spiral-context.h index 29a5f41b2..906cf61df 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -15,7 +15,7 @@ * Released under GNU GPL */ -#include +#include #include #include #include "event-context.h" diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index 777c1b496..da5ad068f 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -14,7 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" #include "display/canvas-arena.h" diff --git a/src/text-context.cpp b/src/text-context.cpp index 5af2c5ebc..a7c6772e5 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -18,11 +18,10 @@ #endif #include -#include +#include #include #include #include -#include #include #include "macros.h" diff --git a/src/text-context.h b/src/text-context.h index ec1710da3..b7d1b8e69 100644 --- a/src/text-context.h +++ b/src/text-context.h @@ -17,7 +17,7 @@ /* #include */ #include #include -#include +#include #include "event-context.h" #include <2geom/point.h> diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 05fe9a459..72e5ee63b 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -42,7 +42,7 @@ sp_object_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* Implementation */ -#include +#include #include diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index 36846edc3..1f8208ebe 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -11,7 +11,7 @@ * This code is in public domain */ -#include +#include #include "forward.h" #include "sp-object.h" diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 9f163c00c..da8393fc5 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "color-item.h" diff --git a/src/ui/dialog/extensions.cpp b/src/ui/dialog/extensions.cpp index 3c778affe..27cd15e8c 100644 --- a/src/ui/dialog/extensions.cpp +++ b/src/ui/dialog/extensions.cpp @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include //for GTK_RESPONSE* types +#include //for GTK_RESPONSE* types #include #include "extension/db.h" diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index af607c124..1598a04d3 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -35,11 +35,7 @@ //Temporary ugly hack //Remove this after the get_filter() calls in //show() on both classes are fixed -#include - -//Another hack -#include -#include +#include //Inkscape includes #include "extension/input.h" diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 8eef5d89b..fc0912539 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -22,9 +22,7 @@ #include #include -#include -#include -#include +#include #include "glyphs.h" diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 28c59c321..ad3553b86 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include "preferences.h" #include "inkscape-preferences.h" diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 0eca5bbca..94ecf968a 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -13,8 +13,7 @@ # include #endif -#include -#include +#include #include #include #include diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 85aefade8..a7dfaa5cd 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -33,11 +33,9 @@ //Temporary ugly hack //Remove this after the get_filter() calls in //show() on both classes are fixed -#include +#include //Another hack -#include -#include #ifdef WITH_GNOME_VFS #include // gnome_vfs_initialized #include diff --git a/src/ui/dialog/print.h b/src/ui/dialog/print.h index cc27955cb..0184bc783 100644 --- a/src/ui/dialog/print.h +++ b/src/ui/dialog/print.h @@ -13,7 +13,7 @@ #include #include // GtkMM -#include // Gtk +#include // Gtk #include "desktop.h" #include "sp-item.h" diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 935fe9806..bebf14984 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -17,11 +17,7 @@ #include #include -#include //for GTK_RESPONSE* types -#include -#include -#include -#include +#include //for GTK_RESPONSE* types #include #include #include diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 3510503d3..ae17214bf 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -18,8 +18,7 @@ # include #endif -#include //for GTK_RESPONSE* types -#include +#include //for GTK_RESPONSE* types #include #include diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index 083cd0077..7fb172531 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -19,7 +19,7 @@ #include "ui/widget/spinbutton.h" #include -#include //for GTK_RESPONSE* types +#include //for GTK_RESPONSE* types #include #include "desktop.h" diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index e6f113e48..4c3446a51 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -14,7 +14,7 @@ #endif #include -#include +#include #include #include diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index 9b5e9c4a8..7bdbdefb1 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -14,7 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include namespace Inkscape { namespace UI { diff --git a/src/ui/view/view.h b/src/ui/view/view.h index e6853555f..13499a2e4 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -14,7 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include #include #include "message.h" diff --git a/src/ui/widget/combo-text.cpp b/src/ui/widget/combo-text.cpp index 7706f7c29..43428adb8 100644 --- a/src/ui/widget/combo-text.cpp +++ b/src/ui/widget/combo-text.cpp @@ -23,7 +23,7 @@ #endif #include "combo-text.h" -#include +#include ComboText::ComboText() : Gtk::ComboBox() diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index b3c8ce376..3e0c27587 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -22,7 +22,7 @@ #include // for Gtk::RESPONSE_* #include -#include +#include #include "panel.h" #include "icon-size.h" diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 50476dc65..ae8cd564e 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -14,7 +14,7 @@ # include #endif -#include +#include #include "selected-style.h" diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp index e90a58b6e..5e5f43263 100644 --- a/src/ui/widget/toolbox.cpp +++ b/src/ui/widget/toolbox.cpp @@ -14,7 +14,7 @@ #endif #include -#include +#include #include "ui/widget/toolbox.h" #include "path-prefix.h" diff --git a/src/verbs.cpp b/src/verbs.cpp index 4dbe15a03..de935f700 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -29,7 +29,7 @@ #endif #include -#include +#include #include #include #include diff --git a/src/widgets/button.h b/src/widgets/button.h index f14af94d1..26191f524 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -16,9 +16,7 @@ #define SP_BUTTON(o) (GTK_CHECK_CAST ((o), SP_TYPE_BUTTON, SPButton)) #define SP_IS_BUTTON(o) (GTK_CHECK_TYPE ((o), SP_TYPE_BUTTON)) -#include -#include -#include +#include #include "helper/action.h" #include "icon-size.h" diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 53d9dd1bc..c045d6e28 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -12,8 +12,7 @@ * ? -2004 */ -#include -#include +#include #include "libnr/nr-point.h" #include "forward.h" diff --git a/src/widgets/eek-preview.h b/src/widgets/eek-preview.h index 49fe8e660..c15f25eb6 100644 --- a/src/widgets/eek-preview.h +++ b/src/widgets/eek-preview.h @@ -40,8 +40,8 @@ #ifndef SEEN_EEK_PREVIEW_H #define SEEN_EEK_PREVIEW_H -#include -#include +#include +#include G_BEGIN_DECLS diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index b4272a3a4..c6e97666a 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include "desktop.h" #include "selection.h" diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 6cc73e42f..efeaa980c 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -32,13 +32,6 @@ #include <2geom/transforms.h> #include -#include -#include -#include -#include -#include -#include -#include #include "../display/nr-plain-stuff-gdk.h" #include diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 6ab2a1a12..61e607ac7 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -28,7 +28,7 @@ struct SPFontPreview; #define SP_IS_FONT_PREVIEW(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_PREVIEW)) #include -#include +#include /* SPFontSelector */ diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h index 7b3854a02..a998dcff3 100644 --- a/src/widgets/gradient-image.h +++ b/src/widgets/gradient-image.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "../libnr/nr-matrix.h" class SPGradient; diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index f7a981c9f..6327e2ff2 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -16,11 +16,7 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include -#include -#include -#include -#include +#include #include "document.h" #include "../document-private.h" diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index 860804ec6..9abbc57af 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include "sp-gradient.h" #include "sp-gradient-spread.h" diff --git a/src/widgets/gradient-toolbar.h b/src/widgets/gradient-toolbar.h index 41138724a..f1e258f6b 100644 --- a/src/widgets/gradient-toolbar.h +++ b/src/widgets/gradient-toolbar.h @@ -12,7 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include struct SPDesktop; GtkWidget *sp_gradient_toolbox_new (SPDesktop *desktop); diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 012d4e9a3..ac40aded0 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include "../forward.h" #define SP_TYPE_GRADIENT_VECTOR_SELECTOR (sp_gradient_vector_selector_get_type ()) diff --git a/src/widgets/icon.h b/src/widgets/icon.h index a20fad73a..371f6ba87 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -22,7 +22,7 @@ #define SP_ICON(o) (GTK_CHECK_CAST ((o), SP_TYPE_ICON, SPIcon)) #define SP_IS_ICON(o) (GTK_CHECK_TYPE ((o), SP_TYPE_ICON)) -#include +#include struct SPIconClass { GtkWidgetClass parent_class; diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index f0b55cf13..610930a46 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -23,14 +23,7 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include "../sp-pattern.h" #include diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index f3aff5a68..eb3eb2008 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -27,7 +27,7 @@ class SPGradient; #define SP_IS_PAINT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_PAINT_SELECTOR)) #define SP_IS_PAINT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_PAINT_SELECTOR)) -#include +#include #include "../forward.h" #include diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h index 7a3509325..fed3caaf0 100644 --- a/src/widgets/ruler.h +++ b/src/widgets/ruler.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include "sp-metric.h" #include #include diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index e08b4ac61..108fae1ef 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -17,7 +17,6 @@ #endif #include -#include #include "widgets/button.h" #include "widgets/spw-utilities.h" diff --git a/src/widgets/select-toolbar.h b/src/widgets/select-toolbar.h index dbab1975a..a4c42880f 100644 --- a/src/widgets/select-toolbar.h +++ b/src/widgets/select-toolbar.h @@ -14,8 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include +#include struct SPDesktop; void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index d73f972d9..e0c9e3cd1 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -10,7 +10,7 @@ */ #include -#include +#include namespace Inkscape { namespace Widgets { diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index a64a03f4e..66ccb27f2 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -9,8 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include +#include #include "xml/repr.h" #include "macros.h" #include "document.h" diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 617c5b012..647ebd6d8 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -42,8 +42,7 @@ struct SPAttributeWidgetClass; struct SPAttributeTable; struct SPAttributeTableClass; -#include -#include +#include #include diff --git a/src/widgets/sp-color-gtkselector.h b/src/widgets/sp-color-gtkselector.h index b9b2b0862..a85d94a5b 100644 --- a/src/widgets/sp-color-gtkselector.h +++ b/src/widgets/sp-color-gtkselector.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_COLOR_GTKSELECTOR_H #define SEEN_SP_COLOR_GTKSELECTOR_H -#include +#include #include "../color.h" #include "sp-color-selector.h" diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 12467041c..bf738df9a 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -2,12 +2,7 @@ # include "config.h" #endif #include -#include #include -#include -#include -#include -#include #include #include "../dialogs/dialog-events.h" #include "sp-color-icc-selector.h" diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index 9fd80c04a..f40d93189 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -2,8 +2,7 @@ #define SEEN_SP_COLOR_ICC_SELECTOR_H #include -#include -#include +#include #include "../color.h" #include "sp-color-slider.h" diff --git a/src/widgets/sp-color-notebook.h b/src/widgets/sp-color-notebook.h index 0b9b2ed87..b17612e03 100644 --- a/src/widgets/sp-color-notebook.h +++ b/src/widgets/sp-color-notebook.h @@ -12,9 +12,7 @@ * This code is in public domain */ -#include -#include -#include +#include #include "../color.h" #include "sp-color-selector.h" diff --git a/src/widgets/sp-color-preview.h b/src/widgets/sp-color-preview.h index 32572e915..731aceb70 100644 --- a/src/widgets/sp-color-preview.h +++ b/src/widgets/sp-color-preview.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include diff --git a/src/widgets/sp-color-scales.h b/src/widgets/sp-color-scales.h index 21a85a08e..b50c386e8 100644 --- a/src/widgets/sp-color-scales.h +++ b/src/widgets/sp-color-scales.h @@ -2,8 +2,7 @@ #define SEEN_SP_COLOR_SCALES_H #include -#include -#include +#include #include #include diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index 3b35140ed..2030d02ff 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_COLOR_SELECTOR_H #define SEEN_SP_COLOR_SELECTOR_H -#include +#include #include "../color.h" #include diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 0690caaab..09d2a87ab 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -10,8 +10,7 @@ * This code is in public domain */ -#include -#include +#include #include "sp-color-scales.h" #include "preferences.h" diff --git a/src/widgets/sp-color-slider.h b/src/widgets/sp-color-slider.h index bdeb3e4b6..8b0bcb9a9 100644 --- a/src/widgets/sp-color-slider.h +++ b/src/widgets/sp-color-slider.h @@ -12,7 +12,7 @@ * This code is in public domain */ -#include +#include #include diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 784dd23ad..147c91525 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -2,10 +2,7 @@ # include "config.h" #endif #include -#include -#include -#include -#include +#include #include #include "../dialogs/dialog-events.h" #include "sp-color-wheel-selector.h" diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index 34a5f4cd0..6c8d2d12b 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -2,8 +2,7 @@ #define SEEN_SP_COLOR_WHEEL_SELECTOR_H #include -#include -#include +#include #include "../color.h" #include "sp-color-slider.h" diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index e9f9cfe73..ba6baf972 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -21,7 +21,7 @@ #define SP_IS_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_WIDGET)) #define SP_IS_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_WIDGET)) -#include +#include namespace Inkscape { class Application; diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h index 8e7b844d0..b437cabf0 100644 --- a/src/widgets/sp-xmlview-attr-list.h +++ b/src/widgets/sp-xmlview-attr-list.h @@ -13,7 +13,6 @@ */ #include -#include #include #include "../xml/repr.h" diff --git a/src/widgets/sp-xmlview-content.h b/src/widgets/sp-xmlview-content.h index 3077b2251..7f8a6d3ef 100644 --- a/src/widgets/sp-xmlview-content.h +++ b/src/widgets/sp-xmlview-content.h @@ -16,7 +16,7 @@ #include -#include +#include #include "../xml/repr.h" #include diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index a5dadbb61..89f4af547 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -12,7 +12,7 @@ * Released under the GNU GPL; see COPYING for details */ -#include +#include #include "../xml/repr.h" #include diff --git a/src/widgets/spinbutton-events.h b/src/widgets/spinbutton-events.h index 683748d0a..46652a346 100644 --- a/src/widgets/spinbutton-events.h +++ b/src/widgets/spinbutton-events.h @@ -10,8 +10,7 @@ */ #include -#include /* GtkWidget */ -#include /* GtkObject */ +#include /* GtkWidget */ gboolean spinbutton_focus_in (GtkWidget *w, GdkEventKey *event, gpointer data); void spinbutton_undo (GtkWidget *w); diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h index 9a387454f..443831353 100644 --- a/src/widgets/spw-utilities.h +++ b/src/widgets/spw-utilities.h @@ -19,7 +19,7 @@ */ #include -#include /* GtkWidget */ +#include /* GtkWidget */ #include namespace Gtk { diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index a25705536..0f3ce83c5 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -15,8 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include +#include #include #include "forward.h" -- cgit v1.2.3 From 3638efba5bec8a6afc9211aa6bbe289767d20b38 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 3 Jun 2011 19:45:55 -0700 Subject: Removed outdated/unsafe SP_DOCUMENT_DEFS macro and reduced usage of SP_ROOT() gtk type function/macro. (bzr r10254) --- src/box3d-context.cpp | 2 +- src/box3d-side.cpp | 2 +- src/desktop.cpp | 4 +- src/dialogs/clonetiler.cpp | 1 + src/dialogs/export.cpp | 7 +-- src/dialogs/find.cpp | 1 + src/dialogs/spellcheck.cpp | 1 + src/document-private.h | 2 - src/document.cpp | 62 ++++++++++++------------- src/document.h | 15 +++++- src/extension/internal/cairo-renderer.cpp | 11 ++--- src/extension/internal/filter/filter.cpp | 2 +- src/extension/internal/javafx-out.cpp | 6 +-- src/extension/internal/latex-text-renderer.cpp | 9 ++-- src/extension/internal/latex-text-renderer.h | 3 +- src/extension/internal/pdfinput/svg-builder.cpp | 10 ++-- src/extension/internal/pov-out.cpp | 3 +- src/extension/internal/svg.cpp | 1 + src/extension/param/parameter.cpp | 2 +- src/extension/patheffect.cpp | 2 +- src/file.cpp | 6 +-- src/filter-chemistry.cpp | 8 ++-- src/forward.h | 6 --- src/gradient-chemistry.cpp | 8 ++-- src/helper/stock-items.cpp | 8 ++-- src/id-clash.cpp | 1 + src/live_effects/effect.cpp | 2 +- src/live_effects/lpeobject.cpp | 2 +- src/main.cpp | 2 +- src/marker.cpp | 2 +- src/object-snapper.cpp | 1 + src/persp3d.cpp | 6 +-- src/rdf.cpp | 7 ++- src/selection-chemistry.cpp | 2 +- src/sp-clippath.cpp | 2 +- src/sp-item-group.cpp | 5 +- src/sp-mask.cpp | 2 +- src/sp-metadata.cpp | 3 +- src/sp-namedview.cpp | 5 +- src/sp-object-repr.cpp | 8 +--- src/sp-object-repr.h | 5 +- src/sp-object.cpp | 4 +- src/sp-pattern.cpp | 4 +- src/sp-root.h | 2 + src/ui/clipboard.cpp | 6 +-- src/ui/dialog/align-and-distribute.cpp | 3 +- src/ui/dialog/document-properties.cpp | 12 ++--- src/ui/dialog/find.cpp | 1 + src/ui/dialog/layers.cpp | 7 +-- src/ui/dialog/svg-fonts-dialog.cpp | 4 +- src/ui/dialog/swatches.cpp | 4 +- src/ui/widget/entity-entry.cpp | 9 ++-- src/ui/widget/page-sizer.cpp | 2 +- src/widgets/desktop-widget.cpp | 6 +-- src/widgets/gradient-selector.cpp | 2 +- src/widgets/gradient-toolbar.cpp | 4 +- src/widgets/gradient-vector.cpp | 4 +- src/widgets/stroke-style.cpp | 2 +- 58 files changed, 166 insertions(+), 147 deletions(-) (limited to 'src') diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index f23e4d883..90f1707b9 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -190,7 +190,7 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g * circumstances, after 'vacuum defs' or when a pre-0.46 file is opened). */ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { - SPDefs *defs = reinterpret_cast(SP_DOCUMENT_DEFS(document)); + SPDefs *defs = document->getDefs(); bool has_persp = false; for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 0c74a8f7e..fdbe33222 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -217,7 +217,7 @@ void box3d_side_set_shape (SPShape *shape) { Box3DSide *side = SP_BOX3D_SIDE (shape); - if (!side->document->root) { + if (!side->document->getRoot()) { // avoid a warning caused by sp_document_height() (which is called from sp_item_i2d_affine() below) // when reading a file containing 3D boxes return; diff --git a/src/desktop.cpp b/src/desktop.cpp index 361ed7fea..cfd3dddd0 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -93,6 +93,8 @@ #include "widgets/desktop-widget.h" #include "box3d-context.h" #include "desktop-style.h" +#include "sp-item-group.h" +#include "sp-root.h" // TODO those includes are only for node tool quick zoom. Remove them after fixing it. #include "ui/tool/node-tool.h" @@ -713,7 +715,7 @@ SPDesktop::set_coordinate_status (Geom::Point p) { SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return SPDocument::getItemFromListAtPointBottom(dkey, SP_GROUP (doc()->root), list, p); + return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); } /** diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 40b5f601e..7ad0eaa14 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -46,6 +46,7 @@ #include "../verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "sp-root.h" using Inkscape::DocumentUndo; diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index b05f6589a..4c1ad4af1 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -54,6 +54,7 @@ #include "preferences.h" #include "verbs.h" #include "interface.h" +#include "sp-root.h" #include "extension/output.h" #include "extension/db.h" @@ -784,7 +785,7 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, if ( SP_ACTIVE_DESKTOP ) { SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); if (bbox) { sp_export_set_area (base, bbox->min()[Geom::X], bbox->min()[Geom::Y], @@ -865,7 +866,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) /** \todo * This returns wrong values if the document has a viewBox. */ - bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); + bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); /* If the drawing is valid, then we'll use it and break otherwise we drop through to the page settings */ if (bbox) { @@ -1501,7 +1502,7 @@ sp_export_detect_size(GtkObject * base) { case SELECTION_DRAWING: { SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); // std::cout << "Drawing " << bbox2; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) { diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index c112b3531..4d392a316 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -60,6 +60,7 @@ sp_find_dialog(){ #include "../sp-image.h" #include "../sp-offset.h" #include +#include "sp-root.h" #define MIN_ONSCREEN_DISTANCE 50 diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index f72612420..ecdc0e0ca 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -40,6 +40,7 @@ #include "display/canvas-bpath.h" #include "display/curve.h" #include "document-undo.h" +#include "sp-root.h" #ifdef HAVE_ASPELL #include diff --git a/src/document-private.h b/src/document-private.h index d641679ed..c851594c3 100644 --- a/src/document-private.h +++ b/src/document-private.h @@ -29,8 +29,6 @@ // XXX only for testing! #include "console-output-undo-observer.h" -#define SP_DOCUMENT_DEFS(d) ((SPObject *) SP_ROOT(d->getRoot())->defs) - namespace Inkscape { namespace XML { class Event; diff --git a/src/document.cpp b/src/document.cpp index c9b822ce6..22cfa5663 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -214,6 +214,11 @@ SPDocument::~SPDocument() { //delete this->_whiteboard_session_manager; } +SPDefs *SPDocument::getDefs() +{ + return root->defs; +} + Persp3D * SPDocument::getCurrentPersp3D() { // Check if current_persp3d is still valid @@ -243,8 +248,7 @@ SPDocument::setCurrentPersp3D(Persp3D * const persp) { void SPDocument::getPerspectivesInDefs(std::vector &list) const { - SPDefs *defs = SP_ROOT(this->root)->defs; - for (SPObject *i = defs->firstChild(); i; i = i->getNext() ) { + for (SPObject *i = root->defs->firstChild(); i; i = i->getNext() ) { if (SP_IS_PERSP3D(i)) { list.push_back(SP_PERSP3D(i)); } @@ -348,7 +352,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, rroot->setAttribute("baseProfile", NULL); // creating namedview - if (!sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview")) { + if (!sp_item_group_get_child_by_name(document->root, NULL, "sodipodi:namedview")) { // if there's none in the document already, Inkscape::XML::Node *rnew = NULL; @@ -388,13 +392,12 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, Inkscape::GC::release(rnew); } - /* Defs */ - if (!SP_ROOT(document->root)->defs) { - Inkscape::XML::Node *r; - r = rdoc->createElement("svg:defs"); + // Defs + if (!document->root->defs) { + Inkscape::XML::Node *r = rdoc->createElement("svg:defs"); rroot->addChild(r, NULL); Inkscape::GC::release(r); - g_assert(SP_ROOT(document->root)->defs); + g_assert(document->root->defs); } /* Default RDF */ @@ -520,17 +523,15 @@ gdouble SPDocument::getWidth() const g_return_val_if_fail(this->priv != NULL, 0.0); g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(this->root); - - if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) - return root->viewBox.x1 - root->viewBox.x0; - return root->width.computed; + gdouble result = root->width.computed; + if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { + result = root->viewBox.x1 - root->viewBox.x0; + } + return result; } void SPDocument::setWidth(gdouble width, const SPUnit *unit) { - SPRoot *root = SP_ROOT(this->root); - if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit); } else { // set to width= @@ -555,8 +556,6 @@ void SPDocument::setWidth(gdouble width, const SPUnit *unit) void SPDocument::setHeight(gdouble height, const SPUnit *unit) { - SPRoot *root = SP_ROOT(this->root); - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit); } else { // set to height= @@ -584,11 +583,11 @@ gdouble SPDocument::getHeight() const g_return_val_if_fail(this->priv != NULL, 0.0); g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(this->root); - - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) - return root->viewBox.y1 - root->viewBox.y0; - return root->height.computed; + gdouble result = root->height.computed; + if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { + result = root->viewBox.y1 - root->viewBox.y0; + } + return result; } Geom::Point SPDocument::getDimensions() const @@ -649,7 +648,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) - to_2geom(rect_with_margins.min())); - SP_GROUP(root)->translateChildItems(tr); + root->translateChildItems(tr); if(nv) { Geom::Translate tr2(-rect_with_margins.min()); @@ -922,17 +921,16 @@ void SPDocument::requestModified() } } -void -sp_document_setup_viewport (SPDocument *doc, SPItemCtx *ctx) +void SPDocument::setupViewport(SPItemCtx *ctx) { ctx->ctx.flags = 0; ctx->i2doc = Geom::identity(); - /* Set up viewport in case svg has it defined as percentages */ - if (SP_ROOT(doc->root)->viewBox_set) { // if set, take from viewBox - ctx->vp.x0 = SP_ROOT(doc->root)->viewBox.x0; - ctx->vp.y0 = SP_ROOT(doc->root)->viewBox.y0; - ctx->vp.x1 = SP_ROOT(doc->root)->viewBox.x1; - ctx->vp.y1 = SP_ROOT(doc->root)->viewBox.y1; + // Set up viewport in case svg has it defined as percentages + if (root->viewBox_set) { // if set, take from viewBox + ctx->vp.x0 = root->viewBox.x0; + ctx->vp.y0 = root->viewBox.y0; + ctx->vp.x1 = root->viewBox.x1; + ctx->vp.y1 = root->viewBox.y1; } else { // as a last resort, set size to A4 ctx->vp.x0 = 0.0; ctx->vp.y0 = 0.0; @@ -954,7 +952,7 @@ SPDocument::_updateDocument() if (this->root->uflags || this->root->mflags) { if (this->root->uflags) { SPItemCtx ctx; - sp_document_setup_viewport (this, &ctx); + setupViewport(&ctx); bool saved = DocumentUndo::getUndoSensitive(this); DocumentUndo::setUndoSensitive(this, false); diff --git a/src/document.h b/src/document.h index 2eb5e2e09..e3c70b2c6 100644 --- a/src/document.h +++ b/src/document.h @@ -44,6 +44,7 @@ struct SPDesktop; struct SPItem; struct SPObject; struct SPGroup; +struct SPRoot; namespace Inkscape { struct Application; @@ -57,9 +58,11 @@ namespace Inkscape { } } +class SPDefs; class SP3DBox; class Persp3D; class Persp3DImpl; +class SPItemCtx; namespace Proj { class TransfMat3x4; @@ -72,6 +75,8 @@ class SPDocument : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, public Inkscape::GC::Anchored { +// Note: multiple public and private sections is not a good practice, but happens +// in this class as transitional to fixing encapsulation: public: typedef sigc::signal IDChangedSignal; typedef sigc::signal ResourcesChangedSignal; @@ -91,7 +96,9 @@ public: Inkscape::XML::Document *rdoc; ///< Our Inkscape::XML::Document Inkscape::XML::Node *rroot; ///< Root element of Inkscape::XML::Document - SPObject *root; ///< Our SPRoot +private: + SPRoot *root; ///< Our SPRoot +public: CRCascade *style_cascade; protected: @@ -122,7 +129,7 @@ public: bool oldSignalsConnected; /** Returns our SPRoot */ - SPObject *getRoot() { return root; } + SPRoot *getRoot() { return root; } Inkscape::XML::Node *getReprRoot() { return rroot; } @@ -141,6 +148,9 @@ public: /** basename(uri) or other human-readable label for the document. */ gchar const* getName() const { return name; } + /** Return the main defs object for the document. */ + SPDefs *getDefs(); + void setCurrentPersp3D(Persp3D * const persp); inline void setCurrentPersp3DImpl(Persp3DImpl * const persp_impl) { current_persp3d_impl = persp_impl; } @@ -248,6 +258,7 @@ public: private: void do_change_uri(gchar const *const filename, bool const rebase); + void setupViewport(SPItemCtx *ctx); }; struct SPUnit; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index f5504d755..bbafd7e94 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -420,19 +420,18 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) ctx->popState(); } -static void sp_root_render(SPItem *item, CairoRenderContext *ctx) +static void sp_root_render(SPRoot *root, CairoRenderContext *ctx) { - SPRoot *root = SP_ROOT(item); CairoRenderer *renderer = ctx->getRenderer(); - if (!ctx->getCurrentState()->has_overflow && item->parent) + if (!ctx->getCurrentState()->has_overflow && root->parent) ctx->addClippingRect(root->x.computed, root->y.computed, root->width.computed, root->height.computed); ctx->pushState(); - renderer->setStateForItem(ctx, item); + renderer->setStateForItem(ctx, root); Geom::Affine tempmat (root->c2p); ctx->transform(&tempmat); - sp_group_render(item, ctx); + sp_group_render(root, ctx); ctx->popState(); } @@ -543,7 +542,7 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) if (SP_IS_ROOT(item)) { TRACE(("root\n")); - return sp_root_render(item, ctx); + return sp_root_render(SP_ROOT(item), ctx); } else if (SP_IS_SYMBOL(item)) { TRACE(("symbol\n")); return sp_symbol_render(item, ctx); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 715278051..fb8d4de4b 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -133,7 +133,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d items.insert >(items.end(), selection->itemList(), NULL); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); - Inkscape::XML::Node * defsrepr = SP_DOCUMENT_DEFS(document->doc())->getRepr(); + Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); for(std::list::iterator item = items.begin(); item != items.end(); item++) { diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 750849eb1..8399d602f 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -38,7 +38,7 @@ #include "helper/geom.h" #include "helper/geom-curves.h" #include - +#include "sp-root.h" #include #include @@ -758,7 +758,7 @@ bool JavaFXOutput::doTree(SPDocument *doc) miny = bignum; maxy = -bignum; - if (!doTreeRecursive(doc, doc->root)) { + if (!doTreeRecursive(doc, doc->getRoot())) { return false; } @@ -875,7 +875,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) out(" content: [\n"); idindex = 0; - doBody(doc, doc->root); + doBody(doc, doc->getRoot()); if (!doTail()) { return false; diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 98142632d..cf7c48251 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -542,13 +542,10 @@ Flowing in rectangle is possible, not in arb shape. fprintf(_stream, "%s", os.str().c_str()); } -void -LaTeXTextRenderer::sp_root_render(SPItem *item) +void LaTeXTextRenderer::sp_root_render(SPRoot *root) { - SPRoot *root = SP_ROOT(item); - push_transform(root->c2p); - sp_group_render(item); + sp_group_render(root); pop_transform(); } @@ -561,7 +558,7 @@ LaTeXTextRenderer::sp_item_invoke_render(SPItem *item) } if (SP_IS_ROOT(item)) { - return sp_root_render(item); + return sp_root_render(SP_ROOT(item)); } else if (SP_IS_GROUP(item)) { return sp_group_render(item); } else if (SP_IS_USE(item)) { diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h index 2259427d6..66055a3bc 100644 --- a/src/extension/internal/latex-text-renderer.h +++ b/src/extension/internal/latex-text-renderer.h @@ -22,6 +22,7 @@ #include class SPItem; +struct SPRoot; namespace Inkscape { namespace Extension { @@ -60,7 +61,7 @@ protected: void writePostamble(); void sp_item_invoke_render(SPItem *item); - void sp_root_render(SPItem *item); + void sp_root_render(SPRoot *item); void sp_group_render(SPItem *item); void sp_use_render(SPItem *item); void sp_text_render(SPItem *item); diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 94edf826e..dc995b7aa 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -531,7 +531,7 @@ void SvgBuilder::setClipPath(GfxState *state, bool even_odd) { clip_path->appendChild(path); Inkscape::GC::release(path); // Append clipPath to defs and get id - SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(clip_path); + _doc->getDefs()->getRepr()->appendChild(clip_path); gchar *urltext = g_strdup_printf ("url(#%s)", clip_path->attribute("id")); Inkscape::GC::release(clip_path); _container->setAttribute("clip-path", urltext); @@ -678,7 +678,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern, delete pattern_builder; // Append the pattern to defs - SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(pattern_node); + _doc->getDefs()->getRepr()->appendChild(pattern_node); gchar *id = g_strdup(pattern_node->attribute("id")); Inkscape::GC::release(pattern_node); @@ -752,7 +752,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for return NULL; } - Inkscape::XML::Node *defs = SP_DOCUMENT_DEFS(_doc)->getRepr(); + Inkscape::XML::Node *defs = _doc->getDefs()->getRepr(); defs->appendChild(gradient); gchar *id = g_strdup(gradient->attribute("id")); Inkscape::GC::release(gradient); @@ -1635,9 +1635,9 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) { sp_repr_set_svg_double(mask_node, "height", height); // Append mask to defs if (_is_top_level) { - SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(mask_node); + _doc->getDefs()->getRepr()->appendChild(mask_node); Inkscape::GC::release(mask_node); - return SP_DOCUMENT_DEFS(_doc)->getRepr()->lastChild(); + return _doc->getDefs()->getRepr()->lastChild(); } else { // Work around for renderer bug when mask isn't defined in pattern static int mask_count = 0; Inkscape::XML::Node *defs = _root->firstChild(); diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 1563d04c1..382f8cbfb 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -35,6 +35,7 @@ #include "helper/geom.h" #include "helper/geom-curves.h" #include +#include "sp-root.h" #include #include @@ -485,7 +486,7 @@ bool PovOutput::doTree(SPDocument *doc) miny = bignum; maxy = -bignum; - if (!doTreeRecursive(doc, doc->root)) + if (!doTreeRecursive(doc, doc->getRoot())) return false; //## Let's make a union of all of the Shapes diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 946ff22fe..afc706e89 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -24,6 +24,7 @@ #include "extension/output.h" #include #include "xml/attribute-record.h" +#include "sp-root.h" #ifdef WITH_GNOME_VFS # include diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index fb53035a1..455fcc3bb 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -354,7 +354,7 @@ Parameter::new_child (Inkscape::XML::Node * parent) Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr(); + Inkscape::XML::Node * defs = doc->getDefs()->getRepr(); Inkscape::XML::Node * params = NULL; GQuark const name_quark = g_quark_from_string("inkscape:extension-params"); diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index 09ee9be0b..6da310d30 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -42,7 +42,7 @@ PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path) return; gchar ** patheffects = g_strsplit(patheffectlist, ";", 128); - Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr(); + Inkscape::XML::Node * defs = doc->getDefs()->getRepr(); for (int i = 0; patheffects[i] != NULL && i < 128; i++) { gchar * patheffect = patheffects[i]; diff --git a/src/file.cpp b/src/file.cpp index a1fc23117..2e7e74610 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -802,7 +802,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens } else { dialog_title = (char const *) _("Select file to save to"); } - gchar* doc_title = doc->root->title(); + gchar* doc_title = doc->getRoot()->title(); Inkscape::UI::Dialog::FileSaveDialog *saveDialog = Inkscape::UI::Dialog::FileSaveDialog::create( parentWindow, @@ -975,7 +975,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, prevent_id_clashes(doc, in_doc); - SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc); + SPObject *in_defs = in_doc->getDefs(); Inkscape::XML::Node *last_def = in_defs->getRepr()->lastChild(); SPCSSAttr *style = sp_css_attr_from_object(doc->getRoot()); @@ -1051,7 +1051,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // preserve parent and viewBox transformations // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); - Geom::Affine affine = SP_ROOT(doc->getRoot())->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); + Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index b2c5f3020..18a31f0d7 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -90,7 +90,7 @@ SPFilter *new_filter(SPDocument *document) { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -187,7 +187,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -242,7 +242,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -356,7 +356,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it // If there are more users for this filter, duplicate it if (filter->hrefcount > count_filter_hrefs(item, filter)) { Inkscape::XML::Node *repr = item->style->getFilter()->getRepr()->duplicate(xml_doc); - SPDefs *defs = reinterpret_cast(SP_DOCUMENT_DEFS(document)); + SPDefs *defs = document->getDefs(); defs->appendChild(repr); filter = SP_FILTER( document->getObjectByRepr(repr) ); diff --git a/src/forward.h b/src/forward.h index 897f3fe48..352fae6fa 100644 --- a/src/forward.h +++ b/src/forward.h @@ -52,12 +52,6 @@ class SPDocumentClass; class SPGroup; class SPGroupClass; -class SPDefs; -class SPDefsClass; - -class SPRoot; -class SPRootClass; - class SPNamedView; class SPNamedViewClass; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 86b63855b..889e319b2 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -106,7 +106,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr g_return_val_if_fail(SP_IS_GRADIENT(vector), NULL); g_return_val_if_fail(vector->hasStops(), NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new private gradient of the requested type @@ -208,7 +208,7 @@ SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *ve } SPDocument *doc = gr->document; - SPObject *defs = SP_DOCUMENT_DEFS(doc); + SPObject *defs = doc->getDefs(); if ((gr->hasStops()) || (gr->state != SP_GRADIENT_STATE_UNKNOWN) || @@ -259,7 +259,7 @@ SPGradient *sp_gradient_fork_vector_if_necessary(SPGradient *gr) Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = gr->getRepr()->duplicate(xml_doc); - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); + doc->getDefs()->getRepr()->addChild(repr, NULL); SPGradient *gr_new = (SPGradient *) doc->getObjectByRepr(repr); gr_new = sp_gradient_ensure_vector_normalized (gr_new); Inkscape::GC::release(repr); @@ -1198,7 +1198,7 @@ static void addStop( Inkscape::XML::Node *parent, Glib::ustring const &color, gi */ SPGradient *sp_document_default_gradient_vector( SPDocument *document, SPColor const &color, bool singleStop ) { - SPDefs *defs = static_cast(SP_DOCUMENT_DEFS(document)); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->rdoc; Inkscape::XML::Node *repr = xml_doc->createElement("svg:linearGradient"); diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 9f3f172ac..96454cf3a 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -69,7 +69,7 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current /* Get the marker we want */ SPObject *object = doc->getObjectById(name); if (object && SP_IS_MARKER(object)) { - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); + SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *mark_repr = object->getRepr()->duplicate(xml_doc); defs->getRepr()->addChild(mark_repr, NULL); @@ -113,7 +113,7 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) /* Get the pattern we want */ SPObject *object = doc->getObjectById(name); if (object && SP_IS_PATTERN(object)) { - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); + SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = object->getRepr()->duplicate(xml_doc); defs->getRepr()->addChild(pat_repr, NULL); @@ -156,7 +156,7 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) /* Get the gradient we want */ SPObject *object = doc->getObjectById(name); if (object && SP_IS_GRADIENT(object)) { - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); + SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = object->getRepr()->duplicate(xml_doc); defs->getRepr()->addChild(pat_repr, NULL); @@ -195,7 +195,7 @@ SPObject *get_stock_item(gchar const *urn) SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); - SPDefs *defs = reinterpret_cast(SP_DOCUMENT_DEFS(doc)); + SPDefs *defs = doc->getDefs(); SPObject *object = NULL; if (!strcmp(base, "marker")) { diff --git a/src/id-clash.cpp b/src/id-clash.cpp index d305b5a9f..d5740c0ba 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -25,6 +25,7 @@ #include "sp-paint-server.h" #include "xml/node.h" #include "xml/repr.h" +#include "sp-root.h" typedef enum { REF_HREF, REF_STYLE, REF_URL, REF_CLIPBOARD } ID_REF_TYPE; diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index ed0d162ac..10abef4a1 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -262,7 +262,7 @@ void Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item) Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); repr->setAttribute("effect", name); - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); // adds to and assigns the 'id' attribute + doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to and assigns the 'id' attribute const gchar * repr_id = repr->attribute("id"); Inkscape::GC::release(repr); diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 1b5ed1d49..3e4e40198 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -253,7 +253,7 @@ LivePathEffectObject *LivePathEffectObject::fork_private_if_necessary(unsigned i Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *dup_repr = this->getRepr()->duplicate(xml_doc); - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(dup_repr, NULL); + doc->getDefs()->getRepr()->addChild(dup_repr, NULL); LivePathEffectObject *lpeobj_new = LIVEPATHEFFECT( doc->getObjectByRepr(dup_repr) ); Inkscape::GC::release(dup_repr); diff --git a/src/main.cpp b/src/main.cpp index ac0994be6..82a4b28c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1353,7 +1353,7 @@ sp_do_export_png(SPDocument *doc) } else if (sp_export_area_page || !(sp_export_id || sp_export_area_drawing)) { /* Export the whole page: note: Inkscape uses 'page' in all menus and dialogs, not 'canvas' */ doc->ensureUpToDate(); - Geom::Point origin (SP_ROOT(doc->root)->x.computed, SP_ROOT(doc->root)->y.computed); + Geom::Point origin(doc->getRoot()->x.computed, doc->getRoot()->y.computed); area = Geom::Rect(origin, origin + doc->getDimensions()); } diff --git a/src/marker.cpp b/src/marker.cpp index faffadd58..5dd23fb1e 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -713,7 +713,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine /*transform*/, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:marker"); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 1e2f71c95..682c26869 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -36,6 +36,7 @@ #include "sp-mask.h" #include "helper/geom-curves.h" #include "desktop.h" +#include "sp-root.h" Inkscape::ObjectSnapper::ObjectSnapper(SnapManager *sm, Geom::Coord const d) : Snapper(sm, d) diff --git a/src/persp3d.cpp b/src/persp3d.cpp index d43e6b2c5..0b346622a 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -209,7 +209,7 @@ persp3d_update(SPObject *object, SPCtx *ctx, guint flags) } Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// if dup is given, copy the attributes over - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr; @@ -253,7 +253,7 @@ Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// Persp3D *persp3d_document_first_persp(SPDocument *document) { Persp3D *first = 0; - for ( SPObject *child = SP_DOCUMENT_DEFS(document)->firstChild(); child && !first; child = child->getNext() ) { + for ( SPObject *child = document->getDefs()->firstChild(); child && !first; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { first = SP_PERSP3D(child); } @@ -565,7 +565,7 @@ persp3d_print_debugging_info (Persp3D *persp) { void persp3d_print_debugging_info_all(SPDocument *document) { - for ( SPObject *child = SP_DOCUMENT_DEFS(document)->firstChild(); child; child = child->getNext() ) { + for ( SPObject *child = document->getDefs()->firstChild(); child; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { persp3d_print_debugging_info(SP_PERSP3D(child)); } diff --git a/src/rdf.cpp b/src/rdf.cpp index c9378cf53..cabbaaed3 100644 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@ -18,6 +18,7 @@ #include "rdf.h" #include "sp-item-group.h" #include "inkscape.h" +#include "sp-root.h" /* Example RDF XML from various places... @@ -566,7 +567,9 @@ unsigned int RDFImpl::setReprText( Inkscape::XML::Node * repr, // set document's title element to the RDF title if (!strcmp(entity.name, "title")) { SPDocument *doc = SP_ACTIVE_DOCUMENT; - if(doc && doc->root) doc->root->setTitle(text); + if (doc && doc->getRoot()) { + doc->getRoot()->setTitle(text); + } } switch (entity.datatype) { @@ -1104,7 +1107,7 @@ void RDFImpl::setDefaults( SPDocument * doc ) g_assert( doc != NULL ); // Create metadata node if it doesn't already exist - if (!sp_item_group_get_child_by_name((SPGroup *) doc->root, NULL, + if (!sp_item_group_get_child_by_name( doc->getRoot(), NULL, XML_TAG_NAME_METADATA)) { if ( !doc->getReprDoc()) { g_critical("XML doc is null."); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 67aba5218..0f756a9a3 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3234,7 +3234,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) g_return_val_if_fail(doc != NULL, false); doc->ensureUpToDate(); - SPItem const *const root = SP_ITEM(doc->root); + SPItem const *const root = doc->getRoot(); Geom::OptRect const bbox(root->getBounds(root->i2d_affine(), SPItem::RENDERING_BBOX)); if (bbox) { doc->fitToRect(*bbox, with_margins); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index be5b9a4d1..89e140f12 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -357,7 +357,7 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view) // Create a mask element (using passed elements), add it to const gchar *SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform) { - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath"); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index a31961d2e..91342688a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -49,6 +49,7 @@ #include "sp-title.h" #include "sp-desc.h" #include "sp-switch.h" +#include "sp-defs.h" using Inkscape::DocumentUndo; @@ -345,8 +346,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) g_return_if_fail (SP_IS_GROUP (group)); SPDocument *doc = group->document; - SPObject *root = doc->getRoot(); - SPObject *defs = SP_OBJECT(SP_ROOT(root)->defs); + SPRoot *root = doc->getRoot(); + SPObject *defs = root->defs; SPItem *gitem = SP_ITEM (group); Inkscape::XML::Node *grepr = gitem->getRepr(); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 700efa572..513e52911 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -268,7 +268,7 @@ sp_mask_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML const gchar * sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform) { - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:mask"); diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 21410d4fd..84dc114db 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -20,6 +20,7 @@ #include "document.h" #include "sp-item-group.h" +#include "sp-root.h" #define noDEBUG_METADATA #ifdef DEBUG_METADATA @@ -213,7 +214,7 @@ sp_document_metadata (SPDocument *document) g_return_val_if_fail (document != NULL, NULL); - nv = sp_item_group_get_child_by_name ((SPGroup *) document->root, NULL, + nv = sp_item_group_get_child_by_name( document->getRoot(), NULL, "metadata"); g_assert (nv != NULL); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 001f7731f..1feb644ad 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -34,6 +34,7 @@ #include "preferences.h" #include "desktop.h" #include "conn-avoid-ref.h" // for defaultConnSpacing. +#include "sp-root.h" using Inkscape::DocumentUndo; @@ -1013,7 +1014,7 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) { g_return_val_if_fail(document != NULL, NULL); - SPObject *nv = sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview"); + SPObject *nv = sp_item_group_get_child_by_name(document->getRoot(), NULL, "sodipodi:namedview"); g_assert(nv != NULL); if (id == NULL) { @@ -1021,7 +1022,7 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) } while (nv && strcmp(nv->getId(), id)) { - nv = sp_item_group_get_child_by_name((SPGroup *) document->root, nv, "sodipodi:namedview"); + nv = sp_item_group_get_child_by_name(document->getRoot(), nv, "sodipodi:namedview"); } return (SPNamedView *) nv; diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 475a57521..a995739b1 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -89,11 +89,7 @@ static unsigned const N_NAME_TYPES = SODIPODI_TYPE + 1; static GType name_to_gtype(NameType name_type, gchar const *name); -/** - * Construct an SPRoot and all its descendents from the given repr. - */ -SPObject * -sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) +SPRoot *sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) { g_assert(document != NULL); g_assert(repr != NULL); @@ -108,7 +104,7 @@ sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) g_assert(object != NULL); object->invoke_build(document, repr, FALSE); - return object; + return SP_ROOT(object); } GType diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h index 02ad3ea93..407af0bcc 100644 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@ -21,7 +21,10 @@ class Node; } -SPObject * sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr); +/** + * Construct an SPRoot and all its descendents from the given repr. + */ +SPRoot *sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr); GType sp_repr_type_lookup (Inkscape::XML::Node *repr); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index c37e48983..e0b3e3201 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1604,9 +1604,9 @@ gchar const * SPObject::getStyleProperty(gchar const *key, gchar const *def) con */ void SPObject::_requireSVGVersion(Inkscape::Version version) { for ( SPObject::ParentIterator iter=this ; iter ; ++iter ) { - SPObject *object=iter; + SPObject *object = iter; if (SP_IS_ROOT(object)) { - SPRoot *root=SP_ROOT(object); + SPRoot *root = SP_ROOT(object); if ( root->version.svg < version ) { root->version.svg = version; } diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 0b2fe8389..d7522fce8 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -469,7 +469,7 @@ SPPattern *pattern_chain(SPPattern *pattern) { SPDocument *document = pattern->document; Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("inkscape:collect", "always"); @@ -522,7 +522,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("patternUnits", "userSpaceOnUse"); diff --git a/src/sp-root.h b/src/sp-root.h index ab379fb50..86b92b2b3 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -25,6 +25,8 @@ #include "enums.h" #include "sp-item-group.h" +class SPDefs; + /** \ element */ struct SPRoot : public SPGroup { struct { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 4f4f8a022..60379a966 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -894,7 +894,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) SPDocument *target_document = sp_desktop_document(desktop); Inkscape::XML::Node *root = clipdoc->getReprRoot(); Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); - Inkscape::XML::Node *target_defs = SP_DOCUMENT_DEFS(target_document)->getRepr(); + Inkscape::XML::Node *target_defs = target_document->getDefs()->getRepr(); Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); prevent_id_clashes(clipdoc, target_document); @@ -1197,7 +1197,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) gdouble dpi = PX_PER_IN; guint32 bgcolor = 0x00000000; - Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed); + Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); @@ -1254,7 +1254,7 @@ void ClipboardManagerImpl::_createInternalClipboard() if ( _clipboardSPDoc == NULL ) { _clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); - _defs = SP_DOCUMENT_DEFS(_clipboardSPDoc)->getRepr(); + _defs = _clipboardSPDoc->getDefs()->getRepr(); _doc = _clipboardSPDoc->getReprDoc(); _root = _clipboardSPDoc->getReprRoot(); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 81e2b64a9..a2169c0b3 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -43,6 +43,7 @@ #include "util/glib-list-iterators.h" #include "verbs.h" #include "widgets/icon.h" +#include "sp-root.h" #include "align-and-distribute.h" @@ -171,7 +172,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = static_cast( sp_desktop_document(desktop)->getRoot() )->getBboxDesktop(); + Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->getBboxDesktop(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0c001da4b..b2ca2a3a8 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -145,7 +145,7 @@ DocumentProperties::init() Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->addListener (&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->addListener (&_repr_events, this); show_all_children(); @@ -156,7 +156,7 @@ DocumentProperties::~DocumentProperties() { Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->removeListenerByData (this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->removeListenerByData (this); } @@ -421,7 +421,7 @@ DocumentProperties::linkSelectedProfile() xml_doc->root()->addChild(defsRepr, NULL); } - g_assert(SP_ROOT(desktop->doc()->root)->defs); + g_assert(desktop->doc()->getDefs()); defsRepr->addChild(cprofRepr, NULL); // TODO check if this next line was sometimes needed. It being there caused an assertion. @@ -877,7 +877,7 @@ DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *docu { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = document->root->getRepr(); + Inkscape::XML::Node *root = document->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } @@ -887,7 +887,7 @@ DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *d { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } @@ -897,7 +897,7 @@ DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->removeListenerByData(this); } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index bdae14c62..aa6b4081e 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -50,6 +50,7 @@ #include "sp-use.h" #include "sp-image.h" #include "sp-offset.h" +#include "sp-root.h" #include "xml/repr.h" diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 0eca5bbca..30924ab86 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -35,6 +35,7 @@ #include "verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "sp-root.h" #include "layers.h" @@ -293,7 +294,7 @@ bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::Tre } void LayersPanel::_selectLayer( SPObject *layer ) { - if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->root)) ) { + if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->getRoot())) ) { if ( _tree.get_selection()->count_selected_rows() != 0 ) { _tree.get_selection()->unselect_all(); } @@ -328,7 +329,7 @@ void LayersPanel::_layersChanged() // g_message("_layersChanged()"); if (_desktop) { SPDocument* document = _desktop->doc(); - SPObject* root = document->root; + SPRoot* root = document->getRoot(); if ( root ) { _selectedConnection.block(); if ( _desktop->layer_manager && _desktop->layer_manager->includes( root ) ) { @@ -402,7 +403,7 @@ void LayersPanel::_pushTreeSelectionToCurrent() _desktop->layer_manager->setCurrentLayer( inTree ); } } else { - _desktop->layer_manager->setCurrentLayer( _desktop->doc()->root ); + _desktop->layer_manager->setCurrentLayer( _desktop->doc()->getRoot() ); } } } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 4d53154d8..fbca0bf10 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -794,7 +794,7 @@ SPFont *new_font(SPDocument *document) { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -911,7 +911,7 @@ SvgFontsDialog::SvgFontsDialog() _FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release)); create_fonts_popup_menu(_FontsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_font)); - _defs_observer.set(SP_DOCUMENT_DEFS(sp_desktop_document(this->getDesktop()))); + _defs_observer.set(sp_desktop_document(this->getDesktop())->getDefs()); _defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts)); _getContents()->show_all(); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 935fe9806..0f4626126 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -858,8 +858,8 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) docPerPanel[panel] = document; if (!found) { sigc::connection conn1 = document->connectResourcesChanged( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); - sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); - sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); + sigc::connection conn2 = document->getDefs()->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); + sigc::connection conn3 = document->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); DocTrack *dt = new DocTrack(document, conn1, conn2, conn3); docTrackings.push_back(dt); diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index e191a9360..e62eb009c 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -25,6 +25,7 @@ #include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" +#include "sp-root.h" #include "entity-entry.h" @@ -87,8 +88,8 @@ void EntityLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); // If RDF title is not set, get the document's and set the RDF: - if ( !text && !strcmp(_entity->name, "title") && doc->root ) { - text = doc->root->title(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } static_cast<Gtk::Entry*>(_packable)->set_text (text ? text : ""); @@ -133,8 +134,8 @@ void EntityMultiLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); // If RDF title is not set, get the document's <title> and set the RDF: - if ( !text && !strcmp(_entity->name, "title") && doc->root ) { - text = doc->root->title(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index f306b9eea..672e1415b 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -422,7 +422,7 @@ PageSizer::setDim (double w, double h, bool changeList) // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); - SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset); + doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 87ce9053f..9f0367665 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -58,6 +58,7 @@ #include "ui/widget/selected-style.h" #include "ui/uxmanager.h" #include "util/ege-appear-time-tracker.h" +#include "sp-root.h" // We're in the "widgets" directory, so no need to explicitly prefix these: #include "button.h" @@ -1888,9 +1889,8 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) SPDocument *doc = dtw->desktop->doc(); Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()), Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) ); - SPObject* root = doc->root; - SPItem* item = SP_ITEM(root); - Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop()); + + Geom::OptRect deskarea = Geom::unify(darea, doc->getRoot()->getBboxDesktop()); /* Canvas region we always show unconditionally */ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64), diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index f7a981c9f..9b1664ac3 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -360,7 +360,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s Inkscape::GC::release(stop); } - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); + doc->getDefs()->getRepr()->addChild(repr, NULL); gr = (SPGradient *) doc->getObjectByRepr(repr); sp_gradient_vector_selector_set_gradient( diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index e7596ead4..64ed1e309 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -521,9 +521,9 @@ GtkWidget * gr_change_widget(SPDesktop *desktop) // connect to release and modified signals of the defs (i.e. when someone changes gradient) sigc::connection *release_connection = new sigc::connection(); - *release_connection = SP_DOCUMENT_DEFS(document)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), widget)); + *release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), widget)); sigc::connection *modified_connection = new sigc::connection(); - *modified_connection = SP_DOCUMENT_DEFS(document)->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), widget)); + *modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), widget)); // when widget is destroyed, disconnect g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(gr_disconnect_sigc), release_connection); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 839ddf67c..8ef0ee313 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -204,8 +204,8 @@ void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPD // Connect signals if (doc) { - gvs->defs_release_connection = SP_DOCUMENT_DEFS(doc)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs)); - gvs->defs_modified_connection = SP_DOCUMENT_DEFS(doc)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs)); + gvs->defs_release_connection = doc->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs)); + gvs->defs_modified_connection = doc->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs)); } if (gr) { gvs->gradient_release_connection = gr->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs)); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 99d8228c8..d2b280e44 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -225,7 +225,7 @@ ink_marker_list_get (SPDocument *source) return NULL; GSList *ml = NULL; - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source); + SPDefs *defs = source->getDefs(); for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_IS_MARKER(child)) { -- cgit v1.2.3 From 0be32d46f7e5ca3b4f4fc6c5f7f19b110b948551 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde <jasper.vandegronde@gmail.com> Date: Sat, 4 Jun 2011 16:16:57 +0200 Subject: Fixed font problem on win32. (bzr r9508.1.87) --- src/libnrtype/FontInstance.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 7dc8bb859..1b65dd88c 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -557,13 +557,19 @@ void font_instance::LoadGlyph(int glyph_id) break; case TT_PRIM_QSPLINE: - //g_assert(polyCurve->cpfx % 2 == 0); - if (polyCurve->cpfx % 2 != 0) return; - - while ( p != endp ) { - path_builder.quadTo(pointfx_to_nrpoint(p[0], scale), - pointfx_to_nrpoint(p[1], scale)); - p += 2; + { + g_assert(polyCurve->cpfx >= 2); + + // The list of points specifies one or more control points and ends with the end point. + // The intermediate points (on the curve) are the points between the control points. + Geom::Point this_control = pointfx_to_nrpoint(*p++, scale); + while ( p+1 != endp ) { // Process all "midpoints" (all points except the last) + Geom::Point new_control = pointfx_to_nrpoint(*p++, scale); + path_builder.quadTo(this_control, (new_control+this_control)/2); + this_control = new_control; + } + Geom::Point end = pointfx_to_nrpoint(*p++, scale); + path_builder.quadTo(this_control, end); } break; -- cgit v1.2.3 From 884cb98ee0fbc0e883ff0a4f2bda43e2c8803312 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sat, 4 Jun 2011 15:33:05 -0700 Subject: Possible Win32 compile fix. (bzr r10256) --- src/extension/internal/emf-win32-inout.cpp | 3 ++- src/extension/internal/emf-win32-print.cpp | 3 ++- src/ui/dialog/filedialogimpl-win32.cpp | 37 ++++++++++++++++-------------- 3 files changed, 24 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 8aa26a213..2d97174b1 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -28,6 +28,7 @@ #endif //#include "inkscape.h" +#include "sp-root.h" #include "sp-path.h" #include "style.h" //#include "color.h" @@ -126,7 +127,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename) context.module = mod; /* fixme: This has to go into module constructor somehow */ /* Create new arena */ - mod->base = SP_ITEM(doc->getRoot()); + mod->base = doc->getRoot(); mod->arena = NRArena::create(); mod->dkey = SPItem::display_key_new(1); mod->root = mod->base->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 9662881fe..38db43091 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -50,6 +50,7 @@ #include "style.h" //#include "sp-paint-server.h" #include "inkscape-version.h" +#include "sp-root.h" //#include "libnrtype/FontFactory.h" //#include "libnrtype/font-instance.h" @@ -146,7 +147,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) d.x1 = _width; d.y1 = _height; } else { - SPItem* doc_item = SP_ITEM(doc->getRoot()); + SPItem* doc_item = doc->getRoot(); doc_item->invoke_bbox(&d, doc_item->i2d_affine(), TRUE); } diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 4f0978c05..09c3d0a52 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -43,6 +43,7 @@ #include "filedialog.h" #include "filedialogimpl-win32.h" +#include "sp-root.h" #include <zlib.h> #include <cairomm/win32_surface.h> @@ -409,7 +410,7 @@ void FileOpenDialogImplWin32::createFilterMenu() *(filterptr++) = L'\0'; _filter_count = extension_index; - _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd + _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd } void FileOpenDialogImplWin32::GetOpenFileName_thread() @@ -421,7 +422,7 @@ void FileOpenDialogImplWin32::GetOpenFileName_thread() WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( _current_directory.data(), _current_directory.length(), - NULL, NULL, NULL); + NULL, NULL, NULL); memset(&ofn, 0, sizeof(ofn)); @@ -962,8 +963,10 @@ bool FileOpenDialogImplWin32::set_svg_preview() g_free(utf8string); // Check the document loaded properly - if(svgDoc == NULL) return false; - if(svgDoc->root == NULL) + if (svgDoc == NULL) { + return false; + } + if (svgDoc->getRoot() == NULL) { svgDoc->doUnref(); return false; @@ -989,14 +992,14 @@ bool FileOpenDialogImplWin32::set_svg_preview() // write object bbox to area Geom::OptRect maybeArea(area); svgDoc->ensureUpToDate(); - static_cast<SPItem *>(svgDoc->root)->invoke_bbox( maybeArea, - static_cast<SPItem *>(svgDoc->root)->i2d_affine(), TRUE); + svgDoc->getRoot()->invoke_bbox( maybeArea, + svgDoc->getRoot()->i2d_affine(), TRUE); NRArena *const arena = NRArena::create(); unsigned const key = SPItem::display_key_new(1); - NRArenaItem *root = static_cast<SPItem*>(svgDoc->root)->invoke_show( + NRArenaItem *root = svgDoc->getRoot()->invoke_show( arena, key, SP_ITEM_SHOW_DISPLAY); NRGC gc(NULL); @@ -1033,7 +1036,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() // Tidy up svgDoc->doUnref(); - static_cast<SPItem*>(svgDoc->root)->invoke_hide(key); + svgDoc->getRoot()->invoke_hide(key); nr_object_unref((NRObject *) arena); // Create the GDK pixbuf @@ -1666,7 +1669,7 @@ void FileSaveDialogImplWin32::createFilterMenu() *(filterptr++) = 0; _filter_count = extension_index; - _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd + _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd } void FileSaveDialogImplWin32::GetSaveFileName_thread() @@ -1678,7 +1681,7 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( _current_directory.data(), _current_directory.length(), - NULL, NULL, NULL); + NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 memset(_path_string, 0, sizeof(_path_string)); @@ -1730,14 +1733,14 @@ FileSaveDialogImplWin32::show() _result = false; _main_loop = g_main_loop_new(g_main_context_default(), FALSE); - if(_main_loop != NULL) - { - if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) - g_main_loop_run(_main_loop); + if(_main_loop != NULL) + { + if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) + g_main_loop_run(_main_loop); - if(_result) - appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); - } + if(_result) + appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); + } return _result; } -- cgit v1.2.3 From f2510631aadaae48e040a1dd0f9bc8b4de6f2054 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Sun, 5 Jun 2011 14:22:18 +0100 Subject: Replace use of deprecated GtkTooltips API Fixed bugs: - https://launchpad.net/bugs/793086 (bzr r10256.1.1) --- src/dialogs/clonetiler.cpp | 203 ++++++++++++++------------------ src/dialogs/export.cpp | 8 +- src/dialogs/find.cpp | 64 +++++----- src/dialogs/item-properties.cpp | 10 +- src/dialogs/spellcheck.cpp | 18 ++- src/dialogs/text-edit.cpp | 14 +-- src/dialogs/xml-tree.cpp | 22 ++-- src/ege-adjustment-action.cpp | 7 +- src/ege-select-one-action.cpp | 4 +- src/libgdl/gdl-dock-bar.c | 11 +- src/libgdl/gdl-dock-item-grip.c | 17 +-- src/libgdl/gdl-switcher.c | 19 +-- src/widgets/button.cpp | 34 ++---- src/widgets/button.h | 6 +- src/widgets/desktop-widget.cpp | 21 ++-- src/widgets/desktop-widget.h | 2 - src/widgets/gradient-selector.cpp | 5 +- src/widgets/gradient-toolbar.cpp | 18 +-- src/widgets/gradient-vector.cpp | 5 +- src/widgets/paint-selector.cpp | 26 ++-- src/widgets/sp-color-icc-selector.cpp | 23 ++-- src/widgets/sp-color-icc-selector.h | 2 - src/widgets/sp-color-notebook.cpp | 13 +- src/widgets/sp-color-scales.cpp | 54 ++++----- src/widgets/sp-color-scales.h | 2 - src/widgets/sp-color-wheel-selector.cpp | 6 +- src/widgets/sp-color-wheel-selector.h | 2 - src/widgets/spw-utilities.cpp | 4 +- src/widgets/toolbox.cpp | 24 ++-- 29 files changed, 252 insertions(+), 392 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 7ad0eaa14..2f78e4742 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1517,12 +1517,12 @@ static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); } -static GtkWidget * clonetiler_checkbox(GtkTooltips *tt, const char *tip, const char *attr) +static GtkWidget * clonetiler_checkbox(const char *tip, const char *attr) { GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); GtkWidget *b = gtk_check_button_new (); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL); + gtk_widget_set_tooltip_text (b, tip); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool value = prefs->getBool(prefs_path + attr); @@ -1544,7 +1544,7 @@ static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data) prefs->setDouble(prefs_path + pref, adj->value); } -static GtkWidget * clonetiler_spinbox(GtkTooltips *tt, const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false) +static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false) { GtkWidget *hb = gtk_hbox_new(FALSE, 0); @@ -1563,7 +1563,7 @@ static GtkWidget * clonetiler_spinbox(GtkTooltips *tt, const char *tip, const ch sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.1, 1); } - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, tip, NULL); + gtk_widget_set_tooltip_text (sb, tip); gtk_entry_set_width_chars (GTK_ENTRY (sb), 4); gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN); @@ -1834,8 +1834,6 @@ void clonetiler_dialog(void) g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); - GtkTooltips *tt = gtk_tooltips_new(); - GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); gtk_container_add (GTK_CONTAINER (dlg), mainbox); @@ -1854,7 +1852,7 @@ void clonetiler_dialog(void) * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary). */ - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), om, _("Select one of the 17 symmetry groups for the tiling"), NULL); + gtk_widget_set_tooltip_text (om, _("Select one of the 17 symmetry groups for the tiling")); gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN); GtkWidget *m = gtk_menu_new (); @@ -1927,7 +1925,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", -10000, 10000, "%"); @@ -1935,7 +1933,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", -10000, 10000, "%"); @@ -1943,8 +1941,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the horizontal shift by this percentage"), "shiftx_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 2, 4); } @@ -1960,7 +1957,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "shifty_per_j", -10000, 10000, "%"); @@ -1968,7 +1965,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "shifty_per_i", -10000, 10000, "%"); @@ -1976,7 +1973,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( _("Randomize the vertical shift by this percentage"), "shifty_rand", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 3, 4); @@ -1991,14 +1988,14 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", 0, 10, "", true); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", 0, 10, "", true); clonetiler_table_attach (table, l, 0, 4, 3); @@ -2013,12 +2010,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each row"), "shifty_alternate"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); clonetiler_table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "shiftx_alternate"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); clonetiler_table_attach (table, l, 0, 5, 3); } @@ -2031,12 +2028,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the shifts for each row"), "shifty_cumulate"); + GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); clonetiler_table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the shifts for each column"), "shiftx_cumulate"); + GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); clonetiler_table_attach (table, l, 0, 6, 3); } @@ -2049,12 +2046,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Exclude tile height in shift"), "shifty_excludeh"); + GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); clonetiler_table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Exclude tile width in shift"), "shiftx_excludew"); + GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); clonetiler_table_attach (table, l, 0, 7, 3); } @@ -2077,7 +2074,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", -100, 1000, "%"); @@ -2085,7 +2082,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", -100, 1000, "%"); @@ -2093,8 +2090,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the horizontal scale by this percentage"), "scalex_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 2, 4); } @@ -2108,7 +2104,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "scaley_per_j", -100, 1000, "%"); @@ -2116,7 +2112,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "scaley_per_i", -100, 1000, "%"); @@ -2124,8 +2120,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the vertical scale by this percentage"), "scaley_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 3, 4); } @@ -2139,15 +2134,13 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", 0, 10, "", true); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", 0, 10, "", true); clonetiler_table_attach (table, l, 0, 4, 3); } @@ -2161,15 +2154,13 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", 0, 10, "", false); clonetiler_table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", 0, 10, "", false); clonetiler_table_attach (table, l, 0, 5, 3); } @@ -2183,12 +2174,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each row"), "scaley_alternate"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); clonetiler_table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "scalex_alternate"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); clonetiler_table_attach (table, l, 0, 6, 3); } @@ -2201,12 +2192,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the scales for each row"), "scaley_cumulate"); + GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); clonetiler_table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the scales for each column"), "scalex_cumulate"); + GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); clonetiler_table_attach (table, l, 0, 7, 3); } @@ -2229,7 +2220,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "rotate_per_j", -180, 180, "°"); @@ -2237,7 +2228,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "rotate_per_i", -180, 180, "°"); @@ -2245,8 +2236,7 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the rotation angle by this percentage"), "rotate_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 4); } @@ -2260,12 +2250,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "rotate_alternatej"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); clonetiler_table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "rotate_alternatei"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); clonetiler_table_attach (table, l, 0, 3, 3); } @@ -2278,12 +2268,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the rotation for each row"), "rotate_cumulatej"); + GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the rotation for each column"), "rotate_cumulatei"); + GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); clonetiler_table_attach (table, l, 0, 4, 3); } @@ -2307,22 +2297,19 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Blur tiles by this percentage for each row"), "blur_per_j", + GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Blur tiles by this percentage for each column"), "blur_per_i", + GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the tile blur by this percentage"), "blur_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 4); } @@ -2336,12 +2323,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each row"), "blur_alternatej"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); clonetiler_table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each column"), "blur_alternatei"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); clonetiler_table_attach (table, l, 0, 3, 3); } @@ -2356,22 +2343,19 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the tile opacity by this percentage"), "opacity_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 4); } @@ -2385,12 +2369,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); clonetiler_table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); clonetiler_table_attach (table, l, 0, 5, 3); } } @@ -2428,22 +2412,19 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Change the tile hue by this percentage for each row"), "hue_per_j", + GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Change the tile hue by this percentage for each column"), "hue_per_i", + GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the tile hue by this percentage"), "hue_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 4); } @@ -2458,22 +2439,19 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Change the color saturation by this percentage for each row"), "saturation_per_j", + GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Change the color saturation by this percentage for each column"), "saturation_per_i", + GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the color saturation by this percentage"), "saturation_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 3, 4); } @@ -2487,22 +2465,19 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Change the color lightness by this percentage for each row"), "lightness_per_j", + GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Change the color lightness by this percentage for each column"), "lightness_per_i", + GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the color lightness by this percentage"), "lightness_rand", + GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 4); } @@ -2516,12 +2491,12 @@ void clonetiler_dialog(void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "color_alternatej"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); clonetiler_table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "color_alternatei"); + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); clonetiler_table_attach (table, l, 0, 5, 3); } @@ -2540,7 +2515,7 @@ void clonetiler_dialog(void) g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); bool old = prefs->getBool(prefs_path + "dotrace"); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"), NULL); + gtk_widget_set_tooltip_text (b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone")); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(b), "toggled", @@ -2566,7 +2541,7 @@ void clonetiler_dialog(void) GtkWidget* radio; { radio = gtk_radio_button_new_with_label (NULL, _("Color")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the visible color and opacity"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); clonetiler_table_attach (table, radio, 0.0, 1, 1); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); @@ -2574,7 +2549,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the total accumulated opacity"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); clonetiler_table_attach (table, radio, 0.0, 2, 1); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); @@ -2582,7 +2557,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Red component of the color"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); clonetiler_table_attach (table, radio, 0.0, 1, 2); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); @@ -2590,7 +2565,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Green component of the color"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); clonetiler_table_attach (table, radio, 0.0, 2, 2); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); @@ -2598,7 +2573,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Blue component of the color"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); clonetiler_table_attach (table, radio, 0.0, 3, 2); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); @@ -2606,7 +2581,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); clonetiler_table_attach (table, radio, 0.0, 1, 3); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); @@ -2614,7 +2589,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); clonetiler_table_attach (table, radio, 0.0, 2, 3); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); @@ -2622,7 +2597,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL); + gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); clonetiler_table_attach (table, radio, 0.0, 3, 3); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); @@ -2646,8 +2621,7 @@ void clonetiler_dialog(void) clonetiler_table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", -10, 10, ""); clonetiler_table_attach (table, l, 0.0, 1, 2); } @@ -2658,8 +2632,7 @@ void clonetiler_dialog(void) clonetiler_table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the picked value by this percentage"), "rand_picked", + GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); clonetiler_table_attach (table, l, 0.0, 1, 4); } @@ -2670,7 +2643,7 @@ void clonetiler_dialog(void) clonetiler_table_attach (table, l, 1.0, 2, 1); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Invert the picked value"), "invert_picked"); + GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked"); clonetiler_table_attach (table, l, 0.0, 2, 2); } } @@ -2689,7 +2662,7 @@ void clonetiler_dialog(void) GtkWidget *b = gtk_check_button_new_with_label (_("Presence")); bool old = prefs->getBool(prefs_path + "pick_to_presence", true); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL); + gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); clonetiler_table_attach (table, b, 0.0, 1, 1); gtk_signal_connect(GTK_OBJECT(b), "toggled", GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_presence"); @@ -2699,7 +2672,7 @@ void clonetiler_dialog(void) GtkWidget *b = gtk_check_button_new_with_label (_("Size")); bool old = prefs->getBool(prefs_path + "pick_to_size"); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL); + gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); clonetiler_table_attach (table, b, 0.0, 2, 1); gtk_signal_connect(GTK_OBJECT(b), "toggled", GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_size"); @@ -2709,7 +2682,7 @@ void clonetiler_dialog(void) GtkWidget *b = gtk_check_button_new_with_label (_("Color")); bool old = prefs->getBool(prefs_path + "pick_to_color", 0); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"), NULL); + gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); clonetiler_table_attach (table, b, 0.0, 1, 2); gtk_signal_connect(GTK_OBJECT(b), "toggled", GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_color"); @@ -2719,7 +2692,7 @@ void clonetiler_dialog(void) GtkWidget *b = gtk_check_button_new_with_label (_("Opacity")); bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL); + gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); clonetiler_table_attach (table, b, 0.0, 2, 2); gtk_signal_connect(GTK_OBJECT(b), "toggled", GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity"); @@ -2746,7 +2719,7 @@ void clonetiler_dialog(void) int value = prefs->getInt(prefs_path + "jmax", 2); gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL); + gtk_widget_set_tooltip_text (sb, _("How many rows in the tiling")); gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0); @@ -2766,7 +2739,7 @@ void clonetiler_dialog(void) int value = prefs->getInt(prefs_path + "imax", 2); gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL); + gtk_widget_set_tooltip_text (sb, _("How many columns in the tiling")); gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0); @@ -2796,7 +2769,7 @@ void clonetiler_dialog(void) gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units); GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Width of the rectangle to be filled"), NULL); + gtk_widget_set_tooltip_text (e, _("Width of the rectangle to be filled")); gtk_entry_set_width_chars (GTK_ENTRY (e), 5); gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT(a), "value_changed", @@ -2821,7 +2794,7 @@ void clonetiler_dialog(void) GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Height of the rectangle to be filled"), NULL); + gtk_widget_set_tooltip_text (e, _("Height of the rectangle to be filled")); gtk_entry_set_width_chars (GTK_ENTRY (e), 5); gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT(a), "value_changed", @@ -2837,7 +2810,7 @@ void clonetiler_dialog(void) GtkWidget* radio; { radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Create the specified number of rows and columns"), NULL); + gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); clonetiler_table_attach (table, radio, 0.0, 1, 1); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg); } @@ -2847,7 +2820,7 @@ void clonetiler_dialog(void) } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Fill the specified width and height with the tiling"), NULL); + gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); clonetiler_table_attach (table, radio, 0.0, 2, 1); gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg); } @@ -2866,7 +2839,7 @@ void clonetiler_dialog(void) GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true); gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size"), NULL); + gtk_widget_set_tooltip_text (b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size")); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(b), "toggled", @@ -2892,7 +2865,7 @@ void clonetiler_dialog(void) GtkWidget *l = gtk_label_new (""); gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> ")); gtk_container_add (GTK_CONTAINER(b), l); - gtk_tooltips_set_tip (tt, b, _("Create and tile the clones of the selection"), NULL); + gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_apply), NULL); gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); } @@ -2908,14 +2881,14 @@ void clonetiler_dialog(void) // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png // So unclumping is the process of spreading a number of objects out more evenly. GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); - gtk_tooltips_set_tip (tt, b, _("Spread out clones to reduce clumping; can be applied repeatedly"), NULL); + gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_unclump), NULL); gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); } { GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); - gtk_tooltips_set_tip (tt, b, _("Remove existing tiled clones of the selected object (siblings only)"), NULL); + gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_remove), NULL); gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); } @@ -2933,7 +2906,7 @@ void clonetiler_dialog(void) { GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); // TRANSLATORS: "change" is a noun here - gtk_tooltips_set_tip (tt, b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"), NULL); + gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_reset), NULL); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 4c1ad4af1..2f1299190 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -450,8 +450,6 @@ sp_export_dialog (void) g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); - GtkTooltips *tt = gtk_tooltips_new(); - Gtk::VBox *vb = new Gtk::VBox(false, 3); vb->set_border_width(3); gtk_container_add (GTK_CONTAINER (dlg), GTK_WIDGET(vb->gobj())); @@ -625,7 +623,7 @@ sp_export_dialog (void) gtk_widget_set_sensitive(GTK_WIDGET(be), TRUE); gtk_object_set_data(GTK_OBJECT(dlg), "batch_checkbox", be); batch_box->pack_start(*Glib::wrap(be), false, false); - gtk_tooltips_set_tip(tt, be, _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)"), NULL); + gtk_widget_set_tooltip_text(be, _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)")); batch_box->show_all(); g_signal_connect(G_OBJECT(be), "toggled", GTK_SIGNAL_FUNC(batch_export_clicked), dlg); vb->pack_start(*batch_box); @@ -637,7 +635,7 @@ sp_export_dialog (void) gtk_widget_set_sensitive(GTK_WIDGET(he), TRUE); gtk_object_set_data(GTK_OBJECT(dlg), "hide_checkbox", he); hide_box->pack_start(*Glib::wrap(he), false, false); - gtk_tooltips_set_tip(tt, he, _("In the exported image, hide all objects except those that are selected"), NULL); + gtk_widget_set_tooltip_text(he, _("In the exported image, hide all objects except those that are selected")); hide_box->show_all(); vb->pack_start(*hide_box); } @@ -658,7 +656,7 @@ sp_export_dialog (void) image_label->pack_start(*l); b->add(*image_label); - gtk_tooltips_set_tip (tt, GTK_WIDGET(b->gobj()), _("Export the bitmap file with these settings"), NULL); + gtk_widget_set_tooltip_text (GTK_WIDGET(b->gobj()), _("Export the bitmap file with these settings")); gtk_signal_connect ( GTK_OBJECT (b->gobj()), "clicked", GTK_SIGNAL_FUNC (sp_export_export_clicked), dlg ); bb->pack_end(*b, false, false, 0); diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index 4d392a316..d07772406 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -412,7 +412,7 @@ sp_find_dialog_reset (GObject *, GObject *dlg) #define FIND_LABELWIDTH 80 void -sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, const gchar *id, GtkTooltips *tt, const gchar *tip) +sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, const gchar *id, const gchar *tip) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); GtkWidget *l = gtk_label_new_with_mnemonic (label); @@ -424,7 +424,7 @@ sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, cons gtk_entry_set_max_length (GTK_ENTRY (tf), 64); gtk_box_pack_start (GTK_BOX (hb), tf, TRUE, TRUE, 0); gtk_object_set_data (GTK_OBJECT (dlg), id, tf); - gtk_tooltips_set_tip (tt, tf, tip, NULL); + gtk_widget_set_tooltip_text (tf, tip); g_signal_connect ( G_OBJECT (tf), "activate", G_CALLBACK (sp_find_dialog_find), dlg ); gtk_label_set_mnemonic_widget (GTK_LABEL(l), tf); @@ -432,10 +432,10 @@ sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, cons } void -sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, GtkTooltips *tt, const gchar *tip, void (*function) (GObject *, GObject *)) +sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gchar *tip, void (*function) (GObject *, GObject *)) { GtkWidget *b = gtk_button_new_with_mnemonic (label); - gtk_tooltips_set_tip (tt, b, tip, NULL); + gtk_widget_set_tooltip_text (b, tip); gtk_box_pack_start (GTK_BOX (hb), b, TRUE, TRUE, 0); g_signal_connect ( G_OBJECT (b), "clicked", G_CALLBACK (function), dlg ); gtk_widget_show (b); @@ -483,7 +483,7 @@ toggle_shapes (GtkToggleButton *tb, gpointer data) GtkWidget * sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, - GtkTooltips *tt, const gchar *tip, + const gchar *tip, const gchar *label, void (*toggled)(GtkToggleButton *, gpointer)) { @@ -495,7 +495,7 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, active); gtk_object_set_data (GTK_OBJECT (w), data, b); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL); + gtk_widget_set_tooltip_text (b, tip); if (toggled) gtk_signal_connect (GTK_OBJECT (b), "toggled", GTK_SIGNAL_FUNC (toggled), w); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); @@ -506,7 +506,7 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, GtkWidget * sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean active, - GtkTooltips *tt, const gchar *tip, + const gchar *tip, const gchar *label, void (*toggled)(GtkToggleButton *, gpointer), guint indent) { @@ -520,7 +520,7 @@ sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean activ gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } - GtkWidget *c = sp_find_types_checkbox (w, data, active, tt, tip, label, toggled); + GtkWidget *c = sp_find_types_checkbox (w, data, active, tip, label, toggled); gtk_box_pack_start (GTK_BOX (hb), c, FALSE, FALSE, 0); return hb; @@ -530,8 +530,6 @@ sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean activ GtkWidget * sp_find_types () { - GtkTooltips *tt = gtk_tooltips_new (); - GtkWidget *vb = gtk_vbox_new (FALSE, 4); gtk_widget_show (vb); @@ -547,7 +545,7 @@ sp_find_types () gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } - GtkWidget *alltypes = sp_find_types_checkbox (vb, "all", TRUE, tt, _("Search in all object types"), _("All types"), toggle_alltypes); + GtkWidget *alltypes = sp_find_types_checkbox (vb, "all", TRUE, _("Search in all object types"), _("All types"), toggle_alltypes); gtk_box_pack_start (GTK_BOX (hb), alltypes, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); @@ -558,7 +556,7 @@ sp_find_types () gtk_widget_show (vb_all); { - GtkWidget *c = sp_find_types_checkbox_indented (vb, "shapes", FALSE, tt, _("Search all shapes"), _("All shapes"), toggle_shapes, 10); + GtkWidget *c = sp_find_types_checkbox_indented (vb, "shapes", FALSE, _("Search all shapes"), _("All shapes"), toggle_shapes, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } @@ -575,22 +573,22 @@ sp_find_types () } { - GtkWidget *c = sp_find_types_checkbox (vb, "rects", FALSE, tt, _("Search rectangles"), _("Rectangles"), NULL); + GtkWidget *c = sp_find_types_checkbox (vb, "rects", FALSE, _("Search rectangles"), _("Rectangles"), NULL); gtk_box_pack_start (GTK_BOX (hb), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox (vb, "ellipses", FALSE, tt, _("Search ellipses, arcs, circles"), _("Ellipses"), NULL); + GtkWidget *c = sp_find_types_checkbox (vb, "ellipses", FALSE, _("Search ellipses, arcs, circles"), _("Ellipses"), NULL); gtk_box_pack_start (GTK_BOX (hb), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox (vb, "stars", FALSE, tt, _("Search stars and polygons"), _("Stars"), NULL); + GtkWidget *c = sp_find_types_checkbox (vb, "stars", FALSE, _("Search stars and polygons"), _("Stars"), NULL); gtk_box_pack_start (GTK_BOX (hb), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox (vb, "spirals", FALSE, tt, _("Search spirals"), _("Spirals"), NULL); + GtkWidget *c = sp_find_types_checkbox (vb, "spirals", FALSE, _("Search spirals"), _("Spirals"), NULL); gtk_box_pack_start (GTK_BOX (hb), c, FALSE, FALSE, 0); } @@ -603,34 +601,34 @@ sp_find_types () { // TRANSLATORS: polyline is a set of connected straight line segments // http://www.w3.org/TR/SVG11/shapes.html#PolylineElement - GtkWidget *c = sp_find_types_checkbox_indented (vb, "paths", TRUE, tt, _("Search paths, lines, polylines"), _("Paths"), NULL, 10); + GtkWidget *c = sp_find_types_checkbox_indented (vb, "paths", TRUE, _("Search paths, lines, polylines"), _("Paths"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox_indented (vb, "texts", TRUE, tt, _("Search text objects"), _("Texts"), NULL, 10); + GtkWidget *c = sp_find_types_checkbox_indented (vb, "texts", TRUE, _("Search text objects"), _("Texts"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox_indented (vb, "groups", TRUE, tt, _("Search groups"), _("Groups"), NULL, 10); + GtkWidget *c = sp_find_types_checkbox_indented (vb, "groups", TRUE, _("Search groups"), _("Groups"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox_indented (vb, "clones", TRUE, tt, _("Search clones"), + GtkWidget *c = sp_find_types_checkbox_indented (vb, "clones", TRUE, _("Search clones"), //TRANSLATORS: "Clones" is a noun indicating type of object to find C_("Find dialog","Clones"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox_indented (vb, "images", TRUE, tt, _("Search images"), _("Images"), NULL, 10); + GtkWidget *c = sp_find_types_checkbox_indented (vb, "images", TRUE, _("Search images"), _("Images"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } { - GtkWidget *c = sp_find_types_checkbox_indented (vb, "offsets", TRUE, tt, _("Search offset objects"), _("Offsets"), NULL, 10); + GtkWidget *c = sp_find_types_checkbox_indented (vb, "offsets", TRUE, _("Search offset objects"), _("Offsets"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } @@ -687,18 +685,16 @@ sp_find_dialog_old (void) g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); - GtkTooltips *tt = gtk_tooltips_new (); - gtk_container_set_border_width (GTK_CONTAINER (dlg), 4); /* Toplevel vbox */ GtkWidget *vb = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (dlg), vb); - sp_find_new_searchfield (dlg, vb, _("_Text:"), "text", tt, _("Find objects by their text content (exact or partial match)")); - sp_find_new_searchfield (dlg, vb, _("_ID:"), "id", tt, _("Find objects by the value of the id attribute (exact or partial match)")); - sp_find_new_searchfield (dlg, vb, _("_Style:"), "style", tt, _("Find objects by the value of the style attribute (exact or partial match)")); - sp_find_new_searchfield (dlg, vb, _("_Attribute:"), "attr", tt ,_("Find objects by the name of an attribute (exact or partial match)")); + sp_find_new_searchfield (dlg, vb, _("_Text:"), "text", _("Find objects by their text content (exact or partial match)")); + sp_find_new_searchfield (dlg, vb, _("_ID:"), "id", _("Find objects by the value of the id attribute (exact or partial match)")); + sp_find_new_searchfield (dlg, vb, _("_Style:"), "style", _("Find objects by the value of the style attribute (exact or partial match)")); + sp_find_new_searchfield (dlg, vb, _("_Attribute:"), "attr", _("Find objects by the name of an attribute (exact or partial match)")); gtk_widget_show_all (vb); @@ -716,7 +712,7 @@ sp_find_dialog_old (void) gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); gtk_object_set_data (GTK_OBJECT (dlg), "inselection", b); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Limit search to the current selection"), NULL); + gtk_widget_set_tooltip_text (b, _("Limit search to the current selection")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } @@ -725,7 +721,7 @@ sp_find_dialog_old (void) gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); gtk_object_set_data (GTK_OBJECT (dlg), "inlayer", b); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Limit search to the current layer"), NULL); + gtk_widget_set_tooltip_text (b, _("Limit search to the current layer")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } @@ -734,7 +730,7 @@ sp_find_dialog_old (void) gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); gtk_object_set_data (GTK_OBJECT (dlg), "includehidden", b); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Include hidden objects in search"), NULL); + gtk_widget_set_tooltip_text (b, _("Include hidden objects in search")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } @@ -743,7 +739,7 @@ sp_find_dialog_old (void) gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); gtk_object_set_data (GTK_OBJECT (dlg), "includelocked", b); - gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Include locked objects in search"), NULL); + gtk_widget_set_tooltip_text (b, _("Include locked objects in search")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } } @@ -754,8 +750,8 @@ sp_find_dialog_old (void) gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); // TRANSLATORS: "Clear" is a verb here - sp_find_new_button (dlg, hb, _("_Clear"), tt, _("Clear values"), sp_find_dialog_reset); - sp_find_new_button (dlg, hb, _("_Find"), tt, _("Select objects matching all of the fields you filled in"), sp_find_dialog_find); + sp_find_new_button (dlg, hb, _("_Clear"), _("Clear values"), sp_find_dialog_reset); + sp_find_new_button (dlg, hb, _("_Find"), _("Select objects matching all of the fields you filled in"), sp_find_dialog_find); } } diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 54707c0aa..cd0cea9b5 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -89,8 +89,6 @@ sp_item_widget_new (void) GtkWidget *spw, *vb, *t, *cb, *l, *f, *tf, *pb, *int_expander, *int_label; GtkTextBuffer *desc_buffer; - GtkTooltips *tt = gtk_tooltips_new(); - /* Create container widget */ spw = sp_widget_new_global (INKSCAPE); gtk_signal_connect ( GTK_OBJECT (spw), "modify_selection", @@ -120,7 +118,7 @@ sp_item_widget_new (void) /* Create the entry box for the object id */ tf = gtk_entry_new (); - gtk_tooltips_set_tip (tt, tf, _("The id= attribute (only letters, digits, and the characters .-_: allowed)"), NULL); + gtk_widget_set_tooltip_text (tf, _("The id= attribute (only letters, digits, and the characters .-_: allowed)")); gtk_entry_set_max_length (GTK_ENTRY (tf), 64); gtk_table_attach ( GTK_TABLE (t), tf, 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -152,7 +150,7 @@ sp_item_widget_new (void) /* Create the entry box for the object label */ tf = gtk_entry_new (); - gtk_tooltips_set_tip (tt, tf, _("A freeform label for the object"), NULL); + gtk_widget_set_tooltip_text (tf, _("A freeform label for the object")); gtk_entry_set_max_length (GTK_ENTRY (tf), 256); gtk_table_attach ( GTK_TABLE (t), tf, 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), @@ -214,7 +212,7 @@ sp_item_widget_new (void) /* Hide */ cb = gtk_check_button_new_with_mnemonic (_("_Hide")); - gtk_tooltips_set_tip (tt, cb, _("Check to make the object invisible"), NULL); + gtk_widget_set_tooltip_text (cb, _("Check to make the object invisible")); gtk_table_attach ( GTK_TABLE (t), cb, 0, 1, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); @@ -224,7 +222,7 @@ sp_item_widget_new (void) /* Lock */ // TRANSLATORS: "Lock" is a verb here cb = gtk_check_button_new_with_mnemonic (_("L_ock")); - gtk_tooltips_set_tip (tt, cb, _("Check to make the object insensitive (not selectable by mouse)"), NULL); + gtk_widget_set_tooltip_text (cb, _("Check to make the object insensitive (not selectable by mouse)")); gtk_table_attach ( GTK_TABLE (t), cb, 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index ecdc0e0ca..47de25061 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -185,10 +185,10 @@ static gboolean sp_spellcheck_dialog_delete(GtkObject *, GdkEvent *, gpointer /* } void -sp_spellcheck_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, GtkTooltips *tt, const gchar *tip, void (*function) (GObject *, GObject *), const gchar *cookie) +sp_spellcheck_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gchar *tip, void (*function) (GObject *, GObject *), const gchar *cookie) { GtkWidget *b = gtk_button_new_with_mnemonic (label); - gtk_tooltips_set_tip (tt, b, tip, NULL); + gtk_widget_set_tooltip_text (b, tip); gtk_box_pack_start (GTK_BOX (hb), b, TRUE, TRUE, 0); g_signal_connect ( G_OBJECT (b), "clicked", G_CALLBACK (function), dlg ); gtk_object_set_data (GTK_OBJECT (dlg), cookie, b); @@ -926,8 +926,6 @@ sp_spellcheck_dialog (void) g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); - GtkTooltips *tt = gtk_tooltips_new (); - gtk_container_set_border_width (GTK_CONTAINER (dlg), 4); /* Toplevel vbox */ @@ -971,18 +969,18 @@ sp_spellcheck_dialog (void) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - sp_spellcheck_new_button (dlg, hb, _("_Accept"), tt, _("Accept the chosen suggestion"), + sp_spellcheck_new_button (dlg, hb, _("_Accept"), _("Accept the chosen suggestion"), sp_spellcheck_accept, "b_accept"); - sp_spellcheck_new_button (dlg, hb, _("_Ignore once"), tt, _("Ignore this word only once"), + sp_spellcheck_new_button (dlg, hb, _("_Ignore once"), _("Ignore this word only once"), sp_spellcheck_ignore_once, "b_ignore_once"); - sp_spellcheck_new_button (dlg, hb, _("_Ignore"), tt, _("Ignore this word in this session"), + sp_spellcheck_new_button (dlg, hb, _("_Ignore"), _("Ignore this word in this session"), sp_spellcheck_ignore, "b_ignore"); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); } { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - sp_spellcheck_new_button (dlg, hb, _("A_dd to dictionary:"), tt, _("Add this word to the chosen dictionary"), + sp_spellcheck_new_button (dlg, hb, _("A_dd to dictionary:"), _("Add this word to the chosen dictionary"), sp_spellcheck_add, "b_add"); GtkComboBox *cbox = GTK_COMBO_BOX (gtk_combo_box_new_text()); gtk_combo_box_append_text (cbox, _lang); @@ -1006,9 +1004,9 @@ sp_spellcheck_dialog (void) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - sp_spellcheck_new_button (dlg, hb, _("_Stop"), tt, _("Stop the check"), + sp_spellcheck_new_button (dlg, hb, _("_Stop"), _("Stop the check"), sp_spellcheck_stop, "b_stop"); - sp_spellcheck_new_button (dlg, hb, _("_Start"), tt, _("Start the check"), + sp_spellcheck_new_button (dlg, hb, _("_Start"), _("Start the check"), sp_spellcheck_start, "b_start"); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); } diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index d46f62d17..46d5637c3 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -188,8 +188,6 @@ sp_text_edit_dialog (void) gtk_window_set_policy (GTK_WINDOW (dlg), TRUE, TRUE, FALSE); - GtkTooltips *tt = gtk_tooltips_new(); - // box containing the notebook and the bottom buttons GtkWidget *mainvb = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (dlg), mainvb); @@ -240,7 +238,7 @@ sp_text_edit_dialog (void) // TODO - replace with Inkscape-specific call GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_LEFT, GTK_ICON_SIZE_LARGE_TOOLBAR ); GtkWidget *b = group = gtk_radio_button_new (NULL); - gtk_tooltips_set_tip (tt, b, _("Align lines left"), NULL); + gtk_widget_set_tooltip_text (b, _("Align lines left")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE ); @@ -255,7 +253,7 @@ sp_text_edit_dialog (void) GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_CENTER, GTK_ICON_SIZE_LARGE_TOOLBAR ); GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); /* TRANSLATORS: `Center' here is a verb. */ - gtk_tooltips_set_tip (tt, b, _("Center lines"), NULL); + gtk_widget_set_tooltip_text (b, _("Center lines")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); @@ -269,7 +267,7 @@ sp_text_edit_dialog (void) // TODO - replace with Inkscape-specific call GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_RIGHT, GTK_ICON_SIZE_LARGE_TOOLBAR ); GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); - gtk_tooltips_set_tip (tt, b, _("Align lines right"), NULL); + gtk_widget_set_tooltip_text (b, _("Align lines right")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); @@ -283,7 +281,7 @@ sp_text_edit_dialog (void) // TODO - replace with Inkscape-specific call GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_FILL, GTK_ICON_SIZE_LARGE_TOOLBAR ); GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); - gtk_tooltips_set_tip (tt, b, _("Justify lines"), NULL); + gtk_widget_set_tooltip_text (b, _("Justify lines")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); @@ -305,7 +303,7 @@ sp_text_edit_dialog (void) GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL ); GtkWidget *b = group = gtk_radio_button_new (NULL); - gtk_tooltips_set_tip (tt, b, _("Horizontal text"), NULL); + gtk_widget_set_tooltip_text (b, _("Horizontal text")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); @@ -319,7 +317,7 @@ sp_text_edit_dialog (void) GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL ); GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); - gtk_tooltips_set_tip (tt, b, _("Vertical text"), NULL); + gtk_widget_set_tooltip_text (b, _("Vertical text")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index ddb419dcd..5fd306149 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -66,7 +66,6 @@ static Inkscape::MessageStack *_message_stack = NULL; static Inkscape::MessageContext *_message_context = NULL; static sigc::connection _message_changed_connection; -static GtkTooltips *tooltips = NULL; static GtkEditable *attr_name = NULL; static GtkTextView *attr_value = NULL; static SPXMLViewTree *tree = NULL; @@ -194,9 +193,6 @@ void sp_xml_tree_dialog() GtkWidget *text_container, *attr_container, *attr_subpaned_container, *box2; GtkWidget *set_attr; - tooltips = gtk_tooltips_new(); - gtk_tooltips_enable(tooltips); - dlg = sp_window_new("", TRUE); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (x == -1000 || y == -1000) { @@ -267,8 +263,8 @@ void sp_xml_tree_dialog() gtk_paned_pack1(GTK_PANED(paned), box, FALSE, FALSE); tree = SP_XMLVIEW_TREE(sp_xmlview_tree_new(NULL, NULL, NULL)); - gtk_tooltips_set_tip( tooltips, GTK_WIDGET(tree), - _("Drag to reorder nodes"), NULL ); + gtk_widget_set_tooltip_text( GTK_WIDGET(tree), + _("Drag to reorder nodes") ); g_signal_connect( G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row), NULL ); @@ -495,9 +491,9 @@ void sp_xml_tree_dialog() FALSE, TRUE, 0); attr_name = GTK_EDITABLE(gtk_entry_new()); - gtk_tooltips_set_tip( tooltips, GTK_WIDGET(attr_name), + gtk_widget_set_tooltip_text( GTK_WIDGET(attr_name), // TRANSLATORS: "Attribute" is a noun here - _("Attribute name"), NULL ); + _("Attribute name") ); gtk_signal_connect( GTK_OBJECT(attributes), "select_row", (GCallback) on_attr_select_row_set_name_content, @@ -515,9 +511,9 @@ void sp_xml_tree_dialog() TRUE, TRUE, 0); set_attr = gtk_button_new(); - gtk_tooltips_set_tip( tooltips, GTK_WIDGET(set_attr), + gtk_widget_set_tooltip_text( GTK_WIDGET(set_attr), // TRANSLATORS: "Set" is a verb here - _("Set attribute"), NULL ); + _("Set attribute") ); // TRANSLATORS: "Set" is a verb here GtkWidget *set_label = gtk_label_new(_("Set")); gtk_container_add(GTK_CONTAINER(set_attr), set_label); @@ -540,9 +536,9 @@ void sp_xml_tree_dialog() attr_value =(GtkTextView *) gtk_text_view_new(); gtk_text_view_set_wrap_mode((GtkTextView *) attr_value, GTK_WRAP_CHAR); - gtk_tooltips_set_tip( tooltips, GTK_WIDGET(attr_value), + gtk_widget_set_tooltip_text( GTK_WIDGET(attr_value), // TRANSLATORS: "Attribute" is a noun here - _("Attribute value"), NULL ); + _("Attribute value") ); gtk_signal_connect( GTK_OBJECT(attributes), "select_row", (GCallback) on_attr_select_row_set_value_content, attr_value ); @@ -895,8 +891,6 @@ void after_tree_move(GtkCTree */*tree*/, static void on_destroy(GtkObject */*object*/, gpointer /*data*/) { set_tree_desktop(NULL); - gtk_object_destroy(GTK_OBJECT(tooltips)); - tooltips = NULL; sp_signal_disconnect_by_data(INKSCAPE, dlg); wd.win = dlg = NULL; wd.stop = 0; diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index f6df395b9..6b0ffd1ab 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -103,7 +103,6 @@ struct _EgeAdjustmentDescr struct _EgeAdjustmentActionPrivate { GtkAdjustment* adj; - GtkTooltips* toolTips; GtkWidget* focusWidget; gdouble climbRate; guint digits; @@ -275,7 +274,6 @@ static void ege_adjustment_action_init( EgeAdjustmentAction* action ) { action->private_data = EGE_ADJUSTMENT_ACTION_GET_PRIVATE( action ); action->private_data->adj = 0; - action->private_data->toolTips = 0; action->private_data->focusWidget = 0; action->private_data->climbRate = 0.0; action->private_data->digits = 2; @@ -852,10 +850,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_object_get_property( G_OBJECT(action), "tooltip", &tooltip ); const gchar* tipstr = g_value_get_string( &tooltip ); if ( tipstr && *tipstr ) { - if ( !act->private_data->toolTips ) { - act->private_data->toolTips = gtk_tooltips_new(); - } - gtk_tooltips_set_tip( act->private_data->toolTips, spinbutton, tipstr, 0 ); + gtk_widget_set_tooltip_text( spinbutton, tipstr ); } g_value_unset( &tooltip ); } diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index 2fd45e268..ea08f1c06 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -652,7 +652,6 @@ GtkWidget* create_tool_item( GtkAction* action ) GtkTreeIter iter; gboolean valid = FALSE; gint index = 0; - GtkTooltips* tooltips = gtk_tooltips_new(); { gchar* sss = 0; @@ -737,7 +736,7 @@ GtkWidget* create_tool_item( GtkAction* action ) sub = gtk_action_create_tool_item( GTK_ACTION(ract) ); gtk_action_connect_proxy( GTK_ACTION(ract), sub ); - gtk_tool_item_set_tooltip( GTK_TOOL_ITEM(sub), tooltips, tip, NULL ); + gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip ); gtk_box_pack_start( GTK_BOX(holder), sub, FALSE, FALSE, 0 ); @@ -750,7 +749,6 @@ GtkWidget* create_tool_item( GtkAction* action ) } g_object_set_data( G_OBJECT(holder), "ege-proxy_action-group", group ); - g_object_set_data( G_OBJECT(holder), "ege-tooltips", tooltips ); gtk_container_add( GTK_CONTAINER(item), holder ); } else { diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index c4882e7ad..37710b693 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -65,7 +65,6 @@ static void gdl_dock_bar_remove_item (GdlDockBar *dockbar, struct _GdlDockBarPrivate { GdlDockMaster *master; GSList *items; - GtkTooltips *tooltips; GtkOrientation orientation; GdlDockBarStyle dockbar_style; }; @@ -130,11 +129,8 @@ gdl_dock_bar_instance_init (GdlDockBar *dockbar) dockbar->_priv = g_new0 (GdlDockBarPrivate, 1); dockbar->_priv->master = NULL; dockbar->_priv->items = NULL; - dockbar->_priv->tooltips = gtk_tooltips_new (); dockbar->_priv->orientation = GTK_ORIENTATION_VERTICAL; dockbar->_priv->dockbar_style = GDL_DOCK_BAR_BOTH; - g_object_ref (dockbar->_priv->tooltips); - gtk_object_sink (GTK_OBJECT (dockbar->_priv->tooltips)); } static void @@ -208,11 +204,6 @@ gdl_dock_bar_destroy (GtkObject *object) priv->master = NULL; } - if (priv->tooltips) { - g_object_unref (priv->tooltips); - priv->tooltips = NULL; - } - dockbar->_priv = NULL; g_free (priv); @@ -334,7 +325,7 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar, gtk_container_add (GTK_CONTAINER (button), box); gtk_box_pack_start (GTK_BOX (dockbar), button, FALSE, FALSE, 0); - gtk_tooltips_set_tip (priv->tooltips, button, name, name); + gtk_widget_set_tooltip_text (button, name); g_free (name); g_object_set_data (G_OBJECT (item), "GdlDockBar", dockbar); diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 6457016de..de09fc150 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -33,7 +33,6 @@ enum { struct _GdlDockItemGripPrivate { GtkWidget *close_button; GtkWidget *iconify_button; - GtkTooltips *tooltips; gboolean icon_pixbuf_valid; GdkPixbuf *icon_pixbuf; @@ -264,11 +263,6 @@ gdl_dock_item_grip_destroy (GtkObject *object) priv->icon_pixbuf = NULL; } - if (priv->tooltips) { - g_object_unref (priv->tooltips); - priv->tooltips = NULL; - } - if (grip->item) g_signal_handlers_disconnect_by_func (grip->item, gdl_dock_item_grip_item_notify, @@ -386,13 +380,10 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked", G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip); - grip->_priv->tooltips = gtk_tooltips_new (); - g_object_ref (grip->_priv->tooltips); - gtk_object_sink (GTK_OBJECT (grip->_priv->tooltips)); - gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->iconify_button, - _("Iconify"), _("Iconify this dock")); - gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->close_button, - _("Close"), _("Close this dock")); + gtk_widget_set_tooltip_text (grip->_priv->iconify_button, + _("Iconify")); + gtk_widget_set_tooltip_text (grip->_priv->close_button, + _("Close")); } static void diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index c5e139e70..aaddc6d80 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -74,7 +74,6 @@ typedef struct { GtkWidget *icon; GtkWidget *arrow; GtkWidget *hbox; - GtkTooltips *tooltips; int id; } Button; @@ -103,7 +102,7 @@ GDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK static Button * button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, - GtkTooltips *tooltips, GtkWidget *arrow, GtkWidget *hbox, int id) + GtkWidget *arrow, GtkWidget *hbox, int id) { Button *button = g_new (Button, 1); @@ -112,7 +111,6 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, button->icon = icon; button->arrow = arrow; button->hbox = hbox; - button->tooltips = tooltips; button->id = id; g_object_ref (button_widget); @@ -120,7 +118,6 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, g_object_ref (icon); g_object_ref (arrow); g_object_ref (hbox); - g_object_ref (tooltips); return button; } @@ -132,7 +129,6 @@ button_free (Button *button) g_object_unref (button->label); g_object_unref (button->icon); g_object_unref (button->hbox); - g_object_unref (button->tooltips); g_free (button); } @@ -750,7 +746,6 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, GtkWidget *icon_widget; GtkWidget *label_widget; GtkWidget *arrow; - GtkTooltips *button_tooltips; button_widget = gtk_toggle_button_new (); if (switcher->priv->show) @@ -781,24 +776,19 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, } gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); gtk_widget_show (label_widget); - button_tooltips = gtk_tooltips_new(); - gtk_tooltips_set_tip (GTK_TOOLTIPS (button_tooltips), button_widget, - tooltips, NULL); + gtk_widget_set_tooltip_text (button_widget, tooltips); switch (INTERNAL_MODE (switcher)) { case GDL_SWITCHER_STYLE_TEXT: gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); - gtk_tooltips_disable (button_tooltips); break; case GDL_SWITCHER_STYLE_ICON: gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0); - gtk_tooltips_enable (button_tooltips); break; case GDL_SWITCHER_STYLE_BOTH: default: gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); - gtk_tooltips_disable (button_tooltips); break; } arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_NONE); @@ -808,7 +798,7 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, switcher->priv->buttons = g_slist_append (switcher->priv->buttons, button_new (button_widget, label_widget, - icon_widget, button_tooltips, + icon_widget, arrow, hbox, switcher_id)); gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher)); @@ -901,7 +891,6 @@ set_switcher_style_internal (GdlSwitcher *switcher, gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0); gtk_widget_show (button->label); - gtk_tooltips_disable (button->tooltips); } break; case GDL_SWITCHER_STYLE_ICON: @@ -914,7 +903,6 @@ set_switcher_style_internal (GdlSwitcher *switcher, } else gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon, "expand", TRUE, NULL); - gtk_tooltips_enable (button->tooltips); break; case GDL_SWITCHER_STYLE_BOTH: if (INTERNAL_MODE (switcher) @@ -929,7 +917,6 @@ set_switcher_style_internal (GdlSwitcher *switcher, button->icon, "expand", FALSE, NULL); } - gtk_tooltips_disable (button->tooltips); gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0); gtk_widget_show (button->label); diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index dc830d096..9676651d3 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -46,7 +46,7 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action static void sp_button_action_set_active (SPAction *action, unsigned int active, void *data); static void sp_button_action_set_sensitive (SPAction *action, unsigned int sensitive, void *data); static void sp_button_action_set_shortcut (SPAction *action, unsigned int shortcut, void *data); -static void sp_button_set_composed_tooltip (GtkTooltips *tooltips, GtkWidget *widget, SPAction *action); +static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); static GtkToggleButtonClass *parent_class; SPActionEventVector button_event_vector = { @@ -98,7 +98,6 @@ sp_button_init (SPButton *button) { button->action = NULL; button->doubleclick_action = NULL; - button->tooltips = NULL; gtk_container_set_border_width (GTK_CONTAINER (button), 0); @@ -116,11 +115,6 @@ sp_button_destroy (GtkObject *object) button = SP_BUTTON (object); - if (button->tooltips) { - g_object_unref (G_OBJECT (button->tooltips)); - button->tooltips = NULL; - } - if (button->action) { sp_button_set_action (button, NULL); } @@ -186,7 +180,7 @@ sp_button_perform_action (SPButton *button, gpointer /*data*/) GtkWidget * -sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action, GtkTooltips *tooltips ) +sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action ) { SPButton *button; @@ -194,9 +188,6 @@ sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPA button->type = type; button->lsize = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION ); - button->tooltips = tooltips; - - if (tooltips) g_object_ref ((GObject *) tooltips); sp_button_set_action (button, action); if (doubleclick_action) @@ -253,9 +244,7 @@ sp_button_set_action (SPButton *button, SPAction *action) } } - if (button->tooltips) { - sp_button_set_composed_tooltip (button->tooltips, (GtkWidget *) button, action); - } + sp_button_set_composed_tooltip ((GtkWidget *) button, action); } static void @@ -283,12 +272,10 @@ static void sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void *data) { SPButton *button=SP_BUTTON (data); - if (button->tooltips) { - sp_button_set_composed_tooltip (button->tooltips, GTK_WIDGET (button), action); - } + sp_button_set_composed_tooltip (GTK_WIDGET (button), action); } -static void sp_button_set_composed_tooltip(GtkTooltips *tooltips, GtkWidget *widget, SPAction *action) +static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) { if (action) { unsigned int shortcut = sp_shortcut_get_primary (action->verb); @@ -298,16 +285,16 @@ static void sp_button_set_composed_tooltip(GtkTooltips *tooltips, GtkWidget *wid gchar *key = sp_shortcut_get_label(shortcut); gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); - gtk_tooltips_set_tip(tooltips, widget, tip, NULL); + gtk_widget_set_tooltip_text(widget, tip); g_free(tip); g_free(key); } else { // action has no shortcut - gtk_tooltips_set_tip(tooltips, widget, action->tip, NULL); + gtk_widget_set_tooltip_text(widget, action->tip); } } else { // no action - gtk_tooltips_set_tip(tooltips, widget, NULL, NULL); + gtk_widget_set_tooltip_text(widget, NULL); } } @@ -316,12 +303,11 @@ sp_button_new_from_data( Inkscape::IconSize size, SPButtonType type, Inkscape::UI::View::View *view, const gchar *name, - const gchar *tip, - GtkTooltips *tooltips ) + const gchar *tip ) { GtkWidget *button; SPAction *action=sp_action_new(view, name, name, tip, name, 0); - button = sp_button_new (size, type, action, NULL, tooltips); + button = sp_button_new (size, type, action, NULL); nr_object_unref ((NRObject *) action); return button; } diff --git a/src/widgets/button.h b/src/widgets/button.h index 26191f524..19a513074 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -38,7 +38,6 @@ struct SPButton { unsigned int psize; SPAction *action; SPAction *doubleclick_action; - GtkTooltips *tooltips; }; struct SPButtonClass { @@ -49,7 +48,7 @@ struct SPButtonClass { GType sp_button_get_type (void); -GtkWidget *sp_button_new (Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action, GtkTooltips *tooltips); +GtkWidget *sp_button_new (Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action); void sp_button_toggle_set_down (SPButton *button, gboolean down); @@ -57,8 +56,7 @@ GtkWidget *sp_button_new_from_data (Inkscape::IconSize size, SPButtonType type, Inkscape::UI::View::View *view, const gchar *name, - const gchar *tip, - GtkTooltips *tooltips); + const gchar *tip); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 9f0367665..1de82a315 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -236,7 +236,7 @@ SPDesktopWidget::setMessage (Inkscape::MessageType type, const gchar *message) gdk_window_process_updates(GTK_WIDGET(sb)->window, TRUE); } - gtk_tooltips_set_tip (this->tt, this->select_status_eventbox, gtk_label_get_text (sb) , NULL); + gtk_widget_set_tooltip_text (this->select_status_eventbox, gtk_label_get_text (sb)); } Geom::Point @@ -313,7 +313,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->window = 0; dtw->desktop = NULL; dtw->_interaction_disabled_counter = 0; - dtw->tt = gtk_tooltips_new (); /* Main table */ dtw->vbox = gtk_vbox_new (FALSE, 0); @@ -359,7 +358,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->hruler = sp_hruler_new (); dtw->hruler_box = eventbox; sp_ruler_set_metric (GTK_RULER (dtw->hruler), SP_PT); - gtk_tooltips_set_tip (dtw->tt, dtw->hruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT))), NULL); + gtk_widget_set_tooltip_text (dtw->hruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT)))); gtk_container_add (GTK_CONTAINER (eventbox), dtw->hruler); gtk_table_attach (GTK_TABLE (canvas_tbl), eventbox, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), widget->style->xthickness, 0); g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_hruler_event), dtw); @@ -371,7 +370,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->vruler = sp_vruler_new (); dtw->vruler_box = eventbox; sp_ruler_set_metric (GTK_RULER (dtw->vruler), SP_PT); - gtk_tooltips_set_tip (dtw->tt, dtw->vruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT))), NULL); + gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT)))); gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler)); gtk_table_attach (GTK_TABLE (canvas_tbl), eventbox, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, widget->style->ythickness); g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_vruler_event), dtw); @@ -389,8 +388,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) SP_BUTTON_TYPE_TOGGLE, NULL, INKSCAPE_ICON_ZOOM_ORIGINAL, - _("Zoom drawing if window size changes"), - dtw->tt); + _("Zoom drawing if window size changes")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("/options/stickyzoom/value")); gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (dtw->sticky_zoom), "toggled", G_CALLBACK (sp_dtw_sticky_zoom_toggled), dtw); @@ -412,8 +410,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) SP_BUTTON_TYPE_TOGGLE, NULL, INKSCAPE_ICON_COLOR_MANAGEMENT, - tip, - dtw->tt ); + tip ); #if ENABLE_LCMS { Glib::ustring current = prefs->getString("/options/displayprofile/uri"); @@ -493,7 +490,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) // zoom status spinbutton dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1); - gtk_tooltips_set_tip (dtw->tt, dtw->zoom_status, _("Zoom"), NULL); + gtk_widget_set_tooltip_text (dtw->zoom_status, _("Zoom")); gtk_widget_set_size_request (dtw->zoom_status, STATUS_ZOOM_WIDTH, -1); gtk_entry_set_width_chars (GTK_ENTRY (dtw->zoom_status), 6); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (dtw->zoom_status), FALSE); @@ -513,7 +510,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_table_attach(GTK_TABLE(dtw->coord_status), gtk_vseparator_new(), 0,1, 0,2, GTK_FILL, GTK_FILL, 0, 0); eventbox = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (eventbox), dtw->coord_status); - gtk_tooltips_set_tip (dtw->tt, eventbox, _("Cursor coordinates"), NULL); + gtk_widget_set_tooltip_text (eventbox, _("Cursor coordinates")); GtkWidget *label_x = gtk_label_new(_("X:")); gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5); gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0); @@ -1595,8 +1592,8 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) } // children } // if aux_toolbox is a container - gtk_tooltips_set_tip(this->tt, this->hruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL); - gtk_tooltips_set_tip(this->tt, this->vruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL); + gtk_widget_set_tooltip_text(this->hruler_box, gettext(sp_unit_get_plural (nv->doc_units))); + gtk_widget_set_tooltip_text(this->vruler_box, gettext(sp_unit_get_plural (nv->doc_units))); sp_desktop_widget_update_rulers(this); ToolboxFactory::updateSnapToolbox(this->desktop, 0, this->snap_toolbox); diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index c045d6e28..57ba71d8f 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -69,8 +69,6 @@ struct SPDesktopWidget { sigc::connection modified_connection; - GtkTooltips *tt; - SPDesktop *desktop; Gtk::Window *window; diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 9a907e78b..3f07e09c8 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -133,7 +133,6 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) GtkWidget *hb = gtk_hbox_new( FALSE, 0 ); sel->nonsolid.push_back(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); - GtkTooltips *ttips = gtk_tooltips_new (); sel->add = gtk_button_new_with_label (_("Duplicate")); sel->nonsolid.push_back(sel->add); @@ -159,12 +158,12 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) sel->nonsolid.push_back(sel->spread); gtk_widget_show(sel->spread); gtk_box_pack_end( GTK_BOX(hb), sel->spread, FALSE, FALSE, 0 ); - gtk_tooltips_set_tip( ttips, sel->spread, + gtk_widget_set_tooltip_text( sel->spread, // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute _("Whether to fill with flat color beyond the ends of the gradient vector " "(spreadMethod=\"pad\"), or repeat the gradient in the same direction " "(spreadMethod=\"repeat\"), or repeat the gradient in alternating opposite " - "directions (spreadMethod=\"reflect\")"), NULL); + "directions (spreadMethod=\"reflect\")")); GtkWidget *m = gtk_menu_new(); GtkWidget *mi = gtk_menu_item_new_with_label(_("none")); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 64ed1e309..10e1fb95a 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -464,8 +464,6 @@ GtkWidget * gr_change_widget(SPDesktop *desktop) SPGradientSpread spr_selected = (SPGradientSpread) INT_MAX; // meaning undefined bool spr_multi = false; - GtkTooltips *tt = gtk_tooltips_new(); - gr_read_selection (selection, ev? ev->get_drag() : 0, gr_selected, gr_multi, spr_selected, spr_multi); GtkWidget *widget = gtk_hbox_new(FALSE, FALSE); @@ -484,7 +482,7 @@ GtkWidget * gr_change_widget(SPDesktop *desktop) { GtkWidget *hb = gtk_hbox_new(FALSE, 1); GtkWidget *b = gtk_button_new_with_label(_("Edit...")); - gtk_tooltips_set_tip(tt, b, _("Edit the stops of the gradient"), NULL); + gtk_widget_set_tooltip_text(b, _("Edit the stops of the gradient")); gtk_widget_show(b); gtk_container_add(GTK_CONTAINER(hb), b); gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(gr_edit), widget); @@ -542,8 +540,6 @@ sp_gradient_toolbox_new(SPDesktop *desktop) gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas); gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop); - GtkTooltips *tt = gtk_tooltips_new(); - sp_toolbox_add_label(tbl, _("<b>New:</b>")); // TODO replace aux_toolbox_space(tbl, AUX_SPACING); @@ -557,8 +553,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) SP_BUTTON_TYPE_TOGGLE, NULL, INKSCAPE_ICON_PAINT_GRADIENT_LINEAR, - _("Create linear gradient"), - tt); + _("Create linear gradient") ); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_type), tbl); g_object_set_data(G_OBJECT(tbl), "linear", button); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), @@ -571,8 +566,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) SP_BUTTON_TYPE_TOGGLE, NULL, INKSCAPE_ICON_PAINT_GRADIENT_RADIAL, - _("Create radial (elliptic or circular) gradient"), - tt); + _("Create radial (elliptic or circular) gradient")); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_type), tbl); g_object_set_data(G_OBJECT(tbl), "radial", button); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), @@ -599,8 +593,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) SP_BUTTON_TYPE_TOGGLE, NULL, INKSCAPE_ICON_OBJECT_FILL, - _("Create gradient in the fill"), - tt); + _("Create gradient in the fill")); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_fillstroke), tbl); g_object_set_data(G_OBJECT(tbl), "fill", button); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), @@ -613,8 +606,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) SP_BUTTON_TYPE_TOGGLE, NULL, INKSCAPE_ICON_OBJECT_STROKE, - _("Create gradient in the stroke"), - tt); + _("Create gradient in the stroke")); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_fillstroke), tbl); g_object_set_data(G_OBJECT(tbl), "stroke", button); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 8ef0ee313..9aa414ab6 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -788,7 +788,6 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_box_pack_start(GTK_BOX(vb), w, TRUE, TRUE, PAD); sp_repr_add_listener(gradient->getRepr(), &grad_edit_dia_repr_events, vb); - GtkTooltips *tt = gtk_tooltips_new(); /* Stop list */ GtkWidget *mnu = gtk_option_menu_new(); @@ -805,12 +804,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s GtkWidget *b = gtk_button_new_with_label(_("Add stop")); gtk_widget_show(b); gtk_container_add(GTK_CONTAINER(hb), b); - gtk_tooltips_set_tip(tt, b, _("Add another control stop to gradient"), NULL); + gtk_widget_set_tooltip_text(b, _("Add another control stop to gradient")); gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(sp_grd_ed_add_stop), vb); b = gtk_button_new_with_label(_("Delete stop")); gtk_widget_show(b); gtk_container_add(GTK_CONTAINER(hb), b); - gtk_tooltips_set_tip(tt, b, _("Delete current control stop from gradient"), NULL); + gtk_widget_set_tooltip_text(b, _("Delete current control stop from gradient")); gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(sp_grd_ed_del_stop), vb); gtk_widget_show(hb); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 610930a46..631675ede 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -71,7 +71,7 @@ static void sp_paint_selector_class_init(SPPaintSelectorClass *klass); static void sp_paint_selector_init(SPPaintSelector *slider); static void sp_paint_selector_destroy(GtkObject *object); -static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gchar const *px, SPPaintSelector::Mode mode, GtkTooltips *tt, gchar const *tip); +static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gchar const *px, SPPaintSelector::Mode mode, gchar const *tip); static void sp_paint_selector_style_button_toggled(GtkToggleButton *tb, SPPaintSelector *psel); static void sp_paint_selector_fillrule_toggled(GtkToggleButton *tb, SPPaintSelector *psel); @@ -210,8 +210,6 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) static void sp_paint_selector_init(SPPaintSelector *psel) { - GtkTooltips *tt = gtk_tooltips_new(); - psel->mode = static_cast<SPPaintSelector::Mode>(-1); // huh? do you mean 0xff? -- I think this means "not in the enum" /* Paint style button box */ @@ -222,19 +220,19 @@ sp_paint_selector_init(SPPaintSelector *psel) /* Buttons */ psel->none = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_NONE, - SPPaintSelector::MODE_NONE, tt, _("No paint")); + SPPaintSelector::MODE_NONE, _("No paint")); psel->solid = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_SOLID, - SPPaintSelector::MODE_COLOR_RGB, tt, _("Flat color")); + SPPaintSelector::MODE_COLOR_RGB, _("Flat color")); psel->gradient = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_GRADIENT_LINEAR, - SPPaintSelector::MODE_GRADIENT_LINEAR, tt, _("Linear gradient")); + SPPaintSelector::MODE_GRADIENT_LINEAR, _("Linear gradient")); psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_GRADIENT_RADIAL, - SPPaintSelector::MODE_GRADIENT_RADIAL, tt, _("Radial gradient")); + SPPaintSelector::MODE_GRADIENT_RADIAL, _("Radial gradient")); psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_PATTERN, - SPPaintSelector::MODE_PATTERN, tt, _("Pattern")); + SPPaintSelector::MODE_PATTERN, _("Pattern")); psel->swatch = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_SWATCH, - SPPaintSelector::MODE_SWATCH, tt, _("Swatch")); + SPPaintSelector::MODE_SWATCH, _("Swatch")); psel->unset = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_UNKNOWN, - SPPaintSelector::MODE_UNSET, tt, _("Unset paint (make it undefined so it can be inherited)")); + SPPaintSelector::MODE_UNSET, _("Unset paint (make it undefined so it can be inherited)")); /* Fillrule */ { @@ -246,7 +244,7 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_button_set_relief(GTK_BUTTON(psel->evenodd), GTK_RELIEF_NONE); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(psel->evenodd), FALSE); // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty - gtk_tooltips_set_tip(tt, psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)"), NULL); + gtk_widget_set_tooltip_text(psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)")); gtk_object_set_data(GTK_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_EVENODD)); w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_EVEN_ODD); gtk_container_add(GTK_CONTAINER(psel->evenodd), w); @@ -257,7 +255,7 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_button_set_relief(GTK_BUTTON(psel->nonzero), GTK_RELIEF_NONE); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(psel->nonzero), FALSE); // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty - gtk_tooltips_set_tip(tt, psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)"), NULL); + gtk_widget_set_tooltip_text(psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)")); gtk_object_set_data(GTK_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_NONZERO)); w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_NONZERO); gtk_container_add(GTK_CONTAINER(psel->nonzero), w); @@ -290,12 +288,12 @@ sp_paint_selector_destroy(GtkObject *object) static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gchar const *pixmap, SPPaintSelector::Mode mode, - GtkTooltips *tt, gchar const *tip) + gchar const *tip) { GtkWidget *b, *w; b = gtk_toggle_button_new(); - gtk_tooltips_set_tip(tt, b, tip, NULL); + gtk_widget_set_tooltip_text(b, tip); gtk_widget_show(b); gtk_container_set_border_width(GTK_CONTAINER(b), 0); diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 72134c48f..0bae54655 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -137,8 +137,7 @@ ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) _fooMap(0), _adj(0), _sbtn(0), - _label(0), - _tt(0) + _label(0) #if ENABLE_LCMS , _profileName(""), @@ -270,8 +269,6 @@ void ColorICCSelector::init() _updating = FALSE; _dragging = FALSE; - _tt = gtk_tooltips_new(); - t = gtk_table_new (5, 3, FALSE); gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 0); @@ -290,7 +287,7 @@ void ColorICCSelector::init() _fixupBtn = gtk_button_new_with_label(_("Fix")); g_signal_connect( G_OBJECT(_fixupBtn), "clicked", G_CALLBACK(_fixupHit), (gpointer)this ); gtk_widget_set_sensitive( _fixupBtn, FALSE ); - gtk_tooltips_set_tip( _tt, _fixupBtn, _("Fix RGB fallback to match icc-color() value."), NULL ); + gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); //gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 ); gtk_widget_show( _fixupBtn ); gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); @@ -338,18 +335,18 @@ void ColorICCSelector::init() /* Slider */ _fooSlider[i] = sp_color_slider_new( _fooAdj[i] ); #if ENABLE_LCMS - gtk_tooltips_set_tip( _tt, _fooSlider[i], tips[i], NULL ); + gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); #else - gtk_tooltips_set_tip( _tt, _fooSlider[i], ".", NULL ); + gtk_widget_set_tooltip_text( _fooSlider[i], "." ); #endif // ENABLE_LCMS gtk_widget_show( _fooSlider[i] ); gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD ); _fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits ); #if ENABLE_LCMS - gtk_tooltips_set_tip( _tt, _fooBtn[i], tips[i], NULL ); + gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); #else - gtk_tooltips_set_tip( _tt, _fooBtn[i], ".", NULL ); + gtk_widget_set_tooltip_text( _fooBtn[i], "." ); #endif // ENABLE_LCMS sp_dialog_defocus_on_enter( _fooBtn[i] ); gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] ); @@ -381,7 +378,7 @@ void ColorICCSelector::init() /* Slider */ _slider = sp_color_slider_new (_adj); - gtk_tooltips_set_tip (_tt, _slider, _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); gtk_widget_show (_slider); gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD); @@ -393,7 +390,7 @@ void ColorICCSelector::init() /* Spinbutton */ _sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (_adj), 1.0, 0); - gtk_tooltips_set_tip (_tt, _sbtn, _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_sbtn, _("Alpha (opacity)")); sp_dialog_defocus_on_enter (_sbtn); gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); gtk_widget_show (_sbtn); @@ -694,8 +691,8 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) for ( guint i = 0; i < _profChannelCount; i++ ) { gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), names[i]); - gtk_tooltips_set_tip( _tt, _fooSlider[i], tips[i], NULL ); - gtk_tooltips_set_tip( _tt, _fooBtn[i], tips[i], NULL ); + gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); + gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); sp_color_slider_set_colors( SP_COLOR_SLIDER(_fooSlider[i]), SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index f40d93189..b0efa35f4 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -66,8 +66,6 @@ protected: GtkWidget* _sbtn; /* Spinbutton */ GtkWidget* _label; /* Label */ - GtkTooltips* _tt; /* tooltip container */ - #if ENABLE_LCMS std::string _profileName; Inkscape::ColorProfile* _prof; diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 174971555..4c2c03e8a 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -203,8 +203,6 @@ void ColorNotebook::init() GType *selector_types = 0; guint selector_type_count = 0; - GtkTooltips *tt = gtk_tooltips_new (); - /* tempory hardcoding to get types loaded */ SP_TYPE_COLOR_SCALES; SP_TYPE_COLOR_WHEEL_SELECTOR; @@ -336,24 +334,21 @@ void ColorNotebook::init() _box_colormanaged = gtk_event_box_new (); GtkWidget *colormanaged = gtk_image_new_from_icon_name ("color-management-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_container_add (GTK_CONTAINER (_box_colormanaged), colormanaged); - GtkTooltips *tooltips_colormanaged = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips_colormanaged, _box_colormanaged, _("Color Managed"), ""); + gtk_widget_set_tooltip_text (_box_colormanaged, _("Color Managed")); gtk_widget_set_sensitive (_box_colormanaged, false); gtk_box_pack_start(GTK_BOX(rgbabox), _box_colormanaged, FALSE, FALSE, 2); _box_outofgamut = gtk_event_box_new (); GtkWidget *outofgamut = gtk_image_new_from_icon_name ("out-of-gamut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_container_add (GTK_CONTAINER (_box_outofgamut), outofgamut); - GtkTooltips *tooltips_outofgamut = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips_outofgamut, _box_outofgamut, _("Out of gamut!"), ""); + gtk_widget_set_tooltip_text (_box_outofgamut, _("Out of gamut!")); gtk_widget_set_sensitive (_box_outofgamut, false); gtk_box_pack_start(GTK_BOX(rgbabox), _box_outofgamut, FALSE, FALSE, 2); _box_toomuchink = gtk_event_box_new (); GtkWidget *toomuchink = gtk_image_new_from_icon_name ("too-much-ink-icon", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_container_add (GTK_CONTAINER (_box_toomuchink), toomuchink); - GtkTooltips *tooltips_toomuchink = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips_toomuchink, _box_toomuchink, _("Too much ink!"), ""); + gtk_widget_set_tooltip_text (_box_toomuchink, _("Too much ink!")); gtk_widget_set_sensitive (_box_toomuchink, false); gtk_box_pack_start(GTK_BOX(rgbabox), _box_toomuchink, FALSE, FALSE, 2); @@ -368,7 +363,7 @@ void ColorNotebook::init() sp_dialog_defocus_on_enter (_rgbae); gtk_entry_set_max_length (GTK_ENTRY (_rgbae), 8); gtk_entry_set_width_chars (GTK_ENTRY (_rgbae), 8); - gtk_tooltips_set_tip (tt, _rgbae, _("Hexadecimal RGBA value of the color"), NULL); + gtk_widget_set_tooltip_text (_rgbae, _("Hexadecimal RGBA value of the color")); gtk_box_pack_start(GTK_BOX(rgbabox), _rgbae, FALSE, FALSE, 0); gtk_label_set_mnemonic_widget (GTK_LABEL(_rgbal), _rgbae); diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index fb8bb0795..001b54752 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -140,8 +140,6 @@ void ColorScales::init() _updating = FALSE; _dragging = FALSE; - _tt = gtk_tooltips_new(); - t = gtk_table_new (5, 3, FALSE); gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 0); @@ -402,17 +400,17 @@ void ColorScales::setMode(SPColorScalesMode mode) case SP_COLOR_SCALES_MODE_RGB: _setRangeLimit(255.0); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_R:")); - gtk_tooltips_set_tip (_tt, _s[0], _("Red"), NULL); - gtk_tooltips_set_tip (_tt, _b[0], _("Red"), NULL); + gtk_widget_set_tooltip_text (_s[0], _("Red")); + gtk_widget_set_tooltip_text (_b[0], _("Red")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_G:")); - gtk_tooltips_set_tip (_tt, _s[1], _("Green"), NULL); - gtk_tooltips_set_tip (_tt, _b[1], _("Green"), NULL); + gtk_widget_set_tooltip_text (_s[1], _("Green")); + gtk_widget_set_tooltip_text (_b[1], _("Green")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_B:")); - gtk_tooltips_set_tip (_tt, _s[2], _("Blue"), NULL); - gtk_tooltips_set_tip (_tt, _b[2], _("Blue"), NULL); + gtk_widget_set_tooltip_text (_s[2], _("Blue")); + gtk_widget_set_tooltip_text (_b[2], _("Blue")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_A:")); - gtk_tooltips_set_tip (_tt, _s[3], _("Alpha (opacity)"), NULL); - gtk_tooltips_set_tip (_tt, _b[3], _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_s[3], _("Alpha (opacity)")); + gtk_widget_set_tooltip_text (_b[3], _("Alpha (opacity)")); sp_color_slider_set_map (SP_COLOR_SLIDER (_s[0]), NULL); gtk_widget_hide (_l[4]); gtk_widget_hide (_s[4]); @@ -428,17 +426,17 @@ void ColorScales::setMode(SPColorScalesMode mode) case SP_COLOR_SCALES_MODE_HSV: _setRangeLimit(255.0); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_H:")); - gtk_tooltips_set_tip (_tt, _s[0], _("Hue"), NULL); - gtk_tooltips_set_tip (_tt, _b[0], _("Hue"), NULL); + gtk_widget_set_tooltip_text (_s[0], _("Hue")); + gtk_widget_set_tooltip_text (_b[0], _("Hue")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_S:")); - gtk_tooltips_set_tip (_tt, _s[1], _("Saturation"), NULL); - gtk_tooltips_set_tip (_tt, _b[1], _("Saturation"), NULL); + gtk_widget_set_tooltip_text (_s[1], _("Saturation")); + gtk_widget_set_tooltip_text (_b[1], _("Saturation")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_L:")); - gtk_tooltips_set_tip (_tt, _s[2], _("Lightness"), NULL); - gtk_tooltips_set_tip (_tt, _b[2], _("Lightness"), NULL); + gtk_widget_set_tooltip_text (_s[2], _("Lightness")); + gtk_widget_set_tooltip_text (_b[2], _("Lightness")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_A:")); - gtk_tooltips_set_tip (_tt, _s[3], _("Alpha (opacity)"), NULL); - gtk_tooltips_set_tip (_tt, _b[3], _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_s[3], _("Alpha (opacity)")); + gtk_widget_set_tooltip_text (_b[3], _("Alpha (opacity)")); sp_color_slider_set_map (SP_COLOR_SLIDER (_s[0]), (guchar*)sp_color_scales_hue_map ()); gtk_widget_hide (_l[4]); gtk_widget_hide (_s[4]); @@ -456,20 +454,20 @@ void ColorScales::setMode(SPColorScalesMode mode) case SP_COLOR_SCALES_MODE_CMYK: _setRangeLimit(100.0); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[0]), _("_C:")); - gtk_tooltips_set_tip (_tt, _s[0], _("Cyan"), NULL); - gtk_tooltips_set_tip (_tt, _b[0], _("Cyan"), NULL); + gtk_widget_set_tooltip_text (_s[0], _("Cyan")); + gtk_widget_set_tooltip_text (_b[0], _("Cyan")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[1]), _("_M:")); - gtk_tooltips_set_tip (_tt, _s[1], _("Magenta"), NULL); - gtk_tooltips_set_tip (_tt, _b[1], _("Magenta"), NULL); + gtk_widget_set_tooltip_text (_s[1], _("Magenta")); + gtk_widget_set_tooltip_text (_b[1], _("Magenta")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[2]), _("_Y:")); - gtk_tooltips_set_tip (_tt, _s[2], _("Yellow"), NULL); - gtk_tooltips_set_tip (_tt, _b[2], _("Yellow"), NULL); + gtk_widget_set_tooltip_text (_s[2], _("Yellow")); + gtk_widget_set_tooltip_text (_b[2], _("Yellow")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[3]), _("_K:")); - gtk_tooltips_set_tip (_tt, _s[3], _("Black"), NULL); - gtk_tooltips_set_tip (_tt, _b[3], _("Black"), NULL); + gtk_widget_set_tooltip_text (_s[3], _("Black")); + gtk_widget_set_tooltip_text (_b[3], _("Black")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (_l[4]), _("_A:")); - gtk_tooltips_set_tip (_tt, _s[4], _("Alpha (opacity)"), NULL); - gtk_tooltips_set_tip (_tt, _b[4], _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_s[4], _("Alpha (opacity)")); + gtk_widget_set_tooltip_text (_b[4], _("Alpha (opacity)")); sp_color_slider_set_map (SP_COLOR_SLIDER (_s[0]), NULL); gtk_widget_show (_l[4]); gtk_widget_show (_s[4]); diff --git a/src/widgets/sp-color-scales.h b/src/widgets/sp-color-scales.h index b50c386e8..798a920af 100644 --- a/src/widgets/sp-color-scales.h +++ b/src/widgets/sp-color-scales.h @@ -65,8 +65,6 @@ protected: GtkWidget *_b[5]; /* Spinbuttons */ GtkWidget *_l[5]; /* Labels */ - GtkTooltips *_tt; /* tooltip container */ - private: // By default, disallow copy constructor and assignment operator ColorScales(ColorScales const &obj); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 147c91525..25ba250a7 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -152,8 +152,6 @@ void ColorWheelSelector::init() _updating = FALSE; _dragging = FALSE; - _tt = gtk_tooltips_new(); - t = gtk_table_new (5, 3, FALSE); gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 0); @@ -179,7 +177,7 @@ void ColorWheelSelector::init() /* Slider */ _slider = sp_color_slider_new (_adj); - gtk_tooltips_set_tip (_tt, _slider, _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); gtk_widget_show (_slider); gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD); @@ -191,7 +189,7 @@ void ColorWheelSelector::init() /* Spinbutton */ _sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (_adj), 1.0, 0); - gtk_tooltips_set_tip (_tt, _sbtn, _("Alpha (opacity)"), NULL); + gtk_widget_set_tooltip_text (_sbtn, _("Alpha (opacity)")); sp_dialog_defocus_on_enter (_sbtn); gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); gtk_widget_show (_sbtn); diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index 6c8d2d12b..553f351a0 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -44,8 +44,6 @@ protected: GtkWidget* _sbtn; /* Spinbutton */ GtkWidget* _label; /* Label */ - GtkTooltips* _tt; /* tooltip container */ - private: // By default, disallow copy constructor and assignment operator ColorWheelSelector( const ColorWheelSelector& obj ); diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 49e3a7495..aec1e2e11 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -92,10 +92,8 @@ GtkWidget *spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *vbox, g_assert (dialog != NULL); g_assert (vbox != NULL); - GtkTooltips *tt = gtk_tooltips_new (); - GtkWidget *b = gtk_check_button_new_with_label (label); - gtk_tooltips_set_tip(tt, b, tip, NULL); + gtk_widget_set_tooltip_text(b, tip); g_assert (b != NULL); gtk_widget_show (b); gtk_box_pack_start (GTK_BOX (vbox), b, FALSE, FALSE, 0); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 0dcecfcb1..238e5df7a 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -548,11 +548,11 @@ static void update_commands_toolbox(SPDesktop *desktop, SPEventContext *eventcon static GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type, Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb, - Inkscape::UI::View::View *view, GtkTooltips *tt); + Inkscape::UI::View::View *view); class VerbAction : public Gtk::Action { public: - static Glib::RefPtr<VerbAction> create(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view, GtkTooltips *tooltips); + static Glib::RefPtr<VerbAction> create(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view); virtual ~VerbAction(); virtual void set_active(bool active = true); @@ -570,31 +570,29 @@ private: Inkscape::Verb* verb; Inkscape::Verb* verb2; Inkscape::UI::View::View *view; - GtkTooltips *tooltips; bool active; - VerbAction(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view, GtkTooltips *tooltips); + VerbAction(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view); }; -Glib::RefPtr<VerbAction> VerbAction::create(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view, GtkTooltips *tooltips) +Glib::RefPtr<VerbAction> VerbAction::create(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view) { Glib::RefPtr<VerbAction> result; SPAction *action = verb->get_action(view); if ( action ) { //SPAction* action2 = verb2 ? verb2->get_action(view) : 0; - result = Glib::RefPtr<VerbAction>(new VerbAction(verb, verb2, view, tooltips)); + result = Glib::RefPtr<VerbAction>(new VerbAction(verb, verb2, view)); } return result; } -VerbAction::VerbAction(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view, GtkTooltips *tooltips) : +VerbAction::VerbAction(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view) : Gtk::Action(Glib::ustring(verb->get_id()), Gtk::StockID(verb->get_image()), Glib::ustring(_(verb->get_name())), Glib::ustring(_(verb->get_tip()))), verb(verb), verb2(verb2), view(view), - tooltips(tooltips), active(false) { } @@ -624,8 +622,7 @@ Gtk::Widget* VerbAction::create_tool_item_vfunc() SP_BUTTON_TYPE_TOGGLE, verb, verb2, - view, - tooltips ); + view ); if ( active ) { sp_button_toggle_set_down( SP_BUTTON(button), active); } @@ -808,7 +805,7 @@ static void delete_prefspusher(GtkObject * /*obj*/, PrefPusher *watcher ) GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inkscape::IconSize size, SPButtonType type, Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb, - Inkscape::UI::View::View *view, GtkTooltips *tt) + Inkscape::UI::View::View *view) { SPAction *action = verb->get_action(view); if (!action) { @@ -824,7 +821,7 @@ GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick(GtkWidget *t, Inksc /* fixme: Handle sensitive/unsensitive */ /* fixme: Implement sp_button_new_from_action */ - GtkWidget *b = sp_button_new(size, type, action, doubleclick_action, tt); + GtkWidget *b = sp_button_new(size, type, action, doubleclick_action); gtk_widget_show(b); @@ -959,9 +956,8 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto } if ( !mainActions->get_action("ToolZoom") ) { - GtkTooltips *tt = gtk_tooltips_new(); for ( guint i = 0; i < G_N_ELEMENTS(tools) && tools[i].type_name; i++ ) { - Glib::RefPtr<VerbAction> va = VerbAction::create(Inkscape::Verb::get(tools[i].verb), Inkscape::Verb::get(tools[i].doubleclick_verb), view, tt); + Glib::RefPtr<VerbAction> va = VerbAction::create(Inkscape::Verb::get(tools[i].verb), Inkscape::Verb::get(tools[i].doubleclick_verb), view); if ( va ) { mainActions->add(va); if ( i == 0 ) { -- cgit v1.2.3 From 22b40932609acd551b39fd901a96cac84f994744 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sun, 5 Jun 2011 19:33:02 +0200 Subject: fix: latex width output to postscript big point 'bp'. Fixed bugs: - https://launchpad.net/bugs/792384 (bzr r10257) --- src/extension/internal/latex-text-renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index cf7c48251..5d9fec905 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -10,7 +10,7 @@ * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma * - * Copyright (C) 2006-2010 Authors + * Copyright (C) 2006-2011 Authors * * Licensed under GNU GPL */ @@ -621,7 +621,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * // scaling of the image when including it in LaTeX os << " \\ifx\\svgwidth\\undefined%\n"; - os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "pt}%\n"; + os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 os << " \\ifx\\svgscale\\undefined%\n"; os << " \\relax%\n"; os << " \\else%\n"; -- cgit v1.2.3 From da2a6c9d0f013483a708cad53bb83c0d0766bd69 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 6 Jun 2011 20:21:21 -0300 Subject: Introducing our new nice measurement tool! :-D (bzr r10259) --- src/Makefile_insert | 3 +- src/measure-context.cpp | 237 +++++++++++++++++++++++++++++++++++ src/measure-context.h | 35 ++++++ src/tools-switch.cpp | 8 ++ src/tools-switch.h | 1 + src/ui/dialog/inkscape-preferences.h | 1 + src/ui/icon-names.h | 2 + src/verbs.cpp | 11 ++ src/verbs.h | 2 + src/widgets/toolbox.cpp | 15 ++- 10 files changed, 313 insertions(+), 2 deletions(-) create mode 100644 src/measure-context.cpp create mode 100644 src/measure-context.h (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index e7bf9715a..aadf9d404 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -251,7 +251,8 @@ ink_common_sources += \ vanishing-point.cpp vanishing-point.h \ verbs.cpp verbs.h \ version.cpp version.h \ - zoom-context.cpp zoom-context.h + zoom-context.cpp zoom-context.h \ + measure-context.cpp measure-context.h # Additional dependencies diff --git a/src/measure-context.cpp b/src/measure-context.cpp new file mode 100644 index 000000000..1e0339424 --- /dev/null +++ b/src/measure-context.cpp @@ -0,0 +1,237 @@ +/* + * Our nice measuring tool + * + * Authors: + * Felipe Correa da Silva Sanches <juca@members.fsf.org> + * + * Copyright (C) 2011 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + +#include <gdk/gdkkeysyms.h> + +#include "macros.h" +#include "display/sp-ctrlline.h" +#include "display/sp-canvas-item.h" +#include "display/sp-canvas-util.h" +#include "desktop.h" +#include "pixmaps/cursor-measure.xpm" +#include "preferences.h" +#include "inkscape.h" +#include "desktop-handles.h" +#include "measure-context.h" +#include "display/canvas-text.h" + +static void sp_measure_context_class_init(SPMeasureContextClass *klass); +static void sp_measure_context_init(SPMeasureContext *measure_context); +static void sp_measure_context_setup(SPEventContext *ec); +static void sp_measure_context_finish (SPEventContext *ec); + +static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event); +static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); + +static SPEventContextClass *parent_class; + +static gint xp = 0, yp = 0; // where drag started +static gint tolerance = 0; +static bool within_tolerance = false; +static SPCanvasItem * line = NULL; +Geom::Point start_point; +SPCanvasItem *measure_text = NULL; + +GType sp_measure_context_get_type(void) +{ + static GType type = 0; + + if (!type) { + GTypeInfo info = { + sizeof(SPMeasureContextClass), + NULL, NULL, + (GClassInitFunc) sp_measure_context_class_init, + NULL, NULL, + sizeof(SPMeasureContext), + 4, + (GInstanceInitFunc) sp_measure_context_init, + NULL, /* value_table */ + }; + type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeasureContext", &info, (GTypeFlags) 0); + } + + return type; +} + +static void sp_measure_context_class_init(SPMeasureContextClass *klass) +{ + SPEventContextClass *event_context_class = (SPEventContextClass *) klass; + + parent_class = (SPEventContextClass*) g_type_class_peek_parent(klass); + + event_context_class->setup = sp_measure_context_setup; + event_context_class->finish = sp_measure_context_finish; + + event_context_class->root_handler = sp_measure_context_root_handler; + event_context_class->item_handler = sp_measure_context_item_handler; +} + +static void sp_measure_context_init (SPMeasureContext *measure_context) +{ + SPEventContext *event_context = SP_EVENT_CONTEXT(measure_context); + + event_context->cursor_shape = cursor_measure_xpm; + event_context->hot_x = 3; + event_context->hot_y = 5; +} + +static void +sp_measure_context_finish (SPEventContext *ec) +{ + SPMeasureContext *mc = SP_MEASURE_CONTEXT(ec); + + ec->enableGrDrag(false); + + if (mc->grabbed) { + sp_canvas_item_ungrab(mc->grabbed, GDK_CURRENT_TIME); + mc->grabbed = NULL; + } +} + +static void sp_measure_context_setup(SPEventContext *ec) +{ + if (((SPEventContextClass *) parent_class)->setup) { + ((SPEventContextClass *) parent_class)->setup(ec); + } +} + +static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) +{ + gint ret = FALSE; + + if (((SPEventContextClass *) parent_class)->item_handler) { + ret = ((SPEventContextClass *) parent_class)->item_handler (event_context, item, event); + } + + return ret; +} + +static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event) +{ + SPDesktop *desktop = event_context->desktop; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); + + SPMeasureContext *mc = SP_MEASURE_CONTEXT(event_context); + gint ret = FALSE; + + switch (event->type) { + case GDK_BUTTON_PRESS: + { + Geom::Point const button_w(event->button.x, event->button.y); + start_point = desktop->w2d(button_w); + if (event->button.button == 1 && !event_context->space_panning) { + // save drag origin + xp = (gint) event->button.x; + yp = (gint) event->button.y; + within_tolerance = true; + + ret = TRUE; + } + + if (!line){ + SPDesktop *desktop = inkscape_active_desktop(); + line = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL); + } + + if (!measure_text){ + measure_text = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, start_point, ""); + SP_CANVASTEXT(measure_text)->rgba = 0x7f7f7fff; + sp_canvastext_set_anchor(SP_CANVASTEXT(measure_text), -1, 1);//why? + } + + sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point, start_point); + sp_canvastext_set_text (SP_CANVASTEXT(measure_text), ""); + sp_canvas_item_show (line); + sp_canvas_item_show (measure_text); + + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, + NULL, event->button.time); + mc->grabbed = SP_CANVAS_ITEM(desktop->acetate); + break; + } + + case GDK_MOTION_NOTIFY: + { + if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) { + ret = TRUE; + + if ( within_tolerance + && ( abs( (gint) event->motion.x - xp ) < tolerance ) + && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) { + break; // do not drag if we're within tolerance from origin + } + // Once the user has moved farther than tolerance from the original location + // (indicating they intend to move the object, not click), then always process the + // motion notify coordinates as given (no snapping back to origin) + within_tolerance = false; + + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const motion_dt(desktop->w2d(motion_w)); + + sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], motion_dt[Geom::X], motion_dt[Geom::Y]); + + Geom::Point measure_text_pos = (start_point + motion_dt)/2; + double length = (start_point - motion_dt).length(); + char* measure_str = (char*) malloc(sizeof(char)*20); + sprintf(measure_str, "%2f", length); + + sp_canvastext_set_coords (SP_CANVASTEXT(measure_text), desktop->dt2doc(measure_text_pos)); + sp_canvastext_set_text (SP_CANVASTEXT(measure_text), measure_str); + free(measure_str); + + gobble_motion_events(GDK_BUTTON1_MASK); + } + break; + } + + case GDK_BUTTON_RELEASE: + { + if (line){ + sp_canvas_item_hide(line); + } + + if (measure_text){ + sp_canvas_item_hide(measure_text); + } + + if (mc->grabbed) { + sp_canvas_item_ungrab(mc->grabbed, event->button.time); + mc->grabbed = NULL; + } + xp = yp = 0; + break; + } + default: + break; + } + + if (!ret) { + if (((SPEventContextClass *) parent_class)->root_handler) { + ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + } + } + + return ret; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/measure-context.h b/src/measure-context.h new file mode 100644 index 000000000..f6065b3e6 --- /dev/null +++ b/src/measure-context.h @@ -0,0 +1,35 @@ +#ifndef __SP_MEASURING_CONTEXT_H__ +#define __SP_MEASURING_CONTEXT_H__ + +/* + * Our fine measuring tool + * + * Authors: + * Felipe Correa da Silva Sanches <juca@members.fsf.org> + * + * Copyright (C) 2011 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "event-context.h" + +#define SP_TYPE_MEASURE_CONTEXT (sp_measure_context_get_type ()) +#define SP_MEASURE_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) +#define SP_IS_MEASURE_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_MEASURE_CONTEXT)) + +class SPMeasureContext; +class SPMeasureContextClass; + +struct SPMeasureContext { + SPEventContext event_context; + SPCanvasItem *grabbed; +}; + +struct SPMeasureContextClass { + SPEventContextClass parent_class; +}; + +GType sp_measure_context_get_type (void); + +#endif diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 1f624cc35..42eaf4474 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -50,6 +50,7 @@ #include "sp-flowtext.h" #include "gradient-context.h" #include "zoom-context.h" +#include "measure-context.h" #include "dropper-context.h" #include "connector-context.h" #include "flood-context.h" @@ -75,6 +76,7 @@ static char const *const tool_names[] = { "/tools/text", "/tools/gradient", "/tools/zoom", + "/tools/measure", "/tools/dropper", "/tools/connector", "/tools/paintbucket", @@ -208,6 +210,12 @@ tools_switch(SPDesktop *dt, int num) inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>drag around an area</b> to zoom in, <b>Shift+click</b> to zoom out.")); break; + case TOOLS_MEASURE: + dt->set_event_context(SP_TYPE_MEASURE_CONTEXT, tool_names[num]); + dt->activate_guides(false); + inkscape_eventcontext_set(sp_desktop_event_context(dt)); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to measure the dimensions of objects.")); + break; case TOOLS_DROPPER: dt->set_event_context(SP_TYPE_DROPPER_CONTEXT, tool_names[num]); dt->activate_guides(false); diff --git a/src/tools-switch.h b/src/tools-switch.h index 4cc9aa93d..75c728179 100644 --- a/src/tools-switch.h +++ b/src/tools-switch.h @@ -31,6 +31,7 @@ enum { TOOLS_TEXT, TOOLS_GRADIENT, TOOLS_ZOOM, + TOOLS_MEASURE, TOOLS_DROPPER, TOOLS_CONNECTOR, TOOLS_PAINTBUCKET, diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index eede9eafe..34bf1e87a 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -46,6 +46,7 @@ enum { PREFS_PAGE_TOOLS_TWEAK, PREFS_PAGE_TOOLS_SPRAY, PREFS_PAGE_TOOLS_ZOOM, + PREFS_PAGE_TOOLS_MEASURE, PREFS_PAGE_TOOLS_SHAPES, PREFS_PAGE_TOOLS_SHAPES_RECT, PREFS_PAGE_TOOLS_SHAPES_3DBOX, diff --git a/src/ui/icon-names.h b/src/ui/icon-names.h index 2ec03c5cc..f7c16b0ed 100644 --- a/src/ui/icon-names.h +++ b/src/ui/icon-names.h @@ -556,6 +556,8 @@ "xml-text-new" #define INKSCAPE_ICON_ZOOM \ "zoom" +#define INKSCAPE_ICON_MEASURE \ + "measure" #define INKSCAPE_ICON_ZOOM_DOUBLE_SIZE \ "zoom-double-size" #define INKSCAPE_ICON_ZOOM_FIT_DRAWING \ diff --git a/src/verbs.cpp b/src/verbs.cpp index de935f700..c332cc93d 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1466,6 +1466,9 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/) case SP_VERB_CONTEXT_ZOOM: tools_switch(dt, TOOLS_ZOOM); break; + case SP_VERB_CONTEXT_MEASURE: + tools_switch(dt, TOOLS_MEASURE); + break; case SP_VERB_CONTEXT_DROPPER: tools_switch(dt, TOOLS_DROPPER); break; @@ -1542,6 +1545,10 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/) prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_ZOOM); dt->_dlg_mgr->showDialog("InkscapePreferences"); break; + case SP_VERB_CONTEXT_MEASURE_PREFS: + prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_MEASURE); + dt->_dlg_mgr->showDialog("InkscapePreferences"); + break; case SP_VERB_CONTEXT_DROPPER_PREFS: prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_DROPPER); dt->_dlg_mgr->showDialog("InkscapePreferences"); @@ -2522,6 +2529,8 @@ Verb *Verb::_base_verbs[] = { N_("Create and edit gradients"), INKSCAPE_ICON_COLOR_GRADIENT), new ContextVerb(SP_VERB_CONTEXT_ZOOM, "ToolZoom", N_("Zoom"), N_("Zoom in or out"), INKSCAPE_ICON_ZOOM), + new ContextVerb(SP_VERB_CONTEXT_MEASURE, "ToolMeasure", N_("Measure"), + N_("Measurement tool"), INKSCAPE_ICON_MEASURE), new ContextVerb(SP_VERB_CONTEXT_DROPPER, "ToolDropper", N_("Dropper"), N_("Pick colors from image"), INKSCAPE_ICON_COLOR_PICKER), new ContextVerb(SP_VERB_CONTEXT_CONNECTOR, "ToolConnector", N_("Connector"), @@ -2565,6 +2574,8 @@ Verb *Verb::_base_verbs[] = { N_("Open Preferences for the Gradient tool"), NULL), new ContextVerb(SP_VERB_CONTEXT_ZOOM_PREFS, "ZoomPrefs", N_("Zoom Preferences"), N_("Open Preferences for the Zoom tool"), NULL), + new ContextVerb(SP_VERB_CONTEXT_MEASURE_PREFS, "MeasurePrefs", N_("Measure Preferences"), + N_("Open Preferences for the Measure tool"), NULL), new ContextVerb(SP_VERB_CONTEXT_DROPPER_PREFS, "DropperPrefs", N_("Dropper Preferences"), N_("Open Preferences for the Dropper tool"), NULL), new ContextVerb(SP_VERB_CONTEXT_CONNECTOR_PREFS, "ConnectorPrefs", N_("Connector Preferences"), diff --git a/src/verbs.h b/src/verbs.h index 0c781f0b6..de7a96797 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -165,6 +165,7 @@ enum { SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_ZOOM, + SP_VERB_CONTEXT_MEASURE, SP_VERB_CONTEXT_DROPPER, SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_PAINTBUCKET, @@ -187,6 +188,7 @@ enum { SP_VERB_CONTEXT_TEXT_PREFS, SP_VERB_CONTEXT_GRADIENT_PREFS, SP_VERB_CONTEXT_ZOOM_PREFS, + SP_VERB_CONTEXT_MEASURE_PREFS, SP_VERB_CONTEXT_DROPPER_PREFS, SP_VERB_CONTEXT_CONNECTOR_PREFS, SP_VERB_CONTEXT_PAINTBUCKET_PREFS, diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 0dcecfcb1..9c3a8346e 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -133,6 +133,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainA static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); static void sp_zoom_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); +static void sp_measure_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); @@ -174,6 +175,7 @@ static struct { { "SPTweakContext", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS }, { "SPSprayContext", "spray_tool", SP_VERB_CONTEXT_SPRAY, SP_VERB_CONTEXT_SPRAY_PREFS }, { "SPZoomContext", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS }, + { "SPMeasureContext", "measure_tool", SP_VERB_CONTEXT_MEASURE, SP_VERB_CONTEXT_MEASURE_PREFS }, { "SPRectContext", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS }, { "Box3DContext", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS }, { "SPArcContext", "arc_tool", SP_VERB_CONTEXT_ARC, SP_VERB_CONTEXT_ARC_PREFS }, @@ -212,6 +214,8 @@ static struct { SP_VERB_INVALID, 0, 0}, { "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar", SP_VERB_INVALID, 0, 0}, + { "SPMeasureContext", "measure_toolbox", 0, sp_measure_toolbox_prep, "MeasureToolbar", + SP_VERB_INVALID, 0, 0}, { "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar", SP_VERB_CONTEXT_STAR_PREFS, "/tools/shapes/star", N_("Style of new stars")}, { "SPRectContext", "rect_toolbox", 0, sp_rect_toolbox_prep, "RectToolbar", @@ -361,6 +365,9 @@ static gchar const * ui_descr = " <toolitem action='ZoomNext' />" " </toolbar>" + " <toolbar name='MeasureToolbar'>" + " </toolbar>" + " <toolbar name='StarToolbar'>" " <separator />" " <toolitem action='StarStateAction' />" @@ -932,7 +939,7 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto SP_VERB_ZOOM_PAGE, SP_VERB_ZOOM_PAGE_WIDTH, SP_VERB_ZOOM_PREV, - SP_VERB_ZOOM_SELECTION, + SP_VERB_ZOOM_SELECTION }; Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small"); @@ -1627,6 +1634,11 @@ static void sp_zoom_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* /*main // no custom GtkAction setup needed } // end of sp_zoom_toolbox_prep() +static void sp_measure_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* /*mainActions*/, GObject* /*holder*/) +{ + // no custom GtkAction setup needed +} // end of sp_measure_toolbox_prep() + void ToolboxFactory::setToolboxDesktop(GtkWidget *toolbox, SPDesktop *desktop) { sigc::connection *conn = static_cast<sigc::connection*>(g_object_get_data(G_OBJECT(toolbox), @@ -1838,6 +1850,7 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) " <toolitem action='ToolNode' />" " <toolitem action='ToolTweak' />" " <toolitem action='ToolZoom' />" + " <toolitem action='ToolMeasure' />" " <!-- Shapes -->" " <toolitem action='ToolRect' />" -- cgit v1.2.3 From eddb7a227c8d55d166a28958a027c85c0df87471 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 6 Jun 2011 20:53:45 -0300 Subject: adding cursor for the measure tool that I forgot to commit in the previous revision. (bzr r10260) --- src/pixmaps/cursor-measure.xpm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/pixmaps/cursor-measure.xpm (limited to 'src') diff --git a/src/pixmaps/cursor-measure.xpm b/src/pixmaps/cursor-measure.xpm new file mode 100644 index 000000000..5f546e2cf --- /dev/null +++ b/src/pixmaps/cursor-measure.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char * cursor_measure_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" .. ", +" .++. ", +" .+..+. ", +" .+....+. ", +".+..+...+. ", +".+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+.+. ", +" .+.+.+. ", +" .+.+. ", +" .+. ", +" . ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; -- cgit v1.2.3 From 0aae946f3b68687c72f547612abe7940098a98d4 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Tue, 7 Jun 2011 22:02:08 -0700 Subject: Fix const on new icon. (bzr r10262) --- src/pixmaps/cursor-measure.xpm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pixmaps/cursor-measure.xpm b/src/pixmaps/cursor-measure.xpm index 5f546e2cf..753bfd14e 100644 --- a/src/pixmaps/cursor-measure.xpm +++ b/src/pixmaps/cursor-measure.xpm @@ -1,5 +1,5 @@ /* XPM */ -static char * cursor_measure_xpm[] = { +static char const * cursor_measure_xpm[] = { "32 32 3 1", " c None", ". c #FFFFFF", -- cgit v1.2.3 From cff58b6bd80f0fb13ab65daea0d92eafd5213ff2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Wed, 8 Jun 2011 20:23:27 +0200 Subject: Save a copy dialog now opens in current directory if this option is set for save as... dialog. (there is also the possibility to manually change the preferences file to change this option independently from save as... dialog) Fixed bugs: - https://launchpad.net/bugs/791098 (bzr r10263) --- src/extension/system.cpp | 10 ++++++++-- src/ui/dialog/inkscape-preferences.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/system.cpp b/src/extension/system.cpp index aa5731985..b3b64ca7d 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -590,10 +590,11 @@ Glib::ustring get_file_save_path (SPDocument *doc, FileSaveMethod method) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring path; + bool use_current_dir = true; switch (method) { case FILE_SAVE_METHOD_SAVE_AS: { - bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true); + use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true); if (doc->getURI() && use_current_dir) { path = Glib::path_get_dirname(doc->getURI()); } else { @@ -605,7 +606,12 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) { path = prefs->getString("/dialogs/save_as/path"); break; case FILE_SAVE_METHOD_SAVE_COPY: - path = prefs->getString("/dialogs/save_copy/path"); + use_current_dir = prefs->getBool("/dialogs/save_copy/use_current_dir", prefs->getBool("/dialogs/save_as/use_current_dir", true)); + if (doc->getURI() && use_current_dir) { + path = Glib::path_get_dirname(doc->getURI()); + } else { + path = prefs->getString("/dialogs/save_copy/path"); + } break; case FILE_SAVE_METHOD_INKSCAPE_SVG: if (doc->getURI()) { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index ad3553b86..447e50831 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1203,7 +1203,7 @@ void InkscapePreferences::initPageSave() { _save_use_current_dir.init( _("Use current directory for \"Save As ...\""), "/dialogs/save_as/use_current_dir", true); _page_save.add_line( false, "", _save_use_current_dir, "", - _("When this option is on, the \"Save as...\" dialog will always open in the directory where the currently open document is; when it's off, it will open in the directory where you last saved a file using that dialog"), true); + _("When this option is on, the \"Save as...\" and \"Save a Copy\" dialogs will always open in the directory where the currently open document is; when it's off, each will open in the directory where you last saved a file using it"), true); // Autosave options -- cgit v1.2.3 From dfde4e23bca26c30ced909192947e147cf1e639e Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Thu, 9 Jun 2011 04:58:18 -0300 Subject: improving the measurement tool Now it detects intersections and displays crosses indicating them the length value displayed corresponds to the first line-segment TODO: display all segment lengths (bzr r10264) --- src/measure-context.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 1e0339424..f89878f7e 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -13,16 +13,25 @@ #include <gdk/gdkkeysyms.h> #include "macros.h" +#include "display/curve.h" +#include "sp-shape.h" #include "display/sp-ctrlline.h" +#include "display/sodipodi-ctrl.h" #include "display/sp-canvas-item.h" #include "display/sp-canvas-util.h" #include "desktop.h" +#include "document.h" #include "pixmaps/cursor-measure.xpm" #include "preferences.h" #include "inkscape.h" #include "desktop-handles.h" #include "measure-context.h" #include "display/canvas-text.h" +#include "path-chemistry.h" +#include "2geom/line.h" +#include <2geom/path-intersection.h> +#include <2geom/pathvector.h> +#include <2geom/crossing.h> static void sp_measure_context_class_init(SPMeasureContextClass *klass); static void sp_measure_context_init(SPMeasureContext *measure_context); @@ -181,10 +190,100 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], motion_dt[Geom::X], motion_dt[Geom::Y]); - Geom::Point measure_text_pos = (start_point + motion_dt)/2; - double length = (start_point - motion_dt).length(); + + //our control line + Geom::PathVector line; + Geom::Path p; + p.start(desktop->dt2doc(start_point)); + p.appendNew<Geom::LineSegment>(desktop->dt2doc(motion_dt)); + line.push_back(p); + + std::vector<Geom::Point> points; + int i; + for (i=0; i<30; i++){ + points.push_back(start_point + i*(motion_dt-start_point)/30); + } + + SPDocument *doc = sp_desktop_document(desktop); + GSList *items = sp_desktop_document(desktop)->getItemsInBox(desktop->dkey, Geom::Rect(start_point, motion_dt)); + double length; +//TODO: select elements crossed by line segment: +// GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); + SPItem* item; + GSList *l; + int counter=0; + std::vector<Geom::Point> intersections; + for (l = items; l != NULL; l = l->next){ + item = (SPItem*) (l->data); +#if 0 +//TODO: deal with all kinds of objects: + + Inkscape::XML::Node *repr = sp_selected_item_to_curved_repr(item, 0); + + if (!repr) continue; + item = (SPItem *) doc->getObjectByRepr(repr); + if (!item) continue; + SPCurve* curve = SP_SHAPE(item)->getCurve(); +#else + SPCurve* curve = NULL; + if (SP_IS_SHAPE(item)) { + curve = SP_SHAPE(item)->getCurve(); + } +#endif + if (!curve) continue; + counter++; + + Geom::PathVector pathv = curve->get_pathvector(); + + // Find all intersections of the control-line with this shape + Geom::CrossingSet cs = Geom::crossings(line, pathv); + // Store the results as intersection points + unsigned int index = 0; + for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); i++) { + if (index >= line.size()) { + break; + } + // Reconstruct and store the points of intersection + for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); m++) { + intersections.push_back(line[index].pointAt((*m).ta)); + } + index++; + } + //g_free(repr); + } + + Geom::Point pa = start_point; + Geom::Point pb = motion_dt; + + if (intersections.size() >= 2){ + pa = desktop->doc2dt(intersections[0]); + pb = desktop->doc2dt(intersections[1]); + } + + unsigned int idx; + for (idx=0;idx<intersections.size(); idx++){ + // Display the intersection indicator (i.e. the cross) + SPCanvasItem * canvasitem = NULL; + canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (desktop), + SP_TYPE_CTRL, + "anchor", GTK_ANCHOR_CENTER, + "size", 5.0, + "stroked", TRUE, + "stroke_color", 0xff0000ff, + "mode", SP_KNOT_MODE_XOR, + "shape", SP_KNOT_SHAPE_CROSS, + NULL ); + + SP_CTRL(canvasitem)->moveto(desktop->doc2dt(intersections[idx])); + desktop->add_temporary_canvasitem(canvasitem, 100); + } + + + Geom::Point measure_text_pos = (pa + pb)/2; + + length = (pa - pb).length(); char* measure_str = (char*) malloc(sizeof(char)*20); - sprintf(measure_str, "%2f", length); + sprintf(measure_str, "%f", length); sp_canvastext_set_coords (SP_CANVASTEXT(measure_text), desktop->dt2doc(measure_text_pos)); sp_canvastext_set_text (SP_CANVASTEXT(measure_text), measure_str); -- cgit v1.2.3 From 31099efbe04b0b71835f11a077ddd6fce7010d9d Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Thu, 9 Jun 2011 22:09:54 -0300 Subject: improving measurement tool (bzr r10265) --- src/measure-context.cpp | 57 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index f89878f7e..2aeb39d5d 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -124,6 +124,11 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte return ret; } +bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) +{ + return p1[Geom::Y] < p2[Geom::Y]; +} + static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event) { SPDesktop *desktop = event_context->desktop; @@ -199,20 +204,21 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv line.push_back(p); std::vector<Geom::Point> points; - int i; - for (i=0; i<30; i++){ - points.push_back(start_point + i*(motion_dt-start_point)/30); + double i; +#define NPOINTS 3000 + for (i=0; i<NPOINTS; i++){ + points.push_back(desktop->d2w(start_point + (i/NPOINTS)*(motion_dt-start_point))); } - SPDocument *doc = sp_desktop_document(desktop); - GSList *items = sp_desktop_document(desktop)->getItemsInBox(desktop->dkey, Geom::Rect(start_point, motion_dt)); double length; -//TODO: select elements crossed by line segment: -// GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); +//select elements crossed by line segment: + GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); SPItem* item; GSList *l; int counter=0; std::vector<Geom::Point> intersections; + intersections.push_back(desktop->dt2doc(start_point)); + for (l = items; l != NULL; l = l->next){ item = (SPItem*) (l->data); #if 0 @@ -251,15 +257,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } //g_free(repr); } - - Geom::Point pa = start_point; - Geom::Point pb = motion_dt; + intersections.push_back(desktop->dt2doc(motion_dt)); - if (intersections.size() >= 2){ - pa = desktop->doc2dt(intersections[0]); - pb = desktop->doc2dt(intersections[1]); - } + //sort intersections + std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); +//TODO: make these not fade out. unsigned int idx; for (idx=0;idx<intersections.size(); idx++){ // Display the intersection indicator (i.e. the cross) @@ -267,7 +270,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRL, "anchor", GTK_ANCHOR_CENTER, - "size", 5.0, + "size", 8.0, "stroked", TRUE, "stroke_color", 0xff0000ff, "mode", SP_KNOT_MODE_XOR, @@ -279,6 +282,29 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } +//TODO: make these not fade out. + Geom::Point previous_point = intersections[0]; + for (idx=1; idx < intersections.size(); idx++){ + Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; + + length = (intersections[idx] - previous_point).length(); + char* measure_str = (char*) malloc(sizeof(char)*20); + sprintf(measure_str, "%f", length); + +// sp_canvastext_set_coords (SP_CANVASTEXT(measure_text), desktop->dt2doc(measure_text_pos)); +// sp_canvastext_set_text (SP_CANVASTEXT(measure_text), measure_str); + +// SPCanvasItem * canvasitem = NULL; + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); + + desktop->add_temporary_canvasitem(canvas_tooltip, 100); + + free(measure_str); + + previous_point = intersections[idx]; + } + +#if 0 Geom::Point measure_text_pos = (pa + pb)/2; length = (pa - pb).length(); @@ -288,6 +314,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv sp_canvastext_set_coords (SP_CANVASTEXT(measure_text), desktop->dt2doc(measure_text_pos)); sp_canvastext_set_text (SP_CANVASTEXT(measure_text), measure_str); free(measure_str); +#endif gobble_motion_events(GDK_BUTTON1_MASK); } -- cgit v1.2.3 From 8bfebadcfb9a99361782320eab0183410a1fdabf Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Fri, 10 Jun 2011 02:46:50 -0700 Subject: Modified build to conditionally build against either libwpg 0.1.x or 0.2.x. Fixes bug #778951. Fixed bugs: - https://launchpad.net/bugs/778951 (bzr r10266) --- src/extension/internal/wpg-input.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 70fa28967..b6425b380 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -50,8 +50,11 @@ #include "document.h" #include "libwpg/libwpg.h" +#if WITH_LIBWPG01 #include "libwpg/WPGStreamImplementation.h" - +#elif WITH_LIBWPG02 +#include "libwpd-stream/libwpd-stream.h" +#endif using namespace libwpg; @@ -62,9 +65,17 @@ namespace Internal { SPDocument * WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) { +#if WITH_LIBWPG01 WPXInputStream* input = new libwpg::WPGFileStream(uri); +#elif WITH_LIBWPG02 + WPXInputStream* input = new WPXFileStream(uri); +#endif if (input->isOLEStream()) { +#if WITH_LIBWPG01 WPXInputStream* olestream = input->getDocumentOLEStream(); +#elif WITH_LIBWPG02 + WPXInputStream* olestream = input->getDocumentOLEStream("PerfectOffice_MAIN"); +#endif if (olestream) { delete input; input = olestream; @@ -79,7 +90,11 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) { return NULL; } +#if WITH_LIBWPG01 libwpg::WPGString output; +#elif WITH_LIBWPG02 + WPXString output; +#endif if (!libwpg::WPGraphics::generateSVG(input, output)) { delete input; return NULL; -- cgit v1.2.3 From a5a2d9c428ceccfddd84f2ff01c3aeac4c37231a Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Fri, 10 Jun 2011 21:47:26 -0700 Subject: Fix debus warnings and build errors. (bzr r10268) --- src/extension/dbus/document-interface.cpp | 172 ++++++++++++++---------------- 1 file changed, 79 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 8e22849b5..4e629a1a9 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -35,6 +35,7 @@ #include "selection.h" //selection struct #include "sp-ellipse.h" #include "sp-object.h" +#include "sp-root.h" #include "style.h" //style_write #include "file.h" //IO @@ -202,8 +203,7 @@ dbus_create_node (SPDesktop *desk, const gchar *type) * There is probably a better way to do this (use the shape tools default styles) * but I'm not sure how. */ -gchar * -finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::Node *newNode, gchar *desc) +gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc) { SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE); @@ -218,11 +218,11 @@ finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::N object->desk->currentLayer()->appendChildRepr(newNode); object->desk->currentLayer()->updateRepr(); - if (object->updates) - - Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)desc); - //else + if (object->updates) { + Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)desc); + //} else { //document_interface_pause_updates(object, error); + } return strdup(newNode->attribute("id")); } @@ -285,7 +285,7 @@ document_interface_class_init (DocumentInterfaceClass *klass) static void document_interface_init (DocumentInterface *object) { - object->desk = NULL; + object->desk = NULL; } @@ -312,37 +312,34 @@ inkscape_error_quark (void) #define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } -GType -inkscape_error_get_type (void) +GType inkscape_error_get_type(void) { - static GType etype = 0; + static GType etype = 0; - if (etype == 0) - { - static const GEnumValue values[] = - { + if (etype == 0) { + static const GEnumValue values[] = + { - ENUM_ENTRY (INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"), - ENUM_ENTRY (INKSCAPE_ERROR_OBJECT, "Incompatible_Object"), - ENUM_ENTRY (INKSCAPE_ERROR_VERB, "Failed_Verb"), - ENUM_ENTRY (INKSCAPE_ERROR_OTHER, "Generic_Error"), - { 0, 0, 0 } - }; + ENUM_ENTRY(INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"), + ENUM_ENTRY(INKSCAPE_ERROR_OBJECT, "Incompatible_Object"), + ENUM_ENTRY(INKSCAPE_ERROR_VERB, "Failed_Verb"), + ENUM_ENTRY(INKSCAPE_ERROR_OTHER, "Generic_Error"), + { 0, 0, 0 } + }; - etype = g_enum_register_static ("InkscapeError", values); - } + etype = g_enum_register_static("InkscapeError", values); + } - return etype; + return etype; } /**************************************************************************** MISC FUNCTIONS ****************************************************************************/ -gboolean -document_interface_delete_all (DocumentInterface *object, GError **error) +gboolean document_interface_delete_all(DocumentInterface *object, GError ** /*error*/) { - sp_edit_clear_all (object->desk); + sp_edit_clear_all(object->desk); return TRUE; } @@ -523,7 +520,7 @@ document_interface_image (DocumentInterface *object, int x, int y, gchar *filena return strdup(newNode->attribute("id")); } -gchar *document_interface_node (DocumentInterface *object, gchar *type, GError **error) +gchar *document_interface_node(DocumentInterface *object, gchar *type, GError ** /*error*/) { SPDocument * doc = sp_desktop_document (object->desk); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); @@ -533,10 +530,11 @@ gchar *document_interface_node (DocumentInterface *object, gchar *type, GError * object->desk->currentLayer()->appendChildRepr(newNode); object->desk->currentLayer()->updateRepr(); - if (object->updates) + if (object->updates) { Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)"created empty node"); - //else + //} else { //document_interface_pause_updates(object, error); + } return strdup(newNode->attribute("id")); } @@ -556,26 +554,23 @@ document_interface_document_get_height (DocumentInterface *object) return sp_desktop_document(object->desk)->getHeight(); } -gchar * -document_interface_document_get_css (DocumentInterface *object, GError **error) +gchar *document_interface_document_get_css(DocumentInterface *object, GError ** /*error*/) { SPCSSAttr *current = (object->desk)->current; return sp_repr_css_write_string(current); } -gboolean -document_interface_document_merge_css (DocumentInterface *object, - gchar *stylestring, GError **error) +gboolean document_interface_document_merge_css(DocumentInterface *object, + gchar *stylestring, GError ** /*error*/) { SPCSSAttr * style = sp_repr_css_attr_new(); - sp_repr_css_attr_add_from_string (style, stylestring); - sp_desktop_set_style (object->desk, style); + sp_repr_css_attr_add_from_string(style, stylestring); + sp_desktop_set_style(object->desk, style); return TRUE; } -gboolean -document_interface_document_set_css (DocumentInterface *object, - gchar *stylestring, GError **error) +gboolean document_interface_document_set_css(DocumentInterface *object, + gchar *stylestring, GError ** /*error*/) { SPCSSAttr * style = sp_repr_css_attr_new(); sp_repr_css_attr_add_from_string (style, stylestring); @@ -808,8 +803,7 @@ document_interface_move_to_layer (DocumentInterface *object, gchar *shape, return TRUE; } -GArray * -document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape) +GArray *document_interface_get_node_coordinates(DocumentInterface * /*object*/, gchar * /*shape*/) { //FIXME: Needs lot's of work. /* @@ -855,29 +849,29 @@ document_interface_save (DocumentInterface *object, GError **error) return FALSE; } -gboolean -document_interface_load (DocumentInterface *object, - gchar *filename, GError **error) +gboolean document_interface_load(DocumentInterface *object, + gchar *filename, GError ** /*error*/) { - desktop_ensure_active (object->desk); + desktop_ensure_active(object->desk); const Glib::ustring file(filename); sp_file_open(file, NULL, TRUE, TRUE); - if (object->updates) + if (object->updates) { Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File"); + } return TRUE; } -gboolean -document_interface_save_as (DocumentInterface *object, - const gchar *filename, GError **error) +gboolean document_interface_save_as(DocumentInterface *object, + const gchar *filename, GError ** /*error*/) { SPDocument * doc = sp_desktop_document(object->desk); #ifdef WITH_GNOME_VFS const Glib::ustring file(filename); return file_save_remote(doc, file, NULL, TRUE, TRUE); #endif - if (!doc || strlen(filename)<1) //Safety check + if (!doc || strlen(filename)<1) { //Safety check return false; + } try { Inkscape::Extension::save(NULL, doc, filename, @@ -892,12 +886,12 @@ document_interface_save_as (DocumentInterface *object, return true; } -gboolean -document_interface_mark_as_unmodified (DocumentInterface *object, GError **error) +gboolean document_interface_mark_as_unmodified(DocumentInterface *object, GError ** /*error*/) { SPDocument * doc = sp_desktop_document(object->desk); - if (doc) + if (doc) { doc->modified_since_save = FALSE; + } return TRUE; } @@ -948,8 +942,7 @@ document_interface_redo (DocumentInterface *object, GError **error) Need to make sure it plays well with verbs because they are used so much. ****************************************************************************/ -void -document_interface_pause_updates (DocumentInterface *object, GError **error) +void document_interface_pause_updates(DocumentInterface *object, GError ** /*error*/) { object->updates = FALSE; object->desk->canvas->drawing_disabled = 1; @@ -959,8 +952,7 @@ document_interface_pause_updates (DocumentInterface *object, GError **error) //sp_desktop_document(object->desk)->root->mflags = FALSE; } -void -document_interface_resume_updates (DocumentInterface *object, GError **error) +void document_interface_resume_updates(DocumentInterface *object, GError ** /*error*/) { object->updates = TRUE; object->desk->canvas->drawing_disabled = 0; @@ -973,16 +965,15 @@ document_interface_resume_updates (DocumentInterface *object, GError **error) Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); } -void -document_interface_update (DocumentInterface *object, GError **error) +void document_interface_update(DocumentInterface *object, GError ** /*error*/) { - sp_desktop_document(object->desk)->root->uflags = TRUE; - sp_desktop_document(object->desk)->root->mflags = TRUE; + sp_desktop_document(object->desk)->getRoot()->uflags = TRUE; + sp_desktop_document(object->desk)->getRoot()->mflags = TRUE; object->desk->enableInteraction(); sp_desktop_document(object->desk)->_updateDocument(); object->desk->disableInteraction(); - sp_desktop_document(object->desk)->root->uflags = FALSE; - sp_desktop_document(object->desk)->root->mflags = FALSE; + sp_desktop_document(object->desk)->getRoot()->uflags = FALSE; + sp_desktop_document(object->desk)->getRoot()->mflags = FALSE; //Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); } @@ -990,8 +981,7 @@ document_interface_update (DocumentInterface *object, GError **error) SELECTION FUNCTIONS FIXME: use call_verb where appropriate (once update system is tested.) ****************************************************************************/ -gboolean -document_interface_selection_get (DocumentInterface *object, char ***out, GError **error) +gboolean document_interface_selection_get(DocumentInterface *object, char ***out, GError ** /*error*/) { Inkscape::Selection * sel = sp_desktop_selection(object->desk); GSList const *oldsel = sel->list(); @@ -1034,10 +1024,9 @@ document_interface_selection_add_list (DocumentInterface *object, return TRUE; } -gboolean -document_interface_selection_set (DocumentInterface *object, char *name, GError **error) +gboolean document_interface_selection_set(DocumentInterface *object, char *name, GError ** /*error*/) { - SPDocument * doc = sp_desktop_document (object->desk); + SPDocument * doc = sp_desktop_document(object->desk); Inkscape::Selection *selection = sp_desktop_selection(object->desk); selection->set(doc->getObjectById(name)); return TRUE; @@ -1055,8 +1044,7 @@ document_interface_selection_set_list (DocumentInterface *object, return TRUE; } -gboolean -document_interface_selection_rotate (DocumentInterface *object, int angle, GError **error) +gboolean document_interface_selection_rotate(DocumentInterface *object, int angle, GError ** /*error*/) { Inkscape::Selection *selection = sp_desktop_selection(object->desk); sp_selection_rotate(selection, angle); @@ -1070,8 +1058,7 @@ document_interface_selection_delete (DocumentInterface *object, GError **error) return dbus_call_verb (object, SP_VERB_EDIT_DELETE, error); } -gboolean -document_interface_selection_clear (DocumentInterface *object, GError **error) +gboolean document_interface_selection_clear(DocumentInterface *object, GError ** /*error*/) { sp_desktop_selection(object->desk)->clear(); return TRUE; @@ -1092,10 +1079,9 @@ document_interface_select_all_in_all_layers(DocumentInterface *object, return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error); } -gboolean -document_interface_selection_box (DocumentInterface *object, int x, int y, - int x2, int y2, gboolean replace, - GError **error) +gboolean document_interface_selection_box(DocumentInterface * /*object*/, int /*x*/, int /*y*/, + int /*x2*/, int /*y2*/, gboolean /*replace*/, + GError ** /*error*/) { //FIXME: implement. return FALSE; @@ -1156,8 +1142,7 @@ document_interface_selection_paste (DocumentInterface *object, GError **error) return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error); } -gboolean -document_interface_selection_scale (DocumentInterface *object, gdouble grow, GError **error) +gboolean document_interface_selection_scale(DocumentInterface *object, gdouble grow, GError ** /*error*/) { Inkscape::Selection *selection = sp_desktop_selection(object->desk); if (!selection) @@ -1168,15 +1153,13 @@ document_interface_selection_scale (DocumentInterface *object, gdouble grow, GEr return TRUE; } -gboolean -document_interface_selection_move (DocumentInterface *object, gdouble x, gdouble y, GError **error) +gboolean document_interface_selection_move(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/) { - sp_selection_move (object->desk, x, 0 - y); //switching coordinate systems. + sp_selection_move(object->desk, x, 0 - y); //switching coordinate systems. return TRUE; } -gboolean -document_interface_selection_move_to (DocumentInterface *object, gdouble x, gdouble y, GError **error) +gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/) { Inkscape::Selection * sel = sp_desktop_selection(object->desk); @@ -1292,13 +1275,12 @@ document_interface_selection_change_level (DocumentInterface *object, gchar *cmd LAYER FUNCTIONS ****************************************************************************/ -gchar * -document_interface_layer_new (DocumentInterface *object, GError **error) +gchar *document_interface_layer_new(DocumentInterface *object, GError ** /*error*/) { SPDesktop * dt = object->desk; SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), Inkscape::LPOS_BELOW); dt->setCurrentLayer(new_layer); - return g_strdup(get_name_from_object (new_layer)); + return g_strdup(get_name_from_object(new_layer)); } gboolean @@ -1314,8 +1296,7 @@ document_interface_layer_set (DocumentInterface *object, return TRUE; } -gchar ** -document_interface_layer_get_all (DocumentInterface *object) +gchar **document_interface_layer_get_all(DocumentInterface * /*object*/) { //FIXME: implement. return NULL; @@ -1348,8 +1329,13 @@ document_interface_layer_previous (DocumentInterface *object, GError **error) return dbus_call_verb (object, SP_VERB_LAYER_PREV, error); } - - - - - +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 3a86fbe8f7ffd5782c1cb736192d4ee5a5dc6d7f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sat, 11 Jun 2011 02:48:13 -0700 Subject: Update to win32 build defines for libwpg issue. (bzr r10269) --- src/extension/internal/wpg-input.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index b6425b380..3cd5044f7 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -49,6 +49,11 @@ #include "extension/input.h" #include "document.h" +// Take a guess and fallback to 0.1.x if no configure has run +#if !defined(WITH_LIBWPG01) && !defined(WITH_LIBWPG02) +#define WITH_LIBWPG01 1 +#endif + #include "libwpg/libwpg.h" #if WITH_LIBWPG01 #include "libwpg/WPGStreamImplementation.h" -- cgit v1.2.3 From 0ddedab9c6185028661dcaaac9f6fbca4c9e93fc Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sun, 12 Jun 2011 18:27:29 +0000 Subject: work in progress cmake commit: - cmake now builds all files that automake does but does NOT link yet - inlcudes nasty hard coded paths and libs (will replace once linking works) (bzr r10272) --- src/2geom/CMakeLists.txt | 244 +++++------ src/CMakeLists.txt | 578 ++++++++++++++----------- src/bind/CMakeLists.txt | 11 +- src/debug/CMakeLists.txt | 23 +- src/dialogs/CMakeLists.txt | 36 +- src/display/CMakeLists.txt | 123 +++--- src/dom/CMakeLists.txt | 68 +-- src/dom/io/CMakeLists.txt | 18 +- src/dom/odf/CMakeLists.txt | 6 +- src/dom/util/CMakeLists.txt | 8 +- src/dom/work/CMakeLists.txt | 20 +- src/extension/CMakeLists.txt | 74 ++-- src/extension/dxf2svg/CMakeLists.txt | 20 +- src/extension/implementation/CMakeLists.txt | 8 +- src/extension/internal/CMakeLists.txt | 56 ++- src/extension/internal/bitmap/CMakeLists.txt | 72 +-- src/extension/internal/filter/CMakeLists.txt | 14 +- src/extension/internal/pdfinput/CMakeLists.txt | 8 +- src/extension/param/CMakeLists.txt | 23 +- src/extension/script/CMakeLists.txt | 4 +- src/filters/CMakeLists.txt | 47 +- src/helper/CMakeLists.txt | 48 +- src/io/CMakeLists.txt | 29 +- src/jabber_whiteboard/CMakeLists.txt | 42 +- src/jabber_whiteboard/dialog/CMakeLists.txt | 5 +- src/libavoid/CMakeLists.txt | 35 +- src/libcola/CMakeLists.txt | 21 +- src/libcroco/CMakeLists.txt | 63 +-- src/libgdl/CMakeLists.txt | 51 +-- src/libnr/CMakeLists.txt | 71 +-- src/libnr/testnr.cpp | 2 + src/libnrtype/CMakeLists.txt | 35 +- src/libvpsc/CMakeLists.txt | 25 +- src/livarot/CMakeLists.txt | 48 +- src/live_effects/CMakeLists.txt | 81 ++-- src/live_effects/parameter/CMakeLists.txt | 24 +- src/pedro/CMakeLists.txt | 23 +- src/svg/CMakeLists.txt | 34 +- src/trace/CMakeLists.txt | 18 +- src/trace/potrace/CMakeLists.txt | 16 +- src/ui/CMakeLists.txt | 64 ++- src/ui/cache/CMakeLists.txt | 4 +- src/ui/dialog/CMakeLists.txt | 93 ++-- src/ui/view/CMakeLists.txt | 12 +- src/ui/widget/CMakeLists.txt | 81 ++-- src/util/CMakeLists.txt | 16 +- src/widgets/CMakeLists.txt | 74 ++-- src/xml/CMakeLists.txt | 40 +- 48 files changed, 1320 insertions(+), 1196 deletions(-) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index 3c8669a9d..91c14db8b 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -1,127 +1,127 @@ -SET(2GEOM_SRC -svg-path.h -svg-path.cpp -svg-path-parser.h -svg-path-parser.cpp - -ord.h - -#nearestpoint.cpp -nearest-point.cpp -nearest-point.h - -bezier-curve.h -circle.cpp -circle.h -curve.h -curves.h -curve-helpers.cpp -ellipse.cpp -ellipse.h -elliptical-arc.cpp -elliptical-arc.h -hvlinesegment.h -sbasis-curve.h -path.cpp -path.h -path-intersection.cpp -path-intersection.h -pathvector.cpp -pathvector.h - -forward.h - -shape.cpp -shape.h -region.cpp -region.h -crossing.h -crossing.cpp -sweep.cpp -sweep.h - -poly.cpp -poly.h -poly-dk-solve.cpp -poly-dk-solve.h -poly-laguerre-solve.cpp -poly-laguerre-solve.h - -quadtree.cpp -quadtree.h - -matrix.cpp -matrix.h -transforms.cpp -transforms.h - -point.h -point.cpp -point-l.h - -coord.h - -d2.h -d2-sbasis.h -d2-sbasis.cpp -rect.h - -piecewise.h -piecewise.cpp - -sbasis.cpp -sbasis.h -sbasis-2d.h -sbasis-2d.cpp -sbasis-geometric.cpp -sbasis-geometric.h -sbasis-math.h -sbasis-math.cpp -sbasis-poly.cpp -sbasis-poly.h -#chebyshev.cpp # requires gsl, not useful, I think -#chebyshev.h -sbasis-roots.cpp -sbasis-to-bezier.cpp -sbasis-to-bezier.h - -bezier-to-sbasis.h - -basic-intersection.h -basic-intersection.cpp -recursive-bezier-intersection.cpp - -geom.cpp -geom.h - -#utils.cpp -utils.h -exception.h -angle.h - -bezier-utils.cpp -bezier-utils.h -choose.h -circulator.h -conjugate_gradient.cpp -conjugate_gradient.h -convex-cover.cpp -convex-cover.h -solve-bezier-one-d.cpp -solve-bezier-parametric.cpp -solver.h -sturm.h -svg-elliptical-arc.cpp -svg-elliptical-arc.h - -#arc-length.cpp -#arc-length.h - -numeric/matrix.cpp +set(2GEOM_SRC + affine.cpp + basic-intersection.cpp + bezier-clipping.cpp + bezier-curve.cpp + bezier-utils.cpp + circle-circle.cpp + circle.cpp + conic_section_clipper_impl.cpp + conicsec.cpp + conjugate_gradient.cpp + convex-cover.cpp + crossing.cpp + curve.cpp + d2-sbasis.cpp + ellipse.cpp + elliptical-arc.cpp + geom.cpp + line.cpp + nearest-point.cpp + numeric/matrix.cpp + path-intersection.cpp + path.cpp + pathvector.cpp + piecewise.cpp + point.cpp + poly.cpp + quadtree.cpp + recursive-bezier-intersection.cpp + region.cpp + sbasis-2d.cpp + sbasis-geometric.cpp + sbasis-math.cpp + sbasis-poly.cpp + sbasis-roots.cpp + sbasis-to-bezier.cpp + sbasis.cpp + shape.cpp + solve-bezier-one-d.cpp + solve-bezier-parametric.cpp + svg-elliptical-arc.cpp + svg-path-parser.cpp + svg-path.cpp + sweep.cpp + transforms.cpp + utils.cpp + + affine.h + angle.h + basic-intersection.h + bezier-curve.h + bezier-to-sbasis.h + bezier-utils.h + bezier.h + choose.h + circle.h + circulator.h + concepts.h + conic_section_clipper.h + conic_section_clipper_cr.h + conic_section_clipper_impl.h + conicsec.h + conjugate_gradient.h + convex-cover.h + coord.h + crossing.h + curve.h + curves.h + d2-sbasis.h + d2.h + ellipse.h + elliptical-arc.h + exception.h + forward.h + geom.h + hvlinesegment.h + interval.h + isnan.h + line.h + linear.h + math-utils.h + nearest-point.h + ord.h + path-intersection.h + path.h + pathvector.h + piecewise.h + point-l.h + point-ops.h + point.h + poly.h + quadtree.h + ray.h + rect.h + region.h + sbasis-2d.h + sbasis-curve.h + sbasis-geometric.h + sbasis-math.h + sbasis-poly.h + sbasis-to-bezier.h + sbasis.h + shape.h + solver.h + sturm.h + svg-elliptical-arc.h + svg-path-parser.h + svg-path.h + sweep.h + transforms.h + utils.h + + numeric/fitting-model.h + numeric/fitting-tool.h + numeric/linear_system.h + numeric/matrix.h + numeric/symmetric-matrix-fs-operation.h + numeric/symmetric-matrix-fs-trace.h + numeric/symmetric-matrix-fs.h + numeric/vector.h ) # make lib for 2geom -ADD_LIBRARY(2geom STATIC ${2GEOM_SRC}) +add_library(2geom STATIC ${2GEOM_SRC}) #TARGET_LINK_LIBRARIES(2geom blas gsl) -TARGET_LINK_LIBRARIES(2geom ${INKSCAPE_LIBS}) +target_link_libraries(2geom ${INKSCAPE_LIBS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f03f22c80..4bd93db12 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,264 +1,348 @@ -IF(WIN32) - SET(ONLY_WIN - registrytool.cpp - #deptool.cpp - winmain.cpp) -ELSEIF(WIN32) - SET(ONLY_WIN) -ENDIF(WIN32) -SET(SP_SRC -sp-anchor.cpp -sp-animation.cpp -sp-clippath.cpp -sp-conn-end.cpp -sp-conn-end-pair.cpp -sp-cursor.cpp -sp-defs.cpp -sp-ellipse.cpp -sp-filter.cpp -sp-filter-primitive.cpp -sp-filter-reference.cpp -sp-flowdiv.cpp -sp-flowregion.cpp -sp-flowtext.cpp -sp-font.cpp -sp-font-face.cpp -sp-gaussian-blur.cpp -sp-glyph.cpp -sp-gradient.cpp -sp-gradient-reference.cpp -sp-guide.cpp -sp-glyph-kerning.cpp -sp-image.cpp -spiral-context.cpp -sp-item.cpp -sp-item-group.cpp -sp-item-notify-moveto.cpp -sp-item-rm-unsatisfied-cns.cpp -sp-item-transform.cpp -sp-item-update-cns.cpp -sp-line.cpp -splivarot.cpp -sp-lpe-item.cpp -sp-mask.cpp -sp-metadata.cpp -sp-metrics.cpp -sp-missing-glyph.cpp -sp-namedview.cpp -sp-object.cpp -sp-object-group.cpp -sp-object-repr.cpp -sp-offset.cpp -sp-paint-server.cpp -sp-path.cpp -sp-pattern.cpp -sp-polygon.cpp -sp-polyline.cpp -sp-rect.cpp -sp-root.cpp -sp-shape.cpp -sp-skeleton.cpp -sp-spiral.cpp -sp-star.cpp -sp-stop.cpp -sp-string.cpp -sp-style-elem.cpp -sp-switch.cpp -sp-symbol.cpp -sp-text.cpp -sp-tref.cpp -sp-tref-reference.cpp -sp-tspan.cpp -sp-use.cpp -sp-use-reference.cpp +set(SP_SRC + sp-anchor.cpp + sp-animation.cpp + sp-clippath.cpp + sp-conn-end-pair.cpp + sp-conn-end.cpp + sp-cursor.cpp + sp-defs.cpp + sp-desc.cpp + sp-ellipse.cpp + sp-filter-primitive.cpp + sp-filter-reference.cpp + sp-filter.cpp + sp-flowdiv.cpp + sp-flowregion.cpp + sp-flowtext.cpp + sp-font-face.cpp + sp-font.cpp + sp-gaussian-blur.cpp + sp-glyph-kerning.cpp + sp-glyph.cpp + sp-gradient-reference.cpp + sp-gradient.cpp + sp-guide.cpp + sp-image.cpp + sp-item-group.cpp + sp-item-notify-moveto.cpp + sp-item-rm-unsatisfied-cns.cpp + sp-item-transform.cpp + sp-item-update-cns.cpp + sp-item.cpp + sp-line.cpp + sp-lpe-item.cpp + sp-mask.cpp + sp-metadata.cpp + sp-metrics.cpp + sp-missing-glyph.cpp + sp-namedview.cpp + sp-object-group.cpp + sp-object-repr.cpp + sp-object.cpp + sp-offset.cpp + sp-paint-server.cpp + sp-path.cpp + sp-pattern.cpp + sp-polygon.cpp + sp-polyline.cpp + sp-rect.cpp + sp-root.cpp + sp-script.cpp + sp-shape.cpp + sp-skeleton.cpp + sp-spiral.cpp + sp-star.cpp + sp-stop.cpp + sp-string.cpp + sp-style-elem.cpp + sp-switch.cpp + sp-symbol.cpp + sp-text.cpp + sp-title.cpp + sp-tref-reference.cpp + sp-tref.cpp + sp-tspan.cpp + sp-use-reference.cpp + sp-use.cpp + spiral-context.cpp + splivarot.cpp ) -SET(INKSCAPE_SRC -arc-context.cpp -attributes.cpp -axis-manip.cpp -box3d-context.cpp -box3d.cpp -box3d-side.cpp -color.cpp -color-profile.cpp -composite-undo-stack-observer.cpp -common-context.cpp -conditions.cpp -conn-avoid-ref.cpp -connection-points.cpp -connector-context.cpp -console-output-undo-observer.cpp -context-fns.cpp -#deptool.cpp -desktop.cpp -desktop-events.cpp -desktop-handles.cpp -desktop-style.cpp -device-manager.cpp -dir-util.cpp -document.cpp -document-subset.cpp -document-undo.cpp -doxygen-main.cpp -draw-anchor.cpp -draw-context.cpp -dropper-context.cpp -dyna-draw-context.cpp -ege-adjustment-action.cpp -ege-color-prof-tracker.cpp -ege-output-action.cpp -ege-select-one-action.cpp -eraser-context.cpp -event-context.cpp -event-log.cpp -extension -extract-uri.cpp -file.cpp -filter-chemistry.cpp -filter-enums.cpp -fixes.cpp -flood-context.cpp -gc-anchored.cpp -gc.cpp -gc-finalized.cpp -gradient-chemistry.cpp -gradient-context.cpp -gradient-drag.cpp -guide-snapper.cpp -help.cpp -id-clash.cpp -ige-mac-menu.c -ink-action.cpp -inkscape.cpp -inkscape.rc -inkscape-stock.cpp -interface.cpp -knot.cpp -knotholder.cpp -knot-holder-entity.cpp -layer-fns.cpp -layer-manager.cpp -line-geometry.cpp -line-snapper.cpp -main-cmdlineact.cpp -main.cpp -marker.cpp -media.cpp -message-context.cpp -message-stack.cpp -mod360.cpp -node-context.cpp -nodepath.cpp -object-edit.cpp -object-hierarchy.cpp -object-snapper.cpp -path-chemistry.cpp -pencil-context.cpp -pen-context.cpp -persp3d.cpp -persp3d-reference.cpp -perspective-line.cpp -plugin.def -preferences.cpp -prefix.cpp -print.cpp -profile-manager.cpp -proj_pt.cpp -rect-context.cpp -rubberband.cpp -satisfied-guide-cns.cpp -selcue.cpp -select-context.cpp -selection-chemistry.cpp -selection.cpp -selection-describer.cpp -#selfname.tpl -seltrans.cpp -seltrans-handles.cpp -shape-editor.cpp -shortcuts.cpp -snap.cpp -snapped-line.cpp -snapped-point.cpp -snapper.cpp -star-context.cpp -style.cpp -#style-test.cpp -svg-view.cpp -svg-view-widget.cpp -text-chemistry.cpp -text-context.cpp -text-editing.cpp -tools-switch.cpp -transf_mat_3x4.cpp -tweak-context.cpp -uri.cpp -uri-references.cpp -vanishing-point.cpp -verbs.cpp -version.cpp -zoom-context.cpp -${ONLY_WIN} +set(INKSCAPE_SRC + arc-context.cpp + attributes.cpp + axis-manip.cpp + box3d-context.cpp + box3d-side.cpp + box3d.cpp + color-profile.cpp + color.cpp + common-context.cpp + composite-undo-stack-observer.cpp + conditions.cpp + conn-avoid-ref.cpp + connection-points.cpp + connector-context.cpp + console-output-undo-observer.cpp + context-fns.cpp + desktop-events.cpp + desktop-handles.cpp + desktop-style.cpp + desktop.cpp + device-manager.cpp + dir-util.cpp + document-subset.cpp + document-undo.cpp + document.cpp + doxygen-main.cpp + draw-anchor.cpp + draw-context.cpp + dropper-context.cpp + dyna-draw-context.cpp + ege-adjustment-action.cpp + ege-color-prof-tracker.cpp + ege-output-action.cpp + ege-select-one-action.cpp + eraser-context.cpp + event-context.cpp + event-log.cpp + extract-uri.cpp + file.cpp + filter-chemistry.cpp + filter-enums.cpp + fixes.cpp + flood-context.cpp + gc-anchored.cpp + gc-finalized.cpp + gc.cpp + gradient-chemistry.cpp + gradient-context.cpp + gradient-drag.cpp + graphlayout.cpp + guide-snapper.cpp + help.cpp + id-clash.cpp + ige-mac-menu.c + ink-action.cpp + ink-comboboxentry-action.cpp + inkscape-version.cpp + inkscape.cpp + inkscape.rc + inkview.cpp + inkview.rc + interface.cpp + knot-holder-entity.cpp + knot.cpp + knotholder.cpp + layer-fns.cpp + layer-manager.cpp + line-geometry.cpp + line-snapper.cpp + lpe-tool-context.cpp + main-cmdlineact.cpp + main.cpp + marker.cpp + measure-context.cpp + media.cpp + message-context.cpp + message-stack.cpp + mod360.cpp + object-edit.cpp + object-hierarchy.cpp + object-snapper.cpp + path-chemistry.cpp + pen-context.cpp + pencil-context.cpp + persp3d-reference.cpp + persp3d.cpp + perspective-line.cpp + preferences.cpp + prefix.cpp + print.cpp + profile-manager.cpp + proj_pt.cpp + rdf.cpp + rect-context.cpp + removeoverlap.cpp + resource-manager.cpp + rubberband.cpp + satisfied-guide-cns.cpp + selcue.cpp + select-context.cpp + selection-chemistry.cpp + selection-describer.cpp + selection.cpp + seltrans-handles.cpp + seltrans.cpp + shape-editor.cpp + shortcuts.cpp + snap-preferences.cpp + snap.cpp + snapped-curve.cpp + snapped-line.cpp + snapped-point.cpp + snapper.cpp + spray-context.cpp + star-context.cpp + style.cpp + svg-view-widget.cpp + svg-view.cpp + text-chemistry.cpp + text-context.cpp + text-editing.cpp + tools-switch.cpp + transf_mat_3x4.cpp + tweak-context.cpp + unclump.cpp + unicoderange.cpp + uri-references.cpp + uri.cpp + vanishing-point.cpp + verbs.cpp + version.cpp + zoom-context.cpp ) + +if(WIN32) + list(APPEND INKSCAPE_SRC + registrytool.cpp + #deptool.cpp + winmain.cpp + ) +endif() + # All folders for internal inkscape -SET(internalfolders -#algorithms -#api -bind -debug -dialogs -display -dom -extension -filters -graphlayout -helper -inkjar -io -jabber_whiteboard -live_effects -pedro -removeoverlap -svg -trace -#traits -ui -util -widgets -xml -2geom +set(internalfolders + #algorithms + #api + bind + debug + dialogs + display + dom + extension + filters + helper + io + jabber_whiteboard + live_effects + pedro + svg + trace + #traits + ui + util + widgets + xml + 2geom ) -SET(libfolders -# Directories containing lists files that describe building internal libraries -libavoid -libcola -libcroco -libgdl -libnr -libnrtype -libvpsc -livarot + +set(libfolders + # Directories containing lists files that describe building internal libraries + libavoid + libcola + libcroco + libgdl + libnr + libnrtype + libvpsc + livarot ) -SET(dirs ${internalfolders} ${libfolders} +set(dirs + ${internalfolders} + ${libfolders} ) -FOREACH(srclistsrc ${dirs}) - ADD_SUBDIRECTORY(${srclistsrc}) -ENDFOREACH(srclistsrc) +foreach(srclistsrc ${dirs}) + add_subdirectory(${srclistsrc}) +endforeach() -SET(INKSCAPE_SRC ${INKSCAPE_SRC} ${GlibOutput}) +set(INKSCAPE_SRC + ${INKSCAPE_SRC} + ${GlibOutput} +) -ADD_LIBRARY(sp STATIC ${SP_SRC}) -TARGET_LINK_LIBRARIES(sp -nr nrtype avoid cola croco gdl vpsc livarot ${internalfolders} ${INKSCAPE_LIBS} +add_library(sp STATIC ${SP_SRC}) +target_link_libraries(sp + nr + nrtype + avoid + cola + croco + gdl + vpsc + livarot + ${internalfolders} + ${INKSCAPE_LIBS} ) + # make executable for INKSCAPE -ADD_EXECUTABLE(inkscape ${INKSCAPE_SRC}) -TARGET_LINK_LIBRARIES(inkscape -nr nrtype sp avoid cola croco gdl vpsc livarot ${internalfolders} ${INKSCAPE_LIBS} +add_executable(inkscape ${INKSCAPE_SRC}) + +target_link_libraries(inkscape + nr + nrtype + sp + avoid + cola + croco + gdl + vpsc + livarot + ${internalfolders} + ${INKSCAPE_LIBS} + + + # system libs + xslt + gtkspell + gsl + gslcblas + gtkmm-2.4 + atkmm-1.6 + gdkmm-2.4 + giomm-2.4 + pangomm-1.4 + gtk-x11-2.0 + glibmm-2.4 + cairomm-1.0 + sigc-2.0 + atk-1.0 + gio-2.0 + png + X11 + xml2 + dl + gomp + popt + aspell + gnomevfs-2 + gconf-2 + pangoft2-1.0 + fontconfig + freetype + z + Magick++ + MagickCore + gc + lcms + poppler-glib + gdk-x11-2.0 + poppler + pangocairo-1.0 + gdk_pixbuf-2.0 + png14 + m + pango-1.0 + cairo + gmodule-2.0 + gobject-2.0 + gthread-2.0 + rt + glib-2.0 + ) # make executable for INKVIEW diff --git a/src/bind/CMakeLists.txt b/src/bind/CMakeLists.txt index a6b5b6883..08b7876c2 100644 --- a/src/bind/CMakeLists.txt +++ b/src/bind/CMakeLists.txt @@ -1,7 +1,6 @@ -SET(bind_SRC -dobinding.cpp -javabind.cpp +set(bind_SRC + dobinding.cpp + javabind.cpp ) -ADD_LIBRARY(bind STATIC ${bind_SRC}) -TARGET_LINK_LIBRARIES(bind -${INKSCAPE_LIBS}) \ No newline at end of file +add_library(bind STATIC ${bind_SRC}) +target_link_libraries(bind ${INKSCAPE_LIBS}) diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 26c4e6934..2dab10144 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -1,12 +1,13 @@ -SET(debug_SRC -demangle.cpp -heap.cpp -log-display-config.cpp -logger.cpp -sysv-heap.cpp -timestamp.cpp -gdk-event-latency-tracker.cpp + +set(debug_SRC + demangle.cpp + heap.cpp + log-display-config.cpp + logger.cpp + sysv-heap.cpp + timestamp.cpp + gdk-event-latency-tracker.cpp ) -ADD_LIBRARY(debug STATIC ${debug_SRC}) -TARGET_LINK_LIBRARIES(debug -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(debug STATIC ${debug_SRC}) +target_link_libraries(debug 2geom ${INKSCAPE_LIBS}) diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index 9bcb1cd5a..aa8f836d5 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -1,25 +1,13 @@ -SET(dialogs_SRC -clonetiler.cpp -dialog-events.cpp -export.cpp -extensions.cpp -fill-style.cpp -find.cpp -guidelinedialog.cpp -iconpreview.cpp -in-dt-coordsys.cpp -item-properties.cpp -layer-properties.cpp -layers-panel.cpp -object-attributes.cpp -rdf.cpp -sp-attribute-widget.cpp -stroke-style.cpp -swatches.cpp -text-edit.cpp -unclump.cpp -xml-tree.cpp +set(dialogs_SRC + clonetiler.cpp + dialog-events.cpp + export.cpp + find.cpp + item-properties.cpp + object-attributes.cpp + spellcheck.cpp + text-edit.cpp + xml-tree.cpp ) -ADD_LIBRARY(dialogs STATIC ${dialogs_SRC}) -TARGET_LINK_LIBRARIES(dialogs -2geom ${INKSCAPE_LIBS}) +add_library(dialogs STATIC ${dialogs_SRC}) +target_link_libraries(dialogs 2geom ${INKSCAPE_LIBS}) diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 9fa2304be..1d3e09200 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -1,59 +1,66 @@ -SET(display_SRC -canvas-arena.cpp -canvas-axonomgrid.cpp -canvas-bpath.cpp -canvas-grid.cpp -canvas-temporary-item.cpp -canvas-temporary-item-list.cpp -curve.cpp -gnome-canvas-acetate.cpp -guideline.cpp -inkscape-cairo.cpp -nr-3dutils.cpp -nr-arena.cpp -nr-arena-glyphs.cpp -nr-arena-group.cpp -nr-arena-image.cpp -nr-arena-item.cpp -nr-arena-shape.cpp -nr-filter-blend.cpp -nr-filter-colormatrix.cpp -nr-filter-component-transfer.cpp -nr-filter-composite.cpp -nr-filter-convolve-matrix.cpp -nr-filter.cpp -nr-filter-diffuselighting.cpp -nr-filter-displacement-map.cpp -nr-filter-flood.cpp -nr-filter-gaussian.cpp -nr-filter-getalpha.cpp -nr-filter-image.cpp -nr-filter-merge.cpp -nr-filter-morphology.cpp -nr-filter-offset.cpp -nr-filter-primitive.cpp -nr-filter-skeleton.cpp -nr-filter-slot.cpp -nr-filter-specularlighting.cpp -nr-filter-tile.cpp -nr-filter-turbulence.cpp -nr-filter-units.cpp -nr-filter-utils.cpp -nr-light.cpp -nr-plain-stuff.cpp -nr-plain-stuff-gdk.cpp -nr-svgfonts.h -pixblock-scaler.cpp -pixblock-transform.cpp -snap-indicator.cpp -sodipodi-ctrl.cpp -sodipodi-ctrlrect.cpp -sp-canvas.cpp -sp-canvas-util.cpp -sp-ctrlline.cpp -sp-ctrlquadr.cpp -#testnr.cpp +set(display_SRC + canvas-arena.cpp + canvas-axonomgrid.cpp + canvas-bpath.cpp + canvas-grid.cpp + canvas-temporary-item-list.cpp + canvas-temporary-item.cpp + canvas-text.cpp + curve.cpp + gnome-canvas-acetate.cpp + grayscale.cpp + guideline.cpp + inkscape-cairo.cpp + nr-3dutils.cpp + nr-arena-glyphs.cpp + nr-arena-group.cpp + nr-arena-image.cpp + nr-arena-item.cpp + nr-arena-shape.cpp + nr-arena.cpp + nr-filter-blend.cpp + nr-filter-colormatrix.cpp + nr-filter-component-transfer.cpp + nr-filter-composite.cpp + nr-filter-convolve-matrix.cpp + nr-filter-diffuselighting.cpp + nr-filter-displacement-map.cpp + nr-filter-flood.cpp + nr-filter-gaussian.cpp + nr-filter-getalpha.cpp + nr-filter-image.cpp + nr-filter-merge.cpp + nr-filter-morphology.cpp + nr-filter-offset.cpp + nr-filter-primitive.cpp + nr-filter-skeleton.cpp + nr-filter-slot.cpp + nr-filter-specularlighting.cpp + nr-filter-tile.cpp + nr-filter-turbulence.cpp + nr-filter-units.cpp + nr-filter-utils.cpp + nr-filter.cpp + nr-light.cpp + nr-plain-stuff-gdk.cpp + nr-plain-stuff.cpp + nr-svgfonts.cpp + nr-svgfonts.h + pixblock-scaler.cpp + pixblock-transform.cpp + snap-indicator.cpp + sodipodi-ctrl.cpp + sodipodi-ctrlrect.cpp + sp-canvas-util.cpp + sp-canvas.cpp + sp-ctrlline.cpp + sp-ctrlpoint.cpp + sp-ctrlquadr.cpp ) -ADD_LIBRARY(display STATIC ${display_SRC}) -TARGET_LINK_LIBRARIES(display -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +include_directories( + "${CMAKE_SOURCE_DIR}/src" +) + +add_library(display STATIC ${display_SRC}) +target_link_libraries(display 2geom ${INKSCAPE_LIBS}) diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index 7c434eb77..53609d241 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -1,38 +1,38 @@ -SET(domfolders -io -odf -util -#work +set(domfolders + io + odf + util + #work ) -FOREACH(domlistsrc ${domfolders}) - ADD_SUBDIRECTORY(${domlistsrc}) -ENDFOREACH(domlistsrc) +foreach(domlistsrc ${domfolders}) + add_subdirectory(${domlistsrc}) +endforeach() -SET(dom_SRC -cssreader.cpp -domimpl.cpp -domptr.cpp -domstring.cpp -lsimpl.cpp -prop-css2.cpp -#prop-css.cpp -#prop-svg.cpp -smilimpl.cpp -svgimpl.cpp -svgreader.cpp -ucd.cpp -uri.cpp -xmlreader.cpp -xmlwriter.cpp -xpathimpl.cpp -xpathparser.cpp -xpathtoken.cpp -${dom_io_SRC} -${dom_odf_SRC} -${dom_util_SRC} -#${dom_work_SRC} +set(dom_SRC + cssreader.cpp + domimpl.cpp + domptr.cpp + domstring.cpp + lsimpl.cpp + prop-css2.cpp + prop-css.cpp + prop-svg.cpp + smilimpl.cpp + svgimpl.cpp + svgreader.cpp + ucd.cpp + uri.cpp + xmlreader.cpp + xmlwriter.cpp + xpathimpl.cpp + xpathparser.cpp + xpathtoken.cpp + ${dom_io_SRC} + ${dom_odf_SRC} + ${dom_util_SRC} + #${dom_work_SRC} ) -ADD_LIBRARY(dom STATIC ${dom_SRC}) -TARGET_LINK_LIBRARIES(dom -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(dom STATIC ${dom_SRC}) +target_link_libraries(dom 2geom ${INKSCAPE_LIBS}) \ No newline at end of file diff --git a/src/dom/io/CMakeLists.txt b/src/dom/io/CMakeLists.txt index c8a98466d..0b0b4630d 100644 --- a/src/dom/io/CMakeLists.txt +++ b/src/dom/io/CMakeLists.txt @@ -1,11 +1,11 @@ -SET(dom_io_SRC -base64stream.cpp -bufferstream.cpp -domstream.cpp -gzipstream.cpp -httpclient.cpp -socket.cpp -stringstream.cpp -uristream.cpp +set(dom_io_SRC + base64stream.cpp + bufferstream.cpp + domstream.cpp + gzipstream.cpp + httpclient.cpp + socket.cpp + stringstream.cpp + uristream.cpp ) diff --git a/src/dom/odf/CMakeLists.txt b/src/dom/odf/CMakeLists.txt index e0cb76060..089f65fbf 100644 --- a/src/dom/odf/CMakeLists.txt +++ b/src/dom/odf/CMakeLists.txt @@ -1,5 +1,5 @@ -SET(dom_odf_SRC -odfdocument.cpp -#SvgOdg.cpp +set(dom_odf_SRC + odfdocument.cpp + #SvgOdg.cpp ) diff --git a/src/dom/util/CMakeLists.txt b/src/dom/util/CMakeLists.txt index 167e980c9..e5f583fa5 100644 --- a/src/dom/util/CMakeLists.txt +++ b/src/dom/util/CMakeLists.txt @@ -1,6 +1,6 @@ -SET(dom_util_SRC -digest.cpp -thread.cpp -ziptool.cpp +set(dom_util_SRC + digest.cpp + thread.cpp + ziptool.cpp ) diff --git a/src/dom/work/CMakeLists.txt b/src/dom/work/CMakeLists.txt index 8cd4676cf..52552c8b9 100644 --- a/src/dom/work/CMakeLists.txt +++ b/src/dom/work/CMakeLists.txt @@ -1,12 +1,12 @@ -SET(dom_work_SRC -#testdom.cpp -#testhttp.cpp -#testjs.cpp -#testodf.cpp -#testsvg.cpp -#testuri.cpp -#testxpath.cpp -#testzip.cpp -#xpathtests.cpp +set(dom_work_SRC + #testdom.cpp + #testhttp.cpp + #testjs.cpp + #testodf.cpp + #testsvg.cpp + #testuri.cpp + #testxpath.cpp + #testzip.cpp + #xpathtests.cpp ) diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index cd640d3d0..73697fbe7 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -1,41 +1,41 @@ -SET(extfolders -#dxf2svg -implementation -internal -internal/bitmap -internal/filter -internal/pdfinput -param -script +set(extfolders + #dxf2svg + implementation + internal + internal/bitmap + internal/filter + internal/pdfinput + param + script ) -FOREACH(extlistsrc ${extfolders}) - ADD_SUBDIRECTORY(${extlistsrc}) -ENDFOREACH(extlistsrc) +foreach(extlistsrc ${extfolders}) + add_subdirectory(${extlistsrc}) +endforeach() -SET(extension_SRC -db.cpp -dependency.cpp -effect.cpp -error-file.cpp -execution-env.cpp -extension.cpp -init.cpp -input.cpp -output.cpp -patheffect.cpp -prefdialog.cpp -print.cpp -system.cpp -timer.cpp -#${extension_dxf2svg_SRC} -${extension_implementation_SRC} -${extension_internal_bitmap_SRC} -${extension_internal_filter_SRC} -${extension_internal_pdfinput_SRC} -${extension_param_SRC} -${extension_script_SRC} +set(extension_SRC + db.cpp + dependency.cpp + effect.cpp + error-file.cpp + execution-env.cpp + extension.cpp + init.cpp + input.cpp + output.cpp + patheffect.cpp + prefdialog.cpp + print.cpp + system.cpp + timer.cpp + #${extension_dxf2svg_SRC} + ${extension_implementation_SRC} + ${extension_internal_bitmap_SRC} + ${extension_internal_filter_SRC} + ${extension_internal_pdfinput_SRC} + ${extension_param_SRC} + ${extension_script_SRC} ) -ADD_LIBRARY(extension STATIC ${extension_SRC}) -TARGET_LINK_LIBRARIES(extension -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(extension STATIC ${extension_SRC}) +target_link_libraries(extension 2geom ${INKSCAPE_LIBS}) diff --git a/src/extension/dxf2svg/CMakeLists.txt b/src/extension/dxf2svg/CMakeLists.txt index b755d7f44..0ff0eaec0 100644 --- a/src/extension/dxf2svg/CMakeLists.txt +++ b/src/extension/dxf2svg/CMakeLists.txt @@ -1,11 +1,11 @@ -SET(extension_dxf2svg_SRC -#aci2rgb.cpp -#entities2elements.cpp -#tables2svg_info.cpp -#blocks.cpp -#entities.cpp -#tables.cpp -#dxf2svg.cpp -#read_dxf.cpp -#test_dxf.cpp +set(extension_dxf2svg_SRC + #aci2rgb.cpp + #entities2elements.cpp + #tables2svg_info.cpp + #blocks.cpp + #entities.cpp + #tables.cpp + #dxf2svg.cpp + #read_dxf.cpp + #test_dxf.cpp ) diff --git a/src/extension/implementation/CMakeLists.txt b/src/extension/implementation/CMakeLists.txt index 87e1b2541..dcdf092c2 100644 --- a/src/extension/implementation/CMakeLists.txt +++ b/src/extension/implementation/CMakeLists.txt @@ -1,5 +1,5 @@ -SET(extension_implementation_SRC -implementation.cpp -xslt.cpp -script.cpp +set(extension_implementation_SRC + implementation.cpp + xslt.cpp + script.cpp ) diff --git a/src/extension/internal/CMakeLists.txt b/src/extension/internal/CMakeLists.txt index 8b23cb0ac..d13ec9f74 100644 --- a/src/extension/internal/CMakeLists.txt +++ b/src/extension/internal/CMakeLists.txt @@ -1,31 +1,29 @@ -IF(WIN32) -SET(EXT_INT_WIN -win32.cpp +set(extension_internal_SRC + bluredge.cpp + cairo-png-out.cpp + cairo-ps-out.cpp + cairo-render-context.cpp + cairo-renderer.cpp + cairo-renderer-pdf-out.cpp + emf-win32-inout.cpp + emf-win32-print.cpp + gdkpixbuf-input.cpp + gimpgrad.cpp + grid.cpp + latex-pstricks.cpp + latex-pstricks-out.cpp + odf.cpp + latex-text-renderer.cpp + pdf-input-cairo.cpp + pov-out.cpp + javafx-out.cpp + svg.cpp + svgz.cpp + wpg-input.cpp ) -ENDIF(WIN32) -SET(extension_internal_SRC -bluredge.cpp -cairo-png-out.cpp -cairo-ps-out.cpp -cairo-render-context.cpp -cairo-renderer.cpp -cairo-renderer-pdf-out.cpp -emf-win32-inout.cpp -emf-win32-print.cpp -gdkpixbuf-input.cpp -gimpgrad.cpp -grid.cpp -latex-pstricks.cpp -latex-pstricks-out.cpp -odf.cpp -pdfinput -latex-text-renderer.cpp -pdf-input-cairo.cpp -pov-out.cpp -javafx-out.cpp -svg.cpp -svgz.cpp -wpg-input.cpp -${EXT_INT_WIN} -) +if(WIN32) + list(APPEND extension_internal_SRC + win32.cpp + ) +endif() diff --git a/src/extension/internal/bitmap/CMakeLists.txt b/src/extension/internal/bitmap/CMakeLists.txt index 8aec17492..a273804ba 100644 --- a/src/extension/internal/bitmap/CMakeLists.txt +++ b/src/extension/internal/bitmap/CMakeLists.txt @@ -1,37 +1,37 @@ -SET(extension_internal_bitmap_SRC -adaptiveThreshold.cpp -addNoise.cpp -blur.cpp -channel.cpp -charcoal.cpp -colorize.cpp -contrast.cpp -cycleColormap.cpp -despeckle.cpp -edge.cpp -emboss.cpp -enhance.cpp -equalize.cpp -gaussianBlur.cpp -imagemagick.cpp -implode.cpp -levelChannel.cpp -level.cpp -medianFilter.cpp -modulate.cpp -negate.cpp -normalize.cpp -oilPaint.cpp -opacity.cpp -raise.cpp -reduceNoise.cpp -sample.cpp -shade.cpp -sharpen.cpp -solarize.cpp -spread.cpp -swirl.cpp -threshold.cpp -unsharpmask.cpp -wave.cpp +set(extension_internal_bitmap_SRC + adaptiveThreshold.cpp + addNoise.cpp + blur.cpp + channel.cpp + charcoal.cpp + colorize.cpp + contrast.cpp + cycleColormap.cpp + despeckle.cpp + edge.cpp + emboss.cpp + enhance.cpp + equalize.cpp + gaussianBlur.cpp + imagemagick.cpp + implode.cpp + levelChannel.cpp + level.cpp + medianFilter.cpp + modulate.cpp + negate.cpp + normalize.cpp + oilPaint.cpp + opacity.cpp + raise.cpp + reduceNoise.cpp + sample.cpp + shade.cpp + sharpen.cpp + solarize.cpp + spread.cpp + swirl.cpp + threshold.cpp + unsharpmask.cpp + wave.cpp ) diff --git a/src/extension/internal/filter/CMakeLists.txt b/src/extension/internal/filter/CMakeLists.txt index 80a14ba3a..349504f94 100644 --- a/src/extension/internal/filter/CMakeLists.txt +++ b/src/extension/internal/filter/CMakeLists.txt @@ -1,8 +1,8 @@ -SET(extension_internal_filter_SRC -drop-shadow.h -filter-all.cpp -filter.cpp -filter-file.cpp -filter.h -snow.h +set(extension_internal_filter_SRC + drop-shadow.h + filter-all.cpp + filter.cpp + filter-file.cpp + filter.h + snow.h ) diff --git a/src/extension/internal/pdfinput/CMakeLists.txt b/src/extension/internal/pdfinput/CMakeLists.txt index 9a093a065..fe31c2a7f 100644 --- a/src/extension/internal/pdfinput/CMakeLists.txt +++ b/src/extension/internal/pdfinput/CMakeLists.txt @@ -1,5 +1,5 @@ -SET(extension_internal_pdfinput_SRC -pdf-input.cpp -pdf-parser.cpp -svg-builder.cpp +set(extension_internal_pdfinput_SRC + pdf-input.cpp + pdf-parser.cpp + svg-builder.cpp ) diff --git a/src/extension/param/CMakeLists.txt b/src/extension/param/CMakeLists.txt index 2ef5d5005..b2981308e 100644 --- a/src/extension/param/CMakeLists.txt +++ b/src/extension/param/CMakeLists.txt @@ -1,14 +1,13 @@ -SET(extension_param_SRC -bool.cpp -color.cpp -description.cpp -groupheader.cpp -enum.cpp -parameter.cpp -float.cpp -int.cpp -notebook.cpp -radiobutton.cpp -string.cpp +set(extension_param_SRC + bool.cpp + color.cpp + description.cpp + enum.cpp + float.cpp + int.cpp + notebook.cpp + parameter.cpp + radiobutton.cpp + string.cpp ) diff --git a/src/extension/script/CMakeLists.txt b/src/extension/script/CMakeLists.txt index 693948508..88977164e 100644 --- a/src/extension/script/CMakeLists.txt +++ b/src/extension/script/CMakeLists.txt @@ -1,3 +1,3 @@ -SET(extension_script_SRC -InkscapeScript.cpp +set(extension_script_SRC + InkscapeScript.cpp ) diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index 554402d35..32819fa68 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -1,25 +1,24 @@ -SET(filters_SRC -blend.cpp -colormatrix.cpp -componenttransfer.cpp -componenttransfer-funcnode.cpp -composite.cpp -convolvematrix.cpp -diffuselighting.cpp -displacementmap.cpp -distantlight.cpp -flood.cpp -image.cpp -merge.cpp -mergenode.cpp -morphology.cpp -offset.cpp -pointlight.cpp -specularlighting.cpp -spotlight.cpp -tile.cpp -turbulence.cpp +set(filters_SRC + blend.cpp + colormatrix.cpp + componenttransfer.cpp + componenttransfer-funcnode.cpp + composite.cpp + convolvematrix.cpp + diffuselighting.cpp + displacementmap.cpp + distantlight.cpp + flood.cpp + image.cpp + merge.cpp + mergenode.cpp + morphology.cpp + offset.cpp + pointlight.cpp + specularlighting.cpp + spotlight.cpp + tile.cpp + turbulence.cpp ) -ADD_LIBRARY(filters STATIC ${filters_SRC}) -TARGET_LINK_LIBRARIES(filters -2geom ${INKSCAPE_LIBS}) +add_library(filters STATIC ${filters_SRC}) +target_link_libraries(filters 2geom ${INKSCAPE_LIBS}) diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index 8f42a0d5a..e2ca2336d 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -1,29 +1,31 @@ include(UseGlibMarshal) GLIB_MARSHAL(sp_marshal sp-marshal "${CMAKE_CURRENT_BINARY_DIR}/helper") -SET(GlibOutput -${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.cpp -${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.h + +set(GlibOutput + ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.cpp + ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.h ) -SET(helper_SRC -action.cpp -geom.cpp -geom-nodetype.cpp -gnome-utils.cpp -pixbuf-ops.cpp -png-write.cpp -stock-items.cpp -unit-menu.cpp -units.cpp -#units-test.cpp -unit-tracker.cpp -window.cpp -sp-marshal.list -# we generate this file and it's .h counter-part -${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.cpp -${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.h +set(helper_SRC + action.cpp + geom.cpp + geom-nodetype.cpp + gnome-utils.cpp + pixbuf-ops.cpp + png-write.cpp + stock-items.cpp + unit-menu.cpp + units.cpp + #units-test.cpp + unit-tracker.cpp + window.cpp + sp-marshal.cpp + sp-marshal.list + # we generate this file and it's .h counter-part + ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.cpp + ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.h ) -ADD_LIBRARY(helper STATIC ${helper_SRC}) -TARGET_LINK_LIBRARIES(helper -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(helper STATIC ${helper_SRC}) +target_link_libraries(helper 2geom ${INKSCAPE_LIBS}) \ No newline at end of file diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index 13b8f568b..b60830042 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -1,16 +1,15 @@ -SET(io_SRC -base64stream.cpp -ftos.cpp -gzipstream.cpp -inkscapestream.cpp -resource.cpp -simple-sax.cpp -#streamtest.cpp -stringstream.cpp -sys.cpp -uristream.cpp -xsltstream.cpp +set(io_SRC + base64stream.cpp + ftos.cpp + gzipstream.cpp + inkjar.cpp + inkscapestream.cpp + resource.cpp + simple-sax.cpp + stringstream.cpp + sys.cpp + uristream.cpp + xsltstream.cpp ) -ADD_LIBRARY(io STATIC ${io_SRC}) -TARGET_LINK_LIBRARIES(io -2geom ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(io STATIC ${io_SRC}) +target_link_libraries(io 2geom ${INKSCAPE_LIBS}) diff --git a/src/jabber_whiteboard/CMakeLists.txt b/src/jabber_whiteboard/CMakeLists.txt index 5f4dfa981..6975d06d6 100644 --- a/src/jabber_whiteboard/CMakeLists.txt +++ b/src/jabber_whiteboard/CMakeLists.txt @@ -1,23 +1,23 @@ -ADD_SUBDIRECTORY(dialog) +add_subdirectory(dialog) -SET(jabber_whiteboard_SRC -defines.cpp -empty.cpp -inkboard-document.cpp -inkboard-node.cpp -invitation-confirm-dialog.cpp -keynode.cpp -message-aggregator.cpp -message-queue.cpp -message-tags.cpp -message-utilities.cpp -#node-tracker.cpp -#node-utilities.cpp -pedrogui.cpp -session-file-selector.cpp -session-manager.cpp -${jabber_whiteboard_dialog_SRC} +set(jabber_whiteboard_SRC + defines.cpp + empty.cpp + inkboard-document.cpp + inkboard-node.cpp + invitation-confirm-dialog.cpp + keynode.cpp + message-aggregator.cpp + message-queue.cpp + message-tags.cpp + message-utilities.cpp + #node-tracker.cpp + #node-utilities.cpp + pedrogui.cpp + session-file-selector.cpp + session-manager.cpp + ${jabber_whiteboard_dialog_SRC} ) -ADD_LIBRARY(jabber_whiteboard STATIC ${jabber_whiteboard_SRC}) -TARGET_LINK_LIBRARIES(jabber_whiteboard -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(jabber_whiteboard STATIC ${jabber_whiteboard_SRC}) +target_link_libraries(jabber_whiteboard 2geom ${INKSCAPE_LIBS}) \ No newline at end of file diff --git a/src/jabber_whiteboard/dialog/CMakeLists.txt b/src/jabber_whiteboard/dialog/CMakeLists.txt index 74863aa4b..8272a61e2 100644 --- a/src/jabber_whiteboard/dialog/CMakeLists.txt +++ b/src/jabber_whiteboard/dialog/CMakeLists.txt @@ -1,3 +1,4 @@ -SET(jabber_whiteboard_dialog_SRC -choose-desktop.cpp + +set(jabber_whiteboard_dialog_SRC + choose-desktop.cpp ) diff --git a/src/libavoid/CMakeLists.txt b/src/libavoid/CMakeLists.txt index 3f408074c..b76cf1d39 100644 --- a/src/libavoid/CMakeLists.txt +++ b/src/libavoid/CMakeLists.txt @@ -1,19 +1,18 @@ -SET(libavoid_SRC -connector.cpp -geometry.cpp -graph.cpp -makepath.cpp -polyutil.cpp -region.cpp -router.cpp -shape.cpp -static.cpp -timer.cpp -vertices.cpp -visibility.cpp -orthogonal.cpp -vpsc.cpp +set(libavoid_SRC + connector.cpp + geometry.cpp + geomtypes.cpp + graph.cpp + makepath.cpp + orthogonal.cpp + router.cpp + shape.cpp + timer.cpp + vertices.cpp + viscluster.cpp + visibility.cpp + vpsc.cpp ) -ADD_LIBRARY(avoid STATIC ${libavoid_SRC}) -TARGET_LINK_LIBRARIES(avoid -${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(avoid STATIC ${libavoid_SRC}) +target_link_libraries(avoid ${INKSCAPE_LIBS}) \ No newline at end of file diff --git a/src/libcola/CMakeLists.txt b/src/libcola/CMakeLists.txt index b5f2e7f1f..19ac816b2 100644 --- a/src/libcola/CMakeLists.txt +++ b/src/libcola/CMakeLists.txt @@ -1,12 +1,11 @@ -SET(libcola_SRC -cola.cpp -conjugate_gradient.cpp -connected_components.cpp -cycle_detector.cpp -gradient_projection.cpp -shortest_paths.cpp -straightener.cpp +set(libcola_SRC + cola.cpp + conjugate_gradient.cpp + connected_components.cpp + cycle_detector.cpp + gradient_projection.cpp + shortest_paths.cpp + straightener.cpp ) -ADD_LIBRARY(cola STATIC ${libcola_SRC}) -TARGET_LINK_LIBRARIES(cola -${INKSCAPE_LIBS}) \ No newline at end of file +add_library(cola STATIC ${libcola_SRC}) +target_link_libraries(cola ${INKSCAPE_LIBS}) \ No newline at end of file diff --git a/src/libcroco/CMakeLists.txt b/src/libcroco/CMakeLists.txt index 3ca55b4b5..7e8aa9176 100644 --- a/src/libcroco/CMakeLists.txt +++ b/src/libcroco/CMakeLists.txt @@ -1,32 +1,33 @@ -SET(libcroco_SRC -cr-additional-sel.c -cr-attr-sel.c -cr-cascade.c -cr-declaration.c -cr-doc-handler.c -cr-enc-handler.c -cr-fonts.c -cr-input.c -cr-libxml-node-iface.c -cr-num.c -cr-om-parser.c -cr-parser.c -cr-parsing-location.c -cr-prop-list.c -cr-pseudo.c -cr-rgb.c -cr-selector.c -cr-sel-eng.c -cr-simple-sel.c -cr-statement.c -cr-string.c -cr-style.c -cr-stylesheet.c -cr-term.c -cr-tknzr.c -cr-token.c -cr-utils.c + +set(libcroco_SRC + cr-additional-sel.c + cr-attr-sel.c + cr-cascade.c + cr-declaration.c + cr-doc-handler.c + cr-enc-handler.c + cr-fonts.c + cr-input.c + cr-libxml-node-iface.c + cr-num.c + cr-om-parser.c + cr-parser.c + cr-parsing-location.c + cr-prop-list.c + cr-pseudo.c + cr-rgb.c + cr-selector.c + cr-sel-eng.c + cr-simple-sel.c + cr-statement.c + cr-string.c + cr-style.c + cr-stylesheet.c + cr-term.c + cr-tknzr.c + cr-token.c + cr-utils.c ) -ADD_LIBRARY(croco STATIC ${libcroco_SRC}) -TARGET_LINK_LIBRARIES(croco -${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(croco STATIC ${libcroco_SRC}) +target_link_libraries(croco ${INKSCAPE_LIBS}) diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt index dea93e6bc..f59ec5420 100644 --- a/src/libgdl/CMakeLists.txt +++ b/src/libgdl/CMakeLists.txt @@ -1,28 +1,29 @@ -IF(WIN32) -SET(GDL_WIN -gdl-win32.c -) -ENDIF(WIN32) -SET(libgdl_SRC -gdl-dock.c -gdl-dock-bar.c -gdl-dock-item.c -gdl-dock-item-grip.c -gdl-dock-master.c -gdl-dock-notebook.c -gdl-dock-object.c -gdl-dock-paned.c -gdl-dock-placeholder.c -gdl-dock-tablabel.c -gdl-i18n.c -gdl-stock.c -gdl-switcher.c -gdl-tools.h -libgdlmarshal.c -libgdltypebuiltins.c -${GDL_WIN} +set(libgdl_SRC + gdl-dock.c + gdl-dock-bar.c + gdl-dock-item.c + gdl-dock-item-grip.c + gdl-dock-master.c + gdl-dock-notebook.c + gdl-dock-object.c + gdl-dock-paned.c + gdl-dock-placeholder.c + gdl-dock-tablabel.c + gdl-i18n.c + gdl-stock.c + gdl-switcher.c + gdl-tools.h + libgdlmarshal.c + libgdltypebuiltins.c + ${GDL_WIN} ) + +if(WIN32) + list(APPEND libgdl_SRC + gdl-win32.c + ) +endif() + ADD_LIBRARY(gdl STATIC ${libgdl_SRC}) -TARGET_LINK_LIBRARIES(gdl -${INKSCAPE_LIBS}) \ No newline at end of file +TARGET_LINK_LIBRARIES(gdl ${INKSCAPE_LIBS}) diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 3bf483181..798eb0d11 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -1,36 +1,37 @@ -SET(libnr_SRC -#in-svg-plane-test.cpp -nr-blit.cpp -nr-compose.cpp -nr-compose-transform.cpp -nr-gradient.cpp -nr-matrix.cpp -nr-matrix-div.cpp -nr-matrix-fns.cpp -nr-matrix-rotate-ops.cpp -nr-object.cpp -nr-pixblock.cpp -nr-pixblock-line.cpp -nr-pixblock-pattern.cpp -nr-pixblock-pixel.cpp -nr-point-fns.cpp -#nr-point-fns-test.cpp -nr-rect.cpp -nr-rect-l.cpp -nr-rotate-fns.cpp -#nr-rotate-fns-test.cpp -nr-rotate-matrix-ops.cpp -nr-scale-matrix-ops.cpp -nr-scale-translate-ops.cpp -nr-translate-matrix-ops.cpp -nr-translate-rotate-ops.cpp -nr-translate-scale-ops.cpp -#nr-translate-test.cpp -nr-types.cpp -#nr-types-test.cpp -nr-values.cpp -testnr.cpp + +set(libnr_SRC + #in-svg-plane-test.cpp + nr-blit.cpp + nr-compose.cpp + nr-compose-transform.cpp + nr-gradient.cpp + nr-matrix.cpp + nr-matrix-div.cpp + nr-matrix-fns.cpp + nr-matrix-rotate-ops.cpp + nr-object.cpp + nr-pixblock.cpp + nr-pixblock-line.cpp + nr-pixblock-pattern.cpp + nr-pixblock-pixel.cpp + nr-point-fns.cpp + #nr-point-fns-test.cpp + nr-rect.cpp + nr-rect-l.cpp + nr-rotate-fns.cpp + #nr-rotate-fns-test.cpp + nr-rotate-matrix-ops.cpp + nr-scale-matrix-ops.cpp + nr-scale-translate-ops.cpp + nr-translate-matrix-ops.cpp + nr-translate-rotate-ops.cpp + nr-translate-scale-ops.cpp + #nr-translate-test.cpp + nr-types.cpp + #nr-types-test.cpp + nr-values.cpp + #testnr.cpp ) -ADD_LIBRARY(nr STATIC ${libnr_SRC}) -TARGET_LINK_LIBRARIES(nr -2geom ${INKSCAPE_LIBS}) + +add_library(nr STATIC ${libnr_SRC}) +target_link_libraries(nr 2geom ${INKSCAPE_LIBS}) diff --git a/src/libnr/testnr.cpp b/src/libnr/testnr.cpp index 12dce4c52..7ce01afab 100644 --- a/src/libnr/testnr.cpp +++ b/src/libnr/testnr.cpp @@ -9,6 +9,8 @@ * This code is in public domain */ +#include <stdio.h> + #if defined (_WIN32) || defined (__WIN32__) # include <windows.h> #include <glib.h> diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 61ecb0091..4402e5066 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -1,19 +1,18 @@ -SET(libnrtype_SRC -FontFactory.cpp -FontInstance.cpp -font-lister.cpp -font-style-to-pos.cpp -Layout-TNG.cpp -Layout-TNG-Compute.cpp -Layout-TNG-Input.cpp -Layout-TNG-OutIter.cpp -Layout-TNG-Output.cpp -Layout-TNG-Scanline-Makers.cpp -nr-type-pos-def.cpp -nr-type-primitives.cpp -RasterFont.cpp -TextWrapper.cpp +set(libnrtype_SRC + FontFactory.cpp + FontInstance.cpp + font-lister.cpp + font-style-to-pos.cpp + Layout-TNG.cpp + Layout-TNG-Compute.cpp + Layout-TNG-Input.cpp + Layout-TNG-OutIter.cpp + Layout-TNG-Output.cpp + Layout-TNG-Scanline-Makers.cpp + nr-type-pos-def.cpp + nr-type-primitives.cpp + RasterFont.cpp + TextWrapper.cpp ) -ADD_LIBRARY(nrtype STATIC ${libnrtype_SRC}) -TARGET_LINK_LIBRARIES(nrtype -nr ${INKSCAPE_LIBS}) +add_library(nrtype STATIC ${libnrtype_SRC}) +target_link_libraries(nrtype nr ${INKSCAPE_LIBS}) diff --git a/src/libvpsc/CMakeLists.txt b/src/libvpsc/CMakeLists.txt index 4c3398b0f..57811ad0a 100644 --- a/src/libvpsc/CMakeLists.txt +++ b/src/libvpsc/CMakeLists.txt @@ -1,13 +1,14 @@ -SET(libvpsc_SRC -block.cpp -blocks.cpp -constraint.cpp -csolve_VPSC.cpp -generate-constraints.cpp -remove_rectangle_overlap.cpp -solve_VPSC.cpp -variable.cpp +set(libvpsc_SRC + block.cpp + blocks.cpp + constraint.cpp + csolve_VPSC.cpp + generate-constraints.cpp + remove_rectangle_overlap.cpp + solve_VPSC.cpp + variable.cpp + pairingheap/PairingHeap.cpp ) -ADD_LIBRARY(vpsc STATIC ${libvpsc_SRC}) -TARGET_LINK_LIBRARIES(vpsc -${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(vpsc STATIC ${libvpsc_SRC}) +target_link_libraries(vpsc ${INKSCAPE_LIBS}) diff --git a/src/livarot/CMakeLists.txt b/src/livarot/CMakeLists.txt index 6eaf84d1c..965926fb8 100644 --- a/src/livarot/CMakeLists.txt +++ b/src/livarot/CMakeLists.txt @@ -1,25 +1,25 @@ -SET(livarot_SRC -AlphaLigne.cpp -AVL.cpp -BitLigne.cpp -float-line.cpp -int-line.cpp -PathConversion.cpp -Path.cpp -PathCutting.cpp -path-description.cpp -PathOutline.cpp -PathSimplify.cpp -PathStroke.cpp -Shape.cpp -ShapeDraw.cpp -ShapeMisc.cpp -ShapeRaster.cpp -ShapeSweep.cpp -sweep-event.cpp -sweep-tree.cpp -sweep-tree-list.cpp +set(livarot_SRC + AlphaLigne.cpp + AVL.cpp + BitLigne.cpp + float-line.cpp + int-line.cpp + PathConversion.cpp + Path.cpp + PathCutting.cpp + path-description.cpp + PathOutline.cpp + PathSimplify.cpp + PathStroke.cpp + Shape.cpp + ShapeDraw.cpp + ShapeMisc.cpp + ShapeRaster.cpp + ShapeSweep.cpp + sweep-event.cpp + sweep-tree.cpp + sweep-tree-list.cpp ) -ADD_LIBRARY(livarot STATIC ${livarot_SRC}) -TARGET_LINK_LIBRARIES(nrtype -${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(livarot STATIC ${livarot_SRC}) +target_link_libraries(nrtype ${INKSCAPE_LIBS}) diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 70e8cbaf8..42f8208ec 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -1,37 +1,48 @@ -ADD_SUBDIRECTORY(parameter) +add_subdirectory(parameter) -SET(live_effects_SRC -bezctx.cpp -effect.cpp -lpe-bendpath.cpp -lpe-boolops.cpp -lpe-circle_with_radius.cpp -lpe-constructgrid.cpp -lpe-curvestitch.cpp -lpe-envelope.cpp -lpe-gears.cpp -lpegroupbbox.cpp -lpe-interpolate.cpp -lpe-knot.cpp -lpe-rough-hatches.cpp -lpe-lattice.cpp -lpe-mirror_symmetry.cpp -lpeobject.cpp -lpeobject-reference.cpp -lpe-patternalongpath.cpp -lpe-perp_bisector.cpp -lpe-perspective_path.cpp -lpe-powerstroke.cpp -lpe-skeleton.cpp -lpe-sketch.cpp -lpe-spiro.cpp -lpe-tangent_to_curve.cpp -lpe-test-doEffect-stack.cpp -lpe-vonkoch.cpp -lpe-dynastroke.cpp -spiro.cpp -${live_effects_parameter_SRC} +set(live_effects_SRC + bezctx.cpp + effect.cpp + lpe-angle_bisector.cpp + lpe-bendpath.cpp + lpe-boolops.cpp + lpe-circle_3pts.cpp + lpe-circle_with_radius.cpp + lpe-constructgrid.cpp + lpe-copy_rotate.cpp + lpe-curvestitch.cpp + lpe-dynastroke.cpp + lpe-envelope.cpp + lpe-extrude.cpp + lpe-gears.cpp + lpe-interpolate.cpp + lpe-knot.cpp + lpe-lattice.cpp + lpe-line_segment.cpp + lpe-mirror_symmetry.cpp + lpe-offset.cpp + lpe-parallel.cpp + lpe-path_length.cpp + lpe-patternalongpath.cpp + lpe-perp_bisector.cpp + lpe-perspective_path.cpp + lpe-powerstroke.cpp + lpe-recursiveskeleton.cpp + lpe-rough-hatches.cpp + lpe-ruler.cpp + lpe-skeleton.cpp + lpe-sketch.cpp + lpe-spiro.cpp + lpe-tangent_to_curve.cpp + lpe-test-doEffect-stack.cpp + lpe-text_label.cpp + lpe-vonkoch.cpp + lpegroupbbox.cpp + lpeobject-reference.cpp + lpeobject.cpp + spiro.cpp + ${live_effects_parameter_SRC} ) -ADD_LIBRARY(live_effects STATIC ${live_effects_SRC}) -TARGET_LINK_LIBRARIES(live_effects -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(live_effects STATIC ${live_effects_SRC}) +target_link_libraries(live_effects 2geom ${INKSCAPE_LIBS}) diff --git a/src/live_effects/parameter/CMakeLists.txt b/src/live_effects/parameter/CMakeLists.txt index 8657b2bec..04a1080f4 100644 --- a/src/live_effects/parameter/CMakeLists.txt +++ b/src/live_effects/parameter/CMakeLists.txt @@ -1,13 +1,13 @@ -SET(live_effects_parameter_SRC -array.cpp -bool.cpp -parameter.cpp -path.cpp -path-reference.cpp -point.cpp -powerstrokepointarray.cpp -random.cpp -text.cpp -unit.cpp -vector.cpp +set(live_effects_parameter_SRC + array.cpp + bool.cpp + parameter.cpp + path.cpp + path-reference.cpp + point.cpp + powerstrokepointarray.cpp + random.cpp + text.cpp + unit.cpp + vector.cpp ) diff --git a/src/pedro/CMakeLists.txt b/src/pedro/CMakeLists.txt index cb9a01b2f..5595d755e 100644 --- a/src/pedro/CMakeLists.txt +++ b/src/pedro/CMakeLists.txt @@ -1,13 +1,12 @@ -SET(pedro_SRC -#empty.cpp -#geckoembed.cpp -pedroconfig.cpp -pedrodom.cpp -#pedrogui.cpp -#pedromain.cpp -pedroutil.cpp -pedroxmpp.cpp +set(pedro_SRC + #empty.cpp + #geckoembed.cpp + pedroconfig.cpp + pedrodom.cpp + #pedrogui.cpp + #pedromain.cpp + pedroutil.cpp + pedroxmpp.cpp ) -ADD_LIBRARY(pedro STATIC ${pedro_SRC}) -TARGET_LINK_LIBRARIES(pedro -${INKSCAPE_LIBS}) \ No newline at end of file +add_library(pedro STATIC ${pedro_SRC}) +target_link_libraries(pedro ${INKSCAPE_LIBS}) \ No newline at end of file diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index 9d5dc0b7b..b2c4b918e 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -1,18 +1,18 @@ -SET(svg_SRC -css-ostringstream.cpp -#ftos.cpp -itos.cpp -path-string.cpp -round.cpp -sp-svg.def -stringstream.cpp -strip-trailing-zeros.cpp -svg-affine.cpp -svg-color.cpp -svg-length.cpp -svg-path.cpp -#test-stubs.cpp +set(svg_SRC + css-ostringstream.cpp + #ftos.cpp + itos.cpp + path-string.cpp + round.cpp + sp-svg.def + stringstream.cpp + strip-trailing-zeros.cpp + svg-affine.cpp + svg-color.cpp + svg-length.cpp + svg-path.cpp + #test-stubs.cpp ) -ADD_LIBRARY(svg STATIC ${svg_SRC}) -TARGET_LINK_LIBRARIES(svg -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(svg STATIC ${svg_SRC}) +target_link_libraries(svg 2geom ${INKSCAPE_LIBS}) diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index 3cb378995..312ee209c 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -1,12 +1,12 @@ -ADD_SUBDIRECTORY(potrace) -SET(trace_SRC -filterset.cpp -imagemap.cpp -imagemap-gdk.cpp -quantize.cpp -siox.cpp -trace.cpp -${trace_potrace_SRC} +add_subdirectory(potrace) +set(trace_SRC + filterset.cpp + imagemap.cpp + imagemap-gdk.cpp + quantize.cpp + siox.cpp + trace.cpp + ${trace_potrace_SRC} ) ADD_LIBRARY(trace STATIC ${trace_SRC}) TARGET_LINK_LIBRARIES(trace diff --git a/src/trace/potrace/CMakeLists.txt b/src/trace/potrace/CMakeLists.txt index f61e8bcd1..e48d7689f 100644 --- a/src/trace/potrace/CMakeLists.txt +++ b/src/trace/potrace/CMakeLists.txt @@ -1,9 +1,9 @@ -SET(trace_potrace_SRC -curve.cpp -decompose.cpp -greymap.cpp -inkscape-potrace.cpp -potracelib.cpp -render.cpp -trace.cpp +set(trace_potrace_SRC + curve.cpp + decompose.cpp + greymap.cpp + inkscape-potrace.cpp + potracelib.cpp + render.cpp + trace.cpp ) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 01dadb7c2..28dcd1ded 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,24 +1,46 @@ -SET(uifolders -cache -dialog -view -widget +set(uifolders + cache + dialog + view + widget ) -FOREACH(uilistsrc ${uifolders}) - ADD_SUBDIRECTORY(${uilistsrc}) -ENDFOREACH(uilistsrc) +foreach(uilistsrc ${uifolders}) + add_subdirectory(${uilistsrc}) +endforeach() -SET(ui_SRC -clipboard.cpp -context-menu.cpp -previewholder.cpp -stock.cpp -stock-items.cpp -${ui_cache_SRC} -${ui_dialog_SRC} -${ui_view_SRC} -${ui_widget_SRC} +set(ui_SRC + clipboard.cpp + context-menu.cpp + previewholder.cpp + uxmanager.cpp + + tool/control-point-selection.cpp + tool/control-point.cpp + tool/curve-drag-point.cpp + tool/event-utils.cpp + tool/manipulator.cpp + tool/modifier-tracker.cpp + tool/multi-path-manipulator.cpp + tool/node-tool.cpp + tool/node.cpp + tool/path-manipulator.cpp + tool/selectable-control-point.cpp + tool/selector.cpp + tool/transform-handle-set.cpp + + ${ui_cache_SRC} + ${ui_dialog_SRC} + ${ui_view_SRC} + ${ui_widget_SRC} +) + +include_directories( + "${CMAKE_SOURCE_DIR}/src" + "${CMAKE_SOURCE_DIR}" + "${CMAKE_SOURCE_DIR}/bind/javainc" + "${CMAKE_SOURCE_DIR}/bind/javainc/linux" + "${CMAKE_SOURCE_DIR}/extension/dbus" ) -ADD_LIBRARY(ui STATIC ${ui_SRC}) -TARGET_LINK_LIBRARIES(ui -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(ui STATIC ${ui_SRC}) +target_link_libraries(ui 2geom ${INKSCAPE_LIBS}) diff --git a/src/ui/cache/CMakeLists.txt b/src/ui/cache/CMakeLists.txt index a78010196..c00410de5 100644 --- a/src/ui/cache/CMakeLists.txt +++ b/src/ui/cache/CMakeLists.txt @@ -1,3 +1,3 @@ -SET(ui_cache_SRC -svg_preview_cache.cpp +set(ui_cache_SRC + svg_preview_cache.cpp ) diff --git a/src/ui/dialog/CMakeLists.txt b/src/ui/dialog/CMakeLists.txt index 98c4a47bb..dbd34cec1 100644 --- a/src/ui/dialog/CMakeLists.txt +++ b/src/ui/dialog/CMakeLists.txt @@ -1,45 +1,52 @@ -IF(WIN32) -SET(ui_dialog_WIN32_SRC -filedialogimpl-win32.cpp -) -ELSEIF(WIN32) - SET(ui_dialog_WIN32_SRC) -ENDIF(WIN32) -SET(ui_dialog_SRC -aboutbox.cpp -align-and-distribute.cpp -color-item.cpp -debug.cpp -dialog.cpp -dialog-manager.cpp -dock-behavior.cpp -document-metadata.cpp -document-properties.cpp -extension-editor.cpp -eek-preview.cpp -ege-paint-def.cpp -filedialog.cpp -filedialogimpl-gtkmm.cpp -fill-and-stroke.cpp -filter-effects-dialog.cpp -find.cpp -floating-behavior.cpp -inkscape-preferences.cpp -input.cpp -livepatheffect-editor.cpp -memory.cpp -messages.cpp -ocaldialogs.cpp -print.cpp -scriptdialog.cpp -#session-player.cpp -tile.cpp -tracedialog.cpp -transformation.cpp -undo-history.cpp -#whiteboard-connect.cpp -#whiteboard-sharewithchat.cpp -#whiteboard-sharewithuser.cpp -${ui_dialog_WIN32_SRC} +set(ui_dialog_SRC + aboutbox.cpp + align-and-distribute.cpp + calligraphic-profile-rename.cpp + color-item.cpp + debug.cpp + desktop-tracker.cpp + dialog-manager.cpp + dialog.cpp + dock-behavior.cpp + document-metadata.cpp + document-properties.cpp + extension-editor.cpp + extensions.cpp + filedialog.cpp + filedialogimpl-gtkmm.cpp + fill-and-stroke.cpp + filter-effects-dialog.cpp + find.cpp + floating-behavior.cpp + glyphs.cpp + guides.cpp + icon-preview.cpp + inkscape-preferences.cpp + input.cpp + layer-properties.cpp + layers.cpp + livepatheffect-editor.cpp + memory.cpp + messages.cpp + ocaldialogs.cpp + print-colors-preview-dialog.cpp + print.cpp + scriptdialog.cpp + session-player.cpp + svg-fonts-dialog.cpp + swatches.cpp + tile.cpp + tracedialog.cpp + transformation.cpp + undo-history.cpp + whiteboard-connect.cpp + whiteboard-sharewithchat.cpp + whiteboard-sharewithuser.cpp ) + +if(WIN32) + list(APPEND ui_dialog_SRC + filedialogimpl-win32.cpp + ) +endif() diff --git a/src/ui/view/CMakeLists.txt b/src/ui/view/CMakeLists.txt index 5c96bc40e..c0914d887 100644 --- a/src/ui/view/CMakeLists.txt +++ b/src/ui/view/CMakeLists.txt @@ -1,10 +1,4 @@ -SET(ui_view_SRC -desktop.cpp -desktop-events.cpp -desktop-handles.cpp -desktop-style.cpp -edit.cpp -edit-widget.cpp -view.cpp -view-widget.cpp +set(ui_view_SRC + view.cpp + view-widget.cpp ) diff --git a/src/ui/widget/CMakeLists.txt b/src/ui/widget/CMakeLists.txt index ffc94c299..c81ea5e24 100644 --- a/src/ui/widget/CMakeLists.txt +++ b/src/ui/widget/CMakeLists.txt @@ -1,40 +1,43 @@ -SET(ui_widget_SRC -button.cpp -color-picker.cpp -color-preview.cpp -combo-text.cpp -dock.cpp -dock-item.cpp -entity-entry.cpp -entry.cpp -filter-effect-chooser.cpp -handlebox.cpp -icon-widget.cpp -imageicon.cpp -imagetoggler.cpp -labelled.cpp -licensor.cpp -notebook-page.cpp -object-composite-settings.cpp -page-sizer.cpp -panel.cpp -point.cpp -preferences-widget.cpp -random.cpp -registered-widget.cpp -registry.cpp -rendering-options.cpp -rotateable.cpp -ruler.cpp -scalar.cpp -scalar-unit.cpp -selected-style.cpp -spin-slider.cpp -style-subject.cpp -style-swatch.cpp -svg-canvas.cpp -tolerance-slider.cpp -toolbox.cpp -unit-menu.cpp -zoom-status.cpp +set(ui_widget_SRC + button.cpp + color-picker.cpp + color-preview.cpp + combo-text.cpp + dock-item.cpp + dock.cpp + entity-entry.cpp + entry.cpp + filter-effect-chooser.cpp + handlebox.cpp + icon-widget.cpp + imageicon.cpp + imagetoggler.cpp + labelled.cpp + layer-selector.cpp + licensor.cpp + notebook-page.cpp + object-composite-settings.cpp + page-sizer.cpp + panel.cpp + point.cpp + preferences-widget.cpp + random.cpp + registered-widget.cpp + registry.cpp + rendering-options.cpp + rotateable.cpp + ruler.cpp + scalar-unit.cpp + scalar.cpp + selected-style.cpp + spin-slider.cpp + spinbutton.cpp + style-subject.cpp + style-swatch.cpp + svg-canvas.cpp + text.cpp + tolerance-slider.cpp + toolbox.cpp + unit-menu.cpp + zoom-status.cpp ) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 18237ac75..936a5fae9 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,7 +1,11 @@ -SET(util_SRC -share.cpp -units.cpp + +set(util_SRC + ege-appear-time-tracker.cpp + ege-tags.cpp + expression-evaluator.cpp + share.cpp + units.cpp ) -ADD_LIBRARY(util STATIC ${util_SRC}) -TARGET_LINK_LIBRARIES(util -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(util STATIC ${util_SRC}) +target_link_libraries(util 2geom ${INKSCAPE_LIBS}) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index f3c0e70fa..b698ced98 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,36 +1,40 @@ -SET(widgets_SRC -button.cpp -calligraphic-profile-rename.cpp -dash-selector.cpp -desktop-widget.cpp -font-selector.cpp -gradient-image.cpp -gradient-selector.cpp -gradient-toolbar.cpp -gradient-vector.cpp -icon.cpp -layer-selector.cpp -paint-selector.cpp -ruler.cpp -select-toolbar.cpp -shrink-wrap-button.cpp -sp-color-gtkselector.cpp -sp-color-icc-selector.cpp -sp-color-notebook.cpp -sp-color-preview.cpp -sp-color-scales.cpp -sp-color-selector.cpp -sp-color-slider.cpp -sp-color-wheel-selector.cpp -spinbutton-events.cpp -sp-widget.cpp -spw-utilities.cpp -sp-xmlview-attr-list.cpp -sp-xmlview-content.cpp -sp-xmlview-tree.cpp -swatch-selector.cpp -toolbox.cpp + +set(widgets_SRC + button.cpp + dash-selector.cpp + desktop-widget.cpp + eek-preview.cpp + ege-paint-def.cpp + fill-style.cpp + font-selector.cpp + gradient-image.cpp + gradient-selector.cpp + gradient-toolbar.cpp + gradient-vector.cpp + icon.cpp + paint-selector.cpp + ruler.cpp + select-toolbar.cpp + shrink-wrap-button.cpp + sp-attribute-widget.cpp + sp-color-gtkselector.cpp + sp-color-icc-selector.cpp + sp-color-notebook.cpp + sp-color-preview.cpp + sp-color-scales.cpp + sp-color-selector.cpp + sp-color-slider.cpp + sp-color-wheel-selector.cpp + sp-widget.cpp + sp-xmlview-attr-list.cpp + sp-xmlview-content.cpp + sp-xmlview-tree.cpp + spinbutton-events.cpp + spw-utilities.cpp + stroke-style.cpp + swatch-selector.cpp + toolbox.cpp ) -ADD_LIBRARY(widgets STATIC ${widgets_SRC}) -TARGET_LINK_LIBRARIES(widgets -2geom ${INKSCAPE_LIBS}) + +add_library(widgets STATIC ${widgets_SRC}) +target_link_libraries(widgets 2geom ${INKSCAPE_LIBS}) diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index 775a4e72f..b92d82489 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -1,21 +1,21 @@ -SET(xml_SRC -composite-node-observer.cpp -croco-node-iface.cpp -event.cpp -log-builder.cpp -node-fns.cpp -quote.cpp -#quote-test.cpp -repr.cpp -#repr-action-test.cpp -repr-css.cpp -repr-io.cpp -repr-sorting.cpp -repr-util.cpp -simple-document.cpp -simple-node.cpp -subtree.cpp +set(xml_SRC + composite-node-observer.cpp + croco-node-iface.cpp + event.cpp + log-builder.cpp + node-fns.cpp + quote.cpp + repr.cpp + repr-css.cpp + repr-io.cpp + repr-sorting.cpp + repr-util.cpp + simple-document.cpp + simple-node.cpp + subtree.cpp + helper-observer.cpp + rebase-hrefs.cpp ) -ADD_LIBRARY(xml STATIC ${xml_SRC}) -TARGET_LINK_LIBRARIES(xml -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +add_library(xml STATIC ${xml_SRC}) +target_link_libraries(xml 2geom ${INKSCAPE_LIBS}) \ No newline at end of file -- cgit v1.2.3 From 321f115f7dad3366f2427443ce0aa725f6881f2e Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sun, 12 Jun 2011 20:46:15 +0000 Subject: cmake: commented unused files/dirs, double checked all files compile this time (bzr r10273) --- src/2geom/CMakeLists.txt | 6 +-- src/CMakeLists.txt | 100 ++++++++++++++++++++-------------------- src/display/CMakeLists.txt | 2 +- src/dom/CMakeLists.txt | 2 +- src/dom/io/CMakeLists.txt | 2 +- src/libcola/CMakeLists.txt | 2 +- src/live_effects/CMakeLists.txt | 2 +- src/ui/dialog/CMakeLists.txt | 8 ++-- 8 files changed, 62 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index 91c14db8b..0ef925a55 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -7,8 +7,8 @@ set(2GEOM_SRC bezier-utils.cpp circle-circle.cpp circle.cpp - conic_section_clipper_impl.cpp - conicsec.cpp + # conic_section_clipper_impl.cpp + # conicsec.cpp conjugate_gradient.cpp convex-cover.cpp crossing.cpp @@ -27,7 +27,7 @@ set(2GEOM_SRC point.cpp poly.cpp quadtree.cpp - recursive-bezier-intersection.cpp + # recursive-bezier-intersection.cpp region.cpp sbasis-2d.cpp sbasis-geometric.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4bd93db12..08ea05387 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ set(SP_SRC sp-anchor.cpp - sp-animation.cpp + # sp-animation.cpp sp-clippath.cpp sp-conn-end-pair.cpp sp-conn-end.cpp @@ -50,7 +50,7 @@ set(SP_SRC sp-root.cpp sp-script.cpp sp-shape.cpp - sp-skeleton.cpp + # sp-skeleton.cpp sp-spiral.cpp sp-star.cpp sp-stop.cpp @@ -225,9 +225,9 @@ set(internalfolders filters helper io - jabber_whiteboard + # jabber_whiteboard live_effects - pedro + # pedro svg trace #traits @@ -296,52 +296,52 @@ target_link_libraries(inkscape # system libs - xslt - gtkspell - gsl - gslcblas - gtkmm-2.4 - atkmm-1.6 - gdkmm-2.4 - giomm-2.4 - pangomm-1.4 - gtk-x11-2.0 - glibmm-2.4 - cairomm-1.0 - sigc-2.0 - atk-1.0 - gio-2.0 - png - X11 - xml2 - dl - gomp - popt - aspell - gnomevfs-2 - gconf-2 - pangoft2-1.0 - fontconfig - freetype - z - Magick++ - MagickCore - gc - lcms - poppler-glib - gdk-x11-2.0 - poppler - pangocairo-1.0 - gdk_pixbuf-2.0 - png14 - m - pango-1.0 - cairo - gmodule-2.0 - gobject-2.0 - gthread-2.0 - rt - glib-2.0 + -lxslt + -lgtkspell + -lgsl + -lgslcblas + -lgtkmm-2.4 + -latkmm-1.6 + -lgdkmm-2.4 + -lgiomm-2.4 + -lpangomm-1.4 + -lgtk-x11-2.0 + -lglibmm-2.4 + -lcairomm-1.0 + -lsigc-2.0 + -latk-1.0 + -lgio-2.0 + -lpng + -lX11 + -lxml2 + -ldl + -lgomp + -lpopt + -laspell + -lgnomevfs-2 + -lgconf-2 + -lpangoft2-1.0 + -lfontconfig + -lfreetype + -lz + -lMagick++ + -lMagickCore + -lgc + -llcms + -lpoppler-glib + -lgdk-x11-2.0 + -lpoppler + -lpangocairo-1.0 + -lgdk_pixbuf-2.0 + -lpng14 + -lm + -lpango-1.0 + -lcairo + -lgmodule-2.0 + -lgobject-2.0 + -lgthread-2.0 + -lrt + -lglib-2.0 ) diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 1d3e09200..a46ff4e84 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -33,7 +33,7 @@ set(display_SRC nr-filter-morphology.cpp nr-filter-offset.cpp nr-filter-primitive.cpp - nr-filter-skeleton.cpp + # nr-filter-skeleton.cpp nr-filter-slot.cpp nr-filter-specularlighting.cpp nr-filter-tile.cpp diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index 53609d241..3648010ac 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -24,7 +24,7 @@ set(dom_SRC ucd.cpp uri.cpp xmlreader.cpp - xmlwriter.cpp + # xmlwriter.cpp xpathimpl.cpp xpathparser.cpp xpathtoken.cpp diff --git a/src/dom/io/CMakeLists.txt b/src/dom/io/CMakeLists.txt index 0b0b4630d..7b99c898f 100644 --- a/src/dom/io/CMakeLists.txt +++ b/src/dom/io/CMakeLists.txt @@ -3,7 +3,7 @@ set(dom_io_SRC bufferstream.cpp domstream.cpp gzipstream.cpp - httpclient.cpp + # httpclient.cpp socket.cpp stringstream.cpp uristream.cpp diff --git a/src/libcola/CMakeLists.txt b/src/libcola/CMakeLists.txt index 19ac816b2..43c510f13 100644 --- a/src/libcola/CMakeLists.txt +++ b/src/libcola/CMakeLists.txt @@ -2,7 +2,7 @@ set(libcola_SRC cola.cpp conjugate_gradient.cpp connected_components.cpp - cycle_detector.cpp + # cycle_detector.cpp gradient_projection.cpp shortest_paths.cpp straightener.cpp diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 42f8208ec..0edbbc922 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -30,7 +30,7 @@ set(live_effects_SRC lpe-recursiveskeleton.cpp lpe-rough-hatches.cpp lpe-ruler.cpp - lpe-skeleton.cpp + # lpe-skeleton.cpp lpe-sketch.cpp lpe-spiro.cpp lpe-tangent_to_curve.cpp diff --git a/src/ui/dialog/CMakeLists.txt b/src/ui/dialog/CMakeLists.txt index dbd34cec1..5f2b31989 100644 --- a/src/ui/dialog/CMakeLists.txt +++ b/src/ui/dialog/CMakeLists.txt @@ -33,16 +33,16 @@ set(ui_dialog_SRC print-colors-preview-dialog.cpp print.cpp scriptdialog.cpp - session-player.cpp + # session-player.cpp svg-fonts-dialog.cpp swatches.cpp tile.cpp tracedialog.cpp transformation.cpp undo-history.cpp - whiteboard-connect.cpp - whiteboard-sharewithchat.cpp - whiteboard-sharewithuser.cpp + # whiteboard-connect.cpp + # whiteboard-sharewithchat.cpp + # whiteboard-sharewithuser.cpp ) if(WIN32) -- cgit v1.2.3 From de03354959190a2c5392d79e03dd22dc45777e41 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sun, 12 Jun 2011 21:27:00 +0000 Subject: cmake: give all libs a _LIB suffix, workaround 'debug' being confused with cake keyword, and also dont mix up dor names with libs. (bzr r10274) --- src/2geom/CMakeLists.txt | 10 ++--- src/CMakeLists.txt | 73 ++++++++++++++++++++++++------------ src/bind/CMakeLists.txt | 4 +- src/debug/CMakeLists.txt | 4 +- src/dialogs/CMakeLists.txt | 4 +- src/display/CMakeLists.txt | 4 +- src/dom/CMakeLists.txt | 4 +- src/extension/CMakeLists.txt | 4 +- src/filters/CMakeLists.txt | 4 +- src/helper/CMakeLists.txt | 9 ++--- src/io/CMakeLists.txt | 5 ++- src/jabber_whiteboard/CMakeLists.txt | 4 +- src/libavoid/CMakeLists.txt | 4 +- src/libcola/CMakeLists.txt | 4 +- src/libcroco/CMakeLists.txt | 4 +- src/libgdl/CMakeLists.txt | 4 +- src/libnr/CMakeLists.txt | 4 +- src/libnrtype/CMakeLists.txt | 4 +- src/libvpsc/CMakeLists.txt | 4 +- src/livarot/CMakeLists.txt | 4 +- src/live_effects/CMakeLists.txt | 4 +- src/pedro/CMakeLists.txt | 4 +- src/svg/CMakeLists.txt | 4 +- src/trace/CMakeLists.txt | 7 ++-- src/ui/CMakeLists.txt | 4 +- src/util/CMakeLists.txt | 4 +- src/widgets/CMakeLists.txt | 4 +- src/xml/CMakeLists.txt | 4 +- 28 files changed, 111 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index 0ef925a55..bdb24cc59 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -1,5 +1,5 @@ -set(2GEOM_SRC +set(2geom_SRC affine.cpp basic-intersection.cpp bezier-clipping.cpp @@ -121,7 +121,7 @@ set(2GEOM_SRC numeric/vector.h ) -# make lib for 2geom -add_library(2geom STATIC ${2GEOM_SRC}) -#TARGET_LINK_LIBRARIES(2geom blas gsl) -target_link_libraries(2geom ${INKSCAPE_LIBS}) +# make lib for 2geom_LIB +add_library(2geom_LIB STATIC ${2geom_SRC}) +#TARGET_LINK_LIBRARIES(2geom_LIB blas_LIB gsl_LIB) +target_link_libraries(2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08ea05387..fa5a5b34e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,8 +129,8 @@ set(INKSCAPE_SRC inkscape-version.cpp inkscape.cpp inkscape.rc - inkview.cpp - inkview.rc + # inkview.cpp + # inkview.rc interface.cpp knot-holder-entity.cpp knot.cpp @@ -264,17 +264,34 @@ set(INKSCAPE_SRC ${GlibOutput} ) -add_library(sp STATIC ${SP_SRC}) -target_link_libraries(sp - nr - nrtype - avoid - cola - croco - gdl - vpsc - livarot - ${internalfolders} +add_library(sp_LIB STATIC ${SP_SRC}) + +target_link_libraries( + sp_LIB + nr_LIB + nrtype_LIB + avoid_LIB + cola_LIB + croco_LIB + gdl_LIB + vpsc_LIB + livarot_LIB + + bind_LIB + display_LIB + dom_LIB + extension_LIB + filters_LIB + helper_LIB + io_LIB + live_effects_LIB + svg_LIB + trace_LIB + ui_LIB + widgets_LIB + xml_LIB + 2geom_LIB + ${INKSCAPE_LIBS} ) @@ -282,16 +299,15 @@ target_link_libraries(sp add_executable(inkscape ${INKSCAPE_SRC}) target_link_libraries(inkscape - nr - nrtype - sp - avoid - cola - croco - gdl - vpsc - livarot - ${internalfolders} + nr_LIB + nrtype_LIB + sp_LIB + avoid_LIB + cola_LIB + croco_LIB + gdl_LIB + vpsc_LIB + livarot_LIB ${INKSCAPE_LIBS} @@ -348,6 +364,15 @@ target_link_libraries(inkscape # make executable for INKVIEW #ADD_EXECUTABLE(inkview inkview.cpp) #TARGET_LINK_LIBRARIES(inkview -# 2geom avoid cola croco gdl nr nrtype vpsc livarot sp ${internalfolders} +# 2geom_LIB +# avoid_LIB +# cola_LIB +# croco_LIB +# gdl_LIB +# nr_LIB +# nrtype_LIB +# vpsc_LIB +# livarot_LIB +# sp_LIB #) diff --git a/src/bind/CMakeLists.txt b/src/bind/CMakeLists.txt index 08b7876c2..71bf0b602 100644 --- a/src/bind/CMakeLists.txt +++ b/src/bind/CMakeLists.txt @@ -2,5 +2,5 @@ set(bind_SRC dobinding.cpp javabind.cpp ) -add_library(bind STATIC ${bind_SRC}) -target_link_libraries(bind ${INKSCAPE_LIBS}) +add_library(bind_LIB STATIC ${bind_SRC}) +target_link_libraries(bind_LIB ${INKSCAPE_LIBS}) diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 2dab10144..6727817f9 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -9,5 +9,5 @@ set(debug_SRC gdk-event-latency-tracker.cpp ) -add_library(debug STATIC ${debug_SRC}) -target_link_libraries(debug 2geom ${INKSCAPE_LIBS}) +add_library(debug_LIB STATIC ${debug_SRC}) +target_link_libraries(debug_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index aa8f836d5..d22b5750c 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -9,5 +9,5 @@ set(dialogs_SRC text-edit.cpp xml-tree.cpp ) -add_library(dialogs STATIC ${dialogs_SRC}) -target_link_libraries(dialogs 2geom ${INKSCAPE_LIBS}) +add_library(dialogs_LIB STATIC ${dialogs_SRC}) +target_link_libraries(dialogs_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index a46ff4e84..86f122297 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -62,5 +62,5 @@ include_directories( "${CMAKE_SOURCE_DIR}/src" ) -add_library(display STATIC ${display_SRC}) -target_link_libraries(display 2geom ${INKSCAPE_LIBS}) +add_library(display_LIB STATIC ${display_SRC}) +target_link_libraries(display_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index 3648010ac..66571d06a 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -34,5 +34,5 @@ set(dom_SRC #${dom_work_SRC} ) -add_library(dom STATIC ${dom_SRC}) -target_link_libraries(dom 2geom ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(dom_LIB STATIC ${dom_SRC}) +target_link_libraries(dom_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 73697fbe7..47cfbe9e4 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -37,5 +37,5 @@ set(extension_SRC ${extension_script_SRC} ) -add_library(extension STATIC ${extension_SRC}) -target_link_libraries(extension 2geom ${INKSCAPE_LIBS}) +add_library(extension_LIB STATIC ${extension_SRC}) +target_link_libraries(extension_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index 32819fa68..a1bec4642 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -20,5 +20,5 @@ set(filters_SRC tile.cpp turbulence.cpp ) -add_library(filters STATIC ${filters_SRC}) -target_link_libraries(filters 2geom ${INKSCAPE_LIBS}) +add_library(filters_LIB STATIC ${filters_SRC}) +target_link_libraries(filters_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index e2ca2336d..86c5eea10 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -2,7 +2,7 @@ include(UseGlibMarshal) GLIB_MARSHAL(sp_marshal sp-marshal "${CMAKE_CURRENT_BINARY_DIR}/helper") -set(GlibOutput +set(sp_marshal_SRC ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.cpp ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.h ) @@ -23,9 +23,8 @@ set(helper_SRC sp-marshal.cpp sp-marshal.list # we generate this file and it's .h counter-part - ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.cpp - ${CMAKE_CURRENT_BINARY_DIR}/sp-marshal.h + ${sp_marshal_SRC} ) -add_library(helper STATIC ${helper_SRC}) -target_link_libraries(helper 2geom ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(helper_LIB STATIC ${helper_SRC}) +target_link_libraries(helper_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index b60830042..88040744b 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -11,5 +11,6 @@ set(io_SRC uristream.cpp xsltstream.cpp ) -add_library(io STATIC ${io_SRC}) -target_link_libraries(io 2geom ${INKSCAPE_LIBS}) + +add_library(io_LIB STATIC ${io_SRC}) +target_link_libraries(io_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/jabber_whiteboard/CMakeLists.txt b/src/jabber_whiteboard/CMakeLists.txt index 6975d06d6..dbe9f1e1e 100644 --- a/src/jabber_whiteboard/CMakeLists.txt +++ b/src/jabber_whiteboard/CMakeLists.txt @@ -19,5 +19,5 @@ set(jabber_whiteboard_SRC ${jabber_whiteboard_dialog_SRC} ) -add_library(jabber_whiteboard STATIC ${jabber_whiteboard_SRC}) -target_link_libraries(jabber_whiteboard 2geom ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(jabber_whiteboard_LIB STATIC ${jabber_whiteboard_SRC}) +target_link_libraries(jabber_whiteboard_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/libavoid/CMakeLists.txt b/src/libavoid/CMakeLists.txt index b76cf1d39..6eb6bdd1d 100644 --- a/src/libavoid/CMakeLists.txt +++ b/src/libavoid/CMakeLists.txt @@ -14,5 +14,5 @@ set(libavoid_SRC vpsc.cpp ) -add_library(avoid STATIC ${libavoid_SRC}) -target_link_libraries(avoid ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(avoid_LIB STATIC ${libavoid_SRC}) +target_link_libraries(avoid_LIB ${INKSCAPE_LIBS}) diff --git a/src/libcola/CMakeLists.txt b/src/libcola/CMakeLists.txt index 43c510f13..40c92d578 100644 --- a/src/libcola/CMakeLists.txt +++ b/src/libcola/CMakeLists.txt @@ -7,5 +7,5 @@ set(libcola_SRC shortest_paths.cpp straightener.cpp ) -add_library(cola STATIC ${libcola_SRC}) -target_link_libraries(cola ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(cola_LIB STATIC ${libcola_SRC}) +target_link_libraries(cola_LIB ${INKSCAPE_LIBS}) diff --git a/src/libcroco/CMakeLists.txt b/src/libcroco/CMakeLists.txt index 7e8aa9176..3aae8eac4 100644 --- a/src/libcroco/CMakeLists.txt +++ b/src/libcroco/CMakeLists.txt @@ -29,5 +29,5 @@ set(libcroco_SRC cr-utils.c ) -add_library(croco STATIC ${libcroco_SRC}) -target_link_libraries(croco ${INKSCAPE_LIBS}) +add_library(croco_LIB STATIC ${libcroco_SRC}) +target_link_libraries(croco_LIB ${INKSCAPE_LIBS}) diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt index f59ec5420..6411579b3 100644 --- a/src/libgdl/CMakeLists.txt +++ b/src/libgdl/CMakeLists.txt @@ -25,5 +25,5 @@ if(WIN32) ) endif() -ADD_LIBRARY(gdl STATIC ${libgdl_SRC}) -TARGET_LINK_LIBRARIES(gdl ${INKSCAPE_LIBS}) +ADD_LIBRARY(gdl_LIB STATIC ${libgdl_SRC}) +TARGET_LINK_LIBRARIES(gdl_LIB ${INKSCAPE_LIBS}) diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 798eb0d11..28fee7b77 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -33,5 +33,5 @@ set(libnr_SRC #testnr.cpp ) -add_library(nr STATIC ${libnr_SRC}) -target_link_libraries(nr 2geom ${INKSCAPE_LIBS}) +add_library(nr_LIB STATIC ${libnr_SRC}) +target_link_libraries(nr_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 4402e5066..75bb5f57b 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -14,5 +14,5 @@ set(libnrtype_SRC RasterFont.cpp TextWrapper.cpp ) -add_library(nrtype STATIC ${libnrtype_SRC}) -target_link_libraries(nrtype nr ${INKSCAPE_LIBS}) +add_library(nrtype_LIB STATIC ${libnrtype_SRC}) +target_link_libraries(nrtype_LIB nr_LIB ${INKSCAPE_LIBS}) diff --git a/src/libvpsc/CMakeLists.txt b/src/libvpsc/CMakeLists.txt index 57811ad0a..0a91c3516 100644 --- a/src/libvpsc/CMakeLists.txt +++ b/src/libvpsc/CMakeLists.txt @@ -10,5 +10,5 @@ set(libvpsc_SRC pairingheap/PairingHeap.cpp ) -add_library(vpsc STATIC ${libvpsc_SRC}) -target_link_libraries(vpsc ${INKSCAPE_LIBS}) +add_library(vpsc_LIB STATIC ${libvpsc_SRC}) +target_link_libraries(vpsc_LIB ${INKSCAPE_LIBS}) diff --git a/src/livarot/CMakeLists.txt b/src/livarot/CMakeLists.txt index 965926fb8..d8f4ba05d 100644 --- a/src/livarot/CMakeLists.txt +++ b/src/livarot/CMakeLists.txt @@ -21,5 +21,5 @@ set(livarot_SRC sweep-tree-list.cpp ) -add_library(livarot STATIC ${livarot_SRC}) -target_link_libraries(nrtype ${INKSCAPE_LIBS}) +add_library(livarot_LIB STATIC ${livarot_SRC}) +target_link_libraries(nrtype_LIB ${INKSCAPE_LIBS}) diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 0edbbc922..61fedbe66 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -44,5 +44,5 @@ set(live_effects_SRC ${live_effects_parameter_SRC} ) -add_library(live_effects STATIC ${live_effects_SRC}) -target_link_libraries(live_effects 2geom ${INKSCAPE_LIBS}) +add_library(live_effects_LIB STATIC ${live_effects_SRC}) +target_link_libraries(live_effects_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/pedro/CMakeLists.txt b/src/pedro/CMakeLists.txt index 5595d755e..4de3592db 100644 --- a/src/pedro/CMakeLists.txt +++ b/src/pedro/CMakeLists.txt @@ -8,5 +8,5 @@ set(pedro_SRC pedroutil.cpp pedroxmpp.cpp ) -add_library(pedro STATIC ${pedro_SRC}) -target_link_libraries(pedro ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(pedro_LIB STATIC ${pedro_SRC}) +target_link_libraries(pedro_LIB ${INKSCAPE_LIBS}) diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index b2c4b918e..4501983bb 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -14,5 +14,5 @@ set(svg_SRC #test-stubs.cpp ) -add_library(svg STATIC ${svg_SRC}) -target_link_libraries(svg 2geom ${INKSCAPE_LIBS}) +add_library(svg_LIB STATIC ${svg_SRC}) +target_link_libraries(svg_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index 312ee209c..d3bdcb6b1 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(potrace) + set(trace_SRC filterset.cpp imagemap.cpp @@ -8,6 +9,6 @@ set(trace_SRC trace.cpp ${trace_potrace_SRC} ) -ADD_LIBRARY(trace STATIC ${trace_SRC}) -TARGET_LINK_LIBRARIES(trace -2geom ${INKSCAPE_LIBS}) \ No newline at end of file + +ADD_LIBRARY(trace_LIB STATIC ${trace_SRC}) +TARGET_LINK_LIBRARIES(trace_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 28dcd1ded..5fa882f1a 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -42,5 +42,5 @@ include_directories( "${CMAKE_SOURCE_DIR}/extension/dbus" ) -add_library(ui STATIC ${ui_SRC}) -target_link_libraries(ui 2geom ${INKSCAPE_LIBS}) +add_library(ui_LIB STATIC ${ui_SRC}) +target_link_libraries(ui_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 936a5fae9..330d49662 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -7,5 +7,5 @@ set(util_SRC units.cpp ) -add_library(util STATIC ${util_SRC}) -target_link_libraries(util 2geom ${INKSCAPE_LIBS}) +add_library(util_LIB STATIC ${util_SRC}) +target_link_libraries(util_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index b698ced98..4c622fbec 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -36,5 +36,5 @@ set(widgets_SRC toolbox.cpp ) -add_library(widgets STATIC ${widgets_SRC}) -target_link_libraries(widgets 2geom ${INKSCAPE_LIBS}) +add_library(widgets_LIB STATIC ${widgets_SRC}) +target_link_libraries(widgets_LIB 2geom_LIB ${INKSCAPE_LIBS}) diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index b92d82489..1aafe2d21 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -17,5 +17,5 @@ set(xml_SRC rebase-hrefs.cpp ) -add_library(xml STATIC ${xml_SRC}) -target_link_libraries(xml 2geom ${INKSCAPE_LIBS}) \ No newline at end of file +add_library(xml_LIB STATIC ${xml_SRC}) +target_link_libraries(xml_LIB 2geom_LIB ${INKSCAPE_LIBS}) -- cgit v1.2.3 From 7172735786c43c2305a92ffd4e5d285d11f88f7f Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 00:19:17 +0000 Subject: cmake: turns out my recent commits (which I undid) were not incorrect, variables were set in subdirectories then used in the parent directory, where they were still unset. Fixing this broke the build because some files in the subdir were not compiling. (bzr r10276) --- src/2geom/CMakeLists.txt | 4 +- src/CMakeLists.txt | 56 +++++------ src/bind/CMakeLists.txt | 5 +- src/debug/CMakeLists.txt | 3 +- src/dialogs/CMakeLists.txt | 5 +- src/display/CMakeLists.txt | 4 +- src/dom/CMakeLists.txt | 46 +++++---- src/dom/io/CMakeLists.txt | 11 --- src/dom/odf/CMakeLists.txt | 5 - src/dom/util/CMakeLists.txt | 6 -- src/dom/work/CMakeLists.txt | 12 --- src/extension/CMakeLists.txt | 123 ++++++++++++++++++++----- src/extension/dxf2svg/CMakeLists.txt | 11 --- src/extension/implementation/CMakeLists.txt | 5 - src/extension/internal/CMakeLists.txt | 29 ------ src/extension/internal/bitmap/CMakeLists.txt | 37 -------- src/extension/internal/filter/CMakeLists.txt | 8 -- src/extension/internal/pdfinput/CMakeLists.txt | 5 - src/extension/param/CMakeLists.txt | 13 --- src/extension/script/CMakeLists.txt | 3 - src/filters/CMakeLists.txt | 5 +- src/helper/CMakeLists.txt | 4 +- src/io/CMakeLists.txt | 4 +- src/jabber_whiteboard/CMakeLists.txt | 7 +- src/jabber_whiteboard/dialog/CMakeLists.txt | 4 - src/libavoid/CMakeLists.txt | 4 +- src/libcola/CMakeLists.txt | 5 +- src/libcroco/CMakeLists.txt | 3 +- src/libgdl/CMakeLists.txt | 4 +- src/libnr/CMakeLists.txt | 3 +- src/libnrtype/CMakeLists.txt | 5 +- src/libvpsc/CMakeLists.txt | 4 +- src/livarot/CMakeLists.txt | 4 +- src/live_effects/CMakeLists.txt | 17 +++- src/live_effects/parameter/CMakeLists.txt | 13 --- src/pedro/CMakeLists.txt | 5 +- src/svg/CMakeLists.txt | 4 +- src/trace/CMakeLists.txt | 13 ++- src/trace/potrace/CMakeLists.txt | 9 -- src/ui/CMakeLists.txt | 114 +++++++++++++++++++---- src/ui/cache/CMakeLists.txt | 3 - src/ui/dialog/CMakeLists.txt | 52 ----------- src/ui/view/CMakeLists.txt | 4 - src/ui/widget/CMakeLists.txt | 43 --------- src/util/CMakeLists.txt | 3 +- src/widgets/CMakeLists.txt | 3 +- src/xml/CMakeLists.txt | 4 +- 47 files changed, 318 insertions(+), 416 deletions(-) delete mode 100644 src/dom/io/CMakeLists.txt delete mode 100644 src/dom/odf/CMakeLists.txt delete mode 100644 src/dom/util/CMakeLists.txt delete mode 100644 src/dom/work/CMakeLists.txt delete mode 100644 src/extension/dxf2svg/CMakeLists.txt delete mode 100644 src/extension/implementation/CMakeLists.txt delete mode 100644 src/extension/internal/CMakeLists.txt delete mode 100644 src/extension/internal/bitmap/CMakeLists.txt delete mode 100644 src/extension/internal/filter/CMakeLists.txt delete mode 100644 src/extension/internal/pdfinput/CMakeLists.txt delete mode 100644 src/extension/param/CMakeLists.txt delete mode 100644 src/extension/script/CMakeLists.txt delete mode 100644 src/jabber_whiteboard/dialog/CMakeLists.txt delete mode 100644 src/live_effects/parameter/CMakeLists.txt delete mode 100644 src/trace/potrace/CMakeLists.txt delete mode 100644 src/ui/cache/CMakeLists.txt delete mode 100644 src/ui/dialog/CMakeLists.txt delete mode 100644 src/ui/view/CMakeLists.txt delete mode 100644 src/ui/widget/CMakeLists.txt (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index bdb24cc59..6c6001c4b 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -122,6 +122,4 @@ set(2geom_SRC ) # make lib for 2geom_LIB -add_library(2geom_LIB STATIC ${2geom_SRC}) -#TARGET_LINK_LIBRARIES(2geom_LIB blas_LIB gsl_LIB) -target_link_libraries(2geom_LIB ${INKSCAPE_LIBS}) +add_library(2geom_LIB ${2geom_SRC}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa5a5b34e..de6175134 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ -set(SP_SRC +set(sp_SRC sp-anchor.cpp # sp-animation.cpp sp-clippath.cpp @@ -69,7 +69,7 @@ set(SP_SRC splivarot.cpp ) -set(INKSCAPE_SRC +set(inkscape_SRC arc-context.cpp attributes.cpp axis-manip.cpp @@ -205,7 +205,7 @@ set(INKSCAPE_SRC ) if(WIN32) - list(APPEND INKSCAPE_SRC + list(APPEND inkscape_SRC registrytool.cpp #deptool.cpp winmain.cpp @@ -259,55 +259,47 @@ foreach(srclistsrc ${dirs}) add_subdirectory(${srclistsrc}) endforeach() -set(INKSCAPE_SRC - ${INKSCAPE_SRC} +set(inkscape_SRC + ${inkscape_SRC} ${GlibOutput} ) -add_library(sp_LIB STATIC ${SP_SRC}) +add_library(sp_LIB ${sp_SRC}) -target_link_libraries( - sp_LIB - nr_LIB - nrtype_LIB - avoid_LIB - cola_LIB +# make executable for INKSCAPE +add_executable(inkscape ${inkscape_SRC}) + +target_link_libraries(inkscape + # order from automake + dom_LIB croco_LIB + avoid_LIB gdl_LIB + cola_LIB vpsc_LIB livarot_LIB + 2geom_LIB + # guessing these ones + ui_LIB bind_LIB + debug_LIB + dialogs_LIB display_LIB - dom_LIB extension_LIB filters_LIB helper_LIB io_LIB - live_effects_LIB + nr_LIB + nrtype_LIB + sp_LIB svg_LIB trace_LIB - ui_LIB + util_LIB widgets_LIB xml_LIB - 2geom_LIB - - ${INKSCAPE_LIBS} -) - -# make executable for INKSCAPE -add_executable(inkscape ${INKSCAPE_SRC}) + live_effects_LIB -target_link_libraries(inkscape - nr_LIB - nrtype_LIB - sp_LIB - avoid_LIB - cola_LIB - croco_LIB - gdl_LIB - vpsc_LIB - livarot_LIB ${INKSCAPE_LIBS} diff --git a/src/bind/CMakeLists.txt b/src/bind/CMakeLists.txt index 71bf0b602..d0f7c7ca0 100644 --- a/src/bind/CMakeLists.txt +++ b/src/bind/CMakeLists.txt @@ -1,6 +1,7 @@ + set(bind_SRC dobinding.cpp javabind.cpp ) -add_library(bind_LIB STATIC ${bind_SRC}) -target_link_libraries(bind_LIB ${INKSCAPE_LIBS}) + +add_library(bind_LIB ${bind_SRC}) diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 6727817f9..0c5760366 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -9,5 +9,4 @@ set(debug_SRC gdk-event-latency-tracker.cpp ) -add_library(debug_LIB STATIC ${debug_SRC}) -target_link_libraries(debug_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(debug_LIB ${debug_SRC}) diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index d22b5750c..bd6942ca6 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -1,3 +1,4 @@ + set(dialogs_SRC clonetiler.cpp dialog-events.cpp @@ -9,5 +10,5 @@ set(dialogs_SRC text-edit.cpp xml-tree.cpp ) -add_library(dialogs_LIB STATIC ${dialogs_SRC}) -target_link_libraries(dialogs_LIB 2geom_LIB ${INKSCAPE_LIBS}) + +add_library(dialogs_LIB ${dialogs_SRC}) diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 86f122297..ff0b7eac1 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -1,3 +1,4 @@ + set(display_SRC canvas-arena.cpp canvas-axonomgrid.cpp @@ -62,5 +63,4 @@ include_directories( "${CMAKE_SOURCE_DIR}/src" ) -add_library(display_LIB STATIC ${display_SRC}) -target_link_libraries(display_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(display_LIB ${display_SRC}) diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index 66571d06a..5a3ebebf8 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -1,13 +1,3 @@ -set(domfolders - io - odf - util - #work -) - -foreach(domlistsrc ${domfolders}) - add_subdirectory(${domlistsrc}) -endforeach() set(dom_SRC cssreader.cpp @@ -28,11 +18,35 @@ set(dom_SRC xpathimpl.cpp xpathparser.cpp xpathtoken.cpp - ${dom_io_SRC} - ${dom_odf_SRC} - ${dom_util_SRC} - #${dom_work_SRC} + + io/base64stream.cpp + io/bufferstream.cpp + io/domstream.cpp + io/gzipstream.cpp + # io/httpclient.cpp + io/socket.cpp + io/stringstream.cpp + io/uristream.cpp + + odf/odfdocument.cpp + #odf/SvgOdg.cpp + + util/digest.cpp + util/thread.cpp + util/ziptool.cpp + + # # Dont use any of them. + # work/svg2.cpp + # work/testdom.cpp + # work/testhttp.cpp + # work/testjs.cpp + # work/testodf.cpp + # work/testsvg.cpp + # work/testuri.cpp + # work/testxpath.cpp + # work/testzip.cpp + # work/xpathtests.cpp + ) -add_library(dom_LIB STATIC ${dom_SRC}) -target_link_libraries(dom_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(dom_LIB ${dom_SRC}) diff --git a/src/dom/io/CMakeLists.txt b/src/dom/io/CMakeLists.txt deleted file mode 100644 index 7b99c898f..000000000 --- a/src/dom/io/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(dom_io_SRC - base64stream.cpp - bufferstream.cpp - domstream.cpp - gzipstream.cpp - # httpclient.cpp - socket.cpp - stringstream.cpp - uristream.cpp -) - diff --git a/src/dom/odf/CMakeLists.txt b/src/dom/odf/CMakeLists.txt deleted file mode 100644 index 089f65fbf..000000000 --- a/src/dom/odf/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(dom_odf_SRC - odfdocument.cpp - #SvgOdg.cpp -) - diff --git a/src/dom/util/CMakeLists.txt b/src/dom/util/CMakeLists.txt deleted file mode 100644 index e5f583fa5..000000000 --- a/src/dom/util/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set(dom_util_SRC - digest.cpp - thread.cpp - ziptool.cpp -) - diff --git a/src/dom/work/CMakeLists.txt b/src/dom/work/CMakeLists.txt deleted file mode 100644 index 52552c8b9..000000000 --- a/src/dom/work/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(dom_work_SRC - #testdom.cpp - #testhttp.cpp - #testjs.cpp - #testodf.cpp - #testsvg.cpp - #testuri.cpp - #testxpath.cpp - #testzip.cpp - #xpathtests.cpp -) - diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 47cfbe9e4..3d8777e3a 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -1,17 +1,3 @@ -set(extfolders - #dxf2svg - implementation - internal - internal/bitmap - internal/filter - internal/pdfinput - param - script -) - -foreach(extlistsrc ${extfolders}) - add_subdirectory(${extlistsrc}) -endforeach() set(extension_SRC db.cpp @@ -28,14 +14,105 @@ set(extension_SRC print.cpp system.cpp timer.cpp - #${extension_dxf2svg_SRC} - ${extension_implementation_SRC} - ${extension_internal_bitmap_SRC} - ${extension_internal_filter_SRC} - ${extension_internal_pdfinput_SRC} - ${extension_param_SRC} - ${extension_script_SRC} + + implementation/implementation.cpp + implementation/xslt.cpp + implementation/script.cpp + + param/bool.cpp + param/color.cpp + param/description.cpp + param/enum.cpp + param/float.cpp + param/int.cpp + param/notebook.cpp + param/parameter.cpp + param/radiobutton.cpp + param/string.cpp + + internal/bluredge.cpp + internal/cairo-png-out.cpp + internal/cairo-ps-out.cpp + # internal/cairo-render-context.cpp # XXX MUST GET THIS WORKING + # internal/cairo-renderer.cpp # XXX MUST GET THIS WORKING + internal/cairo-renderer-pdf-out.cpp + internal/emf-win32-inout.cpp + internal/emf-win32-print.cpp + internal/gdkpixbuf-input.cpp + internal/gimpgrad.cpp + internal/grid.cpp + internal/latex-pstricks.cpp + # internal/latex-pstricks-out.cpp # XXX MUST GET THIS WORKING + internal/odf.cpp + internal/latex-text-renderer.cpp + internal/pdf-input-cairo.cpp + internal/pov-out.cpp + internal/javafx-out.cpp + internal/svg.cpp + internal/svgz.cpp + internal/wpg-input.cpp + + internal/bitmap/adaptiveThreshold.cpp + internal/bitmap/addNoise.cpp + internal/bitmap/blur.cpp + internal/bitmap/channel.cpp + internal/bitmap/charcoal.cpp + internal/bitmap/colorize.cpp + internal/bitmap/contrast.cpp + internal/bitmap/cycleColormap.cpp + internal/bitmap/despeckle.cpp + internal/bitmap/edge.cpp + internal/bitmap/emboss.cpp + internal/bitmap/enhance.cpp + internal/bitmap/equalize.cpp + internal/bitmap/gaussianBlur.cpp + internal/bitmap/imagemagick.cpp + internal/bitmap/implode.cpp + internal/bitmap/level.cpp + internal/bitmap/levelChannel.cpp + internal/bitmap/medianFilter.cpp + internal/bitmap/modulate.cpp + internal/bitmap/negate.cpp + internal/bitmap/normalize.cpp + internal/bitmap/oilPaint.cpp + internal/bitmap/opacity.cpp + internal/bitmap/raise.cpp + internal/bitmap/reduceNoise.cpp + internal/bitmap/sample.cpp + internal/bitmap/shade.cpp + internal/bitmap/sharpen.cpp + internal/bitmap/solarize.cpp + internal/bitmap/spread.cpp + internal/bitmap/swirl.cpp + internal/bitmap/threshold.cpp + internal/bitmap/unsharpmask.cpp + internal/bitmap/wave.cpp + + internal/filter/filter-all.cpp + internal/filter/filter-file.cpp + internal/filter/filter.cpp + + internal/pdfinput/pdf-input.cpp + internal/pdfinput/pdf-parser.cpp + internal/pdfinput/svg-builder.cpp + + script/InkscapeScript.cpp + + # dxf2svg/aci2rgb.cpp + # dxf2svg/entities2elements.cpp + # dxf2svg/tables2svg_info.cpp + # dxf2svg/blocks.cpp + # dxf2svg/entities.cpp + # dxf2svg/tables.cpp + # dxf2svg/dxf2svg.cpp + # dxf2svg/read_dxf.cpp + # dxf2svg/test_dxf.cpp ) -add_library(extension_LIB STATIC ${extension_SRC}) -target_link_libraries(extension_LIB 2geom_LIB ${INKSCAPE_LIBS}) +if(WIN32) + list(APPEND extension_SRC + win32.cpp + ) +endif() + +add_library(extension_LIB ${extension_SRC}) diff --git a/src/extension/dxf2svg/CMakeLists.txt b/src/extension/dxf2svg/CMakeLists.txt deleted file mode 100644 index 0ff0eaec0..000000000 --- a/src/extension/dxf2svg/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(extension_dxf2svg_SRC - #aci2rgb.cpp - #entities2elements.cpp - #tables2svg_info.cpp - #blocks.cpp - #entities.cpp - #tables.cpp - #dxf2svg.cpp - #read_dxf.cpp - #test_dxf.cpp -) diff --git a/src/extension/implementation/CMakeLists.txt b/src/extension/implementation/CMakeLists.txt deleted file mode 100644 index dcdf092c2..000000000 --- a/src/extension/implementation/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(extension_implementation_SRC - implementation.cpp - xslt.cpp - script.cpp -) diff --git a/src/extension/internal/CMakeLists.txt b/src/extension/internal/CMakeLists.txt deleted file mode 100644 index d13ec9f74..000000000 --- a/src/extension/internal/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -set(extension_internal_SRC - bluredge.cpp - cairo-png-out.cpp - cairo-ps-out.cpp - cairo-render-context.cpp - cairo-renderer.cpp - cairo-renderer-pdf-out.cpp - emf-win32-inout.cpp - emf-win32-print.cpp - gdkpixbuf-input.cpp - gimpgrad.cpp - grid.cpp - latex-pstricks.cpp - latex-pstricks-out.cpp - odf.cpp - latex-text-renderer.cpp - pdf-input-cairo.cpp - pov-out.cpp - javafx-out.cpp - svg.cpp - svgz.cpp - wpg-input.cpp -) - -if(WIN32) - list(APPEND extension_internal_SRC - win32.cpp - ) -endif() diff --git a/src/extension/internal/bitmap/CMakeLists.txt b/src/extension/internal/bitmap/CMakeLists.txt deleted file mode 100644 index a273804ba..000000000 --- a/src/extension/internal/bitmap/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -set(extension_internal_bitmap_SRC - adaptiveThreshold.cpp - addNoise.cpp - blur.cpp - channel.cpp - charcoal.cpp - colorize.cpp - contrast.cpp - cycleColormap.cpp - despeckle.cpp - edge.cpp - emboss.cpp - enhance.cpp - equalize.cpp - gaussianBlur.cpp - imagemagick.cpp - implode.cpp - levelChannel.cpp - level.cpp - medianFilter.cpp - modulate.cpp - negate.cpp - normalize.cpp - oilPaint.cpp - opacity.cpp - raise.cpp - reduceNoise.cpp - sample.cpp - shade.cpp - sharpen.cpp - solarize.cpp - spread.cpp - swirl.cpp - threshold.cpp - unsharpmask.cpp - wave.cpp -) diff --git a/src/extension/internal/filter/CMakeLists.txt b/src/extension/internal/filter/CMakeLists.txt deleted file mode 100644 index 349504f94..000000000 --- a/src/extension/internal/filter/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(extension_internal_filter_SRC - drop-shadow.h - filter-all.cpp - filter.cpp - filter-file.cpp - filter.h - snow.h -) diff --git a/src/extension/internal/pdfinput/CMakeLists.txt b/src/extension/internal/pdfinput/CMakeLists.txt deleted file mode 100644 index fe31c2a7f..000000000 --- a/src/extension/internal/pdfinput/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(extension_internal_pdfinput_SRC - pdf-input.cpp - pdf-parser.cpp - svg-builder.cpp -) diff --git a/src/extension/param/CMakeLists.txt b/src/extension/param/CMakeLists.txt deleted file mode 100644 index b2981308e..000000000 --- a/src/extension/param/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -set(extension_param_SRC - bool.cpp - color.cpp - description.cpp - enum.cpp - float.cpp - int.cpp - notebook.cpp - parameter.cpp - radiobutton.cpp - string.cpp -) - diff --git a/src/extension/script/CMakeLists.txt b/src/extension/script/CMakeLists.txt deleted file mode 100644 index 88977164e..000000000 --- a/src/extension/script/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -set(extension_script_SRC - InkscapeScript.cpp -) diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index a1bec4642..ed64fe764 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -1,3 +1,4 @@ + set(filters_SRC blend.cpp colormatrix.cpp @@ -20,5 +21,5 @@ set(filters_SRC tile.cpp turbulence.cpp ) -add_library(filters_LIB STATIC ${filters_SRC}) -target_link_libraries(filters_LIB 2geom_LIB ${INKSCAPE_LIBS}) + +add_library(filters_LIB ${filters_SRC}) diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index 86c5eea10..3f1567cce 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -1,3 +1,4 @@ + include(UseGlibMarshal) GLIB_MARSHAL(sp_marshal sp-marshal "${CMAKE_CURRENT_BINARY_DIR}/helper") @@ -26,5 +27,4 @@ set(helper_SRC ${sp_marshal_SRC} ) -add_library(helper_LIB STATIC ${helper_SRC}) -target_link_libraries(helper_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(helper_LIB ${helper_SRC}) diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index 88040744b..06a5f869a 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -1,3 +1,4 @@ + set(io_SRC base64stream.cpp ftos.cpp @@ -12,5 +13,4 @@ set(io_SRC xsltstream.cpp ) -add_library(io_LIB STATIC ${io_SRC}) -target_link_libraries(io_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(io_LIB ${io_SRC}) diff --git a/src/jabber_whiteboard/CMakeLists.txt b/src/jabber_whiteboard/CMakeLists.txt index dbe9f1e1e..2e1ef311b 100644 --- a/src/jabber_whiteboard/CMakeLists.txt +++ b/src/jabber_whiteboard/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(dialog) set(jabber_whiteboard_SRC defines.cpp @@ -16,8 +15,8 @@ set(jabber_whiteboard_SRC pedrogui.cpp session-file-selector.cpp session-manager.cpp - ${jabber_whiteboard_dialog_SRC} + + dialog/choose-desktop.cpp ) -add_library(jabber_whiteboard_LIB STATIC ${jabber_whiteboard_SRC}) -target_link_libraries(jabber_whiteboard_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(jabber_whiteboard_LIB ${jabber_whiteboard_SRC}) diff --git a/src/jabber_whiteboard/dialog/CMakeLists.txt b/src/jabber_whiteboard/dialog/CMakeLists.txt deleted file mode 100644 index 8272a61e2..000000000 --- a/src/jabber_whiteboard/dialog/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ - -set(jabber_whiteboard_dialog_SRC - choose-desktop.cpp -) diff --git a/src/libavoid/CMakeLists.txt b/src/libavoid/CMakeLists.txt index 6eb6bdd1d..04b7375b1 100644 --- a/src/libavoid/CMakeLists.txt +++ b/src/libavoid/CMakeLists.txt @@ -1,3 +1,4 @@ + set(libavoid_SRC connector.cpp geometry.cpp @@ -14,5 +15,4 @@ set(libavoid_SRC vpsc.cpp ) -add_library(avoid_LIB STATIC ${libavoid_SRC}) -target_link_libraries(avoid_LIB ${INKSCAPE_LIBS}) +add_library(avoid_LIB ${libavoid_SRC}) diff --git a/src/libcola/CMakeLists.txt b/src/libcola/CMakeLists.txt index 40c92d578..032bffb54 100644 --- a/src/libcola/CMakeLists.txt +++ b/src/libcola/CMakeLists.txt @@ -1,3 +1,4 @@ + set(libcola_SRC cola.cpp conjugate_gradient.cpp @@ -7,5 +8,5 @@ set(libcola_SRC shortest_paths.cpp straightener.cpp ) -add_library(cola_LIB STATIC ${libcola_SRC}) -target_link_libraries(cola_LIB ${INKSCAPE_LIBS}) + +add_library(cola_LIB ${libcola_SRC}) diff --git a/src/libcroco/CMakeLists.txt b/src/libcroco/CMakeLists.txt index 3aae8eac4..c4676c504 100644 --- a/src/libcroco/CMakeLists.txt +++ b/src/libcroco/CMakeLists.txt @@ -29,5 +29,4 @@ set(libcroco_SRC cr-utils.c ) -add_library(croco_LIB STATIC ${libcroco_SRC}) -target_link_libraries(croco_LIB ${INKSCAPE_LIBS}) +add_library(croco_LIB ${libcroco_SRC}) diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt index 6411579b3..cf550107a 100644 --- a/src/libgdl/CMakeLists.txt +++ b/src/libgdl/CMakeLists.txt @@ -16,7 +16,6 @@ set(libgdl_SRC gdl-tools.h libgdlmarshal.c libgdltypebuiltins.c - ${GDL_WIN} ) if(WIN32) @@ -25,5 +24,4 @@ if(WIN32) ) endif() -ADD_LIBRARY(gdl_LIB STATIC ${libgdl_SRC}) -TARGET_LINK_LIBRARIES(gdl_LIB ${INKSCAPE_LIBS}) +add_library(gdl_LIB ${libgdl_SRC}) diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 28fee7b77..6895e4dbd 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -33,5 +33,4 @@ set(libnr_SRC #testnr.cpp ) -add_library(nr_LIB STATIC ${libnr_SRC}) -target_link_libraries(nr_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(nr_LIB ${libnr_SRC}) diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 75bb5f57b..069b68bd3 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -1,3 +1,4 @@ + set(libnrtype_SRC FontFactory.cpp FontInstance.cpp @@ -14,5 +15,5 @@ set(libnrtype_SRC RasterFont.cpp TextWrapper.cpp ) -add_library(nrtype_LIB STATIC ${libnrtype_SRC}) -target_link_libraries(nrtype_LIB nr_LIB ${INKSCAPE_LIBS}) + +add_library(nrtype_LIB ${libnrtype_SRC}) diff --git a/src/libvpsc/CMakeLists.txt b/src/libvpsc/CMakeLists.txt index 0a91c3516..ebc1e79d6 100644 --- a/src/libvpsc/CMakeLists.txt +++ b/src/libvpsc/CMakeLists.txt @@ -1,3 +1,4 @@ + set(libvpsc_SRC block.cpp blocks.cpp @@ -10,5 +11,4 @@ set(libvpsc_SRC pairingheap/PairingHeap.cpp ) -add_library(vpsc_LIB STATIC ${libvpsc_SRC}) -target_link_libraries(vpsc_LIB ${INKSCAPE_LIBS}) +add_library(vpsc_LIB ${libvpsc_SRC}) diff --git a/src/livarot/CMakeLists.txt b/src/livarot/CMakeLists.txt index d8f4ba05d..51bb9530e 100644 --- a/src/livarot/CMakeLists.txt +++ b/src/livarot/CMakeLists.txt @@ -1,3 +1,4 @@ + set(livarot_SRC AlphaLigne.cpp AVL.cpp @@ -21,5 +22,4 @@ set(livarot_SRC sweep-tree-list.cpp ) -add_library(livarot_LIB STATIC ${livarot_SRC}) -target_link_libraries(nrtype_LIB ${INKSCAPE_LIBS}) +add_library(livarot_LIB ${livarot_SRC}) diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 61fedbe66..51f8d957c 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(parameter) set(live_effects_SRC bezctx.cpp @@ -41,8 +40,18 @@ set(live_effects_SRC lpeobject-reference.cpp lpeobject.cpp spiro.cpp - ${live_effects_parameter_SRC} + + parameter/array.cpp + parameter/bool.cpp + parameter/parameter.cpp + parameter/path.cpp + parameter/path-reference.cpp + parameter/point.cpp + parameter/powerstrokepointarray.cpp + parameter/random.cpp + parameter/text.cpp + parameter/unit.cpp + parameter/vector.cpp ) -add_library(live_effects_LIB STATIC ${live_effects_SRC}) -target_link_libraries(live_effects_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(live_effects_LIB ${live_effects_SRC}) diff --git a/src/live_effects/parameter/CMakeLists.txt b/src/live_effects/parameter/CMakeLists.txt deleted file mode 100644 index 04a1080f4..000000000 --- a/src/live_effects/parameter/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -set(live_effects_parameter_SRC - array.cpp - bool.cpp - parameter.cpp - path.cpp - path-reference.cpp - point.cpp - powerstrokepointarray.cpp - random.cpp - text.cpp - unit.cpp - vector.cpp -) diff --git a/src/pedro/CMakeLists.txt b/src/pedro/CMakeLists.txt index 4de3592db..8a952f950 100644 --- a/src/pedro/CMakeLists.txt +++ b/src/pedro/CMakeLists.txt @@ -1,3 +1,4 @@ + set(pedro_SRC #empty.cpp #geckoembed.cpp @@ -8,5 +9,5 @@ set(pedro_SRC pedroutil.cpp pedroxmpp.cpp ) -add_library(pedro_LIB STATIC ${pedro_SRC}) -target_link_libraries(pedro_LIB ${INKSCAPE_LIBS}) + +add_library(pedro_LIB ${pedro_SRC}) diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index 4501983bb..1d96f5ac7 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -1,3 +1,4 @@ + set(svg_SRC css-ostringstream.cpp #ftos.cpp @@ -14,5 +15,4 @@ set(svg_SRC #test-stubs.cpp ) -add_library(svg_LIB STATIC ${svg_SRC}) -target_link_libraries(svg_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(svg_LIB ${svg_SRC}) diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index d3bdcb6b1..84aab77e2 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(potrace) set(trace_SRC filterset.cpp @@ -7,8 +6,14 @@ set(trace_SRC quantize.cpp siox.cpp trace.cpp - ${trace_potrace_SRC} + + potrace/curve.cpp + potrace/decompose.cpp + potrace/greymap.cpp + potrace/inkscape-potrace.cpp + potrace/potracelib.cpp + potrace/render.cpp + potrace/trace.cpp ) -ADD_LIBRARY(trace_LIB STATIC ${trace_SRC}) -TARGET_LINK_LIBRARIES(trace_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(trace_LIB ${trace_SRC}) diff --git a/src/trace/potrace/CMakeLists.txt b/src/trace/potrace/CMakeLists.txt deleted file mode 100644 index e48d7689f..000000000 --- a/src/trace/potrace/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(trace_potrace_SRC - curve.cpp - decompose.cpp - greymap.cpp - inkscape-potrace.cpp - potracelib.cpp - render.cpp - trace.cpp -) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 5fa882f1a..7c0f18a65 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,12 +1,3 @@ -set(uifolders - cache - dialog - view - widget -) -foreach(uilistsrc ${uifolders}) - add_subdirectory(${uilistsrc}) -endforeach() set(ui_SRC clipboard.cpp @@ -14,6 +5,8 @@ set(ui_SRC previewholder.cpp uxmanager.cpp + cache/svg_preview_cache.cpp + tool/control-point-selection.cpp tool/control-point.cpp tool/curve-drag-point.cpp @@ -27,13 +20,103 @@ set(ui_SRC tool/selectable-control-point.cpp tool/selector.cpp tool/transform-handle-set.cpp - - ${ui_cache_SRC} - ${ui_dialog_SRC} - ${ui_view_SRC} - ${ui_widget_SRC} + + dialog/aboutbox.cpp + dialog/align-and-distribute.cpp + dialog/calligraphic-profile-rename.cpp + dialog/color-item.cpp + dialog/debug.cpp + dialog/desktop-tracker.cpp + dialog/dialog-manager.cpp + dialog/dialog.cpp + dialog/dock-behavior.cpp + dialog/document-metadata.cpp + dialog/document-properties.cpp + dialog/extension-editor.cpp + dialog/extensions.cpp + dialog/filedialog.cpp + dialog/filedialogimpl-gtkmm.cpp + dialog/fill-and-stroke.cpp + dialog/filter-effects-dialog.cpp + dialog/find.cpp + dialog/floating-behavior.cpp + dialog/glyphs.cpp + dialog/guides.cpp + dialog/icon-preview.cpp + dialog/inkscape-preferences.cpp + dialog/input.cpp + dialog/layer-properties.cpp + dialog/layers.cpp + dialog/livepatheffect-editor.cpp + dialog/memory.cpp + dialog/messages.cpp + dialog/ocaldialogs.cpp + dialog/print-colors-preview-dialog.cpp + dialog/print.cpp + dialog/scriptdialog.cpp + # dialog/session-player.cpp + dialog/svg-fonts-dialog.cpp + dialog/swatches.cpp + dialog/tile.cpp + dialog/tracedialog.cpp + dialog/transformation.cpp + dialog/undo-history.cpp + # dialog/whiteboard-connect.cpp + # dialog/whiteboard-sharewithchat.cpp + # dialog/whiteboard-sharewithuser.cpp + + widget/button.cpp + widget/color-picker.cpp + widget/color-preview.cpp + widget/combo-text.cpp + widget/dock-item.cpp + widget/dock.cpp + widget/entity-entry.cpp + widget/entry.cpp + widget/filter-effect-chooser.cpp + widget/handlebox.cpp + widget/icon-widget.cpp + widget/imageicon.cpp + widget/imagetoggler.cpp + widget/labelled.cpp + widget/layer-selector.cpp + widget/licensor.cpp + widget/notebook-page.cpp + widget/object-composite-settings.cpp + widget/page-sizer.cpp + widget/panel.cpp + widget/point.cpp + widget/preferences-widget.cpp + widget/random.cpp + widget/registered-widget.cpp + widget/registry.cpp + widget/rendering-options.cpp + widget/rotateable.cpp + widget/ruler.cpp + widget/scalar-unit.cpp + widget/scalar.cpp + widget/selected-style.cpp + widget/spin-slider.cpp + widget/spinbutton.cpp + widget/style-subject.cpp + widget/style-swatch.cpp + widget/svg-canvas.cpp + widget/text.cpp + widget/tolerance-slider.cpp + widget/toolbox.cpp + widget/unit-menu.cpp + widget/zoom-status.cpp + + view/view.cpp + view/view-widget.cpp ) +if(WIN32) + list(APPEND ui_SRC + dialog/filedialogimpl-win32.cpp + ) +endif() + include_directories( "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}" @@ -42,5 +125,4 @@ include_directories( "${CMAKE_SOURCE_DIR}/extension/dbus" ) -add_library(ui_LIB STATIC ${ui_SRC}) -target_link_libraries(ui_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(ui_LIB ${ui_SRC}) diff --git a/src/ui/cache/CMakeLists.txt b/src/ui/cache/CMakeLists.txt deleted file mode 100644 index c00410de5..000000000 --- a/src/ui/cache/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -set(ui_cache_SRC - svg_preview_cache.cpp -) diff --git a/src/ui/dialog/CMakeLists.txt b/src/ui/dialog/CMakeLists.txt deleted file mode 100644 index 5f2b31989..000000000 --- a/src/ui/dialog/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ - -set(ui_dialog_SRC - aboutbox.cpp - align-and-distribute.cpp - calligraphic-profile-rename.cpp - color-item.cpp - debug.cpp - desktop-tracker.cpp - dialog-manager.cpp - dialog.cpp - dock-behavior.cpp - document-metadata.cpp - document-properties.cpp - extension-editor.cpp - extensions.cpp - filedialog.cpp - filedialogimpl-gtkmm.cpp - fill-and-stroke.cpp - filter-effects-dialog.cpp - find.cpp - floating-behavior.cpp - glyphs.cpp - guides.cpp - icon-preview.cpp - inkscape-preferences.cpp - input.cpp - layer-properties.cpp - layers.cpp - livepatheffect-editor.cpp - memory.cpp - messages.cpp - ocaldialogs.cpp - print-colors-preview-dialog.cpp - print.cpp - scriptdialog.cpp - # session-player.cpp - svg-fonts-dialog.cpp - swatches.cpp - tile.cpp - tracedialog.cpp - transformation.cpp - undo-history.cpp - # whiteboard-connect.cpp - # whiteboard-sharewithchat.cpp - # whiteboard-sharewithuser.cpp -) - -if(WIN32) - list(APPEND ui_dialog_SRC - filedialogimpl-win32.cpp - ) -endif() diff --git a/src/ui/view/CMakeLists.txt b/src/ui/view/CMakeLists.txt deleted file mode 100644 index c0914d887..000000000 --- a/src/ui/view/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -set(ui_view_SRC - view.cpp - view-widget.cpp -) diff --git a/src/ui/widget/CMakeLists.txt b/src/ui/widget/CMakeLists.txt deleted file mode 100644 index c81ea5e24..000000000 --- a/src/ui/widget/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -set(ui_widget_SRC - button.cpp - color-picker.cpp - color-preview.cpp - combo-text.cpp - dock-item.cpp - dock.cpp - entity-entry.cpp - entry.cpp - filter-effect-chooser.cpp - handlebox.cpp - icon-widget.cpp - imageicon.cpp - imagetoggler.cpp - labelled.cpp - layer-selector.cpp - licensor.cpp - notebook-page.cpp - object-composite-settings.cpp - page-sizer.cpp - panel.cpp - point.cpp - preferences-widget.cpp - random.cpp - registered-widget.cpp - registry.cpp - rendering-options.cpp - rotateable.cpp - ruler.cpp - scalar-unit.cpp - scalar.cpp - selected-style.cpp - spin-slider.cpp - spinbutton.cpp - style-subject.cpp - style-swatch.cpp - svg-canvas.cpp - text.cpp - tolerance-slider.cpp - toolbox.cpp - unit-menu.cpp - zoom-status.cpp -) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 330d49662..a5aed5be2 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -7,5 +7,4 @@ set(util_SRC units.cpp ) -add_library(util_LIB STATIC ${util_SRC}) -target_link_libraries(util_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(util_LIB ${util_SRC}) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 4c622fbec..c4f820e52 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -36,5 +36,4 @@ set(widgets_SRC toolbox.cpp ) -add_library(widgets_LIB STATIC ${widgets_SRC}) -target_link_libraries(widgets_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(widgets_LIB ${widgets_SRC}) diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index 1aafe2d21..353c96998 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -1,3 +1,4 @@ + set(xml_SRC composite-node-observer.cpp croco-node-iface.cpp @@ -17,5 +18,4 @@ set(xml_SRC rebase-hrefs.cpp ) -add_library(xml_LIB STATIC ${xml_SRC}) -target_link_libraries(xml_LIB 2geom_LIB ${INKSCAPE_LIBS}) +add_library(xml_LIB ${xml_SRC}) -- cgit v1.2.3 From 9a8e6cfdc2f8052638e6816e0ffdd36e1b253a6c Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Sun, 12 Jun 2011 18:23:46 +0100 Subject: Replace deprecated GTK_WIDGET_(UN)SET_FLAGS macros (bzr r10277.1.1) --- src/dialogs/text-edit.cpp | 3 ++- src/dialogs/xml-tree.cpp | 7 +++---- src/display/sp-canvas.cpp | 12 +++++------- src/libgdl/gdl-dock-item-grip.c | 6 +++--- src/libgdl/gdl-dock-item.c | 10 +++++----- src/libgdl/gdl-dock-placeholder.c | 5 +++-- src/libgdl/gdl-dock-tablabel.c | 2 +- src/libgdl/gdl-dock.c | 2 +- src/libgdl/gdl-switcher.c | 2 +- src/widgets/button.cpp | 4 ++-- src/widgets/desktop-widget.cpp | 6 +++--- src/widgets/eek-preview.cpp | 4 ++-- src/widgets/gradient-image.cpp | 2 +- src/widgets/sp-color-preview.cpp | 2 +- src/widgets/sp-color-slider.cpp | 4 ++-- 15 files changed, 35 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 46d5637c3..0533a2a35 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -441,7 +441,8 @@ sp_text_edit_dialog (void) { GtkWidget *b = gtk_button_new_from_stock (GTK_STOCK_APPLY); - GTK_WIDGET_SET_FLAGS (b, GTK_CAN_DEFAULT | GTK_HAS_DEFAULT); + gtk_widget_set_can_default (b, TRUE); + gtk_widget_grab_default (b); g_signal_connect ( G_OBJECT (b), "clicked", G_CALLBACK (sp_text_edit_dialog_apply), dlg ); gtk_box_pack_end ( GTK_BOX (hb), b, FALSE, FALSE, 0 ); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 5fd306149..78e7d3dcf 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -1339,8 +1339,7 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/) gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); cancel = gtk_button_new_with_label(_("Cancel")); - GTK_WIDGET_SET_FLAGS( GTK_WIDGET(cancel), - GTK_CAN_DEFAULT ); + gtk_widget_set_can_default( GTK_WIDGET(cancel), TRUE ); gtk_signal_connect_object( GTK_OBJECT(cancel), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(window) ); @@ -1356,8 +1355,8 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/) gtk_signal_connect_object( GTK_OBJECT(create), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(window) ); - GTK_WIDGET_SET_FLAGS( GTK_WIDGET(create), - GTK_CAN_DEFAULT | GTK_RECEIVES_DEFAULT ); + gtk_widget_set_can_default( GTK_WIDGET(create), TRUE ); + gtk_widget_set_receives_default( GTK_WIDGET(create), TRUE ); gtk_container_add(GTK_CONTAINER(bbox), create); gtk_widget_show_all(GTK_WIDGET(window)); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ff1bf32c6..ad2a45eea 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1020,9 +1020,9 @@ sp_canvas_class_init (SPCanvasClass *klass) static void sp_canvas_init (SPCanvas *canvas) { - GTK_WIDGET_UNSET_FLAGS (canvas, GTK_NO_WINDOW); - GTK_WIDGET_UNSET_FLAGS (canvas, GTK_DOUBLE_BUFFERED); - GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS); + gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); + gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); + gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE); canvas->pick_event.type = GDK_LEAVE_NOTIFY; canvas->pick_event.crossing.x = 0; @@ -1176,7 +1176,7 @@ sp_canvas_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_set_realized (widget, TRUE); canvas->pixmap_gc = gdk_gc_new (SP_CANVAS_WINDOW (canvas)); } @@ -2022,7 +2022,7 @@ sp_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event) static gint sp_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) { - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); + gtk_widget_grab_focus (widget); SPCanvas *canvas = SP_CANVAS (widget); @@ -2039,8 +2039,6 @@ sp_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) static gint sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) { - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - SPCanvas *canvas = SP_CANVAS (widget); if (canvas->focused_item) diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index de09fc150..3c6b4ac17 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -341,7 +341,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) { GtkWidget *image; - GTK_WIDGET_SET_FLAGS (grip, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE); grip->_priv = g_new0 (GdlDockItemGripPrivate, 1); grip->_priv->icon_pixbuf_valid = FALSE; @@ -352,7 +352,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) grip->_priv->close_button = gtk_button_new (); gtk_widget_pop_composite_child (); - GTK_WIDGET_UNSET_FLAGS (grip->_priv->close_button, GTK_CAN_FOCUS); + gtk_widget_set_can_focus (grip->_priv->close_button, FALSE); gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip)); gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE); gtk_widget_show (grip->_priv->close_button); @@ -368,7 +368,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) grip->_priv->iconify_button = gtk_button_new (); gtk_widget_pop_composite_child (); - GTK_WIDGET_UNSET_FLAGS (grip->_priv->iconify_button, GTK_CAN_FOCUS); + gtk_widget_set_can_focus (grip->_priv->iconify_button, FALSE); gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip)); gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE); gtk_widget_show (grip->_priv->iconify_button); diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 01a777bad..862b90c0c 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -426,8 +426,8 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) static void gdl_dock_item_instance_init (GdlDockItem *item) { - GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (item), GTK_NO_WINDOW); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (item), GTK_CAN_FOCUS); + gtk_widget_set_has_window (GTK_WIDGET (item), TRUE); + gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE); item->child = NULL; @@ -836,7 +836,7 @@ gdl_dock_item_map (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); + gtk_widget_set_mapped (widget, TRUE); item = GDL_DOCK_ITEM (widget); @@ -861,7 +861,7 @@ gdl_dock_item_unmap (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED); + gtk_widget_set_mapped (widget, FALSE); item = GDL_DOCK_ITEM (widget); @@ -883,7 +883,7 @@ gdl_dock_item_realize (GtkWidget *widget) item = GDL_DOCK_ITEM (widget); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_set_realized (widget, TRUE); /* widget window */ attributes.x = widget->allocation.x; diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index cd900a21d..e1785ae83 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -215,8 +215,9 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) static void gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph) { - GTK_WIDGET_SET_FLAGS (ph, GTK_NO_WINDOW); - GTK_WIDGET_UNSET_FLAGS (ph, GTK_CAN_FOCUS); + gtk_widget_set_has_window (GTK_WIDGET (ph), FALSE); + + gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE); ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1); } diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c index bd755893b..adba98b0d 100644 --- a/src/libgdl/gdl-dock-tablabel.c +++ b/src/libgdl/gdl-dock-tablabel.c @@ -550,7 +550,7 @@ gdl_dock_tablabel_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_set_realized (widget, TRUE); } static void diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index 7c74791db..da0f8c5e3 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -260,7 +260,7 @@ gdl_dock_class_init (GdlDockClass *klass) static void gdl_dock_instance_init (GdlDock *dock) { - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dock), GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE); dock->root = NULL; dock->_priv = g_new0 (GdlDockPrivate, 1); diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index aaddc6d80..65e8b98fe 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -707,7 +707,7 @@ gdl_switcher_instance_init (GdlSwitcher *switcher) { GdlSwitcherPrivate *priv; - GTK_WIDGET_SET_FLAGS (switcher, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (switcher), FALSE); priv = g_new0 (GdlSwitcherPrivate, 1); switcher->priv = priv; diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 9676651d3..e0b3a0fb9 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -101,8 +101,8 @@ sp_button_init (SPButton *button) gtk_container_set_border_width (GTK_CONTAINER (button), 0); - GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (button), GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); + gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE); + gtk_widget_set_can_default (GTK_WIDGET (button), FALSE); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (sp_button_perform_action), NULL); g_signal_connect_after (G_OBJECT (button), "event", G_CALLBACK (sp_button_process_event), NULL); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 1de82a315..d5ec5deff 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -440,7 +440,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if ENABLE_LCMS dtw->canvas->enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable"); #endif // ENABLE_LCMS - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dtw->canvas), GTK_CAN_FOCUS); + gtk_widget_set_can_focus (GTK_WIDGET (dtw->canvas), TRUE); style = gtk_style_copy (GTK_WIDGET (dtw->canvas)->style); style->bg[GTK_STATE_NORMAL] = style->white; gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style); @@ -889,7 +889,7 @@ SPDesktopWidget::shutdown() "If you close without saving, your changes will be discarded."), doc->getName()); // fix for bug 1767940: - GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS); + gtk_widget_set_can_focus(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), FALSE); GtkWidget *close_button; close_button = gtk_button_new_with_mnemonic(_("Close _without saving")); @@ -945,7 +945,7 @@ SPDesktopWidget::shutdown() "Do you want to save this file as Inkscape SVG?"), doc->getName() ? doc->getName() : "Unnamed"); // fix for bug 1767940: - GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS); + gtk_widget_set_can_focus(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), FALSE); GtkWidget *close_button; close_button = gtk_button_new_with_mnemonic(_("Close _without saving")); diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 8fefbe75c..816c4bf50 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -684,8 +684,8 @@ void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewT static void eek_preview_init( EekPreview *preview ) { GtkWidget* widg = GTK_WIDGET(preview); - GTK_WIDGET_SET_FLAGS( widg, GTK_CAN_FOCUS ); - GTK_WIDGET_SET_FLAGS( widg, GTK_RECEIVES_DEFAULT ); + gtk_widget_set_can_focus( widg, TRUE ); + gtk_widget_set_receives_default( widg, TRUE ); gtk_widget_set_sensitive( widg, TRUE ); diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 11d2d528a..62a063755 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -86,7 +86,7 @@ sp_gradient_image_class_init (SPGradientImageClass *klass) static void sp_gradient_image_init (SPGradientImage *image) { - GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (image), FALSE); image->gradient = NULL; image->px = NULL; diff --git a/src/widgets/sp-color-preview.cpp b/src/widgets/sp-color-preview.cpp index 5c8154709..aad850b7c 100644 --- a/src/widgets/sp-color-preview.cpp +++ b/src/widgets/sp-color-preview.cpp @@ -74,7 +74,7 @@ sp_color_preview_class_init (SPColorPreviewClass *klass) static void sp_color_preview_init (SPColorPreview *image) { - GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (image), FALSE); image->rgba = 0xffffffff; } diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 09d2a87ab..2d0789ec4 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -131,7 +131,7 @@ static void sp_color_slider_init (SPColorSlider *slider) { /* We are widget with window */ - GTK_WIDGET_UNSET_FLAGS (slider, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET(slider), TRUE); slider->dragging = FALSE; @@ -186,7 +186,7 @@ sp_color_slider_realize (GtkWidget *widget) slider = SP_COLOR_SLIDER (widget); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_set_realized (widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; -- cgit v1.2.3 From 2c5f1ac093f8d674dae8fc1cae88862d02468356 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 02:33:03 +0000 Subject: cmake: now builds without having most of the source listed in 1 file. (bzr r10278) --- src/CMakeLists.txt | 60 ++++++++++-------------------------- src/bind/CMakeLists.txt | 3 +- src/debug/CMakeLists.txt | 3 +- src/dialogs/CMakeLists.txt | 3 +- src/display/CMakeLists.txt | 7 ++--- src/extension/CMakeLists.txt | 11 ++++--- src/filters/CMakeLists.txt | 3 +- src/helper/CMakeLists.txt | 3 +- src/io/CMakeLists.txt | 3 +- src/jabber_whiteboard/CMakeLists.txt | 3 +- src/libnr/CMakeLists.txt | 4 +-- src/libnrtype/CMakeLists.txt | 4 +-- src/live_effects/CMakeLists.txt | 3 +- src/pedro/CMakeLists.txt | 3 +- src/svg/CMakeLists.txt | 3 +- src/trace/CMakeLists.txt | 3 +- src/ui/CMakeLists.txt | 11 ++----- src/util/CMakeLists.txt | 3 +- src/widgets/CMakeLists.txt | 3 +- src/xml/CMakeLists.txt | 3 +- 20 files changed, 59 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de6175134..72644b416 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,8 +129,6 @@ set(inkscape_SRC inkscape-version.cpp inkscape.cpp inkscape.rc - # inkview.cpp - # inkview.rc interface.cpp knot-holder-entity.cpp knot.cpp @@ -141,7 +139,6 @@ set(inkscape_SRC line-snapper.cpp lpe-tool-context.cpp main-cmdlineact.cpp - main.cpp marker.cpp measure-context.cpp media.cpp @@ -214,8 +211,6 @@ endif() # All folders for internal inkscape set(internalfolders - #algorithms - #api bind debug dialogs @@ -230,7 +225,6 @@ set(internalfolders # pedro svg trace - #traits ui util widgets @@ -244,10 +238,10 @@ set(libfolders libcola libcroco libgdl - libnr - libnrtype libvpsc livarot + libnr + libnrtype ) set(dirs @@ -259,18 +253,28 @@ foreach(srclistsrc ${dirs}) add_subdirectory(${srclistsrc}) endforeach() +get_property(inkscape_global_SRC GLOBAL PROPERTY inkscape_global_SRC) + set(inkscape_SRC + ${inkscape_global_SRC} ${inkscape_SRC} - ${GlibOutput} ) add_library(sp_LIB ${sp_SRC}) +add_library(inkscape_LIB ${inkscape_SRC}) # make executable for INKSCAPE -add_executable(inkscape ${inkscape_SRC}) +add_executable(inkscape main.cpp) target_link_libraries(inkscape # order from automake + sp_LIB + inkscape_LIB + sp_LIB # annoying, we need both! + + nr_LIB + nrtype_LIB + dom_LIB croco_LIB avoid_LIB @@ -280,26 +284,6 @@ target_link_libraries(inkscape livarot_LIB 2geom_LIB - # guessing these ones - ui_LIB - bind_LIB - debug_LIB - dialogs_LIB - display_LIB - extension_LIB - filters_LIB - helper_LIB - io_LIB - nr_LIB - nrtype_LIB - sp_LIB - svg_LIB - trace_LIB - util_LIB - widgets_LIB - xml_LIB - live_effects_LIB - ${INKSCAPE_LIBS} @@ -353,18 +337,8 @@ target_link_libraries(inkscape ) +# TODO # make executable for INKVIEW -#ADD_EXECUTABLE(inkview inkview.cpp) -#TARGET_LINK_LIBRARIES(inkview -# 2geom_LIB -# avoid_LIB -# cola_LIB -# croco_LIB -# gdl_LIB -# nr_LIB -# nrtype_LIB -# vpsc_LIB -# livarot_LIB -# sp_LIB -#) +#add_executable(inkview inkview.cpp) +# ... diff --git a/src/bind/CMakeLists.txt b/src/bind/CMakeLists.txt index d0f7c7ca0..8a98e20a3 100644 --- a/src/bind/CMakeLists.txt +++ b/src/bind/CMakeLists.txt @@ -4,4 +4,5 @@ set(bind_SRC javabind.cpp ) -add_library(bind_LIB ${bind_SRC}) +# add_library(bind_LIB ${bind_SRC}) +add_inkscape_source("${bind_SRC}") diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 0c5760366..9039d52bb 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -9,4 +9,5 @@ set(debug_SRC gdk-event-latency-tracker.cpp ) -add_library(debug_LIB ${debug_SRC}) +# add_library(debug_LIB ${debug_SRC}) +add_inkscape_source("${debug_SRC}") diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index bd6942ca6..f2d05a02b 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -11,4 +11,5 @@ set(dialogs_SRC xml-tree.cpp ) -add_library(dialogs_LIB ${dialogs_SRC}) +# add_library(dialogs_LIB ${dialogs_SRC}) +add_inkscape_source("${dialogs_SRC}") diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index ff0b7eac1..056067ea4 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -59,8 +59,5 @@ set(display_SRC sp-ctrlquadr.cpp ) -include_directories( - "${CMAKE_SOURCE_DIR}/src" -) - -add_library(display_LIB ${display_SRC}) +# add_library(display_LIB ${display_SRC}) +add_inkscape_source("${display_SRC}") diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 3d8777e3a..b2550361f 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -29,12 +29,12 @@ set(extension_SRC param/parameter.cpp param/radiobutton.cpp param/string.cpp - + internal/bluredge.cpp internal/cairo-png-out.cpp internal/cairo-ps-out.cpp - # internal/cairo-render-context.cpp # XXX MUST GET THIS WORKING - # internal/cairo-renderer.cpp # XXX MUST GET THIS WORKING + internal/cairo-render-context.cpp + internal/cairo-renderer.cpp internal/cairo-renderer-pdf-out.cpp internal/emf-win32-inout.cpp internal/emf-win32-print.cpp @@ -42,7 +42,7 @@ set(extension_SRC internal/gimpgrad.cpp internal/grid.cpp internal/latex-pstricks.cpp - # internal/latex-pstricks-out.cpp # XXX MUST GET THIS WORKING + internal/latex-pstricks-out.cpp internal/odf.cpp internal/latex-text-renderer.cpp internal/pdf-input-cairo.cpp @@ -115,4 +115,5 @@ if(WIN32) ) endif() -add_library(extension_LIB ${extension_SRC}) +# add_library(extension_LIB ${extension_SRC}) +add_inkscape_source("${extension_SRC}") diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index ed64fe764..8016553c8 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -22,4 +22,5 @@ set(filters_SRC turbulence.cpp ) -add_library(filters_LIB ${filters_SRC}) +#add_library(filters_LIB ${filters_SRC}) +add_inkscape_source("${filters_SRC}") diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index 3f1567cce..b4786ff54 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -27,4 +27,5 @@ set(helper_SRC ${sp_marshal_SRC} ) -add_library(helper_LIB ${helper_SRC}) +# add_library(helper_LIB ${helper_SRC}) +add_inkscape_source("${helper_SRC}") diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index 06a5f869a..e9bff2bc2 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -13,4 +13,5 @@ set(io_SRC xsltstream.cpp ) -add_library(io_LIB ${io_SRC}) +# add_library(io_LIB ${io_SRC}) +add_inkscape_source("${io_SRC}") diff --git a/src/jabber_whiteboard/CMakeLists.txt b/src/jabber_whiteboard/CMakeLists.txt index 2e1ef311b..62de25d70 100644 --- a/src/jabber_whiteboard/CMakeLists.txt +++ b/src/jabber_whiteboard/CMakeLists.txt @@ -19,4 +19,5 @@ set(jabber_whiteboard_SRC dialog/choose-desktop.cpp ) -add_library(jabber_whiteboard_LIB ${jabber_whiteboard_SRC}) +# add_library(jabber_whiteboard_LIB ${jabber_whiteboard_SRC}) +add_inkscape_source("${jabber_whiteboard_SRC}") diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 6895e4dbd..0d3202636 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -1,5 +1,5 @@ -set(libnr_SRC +set(nr_SRC #in-svg-plane-test.cpp nr-blit.cpp nr-compose.cpp @@ -33,4 +33,4 @@ set(libnr_SRC #testnr.cpp ) -add_library(nr_LIB ${libnr_SRC}) +add_library(nr_LIB ${nr_SRC}) diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 069b68bd3..d5f9b846f 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -1,5 +1,5 @@ -set(libnrtype_SRC +set(nrtype_SRC FontFactory.cpp FontInstance.cpp font-lister.cpp @@ -16,4 +16,4 @@ set(libnrtype_SRC TextWrapper.cpp ) -add_library(nrtype_LIB ${libnrtype_SRC}) +add_library(nrtype_LIB ${nrtype_SRC}) diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 51f8d957c..148ea92f7 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -54,4 +54,5 @@ set(live_effects_SRC parameter/vector.cpp ) -add_library(live_effects_LIB ${live_effects_SRC}) +# add_library(live_effects_LIB ${live_effects_SRC}) +add_inkscape_source("${live_effects_SRC}") diff --git a/src/pedro/CMakeLists.txt b/src/pedro/CMakeLists.txt index 8a952f950..7dce5b755 100644 --- a/src/pedro/CMakeLists.txt +++ b/src/pedro/CMakeLists.txt @@ -10,4 +10,5 @@ set(pedro_SRC pedroxmpp.cpp ) -add_library(pedro_LIB ${pedro_SRC}) +# add_library(pedro_LIB ${pedro_SRC}) +add_inkscape_source("${pedro_SRC}") diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index 1d96f5ac7..8c1f0058e 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -15,4 +15,5 @@ set(svg_SRC #test-stubs.cpp ) -add_library(svg_LIB ${svg_SRC}) +# add_library(svg_LIB ${svg_SRC}) +add_inkscape_source("${svg_SRC}") diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index 84aab77e2..3f712a314 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -16,4 +16,5 @@ set(trace_SRC potrace/trace.cpp ) -add_library(trace_LIB ${trace_SRC}) +# add_library(trace_LIB ${trace_SRC}) +add_inkscape_source("${trace_SRC}") diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 7c0f18a65..bf9ddb4c8 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -117,12 +117,5 @@ if(WIN32) ) endif() -include_directories( - "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}" - "${CMAKE_SOURCE_DIR}/bind/javainc" - "${CMAKE_SOURCE_DIR}/bind/javainc/linux" - "${CMAKE_SOURCE_DIR}/extension/dbus" -) - -add_library(ui_LIB ${ui_SRC}) +# add_library(ui_LIB ${ui_SRC}) +add_inkscape_source("${ui_SRC}") diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index a5aed5be2..ca90272ae 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -7,4 +7,5 @@ set(util_SRC units.cpp ) -add_library(util_LIB ${util_SRC}) +# add_library(util_LIB ${util_SRC}) +add_inkscape_source("${util_SRC}") diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index c4f820e52..09d2d6303 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -36,4 +36,5 @@ set(widgets_SRC toolbox.cpp ) -add_library(widgets_LIB ${widgets_SRC}) +# add_library(widgets_LIB ${widgets_SRC}) +add_inkscape_source("${widgets_SRC}") diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index 353c96998..3cca53fd8 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -18,4 +18,5 @@ set(xml_SRC rebase-hrefs.cpp ) -add_library(xml_LIB ${xml_SRC}) +# add_library(xml_LIB ${xml_SRC}) +add_inkscape_source("${xml_SRC}") -- cgit v1.2.3 From b7a4f23ed217a36eaaefe8f707bcc1b968d1e562 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 05:39:42 +0000 Subject: cmake: - group source/headers per library (for some IDE's) - include headers with source listing (also for IDE's) - remove unneeded Find modules (bzr r10281) --- src/2geom/CMakeLists.txt | 2 +- src/CMakeLists.txt | 410 +++++++++++++++++++++++++++-------- src/bind/CMakeLists.txt | 12 +- src/debug/CMakeLists.txt | 17 +- src/dialogs/CMakeLists.txt | 15 +- src/display/CMakeLists.txt | 69 +++++- src/dom/CMakeLists.txt | 49 ++++- src/extension/CMakeLists.txt | 107 ++++++++- src/filters/CMakeLists.txt | 40 +++- src/helper/CMakeLists.txt | 26 ++- src/io/CMakeLists.txt | 17 +- src/jabber_whiteboard/CMakeLists.txt | 23 +- src/libavoid/CMakeLists.txt | 21 +- src/libcola/CMakeLists.txt | 13 +- src/libcroco/CMakeLists.txt | 32 ++- src/libgdl/CMakeLists.txt | 24 +- src/libnr/CMakeLists.txt | 77 ++++++- src/libnrtype/CMakeLists.txt | 23 +- src/libvpsc/CMakeLists.txt | 17 +- src/livarot/CMakeLists.txt | 18 +- src/live_effects/CMakeLists.txt | 59 ++++- src/pedro/CMakeLists.txt | 2 +- src/svg/CMakeLists.txt | 21 +- src/trace/CMakeLists.txt | 25 ++- src/ui/CMakeLists.txt | 128 ++++++++++- src/util/CMakeLists.txt | 32 ++- src/widgets/CMakeLists.txt | 39 +++- src/xml/CMakeLists.txt | 33 ++- 28 files changed, 1231 insertions(+), 120 deletions(-) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index 6c6001c4b..c04718e79 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -122,4 +122,4 @@ set(2geom_SRC ) # make lib for 2geom_LIB -add_library(2geom_LIB ${2geom_SRC}) +add_inkscape_lib(2geom_LIB "${2geom_SRC}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72644b416..718c92b4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,12 @@ +# ----------------------------------------------------------------------------- +# Define the main source +# ----------------------------------------------------------------------------- + +set(main_SRC + main.cpp +) + set(sp_SRC sp-anchor.cpp # sp-animation.cpp @@ -67,6 +75,91 @@ set(sp_SRC sp-use.cpp spiral-context.cpp splivarot.cpp + + sp-anchor.h + sp-animation.h + sp-clippath.h + sp-conn-end-pair.h + sp-conn-end.h + sp-cursor.h + sp-defs.h + sp-desc.h + sp-ellipse.h + sp-filter-fns.h + sp-filter-primitive.h + sp-filter-reference.h + sp-filter-units.h + sp-filter.h + sp-flowdiv.h + sp-flowregion.h + sp-flowtext.h + sp-font-face.h + sp-font.h + sp-gaussian-blur-fns.h + sp-gaussian-blur.h + sp-glyph-kerning.h + sp-glyph.h + sp-gradient-fns.h + sp-gradient-reference.h + sp-gradient-spread.h + sp-gradient-test.h + sp-gradient-units.h + sp-gradient-vector.h + sp-gradient.h + sp-guide-attachment.h + sp-guide-constraint.h + sp-guide.h + sp-image.h + sp-item-group.h + sp-item-notify-moveto.h + sp-item-rm-unsatisfied-cns.h + sp-item-transform.h + sp-item-update-cns.h + sp-item.h + sp-line.h + sp-linear-gradient-fns.h + sp-linear-gradient.h + sp-lpe-item.h + sp-marker-loc.h + sp-mask.h + sp-metadata.h + sp-metric.h + sp-metrics.h + sp-missing-glyph.h + sp-namedview.h + sp-object-group.h + sp-object-repr.h + sp-object.h + sp-offset.h + sp-paint-server-reference.h + sp-paint-server.h + sp-path.h + sp-pattern.h + sp-polygon.h + sp-polyline.h + sp-radial-gradient-fns.h + sp-radial-gradient.h + sp-rect.h + sp-root.h + sp-script.h + sp-shape.h + # sp-skeleton.h + sp-spiral.h + sp-star.h + sp-stop.h + sp-string.h + sp-style-elem-test.h + sp-style-elem.h + sp-switch.h + sp-symbol.h + sp-text.h + sp-textpath.h + sp-title.h + sp-tref-reference.h + sp-tref.h + sp-tspan.h + sp-use-reference.h + sp-use.h ) set(inkscape_SRC @@ -199,6 +292,194 @@ set(inkscape_SRC verbs.cpp version.cpp zoom-context.cpp + + + # ------- + # Headers + MultiPrinter.h + PylogFormatter.h + TRPIFormatter.h + approx-equal.h + arc-context.h + attributes-test.h + attributes.h + axis-manip.h + bad-uri-exception.h + box3d-context.h + box3d-side.h + box3d.h + color-profile-fns.h + color-profile-test.h + color-profile.h + color-rgba.h + color.h + common-context.h + composite-undo-stack-observer.h + conditions.h + conn-avoid-ref.h + connection-points.h + connection-pool.h + connector-context.h + console-output-undo-observer.h + context-fns.h + decimal-round.h + desktop-events.h + desktop-handles.h + desktop-style.h + desktop.h + device-manager.h + dir-util-test.h + dir-util.h + document-private.h + document-subset.h + document-undo.h + document.h + draw-anchor.h + draw-context.h + dropper-context.h + dyna-draw-context.h + ege-adjustment-action.h + ege-color-prof-tracker.h + ege-output-action.h + ege-select-one-action.h + enums.h + eraser-context.h + event-context.h + event-log.h + event.h + extract-uri-test.h + extract-uri.h + file.h + fill-or-stroke.h + filter-chemistry.h + filter-enums.h + flood-context.h + forward.h + gc-alloc.h + gc-allocator.h + gc-anchored.h + gc-core.h + gc-finalized.h + gc-managed.h + gc-soft-ptr.h + gradient-chemistry.h + gradient-context.h + gradient-drag.h + graphlayout.h + guide-snapper.h + help.h + helper-fns.h + icon-size.h + id-clash.h + ige-mac-menu.h + ink-action.h + ink-comboboxentry-action.h + inkscape-private.h + inkscape-version.h + inkscape.h + interface.h + isinf.h + isnormal.h + knot-enums.h + knot-holder-entity.h + knot.h + knotholder.h + layer-fns.h + layer-manager.h + line-geometry.h + line-snapper.h + lpe-tool-context.h + macros.h + main-cmdlineact.h + marker-test.h + marker.h + measure-context.h + media.h + memeq.h + menus-skeleton.h + message-context.h + message-stack.h + message.h + mod360-test.h + mod360.h + modifier-fns.h + number-opt-number.h + object-edit.h + object-hierarchy.h + object-snapper.h + path-chemistry.h + path-prefix.h + pen-context.h + pencil-context.h + persp3d-reference.h + persp3d.h + perspective-line.h + preferences-skeleton.h + preferences-test.h + preferences.h + prefix.h + print.h + profile-manager.h + proj_pt.h + rdf.h + rect-context.h + registrytool.h + remove-last.h + removeoverlap.h + require-config.h + resource-manager.h + round-test.h + round.h + rubberband.h + satisfied-guide-cns.h + selcue.h + select-context.h + selection-chemistry.h + selection-describer.h + selection.h + seltrans-handles.h + seltrans.h + shape-editor.h + shortcuts.h + snap-candidate.h + snap-enums.h + snap-preferences.h + snap.h + snapped-curve.h + snapped-line.h + snapped-point.h + snapper.h + spiral-context.h + splivarot.h + spray-context.h + star-context.h + streq.h + strneq.h + style-test.h + style.h + svg-profile.h + svg-view-widget.h + svg-view.h + syseq.h + test-helpers.h + text-chemistry.h + text-context.h + text-editing.h + text-tag-attributes.h + tools-switch.h + transf_mat_3x4.h + tweak-context.h + unclump.h + undo-stack-observer.h + unicoderange.h + unit-constants.h + uri-references.h + uri.h + vanishing-point.h + verbs-test.h + verbs.h + version.h + zoom-context.h ) if(WIN32) @@ -209,49 +490,44 @@ if(WIN32) ) endif() + +# ----------------------------------------------------------------------------- +# Load in subdirectories +# ----------------------------------------------------------------------------- + # All folders for internal inkscape -set(internalfolders - bind - debug - dialogs - display - dom - extension - filters - helper - io - # jabber_whiteboard - live_effects - # pedro - svg - trace - ui - util - widgets - xml - 2geom -) +# these call add_inkscape_source +add_subdirectory(bind) +add_subdirectory(debug) +add_subdirectory(dialogs) +add_subdirectory(display) +add_subdirectory(dom) +add_subdirectory(extension) +add_subdirectory(filters) +add_subdirectory(helper) +add_subdirectory(io) +# add_subdirectory(jabber_whiteboard) +add_subdirectory(live_effects) +# add_subdirectory(pedro) +add_subdirectory(svg) +add_subdirectory(trace) +add_subdirectory(ui) +add_subdirectory(util) +add_subdirectory(widgets) +add_subdirectory(xml) +add_subdirectory(2geom) -set(libfolders - # Directories containing lists files that describe building internal libraries - libavoid - libcola - libcroco - libgdl - libvpsc - livarot - libnr - libnrtype -) -set(dirs - ${internalfolders} - ${libfolders} -) +# Directories containing lists files that describe building internal libraries +add_subdirectory(libavoid) +add_subdirectory(libcola) +add_subdirectory(libcroco) +add_subdirectory(libgdl) +add_subdirectory(libvpsc) +add_subdirectory(livarot) +add_subdirectory(libnr) +add_subdirectory(libnrtype) -foreach(srclistsrc ${dirs}) - add_subdirectory(${srclistsrc}) -endforeach() get_property(inkscape_global_SRC GLOBAL PROPERTY inkscape_global_SRC) @@ -260,11 +536,15 @@ set(inkscape_SRC ${inkscape_SRC} ) -add_library(sp_LIB ${sp_SRC}) -add_library(inkscape_LIB ${inkscape_SRC}) + +# ----------------------------------------------------------------------------- +# Setup the executable +# ----------------------------------------------------------------------------- +add_inkscape_lib(sp_LIB "${sp_SRC}") +add_inkscape_lib(inkscape_LIB "${inkscape_SRC}") # make executable for INKSCAPE -add_executable(inkscape main.cpp) +add_executable(inkscape ${main_SRC}) target_link_libraries(inkscape # order from automake @@ -285,56 +565,16 @@ target_link_libraries(inkscape 2geom_LIB ${INKSCAPE_LIBS} - - + # system libs - -lxslt - -lgtkspell - -lgsl - -lgslcblas + -lgsl # needed + -lgslcblas # needed -lgtkmm-2.4 - -latkmm-1.6 -lgdkmm-2.4 - -lgiomm-2.4 -lpangomm-1.4 - -lgtk-x11-2.0 - -lglibmm-2.4 - -lcairomm-1.0 -lsigc-2.0 - -latk-1.0 - -lgio-2.0 - -lpng - -lX11 - -lxml2 - -ldl - -lgomp - -lpopt - -laspell - -lgnomevfs-2 - -lgconf-2 - -lpangoft2-1.0 - -lfontconfig - -lfreetype - -lz -lMagick++ -lMagickCore - -lgc - -llcms - -lpoppler-glib - -lgdk-x11-2.0 - -lpoppler - -lpangocairo-1.0 - -lgdk_pixbuf-2.0 - -lpng14 - -lm - -lpango-1.0 - -lcairo - -lgmodule-2.0 - -lgobject-2.0 - -lgthread-2.0 - -lrt - -lglib-2.0 - ) # TODO diff --git a/src/bind/CMakeLists.txt b/src/bind/CMakeLists.txt index 8a98e20a3..9b6abad4f 100644 --- a/src/bind/CMakeLists.txt +++ b/src/bind/CMakeLists.txt @@ -2,7 +2,17 @@ set(bind_SRC dobinding.cpp javabind.cpp + + + # ------- + # Headers + javabind-private.h + javabind.h + javainc/jni.h + javainc/linux/jni_md.h + javainc/solaris/jni_md.h + javainc/win32/jni_md.h ) -# add_library(bind_LIB ${bind_SRC}) +# add_inkscape_lib(bind_LIB "${bind_SRC}") add_inkscape_source("${bind_SRC}") diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 9039d52bb..5c0354fce 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -7,7 +7,22 @@ set(debug_SRC sysv-heap.cpp timestamp.cpp gdk-event-latency-tracker.cpp + + + # ------ + # Header + demangle.h + event-tracker.h + event.h + gc-heap.h + gdk-event-latency-tracker.h + heap.h + log-display-config.h + logger.h + simple-event.h + sysv-heap.h + timestamp.h ) -# add_library(debug_LIB ${debug_SRC}) +# add_inkscape_lib(debug_LIB "${debug_SRC}") add_inkscape_source("${debug_SRC}") diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index f2d05a02b..6586b78af 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -9,7 +9,20 @@ set(dialogs_SRC spellcheck.cpp text-edit.cpp xml-tree.cpp + + + # ------- + # Headers + clonetiler.h + dialog-events.h + export.h + find.h + item-properties.h + object-attributes.h + spellcheck.h + text-edit.h + xml-tree.h ) -# add_library(dialogs_LIB ${dialogs_SRC}) +# add_inkscape_lib(dialogs_LIB "${dialogs_SRC}") add_inkscape_source("${dialogs_SRC}") diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 056067ea4..30643550f 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -57,7 +57,74 @@ set(display_SRC sp-ctrlline.cpp sp-ctrlpoint.cpp sp-ctrlquadr.cpp + + + # ------- + # Headers + canvas-arena.h + canvas-axonomgrid.h + canvas-bpath.h + canvas-grid.h + canvas-temporary-item-list.h + canvas-temporary-item.h + canvas-text.h + curve-test.h + curve.h + gnome-canvas-acetate.h + grayscale.h + guideline.h + inkscape-cairo.h + nr-3dutils.h + nr-arena-forward.h + nr-arena-glyphs.h + nr-arena-group.h + nr-arena-image.h + nr-arena-item.h + nr-arena-shape.h + nr-arena.h + nr-filter-blend.h + nr-filter-colormatrix.h + nr-filter-component-transfer.h + nr-filter-composite.h + nr-filter-convolve-matrix.h + nr-filter-diffuselighting.h + nr-filter-displacement-map.h + nr-filter-flood.h + nr-filter-gaussian.h + nr-filter-getalpha.h + nr-filter-image.h + nr-filter-merge.h + nr-filter-morphology.h + nr-filter-offset.h + nr-filter-pixops.h + nr-filter-primitive.h + nr-filter-skeleton.h + nr-filter-slot.h + nr-filter-specularlighting.h + nr-filter-tile.h + nr-filter-turbulence.h + nr-filter-types.h + nr-filter-units.h + nr-filter-utils.h + nr-filter.h + nr-light-types.h + nr-light.h + nr-plain-stuff-gdk.h + nr-plain-stuff.h + pixblock-scaler.h + pixblock-transform.h + rendermode.h + snap-indicator.h + sodipodi-ctrl.h + sodipodi-ctrlrect.h + sp-canvas-group.h + sp-canvas-item.h + sp-canvas-util.h + sp-canvas.h + sp-ctrlline.h + sp-ctrlpoint.h + sp-ctrlquadr.h ) -# add_library(display_LIB ${display_SRC}) +# add_inkscape_lib(display_LIB "${display_SRC}") add_inkscape_source("${display_SRC}") diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index 5a3ebebf8..dbaa1a763 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -47,6 +47,53 @@ set(dom_SRC # work/testzip.cpp # work/xpathtests.cpp + + + # ------- + # Headers + css.h + cssreader.h + dom.h + domimpl.h + domptr.h + domstring.h + events.h + ls.h + lsimpl.h + smil.h + smilimpl.h + stylesheets.h + svg.h + svg2.h + svgimpl.h + svgreader.h + svgtypes.h + traversal.h + ucd.h + uri.h + views-level3.h + views.h + xmlreader.h + xmlwriter.h + xpath.h + xpathimpl.h + xpathparser.h + xpathtoken.h + + odf/odfdocument.h + + io/base64stream.h + io/bufferstream.h + io/domstream.h + io/gzipstream.h + io/httpclient.h + io/socket.h + io/stringstream.h + io/uristream.h + + util/digest.h + util/thread.h + util/ziptool.h ) -add_library(dom_LIB ${dom_SRC}) +add_inkscape_lib(dom_LIB "${dom_SRC}") diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index b2550361f..8a58ae2be 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -107,6 +107,111 @@ set(extension_SRC # dxf2svg/dxf2svg.cpp # dxf2svg/read_dxf.cpp # dxf2svg/test_dxf.cpp + + + # ------ + # Header + db.h + dependency.h + effect.h + error-file.h + execution-env.h + extension-forward.h + extension.h + init.h + input.h + output.h + param/bool.h + param/color.h + param/description.h + param/enum.h + param/float.h + param/int.h + param/notebook.h + param/parameter.h + param/radiobutton.h + param/string.h + patheffect.h + prefdialog.h + print.h + system.h + timer.h + + implementation/implementation.h + implementation/script.h + implementation/xslt.h + + internal/bitmap/adaptiveThreshold.h + internal/bitmap/addNoise.h + internal/bitmap/blur.h + internal/bitmap/channel.h + internal/bitmap/charcoal.h + internal/bitmap/colorize.h + internal/bitmap/contrast.h + internal/bitmap/cycleColormap.h + internal/bitmap/despeckle.h + internal/bitmap/edge.h + internal/bitmap/emboss.h + internal/bitmap/enhance.h + internal/bitmap/equalize.h + internal/bitmap/gaussianBlur.h + internal/bitmap/imagemagick.h + internal/bitmap/implode.h + internal/bitmap/level.h + internal/bitmap/levelChannel.h + internal/bitmap/medianFilter.h + internal/bitmap/modulate.h + internal/bitmap/negate.h + internal/bitmap/normalize.h + internal/bitmap/oilPaint.h + internal/bitmap/opacity.h + internal/bitmap/raise.h + internal/bitmap/reduceNoise.h + internal/bitmap/sample.h + internal/bitmap/shade.h + internal/bitmap/sharpen.h + internal/bitmap/solarize.h + internal/bitmap/spread.h + internal/bitmap/swirl.h + internal/bitmap/threshold.h + internal/bitmap/unsharpmask.h + internal/bitmap/wave.h + internal/bluredge.h + internal/cairo-png-out.h + internal/cairo-ps-out.h + internal/cairo-render-context.h + internal/cairo-renderer-pdf-out.h + internal/cairo-renderer.h + internal/clear-n_.h + internal/emf-win32-inout.h + internal/emf-win32-print.h + internal/filter/abc.h + internal/filter/color.h + internal/filter/drop-shadow.h + internal/filter/experimental.h + internal/filter/filter.h + internal/filter/morphology.h + internal/filter/shadows.h + internal/filter/snow.h + internal/gdkpixbuf-input.h + internal/gimpgrad.h + internal/grid.h + internal/javafx-out.h + internal/latex-pstricks-out.h + internal/latex-pstricks.h + internal/latex-text-renderer.h + internal/odf.h + internal/pdf-input-cairo.h + internal/pdfinput/pdf-input.h + internal/pdfinput/pdf-parser.h + internal/pdfinput/svg-builder.h + internal/pov-out.h + internal/svg.h + internal/svgz.h + internal/win32.h + internal/wpg-input.h + + script/InkscapeScript.h ) if(WIN32) @@ -115,5 +220,5 @@ if(WIN32) ) endif() -# add_library(extension_LIB ${extension_SRC}) +# add_inkscape_lib(extension_LIB "${extension_SRC}") add_inkscape_source("${extension_SRC}") diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index 8016553c8..72e0bba78 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -20,7 +20,45 @@ set(filters_SRC spotlight.cpp tile.cpp turbulence.cpp + + # ------- + # Headers + blend-fns.h + blend.h + colormatrix-fns.h + colormatrix.h + componenttransfer-fns.h + componenttransfer-funcnode.h + componenttransfer.h + composite-fns.h + composite.h + convolvematrix-fns.h + convolvematrix.h + diffuselighting-fns.h + diffuselighting.h + displacementmap-fns.h + displacementmap.h + distantlight.h + flood-fns.h + flood.h + image-fns.h + image.h + merge-fns.h + merge.h + mergenode.h + morphology-fns.h + morphology.h + offset-fns.h + offset.h + pointlight.h + specularlighting-fns.h + specularlighting.h + spotlight.h + tile-fns.h + tile.h + turbulence-fns.h + turbulence.h ) -#add_library(filters_LIB ${filters_SRC}) +# add_inkscape_lib(filters_LIB "${filters_SRC}"") add_inkscape_source("${filters_SRC}") diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index b4786ff54..f1069e986 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -21,11 +21,31 @@ set(helper_SRC #units-test.cpp unit-tracker.cpp window.cpp - sp-marshal.cpp - sp-marshal.list + # we generate this file and it's .h counter-part ${sp_marshal_SRC} + + + # ------- + # Headers + action.h + geom-curves.h + geom-nodetype.h + geom.h + gnome-utils.h + helper-forward.h + pixbuf-ops.h + png-write.h + recthull.h + sp-marshal.h + stlport.h + stock-items.h + unit-menu.h + unit-tracker.h + units-test.h + units.h + window.h ) -# add_library(helper_LIB ${helper_SRC}) +# add_inkscape_lib(helper_LIB "${helper_SRC}") add_inkscape_source("${helper_SRC}") diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index e9bff2bc2..c5606779e 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -11,7 +11,22 @@ set(io_SRC sys.cpp uristream.cpp xsltstream.cpp + + + # ------- + # Headers + base64stream.h + ftos.h + gzipstream.h + inkjar.h + inkscapestream.h + resource.h + simple-sax.h + stringstream.h + sys.h + uristream.h + xsltstream.h ) -# add_library(io_LIB ${io_SRC}) +# add_inkscape_lib(io_LIB "${io_SRC}") add_inkscape_source("${io_SRC}") diff --git a/src/jabber_whiteboard/CMakeLists.txt b/src/jabber_whiteboard/CMakeLists.txt index 62de25d70..b91bdf141 100644 --- a/src/jabber_whiteboard/CMakeLists.txt +++ b/src/jabber_whiteboard/CMakeLists.txt @@ -17,7 +17,28 @@ set(jabber_whiteboard_SRC session-manager.cpp dialog/choose-desktop.cpp + + + # ------- + # Headers + defines.h + dialog/choose-desktop.h + inkboard-document.h + invitation-confirm-dialog.h + keynode.h + message-aggregator.h + message-node.h + message-queue.h + message-tags.h + message-utilities.h + message-verifier.h + node-tracker.h + node-utilities.h + pedrogui.h + session-file-selector.h + session-manager.h + tracker-node.h ) -# add_library(jabber_whiteboard_LIB ${jabber_whiteboard_SRC}) +# add_inkscape_lib(jabber_whiteboard_LIB "${jabber_whiteboard_SRC}") add_inkscape_source("${jabber_whiteboard_SRC}") diff --git a/src/libavoid/CMakeLists.txt b/src/libavoid/CMakeLists.txt index 04b7375b1..de067833b 100644 --- a/src/libavoid/CMakeLists.txt +++ b/src/libavoid/CMakeLists.txt @@ -13,6 +13,25 @@ set(libavoid_SRC viscluster.cpp visibility.cpp vpsc.cpp + + # ------- + # Headers + assertions.h + connector.h + debug.h + geometry.h + geomtypes.h + graph.h + libavoid.h + makepath.h + orthogonal.h + router.h + shape.h + timer.h + vertices.h + viscluster.h + visibility.h + vpsc.h ) -add_library(avoid_LIB ${libavoid_SRC}) +add_inkscape_lib(avoid_LIB "${libavoid_SRC}") diff --git a/src/libcola/CMakeLists.txt b/src/libcola/CMakeLists.txt index 032bffb54..c89ffc692 100644 --- a/src/libcola/CMakeLists.txt +++ b/src/libcola/CMakeLists.txt @@ -7,6 +7,17 @@ set(libcola_SRC gradient_projection.cpp shortest_paths.cpp straightener.cpp + + + # ------- + # Headers + cola.h + conjugate_gradient.h + # cycle_detector.h + defs.h + gradient_projection.h + shortest_paths.h + straightener.h ) -add_library(cola_LIB ${libcola_SRC}) +add_inkscape_lib(cola_LIB "${libcola_SRC}") diff --git a/src/libcroco/CMakeLists.txt b/src/libcroco/CMakeLists.txt index c4676c504..890f58825 100644 --- a/src/libcroco/CMakeLists.txt +++ b/src/libcroco/CMakeLists.txt @@ -27,6 +27,36 @@ set(libcroco_SRC cr-tknzr.c cr-token.c cr-utils.c + + cr-additional-sel.h + cr-attr-sel.h + cr-cascade.h + cr-declaration.h + cr-doc-handler.h + cr-enc-handler.h + cr-fonts.h + cr-input.h + cr-libxml-node-iface.h + cr-node-iface.h + cr-num.h + cr-om-parser.h + cr-parser.h + cr-parsing-location.h + cr-prop-list.h + cr-pseudo.h + cr-rgb.h + cr-sel-eng.h + cr-selector.h + cr-simple-sel.h + cr-statement.h + cr-string.h + cr-style.h + cr-stylesheet.h + cr-term.h + cr-tknzr.h + cr-token.h + cr-utils.h + libcroco.h ) -add_library(croco_LIB ${libcroco_SRC}) +add_inkscape_lib(croco_LIB "${libcroco_SRC}") diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt index cf550107a..befb6edb7 100644 --- a/src/libgdl/CMakeLists.txt +++ b/src/libgdl/CMakeLists.txt @@ -16,12 +16,34 @@ set(libgdl_SRC gdl-tools.h libgdlmarshal.c libgdltypebuiltins.c + + + # ------- + # Headers + gdl-dock-bar.h + gdl-dock-item-grip.h + gdl-dock-item.h + gdl-dock-master.h + gdl-dock-notebook.h + gdl-dock-object.h + gdl-dock-paned.h + gdl-dock-placeholder.h + gdl-dock-tablabel.h + gdl-dock.h + gdl-i18n.h + gdl-stock-icons.h + gdl-stock.h + gdl-switcher.h + libgdl.h + libgdlmarshal.h + libgdltypebuiltins.h ) if(WIN32) list(APPEND libgdl_SRC gdl-win32.c + gdl-win32.h ) endif() -add_library(gdl_LIB ${libgdl_SRC}) +add_inkscape_lib(gdl_LIB "${libgdl_SRC}") diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 0d3202636..994c5d348 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -1,6 +1,6 @@ set(nr_SRC - #in-svg-plane-test.cpp + # in-svg-plane-test.cpp nr-blit.cpp nr-compose.cpp nr-compose-transform.cpp @@ -15,11 +15,11 @@ set(nr_SRC nr-pixblock-pattern.cpp nr-pixblock-pixel.cpp nr-point-fns.cpp - #nr-point-fns-test.cpp + # nr-point-fns-test.cpp nr-rect.cpp nr-rect-l.cpp nr-rotate-fns.cpp - #nr-rotate-fns-test.cpp + # nr-rotate-fns-test.cpp nr-rotate-matrix-ops.cpp nr-scale-matrix-ops.cpp nr-scale-translate-ops.cpp @@ -28,9 +28,74 @@ set(nr_SRC nr-translate-scale-ops.cpp #nr-translate-test.cpp nr-types.cpp - #nr-types-test.cpp + # nr-types-test.cpp nr-values.cpp - #testnr.cpp + # testnr.cpp + + # ------- + # Headers + # in-svg-plane-test.h + in-svg-plane.h + nr-blit.h + nr-compose-reference.h + nr-compose-test.h + nr-compose-transform.h + nr-compose.h + nr-convert2geom.h + nr-convex-hull-ops.h + nr-convex-hull.h + nr-coord.h + nr-dim2.h + nr-forward.h + nr-gradient.h + nr-i-coord.h + nr-macros.h + nr-matrix-div.h + nr-matrix-fns.h + nr-matrix-ops.h + nr-matrix-rotate-ops.h + nr-matrix-scale-ops.h + nr-matrix-test.h + nr-matrix-translate-ops.h + nr-matrix.h + nr-maybe.h + nr-object.h + nr-path-code.h + nr-pixblock-line.h + nr-pixblock-pattern.h + nr-pixblock-pixel.h + nr-pixblock.h + nr-pixops.h + # nr-point-fns-test.h + nr-point-fns.h + nr-point-l.h + nr-point-matrix-ops.h + nr-point-ops.h + nr-point.h + nr-rect-l.h + nr-rect-ops.h + nr-rect.h + nr-render.h + nr-rotate-fns-test.h + nr-rotate-fns.h + nr-rotate-matrix-ops.h + nr-rotate-ops.h + nr-rotate-test.h + nr-rotate.h + nr-scale-matrix-ops.h + nr-scale-ops.h + nr-scale-test.h + nr-scale-translate-ops.h + nr-scale.h + nr-translate-matrix-ops.h + nr-translate-ops.h + nr-translate-rotate-ops.h + nr-translate-scale-ops.h + # nr-translate-test.h + nr-translate.h + # nr-types-test.h + nr-types.h + nr-values.h ) -add_library(nr_LIB ${nr_SRC}) +add_inkscape_lib(nr_LIB "${nr_SRC}") diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index d5f9b846f..835665761 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -14,6 +14,27 @@ set(nrtype_SRC nr-type-primitives.cpp RasterFont.cpp TextWrapper.cpp + + FontFactory.h + Layout-TNG-Scanline-Maker.h + Layout-TNG.h + RasterFont.h + TextWrapper.h + boundary-type.h + font-glyph.h + font-instance.h + font-lister.h + font-style-to-pos.h + font-style.h + nr-type-pos-def.h + nr-type-primitives.h + nrtype-forward.h + one-box.h + one-glyph.h + one-para.h + raster-glyph.h + raster-position.h + text-boundary.h ) -add_library(nrtype_LIB ${nrtype_SRC}) +add_inkscape_lib(nrtype_LIB "${nrtype_SRC}") diff --git a/src/libvpsc/CMakeLists.txt b/src/libvpsc/CMakeLists.txt index ebc1e79d6..8db059b5d 100644 --- a/src/libvpsc/CMakeLists.txt +++ b/src/libvpsc/CMakeLists.txt @@ -9,6 +9,21 @@ set(libvpsc_SRC solve_VPSC.cpp variable.cpp pairingheap/PairingHeap.cpp + + + # ------- + # Headers + block.h + blocks.h + constraint.h + csolve_VPSC.h + generate-constraints.h + pairingheap/PairingHeap.h + pairingheap/dsexceptions.h + placement_SolveVPSC.h + remove_rectangle_overlap.h + solve_VPSC.h + variable.h ) -add_library(vpsc_LIB ${libvpsc_SRC}) +add_inkscape_lib(vpsc_LIB "${libvpsc_SRC}") diff --git a/src/livarot/CMakeLists.txt b/src/livarot/CMakeLists.txt index 51bb9530e..1890bd1a7 100644 --- a/src/livarot/CMakeLists.txt +++ b/src/livarot/CMakeLists.txt @@ -20,6 +20,22 @@ set(livarot_SRC sweep-event.cpp sweep-tree.cpp sweep-tree-list.cpp + + AVL.h + AlphaLigne.h + BitLigne.h + Livarot.h + LivarotDefs.h + Path.h + Shape.h + float-line.h + int-line.h + livarot-forward.h + path-description.h + sweep-event-queue.h + sweep-event.h + sweep-tree-list.h + sweep-tree.h ) -add_library(livarot_LIB ${livarot_SRC}) +add_inkscape_lib(livarot_LIB "${livarot_SRC}") diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 148ea92f7..3bca16715 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -52,7 +52,64 @@ set(live_effects_SRC parameter/text.cpp parameter/unit.cpp parameter/vector.cpp + + # ------- + # Headers + bezctx.h + bezctx_intf.h + effect-enum.h + effect.h + lpe-angle_bisector.h + lpe-bendpath.h + lpe-boolops.h + lpe-circle_3pts.h + lpe-circle_with_radius.h + lpe-constructgrid.h + lpe-copy_rotate.h + lpe-curvestitch.h + lpe-dynastroke.h + lpe-envelope.h + lpe-extrude.h + lpe-gears.h + lpe-interpolate.h + lpe-knot.h + lpe-lattice.h + lpe-line_segment.h + lpe-mirror_symmetry.h + lpe-offset.h + lpe-parallel.h + lpe-path_length.h + lpe-patternalongpath.h + lpe-perp_bisector.h + lpe-perspective_path.h + lpe-powerstroke.h + lpe-recursiveskeleton.h + lpe-rough-hatches.h + lpe-ruler.h + lpe-skeleton.h + lpe-sketch.h + lpe-spiro.h + lpe-tangent_to_curve.h + lpe-test-doEffect-stack.h + lpe-text_label.h + lpe-vonkoch.h + lpegroupbbox.h + lpeobject-reference.h + lpeobject.h + parameter/array.h + parameter/bool.h + parameter/enum.h + parameter/parameter.h + parameter/path-reference.h + parameter/path.h + parameter/point.h + parameter/powerstrokepointarray.h + parameter/random.h + parameter/text.h + parameter/unit.h + parameter/vector.h + spiro.h ) -# add_library(live_effects_LIB ${live_effects_SRC}) +# add_inkscape_lib(live_effects_LIB "${live_effects_SRC}") add_inkscape_source("${live_effects_SRC}") diff --git a/src/pedro/CMakeLists.txt b/src/pedro/CMakeLists.txt index 7dce5b755..c51090067 100644 --- a/src/pedro/CMakeLists.txt +++ b/src/pedro/CMakeLists.txt @@ -10,5 +10,5 @@ set(pedro_SRC pedroxmpp.cpp ) -# add_library(pedro_LIB ${pedro_SRC}) +# add_inkscape_lib(pedro_LIB "${pedro_SRC}") add_inkscape_source("${pedro_SRC}") diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index 8c1f0058e..9a721969a 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -12,8 +12,25 @@ set(svg_SRC svg-color.cpp svg-length.cpp svg-path.cpp - #test-stubs.cpp + # test-stubs.cpp + + css-ostringstream-test.h + css-ostringstream.h + path-string.h + stringstream-test.h + stringstream.h + strip-trailing-zeros.h + svg-affine-test.h + svg-color-test.h + svg-color.h + svg-icc-color.h + svg-length-test.h + svg-length.h + svg-path-geom-test.h + svg.h + # test-stubs.h + ) -# add_library(svg_LIB ${svg_SRC}) +# add_inkscape_lib(svg_LIB "${svg_SRC}") add_inkscape_source("${svg_SRC}") diff --git a/src/trace/CMakeLists.txt b/src/trace/CMakeLists.txt index 3f712a314..958907df6 100644 --- a/src/trace/CMakeLists.txt +++ b/src/trace/CMakeLists.txt @@ -14,7 +14,30 @@ set(trace_SRC potrace/potracelib.cpp potrace/render.cpp potrace/trace.cpp + + + # ------- + # Headers + filterset.h + imagemap-gdk.h + imagemap.h + pool.h + quantize.h + siox.h + trace.h + + potrace/auxiliary.h + potrace/bitmap.h + potrace/curve.h + potrace/decompose.h + potrace/greymap.h + potrace/inkscape-potrace.h + potrace/lists.h + potrace/potracelib.h + potrace/progress.h + potrace/render.h + potrace/trace.h ) -# add_library(trace_LIB ${trace_SRC}) +# add_inkscape_lib(trace_LIB "${trace_SRC}") add_inkscape_source("${trace_SRC}") diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index bf9ddb4c8..30b72437f 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -109,6 +109,132 @@ set(ui_SRC view/view.cpp view/view-widget.cpp + + + # ------- + # Headers + clipboard.h + context-menu.h + icon-names.h + previewable.h + previewfillable.h + previewholder.h + uxmanager.h + + cache/svg_preview_cache.h + + dialog/aboutbox.h + dialog/align-and-distribute.h + dialog/behavior.h + dialog/calligraphic-profile-rename.h + dialog/color-item.h + dialog/debug.h + dialog/desktop-tracker.h + dialog/dialog-manager.h + dialog/dialog.h + dialog/dock-behavior.h + dialog/document-metadata.h + dialog/document-properties.h + dialog/extension-editor.h + dialog/extensions.h + dialog/filedialog.h + dialog/filedialogimpl-gtkmm.h + dialog/filedialogimpl-win32.h + dialog/fill-and-stroke.h + dialog/filter-effects-dialog.h + dialog/find.h + dialog/floating-behavior.h + dialog/glyphs.h + dialog/guides.h + dialog/icon-preview.h + dialog/inkscape-preferences.h + dialog/input.h + dialog/layer-properties.h + dialog/layers.h + dialog/livepatheffect-editor.h + dialog/memory.h + dialog/messages.h + dialog/ocaldialogs.h + dialog/panel-dialog.h + dialog/print-colors-preview-dialog.h + dialog/print.h + dialog/scriptdialog.h + dialog/session-player.h + dialog/svg-fonts-dialog.h + dialog/swatches.h + dialog/tile.h + dialog/tracedialog.h + dialog/transformation.h + dialog/undo-history.h + dialog/whiteboard-connect.h + dialog/whiteboard-sharewithchat.h + dialog/whiteboard-sharewithuser.h + + tool/commit-events.h + tool/control-point-selection.h + tool/control-point.h + tool/curve-drag-point.h + tool/event-utils.h + tool/manipulator.h + tool/modifier-tracker.h + tool/multi-path-manipulator.h + tool/node-tool.h + tool/node-types.h + tool/node.h + tool/path-manipulator.h + tool/selectable-control-point.h + tool/selector.h + tool/shape-record.h + tool/transform-handle-set.h + + view/edit-widget-interface.h + view/view-widget.h + view/view.h + + widget/attr-widget.h + widget/button.h + widget/color-picker.h + widget/color-preview.h + widget/combo-enums.h + widget/combo-text.h + widget/dock-item.h + widget/dock.h + widget/entity-entry.h + widget/entry.h + widget/filter-effect-chooser.h + widget/handlebox.h + widget/icon-widget.h + widget/imageicon.h + widget/imagetoggler.h + widget/labelled.h + widget/layer-selector.h + widget/licensor.h + widget/notebook-page.h + widget/object-composite-settings.h + widget/page-sizer.h + widget/panel.h + widget/point.h + widget/preferences-widget.h + widget/random.h + widget/registered-enums.h + widget/registered-widget.h + widget/registry.h + widget/rendering-options.h + widget/rotateable.h + widget/ruler.h + widget/scalar-unit.h + widget/scalar.h + widget/selected-style.h + widget/spin-slider.h + widget/spinbutton.h + widget/style-subject.h + widget/style-swatch.h + widget/svg-canvas.h + widget/text.h + widget/tolerance-slider.h + widget/toolbox.h + widget/unit-menu.h + widget/zoom-status.h ) if(WIN32) @@ -117,5 +243,5 @@ if(WIN32) ) endif() -# add_library(ui_LIB ${ui_SRC}) +# add_inkscape_lib(ui_LIB "${ui_SRC}") add_inkscape_source("${ui_SRC}") diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index ca90272ae..5c8411437 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -5,7 +5,37 @@ set(util_SRC expression-evaluator.cpp share.cpp units.cpp + + accumulators.h + compose.hpp + copy.h + ege-appear-time-tracker.h + ege-tags.h + enums.h + expression-evaluator.h + filter-list.h + find-if-before.h + find-last-if.h + fixed_point.h + format.h + forward-pointer-iterator.h + function.h + glib-list-iterators.h + list-container-test.h + list-container.h + list-copy.h + list.h + longest-common-suffix.h + map-list.h + mathfns.h + reference.h + reverse-list.h + share.h + tuple.h + ucompose.hpp + units.h + unordered-containers.h ) -# add_library(util_LIB ${util_SRC}) +# add_inkscape_lib(util_LIB "${util_SRC}") add_inkscape_source("${util_SRC}") diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 09d2d6303..d9e05f06a 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -34,7 +34,44 @@ set(widgets_SRC stroke-style.cpp swatch-selector.cpp toolbox.cpp + + button.h + dash-selector.h + desktop-widget.h + eek-preview.h + ege-paint-def.h + fill-n-stroke-factory.h + fill-style.h + font-selector.h + gradient-image.h + gradient-selector.h + gradient-toolbar.h + gradient-vector.h + icon.h + paint-selector.h + ruler.h + select-toolbar.h + shrink-wrap-button.h + sp-attribute-widget.h + sp-color-gtkselector.h + sp-color-icc-selector.h + sp-color-notebook.h + sp-color-preview.h + sp-color-scales.h + sp-color-selector.h + sp-color-slider.h + sp-color-wheel-selector.h + sp-widget.h + sp-xmlview-attr-list.h + sp-xmlview-content.h + sp-xmlview-tree.h + spinbutton-events.h + spw-utilities.h + stroke-style.h + swatch-selector.h + toolbox.h + widget-sizes.h ) -# add_library(widgets_LIB ${widgets_SRC}) +# add_inkscape_lib(widgets_LIB "${widgets_SRC}") add_inkscape_source("${widgets_SRC}") diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index 3cca53fd8..d7a0e197d 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -16,7 +16,38 @@ set(xml_SRC subtree.cpp helper-observer.cpp rebase-hrefs.cpp + + attribute-record.h + comment-node.h + composite-node-observer.h + croco-node-iface.h + document.h + element-node.h + event-fns.h + event.h + helper-observer.h + invalid-operation-exception.h + log-builder.h + node-event-vector.h + node-fns.h + node-iterators.h + node-observer.h + node.h + pi-node.h + quote-test.h + quote.h + rebase-hrefs-test.h + rebase-hrefs.h + repr-action-test.h + repr-sorting.h + repr.h + simple-document.h + simple-node.h + sp-css-attr.h + subtree.h + text-node.h + xml-forward.h ) -# add_library(xml_LIB ${xml_SRC}) +# add_inkscape_lib(xml_LIB "${xml_SRC}") add_inkscape_source("${xml_SRC}") -- cgit v1.2.3 From c049136141351920600d1bbd1f330a46a04b1210 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 06:38:36 +0000 Subject: cmake: basic install target (bzr r10282) --- src/CMakeLists.txt | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 718c92b4b..3e7fe3a11 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -582,3 +582,50 @@ target_link_libraries(inkscape #add_executable(inkview inkview.cpp) # ... + +# ----------------------------------------------------------------------------- +# Installation +# ----------------------------------------------------------------------------- + +if(UNIX) + # TODO: man, locale, icons + + # message after building. + add_custom_command( + TARGET blender POST_BUILD MAIN_DEPENDENCY blender + COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${CMAKE_INSTALL_PREFIX}' + ) + + install( + PROGRAMS inkscape + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin + ) + + install( + FILES ${CMAKE_SOURCE_DIR}/inkscape.desktop + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications + ) + + install( + DIRECTORY + ${CMAKE_SOURCE_DIR}/share/clipart + ${CMAKE_SOURCE_DIR}/share/examples + ${CMAKE_SOURCE_DIR}/share/extensions + ${CMAKE_SOURCE_DIR}/share/filters + ${CMAKE_SOURCE_DIR}/share/fonts + ${CMAKE_SOURCE_DIR}/share/gradients + ${CMAKE_SOURCE_DIR}/share/icons + ${CMAKE_SOURCE_DIR}/share/keys + ${CMAKE_SOURCE_DIR}/share/markers + ${CMAKE_SOURCE_DIR}/share/palettes + ${CMAKE_SOURCE_DIR}/share/patterns + ${CMAKE_SOURCE_DIR}/share/screens + ${CMAKE_SOURCE_DIR}/share/templates + ${CMAKE_SOURCE_DIR}/share/tutorials + ${CMAKE_SOURCE_DIR}/share/ui + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/inkscape + ) + +else() + # TODO, WIN32/APPLE +endif() -- cgit v1.2.3 From a1f1e29a8a207ea7ef4be583a050778cf2875217 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Mon, 13 Jun 2011 01:28:49 +0100 Subject: Replace deprecated GtkSignal (bzr r10282.1.1) --- src/connector-context.cpp | 8 +-- src/dialogs/clonetiler.cpp | 102 ++++++++++++++-------------- src/dialogs/export.cpp | 18 ++--- src/dialogs/find.cpp | 8 +-- src/dialogs/item-properties.cpp | 22 +++--- src/dialogs/spellcheck.cpp | 6 +- src/dialogs/text-edit.cpp | 6 +- src/dialogs/xml-tree.cpp | 38 +++++------ src/display/canvas-arena.cpp | 9 +-- src/display/sp-canvas.cpp | 2 +- src/helper/unit-menu.cpp | 4 +- src/knot.cpp | 4 +- src/ui/context-menu.cpp | 34 +++++----- src/ui/dialog/guides.cpp | 12 ++-- src/widgets/desktop-widget.cpp | 6 +- src/widgets/font-selector.cpp | 13 ++-- src/widgets/gradient-selector.cpp | 44 ++++++------ src/widgets/gradient-toolbar.cpp | 2 +- src/widgets/gradient-vector.cpp | 33 ++++----- src/widgets/paint-selector.cpp | 114 +++++++++++++++++--------------- src/widgets/select-toolbar.cpp | 8 +-- src/widgets/sp-color-icc-selector.cpp | 28 ++++---- src/widgets/sp-color-notebook.cpp | 16 ++--- src/widgets/sp-color-scales.cpp | 16 ++--- src/widgets/sp-color-selector.cpp | 52 ++++++++------- src/widgets/sp-color-slider.cpp | 66 +++++++++--------- src/widgets/sp-color-wheel-selector.cpp | 28 ++++---- src/widgets/sp-widget.cpp | 44 ++++++------ src/widgets/toolbox.cpp | 4 +- 29 files changed, 386 insertions(+), 361 deletions(-) (limited to 'src') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 27e052499..251b41066 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1640,8 +1640,8 @@ static void cc_active_shape_add_knot(SPDesktop* desktop, SPItem* item, Connectio knot->_event_handler_id); knot->_event_handler_id = 0; - gtk_signal_connect(GTK_OBJECT(knot->item), "event", - GTK_SIGNAL_FUNC(cc_generic_knot_handler), knot); + g_signal_connect(G_OBJECT(knot->item), "event", + G_CALLBACK(cc_generic_knot_handler), knot); sp_knot_set_position(knot, item->avoidRef->getConnectionPointPos(cp.type, cp.id) * desktop->doc2dt(), 0); sp_knot_show(knot); cphandles[knot] = cp; @@ -1826,8 +1826,8 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) knot->_event_handler_id); knot->_event_handler_id = 0; - gtk_signal_connect(GTK_OBJECT(knot->item), "event", - GTK_SIGNAL_FUNC(cc_generic_knot_handler), knot); + g_signal_connect(G_OBJECT(knot->item), "event", + G_CALLBACK(cc_generic_knot_handler), knot); cc->endpt_handle[i] = knot; } diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 2f78e4742..0cfa1d3c9 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1529,8 +1529,8 @@ static GtkWidget * clonetiler_checkbox(const char *tip, const char *attr) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value); gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); - gtk_signal_connect ( GTK_OBJECT (b), "clicked", - GTK_SIGNAL_FUNC (clonetiler_checkbox_toggled), (gpointer) attr); + g_signal_connect ( G_OBJECT (b), "clicked", + G_CALLBACK (clonetiler_checkbox_toggled), (gpointer) attr); g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); @@ -1570,8 +1570,8 @@ static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); - gtk_signal_connect(GTK_OBJECT(a), "value_changed", - GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr); + g_signal_connect(G_OBJECT(a), "value_changed", + G_CALLBACK(clonetiler_value_changed), (gpointer) attr); if (exponent) { g_object_set_data (G_OBJECT(sb), "oneable", GINT_TO_POINTER(TRUE)); @@ -1824,10 +1824,10 @@ void clonetiler_dialog(void) wd.stop = 0; - gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg); + g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg); + g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg); + g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); @@ -1894,8 +1894,8 @@ void clonetiler_dialog(void) GtkWidget *item = gtk_menu_item_new (); gtk_container_add (GTK_CONTAINER (item), l); - gtk_signal_connect ( GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (clonetiler_symgroup_changed), + g_signal_connect ( G_OBJECT (item), "activate", + G_CALLBACK (clonetiler_symgroup_changed), GINT_TO_POINTER (sg.group) ); gtk_menu_append (GTK_MENU (m), item); @@ -2518,8 +2518,8 @@ void clonetiler_dialog(void) gtk_widget_set_tooltip_text (b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone")); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(b), "toggled", - GTK_SIGNAL_FUNC(clonetiler_do_pick_toggled), dlg); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_do_pick_toggled), dlg); } { @@ -2543,64 +2543,64 @@ void clonetiler_dialog(void) radio = gtk_radio_button_new_with_label (NULL, _("Color")); gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); clonetiler_table_attach (table, radio, 0.0, 1, 1); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); clonetiler_table_attach (table, radio, 0.0, 2, 1); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R")); gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); clonetiler_table_attach (table, radio, 0.0, 1, 2); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G")); gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); clonetiler_table_attach (table, radio, 0.0, 2, 2); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B")); gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); clonetiler_table_attach (table, radio, 0.0, 3, 2); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); clonetiler_table_attach (table, radio, 0.0, 1, 3); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); clonetiler_table_attach (table, radio, 0.0, 2, 3); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); clonetiler_table_attach (table, radio, 0.0, 3, 3); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", - GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); } @@ -2664,8 +2664,8 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); clonetiler_table_attach (table, b, 0.0, 1, 1); - gtk_signal_connect(GTK_OBJECT(b), "toggled", - GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_presence"); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence"); } { @@ -2674,8 +2674,8 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); clonetiler_table_attach (table, b, 0.0, 2, 1); - gtk_signal_connect(GTK_OBJECT(b), "toggled", - GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_size"); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size"); } { @@ -2684,8 +2684,8 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); clonetiler_table_attach (table, b, 0.0, 1, 2); - gtk_signal_connect(GTK_OBJECT(b), "toggled", - GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_color"); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color"); } { @@ -2694,8 +2694,8 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active ((GtkToggleButton *) b, old); gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); clonetiler_table_attach (table, b, 0.0, 2, 2); - gtk_signal_connect(GTK_OBJECT(b), "toggled", - GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity"); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity"); } } gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); @@ -2723,8 +2723,8 @@ void clonetiler_dialog(void) gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0); - gtk_signal_connect(GTK_OBJECT(a), "value_changed", - GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "jmax"); + g_signal_connect(G_OBJECT(a), "value_changed", + G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax"); } { @@ -2743,8 +2743,8 @@ void clonetiler_dialog(void) gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0); - gtk_signal_connect(GTK_OBJECT(a), "value_changed", - GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "imax"); + g_signal_connect(G_OBJECT(a), "value_changed", + G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax"); } clonetiler_table_attach (table, hb, 0.0, 1, 2); @@ -2772,8 +2772,8 @@ void clonetiler_dialog(void) gtk_widget_set_tooltip_text (e, _("Width of the rectangle to be filled")); gtk_entry_set_width_chars (GTK_ENTRY (e), 5); gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0); - gtk_signal_connect(GTK_OBJECT(a), "value_changed", - GTK_SIGNAL_FUNC(clonetiler_fill_width_changed), u); + g_signal_connect(G_OBJECT(a), "value_changed", + G_CALLBACK(clonetiler_fill_width_changed), u); } { GtkWidget *l = gtk_label_new (""); @@ -2797,8 +2797,8 @@ void clonetiler_dialog(void) gtk_widget_set_tooltip_text (e, _("Height of the rectangle to be filled")); gtk_entry_set_width_chars (GTK_ENTRY (e), 5); gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0); - gtk_signal_connect(GTK_OBJECT(a), "value_changed", - GTK_SIGNAL_FUNC(clonetiler_fill_height_changed), u); + g_signal_connect(G_OBJECT(a), "value_changed", + G_CALLBACK(clonetiler_fill_height_changed), u); } gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0); @@ -2812,7 +2812,7 @@ void clonetiler_dialog(void) radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); clonetiler_table_attach (table, radio, 0.0, 1, 1); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg); } if (!prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -2822,7 +2822,7 @@ void clonetiler_dialog(void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); clonetiler_table_attach (table, radio, 0.0, 2, 1); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); } if (prefs->getBool(prefs_path + "fillrect")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); @@ -2842,8 +2842,8 @@ void clonetiler_dialog(void) gtk_widget_set_tooltip_text (b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size")); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(b), "toggled", - GTK_SIGNAL_FUNC(clonetiler_keep_bbox_toggled), NULL); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_keep_bbox_toggled), NULL); } // Statusbar @@ -2866,7 +2866,7 @@ void clonetiler_dialog(void) gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> ")); gtk_container_add (GTK_CONTAINER(b), l); gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); - gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_apply), NULL); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), NULL); gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); } @@ -2882,14 +2882,14 @@ void clonetiler_dialog(void) // So unclumping is the process of spreading a number of objects out more evenly. GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_unclump), NULL); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL); gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); } { GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); - gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_remove), NULL); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), NULL); gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); } @@ -2907,7 +2907,7 @@ void clonetiler_dialog(void) GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); // TRANSLATORS: "change" is a noun here gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_reset), NULL); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), NULL); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } } diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 2f1299190..b076c0f96 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -262,7 +262,7 @@ sp_export_spinbutton_new ( gchar const *key, float val, float min, float max, } if (cb) - gtk_signal_connect (adj, "value_changed", cb, dlg); + g_signal_connect (adj, "value_changed", cb, dlg); return; } // end of sp_export_spinbutton_new() @@ -299,8 +299,8 @@ sp_export_dialog_area_box (GtkWidget * dlg) b->set_data("key", GINT_TO_POINTER(i)); gtk_object_set_data (GTK_OBJECT (dlg), selection_names[i], b->gobj()); togglebox->pack_start(*b, false, true, 0); - gtk_signal_connect ( GTK_OBJECT (b->gobj()), "clicked", - GTK_SIGNAL_FUNC (sp_export_area_toggled), dlg ); + g_signal_connect ( G_OBJECT (b->gobj()), "clicked", + G_CALLBACK (sp_export_area_toggled), dlg ); } g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", @@ -432,13 +432,13 @@ sp_export_dialog (void) g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); - gtk_signal_connect ( GTK_OBJECT (dlg), "event", - GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg); + g_signal_connect ( G_OBJECT (dlg), "event", + G_CALLBACK (sp_dialog_event_handler), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", + g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_export_dialog_destroy), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", + g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_export_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", @@ -657,8 +657,8 @@ sp_export_dialog (void) b->add(*image_label); gtk_widget_set_tooltip_text (GTK_WIDGET(b->gobj()), _("Export the bitmap file with these settings")); - gtk_signal_connect ( GTK_OBJECT (b->gobj()), "clicked", - GTK_SIGNAL_FUNC (sp_export_export_clicked), dlg ); + g_signal_connect ( G_OBJECT (b->gobj()), "clicked", + G_CALLBACK (sp_export_export_clicked), dlg ); bb->pack_end(*b, false, false, 0); } diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index d07772406..62c551523 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -497,7 +497,7 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, gtk_object_set_data (GTK_OBJECT (w), data, b); gtk_widget_set_tooltip_text (b, tip); if (toggled) - gtk_signal_connect (GTK_OBJECT (b), "toggled", GTK_SIGNAL_FUNC (toggled), w); + g_signal_connect (G_OBJECT (b), "toggled", G_CALLBACK (toggled), w); gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); } @@ -676,10 +676,10 @@ sp_find_dialog_old (void) wd.stop = 0; g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd ); - gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg); + g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_find_dialog_destroy), NULL ); - gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_find_dialog_delete), dlg); + g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_find_dialog_destroy), NULL ); + g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_find_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_find_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index cd0cea9b5..cd56c2da4 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -91,11 +91,11 @@ sp_item_widget_new (void) /* Create container widget */ spw = sp_widget_new_global (INKSCAPE); - gtk_signal_connect ( GTK_OBJECT (spw), "modify_selection", - GTK_SIGNAL_FUNC (sp_item_widget_modify_selection), + g_signal_connect ( G_OBJECT (spw), "modify_selection", + G_CALLBACK (sp_item_widget_modify_selection), spw ); - gtk_signal_connect ( GTK_OBJECT (spw), "change_selection", - GTK_SIGNAL_FUNC (sp_item_widget_change_selection), + g_signal_connect ( G_OBJECT (spw), "change_selection", + G_CALLBACK (sp_item_widget_change_selection), spw ); vb = gtk_vbox_new (FALSE, 0); @@ -136,8 +136,8 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), pb, 2, 3, 0, 1, (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_signal_connect ( GTK_OBJECT (pb), "clicked", - GTK_SIGNAL_FUNC (sp_item_widget_label_changed), + g_signal_connect ( G_OBJECT (pb), "clicked", + G_CALLBACK (sp_item_widget_label_changed), spw ); /* Create the label for the object label */ @@ -226,8 +226,8 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), cb, 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_signal_connect ( GTK_OBJECT (cb), "toggled", - GTK_SIGNAL_FUNC (sp_item_widget_sensitivity_toggled), + g_signal_connect ( G_OBJECT (cb), "toggled", + G_CALLBACK (sp_item_widget_sensitivity_toggled), spw ); gtk_object_set_data (GTK_OBJECT (spw), "sensitive", cb); @@ -525,9 +525,9 @@ sp_item_dialog (void) wd.stop = 0; g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); - gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_item_dialog_destroy), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_item_dialog_delete), dlg); + g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); + g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_item_dialog_destroy), dlg); + g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_item_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_item_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 47de25061..1d475a5c3 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -917,10 +917,10 @@ sp_spellcheck_dialog (void) g_signal_connect( G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK( spellcheck_desktop_deactivated ), NULL); - gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg); + g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); - gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_spellcheck_dialog_destroy), NULL ); - gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_spellcheck_dialog_delete), dlg); + g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_spellcheck_dialog_destroy), NULL ); + g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_spellcheck_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_spellcheck_dialog_delete), dlg); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 0533a2a35..2e49cae8f 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -177,10 +177,10 @@ sp_text_edit_dialog (void) wd.stop = 0; g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd ); - gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg ); + g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg ); - gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_text_edit_dialog_destroy), dlg ); - gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_text_edit_dialog_delete), dlg ); + g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_text_edit_dialog_destroy), dlg ); + g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_text_edit_dialog_delete), dlg ); g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_text_edit_dialog_delete), dlg ); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg ); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 78e7d3dcf..c50c07e80 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -221,10 +221,10 @@ void sp_xml_tree_dialog() wd.stop = 0; g_signal_connect ( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_transientize_callback), &wd ); - gtk_signal_connect( GTK_OBJECT(dlg), "event", GTK_SIGNAL_FUNC(sp_dialog_event_handler), dlg ); + g_signal_connect( G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg ); - gtk_signal_connect( GTK_OBJECT(dlg), "destroy", G_CALLBACK(on_destroy), dlg); - gtk_signal_connect( GTK_OBJECT(dlg), "delete_event", G_CALLBACK(on_delete), dlg); + g_signal_connect( G_OBJECT(dlg), "destroy", G_CALLBACK(on_destroy), dlg); + g_signal_connect( G_OBJECT(dlg), "delete_event", G_CALLBACK(on_delete), dlg); g_signal_connect ( G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(on_delete), dlg); g_signal_connect ( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(sp_dialog_hide), dlg); @@ -495,15 +495,15 @@ void sp_xml_tree_dialog() // TRANSLATORS: "Attribute" is a noun here _("Attribute name") ); - gtk_signal_connect( GTK_OBJECT(attributes), "select_row", + g_signal_connect( G_OBJECT(attributes), "select_row", (GCallback) on_attr_select_row_set_name_content, attr_name); - gtk_signal_connect( GTK_OBJECT(attributes), "unselect_row", + g_signal_connect( G_OBJECT(attributes), "unselect_row", (GCallback) on_attr_unselect_row_clear_text, attr_name); - gtk_signal_connect( GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect( G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_clear_text, attr_name); @@ -518,9 +518,9 @@ void sp_xml_tree_dialog() GtkWidget *set_label = gtk_label_new(_("Set")); gtk_container_add(GTK_CONTAINER(set_attr), set_label); - gtk_signal_connect( GTK_OBJECT(set_attr), "clicked", + g_signal_connect( G_OBJECT(set_attr), "clicked", (GCallback) cmd_set_attr, NULL); - gtk_signal_connect( GTK_OBJECT(attr_name), "changed", + g_signal_connect( G_OBJECT(attr_name), "changed", (GCallback) on_editable_changed_enable_if_valid_xml_name, set_attr ); gtk_widget_set_sensitive(GTK_WIDGET(set_attr), FALSE); @@ -539,13 +539,13 @@ void sp_xml_tree_dialog() gtk_widget_set_tooltip_text( GTK_WIDGET(attr_value), // TRANSLATORS: "Attribute" is a noun here _("Attribute value") ); - gtk_signal_connect( GTK_OBJECT(attributes), "select_row", + g_signal_connect( G_OBJECT(attributes), "select_row", (GCallback) on_attr_select_row_set_value_content, attr_value ); - gtk_signal_connect( GTK_OBJECT(attributes), "unselect_row", + g_signal_connect( G_OBJECT(attributes), "unselect_row", (GCallback) on_attr_unselect_row_clear_text, attr_value ); - gtk_signal_connect( GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect( G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_clear_text, attr_value ); gtk_text_view_set_editable(attr_value, TRUE); @@ -1321,8 +1321,8 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/) gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(dlg)); gtk_window_set_modal(GTK_WINDOW(window), TRUE); - gtk_signal_connect(GTK_OBJECT(window), "destroy", gtk_main_quit, NULL); - gtk_signal_connect(GTK_OBJECT(window), "key-press-event", G_CALLBACK(quit_on_esc), window); + g_signal_connect(G_OBJECT(window), "destroy", gtk_main_quit, NULL); + g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(quit_on_esc), window); vbox = gtk_vbox_new(FALSE, 4); gtk_container_add(GTK_CONTAINER(window), vbox); @@ -1340,21 +1340,21 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/) cancel = gtk_button_new_with_label(_("Cancel")); gtk_widget_set_can_default( GTK_WIDGET(cancel), TRUE ); - gtk_signal_connect_object( GTK_OBJECT(cancel), "clicked", + g_signal_connect_swapped( G_OBJECT(cancel), "clicked", G_CALLBACK(gtk_widget_destroy), - GTK_OBJECT(window) ); + G_OBJECT(window) ); gtk_container_add(GTK_CONTAINER(bbox), cancel); create = gtk_button_new_with_label(_("Create")); gtk_widget_set_sensitive(GTK_WIDGET(create), FALSE); - gtk_signal_connect( GTK_OBJECT(entry), "changed", + g_signal_connect( G_OBJECT(entry), "changed", G_CALLBACK(on_editable_changed_enable_if_valid_xml_name), create ); - gtk_signal_connect( GTK_OBJECT(create), "clicked", + g_signal_connect( G_OBJECT(create), "clicked", G_CALLBACK(on_clicked_get_editable_text), &name ); - gtk_signal_connect_object( GTK_OBJECT(create), "clicked", + g_signal_connect_swapped( G_OBJECT(create), "clicked", G_CALLBACK(gtk_widget_destroy), - GTK_OBJECT(window) ); + G_OBJECT(window) ); gtk_widget_set_can_default( GTK_WIDGET(create), TRUE ); gtk_widget_set_receives_default( GTK_WIDGET(create), TRUE ); gtk_container_add(GTK_CONTAINER(bbox), create); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 5975db9cc..8436a3b99 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -77,10 +77,11 @@ sp_canvas_arena_class_init (SPCanvasArenaClass *klass) parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); - signals[ARENA_EVENT] = gtk_signal_new ("arena_event", - GTK_RUN_LAST, - GTK_CLASS_TYPE(object_class), + signals[ARENA_EVENT] = g_signal_new ("arena_event", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_LAST, ((glong)((guint8*)&(klass->arena_event) - (guint8*)klass)), + NULL, NULL, sp_marshal_INT__POINTER_POINTER, GTK_TYPE_INT, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); @@ -329,7 +330,7 @@ sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event) gint ret = FALSE; /* Send event to arena */ - gtk_signal_emit (GTK_OBJECT (arena), signals[ARENA_EVENT], arena->active, event, &ret); + g_signal_emit (G_OBJECT (arena), signals[ARENA_EVENT], 0, arena->active, event, &ret); return ret; } diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ad2a45eea..20c21a8c3 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1360,7 +1360,7 @@ emit_event (SPCanvas *canvas, GdkEvent *event) while (item && !finished) { gtk_object_ref (GTK_OBJECT (item)); - gtk_signal_emit (GTK_OBJECT (item), item_signals[ITEM_EVENT], &ev, &finished); + g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, &ev, &finished); SPCanvasItem *parent = item->parent; gtk_object_unref (GTK_OBJECT (item)); item = parent; diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index 5494aaaeb..bcc8589e2 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -205,7 +205,7 @@ spus_unit_activate(GtkWidget *widget, SPUnitSelector *us) /* when the base changes, signal all the adjustments to get them * to recalculate */ for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { - gtk_signal_emit_by_name(GTK_OBJECT(l->data), "value_changed"); + g_signal_emit_by_name(G_OBJECT(l->data), "value_changed"); } } @@ -233,7 +233,7 @@ spus_rebuild_menu(SPUnitSelector *us) GtkWidget *i = gtk_menu_item_new_with_label( u->abbr ); gtk_object_set_data(GTK_OBJECT(i), "unit", (gpointer) u); - gtk_signal_connect(GTK_OBJECT(i), "activate", GTK_SIGNAL_FUNC(spus_unit_activate), us); + g_signal_connect(G_OBJECT(i), "activate", G_CALLBACK(spus_unit_activate), us); sp_set_font_size_smaller (i); diff --git a/src/knot.cpp b/src/knot.cpp index 28c991fde..638b31007 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -489,8 +489,8 @@ SPKnot *sp_knot_new(SPDesktop *desktop, const gchar *tip) "mode", SP_KNOT_MODE_XOR, NULL); - knot->_event_handler_id = gtk_signal_connect(GTK_OBJECT(knot->item), "event", - GTK_SIGNAL_FUNC(sp_knot_handler), knot); + knot->_event_handler_id = g_signal_connect(G_OBJECT(knot->item), "event", + G_CALLBACK(sp_knot_handler), knot); return knot; } diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 72e5ee63b..a45b8ceaa 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -111,7 +111,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Object Properties...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_properties), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Separator */ @@ -124,21 +124,21 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_widget_set_sensitive(w, FALSE); } else { gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_select_this), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_this), item); } gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Create link */ w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_create_link), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_create_link), item); gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item)); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Set mask */ w = gtk_menu_item_new_with_mnemonic(_("Set Mask")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_mask), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_mask), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); } else { @@ -149,7 +149,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Release mask */ w = gtk_menu_item_new_with_mnemonic(_("Release Mask")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_mask), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_mask), item); if (item && item->mask_ref && item->mask_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); } else { @@ -160,7 +160,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Set Clip */ w = gtk_menu_item_new_with_mnemonic(_("Set _Clip")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_clip), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_clip), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); } else { @@ -171,7 +171,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Release Clip */ w = gtk_menu_item_new_with_mnemonic(_("Release C_lip")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_clip), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_clip), item); if (item && item->clip_ref && item->clip_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); } else { @@ -312,7 +312,7 @@ sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* "Ungroup" */ w = gtk_menu_item_new_with_mnemonic(_("_Ungroup")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_group_ungroup_activate), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_group_ungroup_activate), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(menu), w); } @@ -352,18 +352,18 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Link _Properties...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_properties), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Select item */ w = gtk_menu_item_new_with_mnemonic(_("_Follow Link")); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_follow), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_follow), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Reset transformations */ w = gtk_menu_item_new_with_mnemonic(_("_Remove Link")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_remove), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_remove), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); } @@ -411,13 +411,13 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Image _Properties...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_properties), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_edit), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_edit), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); Inkscape::XML::Node *ir = object->getRepr(); @@ -534,7 +534,7 @@ sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); } @@ -590,21 +590,21 @@ sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Fill and Stroke dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Edit Text dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Text and Font...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_text_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_text_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Spellcheck dialog */ w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g...")); gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_spellcheck_settings), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_spellcheck_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); } diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 12aeddecc..da517ba1a 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -215,12 +215,12 @@ void GuidelinePropertiesDialog::_setup() { _relative_toggle.set_active(_relative_toggle_status); // don't know what this exactly does, but it results in that the dialog closes when entering a value and pressing enter (see LP bug 484187) - gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.getWidget()->gobj()), "activate", - GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); - gtk_signal_connect_object(GTK_OBJECT(_spin_button_y.getWidget()->gobj()), "activate", - GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); - gtk_signal_connect_object(GTK_OBJECT(_spin_angle.getWidget()->gobj()), "activate", - GTK_SIGNAL_FUNC(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_button_x.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_button_y.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_angle.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); // dialog diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index d5ec5deff..69b27d6e4 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -498,8 +498,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) g_signal_connect (G_OBJECT (dtw->zoom_status), "input", G_CALLBACK (sp_dtw_zoom_input), dtw); g_signal_connect (G_OBJECT (dtw->zoom_status), "output", G_CALLBACK (sp_dtw_zoom_output), dtw); gtk_object_set_data (GTK_OBJECT (dtw->zoom_status), "dtw", dtw->canvas); - gtk_signal_connect (GTK_OBJECT (dtw->zoom_status), "focus-in-event", GTK_SIGNAL_FUNC (spinbutton_focus_in), dtw->zoom_status); - gtk_signal_connect (GTK_OBJECT (dtw->zoom_status), "key-press-event", GTK_SIGNAL_FUNC (spinbutton_keypress), dtw->zoom_status); + g_signal_connect (G_OBJECT (dtw->zoom_status), "focus-in-event", G_CALLBACK (spinbutton_focus_in), dtw->zoom_status); + g_signal_connect (G_OBJECT (dtw->zoom_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->zoom_status); dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "value_changed", G_CALLBACK (sp_dtw_zoom_value_changed), dtw); dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); @@ -599,7 +599,7 @@ sp_desktop_widget_destroy (GtkObject *object) } g_signal_handlers_disconnect_by_func(G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK(sp_dtw_zoom_input), dtw); g_signal_handlers_disconnect_by_func(G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK(sp_dtw_zoom_output), dtw); - gtk_signal_disconnect_by_data (GTK_OBJECT (dtw->zoom_status), dtw->zoom_status); + g_signal_handlers_disconnect_matched (G_OBJECT (dtw->zoom_status), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dtw->zoom_status); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index efeaa980c..f493c393a 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -130,12 +130,13 @@ static void sp_font_selector_class_init(SPFontSelectorClass *c) fs_parent_class = (GtkHBoxClass* )gtk_type_class(GTK_TYPE_HBOX); - fs_signals[FONT_SET] = gtk_signal_new ("font_set", - GTK_RUN_FIRST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPFontSelectorClass, font_set), + fs_signals[FONT_SET] = g_signal_new ("font_set", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SPFontSelectorClass, font_set), + NULL, NULL, gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, + G_TYPE_NONE, 1, GTK_TYPE_POINTER); object_class->destroy = sp_font_selector_destroy; @@ -388,7 +389,7 @@ static void sp_font_selector_emit_set (SPFontSelector *fsel) fsel->font->Unref(); } fsel->font = font; - gtk_signal_emit(GTK_OBJECT(fsel), fs_signals[FONT_SET], fsel->font); + g_signal_emit(G_OBJECT(fsel), fs_signals[FONT_SET], 0, fsel->font); } fsel->fontsize_dirty = false; if (font) { diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 3f07e09c8..a3110ed5b 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -85,30 +85,34 @@ sp_gradient_selector_class_init (SPGradientSelectorClass *klass) parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX); - signals[GRABBED] = gtk_signal_new ("grabbed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPGradientSelectorClass, grabbed), + signals[GRABBED] = g_signal_new ("grabbed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPGradientSelectorClass, grabbed), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - signals[DRAGGED] = gtk_signal_new ("dragged", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPGradientSelectorClass, dragged), + G_TYPE_NONE, 0); + signals[DRAGGED] = g_signal_new ("dragged", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPGradientSelectorClass, dragged), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - signals[RELEASED] = gtk_signal_new ("released", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPGradientSelectorClass, released), + G_TYPE_NONE, 0); + signals[RELEASED] = g_signal_new ("released", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPGradientSelectorClass, released), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - signals[CHANGED] = gtk_signal_new ("changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPGradientSelectorClass, changed), + G_TYPE_NONE, 0); + signals[CHANGED] = g_signal_new ("changed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPGradientSelectorClass, changed), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); + G_TYPE_NONE, 0); object_class->destroy = sp_gradient_selector_destroy; } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 10e1fb95a..9186044de 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -485,7 +485,7 @@ GtkWidget * gr_change_widget(SPDesktop *desktop) gtk_widget_set_tooltip_text(b, _("Edit the stops of the gradient")); gtk_widget_show(b); gtk_container_add(GTK_CONTAINER(hb), b); - gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(gr_edit), widget); + g_signal_connect(G_OBJECT(b), "clicked", G_CALLBACK(gr_edit), widget); gtk_box_pack_start (GTK_BOX(buttons), hb, FALSE, FALSE, 0); } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 9aa414ab6..bc29bc974 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -104,13 +104,14 @@ static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass parent_class = static_cast<GtkVBoxClass*>(gtk_type_class(GTK_TYPE_VBOX)); - signals[VECTOR_SET] = gtk_signal_new( "vector_set", - GTK_RUN_LAST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPGradientVectorSelectorClass, vector_set), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); + signals[VECTOR_SET] = g_signal_new( "vector_set", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(SPGradientVectorSelectorClass, vector_set), + NULL, NULL, + gtk_marshal_NONE__POINTER, + G_TYPE_NONE, 1, + GTK_TYPE_POINTER); object_class->destroy = sp_gradient_vector_selector_destroy; } @@ -793,7 +794,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s GtkWidget *mnu = gtk_option_menu_new(); /* Create new menu widget */ update_stop_list(GTK_WIDGET(mnu), gradient, NULL); - gtk_signal_connect(GTK_OBJECT(mnu), "changed", GTK_SIGNAL_FUNC(sp_grad_edit_select), vb); + g_signal_connect(G_OBJECT(mnu), "changed", G_CALLBACK(sp_grad_edit_select), vb); gtk_widget_show(mnu); gtk_object_set_data(GTK_OBJECT(vb), "stopmenu", mnu); gtk_box_pack_start(GTK_BOX(vb), mnu, FALSE, FALSE, 0); @@ -805,12 +806,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_widget_show(b); gtk_container_add(GTK_CONTAINER(hb), b); gtk_widget_set_tooltip_text(b, _("Add another control stop to gradient")); - gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(sp_grd_ed_add_stop), vb); + g_signal_connect(G_OBJECT(b), "clicked", G_CALLBACK(sp_grd_ed_add_stop), vb); b = gtk_button_new_with_label(_("Delete stop")); gtk_widget_show(b); gtk_container_add(GTK_CONTAINER(hb), b); gtk_widget_set_tooltip_text(b, _("Delete current control stop from gradient")); - gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(sp_grd_ed_del_stop), vb); + g_signal_connect(G_OBJECT(b), "clicked", G_CALLBACK(sp_grd_ed_del_stop), vb); gtk_widget_show(hb); gtk_box_pack_start(GTK_BOX(vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); @@ -857,10 +858,10 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s /* Signals */ - gtk_signal_connect(GTK_OBJECT(Offset_adj), "value_changed", - GTK_SIGNAL_FUNC(offadjustmentChanged), vb); + g_signal_connect(G_OBJECT(Offset_adj), "value_changed", + G_CALLBACK(offadjustmentChanged), vb); - // gtk_signal_connect(GTK_OBJECT(slider), "changed", GTK_SIGNAL_FUNC(offsliderChanged), vb); + // g_signal_connect(G_OBJECT(slider), "changed", G_CALLBACK(offsliderChanged), vb); gtk_widget_show(hb); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, PAD); @@ -924,9 +925,9 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) wd.win = dlg; wd.stop = 0; g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_transientize_callback), &wd); - gtk_signal_connect(GTK_OBJECT(dlg), "event", GTK_SIGNAL_FUNC(sp_dialog_event_handler), dlg); - gtk_signal_connect(GTK_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg); - gtk_signal_connect(GTK_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); + g_signal_connect(G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg); + g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg); + g_signal_connect(G_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(sp_dialog_hide), dlg ); g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(sp_dialog_unhide), dlg ); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 631675ede..642837e61 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -164,42 +164,48 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) parent_class = (GtkVBoxClass*)gtk_type_class(GTK_TYPE_VBOX); - psel_signals[MODE_CHANGED] = gtk_signal_new("mode_changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPPaintSelectorClass, mode_changed), + psel_signals[MODE_CHANGED] = g_signal_new("mode_changed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPPaintSelectorClass, mode_changed), + NULL, NULL, gtk_marshal_NONE__UINT, - GTK_TYPE_NONE, 1, GTK_TYPE_UINT); - psel_signals[GRABBED] = gtk_signal_new("grabbed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPPaintSelectorClass, grabbed), + G_TYPE_NONE, 1, GTK_TYPE_UINT); + psel_signals[GRABBED] = g_signal_new("grabbed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPPaintSelectorClass, grabbed), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - psel_signals[DRAGGED] = gtk_signal_new("dragged", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPPaintSelectorClass, dragged), + G_TYPE_NONE, 0); + psel_signals[DRAGGED] = g_signal_new("dragged", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPPaintSelectorClass, dragged), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - psel_signals[RELEASED] = gtk_signal_new("released", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPPaintSelectorClass, released), + G_TYPE_NONE, 0); + psel_signals[RELEASED] = g_signal_new("released", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPPaintSelectorClass, released), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - psel_signals[CHANGED] = gtk_signal_new("changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPPaintSelectorClass, changed), + G_TYPE_NONE, 0); + psel_signals[CHANGED] = g_signal_new("changed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPPaintSelectorClass, changed), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - psel_signals[FILLRULE_CHANGED] = gtk_signal_new("fillrule_changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPPaintSelectorClass, fillrule_changed), + G_TYPE_NONE, 0); + psel_signals[FILLRULE_CHANGED] = g_signal_new("fillrule_changed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPPaintSelectorClass, fillrule_changed), + NULL, NULL, gtk_marshal_NONE__UINT, - GTK_TYPE_NONE, 1, GTK_TYPE_UINT); + G_TYPE_NONE, 1, GTK_TYPE_UINT); object_class->destroy = sp_paint_selector_destroy; } @@ -249,7 +255,7 @@ sp_paint_selector_init(SPPaintSelector *psel) w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_EVEN_ODD); gtk_container_add(GTK_CONTAINER(psel->evenodd), w); gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->evenodd, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(psel->evenodd), "toggled", GTK_SIGNAL_FUNC(sp_paint_selector_fillrule_toggled), psel); + g_signal_connect(G_OBJECT(psel->evenodd), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel); psel->nonzero = gtk_radio_button_new(gtk_radio_button_group(GTK_RADIO_BUTTON(psel->evenodd))); gtk_button_set_relief(GTK_BUTTON(psel->nonzero), GTK_RELIEF_NONE); @@ -260,7 +266,7 @@ sp_paint_selector_init(SPPaintSelector *psel) w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_NONZERO); gtk_container_add(GTK_CONTAINER(psel->nonzero), w); gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->nonzero, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(psel->nonzero), "toggled", GTK_SIGNAL_FUNC(sp_paint_selector_fillrule_toggled), psel); + g_signal_connect(G_OBJECT(psel->nonzero), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel); } /* Frame */ @@ -308,7 +314,7 @@ static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gtk_container_add(GTK_CONTAINER(b), w); gtk_box_pack_start(GTK_BOX(psel->style), b, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(b), "toggled", GTK_SIGNAL_FUNC(sp_paint_selector_style_button_toggled), psel); + g_signal_connect(G_OBJECT(b), "toggled", G_CALLBACK(sp_paint_selector_style_button_toggled), psel); return b; } @@ -326,7 +332,7 @@ sp_paint_selector_fillrule_toggled(GtkToggleButton *tb, SPPaintSelector *psel) { if (!psel->update && gtk_toggle_button_get_active(tb)) { SPPaintSelector::FillRule fr = static_cast<SPPaintSelector::FillRule>(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(tb), "mode"))); - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[FILLRULE_CHANGED], fr); + g_signal_emit(G_OBJECT(psel), psel_signals[FILLRULE_CHANGED], 0, fr); } } @@ -397,7 +403,7 @@ void SPPaintSelector::setMode(Mode mode) break; } this->mode = mode; - gtk_signal_emit(GTK_OBJECT(this), psel_signals[MODE_CHANGED], this->mode); + g_signal_emit(G_OBJECT(this), psel_signals[MODE_CHANGED], 0, this->mode); update = FALSE; } } @@ -610,17 +616,17 @@ sp_paint_selector_set_mode_none(SPPaintSelector *psel) static void sp_paint_selector_color_grabbed(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[GRABBED]); + g_signal_emit(G_OBJECT(psel), psel_signals[GRABBED], 0); } static void sp_paint_selector_color_dragged(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[DRAGGED]); + g_signal_emit(G_OBJECT(psel), psel_signals[DRAGGED], 0); } static void sp_paint_selector_color_released(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[RELEASED]); + g_signal_emit(G_OBJECT(psel), psel_signals[RELEASED], 0); } static void @@ -628,7 +634,7 @@ sp_paint_selector_color_changed(SPColorSelector *csel, SPPaintSelector *psel) { csel->base->getColorAlpha( psel->color, psel->alpha ); - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[CHANGED]); + g_signal_emit(G_OBJECT(psel), psel_signals[CHANGED], 0); } static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelector::Mode /*mode*/) @@ -654,10 +660,10 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec gtk_widget_show(csel); gtk_object_set_data(GTK_OBJECT(vb), "color-selector", csel); gtk_box_pack_start(GTK_BOX(vb), csel, TRUE, TRUE, 0); - gtk_signal_connect(GTK_OBJECT(csel), "grabbed", GTK_SIGNAL_FUNC(sp_paint_selector_color_grabbed), psel); - gtk_signal_connect(GTK_OBJECT(csel), "dragged", GTK_SIGNAL_FUNC(sp_paint_selector_color_dragged), psel); - gtk_signal_connect(GTK_OBJECT(csel), "released", GTK_SIGNAL_FUNC(sp_paint_selector_color_released), psel); - gtk_signal_connect(GTK_OBJECT(csel), "changed", GTK_SIGNAL_FUNC(sp_paint_selector_color_changed), psel); + g_signal_connect(G_OBJECT(csel), "grabbed", G_CALLBACK(sp_paint_selector_color_grabbed), psel); + g_signal_connect(G_OBJECT(csel), "dragged", G_CALLBACK(sp_paint_selector_color_dragged), psel); + g_signal_connect(G_OBJECT(csel), "released", G_CALLBACK(sp_paint_selector_color_released), psel); + g_signal_connect(G_OBJECT(csel), "changed", G_CALLBACK(sp_paint_selector_color_changed), psel); /* Pack everything to frame */ gtk_container_add(GTK_CONTAINER(psel->frame), vb); psel->selector = vb; @@ -677,22 +683,22 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec static void sp_paint_selector_gradient_grabbed(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[GRABBED]); + g_signal_emit(G_OBJECT(psel), psel_signals[GRABBED], 0); } static void sp_paint_selector_gradient_dragged(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[DRAGGED]); + g_signal_emit(G_OBJECT(psel), psel_signals[DRAGGED], 0); } static void sp_paint_selector_gradient_released(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[RELEASED]); + g_signal_emit(G_OBJECT(psel), psel_signals[RELEASED], 0); } static void sp_paint_selector_gradient_changed(SPColorSelector * /*csel*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[CHANGED]); + g_signal_emit(G_OBJECT(psel), psel_signals[CHANGED], 0); } static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSelector::Mode mode) @@ -716,10 +722,10 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe /* Create new gradient selector */ gsel = sp_gradient_selector_new(); gtk_widget_show(gsel); - gtk_signal_connect(GTK_OBJECT(gsel), "grabbed", GTK_SIGNAL_FUNC(sp_paint_selector_gradient_grabbed), psel); - gtk_signal_connect(GTK_OBJECT(gsel), "dragged", GTK_SIGNAL_FUNC(sp_paint_selector_gradient_dragged), psel); - gtk_signal_connect(GTK_OBJECT(gsel), "released", GTK_SIGNAL_FUNC(sp_paint_selector_gradient_released), psel); - gtk_signal_connect(GTK_OBJECT(gsel), "changed", GTK_SIGNAL_FUNC(sp_paint_selector_gradient_changed), psel); + g_signal_connect(G_OBJECT(gsel), "grabbed", G_CALLBACK(sp_paint_selector_gradient_grabbed), psel); + g_signal_connect(G_OBJECT(gsel), "dragged", G_CALLBACK(sp_paint_selector_gradient_dragged), psel); + g_signal_connect(G_OBJECT(gsel), "released", G_CALLBACK(sp_paint_selector_gradient_released), psel); + g_signal_connect(G_OBJECT(gsel), "changed", G_CALLBACK(sp_paint_selector_gradient_changed), psel); /* Pack everything to frame */ gtk_container_add(GTK_CONTAINER(psel->frame), gsel); psel->selector = gsel; @@ -760,7 +766,7 @@ static void sp_psel_pattern_destroy(GtkWidget *widget, SPPaintSelector * /*psel* static void sp_psel_pattern_change(GtkWidget * /*widget*/, SPPaintSelector *psel) { - gtk_signal_emit(GTK_OBJECT(psel), psel_signals[CHANGED]); + g_signal_emit(G_OBJECT(psel), psel_signals[CHANGED], 0); } @@ -991,8 +997,8 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel GtkWidget *mnu = gtk_option_menu_new(); ink_pattern_menu(mnu); - gtk_signal_connect(GTK_OBJECT(mnu), "changed", GTK_SIGNAL_FUNC(sp_psel_pattern_change), psel); - gtk_signal_connect(GTK_OBJECT(mnu), "destroy", GTK_SIGNAL_FUNC(sp_psel_pattern_destroy), psel); + g_signal_connect(G_OBJECT(mnu), "changed", G_CALLBACK(sp_psel_pattern_change), psel); + g_signal_connect(G_OBJECT(mnu), "destroy", G_CALLBACK(sp_psel_pattern_destroy), psel); gtk_object_set_data(GTK_OBJECT(psel), "patternmenu", mnu); g_object_ref( G_OBJECT(mnu)); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 108fae1ef..7012badf8 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -295,7 +295,7 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name, g_object_set( act, "short_label", Q_(shortLabel), NULL ); } - gtk_signal_connect( GTK_OBJECT(adj), "value_changed", GTK_SIGNAL_FUNC(sp_object_layout_any_value_changed), spw ); + g_signal_connect( G_OBJECT(adj), "value_changed", G_CALLBACK(sp_object_layout_any_value_changed), spw ); if ( focusTarget ) { ege_adjustment_action_set_focuswidget( act, focusTarget ); } @@ -398,7 +398,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), verb->get_image(), size ); act = GTK_ACTION(inky); - g_signal_connect( G_OBJECT(inky), "activate", GTK_SIGNAL_FUNC(trigger_sp_action), targetAction ); + g_signal_connect( G_OBJECT(inky), "activate", G_CALLBACK(trigger_sp_action), targetAction ); Inkscape::queueIconPrerender( verb->get_image(), size ); @@ -518,8 +518,8 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_object_set_data( G_OBJECT(spw), "contextActions", contextActions ); // Force update when selection changes. - gtk_signal_connect(GTK_OBJECT(spw), "modify_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_modify_selection), desktop); - gtk_signal_connect(GTK_OBJECT(spw), "change_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_change_selection), desktop); + g_signal_connect(G_OBJECT(spw), "modify_selection", G_CALLBACK(sp_selection_layout_widget_modify_selection), desktop); + g_signal_connect(G_OBJECT(spw), "change_selection", G_CALLBACK(sp_selection_layout_widget_change_selection), desktop); // Update now. sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? sp_desktop_selection(SP_ACTIVE_DESKTOP) : NULL); diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 0bae54655..3a2c7fbed 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -358,11 +358,11 @@ void ColorICCSelector::init() /* Signals */ - gtk_signal_connect( GTK_OBJECT( _fooAdj[i] ), "value_changed", GTK_SIGNAL_FUNC( _adjustmentChanged ), _csel ); + g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); - gtk_signal_connect( GTK_OBJECT( _fooSlider[i] ), "grabbed", GTK_SIGNAL_FUNC( _sliderGrabbed ), _csel ); - gtk_signal_connect( GTK_OBJECT( _fooSlider[i] ), "released", GTK_SIGNAL_FUNC( _sliderReleased ), _csel ); - gtk_signal_connect( GTK_OBJECT( _fooSlider[i] ), "changed", GTK_SIGNAL_FUNC( _sliderChanged ), _csel ); + g_signal_connect( G_OBJECT( _fooSlider[i] ), "grabbed", G_CALLBACK( _sliderGrabbed ), _csel ); + g_signal_connect( G_OBJECT( _fooSlider[i] ), "released", G_CALLBACK( _sliderReleased ), _csel ); + g_signal_connect( G_OBJECT( _fooSlider[i] ), "changed", G_CALLBACK( _sliderChanged ), _csel ); row++; } @@ -397,15 +397,15 @@ void ColorICCSelector::init() gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); /* Signals */ - gtk_signal_connect (GTK_OBJECT (_adj), "value_changed", - GTK_SIGNAL_FUNC (_adjustmentChanged), _csel); - - gtk_signal_connect (GTK_OBJECT (_slider), "grabbed", - GTK_SIGNAL_FUNC (_sliderGrabbed), _csel); - gtk_signal_connect (GTK_OBJECT (_slider), "released", - GTK_SIGNAL_FUNC (_sliderReleased), _csel); - gtk_signal_connect (GTK_OBJECT (_slider), "changed", - GTK_SIGNAL_FUNC (_sliderChanged), _csel); + g_signal_connect (G_OBJECT (_adj), "value_changed", + G_CALLBACK (_adjustmentChanged), _csel); + + g_signal_connect (G_OBJECT (_slider), "grabbed", + G_CALLBACK (_sliderGrabbed), _csel); + g_signal_connect (G_OBJECT (_slider), "released", + G_CALLBACK (_sliderReleased), _csel); + g_signal_connect (G_OBJECT (_slider), "changed", + G_CALLBACK (_sliderChanged), _csel); } static void @@ -700,7 +700,7 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) SPColor(1.0, 1.0, 1.0).toRGBA32(0xff) ); /* _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); - gtk_signal_connect( GTK_OBJECT( _fooAdj[i] ), "value_changed", GTK_SIGNAL_FUNC( _adjustmentChanged ), _csel ); + g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_fooSlider[i]), _fooAdj[i] ); gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_fooBtn[i]), _fooAdj[i] ); diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 4c2c03e8a..06e990dfb 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -318,7 +318,7 @@ void ColorNotebook::init() // but first fix it so it remembers its settings in prefs and does not take that much space (entire vertical column!) //gtk_table_attach (GTK_TABLE (table), align, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); - gtk_signal_connect_object(GTK_OBJECT(_btn), "event", GTK_SIGNAL_FUNC (sp_color_notebook_menu_handler), GTK_OBJECT(_csel)); + g_signal_connect_swapped(G_OBJECT(_btn), "event", G_CALLBACK (sp_color_notebook_menu_handler), G_OBJECT(_csel)); if ( !found ) { gtk_widget_set_sensitive (_btn, FALSE); @@ -383,10 +383,10 @@ void ColorNotebook::init() gtk_table_attach (GTK_TABLE (table), _p, 2, 3, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); #endif - _switchId = g_signal_connect(GTK_OBJECT (_book), "switch-page", - GTK_SIGNAL_FUNC (sp_color_notebook_switch_page), SP_COLOR_NOTEBOOK(_csel)); + _switchId = g_signal_connect(G_OBJECT (_book), "switch-page", + G_CALLBACK (sp_color_notebook_switch_page), SP_COLOR_NOTEBOOK(_csel)); - _entryId = gtk_signal_connect (GTK_OBJECT (_rgbae), "changed", GTK_SIGNAL_FUNC (ColorNotebook::_rgbaEntryChangedHook), _csel); + _entryId = g_signal_connect (G_OBJECT (_rgbae), "changed", G_CALLBACK (ColorNotebook::_rgbaEntryChangedHook), _csel); } static void @@ -648,10 +648,10 @@ GtkWidget* ColorNotebook::addPage(GType page_type, guint submode) // g_message( "Hitting up for tab for '%s'", str ); tab_label = gtk_label_new(_(str)); gtk_notebook_append_page( GTK_NOTEBOOK (_book), page, tab_label ); - gtk_signal_connect (GTK_OBJECT (page), "grabbed", GTK_SIGNAL_FUNC (_entryGrabbed), _csel); - gtk_signal_connect (GTK_OBJECT (page), "dragged", GTK_SIGNAL_FUNC (_entryDragged), _csel); - gtk_signal_connect (GTK_OBJECT (page), "released", GTK_SIGNAL_FUNC (_entryReleased), _csel); - gtk_signal_connect (GTK_OBJECT (page), "changed", GTK_SIGNAL_FUNC (_entryChanged), _csel); + g_signal_connect (G_OBJECT (page), "grabbed", G_CALLBACK (_entryGrabbed), _csel); + g_signal_connect (G_OBJECT (page), "dragged", G_CALLBACK (_entryDragged), _csel); + g_signal_connect (G_OBJECT (page), "released", G_CALLBACK (_entryReleased), _csel); + g_signal_connect (G_OBJECT (page), "changed", G_CALLBACK (_entryChanged), _csel); } return page; diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 001b54752..25162dead 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -168,14 +168,14 @@ void ColorScales::init() /* Attach channel value to adjustment */ gtk_object_set_data (GTK_OBJECT (_a[i]), "channel", GINT_TO_POINTER (i)); /* Signals */ - gtk_signal_connect (GTK_OBJECT (_a[i]), "value_changed", - GTK_SIGNAL_FUNC (_adjustmentAnyChanged), _csel); - gtk_signal_connect (GTK_OBJECT (_s[i]), "grabbed", - GTK_SIGNAL_FUNC (_sliderAnyGrabbed), _csel); - gtk_signal_connect (GTK_OBJECT (_s[i]), "released", - GTK_SIGNAL_FUNC (_sliderAnyReleased), _csel); - gtk_signal_connect (GTK_OBJECT (_s[i]), "changed", - GTK_SIGNAL_FUNC (_sliderAnyChanged), _csel); + g_signal_connect (G_OBJECT (_a[i]), "value_changed", + G_CALLBACK (_adjustmentAnyChanged), _csel); + g_signal_connect (G_OBJECT (_s[i]), "grabbed", + G_CALLBACK (_sliderAnyGrabbed), _csel); + g_signal_connect (G_OBJECT (_s[i]), "released", + G_CALLBACK (_sliderAnyReleased), _csel); + g_signal_connect (G_OBJECT (_s[i]), "changed", + G_CALLBACK (_sliderAnyChanged), _csel); } /* Initial mode is none, so it works */ diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 794cbdb42..bf3564d2e 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -70,28 +70,32 @@ void sp_color_selector_class_init( SPColorSelectorClass *klass ) parent_class = GTK_VBOX_CLASS( gtk_type_class(GTK_TYPE_VBOX) ); - csel_signals[GRABBED] = gtk_signal_new( "grabbed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPColorSelectorClass, grabbed), + csel_signals[GRABBED] = g_signal_new( "grabbed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPColorSelectorClass, grabbed), + NULL, NULL, gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0 ); - csel_signals[DRAGGED] = gtk_signal_new( "dragged", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPColorSelectorClass, dragged), + csel_signals[DRAGGED] = g_signal_new( "dragged", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPColorSelectorClass, dragged), + NULL, NULL, gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0 ); - csel_signals[RELEASED] = gtk_signal_new( "released", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPColorSelectorClass, released), + csel_signals[RELEASED] = g_signal_new( "released", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPColorSelectorClass, released), + NULL, NULL, gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0 ); - csel_signals[CHANGED] = gtk_signal_new( "changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(SPColorSelectorClass, changed), + csel_signals[CHANGED] = g_signal_new( "changed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET(SPColorSelectorClass, changed), + NULL, NULL, gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0 ); @@ -111,7 +115,7 @@ void sp_color_selector_init( SPColorSelector *csel ) { csel->base->init(); } -/* gtk_signal_connect(GTK_OBJECT(csel->rgbae), "changed", GTK_SIGNAL_FUNC(sp_color_selector_rgba_entry_changed), csel); */ +/* g_signal_connect(G_OBJECT(csel->rgbae), "changed", G_CALLBACK(sp_color_selector_rgba_entry_changed), csel); */ } void sp_color_selector_destroy( GtkObject *object ) @@ -230,7 +234,7 @@ void ColorSelector::setColorAlpha( const SPColor& color, gfloat alpha, bool emit _colorChanged(); if (emit) { - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[CHANGED]); + g_signal_emit(G_OBJECT(_csel), csel_signals[CHANGED], 0); } #ifdef DUMP_CHANGE_INFO } else { @@ -248,7 +252,7 @@ void ColorSelector::_grabbed() "GRABBED", FOO_NAME(_csel)); #endif - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[GRABBED]); + g_signal_emit(G_OBJECT(_csel), csel_signals[GRABBED], 0); } void ColorSelector::_released() @@ -259,8 +263,8 @@ void ColorSelector::_released() "RELEASED", FOO_NAME(_csel)); #endif - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[RELEASED]); - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[CHANGED]); + g_signal_emit(G_OBJECT(_csel), csel_signals[RELEASED], 0); + g_signal_emit(G_OBJECT(_csel), csel_signals[CHANGED], 0); } // Called from subclasses to update color and broadcast if needed @@ -288,7 +292,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole "GRABBED", color.toRGBA32( alpha ), (color.icc?color.icc->colorProfile.c_str():"<null>"), FOO_NAME(_csel)); #endif - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[GRABBED]); + g_signal_emit(G_OBJECT(_csel), csel_signals[GRABBED], 0); } else if ( released ) { @@ -297,7 +301,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole "RELEASED", color.toRGBA32( alpha ), (color.icc?color.icc->colorProfile.c_str():"<null>"), FOO_NAME(_csel)); #endif - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[RELEASED]); + g_signal_emit(G_OBJECT(_csel), csel_signals[RELEASED], 0); } if ( colorDifferent || released ) @@ -307,7 +311,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole (_held ? "CHANGED" : "DRAGGED" ), color.toRGBA32( alpha ), (color.icc?color.icc->colorProfile.c_str():"<null>"), FOO_NAME(_csel)); #endif - gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[_held ? CHANGED : DRAGGED]); + g_signal_emit(G_OBJECT(_csel), csel_signals[_held ? CHANGED : DRAGGED], 0); } } diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 2d0789ec4..efea69590 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -87,30 +87,34 @@ sp_color_slider_class_init (SPColorSliderClass *klass) parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET); - slider_signals[GRABBED] = gtk_signal_new ("grabbed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSliderClass, grabbed), + slider_signals[GRABBED] = g_signal_new ("grabbed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPColorSliderClass, grabbed), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - slider_signals[DRAGGED] = gtk_signal_new ("dragged", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSliderClass, dragged), + G_TYPE_NONE, 0); + slider_signals[DRAGGED] = g_signal_new ("dragged", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPColorSliderClass, dragged), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - slider_signals[RELEASED] = gtk_signal_new ("released", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSliderClass, released), + G_TYPE_NONE, 0); + slider_signals[RELEASED] = g_signal_new ("released", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPColorSliderClass, released), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - slider_signals[CHANGED] = gtk_signal_new ("changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSliderClass, changed), + G_TYPE_NONE, 0); + slider_signals[CHANGED] = g_signal_new ("changed", + G_TYPE_FROM_CLASS(object_class), + (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), + G_STRUCT_OFFSET (SPColorSliderClass, changed), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); + G_TYPE_NONE, 0); object_class->destroy = sp_color_slider_destroy; @@ -168,7 +172,7 @@ sp_color_slider_destroy (GtkObject *object) slider = SP_COLOR_SLIDER (object); if (slider->adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (slider->adjustment), slider); + g_signal_handlers_disconnect_matched (G_OBJECT (slider->adjustment), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, slider); gtk_object_unref (GTK_OBJECT (slider->adjustment)); slider->adjustment = NULL; } @@ -265,11 +269,11 @@ sp_color_slider_button_press (GtkWidget *widget, GdkEventButton *event) gint cx, cw; cx = widget->style->xthickness; cw = widget->allocation.width - 2 * cx; - gtk_signal_emit (GTK_OBJECT (slider), slider_signals[GRABBED]); + g_signal_emit (G_OBJECT (slider), slider_signals[GRABBED], 0); slider->dragging = TRUE; slider->oldvalue = slider->value; ColorScales::setScaled( slider->adjustment, CLAMP ((gfloat) (event->x - cx) / cw, 0.0, 1.0) ); - gtk_signal_emit (GTK_OBJECT (slider), slider_signals[DRAGGED]); + g_signal_emit (G_OBJECT (slider), slider_signals[DRAGGED], 0); gdk_pointer_grab (widget->window, FALSE, (GdkEventMask)(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), @@ -289,8 +293,8 @@ sp_color_slider_button_release (GtkWidget *widget, GdkEventButton *event) if (event->button == 1) { gdk_pointer_ungrab (event->time); slider->dragging = FALSE; - gtk_signal_emit (GTK_OBJECT (slider), slider_signals[RELEASED]); - if (slider->value != slider->oldvalue) gtk_signal_emit (GTK_OBJECT (slider), slider_signals[CHANGED]); + g_signal_emit (G_OBJECT (slider), slider_signals[RELEASED], 0); + if (slider->value != slider->oldvalue) g_signal_emit (G_OBJECT (slider), slider_signals[CHANGED], 0); } return FALSE; @@ -308,7 +312,7 @@ sp_color_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event) cx = widget->style->xthickness; cw = widget->allocation.width - 2 * cx; ColorScales::setScaled( slider->adjustment, CLAMP ((gfloat) (event->x - cx) / cw, 0.0, 1.0) ); - gtk_signal_emit (GTK_OBJECT (slider), slider_signals[DRAGGED]); + g_signal_emit (G_OBJECT (slider), slider_signals[DRAGGED], 0); } return FALSE; @@ -340,7 +344,7 @@ void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjust if (slider->adjustment != adjustment) { if (slider->adjustment) { - gtk_signal_disconnect_by_data (GTK_OBJECT (slider->adjustment), slider); + g_signal_handlers_disconnect_matched (G_OBJECT (slider->adjustment), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, slider); gtk_object_unref (GTK_OBJECT (slider->adjustment)); } @@ -348,10 +352,10 @@ void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjust gtk_object_ref (GTK_OBJECT (adjustment)); gtk_object_sink (GTK_OBJECT (adjustment)); - gtk_signal_connect (GTK_OBJECT (adjustment), "changed", - GTK_SIGNAL_FUNC (sp_color_slider_adjustment_changed), slider); - gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", - GTK_SIGNAL_FUNC (sp_color_slider_adjustment_value_changed), slider); + g_signal_connect (G_OBJECT (adjustment), "changed", + G_CALLBACK (sp_color_slider_adjustment_changed), slider); + g_signal_connect (G_OBJECT (adjustment), "value_changed", + G_CALLBACK (sp_color_slider_adjustment_value_changed), slider); slider->value = ColorScales::getScaled( adjustment ); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 25ba250a7..4bbda79a6 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -196,25 +196,25 @@ void ColorWheelSelector::init() gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); /* Signals */ - gtk_signal_connect (GTK_OBJECT (_adj), "value_changed", - GTK_SIGNAL_FUNC (_adjustmentChanged), _csel); + g_signal_connect (G_OBJECT (_adj), "value_changed", + G_CALLBACK (_adjustmentChanged), _csel); - gtk_signal_connect (GTK_OBJECT (_slider), "grabbed", - GTK_SIGNAL_FUNC (_sliderGrabbed), _csel); - gtk_signal_connect (GTK_OBJECT (_slider), "released", - GTK_SIGNAL_FUNC (_sliderReleased), _csel); - gtk_signal_connect (GTK_OBJECT (_slider), "changed", - GTK_SIGNAL_FUNC (_sliderChanged), _csel); + g_signal_connect (G_OBJECT (_slider), "grabbed", + G_CALLBACK (_sliderGrabbed), _csel); + g_signal_connect (G_OBJECT (_slider), "released", + G_CALLBACK (_sliderReleased), _csel); + g_signal_connect (G_OBJECT (_slider), "changed", + G_CALLBACK (_sliderChanged), _csel); - gtk_signal_connect( GTK_OBJECT(_wheel), "changed", - GTK_SIGNAL_FUNC(_wheelChanged), _csel ); + g_signal_connect( G_OBJECT(_wheel), "changed", + G_CALLBACK (_wheelChanged), _csel ); // GTK does not automatically scale the color wheel, so we have to add that in: - gtk_signal_connect( GTK_OBJECT(_wheel), "size-allocate", - GTK_SIGNAL_FUNC(handleWheelAllocation), _csel ); - gtk_signal_connect( GTK_OBJECT(_wheel), "style-set", - GTK_SIGNAL_FUNC(handleWheelStyleSet), _csel ); + g_signal_connect( G_OBJECT (_wheel), "size-allocate", + G_CALLBACK (handleWheelAllocation), _csel ); + g_signal_connect( G_OBJECT (_wheel), "style-set", + G_CALLBACK (handleWheelStyleSet), _csel ); } static void diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index f694c461c..fd20d8e17 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -78,32 +78,36 @@ sp_widget_class_init (SPWidgetClass *klass) object_class->destroy = sp_widget_destroy; - signals[CONSTRUCT] = gtk_signal_new ("construct", - GTK_RUN_FIRST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPWidgetClass, construct), + signals[CONSTRUCT] = g_signal_new ("construct", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SPWidgetClass, construct), + NULL, NULL, gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - signals[CHANGE_SELECTION] = gtk_signal_new ("change_selection", - GTK_RUN_FIRST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPWidgetClass, change_selection), + G_TYPE_NONE, 0); + signals[CHANGE_SELECTION] = g_signal_new ("change_selection", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SPWidgetClass, change_selection), + NULL, NULL, gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, + G_TYPE_NONE, 1, GTK_TYPE_POINTER); - signals[MODIFY_SELECTION] = gtk_signal_new ("modify_selection", - GTK_RUN_FIRST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPWidgetClass, modify_selection), + signals[MODIFY_SELECTION] = g_signal_new ("modify_selection", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SPWidgetClass, modify_selection), + NULL, NULL, gtk_marshal_NONE__POINTER_UINT, - GTK_TYPE_NONE, 2, + G_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_UINT); - signals[SET_SELECTION] = gtk_signal_new ("set_selection", - GTK_RUN_FIRST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPWidgetClass, set_selection), + signals[SET_SELECTION] = g_signal_new ("set_selection", + G_TYPE_FROM_CLASS(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (SPWidgetClass, set_selection), + NULL, NULL, gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, + G_TYPE_NONE, 1, GTK_TYPE_POINTER); widget_class->show = sp_widget_show; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 7f1548df4..f248e22af 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -885,7 +885,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi act = GTK_ACTION(inky); gtk_action_set_sensitive( act, targetAction->sensitive ); - g_signal_connect( G_OBJECT(inky), "activate", GTK_SIGNAL_FUNC(trigger_sp_action), targetAction ); + g_signal_connect( G_OBJECT(inky), "activate", G_CALLBACK(trigger_sp_action), targetAction ); SPAction*rebound = dynamic_cast<SPAction *>( nr_object_ref( dynamic_cast<NRObject *>(targetAction) ) ); nr_active_object_add_listener( (NRActiveObject *)rebound, (NRObjectEventVector *)&action_event_vector, sizeof(SPActionEventVector), inky ); @@ -1089,7 +1089,7 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name, sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(us), adj ); } - gtk_signal_connect( GTK_OBJECT(adj), "value-changed", GTK_SIGNAL_FUNC(callback), dataKludge ); + g_signal_connect( G_OBJECT(adj), "value-changed", G_CALLBACK(callback), dataKludge ); EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, label, tooltip, 0, climb, digits ); if ( shortLabel ) { -- cgit v1.2.3 From 68519ec20c94cc0a9c00134a5139ed0517a61659 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sun, 12 Jun 2011 23:07:23 -0300 Subject: more improvements in the measurement tool: * select elements crossed by the line segment drawn with the tool * allow user to select font size for the length labels (in the toolbar) * use temporary canvas items (bzr r10284) --- src/measure-context.cpp | 76 +++++++++++++++++++------------------------------ src/widgets/toolbox.cpp | 30 +++++++++++++++++-- 2 files changed, 58 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 2aeb39d5d..6870786f2 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -48,7 +48,7 @@ static gint tolerance = 0; static bool within_tolerance = false; static SPCanvasItem * line = NULL; Geom::Point start_point; -SPCanvasItem *measure_text = NULL; +std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items; GType sp_measure_context_get_type(void) { @@ -157,16 +157,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv line = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL); } - if (!measure_text){ - measure_text = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, start_point, ""); - SP_CANVASTEXT(measure_text)->rgba = 0x7f7f7fff; - sp_canvastext_set_anchor(SP_CANVASTEXT(measure_text), -1, 1);//why? - } - sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point, start_point); - sp_canvastext_set_text (SP_CANVASTEXT(measure_text), ""); sp_canvas_item_show (line); - sp_canvas_item_show (measure_text); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, @@ -195,23 +187,23 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], motion_dt[Geom::X], motion_dt[Geom::Y]); - - //our control line - Geom::PathVector line; + Geom::PathVector lineseg; Geom::Path p; p.start(desktop->dt2doc(start_point)); p.appendNew<Geom::LineSegment>(desktop->dt2doc(motion_dt)); - line.push_back(p); + lineseg.push_back(p); + +//TODO: calculate NPOINTS +//800 seems to be a good value for 800x600 resolution +#define NPOINTS 800 std::vector<Geom::Point> points; double i; -#define NPOINTS 3000 for (i=0; i<NPOINTS; i++){ points.push_back(desktop->d2w(start_point + (i/NPOINTS)*(motion_dt-start_point))); } - double length; -//select elements crossed by line segment: + //select elements crossed by line segment: GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); SPItem* item; GSList *l; @@ -242,16 +234,16 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv Geom::PathVector pathv = curve->get_pathvector(); // Find all intersections of the control-line with this shape - Geom::CrossingSet cs = Geom::crossings(line, pathv); + Geom::CrossingSet cs = Geom::crossings(lineseg, pathv); // Store the results as intersection points unsigned int index = 0; for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); i++) { - if (index >= line.size()) { + if (index >= lineseg.size()) { break; } // Reconstruct and store the points of intersection for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); m++) { - intersections.push_back(line[index].pointAt((*m).ta)); + intersections.push_back(lineseg[index].pointAt((*m).ta)); } index++; } @@ -262,8 +254,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv //sort intersections std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); -//TODO: make these not fade out. unsigned int idx; + for (idx=0; idx<measure_tmp_items.size(); idx++){ + desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); + } + measure_tmp_items.clear(); + for (idx=0;idx<intersections.size(); idx++){ // Display the intersection indicator (i.e. the cross) SPCanvasItem * canvasitem = NULL; @@ -278,44 +274,30 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv NULL ); SP_CTRL(canvasitem)->moveto(desktop->doc2dt(intersections[idx])); - desktop->add_temporary_canvasitem(canvasitem, 100); - } + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvasitem, 0)); + } -//TODO: make these not fade out. Geom::Point previous_point = intersections[0]; for (idx=1; idx < intersections.size(); idx++){ Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; +//TODO: shift label a few pixels in the y coordinate - length = (intersections[idx] - previous_point).length(); char* measure_str = (char*) malloc(sizeof(char)*20); - sprintf(measure_str, "%f", length); - -// sp_canvastext_set_coords (SP_CANVASTEXT(measure_text), desktop->dt2doc(measure_text_pos)); -// sp_canvastext_set_text (SP_CANVASTEXT(measure_text), measure_str); - -// SPCanvasItem * canvasitem = NULL; + sprintf(measure_str, "%.2f", (intersections[idx] - previous_point).length()); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); - desktop->add_temporary_canvasitem(canvas_tooltip, 100); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double fontsize = prefs->getInt("/tools/measure/fontsize"); - free(measure_str); + //TODO: get font size option from toolbar + sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); + free(measure_str); previous_point = intersections[idx]; } -#if 0 - Geom::Point measure_text_pos = (pa + pb)/2; - - length = (pa - pb).length(); - char* measure_str = (char*) malloc(sizeof(char)*20); - sprintf(measure_str, "%f", length); - - sp_canvastext_set_coords (SP_CANVASTEXT(measure_text), desktop->dt2doc(measure_text_pos)); - sp_canvastext_set_text (SP_CANVASTEXT(measure_text), measure_str); - free(measure_str); -#endif - gobble_motion_events(GDK_BUTTON1_MASK); } break; @@ -327,9 +309,11 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv sp_canvas_item_hide(line); } - if (measure_text){ - sp_canvas_item_hide(measure_text); + unsigned int idx; + for (idx=0; idx<measure_tmp_items.size(); idx++){ + desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); } + measure_tmp_items.clear(); if (mc->grabbed) { sp_canvas_item_ungrab(mc->grabbed, event->button.time); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f248e22af..122c014eb 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -366,6 +366,7 @@ static gchar const * ui_descr = " </toolbar>" " <toolbar name='MeasureToolbar'>" + " <toolitem action='MeasureFontSizeAction' />" " </toolbar>" " <toolbar name='StarToolbar'>" @@ -1630,9 +1631,34 @@ static void sp_zoom_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* /*main // no custom GtkAction setup needed } // end of sp_zoom_toolbox_prep() -static void sp_measure_toolbox_prep(SPDesktop * /*desktop*/, GtkActionGroup* /*mainActions*/, GObject* /*holder*/) +static void +sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl) { - // no custom GtkAction setup needed + SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + + if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt(Glib::ustring("/tools/measure/fontsize"), adj->value); + } +} + + +static void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder) +{ + EgeAdjustmentAction* eact = 0; + + /* Font Size */ + { + eact = create_adjustment_action( "MeasureFontSizeAction", + _("Font Size"), _("Font Size:"), + _("The font size to be used in the measurement labels"), + "/tools/measure/fontsize", 0.0, + GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL, + 10, 36, 1.0, 4.0, + 0, 0, 0, + sp_measure_fontsize_value_changed); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + } } // end of sp_measure_toolbox_prep() void ToolboxFactory::setToolboxDesktop(GtkWidget *toolbox, SPDesktop *desktop) -- cgit v1.2.3 From c718dcbf1e9dda3371caab929c428cbd2bebc12b Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 13:07:17 +0000 Subject: ignore ./CMakeLists.txt.user (qtcreator stores settings here) also correction to windows path. (bzr r10286) --- src/extension/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 8a58ae2be..2c3c9ab83 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -216,7 +216,8 @@ set(extension_SRC if(WIN32) list(APPEND extension_SRC - win32.cpp + internal/win32.cpp + internal/win32.h ) endif() -- cgit v1.2.3 From 222476b91dd4f70d8d1f5580435d381b81ce9773 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 13 Jun 2011 01:32:05 -0300 Subject: display angle info in the measurement tool (bzr r10288) --- src/measure-context.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 6870786f2..5560be335 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -193,6 +193,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv p.appendNew<Geom::LineSegment>(desktop->dt2doc(motion_dt)); lineseg.push_back(p); + double deltax = motion_dt[Geom::X] - start_point[Geom::X]; + double deltay = motion_dt[Geom::Y] - start_point[Geom::Y]; + double angle = atan2(deltay, deltax); + //TODO: calculate NPOINTS //800 seems to be a good value for 800x600 resolution #define NPOINTS 800 @@ -278,6 +282,9 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double fontsize = prefs->getInt("/tools/measure/fontsize"); + Geom::Point previous_point = intersections[0]; for (idx=1; idx < intersections.size(); idx++){ Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; @@ -287,10 +294,6 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv sprintf(measure_str, "%.2f", (intersections[idx] - previous_point).length()); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double fontsize = prefs->getInt("/tools/measure/fontsize"); - - //TODO: get font size option from toolbar sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); @@ -298,6 +301,14 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv previous_point = intersections[idx]; } + char* angle_str = (char*) malloc(sizeof(char)*20); + sprintf(angle_str, "%.2f degrees", angle * 180/3.1415 ); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(50,0)), angle_str); + sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); + free(angle_str); + gobble_motion_events(GDK_BUTTON1_MASK); } break; -- cgit v1.2.3 From eceeca65839d5e61234c235d5a6df0e360707862 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 15:24:52 +0000 Subject: cmake: The cmake files were using the inkscape-version.cpp file generated by autoconfigure. now generate our own. Also remove bad include. (bzr r10289) --- src/CMakeLists.txt | 31 +++++++++++++++++++++++++++++-- src/helper/CMakeLists.txt | 1 - 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e7fe3a11..7fa4e86e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,7 +219,6 @@ set(inkscape_SRC ige-mac-menu.c ink-action.cpp ink-comboboxentry-action.cpp - inkscape-version.cpp inkscape.cpp inkscape.rc interface.cpp @@ -491,6 +490,33 @@ if(WIN32) endif() +# ----------------------------------------------------------------------------- +# Generate version file +# ----------------------------------------------------------------------------- + +# a custom target that is always built +add_custom_target( + inkscape_version ALL + DEPENDS ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp) + +# creates inkscape-version.cpp using cmake script +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp + COMMAND ${CMAKE_COMMAND} + -DINKSCAPE_SOURCE_DIR=${CMAKE_SOURCE_DIR} + -DINKSCAPE_BINARY_DIR=${CMAKE_BINARY_DIR} + -P ${CMAKE_SOURCE_DIR}/CMakeScripts/inkscape-version.cmake) + +# buildinfo.h is a generated file +set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp + PROPERTIES GENERATED TRUE) + +list(APPEND inkscape_SRC + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp +) + + # ----------------------------------------------------------------------------- # Load in subdirectories # ----------------------------------------------------------------------------- @@ -536,7 +562,6 @@ set(inkscape_SRC ${inkscape_SRC} ) - # ----------------------------------------------------------------------------- # Setup the executable # ----------------------------------------------------------------------------- @@ -546,6 +571,8 @@ add_inkscape_lib(inkscape_LIB "${inkscape_SRC}") # make executable for INKSCAPE add_executable(inkscape ${main_SRC}) +add_dependencies(inkscape inkscape_version) + target_link_libraries(inkscape # order from automake sp_LIB diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index f1069e986..8137487e2 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -37,7 +37,6 @@ set(helper_SRC pixbuf-ops.h png-write.h recthull.h - sp-marshal.h stlport.h stock-items.h unit-menu.h -- cgit v1.2.3 From 1984c1b1d1d964c3e7033be169995ca57bc0cb2a Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 13 Jun 2011 03:44:14 -0300 Subject: =?UTF-8?q?using=20"=C2=B0"=20instead=20of=20"degrees"=20for=20lab?= =?UTF-8?q?eling=20angles=20in=20the=20measure=20tool=20Also=20adding=20pa?= =?UTF-8?q?rentheses=20to=20the=20angle=20lable=20in=20order=20to=20make?= =?UTF-8?q?=20it=20clearly=20distinguishable=20in=20comparison=20to=20the?= =?UTF-8?q?=20length=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r10291) --- src/measure-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 5560be335..56ffc1ff6 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -302,7 +302,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } char* angle_str = (char*) malloc(sizeof(char)*20); - sprintf(angle_str, "%.2f degrees", angle * 180/3.1415 ); + sprintf(angle_str, "(%.2f °)", angle * 180/3.1415 ); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(50,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); -- cgit v1.2.3 From bfb465bd2809f84f6ebc52cae091d840e8ad8bb2 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 13 Jun 2011 03:53:04 -0300 Subject: using green color instead of parentheses to differentiate the angle label in the measure tool (bzr r10292) --- src/measure-context.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 56ffc1ff6..c8046049e 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -302,9 +302,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } char* angle_str = (char*) malloc(sizeof(char)*20); - sprintf(angle_str, "(%.2f °)", angle * 180/3.1415 ); + sprintf(angle_str, "%.2f °", angle * 180/3.1415 ); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(50,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + sp_canvastext_set_rgba32 (SP_CANVASTEXT(canvas_tooltip), 0x337f33ff, 0xffffffff); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(angle_str); -- cgit v1.2.3 From b7ca7be174c5b81b147d68425f1fa275fa154dd7 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 13 Jun 2011 04:13:27 -0300 Subject: fixing the measure tool cursor to have a crosshair just like all other drawing tools fixes bug #796446 (bzr r10293) --- src/measure-context.cpp | 4 +-- src/pixmaps/cursor-measure.xpm | 58 +++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index c8046049e..371ac3356 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -89,8 +89,8 @@ static void sp_measure_context_init (SPMeasureContext *measure_context) SPEventContext *event_context = SP_EVENT_CONTEXT(measure_context); event_context->cursor_shape = cursor_measure_xpm; - event_context->hot_x = 3; - event_context->hot_y = 5; + event_context->hot_x = 4; + event_context->hot_y = 4; } static void diff --git a/src/pixmaps/cursor-measure.xpm b/src/pixmaps/cursor-measure.xpm index 753bfd14e..2a28579c6 100644 --- a/src/pixmaps/cursor-measure.xpm +++ b/src/pixmaps/cursor-measure.xpm @@ -1,37 +1,37 @@ /* XPM */ -static char const * cursor_measure_xpm[] = { +static char const *cursor_measure_xpm[] = { "32 32 3 1", " c None", ". c #FFFFFF", "+ c #000000", -" .. ", -" .++. ", -" .+..+. ", -" .+....+. ", -".+..+...+. ", -".+.+.....+. ", -" .+.......+. ", -" .+.+.....+. ", -" .+...+...+. ", -" .+.+.....+. ", -" .+.......+. ", -" .+.+.....+. ", -" .+...+...+. ", -" .+.+.....+. ", -" .+.......+. ", -" .+.+.....+. ", -" .+...+.+. ", -" .+.+.+. ", -" .+.+. ", -" .+. ", -" . ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ", +" .+. ", +" .+. .. ", +" ... .++. ", +" .+..+. ", +" .+....+. ", +" .+..+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+...+. ", +" .+.+.....+. ", +" .+.......+. ", +" .+.+.....+. ", +" .+...+.+. ", +" .+.+.+. ", +" .+.+. ", +" .+. ", +" . ", " ", " ", " ", -- cgit v1.2.3 From ab46fa7f924696faa9e4876d685006ed669ae34d Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 18:13:23 +0000 Subject: cmake: - remove hard coded include and libraries. - remove gtk/imagemagic modules (use cmakes). (bzr r10294) --- src/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7fa4e86e8..afb65f955 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -592,16 +592,6 @@ target_link_libraries(inkscape 2geom_LIB ${INKSCAPE_LIBS} - - # system libs - -lgsl # needed - -lgslcblas # needed - -lgtkmm-2.4 - -lgdkmm-2.4 - -lpangomm-1.4 - -lsigc-2.0 - -lMagick++ - -lMagickCore ) # TODO -- cgit v1.2.3 From a36b851b6d1ef714b228474af87e1307be1cdce9 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 13 Jun 2011 05:25:08 -0300 Subject: adding preferences page for Measure Tool with option (enabled by default) to ignore first and last points when calculating/displaying distances (bzr r10295) --- src/measure-context.cpp | 22 +++++++++++++++++----- src/ui/dialog/inkscape-preferences.cpp | 6 ++++++ src/ui/dialog/inkscape-preferences.h | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 371ac3356..a4e81475e 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -213,7 +213,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv GSList *l; int counter=0; std::vector<Geom::Point> intersections; - intersections.push_back(desktop->dt2doc(start_point)); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool ignore_1st_and_last = prefs->getBool("/tools/measure/ignore_1st_and_last", true); + + if (!ignore_1st_and_last){ + intersections.push_back(desktop->dt2doc(start_point)); + } for (l = items; l != NULL; l = l->next){ item = (SPItem*) (l->data); @@ -253,10 +258,15 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } //g_free(repr); } - intersections.push_back(desktop->dt2doc(motion_dt)); + + if (!ignore_1st_and_last){ + intersections.push_back(desktop->dt2doc(motion_dt)); + } //sort intersections - std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); + if (intersections.size()>2){ + std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); + } unsigned int idx; for (idx=0; idx<measure_tmp_items.size(); idx++){ @@ -282,10 +292,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double fontsize = prefs->getInt("/tools/measure/fontsize"); - Geom::Point previous_point = intersections[0]; + Geom::Point previous_point; + if (intersections.size()>0) + previous_point = intersections[0]; + for (idx=1; idx < intersections.size(); idx++){ Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; //TODO: shift label a few pixels in the y coordinate diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 447e50831..b8b86fac1 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -480,6 +480,12 @@ void InkscapePreferences::initPageTools() AddSelcueCheckbox(_page_zoom, "/tools/zoom", true); AddGradientCheckbox(_page_zoom, "/tools/zoom", false); + //Measure + this->AddPage(_page_measure, _("Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); + PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); + cb->init ( _("Ignore first and last points"), "/tools/measure/ignore_1st_and_last", true); + _page_measure.add_line( false, "", *cb, "", _("The beggining and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); + //Shapes Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES); _path_shapes = _page_list.get_model()->get_path(iter_shapes); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 34bf1e87a..9e51fbf0a 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -141,6 +141,7 @@ protected: UI::Widget::DialogPage _page_tweak; UI::Widget::DialogPage _page_spray; UI::Widget::DialogPage _page_zoom; + UI::Widget::DialogPage _page_measure; UI::Widget::DialogPage _page_shapes; UI::Widget::DialogPage _page_pencil; UI::Widget::DialogPage _page_pen; @@ -372,6 +373,7 @@ protected: static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddFirstAndLastCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddDotSizeSpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value); static void AddNewObjectsStyle(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); -- cgit v1.2.3 From 5f20daab880e8b496faf8a00aa3707ba3beb3b1a Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 18:35:43 +0000 Subject: cmake: fix for install target (bzr r10296) --- src/CMakeLists.txt | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afb65f955..d048eaa87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -599,50 +599,3 @@ target_link_libraries(inkscape #add_executable(inkview inkview.cpp) # ... - -# ----------------------------------------------------------------------------- -# Installation -# ----------------------------------------------------------------------------- - -if(UNIX) - # TODO: man, locale, icons - - # message after building. - add_custom_command( - TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files & scripts to ${CMAKE_INSTALL_PREFIX}' - ) - - install( - PROGRAMS inkscape - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - ) - - install( - FILES ${CMAKE_SOURCE_DIR}/inkscape.desktop - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications - ) - - install( - DIRECTORY - ${CMAKE_SOURCE_DIR}/share/clipart - ${CMAKE_SOURCE_DIR}/share/examples - ${CMAKE_SOURCE_DIR}/share/extensions - ${CMAKE_SOURCE_DIR}/share/filters - ${CMAKE_SOURCE_DIR}/share/fonts - ${CMAKE_SOURCE_DIR}/share/gradients - ${CMAKE_SOURCE_DIR}/share/icons - ${CMAKE_SOURCE_DIR}/share/keys - ${CMAKE_SOURCE_DIR}/share/markers - ${CMAKE_SOURCE_DIR}/share/palettes - ${CMAKE_SOURCE_DIR}/share/patterns - ${CMAKE_SOURCE_DIR}/share/screens - ${CMAKE_SOURCE_DIR}/share/templates - ${CMAKE_SOURCE_DIR}/share/tutorials - ${CMAKE_SOURCE_DIR}/share/ui - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/inkscape - ) - -else() - # TODO, WIN32/APPLE -endif() -- cgit v1.2.3 From 4f20cb327f420917d761b0fa41e50cb9d4eb1a19 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 13 Jun 2011 21:59:45 +0000 Subject: cmake: - added option WITH_DBUS (currently uses hard coded paths) - remove duplicate version variable. (bzr r10297) --- src/extension/CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 2c3c9ab83..8a1ba37dc 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -221,5 +221,22 @@ if(WIN32) ) endif() +if(WITH_DBUS) + list(APPEND extension_SRC + dbus/application-interface.cpp + dbus/dbus-init.cpp + dbus/document-interface.cpp + + # ------ + # Header + dbus/application-interface.h + dbus/dbus-init.h + dbus/document-interface.h + dbus/wrapper/inkscape-dbus-wrapper.h + ) + + include_directories(dbus) +endif() + # add_inkscape_lib(extension_LIB "${extension_SRC}") add_inkscape_source("${extension_SRC}") -- cgit v1.2.3 From d8f262a5fba55b24449ffa312bdcda3623e10ac8 Mon Sep 17 00:00:00 2001 From: Josh Andler <scislac@gmail.com> Date: Tue, 14 Jun 2011 10:58:01 -0700 Subject: patch for 771738, 635469, 700298, 705382, 716057 by Gellule (bzr r10301) --- src/libavoid/orthogonal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libavoid/orthogonal.cpp b/src/libavoid/orthogonal.cpp index 4a7b0af2d..e0a30b246 100644 --- a/src/libavoid/orthogonal.cpp +++ b/src/libavoid/orthogonal.cpp @@ -1731,7 +1731,7 @@ static void buildOrthogonalChannelInfo(Router *router, Polygon& displayRoute = (*curr)->displayRoute(); // Determine all line segments that we are interested in shifting. // We don't consider the first or last segment of a path. - for (size_t i = 1; i < displayRoute.size(); ++i) + for (size_t i = 1; i < displayRoute.size()-1; ++i) { if (displayRoute.ps[i - 1][dim] == displayRoute.ps[i][dim]) { -- cgit v1.2.3 From c64a07e4e76524cebf777837cdf78b8e3de9092a Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Tue, 14 Jun 2011 17:28:34 -0300 Subject: toggle units in the measure tool (bzr r10302) --- src/measure-context.cpp | 12 +++++++++--- src/widgets/toolbox.cpp | 21 ++++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index a4e81475e..78bfb1cee 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -11,7 +11,7 @@ #include <gdk/gdkkeysyms.h> - +#include "helper/units.h" #include "macros.h" #include "display/curve.h" #include "sp-shape.h" @@ -292,6 +292,9 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } + SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/measure/unitid", SP_UNIT_PX)); + SPUnit unit = sp_unit_get_by_id(unitid); + double fontsize = prefs->getInt("/tools/measure/fontsize"); Geom::Point previous_point; @@ -302,8 +305,11 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; //TODO: shift label a few pixels in the y coordinate + double lengthval = (intersections[idx] - previous_point).length(); + sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); + char* measure_str = (char*) malloc(sizeof(char)*20); - sprintf(measure_str, "%.2f", (intersections[idx] - previous_point).length()); + sprintf(measure_str, "%.2f %s", lengthval, unit.abbr); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); @@ -315,7 +321,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv char* angle_str = (char*) malloc(sizeof(char)*20); sprintf(angle_str, "%.2f °", angle * 180/3.1415 ); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(50,0)), angle_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); sp_canvastext_set_rgba32 (SP_CANVASTEXT(canvas_tooltip), 0x337f33ff, 0xffffffff); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 122c014eb..30fb753de 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -367,6 +367,7 @@ static gchar const * ui_descr = " <toolbar name='MeasureToolbar'>" " <toolitem action='MeasureFontSizeAction' />" + " <toolitem action='MeasureUnitsAction' />" " </toolbar>" " <toolbar name='StarToolbar'>" @@ -1642,10 +1643,21 @@ sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl) } } +static void measure_unit_changed(GtkAction* /*act*/, GObject* tbl) +{ + UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker")); + SPUnit const *unit = tracker->getActiveUnit(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/tools/measure/unitid", unit->unit_id); +} static void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder) { - EgeAdjustmentAction* eact = 0; + UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); + tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); + g_object_set_data( holder, "tracker", tracker ); + + EgeAdjustmentAction *eact = 0; /* Font Size */ { @@ -1659,6 +1671,13 @@ static void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainAct sp_measure_fontsize_value_changed); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } + + // add the units menu + { + GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units"), _("Units:") ); + g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), (GObject*)holder ); + gtk_action_group_add_action( mainActions, act ); + } } // end of sp_measure_toolbox_prep() void ToolboxFactory::setToolboxDesktop(GtkWidget *toolbox, SPDesktop *desktop) -- cgit v1.2.3 From 14d03386c171fca906cb3e08e713a85c091f94c4 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Tue, 14 Jun 2011 23:30:29 +0200 Subject: shift+ctrl dragging a guideline: fix to snap to angles with original angle as offset, like rotating normal objects (bzr r10303) --- src/desktop-events.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index b7b7529a1..a0ceb77e3 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -17,6 +17,7 @@ #include <map> #include <string> #include <2geom/line.h> +#include <2geom/angle.h> #include <glibmm/i18n.h> #include "desktop.h" @@ -314,16 +315,18 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) case SP_DRAG_ROTATE: { Geom::Point pt = motion_dt - guide->point_on_line; - double angle = std::atan2(pt[Geom::Y], pt[Geom::X]); + Geom::Angle angle(pt); if (event->motion.state & GDK_CONTROL_MASK) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12)); if (snaps) { - double sections = floor(angle * snaps / M_PI + .5); - angle = (M_PI / snaps) * sections; + Geom::Angle orig_angle(guide->normal_to_line); + Geom::Angle snap_angle = angle - orig_angle; + double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); + angle = (M_PI / snaps) * sections + orig_angle.radians0(); } } - sp_guide_set_normal(*guide, Geom::Point(1,0) * Geom::Rotate(angle + M_PI_2), false); + sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), false); break; } case SP_DRAG_MOVE_ORIGIN: @@ -380,16 +383,18 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) case SP_DRAG_ROTATE: { Geom::Point pt = event_dt - guide->point_on_line; - double angle = std::atan2(pt[Geom::Y], pt[Geom::X]); - if (event->motion.state & GDK_CONTROL_MASK) { + Geom::Angle angle(pt); + if (event->motion.state & GDK_CONTROL_MASK) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12)); if (snaps) { - double sections = floor(angle * snaps / M_PI + .5); - angle = (M_PI / snaps) * sections; + Geom::Angle orig_angle(guide->normal_to_line); + Geom::Angle snap_angle = angle - orig_angle; + double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); + angle = (M_PI / snaps) * sections + orig_angle.radians0(); } } - sp_guide_set_normal(*guide, Geom::Point(1,0) * Geom::Rotate(angle + M_PI_2), true); + sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), true); break; } case SP_DRAG_MOVE_ORIGIN: -- cgit v1.2.3 From c8fae874884858fb54c05015c72f6f551591d0f9 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Tue, 14 Jun 2011 22:34:06 +0100 Subject: Remove deprecated glib macro wrappers (bzr r10302.1.1) --- src/arc-context.h | 8 ++++---- src/box3d-context.h | 8 ++++---- src/common-context.h | 8 ++++---- src/display/canvas-arena.h | 8 ++++---- src/display/canvas-bpath.h | 8 ++++---- src/display/canvas-grid.h | 8 ++++---- src/display/canvas-text.h | 4 ++-- src/display/gnome-canvas-acetate.h | 8 ++++---- src/display/guideline.h | 4 ++-- src/display/sodipodi-ctrl.h | 8 ++++---- src/display/sodipodi-ctrlrect.h | 8 ++++---- src/display/sp-canvas-group.h | 4 ++-- src/display/sp-canvas-item.h | 6 +++--- src/display/sp-canvas.h | 4 ++-- src/display/sp-ctrlline.h | 4 ++-- src/display/sp-ctrlpoint.h | 4 ++-- src/display/sp-ctrlquadr.h | 4 ++-- src/draw-context.h | 8 ++++---- src/dropper-context.h | 4 ++-- src/dyna-draw-context.h | 8 ++++---- src/eraser-context.h | 8 ++++---- src/flood-context.h | 8 ++++---- src/gradient-context.h | 8 ++++---- src/helper/unit-menu.h | 8 ++++---- src/inkscape-private.h | 8 ++++---- src/libgdl/gdl-dock-bar.h | 10 +++++----- src/libgdl/gdl-dock-item-grip.h | 10 +++++----- src/libgdl/gdl-dock-item.h | 10 +++++----- src/libgdl/gdl-dock-master.h | 10 +++++----- src/libgdl/gdl-dock-notebook.h | 10 +++++----- src/libgdl/gdl-dock-object.h | 10 +++++----- src/libgdl/gdl-dock-paned.h | 10 +++++----- src/libgdl/gdl-dock-placeholder.h | 10 +++++----- src/libgdl/gdl-dock-tablabel.h | 10 +++++----- src/libgdl/gdl-dock.h | 10 +++++----- src/lpe-tool-context.h | 8 ++++---- src/measure-context.h | 4 ++-- src/rect-context.h | 8 ++++---- src/select-context.h | 8 ++++---- src/sp-pattern.h | 8 ++++---- src/spiral-context.h | 8 ++++---- src/spray-context.h | 8 ++++---- src/star-context.h | 8 ++++---- src/svg-view-widget.h | 8 ++++---- src/text-context.h | 8 ++++---- src/tweak-context.h | 8 ++++---- src/ui/tool/node-tool.h | 8 ++++---- src/ui/view/view-widget.h | 8 ++++---- src/widgets/button.h | 4 ++-- src/widgets/desktop-widget.h | 8 ++++---- src/widgets/font-selector.h | 8 ++++---- src/widgets/gradient-image.h | 8 ++++---- src/widgets/gradient-selector.h | 8 ++++---- src/widgets/gradient-vector.h | 8 ++++---- src/widgets/icon.h | 4 ++-- src/widgets/paint-selector.h | 8 ++++---- src/widgets/ruler.h | 12 ++++++------ src/widgets/sp-attribute-widget.h | 16 ++++++++-------- src/widgets/sp-color-gtkselector.h | 8 ++++---- src/widgets/sp-color-icc-selector.h | 8 ++++---- src/widgets/sp-color-notebook.h | 8 ++++---- src/widgets/sp-color-preview.h | 8 ++++---- src/widgets/sp-color-scales.h | 8 ++++---- src/widgets/sp-color-selector.h | 8 ++++---- src/widgets/sp-color-slider.h | 8 ++++---- src/widgets/sp-color-wheel-selector.h | 8 ++++---- src/widgets/sp-widget.h | 8 ++++---- src/widgets/sp-xmlview-attr-list.h | 6 +++--- src/widgets/sp-xmlview-content.h | 6 +++--- src/widgets/sp-xmlview-tree.h | 6 +++--- src/zoom-context.h | 4 ++-- 71 files changed, 272 insertions(+), 272 deletions(-) (limited to 'src') diff --git a/src/arc-context.h b/src/arc-context.h index 3ed4478ba..ddce10801 100644 --- a/src/arc-context.h +++ b/src/arc-context.h @@ -22,10 +22,10 @@ #include "event-context.h" #define SP_TYPE_ARC_CONTEXT (sp_arc_context_get_type()) -#define SP_ARC_CONTEXT(obj) (GTK_CHECK_CAST((obj), SP_TYPE_ARC_CONTEXT, SPArcContext)) -#define SP_ARC_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), SP_TYPE_ARC_CONTEXT, SPArcContextClass)) -#define SP_IS_ARC_CONTEXT(obj) (GTK_CHECK_TYPE((obj), SP_TYPE_ARC_CONTEXT)) -#define SP_IS_ARC_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), SP_TYPE_ARC_CONTEXT)) +#define SP_ARC_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_ARC_CONTEXT, SPArcContext)) +#define SP_ARC_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_ARC_CONTEXT, SPArcContextClass)) +#define SP_IS_ARC_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_ARC_CONTEXT)) +#define SP_IS_ARC_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_ARC_CONTEXT)) class SPArcContext; class SPArcContextClass; diff --git a/src/box3d-context.h b/src/box3d-context.h index 4b8435d74..74d244423 100644 --- a/src/box3d-context.h +++ b/src/box3d-context.h @@ -22,10 +22,10 @@ #include "vanishing-point.h" #define SP_TYPE_BOX3D_CONTEXT (sp_box3d_context_get_type ()) -#define SP_BOX3D_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_BOX3D_CONTEXT, Box3DContext)) -#define SP_BOX3D_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_BOX3D_CONTEXT, Box3DContextClass)) -#define SP_IS_BOX3D_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_BOX3D_CONTEXT)) -#define SP_IS_BOX3D_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_BOX3D_CONTEXT)) +#define SP_BOX3D_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_BOX3D_CONTEXT, Box3DContext)) +#define SP_BOX3D_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_BOX3D_CONTEXT, Box3DContextClass)) +#define SP_IS_BOX3D_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_BOX3D_CONTEXT)) +#define SP_IS_BOX3D_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_BOX3D_CONTEXT)) class Box3DContext; class Box3DContextClass; diff --git a/src/common-context.h b/src/common-context.h index 74b6bbaef..ae0f398b2 100644 --- a/src/common-context.h +++ b/src/common-context.h @@ -24,10 +24,10 @@ #include <2geom/point.h> #define SP_TYPE_COMMON_CONTEXT (sp_common_context_get_type()) -#define SP_COMMON_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_COMMON_CONTEXT, SPCommonContext)) -#define SP_COMMON_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_COMMON_CONTEXT, SPCommonContextClass)) -#define SP_IS_COMMON_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_COMMON_CONTEXT)) -#define SP_IS_COMMON_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_COMMON_CONTEXT)) +#define SP_COMMON_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_COMMON_CONTEXT, SPCommonContext)) +#define SP_COMMON_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_COMMON_CONTEXT, SPCommonContextClass)) +#define SP_IS_COMMON_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COMMON_CONTEXT)) +#define SP_IS_COMMON_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COMMON_CONTEXT)) class SPCommonContext; class SPCommonContextClass; diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 7267583f0..90be5f9e3 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -19,10 +19,10 @@ G_BEGIN_DECLS #define SP_TYPE_CANVAS_ARENA (sp_canvas_arena_get_type ()) -#define SP_CANVAS_ARENA(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CANVAS_ARENA, SPCanvasArena)) -#define SP_CANVAS_ARENA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_CANVAS_ARENA, SPCanvasArenaClass)) -#define SP_IS_CANVAS_ARENA(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CANVAS_ARENA)) -#define SP_IS_CANVAS_ARENA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CANVAS_ARENA)) +#define SP_CANVAS_ARENA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVAS_ARENA, SPCanvasArena)) +#define SP_CANVAS_ARENA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CANVAS_ARENA, SPCanvasArenaClass)) +#define SP_IS_CANVAS_ARENA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CANVAS_ARENA)) +#define SP_IS_CANVAS_ARENA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CANVAS_ARENA)) typedef struct _SPCanvasArena SPCanvasArena; typedef struct _SPCanvasArenaClass SPCanvasArenaClass; diff --git a/src/display/canvas-bpath.h b/src/display/canvas-bpath.h index 7f8b75dfe..ad19797c2 100644 --- a/src/display/canvas-bpath.h +++ b/src/display/canvas-bpath.h @@ -25,10 +25,10 @@ struct SPCanvasGroup; struct SPCurve; #define SP_TYPE_CANVAS_BPATH (sp_canvas_bpath_get_type ()) -#define SP_CANVAS_BPATH(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CANVAS_BPATH, SPCanvasBPath)) -#define SP_CANVAS_BPATH_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_CANVAS_BPATH, SPCanvasBPathClass)) -#define SP_IS_CANVAS_BPATH(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CANVAS_BPATH)) -#define SP_IS_CANVAS_BPATH_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CANVAS_BPATH)) +#define SP_CANVAS_BPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVAS_BPATH, SPCanvasBPath)) +#define SP_CANVAS_BPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CANVAS_BPATH, SPCanvasBPathClass)) +#define SP_IS_CANVAS_BPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CANVAS_BPATH)) +#define SP_IS_CANVAS_BPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CANVAS_BPATH)) #define bpath_liv diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index f386fe05e..f42fecad7 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -39,10 +39,10 @@ enum GridType { #define GRID_MAXTYPENR 1 #define INKSCAPE_TYPE_GRID_CANVASITEM (Inkscape::grid_canvasitem_get_type ()) -#define INKSCAPE_GRID_CANVASITEM(obj) (GTK_CHECK_CAST ((obj), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem)) -#define INKSCAPE_GRID_CANVASITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem)) -#define INKSCAPE_IS_GRID_CANVASITEM(obj) (GTK_CHECK_TYPE ((obj), INKSCAPE_TYPE_GRID_CANVASITEM)) -#define INKSCAPE_IS_GRID_CANVASITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INKSCAPE_TYPE_GRID_CANVASITEM)) +#define INKSCAPE_GRID_CANVASITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem)) +#define INKSCAPE_GRID_CANVASITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem)) +#define INKSCAPE_IS_GRID_CANVASITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INKSCAPE_TYPE_GRID_CANVASITEM)) +#define INKSCAPE_IS_GRID_CANVASITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INKSCAPE_TYPE_GRID_CANVASITEM)) class CanvasGrid; diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index 9a6a93eb4..a621e655c 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -20,8 +20,8 @@ struct SPItem; struct SPDesktop; #define SP_TYPE_CANVASTEXT (sp_canvastext_get_type ()) -#define SP_CANVASTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CANVASTEXT, SPCanvasText)) -#define SP_IS_CANVASTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CANVASTEXT)) +#define SP_CANVASTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVASTEXT, SPCanvasText)) +#define SP_IS_CANVASTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CANVASTEXT)) struct SPCanvasText : public SPCanvasItem { SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users diff --git a/src/display/gnome-canvas-acetate.h b/src/display/gnome-canvas-acetate.h index 8c284291c..756c663ca 100644 --- a/src/display/gnome-canvas-acetate.h +++ b/src/display/gnome-canvas-acetate.h @@ -20,10 +20,10 @@ #define GNOME_TYPE_CANVAS_ACETATE (sp_canvas_acetate_get_type ()) -#define SP_CANVAS_ACETATE(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_CANVAS_ACETATE, SPCanvasAcetate)) -#define SP_CANVAS_ACETATE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_ACETATE, SPCanvasAcetateClass)) -#define GNOME_IS_CANVAS_ACETATE(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_CANVAS_ACETATE)) -#define GNOME_IS_CANVAS_ACETATE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_ACETATE)) +#define SP_CANVAS_ACETATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_ACETATE, SPCanvasAcetate)) +#define SP_CANVAS_ACETATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_ACETATE, SPCanvasAcetateClass)) +#define GNOME_IS_CANVAS_ACETATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_ACETATE)) +#define GNOME_IS_CANVAS_ACETATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_ACETATE)) struct SPCanvasAcetate { diff --git a/src/display/guideline.h b/src/display/guideline.h index dfc3b7007..a3966f76f 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -18,8 +18,8 @@ #include "sp-canvas-item.h" #define SP_TYPE_GUIDELINE (sp_guideline_get_type()) -#define SP_GUIDELINE(o) (GTK_CHECK_CAST((o), SP_TYPE_GUIDELINE, SPGuideLine)) -#define SP_IS_GUIDELINE(o) (GTK_CHECK_TYPE((o), SP_TYPE_GUIDELINE)) +#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)) class SPCtrlPoint; diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index c3b97cbe0..71061b450 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -14,10 +14,10 @@ #define SP_TYPE_CTRL (sp_ctrl_get_type ()) -#define SP_CTRL(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CTRL, SPCtrl)) -#define SP_CTRL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_CTRL, SPCtrlClass)) -#define SP_IS_CTRL(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CTRL)) -#define SP_IS_CTRL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CTRL)) +#define SP_CTRL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRL, SPCtrl)) +#define SP_CTRL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CTRL, SPCtrlClass)) +#define SP_IS_CTRL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRL)) +#define SP_IS_CTRL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CTRL)) typedef enum { SP_CTRL_SHAPE_SQUARE, diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 2ba73a4c9..945deabc4 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -23,10 +23,10 @@ struct SPCanvasBuf; #define SP_TYPE_CTRLRECT (sp_ctrlrect_get_type ()) -#define SP_CTRLRECT(obj) (GTK_CHECK_CAST((obj), SP_TYPE_CTRLRECT, CtrlRect)) -#define SP_CTRLRECT_CLASS(c) (GTK_CHECK_CLASS_CAST((c), SP_TYPE_CTRLRECT, SPCtrlRectClass)) -#define SP_IS_CTRLRECT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CTRLRECT)) -#define SP_IS_CTRLRECT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CTRLRECT)) +#define SP_CTRLRECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CTRLRECT, CtrlRect)) +#define SP_CTRLRECT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), SP_TYPE_CTRLRECT, SPCtrlRectClass)) +#define SP_IS_CTRLRECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLRECT)) +#define SP_IS_CTRLRECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CTRLRECT)) class CtrlRect : public SPCanvasItem { diff --git a/src/display/sp-canvas-group.h b/src/display/sp-canvas-group.h index 10bf0fa6c..354d389b7 100644 --- a/src/display/sp-canvas-group.h +++ b/src/display/sp-canvas-group.h @@ -24,8 +24,8 @@ #include <glib-object.h> #define SP_TYPE_CANVAS_GROUP (sp_canvas_group_get_type()) -#define SP_CANVAS_GROUP(obj) (GTK_CHECK_CAST((obj), SP_TYPE_CANVAS_GROUP, SPCanvasGroup)) -#define SP_IS_CANVAS_GROUP(obj) (GTK_CHECK_TYPE((obj), SP_TYPE_CANVAS_GROUP)) +#define SP_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS_GROUP, SPCanvasGroup)) +#define SP_IS_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS_GROUP)) GType sp_canvas_group_get_type(); diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 26e5aa1f6..f62dc34a7 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -36,9 +36,9 @@ struct SPCanvasGroup; typedef struct _SPCanvasItemClass SPCanvasItemClass; #define SP_TYPE_CANVAS_ITEM (sp_canvas_item_get_type()) -#define SP_CANVAS_ITEM(obj) (GTK_CHECK_CAST((obj), SP_TYPE_CANVAS_ITEM, SPCanvasItem)) -#define SP_IS_CANVAS_ITEM(obj) (GTK_CHECK_TYPE((obj), SP_TYPE_CANVAS_ITEM)) -#define SP_CANVAS_ITEM_GET_CLASS(o) (GTK_CHECK_GET_CLASS((o), SP_TYPE_CANVAS_ITEM, SPCanvasItemClass)) +#define SP_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS_ITEM, SPCanvasItem)) +#define SP_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS_ITEM)) +#define SP_CANVAS_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), SP_TYPE_CANVAS_ITEM, SPCanvasItemClass)) GType sp_canvas_item_get_type(); diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index a6ddafb1e..e151911dc 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -41,8 +41,8 @@ G_BEGIN_DECLS #define SP_TYPE_CANVAS sp_canvas_get_type() -#define SP_CANVAS(obj) (GTK_CHECK_CAST((obj), SP_TYPE_CANVAS, SPCanvas)) -#define SP_IS_CANVAS(obj) (GTK_CHECK_TYPE((obj), SP_TYPE_CANVAS)) +#define SP_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS, SPCanvas)) +#define SP_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS)) GType sp_canvas_get_type(); diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index e69c478fb..eeed7e75d 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -19,8 +19,8 @@ struct SPItem; #define SP_TYPE_CTRLLINE (sp_ctrlline_get_type ()) -#define SP_CTRLLINE(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CTRLLINE, SPCtrlLine)) -#define SP_IS_CTRLLINE(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CTRLLINE)) +#define SP_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLLINE, SPCtrlLine)) +#define SP_IS_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLLINE)) struct SPCtrlLine : public SPCanvasItem{ SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users diff --git a/src/display/sp-ctrlpoint.h b/src/display/sp-ctrlpoint.h index b98d48f67..907f74bf8 100644 --- a/src/display/sp-ctrlpoint.h +++ b/src/display/sp-ctrlpoint.h @@ -17,8 +17,8 @@ struct SPItem; #define SP_TYPE_CTRLPOINT (sp_ctrlpoint_get_type ()) -#define SP_CTRLPOINT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CTRLPOINT, SPCtrlPoint)) -#define SP_IS_CTRLPOINT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CTRLPOINT)) +#define SP_CTRLPOINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLPOINT, SPCtrlPoint)) +#define SP_IS_CTRLPOINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLPOINT)) struct SPCtrlPoint : public SPCanvasItem { SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users diff --git a/src/display/sp-ctrlquadr.h b/src/display/sp-ctrlquadr.h index f3c1ced45..9fdfd29b3 100644 --- a/src/display/sp-ctrlquadr.h +++ b/src/display/sp-ctrlquadr.h @@ -17,8 +17,8 @@ #define SP_TYPE_CTRLQUADR (sp_ctrlquadr_get_type ()) -#define SP_CTRLQUADR(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CTRLQUADR, SPCtrlQuadr)) -#define SP_IS_CTRLQUADR(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CTRLQUADR)) +#define SP_CTRLQUADR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLQUADR, SPCtrlQuadr)) +#define SP_IS_CTRLQUADR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLQUADR)) struct SPCtrlQuadr; struct SPCtrlQuadrClass; diff --git a/src/draw-context.h b/src/draw-context.h index 3cad8da06..4266bdea4 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -24,10 +24,10 @@ /* Freehand context */ #define SP_TYPE_DRAW_CONTEXT (sp_draw_context_get_type()) -#define SP_DRAW_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_DRAW_CONTEXT, SPDrawContext)) -#define SP_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_DRAW_CONTEXT, SPDrawContextClass)) -#define SP_IS_DRAW_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_DRAW_CONTEXT)) -#define SP_IS_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_DRAW_CONTEXT)) +#define SP_DRAW_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_DRAW_CONTEXT, SPDrawContext)) +#define SP_DRAW_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_DRAW_CONTEXT, SPDrawContextClass)) +#define SP_IS_DRAW_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_DRAW_CONTEXT)) +#define SP_IS_DRAW_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_DRAW_CONTEXT)) struct SPDrawAnchor; namespace Inkscape diff --git a/src/dropper-context.h b/src/dropper-context.h index f2d18a507..22c6a1cf3 100644 --- a/src/dropper-context.h +++ b/src/dropper-context.h @@ -15,8 +15,8 @@ #include "event-context.h" #define SP_TYPE_DROPPER_CONTEXT (sp_dropper_context_get_type ()) -#define SP_DROPPER_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_DROPPER_CONTEXT, SPDropperContext)) -#define SP_IS_DROPPER_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_DROPPER_CONTEXT)) +#define SP_DROPPER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DROPPER_CONTEXT, SPDropperContext)) +#define SP_IS_DROPPER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DROPPER_CONTEXT)) class SPDropperContext; class SPDropperContextClass; diff --git a/src/dyna-draw-context.h b/src/dyna-draw-context.h index 9a736a3fc..af63bf653 100644 --- a/src/dyna-draw-context.h +++ b/src/dyna-draw-context.h @@ -22,10 +22,10 @@ #include "splivarot.h" #define SP_TYPE_DYNA_DRAW_CONTEXT (sp_dyna_draw_context_get_type()) -#define SP_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContext)) -#define SP_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContextClass)) -#define SP_IS_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT)) -#define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT)) +#define SP_DYNA_DRAW_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContext)) +#define SP_DYNA_DRAW_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContextClass)) +#define SP_IS_DYNA_DRAW_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT)) +#define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT)) class SPDynaDrawContext; class SPDynaDrawContextClass; diff --git a/src/eraser-context.h b/src/eraser-context.h index a581acd94..68ed04ad5 100644 --- a/src/eraser-context.h +++ b/src/eraser-context.h @@ -22,10 +22,10 @@ #include "common-context.h" #define SP_TYPE_ERASER_CONTEXT (sp_eraser_context_get_type()) -#define SP_ERASER_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_ERASER_CONTEXT, SPEraserContext)) -#define SP_ERASER_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_ERASER_CONTEXT, SPEraserContextClass)) -#define SP_IS_ERASER_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_ERASER_CONTEXT)) -#define SP_IS_ERASER_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_ERASER_CONTEXT)) +#define SP_ERASER_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ERASER_CONTEXT, SPEraserContext)) +#define SP_ERASER_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_ERASER_CONTEXT, SPEraserContextClass)) +#define SP_IS_ERASER_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ERASER_CONTEXT)) +#define SP_IS_ERASER_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ERASER_CONTEXT)) class SPEraserContext; class SPEraserContextClass; diff --git a/src/flood-context.h b/src/flood-context.h index d9da96010..6847c19be 100644 --- a/src/flood-context.h +++ b/src/flood-context.h @@ -19,10 +19,10 @@ #include "helper/units.h" #define SP_TYPE_FLOOD_CONTEXT (sp_flood_context_get_type ()) -#define SP_FLOOD_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_FLOOD_CONTEXT, SPFloodContext)) -#define SP_FLOOD_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_FLOOD_CONTEXT, SPFloodContextClass)) -#define SP_IS_FLOOD_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_FLOOD_CONTEXT)) -#define SP_IS_FLOOD_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_FLOOD_CONTEXT)) +#define SP_FLOOD_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_FLOOD_CONTEXT, SPFloodContext)) +#define SP_FLOOD_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_FLOOD_CONTEXT, SPFloodContextClass)) +#define SP_IS_FLOOD_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_FLOOD_CONTEXT)) +#define SP_IS_FLOOD_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_FLOOD_CONTEXT)) #define FLOOD_COLOR_CHANNEL_R 1 #define FLOOD_COLOR_CHANNEL_G 2 diff --git a/src/gradient-context.h b/src/gradient-context.h index 3bb9efa15..1ed14cf3f 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -20,10 +20,10 @@ #include "event-context.h" #define SP_TYPE_GRADIENT_CONTEXT (sp_gradient_context_get_type()) -#define SP_GRADIENT_CONTEXT(obj) (GTK_CHECK_CAST((obj), SP_TYPE_GRADIENT_CONTEXT, SPGradientContext)) -#define SP_GRADIENT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), SP_TYPE_GRADIENT_CONTEXT, SPGradientContextClass)) -#define SP_IS_GRADIENT_CONTEXT(obj) (GTK_CHECK_TYPE((obj), SP_TYPE_GRADIENT_CONTEXT)) -#define SP_IS_GRADIENT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT_CONTEXT)) +#define SP_GRADIENT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT_CONTEXT, SPGradientContext)) +#define SP_GRADIENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GRADIENT_CONTEXT, SPGradientContextClass)) +#define SP_IS_GRADIENT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GRADIENT_CONTEXT)) +#define SP_IS_GRADIENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT_CONTEXT)) class SPGradientContext; class SPGradientContextClass; diff --git a/src/helper/unit-menu.h b/src/helper/unit-menu.h index 795dda7b7..919873c58 100644 --- a/src/helper/unit-menu.h +++ b/src/helper/unit-menu.h @@ -19,10 +19,10 @@ /* Unit selector Widget */ #define SP_TYPE_UNIT_SELECTOR (sp_unit_selector_get_type()) -#define SP_UNIT_SELECTOR(o) (GTK_CHECK_CAST((o), SP_TYPE_UNIT_SELECTOR, SPUnitSelector)) -#define SP_UNIT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_UNIT_SELECTOR, SPUnitSelectorClass)) -#define SP_IS_UNIT_SELECTOR(o) (GTK_CHECK_TYPE((o), SP_TYPE_UNIT_SELECTOR)) -#define SP_IS_UNIT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_UNIT_SELECTOR)) +#define SP_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_UNIT_SELECTOR, SPUnitSelector)) +#define SP_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_UNIT_SELECTOR, SPUnitSelectorClass)) +#define SP_IS_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_UNIT_SELECTOR)) +#define SP_IS_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_UNIT_SELECTOR)) GType sp_unit_selector_get_type(void); diff --git a/src/inkscape-private.h b/src/inkscape-private.h index 2cb83ae76..a6643b989 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -14,10 +14,10 @@ */ #define SP_TYPE_INKSCAPE (inkscape_get_type ()) -#define SP_INKSCAPE(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape)) -#define SP_INKSCAPE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_INKSCAPE, InkscapeClass)) -#define SP_IS_INKSCAPE(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_INKSCAPE)) -#define SP_IS_INKSCAPE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE)) +#define SP_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape)) +#define SP_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_INKSCAPE, InkscapeClass)) +#define SP_IS_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_INKSCAPE)) +#define SP_IS_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE)) #include "forward.h" #include "inkscape.h" diff --git a/src/libgdl/gdl-dock-bar.h b/src/libgdl/gdl-dock-bar.h index c6697a47c..798dded20 100644 --- a/src/libgdl/gdl-dock-bar.h +++ b/src/libgdl/gdl-dock-bar.h @@ -29,11 +29,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_BAR (gdl_dock_bar_get_type ()) -#define GDL_DOCK_BAR(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_BAR, GdlDockBar)) -#define GDL_DOCK_BAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_BAR, GdlDockBarClass)) -#define GDL_IS_DOCK_BAR(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_BAR)) -#define GDL_IS_DOCK_BAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_BAR)) -#define GDL_DOCK_BAR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_BAR, GdlDockBarClass)) +#define GDL_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_BAR, GdlDockBar)) +#define GDL_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_BAR, GdlDockBarClass)) +#define GDL_IS_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_BAR)) +#define GDL_IS_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_BAR)) +#define GDL_DOCK_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_BAR, GdlDockBarClass)) /* data types & structures */ typedef struct _GdlDockBar GdlDockBar; diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h index 495e9381d..4dfdd7ab3 100644 --- a/src/libgdl/gdl-dock-item-grip.h +++ b/src/libgdl/gdl-dock-item-grip.h @@ -20,15 +20,15 @@ G_BEGIN_DECLS #define GDL_TYPE_DOCK_ITEM_GRIP (gdl_dock_item_grip_get_type()) #define GDL_DOCK_ITEM_GRIP(obj) \ - (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGrip)) + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGrip)) #define GDL_DOCK_ITEM_GRIP_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass)) + (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass)) #define GDL_IS_DOCK_ITEM_GRIP(obj) \ - (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_ITEM_GRIP)) + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_GRIP)) #define GDL_IS_DOCK_ITEM_GRIP_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_GRIP)) + (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_GRIP)) #define GDL_DOCK_ITEM_GRIP_GET_CLASS(obj) \ - (GTK_CHECK_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass)) + (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass)) typedef struct _GdlDockItemGrip GdlDockItemGrip; typedef struct _GdlDockItemGripClass GdlDockItemGripClass; diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h index 17484ad04..6c0029d13 100644 --- a/src/libgdl/gdl-dock-item.h +++ b/src/libgdl/gdl-dock-item.h @@ -36,11 +36,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_ITEM (gdl_dock_item_get_type ()) -#define GDL_DOCK_ITEM(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem)) -#define GDL_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass)) -#define GDL_IS_DOCK_ITEM(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_ITEM)) -#define GDL_IS_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM)) -#define GDL_DOCK_ITEM_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass)) +#define GDL_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem)) +#define GDL_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass)) +#define GDL_IS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM)) +#define GDL_IS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM)) +#define GDL_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass)) /* data types & structures */ typedef enum { diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h index 1a10405b6..3268e68b5 100644 --- a/src/libgdl/gdl-dock-master.h +++ b/src/libgdl/gdl-dock-master.h @@ -33,11 +33,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_MASTER (gdl_dock_master_get_type ()) -#define GDL_DOCK_MASTER(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_MASTER, GdlDockMaster)) -#define GDL_DOCK_MASTER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_MASTER, GdlDockMasterClass)) -#define GDL_IS_DOCK_MASTER(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_MASTER)) -#define GDL_IS_DOCK_MASTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_MASTER)) -#define GDL_DOCK_MASTER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_MASTER, GdlDockMasterClass)) +#define GDL_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_MASTER, GdlDockMaster)) +#define GDL_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_MASTER, GdlDockMasterClass)) +#define GDL_IS_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_MASTER)) +#define GDL_IS_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_MASTER)) +#define GDL_DOCK_MASTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_MASTER, GdlDockMasterClass)) /* data types & structures */ typedef struct _GdlDockMaster GdlDockMaster; diff --git a/src/libgdl/gdl-dock-notebook.h b/src/libgdl/gdl-dock-notebook.h index 105da6c8c..063f53642 100644 --- a/src/libgdl/gdl-dock-notebook.h +++ b/src/libgdl/gdl-dock-notebook.h @@ -28,11 +28,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_NOTEBOOK (gdl_dock_notebook_get_type ()) -#define GDL_DOCK_NOTEBOOK(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebook)) -#define GDL_DOCK_NOTEBOOK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass)) -#define GDL_IS_DOCK_NOTEBOOK(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_NOTEBOOK)) -#define GDL_IS_DOCK_NOTEBOOK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_NOTEBOOK)) -#define GDL_DOCK_NOTEBOOK_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass)) +#define GDL_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebook)) +#define GDL_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass)) +#define GDL_IS_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_NOTEBOOK)) +#define GDL_IS_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_NOTEBOOK)) +#define GDL_DOCK_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass)) /* data types & structures */ typedef struct _GdlDockNotebook GdlDockNotebook; diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h index 684bd043f..6ac36a44c 100644 --- a/src/libgdl/gdl-dock-object.h +++ b/src/libgdl/gdl-dock-object.h @@ -30,11 +30,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_OBJECT (gdl_dock_object_get_type ()) -#define GDL_DOCK_OBJECT(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_OBJECT, GdlDockObject)) -#define GDL_DOCK_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_OBJECT, GdlDockObjectClass)) -#define GDL_IS_DOCK_OBJECT(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_OBJECT)) -#define GDL_IS_DOCK_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_OBJECT)) -#define GDL_DOCK_OBJECT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_OBJECT, GdlDockObjectClass)) +#define GDL_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_OBJECT, GdlDockObject)) +#define GDL_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_OBJECT, GdlDockObjectClass)) +#define GDL_IS_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_OBJECT)) +#define GDL_IS_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_OBJECT)) +#define GDL_DOCK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_OBJECT, GdlDockObjectClass)) /* data types & structures */ typedef enum { diff --git a/src/libgdl/gdl-dock-paned.h b/src/libgdl/gdl-dock-paned.h index 208c9c422..06b496491 100644 --- a/src/libgdl/gdl-dock-paned.h +++ b/src/libgdl/gdl-dock-paned.h @@ -30,11 +30,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_PANED (gdl_dock_paned_get_type ()) -#define GDL_DOCK_PANED(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned)) -#define GDL_DOCK_PANED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass)) -#define GDL_IS_DOCK_PANED(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_PANED)) -#define GDL_IS_DOCK_PANED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED)) -#define GDL_DOCK_PANED_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass)) +#define GDL_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned)) +#define GDL_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass)) +#define GDL_IS_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PANED)) +#define GDL_IS_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED)) +#define GDL_DOCK_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass)) /* data types & structures */ typedef struct _GdlDockPaned GdlDockPaned; diff --git a/src/libgdl/gdl-dock-placeholder.h b/src/libgdl/gdl-dock-placeholder.h index 4a7035b82..aeb55da67 100644 --- a/src/libgdl/gdl-dock-placeholder.h +++ b/src/libgdl/gdl-dock-placeholder.h @@ -30,11 +30,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_PLACEHOLDER (gdl_dock_placeholder_get_type ()) -#define GDL_DOCK_PLACEHOLDER(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder)) -#define GDL_DOCK_PLACEHOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass)) -#define GDL_IS_DOCK_PLACEHOLDER(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_PLACEHOLDER)) -#define GDL_IS_DOCK_PLACEHOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PLACEHOLDER)) -#define GDL_DOCK_PLACEHOLDER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass)) +#define GDL_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder)) +#define GDL_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass)) +#define GDL_IS_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PLACEHOLDER)) +#define GDL_IS_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PLACEHOLDER)) +#define GDL_DOCK_PLACEHOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass)) /* data types & structures */ typedef struct _GdlDockPlaceholder GdlDockPlaceholder; diff --git a/src/libgdl/gdl-dock-tablabel.h b/src/libgdl/gdl-dock-tablabel.h index 8cf3470eb..b78c1c5c7 100644 --- a/src/libgdl/gdl-dock-tablabel.h +++ b/src/libgdl/gdl-dock-tablabel.h @@ -32,11 +32,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_TABLABEL (gdl_dock_tablabel_get_type ()) -#define GDL_DOCK_TABLABEL(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabel)) -#define GDL_DOCK_TABLABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabelClass)) -#define GDL_IS_DOCK_TABLABEL(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_TABLABEL)) -#define GDL_IS_DOCK_TABLABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_TABLABEL)) -#define GDL_DOCK_TABLABEL_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_TABLABEL, GdlDockTablabelClass)) +#define GDL_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabel)) +#define GDL_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabelClass)) +#define GDL_IS_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_TABLABEL)) +#define GDL_IS_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_TABLABEL)) +#define GDL_DOCK_TABLABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_TABLABEL, GdlDockTablabelClass)) /* data types & structures */ typedef struct _GdlDockTablabel GdlDockTablabel; diff --git a/src/libgdl/gdl-dock.h b/src/libgdl/gdl-dock.h index 7508feef7..2259d395d 100644 --- a/src/libgdl/gdl-dock.h +++ b/src/libgdl/gdl-dock.h @@ -31,11 +31,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK (gdl_dock_get_type ()) -#define GDL_DOCK(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK, GdlDock)) -#define GDL_DOCK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK, GdlDockClass)) -#define GDL_IS_DOCK(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK)) -#define GDL_IS_DOCK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK)) -#define GDL_DOCK_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK, GdlDockClass)) +#define GDL_DOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK, GdlDock)) +#define GDL_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK, GdlDockClass)) +#define GDL_IS_DOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK)) +#define GDL_IS_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK)) +#define GDL_DOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK, GdlDockClass)) /* data types & structures */ typedef struct _GdlDock GdlDock; diff --git a/src/lpe-tool-context.h b/src/lpe-tool-context.h index 478989e0b..12e4b3838 100644 --- a/src/lpe-tool-context.h +++ b/src/lpe-tool-context.h @@ -19,10 +19,10 @@ #include "helper/units.h" #define SP_TYPE_LPETOOL_CONTEXT (sp_lpetool_context_get_type()) -#define SP_LPETOOL_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContext)) -#define SP_LPETOOL_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContextClass)) -#define SP_IS_LPETOOL_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_LPETOOL_CONTEXT)) -#define SP_IS_LPETOOL_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_LPETOOL_CONTEXT)) +#define SP_LPETOOL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContext)) +#define SP_LPETOOL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContextClass)) +#define SP_IS_LPETOOL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_LPETOOL_CONTEXT)) +#define SP_IS_LPETOOL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_LPETOOL_CONTEXT)) class SPLPEToolContext; class SPLPEToolContextClass; diff --git a/src/measure-context.h b/src/measure-context.h index f6065b3e6..24cdf5ac8 100644 --- a/src/measure-context.h +++ b/src/measure-context.h @@ -15,8 +15,8 @@ #include "event-context.h" #define SP_TYPE_MEASURE_CONTEXT (sp_measure_context_get_type ()) -#define SP_MEASURE_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) -#define SP_IS_MEASURE_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_MEASURE_CONTEXT)) +#define SP_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) +#define SP_IS_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_MEASURE_CONTEXT)) class SPMeasureContext; class SPMeasureContextClass; diff --git a/src/rect-context.h b/src/rect-context.h index 54f790c68..db7cd605b 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -20,10 +20,10 @@ #include "libnr/nr-point.h" #define SP_TYPE_RECT_CONTEXT (sp_rect_context_get_type ()) -#define SP_RECT_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_RECT_CONTEXT, SPRectContext)) -#define SP_RECT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_RECT_CONTEXT, SPRectContextClass)) -#define SP_IS_RECT_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_RECT_CONTEXT)) -#define SP_IS_RECT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_RECT_CONTEXT)) +#define SP_RECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_RECT_CONTEXT, SPRectContext)) +#define SP_RECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_RECT_CONTEXT, SPRectContextClass)) +#define SP_IS_RECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_RECT_CONTEXT)) +#define SP_IS_RECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_RECT_CONTEXT)) class SPRectContext; class SPRectContextClass; diff --git a/src/select-context.h b/src/select-context.h index 6d12558ca..934892d40 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -16,10 +16,10 @@ #include <gtk/gtk.h> #define SP_TYPE_SELECT_CONTEXT (sp_select_context_get_type ()) -#define SP_SELECT_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_SELECT_CONTEXT, SPSelectContext)) -#define SP_SELECT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_SELECT_CONTEXT, SPSelectContextClass)) -#define SP_IS_SELECT_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_SELECT_CONTEXT)) -#define SP_IS_SELECT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_SELECT_CONTEXT)) +#define SP_SELECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SELECT_CONTEXT, SPSelectContext)) +#define SP_SELECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SELECT_CONTEXT, SPSelectContextClass)) +#define SP_IS_SELECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SELECT_CONTEXT)) +#define SP_IS_SELECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SELECT_CONTEXT)) struct SPCanvasItem; class SPSelectContext; diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 141474277..64544b3dc 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -18,10 +18,10 @@ #include "forward.h" #include "sp-item.h" #define SP_TYPE_PATTERN (sp_pattern_get_type ()) -#define SP_PATTERN(o) (GTK_CHECK_CAST ((o), SP_TYPE_PATTERN, SPPattern)) -#define SP_PATTERN_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_PATTERN, SPPatternClass)) -#define SP_IS_PATTERN(o) (GTK_CHECK_TYPE ((o), SP_TYPE_PATTERN)) -#define SP_IS_PATTERN_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_PATTERN)) +#define SP_PATTERN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_PATTERN, SPPattern)) +#define SP_PATTERN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_PATTERN, SPPatternClass)) +#define SP_IS_PATTERN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_PATTERN)) +#define SP_IS_PATTERN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_PATTERN)) GType sp_pattern_get_type (void); diff --git a/src/spiral-context.h b/src/spiral-context.h index 906cf61df..6d689c49c 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -22,10 +22,10 @@ #include "libnr/nr-point.h" #define SP_TYPE_SPIRAL_CONTEXT (sp_spiral_context_get_type ()) -#define SP_SPIRAL_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContext)) -#define SP_SPIRAL_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContextClass)) -#define SP_IS_SPIRAL_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_SPIRAL_CONTEXT)) -#define SP_IS_SPIRAL_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL_CONTEXT)) +#define SP_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContext)) +#define SP_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContextClass)) +#define SP_IS_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL_CONTEXT)) +#define SP_IS_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL_CONTEXT)) class SPSpiralContext; class SPSpiralContextClass; diff --git a/src/spray-context.h b/src/spray-context.h index c485a6a96..f6d9a9c0b 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -24,10 +24,10 @@ #include "ui/dialog/dialog.h" #define SP_TYPE_SPRAY_CONTEXT (sp_spray_context_get_type()) -#define SP_SPRAY_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_SPRAY_CONTEXT, SPSprayContext)) -#define SP_SPRAY_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_SPRAY_CONTEXT, SPSprayContextClass)) -#define SP_IS_SPRAY_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_SPRAY_CONTEXT)) -#define SP_IS_SPRAY_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_SPRAY_CONTEXT)) +#define SP_SPRAY_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_SPRAY_CONTEXT, SPSprayContext)) +#define SP_SPRAY_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_SPRAY_CONTEXT, SPSprayContextClass)) +#define SP_IS_SPRAY_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_SPRAY_CONTEXT)) +#define SP_IS_SPRAY_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_SPRAY_CONTEXT)) class SPSprayContext; class SPSprayContextClass; diff --git a/src/star-context.h b/src/star-context.h index 3bc8ca386..b66e2dd15 100644 --- a/src/star-context.h +++ b/src/star-context.h @@ -20,10 +20,10 @@ #include "libnr/nr-point.h" #define SP_TYPE_STAR_CONTEXT (sp_star_context_get_type ()) -#define SP_STAR_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_STAR_CONTEXT, SPStarContext)) -#define SP_STAR_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_STAR_CONTEXT, SPStarContextClass)) -#define SP_IS_STAR_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_STAR_CONTEXT)) -#define SP_IS_STAR_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_STAR_CONTEXT)) +#define SP_STAR_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_STAR_CONTEXT, SPStarContext)) +#define SP_STAR_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_STAR_CONTEXT, SPStarContextClass)) +#define SP_IS_STAR_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_STAR_CONTEXT)) +#define SP_IS_STAR_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_STAR_CONTEXT)) class SPStarContext; class SPStarContextClass; diff --git a/src/svg-view-widget.h b/src/svg-view-widget.h index e732841c7..1a8697fdf 100644 --- a/src/svg-view-widget.h +++ b/src/svg-view-widget.h @@ -22,10 +22,10 @@ class SPSVGSPViewWidget; class SPSVGSPViewWidgetClass; #define SP_TYPE_SVG_VIEW_WIDGET (sp_svg_view_widget_get_type ()) -#define SP_SVG_VIEW_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_SVG_VIEW_WIDGET, SPSVGSPViewWidget)) -#define SP_SVG_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_SVG_VIEW_WIDGET, SPSVGSPViewWidgetClass)) -#define SP_IS_SVG_VIEW_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_SVG_VIEW_WIDGET)) -#define SP_IS_SVG_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_SVG_VIEW_WIDGET)) +#define SP_SVG_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SVG_VIEW_WIDGET, SPSVGSPViewWidget)) +#define SP_SVG_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SVG_VIEW_WIDGET, SPSVGSPViewWidgetClass)) +#define SP_IS_SVG_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SVG_VIEW_WIDGET)) +#define SP_IS_SVG_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SVG_VIEW_WIDGET)) GtkType sp_svg_view_widget_get_type (void); diff --git a/src/text-context.h b/src/text-context.h index b7d1b8e69..0d7a93ef0 100644 --- a/src/text-context.h +++ b/src/text-context.h @@ -24,10 +24,10 @@ #include "libnrtype/Layout-TNG.h" #define SP_TYPE_TEXT_CONTEXT (sp_text_context_get_type ()) -#define SP_TEXT_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_TEXT_CONTEXT, SPTextContext)) -#define SP_TEXT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_TEXT_CONTEXT, SPTextContextClass)) -#define SP_IS_TEXT_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_TEXT_CONTEXT)) -#define SP_IS_TEXT_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT)) +#define SP_TEXT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_TEXT_CONTEXT, SPTextContext)) +#define SP_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_TEXT_CONTEXT, SPTextContextClass)) +#define SP_IS_TEXT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_TEXT_CONTEXT)) +#define SP_IS_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT)) class SPTextContext; class SPTextContextClass; diff --git a/src/tweak-context.h b/src/tweak-context.h index 542254b91..5fbd078ef 100644 --- a/src/tweak-context.h +++ b/src/tweak-context.h @@ -16,10 +16,10 @@ #include <libnr/nr-point.h> #define SP_TYPE_TWEAK_CONTEXT (sp_tweak_context_get_type()) -#define SP_TWEAK_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_TWEAK_CONTEXT, SPTweakContext)) -#define SP_TWEAK_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_TWEAK_CONTEXT, SPTweakContextClass)) -#define SP_IS_TWEAK_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_TWEAK_CONTEXT)) -#define SP_IS_TWEAK_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_TWEAK_CONTEXT)) +#define SP_TWEAK_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_TWEAK_CONTEXT, SPTweakContext)) +#define SP_TWEAK_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_TWEAK_CONTEXT, SPTweakContextClass)) +#define SP_IS_TWEAK_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_TWEAK_CONTEXT)) +#define SP_IS_TWEAK_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_TWEAK_CONTEXT)) class SPTweakContext; class SPTweakContextClass; diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index d005a0bdf..218e697b7 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -21,10 +21,10 @@ #include "ui/tool/node-types.h" #define INK_TYPE_NODE_TOOL (ink_node_tool_get_type ()) -#define INK_NODE_TOOL(obj) (GTK_CHECK_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) -#define INK_NODE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) -#define INK_IS_NODE_TOOL(obj) (GTK_CHECK_TYPE ((obj), INK_TYPE_NODE_TOOL)) -#define INK_IS_NODE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) +#define INK_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) +#define INK_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) +#define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) +#define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) class InkNodeTool; class InkNodeToolClass; diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index 7bdbdefb1..f216c8e27 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -25,10 +25,10 @@ class SPViewWidget; class SPNamedView; #define SP_TYPE_VIEW_WIDGET (sp_view_widget_get_type ()) -#define SP_VIEW_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) -#define SP_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_VIEW_WIDGET, SPViewWidgetClass)) -#define SP_IS_VIEW_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_VIEW_WIDGET)) -#define SP_IS_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_VIEW_WIDGET)) +#define SP_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) +#define SP_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VIEW_WIDGET, SPViewWidgetClass)) +#define SP_IS_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VIEW_WIDGET)) +#define SP_IS_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VIEW_WIDGET)) #define SP_VIEW_WIDGET_VIEW(w) (SP_VIEW_WIDGET (w)->view) #define SP_VIEW_WIDGET_DOCUMENT(w) (SP_VIEW_WIDGET (w)->view ? ((SPViewWidget *) (w))->view->doc : NULL) diff --git a/src/widgets/button.h b/src/widgets/button.h index 19a513074..759096443 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -13,8 +13,8 @@ */ #define SP_TYPE_BUTTON (sp_button_get_type ()) -#define SP_BUTTON(o) (GTK_CHECK_CAST ((o), SP_TYPE_BUTTON, SPButton)) -#define SP_IS_BUTTON(o) (GTK_CHECK_TYPE ((o), SP_TYPE_BUTTON)) +#define SP_BUTTON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_BUTTON, SPButton)) +#define SP_IS_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_BUTTON)) #include <gtk/gtk.h> diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 57ba71d8f..6c5af0aac 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -30,10 +30,10 @@ struct SPCanvas; #define SP_TYPE_DESKTOP_WIDGET SPDesktopWidget::getType() -#define SP_DESKTOP_WIDGET(o) (GTK_CHECK_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget)) -#define SP_DESKTOP_WIDGET_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass)) -#define SP_IS_DESKTOP_WIDGET(o) (GTK_CHECK_TYPE ((o), SP_TYPE_DESKTOP_WIDGET)) -#define SP_IS_DESKTOP_WIDGET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_DESKTOP_WIDGET)) +#define SP_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget)) +#define SP_DESKTOP_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass)) +#define SP_IS_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_DESKTOP_WIDGET)) +#define SP_IS_DESKTOP_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_DESKTOP_WIDGET)) void sp_desktop_widget_destroy (SPDesktopWidget* dtw); diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 61e607ac7..41a671bae 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -20,12 +20,12 @@ struct SPFontSelector; struct SPFontPreview; #define SP_TYPE_FONT_SELECTOR (sp_font_selector_get_type ()) -#define SP_FONT_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector)) -#define SP_IS_FONT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_SELECTOR)) +#define SP_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector)) +#define SP_IS_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_FONT_SELECTOR)) #define SP_TYPE_FONT_PREVIEW (sp_font_preview_get_type ()) -#define SP_FONT_PREVIEW(o) (GTK_CHECK_CAST ((o), SP_TYPE_FONT_PREVIEW, SPFontPreview)) -#define SP_IS_FONT_PREVIEW(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_PREVIEW)) +#define SP_FONT_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_PREVIEW, SPFontPreview)) +#define SP_IS_FONT_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_FONT_PREVIEW)) #include <libnrtype/nrtype-forward.h> #include <gtk/gtk.h> diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h index a998dcff3..0f911d4ef 100644 --- a/src/widgets/gradient-image.h +++ b/src/widgets/gradient-image.h @@ -23,10 +23,10 @@ class SPGradient; #include <sigc++/connection.h> #define SP_TYPE_GRADIENT_IMAGE (sp_gradient_image_get_type ()) -#define SP_GRADIENT_IMAGE(o) (GTK_CHECK_CAST ((o), SP_TYPE_GRADIENT_IMAGE, SPGradientImage)) -#define SP_GRADIENT_IMAGE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_IMAGE, SPGradientImageClass)) -#define SP_IS_GRADIENT_IMAGE(o) (GTK_CHECK_TYPE ((o), SP_TYPE_GRADIENT_IMAGE)) -#define SP_IS_GRADIENT_IMAGE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_IMAGE)) +#define SP_GRADIENT_IMAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_GRADIENT_IMAGE, SPGradientImage)) +#define SP_GRADIENT_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_IMAGE, SPGradientImageClass)) +#define SP_IS_GRADIENT_IMAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_GRADIENT_IMAGE)) +#define SP_IS_GRADIENT_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_IMAGE)) struct SPGradientImage { GtkWidget widget; diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index 9abbc57af..d957f7baf 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -25,10 +25,10 @@ class SPGradient; #define SP_TYPE_GRADIENT_SELECTOR (sp_gradient_selector_get_type ()) -#define SP_GRADIENT_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_GRADIENT_SELECTOR, SPGradientSelector)) -#define SP_GRADIENT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_SELECTOR, SPGradientSelectorClass)) -#define SP_IS_GRADIENT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_GRADIENT_SELECTOR)) -#define SP_IS_GRADIENT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_SELECTOR)) +#define SP_GRADIENT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_GRADIENT_SELECTOR, SPGradientSelector)) +#define SP_GRADIENT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_SELECTOR, SPGradientSelectorClass)) +#define SP_IS_GRADIENT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_GRADIENT_SELECTOR)) +#define SP_IS_GRADIENT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_SELECTOR)) diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index ac40aded0..6b165aca2 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -24,10 +24,10 @@ #include "../forward.h" #define SP_TYPE_GRADIENT_VECTOR_SELECTOR (sp_gradient_vector_selector_get_type ()) -#define SP_GRADIENT_VECTOR_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_GRADIENT_VECTOR_SELECTOR, SPGradientVectorSelector)) -#define SP_GRADIENT_VECTOR_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_VECTOR_SELECTOR, SPGradientVectorSelectorClass)) -#define SP_IS_GRADIENT_VECTOR_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_GRADIENT_VECTOR_SELECTOR)) -#define SP_IS_GRADIENT_VECTOR_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_VECTOR_SELECTOR)) +#define SP_GRADIENT_VECTOR_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_GRADIENT_VECTOR_SELECTOR, SPGradientVectorSelector)) +#define SP_GRADIENT_VECTOR_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_VECTOR_SELECTOR, SPGradientVectorSelectorClass)) +#define SP_IS_GRADIENT_VECTOR_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_GRADIENT_VECTOR_SELECTOR)) +#define SP_IS_GRADIENT_VECTOR_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_VECTOR_SELECTOR)) struct SPGradientVectorSelector { GtkVBox vbox; diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 371f6ba87..f04d2f8da 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -19,8 +19,8 @@ #include "icon-size.h" #define SP_TYPE_ICON SPIcon::getType() -#define SP_ICON(o) (GTK_CHECK_CAST ((o), SP_TYPE_ICON, SPIcon)) -#define SP_IS_ICON(o) (GTK_CHECK_TYPE ((o), SP_TYPE_ICON)) +#define SP_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_ICON, SPIcon)) +#define SP_IS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_ICON)) #include <gtk/gtk.h> diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index eb3eb2008..c0e44683b 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -22,10 +22,10 @@ class SPGradient; #define SP_TYPE_PAINT_SELECTOR (sp_paint_selector_get_type ()) -#define SP_PAINT_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_PAINT_SELECTOR, SPPaintSelector)) -#define SP_PAINT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_PAINT_SELECTOR, SPPaintSelectorClass)) -#define SP_IS_PAINT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_PAINT_SELECTOR)) -#define SP_IS_PAINT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_PAINT_SELECTOR)) +#define SP_PAINT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_PAINT_SELECTOR, SPPaintSelector)) +#define SP_PAINT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_PAINT_SELECTOR, SPPaintSelectorClass)) +#define SP_IS_PAINT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_PAINT_SELECTOR)) +#define SP_IS_PAINT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_PAINT_SELECTOR)) #include <gtk/gtk.h> diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h index fed3caaf0..3c55b39c4 100644 --- a/src/widgets/ruler.h +++ b/src/widgets/ruler.h @@ -22,9 +22,9 @@ void sp_ruler_set_metric (GtkRuler * ruler, SPMetric metric); -#define SP_HRULER(obj) GTK_CHECK_CAST (obj, sp_hruler_get_type (), SPHRuler) -#define SP_HRULER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, sp_hruler_get_type (), SPHRulerClass) -#define SP_IS_HRULER(obj) GTK_CHECK_TYPE (obj, sp_hruler_get_type ()) +#define SP_HRULER(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, sp_hruler_get_type (), SPHRuler) +#define SP_HRULER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, sp_hruler_get_type (), SPHRulerClass) +#define SP_IS_HRULER(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, sp_hruler_get_type ()) struct SPHRuler @@ -47,9 +47,9 @@ GtkWidget* sp_hruler_new (void); -#define SP_VRULER(obj) GTK_CHECK_CAST (obj, sp_vruler_get_type (), SPVRuler) -#define SP_VRULER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, sp_vruler_get_type (), SPVRulerClass) -#define SP_IS_VRULER(obj) GTK_CHECK_TYPE (obj, sp_vruler_get_type ()) +#define SP_VRULER(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, sp_vruler_get_type (), SPVRuler) +#define SP_VRULER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, sp_vruler_get_type (), SPVRulerClass) +#define SP_IS_VRULER(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, sp_vruler_get_type ()) struct SPVRuler diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 647ebd6d8..5d23e6754 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -18,16 +18,16 @@ #include <sigc++/connection.h> #define SP_TYPE_ATTRIBUTE_WIDGET (sp_attribute_widget_get_type ()) -#define SP_ATTRIBUTE_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidget)) -#define SP_ATTRIBUTE_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidgetClass)) -#define SP_IS_ATTRIBUTE_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_ATTRIBUTE_WIDGET)) -#define SP_IS_ATTRIBUTE_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_WIDGET)) +#define SP_ATTRIBUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidget)) +#define SP_ATTRIBUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidgetClass)) +#define SP_IS_ATTRIBUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ATTRIBUTE_WIDGET)) +#define SP_IS_ATTRIBUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_WIDGET)) #define SP_TYPE_ATTRIBUTE_TABLE (sp_attribute_table_get_type ()) -#define SP_ATTRIBUTE_TABLE(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTable)) -#define SP_ATTRIBUTE_TABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTableClass)) -#define SP_IS_ATTRIBUTE_TABLE(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_ATTRIBUTE_TABLE)) -#define SP_IS_ATTRIBUTE_TABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_TABLE)) +#define SP_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTable)) +#define SP_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTableClass)) +#define SP_IS_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ATTRIBUTE_TABLE)) +#define SP_IS_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_TABLE)) namespace Inkscape { namespace XML { diff --git a/src/widgets/sp-color-gtkselector.h b/src/widgets/sp-color-gtkselector.h index a85d94a5b..3142406c1 100644 --- a/src/widgets/sp-color-gtkselector.h +++ b/src/widgets/sp-color-gtkselector.h @@ -33,10 +33,10 @@ protected: #define SP_TYPE_COLOR_GTKSELECTOR (sp_color_gtkselector_get_type ()) -#define SP_COLOR_GTKSELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselector)) -#define SP_COLOR_GTKSELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselectorClass)) -#define SP_IS_COLOR_GTKSELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_GTKSELECTOR)) -#define SP_IS_COLOR_GTKSELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_GTKSELECTOR)) +#define SP_COLOR_GTKSELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselector)) +#define SP_COLOR_GTKSELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselectorClass)) +#define SP_IS_COLOR_GTKSELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_GTKSELECTOR)) +#define SP_IS_COLOR_GTKSELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_GTKSELECTOR)) struct SPColorGtkselector { SPColorSelector base; diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index b0efa35f4..9238e3f68 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -82,10 +82,10 @@ private: #define SP_TYPE_COLOR_ICC_SELECTOR (sp_color_icc_selector_get_type ()) -#define SP_COLOR_ICC_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) -#define SP_COLOR_ICC_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) -#define SP_IS_COLOR_ICC_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_ICC_SELECTOR)) -#define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_ICC_SELECTOR)) +#define SP_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) +#define SP_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) +#define SP_IS_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_ICC_SELECTOR)) +#define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_ICC_SELECTOR)) struct SPColorICCSelector { SPColorSelector parent; diff --git a/src/widgets/sp-color-notebook.h b/src/widgets/sp-color-notebook.h index b17612e03..8d2988636 100644 --- a/src/widgets/sp-color-notebook.h +++ b/src/widgets/sp-color-notebook.h @@ -76,10 +76,10 @@ private: #define SP_TYPE_COLOR_NOTEBOOK (sp_color_notebook_get_type ()) -#define SP_COLOR_NOTEBOOK(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_NOTEBOOK, SPColorNotebook)) -#define SP_COLOR_NOTEBOOK_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_NOTEBOOK, SPColorNotebookClass)) -#define SP_IS_COLOR_NOTEBOOK(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_NOTEBOOK)) -#define SP_IS_COLOR_NOTEBOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_NOTEBOOK)) +#define SP_COLOR_NOTEBOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_NOTEBOOK, SPColorNotebook)) +#define SP_COLOR_NOTEBOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_NOTEBOOK, SPColorNotebookClass)) +#define SP_IS_COLOR_NOTEBOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_NOTEBOOK)) +#define SP_IS_COLOR_NOTEBOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_NOTEBOOK)) struct SPColorNotebook { SPColorSelector parent; /* Parent */ diff --git a/src/widgets/sp-color-preview.h b/src/widgets/sp-color-preview.h index 731aceb70..43abdf11f 100644 --- a/src/widgets/sp-color-preview.h +++ b/src/widgets/sp-color-preview.h @@ -20,10 +20,10 @@ #define SP_TYPE_COLOR_PREVIEW (sp_color_preview_get_type ()) -#define SP_COLOR_PREVIEW(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_PREVIEW, SPColorPreview)) -#define SP_COLOR_PREVIEW_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_PREVIEW, SPColorPreviewClass)) -#define SP_IS_COLOR_PREVIEW(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_PREVIEW)) -#define SP_IS_COLOR_PREVIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_PREVIEW)) +#define SP_COLOR_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_PREVIEW, SPColorPreview)) +#define SP_COLOR_PREVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_PREVIEW, SPColorPreviewClass)) +#define SP_IS_COLOR_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_PREVIEW)) +#define SP_IS_COLOR_PREVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_PREVIEW)) struct SPColorPreview { GtkWidget widget; diff --git a/src/widgets/sp-color-scales.h b/src/widgets/sp-color-scales.h index 798a920af..8ffe5e7a8 100644 --- a/src/widgets/sp-color-scales.h +++ b/src/widgets/sp-color-scales.h @@ -74,10 +74,10 @@ private: #define SP_TYPE_COLOR_SCALES (sp_color_scales_get_type()) -#define SP_COLOR_SCALES(o) (GTK_CHECK_CAST((o), SP_TYPE_COLOR_SCALES, SPColorScales)) -#define SP_COLOR_SCALES_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_COLOR_SCALES, SPColorScalesClass)) -#define SP_IS_COLOR_SCALES(o) (GTK_CHECK_TYPE((o), SP_TYPE_COLOR_SCALES)) -#define SP_IS_COLOR_SCALES_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_COLOR_SCALES)) +#define SP_COLOR_SCALES(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_COLOR_SCALES, SPColorScales)) +#define SP_COLOR_SCALES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_COLOR_SCALES, SPColorScalesClass)) +#define SP_IS_COLOR_SCALES(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COLOR_SCALES)) +#define SP_IS_COLOR_SCALES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COLOR_SCALES)) struct SPColorScales { SPColorSelector parent; diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index 2030d02ff..c27cad45f 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -58,10 +58,10 @@ private: #define SP_TYPE_COLOR_SELECTOR (sp_color_selector_get_type ()) -#define SP_COLOR_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_SELECTOR, SPColorSelector)) -#define SP_COLOR_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_SELECTOR, SPColorSelectorClass)) -#define SP_IS_COLOR_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_SELECTOR)) -#define SP_IS_COLOR_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_SELECTOR)) +#define SP_COLOR_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_SELECTOR, SPColorSelector)) +#define SP_COLOR_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_SELECTOR, SPColorSelectorClass)) +#define SP_IS_COLOR_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_SELECTOR)) +#define SP_IS_COLOR_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_SELECTOR)) #define SP_COLOR_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SP_TYPE_COLOR_SELECTOR, SPColorSelectorClass)) struct SPColorSelector { diff --git a/src/widgets/sp-color-slider.h b/src/widgets/sp-color-slider.h index 8b0bcb9a9..b8cfaf869 100644 --- a/src/widgets/sp-color-slider.h +++ b/src/widgets/sp-color-slider.h @@ -22,10 +22,10 @@ struct SPColorSlider; struct SPColorSliderClass; #define SP_TYPE_COLOR_SLIDER (sp_color_slider_get_type ()) -#define SP_COLOR_SLIDER(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_SLIDER, SPColorSlider)) -#define SP_COLOR_SLIDER_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_SLIDER, SPColorSliderClass)) -#define SP_IS_COLOR_SLIDER(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_SLIDER)) -#define SP_IS_COLOR_SLIDER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_SLIDER)) +#define SP_COLOR_SLIDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_SLIDER, SPColorSlider)) +#define SP_COLOR_SLIDER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_SLIDER, SPColorSliderClass)) +#define SP_IS_COLOR_SLIDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_SLIDER)) +#define SP_IS_COLOR_SLIDER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_SLIDER)) struct SPColorSlider { GtkWidget widget; diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index 553f351a0..d8bcb730b 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -53,10 +53,10 @@ private: #define SP_TYPE_COLOR_WHEEL_SELECTOR (sp_color_wheel_selector_get_type ()) -#define SP_COLOR_WHEEL_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_WHEEL_SELECTOR, SPColorWheelSelector)) -#define SP_COLOR_WHEEL_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_WHEEL_SELECTOR, SPColorWheelSelectorClass)) -#define SP_IS_COLOR_WHEEL_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_WHEEL_SELECTOR)) -#define SP_IS_COLOR_WHEEL_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_WHEEL_SELECTOR)) +#define SP_COLOR_WHEEL_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_WHEEL_SELECTOR, SPColorWheelSelector)) +#define SP_COLOR_WHEEL_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_WHEEL_SELECTOR, SPColorWheelSelectorClass)) +#define SP_IS_COLOR_WHEEL_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_WHEEL_SELECTOR)) +#define SP_IS_COLOR_WHEEL_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_WHEEL_SELECTOR)) struct SPColorWheelSelector { SPColorSelector parent; diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index ba6baf972..decd9c056 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -16,10 +16,10 @@ #include <glib.h> #define SP_TYPE_WIDGET (sp_widget_get_type ()) -#define SP_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_WIDGET, SPWidget)) -#define SP_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_WIDGET, SPWidgetClass)) -#define SP_IS_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_WIDGET)) -#define SP_IS_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_WIDGET)) +#define SP_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_WIDGET, SPWidget)) +#define SP_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_WIDGET, SPWidgetClass)) +#define SP_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_WIDGET)) +#define SP_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_WIDGET)) #include <gtk/gtk.h> diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h index b437cabf0..de79c7a37 100644 --- a/src/widgets/sp-xmlview-attr-list.h +++ b/src/widgets/sp-xmlview-attr-list.h @@ -20,9 +20,9 @@ #define SP_TYPE_XMLVIEW_ATTR_LIST (sp_xmlview_attr_list_get_type ()) -#define SP_XMLVIEW_ATTR_LIST(o) (GTK_CHECK_CAST ((o), SP_TYPE_XMLVIEW_ATTR_LIST, SPXMLViewAttrList)) -#define SP_IS_XMLVIEW_ATTR_LIST(o) (GTK_CHECK_TYPE ((o), SP_TYPE_XMLVIEW_ATTR_LIST)) -#define SP_XMLVIEW_ATTR_LIST_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_ATTR_LIST)) +#define SP_XMLVIEW_ATTR_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_ATTR_LIST, SPXMLViewAttrList)) +#define SP_IS_XMLVIEW_ATTR_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_XMLVIEW_ATTR_LIST)) +#define SP_XMLVIEW_ATTR_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_ATTR_LIST)) struct SPXMLViewAttrList { diff --git a/src/widgets/sp-xmlview-content.h b/src/widgets/sp-xmlview-content.h index 7f8a6d3ef..fe26891d0 100644 --- a/src/widgets/sp-xmlview-content.h +++ b/src/widgets/sp-xmlview-content.h @@ -24,9 +24,9 @@ #define SP_TYPE_XMLVIEW_CONTENT (sp_xmlview_content_get_type ()) -#define SP_XMLVIEW_CONTENT(o) (GTK_CHECK_CAST ((o), SP_TYPE_XMLVIEW_CONTENT, SPXMLViewContent)) -#define SP_IS_XMLVIEW_CONTENT(o) (GTK_CHECK_TYPE ((o), SP_TYPE_XMLVIEW_CONTENT)) -#define SP_XMLVIEW_CONTENT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_CONTENT)) +#define SP_XMLVIEW_CONTENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_CONTENT, SPXMLViewContent)) +#define SP_IS_XMLVIEW_CONTENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_XMLVIEW_CONTENT)) +#define SP_XMLVIEW_CONTENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_CONTENT)) struct SPXMLViewContent { diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index 89f4af547..2b04e79eb 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -20,9 +20,9 @@ #define SP_TYPE_XMLVIEW_TREE (sp_xmlview_tree_get_type ()) -#define SP_XMLVIEW_TREE(o) (GTK_CHECK_CAST ((o), SP_TYPE_XMLVIEW_TREE, SPXMLViewTree)) -#define SP_IS_XMLVIEW_TREE(o) (GTK_CHECK_TYPE ((o), SP_TYPE_XMLVIEW_TREE)) -#define SP_XMLVIEW_TREE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_TREE)) +#define SP_XMLVIEW_TREE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_TREE, SPXMLViewTree)) +#define SP_IS_XMLVIEW_TREE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_XMLVIEW_TREE)) +#define SP_XMLVIEW_TREE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_XMLVIEW_TREE)) struct SPXMLViewTree; struct SPXMLViewTreeClass; diff --git a/src/zoom-context.h b/src/zoom-context.h index 133267135..e36dc3fbe 100644 --- a/src/zoom-context.h +++ b/src/zoom-context.h @@ -16,8 +16,8 @@ #include "event-context.h" #define SP_TYPE_ZOOM_CONTEXT (sp_zoom_context_get_type ()) -#define SP_ZOOM_CONTEXT(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_ZOOM_CONTEXT, SPZoomContext)) -#define SP_IS_ZOOM_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_ZOOM_CONTEXT)) +#define SP_ZOOM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ZOOM_CONTEXT, SPZoomContext)) +#define SP_IS_ZOOM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ZOOM_CONTEXT)) class SPZoomContext; class SPZoomContextClass; -- cgit v1.2.3 From 2402528197627887e374dd2a4269dfdeb19acc58 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 15 Jun 2011 01:13:10 +0100 Subject: Clean up deprecated GTK_WIDGET API (bzr r10302.1.2) --- src/display/sp-canvas.cpp | 14 +++++++------- src/ege-color-prof-tracker.cpp | 2 +- src/extension/execution-env.cpp | 2 +- src/ige-mac-menu.c | 4 ++-- src/libgdl/gdl-dock-bar.c | 16 ++++++++-------- src/libgdl/gdl-dock-item-grip.c | 4 ++-- src/libgdl/gdl-dock-item.c | 36 ++++++++++++++++++------------------ src/libgdl/gdl-dock-tablabel.c | 6 +++--- src/libgdl/gdl-dock.c | 26 +++++++++++++------------- src/text-context.cpp | 2 +- src/ui/widget/dock-item.cpp | 2 +- src/widgets/desktop-widget.cpp | 16 ++++++++-------- src/widgets/eek-preview.cpp | 10 +++++----- src/widgets/font-selector.cpp | 8 ++++---- src/widgets/gradient-image.cpp | 6 +++--- src/widgets/icon.cpp | 10 +++++----- src/widgets/ruler.cpp | 4 ++-- src/widgets/sp-color-preview.cpp | 6 +++--- src/widgets/sp-color-slider.cpp | 4 ++-- src/widgets/sp-widget.cpp | 4 ++-- src/widgets/toolbox.cpp | 8 ++++---- 21 files changed, 95 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 20c21a8c3..e2220282d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -537,7 +537,7 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu { g_return_val_if_fail (item != NULL, -1); g_return_val_if_fail (SP_IS_CANVAS_ITEM (item), -1); - g_return_val_if_fail (GTK_WIDGET_MAPPED (item->canvas), -1); + g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), -1); if (item->canvas->grabbed_item) return -1; @@ -628,7 +628,7 @@ sp_canvas_item_grab_focus (SPCanvasItem *item) { g_return_if_fail (item != NULL); g_return_if_fail (SP_IS_CANVAS_ITEM (item)); - g_return_if_fail (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (item->canvas))); + g_return_if_fail (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas))); SPCanvasItem *focused_item = item->canvas->focused_item; @@ -1241,7 +1241,7 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED (widget)) { + if (gtk_widget_get_realized (widget)) { gdk_window_move_resize (widget->window, widget->allocation.x, widget->allocation.y, widget->allocation.width, widget->allocation.height); @@ -1967,7 +1967,7 @@ sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event) { SPCanvas *canvas = SP_CANVAS (widget); - if (!GTK_WIDGET_DRAWABLE (widget) || + if (!gtk_widget_is_drawable (widget) || (event->window != SP_CANVAS_WINDOW (canvas))) return FALSE; @@ -2121,7 +2121,7 @@ do_update (SPCanvas *canvas) } /* Paint if able to */ - if (GTK_WIDGET_DRAWABLE (canvas)) { + if (gtk_widget_is_drawable ( GTK_WIDGET (canvas))) { return paint (canvas); } @@ -2205,7 +2205,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, // scrolling without zoom; redraw only the newly exposed areas if ((dx != 0) || (dy != 0)) { canvas->is_scrolling = is_scrolling; - if (GTK_WIDGET_REALIZED (canvas)) { + if (gtk_widget_get_realized (GTK_WIDGET (canvas))) { gdk_window_scroll (SP_CANVAS_WINDOW (canvas), -dx, -dy); } } @@ -2254,7 +2254,7 @@ sp_canvas_request_redraw (SPCanvas *canvas, int x0, int y0, int x1, int y1) g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); - if (!GTK_WIDGET_DRAWABLE (canvas)) return; + if (!gtk_widget_is_drawable ( GTK_WIDGET (canvas))) return; if ((x0 >= x1) || (y0 >= y1)) return; bbox.x0 = x0; diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp index a6fcaa126..6aeb554f9 100644 --- a/src/ege-color-prof-tracker.cpp +++ b/src/ege-color-prof-tracker.cpp @@ -448,7 +448,7 @@ void target_hierarchy_changed_cb(GtkWidget* widget, GtkWidget* prev_top, gpointe { if ( !prev_top && gtk_widget_get_toplevel(widget) ) { GtkWidget* top = gtk_widget_get_toplevel(widget); - if ( GTK_WIDGET_TOPLEVEL(top) ) { + if ( gtk_widget_is_toplevel(top) ) { GtkWindow* win = GTK_WINDOW(top); g_signal_connect( G_OBJECT(win), "event-after", G_CALLBACK( event_after_cb ), user_data ); g_object_weak_ref( G_OBJECT(win), window_finalized, user_data ); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index a2550024a..b05685902 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -128,7 +128,7 @@ ExecutionEnv::createWorkingDialog (void) { SPDesktop *desktop = (SPDesktop *)_doc; GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget)); - if (!toplevel || !GTK_WIDGET_TOPLEVEL (toplevel)) + if (!toplevel || !gtk_widget_is_toplevel (toplevel)) return; Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false); diff --git a/src/ige-mac-menu.c b/src/ige-mac-menu.c index 29915d980..132817dea 100644 --- a/src/ige-mac-menu.c +++ b/src/ige-mac-menu.c @@ -667,10 +667,10 @@ sync_menu_shell (GtkMenuShell *menu_shell, if (GTK_IS_SEPARATOR_MENU_ITEM (menu_item)) attributes |= kMenuItemAttrSeparator; - if (!GTK_WIDGET_IS_SENSITIVE (menu_item)) + if (!gtk_widget_is_sensitive (menu_item)) attributes |= kMenuItemAttrDisabled; - if (!GTK_WIDGET_VISIBLE (menu_item)) + if (!gtk_widget_get_visible (menu_item)) attributes |= kMenuItemAttrHidden; InsertMenuItemTextWithCFString (carbon_menu, cfstr, diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 37710b693..1e694eec5 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -481,7 +481,7 @@ static void gdl_dock_bar_size_vrequest (GtkWidget *widget, child = children->data; children = children->next; - if (GTK_WIDGET_VISIBLE (child->widget)) + if (gtk_widget_get_visible (child->widget)) { gtk_widget_size_request (child->widget, &child_requisition); @@ -539,7 +539,7 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, child = children->data; children = children->next; - if (GTK_WIDGET_VISIBLE (child->widget)) + if (gtk_widget_get_visible (child->widget)) { nvis_children += 1; if (child->expand) @@ -577,7 +577,7 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, child = children->data; children = children->next; - if ((child->pack == GTK_PACK_START) && GTK_WIDGET_VISIBLE (child->widget)) + if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) { if (box->homogeneous) { @@ -636,7 +636,7 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, child = children->data; children = children->next; - if ((child->pack == GTK_PACK_END) && GTK_WIDGET_VISIBLE (child->widget)) + if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) { GtkRequisition child_requisition; gtk_widget_get_child_requisition (child->widget, &child_requisition); @@ -706,7 +706,7 @@ static void gdl_dock_bar_size_hrequest (GtkWidget *widget, child = children->data; children = children->next; - if (GTK_WIDGET_VISIBLE (child->widget)) + if (gtk_widget_get_visible (child->widget)) { GtkRequisition child_requisition; @@ -768,7 +768,7 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, child = children->data; children = children->next; - if (GTK_WIDGET_VISIBLE (child->widget)) + if (gtk_widget_get_visible (child->widget)) { nvis_children += 1; if (child->expand) @@ -806,7 +806,7 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, child = children->data; children = children->next; - if ((child->pack == GTK_PACK_START) && GTK_WIDGET_VISIBLE (child->widget)) + if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) { if (box->homogeneous) { @@ -869,7 +869,7 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, child = children->data; children = children->next; - if ((child->pack == GTK_PACK_END) && GTK_WIDGET_VISIBLE (child->widget)) + if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) { GtkRequisition child_requisition; gtk_widget_get_child_requisition (child->widget, &child_requisition); diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 3c6b4ac17..c51b782b3 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -59,10 +59,10 @@ gdl_dock_item_grip_get_title_area (GdlDockItemGrip *grip, alloc_height = MAX (grip->_priv->close_button->allocation.height, alloc_height); alloc_height = MAX (grip->_priv->iconify_button->allocation.height, alloc_height); - if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) { + if (gtk_widget_get_visible (grip->_priv->close_button)) { area->width -= grip->_priv->close_button->allocation.width; } - if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { + if (gtk_widget_get_visible (grip->_priv->iconify_button)) { area->width -= grip->_priv->iconify_button->allocation.width; } diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 862b90c0c..b0d97a06d 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -644,7 +644,7 @@ gdl_dock_item_remove (GtkContainer *container, item = GDL_DOCK_ITEM (container); if (item->_priv && widget == item->_priv->grip) { - gboolean grip_was_visible = GTK_WIDGET_VISIBLE (widget); + gboolean grip_was_visible = gtk_widget_get_visible (widget); gtk_widget_unparent (widget); item->_priv->grip = NULL; if (grip_was_visible) @@ -658,7 +658,7 @@ gdl_dock_item_remove (GtkContainer *container, g_return_if_fail (item->child == widget); - was_visible = GTK_WIDGET_VISIBLE (widget); + was_visible = gtk_widget_get_visible (widget); gtk_widget_unparent (widget); item->child = NULL; @@ -781,14 +781,14 @@ gdl_dock_item_size_allocate (GtkWidget *widget, item->_priv->preferred_height = -1; item->_priv->preferred_width = -1; - if (GTK_WIDGET_REALIZED (widget)) + if (gtk_widget_get_realized (widget)) gdk_window_move_resize (widget->window, widget->allocation.x, widget->allocation.y, widget->allocation.width, widget->allocation.height); - if (item->child && GTK_WIDGET_VISIBLE (item->child)) { + if (item->child && gtk_widget_get_visible (item->child)) { GtkAllocation child_allocation; int border_width; @@ -843,13 +843,13 @@ gdl_dock_item_map (GtkWidget *widget) gdk_window_show (widget->window); if (item->child - && GTK_WIDGET_VISIBLE (item->child) - && !GTK_WIDGET_MAPPED (item->child)) + && gtk_widget_get_visible (item->child) + && !gtk_widget_get_mapped (item->child)) gtk_widget_map (item->child); if (item->_priv->grip - && GTK_WIDGET_VISIBLE (item->_priv->grip) - && !GTK_WIDGET_MAPPED (item->_priv->grip)) + && gtk_widget_get_visible (item->_priv->grip) + && !gtk_widget_get_mapped (item->_priv->grip)) gtk_widget_map (item->_priv->grip); } @@ -906,7 +906,7 @@ gdl_dock_item_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, - GTK_WIDGET_STATE (item)); + gtk_widget_get_state (GTK_WIDGET(item))); gdk_window_set_back_pixmap (widget->window, NULL, TRUE); if (item->child) @@ -923,10 +923,10 @@ gdl_dock_item_style_set (GtkWidget *widget, g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) { + if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) { gtk_style_set_background (widget->style, widget->window, widget->state); - if (GTK_WIDGET_DRAWABLE (widget)) + if (gtk_widget_is_drawable (widget)) gdk_window_clear (widget->window); } } @@ -941,7 +941,7 @@ gdl_dock_item_paint (GtkWidget *widget, gtk_paint_box (widget->style, widget->window, - GTK_WIDGET_STATE (widget), + gtk_widget_get_state (widget), GTK_SHADOW_NONE, &event->area, widget, "dockitem", @@ -956,7 +956,7 @@ gdl_dock_item_expose (GtkWidget *widget, g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - if (GTK_WIDGET_DRAWABLE (widget) && event->window == widget->window) { + if (gtk_widget_is_drawable (widget) && event->window == widget->window) { gdl_dock_item_paint (widget, event); GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event)); } @@ -1426,7 +1426,7 @@ gdl_dock_item_dock (GdlDockObject *object, gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent)); /* show automatic object */ - if (GTK_WIDGET_VISIBLE (object)) + if (gtk_widget_get_visible (GTK_WIDGET (object))) gtk_widget_show (GTK_WIDGET (new_parent)); /* use extra docking parameter */ @@ -1506,7 +1506,7 @@ gdl_dock_item_drag_start (GdlDockItem *item) { GdkCursor *fleur; - if (!GTK_WIDGET_REALIZED (item)) + if (!gtk_widget_get_realized (GTK_WIDGET (item))) gtk_widget_realize (GTK_WIDGET (item)); GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_DRAG); @@ -1632,7 +1632,7 @@ gdl_dock_item_real_set_orientation (GdlDockItem *item, { item->orientation = orientation; - if (GTK_WIDGET_DRAWABLE (item)) + if (gtk_widget_is_drawable (GTK_WIDGET (item))) gtk_widget_queue_draw (GTK_WIDGET (item)); gtk_widget_queue_resize (GTK_WIDGET (item)); } @@ -2030,8 +2030,8 @@ gdl_dock_item_or_child_has_focus (GdlDockItem *item) item_child = GTK_CONTAINER (item_child)->focus_child) ; item_or_child_has_focus = - (GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (item)) || - (GTK_IS_WIDGET (item_child) && GTK_WIDGET_HAS_FOCUS (item_child))); + (gtk_widget_has_focus (GTK_WIDGET (item)) || + (GTK_IS_WIDGET (item_child) && gtk_widget_has_focus (item_child))); return item_or_child_has_focus; } diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c index adba98b0d..790bf7612 100644 --- a/src/libgdl/gdl-dock-tablabel.c +++ b/src/libgdl/gdl-dock-tablabel.c @@ -324,14 +324,14 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED (widget)) + if (gtk_widget_get_realized (widget)) gdk_window_move_resize (tablabel->event_window, allocation->x, allocation->y, allocation->width, allocation->height); - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { + if (bin->child && gtk_widget_get_visible (bin->child)) { GtkAllocation child_allocation; child_allocation.x = widget->allocation.x + border_width; @@ -386,7 +386,7 @@ gdl_dock_tablabel_expose (GtkWidget *widget, g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) { + if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) { GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event)); gdl_dock_tablabel_paint (widget, event); }; diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index da0f8c5e3..c366ed69b 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -561,7 +561,7 @@ gdl_dock_size_request (GtkWidget *widget, border_width = container->border_width; /* make request to root */ - if (dock->root && GTK_WIDGET_VISIBLE (dock->root)) + if (dock->root && gtk_widget_get_visible (dock->root)) gtk_widget_size_request (GTK_WIDGET (dock->root), requisition); else { requisition->width = 0; @@ -597,7 +597,7 @@ gdl_dock_size_allocate (GtkWidget *widget, allocation->width = MAX (1, allocation->width - 2 * border_width); allocation->height = MAX (1, allocation->height - 2 * border_width); - if (dock->root && GTK_WIDGET_VISIBLE (dock->root)) + if (dock->root && gtk_widget_get_visible (dock->root)) gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation); } @@ -616,7 +616,7 @@ gdl_dock_map (GtkWidget *widget) if (dock->root) { child = GTK_WIDGET (dock->root); - if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child)) + if (gtk_widget_get_visible (child) && !gtk_widget_get_mapped (child)) gtk_widget_map (child); } } @@ -636,7 +636,7 @@ gdl_dock_unmap (GtkWidget *widget) if (dock->root) { child = GTK_WIDGET (dock->root); - if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_MAPPED (child)) + if (gtk_widget_get_visible (child) && gtk_widget_get_mapped (child)) gtk_widget_unmap (child); } @@ -720,14 +720,14 @@ gdl_dock_remove (GtkContainer *container, g_return_if_fail (widget != NULL); dock = GDL_DOCK (container); - was_visible = GTK_WIDGET_VISIBLE (widget); + was_visible = gtk_widget_get_visible (widget); if (GTK_WIDGET (dock->root) == widget) { dock->root = NULL; GDL_DOCK_OBJECT_UNSET_FLAGS (widget, GDL_DOCK_ATTACHED); gtk_widget_unparent (widget); - if (was_visible && GTK_WIDGET_VISIBLE (GTK_WIDGET (container))) + if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) gtk_widget_queue_resize (GTK_WIDGET (dock)); } } @@ -927,15 +927,15 @@ gdl_dock_dock (GdlDockObject *object, /* Realize the item (create its corresponding GdkWindow) when GdlDock has been realized. */ - if (GTK_WIDGET_REALIZED (dock)) + if (gtk_widget_get_realized (dock)) gtk_widget_realize (widget); /* Map the widget if it's visible and the parent is visible and has been mapped. This is done to make sure that the GdkWindow is visible. */ - if (GTK_WIDGET_VISIBLE (dock) && - GTK_WIDGET_VISIBLE (widget)) { - if (GTK_WIDGET_MAPPED (dock)) + if (gtk_widget_get_visible (dock) && + gtk_widget_get_visible (widget)) { + if (gtk_widget_get_mapped (dock)) gtk_widget_map (widget); /* Make the widget resize. */ @@ -1258,9 +1258,9 @@ gdl_dock_add_floating_item (GdlDock *dock, "floaty", y, NULL)); - if (GTK_WIDGET_VISIBLE (dock)) { + if (gtk_widget_get_visible (dock)) { gtk_widget_show (GTK_WIDGET (new_dock)); - if (GTK_WIDGET_MAPPED (dock)) + if (gtk_widget_get_mapped (dock)) gtk_widget_map (GTK_WIDGET (new_dock)); /* Make the widget resize. */ @@ -1335,7 +1335,7 @@ gdl_dock_xor_rect (GdlDock *dock, widget = GTK_WIDGET (dock); if (!dock->_priv->xor_gc) { - if (GTK_WIDGET_REALIZED (widget)) { + if (gtk_widget_get_realized (widget)) { GdkGCValues values; values.function = GDK_INVERT; diff --git a/src/text-context.cpp b/src/text-context.cpp index a7c6772e5..b709d4d24 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -234,7 +234,7 @@ sp_text_context_setup(SPEventContext *ec) g_signal_connect(G_OBJECT(canvas), "focus_out_event", G_CALLBACK(sptc_focus_out), tc); g_signal_connect(G_OBJECT(tc->imc), "commit", G_CALLBACK(sptc_commit), tc); - if (GTK_WIDGET_HAS_FOCUS(canvas)) { + if (gtk_widget_has_focus(canvas)) { sptc_focus_in(canvas, NULL, tc); } } diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 72a20c385..87f4d0840 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -262,7 +262,7 @@ DockItem::present() void DockItem::grab_focus() { - if (GTK_WIDGET_REALIZED (_gdl_dock_item)) { + if (gtk_widget_get_realized (_gdl_dock_item)) { // make sure the window we're in is present Gtk::Widget *toplevel = getWidget().get_toplevel(); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 69b27d6e4..0d890fa86 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -213,7 +213,7 @@ void CMSPrefWatcher::_setCmsSensitive(bool enabled) #if ENABLE_LCMS for ( std::list<SPDesktopWidget*>::iterator it = _widget_list.begin(); it != _widget_list.end(); ++it ) { SPDesktopWidget *dtw = *it; - if ( GTK_WIDGET_SENSITIVE( dtw->cms_adjust ) != enabled ) { + if ( gtk_widget_get_sensitive( dtw->cms_adjust ) != enabled ) { cms_adjust_set_sensitive( dtw, enabled ); } } @@ -231,7 +231,7 @@ SPDesktopWidget::setMessage (Inkscape::MessageType type, const gchar *message) gtk_label_set_markup (sb, message ? message : ""); // make sure the important messages are displayed immediately! - if (type == Inkscape::IMMEDIATE_MESSAGE && GTK_WIDGET_DRAWABLE (GTK_WIDGET(sb))) { + if (type == Inkscape::IMMEDIATE_MESSAGE && gtk_widget_is_drawable (GTK_WIDGET(sb))) { gtk_widget_queue_draw(GTK_WIDGET(sb)); gdk_window_process_updates(GTK_WIDGET(sb)->window, TRUE); } @@ -697,7 +697,7 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) return; } - if (GTK_WIDGET_REALIZED (widget)) { + if (gtk_widget_get_realized (widget)) { Geom::Rect const area = dtw->desktop->get_display_area(); double zoom = dtw->desktop->current_zoom(); @@ -1077,7 +1077,7 @@ SPDesktopWidget::letZoomGrabFocus() void SPDesktopWidget::getWindowGeometry (gint &x, gint &y, gint &w, gint &h) { - gboolean vis = GTK_WIDGET_VISIBLE (this); + gboolean vis = gtk_widget_get_visible (GTK_WIDGET(this)); (void)vis; // TODO figure out why it is here but not used. Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); @@ -1803,7 +1803,7 @@ void sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (GTK_WIDGET_VISIBLE (dtw->hruler)) { + if (gtk_widget_get_visible (dtw->hruler)) { gtk_widget_hide_all (dtw->hruler); gtk_widget_hide_all (dtw->vruler); prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", false); @@ -1818,7 +1818,7 @@ void sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (GTK_WIDGET_VISIBLE (dtw->hscrollbar)) { + if (gtk_widget_get_visible (dtw->hscrollbar)) { gtk_widget_hide_all (dtw->hscrollbar); gtk_widget_hide_all (dtw->vscrollbar_box); gtk_widget_hide_all( dtw->cms_adjust ); @@ -1834,7 +1834,7 @@ sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw) void sp_desktop_widget_toggle_color_prof_adj( SPDesktopWidget *dtw ) { - if ( GTK_WIDGET_SENSITIVE( dtw->cms_adjust ) ) { + if ( gtk_widget_get_sensitive( dtw->cms_adjust ) ) { if ( SP_BUTTON_IS_DOWN(dtw->cms_adjust) ) { sp_button_toggle_set_down( SP_BUTTON(dtw->cms_adjust), FALSE ); } else { @@ -1848,7 +1848,7 @@ void sp_spw_toggle_menubar (SPDesktopWidget *dtw, bool is_fullscreen) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (GTK_WIDGET_VISIBLE (dtw->menubar)) { + if (gtk_widget_get_visible (dtw->menubar)) { gtk_widget_hide_all (dtw->menubar); prefs->setBool(is_fullscreen ? "/fullscreen/menu/state" : "/window/menu/state", false); } else { diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 816c4bf50..1ca656ae1 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -192,7 +192,7 @@ static guint eek_preview_signals[LAST_SIGNAL] = { 0 }; gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) { -/* g_message("Exposed!!! %s", GTK_WIDGET_HAS_FOCUS(widget) ? "XXX" : "---" ); */ +/* g_message("Exposed!!! %s", gtk_widget_has_focus(widget) ? "XXX" : "---" ); */ gint insetX = 0; gint insetY = 0; @@ -218,13 +218,13 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) } */ - if ( GTK_WIDGET_DRAWABLE( widget ) ) { + if ( gtk_widget_is_drawable( widget ) ) { GtkStyle* style = gtk_widget_get_style( widget ); if ( insetX > 0 || insetY > 0 ) { gtk_paint_flat_box( style, widget->window, - (GtkStateType)GTK_WIDGET_STATE(widget), + (GtkStateType)gtk_widget_get_state(widget), GTK_SHADOW_NONE, NULL, widget, @@ -379,7 +379,7 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) } - if ( GTK_WIDGET_HAS_FOCUS(widget) ) { + if ( gtk_widget_has_focus(widget) ) { gtk_paint_focus( style, widget->window, GTK_STATE_NORMAL, @@ -437,7 +437,7 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton* if ( gtk_get_event_widget( (GdkEvent*)event ) == widget ) { EekPreview* preview = EEK_PREVIEW(widget); - if ( preview->_takesFocus && !GTK_WIDGET_HAS_FOCUS(widget) ) { + if ( preview->_takesFocus && !gtk_widget_has_focus(widget) ) { gtk_widget_grab_focus(widget); } diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index f493c393a..8c6afeb4c 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -620,7 +620,7 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) { SPFontPreview *fprev = SP_FONT_PREVIEW(widget); - if (GTK_WIDGET_DRAWABLE (widget)) { + if (gtk_widget_is_drawable (widget)) { if (fprev->rfont) { int glyphs[SPFP_MAX_LEN]; @@ -811,13 +811,13 @@ void sp_font_preview_set_font(SPFontPreview *fprev, font_instance *font, SPFontS fprev->rfont = fprev->font->RasterFont(flip, 0); } - if (GTK_WIDGET_DRAWABLE (fprev)) gtk_widget_queue_draw (GTK_WIDGET (fprev)); + if (gtk_widget_is_drawable (GTK_WIDGET (fprev))) gtk_widget_queue_draw (GTK_WIDGET (fprev)); } void sp_font_preview_set_rgba32(SPFontPreview *fprev, guint32 rgba) { fprev->rgba = rgba; - if (GTK_WIDGET_DRAWABLE (fprev)) { + if (gtk_widget_is_drawable (GTK_WIDGET (fprev))) { gtk_widget_queue_draw (GTK_WIDGET (fprev)); } } @@ -830,7 +830,7 @@ void sp_font_preview_set_phrase(SPFontPreview *fprev, const gchar *phrase) } else { fprev->phrase = NULL; } - if (GTK_WIDGET_DRAWABLE(fprev)) { + if (gtk_widget_is_drawable( GTK_WIDGET (fprev))) { gtk_widget_queue_draw (GTK_WIDGET (fprev)); } } diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 62a063755..f3a471bfc 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -165,7 +165,7 @@ sp_gradient_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED (widget)) { + if (gtk_widget_get_realized (widget)) { g_free (image->px); image->px = g_new (guchar, 3 * VBLOCK * allocation->width); } @@ -180,7 +180,7 @@ sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event) image = SP_GRADIENT_IMAGE (widget); - if (GTK_WIDGET_DRAWABLE (widget)) { + if (gtk_widget_is_drawable (widget)) { gint x0, y0, x1, y1; x0 = MAX (event->area.x, widget->allocation.x); y0 = MAX (event->area.y, widget->allocation.y); @@ -288,7 +288,7 @@ sp_gradient_image_update (SPGradientImage *image) nr_pixblock_release (&pb); } - if (GTK_WIDGET_DRAWABLE (image)) { + if (gtk_widget_is_drawable (GTK_WIDGET (image))) { gtk_widget_queue_draw (GTK_WIDGET (image)); } } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index c2634f6a1..b1d5c73bb 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -176,7 +176,7 @@ void IconImpl::classInit(SPIconClass *klass) void IconImpl::init(SPIcon *icon) { - GTK_WIDGET_FLAGS(icon) |= GTK_NO_WINDOW; + gtk_widget_set_has_window (GTK_WIDGET (icon), FALSE); icon->lsize = Inkscape::ICON_SIZE_BUTTON; icon->psize = 0; icon->name = 0; @@ -224,14 +224,14 @@ void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) { widget->allocation = *allocation; - if (GTK_WIDGET_DRAWABLE(widget)) { + if (gtk_widget_is_drawable(widget)) { gtk_widget_queue_draw(widget); } } int IconImpl::expose(GtkWidget *widget, GdkEventExpose *event) { - if ( GTK_WIDGET_DRAWABLE(widget) ) { + if ( gtk_widget_is_drawable(widget) ) { SPIcon *icon = SP_ICON(widget); if ( !icon->pb ) { fetchPixbuf( icon ); @@ -995,13 +995,13 @@ void IconImpl::paint(SPIcon *icon, GdkRectangle const */*area*/) bool unref_image = false; /* copied from the expose function of GtkImage */ - if (GTK_WIDGET_STATE (icon) != GTK_STATE_NORMAL && image) { + if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) { GtkIconSource *source = gtk_icon_source_new(); gtk_icon_source_set_pixbuf(source, icon->pb); gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used gtk_icon_source_set_size_wildcarded(source, FALSE); image = gtk_style_render_icon (widget.style, source, gtk_widget_get_direction(&widget), - (GtkStateType) GTK_WIDGET_STATE(&widget), (GtkIconSize)-1, &widget, "gtk-image"); + (GtkStateType) gtk_widget_get_state(&widget), (GtkIconSize)-1, &widget, "gtk-image"); gtk_icon_source_free(source); unref_image = true; } diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index dd0336413..704d395f7 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -246,7 +246,7 @@ sp_ruler_common_draw_ticks (GtkRuler *ruler) g_return_if_fail (ruler != NULL); - if (!GTK_WIDGET_DRAWABLE (ruler)) + if (!gtk_widget_is_drawable (GTK_WIDGET (ruler))) return; g_object_get(G_OBJECT(ruler), "orientation", &orientation, NULL); @@ -425,6 +425,6 @@ sp_ruler_set_metric (GtkRuler *ruler, ruler->metric = const_cast<GtkRulerMetric *>(&sp_ruler_metrics[metric]); - if (GTK_WIDGET_DRAWABLE (ruler)) + if (gtk_widget_is_drawable (GTK_WIDGET (ruler))) gtk_widget_queue_draw (GTK_WIDGET (ruler)); } diff --git a/src/widgets/sp-color-preview.cpp b/src/widgets/sp-color-preview.cpp index aad850b7c..433301f85 100644 --- a/src/widgets/sp-color-preview.cpp +++ b/src/widgets/sp-color-preview.cpp @@ -110,7 +110,7 @@ sp_color_preview_size_allocate (GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; - if (GTK_WIDGET_DRAWABLE (image)) { + if (gtk_widget_is_drawable (GTK_WIDGET (image))) { gtk_widget_queue_draw (GTK_WIDGET (image)); } } @@ -122,7 +122,7 @@ sp_color_preview_expose (GtkWidget *widget, GdkEventExpose *event) cp = SP_COLOR_PREVIEW (widget); - if (GTK_WIDGET_DRAWABLE (widget)) { + if (gtk_widget_is_drawable (widget)) { sp_color_preview_paint (cp, &event->area); } @@ -146,7 +146,7 @@ sp_color_preview_set_rgba32 (SPColorPreview *cp, guint32 rgba) { cp->rgba = rgba; - if (GTK_WIDGET_DRAWABLE (cp)) { + if (gtk_widget_is_drawable (GTK_WIDGET (cp))) { gtk_widget_queue_draw (GTK_WIDGET (cp)); } } diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index efea69590..7b365bc73 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -235,7 +235,7 @@ sp_color_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED (widget)) { + if (gtk_widget_get_realized (widget)) { /* Resize GdkWindow */ gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height); } @@ -248,7 +248,7 @@ sp_color_slider_expose (GtkWidget *widget, GdkEventExpose *event) slider = SP_COLOR_SLIDER (widget); - if (GTK_WIDGET_DRAWABLE (widget)) { + if (gtk_widget_is_drawable (widget)) { gint width, height; width = widget->allocation.width; height = widget->allocation.height; diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index fd20d8e17..d5877db99 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -188,7 +188,7 @@ sp_widget_expose (GtkWidget *widget, GdkEventExpose *event) gtk_container_propagate_expose (GTK_CONTAINER(widget), bin->child, event); } /* - if ((bin->child) && (GTK_WIDGET_NO_WINDOW (bin->child))) { + if ((bin->child) && (!gtk_widget_get_has_window (bin->child))) { GdkEventExpose ce; ce = *event; gtk_widget_event (bin->child, (GdkEvent *) &ce); @@ -237,7 +237,7 @@ sp_widget_construct_global (SPWidget *spw, Inkscape::Application *inkscape) g_return_val_if_fail (!spw->inkscape, NULL); spw->inkscape = inkscape; - if (GTK_WIDGET_VISIBLE (spw)) { + if (gtk_widget_get_visible (GTK_WIDGET(spw))) { g_signal_connect (G_OBJECT (inkscape), "modify_selection", G_CALLBACK (sp_widget_modify_selection), spw); g_signal_connect (G_OBJECT (inkscape), "change_selection", G_CALLBACK (sp_widget_change_selection), spw); g_signal_connect (G_OBJECT (inkscape), "set_selection", G_CALLBACK (sp_widget_set_selection), spw); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 30fb753de..67c15139f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1794,7 +1794,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati { #if DUMP_DETAILS g_message("Set orientation for %p to be %d", toolbox, orientation); - GType type = GTK_WIDGET_TYPE(toolbox); + GType type = G_OBJECT_TYPE(toolbox); g_message(" [%s]", g_type_name(type)); g_message(" %p", g_object_get_data(G_OBJECT(toolbox), BAR_ID_KEY)); #endif @@ -1809,7 +1809,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox)); if (child) { #if DUMP_DETAILS - GType type2 = GTK_WIDGET_TYPE(child); + GType type2 = G_OBJECT_TYPE(child); g_message(" child [%s]", g_type_name(type2)); #endif // DUMP_DETAILS @@ -1823,7 +1823,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati for (GList* curr = children; curr; curr = g_list_next(curr)) { GtkWidget* child2 = GTK_WIDGET(curr->data); #if DUMP_DETAILS - GType type3 = GTK_WIDGET_TYPE(child2); + GType type3 = G_OBJECT_TYPE(child2); g_message(" child2 [%s]", g_type_name(type3)); #endif // DUMP_DETAILS @@ -1833,7 +1833,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati for (GList* curr2 = children2; curr2; curr2 = g_list_next(curr2)) { GtkWidget* child3 = GTK_WIDGET(curr2->data); #if DUMP_DETAILS - GType type4 = GTK_WIDGET_TYPE(child3); + GType type4 = G_OBJECT_TYPE(child3); g_message(" child3 [%s]", g_type_name(type4)); #endif // DUMP_DETAILS if (GTK_IS_TOOLBAR(child3)) { -- cgit v1.2.3 From 4294089d059618544c060911e2eb9663ee76c666 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Wed, 15 Jun 2011 20:40:46 +0200 Subject: add preference for relative guideline rotation snapping (see rev 10303) (bzr r10307) --- src/desktop-events.cpp | 28 ++++++++++++++++++++-------- src/ui/dialog/inkscape-preferences.cpp | 5 ++++- src/ui/dialog/inkscape-preferences.h | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index a0ceb77e3..eb2b3a093 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -319,11 +319,17 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) if (event->motion.state & GDK_CONTROL_MASK) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12)); + bool const relative_snaps = abs(prefs->getBool("/options/relativeguiderotationsnap/value", false)); if (snaps) { - Geom::Angle orig_angle(guide->normal_to_line); - Geom::Angle snap_angle = angle - orig_angle; - double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); - angle = (M_PI / snaps) * sections + orig_angle.radians0(); + if (relative_snaps) { + Geom::Angle orig_angle(guide->normal_to_line); + Geom::Angle snap_angle = angle - orig_angle; + double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); + angle = (M_PI / snaps) * sections + orig_angle.radians0(); + } else { + double sections = floor(angle.radians0() * snaps / M_PI + .5); + angle = (M_PI / snaps) * sections; + } } } sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), false); @@ -387,11 +393,17 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) if (event->motion.state & GDK_CONTROL_MASK) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12)); + bool const relative_snaps = abs(prefs->getBool("/options/relativeguiderotationsnap/value", false)); if (snaps) { - Geom::Angle orig_angle(guide->normal_to_line); - Geom::Angle snap_angle = angle - orig_angle; - double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); - angle = (M_PI / snaps) * sections + orig_angle.radians0(); + if (relative_snaps) { + Geom::Angle orig_angle(guide->normal_to_line); + Geom::Angle snap_angle = angle - orig_angle; + double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); + angle = (M_PI / snaps) * sections + orig_angle.radians0(); + } else { + double sections = floor(angle.radians0() * snaps / M_PI + .5); + angle = (M_PI / snaps) * sections; + } } } sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), true); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index b8b86fac1..52c434961 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -7,7 +7,7 @@ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Bruno Dilly <bruno.dilly@gmail.com> * - * Copyright (C) 2004-2007 Authors + * Copyright (C) 2004-2011 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -270,6 +270,9 @@ void InkscapePreferences::initPageSteps() _steps_rot_snap.init("/options/rotationsnapsperpi/value", labels, values, num_items, 12); _page_steps.add_line( false, _("Rotation snaps every:"), _steps_rot_snap, _("degrees"), _("Rotating with Ctrl pressed snaps every that much degrees; also, pressing [ or ] rotates by this amount"), false); + _steps_rot_relative.init ( _("Relative snapping of guideline angles"), "/options/relativeguiderotationsnap/value", false); + _page_steps.add_line( false, "", _steps_rot_relative, "", + _("When on, the snap angles when rotating a guideline will be relative to the original angle")); _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true); _page_steps.add_line( false, _("Zoom in/out by:"), _steps_zoom, _("%"), _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 9e51fbf0a..13851e525 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -179,6 +179,7 @@ protected: UI::Widget::PrefCheckButton _snap_mouse_pointer; UI::Widget::PrefCombo _steps_rot_snap; + UI::Widget::PrefCheckButton _steps_rot_relative; UI::Widget::PrefCheckButton _steps_compass; UI::Widget::PrefSpinUnit _steps_arrow; UI::Widget::PrefSpinUnit _steps_scale; -- cgit v1.2.3 From ae9ad270fbb639dd75682e4c808ec656ef9dee6a Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Wed, 15 Jun 2011 23:38:26 -0700 Subject: Fix i18n macro include. (bzr r10309) --- src/widgets/ege-paint-def.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp index 2fc6927df..9eb54b039 100644 --- a/src/widgets/ege-paint-def.cpp +++ b/src/widgets/ege-paint-def.cpp @@ -50,6 +50,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <glibmm/i18n.h> #include <glibmm/stringutils.h> #if !defined(_) -- cgit v1.2.3 From 2b8e47a2b1d32186fd64d7bababa4481bff2ad01 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Wed, 15 Jun 2011 23:48:54 -0700 Subject: Conditionalize compilation of image magick sources in cmake. (bzr r10310) --- src/extension/CMakeLists.txt | 155 +++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 8a1ba37dc..60de65416 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -50,43 +50,6 @@ set(extension_SRC internal/javafx-out.cpp internal/svg.cpp internal/svgz.cpp - internal/wpg-input.cpp - - internal/bitmap/adaptiveThreshold.cpp - internal/bitmap/addNoise.cpp - internal/bitmap/blur.cpp - internal/bitmap/channel.cpp - internal/bitmap/charcoal.cpp - internal/bitmap/colorize.cpp - internal/bitmap/contrast.cpp - internal/bitmap/cycleColormap.cpp - internal/bitmap/despeckle.cpp - internal/bitmap/edge.cpp - internal/bitmap/emboss.cpp - internal/bitmap/enhance.cpp - internal/bitmap/equalize.cpp - internal/bitmap/gaussianBlur.cpp - internal/bitmap/imagemagick.cpp - internal/bitmap/implode.cpp - internal/bitmap/level.cpp - internal/bitmap/levelChannel.cpp - internal/bitmap/medianFilter.cpp - internal/bitmap/modulate.cpp - internal/bitmap/negate.cpp - internal/bitmap/normalize.cpp - internal/bitmap/oilPaint.cpp - internal/bitmap/opacity.cpp - internal/bitmap/raise.cpp - internal/bitmap/reduceNoise.cpp - internal/bitmap/sample.cpp - internal/bitmap/shade.cpp - internal/bitmap/sharpen.cpp - internal/bitmap/solarize.cpp - internal/bitmap/spread.cpp - internal/bitmap/swirl.cpp - internal/bitmap/threshold.cpp - internal/bitmap/unsharpmask.cpp - internal/bitmap/wave.cpp internal/filter/filter-all.cpp internal/filter/filter-file.cpp @@ -141,41 +104,6 @@ set(extension_SRC implementation/script.h implementation/xslt.h - internal/bitmap/adaptiveThreshold.h - internal/bitmap/addNoise.h - internal/bitmap/blur.h - internal/bitmap/channel.h - internal/bitmap/charcoal.h - internal/bitmap/colorize.h - internal/bitmap/contrast.h - internal/bitmap/cycleColormap.h - internal/bitmap/despeckle.h - internal/bitmap/edge.h - internal/bitmap/emboss.h - internal/bitmap/enhance.h - internal/bitmap/equalize.h - internal/bitmap/gaussianBlur.h - internal/bitmap/imagemagick.h - internal/bitmap/implode.h - internal/bitmap/level.h - internal/bitmap/levelChannel.h - internal/bitmap/medianFilter.h - internal/bitmap/modulate.h - internal/bitmap/negate.h - internal/bitmap/normalize.h - internal/bitmap/oilPaint.h - internal/bitmap/opacity.h - internal/bitmap/raise.h - internal/bitmap/reduceNoise.h - internal/bitmap/sample.h - internal/bitmap/shade.h - internal/bitmap/sharpen.h - internal/bitmap/solarize.h - internal/bitmap/spread.h - internal/bitmap/swirl.h - internal/bitmap/threshold.h - internal/bitmap/unsharpmask.h - internal/bitmap/wave.h internal/bluredge.h internal/cairo-png-out.h internal/cairo-ps-out.h @@ -209,7 +137,6 @@ set(extension_SRC internal/svg.h internal/svgz.h internal/win32.h - internal/wpg-input.h script/InkscapeScript.h ) @@ -221,6 +148,88 @@ if(WIN32) ) endif() +if(LibWPG_FOUND) + list(APPEND extension_SRC + internal/wpg-input.cpp + internal/wpg-input.h + ) +endif() + +if(ImageMagick_FOUND) + list(APPEND extension_SRC + internal/bitmap/adaptiveThreshold.cpp + internal/bitmap/adaptiveThreshold.h + internal/bitmap/addNoise.cpp + internal/bitmap/addNoise.h + internal/bitmap/blur.cpp + internal/bitmap/blur.h + internal/bitmap/channel.cpp + internal/bitmap/channel.h + internal/bitmap/charcoal.cpp + internal/bitmap/charcoal.h + internal/bitmap/colorize.cpp + internal/bitmap/colorize.h + internal/bitmap/contrast.cpp + internal/bitmap/contrast.h + internal/bitmap/cycleColormap.cpp + internal/bitmap/cycleColormap.h + internal/bitmap/despeckle.cpp + internal/bitmap/despeckle.h + internal/bitmap/edge.cpp + internal/bitmap/edge.h + internal/bitmap/emboss.cpp + internal/bitmap/emboss.h + internal/bitmap/enhance.cpp + internal/bitmap/enhance.h + internal/bitmap/equalize.cpp + internal/bitmap/equalize.h + internal/bitmap/gaussianBlur.cpp + internal/bitmap/gaussianBlur.h + internal/bitmap/imagemagick.cpp + internal/bitmap/imagemagick.h + internal/bitmap/implode.cpp + internal/bitmap/implode.h + internal/bitmap/level.cpp + internal/bitmap/level.h + internal/bitmap/levelChannel.cpp + internal/bitmap/levelChannel.h + internal/bitmap/medianFilter.cpp + internal/bitmap/medianFilter.h + internal/bitmap/modulate.cpp + internal/bitmap/modulate.h + internal/bitmap/negate.cpp + internal/bitmap/negate.h + internal/bitmap/normalize.cpp + internal/bitmap/normalize.h + internal/bitmap/oilPaint.cpp + internal/bitmap/oilPaint.h + internal/bitmap/opacity.cpp + internal/bitmap/opacity.h + internal/bitmap/raise.cpp + internal/bitmap/raise.h + internal/bitmap/reduceNoise.cpp + internal/bitmap/reduceNoise.h + internal/bitmap/sample.cpp + internal/bitmap/sample.h + internal/bitmap/shade.cpp + internal/bitmap/shade.h + internal/bitmap/sharpen.cpp + internal/bitmap/sharpen.h + internal/bitmap/solarize.cpp + internal/bitmap/solarize.h + internal/bitmap/spread.cpp + internal/bitmap/spread.h + internal/bitmap/swirl.cpp + internal/bitmap/swirl.h + internal/bitmap/threshold.cpp + internal/bitmap/threshold.h + internal/bitmap/unsharpmask.cpp + internal/bitmap/unsharpmask.h + internal/bitmap/wave.cpp + internal/bitmap/wave.h + ) +endif() + if(WITH_DBUS) list(APPEND extension_SRC dbus/application-interface.cpp -- cgit v1.2.3 From fb4410db05004e20de5c86a56a0b9b330ad3f81e Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Fri, 17 Jun 2011 02:37:18 -0300 Subject: patch reviewed and accepted from fernandolbastos@gmail.com (GSoC student) Split scripting ui in the document properties dialog to have one tab for embedded scripts and one for external scripts. (bzr r10312) --- src/ui/dialog/document-properties.cpp | 29 +++++++++++++++++++++-------- src/ui/dialog/document-properties.h | 5 +++++ 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index b2ca2a3a8..528f036a2 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -88,6 +88,7 @@ DocumentProperties::DocumentProperties() : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW), _page_page(1, 1, true, true), _page_guides(1, 1), _page_snap(1, 1), _page_cms(1, 1), _page_scripting(1, 1), + _page_external_scripts(1, 1), _page_embedded_scripts(1, 1), //--------------------------------------------------------------- _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), @@ -584,27 +585,36 @@ DocumentProperties::build_scripting() { _page_scripting.show(); + _page_scripting.set_spacing (4); + _page_scripting.pack_start(_scripting_notebook, true, true); + + _scripting_notebook.append_page(_page_external_scripts, _("External scripts")); + _scripting_notebook.append_page(_page_embedded_scripts, _("Embedded scripts")); + + _page_external_scripts.show(); + _page_embedded_scripts.show(); + Gtk::Label *label_script= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); label_script->set_markup (_("<b>External script files:</b>")); _add_btn.set_label(_("Add")); - _page_scripting.set_spacing(4); + _page_external_scripts.set_spacing(4); gint row = 0; label_script->set_alignment(0.0); - _page_scripting.table().attach(*label_script, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(*label_script, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - _page_scripting.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox()); spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); - _page_scripting.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - _page_scripting.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_scripting.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; //# Set up the External Scripts box @@ -675,8 +685,11 @@ void DocumentProperties::removeExternalScript(){ if (name == script->xlinkhref){ //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(obj->getRepr()); - DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + } } current = g_slist_next(current); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index b88f0db26..55070d2e2 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -82,6 +82,11 @@ protected: UI::Widget::NotebookPage _page_snap; UI::Widget::NotebookPage _page_cms; UI::Widget::NotebookPage _page_scripting; + + Gtk::Notebook _scripting_notebook; + UI::Widget::NotebookPage _page_external_scripts; + UI::Widget::NotebookPage _page_embedded_scripts; + Gtk::VBox _grids_vbox; UI::Widget::Registry _wr; -- cgit v1.2.3 From 2f9696ca1493513b67e35229b18d15f1fbbda0f1 Mon Sep 17 00:00:00 2001 From: Ivan Mas??r <helix84@centrum.sk> Date: Fri, 17 Jun 2011 10:21:05 +0200 Subject: * [INTL:sk] Slovak translation update * fix typo (bzr r10313) --- src/extension/internal/filter/experimental.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 8d260f62e..f60a6b414 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -335,7 +335,7 @@ public: "<param name=\"simply\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n" "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n" - "<param name=\"transluscent\" gui-text=\"" N_("Transluscent") "\" type=\"boolean\" >false</param>\n" + "<param name=\"translucent\" gui-text=\"" N_("Translucent") "\" type=\"boolean\" >false</param>\n" "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness</_param>\n" "<param name=\"smooth\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" -- cgit v1.2.3 From 637e36780dacfed78c322064e322f247bd764fd1 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sat, 18 Jun 2011 05:51:28 -0300 Subject: user interface for selecting colors of guidelines (bzr r10315) --- src/sp-guide.cpp | 17 +++++++++++++++++ src/sp-guide.h | 1 + src/ui/dialog/guides.cpp | 16 ++++++++++++++++ src/ui/dialog/guides.h | 3 +++ 4 files changed, 37 insertions(+) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 584a6a366..19b64eb1a 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -412,6 +412,23 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool */ } +void sp_guide_set_color(SPGuide &guide, const unsigned char r, const unsigned char g, const unsigned char b, bool const commit) +{ + g_assert(SP_IS_GUIDE(&guide)); + guide.color = (r << 24) | (g << 16) | (b << 8) | 0x7f; + + if (guide.views){ + sp_guideline_set_color(SP_GUIDELINE(guide.views->data), guide.color); + } + + if (commit){ + std::ostringstream os; + os << "rgb(" << r << "," << g << "," << b << ")"; + //XML Tree being used directly while it shouldn't be + guide.getRepr()->setAttribute("inkscape:color", os.str().c_str()); + } +} + void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit) { g_assert(SP_IS_GUIDE(&guide)); diff --git a/src/sp-guide.h b/src/sp-guide.h index a164fda84..8cf9c7dc2 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -64,6 +64,7 @@ void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit); +void sp_guide_set_color(SPGuide &guide, const unsigned char r, const unsigned char g, const unsigned char b, bool const commit); void sp_guide_remove(SPGuide *guide); char *sp_guide_description(SPGuide const *guide, const bool verbose = true); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index da517ba1a..3e324ca67 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -63,6 +63,14 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { dialog.run(); } +void GuidelinePropertiesDialog::_colorChanged() +{ + const Gdk::Color c = _color.get_color(); + char r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; + //TODO: why 257? verify this! + sp_guide_set_color(*_guide, r, g, b, true); +} + void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); @@ -177,6 +185,11 @@ void GuidelinePropertiesDialog::_setup() { _layout_table.attach(_label_entry, 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _layout_table.attach(_color, + 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged)); + + // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ _unit_menu.setUnitType(UNIT_TYPE_LINEAR); @@ -254,6 +267,9 @@ void GuidelinePropertiesDialog::_setup() { // init name entry _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + Gdk::Color c; + c.set_rgb_p(((_guide->color>>24)&0xff) / 255.0, ((_guide->color>>16)&0xff) / 255.0, ((_guide->color>>8)&0xff) / 255.0); + _color.set_color(c); _modeChanged(); // sets values of spinboxes. diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index efef0142b..88d0310b9 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -20,6 +20,7 @@ #include <gtkmm/label.h> #include <gtkmm/stock.h> #include <gtkmm/adjustment.h> +#include <gtkmm/colorbutton.h> #include "ui/widget/button.h" #include "ui/widget/spinbutton.h" #include "ui/widget/unit-menu.h" @@ -57,6 +58,7 @@ protected: void _response(gint response); void _modeChanged(); + void _colorChanged(); private: GuidelinePropertiesDialog(GuidelinePropertiesDialog const &); // no copy @@ -73,6 +75,7 @@ private: Inkscape::UI::Widget::ScalarUnit _spin_button_x; Inkscape::UI::Widget::ScalarUnit _spin_button_y; Inkscape::UI::Widget::Entry _label_entry; + Gtk::ColorButton _color; Inkscape::UI::Widget::ScalarUnit _spin_angle; static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances -- cgit v1.2.3 From 3c97d4754f895c7c72733689122d4ba5cd03498e Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 18 Jun 2011 12:41:38 +0200 Subject: UI fix / mnemonics (bzr r10317) --- src/ui/dialog/guides.cpp | 8 ++++---- src/ui/dialog/inkscape-preferences.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 3e324ca67..542fed5bb 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -40,10 +40,10 @@ namespace Dialogs { GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop) : _desktop(desktop), _guide(guide), _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), - _spin_button_x(_("X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), - _spin_button_y(_("Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), - _label_entry(_("Label:"), _("Optionally give this guideline a name")), - _spin_angle(_("Angle:"), "", UNIT_TYPE_RADIAL), + _spin_button_x(_("_X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _spin_button_y(_("_Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _label_entry(_("_Label:"), _("Optionally give this guideline a name")), + _spin_angle(_("_Angle:"), "", UNIT_TYPE_RADIAL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) { } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 52c434961..3c272e691 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -487,7 +487,7 @@ void InkscapePreferences::initPageTools() this->AddPage(_page_measure, _("Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); cb->init ( _("Ignore first and last points"), "/tools/measure/ignore_1st_and_last", true); - _page_measure.add_line( false, "", *cb, "", _("The beggining and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); + _page_measure.add_line( false, "", *cb, "", _("The start and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); //Shapes Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES); -- cgit v1.2.3 From 2fc19c4d9d209ed32560c558487954b94755b7f1 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sat, 18 Jun 2011 21:19:11 -0300 Subject: Patch sent by Fernando Lucchesi (GSoC student) and modified by me. Interface for editing content of embedded scripts. (bzr r10318) --- src/ui/dialog/document-properties.cpp | 242 +++++++++++++++++++++++++++++++--- src/ui/dialog/document-properties.h | 27 +++- src/verbs.h | 3 + 3 files changed, 251 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 528f036a2..4434e3bd6 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -460,6 +460,13 @@ void DocumentProperties::external_scripts_list_button_release(GdkEventButton* ev } } +void DocumentProperties::embedded_scripts_list_button_release(GdkEventButton* event) +{ + if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) { + _EmbeddedScriptsContextMenu.popup(event->button, event->time); + } +} + void DocumentProperties::linked_profiles_list_button_release(GdkEventButton* event) { if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) { @@ -477,7 +484,7 @@ void DocumentProperties::cms_create_popup_menu(Gtk::Widget& parent, sigc::slot<v } -void DocumentProperties::scripting_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) +void DocumentProperties::external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) { Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE)); _ExternalScriptsContextMenu.append(*mi); @@ -486,6 +493,15 @@ void DocumentProperties::scripting_create_popup_menu(Gtk::Widget& parent, sigc:: _ExternalScriptsContextMenu.accelerate(parent); } +void DocumentProperties::embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) +{ + Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE)); + _EmbeddedScriptsContextMenu.append(*mi); + mi->signal_activate().connect(rem); + mi->show(); + _EmbeddedScriptsContextMenu.accelerate(parent); +} + void DocumentProperties::removeSelectedProfile(){ Glib::ustring name; if(_LinkedProfilesList.get_selection()) { @@ -591,26 +607,26 @@ DocumentProperties::build_scripting() _scripting_notebook.append_page(_page_external_scripts, _("External scripts")); _scripting_notebook.append_page(_page_embedded_scripts, _("Embedded scripts")); + //# External scripts tab _page_external_scripts.show(); - _page_embedded_scripts.show(); - - Gtk::Label *label_script= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); - label_script->set_markup (_("<b>External script files:</b>")); + + Gtk::Label *label_external= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_external->set_markup (_("<b>External script files:</b>")); _add_btn.set_label(_("Add")); _page_external_scripts.set_spacing(4); gint row = 0; - label_script->set_alignment(0.0); - _page_external_scripts.table().attach(*label_script, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + label_external->set_alignment(0.0); + _page_external_scripts.table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; _page_external_scripts.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox()); - spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); - _page_external_scripts.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox()); + spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); + _page_external_scripts.table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; _page_external_scripts.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); @@ -624,7 +640,58 @@ DocumentProperties::build_scripting() _ExternalScriptsList.set_headers_visible(true); // TODO restore? _ExternalScriptsList.set_fixed_height_mode(true); - populate_external_scripts_box(); + + //# Embedded scripts tab + _page_embedded_scripts.show(); + + Gtk::Label *label_embedded= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_embedded->set_markup (_("<b>Embedded script files:</b>")); + + _new_btn.set_label(_("New")); + + _page_embedded_scripts.set_spacing(4); + row = 0; + + label_embedded->set_alignment(0.0); + _page_embedded_scripts.table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + _page_embedded_scripts.table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox()); + spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); + _page_embedded_scripts.table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + _page_embedded_scripts.table().attach(_new_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + //# Set up the Embedded Scripts box + _EmbeddedScriptsListStore = Gtk::ListStore::create(_EmbeddedScriptsListColumns); + _EmbeddedScriptsList.set_model(_EmbeddedScriptsListStore); + _EmbeddedScriptsList.append_column(_("Script id"), _EmbeddedScriptsListColumns.idColumn); + _EmbeddedScriptsList.set_headers_visible(true); +// TODO restore? _EmbeddedScriptsList.set_fixed_height_mode(true); + + //# Set up the Embedded Scripts content box + Gtk::Label *label_embedded_content= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_embedded_content->set_markup (_("<b>Content:</b>")); + + label_embedded_content->set_alignment(0.0); + _page_embedded_scripts.table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + _page_embedded_scripts.table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + + _EmbeddedContentScroller.add(_EmbeddedContent); + _EmbeddedContentScroller.set_shadow_type(Gtk::SHADOW_IN); + _EmbeddedContentScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _EmbeddedContentScroller.set_size_request(-1, -1); + + _EmbeddedScriptsList.signal_cursor_changed().connect(sigc::mem_fun(*this, &DocumentProperties::changeEmbeddedScript)); + _EmbeddedContent.get_buffer()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::editEmbeddedScript)); + + populate_script_lists(); _ExternalScriptsListScroller.add(_ExternalScriptsList); _ExternalScriptsListScroller.set_shadow_type(Gtk::SHADOW_IN); @@ -633,17 +700,28 @@ DocumentProperties::build_scripting() _add_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::addExternalScript)); + _EmbeddedScriptsListScroller.add(_EmbeddedScriptsList); + _EmbeddedScriptsListScroller.set_shadow_type(Gtk::SHADOW_IN); + _EmbeddedScriptsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); + _EmbeddedScriptsListScroller.set_size_request(-1, 90); + + _new_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::addEmbeddedScript)); + + #if ENABLE_LCMS _ExternalScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::external_scripts_list_button_release)); - scripting_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript)); + external_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript)); + + _EmbeddedScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::embedded_scripts_list_button_release)); + embedded_create_popup_menu(_EmbeddedScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript)); #endif // ENABLE_LCMS //TODO: review this observers code: const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) { - _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); + _scripts_observer.set(SP_OBJECT(current->data)->parent); } - _ext_scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_external_scripts_box)); + _scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_script_lists)); } @@ -662,7 +740,24 @@ void DocumentProperties::addExternalScript(){ // inform the document, so we can undo DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); - populate_external_scripts_box(); + populate_script_lists(); + } +} + +void DocumentProperties::addEmbeddedScript(){ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (!desktop){ + g_warning("No active desktop"); + } else { + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script"); + + xml_doc->root()->addChild(scriptRepr, NULL); + + // inform the document, so we can undo + DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EMBEDDED_SCRIPT, _("Add embedded script...")); + + populate_script_lists(); } } @@ -688,20 +783,126 @@ void DocumentProperties::removeExternalScript(){ Inkscape::XML::Node *repr = obj->getRepr(); if (repr){ sp_repr_unparent(repr); + + // inform the document, so we can undo DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); } } current = g_slist_next(current); } - populate_external_scripts_box(); + populate_script_lists(); +} + +void DocumentProperties::removeEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script")); + } + } + current = g_slist_next(current); + } + + populate_script_lists(); +} + +void DocumentProperties::changeEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + bool voidscript=true; + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + SPObject* child = obj->firstChild(); + //TODO: shouldnt we get all children instead of simply the first child? + + if (child && child->getRepr()){ + const gchar* content = child->getRepr()->content(); + if (content){ + voidscript=false; + _EmbeddedContent.get_buffer()->set_text(content); + } + } + } + current = g_slist_next(current); + } + + if (voidscript) + _EmbeddedContent.get_buffer()->set_text(""); +} + +void DocumentProperties::editEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + Inkscape::XML::Document *xml_doc = SP_ACTIVE_DOCUMENT->getReprDoc(); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + SPObject *child; + while (NULL != (child = obj->firstChild())) child->deleteObject(); + obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str())); + //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text()); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_EMBEDDED_SCRIPT, _("Edit embedded script")); + } + } + current = g_slist_next(current); + } } -void DocumentProperties::populate_external_scripts_box(){ +void DocumentProperties::populate_script_lists(){ _ExternalScriptsListStore->clear(); + _EmbeddedScriptsListStore->clear(); const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); + if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; @@ -710,6 +911,11 @@ void DocumentProperties::populate_external_scripts_box(){ Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append()); row[_ExternalScriptsListColumns.filenameColumn] = script->xlinkhref; } + else // Embedded scripts + { + Gtk::TreeModel::Row row = *(_EmbeddedScriptsListStore->append()); + row[_EmbeddedScriptsListColumns.idColumn] = obj->getId(); + } current = g_slist_next(current); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 55070d2e2..69729f2da 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -64,16 +64,22 @@ protected: #endif // ENABLE_LCMS void external_scripts_list_button_release(GdkEventButton* event); - void populate_external_scripts_box(); + void embedded_scripts_list_button_release(GdkEventButton* event); + void populate_script_lists(); void addExternalScript(); + void addEmbeddedScript(); void removeExternalScript(); - void scripting_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); + void removeEmbeddedScript(); + void changeEmbeddedScript(); + void editEmbeddedScript(); + void external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); + void embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); void _handleActivateDesktop(Inkscape::Application *application, SPDesktop *desktop); void _handleDeactivateDesktop(Inkscape::Application *application, SPDesktop *desktop); - Inkscape::XML::SignalObserver _emb_profiles_observer, _ext_scripts_observer; + Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer; Gtk::Tooltips _tt; Gtk::Notebook _notebook; @@ -127,6 +133,7 @@ protected: //--------------------------------------------------------------- Gtk::Button _add_btn; + Gtk::Button _new_btn; class ExternalScriptsColumns : public Gtk::TreeModel::ColumnRecord { public: @@ -135,11 +142,25 @@ protected: Gtk::TreeModelColumn<Glib::ustring> filenameColumn; }; ExternalScriptsColumns _ExternalScriptsListColumns; + class EmbeddedScriptsColumns : public Gtk::TreeModel::ColumnRecord + { + public: + EmbeddedScriptsColumns() + { add(idColumn); } + Gtk::TreeModelColumn<Glib::ustring> idColumn; + }; + EmbeddedScriptsColumns _EmbeddedScriptsListColumns; Glib::RefPtr<Gtk::ListStore> _ExternalScriptsListStore; + Glib::RefPtr<Gtk::ListStore> _EmbeddedScriptsListStore; Gtk::TreeView _ExternalScriptsList; + Gtk::TreeView _EmbeddedScriptsList; Gtk::ScrolledWindow _ExternalScriptsListScroller; + Gtk::ScrolledWindow _EmbeddedScriptsListScroller; Gtk::Menu _ExternalScriptsContextMenu; + Gtk::Menu _EmbeddedScriptsContextMenu; Gtk::Entry _script_entry; + Gtk::TextView _EmbeddedContent; + Gtk::ScrolledWindow _EmbeddedContentScroller; //--------------------------------------------------------------- Gtk::Notebook _grids_notebook; diff --git a/src/verbs.h b/src/verbs.h index de7a96797..dd5c4db35 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -289,7 +289,10 @@ enum { SP_VERB_EDIT_REMOVE_COLOR_PROFILE, /*Scripting*/ SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, + SP_VERB_EDIT_ADD_EMBEDDED_SCRIPT, + SP_VERB_EDIT_EMBEDDED_SCRIPT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, + SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, /* Footer */ SP_VERB_LAST }; -- cgit v1.2.3 From ac1f4a1f7b4c9263d2ab490b8f346c5ef0a4b716 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sat, 18 Jun 2011 22:47:52 -0300 Subject: I am not sure if it is possible to have a script element with more than a single childnode. Since we are not handling that, this is a warning to be displayed if we even encounter a file with more than one child for one of its script element nodes (bzr r10319) --- src/ui/dialog/document-properties.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 4434e3bd6..569dd2311 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -844,6 +844,15 @@ void DocumentProperties::changeEmbeddedScript(){ SPObject* obj = SP_OBJECT(current->data); if (id == obj->getId()){ + int count=0; + for ( SPObject *child = obj->children ; child; child = child->next ) + { + count++; + } + + if (count>1) + g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); + //XML Tree being used directly here while it shouldn't be. SPObject* child = obj->firstChild(); //TODO: shouldnt we get all children instead of simply the first child? -- cgit v1.2.3 From 8e814a1af48de1e92387c76f50f1af319507bfba Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sun, 19 Jun 2011 03:49:11 -0300 Subject: fix bug 796451: Measure tools should support rotation constraint (bzr r10320) --- src/measure-context.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 78bfb1cee..8920facb9 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -26,6 +26,7 @@ #include "inkscape.h" #include "desktop-handles.h" #include "measure-context.h" +#include "draw-context.h" #include "display/canvas-text.h" #include "path-chemistry.h" #include "2geom/line.h" @@ -184,17 +185,21 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point const motion_dt(desktop->w2d(motion_w)); + Geom::Point end_point = motion_dt; - sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], motion_dt[Geom::X], motion_dt[Geom::Y]); + if (event->motion.state & GDK_CONTROL_MASK) + spdc_endpoint_snap_rotation(event_context, end_point, start_point, event->motion.state); + + sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], end_point[Geom::X], end_point[Geom::Y]); Geom::PathVector lineseg; Geom::Path p; p.start(desktop->dt2doc(start_point)); - p.appendNew<Geom::LineSegment>(desktop->dt2doc(motion_dt)); + p.appendNew<Geom::LineSegment>(desktop->dt2doc(end_point)); lineseg.push_back(p); - double deltax = motion_dt[Geom::X] - start_point[Geom::X]; - double deltay = motion_dt[Geom::Y] - start_point[Geom::Y]; + double deltax = end_point[Geom::X] - start_point[Geom::X]; + double deltay = end_point[Geom::Y] - start_point[Geom::Y]; double angle = atan2(deltay, deltax); //TODO: calculate NPOINTS @@ -204,7 +209,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv std::vector<Geom::Point> points; double i; for (i=0; i<NPOINTS; i++){ - points.push_back(desktop->d2w(start_point + (i/NPOINTS)*(motion_dt-start_point))); + points.push_back(desktop->d2w(start_point + (i/NPOINTS)*(end_point-start_point))); } //select elements crossed by line segment: @@ -260,7 +265,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } if (!ignore_1st_and_last){ - intersections.push_back(desktop->dt2doc(motion_dt)); + intersections.push_back(desktop->dt2doc(end_point)); } //sort intersections @@ -321,7 +326,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv char* angle_str = (char*) malloc(sizeof(char)*20); sprintf(angle_str, "%.2f °", angle * 180/3.1415 ); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); sp_canvastext_set_rgba32 (SP_CANVASTEXT(canvas_tooltip), 0x337f33ff, 0xffffffff); -- cgit v1.2.3 From f6dba310bc22dc65845e0cd0743594545e356a59 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Sun, 19 Jun 2011 11:01:29 +0200 Subject: Fix rendering of control points (bzr r9508.1.88) --- src/display/cairo-utils.cpp | 129 ++++++++------- src/display/cairo-utils.h | 6 + src/display/sodipodi-ctrl.cpp | 361 ++++++++++++++++++++++-------------------- src/display/sodipodi-ctrl.h | 2 +- 4 files changed, 273 insertions(+), 225 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index adf5dcb9a..90f65c33e 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -555,6 +555,62 @@ ink_cairo_pattern_create_checkerboard() return p; } +/* The following two functions use "from" instead of "to", because when you write: + val1 = argb32_from_pixbuf(val1); + the name of the format is closer to the value in that format. */ + +guint32 argb32_from_pixbuf(guint32 c) +{ + guint32 o = 0; +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + guint32 a = (c & 0xff000000) >> 24; +#else + guint32 a = (c & 0x000000ff); +#endif + if (a != 0) { + // extract color components +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + guint32 r = (c & 0x000000ff); + guint32 g = (c & 0x0000ff00) >> 8; + guint32 b = (c & 0x00ff0000) >> 16; +#else + guint32 r = (c & 0xff000000) >> 24; + guint32 g = (c & 0x00ff0000) >> 16; + guint32 b = (c & 0x0000ff00) >> 8; +#endif + // premultiply + r = premul_alpha(r, a); + b = premul_alpha(b, a); + g = premul_alpha(g, a); + // combine into output + o = (a << 24) | (r << 16) | (g << 8) | (b); + } + return o; +} + +guint32 pixbuf_from_argb32(guint32 c) +{ + guint32 a = (c & 0xff000000) >> 24; + if (a == 0) return 0; + + // extract color components + guint32 r = (c & 0x00ff0000) >> 16; + guint32 g = (c & 0x0000ff00) >> 8; + guint32 b = (c & 0x000000ff); + // unpremultiply; adding a/2 gives correct rounding + // (taken from Cairo sources) + r = (r * 255 + a/2) / a; + b = (b * 255 + a/2) / a; + g = (g * 255 + a/2) / a; + // combine into output +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + guint32 o = (r) | (g << 8) | (b << 16) | (a << 24); +#else + guint32 o = (r << 24) | (g << 16) | (b << 8) | (a); +#endif + return o; +} + /** * @brief Convert pixel data from GdkPixbuf format to ARGB. * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. @@ -565,38 +621,11 @@ ink_cairo_pattern_create_checkerboard() void convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int stride) { - // TODO: optimize until it squeaks. - guint32 *ipx = reinterpret_cast<guint32*>(data); - for (int i = 0; i < h; ++i) { + guint32 *px = reinterpret_cast<guint32*>(data + i*stride); for (int j = 0; j < w; ++j) { - int index = i * stride / 4 + j; - guint32 c = ipx[index]; - guint32 o = 0; -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - guint32 a = (c & 0xff000000) >> 24; -#else - guint32 a = (c & 0x000000ff); -#endif - if (a != 0) { - // extract color components -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - guint32 r = (c & 0x000000ff); - guint32 g = (c & 0x0000ff00) >> 8; - guint32 b = (c & 0x00ff0000) >> 16; -#else - guint32 r = (c & 0xff000000) >> 24; - guint32 g = (c & 0x00ff0000) >> 16; - guint32 b = (c & 0x0000ff00) >> 8; -#endif - // premultiply - r = premul_alpha(r, a); - b = premul_alpha(b, a); - g = premul_alpha(g, a); - // combine into output - o = (a << 24) | (r << 16) | (g << 8) | (b); - } - ipx[index] = o; + *px = argb32_from_pixbuf(*px); + ++px; } } } @@ -609,32 +638,11 @@ convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int stride) void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int stride) { - // TODO: optimize until it squeaks. - guint32 *ipx = reinterpret_cast<guint32*>(data); for (int i = 0; i < h; ++i) { + guint32 *px = reinterpret_cast<guint32*>(data + i*stride); for (int j = 0; j < w; ++j) { - int index = i * stride / 4 + j; - guint32 c = ipx[index]; - guint32 o = 0; - guint32 a = (c & 0xff000000) >> 24; - if (a != 0) { - // extract color components - guint32 r = (c & 0x00ff0000) >> 16; - guint32 g = (c & 0x0000ff00) >> 8; - guint32 b = (c & 0x000000ff); - // unpremultiply; adding a/2 gives correct rounding - // (taken from Cairo sources) - r = (r * 255 + a/2) / a; - b = (b * 255 + a/2) / a; - g = (g * 255 + a/2) / a; - // combine into output -#if G_BYTE_ORDER == G_LITTLE_ENDIAN - o = (r) | (g << 8) | (b << 16) | (a << 24); -#else - o = (r << 24) | (g << 16) | (b << 8) | (a); -#endif - } - ipx[index] = o; + *px = pixbuf_from_argb32(*px); + ++px; } } } @@ -642,7 +650,7 @@ convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int stride) /** * @brief Converts GdkPixbuf's data to premultiplied ARGB. * This function will convert a GdkPixbuf in place into Cairo's native pixel format. - * Note that this is a hack intended to save memory. When the pixbuf is Cairo's format, + * Note that this is a hack intended to save memory. When the pixbuf is in Cairo's format, * using it with GTK will result in corrupted drawings. */ void @@ -669,6 +677,17 @@ convert_pixbuf_argb32_to_normal(GdkPixbuf *pb) gdk_pixbuf_get_rowstride(pb)); } +guint32 argb32_from_rgba(guint32 in) +{ + guint32 r, g, b, a; + a = (in & 0x000000ff); + r = premul_alpha((in & 0xff000000) >> 24, a); + g = premul_alpha((in & 0x00ff0000) >> 16, a); + b = premul_alpha((in & 0x0000ff00) >> 8, a); + ASSEMBLE_ARGB32(px, a, r, g, b) + return px; +} + /* Local Variables: mode:c++ diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 1ad3c0b46..0c2ac2dd6 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -107,6 +107,12 @@ void convert_pixbuf_normal_to_argb32(GdkPixbuf *); void convert_pixbuf_argb32_to_normal(GdkPixbuf *); cairo_surface_t *ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb); +G_GNUC_CONST guint32 argb32_from_pixbuf(guint32 in); +G_GNUC_CONST guint32 pixbuf_from_argb32(guint32 in); +/** Convert a pixel in 0xRRGGBBAA format to Cairo ARGB32 format. */ +G_GNUC_CONST guint32 argb32_from_rgba(guint32 in); + + G_GNUC_CONST inline guint32 premul_alpha(guint32 color, guint32 alpha) { diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index a165fd52e..5e939ffee 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -125,7 +125,7 @@ sp_ctrl_destroy (GtkObject *object) ctrl = SP_CTRL (object); if (ctrl->cache) { - g_free(ctrl->cache); + delete[] ctrl->cache; ctrl->cache = NULL; } @@ -176,9 +176,7 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_FILL_COLOR: { - // treat colors with zero alpha as opaque guint32 fill = GTK_VALUE_INT (*arg); - fill = ((fill & 0xff) == 0 && fill) ? fill | 0xff : fill; ctrl->fill_color = fill; ctrl->build = FALSE; sp_canvas_item_request_update (item); @@ -191,9 +189,7 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_STROKE_COLOR: { - // treat colors with zero alpha as opaque guint32 stroke = GTK_VALUE_INT (*arg); - stroke = ((stroke & 0xff) == 0 && stroke) ? stroke | 0xff : stroke; ctrl->stroke_color = stroke; ctrl->build = FALSE; sp_canvas_item_request_update (item); @@ -303,101 +299,162 @@ sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) static void sp_ctrl_build_cache (SPCtrl *ctrl) { - //guchar * p, *q; - //int size, x, y, z, s, a, side, c; - //guint8 fr, fg, fb, fa, sr, sg, sb, sa; - - /*if (ctrl->filled) { - fr = (ctrl->fill_color >> 24) & 0xff; - fg = (ctrl->fill_color >> 16) & 0xff; - fb = (ctrl->fill_color >> 8) & 0xff; - fa = (ctrl->fill_color) & 0xff; + guint32 *p, *q; + gint size, x, y, z, s, a, side, c; + guint32 stroke_color, fill_color; + + if (ctrl->filled) { + if (ctrl->mode == SP_CTRL_MODE_XOR) { + fill_color = ctrl->fill_color; + } else { + fill_color = argb32_from_rgba(ctrl->fill_color); + } } else { - fr = 0x00; fg = 0x00; fb = 0x00; fa = 0x00; + fill_color = 0; } if (ctrl->stroked) { - sr = (ctrl->stroke_color >> 24) & 0xff; - sg = (ctrl->stroke_color >> 16) & 0xff; - sb = (ctrl->stroke_color >> 8) & 0xff; - sa = (ctrl->stroke_color) & 0xff; + if (ctrl->mode == SP_CTRL_MODE_XOR) { + stroke_color = ctrl->stroke_color; + } else { + stroke_color = argb32_from_rgba(ctrl->stroke_color); + } } else { - sr = fr; sg = fg; sb = fb; sa = fa; - }*/ + stroke_color = fill_color; + } - int w, h; // for clarity; w and h are always odd - w = h = (ctrl->span * 2 +1); - int c = ctrl->span ; - if (ctrl->cache) { - cairo_surface_finish(ctrl->cache); - cairo_surface_destroy(ctrl->cache); - } - ctrl->cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); - cairo_t *cr = cairo_create(ctrl->cache); + side = (ctrl->span * 2 +1); + c = ctrl->span; + size = side * side; + if (side < 2) return; - bool supress_paint = false; + if (ctrl->cache) delete[] ctrl->cache; + ctrl->cache = new guint32[size]; switch (ctrl->shape) { case SP_CTRL_SHAPE_SQUARE: - cairo_rectangle(cr, 0, 0, w, h); + p = ctrl->cache; + // top edge + for (x=0; x < side; x++) { + *p++ = stroke_color; + } + // middle + for (y = 2; y < side; y++) { + *p++ = stroke_color; // stroke at first and last pixel + for (x=2; x < side; x++) { + *p++ = fill_color; // fill in the middle + } + *p++ = stroke_color; + } + // bottom edge + for (x=0; x < side; x++) { + *p++ = stroke_color; + } ctrl->build = TRUE; break; case SP_CTRL_SHAPE_DIAMOND: - cairo_move_to(cr, c, 0); // c stands for "center" - it is half of the width / height - cairo_line_to(cr, w, c); - cairo_line_to(cr, c, h); - cairo_line_to(cr, 0, c); - cairo_close_path(cr); + p = ctrl->cache; + for (y = 0; y < side; y++) { + z = abs (c - y); + for (x = 0; x < z; x++) { + *p++ = 0; + } + *p++ = stroke_color; x++; + for (; x < side - z -1; x++) { + *p++ = fill_color; + } + if (z != c) { + *p++ = stroke_color; x++; + } + for (; x < side; x++) { + *p++ = 0; + } + } ctrl->build = TRUE; break; case SP_CTRL_SHAPE_CIRCLE: - cairo_arc(cr, 0.5+c, 0.5+c, c, 0, 2*M_PI); - cairo_close_path(cr); + p = ctrl->cache; + q = p + size -1; + s = -1; + for (y = 0; y <= c ; y++) { + a = abs (c - y); + z = (gint)(0.0 + sqrt ((c+.4)*(c+.4) - a*a)); + x = 0; + while (x < c-z) { + *p++ = 0; + *q-- = 0; + x++; + } + do { + *p++ = stroke_color; + *q-- = stroke_color; + x++; + } while (x < c-s); + while (x < MIN(c+s+1, c+z)) { + *p++ = fill_color; + *q-- = fill_color; + x++; + } + do { + *p++ = stroke_color; + *q-- = stroke_color; + x++; + } while (x <= c+z); + while (x < side) { + *p++ = 0; + *q-- = 0; + x++; + } + s = z; + } ctrl->build = TRUE; break; case SP_CTRL_SHAPE_CROSS: - cairo_move_to(cr, 0.5, 0.5); - cairo_line_to(cr, -0.5+w, -0.5+h); - cairo_move_to(cr, -0.5+w, 0.5); // right stroke - cairo_line_to(cr, 0.5, -0.5+h); - cairo_set_line_width(cr, 1); - cairo_stroke(cr); - supress_paint = true; + p = ctrl->cache; + for (y = 0; y < side; y++) { + z = abs (c - y); + for (x = 0; x < c-z; x++) { + *p++ = 0; + } + *p++ = stroke_color; x++; + for (; x < c + z; x++) { + *p++ = 0; + } + if (z != 0) { + *p++ = stroke_color; x++; + } + for (; x < side; x++) { + *p++ = 0; + } + } ctrl->build = TRUE; break; case SP_CTRL_SHAPE_BITMAP: if (ctrl->pixbuf) { - gdk_cairo_set_source_pixbuf(cr, ctrl->pixbuf, 0, 0); - cairo_paint(cr); - cairo_surface_flush(ctrl->cache); - - // TODO lame!!! find a way to do this without direct pixel manipulation. - int stride = cairo_image_surface_get_stride(ctrl->cache); - guint32 *px = reinterpret_cast<guint32*>(cairo_image_surface_get_data(ctrl->cache)); - - // fix byte order. fill_color is 0xrrggbbaa, cairo needs 0xaarrggbb. - // both quantities are native-endian, so it should be portable. - guint32 fill = ctrl->fill_color; - guint32 stroke = ctrl->stroke_color; - fill = ((fill & 0xff) << 24) | ((fill & 0xffffff00) >> 8); - stroke = ((stroke & 0xff) << 24) | ((stroke & 0xffffff00) >> 8); - - for (int i = 0; i < h; ++i) { - for (int j = 0; j < w; ++j) { - int index = i * stride / 4 + j; - if (px[index] & 0xff000000) { - px[index] = (px[index] & 0x00ffffff) ? stroke : fill; + unsigned char *px; + unsigned int rs; + px = gdk_pixbuf_get_pixels (ctrl->pixbuf); + rs = gdk_pixbuf_get_rowstride (ctrl->pixbuf); + for (y = 0; y < side; y++){ + guint32 *d; + unsigned char *s; + s = px + y * rs; + d = ctrl->cache + side * y; + for (x = 0; x < side; x++) { + if (s[3] < 0x80) { + *d++ = 0; + } else if (s[0] < 0x80) { + *d++ = stroke_color; } else { - px[index] = 0; + *d++ = fill_color; } + s += 4; } } - cairo_surface_mark_dirty(ctrl->cache); - supress_paint = true; } else { g_print ("control has no pixmap\n"); } @@ -406,9 +463,16 @@ sp_ctrl_build_cache (SPCtrl *ctrl) case SP_CTRL_SHAPE_IMAGE: if (ctrl->pixbuf) { - gdk_cairo_set_source_pixbuf(cr, ctrl->pixbuf, 0, 0); - cairo_paint(cr); - supress_paint = true; + guint r = gdk_pixbuf_get_rowstride (ctrl->pixbuf); + guint32 *px; + guchar *data = gdk_pixbuf_get_pixels (ctrl->pixbuf); + p = ctrl->cache; + for (y = 0; y < side; y++){ + px = reinterpret_cast<guint32*>(data + y * r); + for (x = 0; x < side; x++) { + *p++ = *px++; + } + } } else { g_print ("control has no pixmap\n"); } @@ -418,27 +482,13 @@ sp_ctrl_build_cache (SPCtrl *ctrl) default: break; } - - if (ctrl->build && !supress_paint) { - if (ctrl->filled) { - ink_cairo_set_source_rgba32(cr, ctrl->fill_color); - cairo_fill_preserve(cr); - } - if (ctrl->stroked) { - ink_cairo_set_source_rgba32(cr, ctrl->stroke_color); - cairo_set_line_width(cr, 2); - cairo_clip_preserve(cr); - cairo_stroke(cr); - } - } - - cairo_destroy(cr); } -// composite background, foreground, alpha for xor mode -#define COMPOSE_X(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) ) -// composite background, foreground, alpha for color mode -#define COMPOSE_N(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) ) +static inline guint32 compose_xor(guint32 bg, guint32 fg, guint32 a) +{ + guint32 c = bg * (255-a) + (((bg ^ ~fg) + (bg >> 2) - (bg > 127 ? 63 : 0)) & 255) * a; + return (c + 127) / 255; +} static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) @@ -456,88 +506,61 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) sp_ctrl_build_cache (ctrl); } - cairo_set_source_surface(buf->ct, ctrl->cache, - ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0); - cairo_paint(buf->ct); - - /* - double x0 = ctrl->box.x0; - double y0 = ctrl->box.y0; - double w = ctrl->box.x1 - ctrl->box.x0 + 1; - double h = ctrl->box.y1 - ctrl->box.y0 + 1; - //guint32 fill = ctrl->fill_color; - //fill = (fill & 0xff == 0 && fill) ? fill | 0xff : fill; - - - switch (ctrl->shape) { - case SP_CTRL_SHAPE_SQUARE: - cairo_rectangle(buf->ct, x0, y0, w, h); - break; - case SP_CTRL_SHAPE_DIAMOND: - cairo_move_to(buf->ct, x0 + w/2, y0); - cairo_line_to(buf->ct, x0 + w, y0 + h/2); - cairo_line_to(buf->ct, x0 + w/2, y0 + h); - cairo_line_to(buf->ct, x0, y0 + h/2); - cairo_close_path(buf->ct); - break; - //case SP_CTRL_SHAPE_CIRCLE: - default: - cairo_arc(buf->ct, x0 + w/2, y0 + h/2, w/2, 0, 2*M_PI); - cairo_close_path(buf->ct); - break; - } - - //if (ctrl->mode == SP_CTRL_MODE_XOR) { - // cairo_set_operator(buf->ct, CAIRO_OPERATOR_XOR); - //} - if (ctrl->filled) { - ink_cairo_set_source_rgba32(buf->ct, ctrl->fill_color); - cairo_fill_preserve(buf->ct); - } - if (ctrl->stroked) { - ink_cairo_set_source_rgba32(buf->ct, ctrl->stroke_color); - cairo_set_line_width(buf->ct, 2); - cairo_clip_preserve(buf->ct); - cairo_stroke_preserve(buf->ct); - } + int w, h; + w = h = (ctrl->span * 2 +1); - cairo_new_path(buf->ct); - cairo_restore(buf->ct);*/ - - #if 0 - // then we render from ctrl->cache - y0 = MAX (ctrl->box.y0, buf->rect.y0); - y1 = MIN (ctrl->box.y1, buf->rect.y1 - 1); - x0 = MAX (ctrl->box.x0, buf->rect.x0); - x1 = MIN (ctrl->box.x1, buf->rect.x1 - 1); - - for (y = y0; y <= y1; y++) { - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - q = ctrl->cache + ((y - ctrl->box.y0) * (ctrl->span*2+1) + (x0 - ctrl->box.x0)) * 4; - for (x = x0; x <= x1; x++) { - a = *(q + 3); - // 00000000 is the only way to get invisible; all other colors with alpha 00 are treated as mode_color with alpha ff - colormode = false; - if (a == 0x00 && !(q[0] == 0x00 && q[1] == 0x00 && q[2] == 0x00)) { - a = 0xff; - colormode = true; - } - if (ctrl->mode == SP_CTRL_MODE_COLOR || colormode) { - p[0] = COMPOSE_N (p[0], q[0], a); - p[1] = COMPOSE_N (p[1], q[1], a); - p[2] = COMPOSE_N (p[2], q[2], a); - q += 4; - p += 4; - } else if (ctrl->mode == SP_CTRL_MODE_XOR) { - p[0] = COMPOSE_X (p[0], q[0], a); - p[1] = COMPOSE_X (p[1], q[1], a); - p[2] = COMPOSE_X (p[2], q[2], a); - q += 4; - p += 4; + // The code below works even when the target is not an image surface + if (ctrl->mode == SP_CTRL_MODE_XOR) { + // 1. Copy the affected part of output to a temporary surface + cairo_surface_t *work = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + cairo_t *cr = cairo_create(work); + cairo_translate(cr, -ctrl->box.x0, -ctrl->box.y0); + cairo_set_source_surface(cr, cairo_get_target(buf->ct), buf->rect.x0, buf->rect.y0); + cairo_paint(cr); + cairo_destroy(cr); + + // 2. Composite the control on a temporary surface + cairo_surface_flush(work); + int strideb = cairo_image_surface_get_stride(work); + unsigned char *pxb = cairo_image_surface_get_data(work); + guint32 *p = ctrl->cache; + for (int i=0; i<h; ++i) { + guint32 *pb = reinterpret_cast<guint32*>(pxb + i*strideb); + for (int j=0; j<w; ++j) { + guint32 cc = *p++; + guint32 ac = cc & 0xff; + if (ac == 0 && cc != 0) { + *pb++ = argb32_from_rgba(cc | 0x000000ff); + } else { + EXTRACT_ARGB32(*pb, ab,rb,gb,bb) + guint32 ro = compose_xor(rb, (cc & 0xff000000) >> 24, ac); + guint32 go = compose_xor(gb, (cc & 0x00ff0000) >> 16, ac); + guint32 bo = compose_xor(bb, (cc & 0x0000ff00) >> 8, ac); + ASSEMBLE_ARGB32(px, ab,ro,go,bo) + *pb++ = px; + } } } + cairo_surface_mark_dirty(work); + + // 3. Replace the affected part of output with contents of temporary surface + cairo_save(buf->ct); + cairo_set_source_surface(buf->ct, work, + ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0); + cairo_rectangle(buf->ct, ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0, w, h); + cairo_clip(buf->ct); + cairo_set_operator(buf->ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(buf->ct); + cairo_restore(buf->ct); + cairo_surface_destroy(work); + } else { + cairo_surface_t *cache = cairo_image_surface_create_for_data( + reinterpret_cast<unsigned char*>(ctrl->cache), CAIRO_FORMAT_ARGB32, w, h, w*4); + cairo_set_source_surface(buf->ct, cache, + ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0); + cairo_paint(buf->ct); + cairo_surface_destroy(cache); } - #endif ctrl->shown = TRUE; } diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 27728296a..df0470adb 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -49,7 +49,7 @@ struct SPCtrl : public SPCanvasItem { bool _moved; NRRectL box; /* NB! x1 & y1 are included */ - cairo_surface_t *cache; + guint32 *cache; GdkPixbuf * pixbuf; void moveto(Geom::Point const p); -- cgit v1.2.3 From ea08f2a7cf1c578554e07ecd9e7e3c7ad4e6f535 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour <nicoduf@yahoo.fr> Date: Sun, 19 Jun 2011 14:23:52 +0200 Subject: i18n. inkscape.pot update. i18n. String fix in the Tweak tool. Translations. Ukrainian translation update by Yuri Chornoivan. Translations. French translation update. (bzr r10321) --- src/widgets/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 67c15139f..75040ae3d 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -4757,7 +4757,7 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction gdouble values[] = {5, 20, 35, 50, 70, 85, 100}; EgeAdjustmentAction *eact = create_adjustment_action( "SprayPopulationAction", _("Amount"), _("Amount:"), - _("Adjusts the number of items sprayed per clic"), + _("Adjusts the number of items sprayed per click"), "/tools/spray/population", 70, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-population", 1, 100, 1.0, 10.0, -- cgit v1.2.3 From c35fb5074464280ecb579cadeee3418ac1bd866a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Sun, 19 Jun 2011 14:35:53 +0200 Subject: Fix outline view (bzr r9508.1.90) --- src/display/nr-arena-image.cpp | 13 +++++-------- src/display/nr-arena-shape.cpp | 4 +++- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 321d72ec1..cb1bc5849 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -176,27 +176,21 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_restore(ct); } else { // outline; draw a rect instead + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); cairo_save(ct); - cairo_translate(ct, -area->x0, -area->y0); ink_cairo_transform(ct, image->ctm); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); - ink_cairo_set_source_rgba32(ct, rgba); - - cairo_set_line_width(ct, 0.5); cairo_new_path(ct); Geom::Rect r = nr_arena_image_rect (image); - Geom::Point c00 = r.corner(0); Geom::Point c01 = r.corner(3); Geom::Point c11 = r.corner(2); Geom::Point c10 = r.corner(1); cairo_move_to (ct, c00[Geom::X], c00[Geom::Y]); - // the box cairo_line_to (ct, c10[Geom::X], c10[Geom::Y]); cairo_line_to (ct, c11[Geom::X], c11[Geom::Y]); @@ -206,7 +200,10 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock cairo_line_to (ct, c11[Geom::X], c11[Geom::Y]); cairo_move_to (ct, c10[Geom::X], c10[Geom::Y]); cairo_line_to (ct, c01[Geom::X], c01[Geom::Y]); + cairo_restore(ct); + cairo_set_line_width(ct, 0.5); + ink_cairo_set_source_rgba32(ct, rgba); cairo_stroke(ct); } return item->state; diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 9055045f4..f278413b2 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -317,13 +317,15 @@ cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect / guint32 rgba = NR_ARENA_ITEM(shape)->arena->outlinecolor; cairo_save(ct); - ink_cairo_set_source_rgba32(ct, rgba); ink_cairo_transform(ct, shape->ctm); feed_pathvector_to_cairo (ct, shape->curve->get_pathvector()); cairo_restore(ct); + cairo_save(ct); + ink_cairo_set_source_rgba32(ct, rgba); cairo_set_line_width(ct, 0.5); cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode cairo_stroke(ct); + cairo_restore(ct); return item->state; } -- cgit v1.2.3 From 5448c32dfe8264c42d0a627e3a32750e276cd394 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sun, 19 Jun 2011 18:43:29 -0300 Subject: fix bug 796598: Measure tool draws path in wrong window https://bugs.launchpad.net/inkscape/+bug/796598 (bzr r10322) --- src/measure-context.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 8920facb9..9e6a5fe12 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -47,7 +47,6 @@ static SPEventContextClass *parent_class; static gint xp = 0, yp = 0; // where drag started static gint tolerance = 0; static bool within_tolerance = false; -static SPCanvasItem * line = NULL; Geom::Point start_point; std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items; @@ -153,14 +152,6 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv ret = TRUE; } - if (!line){ - SPDesktop *desktop = inkscape_active_desktop(); - line = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLLINE, NULL); - } - - sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point, start_point); - sp_canvas_item_show (line); - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, NULL, event->button.time); @@ -183,14 +174,26 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv // motion notify coordinates as given (no snapping back to origin) within_tolerance = false; + //clear previous temporary canvas items, we'll draw new ones + unsigned int idx; + for (idx=0; idx<measure_tmp_items.size(); idx++){ + desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); + } + measure_tmp_items.clear(); + Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point const motion_dt(desktop->w2d(motion_w)); Geom::Point end_point = motion_dt; + //rotation constraint if (event->motion.state & GDK_CONTROL_MASK) spdc_endpoint_snap_rotation(event_context, end_point, start_point, event->motion.state); - sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], end_point[Geom::X], end_point[Geom::Y]); + //draw control line + SPCanvasItem * control_line = NULL; + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point, end_point); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); Geom::PathVector lineseg; Geom::Path p; @@ -273,12 +276,6 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); } - unsigned int idx; - for (idx=0; idx<measure_tmp_items.size(); idx++){ - desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); - } - measure_tmp_items.clear(); - for (idx=0;idx<intersections.size(); idx++){ // Display the intersection indicator (i.e. the cross) SPCanvasItem * canvasitem = NULL; @@ -340,10 +337,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv case GDK_BUTTON_RELEASE: { - if (line){ - sp_canvas_item_hide(line); - } - + //clear all temporary canvas items related to the measurement tool. unsigned int idx; for (idx=0; idx<measure_tmp_items.size(); idx++){ desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); -- cgit v1.2.3 From 30402f7922af0cf4ea9602fbdc56481d5daaf018 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Sun, 19 Jun 2011 21:12:45 -0300 Subject: fix bug 796449: Measure tools should consider transform https://bugs.launchpad.net/inkscape/+bug/796449 (bzr r10323) --- src/measure-context.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 9e6a5fe12..0c3c42b36 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -248,6 +248,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv if (!curve) continue; counter++; + curve->transform(item->i2doc_affine()); Geom::PathVector pathv = curve->get_pathvector(); // Find all intersections of the control-line with this shape -- cgit v1.2.3 From cd71c7a2ed5f1703618febea53c1637c22243f78 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 20 Jun 2011 00:10:28 -0300 Subject: add "Units:" label to the units selection widget for the measurement tool (bzr r10324) --- src/widgets/toolbox.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 75040ae3d..8241f1941 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -367,6 +367,8 @@ static gchar const * ui_descr = " <toolbar name='MeasureToolbar'>" " <toolitem action='MeasureFontSizeAction' />" + " <separator />" + " <toolitem action='measure_units_label' />" " <toolitem action='MeasureUnitsAction' />" " </toolbar>" @@ -1672,9 +1674,18 @@ static void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainAct gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } - // add the units menu + + // units label + { + EgeOutputAction* act = ege_output_action_new( "measure_units_label", _("Units:"), _("The units to be used for the measurements"), 0 ); + ege_output_action_set_use_markup( act, TRUE ); + g_object_set( act, "visible-overflown", FALSE, NULL ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + } + + // units menu { - GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units"), _("Units:") ); + GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units:"), _("The units to be used for the measurements") ); g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), (GObject*)holder ); gtk_action_group_add_action( mainActions, act ); } -- cgit v1.2.3 From 6b918fadbc14f15cbc2dbaa5c2b2e181e117688a Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Mon, 20 Jun 2011 04:42:05 -0300 Subject: Measure Tool: support measuring of text elements (without having to manually convert them to curves) (bzr r10325) --- src/measure-context.cpp | 82 ++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 0c3c42b36..0792db093 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -15,6 +15,9 @@ #include "macros.h" #include "display/curve.h" #include "sp-shape.h" +#include "sp-text.h" +#include "sp-flowtext.h" +#include "text-editing.h" #include "display/sp-ctrlline.h" #include "display/sodipodi-ctrl.h" #include "display/sp-canvas-item.h" @@ -129,6 +132,23 @@ bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) return p1[Geom::Y] < p2[Geom::Y]; } +void calculate_intersections(Geom::PathVector *lineseg, Geom::PathVector *pathv, std::vector<Geom::Point> *intersections){ + // Find all intersections of the control-line with this shape + Geom::CrossingSet cs = Geom::crossings(*lineseg, *pathv); + // Store the results as intersection points + unsigned int index = 0; + for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); i++) { + if (index >= lineseg->size()) { + break; + } + // Reconstruct and store the points of intersection + for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); m++) { + intersections->push_back((*lineseg)[index].pointAt((*m).ta)); + } + index++; + } +} + static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event) { SPDesktop *desktop = event_context->desktop; @@ -219,7 +239,6 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); SPItem* item; GSList *l; - int counter=0; std::vector<Geom::Point> intersections; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool ignore_1st_and_last = prefs->getBool("/tools/measure/ignore_1st_and_last", true); @@ -230,42 +249,43 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv for (l = items; l != NULL; l = l->next){ item = (SPItem*) (l->data); -#if 0 -//TODO: deal with all kinds of objects: - Inkscape::XML::Node *repr = sp_selected_item_to_curved_repr(item, 0); - - if (!repr) continue; - item = (SPItem *) doc->getObjectByRepr(repr); - if (!item) continue; - SPCurve* curve = SP_SHAPE(item)->getCurve(); -#else SPCurve* curve = NULL; if (SP_IS_SHAPE(item)) { curve = SP_SHAPE(item)->getCurve(); - } -#endif - if (!curve) continue; - counter++; - - curve->transform(item->i2doc_affine()); - Geom::PathVector pathv = curve->get_pathvector(); - - // Find all intersections of the control-line with this shape - Geom::CrossingSet cs = Geom::crossings(lineseg, pathv); - // Store the results as intersection points - unsigned int index = 0; - for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); i++) { - if (index >= lineseg.size()) { - break; - } - // Reconstruct and store the points of intersection - for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); m++) { - intersections.push_back(lineseg[index].pointAt((*m).ta)); + curve->transform(item->i2doc_affine()); + Geom::PathVector pathv = curve->get_pathvector(); + + calculate_intersections(&lineseg, &pathv, &intersections); + } else { + if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)){ + Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin(); + do { + Inkscape::Text::Layout::iterator iter_next = iter; + iter_next.nextGlyph(); // iter_next is one glyph ahead from iter + if (iter == iter_next) + break; + + // get path from iter to iter_next: + SPCurve *curve = te_get_layout(item)->convertToCurves(iter, iter_next); + iter = iter_next; // shift to next glyph + if (!curve) continue; // error converting this glyph + if (curve->is_empty()) { // whitespace glyph? + curve->unref(); + continue; + } + + curve->transform(item->i2doc_affine()); + Geom::PathVector pathv = curve->get_pathvector(); + + calculate_intersections(&lineseg, &pathv, &intersections); + + if (iter == te_get_layout(item)->end()) + break; + + } while (true); } - index++; } - //g_free(repr); } if (!ignore_1st_and_last){ -- cgit v1.2.3 From d673d916a26f751a2568f68b9998f51381cf003e Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Tue, 21 Jun 2011 03:42:23 -0300 Subject: refactoring measure tool code (bzr r10327) --- src/measure-context.cpp | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 0792db093..72759bcb0 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -132,20 +132,28 @@ bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) return p1[Geom::Y] < p2[Geom::Y]; } -void calculate_intersections(Geom::PathVector *lineseg, Geom::PathVector *pathv, std::vector<Geom::Point> *intersections){ +void calculate_intersections(SPDesktop *desktop, SPItem* item, Geom::PathVector *lineseg, SPCurve *curve, std::vector<Geom::Point> *intersections){ + curve->transform(item->i2doc_affine()); + // Find all intersections of the control-line with this shape - Geom::CrossingSet cs = Geom::crossings(*lineseg, *pathv); - // Store the results as intersection points - unsigned int index = 0; - for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); i++) { - if (index >= lineseg->size()) { - break; + Geom::CrossingSet cs = Geom::crossings(*lineseg, curve->get_pathvector()); + + // Reconstruct and store the points of intersection + for (Geom::Crossings::const_iterator m = cs[0].begin(); m != cs[0].end(); m++) { +#if 0 +//TODO: consider only visible intersections + Geom::Point intersection = (*lineseg)[0].pointAt((*m).ta); + double eps = 0.0001; + SPDocument* doc = sp_desktop_document(desktop); + if (((*m).ta > eps && + item == doc->getItemAtPoint(desktop->dkey, (*lineseg)[0].pointAt((*m).ta - eps), false, NULL)) || + ((*m).ta + eps < 1 && + item == doc->getItemAtPoint(desktop->dkey, (*lineseg)[0].pointAt((*m).ta + eps), false, NULL)) ){ + intersections->push_back(intersection); } - // Reconstruct and store the points of intersection - for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); m++) { - intersections->push_back((*lineseg)[index].pointAt((*m).ta)); - } - index++; +#else + intersections->push_back((*lineseg)[0].pointAt((*m).ta)); +#endif } } @@ -250,13 +258,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv for (l = items; l != NULL; l = l->next){ item = (SPItem*) (l->data); - SPCurve* curve = NULL; if (SP_IS_SHAPE(item)) { - curve = SP_SHAPE(item)->getCurve(); - curve->transform(item->i2doc_affine()); - Geom::PathVector pathv = curve->get_pathvector(); - - calculate_intersections(&lineseg, &pathv, &intersections); + calculate_intersections(desktop, item, &lineseg, SP_SHAPE(item)->getCurve(), &intersections); } else { if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)){ Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin(); @@ -278,7 +281,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv curve->transform(item->i2doc_affine()); Geom::PathVector pathv = curve->get_pathvector(); - calculate_intersections(&lineseg, &pathv, &intersections); + calculate_intersections(desktop, item, &lineseg, curve, &intersections); if (iter == te_get_layout(item)->end()) break; -- cgit v1.2.3 From 7743b3270e865679614e2e88fc75110af61f06ee Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Tue, 21 Jun 2011 03:54:50 -0300 Subject: address sissue with measure tool described here: https://bugs.launchpad.net/inkscape/+bug/796451/comments/2 (bzr r10328) --- src/measure-context.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 72759bcb0..75cb0d589 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -129,7 +129,10 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) { - return p1[Geom::Y] < p2[Geom::Y]; + if (p1[Geom::Y] == p2[Geom::Y]) + return p1[Geom::X] < p2[Geom::X]; + else + return p1[Geom::Y] < p2[Geom::Y]; } void calculate_intersections(SPDesktop *desktop, SPItem* item, Geom::PathVector *lineseg, SPCurve *curve, std::vector<Geom::Point> *intersections){ -- cgit v1.2.3 From d7855fbb9be54daf2b8f3b9bfe15b9e2b9afe7d8 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Tue, 21 Jun 2011 06:09:08 -0300 Subject: fix bug 800052: improve measure tool readability https://bugs.launchpad.net/inkscape/+bug/800052 And also using text_extents for calculating area of rendering for the canvas_text labels (although I am not really sure this is correct. May require some extra work to get it right) (bzr r10329) --- src/display/canvas-text.cpp | 45 +++++++++++++++++++++++++++++++++------------ src/display/canvas-text.h | 4 ++++ src/measure-context.cpp | 8 ++++++++ 3 files changed, 45 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 54cbe5da8..f598f8c59 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -74,6 +74,8 @@ sp_canvastext_init (SPCanvasText *canvastext) { canvastext->rgba = 0x33337fff; canvastext->rgba_stroke = 0xffffffff; + canvastext->rgba_background = 0x0000007f; + canvastext->background = false; canvastext->s[Geom::X] = canvastext->s[Geom::Y] = 0.0; canvastext->affine = Geom::identity(); canvastext->fontsize = 10.0; @@ -119,13 +121,29 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) offsetx -= anchor_offset_x; offsety += anchor_offset_y; + if (cl->background){ + cairo_text_extents_t extents; + cairo_text_extents(buf->ct, cl->text, &extents); + + double border = extents.height*0.5; + cairo_rectangle(buf->ct, offsetx - extents.x_bearing - border, + offsety + extents.y_bearing - border, + extents.width + 2*border, + extents.height + 2*border); + + ink_cairo_set_source_rgba32(buf->ct, cl->rgba_background); + cairo_fill(buf->ct); + } + cairo_move_to(buf->ct, offsetx, offsety); cairo_set_font_size(buf->ct, cl->fontsize); cairo_text_path(buf->ct, cl->text); - ink_cairo_set_source_rgba32(buf->ct, cl->rgba_stroke); - cairo_set_line_width (buf->ct, 2.0); - cairo_stroke_preserve(buf->ct); + if (cl->outline){ + ink_cairo_set_source_rgba32(buf->ct, cl->rgba_stroke); + cairo_set_line_width (buf->ct, 2.0); + cairo_stroke_preserve(buf->ct); + } ink_cairo_set_source_rgba32(buf->ct, cl->rgba); cairo_fill(buf->ct); } @@ -148,20 +166,23 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i // set up a temporary cairo_t to measure the text extents; it would be better to compute this in the render() // method but update() seems to be called before so we don't have the information available when we need it - /** - cairo_t tmp_buf; - cairo_text_extents_t bbox; - cairo_text_extents(&tmp_buf, cl->text, &bbox); - **/ - item->x1 = s[Geom::X] + 0; - item->y1 = s[Geom::Y] - cl->fontsize; - item->x2 = s[Geom::X] + cl->fontsize * strlen(cl->text); - item->y2 = s[Geom::Y] + cl->fontsize * 0.5; // for letters below the baseline + cairo_surface_t *tmp_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); + cairo_t* tmp_buf = cairo_create(tmp_surface); + + cairo_text_extents_t extents; + cairo_text_extents(tmp_buf, cl->text, &extents); + double border = extents.height*1.5; + + item->x1 = s[Geom::X] - extents.x_bearing - border; + item->y1 = s[Geom::Y] + extents.y_bearing - border; + item->x2 = s[Geom::X] + extents.width + border; + item->y2 = s[Geom::Y] + extents.height + border; // adjust update region according to anchor shift // FIXME: use the correct text extent anchor_offset_x = arbitrary_factor * cl->fontsize * strlen(cl->text) * (cl->anchor_x + 1.0) / 2.0; anchor_offset_y = cl->fontsize * (cl->anchor_y + 1.0) / 2.0; + item->x1 -= anchor_offset_x; item->x2 -= anchor_offset_x; item->y1 += anchor_offset_y; diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index a621e655c..bd3bd18d4 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -27,6 +27,10 @@ struct SPCanvasText : public SPCanvasItem { SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users guint32 rgba; guint32 rgba_stroke; + guint32 rgba_background; + bool outline; + bool background; + SPDesktop *desktop; // the desktop to which this text is attached; needed for coordinate transforms (TODO: these should be eliminated) gchar* text; diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 75cb0d589..dc2bb09e3 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -342,6 +342,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x0000007f; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(measure_str); @@ -353,6 +357,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); sp_canvastext_set_rgba32 (SP_CANVASTEXT(canvas_tooltip), 0x337f33ff, 0xffffffff); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(angle_str); -- cgit v1.2.3 From 55ba633a0c2c10589ed393d9158f936b7278b10e Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Tue, 21 Jun 2011 19:33:31 -0300 Subject: * Fix text_extents calculation for canvas text items. * Add anchor positioning options. * make measure tool length labels be perfectly centered in the measured linesegments (bzr r10331) --- src/display/canvas-text.cpp | 48 +++++++++++++++++++++++++++++++-------------- src/display/canvas-text.h | 10 ++++++++++ src/measure-context.cpp | 1 + 3 files changed, 44 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index f598f8c59..22342bb71 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -72,6 +72,7 @@ sp_canvastext_class_init (SPCanvasTextClass *klass) static void sp_canvastext_init (SPCanvasText *canvastext) { + canvastext->anchor_position = TEXT_ANCHOR_CENTER; canvastext->rgba = 0x33337fff; canvastext->rgba_stroke = 0xffffffff; canvastext->rgba_background = 0x0000007f; @@ -100,9 +101,6 @@ sp_canvastext_destroy (GtkObject *object) (* GTK_OBJECT_CLASS (parent_class_ct)->destroy) (object); } -// FIXME: remove this as soon as we know how to correctly determine the text extent -static const double arbitrary_factor = 0.8; - // these are set in sp_canvastext_update() and then re-used in sp_canvastext_render(), which is called afterwards static double anchor_offset_x = 0; static double anchor_offset_y = 0; @@ -119,7 +117,9 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) double offsetx = s[Geom::X] - buf->rect.x0; double offsety = s[Geom::Y] - buf->rect.y0; offsetx -= anchor_offset_x; - offsety += anchor_offset_y; + offsety -= anchor_offset_y; + + cairo_set_font_size(buf->ct, cl->fontsize); if (cl->background){ cairo_text_extents_t extents; @@ -136,7 +136,6 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) } cairo_move_to(buf->ct, offsetx, offsety); - cairo_set_font_size(buf->ct, cl->fontsize); cairo_text_path(buf->ct, cl->text); if (cl->outline){ @@ -169,24 +168,43 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i cairo_surface_t *tmp_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); cairo_t* tmp_buf = cairo_create(tmp_surface); + cairo_set_font_size(tmp_buf, cl->fontsize); cairo_text_extents_t extents; cairo_text_extents(tmp_buf, cl->text, &extents); - double border = extents.height*1.5; + double border = extents.height; - item->x1 = s[Geom::X] - extents.x_bearing - border; - item->y1 = s[Geom::Y] + extents.y_bearing - border; - item->x2 = s[Geom::X] + extents.width + border; - item->y2 = s[Geom::Y] + extents.height + border; + item->x1 = s[Geom::X] - extents.x_bearing - 2*border; + item->y1 = s[Geom::Y] + extents.y_bearing - 2*border; + item->x2 = s[Geom::X] + extents.width + 2*border; + item->y2 = s[Geom::Y] + extents.height + 2*border; // adjust update region according to anchor shift - // FIXME: use the correct text extent - anchor_offset_x = arbitrary_factor * cl->fontsize * strlen(cl->text) * (cl->anchor_x + 1.0) / 2.0; - anchor_offset_y = cl->fontsize * (cl->anchor_y + 1.0) / 2.0; + switch (cl->anchor_position){ + case TEXT_ANCHOR_LEFT: + anchor_offset_x = -2*border; + anchor_offset_y = -extents.height/2; + case TEXT_ANCHOR_RIGHT: + anchor_offset_x = extents.width + 2*border; + anchor_offset_y = -extents.height/2; + case TEXT_ANCHOR_BOTTOM: + anchor_offset_x = extents.width/2; + anchor_offset_y = 2*border; + case TEXT_ANCHOR_TOP: + anchor_offset_x = extents.width/2; + anchor_offset_y = -extents.height - 2*border; + case TEXT_ANCHOR_ZERO: + anchor_offset_x = 0; + anchor_offset_y = 0; + case TEXT_ANCHOR_CENTER: + default: + anchor_offset_x = extents.width/2; + anchor_offset_y = -extents.height/2; + } item->x1 -= anchor_offset_x; item->x2 -= anchor_offset_x; - item->y1 += anchor_offset_y; - item->y2 += anchor_offset_y; + item->y1 -= anchor_offset_y; + item->y2 -= anchor_offset_y; sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); } diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index bd3bd18d4..30ddc1557 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -23,6 +23,15 @@ struct SPDesktop; #define SP_CANVASTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVASTEXT, SPCanvasText)) #define SP_IS_CANVASTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CANVASTEXT)) +enum CanvasTextAnchorPositionEnum { + TEXT_ANCHOR_CENTER, + TEXT_ANCHOR_TOP, + TEXT_ANCHOR_BOTTOM, + TEXT_ANCHOR_LEFT, + TEXT_ANCHOR_RIGHT, + TEXT_ANCHOR_ZERO +}; + struct SPCanvasText : public SPCanvasItem { SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users guint32 rgba; @@ -30,6 +39,7 @@ struct SPCanvasText : public SPCanvasItem { guint32 rgba_background; bool outline; bool background; + CanvasTextAnchorPositionEnum anchor_position; SPDesktop *desktop; // the desktop to which this text is attached; needed for coordinate transforms (TODO: these should be eliminated) diff --git a/src/measure-context.cpp b/src/measure-context.cpp index dc2bb09e3..741dd5edd 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -346,6 +346,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x0000007f; SP_CANVASTEXT(canvas_tooltip)->outline = false; SP_CANVASTEXT(canvas_tooltip)->background = true; + SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(measure_str); -- cgit v1.2.3 From e0fed85c5699139e3ef2f5d8ef382d4251af4110 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 22 Jun 2011 02:10:08 +0100 Subject: Replace deprecated GtkCombo (bzr r10331.1.1) --- src/dialogs/text-edit.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 81bd0f5d2..daab8de86 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -341,23 +341,16 @@ sp_text_edit_dialog (void) { GtkWidget *row = gtk_hbox_new (FALSE, VB_MARGIN); - GtkWidget *c = gtk_combo_new (); - gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE); - gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE); - gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE); + GtkWidget *c = gtk_combo_box_text_new_with_entry (); gtk_widget_set_size_request (c, 90, -1); { /* Setup strings */ - GList *sl = NULL; for (int i = 0; spacings[i]; i++) { - sl = g_list_prepend (sl, (void *) spacings[i]); + gtk_combo_box_text_append_text((GtkComboBoxText *) c, spacings[i]); } - sl = g_list_reverse (sl); - gtk_combo_set_popdown_strings ((GtkCombo *) c, sl); - g_list_free (sl); } - g_signal_connect ( (GObject *) ((GtkCombo *) c)->entry, + g_signal_connect ( (GObject *) c, "changed", (GCallback) sp_text_edit_dialog_line_spacing_changed, dlg ); @@ -609,7 +602,7 @@ sp_get_text_dialog_style () // Note that CSS 1.1 does not support line-height; we set it for consistency, but also set // sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext GtkWidget *combo = (GtkWidget*)g_object_get_data ((GObject *) dlg, "line_spacing"); - const char *sstr = gtk_entry_get_text ((GtkEntry *) ((GtkCombo *) (combo))->entry); + const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) combo); sp_repr_css_set_property (css, "line-height", sstr); return css; @@ -820,7 +813,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, height = query->line_height.value; else height = query->line_height.computed; gchar *sstr = g_strdup_printf ("%d%%", (int) floor(height * 100 + 0.5)); - gtk_entry_set_text ((GtkEntry *) ((GtkCombo *) (combo))->entry, sstr); + gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) (combo)), sstr); g_free(sstr); sp_style_unref(query); -- cgit v1.2.3 From fd70df8246aa298587c90fa5d451c25abe858045 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Wed, 22 Jun 2011 14:33:11 +0000 Subject: get cmake working again. (bzr r10334) --- src/CMakeLists.txt | 4 --- src/display/CMakeLists.txt | 19 +++++--------- src/extension/CMakeLists.txt | 3 --- src/filters/CMakeLists.txt | 19 +++----------- src/libnr/CMakeLists.txt | 59 -------------------------------------------- src/libnrtype/CMakeLists.txt | 4 --- src/widgets/CMakeLists.txt | 2 -- 7 files changed, 9 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d048eaa87..1e4ad99e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,6 @@ set(sp_SRC sp-flowtext.cpp sp-font-face.cpp sp-font.cpp - sp-gaussian-blur.cpp sp-glyph-kerning.cpp sp-glyph.cpp sp-gradient-reference.cpp @@ -85,7 +84,6 @@ set(sp_SRC sp-defs.h sp-desc.h sp-ellipse.h - sp-filter-fns.h sp-filter-primitive.h sp-filter-reference.h sp-filter-units.h @@ -95,8 +93,6 @@ set(sp_SRC sp-flowtext.h sp-font-face.h sp-font.h - sp-gaussian-blur-fns.h - sp-gaussian-blur.h sp-glyph-kerning.h sp-glyph.h sp-gradient-fns.h diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 30643550f..e78ddd59f 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -1,5 +1,6 @@ set(display_SRC + cairo-utils.cpp canvas-arena.cpp canvas-axonomgrid.cpp canvas-bpath.cpp @@ -11,7 +12,6 @@ set(display_SRC gnome-canvas-acetate.cpp grayscale.cpp guideline.cpp - inkscape-cairo.cpp nr-3dutils.cpp nr-arena-glyphs.cpp nr-arena-group.cpp @@ -28,7 +28,6 @@ set(display_SRC nr-filter-displacement-map.cpp nr-filter-flood.cpp nr-filter-gaussian.cpp - nr-filter-getalpha.cpp nr-filter-image.cpp nr-filter-merge.cpp nr-filter-morphology.cpp @@ -43,12 +42,9 @@ set(display_SRC nr-filter-utils.cpp nr-filter.cpp nr-light.cpp - nr-plain-stuff-gdk.cpp - nr-plain-stuff.cpp + nr-style.cpp nr-svgfonts.cpp nr-svgfonts.h - pixblock-scaler.cpp - pixblock-transform.cpp snap-indicator.cpp sodipodi-ctrl.cpp sodipodi-ctrlrect.cpp @@ -61,6 +57,8 @@ set(display_SRC # ------- # Headers + cairo-templates.h + cairo-utils.h canvas-arena.h canvas-axonomgrid.h canvas-bpath.h @@ -70,10 +68,10 @@ set(display_SRC canvas-text.h curve-test.h curve.h + display-forward.h gnome-canvas-acetate.h grayscale.h guideline.h - inkscape-cairo.h nr-3dutils.h nr-arena-forward.h nr-arena-glyphs.h @@ -91,12 +89,10 @@ set(display_SRC nr-filter-displacement-map.h nr-filter-flood.h nr-filter-gaussian.h - nr-filter-getalpha.h nr-filter-image.h nr-filter-merge.h nr-filter-morphology.h nr-filter-offset.h - nr-filter-pixops.h nr-filter-primitive.h nr-filter-skeleton.h nr-filter-slot.h @@ -109,10 +105,7 @@ set(display_SRC nr-filter.h nr-light-types.h nr-light.h - nr-plain-stuff-gdk.h - nr-plain-stuff.h - pixblock-scaler.h - pixblock-transform.h + nr-style.h rendermode.h snap-indicator.h sodipodi-ctrl.h diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 60de65416..5ccb5c984 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -136,15 +136,12 @@ set(extension_SRC internal/pov-out.h internal/svg.h internal/svgz.h - internal/win32.h script/InkscapeScript.h ) if(WIN32) list(APPEND extension_SRC - internal/win32.cpp - internal/win32.h ) endif() diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index 72e0bba78..7c698777d 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -2,14 +2,15 @@ set(filters_SRC blend.cpp colormatrix.cpp - componenttransfer.cpp componenttransfer-funcnode.cpp + componenttransfer.cpp composite.cpp convolvematrix.cpp diffuselighting.cpp displacementmap.cpp distantlight.cpp flood.cpp + gaussian-blur.cpp image.cpp merge.cpp mergenode.cpp @@ -23,40 +24,26 @@ set(filters_SRC # ------- # Headers - blend-fns.h blend.h - colormatrix-fns.h colormatrix.h - componenttransfer-fns.h componenttransfer-funcnode.h componenttransfer.h - composite-fns.h composite.h - convolvematrix-fns.h convolvematrix.h - diffuselighting-fns.h diffuselighting.h - displacementmap-fns.h displacementmap.h distantlight.h - flood-fns.h flood.h - image-fns.h + gaussian-blur.h image.h - merge-fns.h merge.h mergenode.h - morphology-fns.h morphology.h - offset-fns.h offset.h pointlight.h - specularlighting-fns.h specularlighting.h spotlight.h - tile-fns.h tile.h - turbulence-fns.h turbulence.h ) diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 994c5d348..b310068c0 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -1,31 +1,12 @@ set(nr_SRC # in-svg-plane-test.cpp - nr-blit.cpp - nr-compose.cpp - nr-compose-transform.cpp - nr-gradient.cpp - nr-matrix.cpp - nr-matrix-div.cpp - nr-matrix-fns.cpp - nr-matrix-rotate-ops.cpp nr-object.cpp - nr-pixblock.cpp - nr-pixblock-line.cpp - nr-pixblock-pattern.cpp - nr-pixblock-pixel.cpp nr-point-fns.cpp # nr-point-fns-test.cpp nr-rect.cpp nr-rect-l.cpp - nr-rotate-fns.cpp # nr-rotate-fns-test.cpp - nr-rotate-matrix-ops.cpp - nr-scale-matrix-ops.cpp - nr-scale-translate-ops.cpp - nr-translate-matrix-ops.cpp - nr-translate-rotate-ops.cpp - nr-translate-scale-ops.cpp #nr-translate-test.cpp nr-types.cpp # nr-types-test.cpp @@ -36,63 +17,23 @@ set(nr_SRC # Headers # in-svg-plane-test.h in-svg-plane.h - nr-blit.h - nr-compose-reference.h - nr-compose-test.h - nr-compose-transform.h - nr-compose.h nr-convert2geom.h - nr-convex-hull-ops.h - nr-convex-hull.h nr-coord.h nr-dim2.h nr-forward.h - nr-gradient.h nr-i-coord.h nr-macros.h - nr-matrix-div.h - nr-matrix-fns.h - nr-matrix-ops.h - nr-matrix-rotate-ops.h - nr-matrix-scale-ops.h - nr-matrix-test.h - nr-matrix-translate-ops.h - nr-matrix.h - nr-maybe.h nr-object.h - nr-path-code.h - nr-pixblock-line.h - nr-pixblock-pattern.h - nr-pixblock-pixel.h - nr-pixblock.h - nr-pixops.h # nr-point-fns-test.h nr-point-fns.h nr-point-l.h - nr-point-matrix-ops.h nr-point-ops.h nr-point.h nr-rect-l.h nr-rect-ops.h nr-rect.h nr-render.h - nr-rotate-fns-test.h - nr-rotate-fns.h - nr-rotate-matrix-ops.h - nr-rotate-ops.h - nr-rotate-test.h - nr-rotate.h - nr-scale-matrix-ops.h - nr-scale-ops.h - nr-scale-test.h - nr-scale-translate-ops.h - nr-scale.h - nr-translate-matrix-ops.h - nr-translate-ops.h - nr-translate-rotate-ops.h - nr-translate-scale-ops.h # nr-translate-test.h - nr-translate.h # nr-types-test.h nr-types.h nr-values.h diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 835665761..3d52e2c4e 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -12,13 +12,11 @@ set(nrtype_SRC Layout-TNG-Scanline-Makers.cpp nr-type-pos-def.cpp nr-type-primitives.cpp - RasterFont.cpp TextWrapper.cpp FontFactory.h Layout-TNG-Scanline-Maker.h Layout-TNG.h - RasterFont.h TextWrapper.h boundary-type.h font-glyph.h @@ -32,8 +30,6 @@ set(nrtype_SRC one-box.h one-glyph.h one-para.h - raster-glyph.h - raster-position.h text-boundary.h ) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index d9e05f06a..1a203afc6 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -20,7 +20,6 @@ set(widgets_SRC sp-color-gtkselector.cpp sp-color-icc-selector.cpp sp-color-notebook.cpp - sp-color-preview.cpp sp-color-scales.cpp sp-color-selector.cpp sp-color-slider.cpp @@ -56,7 +55,6 @@ set(widgets_SRC sp-color-gtkselector.h sp-color-icc-selector.h sp-color-notebook.h - sp-color-preview.h sp-color-scales.h sp-color-selector.h sp-color-slider.h -- cgit v1.2.3 From 7a4aa96e6c3dabfccb8c2be1c3ff86572b187a6f Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Wed, 22 Jun 2011 04:50:13 -0300 Subject: oops! I forgot to put "break;"s in my switch statement :-P (bzr r10337) --- src/display/canvas-text.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 22342bb71..842425f50 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -183,22 +183,28 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i case TEXT_ANCHOR_LEFT: anchor_offset_x = -2*border; anchor_offset_y = -extents.height/2; + break; case TEXT_ANCHOR_RIGHT: anchor_offset_x = extents.width + 2*border; anchor_offset_y = -extents.height/2; + break; case TEXT_ANCHOR_BOTTOM: anchor_offset_x = extents.width/2; anchor_offset_y = 2*border; + break; case TEXT_ANCHOR_TOP: anchor_offset_x = extents.width/2; anchor_offset_y = -extents.height - 2*border; + break; case TEXT_ANCHOR_ZERO: anchor_offset_x = 0; anchor_offset_y = 0; + break; case TEXT_ANCHOR_CENTER: default: anchor_offset_x = extents.width/2; anchor_offset_y = -extents.height/2; + break; } item->x1 -= anchor_offset_x; -- cgit v1.2.3 From 57b425c79a4c460a0b76b07603e76a5df431fd67 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Wed, 22 Jun 2011 05:41:16 -0300 Subject: Revision 10333 introduced dependency on gtk version 2.24 which is currently not available in my development system (Trisquel GNU/Linux 4.5.1 - released on May 25th, 2011) I have brought back the implementation that uses the 2.22 API and used GTK_CHECK_VERSION to keep both implementations, so that I can continue coding. The conditional and its #else block can be deleted in the future (bzr r10338) --- src/dialogs/text-edit.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index daab8de86..76cbdef57 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -341,16 +341,49 @@ sp_text_edit_dialog (void) { GtkWidget *row = gtk_hbox_new (FALSE, VB_MARGIN); + +//This would introduce dependency on gtk version 2.24 which is currently not available in +// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) +//This conditional and its #else block can be deleted in the future. +#if GTK_CHECK_VERSION(2, 24,0) GtkWidget *c = gtk_combo_box_text_new_with_entry (); +#else + GtkWidget *c = gtk_combo_new (); + gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE); + gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE); + gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE); +#endif gtk_widget_set_size_request (c, 90, -1); +//This would introduce dependency on gtk version 2.24 which is currently not available in +// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) +//This conditional and its #else block can be deleted in the future. +#if GTK_CHECK_VERSION(2, 24,0) { /* Setup strings */ for (int i = 0; spacings[i]; i++) { gtk_combo_box_text_append_text((GtkComboBoxText *) c, spacings[i]); } } - +#else + { /* Setup strings */ + GList *sl = NULL; + for (int i = 0; spacings[i]; i++) { + sl = g_list_prepend (sl, (void *) spacings[i]); + } + sl = g_list_reverse (sl); + gtk_combo_set_popdown_strings ((GtkCombo *) c, sl); + g_list_free (sl); + } +#endif + +//This would introduce dependency on gtk version 2.24 which is currently not available in +// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) +//This conditional and its #else block can be deleted in the future. +#if GTK_CHECK_VERSION(2, 24,0) g_signal_connect ( (GObject *) c, +#else + g_signal_connect ( (GObject *) ((GtkCombo *) c)->entry, +#endif "changed", (GCallback) sp_text_edit_dialog_line_spacing_changed, dlg ); @@ -602,7 +635,15 @@ sp_get_text_dialog_style () // Note that CSS 1.1 does not support line-height; we set it for consistency, but also set // sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext GtkWidget *combo = (GtkWidget*)g_object_get_data ((GObject *) dlg, "line_spacing"); + +//This would introduce dependency on gtk version 2.24 which is currently not available in +// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) +//This conditional and its #else block can be deleted in the future. +#if GTK_CHECK_VERSION(2, 24,0) const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) combo); +#else + const char *sstr = gtk_entry_get_text ((GtkEntry *) ((GtkCombo *) (combo))->entry); +#endif sp_repr_css_set_property (css, "line-height", sstr); return css; @@ -813,7 +854,15 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, height = query->line_height.value; else height = query->line_height.computed; gchar *sstr = g_strdup_printf ("%d%%", (int) floor(height * 100 + 0.5)); + +//This would introduce dependency on gtk version 2.24 which is currently not available in +// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) +//This conditional and its #else block can be deleted in the future. +#if GTK_CHECK_VERSION(2, 24,0) gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) (combo)), sstr); +#else + gtk_entry_set_text ((GtkEntry *) ((GtkCombo *) (combo))->entry, sstr); +#endif g_free(sstr); sp_style_unref(query); -- cgit v1.2.3 From 8640e3a8755e772cc7982a9d6f8a47c6ee0dae00 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Wed, 22 Jun 2011 03:07:58 -0700 Subject: Warning cleanup. (bzr r10339) --- src/dialogs/text-edit.cpp | 2 +- src/display/nr-arena-glyphs.cpp | 19 ++++++++--------- src/display/nr-arena-image.cpp | 10 +++++---- src/display/nr-arena-item.cpp | 3 +-- src/display/nr-arena-shape.cpp | 24 +++++++++++++--------- src/display/nr-filter-diffuselighting.cpp | 2 +- src/display/nr-filter-primitive.h | 2 +- src/display/nr-filter-specularlighting.cpp | 2 +- src/display/nr-filter-turbulence.cpp | 3 ++- src/display/sp-canvas-util.cpp | 3 +-- src/display/sp-canvas.cpp | 3 +-- src/extension/internal/cairo-png-out.cpp | 13 +++++------- src/extension/internal/cairo-render-context.cpp | 15 +++++++------- src/extension/internal/cairo-renderer-pdf-out.cpp | 12 ++++++----- src/extension/internal/wpg-input.cpp | 4 ++-- src/knot-holder-entity.cpp | 1 - src/libnr/nr-rect.cpp | 4 ++-- .../parameter/powerstrokepointarray.cpp | 3 +-- src/measure-context.cpp | 3 ++- src/sp-object-group.cpp | 2 +- src/sp-paint-server.cpp | 2 +- src/sp-polyline.cpp | 4 ++-- src/ui/dialog/dock-behavior.cpp | 3 +-- src/widgets/gradient-image.cpp | 7 +++---- 24 files changed, 73 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 76cbdef57..76ad3bcc3 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -925,7 +925,7 @@ sp_text_edit_dialog_default_set_insensitive () } static void -sp_text_edit_dialog_font_changed ( SPFontSelector *fsel, +sp_text_edit_dialog_font_changed ( SPFontSelector * /*fsel*/, font_instance *font, GtkWidget *dlg ) { diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index facb5e9c6..dbac07596 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -149,8 +149,7 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s return NR_ARENA_ITEM_STATE_ALL; } -static guint -nr_arena_glyphs_clip(cairo_t *ct, NRArenaItem *item, NRRectL */*area*/) +static guint nr_arena_glyphs_clip(cairo_t * /*ct*/, NRArenaItem *item, NRRectL * /*area*/) { NRArenaGlyphs *glyphs; @@ -158,7 +157,7 @@ nr_arena_glyphs_clip(cairo_t *ct, NRArenaItem *item, NRRectL */*area*/) if (!glyphs->font) return item->state; - /* TODO : render to greyscale pixblock provided for clipping */ + // TODO : render to greyscale pixblock provided for clipping return item->state; } @@ -283,15 +282,16 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s } -static unsigned int -nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int /*flags*/) +static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock * /*pb*/, unsigned int /*flags*/) { - NRArenaItem *child; + NRArenaItem *child = 0; NRArenaGroup *group = NR_ARENA_GROUP(item); NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); - if (!ct) return item->state; + if (!ct) { + return item->state; + } if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { @@ -352,14 +352,13 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi return item->state; } -static unsigned int -nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area) +static unsigned int nr_arena_glyphs_group_clip(cairo_t * /*ct*/, NRArenaItem *item, NRRectL * /*area*/) { //NRArenaGroup *group = NR_ARENA_GROUP(item); guint ret = item->state; - /* Render children fill mask */ + // Render children fill mask /* for (NRArenaItem *child = group->children; child != NULL; child = child->next) { ret = nr_arena_glyphs_fill_mask(NR_ARENA_GLYPHS(child), area, pb); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index cb1bc5849..36d733eb8 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -134,18 +134,20 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned return NR_ARENA_ITEM_STATE_ALL; } -static unsigned int -nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int /*flags*/ ) +static unsigned int nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/, NRPixBlock * /*pb*/, unsigned int /*flags*/ ) { - if (!ct) + if (!ct) { return item->state; + } bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); NRArenaImage *image = NR_ARENA_IMAGE (item); if (!outline) { - if (!image->pixbuf) return item->state; + if (!image->pixbuf) { + return item->state; + } // FIXME: at the moment gdk_cairo_set_source_pixbuf creates an ARGB copy // of the pixbuf. Fix this in Cairo and/or GDK. diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 8787c1033..526882921 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -767,8 +767,7 @@ nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect &bbox) } /** Returns a background image for use with filter effects. */ -NRPixBlock * -nr_arena_item_get_background (NRArenaItem const *item) +NRPixBlock *nr_arena_item_get_background(NRArenaItem const * /*item*/) { return NULL; } diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index f278413b2..eb7a30e58 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -394,20 +394,24 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } -static guint -nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area) +static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/) { + guint result = 0; + // NOTE: for now this is incorrect, because it doesn't honor clip-rule, // and will be incorrect for nested clipping paths. NRArenaShape *shape = NR_ARENA_SHAPE(item); - if (!shape->curve) return item->state; - - cairo_save(ct); - ink_cairo_transform(ct, shape->ctm); - feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); - cairo_restore(ct); + if (!shape->curve) { + result = item->state; + } else { + cairo_save(ct); + ink_cairo_transform(ct, shape->ctm); + feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); + cairo_restore(ct); - return item->state; + result = item->state; + } + return result; } static NRArenaItem * @@ -508,7 +512,7 @@ nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int * curve and adds it to the shape. Finally, it requests an update of the * arena for the shape. */ -void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve,bool justTrans) +void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve, bool /*justTrans*/) { g_return_if_fail(shape != NULL); g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 0a46a5c86..eaed2a8bd 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -160,7 +160,7 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Affine const &trans) +void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index dd7363d76..ebecb91ec 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -46,7 +46,7 @@ public: virtual ~FilterPrimitive(); virtual void render_cairo(FilterSlot &slot); - virtual int render(FilterSlot &slot, FilterUnits const &units) { return 0; } + virtual int render(FilterSlot & /*slot*/, FilterUnits const & /*units*/) { return 0; } virtual void area_enlarge(NRRectL &area, Geom::Affine const &m); /** diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index eddab36a1..2e5f69d65 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -304,7 +304,7 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { return 0; }*/ -void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Affine const &trans) +void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 6aa435715..f3b03c024 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -342,7 +342,8 @@ void FilterTurbulence::set_type(FilterTurbulenceType t){ gen->dirty(); } -void FilterTurbulence::set_updated(bool u){ +void FilterTurbulence::set_updated(bool /*u*/) +{ } struct Turbulence { diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index 186609e49..d1ea842fd 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -38,8 +38,7 @@ sp_canvas_item_reset_bounds (SPCanvasItem *item) item->y2 = 0.0; } -void -sp_canvas_prepare_buffer (SPCanvasBuf *buf) +void sp_canvas_prepare_buffer(SPCanvasBuf * /*buf*/) { /*if (buf->is_empty) { int y; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c84452c07..472c9ada5 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1620,8 +1620,7 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) return status; } -static void -sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int sw) +static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int /*sw*/) { GtkWidget *widget = GTK_WIDGET (canvas); diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index eb26fc581..b30e22e7e 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -43,10 +43,9 @@ namespace Inkscape { namespace Extension { namespace Internal { -bool -CairoRendererOutput::check (Inkscape::Extension::Extension * module) +bool CairoRendererOutput::check(Inkscape::Extension::Extension * /*module*/) { - return TRUE; + return true; } static bool @@ -93,13 +92,11 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) \param doc Document to be saved \param uri Filename to save to (probably will end in .png) */ -void -CairoRendererOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename) +void CairoRendererOutput::save(Inkscape::Extension::Output * /*mod*/, SPDocument *doc, gchar const *filename) { - if (!png_render_document_to_file(doc, filename)) + if (!png_render_document_to_file(doc, filename)) { throw Inkscape::Extension::Output::save_failed(); - - return; + } } /** diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index b9c2a4488..1c1dac028 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1419,14 +1419,14 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con return true; } -bool -CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const *image_transform, SPStyle const *style) +bool CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsigned int rs, + Geom::Affine const *image_transform, SPStyle const * /*style*/) { g_assert( _is_valid ); - if (_render_mode == RENDER_MODE_CLIP) + if (_render_mode == RENDER_MODE_CLIP) { return true; + } guchar* px_rgba = NULL; guint64 size = 4L * (guint64)w * (guint64)h; @@ -1514,8 +1514,8 @@ CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsi #define GLYPH_ARRAY_SIZE 64 -unsigned int -CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool path) +// TODO investigate why the font is being ignored: +unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/, std::vector<CairoGlyphInfo> const &glyphtext, bool path) { cairo_glyph_t glyph_array[GLYPH_ARRAY_SIZE]; cairo_glyph_t *glyphs = glyph_array; @@ -1551,8 +1551,9 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoG cairo_show_glyphs(cr, glyphs, num_glyphs - num_invalid_glyphs); } - if (num_glyphs > GLYPH_ARRAY_SIZE) + if (num_glyphs > GLYPH_ARRAY_SIZE) { g_free(glyphs); + } return num_glyphs - num_invalid_glyphs; } diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 6527a646b..cdd9647e2 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -43,13 +43,15 @@ namespace Inkscape { namespace Extension { namespace Internal { -bool -CairoRendererPdfOutput::check (Inkscape::Extension::Extension * module) +bool CairoRendererPdfOutput::check(Inkscape::Extension::Extension * /*module*/) { - if (NULL == Inkscape::Extension::db.get("org.inkscape.output.pdf.cairorenderer")) - return FALSE; + bool result = true; - return TRUE; + if (NULL == Inkscape::Extension::db.get("org.inkscape.output.pdf.cairorenderer")) { + result = false; + } + + return result; } static bool diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 3cd5044f7..0f2857570 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -68,8 +68,8 @@ namespace Extension { namespace Internal { -SPDocument * -WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) { +SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) +{ #if WITH_LIBWPG01 WPXInputStream* input = new libwpg::WPGFileStream(uri); #elif WITH_LIBWPG02 diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 7da3d0c0e..128ca281e 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -107,7 +107,6 @@ KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape: SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, item); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // constrainedSnap() will first project the point p onto the constraint line and then try to snap along that line. // This way the constraint is already enforced, no need to worry about that later on Inkscape::Snapper::SnapConstraint transformed_constraint = Inkscape::Snapper::SnapConstraint(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d); diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp index 58e16e963..8e3672e03 100644 --- a/src/libnr/nr-rect.cpp +++ b/src/libnr/nr-rect.cpp @@ -218,8 +218,8 @@ nr_rect_d_union_xy (NRRect *d, NR::Coord x, NR::Coord y) return d; } -NRRect * -nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m) +// TODO investigate for removal: +NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *const /*s*/, NR::Matrix const & /*m*/) { // defunct /* diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 9d43e8447..66337fd8f 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -70,8 +70,7 @@ PowerStrokePointArrayParam::param_newWidget(Gtk::Tooltips * /*tooltips*/) } -void -PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) +void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) { // param_set_and_write_new_value( (*this) * postmul ); } diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 741dd5edd..bc766872b 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -135,7 +135,8 @@ bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) return p1[Geom::Y] < p2[Geom::Y]; } -void calculate_intersections(SPDesktop *desktop, SPItem* item, Geom::PathVector *lineseg, SPCurve *curve, std::vector<Geom::Point> *intersections){ +void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector *lineseg, SPCurve *curve, std::vector<Geom::Point> *intersections) +{ curve->transform(item->i2doc_affine()); // Find all intersections of the control-line with this shape diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index 001d7898f..65fbc0295 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -41,7 +41,7 @@ GType SPObjectGroup::sp_objectgroup_get_type(void) void SPObjectGroupClass::sp_objectgroup_class_init(SPObjectGroupClass *klass) { - GObjectClass * object_class = (GObjectClass *) klass; + //GObjectClass * object_class = (GObjectClass *) klass; SPObjectClass * sp_object_class = (SPObjectClass *) klass; static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index dc99639c8..2ed556b23 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -64,7 +64,7 @@ static void sp_paint_server_class_init(SPPaintServerClass *psc) parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); } -void SPPaintServer::init(SPPaintServer *ps) +void SPPaintServer::init(SPPaintServer * /*ps*/) { } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 705b9a10b..8dbed2a22 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -46,7 +46,7 @@ GType SPPolyLine::sp_polyline_get_type(void) void SPPolyLineClass::sp_polyline_class_init(SPPolyLineClass *klass) { - GObjectClass * gobject_class = (GObjectClass *) klass; + //GObjectClass * gobject_class = (GObjectClass *) klass; SPObjectClass * sp_object_class = (SPObjectClass *) klass; SPItemClass * item_class = (SPItemClass *) klass; @@ -134,7 +134,7 @@ void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value) Inkscape::XML::Node *SPPolyLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPPolyLine *polyline = SP_POLYLINE (object); + SP_POLYLINE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:polyline"); diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 39d671cd8..47cbab485 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -165,8 +165,7 @@ DockBehavior::set_title(Glib::ustring title) _dock_item.set_title(title); } -void -DockBehavior::set_sensitive(bool sensitive) +void DockBehavior::set_sensitive(bool sensitive) { // TODO check this. Seems to be bad that we ignore the parameter get_vbox()->set_sensitive(); diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index ef05ad381..115935f50 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -106,11 +106,10 @@ sp_gradient_image_destroy (GtkObject *object) (* ((GtkObjectClass *) (parent_class))->destroy) (object); } -static void -sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition) +static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisition *requisition) { - requisition->width = 64; - requisition->height = 12; + requisition->width = 64; + requisition->height = 12; } static gint -- cgit v1.2.3 From eff2aa4cbf77f5fec1ba2fd98f482737635db342 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Wed, 22 Jun 2011 09:56:30 -0300 Subject: =?UTF-8?q?The=20label=20=E2=80=98Guides=20Around=20Page=E2=80=99?= =?UTF-8?q?=20does=20not=20include=20a=20verb.=20=E2=80=98Guides=20Around?= =?UTF-8?q?=20Page=E2=80=99=20what=3F=20'Create=20Guides=20Around=20the=20?= =?UTF-8?q?Page'=20:-D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://cuts.thinking-garment.com/144 (bzr r10340) --- src/sp-guide.cpp | 2 +- src/verbs.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 19b64eb1a..aa365eb99 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -296,7 +296,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { sp_guide_pt_pairs_to_guides(dt, pts); - DocumentUndo::done(doc, SP_VERB_NONE, _("Guides Around Page")); + DocumentUndo::done(doc, SP_VERB_NONE, _("Create Guides Around the Page")); } void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) diff --git a/src/verbs.cpp b/src/verbs.cpp index 1cdbd71d0..da2e396c7 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2338,7 +2338,7 @@ Verb *Verb::_base_verbs[] = { N_("Select previous object or node"), NULL), new EditVerb(SP_VERB_EDIT_DESELECT, "EditDeselect", N_("D_eselect"), N_("Deselect any selected objects or nodes"), INKSCAPE_ICON_EDIT_SELECT_NONE), - new EditVerb(SP_VERB_EDIT_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("_Guides Around Page"), + new EditVerb(SP_VERB_EDIT_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("Create _Guides Around the Page"), N_("Create four guides aligned with the page borders"), NULL), new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"), N_("Show next editable path effect parameter"), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT), -- cgit v1.2.3 From e2959fe6ceb1167223b72740f89877d52b354ced Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Wed, 22 Jun 2011 10:30:13 -0300 Subject: Position the 'Set' button to lower right corner of the object properties panel. http://cuts.thinking-garment.com/262 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ’Set’ button of the ‘Object Properties’ panel is placed high up, next to the ID text-entry box, suggesting it is applied only to the ID box. In reality, ‘Set’ button applies the changes for every text field. (bzr r10341) --- src/dialogs/item-properties.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index cd56c2da4..3f757e81f 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -131,15 +131,6 @@ sp_item_widget_new (void) // focus is in the id field initially: gtk_widget_grab_focus (GTK_WIDGET (tf)); - /* Button for setting the object's id, label, title and description. */ - pb = gtk_button_new_with_mnemonic (_("_Set")); - gtk_table_attach ( GTK_TABLE (t), pb, 2, 3, 0, 1, - (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ), - (GtkAttachOptions)0, 0, 0 ); - g_signal_connect ( G_OBJECT (pb), "clicked", - G_CALLBACK (sp_item_widget_label_changed), - spw ); - /* Create the label for the object label */ l = gtk_label_new_with_mnemonic (_("_Label:")); gtk_misc_set_alignment (GTK_MISC (l), 1, 0.5); @@ -219,6 +210,13 @@ sp_item_widget_new (void) g_signal_connect (G_OBJECT(cb), "toggled", G_CALLBACK(sp_item_widget_hidden_toggled), spw); gtk_object_set_data(GTK_OBJECT(spw), "hidden", cb); + /* Button for setting the object's id, label, title and description. */ + pb = gtk_button_new_with_mnemonic (_("_Set")); + gtk_box_pack_start (GTK_BOX (hb_cb), pb, TRUE, TRUE, 10); + g_signal_connect ( G_OBJECT (pb), "clicked", + G_CALLBACK (sp_item_widget_label_changed), + spw ); + /* Lock */ // TRANSLATORS: "Lock" is a verb here cb = gtk_check_button_new_with_mnemonic (_("L_ock")); -- cgit v1.2.3 From 1f189ac0c28ee85408431815dceefd0607b6465b Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Wed, 22 Jun 2011 18:40:59 -0300 Subject: Adding a "Remove All Guides" option to the Edit menu. (bzr r10343) --- src/menus-skeleton.h | 1 + src/sp-guide.cpp | 20 ++++++++++++++++++++ src/sp-guide.h | 1 + src/verbs.cpp | 5 +++++ src/verbs.h | 1 + 5 files changed, 28 insertions(+) (limited to 'src') diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 080163d48..dccd17c59 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -83,6 +83,7 @@ static char const menus_skeleton[] = " <verb verb-id=\"EditDeselect\" />\n" " <separator/>\n" " <verb verb-id=\"EditGuidesAroundPage\" />\n" +" <verb verb-id=\"EditRemoveAllGuides\" />\n" " <separator/>\n" " <verb verb-id=\"DialogXMLEditor\" />\n" " </submenu>\n" diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index aa365eb99..f71bc1762 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -163,6 +163,9 @@ static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML object->readAttr( "inkscape:label" ); object->readAttr( "orientation" ); object->readAttr( "position" ); + + /* Register */ + document->addResource("guide", object); } static void sp_guide_release(SPObject *object) @@ -174,6 +177,11 @@ static void sp_guide_release(SPObject *object) guide->views = g_slist_remove(guide->views, guide->views->data); } + if (object->document) { + // Unregister ourselves + object->document->removeResource("guide", object); + } + if (((SPObjectClass *) parent_class)->release) { ((SPObjectClass *) parent_class)->release(object); } @@ -299,6 +307,18 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { DocumentUndo::done(doc, SP_VERB_NONE, _("Create Guides Around the Page")); } +void +sp_guide_delete_all_guides(SPDesktop *dt) { + SPDocument *doc=sp_desktop_document(dt); + const GSList *current; + while ( (current = doc->getResourceList("guide")) ) { + SPGuide* guide = SP_GUIDE(current->data); + sp_guide_remove(guide); + } + + DocumentUndo::done(doc, SP_VERB_NONE, _("Delete All Guides")); +} + void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line); diff --git a/src/sp-guide.h b/src/sp-guide.h index 8cf9c7dc2..4fbfbed3d 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -60,6 +60,7 @@ GType sp_guide_get_type(); void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); +void sp_guide_delete_all_guides(SPDesktop *dt); void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); diff --git a/src/verbs.cpp b/src/verbs.cpp index da2e396c7..bb22711e8 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -966,6 +966,9 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/) case SP_VERB_EDIT_DESELECT: SelectionHelper::selectNone(dt); break; + case SP_VERB_EDIT_DELETE_ALL_GUIDES: + sp_guide_delete_all_guides(dt); + break; case SP_VERB_EDIT_GUIDES_AROUND_PAGE: sp_guide_create_guides_around_page(dt); break; @@ -2340,6 +2343,8 @@ Verb *Verb::_base_verbs[] = { N_("Deselect any selected objects or nodes"), INKSCAPE_ICON_EDIT_SELECT_NONE), new EditVerb(SP_VERB_EDIT_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("Create _Guides Around the Page"), N_("Create four guides aligned with the page borders"), NULL), + new EditVerb(SP_VERB_EDIT_DELETE_ALL_GUIDES, "EditRemoveAllGuides", N_("Delete All Guides"), + N_("Create four guides aligned with the page borders"), NULL), new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"), N_("Show next editable path effect parameter"), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT), diff --git a/src/verbs.h b/src/verbs.h index 5387b57c2..d20189cde 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -84,6 +84,7 @@ enum { SP_VERB_EDIT_SELECT_NEXT, SP_VERB_EDIT_SELECT_PREV, SP_VERB_EDIT_DESELECT, + SP_VERB_EDIT_DELETE_ALL_GUIDES, SP_VERB_EDIT_GUIDES_AROUND_PAGE, SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, /* Selection */ -- cgit v1.2.3 From 7a7f7a79dcea0c2808e276d6d770d498afd9b162 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 23 Jun 2011 10:53:42 +0100 Subject: Remove dead GTK visual functions (bzr r10344) --- src/svg-view-widget.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index da5ad068f..639216d1f 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -103,11 +103,9 @@ sp_svg_view_widget_init (SPSVGSPViewWidget *vw) gtk_widget_show (vw->sw); /* Canvas */ - gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); vw->canvas = sp_canvas_new_aa (); gtk_widget_pop_colormap (); - gtk_widget_pop_visual (); style = gtk_style_copy (vw->canvas->style); style->bg[GTK_STATE_NORMAL] = style->white; gtk_widget_set_style (vw->canvas, style); -- cgit v1.2.3 From c8c2acc061e70fdf6199a86ce48819a386593814 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Thu, 23 Jun 2011 14:49:05 +0200 Subject: Fix aliasing warnings in glib-list-iterators.h by adding G_GNUC_MAY_ALIAS (bzr r10345) --- src/util/glib-list-iterators.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/util/glib-list-iterators.h b/src/util/glib-list-iterators.h index dfee69c07..9883ae450 100644 --- a/src/util/glib-list-iterators.h +++ b/src/util/glib-list-iterators.h @@ -33,7 +33,7 @@ template <typename T> class GSListConstIterator<T *> { public: typedef std::forward_iterator_tag iterator_category; - typedef T * const value_type; + typedef T * const value_type G_GNUC_MAY_ALIAS; typedef std::ptrdiff_t difference_type; typedef value_type *pointer; typedef value_type &reference; @@ -72,7 +72,7 @@ template <typename T> class GSListIterator<T *> { public: typedef std::forward_iterator_tag iterator_category; - typedef T *value_type; + typedef T *value_type G_GNUC_MAY_ALIAS; typedef std::ptrdiff_t difference_type; typedef value_type *pointer; typedef value_type &reference; @@ -117,7 +117,7 @@ template <typename T> class GListConstIterator<T *> { public: typedef std::bidirectional_iterator_tag iterator_category; - typedef T * const value_type; + typedef T * const value_type G_GNUC_MAY_ALIAS; typedef std::ptrdiff_t difference_type; typedef value_type *pointer; typedef value_type &reference; @@ -166,7 +166,7 @@ template <typename T> class GListIterator<T *> { public: typedef std::bidirectional_iterator_tag iterator_category; - typedef T *value_type; + typedef T *value_type G_GNUC_MAY_ALIAS; typedef std::ptrdiff_t difference_type; typedef value_type *pointer; typedef value_type &reference; -- cgit v1.2.3 From ec576062be919237064a454f812ac1bfad12debc Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Thu, 23 Jun 2011 16:32:07 +0200 Subject: Completely remove Inkboard (bzr r10346) --- src/CMakeLists.txt | 2 - src/dom/CMakeLists.txt | 17 - src/dom/Makefile_insert | 3 - src/dom/io/httpclient.cpp | 167 - src/dom/io/httpclient.h | 115 - src/dom/io/socket.cpp | 663 ---- src/dom/io/socket.h | 115 - src/dom/io/uristream.cpp | 29 - src/dom/io/uristream.h | 7 - src/dom/odf/SvgOdg.cpp | 0 src/jabber_whiteboard/CMakeLists.txt | 44 - src/jabber_whiteboard/Makefile_insert | 43 - src/jabber_whiteboard/architecture/components.svg | 445 --- .../architecture/inkboard-document.svg | 287 -- src/jabber_whiteboard/defines.cpp | 116 - src/jabber_whiteboard/defines.h | 262 -- src/jabber_whiteboard/dialog/choose-desktop.cpp | 107 - src/jabber_whiteboard/dialog/choose-desktop.h | 66 - src/jabber_whiteboard/empty.cpp | 1 - src/jabber_whiteboard/inkboard-document.cpp | 480 --- src/jabber_whiteboard/inkboard-document.h | 167 - src/jabber_whiteboard/inkboard-node.cpp | 150 - .../invitation-confirm-dialog.cpp | 68 - src/jabber_whiteboard/invitation-confirm-dialog.h | 67 - src/jabber_whiteboard/keynode.cpp | 190 - src/jabber_whiteboard/keynode.h | 129 - src/jabber_whiteboard/makefile.in | 17 - src/jabber_whiteboard/message-aggregator.cpp | 64 - src/jabber_whiteboard/message-aggregator.h | 136 - src/jabber_whiteboard/message-node.h | 135 - src/jabber_whiteboard/message-queue.cpp | 138 - src/jabber_whiteboard/message-queue.h | 173 - src/jabber_whiteboard/message-tags.cpp | 67 - src/jabber_whiteboard/message-tags.h | 139 - src/jabber_whiteboard/message-utilities.cpp | 493 --- src/jabber_whiteboard/message-utilities.h | 112 - src/jabber_whiteboard/message-verifier.h | 47 - src/jabber_whiteboard/node-tracker.cpp | 317 -- src/jabber_whiteboard/node-tracker.h | 239 -- src/jabber_whiteboard/node-utilities.cpp | 118 - src/jabber_whiteboard/node-utilities.h | 64 - src/jabber_whiteboard/pedrogui.cpp | 2835 --------------- src/jabber_whiteboard/pedrogui.h | 914 ----- src/jabber_whiteboard/protocol/README.txt | 11 - .../protocol/disconnect-u2u-01.svg | 167 - src/jabber_whiteboard/protocol/protocol.bib | 38 - src/jabber_whiteboard/protocol/protocol.tex | 227 -- .../protocol/session-invite-u2c-01.svg | 376 -- .../protocol/session-invite-u2u-01.svg | 306 -- .../protocol/session-invite-u2u-02.svg | 168 - .../protocol/session-invite-u2u-03.svg | 202 -- .../protocol/session-invite-u2u-04.svg | 151 - src/jabber_whiteboard/protocol/svg2eps.sh | 5 - .../protocol/unsupported-protocol-u2c-01.svg | 277 -- .../protocol/unsupported-protocol-u2u-01.svg | 174 - src/jabber_whiteboard/session-file-selector.cpp | 91 - src/jabber_whiteboard/session-file-selector.h | 59 - src/jabber_whiteboard/session-manager.cpp | 410 --- src/jabber_whiteboard/session-manager.h | 141 - src/jabber_whiteboard/tracker-node.h | 94 - src/pedro/CMakeLists.txt | 14 - src/pedro/Makefile.mingw | 199 -- src/pedro/Makefile_insert | 26 - src/pedro/certs/client.pem | 32 - src/pedro/certs/dh1024.pem | 5 - src/pedro/certs/root.pem | 14 - src/pedro/certs/server.pem | 32 - src/pedro/empty.cpp | 1 - src/pedro/geckoembed.cpp | 59 - src/pedro/geckoembed.h | 64 - src/pedro/icon/Thumbs.db | Bin 10240 -> 0 bytes src/pedro/icon/available.png | Bin 174 -> 0 bytes src/pedro/icon/away.png | Bin 185 -> 0 bytes src/pedro/icon/chat.png | Bin 194 -> 0 bytes src/pedro/icon/dnd.png | Bin 193 -> 0 bytes src/pedro/icon/error.png | Bin 159 -> 0 bytes src/pedro/icon/offline.png | Bin 156 -> 0 bytes src/pedro/icon/xa.png | Bin 214 -> 0 bytes src/pedro/makefile.in | 17 - src/pedro/mingwenv.bat | 2 - src/pedro/pedro.bat | 2 - src/pedro/pedroconfig.cpp | 406 --- src/pedro/pedroconfig.h | 317 -- src/pedro/pedrodom.cpp | 802 ----- src/pedro/pedrodom.h | 363 -- src/pedro/pedrogui.cpp | 2757 --------------- src/pedro/pedrogui.h | 907 ----- src/pedro/pedromain.cpp | 94 - src/pedro/pedroutil.cpp | 1516 -------- src/pedro/pedroutil.h | 545 --- src/pedro/pedroxmpp.cpp | 3649 -------------------- src/pedro/pedroxmpp.h | 1251 ------- src/pedro/work/filerec.cpp | 130 - src/pedro/work/filesend.cpp | 95 - src/pedro/work/groupchat.cpp | 225 -- src/pedro/work/inklayout.svg | 378 -- src/pedro/work/test.cpp | 183 - src/ui/dialog/Makefile_insert | 10 - src/ui/dialog/whiteboard-connect.cpp | 321 -- src/ui/dialog/whiteboard-connect.h | 99 - src/ui/dialog/whiteboard-sharewithchat.cpp | 164 - src/ui/dialog/whiteboard-sharewithchat.h | 96 - src/ui/dialog/whiteboard-sharewithuser.cpp | 227 -- src/ui/dialog/whiteboard-sharewithuser.h | 110 - 104 files changed, 27757 deletions(-) delete mode 100644 src/dom/io/httpclient.cpp delete mode 100644 src/dom/io/httpclient.h delete mode 100644 src/dom/io/socket.cpp delete mode 100644 src/dom/io/socket.h delete mode 100644 src/dom/odf/SvgOdg.cpp delete mode 100644 src/jabber_whiteboard/CMakeLists.txt delete mode 100644 src/jabber_whiteboard/Makefile_insert delete mode 100644 src/jabber_whiteboard/architecture/components.svg delete mode 100644 src/jabber_whiteboard/architecture/inkboard-document.svg delete mode 100644 src/jabber_whiteboard/defines.cpp delete mode 100644 src/jabber_whiteboard/defines.h delete mode 100644 src/jabber_whiteboard/dialog/choose-desktop.cpp delete mode 100644 src/jabber_whiteboard/dialog/choose-desktop.h delete mode 100644 src/jabber_whiteboard/empty.cpp delete mode 100644 src/jabber_whiteboard/inkboard-document.cpp delete mode 100644 src/jabber_whiteboard/inkboard-document.h delete mode 100644 src/jabber_whiteboard/inkboard-node.cpp delete mode 100644 src/jabber_whiteboard/invitation-confirm-dialog.cpp delete mode 100644 src/jabber_whiteboard/invitation-confirm-dialog.h delete mode 100644 src/jabber_whiteboard/keynode.cpp delete mode 100644 src/jabber_whiteboard/keynode.h delete mode 100644 src/jabber_whiteboard/makefile.in delete mode 100644 src/jabber_whiteboard/message-aggregator.cpp delete mode 100644 src/jabber_whiteboard/message-aggregator.h delete mode 100644 src/jabber_whiteboard/message-node.h delete mode 100644 src/jabber_whiteboard/message-queue.cpp delete mode 100644 src/jabber_whiteboard/message-queue.h delete mode 100644 src/jabber_whiteboard/message-tags.cpp delete mode 100644 src/jabber_whiteboard/message-tags.h delete mode 100644 src/jabber_whiteboard/message-utilities.cpp delete mode 100644 src/jabber_whiteboard/message-utilities.h delete mode 100644 src/jabber_whiteboard/message-verifier.h delete mode 100644 src/jabber_whiteboard/node-tracker.cpp delete mode 100644 src/jabber_whiteboard/node-tracker.h delete mode 100644 src/jabber_whiteboard/node-utilities.cpp delete mode 100644 src/jabber_whiteboard/node-utilities.h delete mode 100644 src/jabber_whiteboard/pedrogui.cpp delete mode 100644 src/jabber_whiteboard/pedrogui.h delete mode 100644 src/jabber_whiteboard/protocol/README.txt delete mode 100644 src/jabber_whiteboard/protocol/disconnect-u2u-01.svg delete mode 100644 src/jabber_whiteboard/protocol/protocol.bib delete mode 100644 src/jabber_whiteboard/protocol/protocol.tex delete mode 100644 src/jabber_whiteboard/protocol/session-invite-u2c-01.svg delete mode 100644 src/jabber_whiteboard/protocol/session-invite-u2u-01.svg delete mode 100644 src/jabber_whiteboard/protocol/session-invite-u2u-02.svg delete mode 100644 src/jabber_whiteboard/protocol/session-invite-u2u-03.svg delete mode 100644 src/jabber_whiteboard/protocol/session-invite-u2u-04.svg delete mode 100755 src/jabber_whiteboard/protocol/svg2eps.sh delete mode 100644 src/jabber_whiteboard/protocol/unsupported-protocol-u2c-01.svg delete mode 100644 src/jabber_whiteboard/protocol/unsupported-protocol-u2u-01.svg delete mode 100644 src/jabber_whiteboard/session-file-selector.cpp delete mode 100644 src/jabber_whiteboard/session-file-selector.h delete mode 100644 src/jabber_whiteboard/session-manager.cpp delete mode 100644 src/jabber_whiteboard/session-manager.h delete mode 100644 src/jabber_whiteboard/tracker-node.h delete mode 100644 src/pedro/CMakeLists.txt delete mode 100644 src/pedro/Makefile.mingw delete mode 100644 src/pedro/Makefile_insert delete mode 100644 src/pedro/certs/client.pem delete mode 100644 src/pedro/certs/dh1024.pem delete mode 100644 src/pedro/certs/root.pem delete mode 100644 src/pedro/certs/server.pem delete mode 100644 src/pedro/empty.cpp delete mode 100644 src/pedro/geckoembed.cpp delete mode 100644 src/pedro/geckoembed.h delete mode 100644 src/pedro/icon/Thumbs.db delete mode 100644 src/pedro/icon/available.png delete mode 100644 src/pedro/icon/away.png delete mode 100644 src/pedro/icon/chat.png delete mode 100644 src/pedro/icon/dnd.png delete mode 100644 src/pedro/icon/error.png delete mode 100644 src/pedro/icon/offline.png delete mode 100644 src/pedro/icon/xa.png delete mode 100644 src/pedro/makefile.in delete mode 100644 src/pedro/mingwenv.bat delete mode 100644 src/pedro/pedro.bat delete mode 100644 src/pedro/pedroconfig.cpp delete mode 100644 src/pedro/pedroconfig.h delete mode 100644 src/pedro/pedrodom.cpp delete mode 100644 src/pedro/pedrodom.h delete mode 100644 src/pedro/pedrogui.cpp delete mode 100644 src/pedro/pedrogui.h delete mode 100644 src/pedro/pedromain.cpp delete mode 100644 src/pedro/pedroutil.cpp delete mode 100644 src/pedro/pedroutil.h delete mode 100644 src/pedro/pedroxmpp.cpp delete mode 100644 src/pedro/pedroxmpp.h delete mode 100644 src/pedro/work/filerec.cpp delete mode 100644 src/pedro/work/filesend.cpp delete mode 100644 src/pedro/work/groupchat.cpp delete mode 100644 src/pedro/work/inklayout.svg delete mode 100644 src/pedro/work/test.cpp delete mode 100644 src/ui/dialog/whiteboard-connect.cpp delete mode 100644 src/ui/dialog/whiteboard-connect.h delete mode 100644 src/ui/dialog/whiteboard-sharewithchat.cpp delete mode 100644 src/ui/dialog/whiteboard-sharewithchat.h delete mode 100644 src/ui/dialog/whiteboard-sharewithuser.cpp delete mode 100644 src/ui/dialog/whiteboard-sharewithuser.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e4ad99e6..c508e36d9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -528,9 +528,7 @@ add_subdirectory(extension) add_subdirectory(filters) add_subdirectory(helper) add_subdirectory(io) -# add_subdirectory(jabber_whiteboard) add_subdirectory(live_effects) -# add_subdirectory(pedro) add_subdirectory(svg) add_subdirectory(trace) add_subdirectory(ui) diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index dbaa1a763..b328418c7 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -23,32 +23,15 @@ set(dom_SRC io/bufferstream.cpp io/domstream.cpp io/gzipstream.cpp - # io/httpclient.cpp - io/socket.cpp io/stringstream.cpp io/uristream.cpp odf/odfdocument.cpp - #odf/SvgOdg.cpp util/digest.cpp util/thread.cpp util/ziptool.cpp - # # Dont use any of them. - # work/svg2.cpp - # work/testdom.cpp - # work/testhttp.cpp - # work/testjs.cpp - # work/testodf.cpp - # work/testsvg.cpp - # work/testuri.cpp - # work/testxpath.cpp - # work/testzip.cpp - # work/xpathtests.cpp - - - # ------- # Headers css.h diff --git a/src/dom/Makefile_insert b/src/dom/Makefile_insert index d74d30137..ace53b4a2 100644 --- a/src/dom/Makefile_insert +++ b/src/dom/Makefile_insert @@ -56,11 +56,8 @@ dom_libdom_a_SOURCES = \ dom/io/bufferstream.h \ dom/io/domstream.cpp \ dom/io/domstream.h \ - dom/io/httpclient.h \ dom/io/gzipstream.cpp \ dom/io/gzipstream.h \ - dom/io/socket.cpp \ - dom/io/socket.h \ dom/io/gzipstream.cpp \ dom/io/gzipstream.h \ dom/io/stringstream.cpp \ diff --git a/src/dom/io/httpclient.cpp b/src/dom/io/httpclient.cpp deleted file mode 100644 index 97c8575cf..000000000 --- a/src/dom/io/httpclient.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "httpclient.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - - - -/** - * - */ -HttpClient::HttpClient() -{ -} - - -/** - * - */ -HttpClient::~HttpClient() -{ -} - - -/** - * - */ -bool HttpClient::openGet(const URI &uri) -{ - - socket.disconnect(); - - if (uri.getScheme() == URI::SCHEME_HTTP) - socket.enableSSL(false); - else if (uri.getScheme() == URI::SCHEME_HTTPS) - socket.enableSSL(true); - else - { - //printf("Bad proto scheme:%d\n", uri.getScheme()); - return false; - } - - DOMString host = uri.getHost(); - int port = uri.getPort(); - DOMString path = uri.getPath(); - if (path.size() == 0) - path = "/"; - - //printf("host:%s port:%d, path:%s\n", host.c_str(), port, path.c_str()); - - if (!socket.connect(host, port)) - { - return false; - } - - DOMString msg = "GET "; - msg.append(path); - msg.append(" HTTP/1.0\r\n\r\n"); - //printf("msg:'%s'\n", msg.c_str()); - - //# Make the request - if (!socket.write(msg)) - { - return false; - } - - //# Read the HTTP headers - while (true) - { - if (!socket.readLine(msg)) - return false; - //printf("header:'%s'\n", msg.c_str()); - if (msg.size() < 1) - break; - } - - return true; -} - - -/** - * - */ -int HttpClient::read() -{ - int ret = socket.read(); - return ret; -} - -/** - * - */ -bool HttpClient::write(int ch) -{ - if (!socket.write(ch)) - return false; - return true; -} - -/** - * - */ -bool HttpClient::write(const DOMString &msg) -{ - if (!socket.write(msg)) - return false; - return true; -} - -/** - * - */ -bool HttpClient::close() -{ - socket.disconnect(); - return true; -} - - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### - diff --git a/src/dom/io/httpclient.h b/src/dom/io/httpclient.h deleted file mode 100644 index 50538d0f5..000000000 --- a/src/dom/io/httpclient.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef __HTTPCLIENT_H__ -#define __HTTPCLIENT_H__ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "dom/dom.h" -#include "dom/uri.h" -#include "dom/io/socket.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - - - - - -class HttpClient -{ - -public: - - /** - * - */ - HttpClient(); - - /** - * - */ - virtual ~HttpClient(); - - /** - * - */ - bool openGet(const URI &uri); - - /** - * - */ - int read(); - - /** - * - */ - bool write(int ch); - - /** - * - */ - bool write(const DOMString &msg); - - /** - * - */ - bool close(); - - -private: - - - TcpSocket socket; - -}; - - - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif /* __HTTPCLIENT_H__ */ - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### - diff --git a/src/dom/io/socket.cpp b/src/dom/io/socket.cpp deleted file mode 100644 index e39032040..000000000 --- a/src/dom/io/socket.cpp +++ /dev/null @@ -1,663 +0,0 @@ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef HAVE_SYS_FILIO_H -#include <sys/filio.h> // needed on Solaris 8 -#endif - -#include <cstdio> -#include "socket.h" -#include "dom/util/thread.h" - -#ifdef __WIN32__ -#include <windows.h> -#else /* unix */ -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#include <unistd.h> -#include <sys/ioctl.h> - -#endif - -#ifdef HAVE_SSL -#include <openssl/ssl.h> -#include <openssl/err.h> - -RELAYTOOL_SSL -#endif - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - -static void mybzero(void *s, size_t n) -{ - unsigned char *p = (unsigned char *)s; - while (n > 0) - { - *p++ = (unsigned char)0; - n--; - } -} - -static void mybcopy(void *src, void *dest, size_t n) -{ - unsigned char *p = (unsigned char *)dest; - unsigned char *q = (unsigned char *)src; - while (n > 0) - { - *p++ = *q++; - n--; - } -} - - - -//######################################################################### -//# T C P C O N N E C T I O N -//######################################################################### - -TcpSocket::TcpSocket() -{ - init(); -} - - -TcpSocket::TcpSocket(const DOMString &hostnameArg, int port) -{ - init(); - hostname = hostnameArg; - portno = port; -} - - -#ifdef HAVE_SSL - -static void cryptoLockCallback(int mode, int type, const char *file, int line) -{ - //printf("########### LOCK\n"); - static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ - const char *errstr = NULL; - - int rw = mode & (CRYPTO_READ|CRYPTO_WRITE); - if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE))) - { - errstr = "invalid mode"; - goto err; - } - - if (type < 0 || type >= CRYPTO_NUM_LOCKS) - { - errstr = "type out of bounds"; - goto err; - } - - if (mode & CRYPTO_LOCK) - { - if (modes[type]) - { - errstr = "already locked"; - /* must not happen in a single-threaded program - * (would deadlock) - */ - goto err; - } - - modes[type] = rw; - } - else if (mode & CRYPTO_UNLOCK) - { - if (!modes[type]) - { - errstr = "not locked"; - goto err; - } - - if (modes[type] != rw) - { - errstr = (rw == CRYPTO_READ) ? - "CRYPTO_r_unlock on write lock" : - "CRYPTO_w_unlock on read lock"; - } - - modes[type] = 0; - } - else - { - errstr = "invalid mode"; - goto err; - } - - err: - if (errstr) - { - /* we cannot use bio_err here */ - fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", - errstr, mode, type, file, line); - } -} - -static unsigned long cryptoIdCallback() -{ -#ifdef __WIN32__ - unsigned long ret = (unsigned long) GetCurrentThreadId(); -#else - unsigned long ret = (unsigned long) pthread_self(); -#endif - return ret; -} - -#endif - - -TcpSocket::TcpSocket(const TcpSocket &other) -{ - init(); - sock = other.sock; - hostname = other.hostname; - portno = other.portno; -} - -static bool tcp_socket_inited = false; - -void TcpSocket::init() -{ - if (!tcp_socket_inited) - { -#ifdef __WIN32__ - WORD wVersionRequested = MAKEWORD( 2, 2 ); - WSADATA wsaData; - WSAStartup( wVersionRequested, &wsaData ); -#endif -#ifdef HAVE_SSL - if (libssl_is_present) - { - sslStream = NULL; - sslContext = NULL; - CRYPTO_set_locking_callback(cryptoLockCallback); - CRYPTO_set_id_callback(cryptoIdCallback); - SSL_library_init(); - SSL_load_error_strings(); - } -#endif - tcp_socket_inited = true; - } - sock = -1; - connected = false; - hostname = ""; - portno = -1; - sslEnabled = false; - receiveTimeout = 0; -} - -TcpSocket::~TcpSocket() -{ - disconnect(); -} - -bool TcpSocket::isConnected() -{ - if (!connected || sock < 0) - return false; - return true; -} - -void TcpSocket::enableSSL(bool val) -{ - sslEnabled = val; -} - - -bool TcpSocket::connect(const DOMString &hostnameArg, int portnoArg) -{ - hostname = hostnameArg; - portno = portnoArg; - return connect(); -} - - - -#ifdef HAVE_SSL -/* -static int password_cb(char *buf, int bufLen, int rwflag, void *userdata) -{ - char *password = "password"; - if (bufLen < (int)(strlen(password)+1)) - return 0; - - strcpy(buf,password); - int ret = strlen(password); - return ret; -} - -static void infoCallback(const SSL *ssl, int where, int ret) -{ - switch (where) - { - case SSL_CB_ALERT: - { - printf("## %d SSL ALERT: %s\n", where, SSL_alert_desc_string_long(ret)); - break; - } - default: - { - printf("## %d SSL: %s\n", where, SSL_state_string_long(ssl)); - break; - } - } -} -*/ -#endif - - -bool TcpSocket::startTls() -{ -#ifdef HAVE_SSL - if (libssl_is_present) - { - sslStream = NULL; - sslContext = NULL; - - //SSL_METHOD *meth = SSLv23_method(); - //SSL_METHOD *meth = SSLv3_client_method(); - SSL_METHOD *meth = TLSv1_client_method(); - sslContext = SSL_CTX_new(meth); - //SSL_CTX_set_info_callback(sslContext, infoCallback); - -#if 0 - char *keyFile = "client.pem"; - char *caList = "root.pem"; - /* Load our keys and certificates*/ - if (!(SSL_CTX_use_certificate_chain_file(sslContext, keyFile))) - { - fprintf(stderr, "Can't read certificate file\n"); - disconnect(); - return false; - } - - SSL_CTX_set_default_passwd_cb(sslContext, password_cb); - - if (!(SSL_CTX_use_PrivateKey_file(sslContext, keyFile, SSL_FILETYPE_PEM))) - { - fprintf(stderr, "Can't read key file\n"); - disconnect(); - return false; - } - - /* Load the CAs we trust*/ - if (!(SSL_CTX_load_verify_locations(sslContext, caList, 0))) - { - fprintf(stderr, "Can't read CA list\n"); - disconnect(); - return false; - } -#endif - - /* Connect the SSL socket */ - sslStream = SSL_new(sslContext); - SSL_set_fd(sslStream, sock); - - if (SSL_connect(sslStream)<=0) - { - fprintf(stderr, "SSL connect error\n"); - disconnect(); - return false; - } - - sslEnabled = true; - } -#endif /*HAVE_SSL*/ - return true; -} - - -bool TcpSocket::connect() -{ - if (hostname.size()<1) - { - printf("open: null hostname\n"); - return false; - } - - if (portno<1) - { - printf("open: bad port number\n"); - return false; - } - - sock = socket(PF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - printf("open: error creating socket\n"); - return false; - } - - char *c_hostname = (char *)hostname.c_str(); - struct hostent *server = gethostbyname(c_hostname); - if (!server) - { - printf("open: could not locate host '%s'\n", c_hostname); - return false; - } - - struct sockaddr_in serv_addr; - mybzero((char *) &serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - mybcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, - server->h_length); - serv_addr.sin_port = htons(portno); - - int ret = ::connect(sock, (const sockaddr *)&serv_addr, sizeof(serv_addr)); - if (ret < 0) - { - printf("open: could not connect to host '%s'\n", c_hostname); - return false; - } - - if (sslEnabled) - { - if (!startTls()) - return false; - } - connected = true; - return true; -} - -bool TcpSocket::disconnect() -{ - bool ret = true; - connected = false; -#ifdef HAVE_SSL - if (libssl_is_present) - { - if (sslEnabled) - { - if (sslStream) - { - int r = SSL_shutdown(sslStream); - switch(r) - { - case 1: - break; /* Success */ - case 0: - case -1: - default: - //printf("Shutdown failed"); - ret = false; - } - SSL_free(sslStream); - } - if (sslContext) - SSL_CTX_free(sslContext); - } - sslStream = NULL; - sslContext = NULL; - } -#endif /*HAVE_SSL*/ - -#ifdef __WIN32__ - closesocket(sock); -#else - ::close(sock); -#endif - sock = -1; - sslEnabled = false; - - return ret; -} - - - -bool TcpSocket::setReceiveTimeout(unsigned long millis) -{ - receiveTimeout = millis; - return true; -} - -/** - * For normal sockets, return the number of bytes waiting to be received. - * For SSL, just return >0 when something is ready to be read. - */ -long TcpSocket::available() -{ - if (!isConnected()) - return -1; - - long count = 0; -#ifdef __WIN32__ - if (ioctlsocket(sock, FIONREAD, (unsigned long *)&count) != 0) - return -1; -#else - if (ioctl(sock, FIONREAD, &count) != 0) - return -1; -#endif - if (count<=0 && sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - return SSL_pending(sslStream); - } -#endif - } - return count; -} - - - -bool TcpSocket::write(int ch) -{ - if (!isConnected()) - { - printf("write: socket closed\n"); - return false; - } - unsigned char c = (unsigned char)ch; - - if (sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - int r = SSL_write(sslStream, &c, 1); - if (r<=0) - { - switch(SSL_get_error(sslStream, r)) - { - default: - printf("SSL write problem"); - return -1; - } - } - } -#endif - } - else - { - if (send(sock, (const char *)&c, 1, 0) < 0) - //if (send(sock, &c, 1, 0) < 0) - { - printf("write: could not send data\n"); - return false; - } - } - return true; -} - -bool TcpSocket::write(const DOMString &strArg) -{ - DOMString str = strArg; - - if (!isConnected()) - { - printf("write(str): socket closed\n"); - return false; - } - int len = str.size(); - - if (sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - int r = SSL_write(sslStream, (unsigned char *)str.c_str(), len); - if (r<=0) - { - switch(SSL_get_error(sslStream, r)) - { - default: - printf("SSL write problem"); - return -1; - } - } - } -#endif - } - else - { - if (send(sock, str.c_str(), len, 0) < 0) - //if (send(sock, &c, 1, 0) < 0) - { - printf("write: could not send data\n"); - return false; - } - } - return true; -} - -int TcpSocket::read() -{ - if (!isConnected()) - return -1; - - //We'll use this loop for timeouts, so that SSL and plain sockets - //will behave the same way - if (receiveTimeout > 0) - { - unsigned long tim = 0; - while (true) - { - int avail = available(); - if (avail > 0) - break; - if (tim >= receiveTimeout) - return -2; - org::w3c::dom::util::Thread::sleep(20); - tim += 20; - } - } - - //check again - if (!isConnected()) - return -1; - - unsigned char ch; - if (sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - if (!sslStream) - return -1; - int r = SSL_read(sslStream, &ch, 1); - unsigned long err = SSL_get_error(sslStream, r); - switch (err) - { - case SSL_ERROR_NONE: - break; - case SSL_ERROR_ZERO_RETURN: - return -1; - case SSL_ERROR_SYSCALL: - printf("SSL read problem(syscall) %s\n", - ERR_error_string(ERR_get_error(), NULL)); - return -1; - default: - printf("SSL read problem %s\n", - ERR_error_string(ERR_get_error(), NULL)); - return -1; - } - } -#endif - } - else - { - int ret = recv(sock, (char *)&ch, 1, 0); - if (ret <= 0) - { - if (ret<0) - printf("read: could not receive data\n"); - disconnect(); - return -1; - } - } - return (int)ch; -} - -bool TcpSocket::readLine(DOMString &result) -{ - result = ""; - - while (isConnected()) - { - int ch = read(); - if (ch<0) - return true; - else if (ch=='\r') //we want canonical Net '\r\n' , so skip this - {} - else if (ch=='\n') - return true; - else - result.push_back((char)ch); - } - - return true; -} - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### - diff --git a/src/dom/io/socket.h b/src/dom/io/socket.h deleted file mode 100644 index 6dd255697..000000000 --- a/src/dom/io/socket.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef __DOM_SOCKET_H__ -#define __DOM_SOCKET_H__ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "dom/dom.h" - -#ifdef HAVE_SSL -#include <openssl/ssl.h> -#endif - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - -class TcpSocket -{ -public: - - TcpSocket(); - - TcpSocket(const DOMString &hostname, int port); - - TcpSocket(const TcpSocket &other); - - virtual ~TcpSocket(); - - bool isConnected(); - - void enableSSL(bool val); - - bool connect(const DOMString &hostname, int portno); - - bool startTls(); - - bool connect(); - - bool disconnect(); - - bool setReceiveTimeout(unsigned long millis); - - long available(); - - bool write(int ch); - - bool write(const DOMString &str); - - int read(); - - bool readLine(DOMString &result); - -private: - - void init(); - - DOMString hostname; - int portno; - int sock; - bool connected; - - bool sslEnabled; - - unsigned long receiveTimeout; - -#ifdef HAVE_SSL - SSL_CTX *sslContext; - SSL *sslStream; -#endif - -}; - - - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - -#endif /* __DOM_SOCKET_H__ */ -//######################################################################### -//# E N D O F F I L E -//######################################################################### - diff --git a/src/dom/io/uristream.cpp b/src/dom/io/uristream.cpp index 3e47d99e1..306f7bdf6 100644 --- a/src/dom/io/uristream.cpp +++ b/src/dom/io/uristream.cpp @@ -91,19 +91,6 @@ void UriInputStream::init() throw (StreamException) dataLen = uri.getPath().size(); break; } - - case URI::SCHEME_HTTP: - case URI::SCHEME_HTTPS: - { - if (!httpClient.openGet(uri)) - { - DOMString err = "UriInputStream cannot open URL "; - err.append(uri.toString()); - throw StreamException(err); - } - break; - } - } closed = false; @@ -159,14 +146,6 @@ void UriInputStream::close() throw(StreamException) //do nothing break; } - - case URI::SCHEME_HTTP: - case URI::SCHEME_HTTPS: - { - httpClient.close(); - break; - } - }//switch closed = true; @@ -211,14 +190,6 @@ int UriInputStream::get() throw(StreamException) } break; } - - case URI::SCHEME_HTTP: - case URI::SCHEME_HTTPS: - { - retVal = httpClient.read(); - break; - } - }//switch return retVal; diff --git a/src/dom/io/uristream.h b/src/dom/io/uristream.h index a2d5a19bb..a885726e4 100644 --- a/src/dom/io/uristream.h +++ b/src/dom/io/uristream.h @@ -39,7 +39,6 @@ #include "../uri.h" #include "domstream.h" -#include "httpclient.h" namespace org @@ -89,9 +88,6 @@ private: URI uri; int scheme; - - HttpClient httpClient; - }; // class UriInputStream @@ -161,9 +157,6 @@ private: URI uri; int scheme; - - HttpClient httpClient; - }; // class UriOutputStream diff --git a/src/dom/odf/SvgOdg.cpp b/src/dom/odf/SvgOdg.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/jabber_whiteboard/CMakeLists.txt b/src/jabber_whiteboard/CMakeLists.txt deleted file mode 100644 index b91bdf141..000000000 --- a/src/jabber_whiteboard/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ - -set(jabber_whiteboard_SRC - defines.cpp - empty.cpp - inkboard-document.cpp - inkboard-node.cpp - invitation-confirm-dialog.cpp - keynode.cpp - message-aggregator.cpp - message-queue.cpp - message-tags.cpp - message-utilities.cpp - #node-tracker.cpp - #node-utilities.cpp - pedrogui.cpp - session-file-selector.cpp - session-manager.cpp - - dialog/choose-desktop.cpp - - - # ------- - # Headers - defines.h - dialog/choose-desktop.h - inkboard-document.h - invitation-confirm-dialog.h - keynode.h - message-aggregator.h - message-node.h - message-queue.h - message-tags.h - message-utilities.h - message-verifier.h - node-tracker.h - node-utilities.h - pedrogui.h - session-file-selector.h - session-manager.h - tracker-node.h -) - -# add_inkscape_lib(jabber_whiteboard_LIB "${jabber_whiteboard_SRC}") -add_inkscape_source("${jabber_whiteboard_SRC}") diff --git a/src/jabber_whiteboard/Makefile_insert b/src/jabber_whiteboard/Makefile_insert deleted file mode 100644 index f1bff8917..000000000 --- a/src/jabber_whiteboard/Makefile_insert +++ /dev/null @@ -1,43 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. -# -# Jabber whiteboard communication and Inkscape listener components -# Author: David Yip <yipdw@rose-hulman.edu> - -if WITH_INKBOARD -temp_whiteboard_files = \ - jabber_whiteboard/defines.cpp \ - jabber_whiteboard/defines.h \ - jabber_whiteboard/empty.cpp \ - jabber_whiteboard/keynode.cpp \ - jabber_whiteboard/keynode.h \ - jabber_whiteboard/message-aggregator.cpp \ - jabber_whiteboard/message-aggregator.h \ - jabber_whiteboard/message-node.h \ - jabber_whiteboard/message-queue.cpp \ - jabber_whiteboard/message-queue.h \ - jabber_whiteboard/message-tags.cpp \ - jabber_whiteboard/message-tags.h \ - jabber_whiteboard/message-utilities.cpp \ - jabber_whiteboard/message-utilities.h \ - jabber_whiteboard/node-utilities.h \ - jabber_whiteboard/node-tracker.h \ - jabber_whiteboard/inkboard-node.cpp \ - jabber_whiteboard/inkboard-document.cpp \ - jabber_whiteboard/inkboard-document.h \ - jabber_whiteboard/invitation-confirm-dialog.cpp \ - jabber_whiteboard/invitation-confirm-dialog.h \ - jabber_whiteboard/session-file-selector.cpp \ - jabber_whiteboard/session-file-selector.h \ - jabber_whiteboard/session-manager.cpp \ - jabber_whiteboard/message-verifier.h \ - jabber_whiteboard/dialog/choose-desktop.cpp \ - jabber_whiteboard/dialog/choose-desktop.h \ - jabber_whiteboard/session-manager.h \ - jabber_whiteboard/tracker-node.h \ - jabber_whiteboard/pedrogui.cpp \ - jabber_whiteboard/pedrogui.h -endif - -ink_common_sources += \ - jabber_whiteboard/empty.cpp \ - $(temp_whiteboard_files) diff --git a/src/jabber_whiteboard/architecture/components.svg b/src/jabber_whiteboard/architecture/components.svg deleted file mode 100644 index ba082ac72..000000000 --- a/src/jabber_whiteboard/architecture/components.svg +++ /dev/null @@ -1,445 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="1052.3622" - height="744.09448" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - version="1.0" - sodipodi:docbase="/Users/trythil/src/inkscape/integrate/src/jabber_whiteboard/architecture" - sodipodi:docname="components.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lstart" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lstart" - style="overflow:visible"> - <path - id="path3050" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" - transform="scale(0.8) translate(12.5,0)" /> - </marker> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path3047" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180) translate(12.5,0)" /> - </marker> - <marker - inkscape:stockid="Arrow1Mend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Mend" - style="overflow:visible;"> - <path - id="path3041" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.4) rotate(180) translate(10,0)" /> - </marker> - <marker - inkscape:stockid="Arrow2Mend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow2Mend" - style="overflow:visible;"> - <path - id="path3023" - style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;" - d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " - transform="scale(0.6) rotate(180) translate(0,0)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - gridtolerance="10000" - guidetolerance="10" - objecttolerance="10" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.80408885" - inkscape:cx="762.06598" - inkscape:cy="376.24506" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showguides="true" - inkscape:guide-bbox="true" - inkscape:window-width="1440" - inkscape:window-height="852" - inkscape:window-x="0" - inkscape:window-y="22" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:groupmode="layer" - id="layer2" - inkscape:label="Categories"> - <rect - style="fill:#8ae234;fill-opacity:1;stroke:none;stroke-width:5.30000019;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:5.3, 5.3;stroke-dashoffset:0;stroke-opacity:1;opacity:1" - id="rect1876" - width="521.04095" - height="653.93756" - x="18.871473" - y="63.558342" /> - <text - xml:space="preserve" - style="font-size:36px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;opacity:1" - x="32.819954" - y="103.2849" - id="text2764"><tspan - sodipodi:role="line" - id="tspan2766" - x="32.819954" - y="103.2849">Inkscape interface</tspan></text> - <rect - style="fill:#8ae234;fill-opacity:1;stroke:none;stroke-width:5.30000019;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:5.3, 5.3;stroke-dashoffset:0;stroke-opacity:1;opacity:1" - id="rect2768" - width="486.23013" - height="653.93756" - x="548.25085" - y="63.558342" /> - <text - xml:space="preserve" - style="font-size:36px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;opacity:1" - x="561.9444" - y="103.2849" - id="text2770"><tspan - sodipodi:role="line" - id="tspan2772" - x="561.9444" - y="103.2849">Protocol implementations</tspan></text> - <text - xml:space="preserve" - style="font-size:14.63451385px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="740.13733" - y="351.92361" - id="text2808"><tspan - sodipodi:role="line" - x="740.13733" - y="351.92361" - id="tspan2812">(implementors of</tspan><tspan - sodipodi:role="line" - x="740.13733" - y="370.21676" - id="tspan2816">Inkscape::Whiteboard::Protocol</tspan><tspan - sodipodi:role="line" - x="740.13733" - y="388.5099" - id="tspan2818">interface)</tspan></text> - <rect - style="fill:#4e9a06;fill-opacity:1;stroke:none;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect2859" - width="203.0631" - height="311.52557" - x="37.131538" - y="138.38626" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" - d="M 804.08885,334.66557 C 778.65338,270.66666 826.24231,239.48771 826.24231,239.48771" - id="path2875" - sodipodi:nodetypes="cc" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 798.08709,396.44892 C 790.5769,463.77082 826.49056,489.95209 826.49056,489.95209" - id="path3061" - sodipodi:nodetypes="cc" /> - <text - xml:space="preserve" - style="font-size:36.00000381px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="-386.52069" - y="137.54932" - id="text3063" - transform="matrix(8.852537e-8,-1,1,8.852537e-8,0,0)"><tspan - sodipodi:role="line" - id="tspan3065" - x="-386.52069" - y="137.54932">...</tspan></text> - <text - xml:space="preserve" - style="font-size:12.96438217px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="46.645901" - y="431.21323" - id="text3067"><tspan - sodipodi:role="line" - id="tspan3069" - x="46.645901" - y="431.21323">SessionManager::_inkboards</tspan></text> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:3,1;stroke-dashoffset:0" - d="M 56.280887,662.31132 C 56.280887,662.31132 123.11444,662.31132 122.23505,660.55254" - id="path3071" - sodipodi:nodetypes="cc" /> - <text - xml:space="preserve" - style="font-size:15.54713535px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="138.23271" - y="666.99792" - id="text3073"><tspan - sodipodi:role="line" - id="tspan3075" - x="138.23271" - y="666.99792">interacts with</tspan></text> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" - d="M 448.71991,337.60104 L 219.0677,309.39847" - id="path3093" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect2774" - inkscape:connection-end="#g2851" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" - d="M 448.71991,321.52852 L 219.0677,261.60893" - id="path3095" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect2774" - inkscape:connection-end="#g2843" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" - d="M 448.71991,305.45604 L 208.6028,209.64377" - id="path3097" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect2774" - inkscape:connection-end="#g2838" /> - </g> - <g - inkscape:groupmode="layer" - id="layer3" - inkscape:label="Protocol Box" /> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - style="opacity:1"> - <text - xml:space="preserve" - style="font-size:36px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="11.486983" - y="40.106487" - id="text1872"><tspan - sodipodi:role="line" - id="tspan1874" - x="11.486983" - y="40.106487">Inkboard component diagram</tspan></text> - <rect - style="fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect2774" - width="229.7514" - height="153.16759" - x="450.21991" - y="275.30884" /> - <text - xml:space="preserve" - style="font-size:36px;font-style:normal;font-weight:normal;fill:#eeeeec;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="474.18985" - y="357.96198" - id="text2776"><tspan - sodipodi:role="line" - id="tspan2778" - x="474.18985" - y="357.96198" - style="font-size:22px;fill:#eeeeec">SessionManager</tspan></text> - <g - id="g2868" - transform="translate(-71.3834,-5.743492)"> - <rect - y="158.11241" - x="766.99829" - height="78.904518" - width="233.23247" - id="rect2780" - style="fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <text - id="text2782" - y="203.5363" - x="782.42352" - style="font-size:24.00545883px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="fill:#eeeeec;fill-opacity:1" - y="203.5363" - x="782.42352" - id="tspan2784" - sodipodi:role="line">InkboardProtocol</tspan></text> - </g> - <g - id="g2861" - transform="translate(-75.4859,245.3292)"> - <rect - y="260.22415" - x="766.99829" - height="78.904518" - width="233.23247" - id="rect2786" - style="fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <text - id="text2788" - y="303.53799" - x="782.00726" - style="font-size:15.96343422px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="fill:#eeeeec;fill-opacity:1" - y="303.53799" - x="782.00726" - id="tspan2790" - sodipodi:role="line">JabberWhiteboardProtocol</tspan></text> - </g> - <g - id="g2838" - transform="matrix(0.675812,0,0,0.675812,19.26293,50.01955)"> - <rect - y="155.79167" - x="60.918945" - height="78.904518" - width="233.23247" - id="rect2820" - style="opacity:1;fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <text - id="text2822" - y="203.07533" - x="76.157761" - style="font-size:21.00682449px;font-style:normal;font-weight:normal;opacity:1;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="fill:#eeeeec;fill-opacity:1" - y="203.07533" - x="76.157761" - id="tspan2824" - sodipodi:role="line">InkboardDocument</tspan></text> - </g> - <g - style="opacity:1" - id="g2843" - transform="matrix(0.675812,0,0,0.675812,19.26293,108.8334)"> - <rect - y="155.79167" - x="60.918945" - height="78.904518" - width="233.23247" - id="rect2845" - style="opacity:1;fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <text - id="text2847" - y="203.07533" - x="76.157761" - style="font-size:21.00682449px;font-style:normal;font-weight:normal;opacity:1;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="fill:#eeeeec;fill-opacity:1" - y="203.07533" - x="76.157761" - id="tspan2849" - sodipodi:role="line">InkboardDocument</tspan></text> - </g> - <g - style="opacity:1" - id="g2851" - transform="matrix(0.675812,0,0,0.675812,19.26293,167.6474)"> - <rect - y="155.79167" - x="60.918945" - height="78.904518" - width="233.23247" - id="rect2853" - style="opacity:1;fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <text - id="text2855" - y="203.07533" - x="76.157761" - style="font-size:21.00682449px;font-style:normal;font-weight:normal;opacity:1;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="fill:#eeeeec;fill-opacity:1" - y="203.07533" - x="76.157761" - id="tspan2857" - sodipodi:role="line">InkboardDocument</tspan></text> - </g> - <path - style="fill:#ce5c00;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:3,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" - d="M 756.59014,504.05335 L 663.3642,429.97643" - id="path2866" - inkscape:connector-type="polyline" - inkscape:connection-start="#g2861" - inkscape:connection-end="#rect2774" /> - <path - style="fill:#ce5c00;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:3,1;stroke-dashoffset:0;marker-end:none;marker-start:url(#Arrow1Lstart)" - d="M 681.47131,276.51525 L 749.00463,232.77344" - id="path2873" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect2774" - inkscape:connection-end="#g2868" /> - <g - style="opacity:1" - id="g3077" - transform="matrix(0.675812,0,0,0.675812,310.9202,48.45803)"> - <rect - y="155.79167" - x="60.918945" - height="78.904518" - width="233.23247" - id="rect3079" - style="opacity:1;fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> - <text - id="text3081" - y="203.07533" - x="95.676254" - style="font-size:21.00682449px;font-style:normal;font-weight:normal;opacity:1;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="fill:#eeeeec;fill-opacity:1" - y="203.07533" - x="95.676254" - id="tspan3083" - sodipodi:role="line">XML::LogBuilder</tspan></text> - </g> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart)" - d="M 206.96678,271.91956 L 363.17716,208.08225" - id="path3087" - inkscape:connector-type="polyline" - inkscape:connection-start="#g2851" - inkscape:connection-end="#g3077" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart)" - d="M 219.0677,224.25731 L 351.07624,196.9305" - id="path3089" - inkscape:connector-type="polyline" - inkscape:connection-start="#g2843" - inkscape:connection-end="#g3077" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart)" - d="M 219.0677,181.54037 L 351.07624,180.8336" - id="path3091" - inkscape:connector-type="polyline" - inkscape:connection-start="#g2838" - inkscape:connection-end="#g3077" /> - </g> -</svg> diff --git a/src/jabber_whiteboard/architecture/inkboard-document.svg b/src/jabber_whiteboard/architecture/inkboard-document.svg deleted file mode 100644 index 04d4a19c4..000000000 --- a/src/jabber_whiteboard/architecture/inkboard-document.svg +++ /dev/null @@ -1,287 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="1052.3622" - height="744.09448" - id="svg3135" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - version="1.0" - sodipodi:docbase="/Users/trythil/src/inkscape/integrate/src/jabber_whiteboard/architecture" - sodipodi:docname="inkboard-document.svg"> - <defs - id="defs3137"> - <marker - inkscape:stockid="Arrow1Lstart" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lstart" - style="overflow:visible"> - <path - id="path3050" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" - transform="scale(0.8) translate(12.5,0)" /> - </marker> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path3047" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180) translate(12.5,0)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - gridtolerance="10000" - guidetolerance="10" - objecttolerance="10" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.80408885" - inkscape:cx="711.56452" - inkscape:cy="387.25978" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showguides="true" - inkscape:guide-bbox="true" - inkscape:window-width="1440" - inkscape:window-height="852" - inkscape:window-x="28" - inkscape:window-y="22" /> - <metadata - id="metadata3140"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:groupmode="layer" - id="layer5" - inkscape:label="text boxes"> - <rect - style="fill:#babdb6;fill-opacity:1;stroke:none;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2, 1;stroke-dashoffset:0;stroke-opacity:1" - id="rect3296" - width="273.60159" - height="39.796597" - x="723.8006" - y="213.05864" /> - <rect - style="fill:#babdb6;fill-opacity:1;stroke:none;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2, 1;stroke-dashoffset:0;stroke-opacity:1" - id="rect3298" - width="273.60159" - height="39.796597" - x="723.8006" - y="259.07346" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" - d="M 723.8006,236.70097 L 289.14766,248.59677" - id="path3302" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect3296" - inkscape:connection-end="#g3232" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:1,1;stroke-dashoffset:0;marker-end:url(#Arrow1Lend)" - d="M 289.14766,256.47863 L 723.8006,273.58711" - id="path3304" - inkscape:connector-type="polyline" - inkscape:connection-start="#g3232" - inkscape:connection-end="#rect3298" /> - </g> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <text - xml:space="preserve" - style="font-size:36px;font-style:normal;font-weight:normal;opacity:1;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="11.486983" - y="40.106487" - id="text1872"><tspan - sodipodi:role="line" - id="tspan1874" - x="11.486983" - y="40.106487">Inkscape::Whiteboard::InkboardDocument</tspan></text> - <g - inkscape:groupmode="layer" - id="layer4" - inkscape:label="background" /> - <g - transform="translate(-712.5831,-48.95766)" - id="g2868" - inkscape:connector-avoid="true"> - <rect - style="fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect2780" - width="233.23247" - height="78.904518" - x="766.99829" - y="158.11241" /> - <text - xml:space="preserve" - style="font-size:24.00545883px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="879.69678" - y="203.5363" - id="text2782"><tspan - sodipodi:role="line" - id="tspan2784" - x="879.69678" - y="203.5363" - style="text-align:center;text-anchor:middle;fill:#eeeeec;fill-opacity:1">Serializer</tspan></text> - </g> - <g - transform="translate(-712.5831,54.26476)" - id="g3232" - inkscape:connector-avoid="true"> - <rect - style="fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect3234" - width="233.23247" - height="78.904518" - x="766.99829" - y="158.11241" /> - <text - xml:space="preserve" - style="font-size:24.00545883px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="879.69678" - y="203.5363" - id="text3236"><tspan - sodipodi:role="line" - id="tspan3238" - x="879.69677" - y="203.5363" - style="text-align:center;text-anchor:middle;fill:#eeeeec;fill-opacity:1">Deserializer</tspan></text> - </g> - <g - transform="translate(-660.35,299.2626)" - id="g3244"> - <rect - style="fill:#3465a4;fill-opacity:1;stroke:black;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="rect3246" - width="233.23247" - height="78.904518" - x="766.99829" - y="158.11241" /> - <text - xml:space="preserve" - style="font-size:24.00545883px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="881.91498" - y="204.18727" - id="text3248"><tspan - sodipodi:role="line" - id="tspan3250" - x="881.91498" - y="204.18727" - style="text-align:center;text-anchor:middle;fill:#eeeeec;fill-opacity:1">KeyNodeTable</tspan></text> - </g> - <text - id="text3262" - y="239.62819" - x="732.66614" - style="font-size:21.86437798px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="239.62819" - x="732.66614" - id="tspan3264" - sodipodi:role="line">(from SessionManager)</tspan></text> - <text - id="text3266" - y="286.88666" - x="732.66614" - style="font-size:21.86437798px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="286.88666" - x="732.66614" - id="tspan3268" - sodipodi:role="line">(to XML::LogBuilder)</tspan></text> - <rect - style="fill:#babdb6;fill-opacity:1;stroke:none;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2, 1;stroke-dashoffset:0;stroke-opacity:1" - id="rect3306" - width="273.60159" - height="39.796597" - x="723.8006" - y="162.06924" /> - <text - id="text3308" - y="189.88245" - x="732.66614" - style="font-size:21.86437798px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="189.88245" - x="732.66614" - id="tspan3310" - sodipodi:role="line">(to SessionManager)</tspan></text> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)" - d="M 289.14766,154.32133 L 723.8006,175.34929" - id="path3312" - inkscape:connector-type="polyline" - inkscape:connection-start="#g2868" - inkscape:connection-end="#rect3306" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart);stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0" - d="M 179.76237,292.78169 L 214.53358,455.87501" - id="path3314" - inkscape:connector-type="polyline" - inkscape:connection-start="#g3232" - inkscape:connection-end="#g3244" /> - <path - style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart);stroke-miterlimit:4;stroke-dasharray:2,1;stroke-dashoffset:0" - d="M 271.40703,189.55927 L 299.14766,200.87717 L 299.14766,302.78169 L 239.27925,455.87501" - id="path3316" - inkscape:connector-type="polyline" - inkscape:connection-start="#g2868" - inkscape:connection-end="#g3244" /> - <rect - style="fill:#babdb6;fill-opacity:1;stroke:none;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:2, 1;stroke-dashoffset:0;stroke-opacity:1" - id="rect3318" - width="273.60159" - height="104.46606" - x="723.8006" - y="393.38696" /> - <text - id="text3320" - y="421.20016" - x="732.66614" - style="font-size:21.86437798px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="421.20016" - x="732.66614" - id="tspan3322" - sodipodi:role="line">(sp_repr_replay_log</tspan><tspan - y="448.53064" - x="732.66614" - sodipodi:role="line" - id="tspan3326">actually commits </tspan><tspan - y="475.86111" - x="732.66614" - sodipodi:role="line" - id="tspan3328">changes)</tspan><tspan - y="503.19158" - x="732.66614" - sodipodi:role="line" - id="tspan3324" /></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/defines.cpp b/src/jabber_whiteboard/defines.cpp deleted file mode 100644 index fc56618bf..000000000 --- a/src/jabber_whiteboard/defines.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Whiteboard session manager - * Definitions - * - * Authors: - * Dale Harvey <harveyd@gmail.com> - * - * Copyright (c) 2006 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __INKSCAPE_WHITEBOARD_DEFINES_CPP__ -#define __INKSCAPE_WHITEBOARD_DEFINES_CPP__ - -#include "jabber_whiteboard/defines.h" - -namespace Inkscape { - -namespace Whiteboard { - -namespace Message { - - Wrapper PROTOCOL ("protocol"); - Wrapper NEW ("new"); - Wrapper REMOVE ("remove"); - Wrapper CONFIGURE ("configure"); - Wrapper MOVE ("move"); - - Message CONNECT_REQUEST ("connect-request"); - Message CONNECTED ("connected"); - Message ACCEPT_INVITATION ("accept-invitation"); - Message DECLINE_INVITATION ("decline-invitation"); - Message DOCUMENT_BEGIN ("document-begin"); - Message DOCUMENT_END ("document-end"); -} - -namespace Vars { - - const std::string DOCUMENT_ROOT_NODE("ROOT"); - const std::string INKBOARD_XMLNS("http://inkscape.org/inkboard"); - - const std::string WHITEBOARD_MESSAGE( - "<message type='%1' from='%2' to='%3'>" - "<wb xmlns='%4' session='%5'>%6</wb>" - "</message>"); - - const std::string PROTOCOL_MESSAGE( - "<%1><%2 /></%1>"); - - const std::string NEW_MESSAGE( - "<new parent=\"%1\" id=\"%2\" index=\"%3\" version=\"%4\">%5</new>"); - - const std::string CONFIGURE_MESSAGE( - "<configure target=\"%1\" version=\"%2\" attribute=\"%3\" value=\"%4\" />"); - - const std::string CONFIGURE_TEXT_MESSAGE( - "<configure target=\"%1\" version=\"%2\"><text>%3</text></configure>"); - - const std::string MOVE_MESSAGE( - "<move target=\"%1\" n=\"%2\" />"); - - const std::string REMOVE_MESSAGE( - "<remove target=\"%1\" />"); -} - -namespace State { - - SessionType WHITEBOARD_MUC ("groupchat"); - SessionType WHITEBOARD_PEER ("chat"); - -} - -// Protocol versions -char const* MESSAGE_PROTOCOL_V1 = "1"; -char const* MESSAGE_PROTOCOL_V2 = "2"; -int const HIGHEST_SUPPORTED = 1; - -// Node types (as strings) -char const* NODETYPE_DOCUMENT_STR = "document"; -char const* NODETYPE_ELEMENT_STR = "element"; -char const* NODETYPE_TEXT_STR = "text"; -char const* NODETYPE_COMMENT_STR = "comment"; - -// Number of chars to allocate for type field (in SessionManager::sendMessage) -int const TYPE_FIELD_SIZE = 5; - -// Number of chars to allocate for sequence number field (in SessionManager::sendMessage) -int const SEQNUM_FIELD_SIZE = 70; - -// Designators for certain "special" nodes in the document -// These nodes are "special" because they are generally present in all documents, -// and we generally only want one copy of them -char const* DOCUMENT_ROOT_NODE = "ROOT"; -char const* DOCUMENT_NAMEDVIEW_NODE = "NAMEDVIEW"; - -// Names of these special nodes -char const* DOCUMENT_ROOT_NAME = "svg:svg"; -char const* DOCUMENT_NAMEDVIEW_NAME = "sodipodi:namedview"; - - -} -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/defines.h b/src/jabber_whiteboard/defines.h deleted file mode 100644 index 975ea18ca..000000000 --- a/src/jabber_whiteboard/defines.h +++ /dev/null @@ -1,262 +0,0 @@ -/** - * Whiteboard session manager - * Definitions - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __INKSCAPE_WHITEBOARD_DEFINES_H__ -#define __INKSCAPE_WHITEBOARD_DEFINES_H__ - -#include "xml/node.h" -#include "jabber_whiteboard/message-tags.h" - -#include <algorithm> -#include <cstring> -#include <string> -#include <map> -#include <set> -#include <bitset> -#include <vector> - -#include <glibmm.h> -#include <sigc++/sigc++.h> - -#include "gc-alloc.h" - -// Various specializations of std::less for XMLNodeTracker maps. -namespace std { -using Inkscape::XML::Node; - -/** - * Specialization of std::less<> for pointers to XML::Nodes.a - * - * \see Inkscape::XML::Node - */ -template<> -struct less< Node* > : public binary_function < Node*, Node*, bool > -{ - bool operator()(Node* _x, Node* _y) const - { - return _x < _y; - } - -}; - -} - -namespace Inkscape { - -namespace XML { - class Node; -} - -namespace Util { - template< typename T > class ListContainer; -} - -namespace Whiteboard { - -#define NUM_FLAGS 9 - -namespace Message { - - typedef const std::string Wrapper; - typedef std::string Message; - - extern Wrapper PROTOCOL; - extern Wrapper NEW; - extern Wrapper REMOVE; - extern Wrapper CONFIGURE; - extern Wrapper MOVE; - - extern Message CONNECT_REQUEST; - extern Message CONNECTED; - extern Message ACCEPT_INVITATION; - extern Message DECLINE_INVITATION; - extern Message DOCUMENT_BEGIN; - extern Message DOCUMENT_END; - -} - -namespace Vars { - - extern const std::string DOCUMENT_ROOT_NODE; - - extern const std::string INKBOARD_XMLNS; - - extern const std::string WHITEBOARD_MESSAGE; - extern const std::string PROTOCOL_MESSAGE; - extern const std::string NEW_MESSAGE; - extern const std::string CONFIGURE_MESSAGE; - extern const std::string CONFIGURE_TEXT_MESSAGE; - extern const std::string MOVE_MESSAGE; - extern const std::string REMOVE_MESSAGE; - -} - -namespace State { - - typedef const std::string SessionType; - - extern SessionType WHITEBOARD_MUC; - extern SessionType WHITEBOARD_PEER; - - enum SessionState { - - INITIAL = 0, - AWAITING_INVITATION_REPLY = 1, - CONNECTING = 2, - INVITATION_RECIEVED = 3, - AWAITING_CONNECTED = 4, - CONNECTED = 5, - AWAITING_DOCUMENT_BEGIN = 6, - SYNCHRONISING = 7, - IN_WHITEBOARD = 8 - - }; -} - -namespace Dialog { - - enum DialogReply { - - ACCEPT_INVITATION = 0, - DECLINE_INVITATION = 1 - }; - -} - -class KeyNodePair; -class KeyNodeTable; - -typedef std::pair<Glib::ustring, Glib::ustring> Configure; - -// Message handler modes -enum HandlerMode { - DEFAULT, - PRESENCE, - ERROR -}; - -// Actions to pass to the node tracker when we modify a node in -// the document tree upon event serialization -enum NodeTrackerAction { - NODE_ADD, - NODE_REMOVE, - NODE_UNKNOWN -}; - -// I am assuming that std::string (which will not properly represent Unicode data) will -// suffice for associating (integer, Jabber ID) identifiers with nodes. -// We do not need to preserve all semantics handled by Unicode; we just need to have -// the byte representation. std::string is good enough for that. -// -// The reason for this is that comparisons with std::string are much faster than -// comparisons with Glib::ustring (simply because the latter is using significantly -// more complex text-handling algorithms), and we need speed here. We _could_ use -// Glib::ustring::collate_key() here and therefore get the best of both worlds, -// but collation keys are rather big. -// -// XML node tracker maps - -/// Associates node keys to pointers to XML::Nodes. -/// \see Inkscape::Whiteboard::XMLNodeTracker -typedef std::map< std::string, XML::Node*, std::less< std::string >, GC::Alloc< std::pair< std::string, XML::Node* >, GC::MANUAL > > KeyToTrackerNodeMap; - -/// Associates pointers to XML::Nodes with node keys. -/// \see Inkscape::Whiteboard::XMLNodeTracker -typedef std::map< XML::Node*, std::string, std::less< XML::Node* >, GC::Alloc< std::pair< XML::Node*, std::string >, GC::MANUAL > > TrackerNodeToKeyMap; - - -// TODO: Clean up these typedefs. I'm sure quite a few of these aren't used anymore; additionally, -// it's probably possible to consolidate a few of these types into one. - -// Temporary storage of new object messages and new nodes in said messages -typedef std::list< Glib::ustring > NewChildObjectMessageList; - -typedef std::pair< KeyNodePair, NodeTrackerAction > SerializedEventNodeAction; - -typedef std::list< SerializedEventNodeAction > KeyToNodeActionList; - -//typedef std::map< std::string, SerializedEventNodeAction > KeyToNodeActionMap; - -typedef std::set< std::string > AttributesScannedSet; -typedef std::set< XML::Node* > AttributesUpdatedSet; - -typedef std::map< std::string, XML::Node const* > KeyToNodeMap; -typedef std::map< XML::Node const*, std::string > NodeToKeyMap; - - -// Message context verification and processing -struct MessageProcessor; -class ReceiveMessageQueue; - -typedef std::map< std::string, ReceiveMessageQueue*, std::less< std::string >, GC::Alloc< std::pair< std::string, ReceiveMessageQueue* >, GC::MANUAL > > RecipientToReceiveQueueMap; -typedef std::map< std::string, unsigned int > ReceipientToLatestTransactionMap; - -typedef std::string ReceivedCommitEvent; -typedef std::list< ReceivedCommitEvent > CommitsQueue; - -// Message serialization -typedef std::list< Glib::ustring > SerializedEventList; - - - //typedef std::pair< Glib::ustring, InvitationResponses > Invitation_response_type; - //typedef std::list< Invitation_response_type > Invitation_responses_type; -// Error handling -- someday -// TODO: finish and integrate this -//typedef boost::function< LmHandlerResult (unsigned int code) > ErrorHandlerFunctor; -//typedef std::map< unsigned int, ErrorHandlerFunctor > ErrorHandlerFunctorMap; - -// TODO: breaking these up into namespaces would be nice, but it's too much typing -// for now - -// Protocol versions -extern char const* MESSAGE_PROTOCOL_V1; -extern int const HIGHEST_SUPPORTED; - -// Node types (as strings) -extern char const* NODETYPE_DOCUMENT_STR; -extern char const* NODETYPE_ELEMENT_STR; -extern char const* NODETYPE_TEXT_STR; -extern char const* NODETYPE_COMMENT_STR; - -// Number of chars to allocate for type field (in SessionManager::sendMessage) -extern int const TYPE_FIELD_SIZE; - -// Number of chars to allocate for sequence number field (in SessionManager::sendMessage) -extern int const SEQNUM_FIELD_SIZE; - -// Designators for certain "special" nodes in the document -// These nodes are "special" because they are generally present in all documents -extern char const* DOCUMENT_ROOT_NODE; -extern char const* DOCUMENT_NAMEDVIEW_NODE; - -// Names of these special nodes -extern char const* DOCUMENT_ROOT_NAME; -extern char const* DOCUMENT_NAMEDVIEW_NAME; - -} - -} - - - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/dialog/choose-desktop.cpp b/src/jabber_whiteboard/dialog/choose-desktop.cpp deleted file mode 100644 index bdcabd17f..000000000 --- a/src/jabber_whiteboard/dialog/choose-desktop.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/** - * \brief Choose Desktop dialog - * - * Authors: - * Dale Harvey <harveyd@gmail.com> - * - * Copyright (C) 2006 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#include "choose-desktop.h" - -#include "document.h" -#include "desktop-handles.h" -#include "inkscape.h" - -namespace Inkscape { -namespace Whiteboard { - -void ChooseDesktop::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void ChooseDesktop::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void ChooseDesktop::doubleClickCallback( - const Gtk::TreeModel::Path & /*path*/, - Gtk::TreeViewColumn * /*col*/) -{ - response(Gtk::RESPONSE_OK); - hide(); -} - - -SPDesktop* ChooseDesktop::getDesktop() -{ - Glib::RefPtr<Gtk::TreeModel> model = desktopView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = desktopView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - return iter->get_value(desktopColumns.desktopColumn); -} - - -bool ChooseDesktop::doSetup() -{ - set_title("Choose Desktop"); - set_size_request(300,400); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - desktopView.signal_row_activated().connect( - sigc::mem_fun(*this, &ChooseDesktop::doubleClickCallback) ); - - std::list< SPDesktop* > desktops; - inkscape_get_all_desktops(desktops); - - desktopListStore = Gtk::ListStore::create(desktopColumns); - desktopView.set_model(desktopListStore); - - std::list< SPDesktop* >::iterator p = desktops.begin(); - while(p != desktops.end()) - { - SPDesktop *desktop = (SPDesktop *)*p; - - Gtk::TreeModel::Row row = *(desktopListStore->append()); - row[desktopColumns.nameColumn] = desktop->doc()->getName(); - row[desktopColumns.desktopColumn] = (SPDesktop *)*p; - p++; - } - - Gtk::TreeModel::Row row = *(desktopListStore->append()); - row[desktopColumns.nameColumn] = "Blank Document"; - row[desktopColumns.desktopColumn] = NULL; - - desktopView.append_column("Desktop", desktopColumns.nameColumn); - - desktopScroll.add(desktopView); - desktopScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - get_vbox()->pack_start(desktopScroll); - - show_all_children(); - - return true; -} - -} -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/dialog/choose-desktop.h b/src/jabber_whiteboard/dialog/choose-desktop.h deleted file mode 100644 index 8b26a5545..000000000 --- a/src/jabber_whiteboard/dialog/choose-desktop.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * \brief Choose Desktop dialog - * - * Authors: - * Dale Harvey <harveyd@gmail.com> - * - * Copyright (C) 2006 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#include <gtkmm.h> - -#include "desktop.h" - -namespace Inkscape { -namespace Whiteboard { - -class ChooseDesktop : public Gtk::Dialog -{ -public: - - ChooseDesktop() - { doSetup(); } - - virtual ~ChooseDesktop() - {} - - SPDesktop* getDesktop(); - -private: - - void okCallback(); - void cancelCallback(); - - void doubleClickCallback( - const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - - bool doSetup(); - - class DesktopColumns : public Gtk::TreeModel::ColumnRecord - { - public: - DesktopColumns() - { - add(nameColumn); - add(desktopColumn); - } - - Gtk::TreeModelColumn<Glib::ustring> nameColumn; - Gtk::TreeModelColumn<SPDesktop*> desktopColumn; - }; - - DesktopColumns desktopColumns; - - Gtk::ScrolledWindow desktopScroll; - Gtk::TreeView desktopView; - - Glib::RefPtr<Gtk::ListStore> desktopListStore; - -}; - -} -} - diff --git a/src/jabber_whiteboard/empty.cpp b/src/jabber_whiteboard/empty.cpp deleted file mode 100644 index 2f20405d6..000000000 --- a/src/jabber_whiteboard/empty.cpp +++ /dev/null @@ -1 +0,0 @@ -// empty file to generate a null object file; needed by some archiver tools diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp deleted file mode 100644 index 4b27d530a..000000000 --- a/src/jabber_whiteboard/inkboard-document.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/** - * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glib.h> -#include <glibmm.h> - -#include "jabber_whiteboard/inkboard-document.h" - -#include "util/ucompose.hpp" - -#include "jabber_whiteboard/message-utilities.h" -#include "jabber_whiteboard/defines.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/node-tracker.h" - -#include <glibmm.h> -#include <glib/gmessages.h> -#include <glib/gquark.h> - -#include "jabber_whiteboard/inkboard-document.h" -#include "jabber_whiteboard/defines.h" - -#include "xml/node.h" -#include "xml/event.h" -#include "xml/element-node.h" -#include "xml/text-node.h" -#include "xml/comment-node.h" -#include "xml/pi-node.h" - -#include "util/share.h" -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace Whiteboard { - -InkboardDocument::InkboardDocument(int code, State::SessionType sessionType, - Glib::ustring const& to) -: XML::SimpleNode(code, this), sessionType(sessionType), recipient(to), - _in_transaction(false) -{ - _initBindings(); -} - -void -InkboardDocument::_initBindings() -{ - this->sm = &SessionManager::instance(); - this->state = State::INITIAL; - this->tracker = new KeyNodeTable(); -} - -void -InkboardDocument::setRecipient(Glib::ustring const& val) -{ - this->recipient = val; -} - -Glib::ustring -InkboardDocument::getRecipient() const -{ - return this->recipient; -} - -void -InkboardDocument::setSessionId(Glib::ustring const& val) -{ - this->sessionId = val; -} - -Glib::ustring -InkboardDocument::getSessionId() const -{ - return this->sessionId; -} - -void -InkboardDocument::startSessionNegotiation() -{ - if(this->sessionType == State::WHITEBOARD_PEER) - this->send(recipient, Message::PROTOCOL,Message::CONNECT_REQUEST); - - else if(this->sessionType == State::WHITEBOARD_MUC) - { - // Check that the MUC room is whiteboard enabled, if not no need to send - // anything, just set the room to be whiteboard enabled - } -} - -void -InkboardDocument::terminateSession() -{ - -} - -void -InkboardDocument::recieve(Message::Wrapper &wrapper, Pedro::Element* data) -{ - if(this->handleIncomingState(wrapper,data)) - { - if(wrapper == Message::PROTOCOL) - { - Glib::ustring message = data->getFirstChild()->getFirstChild()->getFirstChild()->getName(); - - if(message == Message::CONNECT_REQUEST) - { - // An MUC member requesting document - - }else if(message == Message::ACCEPT_INVITATION) - { - // TODO : Would be nice to create the desktop here - - this->send(getRecipient(),Message::PROTOCOL, Message::CONNECTED); - this->send(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_BEGIN); - - // Send Document - this->sendDocument(this->root()); - - this->send(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_END); - - }else if(message == Message::DECLINE_INVITATION) - { - this->sm->terminateSession(this->getSessionId()); - } - }else if(wrapper == Message::NEW || wrapper == Message::CONFIGURE - || wrapper == Message::MOVE || wrapper == Message::REMOVE ) - { - handleChange(wrapper,data->getFirstChild()->getFirstChild()); - } - }else{ - g_warning("Recieved Message in invalid state = %d", this->state); - data->print(); - } -} - -bool -InkboardDocument::send(const Glib::ustring &destJid, Message::Wrapper &wrapper, Message::Message &message) -{ - if(this->handleOutgoingState(wrapper,message)) - { - Glib::ustring mes; - if(wrapper == Message::PROTOCOL) - mes = String::ucompose(Vars::PROTOCOL_MESSAGE,wrapper,message); - else - mes = message; - - char *finalmessage = const_cast<char* >(String::ucompose( - Vars::WHITEBOARD_MESSAGE, this->sessionType, this->sm->getClient().getJid(), - destJid, Vars::INKBOARD_XMLNS, this->getSessionId(), mes).c_str()); - - if (!this->sm->getClient().write("%s",finalmessage)) - { return false; } - else - { return true; } - - }else - { - g_warning("Sending Message in invalid state message=%s , state=%d",message.c_str(),this->state); - return false; - } -} - -void -InkboardDocument::sendDocument(Inkscape::XML::Node* root) -{ - for(Inkscape::XML::Node *child = root->firstChild();child!=NULL;child=child->next()) - { - Glib::ustring name(child->name()); - - if(name != "svg:metadata" && name != "svg:defs" && name != "sodipodi:namedview") - { - Glib::ustring parentKey,tempParentKey,key; - - this->addNodeToTracker(child); - Message::Message message = this->composeNewMessage(child); - - this->send(this->getRecipient(),Message::NEW,message); - - if(child->childCount() != 0) - { - sendDocument(child); - } - } - } -} - -bool -InkboardDocument::handleOutgoingState(Message::Wrapper &wrapper, Glib::ustring const& message) -{ - if(wrapper == Message::PROTOCOL) - { - if(message == Message::CONNECT_REQUEST) - return this->handleState(State::INITIAL,State::AWAITING_INVITATION_REPLY); - - else if(message == Message::ACCEPT_INVITATION) - return this->handleState(State::CONNECTING,State::AWAITING_CONNECTED); - - else if(message == Message::CONNECTED) - return this->handleState(State::INVITATION_RECIEVED,State::CONNECTED); - - else if(message == Message::DOCUMENT_BEGIN) - return this->handleState(State::CONNECTED,State::SYNCHRONISING); - - else if(message == Message::DOCUMENT_END) { - return this->handleState(State::SYNCHRONISING,State::IN_WHITEBOARD); - } - - else - return false; - - } else - if(this->state == State::SYNCHRONISING && wrapper == Message::NEW) - return true; - - return this->state == State::IN_WHITEBOARD; -} - -bool -InkboardDocument::handleIncomingState(Message::Wrapper &wrapper, Pedro::Element* data) -{ - if(wrapper == Message::PROTOCOL) - { - Glib::ustring message = data->getFirstChild()->getFirstChild()->getFirstChild()->getName(); - - if(message == Message::CONNECT_REQUEST) - return this->handleState(State::INITIAL,State::CONNECTING); - if(message == Message::ACCEPT_INVITATION) - return this->handleState(State::AWAITING_INVITATION_REPLY,State::INVITATION_RECIEVED); - - else if(message == Message::CONNECTED) - return this->handleState(State::AWAITING_CONNECTED,State::AWAITING_DOCUMENT_BEGIN); - - else if(message == Message::DOCUMENT_BEGIN) - return this->handleState(State::AWAITING_DOCUMENT_BEGIN,State::SYNCHRONISING); - - else if(message == Message::DOCUMENT_END) - return this->handleState(State::SYNCHRONISING,State::IN_WHITEBOARD); - - else - return false; - - } else - if(this->state == State::SYNCHRONISING && wrapper == Message::NEW) - return true; - - return this->state == State::IN_WHITEBOARD; -} - -bool -InkboardDocument::handleState(State::SessionState expectedState, State::SessionState newState) -{ - if(this->state == expectedState) - { - this->state = newState; - return true; - } - - return false; -} - - -void -InkboardDocument::handleChange(Message::Wrapper &wrapper, Pedro::Element* data) -{ - if(wrapper == Message::NEW) - { - Glib::ustring parent = data->getTagAttribute("new","parent"); - Glib::ustring id = data->getTagAttribute("new","id"); - - signed int index = atoi - (data->getTagAttribute("new","index").c_str()); - - Pedro::Element* element = data->getFirstChild(); - - if(parent.size() > 0 && id.size() > 0) - this->changeNew(parent,id,index,element); - - }else if(wrapper == Message::CONFIGURE) - { - if(data->exists("text")) - { - Glib::ustring text = data->getFirstChild()->getValue(); - Glib::ustring target = data->getTagAttribute("configure","target"); - - unsigned int version = atoi - (data->getTagAttribute("configure","version").c_str()); - - if(text.size() > 0 && target.size() > 0) - this->changeConfigureText(target,version,text); - - }else - { - Glib::ustring target = data->getTagAttribute("configure","target"); - Glib::ustring attribute = data->getTagAttribute("configure","attribute"); - Glib::ustring value = data->getTagAttribute("configure","value"); - - unsigned int version = atoi - (data->getTagAttribute("configure","version").c_str()); - - if(target.size() > 0 && attribute.size() > 0 && value.size() > 0) - this->changeConfigure(target,version,attribute,value); - } - }else if(wrapper == Message::MOVE) - { - }else if(wrapper == Message::REMOVE) - { - } -} - -void -InkboardDocument::beginTransaction() -{ - g_assert(!_in_transaction); - _in_transaction = true; -} - -void -InkboardDocument::rollback() -{ - g_assert(_in_transaction); - _in_transaction = false; -} - -void -InkboardDocument::commit() -{ - g_assert(_in_transaction); - _in_transaction = false; -} - -XML::Event* -InkboardDocument::commitUndoable() -{ - g_assert(_in_transaction); - _in_transaction = false; - return NULL; -} - -XML::Node* -InkboardDocument::createElement(char const* name) -{ - return new XML::ElementNode(g_quark_from_string(name), this); -} - -XML::Node* -InkboardDocument::createTextNode(char const* content) -{ - return new XML::TextNode(Util::share_string(content), this); -} - -XML::Node* -InkboardDocument::createComment(char const* content) -{ - return new XML::CommentNode(Util::share_string(content), this); -} - -XML::Node* -InkboardDocument::createPI(char const *target, char const* content) -{ - return new XML::PINode(g_quark_from_string(target), Util::share_string(content), this); -} - - - -void InkboardDocument::notifyChildAdded(XML::Node &/*parent*/, - XML::Node &child, - XML::Node */*prev*/) -{ - if (_in_transaction && state == State::IN_WHITEBOARD) { - - XML::Node *node = (XML::Node *)&child; - - if(tracker->get(node) == "") - { - addNodeToTracker(node); - Message::Message message = composeNewMessage(node); - - send(getRecipient(),Message::NEW,message); - } - } -} - -void InkboardDocument::notifyChildRemoved(XML::Node &/*parent*/, - XML::Node &child, - XML::Node */*prev*/) -{ - if (_in_transaction && state == State::IN_WHITEBOARD) - { - XML::Node *element = (XML::Node *)&child; - - Message::Message message = String::ucompose(Vars::REMOVE_MESSAGE, - tracker->get(element)); - - send(getRecipient(),Message::REMOVE,message); - } -} - -void InkboardDocument::notifyChildOrderChanged(XML::Node &parent, - XML::Node &child, - XML::Node */*old_prev*/, - XML::Node */*new_prev*/) -{ - if (_in_transaction && state == State::IN_WHITEBOARD) - { - unsigned int index = child.position(); - - Message::Message message = String::ucompose(Vars::MOVE_MESSAGE, - tracker->get(&child),index); - - send(getRecipient(),Message::MOVE,message); - } -} - -void InkboardDocument::notifyContentChanged(XML::Node &node, - Util::ptr_shared<char> /*old_content*/, - Util::ptr_shared<char> new_content) -{ - if (_in_transaction && state == State::IN_WHITEBOARD) - { - XML::Node *element = (XML::Node *)&node; - - Glib::ustring value(new_content.pointer()); - - Glib::ustring change = tracker->getLastHistory(element,"text"); - - if(change.size() > 0 && change == value) - return; - - if(new_content.pointer()) - { - unsigned int version = tracker->incrementVersion(element); - - Message::Message message = String::ucompose(Vars::CONFIGURE_TEXT_MESSAGE, - tracker->get(element),version,new_content.pointer()); - - send(getRecipient(),Message::CONFIGURE,message); - } - } -} - -void InkboardDocument::notifyAttributeChanged(XML::Node &node, - GQuark name, - Util::ptr_shared<char> /*old_value*/, - Util::ptr_shared<char> new_value) -{ - if (_in_transaction && state == State::IN_WHITEBOARD) - { - XML::Node *element = (XML::Node *)&node; - - Glib::ustring value(new_value.pointer()); - Glib::ustring attribute(g_quark_to_string(name)); - - Glib::ustring change = tracker->getLastHistory(element,attribute); - - if(change.size() > 0 && change == value) - return; - - if(attribute.size() > 0 && value.size() > 0) - { - unsigned int version = tracker->incrementVersion(element); - - Message::Message message = String::ucompose(Vars::CONFIGURE_MESSAGE, - tracker->get(element),version,attribute.c_str(),value.c_str()); - - send(getRecipient(),Message::CONFIGURE,message); - } - } -} - -} - -} diff --git a/src/jabber_whiteboard/inkboard-document.h b/src/jabber_whiteboard/inkboard-document.h deleted file mode 100644 index 69d92a751..000000000 --- a/src/jabber_whiteboard/inkboard-document.h +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __INKSCAPE_WHITEBOARD_INKBOARDDOCUMENT_H__ -#define __INKSCAPE_WHITEBOARD_INKBOARDDOCUMENT_H__ - -#include <glibmm.h> - -#include "document.h" -#include "xml/document.h" -#include "xml/node.h" -#include "xml/simple-node.h" -#include "xml/node-observer.h" -#include "jabber_whiteboard/defines.h" -#include "jabber_whiteboard/keynode.h" -#include "jabber_whiteboard/session-manager.h" - -namespace Inkscape { - -namespace Whiteboard { - -class InkboardDocument : public XML::SimpleNode, - public XML::Document, - public XML::NodeObserver -{ -public: - - explicit InkboardDocument(int code, State::SessionType sessionType, Glib::ustring const& to); - - XML::NodeType type() const - { - return Inkscape::XML::DOCUMENT_NODE; - } - - State::SessionState state; - KeyNodeTable *tracker; - - void setRecipient(Glib::ustring const& val); - Glib::ustring getRecipient() const; - - void setSessionId(Glib::ustring const& val); - Glib::ustring getSessionId() const; - - void startSessionNegotiation(); - void terminateSession(); - - void recieve(Message::Wrapper &wrapper, Pedro::Element* data); - bool send(const Glib::ustring &destJid, Message::Wrapper &mwrapper, - Message::Message &message); - - void sendDocument(Inkscape::XML::Node* root); - - bool handleOutgoingState(Message::Wrapper &wrapper,Glib::ustring const& message); - bool handleIncomingState(Message::Wrapper &wrapper,Pedro::Element* data); - - bool handleState(State::SessionState expectedState, - State::SessionState newstate); - - void handleChange(Message::Wrapper &wrapper, Pedro::Element* data); - - // - // XML::Session methods - // - bool inTransaction() - { - return _in_transaction; - } - - void beginTransaction(); - void rollback(); - void commit(); - - XML::Event* commitUndoable(); - - XML::Node* createElement(char const* name); - XML::Node* createTextNode(char const* content); - XML::Node* createComment(char const* content); - XML::Node* createPI(char const *target, char const* content); - - // - // XML::NodeObserver methods - // - void notifyChildAdded(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, Inkscape::XML::Node *prev); - - void notifyChildRemoved(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, Inkscape::XML::Node *prev); - - void notifyChildOrderChanged(Inkscape::XML::Node &parent, Inkscape::XML::Node &child, - Inkscape::XML::Node *old_prev, Inkscape::XML::Node *new_prev); - - void notifyContentChanged(Inkscape::XML::Node &node, - Util::ptr_shared<char> old_content, - Util::ptr_shared<char> new_content); - - void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark name, - Util::ptr_shared<char> old_value, - Util::ptr_shared<char> new_value); - - /* Functions below are defined in inkboard-node.cpp */ - Glib::ustring addNodeToTracker(Inkscape::XML::Node* node); - Message::Message composeNewMessage(Inkscape::XML::Node *node); - - void changeConfigure(Glib::ustring target, unsigned int version, - Glib::ustring attribute, Glib::ustring value); - - void changeNew(Glib::ustring target, Glib::ustring, - signed int index, Pedro::Element* data); - - void changeConfigureText(Glib::ustring target, unsigned int version, - Glib::ustring text); - -protected: - /** - * Copy constructor. - * - * \param orig Instance to copy. - */ - InkboardDocument(InkboardDocument const& orig) : - XML::Node(), XML::SimpleNode(orig), - XML::Document(), XML::NodeObserver(), - recipient(orig.recipient), _in_transaction(false) - { - _initBindings(); - } - - XML::SimpleNode* _duplicate(XML::Document* /*xml_doc*/) const - { - return new InkboardDocument(*this); - } - NodeObserver *logger() { return this; } - -private: - void _initBindings(); - - SessionManager *sm; - - State::SessionType sessionType; - - Glib::ustring sessionId; - Glib::ustring recipient; - - bool _in_transaction; -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/inkboard-node.cpp b/src/jabber_whiteboard/inkboard-node.cpp deleted file mode 100644 index f64d0f212..000000000 --- a/src/jabber_whiteboard/inkboard-node.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation - * - * Authors: - * Dale Harvey <harveyd@gmail.com> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glib.h> -#include <glibmm.h> - -#include "util/ucompose.hpp" - -#include "pedro/pedrodom.h" - -#include "xml/node.h" -#include "xml/attribute-record.h" -#include "xml/element-node.h" -#include "xml/text-node.h" - -#include "jabber_whiteboard/message-utilities.h" -#include "jabber_whiteboard/defines.h" -#include "jabber_whiteboard/inkboard-document.h" - - -namespace Inkscape { - -namespace Whiteboard { - -Glib::ustring -InkboardDocument::addNodeToTracker(Inkscape::XML::Node *node) -{ - Glib::ustring rec = this->getRecipient(); - Glib::ustring key = this->tracker->generateKey(rec); - this->tracker->put(key,node); - return key; -} - -Message::Message -InkboardDocument::composeNewMessage(Inkscape::XML::Node *node) -{ - Glib::ustring parentKey; - Glib::ustring key = this->tracker->get(node); - - Glib::ustring tempParentKey = this->tracker->get(node->parent()); - if(tempParentKey.size() < 1) - parentKey = Vars::DOCUMENT_ROOT_NODE; - else - parentKey = tempParentKey; - - unsigned int index = node->position(); - - Message::Message nodeMessage = MessageUtilities::objectToString(node); - Message::Message message = String::ucompose(Vars::NEW_MESSAGE,parentKey,key,index,0,nodeMessage); - - return message; -} - -void -InkboardDocument::changeConfigureText(Glib::ustring target, - unsigned int /*version*/, - Glib::ustring text) -{ - XML::Node *node = this->tracker->get(target); - //unsigned int elementVersion = this->tracker->getVersion(node); - - if(node)// && version == (elementVersion + 1)) - { - this->tracker->incrementVersion(node); - this->tracker->addHistory(node, "text", text); - node->setContent(text.c_str()); - } -} - -void -InkboardDocument::changeConfigure(Glib::ustring target, - unsigned int /*version*/, - Glib::ustring attribute, - Glib::ustring value) -{ - XML::Node *node = this->tracker->get(target); - //unsigned int elementVersion = this->tracker->getVersion(node); - - if(node)// && version == (elementVersion + 1)) - { - this->tracker->incrementVersion(node); - this->tracker->addHistory(node, attribute, value.c_str()); - - if(attribute != "transform") - node->setAttribute(attribute.c_str(),value.c_str()); - } -} - -void -InkboardDocument::changeNew(Glib::ustring parentid, Glib::ustring id, - signed int /*index*/, Pedro::Element* data) -{ - - Glib::ustring name(data->getName()); - - if(name == "text") - { - XML::Node *parent = this->tracker->get(parentid); - XML::Node *node = new XML::TextNode(Util::share_string(data->getValue().c_str()), this); - - if(parent && node) - { - this->tracker->put(id,node); - parent->appendChild(node); - } - }else - { - XML::Node *node = new XML::ElementNode(g_quark_from_string(name.c_str()), this); - this->tracker->put(id,node); - - XML::Node *parent = (parentid != "ROOT") - ? this->tracker->get(parentid.c_str()) : this->root(); - - std::vector<Pedro::Attribute> attributes = data->getAttributes(); - - for (unsigned int i=0; i<attributes.size(); i++) - { - node->setAttribute( - (attributes[i].getName()).c_str(), - (attributes[i].getValue()).c_str()); - } - - if(parent != NULL) - parent->appendChild(node); - } - -} - -} // namespace Whiteboard -} // namespace Inkscape - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/invitation-confirm-dialog.cpp b/src/jabber_whiteboard/invitation-confirm-dialog.cpp deleted file mode 100644 index 7530f58aa..000000000 --- a/src/jabber_whiteboard/invitation-confirm-dialog.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Whiteboard invitation confirmation dialog -- - * quick subclass of Gtk::MessageDialog - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <gtkmm.h> -#include <glibmm.h> -#include <glibmm/i18n.h> - -#include "invitation-confirm-dialog.h" -#include "session-file-selector.h" - -namespace Inkscape { - -namespace Whiteboard { - -InvitationConfirmDialog::InvitationConfirmDialog(Glib::ustring const& msg) : - Gtk::MessageDialog(msg, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, false), - _usesessionfile(_("_Write session file:"), true) -{ - this->_construct(); - this->get_vbox()->show_all_children(); -} - -InvitationConfirmDialog::~InvitationConfirmDialog() -{ - -} - -Glib::ustring const& -InvitationConfirmDialog::getSessionFilePath() -{ - return this->_sfsbox.getFilename(); -} - -bool -InvitationConfirmDialog::useSessionFile() -{ - return this->_sfsbox.isSelected(); -} - -void -InvitationConfirmDialog::_construct() -{ - this->get_vbox()->pack_end(this->_sfsbox); -} - -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/invitation-confirm-dialog.h b/src/jabber_whiteboard/invitation-confirm-dialog.h deleted file mode 100644 index 4143e8866..000000000 --- a/src/jabber_whiteboard/invitation-confirm-dialog.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Whiteboard invitation confirmation dialog -- - * quick subclass of Gtk::MessageDialog - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_INVITATION_CONFIRM_DIALOG_H__ -#define __WHITEBOARD_INVITATION_CONFIRM_DIALOG_H__ - -#include <gtkmm.h> -#include <glibmm.h> - -#include "session-file-selector.h" - -namespace Inkscape { - -namespace Whiteboard { - -class InvitationConfirmDialog : public Gtk::MessageDialog { -public: - InvitationConfirmDialog(Glib::ustring const& msg); - virtual ~InvitationConfirmDialog(); - - Glib::ustring const& getSessionFilePath(); - bool useSessionFile(); - -private: - static unsigned int const SELECT_FILE = 0; - - void _respCallback(int resp); - - Gtk::HBox _filesel; - - SessionFileSelectorBox _sfsbox; - Gtk::CheckButton _usesessionfile; - Gtk::Entry _sessionfile; - Gtk::Button _getfilepath; - - void _construct(); - Glib::ustring _selectedpath; - - // noncopyable, nonassignable - InvitationConfirmDialog(InvitationConfirmDialog const&); - InvitationConfirmDialog& operator=(InvitationConfirmDialog const&); -}; - -} - -} -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/keynode.cpp b/src/jabber_whiteboard/keynode.cpp deleted file mode 100644 index 60acf0ae9..000000000 --- a/src/jabber_whiteboard/keynode.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Inkscape::Whiteboard::KeyNodeTable - structure for lookup of values from keys - * and vice versa - * - * Authors: - * Bob Jamison - * - * Copyright (c) 2005 Authors - */ -#include "keynode.h" -#include "util/ucompose.hpp" - -namespace Inkscape -{ -namespace Whiteboard -{ - - - -void KeyNodeTable::clear() -{ - items.clear(); -} - -void KeyNodeTable::append(const KeyNodeTable &other) -{ - for (unsigned int i = 0; i<other.size() ; i++) - { - KeyNodePair pair = other.item(i); - put(pair); - } -} - -void KeyNodeTable::put(const KeyNodePair &pair) -{ - put(pair.key, pair.node); -} - -void KeyNodeTable::put(const Glib::ustring &key, const XML::Node *node) -{ - //delete existing - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; ) - { - if (key == iter->key || node == iter->node) - iter = items.erase(iter); - else - iter++; - } - - //add new - KeyNodePair pair(key, node); - items.push_back(pair); -} - -XML::Node * KeyNodeTable::get(const Glib::ustring &key) const -{ - std::vector<KeyNodePair>::const_iterator iter; - for (iter = items.begin() ; iter != items.end() ; iter++) - { - if (key == iter->key) - return iter->node; - } - return NULL; -} - - -void KeyNodeTable::remove(const Glib::ustring &key) -{ - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; ) - { - if (key == iter->key) - iter = items.erase(iter); - else - iter++; - } -} - - -Glib::ustring KeyNodeTable::get(XML::Node *node) const -{ - std::vector<KeyNodePair>::const_iterator iter; - for (iter = items.begin() ; iter != items.end() ; iter++) - { - if (node == iter->node) - return iter->key; - } - return ""; -} - -unsigned int KeyNodeTable::incrementVersion(XML::Node *node) -{ - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; iter++) - { - if (node == iter->node) - break; - } - return ++iter->version; -} - -unsigned int KeyNodeTable::getVersion(XML::Node *node) -{ - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; iter++) - { - if (node == iter->node) - break; - } - return iter->version; -} - -void KeyNodeTable::addHistory(XML::Node *node, Glib::ustring attribute, Glib::ustring value) -{ - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; iter++) - { - if (node == iter->node) - { - Configure pair(attribute, value); - iter->history.push_back(pair); - } - } -} - -Glib::ustring KeyNodeTable::getLastHistory(XML::Node *node, Glib::ustring att) -{ - std::list<Configure> hist; - - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; iter++) - { - if (node == iter->node) - hist = iter->history; - } - - std::list<Configure>::iterator it; - for(it = hist.end() ; it != hist.begin() ; it--) - { - if(it->first == att) - { - //g_warning("hist %s %s",it->first,it->second); - return it->second; - } - } - return ""; -} - -void KeyNodeTable::remove(XML::Node *node) -{ - std::vector<KeyNodePair>::iterator iter; - for (iter = items.begin() ; iter != items.end() ; ) - { - if (node == iter->node) - iter = items.erase(iter); - else - iter++; - } -} - -unsigned int KeyNodeTable::size() const -{ - return items.size(); -} - - -KeyNodePair KeyNodeTable::item(unsigned int index) const -{ - if (index>=items.size()) - { - KeyNodePair pair("", NULL); - return pair; - } - return items[index]; -} - -Glib::ustring -KeyNodeTable::generateKey(Glib::ustring jid) -{ - return String::ucompose("%1/%2",this->counter++,jid); -} - - -} // namespace Whiteboard - -} // namespace Inkscape -//######################################################################### -//# E N D O F F I L E -//######################################################################### diff --git a/src/jabber_whiteboard/keynode.h b/src/jabber_whiteboard/keynode.h deleted file mode 100644 index 64c820732..000000000 --- a/src/jabber_whiteboard/keynode.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Inkscape::Whiteboard::KeyNodeTable - structure for lookup of values from keys - * and vice versa - * - * Authors: - * Bob Jamison - * - * Copyright (c) 2005 Authors - */ -#ifndef __KEY_NODE_H__ -#define __KEY_NODE_H__ - -#include <glibmm.h> - -#include <vector> - -#include "xml/node.h" -#include "jabber_whiteboard/defines.h" - -namespace Inkscape -{ -namespace Whiteboard -{ - -class KeyNodePair -{ -public: - - KeyNodePair(const Glib::ustring &keyArg, const XML::Node *nodeArg) - { - this->key = keyArg; - this->node = (XML::Node *)nodeArg; - this->version = 0; - this->index = 0; - this->history.push_back(Configure("","")); - } - - KeyNodePair(const Glib::ustring &keyArg, const XML::Node *nodeArg, - unsigned int version, signed int index) - { - this->key = keyArg; - this->node = (XML::Node *)nodeArg; - this->version = version; - this->index = index; - this->history.push_back(Configure("","")); - } - - KeyNodePair(const KeyNodePair &other) - { - this->key = other.key; - this->node = other.node; - this->version = other.version; - this->index = other.index; - this->history = other.history; - } - - virtual ~KeyNodePair() {} - - Glib::ustring key; - XML::Node *node; - unsigned int version; - signed int index; - std::list< Configure > history; -}; - -class KeyNodeTable -{ -public: - - KeyNodeTable() - { this->counter = 0; } - - KeyNodeTable(const KeyNodeTable &other) - { - items = other.items; - this->counter = 0; - } - - virtual ~KeyNodeTable() - {} - - virtual void clear(); - - virtual void append(const KeyNodeTable &other); - - virtual void put(const KeyNodePair &pair); - - virtual void put(const Glib::ustring &key, const XML::Node *node); - - virtual XML::Node * get(const Glib::ustring &key) const; - - virtual void remove(const Glib::ustring &key); - - virtual Glib::ustring get(XML::Node *node) const; - - virtual void remove(XML::Node *node); - - virtual unsigned int size() const; - - virtual KeyNodePair item(unsigned int index) const; - - virtual Glib::ustring generateKey(Glib::ustring); - - virtual unsigned int getVersion(XML::Node *node); - - virtual unsigned int incrementVersion(XML::Node *node); - - virtual void addHistory(XML::Node *node, Glib::ustring attribute, Glib::ustring value); - - virtual Glib::ustring getLastHistory(XML::Node *node, Glib::ustring attribute); - -private: - - std::vector<KeyNodePair> items; - - unsigned int counter; - -}; - - - -} // namespace Whiteboard - -} // namespace Inkscape - - -#endif /* __KEY_NODE_H__ */ - - diff --git a/src/jabber_whiteboard/makefile.in b/src/jabber_whiteboard/makefile.in deleted file mode 100644 index 5300eb61f..000000000 --- a/src/jabber_whiteboard/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) jabber_whiteboard/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) jabber_whiteboard/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/jabber_whiteboard/message-aggregator.cpp b/src/jabber_whiteboard/message-aggregator.cpp deleted file mode 100644 index 7d4ee4b3f..000000000 --- a/src/jabber_whiteboard/message-aggregator.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Aggregates individual serialized XML::Events into larger packages - * for more efficient delivery - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm.h> -#include "jabber_whiteboard/message-aggregator.h" - -namespace Inkscape { - -namespace Whiteboard { - -bool -MessageAggregator::addOne(Glib::ustring const& msg, Glib::ustring& buf) -{ - // 1. If msg.bytes() > maximum size and the buffer is clear, - // then we have to send an oversize packet -- - // we won't be able to deliver the message any other way. - // Add it to the buffer and return true. Any further attempt to - // aggregate a message will be handled by condition #2. - if (msg.bytes() > MessageAggregator::MAX_SIZE && buf.empty()) { - buf += msg; - return true; - } - - // 2. If msg.bytes() + buf.bytes() > maximum size, return false. - // The user of this class is responsible for retrieving the aggregated message, - // doing something with it, clearing the buffer, and trying again. - // Otherwise, append the message to the buffer and return true. - if (msg.bytes() + buf.bytes() > MessageAggregator::MAX_SIZE) { - return false; - } else { - buf += msg; - return true; - } -} - -bool -MessageAggregator::addOne(Glib::ustring const& msg) -{ - return this->addOne(msg, this->_buf); -} - -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-aggregator.h b/src/jabber_whiteboard/message-aggregator.h deleted file mode 100644 index a73ee9876..000000000 --- a/src/jabber_whiteboard/message-aggregator.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Aggregates individual serialized XML::Events into larger packages - * for more efficient delivery - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_MESSAGE_AGGREGATOR_H__ -#define __WHITEBOARD_MESSAGE_AGGREGATOR_H__ - -#include <glibmm.h> - -namespace Inkscape { - -namespace Whiteboard { - -/** - * Aggregates individual serialized XML::Events into larger messages for increased - * efficiency. - * - * \see Inkscape::Whiteboard::Serializer - */ -class MessageAggregator { -public: - // TODO: This should be user-configurable; perhaps an option in Inkscape Preferences... - /// Maximum size of aggregates in kilobytes; ULONG_MAX = no limit. - static unsigned int const MAX_SIZE = 16384; - - MessageAggregator() { } - virtual ~MessageAggregator() { } - - /** - * Return the instance of this class. - * - * \return MessageAggregator instance. - */ - static MessageAggregator& instance() - { - static MessageAggregator singleton; - return singleton; - } - - /** - * Adds one message to the aggregate - * using a user-provided buffer. Returns true if more messages can be - * added to the buffer; false otherwise. - * - * \param msg The message to add to the aggregate. - * \param buf The aggregate buffer. - * \return Whether or not more messages can be added to the buffer. - */ - bool addOne(Glib::ustring const& msg, Glib::ustring& buf); - - /** - * Adds one message to the aggregate using the internal buffer. - * Note that since this class is designed to be a singleton class, usage of the internal - * buffer is not thread-safe. Use the above method if this matters to you - * (it currently shouldn't matter, but in future...) - * - * Also note that usage of the internal buffer means that you will have to manually - * clear the internal buffer; use reset() for that. - * - * \param msg The message to add to the aggregate. - * \return Whether or not more messages can be added to the buffer. - */ - bool addOne(Glib::ustring const& msg); - - /** - * Return the aggregate message. - * - * Because this method returns a reference to a string, it is not safe to assume - * that its contents will remain untouched across two calls to this MessageAggregator. - * If you require that guarantee, make a copy. - * - * \return A reference to the aggregate message. - */ - Glib::ustring const& getAggregate() - { - return this->_buf; - } - - /** - * Return the aggregate message. - * - * \return The aggregate message. - */ - Glib::ustring const getAggregateCopy() - { - return this->_buf; - } - - /** - * Return the aggregate message and clear the internal buffer. - * - * \return The aggregate message. - */ - Glib::ustring const detachAggregate() - { - Glib::ustring ret = this->_buf; - this->_buf.clear(); - return ret; - } - - /** - * Clear the internal buffer. - */ - void reset() - { - this->_buf.clear(); - } - -private: - Glib::ustring _buf; -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-node.h b/src/jabber_whiteboard/message-node.h deleted file mode 100644 index 8609597ce..000000000 --- a/src/jabber_whiteboard/message-node.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Whiteboard message queue and queue handler functions - * Node for storing messages in message queues - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_MESSAGE_NODE_H__ -#define __WHITEBOARD_MESSAGE_NODE_H__ - -#include <string> -#include <glibmm.h> - -#include "gc-managed.h" -#include "gc-anchored.h" -#include "gc-finalized.h" -#include "message.h" - -namespace Inkscape { - -namespace Whiteboard { - -/** - * Encapsulates a document change message received by or sent to an Inkboard client. - * - * Received messages that end up in a MessageNode are of the following types: - * <ol> - * <li>CHANGE_REPEATABLE</li> - * <li>CHANGE_NOT_REPEATABLE</li> - * <li>CHANGE_COMMIT</li> - * <li>DOCUMENT_BEGIN</li> - * <li>DOCUMENT_END</li> - * <li>DUMMY_CHANGE</li> - * </ol> - * - * This class is intended for use in MessageQueues, although it could potentially - * see use outside of that context. - * - * \see Inkscape::Whiteboard::MessageQueue - */ -class MessageNode : public GC::Managed<>, public GC::Anchored, public GC::Finalized { -public: - /** - * Constructor. - * - * \param seq The sequence number of the message being encapsulated. - * \param sender The sender of the message. - * \param recip The intended recipient. - * \param message_body The body of the message. - * \param type The type of the message. - * \param chatroom Whether or not this message is to be sent to / was received from a chatroom. - */ - MessageNode(unsigned int seq, std::string sender, std::string recip, Glib::ustring const& message_body, MessageType type, bool document, bool chatroom) : - _seq(seq), _type(type), _message(message_body), _document(document), _chatroom(chatroom) - { - this->_sender = sender; - this->_recipient = recip; - } - - virtual ~MessageNode() - { -// g_log(NULL, G_LOG_LEVEL_DEBUG, "MessageNode destructor"); - /* - if (this->_message) { - delete this->_message; - } - */ - } - - unsigned int sequence() - { - return this->_seq; - } - - MessageType type() - { - return this->_type; - } - - bool chatroom() - { - return this->_chatroom; - } - - bool document() - { - return this->_document; - } - - std::string recipient() - { - return this->_recipient; - } - - std::string sender() - { - return this->_sender; - } - - Glib::ustring const& message() - { - return this->_message; - } - -private: - unsigned int _seq; - std::string _sender; - std::string _recipient; - MessageType _type; - Glib::ustring _message; - bool _document; - bool _chatroom; -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-queue.cpp b/src/jabber_whiteboard/message-queue.cpp deleted file mode 100644 index b56c1453c..000000000 --- a/src/jabber_whiteboard/message-queue.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Whiteboard message queue - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> - -#include "desktop-handles.h" -#include "message-stack.h" - -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/message-node.h" -#include "jabber_whiteboard/message-queue.h" - -namespace Inkscape { - -namespace Whiteboard { - -//################################### -//# MESSAGE QUEUE -//################################### - -MessageNode* -MessageQueue::first() -{ - return _queue.front(); -} - -void -MessageQueue::popFront() -{ - _queue.pop_front(); - //g_log(NULL, G_LOG_LEVEL_DEBUG, - // "Removed element, queue size (for %s): %u", - //lm_connection_get_jid(this->_sm->session_data->connection), this->_queue.size()); -} - -unsigned int -MessageQueue::size() -{ - return _queue.size(); -} - -bool -MessageQueue::empty() -{ - return _queue.empty(); -} - -void -MessageQueue::clear() -{ - _queue.clear(); -} - - - -//################################### -//# RECEIVE MESSAGE QUEUE -//################################### -void -ReceiveMessageQueue::insert(MessageNode* msg) -{ - // Check to see if the incoming message has a sequence number - // lower than the sequence number of the latest message processed - // by this message's sender. If it does, drop the message and produce - // a warning. - if (msg->sequence() < _latest) { - g_warning("Received late message (message sequence number is %u, but latest processed message had sequence number %u). Discarding message; session may be desynchronized.", msg->sequence(), this->_latest); - return; - } - - // Otherwise, it is safe to insert this message. - //Inkscape::GC::anchor(msg); - _queue.push_back(msg); - /* - SP_DT_MSGSTACK(_sm->getDesktop())->flashF( - Inkscape::NORMAL_MESSAGE, - _("%u changes queued in receive queue."), - _queue.size()); - */ - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Receive queue size (for %s): %u", - // lm_connection_get_jid(this->_sm->session_data->connection), this->_queue.size()); -} - -void -ReceiveMessageQueue::insertDeferred(MessageNode* msg) -{ - _deferred.push_back(msg); -} - -void -ReceiveMessageQueue::setLatestProcessedPacket(unsigned int seq) -{ - _latest = seq; -} - - -//################################### -//# SEND MESSAGE QUEUE -//################################### -void -SendMessageQueue::insert(MessageNode* msg) -{ - //Inkscape::GC::anchor(msg); - _queue.push_back(msg); - /* - SP_DT_MSGSTACK(_sm->getDesktop())->flashF( - Inkscape::NORMAL_MESSAGE, - _("%u changes queued in send queue."), - _queue.size()); - */ - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Send queue size (for %s): %u", - // lm_connection_get_jid(this->_sm->session_data->connection), - //this->_queue.size()); -} - -} // namespace Whiteboard - -} // namespace Inkscape - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-queue.h b/src/jabber_whiteboard/message-queue.h deleted file mode 100644 index 700a53bae..000000000 --- a/src/jabber_whiteboard/message-queue.h +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Whiteboard message queue - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_MESSAGE_QUEUE_H__ -#define __WHITEBOARD_MESSAGE_QUEUE_H__ - -#include <list> -#include <map> - -#include "gc-alloc.h" -#include "gc-managed.h" - -#include "util/list-container.h" - -namespace Inkscape { - -namespace Whiteboard { - -class MessageNode; - -/// Definition of the basic message node queue -typedef std::list< MessageNode*, GC::Alloc< MessageNode*, GC::MANUAL > > MessageQueueBuffer; - -/** - * MessageQueue interface. - * - * A message queue is used to queue up document change messages for sending and receiving. - * - * Message queues exist to allow us to send/process messages at a given rate rather than - * immediately: this allows us to avoid flooding Jabber servers and clients. - * - * Only one message queue should be created per sender. Message queues store MessageNodes. - * - * \see Inkscape::Whiteboard::MessageNode - */ -class MessageQueue { -public: - /** - * Constructor. - * - * \param sm The SessionManager to associate this MessageQueue with. - */ - MessageQueue() { } - virtual ~MessageQueue() - { - this->_queue.clear(); - } - - /** - * Retrieve the MessageNode at the front of the queue. - */ - virtual MessageNode* first(); - - /** - * Remove the element at the front of the queue. - */ - virtual void popFront(); - - /** - * Get the size of the queue. - * - * \return The size of the queue. - */ - virtual unsigned int size(); - - /** - * Returns whether or not the queue is empty. - * - * \return Whether or not the queue is empty. - */ - virtual bool empty(); - - /** - * Clear the queue. - */ - virtual void clear(); - - /** - * The insertion method. The insertion procedure must be defined - * by a subclass. - * - * \param msg The MessageNode to insert. - */ - virtual void insert(MessageNode* msg) = 0; - -protected: - /** - * Implementation of the queue. - */ - MessageQueueBuffer _queue; -}; - - -/** - * MessageQueue subclass designed to queue up received messages. - * Received messages are dispatched for processing on a periodic basis by a timeout. - * - * \see Inkscape::Whiteboard::Callbacks::dispatchReceiveQueue - */ -class ReceiveMessageQueue : public MessageQueue, public GC::Managed<> { -public: - ReceiveMessageQueue() : _latest(0) { } - - /** - * Insert a message into the queue. - * Late messages (out-of-sequence messages) will be discarded. - * - * \param msg The message node to insert. - */ - void insert(MessageNode* msg); - - /** - * Insert a message into the deferred queue. - * The deferred message queue is used for messages that are not discarded, - * but cannot yet be processed due to missing dependencies. - * - * \param msg The message node to insert. - */ - void insertDeferred(MessageNode* msg); - - /** - * Update the latest processed packet count for this message queue. - * - * \param seq The sequence number of the latest processed packet. - */ - void setLatestProcessedPacket(unsigned int seq); -private: - MessageQueueBuffer _deferred; - unsigned int _latest; -}; - -/** - * MessageQueue subclass designed to queue up messages for sending. - * Messages in this queue are dispatched on a periodic basis by a timeout. - * - * \see Inkscape::Whiteboard::Callbacks::dispatchSendQueue - */ -class SendMessageQueue : public MessageQueue { -public: - SendMessageQueue() { } - - /** - * Insert a message into the queue. - * - * \param msg The message node to insert. - */ - void insert(MessageNode* msg); -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-tags.cpp b/src/jabber_whiteboard/message-tags.cpp deleted file mode 100644 index c82cd0c62..000000000 --- a/src/jabber_whiteboard/message-tags.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Whiteboard session manager - * Message tags - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "jabber_whiteboard/message-tags.h" - -namespace Inkscape { - -namespace Whiteboard { - -const char* MESSAGE_CHANGE = "inkboard:change"; -const char* MESSAGE_NEWOBJ = "inkboard:new"; -const char* MESSAGE_DELETE = "inkboard:delete"; -const char* MESSAGE_DOCUMENT = "inkboard:document"; -const char* MESSAGE_NODECONTENT = "inkboard:node-content"; -const char* MESSAGE_ORDERCHANGE = "inkboard:order-change"; -const char* MESSAGE_COMMIT = "inkboard:commit"; -const char* MESSAGE_UNDO = "inkboard:undo"; -const char* MESSAGE_REDO = "inkboard:redo"; -const char* MESSAGE_DOCBEGIN = "inkboard:document-begin"; -const char* MESSAGE_DOCEND = "inkboard:document-end"; -const char* MESSAGE_OBJKEY = "objid"; -const char* MESSAGE_ID = "id"; -const char* MESSAGE_KEY = "key"; -const char* MESSAGE_OLDVAL = "old"; -const char* MESSAGE_NEWVAL = "new"; -const char* MESSAGE_NAME = "name"; -const char* MESSAGE_ISINTERACTIVE = "interactive"; -const char* MESSAGE_DATA = "data"; -const char* MESSAGE_PARENT = "parent"; -const char* MESSAGE_CHILD = "child"; -const char* MESSAGE_REF = "ref"; -const char* MESSAGE_CONTENT = "content"; -const char* MESSAGE_REPEATABLE = "repeatable"; -const char* MESSAGE_CHATROOM = "chatroom"; - -const char* MESSAGE_TYPE = "inkboard-type"; -const char* MESSAGE_NODETYPE = "node-type"; -const char* MESSAGE_FROM = "from"; -const char* MESSAGE_TO = "to"; -const char* MESSAGE_BODY = "body"; -const char* MESSAGE_QUEUE = "queue"; -const char* MESSAGE_SEQNUM = "sequence-number"; -const char* MESSAGE_PROTOCOL_VER = "inkboard-protocol"; - -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-tags.h b/src/jabber_whiteboard/message-tags.h deleted file mode 100644 index de14778b1..000000000 --- a/src/jabber_whiteboard/message-tags.h +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Whiteboard session manager - * Message tags - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_MESSAGE_TAGS_H__ -#define __WHITEBOARD_MESSAGE_TAGS_H__ - -namespace Inkscape { - -namespace Whiteboard { -/** - * - * These message tags are <b>not</b> used in all messages. - * They are confined to messages of type CHANGE_* and DOCUMENT_*; - * they define the tags that are used inside those messages' bodies. - */ -// TODO: breaking these up into namespaces would be nice, but it's too much typing -// for now -// -// TODO: Some of these message tags are obsolete, and should be removed... - -/// Message tag signaling an attribute change on a node. -extern char const* MESSAGE_CHANGE; - -/// Message tag signaling a new node. -extern char const* MESSAGE_NEWOBJ; - -/// Message tag signaling a node to remove. -extern char const* MESSAGE_DELETE; - -/// Message tag signaling the beginning of a document synchronization. -extern char const* MESSAGE_DOCUMENT; - -/// Message tag signaling a change in node content. -extern char const* MESSAGE_NODECONTENT; - -/// Message tag signaling a change in node order. -extern char const* MESSAGE_ORDERCHANGE; - -/// Message tag signaling a commit. -extern char const* MESSAGE_COMMIT; - -/// Message tag signaling an undo. -extern char const* MESSAGE_UNDO; - -/// Message tag signaling a redo. -extern char const* MESSAGE_REDO; - -/// Message tag signaling the beginning of a document synchronization. -extern char const* MESSAGE_DOCBEGIN; - -/// Message tag signaling the end of a document synchronization. -extern char const* MESSAGE_DOCEND; - -/// Message tag used to identify an object's key. -extern char const* MESSAGE_OBJKEY; - -/// Message tag used to identify a node ID. -extern char const* MESSAGE_ID; - -/// Message tag used to identify an attribute key. -extern char const* MESSAGE_KEY; - -/// Message tag used to identify an old value (attribute or content). -extern char const* MESSAGE_OLDVAL; - -/// Message tag used to identify a new value (attribute or content). -extern char const* MESSAGE_NEWVAL; - -/// Message tag used to identify a node name. -extern char const* MESSAGE_NAME; - -extern char const* MESSAGE_ISINTERACTIVE; -extern char const* MESSAGE_DATA; - -/// Message tag used to identify the parent of a node by string key. -extern char const* MESSAGE_PARENT; - -/// Message tag used to identify a child node by string key. -extern char const* MESSAGE_CHILD; - -/// Message tag used to identify the node previous to a child node by string key. -extern char const* MESSAGE_REF; - -/// Message tag used to identify the content in a node. -extern char const* MESSAGE_CONTENT; -extern char const* MESSAGE_REPEATABLE; -extern char const* MESSAGE_CHATROOM; - -/** - * These message tags are used in all messages. - */ - -/// Message tag used to identify the message type. -extern char const* MESSAGE_TYPE; - -/// Message tag used to identify the type of node being operated on. -extern char const* MESSAGE_NODETYPE; - -/// Message tag used to identify the sender. -extern char const* MESSAGE_FROM; - -/// Message tag used to identify the recipient. -extern char const* MESSAGE_TO; - -/// Message tag used to identify the body portion of the message. -extern char const* MESSAGE_BODY; -extern char const* MESSAGE_QUEUE; - -/// Message tag used to identify the sequence number of the message. -extern char const* MESSAGE_SEQNUM; - -/// Message tag used to identify the Inkboard protocol version being used. -extern char const* MESSAGE_PROTOCOL_VER; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-utilities.cpp b/src/jabber_whiteboard/message-utilities.cpp deleted file mode 100644 index 448cc23e1..000000000 --- a/src/jabber_whiteboard/message-utilities.cpp +++ /dev/null @@ -1,493 +0,0 @@ -/** - * Message generation utilities - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jonas Collaros, Stephen Montgomery - * - * Copyright (c) 2004-2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> - -#include "util/share.h" -#include "util/list.h" -#include "util/ucompose.hpp" - -#include "xml/node.h" -#include "xml/attribute-record.h" -#include "xml/repr.h" - -#include "jabber_whiteboard/defines.h" -#include "jabber_whiteboard/node-utilities.h" -#include "jabber_whiteboard/message-utilities.h" -#include "jabber_whiteboard/node-tracker.h" - -#include <iostream> - -namespace Inkscape { - -namespace Whiteboard { - -// This method can be instructed to not build a message string but only collect nodes that _would_ be transmitted -// and subsequently added to the tracker. This can be useful in the case where an Inkboard user is the only one -// in a chatroom and therefore needs to fill out the node tracker, but does not need to build the message string. -// This can be controlled with the only_collect_nodes flag, which will only create pointers to new XML::Nodes -// in the maps referenced by newidsbuf and newnodesbuf. Passing NULL as the message buffer has the same effect. -// -// only_collect_nodes defaults to false because most invocations of this method also use the message string. - -Glib::ustring -MessageUtilities::objectToString(Inkscape::XML::Node *element) -{ - if(element->type() == Inkscape::XML::TEXT_NODE) - return String::ucompose("<text>%1</text>",element->content()); - - Glib::ustring attributes; - - for ( Inkscape::Util::List<Inkscape::XML::AttributeRecord const> - iter = element->attributeList() ; iter ; ++iter ) - { - attributes.append(g_quark_to_string(iter->key)); - attributes.append("=\""); - attributes.append(iter->value); - attributes.append("\" "); - } - - return String::ucompose("<%1 %2/>",element->name(),attributes); -} -/* -void -MessageUtilities::newObjectMessage(Glib::ustring &msgbuf, - KeyNodeTable& newnodesbuf, - NewChildObjectMessageList& childmsgbuf, - XMLNodeTracker* xmt, - Inkscape::XML::Node const* node, - bool only_collect_nodes, - bool collect_children) -{ - // Initialize pointers - Glib::ustring id, refid, parentid; - - gchar const* name = NULL; - XML::Node* parent = NULL; - XML::Node* ref = NULL; - - bool only_add_children = false; - - //g_log(NULL, G_LOG_LEVEL_DEBUG, "newObjectMessage: processing node %p of type %s", node, NodeUtilities::nodeTypeToString(*node).data()); - - if (node != NULL) { - parent = sp_repr_parent(node); - if (parent != NULL) { - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Attempting to find ID for parent node %p (on node %p)", parent, node); - parentid = NodeUtilities::findNodeID(*parent, xmt, newnodesbuf); - if (parentid.empty()) { - g_warning("Parent %p is not being tracked, creating new ID", parent); - parentid = xmt->generateKey(); - newnodesbuf.put(parentid, parent); - } - - if ( node != parent->firstChild() && parent != NULL ) { - ref = parent->firstChild(); - while (ref->next() != node) { - ref = ref->next(); - } - } - } - - if (ref != NULL) { - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Attempting to find ID for ref node %p (on %p)", ref, node); - refid = NodeUtilities::findNodeID(*ref, xmt, newnodesbuf); - if (refid.empty() && ref != NULL) { - g_warning("Ref %p is not being tracked, creating new ID", ref); - refid = xmt->generateKey(); - newnodesbuf.put(refid, ref); - } - } - - name = static_cast< gchar const* >(node->name()); - } - - // Generate an id for this object and append it onto the list, if - // it's not already in the tracker - if (!xmt->isSpecialNode(node->name())) { - if (!xmt->isTracking(*node)) { - id = xmt->generateKey(); - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Inserting %p with id %s", node, id.c_str()); - newnodesbuf.put(id, node); - } else { - id = xmt->get(*node); - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Found id %s for node %p; not inserting into new nodes buffers.", id.c_str(), node); - } - } else { - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing special node; not generating key"); - id = xmt->get(*node); - if (id.empty()) { - g_warning("Node %p (name %s) is a special node, but it could not be found in the node tracker (possible unexpected duplicate?) Generating unique ID anyway.", node, node->name()); - id = xmt->generateKey(); - newnodesbuf.put(id, node); - } - only_add_children = true; - } - - // If we're only adding children (i.e. this is a special node) - // don't process the given node. - if( !only_add_children && !id.empty() && msgbuf != NULL && !only_collect_nodes ) { - // <MESSAGE_NEWOBJ> - msgbuf = msgbuf + "<" + MESSAGE_NEWOBJ + ">"; - - // <MESSAGE_PARENT> - msgbuf = msgbuf + "<" + MESSAGE_PARENT + ">"; - - if(!parentid.empty()) { - msgbuf += parentid; - } - - // </MESSAGE_NEWOBJ><MESSAGE_CHILD>id</MESSAGE_CHILD> - msgbuf = msgbuf + "</" + MESSAGE_PARENT + ">"; - - msgbuf = msgbuf + "<" + MESSAGE_CHILD + ">"; - msgbuf += id; - - msgbuf = msgbuf + "</" + MESSAGE_CHILD + ">"; - - if(!refid.empty()) { - // <MESSAGE_REF>refid</MESSAGE_REF> - msgbuf = msgbuf + "<" + MESSAGE_REF + ">"; - - msgbuf += refid; - - msgbuf = msgbuf + "</" + MESSAGE_REF + ">"; - } - - // <MESSAGE_NODETYPE>*node.type()</MESSAGE_NODETYPE> - msgbuf = msgbuf + "<" + MESSAGE_NODETYPE + ">" + NodeUtilities::nodeTypeToString(*node); - msgbuf = msgbuf + "</" + MESSAGE_NODETYPE + ">"; - - if (node->content() != NULL) { - // <MESSAGE_CONTENT>node->content()</MESSAGE_CONTENT> - msgbuf = msgbuf + "<" + MESSAGE_CONTENT + ">" + node->content(); - msgbuf = msgbuf + "</" + MESSAGE_CONTENT + ">"; - } - - // <MESSAGE_NAME>name</MESSAGE_NAME> - msgbuf = msgbuf + "<" + MESSAGE_NAME + ">"; - - if( name != NULL ) - msgbuf += name; - - msgbuf = msgbuf + "</" + MESSAGE_NAME + ">"; - - // </MESSAGE_NEWOBJ> - msgbuf = msgbuf + "</" + MESSAGE_NEWOBJ + ">"; - } else if (id.empty()) { - // if ID is NULL, then we have a real problem -- we were not able to find a key - // nor generate one. The only thing we can really do here is abort, since we have - // no way to let the other client(s) uniquely identify this object. - g_warning(_("ID for new object is NULL even after generation and lookup attempts: the new object will NOT be sent, nor will any of its child objects!")); - return; - } else { - - } - - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Generated message"); - - if (!only_collect_nodes && msgbuf != NULL && !id.empty()) { - // Collect new object's attributes and append them onto the msgbuf - Inkscape::Util::List<Inkscape::XML::AttributeRecord const> attrlist = node->attributeList(); - - for(; attrlist; attrlist++) { - MessageUtilities::objectChangeMessage(msgbuf, - xmt, id, g_quark_to_string(attrlist->key), - NULL, attrlist->value, false); - } - } - - if (!only_collect_nodes) - childmsgbuf.push_back(msgbuf); - - if (!id.empty() && collect_children) { - Glib::ustring childbuf; - // Collect any child objects of this new object - for ( Inkscape::XML::Node const *child = node->firstChild(); child != NULL; child = child->next() ) { - childbuf.clear(); - MessageUtilities::newObjectMessage(childbuf, - newnodesbuf, childmsgbuf, xmt, child, only_collect_nodes); - if (!only_collect_nodes) { - // we're recursing down the tree, so we're picking up child nodes first - // and parents afterwards -// childmsgbuf.push_front(childbuf); - } - - } - } -} - -void -MessageUtilities::objectChangeMessage(Glib::ustring &msgbuf, - XMLNodeTracker* xmt, - const Glib::ustring &id, - gchar const* key, - gchar const* oldval, - gchar const* newval, - bool is_interactive) -{ - // Construct message - - // <MESSAGE_CHANGE><MESSAGE_ID>id</MESSAGE_ID> - msgbuf = msgbuf + "<" + MESSAGE_CHANGE + ">"; - msgbuf = msgbuf + "<" + MESSAGE_ID + ">"; - msgbuf += id; - msgbuf = msgbuf + "</" + MESSAGE_ID + ">"; - - // <MESSAGE_KEY>key</MESSAGE_KEY> - msgbuf = msgbuf + "<" + MESSAGE_KEY + ">"; - if (key != NULL) { - msgbuf += key; - } - msgbuf = msgbuf + "</" + MESSAGE_KEY + ">"; - - // <MESSAGE_OLDVAL>oldval</MESSAGE_OLDVAL> - msgbuf = msgbuf + "<" + MESSAGE_OLDVAL + ">"; - if (oldval != NULL) { - msgbuf += oldval; - } - msgbuf = msgbuf + "</" + MESSAGE_OLDVAL + ">"; - - // <MESSAGE_NEWVAL>newval</MESSAGE_NEWVAL> - msgbuf = msgbuf + "<" + MESSAGE_NEWVAL + ">"; - if (newval != NULL) { - msgbuf += newval; - } - msgbuf = msgbuf + "</" + MESSAGE_NEWVAL + ">"; - - // <MESSAGE_ISINTERACTIVE>is_interactive</MESSAGE_ISINTERACTIVE> - msgbuf = msgbuf + "<" + MESSAGE_ISINTERACTIVE + ">"; - if (is_interactive) { - msgbuf += "true"; - } else { - msgbuf += "false"; - } - msgbuf = msgbuf + "</" + MESSAGE_ISINTERACTIVE + ">"; - - // </MESSAGE_CHANGE> - msgbuf = msgbuf + "</" + MESSAGE_CHANGE + ">"; -} - -void -MessageUtilities::objectDeleteMessage(Glib::ustring &msgbuf, - XMLNodeTracker* xmt, - Inkscape::XML::Node const& parent, - Inkscape::XML::Node const& child, - Inkscape::XML::Node const* prev) -{ - /* - gchar const* parentid = NULL; - gchar const* previd = NULL; - gchar const* childid = NULL; - - childid = child.attribute("id"); - parentid = parent.attribute("id"); - if (prev != NULL) { - previd = prev->attribute("id"); - } - - Glib::ustring parentid, previd, childid; - - childid = xmt->get(child); - parentid = xmt->get(parent); - previd = xmt->get(*prev); - - if (childid.empty()) - return; - - - // <MESSAGE_DELETE><MESSAGE_PARENT>parentid</MESSAGE_PARENT> - msgbuf = msgbuf + "<" + MESSAGE_DELETE + ">" + "<" + MESSAGE_PARENT + ">"; - if (!parentid.empty()) { - msgbuf += parentid; - } - msgbuf = msgbuf + "</" + MESSAGE_PARENT + ">"; - - // <MESSAGE_CHILD>childid</MESSAGE_CHILD> - msgbuf = msgbuf + "<" + MESSAGE_CHILD + ">"; - if (!childid.empty()) { - msgbuf += childid; - } - msgbuf = msgbuf + "</" + MESSAGE_CHILD + ">"; - - // <MESSAGE_REF>previd</MESSAGE_REF> - msgbuf = msgbuf + "<" + MESSAGE_REF + ">"; - if (!previd.empty()) { - msgbuf += previd; - } - msgbuf = msgbuf + "</" + MESSAGE_REF + ">"; - - // </MESSAGE_DELETE> - msgbuf = msgbuf + "</" + MESSAGE_DELETE + ">"; -} - -void -MessageUtilities::contentChangeMessage(Glib::ustring& msgbuf, - const Glib::ustring &nodeid, - Util::ptr_shared<char> old_value, - Util::ptr_shared<char> new_value) -{ - if (nodeid.empty()) - return; - - // <MESSAGE_NODECONTENT> - msgbuf = msgbuf + "<" + MESSAGE_NODECONTENT + ">"; - - // <MESSAGE_ID>nodeid</MESSAGE_ID> - msgbuf = msgbuf + "<" + MESSAGE_ID + ">"; - msgbuf += nodeid; - msgbuf = msgbuf + "</" + MESSAGE_ID + ">"; - - // <MESSAGE_OLDVAL>old_value</MESSAGE_OLDVAL> - msgbuf = msgbuf + "<" + MESSAGE_OLDVAL + ">"; - msgbuf += old_value.pointer(); - msgbuf = msgbuf + "</" + MESSAGE_OLDVAL + ">"; - - // <MESSAGE_NEWVAL>new_value</MESSAGE_NEWVAL> - msgbuf = msgbuf + "<" + MESSAGE_NEWVAL + ">"; - msgbuf += new_value.pointer(); - msgbuf = msgbuf + "</" + MESSAGE_NEWVAL + ">"; - - // </MESSAGE_NODECONTENT> - msgbuf = msgbuf + "</" + MESSAGE_NODECONTENT + ">"; -} - -void -MessageUtilities::childOrderChangeMessage(Glib::ustring& msgbuf, - const Glib::ustring &childid, - const Glib::ustring &oldprevid, - const Glib::ustring &newprevid) -{ - if (childid.empty()) - return; - - // <MESSAGE_ORDERCHANGE> - msgbuf = msgbuf + "<" + MESSAGE_ORDERCHANGE + ">"; - - // <MESSAGE_ID>nodeid</MESSAGE_ID> - msgbuf = msgbuf + "<" + MESSAGE_CHILD + ">"; - msgbuf += childid; - msgbuf = msgbuf + "</" + MESSAGE_CHILD + ">"; - - // <MESSAGE_OLDVAL>oldprevid</MESSAGE_OLDVAL> - /* - msgbuf = msgbuf + "<" + MESSAGE_OLDVAL + ">"; - msgbuf += (*oldprevid); - msgbuf = msgbuf + "</" + MESSAGE_OLDVAL + ">"; - - - // <MESSAGE_NEWVAL>newprevid</MESSAGE_NEWVAL> - msgbuf = msgbuf + "<" + MESSAGE_NEWVAL + ">"; - msgbuf += newprevid; - msgbuf = msgbuf + "</" + MESSAGE_NEWVAL + ">"; - - // </MESSAGE_ORDERCHANGE> - msgbuf = msgbuf + "</" + MESSAGE_ORDERCHANGE + ">"; - -} - - -bool -MessageUtilities::getFirstMessageTag(struct Node& buf, const Glib::ustring &msg) -{ - if (msg.empty()) - return false; - - // See if we have a valid start tag, i.e. < ... >. If we do, - // continue; if not, stop and return NULL. - // - // find_first_of returns ULONG_MAX when it cannot find the first - // instance of the given character. - - Glib::ustring::size_type startDelim = msg.find_first_of('<'); - if (startDelim != ULONG_MAX) { - Glib::ustring::size_type endDelim = msg.find_first_of('>'); - if (endDelim != ULONG_MAX) { - if (endDelim > startDelim) { - buf.tag = msg.substr(startDelim+1, (endDelim-startDelim)-1); - if (buf.tag.find_first_of('/') == ULONG_MAX) { // start tags should not be end tags - - - // construct end tag (</buf.data>) - Glib::ustring endTag(buf.tag); - endTag.insert(0, "/"); - - Glib::ustring::size_type endTagLoc = msg.find(endTag, endDelim); - if (endTagLoc != ULONG_MAX) { - buf.data = msg.substr(endDelim+1, ((endTagLoc - 1) - (endDelim + 1))); - buf.next_pos = endTagLoc + endTag.length() + 1; - - return true; - } - } - } - } - } - - return false; -} - -bool -MessageUtilities::findTag(struct Node& buf, const Glib::ustring &msg) -{ - if (msg.empty()) - return false; - - // Read desired tag type out of buffer, and append - // < > to it - - Glib::ustring searchterm("<"); - searchterm += buf.tag; - searchterm + ">"; - - Glib::ustring::size_type tagStart = msg.find(searchterm, 0); - if (tagStart != ULONG_MAX) { - // Find ending tag starting at the point at the end of - // the start tag. - searchterm.insert(1, "/"); - Glib::ustring::size_type tagEnd = msg.find(searchterm, tagStart + searchterm.length()); - if (tagEnd != ULONG_MAX) { - Glib::ustring::size_type start = tagStart + searchterm.length(); - buf.data = msg.substr(start, tagEnd - start); - return true; - } - } - return false; -} - -Glib::ustring -MessageUtilities::makeTagWithContent(const Glib::ustring &tagname, - const Glib::ustring &content) -{ - Glib::ustring buf = "<" + tagname + ">"; - buf += content; - buf += "</" + tagname + ">"; - return buf; -} -*/ - -} - -} - - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/message-utilities.h b/src/jabber_whiteboard/message-utilities.h deleted file mode 100644 index 5ca07a398..000000000 --- a/src/jabber_whiteboard/message-utilities.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Whiteboard session manager - * Message generation utilities - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jonas Collaros, Stephen Montgomery - * - * Copyright (c) 2004-2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_MESSAGE_UTILITIES_H__ -#define __WHITEBOARD_MESSAGE_UTILITIES_H__ - -#include <glibmm.h> -#include "xml/repr.h" - -#include "xml/node.h" -#include "jabber_whiteboard/defines.h" - -using Glib::ustring; - -namespace Inkscape { - -namespace Util { - -template< typename T > -class ptr_shared; - -} - -namespace Whiteboard { - -struct Node { - ustring tag; - ustring data; - ustring::size_type next_pos; -}; - -class XMLNodeTracker; - -class MessageUtilities { -public: - // Message generation utilities - static Glib::ustring objectToString(Inkscape::XML::Node *element); -/* - static void newObjectMessage(Glib::ustring &msgbuf, - KeyNodeTable& newnodesbuf, - NewChildObjectMessageList& childmsgbuf, - XMLNodeTracker* xmt, - Inkscape::XML::Node const* node, - bool only_collect_nodes = false, - bool collect_children = true); - static void objectChangeMessage(Glib::ustring &msgbuf, - XMLNodeTracker* xmt, - const Glib::ustring &id, - gchar const* key, - gchar const* oldval, - gchar const* newval, - bool is_interactive); - static void objectDeleteMessage(Glib::ustring &msgbuf, - XMLNodeTracker* xmt, - Inkscape::XML::Node const& parent, - Inkscape::XML::Node const& child, - Inkscape::XML::Node const* prev); - static void contentChangeMessage(Glib::ustring &msgbuf, - const Glib::ustring &nodeid, - Util::ptr_shared<char> old_value, - Util::ptr_shared<char> new_value); - static void childOrderChangeMessage(Glib::ustring &msgbuf, - const Glib::ustring &childid, - const Glib::ustring &oldprevid, - const Glib::ustring &newprevid); - - // Message parsing utilities - static bool getFirstMessageTag(struct Node& buf, - const Glib::ustring &msg); - static bool findTag(struct Node& buf, - const Glib::ustring &msg); - - // Message tag generation utilities - static Glib::ustring makeTagWithContent(const Glib::ustring &tagname, - const Glib::ustring &content); -*/ -private: - // noncopyable, nonassignable - MessageUtilities(MessageUtilities const&); - MessageUtilities& operator=(MessageUtilities const&); - -}; - -} - -} - - - - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -#endif diff --git a/src/jabber_whiteboard/message-verifier.h b/src/jabber_whiteboard/message-verifier.h deleted file mode 100644 index c7dca9958..000000000 --- a/src/jabber_whiteboard/message-verifier.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __INKSCAPE_WHITEBOARD_MESSAGE_VERIFIER_H__ -#define __INKSCAPE_WHITEBOARD_MESSAGE_VERIFIER_H__ - -/** - * Inkscape::Whiteboard::MessageVerifier -- performs basic XMPP-related - * validity checks on incoming messages - * - * Authors: - * David Yip <yipdw@alumni.rose-hulman.edu> - * - * Copyright (c) 2006 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -namespace Inkscape { - -namespace Whiteboard { - - /** - * The class has been written, but I forgot to commit that file to SVN, - * and the only other copy I have is on a computer that I do not currently - * have access to. So, for now, this is just a placeholder with enums - * to get things working. - */ - -enum MessageValidityTestResult { - RESULT_VALID, - RESULT_INVALID -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/node-tracker.cpp b/src/jabber_whiteboard/node-tracker.cpp deleted file mode 100644 index 286ab8216..000000000 --- a/src/jabber_whiteboard/node-tracker.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/** - * Whiteboard session manager - * XML node tracking facility - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "sp-object.h" -#include "sp-item-group.h" -#include "document.h" -#include "document-private.h" - -#include "xml/node.h" - -#include "util/compose.hpp" - -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/node-tracker.h" - - -// TODO: remove redundant calls to isTracking(); it's a rather unnecessary -// performance burden. -namespace Inkscape { - -namespace Whiteboard { - -// Lookup tables - -/** - * Keys for special nodes. - * - * A special node is a node that can only appear once in a document. - */ -char const* specialnodekeys[] = { - DOCUMENT_ROOT_NODE, - DOCUMENT_NAMEDVIEW_NODE, -}; - -/** - * Names of special nodes. - * - * A special node is a node that can only appear once in a document. - */ -char const* specialnodenames[] = { - DOCUMENT_ROOT_NAME, - DOCUMENT_NAMEDVIEW_NAME, -}; - -XMLNodeTracker::XMLNodeTracker(SessionManager* sm) : - _rootKey(DOCUMENT_ROOT_NODE), - _namedviewKey(DOCUMENT_NAMEDVIEW_NODE) -{ - _sm = sm; - init(); -} - -XMLNodeTracker::XMLNodeTracker() : - _rootKey(DOCUMENT_ROOT_NODE), - _namedviewKey(DOCUMENT_NAMEDVIEW_NODE) -{ - _sm = NULL; - init(); -} - -XMLNodeTracker::~XMLNodeTracker() -{ - _clear(); -} - - -void -XMLNodeTracker::init() -{ - _counter = 0; - - // Construct special node maps - createSpecialNodeTables(); - if (_sm) - reset(); -} - -void -XMLNodeTracker::setSessionManager(const SessionManager *val) -{ - _sm = (SessionManager *)val; - if (_sm) - reset(); -} - -void -XMLNodeTracker::put(const Glib::ustring &key, const XML::Node &nodeArg) -{ - keyNodeTable.put(key, &nodeArg); -} - - -void -XMLNodeTracker::process(const KeyToNodeActionList &actions) -{ - KeyToNodeActionList::const_iterator iter = actions.begin(); - for(; iter != actions.end(); iter++) { - // Get the action to perform. - SerializedEventNodeAction action = *iter; - switch(action.second) { - case NODE_ADD: - //g_log(NULL, G_LOG_LEVEL_DEBUG, - //"NODE_ADD event: key %s, node %p", - //action.first.first.c_str(), action.first.second); - put(action.first.key, *action.first.node); - break; - case NODE_REMOVE: - //g_log(NULL, G_LOG_LEVEL_DEBUG, - //"NODE_REMOVE event: key %s, node %p", - // action.first.first.c_str(), action.first.second); - //remove(const_cast< XML::Node& >(*action.first.second)); - break; - default: - break; - } - } -} - -XML::Node* -XMLNodeTracker::get(const Glib::ustring &key) -{ - XML::Node *node = keyNodeTable.get(key); - if (node) - return node; - - g_warning("Key %s is not being tracked!", key.c_str()); - return NULL; -} - -Glib::ustring -XMLNodeTracker::get(const XML::Node &nodeArg) -{ - Glib::ustring key = keyNodeTable.get((XML::Node *)&nodeArg); - return key; -} - -bool -XMLNodeTracker::isTracking(const Glib::ustring &key) -{ - return (get(key)!=NULL); -} - -bool -XMLNodeTracker::isTracking(const XML::Node &node) -{ - return (get(node).size()>0); -} - - -bool -XMLNodeTracker::isRootNode(const XML::Node &node) -{ - XML::Node* docroot = _sm->getDocument()->getReprRoot(); - return (docroot == &node); -} - - -void -XMLNodeTracker::remove(const Glib::ustring& key) -{ - g_log(NULL, G_LOG_LEVEL_DEBUG, "Removing node with key %s", key.c_str()); - keyNodeTable.remove(key); -} - -void -XMLNodeTracker::remove(const XML::Node &nodeArg) -{ - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Removing node %p", &node); - keyNodeTable.remove((XML::Node *)&nodeArg); -} - - -bool -XMLNodeTracker::isSpecialNode(const Glib::ustring &name) -{ - return (_specialnodes.find(name.data()) != _specialnodes.end()); -} - -Glib::ustring -XMLNodeTracker::getSpecialNodeKeyFromName(Glib::ustring const& name) -{ - return _specialnodes[name.data()]; -} - -Glib::ustring -XMLNodeTracker::generateKey(gchar const* JID) -{ - return String::compose("%1;%2", _counter++, JID); -} - -Glib::ustring -XMLNodeTracker::generateKey() -{ - std::bitset< NUM_FLAGS >& status = _sm->getStatus(); - Glib::ustring ret; - if (status[IN_CHATROOM]) { - // This is not strictly required for chatrooms: chatrooms will - // function just fine with the user-to-user ID scheme. However, - // the user-to-user scheme can lead to loss of anonymity - // in anonymous chat rooms, since it contains the real JID - // of a user. - /* - ret = String::compose("%1;%2@%3/%4", - _counter++, - _sm->getClient().getUsername(), - _sm->getClient().getHost(), - sd->chat_handle); - */ - //We need to work on this since Pedro allows multiple chatrooms - ret = String::compose("%1;%2", - _counter++, - _sm->getClient().getJid()); - } else { - ret = String::compose("%1;%2", - _counter++, - _sm->getClient().getJid()); - } - return ret; -} - -void -XMLNodeTracker::createSpecialNodeTables() -{ - int const sz = sizeof(specialnodekeys) / sizeof(char const*); - for(int i = 0; i < sz; i++) - _specialnodes[specialnodenames[i]] = specialnodekeys[i]; -} - - -// rather nasty and crufty debugging function -void -XMLNodeTracker::dump() -{ - g_log(NULL, G_LOG_LEVEL_DEBUG, "XMLNodeTracker dump for %s", - _sm->getClient().getJid().c_str()); - - - - g_log(NULL, G_LOG_LEVEL_DEBUG, "%u entries in keyNodeTable", - keyNodeTable.size()); - - g_log(NULL, G_LOG_LEVEL_DEBUG, "XMLNodeTracker keyNodeTable dump"); - for (unsigned int i=0 ; i<keyNodeTable.size() ; i++) - { - KeyNodePair pair = keyNodeTable.item(i); - Glib::ustring key = pair.key; - XML::Node *node = pair.node; - char *name = "none"; - char *content = "none"; - if (node) - { - name = (char *)node->name(); - content = (char *)node->content(); - } - g_log(NULL, G_LOG_LEVEL_DEBUG, "%s\t->\t%p (%s) (%s)", - key.c_str(), node, name, content); - } - - g_log(NULL, G_LOG_LEVEL_DEBUG, "_specialnodes dump"); - std::map< char const*, char const* >::iterator k = _specialnodes.begin(); - while(k != _specialnodes.end()) { - g_log(NULL, G_LOG_LEVEL_DEBUG, "%s\t->\t%s", (*k).first, (*k).second); - k++; - } -} - -void XMLNodeTracker::reset() -{ - _clear(); - - // Find and insert special nodes - // root node - put(_rootKey, *(_sm->getDocument()->getReprRoot())); - - // namedview node - SPObject* namedview = sp_item_group_get_child_by_name( - (SPGroup *)_sm->getDocument()->root, - NULL, DOCUMENT_NAMEDVIEW_NAME); - if (!namedview) { - g_warning("namedview node does not exist; it will be created during synchronization"); - } else { - put(_namedviewKey, *(namedview->getRepr())); - } -} - -void -XMLNodeTracker::_clear() -{ - // Remove all keys in both trackers, and delete each key. - keyNodeTable.clear(); -} - -} // namespace Whiteboard - -} // namespace Inkscape - - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/node-tracker.h b/src/jabber_whiteboard/node-tracker.h deleted file mode 100644 index 66814c5ca..000000000 --- a/src/jabber_whiteboard/node-tracker.h +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Whiteboard session manager - * XML node tracking facility - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_XML_NODE_TRACKER_H__ -#define __WHITEBOARD_XML_NODE_TRACKER_H__ - -#include "jabber_whiteboard/tracker-node.h" -#include "jabber_whiteboard/defines.h" - -#include <bitset> -#include <cstring> -#include <map> -#include <glibmm.h> - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; - -/** - * std::less-like functor for C-style strings. - */ -struct strcmpless : public std::binary_function< char const*, char const*, bool > -{ - bool operator()(char const* _x, char const* _y) const - { - return (strcmp(_x, _y) < 0); - } -}; - - -// TODO: This is a pretty heinous mess of methods that accept -// both pointers and references -- a lot of it has to do with -// XML::Node& in the node observer and XML::Node* elsewhere, -// although some of it (like Glib::ustring const& vs. -// Glib::ustring const*) is completely mea culpa. When possible -// it'd be good to thin this class out. - -/** - * XMLNodeTracker generates and watches unique IDs for XML::Nodes for use in - * document event serialization and deserialization. - * - * More specifically, it has three tasks: - * <ol> - * <li>Association XML::Nodes with string IDs, and vice versa.</li> - * <li>Facilitation of lookup of a string ID or XML::Node given the other key.</li> - * <li>Generation of new string IDs for XML::Nodes.</li> - * </ol> - * - * XML::Nodes are assigned an ID that follows one of two forms: - * <ol> - * <li>unsigned integer;user JID</li> - * <li>unsigned integer;chatroom@conference server/handle</li> - * </ol> - * - * Form 1 is used in user-to-user sessions; form 2 is used in chatroom sessions. - */ -class XMLNodeTracker { -public: - /** - * Constructor. - */ - XMLNodeTracker(); - - /** - * Constructor. - * - * \param sm The SessionManager with which an XMLNodeTracker instance is to be associated with. - */ - XMLNodeTracker(SessionManager* sm); - - virtual ~XMLNodeTracker(); - - void setSessionManager(const SessionManager *val); - - /** - * Insert a (key,node) pair into the tracker. - * - * \param key The key to associate with the node. - * \param node The node to associate with the key. - */ - void put(const Glib::ustring &key, const XML::Node &node); - - /** - * Process a list of node actions to add and remove nodes from the tracker. - * - * \param actions The action list to process. - */ - void process(const KeyToNodeActionList& actions); - - /** - * Retrieve an XML::Node given a key. - * - * \param key Reference to a const string key. - * \return Pointer to an XML::Node, or NULL if no associated node could be found. - */ - XML::Node* get(const Glib::ustring &key); - - /** - * Retrieve a string key given a reference to an XML::Node. - * - * \param node Reference to a const XML::Node. - * \return The associated string key, or an empty string if no associated key could be found. - */ - Glib::ustring get(const XML::Node &node); - - /** - * Remove an entry from the tracker based on key. - * - * \param The key of the entry to remove. - */ - void remove(const Glib::ustring& key); - - /** - * Remove an entry from the tracker based on XML::Node. - * - * \param A reference to the XML::Node associated with the entry to remove. - */ - void remove(const XML::Node& node); - - /** - * Return whether or not a (key,node) pair is being tracked, given a string key. - * - * \param The key associated with the pair to check. - * \return Whether or not the pair is being tracked. - */ - bool isTracking(const Glib::ustring &key); - - /** - * Return whether or not a (key,node) pair is being tracked, given a node. - * - * \param The node associated with the pair to check. - * \return Whether or not the pair is being tracked. - */ - bool isTracking(const XML::Node & node); - - /** - * Return whether or not a node identified by a given name is a special node. - * - * \see Inkscape::Whiteboard::specialnodekeys - * \see Inkscape::Whiteboard::specialnodenames - * - * \param The name associated with the node. - * \return Whether or not the node is a special node. - */ - bool isSpecialNode(Glib::ustring const& name); - - /** - * Retrieve the key of a special node given the name of a special node. - * - * \see Inkscape::Whiteboard::specialnodekeys - * \see Inkscape::Whiteboard::specialnodenames - * - * \param The name associated with the node. - * \return The key of the special node. - */ - Glib::ustring getSpecialNodeKeyFromName( - const Glib::ustring &name); - - /** - * Returns whether or not the given node is the root node of the SPDocument associated - * with an XMLNodeTracker's SessionManager. - * - * \param Reference to an XML::Node to test. - * \return Whether or not the given node is the document root node. - */ - bool isRootNode(const XML::Node& node); - - /** - * Generate a node key given a JID. - * - * \param The JID to use in the key. - * \return A node string key. - */ - Glib::ustring generateKey(gchar const* JID); - - /** - * Generate a node key given the JID specified in the SessionData structure associated - * with an XMLNodeTracker's SessionManager. - * - * \return A node string key. - */ - Glib::ustring generateKey(); - - // TODO: remove debugging function - void dump(); - void reset(); - -private: - //common code called by constructors - void init(); - - void createSpecialNodeTables(); - void _clear(); - - unsigned int _counter; - SessionManager* _sm; - - //KeyNodeTable keyNodeTable; - - std::map< char const*, char const*, strcmpless > _specialnodes; - - // Keys for special nodes - Glib::ustring _rootKey; - Glib::ustring _defsKey; - Glib::ustring _namedviewKey; - Glib::ustring _metadataKey; - - // noncopyable, nonassignable - XMLNodeTracker(XMLNodeTracker const&); - XMLNodeTracker& operator=(XMLNodeTracker const&); -}; - -} - -} - - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/node-utilities.cpp b/src/jabber_whiteboard/node-utilities.cpp deleted file mode 100644 index 06e19f825..000000000 --- a/src/jabber_whiteboard/node-utilities.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Whiteboard session manager - * XML node manipulation / retrieval utilities - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "util/shared-c-string-ptr.h" -#include "util/list.h" - -#include "xml/node-observer.h" -#include "xml/attribute-record.h" -#include "xml/repr.h" - -#include "jabber_whiteboard/defines.h" -#include "jabber_whiteboard/node-utilities.h" -#include "jabber_whiteboard/node-tracker.h" -//#include "jabber_whiteboard/node-observer.h" - -namespace Inkscape { - -namespace Whiteboard { - -/* -Inkscape::XML::Node* -NodeUtilities::lookupReprByValue(Inkscape::XML::Node* root, gchar const* key, Glib::ustring const* value) -{ - GQuark const quark = g_quark_from_string(key); - if (root == NULL) { - return NULL; - } - - Inkscape::Util::List<Inkscape::XML::AttributeRecord const> attrlist = root->attributeList(); - for( ; attrlist ; attrlist++) { - if ((attrlist->key == quark) && (strcmp(attrlist->value, value->data()) == 0)) { - return root; - } - } - Inkscape::XML::Node* result; - for ( Inkscape::XML::Node* child = root->firstChild() ; child != NULL ; child = child->next() ) { - result = NodeUtilities::lookupReprByValue(child, key, value); - if(result != NULL) { - return result; - } - } - - return NULL; -} -*/ - -Glib::ustring -NodeUtilities::nodeTypeToString(XML::Node const& node) -{ - switch(node.type()) { - case XML::DOCUMENT_NODE: - return NODETYPE_DOCUMENT_STR; - case XML::ELEMENT_NODE: - return NODETYPE_ELEMENT_STR; - case XML::TEXT_NODE: - return NODETYPE_TEXT_STR; - case XML::COMMENT_NODE: - default: - return NODETYPE_COMMENT_STR; - } -} - -XML::NodeType -NodeUtilities::stringToNodeType(Glib::ustring const& type) -{ - if (type == NODETYPE_DOCUMENT_STR) { - return XML::DOCUMENT_NODE; - } else if (type == NODETYPE_ELEMENT_STR) { - return XML::ELEMENT_NODE; - } else if (type == NODETYPE_TEXT_STR) { - return XML::TEXT_NODE; - } else { - return XML::COMMENT_NODE; - } -} - -Glib::ustring -NodeUtilities::findNodeID(XML::Node const& node, - XMLNodeTracker* tracker, - KeyNodeTable const& newnodes) -{ - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Attempting to locate id for %p", &node); - Glib::ustring key = newnodes.get((XML::Node *)&node); - if (key.size()>0) - return key; - - if (tracker->isTracking(node)) { - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Located id for %p (in tracker): %s", &node, tracker->get(node).c_str()); - return tracker->get(node); - } else { - //g_log(NULL, G_LOG_LEVEL_DEBUG, "Failed to locate id"); - return ""; - } -} - -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/node-utilities.h b/src/jabber_whiteboard/node-utilities.h deleted file mode 100644 index 8f8646328..000000000 --- a/src/jabber_whiteboard/node-utilities.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Whiteboard session manager - * XML node manipulation / retrieval utilities - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_NODE_UTILITIES_H__ -#define __WHITEBOARD_NODE_UTILITIES_H__ - -#include "jabber_whiteboard/defines.h" -#include "xml/node.h" -#include <glibmm.h> - -namespace Inkscape { - -namespace XML { - -class Node; - -} - -namespace Whiteboard { - -class XMLNodeTracker; - -class NodeUtilities { -public: - // Node utilities - //static Inkscape::XML::Node* lookupReprByValue(Inkscape::XML::Node* root, - // gchar const* key, Glib::ustring const* value); - static Glib::ustring nodeTypeToString(XML::Node const& node); - static XML::NodeType stringToNodeType(Glib::ustring const& type); - - // Node key search utility method - static Glib::ustring findNodeID(XML::Node const& node, - XMLNodeTracker* tracker, - KeyNodeTable const& newnodes); - -private: - // noncopyable, nonassignable - NodeUtilities(NodeUtilities const&); - NodeUtilities& operator=(NodeUtilities const&); -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/jabber_whiteboard/pedrogui.cpp b/src/jabber_whiteboard/pedrogui.cpp deleted file mode 100644 index 035fc5a2f..000000000 --- a/src/jabber_whiteboard/pedrogui.cpp +++ /dev/null @@ -1,2835 +0,0 @@ -/* - * Simple demo GUI for the Pedro mini-XMPP client. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "jabber_whiteboard/pedrogui.h" -#include "jabber_whiteboard/session-manager.h" - -#include <glibmm/i18n.h> - -#include <stdarg.h> - -namespace Pedro -{ - - - -//######################################################################### -//# I C O N S -//######################################################################### - -static const guint8 icon_available[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\37733" - "3\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\0" - "\0\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377" - "\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377" - "\0\377\0\0\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377" - "\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""3" - "33\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377" - "\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0\0\377" - "\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0\0\377" - "\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377" - "\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_away[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0""333\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0" - "\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\0\0\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\0\0\377\377\377\377\0\377\0\0\377\377\377\377" - "\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\0\0\377" - "\377\0\0\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\0\0" - "\0\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\377\0\0\377\377\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377" - "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377" - "\377\377\377\0\0\377\377\0\0\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377" - "\377\0\0\0\377\377\377\377\377\377\0\0\377\377\377\377\0\377\0\0\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377\377\0\0\377" - "\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0LLL\377333\377\0\0\0\377\0\0\0\377LLL\377\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0"}; - - -static const guint8 icon_chat[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377" - "\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377\377\377\0\37733" - "3\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377" - "fff\377\377\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377333\377" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377fff" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0" - "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""33" - "3\377\377\377\0\377fff\377\377\377\0\377\0\0\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377fff\377\0\0\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377" - "\0\377\377\377\0\377\377\377\0""333\377\0\0\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0\377" - "\0\0\0\377\377\377\377\0\377\377\377\0""333\377\0\0\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0LLL\377\0\0\0\377" - "\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\0\0\0\377\377\377" - "\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0LLL\377333" - "\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377" - "\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377333\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377" - "\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_dnd[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377" - "\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377\377\377\0\37733" - "3\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377" - "fff\377\377\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377333\377" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377fff" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\177\0\0\377\177\0\0\377" - "\177\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "333\377\377\377\0\377fff\377\377\377\0\377\177\0\0\377\377\0\0\377\377" - "\0\0\377\377\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377fff\377\177\0\0\377\377\377\377\377fff\377" - "\377\0\0\377fff\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377" - "\377\0\377\377\377\0""333\377\177\0\0\377\377\0\0\377fff\377\377\377" - "\377\377fff\377\377\377\377\377fff\377\377\0\0\377\177\0\0\377\377\377" - "\377\0\377\377\377\0""333\377\177\0\0\377\377\0\0\377\377\0\0\377fff" - "\377\377\377\377\377fff\377\377\0\0\377\377\0\0\377\177\0\0\377\377\377" - "\377\0\377\377\377\0LLL\377\177\0\0\377\377\0\0\377fff\377\377\377\377" - "\377fff\377\377\377\377\377fff\377\377\0\0\377\177\0\0\377\377\377\377" - "\0\377\377\377\0LLL\377333\377\177\0\0\377\377\377\377\377fff\377\377" - "\0\0\377fff\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0""333\377333\377\177\0\0\377\377\0\0\377" - "\377\0\0\377\377\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\177\0\0\377\177\0\0\377\177\0\0\377\377\377\377\0\377\377" - "\377\0\377\377\377\0"}; - - -static const guint8 icon_error[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0""333\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\377\0\0\0\0\377\350\350\350\377333\377\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\350\350\350\377fff\377\0\0\0\377\350\350\350\377\350\350\350\377333" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\350\350\350\377\350\350\350\377\350\350\350\377\0\0\0\377\350\350\350" - "\377\350\350\350\377\350\350\350\377333\377\377\377\377\0\377\377\377" - "\0\377\377\377\0""333\377\350\350\350\377\350\350\350\377\0\0\0\377\0" - "\0\0\377fff\377\350\350\350\377\350\350\350\377333\377\377\377\377\0" - "\377\377\377\0\377\377\377\0""333\377\350\350\350\377\350\350\350\377" - "\0\0\0\377\350\350\350\377\0\0\0\377\0\0\0\377\0\0\0\377333\377\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377\350\350\350\377\0\0\0\377" - "\350\350\350\377\0\0\0\377\350\350\350\377\350\350\350\377\350\350\350" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""3" - "33\377\350\350\350\377\0\0\0\377\0\0\0\377\0\0\0\377\350\350\350\377" - "fff\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\0\0\0\377\350\350\350\377\350\350\350\377\350\350\350" - "\377\0\0\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377\350\350\350\377\350\350\350" - "\377\350\350\350\377333\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0" - "\377\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0" - "\0\377\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_offline[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\377\377\377\377\377\377\377\377\377\377333\377\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377333\377\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377\377\377\377\377\377\377\377" - "\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377\377\377\377" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\377\377\377\377\377\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377" - "\377\377\377\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377" - "\0""333\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" - "\377\377\377\377\377\377\377\377\377\377\377\377333\377\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\377\377\377" - "\377\377\377\0\0\0\377\377\377\377\377\377\377\377\377333\377\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377\377\377\377\377" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0""333\377\377\377\377\377\377\377\377\377\377" - "\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0" - "\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377" - "\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_xa[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377333\377333\377" - "333\377\377\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\0\0\377333\377\377\377\0\377\377" - "\377\0\377\377\377\0\377333\377\377\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\0\0\377" - "\177\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0""333\377\377\0\0" - "\377\377\377\0\377fff\377\377\377\0\377\177\0\0\377\177\0\0\377\377\0" - "\0\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377\377\0""333\377" - "\377\0\0\377\177\0\0\377\177\0\0\377\177\0\0\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\0\0\0\377\0\0\0\377\177\0\0\377\177\0\0" - "\377\177\0\0\377\377\0\0\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\262\262\262\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377" - "\377\377\177\0\0\377\177\0\0\377\377\377\377\377\262\262\262\377\0\0" - "\0\377\262\262\262\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\262\262\262\377\0\0\0\377\177\0\0\377\177\0\0\377\377\377\377\377" - "\0\0\0\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\0\0\0" - "\377\0\0\0\377\377\377\377\377\0\0\0\377\177\0\0\377\177\0\0\377\377" - "\377\377\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377\0\0" - "\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\177" - "\0\0\377\377\377\377\0\177\0\0\377\262\262\262\377\0\0\0\377\262\262" - "\262\377\377\377\377\377\377\377\377\377\377\377\377\377\177\0\0\377" - "\177\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\177\0\0\377\377" - "\377\377\377\377\377\377\377\177\0\0\377\177\0\0\377\177\0\0\377\177" - "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\177\0\0\377\177\0\0\377\177\0\0\377333\377\0\0\0\377\0\0\0" - "\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377" - "333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0"}; - - -//######################################################################### -//# R O S T E R -//######################################################################### - - -void Roster::doubleClickCallback(const Gtk::TreeModel::Path &/*path*/, - Gtk::TreeViewColumn */*col*/) -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("Double clicked:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); - -} - -void Roster::chatCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("Chat with:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); -} - -void Roster::sendFileCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("Send file to:%s\n", nick.c_str()); - if (parent) - parent->doSendFile(nick); -} - -void Roster::shareCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("share to:%s\n", nick.c_str()); - if (parent) - parent->doShare(nick); -} - -bool Roster::buttonPressCallback(GdkEventButton* event) -{ - if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) - { - Gtk::Widget *wid = uiManager->get_widget("/PopupMenu"); - Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid); - popupMenu->popup(event->button, event->time); - return true; - } - else - return false; -} - -bool Roster::doSetup() -{ - set_size_request(200,200); - - pixbuf_available = Gdk::Pixbuf::create_from_inline( - sizeof(icon_available), icon_available, false); - pixbuf_away = Gdk::Pixbuf::create_from_inline( - sizeof(icon_away), icon_away, false); - pixbuf_chat = Gdk::Pixbuf::create_from_inline( - sizeof(icon_chat), icon_chat, false); - pixbuf_dnd = Gdk::Pixbuf::create_from_inline( - sizeof(icon_dnd), icon_dnd, false); - pixbuf_error = Gdk::Pixbuf::create_from_inline( - sizeof(icon_error), icon_error, false); - pixbuf_offline = Gdk::Pixbuf::create_from_inline( - sizeof(icon_offline), icon_offline, false); - pixbuf_xa = Gdk::Pixbuf::create_from_inline( - sizeof(icon_xa), icon_xa, false); - - rosterView.setParent(this); - treeStore = Gtk::TreeStore::create(rosterColumns); - rosterView.set_model(treeStore); - - Gtk::CellRendererText *rend0 = new Gtk::CellRendererText(); - //rend0->property_background() = "gray"; - //rend0->property_foreground() = "black"; - rosterView.append_column("Group", *rend0); - Gtk::TreeViewColumn *col0 = rosterView.get_column(0); - col0->add_attribute(*rend0, "text", 0); - - Gtk::CellRendererPixbuf *rend1 = new Gtk::CellRendererPixbuf(); - rosterView.append_column("Status", *rend1); - Gtk::TreeViewColumn *col1 = rosterView.get_column(1); - col1->add_attribute(*rend1, "pixbuf", 1); - - Gtk::CellRendererText *rend2 = new Gtk::CellRendererText(); - rosterView.append_column("Item", *rend2); - Gtk::TreeViewColumn *col2 = rosterView.get_column(2); - col2->add_attribute(*rend2, "text", 2); - - Gtk::CellRendererText *rend3 = new Gtk::CellRendererText(); - rosterView.append_column("Name", *rend3); - Gtk::TreeViewColumn *col3 = rosterView.get_column(3); - col3->add_attribute(*rend3, "text", 3); - - Gtk::CellRendererText *rend4 = new Gtk::CellRendererText(); - rosterView.append_column("Subscription", *rend4); - Gtk::TreeViewColumn *col4 = rosterView.get_column(4); - col4->add_attribute(*rend4, "text", 4); - - rosterView.signal_row_activated().connect( - sigc::mem_fun(*this, &Roster::doubleClickCallback) ); - - add(rosterView); - set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - //##### POPUP MENU - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - - actionGroup->add( Gtk::Action::create("UserMenu", "_User Menu") ); - - actionGroup->add( Gtk::Action::create("Chat", - Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &Roster::chatCallback) ); - actionGroup->add( Gtk::Action::create("SendFile", - Gtk::Stock::CONNECT, "Send file"), - sigc::mem_fun(*this, &Roster::sendFileCallback) ); - actionGroup->add( Gtk::Action::create("Share", - Gtk::Stock::CONNECT, "Share whiteboard"), - sigc::mem_fun(*this, &Roster::shareCallback) ); - - - uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - - Glib::ustring ui_info = - "<ui>" - " <popup name='PopupMenu'>" - " <menuitem action='Chat'/>" - " <menuitem action='SendFile'/>" - " <menuitem action='Share'/>" - " </popup>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - - - show_all_children(); - - return true; -} - - -/** - * Clear the roster - */ -void Roster::clear() -{ - treeStore->clear(); -} - -/** - * Regenerate the roster - */ -void Roster::refresh() -{ - if (!parent) - return; - treeStore->clear(); - std::vector<XmppUser> items = parent->client.getRoster(); - - //## Add in tree fashion - DOMString lastGroup = ""; - Gtk::TreeModel::Row row = *(treeStore->append()); - row[rosterColumns.groupColumn] = ""; - for (unsigned int i=0 ; i<items.size() ; i++) - { - XmppUser user = items[i]; - if (user.group != lastGroup) - { - if (lastGroup.size()>0) - row = *(treeStore->append()); - row[rosterColumns.groupColumn] = user.group; - lastGroup = user.group; - } - Glib::RefPtr<Gdk::Pixbuf> pb = pixbuf_offline; - if (user.show == "available") - pb = pixbuf_available; - else if (user.show == "away") - pb = pixbuf_away; - else if (user.show == "chat") - pb = pixbuf_chat; - else if (user.show == "dnd") - pb = pixbuf_dnd; - else if (user.show == "xa") - pb = pixbuf_xa; - else - { - //printf("Unknown show for %s:'%s'\n", user.c_str(), show.c_str()); - } - Gtk::TreeModel::Row childRow = *(treeStore->append(row.children())); - childRow[rosterColumns.statusColumn] = pb; - childRow[rosterColumns.userColumn] = user.jid; - childRow[rosterColumns.nameColumn] = user.nick; - childRow[rosterColumns.subColumn] = user.subscription; - } - rosterView.expand_all(); -} - -//######################################################################### -//# M E S S A G E L I S T -//######################################################################### - -bool MessageList::doSetup() -{ - set_size_request(400,200); - - messageListBuffer = Gtk::TextBuffer::create(); - messageList.set_buffer(messageListBuffer); - messageList.set_editable(false); - messageList.set_wrap_mode(Gtk::WRAP_WORD_CHAR); - - Glib::RefPtr<Gtk::TextBuffer::TagTable> table = - messageListBuffer->get_tag_table(); - Glib::RefPtr<Gtk::TextBuffer::Tag> color0 = - Gtk::TextBuffer::Tag::create("color0"); - color0->property_foreground() = "DarkGreen"; - color0->property_weight() = Pango::WEIGHT_BOLD; - table->add(color0); - Glib::RefPtr<Gtk::TextBuffer::Tag> color1 = - Gtk::TextBuffer::Tag::create("color1"); - color1->property_foreground() = "chocolate4"; - color1->property_weight() = Pango::WEIGHT_BOLD; - table->add(color1); - Glib::RefPtr<Gtk::TextBuffer::Tag> color2 = - Gtk::TextBuffer::Tag::create("color2"); - color2->property_foreground() = "red4"; - color2->property_weight() = Pango::WEIGHT_BOLD; - table->add(color2); - Glib::RefPtr<Gtk::TextBuffer::Tag> color3 = - Gtk::TextBuffer::Tag::create("color3"); - color3->property_foreground() = "MidnightBlue"; - color3->property_weight() = Pango::WEIGHT_BOLD; - table->add(color3); - Glib::RefPtr<Gtk::TextBuffer::Tag> color4 = - Gtk::TextBuffer::Tag::create("color4"); - color4->property_foreground() = "turquoise4"; - color4->property_weight() = Pango::WEIGHT_BOLD; - table->add(color4); - Glib::RefPtr<Gtk::TextBuffer::Tag> color5 = - Gtk::TextBuffer::Tag::create("color5"); - color5->property_foreground() = "OliveDrab"; - color5->property_weight() = Pango::WEIGHT_BOLD; - table->add(color5); - Glib::RefPtr<Gtk::TextBuffer::Tag> color6 = - Gtk::TextBuffer::Tag::create("color6"); - color6->property_foreground() = "purple4"; - color6->property_weight() = Pango::WEIGHT_BOLD; - table->add(color6); - Glib::RefPtr<Gtk::TextBuffer::Tag> color7 = - Gtk::TextBuffer::Tag::create("color7"); - color7->property_foreground() = "VioletRed4"; - color7->property_weight() = Pango::WEIGHT_BOLD; - table->add(color7); - - add(messageList); - set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - - show_all_children(); - - return true; -} - -/** - * Clear all messages from the list - */ -void MessageList::clear() -{ - messageListBuffer->erase(messageListBuffer->begin(), - messageListBuffer->end()); -} - - -/** - * Post a message to the list - */ -void MessageList::postMessage(const DOMString &from, const DOMString &msg) -{ - DOMString out = "<"; - out.append(from); - out.append("> "); - - int val = 0; - for (unsigned int i=0 ; i<from.size() ; i++) - val += from[i]; - val = val % 8; - - char buf[16]; - sprintf(buf, "color%d", val); - DOMString tagName = buf; - - messageListBuffer->insert_with_tag( - messageListBuffer->end(), out, tagName); - messageListBuffer->insert(messageListBuffer->end(), msg); - messageListBuffer->insert(messageListBuffer->end(), "\n"); - //Gtk::Adjustment *adj = get_vadjustment(); - //adj->set_value(adj->get_upper()-adj->get_page_size()); - Glib::RefPtr<Gtk::TextBuffer::Mark> mark = - messageListBuffer->create_mark("temp", messageListBuffer->end()); - messageList.scroll_mark_onscreen(mark); - messageListBuffer->delete_mark(mark); -} - - - -//######################################################################### -//# U S E R L I S T -//######################################################################### -void UserList::doubleClickCallback(const Gtk::TreeModel::Path &/*path*/, - Gtk::TreeViewColumn */*col*/) -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Double clicked:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); - -} - -void UserList::chatCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Chat with:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); -} - -void UserList::sendFileCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Send file to:%s\n", nick.c_str()); - if (parent) - parent->doSendFile(nick); -} - -void UserList::shareCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Send file to:%s\n", nick.c_str()); - if (parent) - parent->doShare(nick); -} - -bool UserList::buttonPressCallback(GdkEventButton* event) -{ - if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) - { - Gtk::Widget *wid = uiManager->get_widget("/PopupMenu"); - Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid); - popupMenu->popup(event->button, event->time); - return true; - } - else - return false; -} - -bool UserList::doSetup() -{ - set_size_request(200,200); - - setParent(NULL); - - pixbuf_available = Gdk::Pixbuf::create_from_inline( - sizeof(icon_available), icon_available, false); - pixbuf_away = Gdk::Pixbuf::create_from_inline( - sizeof(icon_away), icon_away, false); - pixbuf_chat = Gdk::Pixbuf::create_from_inline( - sizeof(icon_chat), icon_chat, false); - pixbuf_dnd = Gdk::Pixbuf::create_from_inline( - sizeof(icon_dnd), icon_dnd, false); - pixbuf_error = Gdk::Pixbuf::create_from_inline( - sizeof(icon_error), icon_error, false); - pixbuf_offline = Gdk::Pixbuf::create_from_inline( - sizeof(icon_offline), icon_offline, false); - pixbuf_xa = Gdk::Pixbuf::create_from_inline( - sizeof(icon_xa), icon_xa, false); - - userList.setParent(this); - userListStore = Gtk::ListStore::create(userListColumns); - userList.set_model(userListStore); - - Gtk::CellRendererPixbuf *rend0 = new Gtk::CellRendererPixbuf(); - userList.append_column("Status", *rend0); - Gtk::TreeViewColumn *col0 = userList.get_column(0); - col0->add_attribute(*rend0, "pixbuf", 0); - - Gtk::CellRendererText *rend1 = new Gtk::CellRendererText(); - //rend1->property_background() = "gray"; - //rend1->property_foreground() = "black"; - userList.append_column("User", *rend1); - Gtk::TreeViewColumn *col1 = userList.get_column(1); - col1->add_attribute(*rend1, "text", 1); - - userList.set_headers_visible(false); - - userList.signal_row_activated().connect( - sigc::mem_fun(*this, &UserList::doubleClickCallback) ); - - add(userList); - set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - //##### POPUP MENU - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - - actionGroup->add( Gtk::Action::create("UserMenu", "_User Menu") ); - - actionGroup->add( Gtk::Action::create("Chat", - Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &UserList::chatCallback) ); - actionGroup->add( Gtk::Action::create("SendFile", - Gtk::Stock::CONNECT, "Send file"), - sigc::mem_fun(*this, &UserList::sendFileCallback) ); - actionGroup->add( Gtk::Action::create("Share", - Gtk::Stock::CONNECT, "Share whiteboard"), - sigc::mem_fun(*this, &UserList::shareCallback) ); - - - uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - - Glib::ustring ui_info = - "<ui>" - " <popup name='PopupMenu'>" - " <menuitem action='Chat'/>" - " <menuitem action='SendFile'/>" - " <menuitem action='Share'/>" - " </popup>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - - show_all_children(); - - return true; -} - -/** - * Clear all messages from the list - */ -void UserList::clear() -{ - userListStore->clear(); -} - - -/** - * Add a user to the list - */ -void UserList::addUser(const DOMString &user, const DOMString &show) -{ - Glib::RefPtr<Gdk::Pixbuf> pb = pixbuf_offline; - if (show == "available") - pb = pixbuf_available; - else if (show == "away") - pb = pixbuf_away; - else if (show == "chat") - pb = pixbuf_chat; - else if (show == "dnd") - pb = pixbuf_dnd; - else if (show == "xa") - pb = pixbuf_xa; - else - { - //printf("Unknown show for %s:'%s'\n", user.c_str(), show.c_str()); - } - Gtk::TreeModel::Row row = *(userListStore->append()); - row[userListColumns.userColumn] = user; - row[userListColumns.statusColumn] = pb; -} - - - - -//######################################################################### -//# C H A T W I N D O W -//######################################################################### -ChatWindow::ChatWindow(PedroGui &par, const DOMString jidArg) - : parent(par) -{ - jid = jidArg; - doSetup(); -} - -ChatWindow::~ChatWindow() -{ -} - -void ChatWindow::leaveCallback() -{ - hide(); - parent.chatDelete(jid); -} - - -void ChatWindow::hideCallback() -{ - hide(); - parent.chatDelete(jid); -} - -void ChatWindow::shareCallback() -{ -// hide(); - parent.doShare(this->jid); -} - -void ChatWindow::textEnterCallback() -{ - DOMString str = inputTxt.get_text(); - if (str.size() > 0) - parent.client.message(jid, str); - inputTxt.set_text(""); - messageList.postMessage(parent.client.getJid(), str); -} - -bool ChatWindow::doSetup() -{ - DOMString title = "Private Chat - "; - title.append(jid); - set_title(title); - - set_size_request(500,300); - - signal_hide().connect( - sigc::mem_fun(*this, &ChatWindow::hideCallback) ); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Leave", Gtk::Stock::CANCEL), - sigc::mem_fun(*this, &ChatWindow::leaveCallback) ); - actionGroup->add( Gtk::Action::create("Share", Gtk::Stock::CONNECT, - "Share whiteboard"), sigc::mem_fun(*this, &ChatWindow::shareCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Leave'/>" - " <menuitem action='Share'/>" - " </menu>" - " </menubar>" - "</ui>"; - - add(vbox); - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - vbox.pack_end(vPaned); - - vPaned.add1(messageList); - vPaned.add2(inputTxt); - - inputTxt.signal_activate().connect( - sigc::mem_fun(*this, &ChatWindow::textEnterCallback) ); - - show_all_children(); - - return true; -} - -bool ChatWindow::postMessage(const DOMString &data) -{ - messageList.postMessage(jid, data); - return true; -} - -//######################################################################### -//# G R O U P C H A T W I N D O W -//######################################################################### - -GroupChatWindow::GroupChatWindow(PedroGui &par, - const DOMString &groupJidArg, - const DOMString &nickArg) - : parent(par) -{ - groupJid = groupJidArg; - nick = nickArg; - doSetup(); -} - -GroupChatWindow::~GroupChatWindow() -{ -} - - -void GroupChatWindow::leaveCallback() -{ - parent.client.groupChatLeave(groupJid, nick); - hide(); - parent.groupChatDelete(groupJid, nick); -} - -void GroupChatWindow::hideCallback() -{ - parent.client.groupChatLeave(groupJid, nick); - hide(); - parent.groupChatDelete(groupJid, nick); -} - -void GroupChatWindow::textEnterCallback() -{ - DOMString str = inputTxt.get_text(); - if (str.size() > 0) - parent.client.groupChatMessage(groupJid, str); - inputTxt.set_text(""); -} - -void GroupChatWindow::shareCallback() -{ - parent.doGroupShare(groupJid); -} - -bool GroupChatWindow::doSetup() -{ - DOMString title = "Group Chat - "; - title.append(groupJid); - set_title(title); - - userList.setParent(this); - - set_size_request(500,300); - - signal_hide().connect( - sigc::mem_fun(*this, &GroupChatWindow::hideCallback) ); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Leave", Gtk::Stock::CANCEL), - sigc::mem_fun(*this, &GroupChatWindow::leaveCallback) ); - actionGroup->add( Gtk::Action::create("Share", Gtk::Stock::CONNECT, "Share whiteboard"), - sigc::mem_fun(*this, &GroupChatWindow::shareCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Leave'/>" - " <menuitem action='Share'/>" - " </menu>" - " </menubar>" - "</ui>"; - - add(vbox); - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - vbox.pack_end(vPaned); - - vPaned.add1(hPaned); - vPaned.add2(inputTxt); - inputTxt.signal_activate().connect( - sigc::mem_fun(*this, &GroupChatWindow::textEnterCallback) ); - - - hPaned.add1(messageList); - hPaned.add2(userList); - - - show_all_children(); - - - return true; -} - -bool GroupChatWindow::receiveMessage(const DOMString &from, - const DOMString &data) -{ - messageList.postMessage(from, data); - return true; -} - -bool GroupChatWindow::receivePresence(const DOMString &fromNick, - bool presence, - const DOMString &show, - const DOMString &/*status*/) -{ - - DOMString presStr = ""; - presStr.append(fromNick); - if (!presence) - presStr.append(" left the group"); - else - { - if (show.size()<1) - presStr.append(" joined the group"); - else - { - presStr.append(" : "); - presStr.append(show); - } - } - - if (presStr != "xa") - messageList.postMessage("*", presStr); - - userList.clear(); - std::vector<XmppUser> memberList = - parent.client.groupChatGetUserList(groupJid); - for (unsigned int i=0 ; i<memberList.size() ; i++) - { - XmppUser user = memberList[i]; - userList.addUser(user.nick, user.show); - } - return true; -} - - -void GroupChatWindow::doChat(const DOMString &nick) -{ - printf("##Chat with %s\n", nick.c_str()); - DOMString fullJid = groupJid; - fullJid.append("/"); - fullJid.append(nick); - parent.doChat(fullJid); -} - -void GroupChatWindow::doSendFile(const DOMString &nick) -{ - printf("##Send file to %s\n", nick.c_str()); - DOMString fullJid = groupJid; - fullJid.append("/"); - fullJid.append(nick); - parent.doSendFile(fullJid); - -} - -void GroupChatWindow::doShare(const DOMString &nick) -{ - printf("##Share inkboard with %s\n", nick.c_str()); - DOMString fullJid = groupJid; - fullJid.append("/"); - fullJid.append(nick); - parent.doShare(fullJid); - -} - - -//######################################################################### -//# C O N F I G D I A L O G -//######################################################################### - - -void ConfigDialog::okCallback() -{ - Glib::ustring pass = passField.get_text(); - Glib::ustring newpass = newField.get_text(); - Glib::ustring confpass = confField.get_text(); - if ((pass.size() < 5 || pass.size() > 12 ) || - (newpass.size() < 5 || newpass.size() > 12 ) || - (confpass.size() < 5 || confpass.size()> 12 )) - { - Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else if (newpass != confpass) - { - Gtk::MessageDialog dlg(*this, "New password and confirmation do not match", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else - { - //response(Gtk::RESPONSE_OK); - hide(); - } -} - -void ConfigDialog::cancelCallback() -{ - //response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void ConfigDialog::on_response(int response_id) -{ - if (response_id == Gtk::RESPONSE_OK) - okCallback(); - else - cancelCallback(); -} - -bool ConfigDialog::doSetup() -{ - set_title("Change Password"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"), - sigc::mem_fun(*this, &ConfigDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &ConfigDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Change'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(3, 2); - get_vbox()->pack_start(table); - - passLabel.set_text("Current Password"); - table.attach(passLabel, 0, 1, 0, 1); - passField.set_visibility(false); - passField.set_text(parent.client.getPassword()); - table.attach(passField, 1, 2, 0, 1); - - newLabel.set_text("New Password"); - table.attach(newLabel, 0, 1, 1, 2); - newField.set_visibility(false); - table.attach(newField, 1, 2, 1, 2); - - confLabel.set_text("Confirm New Password"); - table.attach(confLabel, 0, 1, 2, 3); - confField.set_visibility(false); - confField.signal_activate().connect( - sigc::mem_fun(*this, &ConfigDialog::okCallback) ); - table.attach(confField, 1, 2, 2, 3); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - -//######################################################################### -//# P A S S W O R D D I A L O G -//######################################################################### - - -void PasswordDialog::okCallback() -{ - Glib::ustring pass = passField.get_text(); - Glib::ustring newpass = newField.get_text(); - Glib::ustring confpass = confField.get_text(); - if ((pass.size() < 5 || pass.size() > 12 ) || - (newpass.size() < 5 || newpass.size() > 12 ) || - (confpass.size() < 5 || confpass.size()> 12 )) - { - Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else if (newpass != confpass) - { - Gtk::MessageDialog dlg(*this, "New password and confirmation do not match", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else - { - //response(Gtk::RESPONSE_OK); - hide(); - } -} - -void PasswordDialog::cancelCallback() -{ - //response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void PasswordDialog::on_response(int response_id) -{ - if (response_id == Gtk::RESPONSE_OK) - okCallback(); - else - cancelCallback(); -} - -bool PasswordDialog::doSetup() -{ - set_title("Change Password"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"), - sigc::mem_fun(*this, &PasswordDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &PasswordDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Change'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(3, 2); - get_vbox()->pack_start(table); - - passLabel.set_text("Current Password"); - table.attach(passLabel, 0, 1, 0, 1); - passField.set_visibility(false); - passField.set_text(parent.client.getPassword()); - table.attach(passField, 1, 2, 0, 1); - - newLabel.set_text("New Password"); - table.attach(newLabel, 0, 1, 1, 2); - newField.set_visibility(false); - table.attach(newField, 1, 2, 1, 2); - - confLabel.set_text("Confirm New Password"); - table.attach(confLabel, 0, 1, 2, 3); - confField.set_visibility(false); - confField.signal_activate().connect( - sigc::mem_fun(*this, &PasswordDialog::okCallback) ); - table.attach(confField, 1, 2, 2, 3); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - -//######################################################################### -//# C H A T D I A L O G -//######################################################################### - - -void ChatDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void ChatDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -bool ChatDialog::doSetup() -{ - set_title("Chat with User"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Chat", Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &ChatDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &ChatDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Chat'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(2, 2); - get_vbox()->pack_start(table); - - userLabel.set_text("User"); - table.attach(userLabel, 0, 1, 0, 1); - //userField.set_text(""); - table.attach(userField, 1, 2, 0, 1); - - //userField.set_text(""); - table.attach(textField, 0, 2, 1, 2); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - -//######################################################################### -//# G R O U P C H A T D I A L O G -//######################################################################### - - -void GroupChatDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void GroupChatDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -bool GroupChatDialog::doSetup() -{ - set_title("Join Group Chat"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Join", Gtk::Stock::CONNECT, "Join Group"), - sigc::mem_fun(*this, &GroupChatDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &GroupChatDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Join'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(4, 2); - get_vbox()->pack_start(table); - - groupLabel.set_text("Group"); - table.attach(groupLabel, 0, 1, 0, 1); - groupField.set_text(parent.config.getMucGroup()); - table.attach(groupField, 1, 2, 0, 1); - - hostLabel.set_text("Host"); - table.attach(hostLabel, 0, 1, 1, 2); - hostField.set_text(parent.config.getMucHost()); - table.attach(hostField, 1, 2, 1, 2); - - nickLabel.set_text("Alt Name"); - table.attach(nickLabel, 0, 1, 2, 3); - nickField.set_text(parent.config.getMucNick()); - table.attach(nickField, 1, 2, 2, 3); - - passLabel.set_text("Password"); - table.attach(passLabel, 0, 1, 3, 4); - passField.set_visibility(false); - passField.set_text(parent.config.getMucPassword()); - table.attach(passField, 1, 2, 3, 4); - - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - - - - -//######################################################################### -//# C O N N E C T D I A L O G -//######################################################################### - - -void ConnectDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void ConnectDialog::saveCallback() -{ - Gtk::Entry txtField; - Gtk::Dialog dlg("Account name", *this, true, true); - dlg.get_vbox()->pack_start(txtField); - txtField.signal_activate().connect( - sigc::bind(sigc::mem_fun(dlg, &Gtk::Dialog::response), - Gtk::RESPONSE_OK )); - dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - dlg.show_all_children(); - int ret = dlg.run(); - if (ret != Gtk::RESPONSE_OK) - return; - - Glib::ustring name = txtField.get_text(); - if (name.size() < 1) - { - parent.error("Account name too short"); - return; - } - - if (parent.config.accountExists(name)) - { - parent.config.accountRemove(name); - } - - XmppAccount account; - account.setName(name); - account.setHost(getHost()); - account.setPort(getPort()); - account.setUsername(getUser()); - account.setPassword(getPass()); - parent.config.accountAdd(account); - - refresh(); - - parent.configSave(); -} - -void ConnectDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -void ConnectDialog::doubleClickCallback( - const Gtk::TreeModel::Path &/*path*/, - Gtk::TreeViewColumn */*col*/) -{ - Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString name = iter->get_value(accountColumns.nameColumn); - //printf("Double clicked:%s\n", name.c_str()); - XmppAccount account; - if (!parent.config.accountFind(name, account)) - return; - setHost(account.getHost()); - setPort(account.getPort()); - setUser(account.getUsername()); - setPass(account.getPassword()); - - response(Gtk::RESPONSE_OK); - hide(); -} - -void ConnectDialog::selectedCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString name = iter->get_value(accountColumns.nameColumn); - //printf("Single clicked:%s\n", name.c_str()); - XmppAccount account; - if (!parent.config.accountFind(name, account)) - return; - setHost(account.getHost()); - setPort(account.getPort()); - setUser(account.getUsername()); - setPass(account.getPassword()); -} - -void ConnectDialog::deleteCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString name = iter->get_value(accountColumns.nameColumn); - - parent.config.accountRemove(name); - refresh(); - parent.configSave(); - -} - - - -void ConnectDialog::buttonPressCallback(GdkEventButton* event) -{ - if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) - { - Gtk::Widget *wid = accountUiManager->get_widget("/PopupMenu"); - Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid); - popupMenu->popup(event->button, event->time); - } -} - - -bool ConnectDialog::doSetup() -{ - set_title("Connect"); - set_size_request(300,400); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Connect", - Gtk::Stock::CONNECT, "Connect"), - sigc::mem_fun(*this, &ConnectDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Save", - Gtk::Stock::CONNECT, "Save as account"), - sigc::mem_fun(*this, &ConnectDialog::saveCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", - Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &ConnectDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Connect'/>" - " <separator/>" - " <menuitem action='Save'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(6, 2); - get_vbox()->pack_start(table); - - parent.client.setHost("enter server name"); - parent.client.setPort(5222); - parent.client.setUsername(""); - parent.client.setPassword(""); - parent.client.setResource("inkscape"); - - hostLabel.set_text("Host"); - table.attach(hostLabel, 0, 1, 0, 1); - hostField.set_text(parent.client.getHost()); - table.attach(hostField, 1, 2, 0, 1); - - portLabel.set_text("Port"); - table.attach(portLabel, 0, 1, 1, 2); - portSpinner.set_digits(0); - portSpinner.set_range(1, 65000); - portSpinner.set_value(parent.client.getPort()); - table.attach(portSpinner, 1, 2, 1, 2); - - userLabel.set_text("Username"); - table.attach(userLabel, 0, 1, 2, 3); - userField.set_text(parent.client.getUsername()); - table.attach(userField, 1, 2, 2, 3); - - passLabel.set_text("Password"); - table.attach(passLabel, 0, 1, 3, 4); - passField.set_visibility(false); - passField.set_text(parent.client.getPassword()); - passField.signal_activate().connect( - sigc::mem_fun(*this, &ConnectDialog::okCallback) ); - table.attach(passField, 1, 2, 3, 4); - - resourceLabel.set_text("Resource"); - table.attach(resourceLabel, 0, 1, 4, 5); - resourceField.set_text(parent.client.getResource()); - table.attach(resourceField, 1, 2, 4, 5); - - registerLabel.set_text("Register"); - table.attach(registerLabel, 0, 1, 5, 6); - registerButton.set_active(false); - table.attach(registerButton, 1, 2, 5, 6); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - - //###################### - //# ACCOUNT LIST - //###################### - - - accountListStore = Gtk::ListStore::create(accountColumns); - accountView.set_model(accountListStore); - - accountView.signal_row_activated().connect( - sigc::mem_fun(*this, &ConnectDialog::doubleClickCallback) ); - - accountView.get_selection()->signal_changed().connect( - sigc::mem_fun(*this, &ConnectDialog::selectedCallback) ); - - accountView.append_column("Account", accountColumns.nameColumn); - accountView.append_column("Host", accountColumns.hostColumn); - - //accountView.signal_row_activated().connect( - // sigc::mem_fun(*this, &AccountDialog::connectCallback) ); - - accountScroll.add(accountView); - accountScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - get_vbox()->pack_start(accountScroll); - - //##### POPUP MENU - accountView.signal_button_press_event().connect_notify( - sigc::mem_fun(*this, &ConnectDialog::buttonPressCallback) ); - - Glib::RefPtr<Gtk::ActionGroup> accountActionGroup = - Gtk::ActionGroup::create(); - - accountActionGroup->add( Gtk::Action::create("PopupMenu", "_Account") ); - - accountActionGroup->add( Gtk::Action::create("Delete", - Gtk::Stock::DELETE, "Delete"), - sigc::mem_fun(*this, &ConnectDialog::deleteCallback) ); - - - accountUiManager = Gtk::UIManager::create(); - - accountUiManager->insert_action_group(accountActionGroup, 0); - - Glib::ustring account_ui_info = - "<ui>" - " <popup name='PopupMenu'>" - " <menuitem action='Delete'/>" - " </popup>" - "</ui>"; - - accountUiManager->add_ui_from_string(account_ui_info); - //Gtk::Widget* accountMenuBar = uiManager->get_widget("/PopupMenu"); - //get_vbox()->pack_start(*accountMenuBar, Gtk::PACK_SHRINK); - - refresh(); - - show_all_children(); - - return true; -} - - -/** - * Regenerate the account list - */ -void ConnectDialog::refresh() -{ - accountListStore->clear(); - - std::vector<XmppAccount> accounts = parent.config.getAccounts(); - for (unsigned int i=0 ; i<accounts.size() ; i++) - { - XmppAccount account = accounts[i]; - Gtk::TreeModel::Row row = *(accountListStore->append()); - row[accountColumns.nameColumn] = account.getName(); - row[accountColumns.hostColumn] = account.getHost(); - } - accountView.expand_all(); -} - - - -//######################################################################### -//# F I L E S E N D D I A L O G -//######################################################################### - - -void FileSendDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void FileSendDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -void FileSendDialog::buttonCallback() -{ - Gtk::FileChooserDialog dlg("Select a file to send", - Gtk::FILE_CHOOSER_ACTION_OPEN); - dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT) - { - fileName = dlg.get_filename(); - fileNameField.set_text(fileName); - } -} - -bool FileSendDialog::doSetup() -{ - set_title("Send file to user"); - set_size_request(400,150); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"), - sigc::mem_fun(*this, &FileSendDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &FileSendDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Send'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(2, 2); - get_vbox()->pack_start(table); - - jidLabel.set_text("User ID"); - table.attach(jidLabel, 0, 1, 0, 1); - jidField.set_text("inkscape"); - table.attach(jidField, 1, 2, 0, 1); - - selectFileButton.set_label("Select"); - selectFileButton.signal_clicked().connect( - sigc::mem_fun(*this, &FileSendDialog::buttonCallback) ); - table.attach(selectFileButton, 0, 1, 1, 2); - - fileName = ""; - fileNameField.set_text("No file selected"); - fileNameField.set_editable(false); - table.attach(fileNameField, 1, 2, 1, 2); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - - -//######################################################################### -//# F I L E R E C E I V E D I A L O G -//######################################################################### - - -void FileReceiveDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void FileReceiveDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void FileReceiveDialog::buttonCallback() -{ - Gtk::FileChooserDialog dlg("Select a file to save", - Gtk::FILE_CHOOSER_ACTION_SAVE); - dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT) - { - fileName = dlg.get_filename(); - fileNameField.set_text(fileName); - } -} - - -bool FileReceiveDialog::doSetup() -{ - set_title("File being sent by user"); - set_size_request(450,250); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"), - sigc::mem_fun(*this, &FileReceiveDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &FileReceiveDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Send'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(6, 2); - get_vbox()->pack_start(table); - - jidLabel.set_text("User ID"); - table.attach(jidLabel, 0, 1, 0, 1); - jidField.set_text(jid); - jidField.set_editable(false); - table.attach(jidField, 1, 2, 0, 1); - - offeredLabel.set_text("File Offered"); - table.attach(offeredLabel, 0, 1, 1, 2); - offeredField.set_text(offeredName); - offeredField.set_editable(false); - table.attach(offeredField, 1, 2, 1, 2); - - descLabel.set_text("Description"); - table.attach(descLabel, 0, 1, 2, 3); - descField.set_text(desc); - descField.set_editable(false); - table.attach(descField, 1, 2, 2, 3); - - char buf[32]; - snprintf(buf, 31, "%ld", fileSize); - sizeLabel.set_text("Size"); - table.attach(sizeLabel, 0, 1, 3, 4); - sizeField.set_text(buf); - sizeField.set_editable(false); - table.attach(sizeField, 1, 2, 3, 4); - - hashLabel.set_text("MD5 Hash"); - table.attach(hashLabel, 0, 1, 4, 5); - hashField.set_text(hash); - hashField.set_editable(false); - table.attach(hashField, 1, 2, 4, 5); - - selectFileButton.set_label("Select"); - selectFileButton.signal_clicked().connect( - sigc::mem_fun(*this, &FileReceiveDialog::buttonCallback) ); - table.attach(selectFileButton, 0, 1, 5, 6); - - fileName = ""; - fileNameField.set_text("No file selected"); - fileNameField.set_editable(false); - table.attach(fileNameField, 1, 2, 5, 6); - - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - - -//######################################################################### -//# M A I N W I N D O W -//######################################################################### - -PedroGui::PedroGui() -{ - doSetup(); -} - -PedroGui::~PedroGui() -{ - chatDeleteAll(); - groupChatDeleteAll(); -} - - -void PedroGui::error(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - gchar * buffer = g_strdup_vprintf(fmt, args); - va_end(args) ; - - Gtk::MessageDialog dlg(buffer, - false, - Gtk::MESSAGE_ERROR, - Gtk::BUTTONS_OK, - true); - dlg.run(); - g_free(buffer); -} - -void PedroGui::status(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - gchar * buffer = g_strdup_vprintf(fmt, args); - va_end(args) ; - messageList.postMessage("STATUS", buffer); - g_free(buffer); -} - -//################################ -//# CHAT WINDOW MANAGEMENT -//################################ -bool PedroGui::chatCreate(const DOMString &userJid) -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; iter++) - { - if (userJid == (*iter)->getJid()) - return false; - } - ChatWindow *chat = new ChatWindow(*this, userJid); - chat->show(); - chats.push_back(chat); - return true; -} - -bool PedroGui::chatDelete(const DOMString &userJid) -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; ) - { - if (userJid == (*iter)->getJid()) - { - delete(*iter); - iter = chats.erase(iter); - } - else - iter++; - } - return true; -} - -bool PedroGui::chatDeleteAll() -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; ) - { - delete(*iter); - iter = chats.erase(iter); - } - return true; -} - -bool PedroGui::chatMessage(const DOMString &from, const DOMString &data) -{ - if(data.size() > 0) - { - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; iter++) - { - if (from == (*iter)->getJid()) - { - (*iter)->postMessage(data); - return true; - } - } - ChatWindow *chat = new ChatWindow(*this, from); - chat->show(); - chats.push_back(chat); - chat->postMessage(data); - } - return true; -} - - -//################################ -//# GROUP CHAT WINDOW MANAGEMENT -//################################ - -bool PedroGui::groupChatCreate(const DOMString &groupJid, const DOMString &nick) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++) - { - if (groupJid == (*iter)->getGroupJid()) - return false; - } - GroupChatWindow *chat = new GroupChatWindow(*this, groupJid, nick); - chat->show(); - groupChats.push_back(chat); - return true; -} - - -bool PedroGui::groupChatDelete(const DOMString &groupJid, const DOMString &nick) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ;) - { - if (groupJid == (*iter)->getGroupJid() && - nick == (*iter)->getNick()) - { - delete(*iter); - iter = groupChats.erase(iter); - } - else - iter++; - } - return true; -} - - -bool PedroGui::groupChatDeleteAll() -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; ) - { - delete(*iter); - iter = groupChats.erase(iter); - } - return true; -} - - -bool PedroGui::groupChatMessage(const DOMString &groupJid, - const DOMString &from, const DOMString &data) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++) - { - if (groupJid == (*iter)->getGroupJid()) - { - (*iter)->receiveMessage(from, data); - } - } - return true; -} - -bool PedroGui::groupChatPresence(const DOMString &groupJid, - const DOMString &nick, bool presence, - const DOMString &show, - const DOMString &status) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++) - { - if (groupJid == (*iter)->getGroupJid()) - { - (*iter)->receivePresence(nick, presence, show, status); - } - } - return true; -} - -//################################ -//# EVENTS -//################################ - -/** - * - */ -void PedroGui::padlockEnable() -{ - padlockIcon.set(Gtk::Stock::DIALOG_AUTHENTICATION, - Gtk::ICON_SIZE_MENU); -} - -/** - * - */ -void PedroGui::padlockDisable() -{ - padlockIcon.clear(); -} - - -/** - * - */ -void PedroGui::handleConnectEvent() -{ - status("##### CONNECTED"); - actionEnable("Connect", false); - actionEnable("Chat", true); - actionEnable("GroupChat", true); - actionEnable("Disconnect", true); - actionEnable("RegPass", true); - actionEnable("RegCancel", true); - DOMString title = "Pedro - "; - title.append(client.getJid()); - set_title(title); -} - - -/** - * - */ -void PedroGui::handleDisconnectEvent() -{ - status("##### DISCONNECTED"); - actionEnable("Connect", true); - actionEnable("Chat", false); - actionEnable("GroupChat", false); - actionEnable("Disconnect", false); - actionEnable("RegPass", false); - actionEnable("RegCancel", false); - padlockDisable(); - DOMString title = "Pedro"; - set_title(title); - chatDeleteAll(); - groupChatDeleteAll(); - roster.clear(); -} - - -/** - * - */ -void PedroGui::doEvent(const XmppEvent &event) -{ - - int typ = event.getType(); - switch (typ) - { - case XmppEvent::EVENT_STATUS: - { - //printf("##### STATUS: %s\n", event.getData().c_str()); - status("%s", event.getData().c_str()); - break; - } - case XmppEvent::EVENT_ERROR: - { - //printf("##### ERROR: %s\n", event.getData().c_str()); - error("%s", event.getData().c_str()); - padlockDisable(); - break; - } - case XmppEvent::EVENT_SSL_STARTED: - { - padlockEnable(); - break; - } - case XmppEvent::EVENT_CONNECTED: - { - handleConnectEvent(); - break; - } - case XmppEvent::EVENT_DISCONNECTED: - { - handleDisconnectEvent(); - break; - } - case XmppEvent::EVENT_MESSAGE: - { - status("##### MESSAGE: %s\n", event.getFrom().c_str()); - chatMessage(event.getFrom(), event.getData()); - break; - } - case XmppEvent::EVENT_PRESENCE: - { - status("##### PRESENCE: %s\n", event.getFrom().c_str()); - roster.refresh(); - break; - } - case XmppEvent::EVENT_ROSTER: - { - status("##### ROSTER\n"); - roster.refresh(); - break; - } - case XmppEvent::EVENT_MUC_JOIN: - { - status("##### GROUP JOINED: %s\n", event.getGroup().c_str()); - break; - } - case XmppEvent::EVENT_MUC_MESSAGE: - { - //printf("##### MUC_MESSAGE: %s\n", event.getGroup().c_str()); - groupChatMessage(event.getGroup(), - event.getFrom(), event.getData()); - break; - } - case XmppEvent::EVENT_MUC_PRESENCE: - { - //printf("##### MUC_USER LIST: %s\n", event.getFrom().c_str()); - groupChatPresence(event.getGroup(), - event.getFrom(), - event.getPresence(), - event.getShow(), - event.getStatus()); - break; - } - case XmppEvent::EVENT_MUC_LEAVE: - { - status("##### GROUP LEFT: %s\n", event.getGroup().c_str()); - groupChatDelete(event.getGroup(), event.getFrom()); - break; - } - case XmppEvent::EVENT_FILE_RECEIVE: - { - status("##### FILE RECEIVE: %s\n", event.getFileName().c_str()); - doReceiveFile(event.getFrom(), event.getIqId(), event.getStreamId(), - event.getFileName(), event.getFileDesc(), - event.getFileSize(), event.getFileHash()); - break; - } - case XmppEvent::EVENT_REGISTRATION_NEW: - { - status("##### REGISTERED: %s at %s\n", - event.getTo().c_str(), event.getFrom().c_str()); - break; - } - case XmppEvent::EVENT_REGISTRATION_CHANGE_PASS: - { - status("##### PASSWORD CHANGED: %s at %s\n", - event.getTo().c_str(), event.getFrom().c_str()); - break; - } - case XmppEvent::EVENT_REGISTRATION_CANCEL: - { - //client.disconnect(); - status("##### REGISTERATION CANCELLED: %s at %s\n", - event.getTo().c_str(), event.getFrom().c_str()); - break; - } - default: - { - printf("unknown event type: %d\n", typ); - break; - } - } - -} - -/** - * - */ -bool PedroGui::checkEventQueue() -{ - while (client.eventQueueAvailable() > 0) - { - XmppEvent evt = client.eventQueuePop(); - doEvent(evt); - } - - while( Gtk::Main::events_pending() ) - Gtk::Main::iteration(); - - return true; -} - - -//################## -//# COMMANDS -//################## -void PedroGui::doChat(const DOMString &jid) -{ - if (jid.size()>0) - { - chatCreate(jid); - return; - } - - FileSendDialog dlg(*this); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - chatCreate(dlg.getJid()); - } - -} - -void PedroGui::doSendFile(const DOMString &jid) -{ - FileSendDialog dlg(*this); - if (jid.size()>0) - dlg.setJid(jid); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - DOMString fileName = dlg.getFileName(); - printf("fileName:%s\n", fileName.c_str()); - DOMString offeredName = ""; - DOMString desc = ""; - client.fileSendBackground(jid, offeredName, fileName, desc); - } - -} - -void PedroGui::doReceiveFile( - const DOMString &jid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &offeredName, - const DOMString &desc, - long size, - const DOMString &hash - ) - -{ - FileReceiveDialog dlg(*this, jid, iqId, streamId, - offeredName, desc, size, hash); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - DOMString fileName = dlg.getFileName(); - printf("fileName:%s\n", fileName.c_str()); - client.fileReceiveBackground(jid, iqId, streamId, fileName, size, hash); - } - -} - -void PedroGui::doShare(const DOMString &jid) -{ - Inkscape::Whiteboard::SessionManager& sm = - Inkscape::Whiteboard::SessionManager::instance(); - sm.initialiseSession(jid, Inkscape::Whiteboard::State::WHITEBOARD_PEER); -} - -void PedroGui::doGroupShare(const DOMString &groupJid) -{ - Inkscape::Whiteboard::SessionManager& sm = - Inkscape::Whiteboard::SessionManager::instance(); - sm.initialiseSession(groupJid, Inkscape::Whiteboard::State::WHITEBOARD_MUC); -} - -//################## -//# CALLBACKS -//################## -void PedroGui::connectCallback() -{ - ConnectDialog dialog(*this); - int result = dialog.run(); - dialog.hide(); - if (result == Gtk::RESPONSE_OK) - { - client.setHost(dialog.getHost()); - client.setPort(dialog.getPort()); - client.setUsername(dialog.getUser()); - client.setPassword(dialog.getPass()); - client.setResource(dialog.getResource()); - client.setDoRegister(dialog.getRegister()); - client.connect(); - } -} - - - -void PedroGui::chatCallback() -{ - ChatDialog dialog(*this); - int result = dialog.run(); - dialog.hide(); - if (result == Gtk::RESPONSE_OK) - { - client.message(dialog.getUser(), dialog.getText()); - } -} - - - -void PedroGui::groupChatCallback() -{ - GroupChatDialog dialog(*this); - int result = dialog.run(); - dialog.hide(); - if (result != Gtk::RESPONSE_OK) - return; - DOMString groupJid = dialog.getGroup(); - groupJid.append("@"); - groupJid.append(dialog.getHost()); - if (client.groupChatExists(groupJid)) - { - error("Group chat %s already exists", groupJid.c_str()); - return; - } - groupChatCreate(groupJid, dialog.getNick()); - client.groupChatJoin(groupJid, dialog.getNick(), dialog.getPass() ); - config.setMucGroup(dialog.getGroup()); - config.setMucHost(dialog.getHost()); - config.setMucNick(dialog.getNick()); - config.setMucPassword(dialog.getPass()); - - configSave(); -} - - -void PedroGui::disconnectCallback() -{ - client.disconnect(); -} - - -void PedroGui::quitCallback() -{ - client.disconnect(); - hide(); - //Severe overkill! :-) - //Gtk::Main::quit(); -} - - -void PedroGui::fontCallback() -{ - Gtk::FontSelectionDialog dlg; - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - Glib::ustring fontName = dlg.get_font_name(); - Pango::FontDescription fontDesc(fontName); - modify_font(fontDesc); - } -} - -void PedroGui::colorCallback() -{ - Gtk::ColorSelectionDialog dlg; - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - Gdk::Color col = dlg.get_colorsel()->get_current_color(); - modify_bg(Gtk::STATE_NORMAL, col); - } -} - -void PedroGui::regPassCallback() -{ - PasswordDialog dlg(*this); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - DOMString newpass = dlg.getNewPass(); - client.inBandRegistrationChangePassword(newpass); - } -} - - -void PedroGui::regCancelCallback() -{ - Gtk::MessageDialog dlg(*this, "Do you want to cancel your registration on the server?", - false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_YES) - { - client.inBandRegistrationCancel(); - } -} - - - -void PedroGui::sendFileCallback() -{ - doSendFile(""); -} - - - -void PedroGui::aboutCallback() -{ - Gtk::AboutDialog dlg; - dlg.set_name("Inkboard"); - std::vector<Glib::ustring>authors; - authors.push_back("David Yip <yipdw@rose-hulman.edu>"); - authors.push_back("Dale Harvey <harveyd@gmail.com>"); - dlg.set_authors(authors); - DOMString comments = _("Shared SVG whiteboard tool."); - comments.append(_("Based on the Pedro XMPP client")); - dlg.set_comments(comments); - dlg.set_version("1.0"); - dlg.run(); -} - - - -void PedroGui::actionEnable(const DOMString &name, bool val) -{ - DOMString path = "/ui/MenuBar/"; - path.append(name); - Glib::RefPtr<Gtk::Action> action = uiManager->get_action(path); - if (!action) - { - path = "/ui/MenuBar/MenuFile/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuEdit/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuRegister/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuTransfer/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuHelp/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - return; - action->set_sensitive(val); -} - - -bool PedroGui::configLoad() -{ - if (!config.readFile("pedro.ini")) - return false; - return true; -} - - -bool PedroGui::configSave() -{ - if (!config.writeFile("pedro.ini")) - return false; - return true; -} - - - - -bool PedroGui::doSetup() -{ - configLoad(); - - set_title("Pedro XMPP Client"); - set_size_request(500, 300); - add(mainBox); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - - //### FILE MENU - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - - actionGroup->add( Gtk::Action::create("Connect", - Gtk::Stock::CONNECT, "Connect"), - sigc::mem_fun(*this, &PedroGui::connectCallback) ); - - actionGroup->add( Gtk::Action::create("Chat", - Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &PedroGui::chatCallback) ); - - actionGroup->add( Gtk::Action::create("GroupChat", - Gtk::Stock::CONNECT, "Group Chat"), - sigc::mem_fun(*this, &PedroGui::groupChatCallback) ); - - actionGroup->add( Gtk::Action::create("Disconnect", - Gtk::Stock::DISCONNECT, "Disconnect"), - sigc::mem_fun(*this, &PedroGui::disconnectCallback) ); - - actionGroup->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT), - sigc::mem_fun(*this, &PedroGui::quitCallback) ); - - //### EDIT MENU - actionGroup->add( Gtk::Action::create("MenuEdit", "_Edit") ); - actionGroup->add( Gtk::Action::create("SelectFont", - Gtk::Stock::SELECT_FONT, "Select Font"), - sigc::mem_fun(*this, &PedroGui::fontCallback) ); - actionGroup->add( Gtk::Action::create("SelectColor", - Gtk::Stock::SELECT_COLOR, "Select Color"), - sigc::mem_fun(*this, &PedroGui::colorCallback) ); - - //### REGISTER MENU - actionGroup->add( Gtk::Action::create("MenuRegister", "_Registration") ); - actionGroup->add( Gtk::Action::create("RegPass", - Gtk::Stock::DIALOG_AUTHENTICATION, "Change Password"), - sigc::mem_fun(*this, &PedroGui::regPassCallback) ); - actionGroup->add( Gtk::Action::create("RegCancel", - Gtk::Stock::CANCEL, "Cancel Registration"), - sigc::mem_fun(*this, &PedroGui::regCancelCallback) ); - - //### TRANSFER MENU - actionGroup->add( Gtk::Action::create("MenuTransfer", "_Transfer") ); - actionGroup->add( Gtk::Action::create("SendFile", - Gtk::Stock::NETWORK, "Send File"), - sigc::mem_fun(*this, &PedroGui::sendFileCallback) ); - - //### HELP MENU - actionGroup->add( Gtk::Action::create("MenuHelp", "_Help") ); - actionGroup->add( Gtk::Action::create("About", - Gtk::Stock::ABOUT, "About Pedro"), - sigc::mem_fun(*this, &PedroGui::aboutCallback) ); - - uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Connect'/>" - " <separator/>" - " <menuitem action='Chat'/>" - " <menuitem action='GroupChat'/>" - " <separator/>" - " <menuitem action='Disconnect'/>" - " <menuitem action='Quit'/>" - " </menu>" - " <menu action='MenuEdit'>" - " <menuitem action='SelectFont'/>" - " <menuitem action='SelectColor'/>" - " </menu>" - " <menu action='MenuRegister'>" - " <menuitem action='RegPass'/>" - " <menuitem action='RegCancel'/>" - " </menu>" - " <menu action='MenuTransfer'>" - " <menuitem action='SendFile'/>" - " </menu>" - " <menu action='MenuHelp'>" - " <menuitem action='About'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - menuBarBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - padlockDisable(); - menuBarBox.pack_end(padlockIcon, Gtk::PACK_SHRINK); - - mainBox.pack_start(menuBarBox, Gtk::PACK_SHRINK); - - actionEnable("Connect", true); - actionEnable("Chat", false); - actionEnable("GroupChat", false); - actionEnable("Disconnect", false); - actionEnable("RegPass", false); - actionEnable("RegCancel", false); - - mainBox.pack_start(vPaned); - vPaned.add1(roster); - vPaned.add2(messageList); - roster.setParent(this); - - show_all_children(); - - //# Start a timer to check the queue every nn milliseconds - Glib::signal_timeout().connect( - sigc::mem_fun(*this, &PedroGui::checkEventQueue), 20 ); - - //client.addXmppEventListener(*this); - client.eventQueueEnable(true); - - return true; -} - - -} // namespace Pedro - - - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/jabber_whiteboard/pedrogui.h b/src/jabber_whiteboard/pedrogui.h deleted file mode 100644 index f4ebb4544..000000000 --- a/src/jabber_whiteboard/pedrogui.h +++ /dev/null @@ -1,914 +0,0 @@ -#ifndef __PEDROGUI_H__ -#define __PEDROGUI_H__ -/* - * Simple demo GUI for the Pedro mini-XMPP client. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include <gtkmm.h> -#include "ui/widget/spinbutton.h" - -#include "pedro/pedroxmpp.h" -#include "pedro/pedroconfig.h" - - -namespace Pedro -{ - - -class PedroGui; -class GroupChatWindow; - -//######################################################################### -//# R O S T E R -//######################################################################### -class Roster : public Gtk::ScrolledWindow -{ -public: - - Roster() - { doSetup(); } - - virtual ~Roster() - {} - - /** - * Clear all roster items from the list - */ - virtual void clear(); - - /** - * Regenerate the roster - */ - virtual void refresh(); - - - void setParent(PedroGui *val) - { parent = val; } - -private: - - class CustomTreeView : public Gtk::TreeView - { - public: - CustomTreeView() - { parent = NULL; } - virtual ~CustomTreeView() - {} - - bool on_button_press_event(GdkEventButton* event) - { - Gtk::TreeView::on_button_press_event(event); - if (parent) - parent->buttonPressCallback(event); - return true; - } - void setParent(Roster *val) - { parent = val; } - - private: - Roster *parent; - }; - - void doubleClickCallback(const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - - void sendFileCallback(); - void chatCallback(); - void shareCallback(); - bool buttonPressCallback(GdkEventButton* event); - - bool doSetup(); - - Glib::RefPtr<Gdk::Pixbuf> pixbuf_available; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_away; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_chat; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_dnd; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_error; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_offline; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_xa; - - class RosterColumns : public Gtk::TreeModel::ColumnRecord - { - public: - RosterColumns() - { - add(groupColumn); - add(statusColumn); add(userColumn); - add(nameColumn); add(subColumn); - } - - Gtk::TreeModelColumn<Glib::ustring> groupColumn; - Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > statusColumn; - Gtk::TreeModelColumn<Glib::ustring> userColumn; - Gtk::TreeModelColumn<Glib::ustring> nameColumn; - Gtk::TreeModelColumn<Glib::ustring> subColumn; - }; - - RosterColumns rosterColumns; - - Glib::RefPtr<Gtk::UIManager> uiManager; - - Glib::RefPtr<Gtk::TreeStore> treeStore; - CustomTreeView rosterView; - - PedroGui *parent; -}; - -//######################################################################### -//# M E S S A G E L I S T -//######################################################################### -class MessageList : public Gtk::ScrolledWindow -{ -public: - - MessageList() - { doSetup(); } - - virtual ~MessageList() - {} - - /** - * Clear all messages from the list - */ - virtual void clear(); - - /** - * Post a message to the list - */ - virtual void postMessage(const DOMString &from, const DOMString &msg); - -private: - - bool doSetup(); - - Gtk::TextView messageList; - Glib::RefPtr<Gtk::TextBuffer> messageListBuffer; - -}; - -//######################################################################### -//# U S E R L I S T -//######################################################################### -class UserList : public Gtk::ScrolledWindow -{ -public: - - UserList() - { doSetup(); } - - virtual ~UserList() - {} - - /** - * Clear all messages from the list - */ - virtual void clear(); - - /** - * Post a message to the list - */ - virtual void addUser(const DOMString &user, const DOMString &show); - - - void setParent(GroupChatWindow *val) - { parent = val; } - -private: - - class CustomTreeView : public Gtk::TreeView - { - public: - CustomTreeView() - { parent = NULL; } - virtual ~CustomTreeView() - {} - - bool on_button_press_event(GdkEventButton* event) - { - Gtk::TreeView::on_button_press_event(event); - if (parent) - parent->buttonPressCallback(event); - return true; - } - void setParent(UserList *val) - { parent = val; } - - private: - UserList *parent; - }; - - void doubleClickCallback(const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - - void sendFileCallback(); - void chatCallback(); - void shareCallback(); - bool buttonPressCallback(GdkEventButton* event); - - bool doSetup(); - - Glib::RefPtr<Gdk::Pixbuf> pixbuf_available; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_away; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_chat; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_dnd; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_error; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_offline; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_xa; - - class UserListColumns : public Gtk::TreeModel::ColumnRecord - { - public: - UserListColumns() - { add(statusColumn); add(userColumn); } - - Gtk::TreeModelColumn<Glib::ustring> userColumn; - Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > statusColumn; - }; - - UserListColumns userListColumns; - - Glib::RefPtr<Gtk::UIManager> uiManager; - - Glib::RefPtr<Gtk::ListStore> userListStore; - CustomTreeView userList; - - GroupChatWindow *parent; -}; - - -//######################################################################### -//# C H A T W I N D O W -//######################################################################### -class ChatWindow : public Gtk::Window -{ -public: - - ChatWindow(PedroGui &par, const DOMString jid); - - virtual ~ChatWindow(); - - virtual DOMString getJid() - { return jid; } - - virtual void setJid(const DOMString &val) - { jid = val; } - - virtual bool postMessage(const DOMString &data); - -private: - - DOMString jid; - - void leaveCallback(); - void hideCallback(); - void shareCallback(); - void textEnterCallback(); - - bool doSetup(); - - Gtk::VBox vbox; - Gtk::VPaned vPaned; - - MessageList messageList; - - Gtk::Entry inputTxt; - - PedroGui &parent; -}; - - -//######################################################################### -//# G R O U P C H A T W I N D O W -//######################################################################### -class GroupChatWindow : public Gtk::Window -{ -public: - - GroupChatWindow(PedroGui &par, const DOMString &groupJid, - const DOMString &nick); - - virtual ~GroupChatWindow(); - - - virtual DOMString getGroupJid() - { return groupJid; } - - virtual void setGroupJid(const DOMString &val) - { groupJid = val; } - - virtual DOMString getNick() - { return nick; } - - virtual void setNick(const DOMString &val) - { nick = val; } - - virtual bool receiveMessage(const DOMString &from, - const DOMString &data); - - virtual bool receivePresence(const DOMString &nick, - bool presence, - const DOMString &show, - const DOMString &status); - - virtual void doSendFile(const DOMString &nick); - - virtual void doChat(const DOMString &nick); - virtual void doShare(const DOMString &nick); - - -private: - - void textEnterCallback(); - void leaveCallback(); - void hideCallback(); - void shareCallback(); - - bool doSetup(); - - Gtk::VBox vbox; - Gtk::VPaned vPaned; - Gtk::HPaned hPaned; - - MessageList messageList; - - UserList userList; - - Gtk::Entry inputTxt; - - DOMString groupJid; - DOMString nick; - - PedroGui &parent; - }; - - - -//######################################################################### -//# C O N F I G D I A L O G -//######################################################################### - -class ConfigDialog : public Gtk::Dialog -{ -public: - - ConfigDialog (PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~ConfigDialog () - {} - - DOMString getPass() - { return passField.get_text(); } - DOMString getNewPass() - { return newField.get_text(); } - DOMString getConfirm() - { return confField.get_text(); } - -protected: - - //Overloaded from Gtk::Dialog - virtual void on_response(int response_id); - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label newLabel; - Gtk::Entry newField; - Gtk::Label confLabel; - Gtk::Entry confField; - - PedroGui &parent; -}; - - -//######################################################################### -//# P A S S W O R D D I A L O G -//######################################################################### -class PasswordDialog : public Gtk::Dialog -{ -public: - - PasswordDialog (PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~PasswordDialog () - {} - - DOMString getPass() - { return passField.get_text(); } - DOMString getNewPass() - { return newField.get_text(); } - DOMString getConfirm() - { return confField.get_text(); } - -protected: - - //Overloaded from Gtk::Dialog - virtual void on_response(int response_id); - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label newLabel; - Gtk::Entry newField; - Gtk::Label confLabel; - Gtk::Entry confField; - - PedroGui &parent; -}; - - - -//######################################################################### -//# C H A T D I A L O G -//######################################################################### -class ChatDialog : public Gtk::Dialog -{ -public: - - ChatDialog(PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~ChatDialog() - {} - - DOMString getUser() - { return userField.get_text(); } - - DOMString getText() - { return textField.get_text(); } - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label userLabel; - Gtk::Entry userField; - Gtk::Entry textField; - - PedroGui &parent; -}; - - - -//######################################################################### -//# G R O U P C H A T D I A L O G -//######################################################################### - -class GroupChatDialog : public Gtk::Dialog -{ -public: - - GroupChatDialog(PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~GroupChatDialog() - {} - - DOMString getGroup() - { return groupField.get_text(); } - DOMString getHost() - { return hostField.get_text(); } - DOMString getPass() - { return passField.get_text(); } - DOMString getNick() - { return nickField.get_text(); } - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label groupLabel; - Gtk::Entry groupField; - Gtk::Label hostLabel; - Gtk::Entry hostField; - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label nickLabel; - Gtk::Entry nickField; - - PedroGui &parent; -}; - - -//######################################################################### -//# C O N N E C T D I A L O G -//######################################################################### -class ConnectDialog : public Gtk::Dialog -{ -public: - - ConnectDialog (PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~ConnectDialog () - {} - - DOMString getHost() - { return hostField.get_text(); } - void setHost(const DOMString &val) - { hostField.set_text(val); } - int getPort() - { return (int)portSpinner.get_value(); } - void setPort(int val) - { portSpinner.set_value(val); } - DOMString getUser() - { return userField.get_text(); } - void setUser(const DOMString &val) - { userField.set_text(val); } - DOMString getPass() - { return passField.get_text(); } - void setPass(const DOMString &val) - { passField.set_text(val); } - DOMString getResource() - { return resourceField.get_text(); } - void setResource(const DOMString &val) - { resourceField.set_text(val); } - bool getRegister() - { return registerButton.get_active(); } - - /** - * Regenerate the account list - */ - virtual void refresh(); - -private: - - void okCallback(); - void saveCallback(); - void cancelCallback(); - void doubleClickCallback( - const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - void selectedCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label hostLabel; - Gtk::Entry hostField; - Gtk::Label portLabel; - Inkscape::UI::Widget::SpinButton portSpinner; - Gtk::Label userLabel; - Gtk::Entry userField; - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label resourceLabel; - Gtk::Entry resourceField; - Gtk::Label registerLabel; - Gtk::CheckButton registerButton; - - Glib::RefPtr<Gtk::UIManager> uiManager; - - - //## Account list - - void buttonPressCallback(GdkEventButton* event); - - Gtk::ScrolledWindow accountScroll; - - void connectCallback(); - - void modifyCallback(); - - void deleteCallback(); - - - class AccountColumns : public Gtk::TreeModel::ColumnRecord - { - public: - AccountColumns() - { - add(nameColumn); - add(hostColumn); - } - - Gtk::TreeModelColumn<Glib::ustring> nameColumn; - Gtk::TreeModelColumn<Glib::ustring> hostColumn; - }; - - AccountColumns accountColumns; - - Glib::RefPtr<Gtk::UIManager> accountUiManager; - - Glib::RefPtr<Gtk::ListStore> accountListStore; - Gtk::TreeView accountView; - - - PedroGui &parent; -}; - - - - -//######################################################################### -//# F I L E S E N D D I A L O G -//######################################################################### - -class FileSendDialog : public Gtk::Dialog -{ -public: - - FileSendDialog(PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~FileSendDialog() - {} - - DOMString getFileName() - { return fileName; } - DOMString getJid() - { return jidField.get_text(); } - void setJid(const DOMString &val) - { return jidField.set_text(val); } - -private: - - void okCallback(); - void cancelCallback(); - void buttonCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label jidLabel; - Gtk::Entry jidField; - - DOMString fileName; - Gtk::Entry fileNameField; - - Gtk::Button selectFileButton; - - PedroGui &parent; -}; - -//######################################################################### -//# F I L E R E C E I V E D I A L O G -//######################################################################### - -class FileReceiveDialog : public Gtk::Dialog -{ -public: - - FileReceiveDialog(PedroGui &par, - const DOMString &jidArg, - const DOMString &iqIdArg, - const DOMString &streamIdArg, - const DOMString &offeredNameArg, - const DOMString &descArg, - long sizeArg, - const DOMString &hashArg - ) : parent(par) - { - jid = jidArg; - iqId = iqIdArg; - streamId = streamIdArg; - offeredName = offeredNameArg; - desc = descArg; - fileSize = sizeArg; - hash = hashArg; - doSetup(); - } - - virtual ~FileReceiveDialog() - {} - - DOMString getJid() - { return jid; } - DOMString getIq() - { return iqId; } - DOMString getStreamId() - { return streamId; } - DOMString getOfferedName() - { return offeredName; } - DOMString getFileName() - { return fileName; } - DOMString getDescription() - { return desc; } - long getSize() - { return fileSize; } - DOMString getHash() - { return hash; } - -private: - - void okCallback(); - void cancelCallback(); - void buttonCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label jidLabel; - Gtk::Entry jidField; - Gtk::Label offeredLabel; - Gtk::Entry offeredField; - Gtk::Label descLabel; - Gtk::Entry descField; - Gtk::Label sizeLabel; - Gtk::Entry sizeField; - Gtk::Label hashLabel; - Gtk::Entry hashField; - - Gtk::Entry fileNameField; - - Gtk::Button selectFileButton; - - DOMString jid; - DOMString iqId; - DOMString streamId; - DOMString offeredName; - DOMString desc; - long fileSize; - DOMString hash; - - DOMString fileName; - - PedroGui &parent; -}; - - - -//######################################################################### -//# M A I N W I N D O W -//######################################################################### - -class PedroGui : public Gtk::Window -{ -public: - - PedroGui(); - - virtual ~PedroGui(); - - //Let everyone share these - XmppClient client; - XmppConfig config; - - - virtual void error(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - virtual void status(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - - - void handleConnectEvent(); - - void handleDisconnectEvent(); - - /** - * - */ - virtual void doEvent(const XmppEvent &event); - - /** - * - */ - bool checkEventQueue(); - - - bool chatCreate(const DOMString &userJid); - bool chatDelete(const DOMString &userJid); - bool chatDeleteAll(); - bool chatMessage(const DOMString &jid, const DOMString &data); - - bool groupChatCreate(const DOMString &groupJid, - const DOMString &nick); - bool groupChatDelete(const DOMString &groupJid, - const DOMString &nick); - bool groupChatDeleteAll(); - bool groupChatMessage(const DOMString &groupJid, - const DOMString &from, const DOMString &data); - bool groupChatPresence(const DOMString &groupJid, - const DOMString &nick, - bool presence, - const DOMString &show, - const DOMString &status); - - void doChat(const DOMString &jid); - void doSendFile(const DOMString &jid); - void doReceiveFile(const DOMString &jid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &offeredName, - const DOMString &desc, - long size, - const DOMString &hash); - - void doShare(const DOMString &jid); - void doGroupShare(const DOMString &groupJid); - - //# File menu - void connectCallback(); - void chatCallback(); - void groupChatCallback(); - void disconnectCallback(); - void quitCallback(); - - //# Edit menu - void fontCallback(); - void colorCallback(); - - //# Transfer menu - void sendFileCallback(); - - //# Registration menu - void regPassCallback(); - void regCancelCallback(); - - //# Help menu - void aboutCallback(); - - //# Configuration file - bool configLoad(); - bool configSave(); - - -private: - - bool doSetup(); - - Gtk::VBox mainBox; - - Gtk::HBox menuBarBox; - - Gtk::Image padlockIcon; - void padlockEnable(); - void padlockDisable(); - - - Pango::FontDescription fontDesc; - Gdk::Color foregroundColor; - Gdk::Color backgroundColor; - - Gtk::VPaned vPaned; - MessageList messageList; - Roster roster; - - Glib::RefPtr<Gtk::UIManager> uiManager; - void actionEnable(const DOMString &name, bool val); - - std::vector<ChatWindow *>chats; - - std::vector<GroupChatWindow *>groupChats; -}; - - -} //namespace Pedro - -#endif /* __PEDROGUI_H__ */ -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - diff --git a/src/jabber_whiteboard/protocol/README.txt b/src/jabber_whiteboard/protocol/README.txt deleted file mode 100644 index b13a2efa0..000000000 --- a/src/jabber_whiteboard/protocol/README.txt +++ /dev/null @@ -1,11 +0,0 @@ -To do a LaTeX compilation of the Inkboard protocol specification, do the following: - -1) Run svg2eps.sh to convert the SVGs to EPS files, or do some equivalent procedure. -2) Run the command - - latex protocol - -The fancyvrb, enumerate, and graphicx packages are required. - - -IMPORTANT NOTE: This protocol specification is nowhere near finalized. \ No newline at end of file diff --git a/src/jabber_whiteboard/protocol/disconnect-u2u-01.svg b/src/jabber_whiteboard/protocol/disconnect-u2u-01.svg deleted file mode 100644 index 3977edc8c..000000000 --- a/src/jabber_whiteboard/protocol/disconnect-u2u-01.svg +++ /dev/null @@ -1,167 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="disconnect-u2u-01.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.86180109" - inkscape:cx="454.05542" - inkscape:cy="653.01298" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" - showguides="true" - inkscape:guide-bbox="true" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000858px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61508" - y="120.14616" - id="text2992" - transform="matrix(0.996475,8.38928e-2,-8.38928e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61508" - y="120.14616">DISCONNECTED_FROM_USER_SIGNAL</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session: disconnection and termination of session (user-to-user)</tspan></text> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect3187" - width="16.409977" - height="833.62683" - x="634.81885" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="614.79059" - y="77.251221" - id="text3189"><tspan - sodipodi:role="line" - id="tspan3191" - x="614.79059" - y="77.251221">Juliet</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="114.87569" - y="183.25214" - id="text1930"><tspan - sodipodi:role="line" - x="114.87569" - y="183.25214" - id="tspan1942">Client disconnect; Inkboard document is removed</tspan><tspan - sodipodi:role="line" - x="114.87569" - y="198.25214" - id="tspan1946">from tracking queue</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="331.21838" - y="228.95816" - id="text1954"><tspan - sodipodi:role="line" - x="331.21838" - y="228.95816" - id="tspan1956">Client disconnect; Inkboard document is removed</tspan><tspan - sodipodi:role="line" - x="331.21838" - y="243.95816" - id="tspan1958">from tracking queue.</tspan><tspan - sodipodi:role="line" - x="331.21838" - y="258.95816" - id="tspan3285" /><tspan - sodipodi:role="line" - x="331.21838" - y="273.95816" - id="tspan3287">Inkboard notifies Juliet of Romeo's disconnection.</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/protocol.bib b/src/jabber_whiteboard/protocol/protocol.bib deleted file mode 100644 index 181242cc2..000000000 --- a/src/jabber_whiteboard/protocol/protocol.bib +++ /dev/null @@ -1,38 +0,0 @@ -@misc{rfc3920, - author="P. Saint-Andre", - title="{Extensible Messaging and Presence Protocol (XMPP): Core}", - series="Request for Comments", - number="3920", - howpublished="RFC 3920 (Proposed Standard)", - publisher="IETF", - organisation="Internet Engineering Task Force", - year=2004, - month=oct, - url="http://www.ietf.org/rfc/rfc3920.txt", -} - -@misc{jep0045, - author="P. Saint-Andre", - title="{Multi-User Chat}", - series="Jabber Enhancement Proposals", - number="0045", - howpublished="JEP 0045 (Standards Track)", - publisher="Jabber Foundation", - organisation="Jabber Software Foundation", - year=2005, - month=sep, - url="http://www.jabber.org/jeps/jep-0045.html", -} - -@misc{rfc2119, - author="S. Bradner", - title="{Key words for use in RFCs to Indicate Requirement Levels}", - series="Request for Comments", - number="2119", - howpublished="RFC 2119 (Best Current Practice)", - publisher="IETF", - organisation="Internet Engineering Task Force", - year=1997, - month=mar, - url="http://www.ietf.org/rfc/rfc2119.txt", -} \ No newline at end of file diff --git a/src/jabber_whiteboard/protocol/protocol.tex b/src/jabber_whiteboard/protocol/protocol.tex deleted file mode 100644 index cdd03d297..000000000 --- a/src/jabber_whiteboard/protocol/protocol.tex +++ /dev/null @@ -1,227 +0,0 @@ -\documentclass[11pt]{article} -\usepackage{enumerate,fancyvrb,graphicx} -\usepackage[utf8x]{inputenc} -\usepackage{fullpage} -\linespread{1.25} - -\begin{document} -\title{The Inkboard protocol specification} -\author{David Yip} -\maketitle - -\begin{abstract} -Inkboard is a component of the Inkscape vector graphics editor that allows Inkscape users to collaborate on Inkscape documents. This document describes the protocol used by Inkboard clients to manage sessions, communicate document changes, and resolve conflicting changes. -\end{abstract} - -\tableofcontents - -\section{Introduction} -\subsection{Overview} -Inkboard is a component of the Inkscape vector graphics editor that allows Inkscape users to collaborate on Inkscape documents. The protocol is implemented as a layer on top of the XMPP instant-messaging protocol\cite{rfc3920}, which is the core of the Jabber instant-messaging system. - -\subsection{Terminology} -The capitalized key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14, RFC 2119\cite{rfc2119}. - -\section{Definitions} -The following definitions are used throughout this document. -\begin{itemize} -\item {\em Inkboard user}: The user of an Inkboard client. -\item {\em Inkboard change}: An XML fragment specifying a change to be made to a document. A full listing of change types is given in Section \ref{change-types}. -\item {\em User-to-user session}: An Inkboard session only occurring between two users. Analogous to traditional text-based instant messaging between two users. -\item {\em User-to-conference session}: An Inkboard session occurring between a user and a multi-user conference room. Analogous to traditional text-based chat rooms. -\end{itemize} - -\subsection{Dramatis Personae} -Throughout this document, references will be made to the following fictional entities: -\begin{center} -\begin{tabular}[t]{|c|c|} -\hline -Entity Name & Role \\ -\hline -Romeo & Inkboard user \\ -\hline -Juliet & Inkboard user \\ -\hline -Chat & Conference room \\ -\hline -\end{tabular} -\end{center} - -\section{A brief overview of the Inkboard architecture} -Because the Inkboard protocol is heavily influenced by the architecture of the Inkboard component, a brief overview of Inkboard's architecture may be helpful in understanding the Inkboard protocol. - -Inkboard is implemented as a listener attached to the Inkscape undo/redo mechanism. Inkscape maintains one undo log and one redo log per document. Inkscape undo log listeners receive notifications on the following events: - -\begin{enumerate} -\item An undo action was requested by the user. -\item A redo action was requested by the user. -\item A set of changes was committed to the undo log. -\end{enumerate} - -When any of these events occur, the Inkboard undo listener receives a pointer to an object of type \texttt{Inkscape::XML::Event}, which represents manipulations on the XML tree representing an SVG document. The Inkboard undo listener serializes these \texttt{Inkscape::XML::Event} objects into Inkboard changes and then sends them out to the recipient. - -The receiving Inkboard client attempts to deserialize these messages into \texttt{Inkscape::XML::Event} objects. If deserialization is successful, these \texttt{Inkscape::XML::Event} objects are replayed using the Inkscape undo mechanism. - -\section{Inkboard and XMPP} -\subsection{Format of Inkboard messages} -Inkboard messages are encapsulated in XMPP message stanzas, the format of which is described in \cite{rfc3920}. Inkboard data is wrapped in an \texttt{<inkboard>} element which MUST contain the following attributes: -\begin{center} -\begin{tabular}[t]{|c|c|} -\hline -Attribute & Description \\ -\hline -\texttt{protocol} & Version of the Inkboard protocol utilized by the client that sent the message.\\ -& Clients conforming to this specification MUST use version number 2 in this field. \\ -\hline -\texttt{type} & Numeric identifier of a message type. \\ -& See Section \ref{message-types} for a full listing of Inkboard message types. \\ -\hline -\texttt{seq} & Sequence number of the message. This MUST be monotonically increasing. \\ -\hline -\end{tabular} -\end{center} - -Inkboard changes MUST be wrapped inside an \texttt{<x:inkboard-data>} element inside the \texttt{<inkboard>} element. The \texttt{<x:inkboard-data>} tag MUST contain zero or more Inkboard changes. See Section \ref{example-messages} for examples of Inkboard messages, and Section \ref{change-types} for a full listing of Inkboard change types. - -The Inkboard XML schema is available at \texttt{http://inkscape.org/inkboard}. - -\subsection{Inkboard message queuing rules} -Inkboard messages MUST be processed as soon as possible (i.e. as soon as they are received), with the sole exception of Inkboard messages of type \texttt{CHANGE}. - -Inkboard messages of type \texttt{CHANGE} SHOULD NOT be applied to a document as they are received; instead, Inkboard clients SHOULD queue up changes until receipt of a \texttt{COMMIT} message. Upon receipt of a \texttt{COMMIT} message from a particular Inkboard client, Inkboard clients implementing the queuing method MUST commit all uncommitted changes received from that particular client. - -\subsection{Example Inkboard messages} -\label{example-messages} -\subsubsection{Null message} -\VerbatimInput[tabsize=2]{inkboard-message-examples/null-message.txt} - -\subsubsection{Sending a change} -\VerbatimInput[tabsize=2]{inkboard-message-examples/1-1-change-message.txt} - -\section{Session establishment} -\subsection{User-to-user} -User-to-user sessions MUST be negotiated according to the procedure outlined below. - -\begin{figure} -\label{u2u-session-establishment-figure-accept} -\centering -\includegraphics[width=5in]{eps/session-invite-u2u-01.eps} -\caption{Initiation of an Inkboard session between two users.} -\end{figure} - -\begin{figure} -\label{u2u-session-establishment-figure-reject} -\centering -\includegraphics[width=5in]{eps/session-invite-u2u-02.eps} -\caption{Attempt to initiate an Inkboard session between two users, with the second user rejecting the invitiation.} -\end{figure} - -\begin{enumerate} -\item Romeo invites Juliet to a user-to-user session using his Inkboard client. -\item Romeo's Inkboard client sends a \texttt{CONNECT\_REQUEST\_USER} message to Juliet's Inkboard client. -\item Juliet's Inkboard client notifies Juliet that Romeo has invited her to a user-to-user session. -\begin{enumerate} -\item If Juliet accepts Romeo's invitation: -\begin{enumerate} -\item Juliet's Inkboard client sends a \texttt{CONNECT\_REQUEST\_RESPONSE\_USER} message to Romeo's Inkboard client. -\item Romeo's Inkboard client notifies Romeo that Juliet has accepted his invitation. -\item Romeo's Inkboard client sends a \texttt{CONNECTED\_SIGNAL} message to Juliet's Inkboard client. -\item Romeo's Inkboard client serializes the current contents of Romeo's SVG document. -\item Romeo's Inkboard client sends a \texttt{DOCUMENT\_BEGIN} message to Juliet's Inkboard client. -\item Romeo's Inkboard client sends the serialized document to Juliet's Inkboard client as a series of \texttt{CHANGE} messages. -\item Romeo's Inkboard client sends a \texttt{COMMIT} message to Juliet's Inkboard client. -\item Upon receipt of Romeo's \texttt{DOCUMENT\_BEGIN} message, Juliet's Inkboard client prepares to process incoming \texttt{CHANGE} messages from Romeo's Inkboard client by doing the following actions: -\begin{enumerate} -\item Juliet's existing document is cleared. -\item Juliet's Inkboard client prepares to receive and process incoming \texttt{CHANGE} messages. -\end{enumerate} -\item Upon receipt of Romeo's \texttt{COMMIT} message, Juliet's Inkboard client commits all changes sent by Romeo's Inkboard client. -\end{enumerate} -\item If Juliet rejects Romeo's invitation: -\begin{enumerate} -\item Juliet's Inkboard client sends a \texttt{CONNECT\_REQUEST\_REFUSED\_BY\_PEER} message to Romeo's Inkboard client. -\item Romeo's Inkboard client notifies Romeo that Juliet refused his invitation. -\end{enumerate} -\end{enumerate} -\end{enumerate} - -\subsubsection{Example of accepted invitation} - -\subsubsection{Example of rejected invitation} - -\subsection{User-to-conference} -User-to-conference sessions MUST be negotiated according to the procedures outlined below. - -The procedure for user-to-conference session establishment differs based on whether or not there already exist Inkboard users in a Jabber conference room; therefore, there are two modes of operation for Inkboard clients. These two modes are dubbed {\em synchronization mode}, in which an Inkboard client synchronizes with the rest of the conference, and {\em transceiver mode}, in which an Inkboard client transmits and receives changes to/from all other conference members. The presence of other Inkboard users is determined by the following rules: - -\begin{enumerate} -\item If the user joining a user-to-conference session is the only member of the conference, then that user's Inkboard client SHOULD assume that it is the first participant in a chatroom and immediately enters transceiver mode. -\item If the user joining a user-to-conference session is not the only member of the conference, then that user's Inkboard client MUST enter synchronization mode. See Section \ref{joining-existing-conference} for synchronization mode procedures. -\end{enumerate} - -Room rosters MUST be processed according to the procedures given in Section 6.3.3 of \cite{jep0045}. - -\begin{figure} -\label{u2c-session-establishment-figure-accept} -\centering -\includegraphics[width=5in]{eps/session-invite-u2c-01.eps} -\caption{Initiation of an Inkboard session between a user and a conference in which Inkboard users are already involved in a conference.} -\end{figure} - -\subsubsection{User establishing a new conference} -\begin{enumerate} -\item -\end{enumerate} - -\subsubsection{User joining an existing conference} -\label{joining-existing-conference} -\begin{enumerate} -\item -\end{enumerate} - -\section{Session establishment error cases} -\subsection{Incompatible protocol versions} - -\subsubsection{User-to-user} - -\subsubsection{User-to-conference} - -\subsection{Duplicate session establishment requests} - -\subsection{Mutual invitation} - -\section{Transmitting changes} -\subsection{User-to-user} - -\subsection{User-to-conference} - -\section{Change conflict resolution} - -\section{Client requirements} -[describe what is required of a client implementing this protocol; this will probably need to delve into the Inkscape document model a little bit] - -\section{Contributors} -[TBW] - -\section{Acknowledgments} -[TBW] - -\section{Security considerations} -[TBW] - -\section{IANA Considerations} -[TBW, although most likely ``None''] - -\appendix -\section{Appendices} - -\subsection{Full listing of message types} -\label{message-types} - -\subsection{Full listing of change types} -\label{change-types} - -\bibliographystyle{alpha} -\bibliography{protocol.bib} - -\end{document} \ No newline at end of file diff --git a/src/jabber_whiteboard/protocol/session-invite-u2c-01.svg b/src/jabber_whiteboard/protocol/session-invite-u2c-01.svg deleted file mode 100644 index c608812d8..000000000 --- a/src/jabber_whiteboard/protocol/session-invite-u2c-01.svg +++ /dev/null @@ -1,376 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="session-invite-u2c-01.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.86180109" - inkscape:cx="449.41398" - inkscape:cy="612.40036" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" - showguides="true" - inkscape:guide-bbox="true" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1927" - width="16.409977" - height="190.78708" - x="635.0661" - y="90.737564" - ry="0.39570743" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="608.67877" - y="77.251221" - id="text1933"><tspan - sodipodi:role="line" - id="tspan1935" - x="608.67877" - y="77.251221">Chat</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000858px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61508" - y="120.14616" - id="text2992" - transform="matrix(0.996475,8.38928e-2,-8.38928e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61508" - y="120.14616">CHATROOM_SYNCHRONIZE_REQUEST</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session invitation (user-to-chatroom): Inkboard users already in chat</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,196.29025 L 122.38422,284.52748" - id="path3000" /> - <text - xml:space="preserve" - style="font-size:11.9999876px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="236.16333" - y="285.77191" - id="text3002" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3004" - x="236.16333" - y="285.77191">CHATROOM_SYNCHRONIZE_RESPONSE</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="653.08478" - y="194.535" - id="text3054"><tspan - sodipodi:role="line" - x="653.08478" - y="194.535" - id="tspan3078">(from Romeo)</tspan><tspan - sodipodi:role="line" - x="653.08478" - y="209.535" - id="tspan3144" /><tspan - sodipodi:role="line" - x="653.08478" - y="224.535" - id="tspan3080">(future synch</tspan><tspan - sodipodi:role="line" - x="653.08478" - y="239.535" - id="tspan3082">responses</tspan><tspan - sodipodi:role="line" - x="653.08478" - y="254.535" - id="tspan3086">ignored by</tspan><tspan - sodipodi:role="line" - x="653.08478" - y="269.535" - id="tspan3120">Romeo)</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,299.41817 L 624.59663,347.72315" - id="path3060" /> - <text - xml:space="preserve" - style="font-size:12.00015259px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="303.54501" - y="285.5632" - id="text3062" - transform="matrix(0.996475,8.389188e-2,-8.389188e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan3064" - x="303.54501" - y="285.5632">DOCUMENT_SENDER_REQUEST</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,236.29025 L 122.38422,324.52748" - id="path3072" /> - <text - xml:space="preserve" - style="font-size:11.99997234px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="230.29608" - y="325.33881" - id="text3074" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3076" - x="230.29608" - y="325.33881">CHATROOM_SYNCHRONIZE_RESPONSE</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,364.29025 L 122.38422,452.52748" - id="path3100" /> - <text - xml:space="preserve" - style="font-size:11.99979305px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="261.85782" - y="453.34647" - id="text3102" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3104" - x="261.85782" - y="453.34647">DOCUMENT_BEGIN</tspan></text> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="616.67877" - y="326.65308" - id="text3148"><tspan - sodipodi:role="line" - id="tspan3150" - x="616.67877" - y="326.65308">Juliet</tspan></text> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect3152" - width="16.409977" - height="588.79077" - x="635.0661" - y="340.73755" - ry="1.2211984" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,400.29025 L 122.38422,488.52748" - id="path3173" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,436.29025 L 122.38422,524.52748" - id="path3179" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,476.29025 L 122.38422,564.52748" - id="path3181" /> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="345.78745" - y="478.50262" - id="text3183"><tspan - sodipodi:role="line" - id="tspan3185" - x="345.78745" - y="478.50262">(...data...)</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="654.76404" - y="370.90982" - id="text2157"><tspan - sodipodi:role="line" - x="654.76404" - y="370.90982" - id="tspan2161">Juliet sends</tspan><tspan - sodipodi:role="line" - x="654.76404" - y="385.90982" - id="tspan2165">contents of </tspan><tspan - sodipodi:role="line" - x="654.76404" - y="400.90982" - id="tspan2167">document </tspan><tspan - sodipodi:role="line" - x="654.76404" - y="415.90982" - id="tspan2169">at the time of</tspan><tspan - sodipodi:role="line" - x="654.76404" - y="430.90982" - id="tspan2171">receipt of </tspan><tspan - sodipodi:role="line" - x="654.76404" - y="445.90982" - id="tspan2173">Romeo's request.</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:red;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 719.42355,350.34404 C 720.25008,347.03792 694.75869,345.7026 689.25418,345.7026 C 682.14416,345.7026 669.99443,350.69103 663.72624,353.82512 C 652.81295,359.28177 650.74673,370.28572 642.83975,378.19269 C 637.49763,383.53482 633.55687,397.57227 633.55687,404.88099 C 633.55687,419.56123 635.04648,426.70301 642.83975,439.6918 C 648.6135,449.31472 662.25364,455.57988 671.84877,459.41793 C 682.98476,463.87233 688.02403,469.84722 699.69742,472.1819 C 711.66047,474.57451 726.46764,468.63937 735.6686,461.73865 C 748.30073,452.26455 755.62864,443.55661 763.51725,430.40892 C 771.10777,417.75805 763.53779,402.66295 761.19653,390.95666 C 759.09409,380.44448 755.97902,374.27956 747.2722,367.74945 C 729.53409,354.44586 715.27964,346.43651 698.53706,360.78729 C 697.29112,361.85523 696.21634,363.10801 695.05598,364.26837" - id="path2177" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:red;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 697.3767,469.86118 C 662.45581,499.79337 655.11743,532.76379 599.90641,560.3693 C 557.38172,581.63165 498.23082,592.20519 469.94603,634.63238 C 462.94102,645.13989 448.0551,651.25817 445.57846,663.64139" - id="path2179" /> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="362.0325" - y="677.56573" - id="text3055"><tspan - sodipodi:role="line" - id="tspan3057" - x="362.0325" - y="677.56573">PROBLEM: There is not yet any way to store</tspan><tspan - sodipodi:role="line" - x="362.0325" - y="692.56573" - id="tspan3059">multiple revisions of a node in an SVG</tspan><tspan - sodipodi:role="line" - x="362.0325" - y="707.56573" - id="tspan3061">document. This needs to be worked out</tspan><tspan - sodipodi:role="line" - x="362.0325" - y="722.56573" - id="tspan3063">before the circled criteria can actually</tspan><tspan - sodipodi:role="line" - x="362.0325" - y="737.56573" - id="tspan3065">be implemented.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="116.03606" - y="223.86473" - id="text3067"><tspan - sodipodi:role="line" - id="tspan3069" - x="116.03606" - y="223.86473">Romeo</tspan><tspan - sodipodi:role="line" - x="116.03606" - y="238.86473" - id="tspan3071">receives</tspan><tspan - sodipodi:role="line" - x="116.03606" - y="253.86473" - id="tspan3073">acknowledgement</tspan><tspan - sodipodi:role="line" - x="116.03606" - y="268.86473" - id="tspan3075">from Juliet</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,514.58215 L 122.38422,602.81938" - id="path1976" /> - <text - xml:space="preserve" - style="font-size:11.99978924px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="257.46045" - y="601.67126" - id="text1980" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan1982" - x="257.46045" - y="601.67126">CHANGE_COMMIT</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="116.03606" - y="625.34955" - id="text1984"><tspan - sodipodi:role="line" - id="tspan1986" - x="116.03606" - y="625.34955">Romeo commits changes</tspan><tspan - sodipodi:role="line" - x="116.03606" - y="640.34955" - id="tspan1988">sent by Juliet</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/session-invite-u2u-01.svg b/src/jabber_whiteboard/protocol/session-invite-u2u-01.svg deleted file mode 100644 index fa19a2345..000000000 --- a/src/jabber_whiteboard/protocol/session-invite-u2u-01.svg +++ /dev/null @@ -1,306 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="session-invite-u2u-01.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="1.2187708" - inkscape:cx="468.98529" - inkscape:cy="604.89451" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" - showguides="true" - inkscape:guide-bbox="true" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1927" - width="16.409977" - height="833.62683" - x="635.0661" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="608.67877" - y="77.251221" - id="text1933"><tspan - sodipodi:role="line" - id="tspan1935" - x="608.67877" - y="77.251221">Juliet</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1;opacity:1;color:black;marker:none;marker-mid:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000286px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61496" - y="120.1461" - id="text2992" - transform="matrix(0.996475,8.389284e-2,-8.389284e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61496" - y="120.1461">CONNECT_REQUEST_USER</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session invitation (user-to-user): recipient Juliet accepts invitation</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,206.29025 L 122.38422,294.52748" - id="path3000" /> - <text - xml:space="preserve" - style="font-size:12.00000477px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="234.69696" - y="295.66422" - id="text3002" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3004" - x="234.69696" - y="295.66422">CONNECT_REQUEST_RESPONSE_USER</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,421.22589 L 624.59663,469.53087" - id="path3006" /> - <text - xml:space="preserve" - style="font-size:12.00000858px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="313.76007" - y="406.93933" - id="text3008" - transform="matrix(0.996475,8.38928e-2,-8.38928e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan3010" - x="313.76007" - y="406.93933">DOCUMENT_BEGIN</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,461.83851 L 624.59663,510.14349" - id="path3014" /> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,497.80969 L 624.59663,546.11467" - id="path3016" /> - <text - xml:space="preserve" - style="font-size:11.99999809px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="309.69238" - y="485.40234" - id="text3018" - transform="matrix(0.997001,7.738702e-2,-7.738702e-2,0.997001,0,0)"><tspan - sodipodi:role="line" - id="tspan3020" - x="309.69238" - y="485.40234">(...more CHANGE data...)</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,536.10159 L 624.59663,584.40657" - id="path3022" /> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="654.44336" - y="486.36777" - id="text2034"><tspan - sodipodi:role="line" - id="tspan2036" - x="654.44336" - y="486.36777">Begin </tspan><tspan - sodipodi:role="line" - x="654.44336" - y="501.36777" - id="tspan2038">deserialization</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="345.42999" - y="194.12042" - id="text1943"><tspan - sodipodi:role="line" - id="tspan1945" - x="345.42999" - y="194.12042">Inkboard notifies Juliet of Romeo's invitation. </tspan><tspan - sodipodi:role="line" - x="345.42999" - y="209.12042" - id="tspan2417">Juliet accepts.</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,574.65917 L 624.59663,622.96415" - id="path2024" /> - <text - xml:space="preserve" - style="font-size:12.00001431px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;font-variant:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;opacity:1;color:black;fill-rule:nonzero;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;visibility:visible;display:inline;overflow:visible" - x="370.46198" - y="562.08289" - id="text2026" - transform="matrix(0.996475,8.389276e-2,-8.389276e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2028" - x="370.46198" - y="562.08289">COMMIT</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="490.04276" - y="649.49731" - id="text2030"><tspan - sodipodi:role="line" - x="490.04276" - y="649.49731" - id="tspan2034">Juliet commits changes</tspan><tspan - sodipodi:role="line" - x="490.04276" - y="664.49731" - id="tspan2039">sent by Romeo.</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,305.72292 L 624.59663,354.0279" - id="path2531" /> - <text - xml:space="preserve" - style="font-size:12.00000572px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="304.07016" - y="291.84348" - id="text2533" - transform="matrix(0.996475,8.389282e-2,-8.389282e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2535" - x="304.07016" - y="291.84348">CONNECTED_SIGNAL</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="251.07263" - y="284.86609" - id="text2537"><tspan - sodipodi:role="line" - x="251.07263" - y="284.86609" - id="tspan2545">Inkboard notifies Romeo that Juliet has</tspan><tspan - sodipodi:role="line" - x="251.07263" - y="299.86609" - id="tspan2553">accepted the invitation.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="321.33243" - y="369.62021" - id="text1904"><tspan - sodipodi:role="line" - x="321.33243" - y="369.62021" - id="tspan1906">Inkboard notifies Juliet that Romeo has</tspan><tspan - sodipodi:role="line" - x="321.33243" - y="384.62021" - id="tspan1908">acknowledged the invitation acceptance.</tspan></text> - <text - xml:space="preserve" - style="font-size:12.00001717px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="360.75647" - y="446.80051" - id="text1907" - transform="matrix(0.996475,8.389274e-2,-8.389274e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan1909" - x="360.75647" - y="446.80051">CHANGE</tspan></text> - <text - xml:space="preserve" - style="font-size:12.00002003px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="366.68692" - y="517.24152" - id="text1911" - transform="matrix(0.996475,8.389272e-2,-8.389272e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan1913" - x="366.68692" - y="517.24152">CHANGE</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/session-invite-u2u-02.svg b/src/jabber_whiteboard/protocol/session-invite-u2u-02.svg deleted file mode 100644 index 84db6d282..000000000 --- a/src/jabber_whiteboard/protocol/session-invite-u2u-02.svg +++ /dev/null @@ -1,168 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="session-invite-u2u-02.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="1.7236022" - inkscape:cx="365.02179" - inkscape:cy="831.05834" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1927" - width="16.409977" - height="833.62683" - x="635.0661" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="608.67877" - y="77.251221" - id="text1933"><tspan - sodipodi:role="line" - id="tspan1935" - x="608.67877" - y="77.251221">Juliet</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1;opacity:1;color:black;marker:none;marker-mid:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000286px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61496" - y="120.1461" - id="text2992" - transform="matrix(0.996475,8.389284e-2,-8.389284e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61496" - y="120.1461">CONNECT_REQUEST_USER</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session invitation (user-to-user): recipient Juliet rejects invitation</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,206.29025 L 122.38422,294.52748" - id="path3000" /> - <text - xml:space="preserve" - style="font-size:12.00000477px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="234.69696" - y="295.66422" - id="text3002" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3004" - x="234.69696" - y="295.66422">CONNECT_REQUEST_REFUSED_BY_PEER</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="117.19642" - y="315.53323" - id="text2061"><tspan - sodipodi:role="line" - id="tspan2063" - x="117.19642" - y="315.53323">Inkboard notifies Romeo of invitation refusal.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="343.98434" - y="191.20412" - id="text2065"><tspan - sodipodi:role="line" - id="tspan2067" - x="343.98434" - y="191.20412">Inkboard notifies Juliet of Romeo's invitation; </tspan><tspan - sodipodi:role="line" - x="343.98434" - y="206.20412" - id="tspan2487">Juliet rejects it.</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/session-invite-u2u-03.svg b/src/jabber_whiteboard/protocol/session-invite-u2u-03.svg deleted file mode 100644 index 1161e77c4..000000000 --- a/src/jabber_whiteboard/protocol/session-invite-u2u-03.svg +++ /dev/null @@ -1,202 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="session-invite-u2u-03.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.86180109" - inkscape:cx="398.35811" - inkscape:cy="643.85894" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1927" - width="16.409977" - height="833.62683" - x="635.0661" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="608.67877" - y="77.251221" - id="text1933"><tspan - sodipodi:role="line" - id="tspan1935" - x="608.67877" - y="77.251221">Juliet</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1;opacity:1;color:black;marker:none;marker-mid:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000286px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61496" - y="120.1461" - id="text2992" - transform="matrix(0.996475,8.389284e-2,-8.389284e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61496" - y="120.1461">CONNECT_REQUEST_USER</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session invitation (user-to-user): recipients invite each other</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 637.16579,153.35691 L 121.22386,241.59414" - id="path3000" /> - <text - xml:space="preserve" - style="font-size:11.99998569px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="241.31259" - y="243.13264" - id="text3002" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3004" - x="241.31259" - y="243.13264">CONNECT_REQUEST_USER</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,323.41817 L 624.59663,371.72315" - id="path3042" /> - <text - xml:space="preserve" - style="font-size:12.00009537px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="305.55701" - y="309.47778" - id="text3044" - transform="matrix(0.996475,8.389218e-2,-8.389218e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan3046" - x="305.55701" - y="309.47778">CONNECT_REQUEST_REFUSED_BY_PEER</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-end:url(#Arrow1Lend);stroke-opacity:1" - d="M 638.32615,397.03263 L 122.38422,485.26986" - id="path3048" /> - <text - xml:space="preserve" - style="font-size:11.99998569px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="206.72" - y="484.34323" - id="text3050" - transform="matrix(0.989185,-0.146672,0.146672,0.989185,0,0)"><tspan - sodipodi:role="line" - id="tspan3052" - x="206.72" - y="484.34323">CONNECT_REQUEST_REFUSED_BY_PEER</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="112.55498" - y="300.25034" - id="text2096"><tspan - sodipodi:role="line" - x="112.55498" - y="300.25034" - id="tspan2104">Inkboard notifies Romeo of double-invite situation </tspan><tspan - sodipodi:role="line" - x="112.55498" - y="315.25034" - id="tspan2108">and automatic sending of invitation refusal.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="341.09631" - y="382.6636" - id="text2100"><tspan - sodipodi:role="line" - id="tspan2102" - x="341.09631" - y="382.6636">Inkboard notifies Juliet of double-invite situation </tspan><tspan - sodipodi:role="line" - x="341.09631" - y="397.6636" - id="tspan2110">and automatic sending of invitation refusal.</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/session-invite-u2u-04.svg b/src/jabber_whiteboard/protocol/session-invite-u2u-04.svg deleted file mode 100644 index 842b65e20..000000000 --- a/src/jabber_whiteboard/protocol/session-invite-u2u-04.svg +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="session-invite-u2u-04.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.86180109" - inkscape:cx="454.05542" - inkscape:cy="653.01298" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" - showguides="true" - inkscape:guide-bbox="true" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000858px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61508" - y="120.14616" - id="text2992" - transform="matrix(0.996475,8.38928e-2,-8.38928e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61508" - y="120.14616">CONNECT_REQUEST_USER</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session invitation (user-to-user): </tspan><tspan - sodipodi:role="line" - x="5.7987185" - y="46.20682" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" - id="tspan2053">Romeo and Juliet are already in a session</tspan></text> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect3187" - width="16.409977" - height="833.62683" - x="634.81885" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="614.79059" - y="77.251221" - id="text3189"><tspan - sodipodi:role="line" - id="tspan3191" - x="614.79059" - y="77.251221">Juliet</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 632.52435,215.78213 L 116.58242,304.01936" - id="path3193" /> - <text - xml:space="preserve" - style="font-size:12.00010777px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="259.78326" - y="308.45236" - id="text3195" - transform="matrix(0.988528,-0.151038,0.151038,0.988528,0,0)"><tspan - sodipodi:role="line" - id="tspan3197" - x="259.78326" - y="308.45236">ALREADY_IN_SESSION</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/svg2eps.sh b/src/jabber_whiteboard/protocol/svg2eps.sh deleted file mode 100755 index aaaa5dfa4..000000000 --- a/src/jabber_whiteboard/protocol/svg2eps.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -mkdir eps -for i in *.svg; do \ - inkscape -E eps/`echo $i | sed -r 's/([a-zA-Z0-9\-]+)\.svg/\1/g;'`.eps $i; \ -done diff --git a/src/jabber_whiteboard/protocol/unsupported-protocol-u2c-01.svg b/src/jabber_whiteboard/protocol/unsupported-protocol-u2c-01.svg deleted file mode 100644 index 36ddf78ba..000000000 --- a/src/jabber_whiteboard/protocol/unsupported-protocol-u2c-01.svg +++ /dev/null @@ -1,277 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="unsupported-protocol-u2c-01.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.86180109" - inkscape:cx="457.5365" - inkscape:cy="582.23099" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" - showguides="true" - inkscape:guide-bbox="true" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000858px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61508" - y="120.14616" - id="text2992" - transform="matrix(0.996475,8.38928e-2,-8.38928e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61508" - y="120.14616">CHATROOM_SYNCHRONIZE_REQUEST</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session: unsupported protocol version error signaling (user-to-chat)</tspan></text> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect3187" - width="16.409977" - height="833.62683" - x="634.81885" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="614.79059" - y="77.251221" - id="text3189"><tspan - sodipodi:role="line" - id="tspan3191" - x="614.79059" - y="77.251221">Chat</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 632.52435,215.78213 L 116.58242,304.01936" - id="path3193" /> - <text - xml:space="preserve" - style="font-size:12.00010681px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="236.66701" - y="306.09424" - id="text3195" - transform="matrix(0.988528,-0.151038,0.151038,0.988528,0,0)"><tspan - sodipodi:role="line" - id="tspan3197" - x="236.66701" - y="306.09424">UNSUPPORTED_PROTOCOL_VERSION</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="650.8866" - y="216.45934" - id="text3207"><tspan - sodipodi:role="line" - x="650.8866" - y="216.45934" - id="tspan3211">(from user Juliet)</tspan><tspan - sodipodi:role="line" - x="650.8866" - y="231.45934" - id="tspan3398" /><tspan - sodipodi:role="line" - x="650.8866" - y="246.45934" - id="tspan3400">Message MUST</tspan><tspan - sodipodi:role="line" - x="650.8866" - y="261.45934" - id="tspan3402">be sent with</tspan><tspan - sodipodi:role="line" - x="650.8866" - y="276.45934" - id="tspan3404">Alice's protocol</tspan><tspan - sodipodi:role="line" - x="650.8866" - y="291.45934" - id="tspan3406">revision.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="117.19642" - y="319.97647" - id="text3142"><tspan - sodipodi:role="line" - id="tspan3144" - x="117.19642" - y="319.97647">Inkboard notifies Romeo that she is attempting</tspan><tspan - sodipodi:role="line" - x="117.19642" - y="334.97647" - id="tspan3146">to connect to a chatroom in which all clients</tspan><tspan - sodipodi:role="line" - x="117.19642" - y="349.97647" - id="tspan3150">are using a version of the Inkboard protocol</tspan><tspan - sodipodi:role="line" - x="117.19642" - y="364.97647" - id="tspan2177">that is incompatible with Romeo's client.</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 637.38647,342.15763 L 121.44454,430.39486" - id="path3152" /> - <text - xml:space="preserve" - style="font-size:12.00020504px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="222.38684" - y="431.75641" - id="text3154" - transform="matrix(0.988528,-0.151038,0.151038,0.988528,0,0)"><tspan - sodipodi:role="line" - id="tspan3156" - x="222.38684" - y="431.75641">UNSUPPORTED_PROTOCOL_VERSION</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="467.10638" - y="388.63593" - id="text3158"><tspan - sodipodi:role="line" - id="tspan3160" - x="467.10638" - y="388.63593">Other notifications of </tspan><tspan - sodipodi:role="line" - x="467.10638" - y="403.63593" - id="tspan3162">incorrect protocol version</tspan><tspan - sodipodi:role="line" - x="467.10638" - y="418.63593" - id="tspan3166">from other chatroom users</tspan><tspan - sodipodi:role="line" - x="467.10638" - y="433.63593" - id="tspan3164">are ignored by Romeo.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="153.1676" - y="578.93506" - id="text3168"><tspan - sodipodi:role="line" - x="153.1676" - y="578.93506" - id="tspan3172">NOTE: This scheme has at least one big flaw.</tspan><tspan - sodipodi:role="line" - x="153.1676" - y="593.93506" - id="tspan3202">It allows for the creation of malicious agents that could be targeted to </tspan><tspan - sodipodi:role="line" - x="153.1676" - y="608.93506" - id="tspan3213">try to block a specific user by sending UNSUPPORTED_PROTOCOL_VERSION</tspan><tspan - sodipodi:role="line" - x="153.1676" - y="623.93506" - id="tspan3215">messages.</tspan><tspan - sodipodi:role="line" - x="153.1676" - y="638.93506" - id="tspan3217" /><tspan - sodipodi:role="line" - x="153.1676" - y="653.93506" - id="tspan3219">The ordering of messages is handled by the Jabber MUC server, so such an</tspan><tspan - sodipodi:role="line" - x="153.1676" - y="668.93506" - id="tspan3221">attack will not always work, but the possibility of it working certainly</tspan><tspan - sodipodi:role="line" - x="153.1676" - y="683.93506" - id="tspan3223">exists. A better way would be to encode the required protocol version(s)</tspan><tspan - sodipodi:role="line" - x="153.1676" - y="698.93506" - id="tspan3225">in the chatroom itself, but I haven't worked that out just yet.</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/protocol/unsupported-protocol-u2u-01.svg b/src/jabber_whiteboard/protocol/unsupported-protocol-u2u-01.svg deleted file mode 100644 index 5e7c4156c..000000000 --- a/src/jabber_whiteboard/protocol/unsupported-protocol-u2u-01.svg +++ /dev/null @@ -1,174 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.43+devel" - sodipodi:docbase="/home/trythil/src/inkscape-integrate/src/jabber_whiteboard/protocol" - sodipodi:docname="unsupported-protocol-u2u-01.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Lend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lend" - style="overflow:visible;"> - <path - id="path2982" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.8) rotate(180)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.86180109" - inkscape:cx="454.05542" - inkscape:cy="653.01298" - inkscape:document-units="px" - inkscape:current-layer="layer1" - inkscape:window-width="1392" - inkscape:window-height="995" - inkscape:window-x="0" - inkscape:window-y="3" - showguides="true" - inkscape:guide-bbox="true" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect1925" - width="16.409977" - height="833.62683" - x="96.818855" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="68.790588" - y="77.251221" - id="text1929"><tspan - sodipodi:role="line" - id="tspan1931" - x="68.790588" - y="77.251221">Romeo</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 103.39752,133.41817 L 624.59663,181.72315" - id="path1937" /> - <text - xml:space="preserve" - style="font-size:12.00000858px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="289.61508" - y="120.14616" - id="text2992" - transform="matrix(0.996475,8.38928e-2,-8.38928e-2,0.996475,0,0)"><tspan - sodipodi:role="line" - id="tspan2994" - x="289.61508" - y="120.14616">CONNECT_REQUEST_USER</tspan></text> - <text - xml:space="preserve" - style="font-size:13.0673542px;font-style:normal;font-weight:normal;line-height:125%;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="5.7987185" - y="23.14624" - id="text2996" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2998" - x="5.7987185" - y="23.14624" - style="font-size:18.44846344px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans">Inkboard session: unsupported protocol version error signaling (user-to-user)</tspan></text> - <rect - style="opacity:1;color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - id="rect3187" - width="16.409977" - height="833.62683" - x="634.81885" - y="90.737564" - ry="1.7290077" /> - <text - xml:space="preserve" - style="font-size:28.80731773px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="614.79059" - y="77.251221" - id="text3189"><tspan - sodipodi:role="line" - id="tspan3191" - x="614.79059" - y="77.251221">Juliet</tspan></text> - <path - style="opacity:1;color:black;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:1.02934766px;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Lend);stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" - d="M 632.52435,215.78213 L 116.58242,304.01936" - id="path3193" /> - <text - xml:space="preserve" - style="font-size:12.00010681px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="236.66701" - y="306.09424" - id="text3195" - transform="matrix(0.988528,-0.151038,0.151038,0.988528,0,0)"><tspan - sodipodi:role="line" - id="tspan3197" - x="236.66701" - y="306.09424">UNSUPPORTED_PROTOCOL_VERSION</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="116.55498" - y="321.65576" - id="text3098"><tspan - sodipodi:role="line" - id="tspan3100" - x="116.55498" - y="321.65576">Inkboard notifies Romeo that Juliet is not running</tspan><tspan - sodipodi:role="line" - x="116.55498" - y="336.65576" - id="tspan3102">a compatible Inkboard client.</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="394.91898" - y="192.98698" - id="text3104"><tspan - sodipodi:role="line" - x="394.91898" - y="192.98698" - id="tspan3108">Inkboard does not notify Juliet of Bob's</tspan><tspan - sodipodi:role="line" - x="394.91898" - y="207.98698" - id="tspan3112">connection attempt.</tspan></text> - </g> -</svg> diff --git a/src/jabber_whiteboard/session-file-selector.cpp b/src/jabber_whiteboard/session-file-selector.cpp deleted file mode 100644 index 854d61d10..000000000 --- a/src/jabber_whiteboard/session-file-selector.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Session file selector widget - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm.h> -#include <gtkmm.h> - -#include "session-file-selector.h" - -#include <glibmm/i18n.h> - -namespace Inkscape { - -namespace Whiteboard { - -SessionFileSelectorBox::SessionFileSelectorBox() : - _usesessionfile(_("_Write session file:"), true) -{ - this->_construct(); -} - -SessionFileSelectorBox::~SessionFileSelectorBox() -{ - -} - -bool -SessionFileSelectorBox::isSelected() -{ - return this->_usesessionfile.get_active(); -} - -Glib::ustring const& -SessionFileSelectorBox::getFilename() -{ - return this->_filename; -} - -void -SessionFileSelectorBox::_construct() -{ - this->_getfilepath.set_label("..."); - - this->pack_start(this->_usesessionfile); - this->pack_start(this->_sessionfile); - this->pack_end(this->_getfilepath); - - this->_getfilepath.signal_clicked().connect(sigc::mem_fun(*this, &SessionFileSelectorBox::_callback)); -} - -void -SessionFileSelectorBox::_callback() { - Gtk::FileChooserDialog sessionfiledlg(_("Select a location and filename"), Gtk::FILE_CHOOSER_ACTION_SAVE); - sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - sessionfiledlg.add_button(_("Set filename"), Gtk::RESPONSE_OK); - int result = sessionfiledlg.run(); - switch (result) { - case Gtk::RESPONSE_OK: - { - this->_usesessionfile.set_active(); - this->_sessionfile.set_text(sessionfiledlg.get_filename()); - this->_filename = sessionfiledlg.get_filename(); - break; - } - case Gtk::RESPONSE_CANCEL: - default: - break; - } -} - -} - -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ diff --git a/src/jabber_whiteboard/session-file-selector.h b/src/jabber_whiteboard/session-file-selector.h deleted file mode 100644 index ed6101ac5..000000000 --- a/src/jabber_whiteboard/session-file-selector.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Session file selector widget - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_SESSION_FILE_SELECTOR_BOX_H__ -#define __WHITEBOARD_SESSION_FILE_SELECTOR_BOX_H__ - -#include <glibmm.h> -#include <gtkmm.h> - -namespace Inkscape { - -namespace Whiteboard { - -class SessionFileSelectorBox : public Gtk::HBox { -public: - SessionFileSelectorBox(); - virtual ~SessionFileSelectorBox(); - - bool isSelected(); - Glib::ustring const& getFilename(); - -private: - // Construction - void _construct(); - void _callback(); - - // GTK+ widgets - Gtk::CheckButton _usesessionfile; - Gtk::Entry _sessionfile; - Gtk::Button _getfilepath; - - // Internal state - Glib::ustring _filename; -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp deleted file mode 100644 index 60d0b7378..000000000 --- a/src/jabber_whiteboard/session-manager.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/** - * Whiteboard session manager - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * Bob Jamison (Pedro port) - * Abhishek Sharma - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <functional> -#include <algorithm> -#include <iostream> -#include <time.h> - -#include <gtkmm.h> -#include <glibmm/i18n.h> - -#include "xml/node.h" -#include "xml/repr.h" - -#include "util/ucompose.hpp" - -#include "xml/node-observer.h" - -#include "pedro/pedrodom.h" - -#include "ui/view/view-widget.h" - -#include "document-private.h" -#include "interface.h" -#include "sp-namedview.h" -#include "document.h" -#include "desktop.h" -#include "desktop-handles.h" - -#include "jabber_whiteboard/invitation-confirm-dialog.h" -#include "jabber_whiteboard/message-verifier.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/inkboard-document.h" -#include "jabber_whiteboard/defines.h" - -#include "jabber_whiteboard/dialog/choose-desktop.h" - -namespace Inkscape { - -namespace Whiteboard { - -//######################################################################### -//# S E S S I O N M A N A G E R -//######################################################################### - -SessionManager *sessionManagerInstance = NULL; - -void SessionManager::showClient() -{ - SessionManager::instance().gui.show(); -} - -SessionManager &SessionManager::instance() -{ - if (!sessionManagerInstance) { - sessionManagerInstance = new SessionManager(); - } - return *sessionManagerInstance; -} - -SessionManager::SessionManager() -{ - getClient().addXmppEventListener(*this); - - this->CheckPendingInvitations = - Glib::signal_timeout().connect(sigc::mem_fun( - *this, &SessionManager::checkInvitationQueue), 50); -} - -SessionManager::~SessionManager() -{ - getClient().removeXmppEventListener(*this); - getClient().disconnect(); -} - -/** - * Initiates a shared session with a user or conference room. - * - * \param to The recipient to which this desktop will be linked, specified as a JID. - * \param type Type of the session; i.e. private message or group chat. - */ -void -SessionManager::initialiseSession(Glib::ustring const& to, State::SessionType type) -{ - - SPDocument* doc = makeInkboardDocument(g_quark_from_static_string("xml"), "svg:svg", type, to); - InkboardDocument* inkdoc = dynamic_cast< InkboardDocument* >(doc->rdoc); - if(inkdoc == NULL) return; - - if(type == State::WHITEBOARD_PEER) - { - ChooseDesktop dialog; - int result = dialog.run(); - - if(result == Gtk::RESPONSE_OK) - { - SPDesktop *desktop = dialog.getDesktop(); - - if(desktop != NULL) - { - Inkscape::XML::Document *old_doc = - sp_desktop_document(desktop)->rdoc; - inkdoc->root()->mergeFrom(old_doc->root(),"id"); - } - }else { return; } - } - - char * sessionId = createSessionId(10); - - inkdoc->setSessionId(sessionId); - - makeInkboardDesktop(doc); - addSession(WhiteboardRecord(sessionId, inkdoc)); - - inkdoc->startSessionNegotiation(); - - -} - -void -SessionManager::terminateSession(Glib::ustring const& sessionId) -{ - WhiteboardList::iterator i = whiteboards.begin(); - for(; i != whiteboards.end(); ++i) { - if ((*i).first == sessionId) - break; - } - - if (i != whiteboards.end()) { - (*i).second->terminateSession(); - whiteboards.erase(i); - } -} - -void -SessionManager::addSession(WhiteboardRecord whiteboard) -{ - whiteboards.push_back(whiteboard); -} - -InkboardDocument* -SessionManager::getInkboardSession(Glib::ustring const& sessionId) -{ - WhiteboardList::iterator i = whiteboards.begin(); - for(; i != whiteboards.end(); ++i) { - if ((*i).first == sessionId) { - return (*i).second; - } - } - return NULL; -} - -void -SessionManager::processXmppEvent(const Pedro::XmppEvent &event) -{ - int type = event.getType(); - - switch (type) { - case Pedro::XmppEvent::EVENT_STATUS: - { - break; - } - case Pedro::XmppEvent::EVENT_ERROR: - { - break; - } - case Pedro::XmppEvent::EVENT_CONNECTED: - { - break; - } - case Pedro::XmppEvent::EVENT_DISCONNECTED: - { - break; - } - case Pedro::XmppEvent::EVENT_MUC_MESSAGE: - case Pedro::XmppEvent::EVENT_MESSAGE: - { - Pedro::Element *root = event.getDOM(); - - if (root && root->getTagAttribute("wb", "xmlns") == Vars::INKBOARD_XMLNS) - processWhiteboardEvent(event); - - break; - } - case Pedro::XmppEvent::EVENT_PRESENCE: - { - break; - } - case Pedro::XmppEvent::EVENT_MUC_JOIN: - { - break; - } - case Pedro::XmppEvent::EVENT_MUC_LEAVE: - { - break; - } - case Pedro::XmppEvent::EVENT_MUC_PRESENCE: - { - break; - } - default: - { - break; - } - } -} - -/** - * Handles all incoming messages from pedro within a valid namespace, CONNECT_REQUEST messages - * are handled here, as they have no InkboardDocument to be handled from, all other messages - * are passed to their appropriate Inkboard document, which is identified by the 'session' - * attribute of the 'wb' element - * - */ -void -SessionManager::processWhiteboardEvent(Pedro::XmppEvent const& event) -{ - Pedro::Element* root = event.getDOM(); - if (root == NULL) { - g_warning("Received null DOM; ignoring message."); - return; - } - - Pedro::DOMString session = root->getTagAttribute("wb", "session"); - Pedro::DOMString type = root->getTagAttribute("message", "type"); - Pedro::DOMString domwrapper = root->getFirstChild()->getFirstChild()->getFirstChild()->getName(); - - if (session.empty()) { - g_warning("Received incomplete Whiteboard message, missing session identifier; ignoring message."); - return; - } - - if(root->exists(Message::CONNECT_REQUEST) && type == State::WHITEBOARD_PEER) - { - handleIncomingInvitation(Invitation(event.getFrom(),session)); - - }else - { - Message::Wrapper wrapper = static_cast< Message::Wrapper >(domwrapper); - InkboardDocument* doc = getInkboardSession(session); - - if(doc != NULL) - doc->recieve(wrapper, root->getFirstChild()); - } -} - -char* -SessionManager::createSessionId(int size) -{ - // Create a random session identifier - char * randomString = (char*) malloc (size); - for (int n=0; n<size; n++) - randomString[n]=rand()%26+'a'; - randomString[size+1]='\0'; - - return randomString; -} - -/** - * Adds an invitation to a queue to be executed in SessionManager::_checkInvitationQueue() - * as when this method is called, we're still executing in Pedro's context, which causes - * issues when we run a dialog main loop. - * - */ -void -SessionManager::handleIncomingInvitation(Invitation invitation) -{ - // don't insert duplicate invitations - if (std::find(invitations.begin(),invitations.end(),invitation) != invitations.end()) - return; - - invitations.push_back(invitation); - -} - -bool -SessionManager::checkInvitationQueue() -{ - // The user is currently busy with an action. Defer invitation processing - // until the user is free. - int x, y; - Gdk::ModifierType mt; - Gdk::Display::get_default()->get_pointer(x, y, mt); - if (mt & GDK_BUTTON1_MASK) - return true; - - if (invitations.size() > 0) - { - // There's an invitation to process; process it. - Invitation invitation = invitations.front(); - Glib::ustring from = invitation.first; - Glib::ustring sessionId = invitation.second; - - Glib::ustring primary = - "<span weight=\"bold\" size=\"larger\">" + - String::ucompose(_("<b>%1</b> has invited you to a whiteboard session."), from) + - "</span>\n\n" + - String::ucompose(_("Do you wish to accept <b>%1</b>'s whiteboard session invitation?"), from); - - InvitationConfirmDialog dialog(primary); - - dialog.add_button(_("Accept invitation"), Dialog::ACCEPT_INVITATION); - dialog.add_button(_("Decline invitation"), Dialog::DECLINE_INVITATION); - - Dialog::DialogReply reply = static_cast< Dialog::DialogReply >(dialog.run()); - - - SPDocument* doc = makeInkboardDocument(g_quark_from_static_string("xml"), "svg:svg", State::WHITEBOARD_PEER, from); - - InkboardDocument* inkdoc = dynamic_cast< InkboardDocument* >(doc->rdoc); - if(inkdoc == NULL) return true; - - inkdoc->handleState(State::INITIAL,State::CONNECTING); - inkdoc->setSessionId(sessionId); - addSession(WhiteboardRecord(sessionId, inkdoc)); - - switch (reply) { - - case Dialog::ACCEPT_INVITATION:{ - inkdoc->send(from, Message::PROTOCOL,Message::ACCEPT_INVITATION); - makeInkboardDesktop(doc); - break; } - - case Dialog::DECLINE_INVITATION: default: { - inkdoc->send(from, Message::PROTOCOL,Message::DECLINE_INVITATION); - terminateSession(sessionId); - break; } - } - - invitations.pop_front(); - - } - - return true; -} - -//######################################################################### -//# HELPER FUNCTIONS -//######################################################################### - -SPDocument* -makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, Glib::ustring const& to) -{ - SPDocument* doc; - - InkboardDocument* rdoc = new InkboardDocument(g_quark_from_static_string("xml"), type, to); - rdoc->setAttribute("version", "1.0"); - rdoc->setAttribute("standalone", "no"); - XML::Node *comment = rdoc->createComment(" Created with Inkscape (http://www.inkscape.org/) "); - rdoc->appendChild(comment); - GC::release(comment); - - XML::Node* root = rdoc->createElement(rootname); - rdoc->appendChild(root); - GC::release(root); - - Glib::ustring name = String::ucompose( - _("Inkboard session (%1 to %2)"), SessionManager::instance().getClient().getJid(), to); - - doc = SPDocument::createDoc(rdoc, NULL, NULL, name.c_str(), TRUE); - g_return_val_if_fail(doc != NULL, NULL); - - return doc; -} - -// TODO: When the switchover to the new GUI is complete, this function should go away -// and be replaced with a call to Inkscape::NSApplication::Editor::createDesktop. -// It currently only exists to correctly mimic the desktop creation functionality -// in file.cpp. -// -// \see sp_file_new -SPDesktop *makeInkboardDesktop(SPDocument* doc) -{ - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); - g_return_val_if_fail(dtw != NULL, NULL); - doc->doUnref(); - - sp_create_window(dtw, TRUE); - SPDesktop *dt = static_cast<SPDesktop*>(dtw->view); - sp_namedview_window_from_document(dt); - sp_namedview_update_layers_from_document(dt); - - return dt; -} - -} // namespace Whiteboard - -} // namespace Inkscape - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/session-manager.h b/src/jabber_whiteboard/session-manager.h deleted file mode 100644 index ce57cc425..000000000 --- a/src/jabber_whiteboard/session-manager.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Whiteboard session manager - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * Bob Jamison (Pedro port) - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __INKSCAPE_WHITEBOARD_SESSION_MANAGER_H__ -#define __INKSCAPE_WHITEBOARD_SESSION_MANAGER_H__ - -#include <glibmm.h> - -#include <list> -#include <bitset> - -#include "desktop.h" - -#include "jabber_whiteboard/pedrogui.h" -#include "jabber_whiteboard/message-queue.h" -#include "jabber_whiteboard/defines.h" - -#include "gc-alloc.h" - -class SPDocument; -class SPDesktop; - - -namespace Inkscape { - -namespace Whiteboard { - -class InkboardDocument; - -typedef Glib::ustring from,sessionId; -typedef std::pair< Glib::ustring, InkboardDocument* > WhiteboardRecord; -typedef std::vector< WhiteboardRecord, GC::Alloc< WhiteboardRecord, GC::MANUAL > > WhiteboardList; - -typedef std::pair< from, sessionId > Invitation; -typedef std::list< Invitation > InvitationList; - -class SessionManager : public Pedro::XmppEventListener -{ - -public: - - SessionManager(); - - virtual ~SessionManager(); - - static void showClient(); - static SessionManager& instance(); - - virtual Pedro::XmppClient &getClient() - { return gui.client; } - - /** - * Handles all incoming XMPP events associated with this document - * apart from CONNECT_REQUEST, which is handled in SessionManager - */ - virtual void processXmppEvent(const Pedro::XmppEvent &event); - - - /** - * Initiates a shared session with a user or conference room. - * - * \param to The recipient to which this desktop will be linked, specified as a JID. - * \param type Type of the session; i.e. private message or group chat. - */ - virtual void initialiseSession(Glib::ustring const& to, State::SessionType type); - - /** - * Terminates an Inkboard session to a given recipient. If the session to be - * terminated does not exist, does nothing. - * - * \param sessionId The session identifier to be terminated. - */ - virtual void terminateSession(Glib::ustring const& sessionId); - - /** - * Adds a session to whiteboard - * - * \param sessionId The session identifier to be terminated. - */ - virtual void addSession(WhiteboardRecord whiteboard); - - /** - * Locates an Inkboard session by recipient JID. - * - * \param to The recipient JID identifying the session to be located. - * \return A pointer to the InkboardDocument associated with the Inkboard session, - * or NULL if no such session exists. - */ - InkboardDocument* getInkboardSession(Glib::ustring const& to); - - - void operator=(XmppEventListener const& /*other*/) - {} - -private: - - Pedro::PedroGui gui; - WhiteboardList whiteboards; - InvitationList invitations; - sigc::connection CheckPendingInvitations; - - void processWhiteboardEvent(Pedro::XmppEvent const& event); - - void handleIncomingInvitation(Invitation invitation); - - bool checkInvitationQueue(); - - char* createSessionId(int size); - -}; - -SPDocument* makeInkboardDocument(int code, gchar const* rootname, - State::SessionType type, Glib::ustring const& to); - -SPDesktop* makeInkboardDesktop(SPDocument* doc); - -} // namespace Whiteboard - -} // namespace Inkscape - -#endif /* __SESSION_MANAGER_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/jabber_whiteboard/tracker-node.h b/src/jabber_whiteboard/tracker-node.h deleted file mode 100644 index 02fea0050..000000000 --- a/src/jabber_whiteboard/tracker-node.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Whiteboard session manager - * XML node tracking facility - * - * Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_TRACKER_NODE_H__ -#define __WHITEBOARD_TRACKER_NODE_H__ - -#include "xml/node.h" - -#include "gc-managed.h" -#include "gc-finalized.h" - -#include <glibmm.h> -#include <bitset> - -namespace Inkscape { - -namespace Whiteboard { - -// set _size in TrackerNode private members if you add or delete -// any more listeners -enum ListenerType { - ATTR_CHANGED, - CHILD_ADDED, - CHILD_REMOVED, - CHILD_ORDER_CHANGED, - CONTENT_CHANGED -}; - -struct TrackerNode : public GC::Managed<> { -public: - TrackerNode(XML::Node const* n) : _node(n) - { - } - - virtual ~TrackerNode() - { - } - - void lock(ListenerType listener) - { - if (listener < _size) { - this->_listener_locks.set(listener, true); - } - } - - void unlock(ListenerType listener) - { - if (listener < _size) { - this->_listener_locks.set(listener, false); - } - } - - bool isLocked(ListenerType listener) - { - return (this->_listener_locks[listener]); - } - - XML::Node const* _node; - -private: - // change this if any other flags are added - static unsigned short const _size = 5; - std::bitset< _size > _listener_locks; - - // noncopyable, nonassignable - TrackerNode(TrackerNode const&); - TrackerNode& operator=(TrackerNode const&); -}; - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/pedro/CMakeLists.txt b/src/pedro/CMakeLists.txt deleted file mode 100644 index c51090067..000000000 --- a/src/pedro/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ - -set(pedro_SRC - #empty.cpp - #geckoembed.cpp - pedroconfig.cpp - pedrodom.cpp - #pedrogui.cpp - #pedromain.cpp - pedroutil.cpp - pedroxmpp.cpp -) - -# add_inkscape_lib(pedro_LIB "${pedro_SRC}") -add_inkscape_source("${pedro_SRC}") diff --git a/src/pedro/Makefile.mingw b/src/pedro/Makefile.mingw deleted file mode 100644 index 81c3d6ef6..000000000 --- a/src/pedro/Makefile.mingw +++ /dev/null @@ -1,199 +0,0 @@ -########################################################################### -# -# -# Makefile for the Pedro mini-XMPP client -# -# Authors: -# Bob Jamison -# -# Copyright (C) 2005-2007 Bob Jamison -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# -########################################################################## -# FILE SEPARATORS -# $(S) will be set to one of these -########################################################################## -BSLASH := \\# -FSLASH := / - -########################################################################## -# SENSE ARCHITECTURE -########################################################################## -ifdef ComSpec -ARCH=win32 -else -ARCH=xlib -endif - -########################################################################## -# WIN32 SETTINGS -########################################################################## -ifeq ($(ARCH),win32) - -####### Where is your GTK directory? -GTK=c:/gtk210 - -####### Same thing, DOS style -GTKDOS=c:\gtk210 - -#SSL=openssl-0.9.8a -SSL=$(GTK) - - - -CFLAGS = -g -Wall -DHAVE_SSL \ --DRELAYTOOL_SSL="static const int libssl_is_present=1; static int __attribute__((unused)) libssl_symbol_is_present(char *s){ return 1; }" - -INC = -I. -I$(GTK)/include -I$(SSL)/include - - -LIBSC = -mconsole -L$(GTK)/lib -L$(SSL) -lssl -lcrypto -lgdi32 -lws2_32 -LIBS = -mwindows -L$(GTK)/lib -L$(SSL) -lssl -lcrypto -lgdi32 -lws2_32 - -RM = del -CP = copy -S = $(BSLASH) - - -all: test.exe pedro.exe - -GTKINC = -DGLIBMM_DLL \ --I$(GTK)/include/glibmm-2.4 -I$(GTK)/lib/glibmm-2.4/include \ --I$(GTK)/include/gtkmm-2.4 -I$(GTK)/lib/gtkmm-2.4/include \ --I$(GTK)/include/gdkmm-2.4 -I$(GTK)/lib/gdkmm-2.4/include \ --I$(GTK)/include/pangomm-1.4 -I$(GTK)/include/pangomm-1.4 \ --I$(GTK)/include/atkmm-1.6 -I$(GTK)/include/cairomm-1.0 \ --I$(GTK)/include/sigc++-2.0 -I$(GTK)/lib/sigc++-2.0/include \ --I$(GTK)/include/gtk-2.0 -I$(GTK)/lib/gtk-2.0/include \ --I$(GTK)/include/atk-1.0 -I$(GTK)/include/pango-1.0 \ --I$(GTK)/include/glib-2.0 -I$(GTK)/lib/glib-2.0/include \ --I$(GTK)/include/cairo - -####### Our Gtk libs -GTKLIBS = -L$(GTK)/lib \ --lgtkmm-2.4 -lgdkmm-2.4 -lglibmm-2.4 \ --latkmm-1.6 -lpangomm-1.4 -lsigc-2.0 \ --lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 \ --lgdk_pixbuf-2.0 -lm -lpangoft2-1.0 -lpangowin32-1.0 -lpango-1.0 \ --lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 - -endif - - -########################################################################## -# XLIB SETTINGS -########################################################################## -ifeq ($(ARCH),xlib) - -CFLAGS = -g -Wall -DHAVE_SSL -DHAVE_PTHREAD_H -XINC = -I/usr/X11R6/include -XLIB = -L/usr/X11R6/lib -lXrender -lX11 -INC = -I. -I.. $(XINC) -LIBS = $(XLIB) -lpthread -lssl -RM = rm -rf -CP = cp -S = $(FSLASH) -all: test pedro - -GTKINC += `pkg-config gtkmm-2.4 --cflags` -GTKLIBS += `pkg-config gtkmm-2.4 --libs` - -endif - - - -OBJ = \ -pedrodom.o \ -pedroxmpp.o \ -pedroconfig.o \ -pedroutil.o - - -GUIOBJ = \ -pedrogui.o \ -geckoembed.o \ -pedromain.o - - -TESTOBJ = \ -work/test.o \ -work/filesend.o \ -work/filerec.o \ -work/groupchat.o - -test.exe: libpedro.a work/test.o - $(CXX) -o $@ work/test.o libpedro.a $(LIBSC) -test: libpedro.a work/test.o - $(CXX) -o $@ work/test.o libpedro.a $(LIBSC) - -filesend.exe: libpedro.a work/filesend.o - $(CXX) -o $@ work/filesend.o libpedro.a $(LIBSC) -filesend: libpedro.a work/filesend.o - $(CXX) -o $@ work/filesend.o libpedro.a $(LIBSC) - -filerec.exe: libpedro.a work/filerec.o - $(CXX) -o $@ work/filerec.o libpedro.a $(LIBSC) -filerec: libpedro.a work/filerec.o - $(CXX) -o $@ work/filerec.o libpedro.a $(LIBSC) - -groupchat.exe: libpedro.a work/groupchat.o - $(CXX) -o $@ work/groupchat.o libpedro.a $(LIBSC) -groupchat: libpedro.a work/groupchat.o - $(CXX) -o $@ work/groupchat.o libpedro.a $(LIBSC) - -pedro.exe: libpedro.a $(GUIOBJ) - $(CXX) -o $@ pedromain.o pedrogui.o libpedro.a $(GTKLIBS) $(LIBS) -pedro: libpedro.a pedromain.o pedrogui.o - $(CXX) -o $@ pedromain.o pedrogui.o libpedro.a $(GTKLIBS) $(LIBS) - - -libpedro.a: $(OBJ) - ar crv libpedro.a $(OBJ) - -pedromain.o: pedromain.cpp - $(CXX) $(CFLAGS) $(INC) $(GTKINC) -c -o $@ $< - -pedrogui.o: pedrogui.cpp pedrogui.h - $(CXX) $(CFLAGS) $(INC) $(GTKINC) -c -o $@ $< - -geckoembed.o: geckoembed.cpp geckoembed.h - $(CXX) $(CFLAGS) $(INC) $(GTKINC) -c -o $@ $< - -.cpp.o: - $(CXX) $(CFLAGS) $(INC) -c -o $@ $< - -clean: - $(foreach a, $(OBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - $(foreach a, $(GUIOBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - $(foreach a, $(TESTOBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - -$(RM) *.a - -$(RM) test - -$(RM) test.exe - -$(RM) filesend - -$(RM) filesend.exe - -$(RM) filerec - -$(RM) filerec.exe - -$(RM) groupchat - -$(RM) groupchat.exe - -$(RM) pedro - -$(RM) pedro.exe - -$(RM) core.* - -########################################################################### -# E N D O F F I L E -########################################################################### - diff --git a/src/pedro/Makefile_insert b/src/pedro/Makefile_insert deleted file mode 100644 index bc9d32fdb..000000000 --- a/src/pedro/Makefile_insert +++ /dev/null @@ -1,26 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. -# -# Pedro mini-XMPP client, used for Inkboard's Jabber functionality -# Author: Bob Jamison - -pedro/all: pedro/libpedro.a -pedro/clean: - rm -f pedro/libpedro.a $(pedro_libpedro_a_OBJECTS) - -pedro_SOURCES= \ - pedro/pedroconfig.cpp \ - pedro/pedroconfig.h \ - pedro/pedrodom.cpp \ - pedro/pedrodom.h \ - pedro/pedroutil.cpp \ - pedro/pedroutil.h \ - pedro/pedroxmpp.cpp \ - pedro/pedroxmpp.h - -if WITH_INKBOARD -temp_pedro_files = $(pedro_SOURCES) -endif - -pedro_libpedro_a_SOURCES = \ - pedro/empty.cpp \ - $(temp_pedro_files) diff --git a/src/pedro/certs/client.pem b/src/pedro/certs/client.pem deleted file mode 100644 index 06f2e6ce0..000000000 --- a/src/pedro/certs/client.pem +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,6D3B09E4CA5421FF - -SaDJA2MhJ12ZmDxfGkSLhQgjYPEQYqVfs5b4DZTz+9pJqzuNxHrZZU43oArbWBdB -3DKc1THejbyHF2lY7xgPLk/5iax5r+CXesDKZroSliHyERBIOCUgDN6ecwvVGtYv -C8IhlwGPEXyxr59lyV37RjkSUVXYBqiRbLlNIcQtp5T6GkFe+yftOnv6/UADCLTS -Pu8xwkda1rf7dgPwYIKuk2SOTTe1VMDtWacRUGu8NteTJ4aiVaeeo9wdsKId5U2b -Z7NTJjOjvdXOLRonfkGvDXmrmN4eICks0bV0ZBtkULAfGjKNGs6riY+XNGKNRmjI -idRRB0za+EGorpiJ/vbe7n7uaFXIJlfqCwhTi4Up3mS8sR4tLHfmdjp85GV9P9B3 -xX3CHIeG5/EYDt0Qn1gRL5ODL/0O7nFGJslhcQUS6bMmcg9nSzhClTE2gREz0j9g -pwzvRpEkIl3Tw4niZLIX8fW2cEIyKTBMCCG2MDwHHgXRL3SUXkOGeitFefkcXN/z -/UWRS8XQcX7/lGWCiuEpgn+esoirjf8lFNVsx6OT0UXj3oBxGrz1iB/vpu/PMBVQ -JsbEPSh/ElHSDUItw2ytjJmkolRtM01b7cFj16ZxbHjinXWTIGZFWUYIlaeA2zHK -D/NRMFJwjrQYhjRgPqltvbw7M01Co7SNFBwSotARr36FBjsxbOH3F1jY6w+kXvJU -X5m83C9UONM2K7kkKYXbE2yW+kzJF2LFX0Uu4yDluxNG767/WwqiQSI63aIzNAPp -rSsaIMBSbVZia8q49gcvGyuvqBZpwm/PcZwr/PHJjvGs8hdU1ACmyQ== ------END RSA PRIVATE KEY----- ------BEGIN CERTIFICATE----- -MIICFTCCAX4CAgECMA0GCSqGSIb3DQEBBAUAMFcxCzAJBgNVBAYTAlVTMRMwEQYD -VQQKEwpSVEZNLCBJbmMuMRkwFwYDVQQLExBXaWRnZXRzIERpdmlzaW9uMRgwFgYD -VQQDEw9UZXN0IENBMjAwMTA1MTcwHhcNMDEwNTE3MTYxMTM2WhcNMDQwMzA2MTYx -MTM2WjBOMQswCQYDVQQGEwJVUzETMBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UE -CxMQV2lkZ2V0cyBEaXZpc2lvbjEPMA0GA1UEAxMGY2xpZW50MIGfMA0GCSqGSIb3 -DQEBAQUAA4GNADCBiQKBgQCHNWSoNh6msUwYGGd7TYQDsdSG0ao6QXaYjk+78ZyM -QeZUBu2dZFjG4wnzkKwrD4rp/J5PLR9AdxR72lb9AavEOKL2UDHJGsscZkGVw/bz -ZbxrKF2rvdpZSvKP1OhV1MOds/WTpRm1gcmVSoV5vLOMqVjzjHoxQ/+1zpjzMxWL -0wIDAQABMA0GCSqGSIb3DQEBBAUAA4GBACTJhRR5tv8A7dc5+zmKR1Q/i8qE3Mrn -mp/MOXHfX+ifJ/w+twoc/yd4En+7pr+hGsiTofct1JOZDW9Akq/ZGu1+NpVRT7Cw -53EdMwpi7ArwZAsLIUBsKA7QmLTbdwjU5S7WlZ24eygZHyqZrK4Few+JuzlFkkoI -FIDCfinyz24m ------END CERTIFICATE----- diff --git a/src/pedro/certs/dh1024.pem b/src/pedro/certs/dh1024.pem deleted file mode 100644 index aa68d98ec..000000000 --- a/src/pedro/certs/dh1024.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN DH PARAMETERS----- -MIGHAoGBANmAnfkETuKHOCWaE+W+F3kM/e7z5A8hZb7OqwGMQrUOaBEAr4BWeZBn -G/87hhwZgNP69/KUchm714qd/PpOspCaUJ20x6PcmKujpAgca/f19HGMBjRawQMk -R9oaBwazuQT0l0rTTKmvpMEcrQQIcVWii3CZI56I56oqF8biGPD7AgEC ------END DH PARAMETERS----- diff --git a/src/pedro/certs/root.pem b/src/pedro/certs/root.pem deleted file mode 100644 index db0c59fbf..000000000 --- a/src/pedro/certs/root.pem +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICIjCCAYugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJVUzET -MBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UECxMQV2lkZ2V0cyBEaXZpc2lvbjEY -MBYGA1UEAxMPVGVzdCBDQTIwMDEwNTE3MB4XDTAxMDUxNzE2MDExNFoXDTA2MTIy -NTE2MDExNFowVzELMAkGA1UEBhMCVVMxEzARBgNVBAoTClJURk0sIEluYy4xGTAX -BgNVBAsTEFdpZGdldHMgRGl2aXNpb24xGDAWBgNVBAMTD1Rlc3QgQ0EyMDAxMDUx -NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAmkX40warmH0+lnwD9YjsJhRz -ZX6qXadFry0y2trZ6gMs8Mv33IKPwOu8TE7V+3PESEtjI2wr8juV9OkbIPOm+td5 -M8+6vXyIW+JBo3ch99i0QMTf5/jTgsW+3IjV8yEdiGcZFp2NWKLRvZPq2VRbuF7R -1pvgcaRuBJ0wGOohwnsCAwEAATANBgkqhkiG9w0BAQQFAAOBgQCUB8zMKIlX5io8 -TalbzH9Qke7BcvFAL+wp/5w1ToVsWkNrINSWKv6bl/jcqOD3aPhK7qhaeOU8ZWKL -PoPPCnRl9Wo+1JtsOO3qIgJP79Bl9ooLGahixF2v/gea5qNISjQvwYllLSa//APP -6kXHngO0RIRbiTBYHSkAzm6hDdsvVA== ------END CERTIFICATE----- diff --git a/src/pedro/certs/server.pem b/src/pedro/certs/server.pem deleted file mode 100644 index 87376dbf0..000000000 --- a/src/pedro/certs/server.pem +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,5772A2A7BE34B611 - -1yJ+xAn4MudcIfXXy7ElYngJ9EohIh8yvcyVLmE4kVd0xeaL/Bqhvk25BjYCK5d9 -k1K8cjgnKEBjbC++0xtJxFSbUhwoKTLwn+sBoJDcFzMKkmJXXDbSTOaNr1sVwiAR -SnB4lhUcHguYoV5zlRJn53ft7t1mjB6RwGH+d1Zx6t95OqM1lnKqwekwmotVAWHj -ncu3N8qhmoPMppmzEv0fOo2/pK2WohcJykSeN5zBrZCUxoO0NBNEZkFUcVjR+KsA -1ZeI1mU60szqg+AoU/XtFcow8RtG1QZKQbbXzyfbwaG+6LqkHaWYKHQEI1546yWK -us1HJ734uUkZoyyyazG6PiGCYV2u/aY0i3qdmyDqTvmVIvve7E4glBrtDS9h7D40 -nPShIvOatoPzIK4Y0QSvrI3G1vTsIZT3IOZto4AWuOkLNfYS2ce7prOreF0KjhV0 -3tggw9pHdDmTjHTiIkXqheZxZ7TVu+pddZW+CuB62I8lCBGPW7os1f21e3eOD/oY -YPCI44aJvgP+zUORuZBWqaSJ0AAIuVW9S83Yzkz/tlSFHViOebyd8Cug4TlxK1VI -q6hbSafh4C8ma7YzlvqjMzqFifcIolcbx+1A6ot0UiayJTUra4d6Uc4Rbc9RIiG0 -jfDWC6aii9YkAgRl9WqSd31yASge/HDqVXFwR48qdlYQ57rcHviqxyrwRDnfw/lX -Mf6LPiDKEco4MKej7SR2kK2c2AgxUzpGZeAY6ePyhxbdhA0eY21nDeFd/RbwSc5s -eTiCCMr41OB4hfBFXKDKqsM3K7klhoz6D5WsgE6u3lDoTdz76xOSTg== ------END RSA PRIVATE KEY----- ------BEGIN CERTIFICATE----- -MIICGDCCAYECAgEBMA0GCSqGSIb3DQEBBAUAMFcxCzAJBgNVBAYTAlVTMRMwEQYD -VQQKEwpSVEZNLCBJbmMuMRkwFwYDVQQLExBXaWRnZXRzIERpdmlzaW9uMRgwFgYD -VQQDEw9UZXN0IENBMjAwMTA1MTcwHhcNMDEwNTE3MTYxMDU5WhcNMDQwMzA2MTYx -MDU5WjBRMQswCQYDVQQGEwJVUzETMBEGA1UEChMKUlRGTSwgSW5jLjEZMBcGA1UE -CxMQV2lkZ2V0cyBEaXZpc2lvbjESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqG -SIb3DQEBAQUAA4GNADCBiQKBgQCiWhMjNOPlPLNW4DJFBiL2fFEIkHuRor0pKw25 -J0ZYHW93lHQ4yxA6afQr99ayRjMY0D26pH41f0qjDgO4OXskBsaYOFzapSZtQMbT -97OCZ7aHtK8z0ZGNW/cslu+1oOLomgRxJomIFgW1RyUUkQP1n0hemtUdCLOLlO7Q -CPqZLQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAIumUwl1OoWuyN2xfoBHYAs+lRLY -KmFLoI5+iMcGxWIsksmA+b0FLRAN43wmhPnums8eXgYbDCrKLv2xWcvKDP3mps7m -AMivwtu/eFpYz6J8Mo1fsV4Ys08A/uPXkT23jyKo2hMu8mywkqXCXYF2e+7pEeBr -dsbmkWK5NgoMl8eM ------END CERTIFICATE----- diff --git a/src/pedro/empty.cpp b/src/pedro/empty.cpp deleted file mode 100644 index 2f20405d6..000000000 --- a/src/pedro/empty.cpp +++ /dev/null @@ -1 +0,0 @@ -// empty file to generate a null object file; needed by some archiver tools diff --git a/src/pedro/geckoembed.cpp b/src/pedro/geckoembed.cpp deleted file mode 100644 index 8f979ad88..000000000 --- a/src/pedro/geckoembed.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Implementation the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <stdarg.h> - -#ifdef GECKO_EMBED - -#include "geckoembed.h" - - -namespace Pedro -{ - - - - - - - - - - - - - - - - - - - -} //namespace Pedro - -#endif /* GECKO_EMBED */ -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/geckoembed.h b/src/pedro/geckoembed.h deleted file mode 100644 index af3970006..000000000 --- a/src/pedro/geckoembed.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __GECKOEMBED_H__ -#define __GECKOEMBED_H__ -/* - * Implementation the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <stdarg.h> - - -namespace Pedro -{ - - -class GeckoEmbed -{ -public: - - GeckoEmbed() - { - init(); - } - - virtual ~GeckoEmbed() - { - } - - - -private: - - void init() - { - } - - -}; - - -} //namespace Pedro -#define __GECKOEMBED_H__ -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/icon/Thumbs.db b/src/pedro/icon/Thumbs.db deleted file mode 100644 index b1142522c..000000000 Binary files a/src/pedro/icon/Thumbs.db and /dev/null differ diff --git a/src/pedro/icon/available.png b/src/pedro/icon/available.png deleted file mode 100644 index e88ebd45b..000000000 Binary files a/src/pedro/icon/available.png and /dev/null differ diff --git a/src/pedro/icon/away.png b/src/pedro/icon/away.png deleted file mode 100644 index 9bb899869..000000000 Binary files a/src/pedro/icon/away.png and /dev/null differ diff --git a/src/pedro/icon/chat.png b/src/pedro/icon/chat.png deleted file mode 100644 index 84ac5945a..000000000 Binary files a/src/pedro/icon/chat.png and /dev/null differ diff --git a/src/pedro/icon/dnd.png b/src/pedro/icon/dnd.png deleted file mode 100644 index 25c7a6e5f..000000000 Binary files a/src/pedro/icon/dnd.png and /dev/null differ diff --git a/src/pedro/icon/error.png b/src/pedro/icon/error.png deleted file mode 100644 index 35febd2ba..000000000 Binary files a/src/pedro/icon/error.png and /dev/null differ diff --git a/src/pedro/icon/offline.png b/src/pedro/icon/offline.png deleted file mode 100644 index 06284fa30..000000000 Binary files a/src/pedro/icon/offline.png and /dev/null differ diff --git a/src/pedro/icon/xa.png b/src/pedro/icon/xa.png deleted file mode 100644 index 309da1cb3..000000000 Binary files a/src/pedro/icon/xa.png and /dev/null differ diff --git a/src/pedro/makefile.in b/src/pedro/makefile.in deleted file mode 100644 index 8c8831f09..000000000 --- a/src/pedro/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) pedro/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) pedro/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/pedro/mingwenv.bat b/src/pedro/mingwenv.bat deleted file mode 100644 index f9ec1e7c5..000000000 --- a/src/pedro/mingwenv.bat +++ /dev/null @@ -1,2 +0,0 @@ -set PATH=c:\mingw4\bin;%PATH% -set RM=del diff --git a/src/pedro/pedro.bat b/src/pedro/pedro.bat deleted file mode 100644 index 6cae5a26e..000000000 --- a/src/pedro/pedro.bat +++ /dev/null @@ -1,2 +0,0 @@ -set path=c:\gtk28\bin;%path% -start pedro.exe diff --git a/src/pedro/pedroconfig.cpp b/src/pedro/pedroconfig.cpp deleted file mode 100644 index 250674477..000000000 --- a/src/pedro/pedroconfig.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Implementation the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -/* -==================================================== -We are expecting an xml file with this format: - -<pedro> - - <!-- zero to many of these --> - <account> - <name>Jabber's Main Server</name> - <host>jabber.org</host> - <port>5222</port> - <username>myname</username> - <password>mypassword</password> - </account> - -</pedro> - - -==================================================== -*/ - - - -#include "pedroconfig.h" -#include "pedrodom.h" - -#include <stdio.h> -#include <cstring> -#include <string> -#include <cstdlib> -#include <stdlib.h> -#include <string.h> - -namespace Pedro -{ - - -static long getInt(const DOMString &s) -{ - char *start = (char *) s.c_str(); - char *end; - long val = strtol(start, &end, 10); - if (end == start) // did we read more than 1 digit? - val = 0L; - return val; -} - - - -bool XmppConfig::read(const DOMString &buffer) -{ - Parser parser; - - Element *root = parser.parse(buffer); - - if (!root) - { - error("Error in configuration syntax"); - return false; - } - - accounts.clear(); - - std::vector<Element *> mucElems = root->findElements("muc"); - if (mucElems.size() > 0) - { - Element *elem = mucElems[0]; - mucGroup = elem->getTagValue("group"); - mucHost = elem->getTagValue("host"); - mucNick = elem->getTagValue("nick"); - mucPassword = elem->getTagValue("password"); - } - - std::vector<Element *> accountElems = root->findElements("account"); - - for (unsigned int i=0 ; i<accountElems .size() ; i++) - { - XmppAccount account; - Element *elem = accountElems [i]; - - DOMString str = elem->getTagValue("name"); - if (str.size()==0) - str = "unnamed account"; - account.setName(str); - - str = elem->getTagValue("host"); - if (str.size()==0) - str = "jabber.org"; - account.setHost(str); - - str = elem->getTagValue("port"); - int port = (int) getInt(str); - if (port == 0) - port = 5222; - account.setPort(port); - - str = elem->getTagValue("username"); - if (str.size()==0) - str = "noname"; - account.setUsername(str); - - str = elem->getTagValue("password"); - if (str.size()==0) - str = "nopass"; - account.setPassword(str); - - accounts.push_back(account); - } - - - delete root; - - return true; -} - - - - - - -bool XmppConfig::readFile(const DOMString &fileName) -{ - - FILE *f = fopen(fileName.c_str(), "rb"); - if (!f) - { - error("Could not open configuration file '%s' for reading", - fileName.c_str()); - return false; - } - - DOMString buffer; - while (!feof(f)) - { - char ch = (char) fgetc(f); - buffer.push_back(ch); - } - fclose(f); - - if (!read(buffer)) - return false; - - return true; -} - - -DOMString XmppConfig::toXmlBuffer() -{ - - DOMString buf; - - char fmtbuf[32]; - - buf.append("<pedro>\n"); - buf.append(" <muc>\n"); - buf.append(" <group>"); - buf.append(mucGroup); - buf.append("</group>\n"); - buf.append(" <host>"); - buf.append(mucHost); - buf.append("</host>\n"); - buf.append(" <nick>"); - buf.append(mucNick); - buf.append("</nick>\n"); - buf.append(" <password>"); - buf.append(mucPassword); - buf.append("</password>\n"); - buf.append(" </muc>\n"); - - for (unsigned int i = 0 ; i<accounts.size() ; i++) - { - XmppAccount acc = accounts[i]; - buf.append(" <account>\n"); - buf.append(" <name>"); - buf.append(acc.getName()); - buf.append("</name>\n"); - buf.append(" <host>"); - buf.append(acc.getHost()); - buf.append("</host>\n"); - buf.append(" <port>"); - snprintf(fmtbuf, 31, "%d", acc.getPort()); - buf.append(fmtbuf); - buf.append("</port>\n"); - buf.append(" <username>"); - buf.append(acc.getUsername()); - buf.append("</username>\n"); - buf.append(" <password>"); - buf.append(acc.getPassword()); - buf.append("</password>\n"); - buf.append(" </account>\n"); - } - - buf.append("</pedro>\n"); - - return buf; -} - - - - -bool XmppConfig::writeFile(const DOMString &fileName) -{ - - FILE *f = fopen(fileName.c_str(), "wb"); - if (!f) - { - error("Could not open configuration file '%s' for writing", - fileName.c_str()); - return false; - } - - DOMString buffer = toXmlBuffer(); - char *s = (char *)buffer.c_str(); - size_t len = (size_t) strlen(s); //in case we have wide chars - - if (fwrite(s, 1, len, f) != len) - { - return false; - } - fclose(f); - - if (!read(buffer)) - return false; - - return true; -} - - -/** - * - */ -DOMString XmppConfig::getMucGroup() -{ - return mucGroup; -} - -/** - * - */ -void XmppConfig::setMucGroup(const DOMString &val) -{ - mucGroup = val; -} - -/** - * - */ -DOMString XmppConfig::getMucHost() -{ - return mucHost; -} - -/** - * - */ -void XmppConfig::setMucHost(const DOMString &val) -{ - mucHost = val; -} - -/** - * - */ -DOMString XmppConfig::getMucNick() -{ - return mucNick; -} - -/** - * - */ -void XmppConfig::setMucNick(const DOMString &val) -{ - mucNick = val; -} - -/** - * - */ -DOMString XmppConfig::getMucPassword() -{ - return mucPassword; -} - -/** - * - */ -void XmppConfig::setMucPassword(const DOMString &val) -{ - mucPassword = val; -} - - - -/** - * - */ -std::vector<XmppAccount> &XmppConfig::getAccounts() -{ - return accounts; -} - - -/** - * - */ -bool XmppConfig::accountAdd(const XmppAccount &account) -{ - DOMString name = account.getName(); - if (name.size() < 1) - return false; - if (accountExists(name)) - return false; - accounts.push_back(account); - return true; -} - - -/** - * - */ -bool XmppConfig::accountExists(const DOMString &accountName) -{ - if (accountName.size() < 1) - return false; - std::vector<XmppAccount>::iterator iter; - for (iter = accounts.begin() ; iter!= accounts.end() ; iter++) - { - if (iter->getName() == accountName) - return true; - } - return false; -} - - - -/** - * - */ -void XmppConfig::accountRemove(const DOMString &accountName) -{ - if (accountName.size() < 1) - return; - std::vector<XmppAccount>::iterator iter; - for (iter = accounts.begin() ; iter!= accounts.end() ; ) - { - if (iter->getName() == accountName) - iter = accounts.erase(iter); - else - iter++; - } -} - - -/** - * - */ -bool XmppConfig::accountFind(const DOMString &accountName, - XmppAccount &retVal) -{ - if (accountName.size() < 1) - return false; - std::vector<XmppAccount>::iterator iter; - for (iter = accounts.begin() ; iter!= accounts.end() ; iter++) - { - if (iter->getName() == accountName) - { - retVal = (*iter); - return true; - } - } - return false; -} - - - - - -} //namespace Pedro -//######################################################################## -//# E N D O F F I L E -//######################################################################## diff --git a/src/pedro/pedroconfig.h b/src/pedro/pedroconfig.h deleted file mode 100644 index be8c6c665..000000000 --- a/src/pedro/pedroconfig.h +++ /dev/null @@ -1,317 +0,0 @@ -#ifndef __PEDROCONFIG_H__ -#define __PEDROCONFIG_H__ -/* - * Implementation the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "pedrodom.h" -#include "pedroxmpp.h" - -#include <vector> - - - -namespace Pedro -{ - - -/** - * Individual account record - */ -class XmppAccount -{ - -public: - - /** - * - */ - XmppAccount() - { init(); } - - /** - * - */ - XmppAccount(const XmppAccount &other) - { assign(other); } - - /** - * - */ - XmppAccount operator=(const XmppAccount &other) - { assign(other); return *this; } - - /** - * - */ - virtual ~XmppAccount() - {} - - - /** - * - */ - virtual DOMString getName() const - { return name; } - - /** - * - */ - virtual void setName(const DOMString &val) - { name = val; } - - /** - * - */ - virtual DOMString getHost() const - { return host; } - - /** - * - */ - virtual void setHost(const DOMString &val) - { host = val; } - - /** - * - */ - virtual int getPort() const - { return port; } - - /** - * - */ - virtual void setPort(int val) - { port = val; } - - /** - * - */ - virtual DOMString getUsername() const - { return username; } - - /** - * - */ - virtual void setUsername(const DOMString &val) - { username = val; } - - /** - * - */ - virtual DOMString getPassword() const - { return password; } - - /** - * - */ - virtual void setPassword(const DOMString &val) - { password = val; } - - - -private: - - void init() - { - name = "noname"; - host = "jabber.org"; - port = 5222; - username = "nobody"; - password = "nopass"; - } - - void assign(const XmppAccount &other) - { - name = other.name; - host = other.host; - port = other.port; - username = other.username; - password = other.password; - } - - DOMString name; - DOMString host; - int port; - DOMString username; - DOMString password; - -}; - - - -/** - * Configuration record - */ -class XmppConfig : XmppEventTarget -{ - -public: - - /** - * - */ - XmppConfig() - { init(); } - - /** - * - */ - XmppConfig(const XmppConfig &other) : XmppEventTarget(other) - { assign(other); } - - /** - * - */ - virtual XmppConfig &operator=(const XmppConfig &other) - { assign(other); return *this; } - - /** - * - */ - virtual ~XmppConfig() - {} - - - /** - * Parse a configuration xml chunk from a memory buffer - */ - virtual bool read(const DOMString &buffer); - - /** - * Parse a configuration file - */ - virtual bool readFile(const DOMString &fileName); - - /** - * Ouputs this object as a string formatted in XML - */ - virtual DOMString toXmlBuffer(); - - /** - * Write a configuration file - */ - virtual bool writeFile(const DOMString &fileName); - - /** - * - */ - virtual std::vector<XmppAccount> &getAccounts(); - - /** - * - */ - virtual DOMString getMucGroup(); - - /** - * - */ - virtual void setMucGroup(const DOMString &val); - - /** - * - */ - virtual DOMString getMucHost(); - - /** - * - */ - virtual void setMucHost(const DOMString &val); - - /** - * - */ - virtual DOMString getMucNick(); - - /** - * - */ - virtual void setMucNick(const DOMString &val); - - /** - * - */ - virtual DOMString getMucPassword(); - - /** - * - */ - virtual void setMucPassword(const DOMString &val); - - /** - * - */ - virtual bool accountAdd(const XmppAccount &account); - - /** - * - */ - virtual bool accountExists(const DOMString &accountName); - - /** - * - */ - virtual void accountRemove(const DOMString &accountName); - - /** - * - */ - bool accountFind(const DOMString &accountName, - XmppAccount &retVal); - - -private: - - void init() - { - } - - void assign(const XmppConfig &other) - { - accounts = other.accounts; - } - - //# Group stuff - DOMString mucGroup; - - DOMString mucHost; - - DOMString mucNick; - - DOMString mucPassword; - - std::vector<XmppAccount> accounts; - -}; - - - - -} //namespace Pedro - -#endif /* __PEDROCONFIG_H__ */ - -//######################################################################## -//# E N D O F F I L E -//######################################################################## diff --git a/src/pedro/pedrodom.cpp b/src/pedro/pedrodom.cpp deleted file mode 100644 index 1131e66b8..000000000 --- a/src/pedro/pedrodom.cpp +++ /dev/null @@ -1,802 +0,0 @@ -/* - * Implementation of the Pedro mini-DOM parser and tree - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> - - -#include "pedrodom.h" - -namespace Pedro -{ - - - -//######################################################################## -//# E L E M E N T -//######################################################################## - -Element *Element::clone() -{ - Element *elem = new Element(name, value); - elem->parent = parent; - elem->attributes = attributes; - elem->namespaces = namespaces; - - ElementList::iterator iter; - for (iter = children.begin(); iter != children.end() ; iter++) - { - elem->addChild((*iter)->clone()); - } - return elem; -} - - -void Element::findElementsRecursive(std::vector<Element *>&res, const DOMString &name) -{ - if (getName() == name) - { - res.push_back(this); - } - for (unsigned int i=0; i<children.size() ; i++) - children[i]->findElementsRecursive(res, name); -} - -std::vector<Element *> Element::findElements(const DOMString &name) -{ - std::vector<Element *> res; - findElementsRecursive(res, name); - return res; -} - -DOMString Element::getAttribute(const DOMString &name) -{ - for (unsigned int i=0 ; i<attributes.size() ; i++) - if (attributes[i].getName() ==name) - return attributes[i].getValue(); - return ""; -} - -DOMString Element::getTagAttribute(const DOMString &tagName, const DOMString &attrName) -{ - ElementList elems = findElements(tagName); - if (elems.size() <1) - return ""; - DOMString res = elems[0]->getAttribute(attrName); - return res; -} - -DOMString Element::getTagValue(const DOMString &tagName) -{ - ElementList elems = findElements(tagName); - if (elems.size() <1) - return ""; - DOMString res = elems[0]->getValue(); - return res; -} - -void Element::addChild(Element *child) -{ - if (!child) - return; - child->parent = this; - children.push_back(child); -} - - -void Element::addAttribute(const DOMString &name, const DOMString &value) -{ - Attribute attr(name, value); - attributes.push_back(attr); -} - -void Element::addNamespace(const DOMString &prefix, const DOMString &namespaceURI) -{ - Namespace ns(prefix, namespaceURI); - namespaces.push_back(ns); -} - -void Element::writeIndentedRecursive(FILE *f, int indent) -{ - int i; - if (!f) - return; - //Opening tag, and attributes - for (i=0;i<indent;i++) - fputc(' ',f); - fprintf(f,"<%s",name.c_str()); - for (unsigned int i=0 ; i<attributes.size() ; i++) - { - fprintf(f," %s=\"%s\"", - attributes[i].getName().c_str(), - attributes[i].getValue().c_str()); - } - for (unsigned int i=0 ; i<namespaces.size() ; i++) - { - fprintf(f," xmlns:%s=\"%s\"", - namespaces[i].getPrefix().c_str(), - namespaces[i].getNamespaceURI().c_str()); - } - fprintf(f,">\n"); - - //Between the tags - if (value.size() > 0) - { - for (int i=0;i<indent;i++) - fputc(' ', f); - fprintf(f," %s\n", value.c_str()); - } - - for (unsigned int i=0 ; i<children.size() ; i++) - children[i]->writeIndentedRecursive(f, indent+2); - - //Closing tag - for (int i=0; i<indent; i++) - fputc(' ',f); - fprintf(f,"</%s>\n", name.c_str()); -} - -void Element::writeIndented(FILE *f) -{ - writeIndentedRecursive(f, 0); -} - -void Element::print() -{ - writeIndented(stdout); -} - - -//######################################################################## -//# P A R S E R -//######################################################################## - - - -typedef struct - { - char *escaped; - char value; - } EntityEntry; - -static EntityEntry entities[] = -{ - { "&" , '&' }, - { "<" , '<' }, - { ">" , '>' }, - { "'", '\'' }, - { """, '"' }, - { NULL , '\0' } -}; - - - -/** - * Removes whitespace from beginning and end of a string - */ -DOMString Parser::trim(const DOMString &s) -{ - if (s.size() < 1) - return s; - - //Find first non-ws char - unsigned int begin = 0; - for ( ; begin < s.size() ; begin++) - { - if (!isspace(s[begin])) - break; - } - - //Find first non-ws char, going in reverse - unsigned int end = s.size() - 1; - for ( ; end > begin ; end--) - { - if (!isspace(s[end])) - break; - } - //trace("begin:%d end:%d", begin, end); - - DOMString res = s.substr(begin, end-begin+1); - return res; -} - -void Parser::getLineAndColumn(long pos, long *lineNr, long *colNr) -{ - long line = 1; - long col = 1; - for (long i=0 ; i<pos ; i++) - { - XMLCh ch = parsebuf[i]; - if (ch == '\n' || ch == '\r') - { - col = 0; - line ++; - } - else - col++; - } - *lineNr = line; - *colNr = col; - -} - - -void Parser::error(char const *fmt, ...) -{ - long lineNr; - long colNr; - getLineAndColumn(currentPosition, &lineNr, &colNr); - va_list args; - fprintf(stderr, "xml error at line %ld, column %ld:", lineNr, colNr); - va_start(args,fmt); - vfprintf(stderr,fmt,args); - va_end(args) ; - fprintf(stderr, "\n"); -} - - - -int Parser::peek(long pos) -{ - if (pos >= parselen) - return -1; - currentPosition = pos; - int ch = parsebuf[pos]; - //printf("ch:%c\n", ch); - return ch; -} - - - -DOMString Parser::encode(const DOMString &str) -{ - DOMString ret; - for (unsigned int i=0 ; i<str.size() ; i++) - { - XMLCh ch = (XMLCh)str[i]; - if (ch == '&') - ret.append("&"); - else if (ch == '<') - ret.append("<"); - else if (ch == '>') - ret.append(">"); - else if (ch == '\'') - ret.append("'"); - else if (ch == '"') - ret.append("""); - else - ret.push_back(ch); - - } - return ret; -} - - -int Parser::match(long p0, const char *text) -{ - int p = p0; - while (*text) - { - if (peek(p) != *text) - return p0; - p++; text++; - } - return p; -} - - - -int Parser::skipwhite(long p) -{ - - while (p<parselen) - { - int p2 = match(p, "<!--"); - if (p2 > p) - { - p = p2; - while (p<parselen) - { - p2 = match(p, "-->"); - if (p2 > p) - { - p = p2; - break; - } - p++; - } - } - XMLCh b = peek(p); - if (!isspace(b)) - break; - p++; - } - return p; -} - -/* modify this to allow all chars for an element or attribute name*/ -int Parser::getWord(int p0, DOMString &buf) -{ - int p = p0; - while (p<parselen) - { - XMLCh b = peek(p); - if (b<=' ' || b=='/' || b=='>' || b=='=') - break; - buf.push_back(b); - p++; - } - return p; -} - -int Parser::getQuoted(int p0, DOMString &buf, int do_i_parse) -{ - - int p = p0; - if (peek(p) != '"' && peek(p) != '\'') - return p0; - p++; - - while ( p<parselen ) - { - XMLCh b = peek(p); - if (b=='"' || b=='\'') - break; - if (b=='&' && do_i_parse) - { - bool found = false; - for (EntityEntry *ee = entities ; ee->value ; ee++) - { - int p2 = match(p, ee->escaped); - if (p2>p) - { - buf.push_back(ee->value); - p = p2; - found = true; - break; - } - } - if (!found) - { - error("unterminated entity"); - return false; - } - } - else - { - buf.push_back(b); - p++; - } - } - return p; -} - -int Parser::parseVersion(int p0) -{ - //printf("### parseVersion: %d\n", p0); - - int p = p0; - - p = skipwhite(p0); - - if (peek(p) != '<') - return p0; - - p++; - if (p>=parselen || peek(p)!='?') - return p0; - - p++; - - DOMString buf; - - while (p<parselen) - { - XMLCh ch = peek(p); - if (ch=='?') - { - p++; - break; - } - buf.push_back(ch); - p++; - } - - if (peek(p) != '>') - return p0; - p++; - - //printf("Got version:%s\n",buf.c_str()); - return p; -} - -int Parser::parseDoctype(int p0) -{ - //printf("### parseDoctype: %d\n", p0); - - int p = p0; - p = skipwhite(p); - - if (p>=parselen || peek(p)!='<') - return p0; - - p++; - - if (peek(p)!='!' || peek(p+1)=='-') - return p0; - p++; - - DOMString buf; - while (p<parselen) - { - XMLCh ch = peek(p); - if (ch=='>') - { - p++; - break; - } - buf.push_back(ch); - p++; - } - - //printf("Got doctype:%s\n",buf.c_str()); - return p; -} - -int Parser::parseElement(int p0, Element *par,int depth) -{ - - int p = p0; - - int p2 = p; - - p = skipwhite(p); - - //## Get open tag - XMLCh ch = peek(p); - if (ch!='<') - return p0; - - p++; - - DOMString openTagName; - p = skipwhite(p); - p = getWord(p, openTagName); - //printf("####tag :%s\n", openTagName.c_str()); - p = skipwhite(p); - - //Add element to tree - Element *n = new Element(openTagName); - n->parent = par; - par->addChild(n); - - // Get attributes - if (peek(p) != '>') - { - while (p<parselen) - { - p = skipwhite(p); - ch = peek(p); - //printf("ch:%c\n",ch); - if (ch=='>') - break; - else if (ch=='/' && p<parselen+1) - { - p++; - p = skipwhite(p); - ch = peek(p); - if (ch=='>') - { - p++; - //printf("quick close\n"); - return p; - } - } - DOMString attrName; - p2 = getWord(p, attrName); - if (p2==p) - break; - //printf("name:%s",buf); - p=p2; - p = skipwhite(p); - ch = peek(p); - //printf("ch:%c\n",ch); - if (ch!='=') - break; - p++; - p = skipwhite(p); - // ch = parsebuf[p]; - // printf("ch:%c\n",ch); - DOMString attrVal; - p2 = getQuoted(p, attrVal, true); - p=p2+1; - //printf("name:'%s' value:'%s'\n",attrName.c_str(),attrVal.c_str()); - char *namestr = (char *)attrName.c_str(); - if (strncmp(namestr, "xmlns:", 6)==0) - n->addNamespace(attrName, attrVal); - else - n->addAttribute(attrName, attrVal); - } - } - - bool cdata = false; - - p++; - // ### Get intervening data ### */ - DOMString data; - while (p<parselen) - { - //# COMMENT - p2 = match(p, "<!--"); - if (!cdata && p2>p) - { - p = p2; - while (p<parselen) - { - p2 = match(p, "-->"); - if (p2 > p) - { - p = p2; - break; - } - p++; - } - } - - ch = peek(p); - //# END TAG - if (ch=='<' && !cdata && peek(p+1)=='/') - { - break; - } - //# CDATA - p2 = match(p, "<![CDATA["); - if (p2 > p) - { - cdata = true; - p = p2; - continue; - } - - //# CHILD ELEMENT - if (ch == '<') - { - p2 = parseElement(p, n, depth+1); - if (p2 == p) - { - /* - printf("problem on element:%s. p2:%d p:%d\n", - openTagName.c_str(), p2, p); - */ - return p0; - } - p = p2; - continue; - } - //# ENTITY - if (ch=='&' && !cdata) - { - bool found = false; - for (EntityEntry *ee = entities ; ee->value ; ee++) - { - int p2 = match(p, ee->escaped); - if (p2>p) - { - data.push_back(ee->value); - p = p2; - found = true; - break; - } - } - if (!found) - { - error("unterminated entity"); - return -1; - } - continue; - } - - //# NONE OF THE ABOVE - data.push_back(ch); - p++; - }/*while*/ - - - n->value = data; - //printf("%d : data:%s\n",p,data.c_str()); - - //## Get close tag - p = skipwhite(p); - ch = peek(p); - if (ch != '<') - { - error("no < for end tag\n"); - return p0; - } - p++; - ch = peek(p); - if (ch != '/') - { - error("no / on end tag"); - return p0; - } - p++; - ch = peek(p); - p = skipwhite(p); - DOMString closeTagName; - p = getWord(p, closeTagName); - if (openTagName != closeTagName) - { - error("Mismatched closing tag. Expected </%s>. Got '%s'.", - openTagName.c_str(), closeTagName.c_str()); - return p0; - } - p = skipwhite(p); - if (peek(p) != '>') - { - error("no > on end tag for '%s'", closeTagName.c_str()); - return p0; - } - p++; - // printf("close element:%s\n",closeTagName.c_str()); - p = skipwhite(p); - return p; -} - - - - -Element *Parser::parse(XMLCh *buf,int pos,int len) -{ - parselen = len; - parsebuf = buf; - Element *rootNode = new Element("root"); - pos = parseVersion(pos); - pos = parseDoctype(pos); - pos = parseElement(pos, rootNode, 0); - return rootNode; -} - - -Element *Parser::parse(const char *buf, int pos, int len) -{ - XMLCh *charbuf = new XMLCh[len + 1]; - long i = 0; - for ( ; i < len ; i++) - charbuf[i] = (XMLCh)buf[i]; - charbuf[i] = '\0'; - - Element *n = parse(charbuf, pos, len); - delete[] charbuf; - return n; -} - -Element *Parser::parse(const DOMString &buf) -{ - long len = (long)buf.size(); - XMLCh *charbuf = new XMLCh[len + 1]; - long i = 0; - for ( ; i < len ; i++) - charbuf[i] = (XMLCh)buf[i]; - charbuf[i] = '\0'; - - Element *n = parse(charbuf, 0, len); - delete[] charbuf; - return n; -} - -Element *Parser::parseFile(const DOMString &fileName) -{ - - //##### LOAD INTO A CHAR BUF, THEN CONVERT TO XMLCh - FILE *f = fopen(fileName.c_str(), "rb"); - if (!f) - return NULL; - - struct stat statBuf; - if (fstat(fileno(f),&statBuf)<0) - { - fclose(f); - return NULL; - } - long filelen = statBuf.st_size; - - //printf("length:%d\n",filelen); - XMLCh *charbuf = new XMLCh[filelen + 1]; - for (XMLCh *p=charbuf ; !feof(f) ; p++) - { - *p = (XMLCh)fgetc(f); - } - fclose(f); - charbuf[filelen] = '\0'; - - - /* - printf("nrbytes:%d\n",wc_count); - printf("buf:%ls\n======\n",charbuf); - */ - Element *n = parse(charbuf, 0, filelen); - delete [] charbuf; - return n; -} - - - - - - - -}//namespace Pedro - -#if 0 -//######################################################################## -//# T E S T -//######################################################################## - -bool doTest(char *fileName) -{ - Pedro::Parser parser; - - Pedro::Element *elem = parser.parseFile(fileName); - - if (!elem) - { - printf("Parsing failed\n"); - return false; - } - - elem->print(); - - delete elem; - - return true; -} - - - -int main(int argc, char **argv) -{ - if (argc != 2) - { - printf("usage: %s <xmlfile>\n", argv[0]); - return 1; - } - - if (!doTest(argv[1])) - return 1; - - return 0; -} - -#endif - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - - diff --git a/src/pedro/pedrodom.h b/src/pedro/pedrodom.h deleted file mode 100644 index 91ad21da2..000000000 --- a/src/pedro/pedrodom.h +++ /dev/null @@ -1,363 +0,0 @@ -#ifndef __PEDRODOM_H__ -#define __PEDRODOM_H__ -/* - * API for the Pedro mini-DOM parser and tree - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <glib.h> - -#include <string> -#include <vector> - - -namespace Pedro -{ - -typedef std::string DOMString; -typedef unsigned int XMLCh; - - -class Namespace -{ -public: - Namespace() - {} - - Namespace(const DOMString &prefixArg, const DOMString &namespaceURIArg) - { - prefix = prefixArg; - namespaceURI = namespaceURIArg; - } - - Namespace(const Namespace &other) - { - assign(other); - } - - Namespace &operator=(const Namespace &other) - { - assign(other); - return *this; - } - - virtual ~Namespace() - {} - - virtual DOMString getPrefix() - { return prefix; } - - virtual DOMString getNamespaceURI() - { return namespaceURI; } - -protected: - - void assign(const Namespace &other) - { - prefix = other.prefix; - namespaceURI = other.namespaceURI; - } - - DOMString prefix; - DOMString namespaceURI; - -}; - -class Attribute -{ -public: - Attribute() - {} - - Attribute(const DOMString &nameArg, const DOMString &valueArg) - { - name = nameArg; - value = valueArg; - } - - Attribute(const Attribute &other) - { - assign(other); - } - - Attribute &operator=(const Attribute &other) - { - assign(other); - return *this; - } - - virtual ~Attribute() - {} - - virtual DOMString getName() - { return name; } - - virtual DOMString getValue() - { return value; } - -protected: - - void assign(const Attribute &other) - { - name = other.name; - value = other.value; - } - - DOMString name; - DOMString value; - -}; - - -//#Define a list of elements. (Children, search results, etc) -class Element; -typedef std::vector<Element *> ElementList; - - - -class Element -{ -friend class Parser; - -public: - Element() - { - parent = NULL; - } - - Element(const DOMString &nameArg) - { - parent = NULL; - name = nameArg; - } - - Element(const DOMString &nameArg, const DOMString &valueArg) - { - parent = NULL; - name = nameArg; - value = valueArg; - } - - Element(const Element &other) - { - assign(other); - } - - Element &operator=(const Element &other) - { - assign(other); - return *this; - } - - virtual Element *clone(); - - virtual ~Element() - { - for (unsigned int i=0 ; i<children.size() ; i++) - delete children[i]; - } - - virtual DOMString getName() - { return name; } - - virtual DOMString getValue() - { return value; } - - Element *getParent() - { return parent; } - - Element *getFirstChild() - { return (children.size() == 0) ? NULL : children[0]; } - - ElementList getChildren() - { return children; } - - ElementList findElements(const DOMString &name); - - DOMString getAttribute(const DOMString &name); - - std::vector<Attribute> &getAttributes() - { return attributes; } - - DOMString getTagAttribute(const DOMString &tagName, const DOMString &attrName); - - DOMString getTagValue(const DOMString &tagName); - - void addChild(Element *child); - - void addAttribute(const DOMString &name, const DOMString &value); - - void addNamespace(const DOMString &prefix, const DOMString &namespaceURI); - - bool exists(const DOMString &name) - { return (findElements(name).size() > 0); } - - /** - * Prettyprint an XML tree to an output stream. Elements are indented - * according to element hierarchy. - * @param f a stream to receive the output - * @param elem the element to output - */ - void writeIndented(FILE *f); - - /** - * Prettyprint an XML tree to standard output. This is the equivalent of - * writeIndented(stdout). - * @param elem the element to output - */ - void print(); - -protected: - - void assign(const Element &other) - { - parent = other.parent; - children = other.children; - attributes = other.attributes; - namespaces = other.namespaces; - name = other.name; - value = other.value; - } - - void findElementsRecursive(std::vector<Element *>&res, const DOMString &name); - - void writeIndentedRecursive(FILE *f, int indent); - - Element *parent; - - ElementList children; - - std::vector<Attribute> attributes; - std::vector<Namespace> namespaces; - - DOMString name; - DOMString value; - -}; - - - - - -class Parser -{ -public: - /** - * Constructor - */ - Parser() - { init(); } - - virtual ~Parser() - {} - - /** - * Parse XML in a char buffer. - * @param buf a character buffer to parse - * @param pos position to start parsing - * @param len number of chars, from pos, to parse. - * @return a pointer to the root of the XML document; - */ - Element *parse(const char *buf,int pos,int len); - - /** - * Parse XML in a char buffer. - * @param buf a character buffer to parse - * @param pos position to start parsing - * @param len number of chars, from pos, to parse. - * @return a pointer to the root of the XML document; - */ - Element *parse(const DOMString &buf); - - /** - * Parse a named XML file. The file is loaded like a data file; - * the original format is not preserved. - * @param fileName the name of the file to read - * @return a pointer to the root of the XML document; - */ - Element *parseFile(const DOMString &fileName); - - /** - * Utility method to preprocess a string for XML - * output, escaping its entities. - * @param str the string to encode - */ - static DOMString encode(const DOMString &str); - - /** - * Removes whitespace from beginning and end of a string - */ - DOMString trim(const DOMString &s); - -private: - - void init() - { - keepGoing = true; - currentNode = NULL; - parselen = 0; - parsebuf = NULL; - currentPosition = 0; - } - - void getLineAndColumn(long pos, long *lineNr, long *colNr); - - void error(char const *fmt, ...) G_GNUC_PRINTF(2,3); - - int peek(long pos); - - int match(long pos, const char *text); - - int skipwhite(long p); - - int getWord(int p0, DOMString &buf); - - int getQuoted(int p0, DOMString &buf, int do_i_parse); - - int parseVersion(int p0); - - int parseDoctype(int p0); - - int parseElement(int p0, Element *par,int depth); - - Element *parse(XMLCh *buf,int pos,int len); - - bool keepGoing; - Element *currentNode; - long parselen; - XMLCh *parsebuf; - DOMString cdatabuf; - long currentPosition; - int colNr; - -}; - - - -}//namespace Pedro - - -#endif /* __PEDRODOM_H__ */ - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/pedrogui.cpp b/src/pedro/pedrogui.cpp deleted file mode 100644 index 38c66b407..000000000 --- a/src/pedro/pedrogui.cpp +++ /dev/null @@ -1,2757 +0,0 @@ -/* - * Simple demo GUI for the Pedro mini-XMPP client. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "pedrogui.h" - -#include <stdarg.h> - -namespace Pedro -{ - - - -//######################################################################### -//# I C O N S -//######################################################################### - -static const guint8 icon_available[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\37733" - "3\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\0" - "\0\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377" - "\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377" - "\0\377\0\0\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377" - "\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""3" - "33\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377" - "\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0\0\377" - "\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0\0\377" - "\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377" - "\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_away[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0""333\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0" - "\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\0\0\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\0\0\377\377\377\377\0\377\0\0\377\377\377\377" - "\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\0\0\377" - "\377\0\0\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\0\0" - "\0\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\377\0\0\377\377\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377" - "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377" - "\377\377\377\0\0\377\377\0\0\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377" - "\377\0\0\0\377\377\377\377\377\377\0\0\377\377\377\377\0\377\0\0\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377\377\0\0\377" - "\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0LLL\377333\377\0\0\0\377\0\0\0\377LLL\377\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0"}; - - -static const guint8 icon_chat[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377" - "\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377\377\377\0\37733" - "3\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377" - "fff\377\377\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377333\377" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377fff" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0" - "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""33" - "3\377\377\377\0\377fff\377\377\377\0\377\0\0\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377fff\377\0\0\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377" - "\0\377\377\377\0\377\377\377\0""333\377\0\0\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0\377" - "\0\0\0\377\377\377\377\0\377\377\377\0""333\377\0\0\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0LLL\377\0\0\0\377" - "\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\0\0\0\377\377\377" - "\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0LLL\377333" - "\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377" - "\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377333\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377" - "\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_dnd[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377" - "\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377" - "\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377\377\377\0\37733" - "3\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377" - "fff\377\377\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377333\377" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377fff" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\177\0\0\377\177\0\0\377" - "\177\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0" - "333\377\377\377\0\377fff\377\377\377\0\377\177\0\0\377\377\0\0\377\377" - "\0\0\377\377\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\0\377fff\377\177\0\0\377\377\377\377\377fff\377" - "\377\0\0\377fff\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377" - "\377\0\377\377\377\0""333\377\177\0\0\377\377\0\0\377fff\377\377\377" - "\377\377fff\377\377\377\377\377fff\377\377\0\0\377\177\0\0\377\377\377" - "\377\0\377\377\377\0""333\377\177\0\0\377\377\0\0\377\377\0\0\377fff" - "\377\377\377\377\377fff\377\377\0\0\377\377\0\0\377\177\0\0\377\377\377" - "\377\0\377\377\377\0LLL\377\177\0\0\377\377\0\0\377fff\377\377\377\377" - "\377fff\377\377\377\377\377fff\377\377\0\0\377\177\0\0\377\377\377\377" - "\0\377\377\377\0LLL\377333\377\177\0\0\377\377\377\377\377fff\377\377" - "\0\0\377fff\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0""333\377333\377\177\0\0\377\377\0\0\377" - "\377\0\0\377\377\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\177\0\0\377\177\0\0\377\177\0\0\377\377\377\377\0\377\377" - "\377\0\377\377\377\0"}; - - -static const guint8 icon_error[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0""333\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\377\0\0\0\0\377\350\350\350\377333\377\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\350\350\350\377fff\377\0\0\0\377\350\350\350\377\350\350\350\377333" - "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\350\350\350\377\350\350\350\377\350\350\350\377\0\0\0\377\350\350\350" - "\377\350\350\350\377\350\350\350\377333\377\377\377\377\0\377\377\377" - "\0\377\377\377\0""333\377\350\350\350\377\350\350\350\377\0\0\0\377\0" - "\0\0\377fff\377\350\350\350\377\350\350\350\377333\377\377\377\377\0" - "\377\377\377\0\377\377\377\0""333\377\350\350\350\377\350\350\350\377" - "\0\0\0\377\350\350\350\377\0\0\0\377\0\0\0\377\0\0\0\377333\377\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377\350\350\350\377\0\0\0\377" - "\350\350\350\377\0\0\0\377\350\350\350\377\350\350\350\377\350\350\350" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""3" - "33\377\350\350\350\377\0\0\0\377\0\0\0\377\0\0\0\377\350\350\350\377" - "fff\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\0\0\0\377\350\350\350\377\350\350\350\377\350\350\350" - "\377\0\0\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377\350\350\350\377\350\350\350" - "\377\350\350\350\377333\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0" - "\377\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0" - "\0\377\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_offline[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\377\377\377\377\377\377\377\377\377\377333\377\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0""333\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\377\377\377\377\377\377\377333\377\377\377" - "\377\0\377\377\377\0\377\377\377\0""333\377\377\377\377\377\377\377\377" - "\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377\377\377\377" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377" - "\377\377\377\377\377\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377" - "\377\377\377\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377" - "\0""333\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377" - "\377\377\377\377\377\377\377\377\377\377\377\377333\377\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\377\377\377" - "\377\377\377\0\0\0\377\377\377\377\377\377\377\377\377333\377\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377" - "\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377\377\377\377\377" - "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0""333\377\377\377\377\377\377\377\377\377\377" - "\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0" - "\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377" - "\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0" - "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377" - "\0\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"}; - - -static const guint8 icon_xa[] = -{ "" - /* Pixbuf magic (0x47646b50) */ - "GdkP" - /* length: header (24) + pixel_data (672) */ - "\0\0\2\270" - /* pixdata_type (0x1010002) */ - "\1\1\0\2" - /* rowstride (48) */ - "\0\0\0""0" - /* width (12) */ - "\0\0\0\14" - /* height (14) */ - "\0\0\0\16" - /* pixel_data: */ - "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377333\377333\377" - "333\377\377\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\0\0\377333\377\377\377\0\377\377" - "\377\0\377\377\377\0\377333\377\377\0\0\377\377\377\377\0\377\377\377" - "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\0\0\377" - "\177\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0""333\377\377\0\0" - "\377\377\377\0\377fff\377\377\377\0\377\177\0\0\377\177\0\0\377\377\0" - "\0\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377\377\0""333\377" - "\377\0\0\377\177\0\0\377\177\0\0\377\177\0\0\377\377\377\377\377\377" - "\377\377\377\377\377\377\377\0\0\0\377\0\0\0\377\177\0\0\377\177\0\0" - "\377\177\0\0\377\377\0\0\377\377\377\377\377\377\377\377\377\377\377" - "\377\377\262\262\262\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377" - "\377\377\177\0\0\377\177\0\0\377\377\377\377\377\262\262\262\377\0\0" - "\0\377\262\262\262\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377" - "\377\262\262\262\377\0\0\0\377\177\0\0\377\177\0\0\377\377\377\377\377" - "\0\0\0\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\0\0\0" - "\377\0\0\0\377\377\377\377\377\0\0\0\377\177\0\0\377\177\0\0\377\377" - "\377\377\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377\0\0" - "\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\177" - "\0\0\377\377\377\377\0\177\0\0\377\262\262\262\377\0\0\0\377\262\262" - "\262\377\377\377\377\377\377\377\377\377\377\377\377\377\177\0\0\377" - "\177\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\177\0\0\377\377" - "\377\377\377\377\377\377\377\177\0\0\377\177\0\0\377\177\0\0\377\177" - "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\177\0\0\377\177\0\0\377\177\0\0\377333\377\0\0\0\377\0\0\0" - "\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" - "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377" - "333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" - "\377\0\377\377\377\0\377\377\377\0"}; - - -//######################################################################### -//# R O S T E R -//######################################################################### - - -void Roster::doubleClickCallback(const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col) -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("Double clicked:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); - -} - -void Roster::chatCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("Chat with:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); -} - -void Roster::sendFileCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(rosterColumns.userColumn); - //printf("Send file to:%s\n", nick.c_str()); - if (parent) - parent->doSendFile(nick); -} - -bool Roster::buttonPressCallback(GdkEventButton* event) -{ - if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) - { - Gtk::Widget *wid = uiManager->get_widget("/PopupMenu"); - Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid); - popupMenu->popup(event->button, event->time); - return true; - } - else - return false; -} - -bool Roster::doSetup() -{ - set_size_request(200,200); - - pixbuf_available = Gdk::Pixbuf::create_from_inline( - sizeof(icon_available), icon_available, false); - pixbuf_away = Gdk::Pixbuf::create_from_inline( - sizeof(icon_away), icon_away, false); - pixbuf_chat = Gdk::Pixbuf::create_from_inline( - sizeof(icon_chat), icon_chat, false); - pixbuf_dnd = Gdk::Pixbuf::create_from_inline( - sizeof(icon_dnd), icon_dnd, false); - pixbuf_error = Gdk::Pixbuf::create_from_inline( - sizeof(icon_error), icon_error, false); - pixbuf_offline = Gdk::Pixbuf::create_from_inline( - sizeof(icon_offline), icon_offline, false); - pixbuf_xa = Gdk::Pixbuf::create_from_inline( - sizeof(icon_xa), icon_xa, false); - - rosterView.setParent(this); - treeStore = Gtk::TreeStore::create(rosterColumns); - rosterView.set_model(treeStore); - - Gtk::CellRendererText *rend0 = new Gtk::CellRendererText(); - //rend0->property_background() = "gray"; - //rend0->property_foreground() = "black"; - rosterView.append_column("Group", *rend0); - Gtk::TreeViewColumn *col0 = rosterView.get_column(0); - col0->add_attribute(*rend0, "text", 0); - - Gtk::CellRendererPixbuf *rend1 = new Gtk::CellRendererPixbuf(); - rosterView.append_column("Status", *rend1); - Gtk::TreeViewColumn *col1 = rosterView.get_column(1); - col1->add_attribute(*rend1, "pixbuf", 1); - - Gtk::CellRendererText *rend2 = new Gtk::CellRendererText(); - rosterView.append_column("Item", *rend2); - Gtk::TreeViewColumn *col2 = rosterView.get_column(2); - col2->add_attribute(*rend2, "text", 2); - - Gtk::CellRendererText *rend3 = new Gtk::CellRendererText(); - rosterView.append_column("Name", *rend3); - Gtk::TreeViewColumn *col3 = rosterView.get_column(3); - col3->add_attribute(*rend3, "text", 3); - - Gtk::CellRendererText *rend4 = new Gtk::CellRendererText(); - rosterView.append_column("Subscription", *rend4); - Gtk::TreeViewColumn *col4 = rosterView.get_column(4); - col4->add_attribute(*rend4, "text", 4); - - rosterView.signal_row_activated().connect( - sigc::mem_fun(*this, &Roster::doubleClickCallback) ); - - add(rosterView); - set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - //##### POPUP MENU - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - - actionGroup->add( Gtk::Action::create("UserMenu", "_User Menu") ); - - actionGroup->add( Gtk::Action::create("Chat", - Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &Roster::chatCallback) ); - actionGroup->add( Gtk::Action::create("SendFile", - Gtk::Stock::CONNECT, "Send file"), - sigc::mem_fun(*this, &Roster::sendFileCallback) ); - - - uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - - Glib::ustring ui_info = - "<ui>" - " <popup name='PopupMenu'>" - " <menuitem action='Chat'/>" - " <menuitem action='SendFile'/>" - " </popup>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - - - show_all_children(); - - return true; -} - - -/** - * Clear the roster - */ -void Roster::clear() -{ - treeStore->clear(); -} - -/** - * Regenerate the roster - */ -void Roster::refresh() -{ - if (!parent) - return; - treeStore->clear(); - std::vector<XmppUser> items = parent->client.getRoster(); - - //## Add in tree fashion - DOMString lastGroup = ""; - Gtk::TreeModel::Row row = *(treeStore->append()); - row[rosterColumns.groupColumn] = ""; - for (unsigned int i=0 ; i<items.size() ; i++) - { - XmppUser user = items[i]; - if (user.group != lastGroup) - { - if (lastGroup.size()>0) - row = *(treeStore->append()); - row[rosterColumns.groupColumn] = user.group; - lastGroup = user.group; - } - Glib::RefPtr<Gdk::Pixbuf> pb = pixbuf_offline; - if (user.show == "available") - pb = pixbuf_available; - else if (user.show == "away") - pb = pixbuf_away; - else if (user.show == "chat") - pb = pixbuf_chat; - else if (user.show == "dnd") - pb = pixbuf_dnd; - else if (user.show == "xa") - pb = pixbuf_xa; - else - { - //printf("Unknown show for %s:'%s'\n", user.c_str(), show.c_str()); - } - Gtk::TreeModel::Row childRow = *(treeStore->append(row.children())); - childRow[rosterColumns.statusColumn] = pb; - childRow[rosterColumns.userColumn] = user.jid; - childRow[rosterColumns.nameColumn] = user.nick; - childRow[rosterColumns.subColumn] = user.subscription; - } - rosterView.expand_all(); -} - -//######################################################################### -//# M E S S A G E L I S T -//######################################################################### - -bool MessageList::doSetup() -{ - set_size_request(400,200); - - messageListBuffer = Gtk::TextBuffer::create(); - messageList.set_buffer(messageListBuffer); - messageList.set_editable(false); - messageList.set_wrap_mode(Gtk::WRAP_WORD_CHAR); - - Glib::RefPtr<Gtk::TextBuffer::TagTable> table = - messageListBuffer->get_tag_table(); - Glib::RefPtr<Gtk::TextBuffer::Tag> color0 = - Gtk::TextBuffer::Tag::create("color0"); - color0->property_foreground() = "DarkGreen"; - color0->property_weight() = Pango::WEIGHT_BOLD; - table->add(color0); - Glib::RefPtr<Gtk::TextBuffer::Tag> color1 = - Gtk::TextBuffer::Tag::create("color1"); - color1->property_foreground() = "chocolate4"; - color1->property_weight() = Pango::WEIGHT_BOLD; - table->add(color1); - Glib::RefPtr<Gtk::TextBuffer::Tag> color2 = - Gtk::TextBuffer::Tag::create("color2"); - color2->property_foreground() = "red4"; - color2->property_weight() = Pango::WEIGHT_BOLD; - table->add(color2); - Glib::RefPtr<Gtk::TextBuffer::Tag> color3 = - Gtk::TextBuffer::Tag::create("color3"); - color3->property_foreground() = "MidnightBlue"; - color3->property_weight() = Pango::WEIGHT_BOLD; - table->add(color3); - Glib::RefPtr<Gtk::TextBuffer::Tag> color4 = - Gtk::TextBuffer::Tag::create("color4"); - color4->property_foreground() = "turquoise4"; - color4->property_weight() = Pango::WEIGHT_BOLD; - table->add(color4); - Glib::RefPtr<Gtk::TextBuffer::Tag> color5 = - Gtk::TextBuffer::Tag::create("color5"); - color5->property_foreground() = "OliveDrab"; - color5->property_weight() = Pango::WEIGHT_BOLD; - table->add(color5); - Glib::RefPtr<Gtk::TextBuffer::Tag> color6 = - Gtk::TextBuffer::Tag::create("color6"); - color6->property_foreground() = "purple4"; - color6->property_weight() = Pango::WEIGHT_BOLD; - table->add(color6); - Glib::RefPtr<Gtk::TextBuffer::Tag> color7 = - Gtk::TextBuffer::Tag::create("color7"); - color7->property_foreground() = "VioletRed4"; - color7->property_weight() = Pango::WEIGHT_BOLD; - table->add(color7); - - add(messageList); - set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - - show_all_children(); - - return true; -} - -/** - * Clear all messages from the list - */ -void MessageList::clear() -{ - messageListBuffer->erase(messageListBuffer->begin(), - messageListBuffer->end()); -} - - -/** - * Post a message to the list - */ -void MessageList::postMessage(const DOMString &from, const DOMString &msg) -{ - DOMString out = "<"; - out.append(from); - out.append("> "); - - int val = 0; - for (unsigned int i=0 ; i<from.size() ; i++) - val += from[i]; - val = val % 8; - - char buf[16]; - sprintf(buf, "color%d", val); - DOMString tagName = buf; - - messageListBuffer->insert_with_tag( - messageListBuffer->end(), out, tagName); - messageListBuffer->insert(messageListBuffer->end(), msg); - messageListBuffer->insert(messageListBuffer->end(), "\n"); - //Gtk::Adjustment *adj = get_vadjustment(); - //adj->set_value(adj->get_upper()-adj->get_page_size()); - Glib::RefPtr<Gtk::TextBuffer::Mark> mark = - messageListBuffer->create_mark("temp", messageListBuffer->end()); - messageList.scroll_mark_onscreen(mark); - messageListBuffer->delete_mark(mark); -} - - - -//######################################################################### -//# U S E R L I S T -//######################################################################### -void UserList::doubleClickCallback(const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col) -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Double clicked:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); - -} - -void UserList::chatCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Chat with:%s\n", nick.c_str()); - if (parent) - parent->doChat(nick); -} - -void UserList::sendFileCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = userList.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString nick = iter->get_value(userListColumns.userColumn); - //printf("Send file to:%s\n", nick.c_str()); - if (parent) - parent->doSendFile(nick); -} - -bool UserList::buttonPressCallback(GdkEventButton* event) -{ - if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) - { - Gtk::Widget *wid = uiManager->get_widget("/PopupMenu"); - Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid); - popupMenu->popup(event->button, event->time); - return true; - } - else - return false; -} - -bool UserList::doSetup() -{ - set_size_request(200,200); - - setParent(NULL); - - pixbuf_available = Gdk::Pixbuf::create_from_inline( - sizeof(icon_available), icon_available, false); - pixbuf_away = Gdk::Pixbuf::create_from_inline( - sizeof(icon_away), icon_away, false); - pixbuf_chat = Gdk::Pixbuf::create_from_inline( - sizeof(icon_chat), icon_chat, false); - pixbuf_dnd = Gdk::Pixbuf::create_from_inline( - sizeof(icon_dnd), icon_dnd, false); - pixbuf_error = Gdk::Pixbuf::create_from_inline( - sizeof(icon_error), icon_error, false); - pixbuf_offline = Gdk::Pixbuf::create_from_inline( - sizeof(icon_offline), icon_offline, false); - pixbuf_xa = Gdk::Pixbuf::create_from_inline( - sizeof(icon_xa), icon_xa, false); - - userList.setParent(this); - userListStore = Gtk::ListStore::create(userListColumns); - userList.set_model(userListStore); - - Gtk::CellRendererPixbuf *rend0 = new Gtk::CellRendererPixbuf(); - userList.append_column("Status", *rend0); - Gtk::TreeViewColumn *col0 = userList.get_column(0); - col0->add_attribute(*rend0, "pixbuf", 0); - - Gtk::CellRendererText *rend1 = new Gtk::CellRendererText(); - //rend1->property_background() = "gray"; - //rend1->property_foreground() = "black"; - userList.append_column("User", *rend1); - Gtk::TreeViewColumn *col1 = userList.get_column(1); - col1->add_attribute(*rend1, "text", 1); - - userList.set_headers_visible(false); - - userList.signal_row_activated().connect( - sigc::mem_fun(*this, &UserList::doubleClickCallback) ); - - add(userList); - set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - //##### POPUP MENU - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - - actionGroup->add( Gtk::Action::create("UserMenu", "_User Menu") ); - - actionGroup->add( Gtk::Action::create("Chat", - Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &UserList::chatCallback) ); - actionGroup->add( Gtk::Action::create("SendFile", - Gtk::Stock::CONNECT, "Send file"), - sigc::mem_fun(*this, &UserList::sendFileCallback) ); - - - uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - - Glib::ustring ui_info = - "<ui>" - " <popup name='PopupMenu'>" - " <menuitem action='Chat'/>" - " <menuitem action='SendFile'/>" - " </popup>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - - show_all_children(); - - return true; -} - -/** - * Clear all messages from the list - */ -void UserList::clear() -{ - userListStore->clear(); -} - - -/** - * Add a user to the list - */ -void UserList::addUser(const DOMString &user, const DOMString &show) -{ - Glib::RefPtr<Gdk::Pixbuf> pb = pixbuf_offline; - if (show == "available") - pb = pixbuf_available; - else if (show == "away") - pb = pixbuf_away; - else if (show == "chat") - pb = pixbuf_chat; - else if (show == "dnd") - pb = pixbuf_dnd; - else if (show == "xa") - pb = pixbuf_xa; - else - { - //printf("Unknown show for %s:'%s'\n", user.c_str(), show.c_str()); - } - Gtk::TreeModel::Row row = *(userListStore->append()); - row[userListColumns.userColumn] = user; - row[userListColumns.statusColumn] = pb; -} - - - - -//######################################################################### -//# C H A T W I N D O W -//######################################################################### -ChatWindow::ChatWindow(PedroGui &par, const DOMString jidArg) - : parent(par) -{ - jid = jidArg; - doSetup(); -} - -ChatWindow::~ChatWindow() -{ -} - -void ChatWindow::leaveCallback() -{ - hide(); - parent.chatDelete(jid); -} - - -void ChatWindow::hideCallback() -{ - hide(); - parent.chatDelete(jid); -} - - -void ChatWindow::textEnterCallback() -{ - DOMString str = inputTxt.get_text(); - if (str.size() > 0) - parent.client.message(jid, str); - inputTxt.set_text(""); - messageList.postMessage(parent.client.getJid(), str); -} - -bool ChatWindow::doSetup() -{ - DOMString title = "Private Chat - "; - title.append(jid); - set_title(title); - - set_size_request(500,300); - - signal_hide().connect( - sigc::mem_fun(*this, &ChatWindow::hideCallback) ); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Leave", Gtk::Stock::CANCEL), - sigc::mem_fun(*this, &ChatWindow::leaveCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Leave'/>" - " </menu>" - " </menubar>" - "</ui>"; - - add(vbox); - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - vbox.pack_end(vPaned); - - vPaned.add1(messageList); - vPaned.add2(inputTxt); - - inputTxt.signal_activate().connect( - sigc::mem_fun(*this, &ChatWindow::textEnterCallback) ); - - show_all_children(); - - return true; -} - -bool ChatWindow::postMessage(const DOMString &data) -{ - messageList.postMessage(jid, data); - return true; -} - -//######################################################################### -//# G R O U P C H A T W I N D O W -//######################################################################### - -GroupChatWindow::GroupChatWindow(PedroGui &par, - const DOMString &groupJidArg, - const DOMString &nickArg) - : parent(par) -{ - groupJid = groupJidArg; - nick = nickArg; - doSetup(); -} - -GroupChatWindow::~GroupChatWindow() -{ -} - - -void GroupChatWindow::leaveCallback() -{ - parent.client.groupChatLeave(groupJid, nick); - hide(); - parent.groupChatDelete(groupJid, nick); -} - -void GroupChatWindow::hideCallback() -{ - parent.client.groupChatLeave(groupJid, nick); - hide(); - parent.groupChatDelete(groupJid, nick); -} - -void GroupChatWindow::textEnterCallback() -{ - DOMString str = inputTxt.get_text(); - if (str.size() > 0) - parent.client.groupChatMessage(groupJid, str); - inputTxt.set_text(""); -} - -bool GroupChatWindow::doSetup() -{ - DOMString title = "Group Chat - "; - title.append(groupJid); - set_title(title); - - userList.setParent(this); - - set_size_request(500,300); - - signal_hide().connect( - sigc::mem_fun(*this, &GroupChatWindow::hideCallback) ); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Leave", Gtk::Stock::CANCEL), - sigc::mem_fun(*this, &GroupChatWindow::leaveCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Leave'/>" - " </menu>" - " </menubar>" - "</ui>"; - - add(vbox); - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - vbox.pack_end(vPaned); - - vPaned.add1(hPaned); - vPaned.add2(inputTxt); - inputTxt.signal_activate().connect( - sigc::mem_fun(*this, &GroupChatWindow::textEnterCallback) ); - - - hPaned.add1(messageList); - hPaned.add2(userList); - - - show_all_children(); - - - return true; -} - -bool GroupChatWindow::receiveMessage(const DOMString &from, - const DOMString &data) -{ - messageList.postMessage(from, data); - return true; -} - -bool GroupChatWindow::receivePresence(const DOMString &fromNick, - bool presence, - const DOMString &show, - const DOMString &status) -{ - - DOMString presStr = ""; - presStr.append(fromNick); - if (!presence) - presStr.append(" left the group"); - else - { - if (show.size()<1) - presStr.append(" joined the group"); - else - { - presStr.append(" : "); - presStr.append(show); - } - } - - if (presStr != "xa") - messageList.postMessage("*", presStr); - - userList.clear(); - std::vector<XmppUser> memberList = - parent.client.groupChatGetUserList(groupJid); - for (unsigned int i=0 ; i<memberList.size() ; i++) - { - XmppUser user = memberList[i]; - userList.addUser(user.nick, user.show); - } - return true; -} - - -void GroupChatWindow::doChat(const DOMString &nick) -{ - printf("##Chat with %s\n", nick.c_str()); - DOMString fullJid = groupJid; - fullJid.append("/"); - fullJid.append(nick); - parent.doChat(fullJid); -} - -void GroupChatWindow::doSendFile(const DOMString &nick) -{ - printf("##Send file to %s\n", nick.c_str()); - DOMString fullJid = groupJid; - fullJid.append("/"); - fullJid.append(nick); - parent.doSendFile(fullJid); - -} - - - - -//######################################################################### -//# C O N F I G D I A L O G -//######################################################################### - - -void ConfigDialog::okCallback() -{ - Glib::ustring pass = passField.get_text(); - Glib::ustring newpass = newField.get_text(); - Glib::ustring confpass = confField.get_text(); - if ((pass.size() < 5 || pass.size() > 12 ) || - (newpass.size() < 5 || newpass.size() > 12 ) || - (confpass.size() < 5 || confpass.size()> 12 )) - { - Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else if (newpass != confpass) - { - Gtk::MessageDialog dlg(*this, "New password and confirmation do not match", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else - { - //response(Gtk::RESPONSE_OK); - hide(); - } -} - -void ConfigDialog::cancelCallback() -{ - //response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void ConfigDialog::on_response(int response_id) -{ - if (response_id == Gtk::RESPONSE_OK) - okCallback(); - else - cancelCallback(); -} - -bool ConfigDialog::doSetup() -{ - set_title("Change Password"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"), - sigc::mem_fun(*this, &ConfigDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &ConfigDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Change'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(3, 2); - get_vbox()->pack_start(table); - - passLabel.set_text("Current Password"); - table.attach(passLabel, 0, 1, 0, 1); - passField.set_visibility(false); - passField.set_text(parent.client.getPassword()); - table.attach(passField, 1, 2, 0, 1); - - newLabel.set_text("New Password"); - table.attach(newLabel, 0, 1, 1, 2); - newField.set_visibility(false); - table.attach(newField, 1, 2, 1, 2); - - confLabel.set_text("Confirm New Password"); - table.attach(confLabel, 0, 1, 2, 3); - confField.set_visibility(false); - confField.signal_activate().connect( - sigc::mem_fun(*this, &ConfigDialog::okCallback) ); - table.attach(confField, 1, 2, 2, 3); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - -//######################################################################### -//# P A S S W O R D D I A L O G -//######################################################################### - - -void PasswordDialog::okCallback() -{ - Glib::ustring pass = passField.get_text(); - Glib::ustring newpass = newField.get_text(); - Glib::ustring confpass = confField.get_text(); - if ((pass.size() < 5 || pass.size() > 12 ) || - (newpass.size() < 5 || newpass.size() > 12 ) || - (confpass.size() < 5 || confpass.size()> 12 )) - { - Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else if (newpass != confpass) - { - Gtk::MessageDialog dlg(*this, "New password and confirmation do not match", - false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); - dlg.run(); - } - else - { - //response(Gtk::RESPONSE_OK); - hide(); - } -} - -void PasswordDialog::cancelCallback() -{ - //response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void PasswordDialog::on_response(int response_id) -{ - if (response_id == Gtk::RESPONSE_OK) - okCallback(); - else - cancelCallback(); -} - -bool PasswordDialog::doSetup() -{ - set_title("Change Password"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"), - sigc::mem_fun(*this, &PasswordDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &PasswordDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Change'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(3, 2); - get_vbox()->pack_start(table); - - passLabel.set_text("Current Password"); - table.attach(passLabel, 0, 1, 0, 1); - passField.set_visibility(false); - passField.set_text(parent.client.getPassword()); - table.attach(passField, 1, 2, 0, 1); - - newLabel.set_text("New Password"); - table.attach(newLabel, 0, 1, 1, 2); - newField.set_visibility(false); - table.attach(newField, 1, 2, 1, 2); - - confLabel.set_text("Confirm New Password"); - table.attach(confLabel, 0, 1, 2, 3); - confField.set_visibility(false); - confField.signal_activate().connect( - sigc::mem_fun(*this, &PasswordDialog::okCallback) ); - table.attach(confField, 1, 2, 2, 3); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - -//######################################################################### -//# C H A T D I A L O G -//######################################################################### - - -void ChatDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void ChatDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -bool ChatDialog::doSetup() -{ - set_title("Chat with User"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Chat", Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &ChatDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &ChatDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Chat'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(2, 2); - get_vbox()->pack_start(table); - - userLabel.set_text("User"); - table.attach(userLabel, 0, 1, 0, 1); - //userField.set_text(""); - table.attach(userField, 1, 2, 0, 1); - - //userField.set_text(""); - table.attach(textField, 0, 2, 1, 2); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - -//######################################################################### -//# G R O U P C H A T D I A L O G -//######################################################################### - - -void GroupChatDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void GroupChatDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -bool GroupChatDialog::doSetup() -{ - set_title("Join Group Chat"); - set_size_request(300,200); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Join", Gtk::Stock::CONNECT, "Join Group"), - sigc::mem_fun(*this, &GroupChatDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &GroupChatDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Join'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(4, 2); - get_vbox()->pack_start(table); - - groupLabel.set_text("Group"); - table.attach(groupLabel, 0, 1, 0, 1); - groupField.set_text(parent.config.getMucGroup()); - table.attach(groupField, 1, 2, 0, 1); - - hostLabel.set_text("Host"); - table.attach(hostLabel, 0, 1, 1, 2); - hostField.set_text(parent.config.getMucHost()); - table.attach(hostField, 1, 2, 1, 2); - - nickLabel.set_text("Alt Name"); - table.attach(nickLabel, 0, 1, 2, 3); - nickField.set_text(parent.config.getMucNick()); - table.attach(nickField, 1, 2, 2, 3); - - passLabel.set_text("Password"); - table.attach(passLabel, 0, 1, 3, 4); - passField.set_visibility(false); - passField.set_text(parent.config.getMucPassword()); - table.attach(passField, 1, 2, 3, 4); - - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - - - - -//######################################################################### -//# C O N N E C T D I A L O G -//######################################################################### - - -void ConnectDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void ConnectDialog::saveCallback() -{ - Gtk::Entry txtField; - Gtk::Dialog dlg("Account name", *this, true, true); - dlg.get_vbox()->pack_start(txtField); - txtField.signal_activate().connect( - sigc::bind(sigc::mem_fun(dlg, &Gtk::Dialog::response), - Gtk::RESPONSE_OK )); - dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - dlg.show_all_children(); - int ret = dlg.run(); - if (ret != Gtk::RESPONSE_OK) - return; - - Glib::ustring name = txtField.get_text(); - if (name.size() < 1) - { - parent.error("Account name too short"); - return; - } - - if (parent.config.accountExists(name)) - { - parent.config.accountRemove(name); - } - - XmppAccount account; - account.setName(name); - account.setHost(getHost()); - account.setPort(getPort()); - account.setUsername(getUser()); - account.setPassword(getPass()); - parent.config.accountAdd(account); - - refresh(); - - parent.configSave(); -} - -void ConnectDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -void ConnectDialog::doubleClickCallback( - const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col) -{ - Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString name = iter->get_value(accountColumns.nameColumn); - //printf("Double clicked:%s\n", name.c_str()); - XmppAccount account; - if (!parent.config.accountFind(name, account)) - return; - setHost(account.getHost()); - setPort(account.getPort()); - setUser(account.getUsername()); - setPass(account.getPassword()); - - response(Gtk::RESPONSE_OK); - hide(); -} - -void ConnectDialog::selectedCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString name = iter->get_value(accountColumns.nameColumn); - //printf("Single clicked:%s\n", name.c_str()); - XmppAccount account; - if (!parent.config.accountFind(name, account)) - return; - setHost(account.getHost()); - setPort(account.getPort()); - setUser(account.getUsername()); - setPass(account.getPassword()); -} - -void ConnectDialog::deleteCallback() -{ - Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model(); - Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection(); - Gtk::TreeModel::iterator iter = sel->get_selected(); - DOMString name = iter->get_value(accountColumns.nameColumn); - - parent.config.accountRemove(name); - refresh(); - parent.configSave(); - -} - - - -void ConnectDialog::buttonPressCallback(GdkEventButton* event) -{ - if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) - { - Gtk::Widget *wid = accountUiManager->get_widget("/PopupMenu"); - Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid); - popupMenu->popup(event->button, event->time); - } -} - - -bool ConnectDialog::doSetup() -{ - set_title("Connect"); - set_size_request(300,400); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Connect", - Gtk::Stock::CONNECT, "Connect"), - sigc::mem_fun(*this, &ConnectDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Save", - Gtk::Stock::CONNECT, "Save as account"), - sigc::mem_fun(*this, &ConnectDialog::saveCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", - Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &ConnectDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Connect'/>" - " <separator/>" - " <menuitem action='Save'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(6, 2); - get_vbox()->pack_start(table); - - parent.client.setHost("broadway.dynalias.com"); - parent.client.setPort(5222); - parent.client.setUsername(""); - parent.client.setPassword(""); - parent.client.setResource("pedroXmpp"); - - hostLabel.set_text("Host"); - table.attach(hostLabel, 0, 1, 0, 1); - hostField.set_text(parent.client.getHost()); - table.attach(hostField, 1, 2, 0, 1); - - portLabel.set_text("Port"); - table.attach(portLabel, 0, 1, 1, 2); - portSpinner.set_digits(0); - portSpinner.set_range(1, 65000); - portSpinner.set_value(parent.client.getPort()); - table.attach(portSpinner, 1, 2, 1, 2); - - userLabel.set_text("Username"); - table.attach(userLabel, 0, 1, 2, 3); - userField.set_text(parent.client.getUsername()); - table.attach(userField, 1, 2, 2, 3); - - passLabel.set_text("Password"); - table.attach(passLabel, 0, 1, 3, 4); - passField.set_visibility(false); - passField.set_text(parent.client.getPassword()); - passField.signal_activate().connect( - sigc::mem_fun(*this, &ConnectDialog::okCallback) ); - table.attach(passField, 1, 2, 3, 4); - - resourceLabel.set_text("Resource"); - table.attach(resourceLabel, 0, 1, 4, 5); - resourceField.set_text(parent.client.getResource()); - table.attach(resourceField, 1, 2, 4, 5); - - registerLabel.set_text("Register"); - table.attach(registerLabel, 0, 1, 5, 6); - registerButton.set_active(false); - table.attach(registerButton, 1, 2, 5, 6); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - - //###################### - //# ACCOUNT LIST - //###################### - - - accountListStore = Gtk::ListStore::create(accountColumns); - accountView.set_model(accountListStore); - - accountView.signal_row_activated().connect( - sigc::mem_fun(*this, &ConnectDialog::doubleClickCallback) ); - - accountView.get_selection()->signal_changed().connect( - sigc::mem_fun(*this, &ConnectDialog::selectedCallback) ); - - accountView.append_column("Account", accountColumns.nameColumn); - accountView.append_column("Host", accountColumns.hostColumn); - - //accountView.signal_row_activated().connect( - // sigc::mem_fun(*this, &AccountDialog::connectCallback) ); - - accountScroll.add(accountView); - accountScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - - get_vbox()->pack_start(accountScroll); - - //##### POPUP MENU - accountView.signal_button_press_event().connect_notify( - sigc::mem_fun(*this, &ConnectDialog::buttonPressCallback) ); - - Glib::RefPtr<Gtk::ActionGroup> accountActionGroup = - Gtk::ActionGroup::create(); - - accountActionGroup->add( Gtk::Action::create("PopupMenu", "_Account") ); - - accountActionGroup->add( Gtk::Action::create("Delete", - Gtk::Stock::DELETE, "Delete"), - sigc::mem_fun(*this, &ConnectDialog::deleteCallback) ); - - - accountUiManager = Gtk::UIManager::create(); - - accountUiManager->insert_action_group(accountActionGroup, 0); - - Glib::ustring account_ui_info = - "<ui>" - " <popup name='PopupMenu'>" - " <menuitem action='Delete'/>" - " </popup>" - "</ui>"; - - accountUiManager->add_ui_from_string(account_ui_info); - //Gtk::Widget* accountMenuBar = uiManager->get_widget("/PopupMenu"); - //get_vbox()->pack_start(*accountMenuBar, Gtk::PACK_SHRINK); - - refresh(); - - show_all_children(); - - return true; -} - - -/** - * Regenerate the account list - */ -void ConnectDialog::refresh() -{ - accountListStore->clear(); - - std::vector<XmppAccount> accounts = parent.config.getAccounts(); - for (unsigned int i=0 ; i<accounts.size() ; i++) - { - XmppAccount account = accounts[i]; - Gtk::TreeModel::Row row = *(accountListStore->append()); - row[accountColumns.nameColumn] = account.getName(); - row[accountColumns.hostColumn] = account.getHost(); - } - accountView.expand_all(); -} - - - -//######################################################################### -//# F I L E S E N D D I A L O G -//######################################################################### - - -void FileSendDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void FileSendDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - - -void FileSendDialog::buttonCallback() -{ - Gtk::FileChooserDialog dlg("Select a file to send", - Gtk::FILE_CHOOSER_ACTION_OPEN); - dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT) - { - fileName = dlg.get_filename(); - fileNameField.set_text(fileName); - } -} - -bool FileSendDialog::doSetup() -{ - set_title("Send file to user"); - set_size_request(400,150); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"), - sigc::mem_fun(*this, &FileSendDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &FileSendDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Send'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(2, 2); - get_vbox()->pack_start(table); - - jidLabel.set_text("User ID"); - table.attach(jidLabel, 0, 1, 0, 1); - jidField.set_text("inkscape"); - table.attach(jidField, 1, 2, 0, 1); - - selectFileButton.set_label("Select"); - selectFileButton.signal_clicked().connect( - sigc::mem_fun(*this, &FileSendDialog::buttonCallback) ); - table.attach(selectFileButton, 0, 1, 1, 2); - - fileName = ""; - fileNameField.set_text("No file selected"); - fileNameField.set_editable(false); - table.attach(fileNameField, 1, 2, 1, 2); - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - - -//######################################################################### -//# F I L E R E C E I V E D I A L O G -//######################################################################### - - -void FileReceiveDialog::okCallback() -{ - response(Gtk::RESPONSE_OK); - hide(); -} - -void FileReceiveDialog::cancelCallback() -{ - response(Gtk::RESPONSE_CANCEL); - hide(); -} - -void FileReceiveDialog::buttonCallback() -{ - Gtk::FileChooserDialog dlg("Select a file to save", - Gtk::FILE_CHOOSER_ACTION_SAVE); - dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT) - { - fileName = dlg.get_filename(); - fileNameField.set_text(fileName); - } -} - - -bool FileReceiveDialog::doSetup() -{ - set_title("File being sent by user"); - set_size_request(450,250); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"), - sigc::mem_fun(*this, &FileReceiveDialog::okCallback) ); - actionGroup->add( Gtk::Action::create("Cancel", Gtk::Stock::CANCEL, "Cancel"), - sigc::mem_fun(*this, &FileReceiveDialog::cancelCallback) ); - - - Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Send'/>" - " <separator/>" - " <menuitem action='Cancel'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - table.resize(6, 2); - get_vbox()->pack_start(table); - - jidLabel.set_text("User ID"); - table.attach(jidLabel, 0, 1, 0, 1); - jidField.set_text(jid); - jidField.set_editable(false); - table.attach(jidField, 1, 2, 0, 1); - - offeredLabel.set_text("File Offered"); - table.attach(offeredLabel, 0, 1, 1, 2); - offeredField.set_text(offeredName); - offeredField.set_editable(false); - table.attach(offeredField, 1, 2, 1, 2); - - descLabel.set_text("Description"); - table.attach(descLabel, 0, 1, 2, 3); - descField.set_text(desc); - descField.set_editable(false); - table.attach(descField, 1, 2, 2, 3); - - char buf[32]; - snprintf(buf, 31, "%ld", fileSize); - sizeLabel.set_text("Size"); - table.attach(sizeLabel, 0, 1, 3, 4); - sizeField.set_text(buf); - sizeField.set_editable(false); - table.attach(sizeField, 1, 2, 3, 4); - - hashLabel.set_text("MD5 Hash"); - table.attach(hashLabel, 0, 1, 4, 5); - hashField.set_text(hash); - hashField.set_editable(false); - table.attach(hashField, 1, 2, 4, 5); - - selectFileButton.set_label("Select"); - selectFileButton.signal_clicked().connect( - sigc::mem_fun(*this, &FileReceiveDialog::buttonCallback) ); - table.attach(selectFileButton, 0, 1, 5, 6); - - fileName = ""; - fileNameField.set_text("No file selected"); - fileNameField.set_editable(false); - table.attach(fileNameField, 1, 2, 5, 6); - - - add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - show_all_children(); - - return true; -} - - -//######################################################################### -//# M A I N W I N D O W -//######################################################################### - -PedroGui::PedroGui() -{ - doSetup(); -} - -PedroGui::~PedroGui() -{ - chatDeleteAll(); - groupChatDeleteAll(); -} - - -void PedroGui::error(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - gchar * buffer = g_strdup_vprintf(fmt, args); - va_end(args) ; - - Gtk::MessageDialog dlg(buffer, - false, - Gtk::MESSAGE_ERROR, - Gtk::BUTTONS_OK, - true); - dlg.run(); - g_free(buffer); -} - -void PedroGui::status(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - gchar * buffer = g_strdup_vprintf(fmt, args); - va_end(args) ; - messageList.postMessage("STATUS", buffer); - g_free(buffer); -} - -//################################ -//# CHAT WINDOW MANAGEMENT -//################################ -bool PedroGui::chatCreate(const DOMString &userJid) -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; iter++) - { - if (userJid == (*iter)->getJid()) - return false; - } - ChatWindow *chat = new ChatWindow(*this, userJid); - chat->show(); - chats.push_back(chat); - return true; -} - -bool PedroGui::chatDelete(const DOMString &userJid) -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; ) - { - if (userJid == (*iter)->getJid()) - { - delete(*iter); - iter = chats.erase(iter); - } - else - iter++; - } - return true; -} - -bool PedroGui::chatDeleteAll() -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; ) - { - delete(*iter); - iter = chats.erase(iter); - } - return true; -} - -bool PedroGui::chatMessage(const DOMString &from, const DOMString &data) -{ - std::vector<ChatWindow *>::iterator iter; - for (iter=chats.begin() ; iter != chats.end() ; iter++) - { - if (from == (*iter)->getJid()) - { - (*iter)->postMessage(data); - return true; - } - } - ChatWindow *chat = new ChatWindow(*this, from); - chat->show(); - chats.push_back(chat); - chat->postMessage(data); - return true; -} - - -//################################ -//# GROUP CHAT WINDOW MANAGEMENT -//################################ - -bool PedroGui::groupChatCreate(const DOMString &groupJid, const DOMString &nick) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++) - { - if (groupJid == (*iter)->getGroupJid()) - return false; - } - GroupChatWindow *chat = new GroupChatWindow(*this, groupJid, nick); - chat->show(); - groupChats.push_back(chat); - return true; -} - - -bool PedroGui::groupChatDelete(const DOMString &groupJid, const DOMString &nick) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ;) - { - if (groupJid == (*iter)->getGroupJid() && - nick == (*iter)->getNick()) - { - delete(*iter); - iter = groupChats.erase(iter); - } - else - iter++; - } - return true; -} - - -bool PedroGui::groupChatDeleteAll() -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; ) - { - delete(*iter); - iter = groupChats.erase(iter); - } - return true; -} - - -bool PedroGui::groupChatMessage(const DOMString &groupJid, - const DOMString &from, const DOMString &data) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++) - { - if (groupJid == (*iter)->getGroupJid()) - { - (*iter)->receiveMessage(from, data); - } - } - return true; -} - -bool PedroGui::groupChatPresence(const DOMString &groupJid, - const DOMString &nick, bool presence, - const DOMString &show, - const DOMString &status) -{ - std::vector<GroupChatWindow *>::iterator iter; - for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++) - { - if (groupJid == (*iter)->getGroupJid()) - { - (*iter)->receivePresence(nick, presence, show, status); - } - } - return true; -} - -//################################ -//# EVENTS -//################################ - -/** - * - */ -void PedroGui::padlockEnable() -{ - padlockIcon.set(Gtk::Stock::DIALOG_AUTHENTICATION, - Gtk::ICON_SIZE_MENU); -} - -/** - * - */ -void PedroGui::padlockDisable() -{ - padlockIcon.clear(); -} - - -/** - * - */ -void PedroGui::handleConnectEvent() -{ - status("##### CONNECTED"); - actionEnable("Connect", false); - actionEnable("Chat", true); - actionEnable("GroupChat", true); - actionEnable("Disconnect", true); - actionEnable("RegPass", true); - actionEnable("RegCancel", true); - DOMString title = "Pedro - "; - title.append(client.getJid()); - set_title(title); -} - - -/** - * - */ -void PedroGui::handleDisconnectEvent() -{ - status("##### DISCONNECTED"); - actionEnable("Connect", true); - actionEnable("Chat", false); - actionEnable("GroupChat", false); - actionEnable("Disconnect", false); - actionEnable("RegPass", false); - actionEnable("RegCancel", false); - padlockDisable(); - DOMString title = "Pedro"; - set_title(title); - chatDeleteAll(); - groupChatDeleteAll(); - roster.clear(); -} - - -/** - * - */ -void PedroGui::doEvent(const XmppEvent &event) -{ - - int typ = event.getType(); - switch (typ) - { - case XmppEvent::EVENT_STATUS: - { - //printf("##### STATUS: %s\n", event.getData().c_str()); - status("%s", event.getData().c_str()); - break; - } - case XmppEvent::EVENT_ERROR: - { - //printf("##### ERROR: %s\n", event.getData().c_str()); - error("%s", event.getData().c_str()); - padlockDisable(); - break; - } - case XmppEvent::EVENT_SSL_STARTED: - { - padlockEnable(); - break; - } - case XmppEvent::EVENT_CONNECTED: - { - handleConnectEvent(); - break; - } - case XmppEvent::EVENT_DISCONNECTED: - { - handleDisconnectEvent(); - break; - } - case XmppEvent::EVENT_MESSAGE: - { - status("##### MESSAGE: %s\n", event.getFrom().c_str()); - chatMessage(event.getFrom(), event.getData()); - break; - } - case XmppEvent::EVENT_PRESENCE: - { - status("##### PRESENCE: %s\n", event.getFrom().c_str()); - roster.refresh(); - break; - } - case XmppEvent::EVENT_ROSTER: - { - status("##### ROSTER\n"); - roster.refresh(); - break; - } - case XmppEvent::EVENT_MUC_JOIN: - { - status("##### GROUP JOINED: %s\n", event.getGroup().c_str()); - break; - } - case XmppEvent::EVENT_MUC_MESSAGE: - { - //printf("##### MUC_MESSAGE: %s\n", event.getGroup().c_str()); - groupChatMessage(event.getGroup(), - event.getFrom(), event.getData()); - break; - } - case XmppEvent::EVENT_MUC_PRESENCE: - { - //printf("##### MUC_USER LIST: %s\n", event.getFrom().c_str()); - groupChatPresence(event.getGroup(), - event.getFrom(), - event.getPresence(), - event.getShow(), - event.getStatus()); - break; - } - case XmppEvent::EVENT_MUC_LEAVE: - { - status("##### GROUP LEFT: %s\n", event.getGroup().c_str()); - groupChatDelete(event.getGroup(), event.getFrom()); - break; - } - case XmppEvent::EVENT_FILE_RECEIVE: - { - status("##### FILE RECEIVE: %s\n", event.getFileName().c_str()); - doReceiveFile(event.getFrom(), event.getIqId(), event.getStreamId(), - event.getFileName(), event.getFileDesc(), - event.getFileSize(), event.getFileHash()); - break; - } - case XmppEvent::EVENT_REGISTRATION_NEW: - { - status("##### REGISTERED: %s at %s\n", - event.getTo().c_str(), event.getFrom().c_str()); - break; - } - case XmppEvent::EVENT_REGISTRATION_CHANGE_PASS: - { - status("##### PASSWORD CHANGED: %s at %s\n", - event.getTo().c_str(), event.getFrom().c_str()); - break; - } - case XmppEvent::EVENT_REGISTRATION_CANCEL: - { - //client.disconnect(); - status("##### REGISTERATION CANCELLED: %s at %s\n", - event.getTo().c_str(), event.getFrom().c_str()); - break; - } - default: - { - printf("unknown event type: %d\n", typ); - break; - } - } - -} - -/** - * - */ -bool PedroGui::checkEventQueue() -{ - while (client.eventQueueAvailable() > 0) - { - XmppEvent evt = client.eventQueuePop(); - doEvent(evt); - } - - while( Gtk::Main::events_pending() ) - Gtk::Main::iteration(); - - return true; -} - - -//################## -//# COMMANDS -//################## -void PedroGui::doChat(const DOMString &jid) -{ - if (jid.size()>0) - { - chatCreate(jid); - return; - } - - FileSendDialog dlg(*this); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - chatCreate(dlg.getJid()); - } - -} - -void PedroGui::doSendFile(const DOMString &jid) -{ - FileSendDialog dlg(*this); - if (jid.size()>0) - dlg.setJid(jid); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - DOMString fileName = dlg.getFileName(); - printf("fileName:%s\n", fileName.c_str()); - DOMString offeredName = ""; - DOMString desc = ""; - client.fileSendBackground(jid, offeredName, fileName, desc); - } - -} - -void PedroGui::doReceiveFile( - const DOMString &jid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &offeredName, - const DOMString &desc, - long size, - const DOMString &hash - ) - -{ - FileReceiveDialog dlg(*this, jid, iqId, streamId, - offeredName, desc, size, hash); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - DOMString fileName = dlg.getFileName(); - printf("fileName:%s\n", fileName.c_str()); - client.fileReceiveBackground(jid, iqId, streamId, fileName, size, hash); - } - -} - - -//################## -//# CALLBACKS -//################## -void PedroGui::connectCallback() -{ - ConnectDialog dialog(*this); - int result = dialog.run(); - dialog.hide(); - if (result == Gtk::RESPONSE_OK) - { - client.setHost(dialog.getHost()); - client.setPort(dialog.getPort()); - client.setUsername(dialog.getUser()); - client.setPassword(dialog.getPass()); - client.setResource(dialog.getResource()); - client.setDoRegister(dialog.getRegister()); - client.connect(); - } -} - - - -void PedroGui::chatCallback() -{ - ChatDialog dialog(*this); - int result = dialog.run(); - dialog.hide(); - if (result == Gtk::RESPONSE_OK) - { - client.message(dialog.getUser(), dialog.getText()); - } -} - - - -void PedroGui::groupChatCallback() -{ - GroupChatDialog dialog(*this); - int result = dialog.run(); - dialog.hide(); - if (result != Gtk::RESPONSE_OK) - return; - DOMString groupJid = dialog.getGroup(); - groupJid.append("@"); - groupJid.append(dialog.getHost()); - if (client.groupChatExists(groupJid)) - { - error("Group chat %s already exists", groupJid.c_str()); - return; - } - groupChatCreate(groupJid, dialog.getNick()); - client.groupChatJoin(groupJid, dialog.getNick(), dialog.getPass() ); - config.setMucGroup(dialog.getGroup()); - config.setMucHost(dialog.getHost()); - config.setMucNick(dialog.getNick()); - config.setMucPassword(dialog.getPass()); - - configSave(); -} - - -void PedroGui::disconnectCallback() -{ - client.disconnect(); -} - - -void PedroGui::quitCallback() -{ - Gtk::Main::quit(); -} - - -void PedroGui::fontCallback() -{ - Gtk::FontSelectionDialog dlg; - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - Glib::ustring fontName = dlg.get_font_name(); - Pango::FontDescription fontDesc(fontName); - modify_font(fontDesc); - } -} - -void PedroGui::colorCallback() -{ - Gtk::ColorSelectionDialog dlg; - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - Gdk::Color col = dlg.get_colorsel()->get_current_color(); - modify_bg(Gtk::STATE_NORMAL, col); - } -} - -void PedroGui::regPassCallback() -{ - PasswordDialog dlg(*this); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) - { - DOMString newpass = dlg.getNewPass(); - client.inBandRegistrationChangePassword(newpass); - } -} - - -void PedroGui::regCancelCallback() -{ - Gtk::MessageDialog dlg(*this, "Do you want to cancel your registration on the server?", - false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true); - int ret = dlg.run(); - if (ret == Gtk::RESPONSE_YES) - { - client.inBandRegistrationCancel(); - } -} - - - -void PedroGui::sendFileCallback() -{ - doSendFile(""); -} - - - -void PedroGui::aboutCallback() -{ - Gtk::AboutDialog dlg; - std::vector<Glib::ustring>authors; - authors.push_back("Bob Jamison"); - dlg.set_authors(authors); - DOMString comments = "A simple XMPP gui client "; - comments.append("Based on the Pedro XMPP client"); - dlg.set_comments(comments); - dlg.set_version("1.0"); - dlg.run(); -} - - - -void PedroGui::actionEnable(const DOMString &name, bool val) -{ - DOMString path = "/ui/MenuBar/"; - path.append(name); - Glib::RefPtr<Gtk::Action> action = uiManager->get_action(path); - if (!action) - { - path = "/ui/MenuBar/MenuFile/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuEdit/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuRegister/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuTransfer/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - { - path = "/ui/MenuBar/MenuHelp/"; - path.append(name); - action = uiManager->get_action(path); - } - if (!action) - return; - action->set_sensitive(val); -} - - -bool PedroGui::configLoad() -{ - if (!config.readFile("pedro.ini")) - return false; - return true; -} - - -bool PedroGui::configSave() -{ - if (!config.writeFile("pedro.ini")) - return false; - return true; -} - - - - -bool PedroGui::doSetup() -{ - configLoad(); - - set_title("Pedro XMPP Client"); - set_size_request(500, 300); - add(mainBox); - - Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create(); - - //### FILE MENU - actionGroup->add( Gtk::Action::create("MenuFile", "_File") ); - - actionGroup->add( Gtk::Action::create("Connect", - Gtk::Stock::CONNECT, "Connect"), - sigc::mem_fun(*this, &PedroGui::connectCallback) ); - - actionGroup->add( Gtk::Action::create("Chat", - Gtk::Stock::CONNECT, "Chat"), - sigc::mem_fun(*this, &PedroGui::chatCallback) ); - - actionGroup->add( Gtk::Action::create("GroupChat", - Gtk::Stock::CONNECT, "Group Chat"), - sigc::mem_fun(*this, &PedroGui::groupChatCallback) ); - - actionGroup->add( Gtk::Action::create("Disconnect", - Gtk::Stock::DISCONNECT, "Disconnect"), - sigc::mem_fun(*this, &PedroGui::disconnectCallback) ); - - actionGroup->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT), - sigc::mem_fun(*this, &PedroGui::quitCallback) ); - - //### EDIT MENU - actionGroup->add( Gtk::Action::create("MenuEdit", "_Edit") ); - actionGroup->add( Gtk::Action::create("SelectFont", - Gtk::Stock::SELECT_FONT, "Select Font"), - sigc::mem_fun(*this, &PedroGui::fontCallback) ); - actionGroup->add( Gtk::Action::create("SelectColor", - Gtk::Stock::SELECT_COLOR, "Select Color"), - sigc::mem_fun(*this, &PedroGui::colorCallback) ); - - //### REGISTER MENU - actionGroup->add( Gtk::Action::create("MenuRegister", "_Registration") ); - actionGroup->add( Gtk::Action::create("RegPass", - Gtk::Stock::DIALOG_AUTHENTICATION, "Change Password"), - sigc::mem_fun(*this, &PedroGui::regPassCallback) ); - actionGroup->add( Gtk::Action::create("RegCancel", - Gtk::Stock::CANCEL, "Cancel Registration"), - sigc::mem_fun(*this, &PedroGui::regCancelCallback) ); - - //### TRANSFER MENU - actionGroup->add( Gtk::Action::create("MenuTransfer", "_Transfer") ); - actionGroup->add( Gtk::Action::create("SendFile", - Gtk::Stock::NETWORK, "Send File"), - sigc::mem_fun(*this, &PedroGui::sendFileCallback) ); - - //### HELP MENU - actionGroup->add( Gtk::Action::create("MenuHelp", "_Help") ); - actionGroup->add( Gtk::Action::create("About", - Gtk::Stock::ABOUT, "About Pedro"), - sigc::mem_fun(*this, &PedroGui::aboutCallback) ); - - uiManager = Gtk::UIManager::create(); - - uiManager->insert_action_group(actionGroup, 0); - add_accel_group(uiManager->get_accel_group()); - - Glib::ustring ui_info = - "<ui>" - " <menubar name='MenuBar'>" - " <menu action='MenuFile'>" - " <menuitem action='Connect'/>" - " <separator/>" - " <menuitem action='Chat'/>" - " <menuitem action='GroupChat'/>" - " <separator/>" - " <menuitem action='Disconnect'/>" - " <menuitem action='Quit'/>" - " </menu>" - " <menu action='MenuEdit'>" - " <menuitem action='SelectFont'/>" - " <menuitem action='SelectColor'/>" - " </menu>" - " <menu action='MenuRegister'>" - " <menuitem action='RegPass'/>" - " <menuitem action='RegCancel'/>" - " </menu>" - " <menu action='MenuTransfer'>" - " <menuitem action='SendFile'/>" - " </menu>" - " <menu action='MenuHelp'>" - " <menuitem action='About'/>" - " </menu>" - " </menubar>" - "</ui>"; - - uiManager->add_ui_from_string(ui_info); - Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - menuBarBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); - - padlockDisable(); - menuBarBox.pack_end(padlockIcon, Gtk::PACK_SHRINK); - - mainBox.pack_start(menuBarBox, Gtk::PACK_SHRINK); - - actionEnable("Connect", true); - actionEnable("Chat", false); - actionEnable("GroupChat", false); - actionEnable("Disconnect", false); - actionEnable("RegPass", false); - actionEnable("RegCancel", false); - - mainBox.pack_start(vPaned); - vPaned.add1(roster); - vPaned.add2(messageList); - roster.setParent(this); - - show_all_children(); - - //# Start a timer to check the queue every nn milliseconds - Glib::signal_timeout().connect( - sigc::mem_fun(*this, &PedroGui::checkEventQueue), 20 ); - - //client.addXmppEventListener(*this); - client.eventQueueEnable(true); - - return true; -} - - -} // namespace Pedro - - - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/pedrogui.h b/src/pedro/pedrogui.h deleted file mode 100644 index 2898da118..000000000 --- a/src/pedro/pedrogui.h +++ /dev/null @@ -1,907 +0,0 @@ -#ifndef __PEDROGUI_H__ -#define __PEDROGUI_H__ -/* - * Simple demo GUI for the Pedro mini-XMPP client. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include <gtkmm.h> -#include "ui/widget/spinbutton.h" - -#include "pedroxmpp.h" -#include "pedroconfig.h" - - -namespace Pedro -{ - - -class PedroGui; -class GroupChatWindow; - -//######################################################################### -//# R O S T E R -//######################################################################### -class Roster : public Gtk::ScrolledWindow -{ -public: - - Roster() - { doSetup(); } - - virtual ~Roster() - {} - - /** - * Clear all roster items from the list - */ - virtual void clear(); - - /** - * Regenerate the roster - */ - virtual void refresh(); - - - void setParent(PedroGui *val) - { parent = val; } - -private: - - class CustomTreeView : public Gtk::TreeView - { - public: - CustomTreeView() - { parent = NULL; } - virtual ~CustomTreeView() - {} - - bool on_button_press_event(GdkEventButton* event) - { - Gtk::TreeView::on_button_press_event(event); - if (parent) - parent->buttonPressCallback(event); - return true; - } - void setParent(Roster *val) - { parent = val; } - - private: - Roster *parent; - }; - - void doubleClickCallback(const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - - void sendFileCallback(); - void chatCallback(); - bool buttonPressCallback(GdkEventButton* event); - - bool doSetup(); - - Glib::RefPtr<Gdk::Pixbuf> pixbuf_available; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_away; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_chat; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_dnd; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_error; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_offline; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_xa; - - class RosterColumns : public Gtk::TreeModel::ColumnRecord - { - public: - RosterColumns() - { - add(groupColumn); - add(statusColumn); add(userColumn); - add(nameColumn); add(subColumn); - } - - Gtk::TreeModelColumn<Glib::ustring> groupColumn; - Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > statusColumn; - Gtk::TreeModelColumn<Glib::ustring> userColumn; - Gtk::TreeModelColumn<Glib::ustring> nameColumn; - Gtk::TreeModelColumn<Glib::ustring> subColumn; - }; - - RosterColumns rosterColumns; - - Glib::RefPtr<Gtk::UIManager> uiManager; - - Glib::RefPtr<Gtk::TreeStore> treeStore; - CustomTreeView rosterView; - - PedroGui *parent; -}; - -//######################################################################### -//# M E S S A G E L I S T -//######################################################################### -class MessageList : public Gtk::ScrolledWindow -{ -public: - - MessageList() - { doSetup(); } - - virtual ~MessageList() - {} - - /** - * Clear all messages from the list - */ - virtual void clear(); - - /** - * Post a message to the list - */ - virtual void postMessage(const DOMString &from, const DOMString &msg); - -private: - - bool doSetup(); - - Gtk::TextView messageList; - Glib::RefPtr<Gtk::TextBuffer> messageListBuffer; - -}; - -//######################################################################### -//# U S E R L I S T -//######################################################################### -class UserList : public Gtk::ScrolledWindow -{ -public: - - UserList() - { doSetup(); } - - virtual ~UserList() - {} - - /** - * Clear all messages from the list - */ - virtual void clear(); - - /** - * Post a message to the list - */ - virtual void addUser(const DOMString &user, const DOMString &show); - - - void setParent(GroupChatWindow *val) - { parent = val; } - -private: - - class CustomTreeView : public Gtk::TreeView - { - public: - CustomTreeView() - { parent = NULL; } - virtual ~CustomTreeView() - {} - - bool on_button_press_event(GdkEventButton* event) - { - Gtk::TreeView::on_button_press_event(event); - if (parent) - parent->buttonPressCallback(event); - return true; - } - void setParent(UserList *val) - { parent = val; } - - private: - UserList *parent; - }; - - void doubleClickCallback(const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - - void sendFileCallback(); - void chatCallback(); - bool buttonPressCallback(GdkEventButton* event); - - bool doSetup(); - - Glib::RefPtr<Gdk::Pixbuf> pixbuf_available; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_away; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_chat; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_dnd; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_error; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_offline; - Glib::RefPtr<Gdk::Pixbuf> pixbuf_xa; - - class UserListColumns : public Gtk::TreeModel::ColumnRecord - { - public: - UserListColumns() - { add(statusColumn); add(userColumn); } - - Gtk::TreeModelColumn<Glib::ustring> userColumn; - Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > statusColumn; - }; - - UserListColumns userListColumns; - - Glib::RefPtr<Gtk::UIManager> uiManager; - - Glib::RefPtr<Gtk::ListStore> userListStore; - CustomTreeView userList; - - GroupChatWindow *parent; -}; - - -//######################################################################### -//# C H A T W I N D O W -//######################################################################### -class ChatWindow : public Gtk::Window -{ -public: - - ChatWindow(PedroGui &par, const DOMString jid); - - virtual ~ChatWindow(); - - virtual DOMString getJid() - { return jid; } - - virtual void setJid(const DOMString &val) - { jid = val; } - - virtual bool postMessage(const DOMString &data); - -private: - - DOMString jid; - - void leaveCallback(); - void hideCallback(); - void textEnterCallback(); - - bool doSetup(); - - Gtk::VBox vbox; - Gtk::VPaned vPaned; - - MessageList messageList; - - Gtk::Entry inputTxt; - - PedroGui &parent; -}; - - -//######################################################################### -//# G R O U P C H A T W I N D O W -//######################################################################### -class GroupChatWindow : public Gtk::Window -{ -public: - - GroupChatWindow(PedroGui &par, const DOMString &groupJid, - const DOMString &nick); - - virtual ~GroupChatWindow(); - - - virtual DOMString getGroupJid() - { return groupJid; } - - virtual void setGroupJid(const DOMString &val) - { groupJid = val; } - - virtual DOMString getNick() - { return nick; } - - virtual void setNick(const DOMString &val) - { nick = val; } - - virtual bool receiveMessage(const DOMString &from, - const DOMString &data); - - virtual bool receivePresence(const DOMString &nick, - bool presence, - const DOMString &show, - const DOMString &status); - - virtual void doSendFile(const DOMString &nick); - - virtual void doChat(const DOMString &nick); - - -private: - - void textEnterCallback(); - void leaveCallback(); - void hideCallback(); - - bool doSetup(); - - Gtk::VBox vbox; - Gtk::VPaned vPaned; - Gtk::HPaned hPaned; - - MessageList messageList; - - UserList userList; - - Gtk::Entry inputTxt; - - DOMString groupJid; - DOMString nick; - - PedroGui &parent; - }; - - - -//######################################################################### -//# C O N F I G D I A L O G -//######################################################################### - -class ConfigDialog : public Gtk::Dialog -{ -public: - - ConfigDialog (PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~ConfigDialog () - {} - - DOMString getPass() - { return passField.get_text(); } - DOMString getNewPass() - { return newField.get_text(); } - DOMString getConfirm() - { return confField.get_text(); } - -protected: - - //Overloaded from Gtk::Dialog - virtual void on_response(int response_id); - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label newLabel; - Gtk::Entry newField; - Gtk::Label confLabel; - Gtk::Entry confField; - - PedroGui &parent; -}; - - -//######################################################################### -//# P A S S W O R D D I A L O G -//######################################################################### -class PasswordDialog : public Gtk::Dialog -{ -public: - - PasswordDialog (PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~PasswordDialog () - {} - - DOMString getPass() - { return passField.get_text(); } - DOMString getNewPass() - { return newField.get_text(); } - DOMString getConfirm() - { return confField.get_text(); } - -protected: - - //Overloaded from Gtk::Dialog - virtual void on_response(int response_id); - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label newLabel; - Gtk::Entry newField; - Gtk::Label confLabel; - Gtk::Entry confField; - - PedroGui &parent; -}; - - - -//######################################################################### -//# C H A T D I A L O G -//######################################################################### -class ChatDialog : public Gtk::Dialog -{ -public: - - ChatDialog(PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~ChatDialog() - {} - - DOMString getUser() - { return userField.get_text(); } - - DOMString getText() - { return textField.get_text(); } - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label userLabel; - Gtk::Entry userField; - Gtk::Entry textField; - - PedroGui &parent; -}; - - - -//######################################################################### -//# G R O U P C H A T D I A L O G -//######################################################################### - -class GroupChatDialog : public Gtk::Dialog -{ -public: - - GroupChatDialog(PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~GroupChatDialog() - {} - - DOMString getGroup() - { return groupField.get_text(); } - DOMString getHost() - { return hostField.get_text(); } - DOMString getPass() - { return passField.get_text(); } - DOMString getNick() - { return nickField.get_text(); } - -private: - - void okCallback(); - void cancelCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label groupLabel; - Gtk::Entry groupField; - Gtk::Label hostLabel; - Gtk::Entry hostField; - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label nickLabel; - Gtk::Entry nickField; - - PedroGui &parent; -}; - - -//######################################################################### -//# C O N N E C T D I A L O G -//######################################################################### -class ConnectDialog : public Gtk::Dialog -{ -public: - - ConnectDialog (PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~ConnectDialog () - {} - - DOMString getHost() - { return hostField.get_text(); } - void setHost(const DOMString &val) - { hostField.set_text(val); } - int getPort() - { return (int)portSpinner.get_value(); } - void setPort(int val) - { portSpinner.set_value(val); } - DOMString getUser() - { return userField.get_text(); } - void setUser(const DOMString &val) - { userField.set_text(val); } - DOMString getPass() - { return passField.get_text(); } - void setPass(const DOMString &val) - { passField.set_text(val); } - DOMString getResource() - { return resourceField.get_text(); } - void setResource(const DOMString &val) - { resourceField.set_text(val); } - bool getRegister() - { return registerButton.get_active(); } - - /** - * Regenerate the account list - */ - virtual void refresh(); - -private: - - void okCallback(); - void saveCallback(); - void cancelCallback(); - void doubleClickCallback( - const Gtk::TreeModel::Path &path, - Gtk::TreeViewColumn *col); - void selectedCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label hostLabel; - Gtk::Entry hostField; - Gtk::Label portLabel; - Inkscape::UI::Widget::SpinButton portSpinner; - Gtk::Label userLabel; - Gtk::Entry userField; - Gtk::Label passLabel; - Gtk::Entry passField; - Gtk::Label resourceLabel; - Gtk::Entry resourceField; - Gtk::Label registerLabel; - Gtk::CheckButton registerButton; - - Glib::RefPtr<Gtk::UIManager> uiManager; - - - //## Account list - - void buttonPressCallback(GdkEventButton* event); - - Gtk::ScrolledWindow accountScroll; - - void connectCallback(); - - void modifyCallback(); - - void deleteCallback(); - - - class AccountColumns : public Gtk::TreeModel::ColumnRecord - { - public: - AccountColumns() - { - add(nameColumn); - add(hostColumn); - } - - Gtk::TreeModelColumn<Glib::ustring> nameColumn; - Gtk::TreeModelColumn<Glib::ustring> hostColumn; - }; - - AccountColumns accountColumns; - - Glib::RefPtr<Gtk::UIManager> accountUiManager; - - Glib::RefPtr<Gtk::ListStore> accountListStore; - Gtk::TreeView accountView; - - - PedroGui &parent; -}; - - - - -//######################################################################### -//# F I L E S E N D D I A L O G -//######################################################################### - -class FileSendDialog : public Gtk::Dialog -{ -public: - - FileSendDialog(PedroGui &par) : parent(par) - { doSetup(); } - - virtual ~FileSendDialog() - {} - - DOMString getFileName() - { return fileName; } - DOMString getJid() - { return jidField.get_text(); } - void setJid(const DOMString &val) - { return jidField.set_text(val); } - -private: - - void okCallback(); - void cancelCallback(); - void buttonCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label jidLabel; - Gtk::Entry jidField; - - DOMString fileName; - Gtk::Entry fileNameField; - - Gtk::Button selectFileButton; - - PedroGui &parent; -}; - -//######################################################################### -//# F I L E R E C E I V E D I A L O G -//######################################################################### - -class FileReceiveDialog : public Gtk::Dialog -{ -public: - - FileReceiveDialog(PedroGui &par, - const DOMString &jidArg, - const DOMString &iqIdArg, - const DOMString &streamIdArg, - const DOMString &offeredNameArg, - const DOMString &descArg, - long sizeArg, - const DOMString &hashArg - ) : parent(par) - { - jid = jidArg; - iqId = iqIdArg; - streamId = streamIdArg; - offeredName = offeredNameArg; - desc = descArg; - fileSize = sizeArg; - hash = hashArg; - doSetup(); - } - - virtual ~FileReceiveDialog() - {} - - DOMString getJid() - { return jid; } - DOMString getIq() - { return iqId; } - DOMString getStreamId() - { return streamId; } - DOMString getOfferedName() - { return offeredName; } - DOMString getFileName() - { return fileName; } - DOMString getDescription() - { return desc; } - long getSize() - { return fileSize; } - DOMString getHash() - { return hash; } - -private: - - void okCallback(); - void cancelCallback(); - void buttonCallback(); - - bool doSetup(); - - Gtk::Table table; - - Gtk::Label jidLabel; - Gtk::Entry jidField; - Gtk::Label offeredLabel; - Gtk::Entry offeredField; - Gtk::Label descLabel; - Gtk::Entry descField; - Gtk::Label sizeLabel; - Gtk::Entry sizeField; - Gtk::Label hashLabel; - Gtk::Entry hashField; - - Gtk::Entry fileNameField; - - Gtk::Button selectFileButton; - - DOMString jid; - DOMString iqId; - DOMString streamId; - DOMString offeredName; - DOMString desc; - long fileSize; - DOMString hash; - - DOMString fileName; - - PedroGui &parent; -}; - - - -//######################################################################### -//# M A I N W I N D O W -//######################################################################### - -class PedroGui : public Gtk::Window -{ -public: - - PedroGui(); - - virtual ~PedroGui(); - - //Let everyone share these - XmppClient client; - XmppConfig config; - - - virtual void error(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - virtual void status(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - - - void handleConnectEvent(); - - void handleDisconnectEvent(); - - /** - * - */ - virtual void doEvent(const XmppEvent &event); - - /** - * - */ - bool checkEventQueue(); - - - bool chatCreate(const DOMString &userJid); - bool chatDelete(const DOMString &userJid); - bool chatDeleteAll(); - bool chatMessage(const DOMString &jid, const DOMString &data); - - bool groupChatCreate(const DOMString &groupJid, - const DOMString &nick); - bool groupChatDelete(const DOMString &groupJid, - const DOMString &nick); - bool groupChatDeleteAll(); - bool groupChatMessage(const DOMString &groupJid, - const DOMString &from, const DOMString &data); - bool groupChatPresence(const DOMString &groupJid, - const DOMString &nick, - bool presence, - const DOMString &show, - const DOMString &status); - - void doChat(const DOMString &jid); - void doSendFile(const DOMString &jid); - void doReceiveFile(const DOMString &jid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &offeredName, - const DOMString &desc, - long size, - const DOMString &hash); - - - //# File menu - void connectCallback(); - void chatCallback(); - void groupChatCallback(); - void disconnectCallback(); - void quitCallback(); - - //# Edit menu - void fontCallback(); - void colorCallback(); - - //# Transfer menu - void sendFileCallback(); - - //# Registration menu - void regPassCallback(); - void regCancelCallback(); - - //# Help menu - void aboutCallback(); - - //# Configuration file - bool configLoad(); - bool configSave(); - - -private: - - bool doSetup(); - - Gtk::VBox mainBox; - - Gtk::HBox menuBarBox; - - Gtk::Image padlockIcon; - void padlockEnable(); - void padlockDisable(); - - - Pango::FontDescription fontDesc; - Gdk::Color foregroundColor; - Gdk::Color backgroundColor; - - Gtk::VPaned vPaned; - MessageList messageList; - Roster roster; - - Glib::RefPtr<Gtk::UIManager> uiManager; - void actionEnable(const DOMString &name, bool val); - - std::vector<ChatWindow *>chats; - - std::vector<GroupChatWindow *>groupChats; -}; - - -} //namespace Pedro - -#endif /* __PEDROGUI_H__ */ -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - diff --git a/src/pedro/pedromain.cpp b/src/pedro/pedromain.cpp deleted file mode 100644 index 60322f718..000000000 --- a/src/pedro/pedromain.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Implementation the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> - - - - -//####################################################################### -//# G E C K O (xulrunner) -//####################################################################### - -#ifdef GECKO_EMBED - - -#include "geckoembed.h" - -int main(int argc, char *argv[]) -{ - GeckoEmbed embedder; - - embedder.run(); - - return 0; -} - - -//####################################################################### -//# G T K M M (pedrogui) -//####################################################################### -#else /* NOT GECKO_EMBED */ - - - -#include "pedrogui.h" - -int main(int argc, char *argv[]) -{ - Gtk::Main kit(argc, argv); - - Pedro::PedroGui window; - - kit.run(window); - - return 0; -} - - - -#endif /* GECKO_EMBED */ - - - - - -#ifdef __WIN32__ -#include <windows.h> - -extern "C" int __export WINAPI -WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, - char *lpszCmdLine, int nCmdShow) -{ - int ret = main (__argc, __argv); - return ret; -} - -#endif - - - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/pedroutil.cpp b/src/pedro/pedroutil.cpp deleted file mode 100644 index 09407ff08..000000000 --- a/src/pedro/pedroutil.cpp +++ /dev/null @@ -1,1516 +0,0 @@ -/* - * Support classes for the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <stdio.h> -#include <stdarg.h> -#include <string.h> -#include <sys/stat.h> - -#include "pedroutil.h" - - - -#ifdef __WIN32__ - -#include <windows.h> - -#else /* UNIX */ - -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#include <unistd.h> -#include <sys/ioctl.h> - -#include <pthread.h> - -#endif /* UNIX */ - -#ifdef HAVE_SSL -RELAYTOOL_SSL -#endif - - -namespace Pedro -{ - - - - - -//######################################################################## -//######################################################################## -//# B A S E 6 4 -//######################################################################## -//######################################################################## - - -//################# -//# ENCODER -//################# - - -static const char *base64encode = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - - -/** - * Writes the specified byte to the output buffer - */ -void Base64Encoder::append(int ch) -{ - outBuf <<= 8; - outBuf |= (ch & 0xff); - bitCount += 8; - if (bitCount >= 24) - { - int indx = (int)((outBuf & 0x00fc0000L) >> 18); - int obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - indx = (int)((outBuf & 0x0003f000L) >> 12); - obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - indx = (int)((outBuf & 0x00000fc0L) >> 6); - obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - indx = (int)((outBuf & 0x0000003fL) ); - obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - bitCount = 0; - outBuf = 0L; - } -} - -/** - * Writes the specified string to the output buffer - */ -void Base64Encoder::append(char *str) -{ - while (*str) - append((int)*str++); -} - -/** - * Writes the specified string to the output buffer - */ -void Base64Encoder::append(unsigned char *str, int len) -{ - while (len>0) - { - append((int)*str++); - len--; - } -} - -/** - * Writes the specified string to the output buffer - */ -void Base64Encoder::append(const DOMString &str) -{ - append((char *)str.c_str()); -} - -/** - * Closes this output stream and releases any system resources - * associated with this stream. - */ -DOMString Base64Encoder::finish() -{ - //get any last bytes (1 or 2) out of the buffer - if (bitCount == 16) - { - outBuf <<= 2; //pad to make 18 bits - - int indx = (int)((outBuf & 0x0003f000L) >> 12); - int obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - indx = (int)((outBuf & 0x00000fc0L) >> 6); - obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - indx = (int)((outBuf & 0x0000003fL) ); - obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - buf.push_back('='); - } - else if (bitCount == 8) - { - outBuf <<= 4; //pad to make 12 bits - - int indx = (int)((outBuf & 0x00000fc0L) >> 6); - int obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - indx = (int)((outBuf & 0x0000003fL) ); - obyte = (int)base64encode[indx & 63]; - buf.push_back(obyte); - - buf.push_back('='); - buf.push_back('='); - } - - DOMString ret = buf; - reset(); - return ret; -} - - -DOMString Base64Encoder::encode(const DOMString &str) -{ - Base64Encoder encoder; - encoder.append(str); - DOMString ret = encoder.finish(); - return ret; -} - - - -//################# -//# DECODER -//################# - -static int base64decode[] = -{ -/*00*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*08*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*10*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*18*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*20*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*28*/ -1, -1, -1, 62, -1, -1, -1, 63, -/*30*/ 52, 53, 54, 55, 56, 57, 58, 59, -/*38*/ 60, 61, -1, -1, -1, -1, -1, -1, -/*40*/ -1, 0, 1, 2, 3, 4, 5, 6, -/*48*/ 7, 8, 9, 10, 11, 12, 13, 14, -/*50*/ 15, 16, 17, 18, 19, 20, 21, 22, -/*58*/ 23, 24, 25, -1, -1, -1, -1, -1, -/*60*/ -1, 26, 27, 28, 29, 30, 31, 32, -/*68*/ 33, 34, 35, 36, 37, 38, 39, 40, -/*70*/ 41, 42, 43, 44, 45, 46, 47, 48, -/*78*/ 49, 50, 51, -1, -1, -1, -1, -1 -}; - - - -/** - * Appends one char to the decoder - */ -void Base64Decoder::append(int ch) -{ - if (isspace(ch)) - return; - else if (ch == '=') //padding - { - inBytes[inCount++] = 0; - } - else - { - int byteVal = base64decode[ch & 0x7f]; - //printf("char:%c %d\n", ch, byteVal); - if (byteVal < 0) - { - //Bad lookup value - } - inBytes[inCount++] = byteVal; - } - - if (inCount >=4 ) - { - unsigned char b0 = ((inBytes[0]<<2) & 0xfc) | ((inBytes[1]>>4) & 0x03); - unsigned char b1 = ((inBytes[1]<<4) & 0xf0) | ((inBytes[2]>>2) & 0x0f); - unsigned char b2 = ((inBytes[2]<<6) & 0xc0) | ((inBytes[3] ) & 0x3f); - buf.push_back(b0); - buf.push_back(b1); - buf.push_back(b2); - inCount = 0; - } - -} - -void Base64Decoder::append(char *str) -{ - while (*str) - append((int)*str++); -} - -void Base64Decoder::append(const DOMString &str) -{ - append((char *)str.c_str()); -} - -std::vector<unsigned char> Base64Decoder::finish() -{ - std::vector<unsigned char> ret = buf; - reset(); - return ret; -} - -std::vector<unsigned char> Base64Decoder::decode(const DOMString &str) -{ - Base64Decoder decoder; - decoder.append(str); - std::vector<unsigned char> ret = decoder.finish(); - return ret; -} - -DOMString Base64Decoder::decodeToString(const DOMString &str) -{ - Base64Decoder decoder; - decoder.append(str); - std::vector<unsigned char> ret = decoder.finish(); - DOMString buf; - for (unsigned int i=0 ; i<ret.size() ; i++) - buf.push_back(ret[i]); - return buf; -} - - - - - - - -//######################################################################## -//######################################################################## -//### S H A 1 H A S H I N G -//######################################################################## -//######################################################################## - -void Sha1::hash(unsigned char *dataIn, int len, unsigned char *digest) -{ - Sha1 sha1; - sha1.append(dataIn, len); - sha1.finish(digest); -} - -static const char *sha1hex = "0123456789abcdef"; - -DOMString Sha1::hashHex(unsigned char *dataIn, int len) -{ - unsigned char hashout[20]; - hash(dataIn, len, hashout); - DOMString ret; - for (int i=0 ; i<20 ; i++) - { - unsigned char ch = hashout[i]; - ret.push_back(sha1hex[ (ch>>4) & 15 ]); - ret.push_back(sha1hex[ ch & 15 ]); - } - return ret; -} - - -DOMString Sha1::hashHex(const DOMString &str) -{ - return hashHex((unsigned char *)str.c_str(), str.size()); -} - - -void Sha1::init() -{ - - longNr = 0; - byteNr = 0; - nrBytesHi = 0; - nrBytesLo = 0; - - // Initialize H with the magic constants (see FIPS180 for constants) - hashBuf[0] = 0x67452301L; - hashBuf[1] = 0xefcdab89L; - hashBuf[2] = 0x98badcfeL; - hashBuf[3] = 0x10325476L; - hashBuf[4] = 0xc3d2e1f0L; - - for (int i = 0; i < 4; i++) - inb[i] = 0; - - for (int i = 0; i < 80; i++) - inBuf[i] = 0; -} - - -void Sha1::append(unsigned char ch) -{ - if (nrBytesLo == 0xffffffffL) - { - nrBytesHi++; - nrBytesLo = 0; - } - else - nrBytesLo++; - - inb[byteNr++] = (unsigned long)ch; - if (byteNr >= 4) - { - inBuf[longNr++] = inb[0] << 24 | inb[1] << 16 | - inb[2] << 8 | inb[3]; - byteNr = 0; - } - if (longNr >= 16) - { - transform(); - longNr = 0; - } -} - - -void Sha1::append(unsigned char *dataIn, int len) -{ - for (int i = 0; i < len; i++) - append(dataIn[i]); -} - - -void Sha1::append(const DOMString &str) -{ - append((unsigned char *)str.c_str(), str.size()); -} - - -void Sha1::finish(unsigned char digest[20]) -{ - //snapshot the bit count now before padding - unsigned long nrBitsLo = (nrBytesLo << 3) & 0xffffffff; - unsigned long nrBitsHi = (nrBytesHi << 3) | ((nrBytesLo >> 29) & 7); - - //Append terminal char - append(0x80); - - //pad until we have a 56 of 64 bytes, allowing for 8 bytes at the end - while (longNr != 14) - append(0); - - - //##### Append length in bits - append((unsigned char)((nrBitsHi>>24) & 0xff)); - append((unsigned char)((nrBitsHi>>16) & 0xff)); - append((unsigned char)((nrBitsHi>> 8) & 0xff)); - append((unsigned char)((nrBitsHi ) & 0xff)); - append((unsigned char)((nrBitsLo>>24) & 0xff)); - append((unsigned char)((nrBitsLo>>16) & 0xff)); - append((unsigned char)((nrBitsLo>> 8) & 0xff)); - append((unsigned char)((nrBitsLo ) & 0xff)); - - - //copy out answer - int indx = 0; - for (int i=0 ; i<5 ; i++) - { - digest[indx++] = (unsigned char)((hashBuf[i] >> 24) & 0xff); - digest[indx++] = (unsigned char)((hashBuf[i] >> 16) & 0xff); - digest[indx++] = (unsigned char)((hashBuf[i] >> 8) & 0xff); - digest[indx++] = (unsigned char)((hashBuf[i] ) & 0xff); - } - - // Re-initialize the context (also zeroizes contents) - init(); -} - - - -#define SHA_ROTL(X,n) ((((X) << (n)) & 0xffffffff) | (((X) >> (32-(n))) & 0xffffffff)) - -void Sha1::transform() -{ - unsigned long *W = inBuf; - unsigned long *H = hashBuf; - - for (int t = 16; t <= 79; t++) - W[t] = SHA_ROTL(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1); - - unsigned long A = H[0]; - unsigned long B = H[1]; - unsigned long C = H[2]; - unsigned long D = H[3]; - unsigned long E = H[4]; - - unsigned long TEMP; - - for (int t = 0; t <= 19; t++) - { - TEMP = (SHA_ROTL(A,5) + ((B&C)|((~B)&D)) + - E + W[t] + 0x5a827999L) & 0xffffffffL; - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP; - } - for (int t = 20; t <= 39; t++) - { - TEMP = (SHA_ROTL(A,5) + (B^C^D) + - E + W[t] + 0x6ed9eba1L) & 0xffffffffL; - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP; - } - for (int t = 40; t <= 59; t++) - { - TEMP = (SHA_ROTL(A,5) + ((B&C)|(B&D)|(C&D)) + - E + W[t] + 0x8f1bbcdcL) & 0xffffffffL; - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP; - } - for (int t = 60; t <= 79; t++) - { - TEMP = (SHA_ROTL(A,5) + (B^C^D) + - E + W[t] + 0xca62c1d6L) & 0xffffffffL; - E = D; D = C; C = SHA_ROTL(B, 30); B = A; A = TEMP; - } - - H[0] = (H[0] + A) & 0xffffffffL; - H[1] = (H[1] + B) & 0xffffffffL; - H[2] = (H[2] + C) & 0xffffffffL; - H[3] = (H[3] + D) & 0xffffffffL; - H[4] = (H[4] + E) & 0xffffffffL; -} - - - -//######################################################################## -//######################################################################## -//### M D 5 H A S H I N G -//######################################################################## -//######################################################################## - - - - -void Md5::hash(unsigned char *dataIn, unsigned long len, unsigned char *digest) -{ - Md5 md5; - md5.append(dataIn, len); - md5.finish(digest); -} - -DOMString Md5::hashHex(unsigned char *dataIn, unsigned long len) -{ - Md5 md5; - md5.append(dataIn, len); - DOMString ret = md5.finishHex(); - return ret; -} - -DOMString Md5::hashHex(const DOMString &str) -{ - Md5 md5; - md5.append(str); - DOMString ret = md5.finishHex(); - return ret; -} - - -/** - * Initialize MD5 polynomials and storage - */ -void Md5::init() -{ - hashBuf[0] = 0x67452301; - hashBuf[1] = 0xefcdab89; - hashBuf[2] = 0x98badcfe; - hashBuf[3] = 0x10325476; - - nrBytesHi = 0; - nrBytesLo = 0; - byteNr = 0; - longNr = 0; -} - - - - -/** - * Update with one character - */ -void Md5::append(unsigned char ch) -{ - if (nrBytesLo == 0xffffffff) - { - nrBytesLo = 0; - nrBytesHi++; - } - else - nrBytesLo++; - - //pack 64 bytes into 16 longs - inb[byteNr++] = (unsigned long)ch; - if (byteNr >= 4) - { - unsigned long val = - inb[3] << 24 | inb[2] << 16 | inb[1] << 8 | inb[0]; - inBuf[longNr++] = val; - byteNr = 0; - } - if (longNr >= 16) - { - transform(); - longNr = 0; - } -} - - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void Md5::append(unsigned char *source, unsigned long len) -{ - while (len--) - append(*source++); -} - - -/* - * Update context to reflect the concatenation of another string - */ -void Md5::append(const DOMString &str) -{ - append((unsigned char *)str.c_str(), str.size()); -} - - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void Md5::finish(unsigned char *digest) -{ - //snapshot the bit count now before padding - unsigned long nrBitsLo = (nrBytesLo << 3) & 0xffffffff; - unsigned long nrBitsHi = (nrBytesHi << 3) | ((nrBytesLo >> 29) & 7); - - //Append terminal char - append(0x80); - - //pad until we have a 56 of 64 bytes, allowing for 8 bytes at the end - while (longNr != 14) - append(0); - - //##### Append length in bits - append((unsigned char)((nrBitsLo ) & 0xff)); - append((unsigned char)((nrBitsLo>> 8) & 0xff)); - append((unsigned char)((nrBitsLo>>16) & 0xff)); - append((unsigned char)((nrBitsLo>>24) & 0xff)); - append((unsigned char)((nrBitsHi ) & 0xff)); - append((unsigned char)((nrBitsHi>> 8) & 0xff)); - append((unsigned char)((nrBitsHi>>16) & 0xff)); - append((unsigned char)((nrBitsHi>>24) & 0xff)); - - //copy out answer - int indx = 0; - for (int i=0 ; i<4 ; i++) - { - digest[indx++] = (unsigned char)((hashBuf[i] ) & 0xff); - digest[indx++] = (unsigned char)((hashBuf[i] >> 8) & 0xff); - digest[indx++] = (unsigned char)((hashBuf[i] >> 16) & 0xff); - digest[indx++] = (unsigned char)((hashBuf[i] >> 24) & 0xff); - } - - init(); // Security! ;-) -} - - - -static const char *md5hex = "0123456789abcdef"; - -DOMString Md5::finishHex() -{ - unsigned char hashout[16]; - finish(hashout); - DOMString ret; - for (int i=0 ; i<16 ; i++) - { - unsigned char ch = hashout[i]; - ret.push_back(md5hex[ (ch>>4) & 15 ]); - ret.push_back(md5hex[ ch & 15 ]); - } - return ret; -} - - - -//# The four core functions - F1 is optimized somewhat - -// #define F1(x, y, z) (x & y | ~x & z) -#define M(x) ((x) &= 0xffffffff) -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -// ## This is the central step in the MD5 algorithm. -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += (f(x, y, z) + data), M(w), w = w<<s | w>>(32-s), w += x, M(w) ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - * @parm buf points to an array of 4 unsigned 32bit (at least) integers - * @parm in points to an array of 16 unsigned 32bit (at least) integers - */ -void Md5::transform() -{ - unsigned long *i = inBuf; - unsigned long a = hashBuf[0]; - unsigned long b = hashBuf[1]; - unsigned long c = hashBuf[2]; - unsigned long d = hashBuf[3]; - - MD5STEP(F1, a, b, c, d, i[ 0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, i[ 1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, i[ 2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, i[ 3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, i[ 4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, i[ 5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, i[ 6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, i[ 7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, i[ 8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, i[ 9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, i[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, i[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, i[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, i[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, i[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, i[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, i[ 1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, i[ 6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, i[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, i[ 0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, i[ 5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, i[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, i[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, i[ 4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, i[ 9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, i[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, i[ 3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, i[ 8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, i[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, i[ 2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, i[ 7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, i[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, i[ 5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, i[ 8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, i[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, i[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, i[ 1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, i[ 4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, i[ 7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, i[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, i[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, i[ 0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, i[ 3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, i[ 6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, i[ 9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, i[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, i[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, i[ 2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, i[ 0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, i[ 7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, i[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, i[ 5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, i[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, i[ 3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, i[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, i[ 1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, i[ 8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, i[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, i[ 6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, i[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, i[ 4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, i[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, i[ 2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, i[ 9] + 0xeb86d391, 21); - - hashBuf[0] += a; - hashBuf[1] += b; - hashBuf[2] += c; - hashBuf[3] += d; -} - - - - - -//######################################################################## -//######################################################################## -//### T H R E A D -//######################################################################## -//######################################################################## - - - - - -#ifdef __WIN32__ - - -static DWORD WINAPI WinThreadFunction(LPVOID context) -{ - Thread *thread = (Thread *)context; - thread->execute(); - return 0; -} - - -void Thread::start() -{ - DWORD dwThreadId; - HANDLE hThread = CreateThread(NULL, 0, WinThreadFunction, - (LPVOID)this, 0, &dwThreadId); - //Make sure the thread is started before 'this' is deallocated - while (!started) - sleep(10); - CloseHandle(hThread); -} - -void Thread::sleep(unsigned long millis) -{ - Sleep(millis); -} - -#else /* UNIX */ - - -void *PthreadThreadFunction(void *context) -{ - Thread *thread = (Thread *)context; - thread->execute(); - return NULL; -} - - -void Thread::start() -{ - pthread_t thread; - - int ret = pthread_create(&thread, NULL, - PthreadThreadFunction, (void *)this); - if (ret != 0) - printf("Thread::start: thread creation failed: %s\n", strerror(ret)); - - //Make sure the thread is started before 'this' is deallocated - while (!started) - sleep(10); - -} - -void Thread::sleep(unsigned long millis) -{ - timespec requested; - requested.tv_sec = millis / 1000; - requested.tv_nsec = (millis % 1000 ) * 1000000L; - nanosleep(&requested, NULL); -} - -#endif - - - - - - - - -//######################################################################## -//######################################################################## -//### S O C K E T -//######################################################################## -//######################################################################## - - - - - -//######################################################################### -//# U T I L I T Y -//######################################################################### - -static void mybzero(void *s, size_t n) -{ - unsigned char *p = (unsigned char *)s; - while (n > 0) - { - *p++ = (unsigned char)0; - n--; - } -} - -static void mybcopy(void *src, void *dest, size_t n) -{ - unsigned char *p = (unsigned char *)dest; - unsigned char *q = (unsigned char *)src; - while (n > 0) - { - *p++ = *q++; - n--; - } -} - - - -//######################################################################### -//# T C P C O N N E C T I O N -//######################################################################### - -TcpSocket::TcpSocket() -{ - init(); -} - - -TcpSocket::TcpSocket(const std::string &hostnameArg, int port) -{ - init(); - hostname = hostnameArg; - portno = port; -} - - - - -#ifdef HAVE_SSL - -static void cryptoLockCallback(int mode, int type, const char */*file*/, int /*line*/) -{ - //printf("########### LOCK\n"); - static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ - const char *errstr = NULL; - - int rw = mode & (CRYPTO_READ|CRYPTO_WRITE); - if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE))) - { - errstr = "invalid mode"; - goto err; - } - - if (type < 0 || type >= CRYPTO_NUM_LOCKS) - { - errstr = "type out of bounds"; - goto err; - } - - if (mode & CRYPTO_LOCK) - { - if (modes[type]) - { - errstr = "already locked"; - /* must not happen in a single-threaded program - * (would deadlock) - */ - goto err; - } - - modes[type] = rw; - } - else if (mode & CRYPTO_UNLOCK) - { - if (!modes[type]) - { - errstr = "not locked"; - goto err; - } - - if (modes[type] != rw) - { - errstr = (rw == CRYPTO_READ) ? - "CRYPTO_r_unlock on write lock" : - "CRYPTO_w_unlock on read lock"; - } - - modes[type] = 0; - } - else - { - errstr = "invalid mode"; - goto err; - } - - err: - if (errstr) - { - //how do we pass a context pointer here? - //error("openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d", - // errstr, mode, type, file, line); - } -} - -static unsigned long cryptoIdCallback() -{ -#ifdef __WIN32__ - unsigned long ret = (unsigned long) GetCurrentThreadId(); -#else - unsigned long ret = (unsigned long) pthread_self(); -#endif - return ret; -} - -#endif - - -TcpSocket::TcpSocket(const TcpSocket &other) -{ - init(); - sock = other.sock; - hostname = other.hostname; - portno = other.portno; -} - - -void TcpSocket::error(const char *fmt, ...) -{ - static char buf[256]; - lastError = "TcpSocket err: "; - va_list args; - va_start(args, fmt); - vsnprintf(buf, 255, fmt, args); - va_end(args); - lastError.append(buf); - fprintf(stderr, "%s\n", lastError.c_str()); -} - - -DOMString &TcpSocket::getLastError() -{ - return lastError; -} - - - -static bool tcp_socket_inited = false; - -void TcpSocket::init() -{ - if (!tcp_socket_inited) - { -#ifdef __WIN32__ - WORD wVersionRequested = MAKEWORD( 2, 2 ); - WSADATA wsaData; - WSAStartup( wVersionRequested, &wsaData ); -#endif -#ifdef HAVE_SSL - if (libssl_is_present) - { - sslStream = NULL; - sslContext = NULL; - CRYPTO_set_locking_callback(cryptoLockCallback); - CRYPTO_set_id_callback(cryptoIdCallback); - SSL_library_init(); - SSL_load_error_strings(); - } -#endif - tcp_socket_inited = true; - } - sock = -1; - connected = false; - hostname = ""; - portno = -1; - sslEnabled = false; - receiveTimeout = 0; -} - -TcpSocket::~TcpSocket() -{ - disconnect(); -} - -bool TcpSocket::isConnected() -{ - if (!connected || sock < 0) - return false; - return true; -} - -bool TcpSocket::getHaveSSL() -{ -#ifdef HAVE_SSL - if (libssl_is_present) - { - return true; - } else { - return false; - } -#else - return false; -#endif -} - -void TcpSocket::enableSSL(bool val) -{ - sslEnabled = val; -} - -bool TcpSocket::getEnableSSL() -{ - return sslEnabled; -} - - - -bool TcpSocket::connect(const std::string &hostnameArg, int portnoArg) -{ - hostname = hostnameArg; - portno = portnoArg; - return connect(); -} - - - -#ifdef HAVE_SSL -/* -static int password_cb(char *buf, int bufLen, int rwflag, void *userdata) -{ - char *password = "password"; - if (bufLen < (int)(strlen(password)+1)) - return 0; - - strcpy(buf,password); - int ret = strlen(password); - return ret; -} - -static void infoCallback(const SSL *ssl, int where, int ret) -{ - switch (where) - { - case SSL_CB_ALERT: - { - printf("## %d SSL ALERT: %s\n", where, SSL_alert_desc_string_long(ret)); - break; - } - default: - { - printf("## %d SSL: %s\n", where, SSL_state_string_long(ssl)); - break; - } - } -} -*/ -#endif - - -bool TcpSocket::startTls() -{ -#ifndef HAVE_SSL - error("SSL starttls() error: client not compiled with SSL enabled"); - return false; -#else /*HAVE_SSL*/ - if (!libssl_is_present) - { - error("SSL starttls() error: the correct version of libssl was not found"); - return false; - } - - sslStream = NULL; - sslContext = NULL; - - //SSL_METHOD *meth = SSLv23_method(); - //SSL_METHOD *meth = SSLv3_client_method(); - SSL_METHOD *meth = TLSv1_client_method(); - sslContext = SSL_CTX_new(meth); - //SSL_CTX_set_info_callback(sslContext, infoCallback); - - /** - * For now, let's accept all connections. Ignore this - * block of code - * - char *keyFile = "client.pem"; - char *caList = "root.pem"; - //# Load our keys and certificates - if (!(SSL_CTX_use_certificate_chain_file(sslContext, keyFile))) - { - fprintf(stderr, "Can't read certificate file\n"); - disconnect(); - return false; - } - - SSL_CTX_set_default_passwd_cb(sslContext, password_cb); - - if (!(SSL_CTX_use_PrivateKey_file(sslContext, keyFile, SSL_FILETYPE_PEM))) - { - fprintf(stderr, "Can't read key file\n"); - disconnect(); - return false; - } - - //## Load the CAs we trust - if (!(SSL_CTX_load_verify_locations(sslContext, caList, 0))) - { - fprintf(stderr, "Can't read CA list\n"); - disconnect(); - return false; - } - */ - - /* Connect the SSL socket */ - sslStream = SSL_new(sslContext); - SSL_set_fd(sslStream, sock); - - int ret = SSL_connect(sslStream); - if (ret == 0) - { - error("SSL connection not successful"); - disconnect(); - return false; - } - else if (ret < 0) - { - int err = SSL_get_error(sslStream, ret); - error("SSL connect error %d", err); - disconnect(); - return false; - } - - sslEnabled = true; - return true; -#endif /* HAVE_SSL */ -} - - -bool TcpSocket::connect() -{ - if (hostname.size()<1) - { - error("open: null hostname"); - return false; - } - - if (portno<1) - { - error("open: bad port number"); - return false; - } - - sock = socket(PF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - error("open: error creating socket"); - return false; - } - - char *c_hostname = (char *)hostname.c_str(); - struct hostent *server = gethostbyname(c_hostname); - if (!server) - { - error("open: could not locate host '%s'", c_hostname); - return false; - } - - struct sockaddr_in serv_addr; - mybzero((char *) &serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - mybcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, - server->h_length); - serv_addr.sin_port = htons(portno); - - int ret = ::connect(sock, (const sockaddr *)&serv_addr, sizeof(serv_addr)); - if (ret < 0) - { - error("open: could not connect to host '%s'", c_hostname); - return false; - } - - if (sslEnabled) - { - if (!startTls()) - return false; - } - connected = true; - return true; -} - -bool TcpSocket::disconnect() -{ - bool ret = true; - connected = false; -#ifdef HAVE_SSL - if (libssl_is_present) - { - if (sslEnabled) - { - if (sslStream) - { - int r = SSL_shutdown(sslStream); - switch(r) - { - case 1: - break; /* Success */ - case 0: - case -1: - default: - error("Shutdown failed"); - ret = false; - } - SSL_free(sslStream); - } - if (sslContext) - SSL_CTX_free(sslContext); - } - sslStream = NULL; - sslContext = NULL; - } -#endif /*HAVE_SSL*/ - -#ifdef __WIN32__ - closesocket(sock); -#else - ::close(sock); -#endif - sock = -1; - sslEnabled = false; - - return ret; -} - - - -bool TcpSocket::setReceiveTimeout(unsigned long millis) -{ - receiveTimeout = millis; - return true; -} - -/** - * For normal sockets, return the number of bytes waiting to be received. - * For SSL, just return >0 when something is ready to be read. - */ -long TcpSocket::available() -{ - if (!isConnected()) - return -1; - - long count = 0; -#ifdef __WIN32__ - if (ioctlsocket(sock, FIONREAD, (unsigned long *)&count) != 0) - return -1; -#else - if (ioctl(sock, FIONREAD, &count) != 0) - return -1; -#endif - if (count<=0 && sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - return SSL_pending(sslStream); - } -#endif - } - return count; -} - - - -bool TcpSocket::write(int ch) -{ - if (!isConnected()) - { - error("write: socket closed"); - return false; - } - unsigned char c = (unsigned char)ch; - - if (sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - int r = SSL_write(sslStream, &c, 1); - if (r<=0) - { - switch(SSL_get_error(sslStream, r)) - { - default: - error("SSL write problem"); - return -1; - } - } - } -#endif - } - else - { - if (send(sock, (const char *)&c, 1, 0) < 0) - //if (send(sock, &c, 1, 0) < 0) - { - error("write: could not send data"); - return false; - } - } - return true; -} - -bool TcpSocket::write(char *str) -{ - if (!isConnected()) - { - error("write(str): socket closed"); - return false; - } - int len = strlen(str); - - if (sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - int r = SSL_write(sslStream, (unsigned char *)str, len); - if (r<=0) - { - switch(SSL_get_error(sslStream, r)) - { - default: - error("SSL write problem"); - return -1; - } - } - } -#endif - } - else - { - if (send(sock, str, len, 0) < 0) - //if (send(sock, &c, 1, 0) < 0) - { - error("write: could not send data"); - return false; - } - } - return true; -} - -bool TcpSocket::write(const std::string &str) -{ - return write((char *)str.c_str()); -} - -int TcpSocket::read() -{ - if (!isConnected()) - return -1; - - //We'll use this loop for timeouts, so that SSL and plain sockets - //will behave the same way - if (receiveTimeout > 0) - { - unsigned long tim = 0; - while (true) - { - int avail = available(); - if (avail > 0) - break; - if (tim >= receiveTimeout) - return -2; - Thread::sleep(20); - tim += 20; - } - } - - //check again - if (!isConnected()) - return -1; - - unsigned char ch; - if (sslEnabled) - { -#ifdef HAVE_SSL - if (libssl_is_present) - { - if (!sslStream) - return -1; - int r = SSL_read(sslStream, &ch, 1); - unsigned long err = SSL_get_error(sslStream, r); - switch (err) - { - case SSL_ERROR_NONE: - break; - case SSL_ERROR_ZERO_RETURN: - return -1; - case SSL_ERROR_SYSCALL: - error("SSL read problem(syscall) %s", - ERR_error_string(ERR_get_error(), NULL)); - return -1; - default: - error("SSL read problem %s", - ERR_error_string(ERR_get_error(), NULL)); - return -1; - } - } -#endif - } - else - { - if (recv(sock, (char *)&ch, 1, 0) <= 0) - { - error("read: could not receive data"); - disconnect(); - return -1; - } - } - return (int)ch; -} - -std::string TcpSocket::readLine() -{ - std::string ret; - - while (isConnected()) - { - int ch = read(); - if (ch<0) - return ret; - if (ch=='\r' || ch=='\n') - return ret; - ret.push_back((char)ch); - } - - return ret; -} - - - - - - - - - -} //namespace Pedro -//######################################################################## -//# E N D O F F I L E -//######################################################################## - - - - - - - - - - - diff --git a/src/pedro/pedroutil.h b/src/pedro/pedroutil.h deleted file mode 100644 index fde2b16f8..000000000 --- a/src/pedro/pedroutil.h +++ /dev/null @@ -1,545 +0,0 @@ -#ifndef __PEDROUTIL_H__ -#define __PEDROUTIL_H__ -/* - * Support classes for the Pedro mini-XMPP client. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <stdarg.h> -#include <vector> - -#include <string> - -#include "pedrodom.h" - - -#ifdef HAVE_SSL -#include <openssl/ssl.h> -#include <openssl/err.h> -#endif - - - -namespace Pedro -{ - - - - -//######################################################################## -//######################################################################## -//# B A S E 6 4 -//######################################################################## -//######################################################################## - - -//################# -//# ENCODER -//################# - - -/** - * This class is for Base-64 encoding - */ -class Base64Encoder -{ - -public: - - Base64Encoder() - { - reset(); - } - - virtual ~Base64Encoder() - {} - - virtual void reset() - { - outBuf = 0L; - bitCount = 0; - buf = ""; - } - - virtual void append(int ch); - - virtual void append(char *str); - - virtual void append(unsigned char *str, int len); - - virtual void append(const DOMString &str); - - virtual DOMString finish(); - - static DOMString encode(const DOMString &str); - - -private: - - - unsigned long outBuf; - - int bitCount; - - DOMString buf; - -}; - - - - -//################# -//# DECODER -//################# - -class Base64Decoder -{ -public: - Base64Decoder() - { - reset(); - } - - virtual ~Base64Decoder() - {} - - virtual void reset() - { - inCount = 0; - buf.clear(); - } - - - virtual void append(int ch); - - virtual void append(char *str); - - virtual void append(const DOMString &str); - - std::vector<unsigned char> finish(); - - static std::vector<unsigned char> decode(const DOMString &str); - - static DOMString decodeToString(const DOMString &str); - -private: - - int inBytes[4]; - int inCount; - std::vector<unsigned char> buf; -}; - - - - -//######################################################################## -//######################################################################## -//### S H A 1 H A S H I N G -//######################################################################## -//######################################################################## - -/** - * This class performs a slow SHA1 hash on a stream of input data. - */ -class Sha1 -{ -public: - - /** - * Constructor - */ - Sha1() - { init(); } - - /** - * - */ - virtual ~Sha1() - { init(); } - - - /** - * Static convenience method. This would be the most commonly used - * version; - * @parm digest points to a bufer of 20 unsigned chars - */ - static void hash(unsigned char *dataIn, int len, unsigned char *digest); - - /** - * Static convenience method. This will fill a string with the hex - * coded string. - */ - static DOMString hashHex(unsigned char *dataIn, int len); - - /** - * Static convenience method. - */ - static DOMString hashHex(const DOMString &str); - - /** - * Initialize the context (also zeroizes contents) - */ - virtual void init(); - - /** - * Append a single character - */ - virtual void append(unsigned char ch); - - /** - * Append a data buffer - */ - virtual void append(unsigned char *dataIn, int len); - - /** - * Append a String - */ - virtual void append(const DOMString &str); - - /** - * - * @parm digest points to a bufer of 20 unsigned chars - */ - virtual void finish(unsigned char *digest); - - -private: - - void transform(); - - unsigned long hashBuf[5]; - unsigned long inBuf[80]; - unsigned long nrBytesHi; - unsigned long nrBytesLo; - int longNr; - int byteNr; - unsigned long inb[4]; - -}; - - - - - -//######################################################################## -//######################################################################## -//### M D 5 H A S H I N G -//######################################################################## -//######################################################################## - - -/** - * This is a utility version of a simple MD5 hash algorithm. This is - * neither efficient nor fast. It is intended to be a small simple utility - * for hashing small amounts of data in a non-time-critical place. - * - * Note that this is a rewrite whose purpose is to remove any - * machine dependencies. - */ -class Md5 -{ -public: - - /** - * Constructor - */ - Md5() - { init(); } - - /** - * Destructor - */ - virtual ~Md5() - {} - - /** - * Static convenience method. - * @parm digest points to an buffer of 16 unsigned chars - */ - static void hash(unsigned char *dataIn, - unsigned long len, unsigned char *digest); - - /** - * Static convenience method. - * Hash a byte array of a given length - */ - static DOMString hashHex(unsigned char *dataIn, unsigned long len); - - /** - * Static convenience method. - * Hash a String - */ - static DOMString hashHex(const DOMString &str); - - /** - * Initialize the context (also zeroizes contents) - */ - virtual void init(); - - /* - * Update with one character - */ - virtual void append(unsigned char ch); - - /** - * Update with a byte buffer of a given length - */ - virtual void append(unsigned char *dataIn, unsigned long len); - - /** - * Update with a string - */ - virtual void append(const DOMString &str); - - /** - * Finalize and output the hash. - * @parm digest points to an buffer of 16 unsigned chars - */ - virtual void finish(unsigned char *digest); - - - /** - * Same as above , but hex to an output String - */ - virtual DOMString finishHex(); - -private: - - void transform(); - - unsigned long hashBuf[4]; - unsigned long inBuf[16]; - unsigned long nrBytesHi; - unsigned long nrBytesLo; - - unsigned long inb[4]; // Buffer for input bytes as longs - int byteNr; // which byte in long - int longNr; // which long in 8 long segment - -}; - - - - - -//######################################################################## -//######################################################################## -//### T H R E A D -//######################################################################## -//######################################################################## - - - -/** - * This is the interface for a delegate class which can - * be run by a Thread. - * Thread thread(runnable); - * thread.start(); - */ -class Runnable -{ -public: - - Runnable() - {} - virtual ~Runnable() - {} - - /** - * The method of a delegate class which can - * be run by a Thread. Thread is completed when this - * method is done. - */ - virtual void run() = 0; - -}; - - - -/** - * A simple wrapper of native threads in a portable class. - * It can be used either to execute its own run() method, or - * delegate to a Runnable class's run() method. - */ -class Thread -{ -public: - - /** - * Create a thread which will execute its own run() method. - */ - Thread() - { runnable = NULL ; started = false; } - - /** - * Create a thread which will run a Runnable class's run() method. - */ - Thread(const Runnable &runner) - { runnable = (Runnable *)&runner; started = false; } - - /** - * This does not kill a spawned thread. - */ - virtual ~Thread() - {} - - /** - * Static method to pause the current thread for a given - * number of milliseconds. - */ - static void sleep(unsigned long millis); - - /** - * This method will be executed if the Thread was created with - * no delegated Runnable class. The thread is completed when - * the method is done. - */ - virtual void run() - {} - - /** - * Starts the thread. - */ - virtual void start(); - - /** - * Calls either this class's run() method, or that of a Runnable. - * A user would normally not call this directly. - */ - virtual void execute() - { - started = true; - if (runnable) - runnable->run(); - else - run(); - } - -private: - - Runnable *runnable; - - bool started; - -}; - - - - - - -//######################################################################## -//######################################################################## -//### S O C K E T -//######################################################################## -//######################################################################## - - - -/** - * A socket wrapper that provides cross-platform capability, plus SSL - */ -class TcpSocket -{ -public: - - TcpSocket(); - - TcpSocket(const std::string &hostname, int port); - - TcpSocket(const char *hostname, int port); - - TcpSocket(const TcpSocket &other); - - virtual ~TcpSocket(); - - void error(const char *fmt, ...); - - DOMString &getLastError(); - - bool isConnected(); - - void enableSSL(bool val); - - bool getEnableSSL(); - - bool getHaveSSL(); - - bool connect(const std::string &hostname, int portno); - - bool connect(const char *hostname, int portno); - - bool startTls(); - - bool connect(); - - bool disconnect(); - - bool setReceiveTimeout(unsigned long millis); - - long available(); - - bool write(int ch); - - bool write(char *str); - - bool write(const std::string &str); - - int read(); - - std::string readLine(); - -private: - void init(); - - DOMString lastError; - - std::string hostname; - int portno; - int sock; - bool connected; - - bool sslEnabled; - - unsigned long receiveTimeout; - - -#ifdef HAVE_SSL - SSL_CTX *sslContext; - SSL *sslStream; -#endif - -}; - - - - - - -} //namespace Pedro - -#endif /* __PEDROUTIL_H__ */ - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/pedroxmpp.cpp b/src/pedro/pedroxmpp.cpp deleted file mode 100644 index 3baeeee06..000000000 --- a/src/pedro/pedroxmpp.cpp +++ /dev/null @@ -1,3649 +0,0 @@ -/* - * Implementation the Pedro mini-XMPP client - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include <algorithm> -#include <cstdio> -#include <stdarg.h> -#include <stdlib.h> - -#include <sys/stat.h> - -#include <time.h> - -#include "pedroxmpp.h" -#include "pedrodom.h" -#include "pedroutil.h" - -#include <map> - - - -namespace Pedro -{ - - -//######################################################################## -//######################################################################## -//# X M P P E V E N T -//######################################################################## -//######################################################################## - - -XmppEvent::XmppEvent(int type) -{ - eventType = type; - presence = false; - dom = NULL; -} - -XmppEvent::XmppEvent(const XmppEvent &other) -{ - assign(other); -} - -XmppEvent &XmppEvent::operator=(const XmppEvent &other) -{ - assign(other); - return (*this); -} - -XmppEvent::~XmppEvent() -{ - if (dom) - delete dom; -} - -void XmppEvent::assign(const XmppEvent &other) -{ - eventType = other.eventType; - presence = other.presence; - status = other.status; - show = other.show; - to = other.to; - from = other.from; - group = other.group; - data = other.data; - fileName = other.fileName; - fileDesc = other.fileDesc; - fileSize = other.fileSize; - fileHash = other.fileHash; - setDOM(other.dom); -} - -int XmppEvent::getType() const -{ - return eventType; -} - -DOMString XmppEvent::getIqId() const -{ - return iqId; -} - -void XmppEvent::setIqId(const DOMString &val) -{ - iqId = val; -} - -DOMString XmppEvent::getStreamId() const -{ - return streamId; -} - -void XmppEvent::setStreamId(const DOMString &val) -{ - streamId = val; -} - -bool XmppEvent::getPresence() const -{ - return presence; -} - -void XmppEvent::setPresence(bool val) -{ - presence = val; -} - -DOMString XmppEvent::getShow() const -{ - return show; -} - -void XmppEvent::setShow(const DOMString &val) -{ - show = val; -} - -DOMString XmppEvent::getStatus() const -{ - return status; -} - -void XmppEvent::setStatus(const DOMString &val) -{ - status = val; -} - -DOMString XmppEvent::getTo() const -{ - return to; -} - -void XmppEvent::setTo(const DOMString &val) -{ - to = val; -} - -DOMString XmppEvent::getFrom() const -{ - return from; -} - -void XmppEvent::setFrom(const DOMString &val) -{ - from = val; -} - -DOMString XmppEvent::getGroup() const -{ - return group; -} - -void XmppEvent::setGroup(const DOMString &val) -{ - group = val; -} - -DOMString XmppEvent::getData() const -{ - return data; -} - -void XmppEvent::setData(const DOMString &val) -{ - data = val; -} - -DOMString XmppEvent::getFileName() const -{ - return fileName; -} - -void XmppEvent::setFileName(const DOMString &val) -{ - fileName = val; -} - -DOMString XmppEvent::getFileDesc() const -{ - return fileDesc; -} - -void XmppEvent::setFileDesc(const DOMString &val) -{ - fileDesc = val; -} - -long XmppEvent::getFileSize() const -{ - return fileSize; -} - -void XmppEvent::setFileSize(long val) -{ - fileSize = val; -} - -DOMString XmppEvent::getFileHash() const -{ - return fileHash; -} - -void XmppEvent::setFileHash(const DOMString &val) -{ - fileHash = val; -} - -Element *XmppEvent::getDOM() const -{ - return dom; -} - -void XmppEvent::setDOM(const Element *val) -{ - if (!val) - dom = NULL; - else - dom = ((Element *)val)->clone(); -} - - -std::vector<XmppUser> XmppEvent::getUserList() const -{ - return userList; -} - -void XmppEvent::setUserList(const std::vector<XmppUser> &val) -{ - userList = val; -} - - - - - - - - - -//######################################################################## -//######################################################################## -//# X M P P E V E N T T A R G E T -//######################################################################## -//######################################################################## - - -//########################### -//# CONSTRUCTORS -//########################### - -XmppEventTarget::XmppEventTarget() -{ - eventQueueEnabled = false; -} - - -XmppEventTarget::XmppEventTarget(const XmppEventTarget &other) -{ - listeners = other.listeners; - eventQueueEnabled = other.eventQueueEnabled; -} - -XmppEventTarget::~XmppEventTarget() -{ -} - - -//########################### -//# M E S S A G E S -//########################### - -/** - * Print a printf()-like formatted error message - */ -void XmppEventTarget::error(const char *fmt, ...) -{ - va_list args; - va_start(args,fmt); - gchar * buffer = g_strdup_vprintf(fmt, args); - va_end(args) ; - fprintf(stderr, "Error:%s\n", buffer); - XmppEvent evt(XmppEvent::EVENT_ERROR); - evt.setData(buffer); - dispatchXmppEvent(evt); - g_free(buffer); -} - - - -/** - * Print a printf()-like formatted trace message - */ -void XmppEventTarget::status(const char *fmt, ...) -{ - va_list args; - va_start(args,fmt); - gchar * buffer = g_strdup_vprintf(fmt, args); - va_end(args) ; - //printf("Status:%s\n", buffer); - XmppEvent evt(XmppEvent::EVENT_STATUS); - evt.setData(buffer); - dispatchXmppEvent(evt); - g_free(buffer); -} - - - -//########################### -//# L I S T E N E R S -//########################### - -void XmppEventTarget::dispatchXmppEvent(const XmppEvent &event) -{ - std::vector<XmppEventListener *>::iterator iter; - for (iter = listeners.begin(); iter != listeners.end() ; iter++) - (*iter)->processXmppEvent(event); - if (eventQueueEnabled) - eventQueue.push_back(event); -} - -void XmppEventTarget::addXmppEventListener(const XmppEventListener &listener) -{ - XmppEventListener *lsnr = (XmppEventListener *)&listener; - std::vector<XmppEventListener *>::iterator iter; - for (iter = listeners.begin(); iter != listeners.end() ; iter++) - if (*iter == lsnr) - return; - listeners.push_back(lsnr); -} - -void XmppEventTarget::removeXmppEventListener(const XmppEventListener &listener) -{ - XmppEventListener *lsnr = (XmppEventListener *)&listener; - std::vector<XmppEventListener *>::iterator iter; - for (iter = listeners.begin(); iter != listeners.end() ; iter++) - if (*iter == lsnr) - listeners.erase(iter); -} - -void XmppEventTarget::clearXmppEventListeners() -{ - listeners.clear(); -} - - -//########################### -//# E V E N T Q U E U E -//########################### - -void XmppEventTarget::eventQueueEnable(bool val) -{ - eventQueueEnabled = val; - if (!eventQueueEnabled) - eventQueue.clear(); -} - -int XmppEventTarget::eventQueueAvailable() -{ - return eventQueue.size(); -} - -XmppEvent XmppEventTarget::eventQueuePop() -{ - if (!eventQueueEnabled || eventQueue.size()<1) - { - XmppEvent dummy(XmppEvent::EVENT_NONE); - return dummy; - } - XmppEvent event = *(eventQueue.begin()); - eventQueue.erase(eventQueue.begin()); - return event; -} - - - - - -//######################################################################## -//######################################################################## -//# X M P P S T R E A M -//######################################################################## -//######################################################################## - - -/** - * - */ -class XmppStream -{ -public: - - /** - * - */ - XmppStream() - { reset(); } - - /** - * - */ - XmppStream(const XmppStream &other) - { assign(other); } - - /** - * - */ - XmppStream &operator=(const XmppStream &other) - { assign(other); return *this; } - - /** - * - */ - virtual ~XmppStream() - {} - - /** - * - */ - virtual void reset() - { - state = XmppClient::STREAM_AVAILABLE; - seqNr = 0; - messageId = ""; - sourceId = ""; - data.clear(); - } - - /** - * - */ - virtual int getState() - { return state; } - - /** - * - */ - virtual void setState(int val) - { state = val; } - - /** - * - */ - virtual DOMString getStreamId() - { return streamId; } - - /** - * - */ - void setStreamId(const DOMString &val) - { streamId = val; } - - /** - * - */ - virtual DOMString getMessageId() - { return messageId; } - - /** - * - */ - void setMessageId(const DOMString &val) - { messageId = val; } - - /** - * - */ - virtual int getSeqNr() - { - seqNr++; - if (seqNr >= 65535) - seqNr = 0; - return seqNr; - } - - /** - * - */ - virtual DOMString getPeerId() - { return sourceId; } - - /** - * - */ - virtual void setPeerId(const DOMString &val) - { sourceId = val; } - - /** - * - */ - int available() - { return data.size(); } - - /** - * - */ - void receiveData(std::vector<unsigned char> &newData) - { - std::vector<unsigned char>::iterator iter; - for (iter=newData.begin() ; iter!=newData.end() ; iter++) - data.push_back(*iter); - } - - /** - * - */ - std::vector<unsigned char> read() - { - if (state != XmppClient::STREAM_OPEN) - { - std::vector<unsigned char>dummy; - return dummy; - } - std::vector<unsigned char> ret = data; - data.clear(); - return ret; - } - -private: - - void assign(const XmppStream &other) - { - streamId = other.streamId; - messageId = other.messageId; - sourceId = other.sourceId; - state = other.state; - seqNr = other.seqNr; - data = other.data; - } - - - DOMString streamId; - - DOMString messageId; - - DOMString sourceId; - - int state; - - long seqNr; - - std::vector<unsigned char> data; -}; - - - - - - - - - - -//######################################################################## -//######################################################################## -//# X M P P C L I E N T -//######################################################################## -//######################################################################## - -class ReceiverThread : public Runnable -{ -public: - - ReceiverThread(XmppClient &par) : client(par) {} - - virtual ~ReceiverThread() {} - - void run() - { client.receiveAndProcessLoop(); } - -private: - - XmppClient &client; -}; - - - - - -//######################################################################## -//# CONSTRUCTORS -//######################################################################## - -XmppClient::XmppClient() -{ - init(); -} - - -XmppClient::XmppClient(const XmppClient &other) : XmppEventTarget(other) -{ - init(); - assign(other); -} - -void XmppClient::assign(const XmppClient &other) -{ - msgId = other.msgId; - host = other.host; - realm = other.realm; - port = other.port; - username = other.username; - password = other.password; - resource = other.resource; - connected = other.connected; - doRegister = other.doRegister; - groupChats = other.groupChats; - streamPacket = other.streamPacket; -} - - -void XmppClient::init() -{ - sock = new TcpSocket(); - msgId = 0; - connected = false; - doRegister = false; - streamPacket = "message"; - -} - -XmppClient::~XmppClient() -{ - disconnect(); - delete sock; - std::map<DOMString, XmppStream *>::iterator iter; - for (iter = outputStreams.begin(); iter!=outputStreams.end() ; iter++) - delete iter->second; - for (iter = inputStreams.begin(); iter!=inputStreams.end() ; iter++) - delete iter->second; - for (iter = fileSends.begin(); iter!=fileSends.end() ; iter++) - delete iter->second; - groupChatsClear(); -} - - - - - - -//######################################################################## -//# UTILILY -//######################################################################## - -/** - * - */ -bool XmppClient::pause(unsigned long millis) -{ - Thread::sleep(millis); - return true; -} - - -static int strIndex(const DOMString &str, const char *key) -{ - unsigned int p = str.find(key); - if (p == str.npos) - return -1; - return p; -} - - -DOMString XmppClient::toXml(const DOMString &str) -{ - return Parser::encode(str); -} - - - -static DOMString trim(const DOMString &str) -{ - unsigned int i; - for (i=0 ; i<str.size() ; i++) - if (!isspace(str[i])) - break; - int start = i; - for (i=str.size() ; i>0 ; i--) - if (!isspace(str[i-1])) - break; - int end = i; - if (start>=end) - return ""; - return str.substr(start, end); -} - - - - - -//######################################################################## -//# VARIABLES (ones that need special handling) -//######################################################################## - -/** - * - */ -DOMString XmppClient::getUsername() -{ - return username; -} - -/** - * - */ -void XmppClient::setUsername(const DOMString &val) -{ - int p = strIndex(val, "@"); - if (p > 0) - { - username = val.substr(0, p); - realm = val.substr(p+1, jid.size()-p-1); - } - else - { - realm = host; - username = val; - } -} - - - - - - - - -//######################################################################## -//# RECEIVING -//######################################################################## - - -DOMString XmppClient::readStanza() -{ - - int openCount = 0; - bool inTag = false; - bool slashSeen = false; - bool trivialTag = false; - bool querySeen = false; - bool inQuote = false; - bool textSeen = false; - DOMString buf; - - - time_t timeout = time((time_t *)0) + 180; - - while (true) - { - int ch = sock->read(); - //printf("%c", ch); fflush(stdout); - if (ch<0) - { - if (ch == -2) //a simple timeout, not an error - { - //Since we are timed out, let's assume that we - //are between chunks of text. Let's reset all states. - //printf("-----#### Timeout\n"); - time_t currentTime = time((time_t *)0); - if (currentTime > timeout) - { - timeout = currentTime + 180; - if (!write("\n")) - { - error("ping send error"); - disconnect(); - return ""; - } - } - continue; - } - else - { - keepGoing = false; - if (!sock->isConnected()) - { - disconnect(); - return ""; - } - else - { - error("socket read error: %s", sock->getLastError().c_str()); - disconnect(); - return ""; - } - } - } - buf.push_back(ch); - if (ch == '<') - { - inTag = true; - slashSeen = false; - querySeen = false; - inQuote = false; - textSeen = false; - trivialTag = false; - } - else if (ch == '>') - { - if (!inTag) //unescaped '>' in pcdata? horror - continue; - inTag = false; - if (!trivialTag && !querySeen) - { - if (slashSeen) - openCount--; - else - openCount++; - } - //printf("# openCount:%d t:%d q:%d\n", - // openCount, trivialTag, querySeen); - //check if we are 'balanced', but not a <?version?> tag - if (openCount <= 0 && !querySeen) - { - break; - } - //we know that this one will be open-ended - if (strIndex(buf, "<stream:stream") >= 0) - { - buf.append("</stream:stream>"); - break; - } - } - else if (ch == '/') - { - if (inTag && !inQuote) - { - slashSeen = true; - if (textSeen) // <tagName/> <--looks like this - trivialTag = true; - } - } - else if (ch == '?') - { - if (inTag && !inQuote) - querySeen = true; - } - else if (ch == '"' || ch == '\'') - { - if (inTag) - inQuote = !inQuote; - } - else - { - if (inTag && !inQuote && !isspace(ch)) - textSeen = true; - } - } - return buf; -} - - - -static bool isGroupChat(Element *root) -{ - if (!root) - return false; - ElementList elems = root->findElements("x"); - for (unsigned int i=0 ; i<elems.size() ; i++) - { - DOMString xmlns = elems[i]->getAttribute("xmlns"); - //printf("### XMLNS ### %s\n", xmlns.c_str()); - if (strIndex(xmlns, "http://jabber.org/protocol/muc") >=0 ) - return true; - } - return false; -} - - - - -static bool parseJid(const DOMString &fullJid, - DOMString &jid, DOMString &resource) -{ - DOMString str = fullJid; - jid.clear(); - resource.clear(); - unsigned int p = str.size(); - unsigned int p2 = str.rfind('/', p); - if (p2 != str.npos) - { - resource = str.substr(p2+1, p-(p2+1)); - str = str.substr(0, p); - p = p2; - } - jid = str.substr(0, p); - printf("fullJid:%s jid:%s rsrc:%s\n", - fullJid.c_str(), jid.c_str(), resource.c_str()); - return true; -} - - - - -bool XmppClient::processMessage(Element *root) -{ - DOMString from = root->getTagAttribute("message", "from"); - DOMString to = root->getTagAttribute("message", "to"); - DOMString type = root->getTagAttribute("message", "type"); - - //####Check for embedded namespaces here - //### FILE TRANSFERS - if (processFileMessage(root)) - return true; - - //### STREAMS - if (processInBandByteStreamMessage(root)) - return true; - - - //#### NORMAL MESSAGES - DOMString subject = root->getTagValue("subject"); - DOMString body = root->getTagValue("body"); - DOMString thread = root->getTagValue("thread"); - //##rfc 3921, para 2.4. ignore if no recognizable info - //if (subject.size() < 1 && thread.size()<1) - // return true; - - if (type == "groupchat") - { - DOMString fromGid; - DOMString fromNick; - parseJid(from, fromGid, fromNick); - //printf("fromGid:%s fromNick:%s\n", - // fromGid.c_str(), fromNick.c_str()); - DOMString toGid; - DOMString toNick; - parseJid(to, toGid, toNick); - //printf("toGid:%s toNick:%s\n", - // toGid.c_str(), toNick.c_str()); - - if (fromNick.size() > 0)//normal group message - { - XmppEvent event(XmppEvent::EVENT_MUC_MESSAGE); - event.setGroup(fromGid); - event.setFrom(fromNick); - event.setData(body); - event.setDOM(root); - dispatchXmppEvent(event); - } - else // from the server itself - { - //note the space before, so it doesnt match 'unlocked' - if (strIndex(body, " locked") >= 0) - { - printf("LOCKED!! ;)\n"); - const char *fmt = - "<iq id='create%d' to='%s' type='set'>" - "<query xmlns='http://jabber.org/protocol/muc#owner'>" - "<x xmlns='jabber:x:data' type='submit'/>" - "</query></iq>\n"; - if (!write(fmt, msgId++, fromGid.c_str())) - return false; - } - } - } - else - { - XmppEvent event(XmppEvent::EVENT_MESSAGE); - event.setFrom(from); - event.setData(body); - event.setDOM(root); - dispatchXmppEvent(event); - } - - return true; -} - - - - -bool XmppClient::processPresence(Element *root) -{ - - DOMString fullJid = root->getTagAttribute("presence", "from"); - DOMString to = root->getTagAttribute("presence", "to"); - DOMString presenceStr = root->getTagAttribute("presence", "type"); - bool presence = true; - if (presenceStr == "unavailable") - presence = false; - DOMString status = root->getTagValue("status"); - DOMString show = root->getTagValue("show"); - - if (isGroupChat(root)) - { - DOMString fromGid; - DOMString fromNick; - parseJid(fullJid, fromGid, fromNick); - //printf("fromGid:%s fromNick:%s\n", - // fromGid.c_str(), fromNick.c_str()); - DOMString item_jid = root->getTagAttribute("item", "jid"); - if (item_jid == jid || item_jid == to) //Me - { - if (presence) - { - groupChatCreate(fromGid); - groupChatUserAdd(fromGid, fromNick, ""); - groupChatUserShow(fromGid, fromNick, "available"); - - XmppEvent event(XmppEvent::EVENT_MUC_JOIN); - event.setGroup(fromGid); - event.setFrom(fromNick); - event.setPresence(presence); - event.setShow(show); - event.setStatus(status); - dispatchXmppEvent(event); - } - else - { - groupChatDelete(fromGid); - groupChatUserDelete(fromGid, fromNick); - - XmppEvent event(XmppEvent::EVENT_MUC_LEAVE); - event.setGroup(fromGid); - event.setFrom(fromNick); - event.setPresence(presence); - event.setShow(show); - event.setStatus(status); - dispatchXmppEvent(event); - } - } - else // someone else - { - if (presence) - { - groupChatUserAdd(fromGid, fromNick, ""); - } - else - groupChatUserDelete(fromGid, fromNick); - groupChatUserShow(fromGid, fromNick, show); - XmppEvent event(XmppEvent::EVENT_MUC_PRESENCE); - event.setGroup(fromGid); - event.setFrom(fromNick); - event.setPresence(presence); - event.setShow(show); - event.setStatus(status); - dispatchXmppEvent(event); - } - } - else - { - DOMString shortJid; - DOMString dummy; - parseJid(fullJid, shortJid, dummy); - rosterShow(shortJid, show); //users in roster do not have resource - - XmppEvent event(XmppEvent::EVENT_PRESENCE); - event.setFrom(fullJid); - event.setPresence(presence); - event.setShow(show); - event.setStatus(status); - dispatchXmppEvent(event); - } - - return true; -} - - - -bool XmppClient::processIq(Element *root) -{ - DOMString from = root->getTagAttribute("iq", "from"); - DOMString id = root->getTagAttribute("iq", "id"); - DOMString type = root->getTagAttribute("iq", "type"); - DOMString xmlns = root->getTagAttribute("query", "xmlns"); - - if (id.size()<1) - return true; - - //Group chat - if (strIndex(xmlns, "http://jabber.org/protocol/muc") >=0 ) - { - printf("results of MUC query\n"); - } - //printf("###IQ xmlns:%s\n", xmlns.c_str()); - - //### FILE TRANSFERS - if (processFileMessage(root)) - return true; - - //### STREAMS - if (processInBandByteStreamMessage(root)) - return true; - - - //###Normal Roster stuff - if (root->getTagAttribute("query", "xmlns") == "jabber:iq:roster") - { - roster.clear(); - ElementList elems = root->findElements("item"); - for (unsigned int i=0 ; i<elems.size() ; i++) - { - Element *item = elems[i]; - DOMString userJid = item->getAttribute("jid"); - DOMString name = item->getAttribute("name"); - DOMString subscription = item->getAttribute("subscription"); - DOMString group = item->getTagValue("group"); - //printf("jid:%s name:%s sub:%s group:%s\n", userJid.c_str(), name.c_str(), - // subscription.c_str(), group.c_str()); - XmppUser user(userJid, name, subscription, group); - roster.push_back(user); - } - XmppEvent event(XmppEvent::XmppEvent::EVENT_ROSTER); - dispatchXmppEvent(event); - } - - else if (id.find("regnew") != id.npos) - { - - } - - else if (id.find("regpass") != id.npos) - { - ElementList list = root->findElements("error"); - if (list.size()==0) - { - XmppEvent evt(XmppEvent::EVENT_REGISTRATION_CHANGE_PASS); - evt.setTo(username); - evt.setFrom(host); - dispatchXmppEvent(evt); - return true; - } - - Element *errElem = list[0]; - DOMString errMsg = "Password change error: "; - if (errElem->findElements("bad-request").size()>0) - { - errMsg.append("password change does not contain complete information"); - } - else if (errElem->findElements("not-authorized").size()>0) - { - errMsg.append("server does not consider the channel safe " - "enough to enable a password change"); - } - else if (errElem->findElements("not-allowed").size()>0) - { - errMsg.append("server does not allow password changes"); - } - else if (errElem->findElements("unexpected-request").size()>0) - { - errMsg.append( - "IQ set does not contain a 'from' address because " - "the entity is not registered with the server"); - } - error("%s", errMsg.c_str()); - } - - else if (id.find("regcancel") != id.npos) - { - ElementList list = root->findElements("error"); - if (list.size()==0) - { - XmppEvent evt(XmppEvent::EVENT_REGISTRATION_CANCEL); - evt.setTo(username); - evt.setFrom(host); - dispatchXmppEvent(evt); - return true; - } - - Element *errElem = list[0]; - DOMString errMsg = "Registration cancel error: "; - if (errElem->findElements("bad-request").size()>0) - { - errMsg.append("The <remove/> element was not the only child element of the <query/> element."); - } - else if (errElem->findElements("forbidden").size()>0) - { - errMsg.append("sender does not have sufficient permissions to cancel the registration"); - } - else if (errElem->findElements("not-allowed").size()>0) - { - errMsg.append("not allowed to cancel registrations in-band"); - } - else if (errElem->findElements("registration-required").size()>0) - { - errMsg.append("not previously registered"); - } - else if (errElem->findElements("unexpected-request").size()>0) - { - errMsg.append( - "IQ set does not contain a 'from' address because " - "the entity is not registered with the server"); - } - error("%s", errMsg.c_str()); - } - - return true; -} - - - - - -bool XmppClient::receiveAndProcess() -{ - if (!keepGoing) - return false; - - Parser parser; - - DOMString recvBuf = readStanza(); - recvBuf = trim(recvBuf); - if (recvBuf.size() < 1) - return true; - - //Ugly hack. Apparently the first char can be dropped on timeouts - //if (recvBuf[0] != '<') - // recvBuf.insert(0, "<"); - - status("RECV: %s", recvBuf.c_str()); - Element *root = parser.parse(recvBuf); - if (!root) - { - printf("Bad elem\n"); - return true; - } - - //#### MESSAGE - ElementList elems = root->findElements("message"); - if (elems.size()>0) - { - if (!processMessage(root)) - return false; - } - - //#### PRESENCE - elems = root->findElements("presence"); - if (elems.size()>0) - { - if (!processPresence(root)) - return false; - } - - //#### INFO - elems = root->findElements("iq"); - if (elems.size()>0) - { - if (!processIq(root)) - return false; - } - - delete root; - - return true; -} - - -bool XmppClient::receiveAndProcessLoop() -{ - keepGoing = true; - while (true) - { - if (!keepGoing) - { - status("Abort requested"); - break; - } - if (!receiveAndProcess()) - return false; - } - return true; -} - - - - -//######################################################################## -//# SENDING -//######################################################################## - - -bool XmppClient::write(const char *fmt, ...) -{ - bool rc = true; - va_list args; - va_start(args,fmt); - gchar * buffer = g_strdup_vprintf(fmt,args); - va_end(args) ; - status("SEND: %s", buffer); - if (!sock->write(buffer)) - { - error("Cannot write to socket: %s", sock->getLastError().c_str()); - rc = false; - } - g_free(buffer); - return rc; -} - - - - - - -//######################################################################## -//# R E G I S T R A T I O N -//######################################################################## - -/** - * Perform JEP-077 In-Band Registration. Performed synchronously after SSL, - * before authentication - */ -bool XmppClient::inBandRegistrationNew() -{ - Parser parser; - - const char *fmt = - "<iq type='get' id='regnew%d'>" - "<query xmlns='jabber:iq:register'/>" - "</iq>\n\n"; - if (!write(fmt, msgId++)) - return false; - - DOMString recbuf = readStanza(); - status("RECV reg: %s", recbuf.c_str()); - Element *elem = parser.parse(recbuf); - //elem->print(); - - //# does the entity send the newer "instructions" tag? - ElementList fields = elem->findElements("field"); - std::vector<DOMString> fnames; - for (unsigned int i=0; i<fields.size() ; i++) - { - DOMString fname = fields[i]->getAttribute("var"); - if (fname == "FORM_TYPE") - continue; - fnames.push_back(fname); - status("field name:%s", fname.c_str()); - } - - //Do we have any fields? - if (fnames.size() == 0) - { - //If no fields, maybe the older method was offered - if (elem->findElements("username").size() == 0 || - elem->findElements("password").size() == 0) - { - error("server did not offer registration"); - delete elem; - return false; - } - } - - delete elem; - - fmt = - "<iq type='set' id='regnew%d'>" - "<query xmlns='jabber:iq:register'>" - "<username>%s</username>" - "<password>%s</password>" - "<email/><name/>" - "</query>" - "</iq>\n\n"; - if (!write(fmt, msgId++, toXml(username).c_str(), - toXml(password).c_str() )) - return false; - - - recbuf = readStanza(); - status("RECV reg: %s", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - - ElementList list = elem->findElements("error"); - if (list.size()>0) - { - Element *errElem = list[0]; - DOMString code = errElem->getAttribute("code"); - DOMString errMsg = "Registration error: "; - if (code == "409") - { - errMsg.append("conflict with existing user name"); - } - else if (code == "406") - { - errMsg.append("some registration information was not provided"); - } - error("%s", errMsg.c_str()); - delete elem; - return false; - } - - delete elem; - - XmppEvent evt(XmppEvent::EVENT_REGISTRATION_NEW); - evt.setTo(username); - evt.setFrom(host); - dispatchXmppEvent(evt); - - return true; -} - - -/** - * Perform JEP-077 In-Band Registration. Performed asynchronously, after login. - * See processIq() for response handling. - */ -bool XmppClient::inBandRegistrationChangePassword(const DOMString &newpassword) -{ - Parser parser; - - //# Let's try it form-style to allow the common old/new password thing - const char *fmt = - "<iq type='set' id='regpass%d' to='%s'>" - " <query xmlns='jabber:iq:register'>" - " <x xmlns='jabber:x:data' type='form'>" - " <field type='hidden' var='FORM_TYPE'>" - " <value>jabber:iq:register:changepassword</value>" - " </field>" - " <field type='text-single' var='username'>" - " <value>%s</value>" - " </field>" - " <field type='text-private' var='old_password'>" - " <value>%s</value>" - " </field>" - " <field type='text-private' var='password'>" - " <value>%s</value>" - " </field>" - " </x>" - " </query>" - "</iq>\n\n"; - - if (!write(fmt, msgId++, host.c_str(), - username.c_str(), password.c_str(), newpassword.c_str())) - return false; - - return true; - -} - - -/** - * Perform JEP-077 In-Band Registration. Performed asynchronously, after login. - * See processIq() for response handling. - */ -bool XmppClient::inBandRegistrationCancel() -{ - Parser parser; - - const char *fmt = - "<iq type='set' id='regcancel%d'>" - "<query xmlns='jabber:iq:register'><remove/></query>" - "</iq>\n\n"; - if (!write(fmt, msgId++)) - return false; - - return true; -} - - - - - -//######################################################################## -//# A U T H E N T I C A T E -//######################################################################## - - - -bool XmppClient::iqAuthenticate(const DOMString &streamId) -{ - Parser parser; - - const char *fmt = - "<iq type='get' to='%s' id='auth%d'>" - "<query xmlns='jabber:iq:auth'><username>%s</username></query>" - "</iq>\n"; - if (!write(fmt, realm.c_str(), msgId++, username.c_str())) - return false; - - DOMString recbuf = readStanza(); - status("iq auth recv: '%s'\n", recbuf.c_str()); - Element *elem = parser.parse(recbuf); - //elem->print(); - DOMString iqType = elem->getTagAttribute("iq", "type"); - //printf("##iqType:%s\n", iqType.c_str()); - delete elem; - - if (iqType != "result") - { - error("error:server does not allow login"); - return false; - } - - bool digest = true; - if (digest) - { - //## Digest authentication - DOMString digest = streamId; - digest.append(password); - digest = Sha1::hashHex(digest); - //printf("digest:%s\n", digest.c_str()); - fmt = - "<iq type='set' id='auth%d'>" - "<query xmlns='jabber:iq:auth'>" - "<username>%s</username>" - "<digest>%s</digest>" - "<resource>%s</resource>" - "</query>" - "</iq>\n"; - if (!write(fmt, msgId++, username.c_str(), - digest.c_str(), resource.c_str())) - return false; - } - else - { - - //## Plaintext authentication - fmt = - "<iq type='set' id='auth%d'>" - "<query xmlns='jabber:iq:auth'>" - "<username>%s</username>" - "<password>%s</password>" - "<resource>%s</resource>" - "</query>" - "</iq>\n"; - if (!write(fmt, msgId++, username.c_str(), - password.c_str(), resource.c_str())) - return false; - } - - recbuf = readStanza(); - status("iq auth recv: '%s'\n", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - iqType = elem->getTagAttribute("iq", "type"); - //printf("##iqType:%s\n", iqType.c_str()); - delete elem; - - if (iqType != "result") - { - error("server does not allow login"); - return false; - } - - return true; -} - - -/** - * Parse a sasl challenge to retrieve all of its key=value pairs - */ -static bool saslParse(const DOMString &s, - std::map<DOMString, DOMString> &vals) -{ - - vals.clear(); - - int p = 0; - int siz = s.size(); - - while (p < siz) - { - DOMString key; - DOMString value; - char ch = '\0'; - - //# Parse key - while (p<siz) - { - ch = s[p++]; - if (ch == '=') - break; - key.push_back(ch); - } - - //No value? - if (ch != '=') - break; - - //# Parse value - bool quoted = false; - while (p<siz) - { - ch = s[p++]; - if (ch == '"') - quoted = !quoted; - else if (ch == ',' && !quoted) - break; - else - value.push_back(ch); - } - - //printf("# Key: '%s' Value: '%s'\n", key.c_str(), value.c_str()); - vals[key] = value; - if (ch != ',') - break; - } - - return true; -} - - - -/** - * Attempt suthentication using the MD5 SASL mechanism - */ -bool XmppClient::saslMd5Authenticate() -{ - Parser parser; - const char *fmt = - "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' " - "mechanism='DIGEST-MD5'/>\n"; - if (!write("%s",fmt)) - return false; - - DOMString recbuf = readStanza(); - status("challenge received: '%s'", recbuf.c_str()); - Element *elem = parser.parse(recbuf); - //elem->print(); - DOMString b64challenge = elem->getTagValue("challenge"); - delete elem; - - if (b64challenge.size() < 1) - { - error("login: no SASL challenge offered by server"); - return false; - } - DOMString challenge = Base64Decoder::decodeToString(b64challenge); - status("md5 challenge:'%s'", challenge.c_str()); - - std::map<DOMString, DOMString> attrs; - if (!saslParse(challenge, attrs)) - { - error("login: error parsing SASL challenge"); - return false; - } - - DOMString nonce = attrs["nonce"]; - if (nonce.size()==0) - { - error("login: no SASL nonce sent by server"); - return false; - } - - DOMString realm = attrs["realm"]; - if (realm.size()==0) - { - //Apparently this is not a problem - //error("login: no SASL realm sent by server"); - //return false; - } - - status("SASL recv nonce: '%s' realm:'%s'\n", nonce.c_str(), realm.c_str()); - - char idBuf[14]; - snprintf(idBuf, 13, "%dsasl", msgId++); - DOMString cnonceStr = idBuf; - DOMString cnonce = Sha1::hashHex(cnonceStr); - DOMString authzid = username; authzid.append("@"); authzid.append(host); - DOMString digest_uri = "xmpp/"; digest_uri.append(host); - - //## Make A1 - Md5 md5; - md5.append(username); - md5.append(":"); - md5.append(realm); - md5.append(":"); - md5.append(password); - unsigned char a1tmp[16]; - md5.finish(a1tmp); - md5.init(); - md5.append(a1tmp, 16); - md5.append(":"); - md5.append(nonce); - md5.append(":"); - md5.append(cnonce); - //RFC2831 says authzid is optional. Wildfire has trouble with authzid's - //md5.append(":"); - //md5.append(authzid); - md5.append(""); - DOMString a1 = md5.finishHex(); - status("##a1:'%s'", a1.c_str()); - - //# Make A2 - md5.init(); - md5.append("AUTHENTICATE:"); - md5.append(digest_uri); - DOMString a2 = md5.finishHex(); - status("##a2:'%s'", a2.c_str()); - - //# Now make the response - md5.init(); - md5.append(a1); - md5.append(":"); - md5.append(nonce); - md5.append(":"); - md5.append("00000001");//nc - md5.append(":"); - md5.append(cnonce); - md5.append(":"); - md5.append("auth");//qop - md5.append(":"); - md5.append(a2); - DOMString response = md5.finishHex(); - - DOMString resp; - resp.append("username=\""); resp.append(username); resp.append("\","); - resp.append("realm=\""); resp.append(realm); resp.append("\","); - resp.append("nonce=\""); resp.append(nonce); resp.append("\","); - resp.append("cnonce=\""); resp.append(cnonce); resp.append("\","); - resp.append("nc=00000001,qop=auth,"); - resp.append("digest-uri=\""); resp.append(digest_uri); resp.append("\"," ); - //resp.append("authzid=\""); resp.append(authzid); resp.append("\","); - resp.append("response="); resp.append(response); resp.append(","); - resp.append("charset=utf-8"); - status("sending response:'%s'", resp.c_str()); - resp = Base64Encoder::encode(resp); - status("base64 response:'%s'", resp.c_str()); - fmt = - "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>\n"; - if (!write(fmt, resp.c_str())) - return false; - - recbuf = readStanza(); - status("server says: '%s'", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - //# Success or failure already? - if (elem->findElements("success").size() > 0) - { - delete elem; - return true; - } - else - { - ElementList list = elem->findElements("failure"); - if (list.size() > 0) - { - DOMString errmsg = ""; - Element *errmsgElem = list[0]->getFirstChild(); - if (errmsgElem) - errmsg = errmsgElem->getName(); - error("login: initial md5 authentication failed: %s", errmsg.c_str()); - delete elem; - return false; - } - } - //# Continue for one more SASL cycle - b64challenge = elem->getTagValue("challenge"); - delete elem; - - if (b64challenge.size() < 1) - { - error("login: no second SASL challenge offered by server"); - return false; - } - - challenge = Base64Decoder::decodeToString(b64challenge); - status("md5 challenge: '%s'", challenge.c_str()); - - if (!saslParse(challenge, attrs)) - { - error("login: error parsing SASL challenge"); - return false; - } - - DOMString rspauth = attrs["rspauth"]; - if (rspauth.size()==0) - { - error("login: no SASL respauth sent by server\n"); - return false; - } - - fmt = - "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>\n"; - if (!write("%s",fmt)) - return false; - - recbuf = readStanza(); - status("SASL recv: '%s", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - b64challenge = elem->getTagValue("challenge"); - bool success = (elem->findElements("success").size() > 0); - delete elem; - - return success; -} - - - -/** - * Attempt to authentication using the SASL PLAIN mechanism. This - * is used most commonly my Google Talk. - */ -bool XmppClient::saslPlainAuthenticate() -{ - Parser parser; - - DOMString id = username; - //id.append("@"); - //id.append(host); - Base64Encoder encoder; - encoder.append('\0'); - encoder.append(id); - encoder.append('\0'); - encoder.append(password); - DOMString base64Auth = encoder.finish(); - //printf("authbuf:%s\n", base64Auth.c_str()); - - const char *fmt = - "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' " - "mechanism='PLAIN'>%s</auth>\n"; - if (!write(fmt, base64Auth.c_str())) - return false; - DOMString recbuf = readStanza(); - status("challenge received: '%s'", recbuf.c_str()); - Element *elem = parser.parse(recbuf); - - bool success = (elem->findElements("success").size() > 0); - delete elem; - - return success; -} - - - -/** - * Handshake with SASL, and use one of its offered mechanisms to - * authenticate. - * @param streamId used for iq auth fallback is SASL not supported - */ -bool XmppClient::saslAuthenticate(const DOMString &streamId) -{ - Parser parser; - - DOMString recbuf = readStanza(); - status("RECV: '%s'\n", recbuf.c_str()); - Element *elem = parser.parse(recbuf); - //elem->print(); - - //Check for starttls - bool wantStartTls = false; - if (elem->findElements("starttls").size() > 0) - { - wantStartTls = true; - if (elem->findElements("required").size() > 0) - status("login: STARTTLS required"); - else - status("login: STARTTLS available"); - } - - //# do we want TLS, are we not already running SSL, and can - //# the client actually do an ssl connection? - if (wantStartTls && !sock->getEnableSSL() && sock->getHaveSSL()) - { - delete elem; - const char *fmt = - "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n"; - if (!write("%s",fmt)) - return false; - recbuf = readStanza(); - status("RECV: '%s'\n", recbuf.c_str()); - elem = parser.parse(recbuf); - if (elem->getTagAttribute("proceed", "xmlns").size()<1) - { - error("Server rejected TLS negotiation"); - disconnect(); - return false; - } - delete elem; - if (!sock->startTls()) - { - DOMString tcperr = sock->getLastError(); - error("Could not start TLS: %s", tcperr.c_str()); - disconnect(); - return false; - } - - fmt = - "<stream:stream xmlns='jabber:client' " - "xmlns:stream='http://etherx.jabber.org/streams' " - "to='%s' version='1.0'>\n\n"; - if (!write(fmt, realm.c_str())) - return false; - - recbuf = readStanza(); - status("RECVx: '%s'", recbuf.c_str()); - recbuf.append("</stream:stream>"); - elem = parser.parse(recbuf); - bool success = - (elem->getTagAttribute("stream:stream", "id").size()>0); - if (!success) - { - error("STARTTLS negotiation failed"); - disconnect(); - return false; - } - delete elem; - recbuf = readStanza(); - status("RECV: '%s'\n", recbuf.c_str()); - elem = parser.parse(recbuf); - - XmppEvent event(XmppEvent::EVENT_SSL_STARTED); - dispatchXmppEvent(event); - } - - //register, if user requests - if (doRegister) - { - if (!inBandRegistrationNew()) - return false; - } - - //check for sasl authentication mechanisms - ElementList elems = elem->findElements("mechanism"); - if (elems.size() < 1) - { - status("login: no SASL mechanism offered by server"); - //fall back to iq - if (iqAuthenticate(streamId)) - return true; - return false; - } - bool md5Found = false; - bool plainFound = false; - for (unsigned int i=0 ; i<elems.size() ; i++) - { - DOMString mech = elems[i]->getValue(); - if (mech == "DIGEST-MD5") - { - status("MD5 authentication offered"); - md5Found = true; - } - else if (mech == "PLAIN") - { - status("PLAIN authentication offered"); - plainFound = true; - } - } - delete elem; - - bool success = false; - if (md5Found) - { - success = saslMd5Authenticate(); - } - else if (plainFound) - { - success = saslPlainAuthenticate(); - } - else - { - error("not able to handle sasl authentication mechanisms"); - return false; - } - - if (success) - status("###### SASL authentication success\n"); - else - error("###### SASL authentication failure\n"); - - return success; -} - - - - - - -//######################################################################## -//# CONNECT -//######################################################################## - - -/** - * Check if we are connected, and fail with an error if we are not - */ -bool XmppClient::checkConnect() -{ - if (!connected) - { - XmppEvent evt(XmppEvent::EVENT_ERROR); - evt.setData("Attempted operation while disconnected"); - dispatchXmppEvent(evt); - return false; - } - return true; -} - - - -/** - * Create an XMPP session with a server. This - * is basically the transport layer of XMPP. - */ -bool XmppClient::createSession() -{ - - Parser parser; - if (port==443 || port==5223) - sock->enableSSL(true); - if (!sock->connect(host, port)) - { - error("Cannot connect:%s", sock->getLastError().c_str()); - return false; - } - - if (sock->getEnableSSL()) - { - XmppEvent event(XmppEvent::EVENT_SSL_STARTED); - dispatchXmppEvent(event); - } - - const char *fmt = - "<stream:stream " - "to='%s' " - "xmlns='jabber:client' " - "xmlns:stream='http://etherx.jabber.org/streams' " - "version='1.0'>\n\n"; - if (!write(fmt, realm.c_str())) - return false; - - DOMString recbuf = readStanza(); - status("RECV: '%s'\n", recbuf.c_str()); - recbuf.append("</stream:stream>"); - Element *elem = parser.parse(recbuf); - //elem->print(); - bool useSasl = false; - DOMString streamId = elem->getTagAttribute("stream:stream", "id"); - //printf("### StreamID: %s\n", streamId.c_str()); - DOMString streamVersion = elem->getTagAttribute("stream:stream", "version"); - if (streamVersion == "1.0") - useSasl = true; - - if (useSasl) - { - if (!saslAuthenticate(streamId)) - return false; - - fmt = - "<stream:stream " - "to='%s' " - "xmlns='jabber:client' " - "xmlns:stream='http://etherx.jabber.org/streams' " - "version='1.0'>\n\n"; - - if (!write(fmt, realm.c_str())) - return false; - recbuf = readStanza(); - recbuf.append("</stream:stream>\n"); - //printf("now server says:: '%s'\n", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - delete elem; - - recbuf = readStanza(); - //printf("now server says:: '%s'\n", recbuf.c_str()); - elem = parser.parse(recbuf); - bool hasBind = (elem->findElements("bind").size() > 0); - //elem->print(); - delete elem; - - if (!hasBind) - { - error("no binding provided by server"); - return false; - } - - - } - else // not SASL - { - if (!iqAuthenticate(streamId)) - return false; - } - - - //### Resource binding - fmt = - "<iq type='set' id='bind%d'>" - "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>" - "<resource>%s</resource>" - "</bind></iq>\n"; - if (!write(fmt, msgId++, resource.c_str())) - return false; - - recbuf = readStanza(); - status("bind result: '%s'", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - DOMString bindType = elem->getTagAttribute("iq", "type"); - //printf("##bindType:%s\n", bindType.c_str()); - DOMString givenFullJid = elem->getTagValue("jid"); - delete elem; - - if (bindType != "result") - { - error("no binding with server failed"); - return false; - } - - //The server sent us a JID. We need to listen. - if (givenFullJid.size()>0) - { - DOMString givenJid, givenResource; - parseJid(givenFullJid, givenJid, givenResource); - status("given user: %s realm: %s, rsrc: %s", - givenJid.c_str(), realm.c_str(), givenResource.c_str()); - setResource(givenResource); - } - - - fmt = - "<iq type='set' id='sess%d'>" - "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>" - "</iq>\n"; - if (!write(fmt, msgId++)) - return false; - - recbuf = readStanza(); - status("session received: '%s'", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - DOMString sessionType = elem->getTagAttribute("iq", "type"); - //printf("##sessionType:%s\n", sessionType.c_str()); - delete elem; - - if (sessionType != "result") - { - error("no session provided by server"); - return false; - } - - //printf("########## COOL #########\n"); - //Now that we are bound, we have a valid JID - jid = username; - jid.append("@"); - jid.append(realm); - jid.append("/"); - jid.append(resource); - - //We are now done with the synchronous handshaking. Let's go into - //async mode - - fmt = - "<iq type='get' id='roster%d'><query xmlns='jabber:iq:roster'/></iq>\n"; - if (!write(fmt, msgId++)) - return false; - - fmt = - "<iq type='get' id='discoItems%d' to='%s'>" - "<query xmlns='http://jabber.org/protocol/disco#items'/></iq>\n"; - if (!write(fmt, msgId++, realm.c_str())) - return false; - - fmt = - "<iq type='get' id='discoInfo%d' to='conference.%s'>" - "<query xmlns='http://jabber.org/protocol/disco#info'/></iq>\n"; - if (!write(fmt, msgId++, realm.c_str())) - return false; - - fmt = - "<presence/>\n"; - if (!write("%s",fmt)) - return false; - - /* - recbuf = readStanza(); - status("stream received: '%s'", recbuf.c_str()); - elem = parser.parse(recbuf); - //elem->print(); - delete elem; - */ - - //We are now logged in - status("Connected"); - connected = true; - XmppEvent evt(XmppEvent::EVENT_CONNECTED); - evt.setData(host); - dispatchXmppEvent(evt); - //Thread::sleep(1000000); - - sock->setReceiveTimeout(1000); - ReceiverThread runner(*this); - Thread thread(runner); - thread.start(); - - return true; -} - - - -/** - * Public call to connect - */ -bool XmppClient::connect() -{ - if (!createSession()) - { - disconnect(); - return false; - } - return true; -} - - -/** - * Public call to connect - */ -bool XmppClient::connect(DOMString hostArg, int portArg, - DOMString usernameArg, - DOMString passwordArg, - DOMString resourceArg) -{ - host = hostArg; - port = portArg; - password = passwordArg; - resource = resourceArg; - - //parse this one - setUsername(usernameArg); - - bool ret = connect(); - return ret; -} - - - -/** - * Public call to disconnect - */ -bool XmppClient::disconnect() -{ - if (connected) - { - const char *fmt = - "<presence type='unavailable'/>\n"; - write("%s",fmt); - } - keepGoing = false; - connected = false; - Thread::sleep(2000); //allow receiving thread to quit - sock->disconnect(); - roster.clear(); - groupChatsClear(); - XmppEvent event(XmppEvent::EVENT_DISCONNECTED); - event.setData(host); - dispatchXmppEvent(event); - return true; -} - - - - - -//######################################################################## -//# ROSTER -//######################################################################## - -/** - * Add an XMPP id to your roster - */ -bool XmppClient::rosterAdd(const DOMString &rosterGroup, - const DOMString &otherJid, - const DOMString &name) -{ - if (!checkConnect()) - return false; - const char *fmt = - "<iq type='set' id='roster_%d'>" - "<query xmlns='jabber:iq:roster'>" - "<item jid='%s' name='%s'><group>%s</group></item>" - "</query></iq>\n"; - if (!write(fmt, msgId++, otherJid.c_str(), - name.c_str(), rosterGroup.c_str())) - { - return false; - } - return true; -} - - - -/** - * Delete an XMPP id from your roster. - */ -bool XmppClient::rosterDelete(const DOMString &otherJid) -{ - if (!checkConnect()) - return false; - const char *fmt = - "<iq type='set' id='roster_%d'>" - "<query xmlns='jabber:iq:roster'>" - "<item jid='%s' subscription='remove'><group>%s</group></item>" - "</query></iq>\n"; - if (!write(fmt, msgId++, otherJid.c_str())) - { - return false; - } - return true; -} - - -/** - * Comparison method for sort() call below - */ -static bool xmppRosterCompare(const XmppUser& p1, const XmppUser& p2) -{ - DOMString s1 = p1.group; - DOMString s2 = p2.group; - for (unsigned int len=0 ; len<s1.size() && len<s2.size() ; len++) - { - int comp = tolower(s1[len]) - tolower(s2[len]); - if (comp) - return (comp<0); - } - - s1 = p1.jid; - s2 = p2.jid; - for (unsigned int len=0 ; len<s1.size() && len<s2.size() ; len++) - { - int comp = tolower(s1[len]) - tolower(s2[len]); - if (comp) - return (comp<0); - } - return false; -} - - - -/** - * Sort and return the roster that has just been reported by - * an XmppEvent::EVENT_ROSTER event. - */ -std::vector<XmppUser> XmppClient::getRoster() -{ - std::vector<XmppUser> ros = roster; - std::sort(ros.begin(), ros.end(), xmppRosterCompare); - return ros; -} - - -/** - * - */ -void XmppClient::rosterShow(const DOMString &jid, const DOMString &show) -{ - DOMString theShow = show; - if (theShow == "") - theShow = "available"; - - std::vector<XmppUser>::iterator iter; - for (iter=roster.begin() ; iter != roster.end() ; iter++) - { - if (iter->jid == jid) - iter->show = theShow; - } -} - - - - - - -//######################################################################## -//# CHAT (individual) -//######################################################################## - -/** - * Send a message to an xmpp jid - */ -bool XmppClient::message(const DOMString &user, const DOMString &subj, - const DOMString &msg) -{ - if (!checkConnect()) - return false; - - DOMString xmlSubj = toXml(subj); - DOMString xmlMsg = toXml(msg); - - if (xmlSubj.size() > 0) - { - const char *fmt = - "<message to='%s' from='%s' type='chat'>" - "<subject>%s</subject><body>%s</body></message>\n"; - if (!write(fmt, user.c_str(), jid.c_str(), - xmlSubj.c_str(), xmlMsg.c_str())) - return false; - } - else - { - const char *fmt = - "<message to='%s' from='%s'>" - "<body>%s</body></message>\n"; - if (!write(fmt, user.c_str(), jid.c_str(), xmlMsg.c_str())) - return false; - } - return true; -} - - - -/** - * - */ -bool XmppClient::message(const DOMString &user, const DOMString &msg) -{ - return message(user, "", msg); -} - - - -/** - * - */ -bool XmppClient::presence(const DOMString &presence) -{ - if (!checkConnect()) - return false; - - DOMString xmlPres = toXml(presence); - - const char *fmt = - "<presence><show>%s</show></presence>\n"; - if (!write(fmt, xmlPres.c_str())) - return false; - return true; -} - - - - - - -//######################################################################## -//# GROUP CHAT -//######################################################################## - -/** - * - */ -bool XmppClient::groupChatCreate(const DOMString &groupJid) -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - { - if ((*iter)->getGroupJid() == groupJid) - { - //error("Group chat '%s' already exists", groupJid.c_str()); - return false; - } - } - XmppGroupChat *chat = new XmppGroupChat(groupJid); - groupChats.push_back(chat); - return true; -} - - - -/** - * - */ -void XmppClient::groupChatDelete(const DOMString &groupJid) -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; ) - { - XmppGroupChat *chat = *iter; - if (chat->getGroupJid() == groupJid) - { - iter = groupChats.erase(iter); - delete chat; - } - else - iter++; - } -} - - - -/** - * - */ -bool XmppClient::groupChatExists(const DOMString &groupJid) -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - if ((*iter)->getGroupJid() == groupJid) - return true; - return false; -} - - - -/** - * - */ -void XmppClient::groupChatsClear() -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - delete (*iter); - groupChats.clear(); -} - - - - -/** - * - */ -void XmppClient::groupChatUserAdd(const DOMString &groupJid, - const DOMString &nick, - const DOMString &jid) -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - { - if ((*iter)->getGroupJid() == groupJid) - { - (*iter)->userAdd(nick, jid); - } - } -} - - - -/** - * - */ -void XmppClient::groupChatUserShow(const DOMString &groupJid, - const DOMString &nick, - const DOMString &show) -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - { - if ((*iter)->getGroupJid() == groupJid) - { - (*iter)->userShow(nick, show); - } - } -} - - - - -/** - * - */ -void XmppClient::groupChatUserDelete(const DOMString &groupJid, - const DOMString &nick) -{ - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - { - if ((*iter)->getGroupJid() == groupJid) - { - (*iter)->userDelete(nick); - } - } -} - - - -/** - * Comparison method for the sort() below - */ -static bool xmppUserCompare(const XmppUser& p1, const XmppUser& p2) -{ - DOMString s1 = p1.nick; - DOMString s2 = p2.nick; - int comp = 0; - for (unsigned int len=0 ; len<s1.size() && len<s2.size() ; len++) - { - comp = tolower(s1[len]) - tolower(s2[len]); - if (comp) - break; - } - return (comp<0); -} - - - -/** - * Return the user list for the named group - */ -std::vector<XmppUser> XmppClient::groupChatGetUserList( - const DOMString &groupJid) -{ - if (!checkConnect()) - { - std::vector<XmppUser> dummy; - return dummy; - } - - std::vector<XmppGroupChat *>::iterator iter; - for (iter=groupChats.begin() ; iter!=groupChats.end() ; iter++) - { - if ((*iter)->getGroupJid() == groupJid ) - { - std::vector<XmppUser> uList = (*iter)->getUserList(); - std::sort(uList.begin(), uList.end(), xmppUserCompare); - return uList; - } - } - std::vector<XmppUser> dummy; - return dummy; -} - - - - -/** - * Try to join a group - */ -bool XmppClient::groupChatJoin(const DOMString &groupJid, - const DOMString &nick, - const DOMString &/*pass*/) -{ - if (!checkConnect()) - return false; - - DOMString user = nick; - if (user.size()<1) - user = username; - - const char *fmt = - "<presence to='%s/%s'>" - "<x xmlns='http://jabber.org/protocol/muc'/></presence>\n"; - if (!write(fmt, groupJid.c_str(), user.c_str())) - return false; - return true; -} - - - - -/** - * Leave a group - */ -bool XmppClient::groupChatLeave(const DOMString &groupJid, - const DOMString &nick) -{ - if (!checkConnect()) - return false; - - DOMString user = nick; - if (user.size()<1) - user = username; - - const char *fmt = - "<presence to='%s/%s' type='unavailable'>" - "<x xmlns='http://jabber.org/protocol/muc'/></presence>\n"; - if (!write(fmt, groupJid.c_str(), user.c_str())) - return false; - return true; -} - - - - -/** - * Send a message to a group - */ -bool XmppClient::groupChatMessage(const DOMString &groupJid, - const DOMString &msg) -{ - if (!checkConnect()) - { - return false; - } - - DOMString xmlMsg = toXml(msg); - - const char *fmt = - "<message from='%s' to='%s' type='groupchat'>" - "<body>%s</body></message>\n"; - if (!write(fmt, jid.c_str(), groupJid.c_str(), xmlMsg.c_str())) - return false; - /* - const char *fmt = - "<message to='%s' type='groupchat'>" - "<body>%s</body></message>\n"; - if (!write(fmt, groupJid.c_str(), xmlMsg.c_str())) - return false; - */ - return true; -} - - - - -/** - * Send a message to an individual in a group - */ -bool XmppClient::groupChatPrivateMessage(const DOMString &groupJid, - const DOMString &toNick, - const DOMString &msg) -{ - if (!checkConnect()) - return false; - - DOMString xmlMsg = toXml(msg); - - /* - const char *fmt = - "<message from='%s' to='%s/%s' type='chat'>" - "<body>%s</body></message>\n"; - if (!write(fmt, jid.c_str(), groupJid.c_str(), - toNick.c_str(), xmlMsg.c_str())) - return false; - */ - const char *fmt = - "<message to='%s/%s' type='chat'>" - "<body>%s</body></message>\n"; - if (!write(fmt, groupJid.c_str(), - toNick.c_str(), xmlMsg.c_str())) - return false; - return true; -} - - - - -/** - * Change your presence within a group - */ -bool XmppClient::groupChatPresence(const DOMString &groupJid, - const DOMString &myNick, - const DOMString &presence) -{ - if (!checkConnect()) - return false; - - DOMString user = myNick; - if (user.size()<1) - user = username; - - DOMString xmlPresence = toXml(presence); - - const char *fmt = - "<presence to='%s/%s' type='%s'>" - "<x xmlns='http://jabber.org/protocol/muc'/></presence>\n"; - if (!write(fmt, groupJid.c_str(), - user.c_str(), xmlPresence.c_str())) - return true; - return true; -} - - - - - -//######################################################################## -//# S T R E A M S -//######################################################################## - - -bool XmppClient::processInBandByteStreamMessage(Element *root) -{ - DOMString from = root->getAttribute("from"); - DOMString id = root->getAttribute("id"); - DOMString type = root->getAttribute("type"); - - //### Incoming stream requests - //Input streams are id's by stream id - DOMString ibbNamespace = "http://jabber.org/protocol/ibb"; - - if (root->getTagAttribute("open", "xmlns") == ibbNamespace) - { - DOMString streamId = root->getTagAttribute("open", "sid"); - XmppEvent event(XmppEvent::XmppEvent::EVENT_STREAM_RECEIVE_INIT); - dispatchXmppEvent(event); - std::map<DOMString, XmppStream *>::iterator iter = - inputStreams.find(streamId); - if (iter != inputStreams.end()) - { - XmppStream *ins = iter->second; - ins->setState(STREAM_OPENING); - ins->setMessageId(id); - return true; - } - return true; - } - - else if (root->getTagAttribute("close", "xmlns") == ibbNamespace) - { - XmppEvent event(XmppEvent::XmppEvent::EVENT_STREAM_RECEIVE_CLOSE); - dispatchXmppEvent(event); - DOMString streamId = root->getTagAttribute("close", "sid"); - std::map<DOMString, XmppStream *>::iterator iter = - inputStreams.find(streamId); - if (iter != inputStreams.end()) - { - XmppStream *ins = iter->second; - if (from == ins->getPeerId()) - { - ins->setState(STREAM_CLOSING); - ins->setMessageId(id); - return true; - } - } - return true; - } - - else if (root->getTagAttribute("data", "xmlns") == ibbNamespace) - { - DOMString streamId = root->getTagAttribute("data", "sid"); - std::map<DOMString, XmppStream *>::iterator iter = - inputStreams.find(streamId); - if (iter != inputStreams.end()) - { - XmppStream *ins = iter->second; - if (ins->getState() != STREAM_OPEN) - { - XmppEvent event(XmppEvent::EVENT_ERROR); - event.setFrom(from); - event.setData("received unrequested stream data"); - dispatchXmppEvent(event); - return true; - } - DOMString data = root->getTagValue("data"); - std::vector<unsigned char>binData = - Base64Decoder::decode(data); - ins->receiveData(binData); - } - } - - //### Responses to outgoing requests - //Output streams are id's by message id - std::map<DOMString, XmppStream *>::iterator iter = - outputStreams.find(id); - if (iter != outputStreams.end()) - { - XmppStream *outs = iter->second; - if (type == "error") - { - outs->setState(STREAM_ERROR); - return true; - } - else if (type == "result") - { - if (outs->getState() == STREAM_OPENING) - { - outs->setState(STREAM_OPEN); - } - else if (outs->getState() == STREAM_CLOSING) - { - outs->setState(STREAM_CLOSED); - } - return true; - } - } - - return false; -} - - -/** - * - */ -bool XmppClient::outputStreamOpen(const DOMString &destId, - const DOMString &streamIdArg) -{ - char buf[32]; - snprintf(buf, 31, "inband%d", getMsgId()); - DOMString messageId = buf; - - //Output streams are id's by message id - XmppStream *outs = new XmppStream(); - outputStreams[messageId] = outs; - - outs->setState(STREAM_OPENING); - - DOMString streamId = streamIdArg; - if (streamId.size()<1) - { - snprintf(buf, 31, "stream%d", getMsgId()); - DOMString streamId = buf; - } - outs->setMessageId(messageId); - outs->setStreamId(streamId); - outs->setPeerId(destId); - - - const char *fmt = - "<%s type='set' to='%s' id='%s'>" - "<open sid='%s' block-size='4096'" - " xmlns='http://jabber.org/protocol/ibb'/></%s>\n"; - if (!write(fmt, - streamPacket.c_str(), - destId.c_str(), messageId.c_str(), - streamId.c_str(), - streamPacket.c_str())) - { - outs->reset(); - return -1; - } - - int state = outs->getState(); - for (int tim=0 ; tim<20 ; tim++) - { - if (state == STREAM_OPEN) - break; - else if (state == STREAM_ERROR) - { - printf("ERROR\n"); - outs->reset(); - return false; - } - Thread::sleep(1000); - state = outs->getState(); - } - if (state != STREAM_OPEN) - { - printf("TIMEOUT ERROR\n"); - outs->reset(); - return -1; - } - - return true; -} - -/** - * - */ -bool XmppClient::outputStreamWrite(const DOMString &streamId, - const std::vector<unsigned char> &buf) -{ - std::map<DOMString, XmppStream *>::iterator iter = - outputStreams.find(streamId); - if (iter == outputStreams.end()) - return false; - XmppStream *outs = iter->second; - - unsigned int len = buf.size(); - unsigned int pos = 0; - - while (pos < len) - { - unsigned int pos2 = pos + 1024; - if (pos2>len) - pos2 = len; - - Base64Encoder encoder; - for (unsigned int i=pos ; i<pos2 ; i++) - encoder.append(buf[i]); - DOMString b64data = encoder.finish(); - - - const char *fmt = - "<message to='%s' id='msg%d'>" - "<data xmlns='http://jabber.org/protocol/ibb' sid='%s' seq='%d'>" - "%s" - "</data>" - "<amp xmlns='http://jabber.org/protocol/amp'>" - "<rule condition='deliver-at' value='stored' action='error'/>" - "<rule condition='match-resource' value='exact' action='error'/>" - "</amp>" - "</message>\n"; - if (!write(fmt, - outs->getPeerId().c_str(), - getMsgId(), - outs->getStreamId().c_str(), - outs->getSeqNr(), - b64data.c_str())) - { - outs->reset(); - return false; - } - pause(5000); - - pos = pos2; - } - - return true; -} - -/** - * - */ -bool XmppClient::outputStreamClose(const DOMString &streamId) -{ - std::map<DOMString, XmppStream *>::iterator iter = - outputStreams.find(streamId); - if (iter == outputStreams.end()) - return false; - XmppStream *outs = iter->second; - - char buf[32]; - snprintf(buf, 31, "inband%d", getMsgId()); - DOMString messageId = buf; - outs->setMessageId(messageId); - - outs->setState(STREAM_CLOSING); - const char *fmt = - "<%s type='set' to='%s' id='%s'>" - "<close sid='%s' xmlns='http://jabber.org/protocol/ibb'/></%s>\n"; - if (!write(fmt, - streamPacket.c_str(), - outs->getPeerId().c_str(), - messageId.c_str(), - outs->getStreamId().c_str(), - streamPacket.c_str() - )) - return false; - - int state = outs->getState(); - for (int tim=0 ; tim<20 ; tim++) - { - if (state == STREAM_CLOSED) - break; - else if (state == STREAM_ERROR) - { - printf("ERROR\n"); - outs->reset(); - return false; - } - Thread::sleep(1000); - state = outs->getState(); - } - if (state != STREAM_CLOSED) - { - printf("TIMEOUT ERROR\n"); - outs->reset(); - return false; - } - - delete outs; - outputStreams.erase(streamId); - - return true; -} - - -/** - * - */ -bool XmppClient::inputStreamOpen(const DOMString &fromJid, - const DOMString &streamId, - const DOMString &/*iqId*/) -{ - XmppStream *ins = new XmppStream(); - - inputStreams[streamId] = ins; - ins->reset(); - ins->setPeerId(fromJid); - ins->setState(STREAM_CLOSED); - ins->setStreamId(streamId); - - int state = ins->getState(); - for (int tim=0 ; tim<20 ; tim++) - { - if (state == STREAM_OPENING) - break; - else if (state == STREAM_ERROR) - { - printf("ERROR\n"); - ins->reset(); - return false; - } - Thread::sleep(1000); - state = ins->getState(); - } - if (state != STREAM_OPENING) - { - printf("TIMEOUT ERROR\n"); - ins->reset(); - return false; - } - const char *fmt = - "<%s type='result' to='%s' id='%s'/>\n"; - if (!write(fmt, streamPacket.c_str(), - fromJid.c_str(), ins->getMessageId().c_str())) - { - return false; - } - - ins->setState(STREAM_OPEN); - return true; -} - - - -/** - * - */ -bool XmppClient::inputStreamClose(const DOMString &streamId) -{ - std::map<DOMString, XmppStream *>::iterator iter = - inputStreams.find(streamId); - if (iter == inputStreams.end()) - return false; - XmppStream *ins = iter->second; - - if (ins->getState() == STREAM_CLOSING) - { - const char *fmt = - "<iq type='result' to='%s' id='%s'/>\n"; - if (!write(fmt, ins->getPeerId().c_str(), - ins->getMessageId().c_str())) - { - return false; - } - } - inputStreams.erase(streamId); - delete ins; - - return true; -} - - - - - - -//######################################################################## -//# FILE TRANSFERS -//######################################################################## - - -bool XmppClient::processFileMessage(Element *root) -{ - DOMString siNamespace = "http://jabber.org/protocol/si"; - if (root->getTagAttribute("si", "xmlns") != siNamespace) - return false; - - - Element *mainElement = root->getFirstChild(); - if (!mainElement) - return false; - - DOMString from = mainElement->getAttribute("from"); - DOMString id = mainElement->getAttribute("id"); - DOMString type = mainElement->getAttribute("type"); - - status("received file message from %s", from.c_str()); - - if (type == "set") - { - DOMString streamId = root->getTagAttribute("si", "id"); - DOMString fname = root->getTagAttribute("file", "name"); - DOMString sizeStr = root->getTagAttribute("file", "size"); - DOMString hash = root->getTagAttribute("file", "hash"); - XmppEvent event(XmppEvent::XmppEvent::EVENT_FILE_RECEIVE); - event.setFrom(from); - event.setIqId(id); - event.setStreamId(streamId); - event.setFileName(fname); - event.setFileHash(hash); - event.setFileSize(atol(sizeStr.c_str())); - dispatchXmppEvent(event); - return true; - } - - //##expecting result or error - //file sends id'd by message id's - std::map<DOMString, XmppStream *>::iterator iter = - fileSends.find(id); - if (iter != fileSends.end()) - { - XmppStream *outf = iter->second; - if (from != outf->getPeerId()) - return true; - if (type == "error") - { - outf->setState(STREAM_ERROR); - error("user '%s' rejected file", from.c_str()); - return true; - } - else if (type == "result") - { - if (outf->getState() == STREAM_OPENING) - { - XmppEvent event(XmppEvent::XmppEvent::EVENT_FILE_ACCEPTED); - event.setFrom(from); - dispatchXmppEvent(event); - outf->setState(STREAM_OPEN); - } - else if (outf->getState() == STREAM_CLOSING) - { - outf->setState(STREAM_CLOSED); - } - return true; - } - } - - return true; -} - - - - - - -/** - * - */ -bool XmppClient::fileSend(const DOMString &destJidArg, - const DOMString &offeredNameArg, - const DOMString &fileNameArg, - const DOMString &descriptionArg) -{ - DOMString destJid = destJidArg; - DOMString offeredName = offeredNameArg; - DOMString fileName = fileNameArg; - DOMString description = descriptionArg; - - struct stat finfo; - if (stat(fileName.c_str(), &finfo)<0) - { - error("Cannot stat file '%s' for sending", fileName.c_str()); - return false; - } - long fileLen = finfo.st_size; - if (!fileLen > 1000000) - { - error("'%s' too large", fileName.c_str()); - return false; - } - if (!S_ISREG(finfo.st_mode)) - { - error("'%s' is not a regular file", fileName.c_str()); - return false; - } - FILE *f = fopen(fileName.c_str(), "rb"); - if (!f) - { - error("cannot open '%s' for sending", fileName.c_str()); - return false; - } - std::vector<unsigned char> sendBuf; - Md5 md5hash; - for (long i=0 ; i<fileLen && !feof(f); i++) - { - int ch = fgetc(f); - if (ch<0) - break; - md5hash.append((unsigned char)ch); - sendBuf.push_back((unsigned char)ch); - } - fclose(f); - DOMString hash = md5hash.finishHex(); - printf("Hash:%s\n", hash.c_str()); - - - //## get the last path segment from the whole path - if (offeredName.size()<1) - { - int slashPos = -1; - for (unsigned int i=0 ; i<fileName.size() ; i++) - { - int ch = fileName[i]; - if (ch == '/' || ch == '\\') - slashPos = i; - } - if (slashPos>=0 && slashPos<=(int)(fileName.size()-1)) - { - offeredName = fileName.substr(slashPos+1, - fileName.size()-slashPos-1); - printf("offeredName:%s\n", offeredName.c_str()); - } - } - - char buf[32]; - snprintf(buf, 31, "file%d", getMsgId()); - DOMString messageId = buf; - - XmppStream *outf = new XmppStream(); - - outf->setState(STREAM_OPENING); - outf->setMessageId(messageId); - fileSends[messageId] = outf; - - snprintf(buf, 31, "stream%d", getMsgId()); - DOMString streamId = buf; - //outf->setStreamId(streamId); - - outf->setPeerId(destJid); - - char dtgBuf[81]; - struct tm *timeVal = gmtime(&(finfo.st_mtime)); - strftime(dtgBuf, 80, "%Y-%m-%dT%H:%M:%Sz", timeVal); - - const char *fmt = - "<%s type='set' id='%s' to='%s'>" - "<si xmlns='http://jabber.org/protocol/si' id='%s'" - " mime-type='text/plain'" - " profile='http://jabber.org/protocol/si/profile/file-transfer'>" - "<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'" - " name='%s' size='%d' hash='%s' date='%s'><desc>%s</desc></file>" - "<feature xmlns='http://jabber.org/protocol/feature-neg'>" - "<x xmlns='jabber:x:data' type='form'>" - "<field var='stream-method' type='list-single'>" - //"<option><value>http://jabber.org/protocol/bytestreams</value></option>" - "<option><value>http://jabber.org/protocol/ibb</value></option>" - "</field></x></feature></si></%s>\n"; - if (!write(fmt, streamPacket.c_str(), - messageId.c_str(), destJid.c_str(), - streamId.c_str(), offeredName.c_str(), fileLen, - hash.c_str(), dtgBuf, description.c_str(), - streamPacket.c_str())) - { - return false; - } - - int ret = true; - int state = outf->getState(); - for (int tim=0 ; tim<20 ; tim++) - { - printf("##### waiting for open\n"); - if (state == STREAM_OPEN) - { - outf->reset(); - break; - } - else if (state == STREAM_ERROR) - { - printf("ERROR\n"); - outf->reset(); - ret = false; - } - Thread::sleep(1000); - state = outf->getState(); - } - if (state != STREAM_OPEN) - { - printf("TIMEOUT ERROR\n"); - ret = false; - } - - //free up this resource - fileSends.erase(messageId); - delete outf; - - if (!outputStreamOpen(destJid, streamId)) - { - error("cannot open output stream %s", streamId.c_str()); - return false; - } - - if (!outputStreamWrite(streamId, sendBuf)) - { - } - - if (!outputStreamClose(streamId)) - { - } - - return true; -} - - -class FileSendThread : public Thread -{ -public: - - FileSendThread(XmppClient &par, - const DOMString &destJidArg, - const DOMString &offeredNameArg, - const DOMString &fileNameArg, - const DOMString &descriptionArg) : client(par) - { - destJid = destJidArg; - offeredName = offeredNameArg; - fileName = fileNameArg; - description = descriptionArg; - } - - virtual ~FileSendThread() {} - - void run() - { - client.fileSend(destJid, offeredName, - fileName, description); - } - -private: - - XmppClient &client; - DOMString destJid; - DOMString offeredName; - DOMString fileName; - DOMString description; -}; - -/** - * - */ -bool XmppClient::fileSendBackground(const DOMString &destJid, - const DOMString &offeredName, - const DOMString &fileName, - const DOMString &description) -{ - FileSendThread thread(*this, destJid, offeredName, - fileName, description); - thread.start(); - return true; -} - - -/** - * - */ -bool XmppClient::fileReceive(const DOMString &fromJid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &fileName, - long /*fileSize*/, - const DOMString &/*fileHash*/) -{ - const char *fmt = - "<%s type='result' to='%s' id='%s'>" - "<si xmlns='http://jabber.org/protocol/si'>" - "<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'/>" - "<feature xmlns='http://jabber.org/protocol/feature-neg'>" - "<x xmlns='jabber:x:data' type='submit'>" - "<field var='stream-method'>" - "<value>http://jabber.org/protocol/ibb</value>" - "</field></x></feature></si></%s>\n"; - if (!write(fmt, streamPacket.c_str(), - fromJid.c_str(), iqId.c_str(), - streamPacket.c_str())) - { - return false; - } - - if (!inputStreamOpen(fromJid, streamId, iqId)) - { - return false; - } - - XmppStream *ins = inputStreams[streamId]; - - Md5 md5; - FILE *f = fopen(fileName.c_str(), "wb"); - if (!f) - { - return false; - } - - while (true) - { - if (ins->available()<1) - { - if (ins->getState() == STREAM_CLOSING) - break; - pause(100); - continue; - } - std::vector<unsigned char> ret = ins->read(); - std::vector<unsigned char>::iterator iter; - for (iter=ret.begin() ; iter!=ret.end() ; iter++) - { - unsigned char ch = *iter; - md5.append(&ch, 1); - fwrite(&ch, 1, 1, f); - } - } - - inputStreamClose(streamId); - fclose(f); - - DOMString hash = md5.finishHex(); - printf("received file hash:%s\n", hash.c_str()); - - return true; -} - - - -class FileReceiveThread : public Thread -{ -public: - - FileReceiveThread(XmppClient &par, - const DOMString &fromJidArg, - const DOMString &iqIdArg, - const DOMString &streamIdArg, - const DOMString &fileNameArg, - long fileSizeArg, - const DOMString &fileHashArg) : client(par) - { - fromJid = fromJidArg; - iqId = iqIdArg; - streamId = streamIdArg; - fileName = fileNameArg; - fileSize = fileSizeArg; - fileHash = fileHashArg; - } - - virtual ~FileReceiveThread() {} - - void run() - { - client.fileReceive(fromJid, iqId, streamId, - fileName, fileSize, fileHash); - } - -private: - - XmppClient &client; - DOMString fromJid; - DOMString iqId; - DOMString streamId; - DOMString fileName; - long fileSize; - DOMString fileHash; -}; - -/** - * - */ -bool XmppClient::fileReceiveBackground(const DOMString &fromJid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &fileName, - long fileSize, - const DOMString &fileHash) -{ - FileReceiveThread thread(*this, fromJid, iqId, streamId, - fileName, fileSize, fileHash); - thread.start(); - return true; -} - - - -//######################################################################## -//# X M P P G R O U P C H A T -//######################################################################## - -/** - * - */ -XmppGroupChat::XmppGroupChat(const DOMString &groupJidArg) -{ - groupJid = groupJidArg; -} - -/** - * - */ -XmppGroupChat::XmppGroupChat(const XmppGroupChat &other) -{ - groupJid = other.groupJid; - userList = other.userList; -} - -/** - * - */ -XmppGroupChat::~XmppGroupChat() -{ -} - - -/** - * - */ -DOMString XmppGroupChat::getGroupJid() -{ - return groupJid; -} - - -void XmppGroupChat::userAdd(const DOMString &nick, - const DOMString &jid) -{ - std::vector<XmppUser>::iterator iter; - for (iter= userList.begin() ; iter!=userList.end() ; iter++) - { - if (iter->nick == nick) - return; - } - XmppUser user(jid, nick); - userList.push_back(user); -} - -void XmppGroupChat::userShow(const DOMString &nick, - const DOMString &show) -{ - DOMString theShow = show; - if (theShow == "") - theShow = "available"; // a join message will now have a show - std::vector<XmppUser>::iterator iter; - for (iter= userList.begin() ; iter!=userList.end() ; iter++) - { - if (iter->nick == nick) - iter->show = theShow; - } -} - -void XmppGroupChat::userDelete(const DOMString &nick) -{ - std::vector<XmppUser>::iterator iter; - for (iter= userList.begin() ; iter!=userList.end() ; ) - { - if (iter->nick == nick) - iter = userList.erase(iter); - else - iter++; - } -} - -std::vector<XmppUser> XmppGroupChat::getUserList() const -{ - return userList; -} - - - - - - - - - -} //namespace Pedro -//######################################################################## -//# E N D O F F I L E -//######################################################################## - - - - - - - - - - - - - - - diff --git a/src/pedro/pedroxmpp.h b/src/pedro/pedroxmpp.h deleted file mode 100644 index ee3234fd4..000000000 --- a/src/pedro/pedroxmpp.h +++ /dev/null @@ -1,1251 +0,0 @@ -#ifndef __XMPP_H__ -#define __XMPP_H__ -/* - * API for the Pedro mini-XMPP client. - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <glib.h> -#include <vector> -#include <map> - -#include <string> - -#include "pedrodom.h" - -namespace Pedro -{ - -typedef std::string DOMString; - - -//######################################################################## -//# X M P P E V E N T -//######################################################################## -class XmppUser -{ -public: - XmppUser() - { - } - XmppUser(const DOMString &jidArg, const DOMString &nickArg) - { - jid = jidArg; - nick = nickArg; - } - XmppUser(const DOMString &jidArg, const DOMString &nickArg, - const DOMString &subscriptionArg, const DOMString &groupArg) - { - jid = jidArg; - nick = nickArg; - subscription = subscriptionArg; - group = groupArg; - } - XmppUser(const XmppUser &other) - { - jid = other.jid; - nick = other.nick; - subscription = other.subscription; - group = other.group; - show = other.show; - } - XmppUser &operator=(const XmppUser &other) - { - jid = other.jid; - nick = other.nick; - subscription = other.subscription; - group = other.group; - show = other.show; - return *this; - } - virtual ~XmppUser() - {} - DOMString jid; - DOMString nick; - DOMString subscription; - DOMString group; - DOMString show; -}; - - - - - -/** - * Class that emits information from a client - */ -class XmppEvent -{ - -public: - - /** - * People might want to refer to these docs to understand - * the XMPP terminology used here. - * http://www.ietf.org/rfc/rfc3920.txt -- Xmpp Core - * http://www.ietf.org/rfc/rfc3921.txt -- Messaging and presence - * http://www.jabber.org/jeps/jep-0077.html -- In-Band registration - * http://www.jabber.org/jeps/jep-0045.html -- Multiuser Chat - * http://www.jabber.org/jeps/jep-0047.html -- In-Band byte streams - * http://www.jabber.org/jeps/jep-0096.html -- File transfer - */ - - /** - * No event type. Default - */ - static const int EVENT_NONE = 0; - - /** - * Client emits a status message. Message is in getData(). - */ - static const int EVENT_STATUS = 1; - - /** - * Client emits an error message. Message is in getData(). - */ - static const int EVENT_ERROR = 2; - - /** - * Client has connected to a host. Host name is in getData(). - */ - static const int EVENT_CONNECTED = 10; - - /** - * Client has disconnected from a host. Host name is in getData(). - */ - static const int EVENT_DISCONNECTED = 11; - - /** - * Client has begun speaking to the server in SSL. This is usually - * emitted just before EVENT_CONNECTED, since authorization has not - * yet taken place. - */ - static const int EVENT_SSL_STARTED = 12; - - /** - * Client has successfully registered a new account on a server. - * The server is in getFrom(), the user in getTo() - */ - static const int EVENT_REGISTRATION_NEW = 20; - - /** - * Client has successfully changed the password of an existing account on a server. - * The server is in getFrom(), the user in getTo() - */ - static const int EVENT_REGISTRATION_CHANGE_PASS = 21; - - /** - * Client has successfully cancelled an existing account on a server. - * The server is in getFrom(), the user in getTo() - */ - static const int EVENT_REGISTRATION_CANCEL = 22; - - /** - * A <presence> packet has been received. - * getFrom() returns the full jabber id - * getPresence() returns the available/unavailable boolean - * getShow() returns the jabber 'show' string: 'show', 'away', 'xa', etc - * getStatus() returns a status message, sent from a client - * Note: if a presence packet is determined to be MUC, it is - * rather sent as an EVENT_MUC_JOIN, LEAVE, or PRESENCE - */ - static const int EVENT_PRESENCE = 30; - - /** - * Client has just received a complete roster. The collected information - * can be found at client.getRoster(), and is a std::vector of XmppUser - * records. - */ - static const int EVENT_ROSTER = 31; - - /** - * Client has just received a message packet. - * getFrom() returns the full jabber id of the sender - * getData() returns the text of the message - * getDom() returns the DOM treelet for this stanza. This is provided - * to make message extension easier. - * Note: if a message packet is determined to be MUC, it is - * rather sent as an EVENT_MUC_MESSAGE - */ - static const int EVENT_MESSAGE = 32; - - /** - * THIS user has just joined a multi-user chat group. - * getGroup() returns the group name - * getFrom() returns the nick of the user in the group - * getPresence() returns the available/unavailable boolean - * getShow() returns the jabber 'show' string: 'show', 'away', 'xa', etc - * getStatus() returns a status message, sent from a client - */ - static const int EVENT_MUC_JOIN = 40; - - /** - * THIS user has just left a multi-user chat group. - * getGroup() returns the group name - * getFrom() returns the nick of the user in the group - * getPresence() returns the available/unavailable boolean - * getShow() returns the jabber 'show' string: 'show', 'away', 'xa', etc - * getStatus() returns a status message, sent from a client - */ - static const int EVENT_MUC_LEAVE = 41; - - /** - * Presence for another user in a multi-user chat room. - * getGroup() returns the group name - * getFrom() returns the nick of the user in the group - * getPresence() returns the available/unavailable boolean - * getShow() returns the jabber 'show' string: 'show', 'away', 'xa', etc - * getStatus() returns a status message, sent from a client - */ - static const int EVENT_MUC_PRESENCE = 42; - - /** - * Client has just received a message packet from a multi-user chat room - * getGroup() returns the group name - * getFrom() returns the full jabber id of the sender - * getData() returns the text of the message - * getDom() returns the DOM treelet for this stanza. This is provided - * to make message extension easier. - */ - static const int EVENT_MUC_MESSAGE = 43; - - /** - * Client has begun receiving a stream - */ - static const int EVENT_STREAM_RECEIVE_INIT = 50; - - /** - * Client receives another stream packet. - */ - static const int EVENT_STREAM_RECEIVE = 51; - - /** - * Client has received the end of a stream - */ - static const int EVENT_STREAM_RECEIVE_CLOSE = 52; - - /** - * Other client has accepted a file. - */ - static const int EVENT_FILE_ACCEPTED = 60; - - /** - * This client has just received a file. - */ - static const int EVENT_FILE_RECEIVE = 61; - - /** - * Constructs an event with one of the types above. - */ - XmppEvent(int type); - - /** - * Copy constructor - */ - XmppEvent(const XmppEvent &other); - - /** - * Assignment - */ - virtual XmppEvent &operator=(const XmppEvent &other); - - /** - * Destructor - */ - virtual ~XmppEvent(); - - /** - * Assignment - */ - virtual void assign(const XmppEvent &other); - - /** - * Return the event type. - */ - virtual int getType() const; - - - /** - * - */ - virtual DOMString getIqId() const; - - - /** - * - */ - virtual void setIqId(const DOMString &val); - - /** - * - */ - virtual DOMString getStreamId() const; - - - /** - * - */ - virtual void setStreamId(const DOMString &val); - - /** - * - */ - virtual bool getPresence() const; - - - /** - * - */ - virtual void setPresence(bool val); - - /** - * - */ - virtual DOMString getShow() const; - - - /** - * - */ - virtual void setShow(const DOMString &val); - - /** - * - */ - virtual DOMString getStatus() const; - - /** - * - */ - virtual void setStatus(const DOMString &val); - - /** - * - */ - virtual DOMString getTo() const; - - /** - * - */ - virtual void setTo(const DOMString &val); - - /** - * - */ - virtual DOMString getFrom() const; - - /** - * - */ - virtual void setFrom(const DOMString &val); - - /** - * - */ - virtual DOMString getGroup() const; - - /** - * - */ - virtual void setGroup(const DOMString &val); - - /** - * - */ - virtual Element *getDOM() const; - - - /** - * - */ - virtual void setDOM(const Element *val); - - /** - * - */ - virtual std::vector<XmppUser> getUserList() const; - - /** - * - */ - virtual void setUserList(const std::vector<XmppUser> &userList); - - /** - * - */ - virtual DOMString getFileName() const; - - - /** - * - */ - virtual void setFileName(const DOMString &val); - - - /** - * - */ - virtual DOMString getFileDesc() const; - - - /** - * - */ - virtual void setFileDesc(const DOMString &val); - - - /** - * - */ - virtual long getFileSize() const; - - - /** - * - */ - virtual void setFileSize(long val); - - /** - * - */ - virtual DOMString getFileHash() const; - - /** - * - */ - virtual void setFileHash(const DOMString &val); - - /** - * - */ - virtual DOMString getData() const; - - - /** - * - */ - virtual void setData(const DOMString &val); - -private: - - int eventType; - - DOMString iqId; - - DOMString streamId; - - bool presence; - - DOMString show; - - DOMString status; - - DOMString to; - - DOMString from; - - DOMString group; - - DOMString data; - - DOMString fileName; - DOMString fileDesc; - long fileSize; - DOMString fileHash; - - Element *dom; - - std::vector<XmppUser>userList; - -}; - - - - - - -//######################################################################## -//# X M P P E V E N T L I S T E N E R -//######################################################################## - -/** - * Class that receives and processes an XmppEvent. Users should inherit - * from this class, and overload processXmppEvent() to perform their event - * handling - */ -class XmppEventListener -{ -public: - - /** - * Constructor - */ - XmppEventListener() - {} - - /** - * Assignment - */ - XmppEventListener(const XmppEventListener &/*other*/) - {} - - - /** - * Destructor - */ - virtual ~XmppEventListener() - {} - - /** - * Overload this method to provide your application-specific - * event handling. Use event.getType() to decide what to do - * with the event. - */ - virtual void processXmppEvent(const XmppEvent &/*event*/) - {} - -}; - - - -//######################################################################## -//# X M P P E V E N T T A R G E T -//######################################################################## - -/** - * A base class for classes that emit XmppEvents. - * - * Note: terminology: 'target' is the common term for this, although it - * seems odd that a 'target' is the source of the events. It is clearer - * if you consider that the greater system targets this class with events, - * and this class delegates the handling to its listeners. - */ -class XmppEventTarget -{ -public: - - /** - * Constructor - */ - XmppEventTarget(); - - /** - * Copy constructor - */ - XmppEventTarget(const XmppEventTarget &other); - - /** - * Destructor - */ - virtual ~XmppEventTarget(); - - - //########################### - //# M E S S A G E S - //########################### - - - /** - * Send an error message to all subscribers - */ - void error(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - - /** - * Send a status message to all subscribers - */ - void status(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - //########################### - //# LISTENERS - //########################### - - /** - * Subscribe a subclass of XmppEventListener to this target's events. - */ - virtual void addXmppEventListener(const XmppEventListener &listener); - - /** - * Unsubscribe a subclass of XmppEventListener from this target's events. - */ - virtual void removeXmppEventListener(const XmppEventListener &listener); - - /** - * Remove all event subscribers - */ - virtual void clearXmppEventListeners(); - - /** - * This sends an event to all registered listeners. - */ - virtual void dispatchXmppEvent(const XmppEvent &event); - - /** - * By enabling this, you provide an alternate way to get XmppEvents. - * Any event sent to dispatchXmppEvent() is also sent to this queue, - * so that it can be later be picked up by eventQueuePop(); - * This can sometimes be good for GUI's which can't always respond - * repidly or asynchronously. - */ - void eventQueueEnable(bool val); - - /** - * Return true if there is one or more XmppEvents waiting in the event - * queue. This is used to avoid calling eventQueuePop() when there is - * nothing in the queue. - */ - int eventQueueAvailable(); - - /** - * Return the next XmppEvent in the queue. Users should check that - * eventQueueAvailable() is greater than 0 before calling this. If - * people forget to do this, an event of type XmppEvent::EVENT_NONE - * is generated and returned. - */ - XmppEvent eventQueuePop(); - - -private: - - std::vector<XmppEventListener *> listeners; - - std::vector<XmppEvent> eventQueue; - bool eventQueueEnabled; -}; - - - - - -//######################################################################## -//# X M P P C L I E N T -//######################################################################## - -//forward declarations -class TcpSocket; -class XmppChat; -class XmppGroupChat; -class XmppStream; - - -/** - * This is the actual XMPP (Jabber) client. - */ -class XmppClient : public XmppEventTarget -{ - -public: - - //########################### - //# CONSTRUCTORS - //########################### - - /** - * Constructor - */ - XmppClient(); - - /** - * Copy constructor - */ - XmppClient(const XmppClient &other); - - /** - * Assignment - */ - void assign(const XmppClient &other); - - /** - * Destructor - */ - virtual ~XmppClient(); - - - //########################### - //# UTILITY - //########################### - - /** - * Pause execution of the app for a given number of - * milliseconds. Use this rarely, only when really needed. - */ - virtual bool pause(unsigned long millis); - - /** - * Process a string so that it can safely be - * placed in XML as PCDATA - */ - DOMString toXml(const DOMString &str); - - //########################### - //# CONNECTION - //########################### - - /** - * - */ - virtual bool connect(); - - /** - * - */ - virtual bool connect(DOMString host, int port, - DOMString userName, - DOMString password, - DOMString resource); - - /** - * - */ - virtual bool disconnect(); - - - /** - * - */ - virtual bool write(const char *fmt, ...) G_GNUC_PRINTF(2,3); - - //####################### - //# V A R I A B L E S - //####################### - - /** - * - */ - virtual bool isConnected() - { return connected; } - - /** - * - */ - virtual DOMString getHost() - { return host; } - - /** - * - */ - virtual void setHost(const DOMString &val) - { host = val; } - - /** - * - */ - virtual DOMString getRealm() - { return realm; } - - /** - * - */ - virtual void setRealm(const DOMString &val) - { realm = val; } - - /** - * - */ - virtual int getPort() - { return port; } - - /** - * - */ - virtual void setPort(int val) - { port = val; } - - /** - * - */ - virtual DOMString getUsername(); - - /** - * - */ - virtual void setUsername(const DOMString &val); - - /** - * - */ - virtual DOMString getPassword() - { return password; } - - /** - * - */ - virtual void setPassword(const DOMString &val) - { password = val; } - - /** - * - */ - virtual DOMString getResource() - { return resource; } - - /** - * - */ - virtual void setResource(const DOMString &val) - { resource = val; } - - /** - * - */ - virtual void setJid(const DOMString &val) - { jid = val; } - - /** - * - */ - virtual DOMString getJid() - { return jid; } - - - - /** - * - */ - virtual int getMsgId() - { return msgId++; } - - - - //####################### - //# P R O C E S S I N G - //####################### - - - /** - * - */ - bool processMessage(Element *root); - - /** - * - */ - bool processPresence(Element *root); - - /** - * - */ - bool processIq(Element *root); - - /** - * - */ - virtual bool receiveAndProcess(); - - /** - * - */ - virtual bool receiveAndProcessLoop(); - - //####################### - //# ROSTER - //####################### - - /** - * - */ - bool rosterAdd(const DOMString &rosterGroup, - const DOMString &otherJid, - const DOMString &name); - - /** - * - */ - bool rosterDelete(const DOMString &otherJid); - - /** - * - */ - std::vector<XmppUser> getRoster(); - - /** - * - */ - virtual void rosterShow(const DOMString &jid, const DOMString &show); - - //####################### - //# REGISTRATION - //####################### - - /** - * Set whether the client should to in-band registration - * before authentication. Causes inBandRegistrationNew() to be called - * synchronously, before async is started. - */ - virtual void setDoRegister(bool val) - { doRegister = val; } - - /** - * Change the password of an existing account with a server - */ - bool inBandRegistrationChangePassword(const DOMString &newPassword); - - /** - * Cancel an existing account with a server - */ - bool inBandRegistrationCancel(); - - - //####################### - //# CHAT (individual) - //####################### - - /** - * - */ - virtual bool message(const DOMString &user, const DOMString &subj, - const DOMString &text); - - /** - * - */ - virtual bool message(const DOMString &user, const DOMString &text); - - /** - * - */ - virtual bool presence(const DOMString &presence); - - //####################### - //# GROUP CHAT - //####################### - - /** - * - */ - virtual bool groupChatCreate(const DOMString &groupJid); - - /** - * - */ - virtual void groupChatDelete(const DOMString &groupJid); - - /** - * - */ - bool groupChatExists(const DOMString &groupJid); - - /** - * - */ - virtual void groupChatsClear(); - - /** - * - */ - virtual void groupChatUserAdd(const DOMString &groupJid, - const DOMString &nick, - const DOMString &jid); - /** - * - */ - virtual void groupChatUserShow(const DOMString &groupJid, - const DOMString &nick, - const DOMString &show); - - /** - * - */ - virtual void groupChatUserDelete(const DOMString &groupJid, - const DOMString &nick); - - /** - * - */ - virtual std::vector<XmppUser> - groupChatGetUserList(const DOMString &groupJid); - - /** - * - */ - virtual bool groupChatJoin(const DOMString &groupJid, - const DOMString &nick, - const DOMString &pass); - - /** - * - */ - virtual bool groupChatLeave(const DOMString &groupJid, - const DOMString &nick); - - /** - * - */ - virtual bool groupChatMessage(const DOMString &groupJid, - const DOMString &msg); - - /** - * - */ - virtual bool groupChatPrivateMessage(const DOMString &groupJid, - const DOMString &toNick, - const DOMString &msg); - - /** - * - */ - virtual bool groupChatPresence(const DOMString &groupJid, - const DOMString &nick, - const DOMString &presence); - - - //####################### - //# STREAMS - //####################### - - typedef enum - { - STREAM_AVAILABLE, - STREAM_OPENING, - STREAM_OPEN, - STREAM_CLOSING, - STREAM_CLOSED, - STREAM_ERROR - } StreamStates; - - /** - * - */ - virtual bool outputStreamOpen(const DOMString &jid, - const DOMString &streamId); - - /** - * - */ - virtual bool outputStreamWrite(const DOMString &streamId, - const std::vector<unsigned char> &buf); - - /** - * - */ - virtual bool outputStreamClose(const DOMString &streamId); - - /** - * - */ - virtual bool inputStreamOpen(const DOMString &jid, - const DOMString &streamId, - const DOMString &iqId); - - /** - * - */ - virtual bool inputStreamClose(const DOMString &streamId); - - - //####################### - //# FILE TRANSFERS - //####################### - - /** - * - */ - virtual bool fileSend(const DOMString &destJid, - const DOMString &offeredName, - const DOMString &fileName, - const DOMString &description); - - /** - * - */ - virtual bool fileSendBackground(const DOMString &destJid, - const DOMString &offeredName, - const DOMString &fileName, - const DOMString &description); - - /** - * - */ - virtual bool fileReceive(const DOMString &fromJid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &fileName, - long fileSize, - const DOMString &fileHash); - /** - * - */ - virtual bool fileReceiveBackground(const DOMString &fromJid, - const DOMString &iqId, - const DOMString &streamId, - const DOMString &fileName, - long fileSize, - const DOMString &fileHash); - - -private: - - void init(); - - DOMString host; - - /** - * will be same as host, unless username is - * user@realm - */ - DOMString realm; - - int port; - - DOMString username; - - DOMString password; - - DOMString resource; - - DOMString jid; - - int msgId; - - TcpSocket *sock; - - bool connected; - - bool createSession(); - - bool checkConnect(); - - DOMString readStanza(); - - bool saslMd5Authenticate(); - - bool saslPlainAuthenticate(); - - bool saslAuthenticate(const DOMString &streamId); - - bool iqAuthenticate(const DOMString &streamId); - - /** - * Register a new account with a server. Not done by user - */ - bool inBandRegistrationNew(); - - bool keepGoing; - - bool doRegister; - - std::vector<XmppGroupChat *>groupChats; - - //#### Roster - std::vector<XmppUser>roster; - - - //#### Streams - - bool processInBandByteStreamMessage(Element *root); - - DOMString streamPacket; - - std::map<DOMString, XmppStream *> outputStreams; - - std::map<DOMString, XmppStream *> inputStreams; - - - //#### File send - - bool processFileMessage(Element *root); - - std::map<DOMString, XmppStream *> fileSends; - -}; - - - - -//######################################################################## -//# X M P P G R O U P C H A T -//######################################################################## - -/** - * - */ -class XmppGroupChat -{ -public: - - /** - * - */ - XmppGroupChat(const DOMString &groupJid); - - /** - * - */ - XmppGroupChat(const XmppGroupChat &other); - - /** - * - */ - virtual ~XmppGroupChat(); - - /** - * - */ - virtual DOMString getGroupJid(); - - /** - * - */ - virtual void userAdd(const DOMString &nick, - const DOMString &jid); - /** - * - */ - virtual void userShow(const DOMString &nick, - const DOMString &show); - - /** - * - */ - virtual void userDelete(const DOMString &nick); - - /** - * - */ - virtual std::vector<XmppUser> getUserList() const; - - -private: - - DOMString groupJid; - - std::vector<XmppUser>userList; - -}; - - - - - - - - - - -} //namespace Pedro - -#endif /* __XMPP_H__ */ - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/pedro/work/filerec.cpp b/src/pedro/work/filerec.cpp deleted file mode 100644 index 01d9b6bd8..000000000 --- a/src/pedro/work/filerec.cpp +++ /dev/null @@ -1,130 +0,0 @@ - - -#include <stdio.h> - -#include "pedroxmpp.h" - -//######################################################################## -//# T E S T -//######################################################################## - - -class TestListener : public Pedro::XmppEventListener -{ -public: - TestListener() - { - incoming = false; - } - - virtual ~TestListener(){} - - virtual void processXmppEvent(const Pedro::XmppEvent &evt) - { - int typ = evt.getType(); - switch (typ) - { - case Pedro::XmppEvent::EVENT_STATUS: - { - printf("STATUS: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_ERROR: - { - printf("ERROR: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_CONNECTED: - { - printf("CONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_DISCONNECTED: - { - printf("DISCONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_MUC_PRESENCE: - { - printf("MUC PRESENCE\n"); - printf("group : %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - printf("presence: %d\n", evt.getPresence()); - break; - } - case Pedro::XmppEvent::EVENT_FILE_RECEIVE: - { - printf("FILE RECEIVE\n"); - from = evt.getFrom(); - streamId = evt.getStreamId(); - iqId = evt.getIqId(); - fileName = evt.getFileName(); - fileHash = evt.getFileHash(); - fileSize = evt.getFileSize(); - incoming = true; - break; - } - - } - } - - Pedro::DOMString from; - Pedro::DOMString streamId; - Pedro::DOMString iqId; - Pedro::DOMString fileName; - Pedro::DOMString fileHash; - long fileSize; - bool incoming; -}; - - -bool doTest() -{ - printf("############ RECEIVING FILE\n"); - - Pedro::XmppClient client; - TestListener listener; - client.addXmppEventListener(listener); - - //Host, port, user, pass, resource - if (!client.connect("jabber.org.uk", 443, "ishmal", "PASSWORD", "filerec")) - { - printf("Connect failed\n"); - return false; - } - - while (true) - { - printf("####Waiting for file\n"); - if (listener.incoming) - break; - client.pause(2000); - } - - printf("#####GOT A FILE\n"); -/* -TODO: Just Commented out to compile - if (!client.fileReceive(listener.from, - listener.iqId, - listener.streamId, - listener.fileName, - "text.sav", - listener.fileHash)) - { - return false; - } -*/ - client.pause(1000000); - - client.disconnect(); - - return true; -} - -int main(int argc, char **argv) -{ - if (!doTest()) - return 1; - return 0; -} - diff --git a/src/pedro/work/filesend.cpp b/src/pedro/work/filesend.cpp deleted file mode 100644 index 7a114abe2..000000000 --- a/src/pedro/work/filesend.cpp +++ /dev/null @@ -1,95 +0,0 @@ - - -#include <stdio.h> - -#include "pedroxmpp.h" - -//######################################################################## -//# T E S T -//######################################################################## - - -class TestListener : public Pedro::XmppEventListener -{ -public: - TestListener(){} - - virtual ~TestListener(){} - - virtual void processXmppEvent(const Pedro::XmppEvent &evt) - { - int typ = evt.getType(); - switch (typ) - { - case Pedro::XmppEvent::EVENT_STATUS: - { - printf("STATUS: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_ERROR: - { - printf("ERROR: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_CONNECTED: - { - printf("CONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_DISCONNECTED: - { - printf("DISCONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_MUC_PRESENCE: - { - printf("MUC PRESENCE\n"); - printf("group : %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - printf("presence: %d\n", evt.getPresence()); - break; - } - - } - } -}; - - -bool doTest() -{ - printf("############ SENDING FILE\n"); - - Pedro::XmppClient client; - TestListener listener; - client.addXmppEventListener(listener); - - //Host, port, user, pass, resource - if (!client.connect("jabber.org.uk", 443, "ishmal", "PASSWORD", "filesend")) - { - printf("Connect failed\n"); - return false; - } - - - if (!client.fileSend("ishmal@jabber.org.uk/filerec", - "server.pem" , "server.pem", - "a short story by edgar allen poe")) - { - return false; - } - - printf("OK\n"); - client.pause(1000000); - - client.disconnect(); - - return true; -} - -int main(int argc, char **argv) -{ - if (!doTest()) - return 1; - return 0; -} - diff --git a/src/pedro/work/groupchat.cpp b/src/pedro/work/groupchat.cpp deleted file mode 100644 index 6c2e186d9..000000000 --- a/src/pedro/work/groupchat.cpp +++ /dev/null @@ -1,225 +0,0 @@ - - -#include <stdio.h> -#include <string.h> - -#include "pedroxmpp.h" - -//######################################################################## -//# T E S T -//######################################################################## - -using namespace Pedro; - - -class Listener : public Pedro::XmppEventListener -{ -public: - Listener(){} - - virtual ~Listener(){} - - virtual void processXmppEvent(const Pedro::XmppEvent &evt) - { - int typ = evt.getType(); - switch (typ) - { - case Pedro::XmppEvent::EVENT_STATUS: - { - printf("STATUS: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_ERROR: - { - printf("ERROR: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_CONNECTED: - { - printf("CONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_DISCONNECTED: - { - printf("DISCONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_MESSAGE: - { - printf("<%s> %s\n", evt.getFrom().c_str(), evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_PRESENCE: - { - printf("PRESENCE\n"); - printf("from : %s\n", evt.getFrom().c_str()); - //printf("presence : %s\n", evt.getPresence().c_str()); - // TODO: Just Commented out to compile - break; - } - case Pedro::XmppEvent::EVENT_MUC_MESSAGE: - { - printf("<%s> %s\n", evt.getFrom().c_str(), evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_MUC_JOIN: - { - printf("MUC JOIN\n"); - printf("group: %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - //printf("presence: %s\n", evt.getPresence().c_str()); - // TODO: Just Commented out to compile - break; - } - case Pedro::XmppEvent::EVENT_MUC_LEAVE: - { - printf("MUC LEAVE\n"); - printf("group: %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - //printf("presence: %s\n", evt.getPresence().c_str()); - // TODO: Just Commented out to compile - break; - } - case Pedro::XmppEvent::EVENT_MUC_PRESENCE: - { - printf("MUC PRESENCE\n"); - printf("group : %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - //printf("presence: %s\n", evt.getPresence().c_str()); - // TODO: Just Commented out to compile - break; - } - - } - } -}; - - -class CommandLineGroupChat -{ -public: - CommandLineGroupChat(const DOMString &hostArg, - int portArg, - const DOMString &userArg, - const DOMString &passArg, - const DOMString &resourceArg, - const DOMString &groupJidArg, - const DOMString &nickArg) - { - host = hostArg; - port = portArg; - user = userArg; - pass = passArg; - resource = resourceArg; - groupJid = groupJidArg; - nick = nickArg; - } - ~CommandLineGroupChat() - { - client.disconnect(); - } - - virtual bool run(); - virtual bool processCommandLine(); - -private: - - DOMString host; - int port; - DOMString user; - DOMString pass; - DOMString resource; - DOMString groupJid; - DOMString nick; - - XmppClient client; - -}; - - -bool CommandLineGroupChat::run() -{ - Listener listener; - client.addXmppEventListener(listener); - - //Host, port, user, pass, resource - if (!client.connect(host, port, user, pass, resource)) - { - return false; - } - - //Group jabber id, nick, pass - if (!client.groupChatJoin(groupJid, nick, "")) - { - printf("failed join\n"); - return false; - } - - //Allow receive buffer to clear out - client.pause(10000); - - while (true) - { - if (!processCommandLine()) - break; - } - - //Group jabber id, nick - client.groupChatLeave(groupJid, nick); - - - client.disconnect(); - - return true; -} - - -bool CommandLineGroupChat::processCommandLine() -{ - char buf[512]; - printf("send>:"); - fgets(buf, 511, stdin); - - if (buf[0]=='/') - { - if (strncmp(buf, "/q", 2)==0) - return false; - else - { - printf("Unknown command\n"); - return true; - } - } - - else - { - DOMString msg = buf; - if (msg.size() > 0 ) - { - if (!client.groupChatMessage(groupJid, buf)) - { - printf("failed message send\n"); - return false; - } - } - } - - return true; -} - - -int main(int argc, char **argv) -{ - if (argc!=8) - { - printf("usage: %s host port user pass resource groupid nick\n", argv[0]); - return 1; - } - int port = atoi(argv[2]); - CommandLineGroupChat groupChat(argv[1], port, argv[3], argv[4], - argv[5], argv[6], argv[7]); - if (!groupChat.run()) - return 1; - return 0; -} - diff --git a/src/pedro/work/inklayout.svg b/src/pedro/work/inklayout.svg deleted file mode 100644 index 5f28a129b..000000000 --- a/src/pedro/work/inklayout.svg +++ /dev/null @@ -1,378 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="841.88977pt" - height="595.27557pt" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.42+devel" - version="1.0" - sodipodi:docbase="/home/rjamison/pedro" - sodipodi:docname="inklayout.svg"> - <defs - id="defs4"> - <marker - inkscape:stockid="Arrow1Mend" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Mend" - style="overflow:visible;"> - <path - id="path4241" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" - transform="scale(0.4) rotate(180)" /> - </marker> - <marker - inkscape:stockid="Arrow1Mstart" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Mstart" - style="overflow:visible"> - <path - id="path4244" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" - transform="scale(0.4)" /> - </marker> - <marker - inkscape:stockid="TriangleInL" - orient="auto" - refY="0.0" - refX="0.0" - id="TriangleInL" - style="overflow:visible"> - <path - id="path4158" - d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" - transform="scale(-0.8)" /> - </marker> - <marker - inkscape:stockid="Arrow2Lstart" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow2Lstart" - style="overflow:visible"> - <path - id="path4232" - style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round" - d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " - transform="scale(1.1) translate(-5,0)" /> - </marker> - <marker - inkscape:stockid="Arrow1Lstart" - orient="auto" - refY="0.0" - refX="0.0" - id="Arrow1Lstart" - style="overflow:visible"> - <path - id="path4250" - d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " - style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" - transform="scale(0.8)" /> - </marker> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.98994949" - inkscape:cx="544.45061" - inkscape:cy="385.08312" - inkscape:document-units="px" - inkscape:current-layer="layer1" - fill="#000000" - inkscape:window-width="899" - inkscape:window-height="951" - inkscape:window-x="284" - inkscape:window-y="59" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <rect - y="20.094482" - x="424.57144" - height="37.142857" - width="240" - id="rect3148" - style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.20000005;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <rect - style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.20000005;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="rect2273" - width="240" - height="37.142857" - x="418.57144" - y="14.094482" /> - <rect - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="rect1358" - width="83.244057" - height="35.076485" - x="191.22281" - y="182.43959" /> - <text - xml:space="preserve" - style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="199.27339" - y="203.54922" - id="text2233" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan2235" - x="199.27339" - y="203.54922">Private chat</tspan></text> - <rect - y="278.15387" - x="282.6514" - height="35.076485" - width="83.244057" - id="rect2237" - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <text - id="text2239" - y="331.4064" - x="252.13055" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="331.4064" - x="252.13055" - id="tspan2241" - sodipodi:role="line">Gui Client Main Window</tspan></text> - <rect - y="182.43959" - x="289.22281" - height="35.076485" - width="83.244057" - id="rect2243" - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <text - id="text2245" - y="204.97781" - x="302.9877" - style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve" - sodipodi:linespacing="125%"><tspan - y="204.97781" - x="302.9877" - id="tspan2247" - sodipodi:role="line">Group chat</tspan></text> - <rect - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.62177706;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="rect2249" - width="96.722092" - height="35.076485" - x="391.2695" - y="182.43959" /> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="419.9877" - y="173.54926" - id="text2251"><tspan - sodipodi:role="line" - id="tspan2253" - x="419.9877" - y="173.54926">Dialog</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 249.87329,217.80449 L 307.24497,277.86545" - id="path2255" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect1358" - inkscape:connection-end="#rect2237" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 329.62092,217.80449 L 325.49734,277.86545" - id="path2257" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect2243" - inkscape:connection-end="#rect2237" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 418.11835,217.82696 L 345.75854,277.86545" - id="path2259" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect2249" - inkscape:connection-end="#rect2237" /> - <text - xml:space="preserve" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="428.57141" - y="39.808769" - id="text2261" - sodipodi:linespacing="100%"><tspan - sodipodi:role="line" - id="tspan2263" - x="428.57141" - y="39.808769">Inkboard Layout</tspan></text> - <rect - y="182.02116" - x="582.86676" - height="35.076485" - width="83.244057" - id="rect3150" - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <text - id="text3152" - y="173.84511" - x="603.06018" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="173.84511" - x="603.06018" - id="tspan3154" - sodipodi:role="line">Session</tspan></text> - <rect - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="rect3156" - width="83.244057" - height="35.076485" - x="674.29535" - y="277.73547" /> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="664.48877" - y="330.98801" - id="text3158"><tspan - sodipodi:role="line" - id="tspan3160" - x="664.48877" - y="330.98801">Session Manager</tspan></text> - <rect - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="rect3162" - width="83.244057" - height="35.076485" - x="680.86676" - y="182.02116" /> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="701.06018" - y="173.84511" - id="text3164"><tspan - sodipodi:role="line" - id="tspan3166" - x="701.06018" - y="173.84511">Session</tspan></text> - <rect - y="182.02116" - x="782.86676" - height="35.076485" - width="83.244057" - id="rect3168" - style="fill:none;fill-opacity:0.75;stroke:#000000;stroke-width:0.57683086;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <text - id="text3170" - y="173.84511" - x="803.06018" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="173.84511" - x="803.06018" - id="tspan3172" - sodipodi:role="line">Session</tspan></text> - <path - inkscape:connection-end="#rect2237" - inkscape:connection-start="#rect1358" - inkscape:connector-type="polyline" - id="path3174" - d="M 249.87329,217.80449 L 307.24497,277.86545" - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> - <text - id="text3180" - y="195.69208" - x="407.84482" - style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve" - sodipodi:linespacing="125%"><tspan - y="195.69208" - x="407.84482" - id="tspan3182" - sodipodi:role="line">Private chat</tspan></text> - <text - xml:space="preserve" - style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="393.70197" - y="208.54922" - id="text3184" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan3186" - x="393.70197" - y="208.54922">w/ group member</tspan></text> - <text - id="text3188" - y="174.26353" - x="311.41626" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - y="174.26353" - x="311.41626" - id="tspan3190" - sodipodi:role="line">Dialog</tspan></text> - <text - xml:space="preserve" - style="font-size:12px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="213.41626" - y="174.26353" - id="text3192"><tspan - sodipodi:role="line" - id="tspan3194" - x="213.41626" - y="174.26353">Dialog</tspan></text> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 804.26751,217.38606 L 736.13865,277.44706" - id="path3196" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect3168" - inkscape:connection-end="#rect3156" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 721.26487,217.38606 L 717.14129,277.44706" - id="path3198" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect3162" - inkscape:connection-end="#rect3156" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 641.51724,217.38606 L 698.88893,277.44706" - id="path3200" - inkscape:connector-type="polyline" - inkscape:connection-start="#rect3150" - inkscape:connection-end="#rect3156" /> - <path - style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:6.1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;marker-start:url(#Arrow1Mstart);marker-end:url(#Arrow1Mend)" - d="M 452.54834,260.23141 C 615.1829,260.23141 616.19305,260.23141 616.19305,260.23141" - id="path3202" /> - </g> -</svg> diff --git a/src/pedro/work/test.cpp b/src/pedro/work/test.cpp deleted file mode 100644 index f822ceca9..000000000 --- a/src/pedro/work/test.cpp +++ /dev/null @@ -1,183 +0,0 @@ - - -#include <stdio.h> - -#include "pedroxmpp.h" -#include "pedroconfig.h" - -//######################################################################## -//# T E S T -//######################################################################## - - -class TestListener : public Pedro::XmppEventListener -{ -public: - TestListener(){} - - virtual ~TestListener(){} - - virtual void processXmppEvent(const Pedro::XmppEvent &evt) - { - int typ = evt.getType(); - switch (typ) - { - case Pedro::XmppEvent::EVENT_STATUS: - { - printf("STATUS: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_ERROR: - { - printf("ERROR: %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_CONNECTED: - { - printf("CONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_DISCONNECTED: - { - printf("DISCONNECTED\n"); - break; - } - case Pedro::XmppEvent::EVENT_MESSAGE: - { - printf("MESSAGE\n"); - printf("from : %s\n", evt.getFrom().c_str()); - printf("msg : %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_PRESENCE: - { - printf("PRESENCE\n"); - printf("from : %s\n", evt.getFrom().c_str()); - printf("presence : %d\n", evt.getPresence()); - break; - } - case Pedro::XmppEvent::EVENT_MUC_MESSAGE: - { - printf("MUC GROUP MESSAGE\n"); - printf("group: %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - printf("msg : %s\n", evt.getData().c_str()); - break; - } - case Pedro::XmppEvent::EVENT_MUC_JOIN: - { - printf("MUC JOIN\n"); - printf("group: %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - printf("presence: %d\n", evt.getPresence()); - break; - } - case Pedro::XmppEvent::EVENT_MUC_LEAVE: - { - printf("MUC LEAVE\n"); - printf("group: %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - printf("presence: %d\n", evt.getPresence()); - break; - } - case Pedro::XmppEvent::EVENT_MUC_PRESENCE: - { - printf("MUC PRESENCE\n"); - printf("group : %s\n", evt.getGroup().c_str()); - printf("from : %s\n", evt.getFrom().c_str()); - printf("presence: %d\n", evt.getPresence()); - break; - } - - } - } -}; - - -bool doTest() -{ - printf("############ TESTING\n"); - - char *groupJid = "inkscape@conference.gristle.org"; - - Pedro::XmppClient client; - TestListener listener; - client.addXmppEventListener(listener); - - //Host, port, user, pass, resource - if (!client.connect("jabber.org.uk", 443, "ishmal", "PASSWORD", "myclient")) - { - printf("Connect failed\n"); - return false; - } - - //Group jabber id, nick, pass - client.groupChatJoin(groupJid, "mynick", ""); - - client.pause(8000); - - //Group jabber id, nick, msg - //client.groupChatMessage(groupJid, "hello, world"); - - client.pause(3000); - - //client.groupChatGetUserList(groupJid); - - client.pause(3000); - - //client.groupChatPrivateMessage("inkscape2@conference.gristle.org", - // "ishmal", "hello, world"); - client.message("ishmal@jabber.org.uk/https", "hey, bob"); - - client.pause(60000); - - //Group jabber id, nick - client.groupChatLeave(groupJid, "mynick"); - - client.pause(1000000); - - client.disconnect(); - - return true; -} - - -bool configTest() -{ - printf("#################################\n"); - printf("## C o n f i g t e s t\n"); - printf("#################################\n"); - - Pedro::XmppConfig config; - - if (!config.readFile("pedro.ini")) - { - printf("could not read config file\n"); - return false; - } - - Pedro::DOMString str = config.toXmlBuffer(); - - printf("#################################\n"); - printf("%s\n", str.c_str()); - - if (!config.writeFile("pedro2.ini")) - { - printf("could not write config file\n"); - return false; - } - - - return true; - -}; - - - -int main(int argc, char **argv) -{ - if (!configTest()) - return 1; - return 0; -} - diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index da9be1e7c..5d6592897 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -1,15 +1,5 @@ ## Makefile.am fragment sourced by src/Makefile.am. -##if WITH_INKBOARD -## inkboard_dialogs = \ -## ui/dialog/whiteboard-connect.cpp \ -## ui/dialog/whiteboard-connect.h \ -## ui/dialog/whiteboard-sharewithchat.cpp \ -## ui/dialog/whiteboard-sharewithchat.h \ -## ui/dialog/whiteboard-sharewithuser.cpp \ -## ui/dialog/whiteboard-sharewithuser.h -##endif - ink_common_sources += \ ui/dialog/aboutbox.cpp \ ui/dialog/aboutbox.h \ diff --git a/src/ui/dialog/whiteboard-connect.cpp b/src/ui/dialog/whiteboard-connect.cpp deleted file mode 100644 index ca18cd20d..000000000 --- a/src/ui/dialog/whiteboard-connect.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/** @file - * @brief Whiteboard connection dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> -#include <gtk/gtk.h> -#include <gtkmm/entry.h> -#include <gtkmm/checkbutton.h> -#include <gtkmm/table.h> - -#include "inkscape.h" -#include "desktop.h" -#include "message-stack.h" -#include "preferences.h" - -#include "jabber_whiteboard/session-manager.h" - -#include "message-context.h" -#include "ui/dialog/whiteboard-connect.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace UI { - -namespace Dialog { - -WhiteboardConnectDialog* -WhiteboardConnectDialog::create() -{ - return new WhiteboardConnectDialogImpl(); -} - -WhiteboardConnectDialogImpl::WhiteboardConnectDialogImpl() : - _layout(4, 4, false), _usessl(_("_Use SSL"), true), _register(_("_Register"), true) -{ - this->setSessionManager(); - this->_construct(); - //this->set_resize_mode(Gtk::RESIZE_IMMEDIATE); - this->set_resizable(false); - this->get_vbox()->show_all_children(); -} - -WhiteboardConnectDialogImpl::~WhiteboardConnectDialogImpl() -{ -} - -void WhiteboardConnectDialogImpl::present() -{ - Dialog::present(); -} - -void -WhiteboardConnectDialogImpl::setSessionManager() -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); -} - -void -WhiteboardConnectDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Construct dialog interface - this->_labels[0].set_markup_with_mnemonic(_("_Server:")); - this->_labels[1].set_markup_with_mnemonic(_("_Username:")); - this->_labels[2].set_markup_with_mnemonic(_("_Password:")); - this->_labels[3].set_markup_with_mnemonic(_("P_ort:")); - - this->_labels[0].set_mnemonic_widget(this->_server); - this->_labels[1].set_mnemonic_widget(this->_username); - this->_labels[2].set_mnemonic_widget(this->_password); - this->_labels[3].set_mnemonic_widget(this->_port); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - this->_server.set_text(prefs->getString("/whiteboard/server/name")); - /// @todo Convert port to an integer preference? - this->_port.set_text(prefs->getString("/whiteboard/server/port")); - this->_username.set_text(prefs->getString("/whiteboard/server/username")); - this->_usessl.set_active(prefs->getBool("/whiteboard/server/ssl", false); - - this->_layout.attach(this->_labels[0], 0, 1, 0, 1); - this->_layout.attach(this->_labels[1], 0, 1, 1, 2); - this->_layout.attach(this->_labels[2], 0, 1, 2, 3); - this->_layout.attach(this->_labels[3], 2, 3, 0, 1); - - this->_layout.attach(this->_server, 1, 2, 0, 1); - this->_layout.attach(this->_port, 3, 4, 0, 1); - this->_layout.attach(this->_username, 1, 4, 1, 2); - this->_layout.attach(this->_password, 1, 4, 2, 3); - - this->_checkboxes.attach(this->_blank,0,1,0,1); - this->_checkboxes.attach(this->_blank,0,1,1,2); - - this->_checkboxes.attach(this->_usessl, 1, 4, 0, 1); - this->_checkboxes.attach(this->_register, 1, 5, 1, 2); - - this->_layout.set_col_spacings(1); - this->_layout.set_row_spacings(1); - - this->_password.set_visibility(false); - this->_password.set_invisible_char('*'); - - // Buttons - this->_ok.set_label(_("Connect")); - this->_cancel.set_label(_("Cancel")); - - this->_ok.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_respCallback), GTK_RESPONSE_OK)); - this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_respCallback), GTK_RESPONSE_CANCEL)); - - this->_register.signal_clicked().connect(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_registerCallback)); - this->_usessl.signal_clicked().connect(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_useSSLClickedCallback)); - - this->_buttons.pack_start(this->_cancel, true, true, 0); - this->_buttons.pack_end(this->_ok, true, true, 0); - - // Pack widgets into main vbox - main->pack_start(this->_layout,Gtk::PACK_SHRINK); - main->pack_start(this->_checkboxes,Gtk::PACK_SHRINK); - main->pack_end(this->_buttons,Gtk::PACK_SHRINK); -} - - -void -WhiteboardConnectDialogImpl::_registerCallback() -{ - if (this->_register.get_active()) - { - Glib::ustring server, port; - bool usessl; - - server = this->_server.get_text(); - port = this->_port.get_text(); - usessl = this->_usessl.get_active(); - - Glib::ustring msg = String::ucompose(_("Establishing connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - if(this->_sm->initializeConnection(server,port,usessl) == CONNECT_SUCCESS) - { - - std::vector<Glib::ustring> entries = this->_sm->getRegistrationInfo(); - - for(unsigned i = 0; i<entries.size();i++) - { - - Gtk::Entry *entry = manage (new Gtk::Entry); - Gtk::Label *label = manage (new Gtk::Label); - - Glib::ustring::size_type zero=0,one=1; - Glib::ustring LabelText = entries[i].replace(zero,one,one,Glib::Unicode::toupper(entries[i].at(0))); - - (*label).set_markup_with_mnemonic(LabelText.c_str()); - (*label).set_mnemonic_widget(*entry); - - this->_layout.attach (*label, 0, 1, i+3, i+4, Gtk::FILL|Gtk::EXPAND|Gtk::SHRINK, (Gtk::AttachOptions)0,0,0); - this->_layout.attach (*entry, 1, 4, i+3, i+4, Gtk::FILL|Gtk::EXPAND|Gtk::SHRINK, (Gtk::AttachOptions)0,0,0); - - this->registerlabels.push_back(label); - this->registerentries.push_back(entry); - } - }else{ - Glib::ustring msg = String::ucompose(_("Failed to establish connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - } - - }else{ - - for(unsigned i = 0; i<registerlabels.size();i++) - { - this->_layout.remove(*registerlabels[i]); - this->_layout.remove(*registerentries[i]); - - delete registerlabels[i]; - delete registerentries[i]; - } - - registerentries.erase(registerentries.begin(), registerentries.end()); - registerlabels.erase(registerlabels.begin(), registerlabels.end()); - } - - this->get_vbox()->show_all_children(); - //this->reshow_with_initial_size(); -} - -void -WhiteboardConnectDialogImpl::_respCallback(int resp) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (resp == GTK_RESPONSE_OK) - { - Glib::ustring server, port, username, password; - bool usessl; - - server = this->_server.get_text(); - port = this->_port.get_text(); - username = this->_username.get_text(); - password = this->_password.get_text(); - usessl = this->_usessl.get_active(); - - Glib::ustring msg = String::ucompose(_("Establishing connection to Jabber server <b>%1</b> as user <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - if (!this->_register.get_active()) - { - switch (this->_sm->connectToServer(server, port, username, password, usessl)) { - case FAILED_TO_CONNECT: - msg = String::ucompose(_("Failed to establish connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case INVALID_AUTH: - msg = String::ucompose(_("Authentication failed on Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case SSL_INITIALIZATION_ERROR: - msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - - case CONNECT_SUCCESS: - msg = String::ucompose(_("Connected to Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - // Save preferences - prefs->setString(this->_prefs_path + "/server", this->_server.get_text()); - break; - default: - break; - } - }else{ - - std::vector<Glib::ustring> key,val; - - for(unsigned i = 0; i<registerlabels.size();i++) - { - key.push_back((*registerlabels[i]).get_text()); - val.push_back((*registerentries[i]).get_text()); - } - - switch (this->_sm->registerWithServer(username, password, key, val)) - { - case FAILED_TO_CONNECT: - msg = String::ucompose(_("Failed to establish connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case INVALID_AUTH: - msg = String::ucompose(_("Registration failed on Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case SSL_INITIALIZATION_ERROR: - msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - - case CONNECT_SUCCESS: - msg = String::ucompose(_("Connected to Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - // Save preferences - prefs->setString(this->_prefs_path + "/server", this->_server.get_text()); - break; - default: - break; - } - } - } - - this->_password.set_text(""); - this->hide(); -} - -void -WhiteboardConnectDialogImpl::_useSSLClickedCallback() -{ - if (this->_usessl.get_active()) { - this->_port.set_text("5223"); - - // String::ucompose seems to format numbers according to locale; unfortunately, - // I'm not yet sure how to turn that off - //this->_port.set_text(String::ucompose("%1", LM_CONNECTION_DEFAULT_PORT_SSL)); - } else { - this->_port.set_text("5222"); - } -} - -} // namespace Dialog - -} // namespace UI - -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/whiteboard-connect.h b/src/ui/dialog/whiteboard-connect.h deleted file mode 100644 index 8b34215f9..000000000 --- a/src/ui/dialog/whiteboard-connect.h +++ /dev/null @@ -1,99 +0,0 @@ -/** @file - * @brief Whiteboard connection dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_CONNECT_DIALOG_H__ -#define __WHITEBOARD_CONNECT_DIALOG_H__ - -#include "verbs.h" -#include "dialog.h" - -#include <vector> - -struct SPDesktop; - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; - -} - -namespace UI { - -namespace Dialog { - -class WhiteboardConnectDialog : public Dialog { -public: - WhiteboardConnectDialog() : Dialog("/dialogs/whiteboard_connect", SP_VERB_DIALOG_WHITEBOARD_CONNECT) - { - - } - - static WhiteboardConnectDialog* create(); - - virtual ~WhiteboardConnectDialog() - { - - } -}; - -class WhiteboardConnectDialogImpl : public WhiteboardConnectDialog { -public: - WhiteboardConnectDialogImpl(); - ~WhiteboardConnectDialogImpl(); - void present(); - void setSessionManager(); - -private: - - // GTK+ widgets - std::vector<Gtk::Label*> registerlabels; - std::vector<Gtk::Entry*> registerentries; - - Gtk::Table _layout,_checkboxes; - Gtk::HBox _buttons; - - Gtk::Entry _server; - Gtk::Entry _username; - Gtk::Entry _password; - Gtk::Entry _port; - - Gtk::Label _labels[4],_blank; - - Gtk::CheckButton _usessl,_register; - - Gtk::Button _ok, _cancel; - - // Construction and callbacks - void _construct(); - void _respCallback(int resp); - - void _registerCallback(); - void _useSSLClickedCallback(); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; -}; - - -} - -} - -} - -#endif diff --git a/src/ui/dialog/whiteboard-sharewithchat.cpp b/src/ui/dialog/whiteboard-sharewithchat.cpp deleted file mode 100644 index 8ef69613a..000000000 --- a/src/ui/dialog/whiteboard-sharewithchat.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/** @file - * @brief Whiteboard share with chatroom dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> - -#include <sigc++/sigc++.h> -#include <gtk/gtk.h> - -#include "message-stack.h" -#include "message-context.h" -#include "inkscape.h" -#include "desktop.h" - -#include "preferences.h" - -#include "jabber_whiteboard/typedefs.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/buddy-list-manager.h" - -#include "jabber_whiteboard/session-file-selector.h" - -#include "ui/dialog/whiteboard-sharewithchat.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { -namespace UI { -namespace Dialog { - -WhiteboardShareWithChatroomDialog* -WhiteboardShareWithChatroomDialog::create() -{ - return new WhiteboardShareWithChatroomDialogImpl(); -} - -WhiteboardShareWithChatroomDialogImpl::WhiteboardShareWithChatroomDialogImpl() : - _layout(4, 2, false) -{ - this->setSessionManager(); - this->_construct(); - this->get_vbox()->show_all_children(); -} - -WhiteboardShareWithChatroomDialogImpl::~WhiteboardShareWithChatroomDialogImpl() -{ - -} - -void -WhiteboardShareWithChatroomDialogImpl::setSessionManager() -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); - -} - - -void -WhiteboardShareWithChatroomDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Construct labels - this->_labels[0].set_markup_with_mnemonic(_("Chatroom _name:")); - this->_labels[1].set_markup_with_mnemonic(_("Chatroom _server:")); - this->_labels[2].set_markup_with_mnemonic(_("Chatroom _password:")); - this->_labels[3].set_markup_with_mnemonic(_("Chatroom _handle:")); - - this->_labels[0].set_mnemonic_widget(this->_roomname); - this->_labels[1].set_mnemonic_widget(this->_confserver); - this->_labels[2].set_mnemonic_widget(this->_roompass); - this->_labels[3].set_mnemonic_widget(this->_handle); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - this->_roomname.set_text(prefs->getString("/whiteboard/room/name")); - this->_confserver.set_text(prefs->getString("/whiteboard/room/server")); - this->_handle.set_text(prefs->getString("/whiteboard/server/username")); - - // Pack table - this->_layout.attach(this->_labels[0], 0, 1, 0, 1); - this->_layout.attach(this->_labels[1], 0, 1, 1, 2); - this->_layout.attach(this->_labels[2], 0, 1, 2, 3); - this->_layout.attach(this->_labels[3], 0, 1, 3, 4); - - this->_layout.attach(this->_roomname, 1, 2, 0, 1); - this->_layout.attach(this->_confserver, 1, 2, 1, 2); - this->_layout.attach(this->_roompass, 1, 2, 2, 3); - this->_layout.attach(this->_handle, 1, 2, 3, 4); - - // Button setup and callback registration - this->_share.set_label(_("Connect to chatroom")); - this->_cancel.set_label(_("Cancel")); - this->_share.set_use_underline(true); - this->_cancel.set_use_underline(true); - - this->_share.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithChatroomDialogImpl::_respCallback), WhiteboardShareWithChatroomDialogImpl::SHARE)); - this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithChatroomDialogImpl::_respCallback), WhiteboardShareWithChatroomDialogImpl::CANCEL)); - - // Pack buttons - this->_buttonsbox.pack_start(this->_cancel); - this->_buttonsbox.pack_start(this->_share); - - // Set default values - Glib::ustring jid = this->_sm->session_data->jid; - Glib::ustring nick = jid.substr(0, jid.find_first_of('@')); - this->_handle.set_text(nick); - this->_roomname.set_text("inkboard"); - - // Pack into main box - main->pack_start(this->_layout); - main->pack_end(this->_buttonsbox); -} - -void -WhiteboardShareWithChatroomDialogImpl::_respCallback(int resp) -{ - switch (resp) { - case SHARE: - { - Glib::ustring chatroom, server, handle, password; - chatroom = this->_roomname.get_text(); - server = this->_confserver.get_text(); - password = this->_roompass.get_text(); - handle = this->_handle.get_text(); - - Glib::ustring msg = String::ucompose(_("Synchronizing with chatroom <b>%1@%2</b> using the handle <b>%3</b>"), chatroom, server, handle); - - this->_desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.data()); - - this->_desktop->whiteboard_session_manager()->sendRequestToChatroom(server, chatroom, handle, password); - } - case CANCEL: - default: - this->hide(); - break; - } -} - -} // namespace Dialog -} // namespace UI -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/dialog/whiteboard-sharewithchat.h b/src/ui/dialog/whiteboard-sharewithchat.h deleted file mode 100644 index 4a6c2fc89..000000000 --- a/src/ui/dialog/whiteboard-sharewithchat.h +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - * @brief Whiteboard share with chatroom dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_SHAREWITHCHAT_DIALOG_H__ -#define __WHITEBOARD_SHAREWITHCHAT_DIALOG_H__ - -#include "verbs.h" -#include "dialog.h" - -#include <gtkmm/table.h> -#include "jabber_whiteboard/session-file-selector.h" - -struct SPDesktop; - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; - -} - -namespace UI { - -namespace Dialog { - -class WhiteboardShareWithChatroomDialog : public Dialog { -public: - WhiteboardShareWithChatroomDialog() : Dialog("/dialogs/whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER) - { - - } - - static WhiteboardShareWithChatroomDialog* create(); - - virtual ~WhiteboardShareWithChatroomDialog() - { - - } -}; - - -class WhiteboardShareWithChatroomDialogImpl : public WhiteboardShareWithChatroomDialog { -public: - WhiteboardShareWithChatroomDialogImpl(); - ~WhiteboardShareWithChatroomDialogImpl(); - void setSessionManager(); - -private: - // Response flags - static unsigned int const SHARE = 0; - static unsigned int const CANCEL = 2; - - // GTK+ widgets - Gtk::Table _layout; - - Gtk::HBox _buttonsbox; - Whiteboard::SessionFileSelectorBox _sfsbox; - - Gtk::Entry _roomname; - Gtk::Entry _roompass; - Gtk::Entry _confserver; - Gtk::Entry _handle; - - Gtk::Label _labels[4]; - - Gtk::Button _share, _cancel; - - // Construction and callback - void _construct(); - void _respCallback(int resp); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; -}; - -} - -} - -} - -#endif diff --git a/src/ui/dialog/whiteboard-sharewithuser.cpp b/src/ui/dialog/whiteboard-sharewithuser.cpp deleted file mode 100644 index 772184107..000000000 --- a/src/ui/dialog/whiteboard-sharewithuser.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/** @file - * Whiteboard share with user dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> - -#include <sigc++/sigc++.h> -#include <gtk/gtk.h> - -#include "message-stack.h" -#include "message-context.h" -#include "inkscape.h" -#include "desktop.h" - -#include "jabber_whiteboard/typedefs.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/buddy-list-manager.h" - -#include "jabber_whiteboard/session-file-selector.h" - -#include "ui/dialog/whiteboard-sharewithuser.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace UI { - -namespace Dialog { - -WhiteboardShareWithUserDialog* -WhiteboardShareWithUserDialog::create() -{ - return new WhiteboardShareWithUserDialogImpl(); -} - -WhiteboardShareWithUserDialogImpl::WhiteboardShareWithUserDialogImpl() -{ - this->setSessionManager(); - this->_construct(); - this->get_vbox()->show_all_children(); - - this->_sm->session_data->buddyList.addInsertListener(sigc::mem_fun(this, &WhiteboardShareWithUserDialogImpl::_insertBuddy)); - this->_sm->session_data->buddyList.addEraseListener(sigc::mem_fun(this, &WhiteboardShareWithUserDialogImpl::_eraseBuddy)); - -} - -WhiteboardShareWithUserDialogImpl::~WhiteboardShareWithUserDialogImpl() -{ - -} - -void -WhiteboardShareWithUserDialogImpl::setSessionManager() -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); - -} - - -void -WhiteboardShareWithUserDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Construct dialog interface - this->_labels[0].set_markup_with_mnemonic(_("_User's Jabber ID:")); - this->_labels[0].set_mnemonic_widget(this->_jid); - - // Buttons - this->_share.set_label(_("_Invite user")); - this->_cancel.set_label(_("_Cancel")); - this->_share.set_use_underline(true); - this->_cancel.set_use_underline(true); - - // Button callbacks - this->_share.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithUserDialogImpl::_respCallback), SHARE)); - this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithUserDialogImpl::_respCallback), CANCEL)); - - // Construct ListStore for buddy list information - this->_buddylistdata = Gtk::ListStore::create(this->_blm); - this->_buddylist.set_model(this->_buddylistdata); - this->_buddylist.append_column(_("Buddy List"), this->_blm.jid); - - // Fill buddy list - this->_fillBuddyList(); - - // Buddy list onclick callback - this->_buddylist.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &WhiteboardShareWithUserDialogImpl::_listCallback)); - - // Pack widgets into boxes - this->_listwindow.add(this->_buddylist); - this->_listwindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - this->_buddylistbox.pack_start(this->_listwindow); - - this->_connecttojidbox.pack_start(this->_labels[0]); - this->_connecttojidbox.pack_end(this->_jid); - - this->_buttons.pack_start(this->_cancel); - this->_buttons.pack_end(this->_share); - - // Pack boxes into main box - main->pack_start(this->_buddylistbox); - main->pack_start(this->_connecttojidbox); - main->pack_start(this->_sfsbox); - main->pack_end(this->_buttons); -} - - -void -WhiteboardShareWithUserDialogImpl::_fillBuddyList() -{ - Whiteboard::BuddyList& bl = this->_sm->session_data->buddyList.getList(); - - for(Whiteboard::BuddyList::iterator i = bl.begin(); i != bl.end(); i++) { - this->_insertBuddy(*i); - } -// std::for_each(bl.begin(), bl.end(), std::mem_fun(&WhiteboardShareWithUserDialogImpl::_insertBuddy)); -} - -void -WhiteboardShareWithUserDialogImpl::_insertBuddy(std::string const& jid) -{ - // FIXME: need a better way to avoid inserting duplicate rows in the case - // of duplicate Jabber presence messages - typedef Gtk::TreeModel::Children type_children; - type_children children = this->_buddylistdata->children(); - for(type_children::iterator i = children.begin(); i != children.end(); i++) { - if ((*i).get_value(this->_blm.jid) == jid) { - return; - } - } - - Gtk::TreeModel::Row row = *(this->_buddylistdata->append()); - row[this->_blm.jid] = jid; -} - -void -WhiteboardShareWithUserDialogImpl::_eraseBuddy(std::string const& jid) -{ - // FIXME: Doesn't gtkmm provide a better way to erase rows from a ListStore? - typedef Gtk::TreeModel::Children type_children; - type_children children = this->_buddylistdata->children(); - for(type_children::iterator i = children.begin(); i != children.end(); i++) { - if ((*i).get_value(this->_blm.jid) == jid) { - this->_buddylistdata->erase(i); - return; - } - } -} - -void -WhiteboardShareWithUserDialogImpl::_respCallback(int resp) -{ - switch (resp) { - case SHARE: - { - Glib::ustring jid = this->_jid.get_text(); - - // Check that the JID is in the format user@host/resource - if (jid.find("@", 0) == Glib::ustring::npos) { - jid += "@"; - jid += lm_connection_get_server(this->_sm->session_data->connection); - } - - if (jid.find("/", 0) == Glib::ustring::npos) { - jid += "/" + static_cast< Glib::ustring >(RESOURCE_NAME); - } - - g_log(NULL, G_LOG_LEVEL_DEBUG, "Full JID is %s", jid.c_str()); - - Glib::ustring msg = String::ucompose(_("Sending whiteboard invitation to <b>%1</b>"), jid); - this->_sm->desktop()->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.data()); - if (this->_sfsbox.isSelected()) { - this->_sm->session_data->sessionFile = this->_sfsbox.getFilename(); - } else { - this->_sm->session_data->sessionFile.clear(); - } - this->_sm->sendRequestToUser(jid); - this->hide(); - break; - } - - case CANCEL: - this->hide(); - break; - - default: - break; - } -} - -void -WhiteboardShareWithUserDialogImpl::_listCallback() -{ - Glib::RefPtr< Gtk::TreeSelection > sel = this->_buddylist.get_selection(); - - typedef Gtk::TreeModel::Children type_children; - type_children::iterator row = sel->get_selected(); - this->_jid.set_text((*row).get_value(this->_blm.jid)); -} - -} - -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/whiteboard-sharewithuser.h b/src/ui/dialog/whiteboard-sharewithuser.h deleted file mode 100644 index 24ec91be5..000000000 --- a/src/ui/dialog/whiteboard-sharewithuser.h +++ /dev/null @@ -1,110 +0,0 @@ -/** @file - * @brief Whiteboard share with user dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_SHAREWITHUSER_DIALOG_H__ -#define __WHITEBOARD_SHAREWITHUSER_DIALOG_H__ - -#include <gtkmm/liststore.h> -#include <gtkmm/treeview.h> -#include <gtkmm/scrolledwindow.h> - -#include "verbs.h" -#include "ui/dialog/dialog.h" -#include "jabber_whiteboard/session-file-selector.h" - - -struct SPDesktop; - -namespace Inkscape { - namespace Whiteboard { - class SessionManager; - } - namespace UI { - namespace Dialog { - -class WhiteboardShareWithUserDialog : public Dialog { -public: - WhiteboardShareWithUserDialog() : Dialog("/dialogs/whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER) - { - - } - - static WhiteboardShareWithUserDialog* create(); - - virtual ~WhiteboardShareWithUserDialog() - { - - } -}; - -class WhiteboardShareWithUserDialogImpl : public WhiteboardShareWithUserDialog { -public: - WhiteboardShareWithUserDialogImpl(); - ~WhiteboardShareWithUserDialogImpl(); - void setSessionManager(); - -private: - // Response flags - static unsigned int const SHARE = 0; - static unsigned int const CANCEL = 2; - - // GTK+ widgets - Gtk::HBox _connecttojidbox; - Gtk::HBox _buddylistbox; - Gtk::HBox _buttons; - - Whiteboard::SessionFileSelectorBox _sfsbox; - - Gtk::Entry _jid; - - // more or less shamelessly stolen from gtkmm tutorial book - Glib::RefPtr< Gtk::ListStore > _buddylistdata; - Gtk::TreeView _buddylist; - class BuddyListModel : public Gtk::TreeModel::ColumnRecord { - public: - BuddyListModel() - { - add(jid); - } - - Gtk::TreeModelColumn< std::string > jid; - }; - BuddyListModel _blm; - - Gtk::Label _labels[2]; - Gtk::ScrolledWindow _listwindow; - - Gtk::Button _share, _cancel; - - // Construction and callback - void _construct(); - void _respCallback(int resp); - void _listCallback(); - - // Buddy list management - void _fillBuddyList(); - void _insertBuddy(std::string const& jid); - void _eraseBuddy(std::string const& jid); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; -}; - - -} - -} - -} - -#endif -- cgit v1.2.3 From 6d8cf6aca31bcdd14a334d6c8861920634fb61a5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Thu, 23 Jun 2011 16:37:43 +0200 Subject: Remove the dom/work directory (bzr r10347) --- src/dom/work/001.css | 214 -- src/dom/work/Idlp.java | 394 --- src/dom/work/Main.java | 15 - src/dom/work/acid.css | 110 - src/dom/work/base.css | 32 - src/dom/work/css.idl | 633 ---- src/dom/work/cssprop.txt | 123 - src/dom/work/dom.idl | 548 ---- src/dom/work/events.idl | 298 -- src/dom/work/idl.g | 1386 --------- src/dom/work/inkscape.css | 493 --- src/dom/work/ls.idl | 171 - src/dom/work/meyerweb.css | 181 -- src/dom/work/prop-css.txt | 1082 ------- src/dom/work/prop-svg.txt | 651 ---- src/dom/work/ranges.idl | 122 - src/dom/work/sandb1.css | 149 - src/dom/work/smil.idl | 369 --- src/dom/work/stylesheets.idl | 71 - src/dom/work/svg.idl | 1751 ----------- src/dom/work/svg2.cpp | 7049 ------------------------------------------ src/dom/work/testdom.cpp | 107 - src/dom/work/testhttp.cpp | 82 - src/dom/work/testjs.cpp | 128 - src/dom/work/testodf.cpp | 98 - src/dom/work/testsvg.cpp | 80 - src/dom/work/testuri.cpp | 117 - src/dom/work/testxpath.cpp | 1434 --------- src/dom/work/testzip.cpp | 65 - src/dom/work/traversal.idl | 102 - src/dom/work/views.idl | 38 - src/dom/work/xpath.idl | 115 - src/dom/work/xpathtests.cpp | 1290 -------- 33 files changed, 19498 deletions(-) delete mode 100644 src/dom/work/001.css delete mode 100644 src/dom/work/Idlp.java delete mode 100644 src/dom/work/Main.java delete mode 100644 src/dom/work/acid.css delete mode 100644 src/dom/work/base.css delete mode 100644 src/dom/work/css.idl delete mode 100644 src/dom/work/cssprop.txt delete mode 100644 src/dom/work/dom.idl delete mode 100644 src/dom/work/events.idl delete mode 100644 src/dom/work/idl.g delete mode 100644 src/dom/work/inkscape.css delete mode 100644 src/dom/work/ls.idl delete mode 100644 src/dom/work/meyerweb.css delete mode 100644 src/dom/work/prop-css.txt delete mode 100644 src/dom/work/prop-svg.txt delete mode 100644 src/dom/work/ranges.idl delete mode 100644 src/dom/work/sandb1.css delete mode 100644 src/dom/work/smil.idl delete mode 100644 src/dom/work/stylesheets.idl delete mode 100644 src/dom/work/svg.idl delete mode 100644 src/dom/work/svg2.cpp delete mode 100644 src/dom/work/testdom.cpp delete mode 100644 src/dom/work/testhttp.cpp delete mode 100644 src/dom/work/testjs.cpp delete mode 100644 src/dom/work/testodf.cpp delete mode 100644 src/dom/work/testsvg.cpp delete mode 100644 src/dom/work/testuri.cpp delete mode 100644 src/dom/work/testxpath.cpp delete mode 100644 src/dom/work/testzip.cpp delete mode 100644 src/dom/work/traversal.idl delete mode 100644 src/dom/work/views.idl delete mode 100644 src/dom/work/xpath.idl delete mode 100644 src/dom/work/xpathtests.cpp (limited to 'src') diff --git a/src/dom/work/001.css b/src/dom/work/001.css deleted file mode 100644 index 6f07bc312..000000000 --- a/src/dom/work/001.css +++ /dev/null @@ -1,214 +0,0 @@ -/* css Zen Garden default style - 'Tranquille' by Dave Shea - http://www.mezzoblue.com/ */ -/* css released under Creative Commons License - http://creativecommons.org/licenses/by-nc-sa/1.0/ */ -/* All associated graphics copyright 2003, Dave Shea */ -/* Added: May 7th, 2003 */ - - -/* IMPORTANT */ -/* This design is not a template. You may not reproduce it elsewhere without the - designer's written permission. However, feel free to study the CSS and use - techniques you learn from it elsewhere. */ - - -/* The Zen Garden default was the first I put together, and almost didn't make the cut. I briefly flirted with using - 'Salmon Cream Cheese' as the main style for the Garden, but switched back to this one before launch. - - All graphics in this design were illustrated by me in Photoshop. Google Image Search provided inspiration for - some of the elements. I did a bit of research on Kanji to come up with the characters on the top left. Anyone who - can read that will most likely tell you it makes no sense, but the best I could do was putting together the - characters for 'beginning' 'complete' and 'skill' to roughly say something like 'we're breaking fresh ground.' - - It's a stretch. */ - - -/* basic elements */ -html { - margin: 0px; - padding: 0px; - } -body { - font: 9pt/17pt georgia; - color: #555753; - background: #fff url(/001/blossoms.jpg) no-repeat bottom right; - margin: 0px; - padding: 0px; - } -p { - font: 9pt/17pt georgia; - margin-top: 0px; - text-align: justify; - } -h3 { - font: italic normal 12pt georgia; - letter-spacing: 1px; - margin-bottom: 0px; - color: #7D775C; - } -a:link { - font-weight: bold; - text-decoration: none; - color: #B7A5DF; - } -a:visited { - font-weight: bold; - text-decoration: none; - color: #D4CDDC; - } -a:hover, a:active { - text-decoration: underline; - color: #9685BA; - } -acronym { - border-bottom: none; - } - - -/* specific divs */ -#container { - background: url(/001/zen-bg.jpg) no-repeat top left; - padding: 0px 175px 0px 110px; - margin: 0px; - position: absolute; - top: 0px; - left: 0px; - } - -#intro { - min-width: 470px; - } -#pageHeader { - margin-bottom: 20px; - } - -/* using an image to replace text in an h1. This trick courtesy Douglas Bowman, http://www.stopdesign.com/articles/css/replace-text/ */ -#pageHeader h1 { - background: transparent url(/001/h1.gif) no-repeat top left; - margin-top: 10px; - width: 219px; - height: 87px; - float: left; - } -#pageHeader h1 span { - display:none - } -#pageHeader h2 { - background: transparent url(/001/h2.gif) no-repeat top left; - margin-top: 58px; - margin-bottom: 40px; - width: 200px; - height: 18px; - float: right; - } -#pageHeader h2 span { - display:none - } - -#quickSummary { - clear:both; - margin: 20px 20px 20px 10px; - width: 160px; - float: left; - } -#quickSummary p { - font: italic 10pt/22pt georgia; - text-align:center; - } - -#preamble { - clear: right; - padding: 0px 10px 0px 10px; - } -#supportingText { - padding-left: 10px; - margin-bottom: 40px; - } - -#footer { - text-align: center; - } -#footer a:link, #footer a:visited { - margin-right: 20px; - } - -#linkList { - margin-left: 600px; - position: absolute; - top: 0px; - right: 0px; - } -#linkList2 { - font: 10px verdana, sans-serif; - background: transparent url(/001/paper-bg.jpg) top left repeat-y; - padding: 10px; - margin-top: 150px; - width: 130px; - } -#linkList h3.select { - background: transparent url(/001/h3.gif) no-repeat top left; - margin: 10px 0px 5px 0px; - width: 97px; - height: 16px; - } -#linkList h3.select span { - display:none - } -#linkList h3.favorites { - background: transparent url(/001/h4.gif) no-repeat top left; - margin: 25px 0px 5px 0px; - width: 60px; - height: 18px; - } -#linkList h3.favorites span { - display:none - } -#linkList h3.archives { - background: transparent url(/001/h5.gif) no-repeat top left; - margin: 25px 0px 5px 0px; - width:57px; - height: 14px; - } -#linkList h3.archives span { - display:none - } -#linkList h3.resources { - background: transparent url(/001/h6.gif) no-repeat top left; - margin: 25px 0px 5px 0px; - width:63px; - height: 10px; - } -#linkList h3.resources span { - display:none - } - - -#linkList ul { - margin: 0px; - padding: 0px; - } -#linkList li { - line-height: 2.5ex; - background: transparent url(/001/cr1.gif) no-repeat top center; - display: block; - padding-top: 5px; - margin-bottom: 5px; - list-style-type: none; - } -#linkList li a:link { - color: #988F5E; - } -#linkList li a:visited { - color: #B3AE94; - } - - -#extraDiv1 { - background: transparent url(/001/cr2.gif) top left no-repeat; - position: absolute; - top: 40px; - right: 0px; - width: 148px; - height: 110px; - } -.accesskey { - text-decoration: underline; - } \ No newline at end of file diff --git a/src/dom/work/Idlp.java b/src/dom/work/Idlp.java deleted file mode 100644 index 2f45cf175..000000000 --- a/src/dom/work/Idlp.java +++ /dev/null @@ -1,394 +0,0 @@ -import java.io.*; -import java.util.*; - - -public class Idlp -{ -String parsebuf; -int len; - - -void error(String msg) -{ - System.out.println("Idlp err : " + msg); -} - -void trace(String msg) -{ - System.out.println("Idlp : " + msg); -} - - - - - - -int get(int pos) -{ - if (pos<0 || pos>=len) - return -1; - else - return (int) parsebuf.charAt(pos); -} - - -int skipwhite(int pos) -{ - trace("skipwhite()"); - while (pos < len) - { - int ch = get(pos); - if (ch == '/' && get(pos + 1) == '/') - { - pos += 2; - while (pos < len) - { - ch = get(pos); - if (ch == '\n' || ch == '\r') - break; - pos++; - } - } - else if (!Character.isWhitespace(ch)) - { - break; - } - pos++; - } - return pos; -} - -boolean match(String key) -{ - trace("match(" + key + ")"); - int p = 0; - for (int i=0 ; i<key.length() ; i++) - { - if (get(p) != key.charAt(i)) - return false; - p++; - } - return true; - -} - -String word = ""; - -int getword(int pos) -{ - trace("getword()"); - StringBuffer buf = new StringBuffer(); - while (pos < len) - { - int ch = get(pos); - if (ch < 0) - break; - if (!Character.isLetterOrDigit(ch) && ch != '#' && ch != '_') - break; - buf.append((char)ch); - pos++; - } - word = buf.toString(); - return pos; -} - -int getDirective(String name, int pos) -{ - trace("getDirective()"); - if (name.length() == 0 || name.charAt(0) != '#') - return -1; - while (pos < len) - { - int ch = get(pos); - if (ch == '\n' || ch == '\r') - break; - pos++; - } - return pos; -} - -int getTypedef(int pos) -{ - trace("getTypedef()"); - while (pos < len) - { - int ch = get(pos++); - if (ch == ';') - break; - } - return pos; -} - - -int getInterface(int pos) -{ - trace("getInterface()"); - pos = skipwhite(pos); - int p = getword(pos); - if (p < 0) - return -1; - if (p <= pos) - { - error("expected interface name"); - return -1; - } - String intfName = word; - trace("intf: " + intfName); - pos = p; - pos = skipwhite(pos); - int ch = get(pos); - if (ch == ';') - { - pos++; //forward decl - trace("forward decl"); - return pos; - } - if (ch != '{') - { - error("Expected opening { for interface"); - return -1; - } - pos++; - while (true) - { - pos = skipwhite(pos); - ch = get(pos); - if (ch == '}') - { - break; - } - p = getword(pos); - if (p < 0) - { - return -1; - } - if (p<=pos) - { - error("expected word"); - return -1; - } - trace("word : " + word); - if (word.equals("typedef")) - { - pos = p; - p = getTypedef(pos); - if (p < 0) - return -1; - } - pos = p; - } - - return pos; -} - - -int getException(int pos) -{ - trace("getException()"); - pos = skipwhite(pos); - int p = getword(pos); - if (p < 0) - return -1; - if (p <= pos) - { - error("expected exception name"); - return -1; - } - String exName = word; - trace("ex: " + exName); - pos = p; - pos = skipwhite(pos); - int ch = get(pos); - if (ch == ';') - { - pos++; //forward decl - trace("forward decl"); - return pos; - } - if (ch != '{') - { - error("Expected opening { for exception"); - return -1; - } - pos++; - while (pos < len) - { - ch = get(pos++); - if (ch == '}') - { - break; - } - } - pos = skipwhite(pos); - ch = get(pos); - if (ch != ';') - { - error("expected ; for exception"); - return -1; - } - pos++; - return pos; -} - - - -int getModule(int pos) -{ - trace("getModule()"); - pos = skipwhite(pos); - int p = getword(pos); - if (p < 0) - return -1; - if (p <= pos) - { - error("expected module name"); - return -1; - } - String modName = word; - trace("mod: " + modName); - pos = p; - pos = skipwhite(pos); - int ch = get(pos); - if (ch != '{') - { - error("Expected opening { for module"); - return -1; - } - pos++; - while (true) - { - pos = skipwhite(pos); - ch = get(pos); - if (ch == '}') - { - break; - } - p = getword(pos); - if (p < 0) - { - return -1; - } - if (p<=pos) - { - error("expected word"); - return -1; - } - trace("word : " + word); - if (word.equals("typedef")) - { - pos = p; - p = getTypedef(pos); - if (p < 0) - return -1; - } - else if (word.equals("interface")) - { - pos = p; - p = getInterface(pos); - if (p < 0) - return -1; - } - else if (word.equals("exception")) - { - pos = p; - p = getException(pos); - if (p < 0) - return -1; - } - else if (word.equals("module")) - { - pos = p; - p = getModule(pos); - if (p < 0) - return -1; - } - pos = p; - } - - return pos; -} - -boolean parse() -{ - trace("parse()"); - len = parsebuf.length(); - int pos = 0; - while (pos < len) - { - pos = skipwhite(pos); - if (pos >= len) - break; - int ch = get(pos); - int p = getword(pos); - if (p < 0) - return false; - if (p<=pos) - { - error("expected word"); - return false; - } - trace("word: " + word); - if (word.length() == 0) - break; - if (word.charAt(0) == '#') - { - p = getDirective(word, pos); - if (p < 0) - return false; - } - else if (word.equals("module")) - { - pos = p; - p = getModule(pos); - if (p<0) - return false; - } - pos = p; - } - - return true; -} - - -boolean run() -{ - parsebuf = ""; - boolean ret = true; - try - { - StringBuffer inbuf = new StringBuffer(); - FileReader in = new FileReader("svg.idl"); - while (true) - { - int ch = in.read(); - if (ch < 0) - break; - inbuf.append((char)ch); - } - in.close(); - parsebuf = inbuf.toString(); - ret = parse(); - } - catch (IOException e) - { - error("run : " + e); - return false; - } - return ret; -} - - -public Idlp() -{ -} - - -public static void main(String argv[]) -{ - Idlp idlp = new Idlp(); - idlp.run(); -} - - - -} diff --git a/src/dom/work/Main.java b/src/dom/work/Main.java deleted file mode 100644 index d4d9177d3..000000000 --- a/src/dom/work/Main.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.io.*; -import antlr.*; - -public class Main { - public static void main(String[] args) { - try { - IDLLexer lexer = new IDLLexer(new DataInputStream(System.in)); - IDLParser parser = new IDLParser(lexer); - parser.specification(); - } catch(Exception e) { - System.err.println("exception: "+e); - } - } -} - diff --git a/src/dom/work/acid.css b/src/dom/work/acid.css deleted file mode 100644 index 7ea8750f5..000000000 --- a/src/dom/work/acid.css +++ /dev/null @@ -1,110 +0,0 @@ - /* section numbers refer to CSS2.1 */ - - /* page setup */ - html { font: 12px sans-serif; margin: 0; padding: 0; overflow: hidden; /* hides scrollbars on viewport, see 11.1.1:3 */ background: white; color: red; } - body { margin: 0; padding: 0; } - - /* introduction message */ - .intro { font: 2em sans-serif; margin: 3.5em 2em; padding: 0.5em; border: solid thin; background: white; color: black; position: relative; z-index: 2; /* should cover the black and red bars that are fixed-positioned */ } - .intro * { font: inherit; margin: 0; padding: 0; } - .intro h1 { font-size: 1em; font-weight: bolder; margin: 0; padding: 0; } - .intro :link { color: blue; } - .intro :visited { color: purple; } - - /* picture setup */ - #top { margin: 100em 3em 0; padding: 2em 0 0 .5em; text-align: left; font: 2em/24px sans-serif; color: navy; white-space: pre; } /* "Hello World!" text */ - .picture { position: relative; border: 1em solid transparent; margin: 0 0 100em 3em; } /* containing block for face */ - .picture { background: red; } /* overriden by preferred stylesheet below */ - - /* top line of face (scalp): fixed positioning and min/max height/width */ - .picture p { position: fixed; margin: 0; padding: 0; border: 0; top: 9em; left: 11em; width: 140%; max-width: 4em; height: 8px; min-height: 1em; max-height: 2mm; /* min-height overrides max-height, see 10.7 */ background: black; border-bottom: 0.5em yellow solid; } - - /* bits that shouldn't be part of the top line (and shouldn't be visible at all): HTML parsing, "+" combinator, stacking order */ - .picture p.bad { border-bottom: red solid; /* shouldn't matter, because the "p + table + p" rule below should match it too, thus hiding it */ } - .picture p + p { background: maroon; z-index: 1; } /* shouldn't match anything */ - .picture p + table + p { margin-top: 3em; /* should end up under the absolutely positioned table below, and thus not be visible */ } - - /* second line of face: attribute selectors, float positioning */ - [class~=one].first.one { position: absolute; top: 0; margin: 36px 0 0 60px; padding: 0; border: black 2em; border-style: none solid; /* shrink wraps around float */ } - [class~=one][class~=first] [class=second\ two][class="second two"] { float: right; width: 48px; height: 12px; background: yellow; margin: 0; padding: 0; } /* only content of abs pos block */ - - /* third line of face: width and overflow */ - .forehead { margin: 4em; width: 8em; border-left: solid black 1em; border-right: solid black 1em; background: red url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4%2F58BAAT%2FAf9jgNErAAAAAElFTkSuQmCC); /* that's a 1x1 yellow pixel PNG */ } - .forehead * { width: 12em; line-height: 1em; } - - /* class selectors headache */ - .two.error.two { background: maroon; } /* shouldn't match */ - .forehead.error.forehead { background: red; } /* shouldn't match */ - [class=second two] { background: red; } /* this should be ignored (invalid selector -- grammar says it only accepts IDENTs or STRINGs) */ - - /* fourth and fifth lines of face, with eyes: paint order test (see appendix E) and fixed backgrounds */ - /* the two images are identical: 2-by-2 squares with the top left - and bottom right pixels set to yellow and the other two set to - transparent. Since they are offset by one pixel from each other, - the second one paints exactly over the transparent parts of the - first one, thus creating a solid yellow block. */ - .eyes { position: absolute; top: 5em; left: 3em; margin: 0; padding: 0; background: red; } - #eyes-a { height: 0; line-height: 2em; text-align: right; } /* contents should paint top-most because they're inline */ - #eyes-a object { display: inline; vertical-align: bottom; } - #eyes-a object[type] { width: 7.5em; height: 2.5em; } /* should have no effect since that object should fallback to being inline (height/width don't apply to inlines) */ - #eyes-a object object object { border-right: solid 1em black; padding: 0 12px 0 11px; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABnRSTlMAAAAAAABupgeRAAAABmJLR0QA%2FwD%2FAP%2BgvaeTAAAAEUlEQVR42mP4%2F58BCv7%2FZwAAHfAD%2FabwPj4AAAAASUVORK5CYII%3D) fixed 1px 0; } - #eyes-b { float: left; width: 10em; height: 2em; background: fixed url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABnRSTlMAAAAAAABupgeRAAAABmJLR0QA%2FwD%2FAP%2BgvaeTAAAAEUlEQVR42mP4%2F58BCv7%2FZwAAHfAD%2FabwPj4AAAAASUVORK5CYII%3D); border-left: solid 1em black; border-right: solid 1em red; } /* should paint in the middle layer because it is a float */ - #eyes-c { display: block; background: red; border-left: 2em solid yellow; width: 10em; height: 2em; } /* should paint bottom most because it is a block */ - - /* lines six to nine, with nose: auto margins */ - .nose { float: left; margin: -2em 2em -1em; border: solid 1em black; border-top: 0; min-height: 80%; height: 60%; max-height: 3em; /* percentages become auto (see 10.5 and 10.7) and intrinsic height is more than 3em, so 3em wins */ padding: 0; width: 12em; } - .nose > div { padding: 1em 1em 3em; height: 0; background: yellow; } - .nose div div { width: 2em; height: 2em; background: red; margin: auto; } - .nose :hover div { border-color: blue; } - .nose div:hover :before { border-bottom-color: inherit; } - .nose div:hover :after { border-top-color: inherit; } - .nose div div:before { display: block; border-style: none solid solid; border-color: red yellow black yellow; border-width: 1em; content: ''; height: 0; } - .nose div :after { display: block; border-style: solid solid none; border-color: black yellow red yellow; border-width: 1em; content: ''; height: 0; } - - /* between lines nine and ten: margin collapsing with 'float' and 'clear' */ - .empty { margin: 6.25em; height: 10%; /* computes to auto which makes it empty per 8.3.1:7 (own margins) */ } - .empty div { margin: 0 2em -6em 4em; } - .smile { margin: 5em 3em; clear: both; /* clearance is negative (see 8.3.1 and 9.5.1) */ } - - /* line ten and eleven: containing block for abs pos */ - .smile div { margin-top: 0.25em; background: black; width: 12em; height: 2em; position: relative; bottom: -1em; } - .smile div div { position: absolute; top: 0; right: 1em; width: auto; height: 0; margin: 0; border: yellow solid 1em; } - - /* smile (over lines ten and eleven): backgrounds behind borders, inheritance of 'float', nested floats, negative heights */ - .smile div div span { display: inline; margin: -1em 0 0 0; border: solid 1em transparent; border-style: none solid; float: right; background: black; height: 1em; } - .smile div div span em { float: inherit; border-top: solid yellow 1em; border-bottom: solid black 1em; } /* zero-height block; width comes from (zero-height) child. */ - .smile div div span em strong { width: 6em; display: block; margin-bottom: -1em; /* should have no effect, since parent has top&bottom borders, so this margin doesn't collapse */ } - - /* line twelve: line-height */ - .chin { margin: -4em 4em 0; width: 8em; line-height: 1em; border-left: solid 1em black; border-right: solid 1em black; background: yellow url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAFSDNYfAAAAaklEQVR42u3XQQrAIAwAQeP%2F%2F6wf8CJBJTK9lnQ7FpHGaOurt1I34nfH9pMMZAZ8BwMGEvvh%2BBsJCAgICLwIOA8EBAQEBAQEBAQEBK79H5RfIQAAAAAAAAAAAAAAAAAAAAAAAAAAAID%2FABMSqAfj%2FsLmvAAAAABJRU5ErkJggg%3D%3D) /* 64x64 red square */ no-repeat fixed /* shouldn't be visible unless the smiley is moved to the top left of the viewport */; } - .chin div { display: inline; font: 2px/4px serif; } - - /* line thirteen: cascade and selector tests */ - .parser-container div { color: maroon; border: solid; color: orange; } /* setup */ - div.parser-container * { border-color: black; /* overrides (implied) border-color on previous line */ } /* setup */ - * div.parser { border-width: 0 2em; /* overrides (implied) declarations on earlier line */ } /* setup */ - - /* line thirteen continued: parser tests */ - .parser { /* comment parsing test -- comment ends before the end of this line, the backslash should have no effect: \*/ } - .parser { margin: 0 5em 1em; padding: 0 1em; width: 2em; height: 1em; error: \}; background: yellow; } /* setup with parsing test */ - * html .parser { background: gray; } - \.parser { padding: 2em; } - .parser { m\argin: 2em; }; - .parser { height: 3em; } - .parser { width: 200; } - .parser { border: 5em solid red ! error; } - .parser { background: red pink; } - - /* line fourteen (last line of face): table */ - ul { display: table; padding: 0; margin: -1em 7em 0; background: red; } - ul li { padding: 0; margin: 0; } - ul li.first-part { display: table-cell; height: 1em; width: 1em; background: black; } - ul li.second-part { display: table; height: 1em; width: 1em; background: black; } /* anonymous table cell wraps around this */ - ul li.third-part { display: table-cell; height: 0.5em; /* gets stretched to fit row */ width: 1em; background: black; } - ul li.fourth-part { list-style: none; height: 1em; width: 1em; background: black; } /* anonymous table cell wraps around this */ - - /* bits that shouldn't appear: inline alignment in cells */ - .image-height-test { height: 10px; overflow: hidden; font: 20em serif; } /* only the area between the top of the line box and the top of the image should be visible */ - table { margin: 0; border-spacing: 0; } - td { padding: 0; } - diff --git a/src/dom/work/base.css b/src/dom/work/base.css deleted file mode 100644 index 7176bbf94..000000000 --- a/src/dom/work/base.css +++ /dev/null @@ -1,32 +0,0 @@ -/* recover from old-browser styling */ - -*.oldbl {display: block !important;} -*.oldin {display: inline !important;} -*.ahem {display: none !important;} -img.pic {display: block !important;} - -/* NS6.x-specific fix(es) */ - -/*|*:-moz-list-bullet, *|*:-moz-list-number {font-size: 1em;}/ - -/* misc */ - -.skipper {display: none !important;} - -* {font-size: 100%;} -h1 {font-size: 2em;} -h2 {font-size: 1.5em;} -h3 {font-size: 1.33em;} -h4 {font-size: 1.1em;} -h5 {font-size: 0.9em;} -h6 {font-size: 0.75em;} -pre, code, tt {font: 95% "Andale Mono", Courier, "Courier New", monospace;} - -img.pic {float: right; margin: 0.25em 0 0.66em 1.5em;} -img.border {border: 3px double;} - -p.contact {margin: 0 1em !important; text-align: right; font-size: 90%;} - -#main {min-height: 30em;} -#header h1 a, #nav a {text-decoration: none;} -#nav {padding-top: 0.75em;} diff --git a/src/dom/work/css.idl b/src/dom/work/css.idl deleted file mode 100644 index 5033f901c..000000000 --- a/src/dom/work/css.idl +++ /dev/null @@ -1,633 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -// File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl - -#ifndef _CSS_IDL_ -#define _CSS_IDL_ - -#include "dom.idl" -#include "stylesheets.idl" -#include "views.idl" - -#pragma prefix "dom.w3c.org" -module css -{ - - typedef dom::DOMString DOMString; - typedef dom::Element Element; - typedef dom::DOMImplementation DOMImplementation; - - interface CSSRule; - interface CSSStyleSheet; - interface CSSStyleDeclaration; - interface CSSValue; - interface Counter; - interface Rect; - interface RGBColor; - - // Introduced in DOM Level 2: - interface CSSRuleList { - readonly attribute unsigned long length; - CSSRule item(in unsigned long index); - }; - - // Introduced in DOM Level 2: - interface CSSRule { - - // RuleType - const unsigned short UNKNOWN_RULE = 0; - const unsigned short STYLE_RULE = 1; - const unsigned short CHARSET_RULE = 2; - const unsigned short IMPORT_RULE = 3; - const unsigned short MEDIA_RULE = 4; - const unsigned short FONT_FACE_RULE = 5; - const unsigned short PAGE_RULE = 6; - - readonly attribute unsigned short type; - attribute DOMString cssText; - // raises(dom::DOMException) on setting - - readonly attribute CSSStyleSheet parentStyleSheet; - readonly attribute CSSRule parentRule; - }; - - // Introduced in DOM Level 2: - interface CSSStyleRule : CSSRule { - attribute DOMString selectorText; - // raises(dom::DOMException) on setting - - readonly attribute CSSStyleDeclaration style; - }; - - // Introduced in DOM Level 2: - interface CSSMediaRule : CSSRule { - readonly attribute stylesheets::MediaList media; - readonly attribute CSSRuleList cssRules; - unsigned long insertRule(in DOMString rule, - in unsigned long index) - raises(dom::DOMException); - void deleteRule(in unsigned long index) - raises(dom::DOMException); - }; - - // Introduced in DOM Level 2: - interface CSSFontFaceRule : CSSRule { - readonly attribute CSSStyleDeclaration style; - }; - - // Introduced in DOM Level 2: - interface CSSPageRule : CSSRule { - attribute DOMString selectorText; - // raises(dom::DOMException) on setting - - readonly attribute CSSStyleDeclaration style; - }; - - // Introduced in DOM Level 2: - interface CSSImportRule : CSSRule { - readonly attribute DOMString href; - readonly attribute stylesheets::MediaList media; - readonly attribute CSSStyleSheet styleSheet; - }; - - // Introduced in DOM Level 2: - interface CSSCharsetRule : CSSRule { - attribute DOMString encoding; - // raises(dom::DOMException) on setting - - }; - - // Introduced in DOM Level 2: - interface CSSUnknownRule : CSSRule { - }; - - // Introduced in DOM Level 2: - interface CSSStyleDeclaration { - attribute DOMString cssText; - // raises(dom::DOMException) on setting - - DOMString getPropertyValue(in DOMString propertyName); - CSSValue getPropertyCSSValue(in DOMString propertyName); - DOMString removeProperty(in DOMString propertyName) - raises(dom::DOMException); - DOMString getPropertyPriority(in DOMString propertyName); - void setProperty(in DOMString propertyName, - in DOMString value, - in DOMString priority) - raises(dom::DOMException); - readonly attribute unsigned long length; - DOMString item(in unsigned long index); - readonly attribute CSSRule parentRule; - }; - - // Introduced in DOM Level 2: - interface CSSValue { - - // UnitTypes - const unsigned short CSS_INHERIT = 0; - const unsigned short CSS_PRIMITIVE_VALUE = 1; - const unsigned short CSS_VALUE_LIST = 2; - const unsigned short CSS_CUSTOM = 3; - - attribute DOMString cssText; - // raises(dom::DOMException) on setting - - readonly attribute unsigned short cssValueType; - }; - - // Introduced in DOM Level 2: - interface CSSPrimitiveValue : CSSValue { - - // UnitTypes - const unsigned short CSS_UNKNOWN = 0; - const unsigned short CSS_NUMBER = 1; - const unsigned short CSS_PERCENTAGE = 2; - const unsigned short CSS_EMS = 3; - const unsigned short CSS_EXS = 4; - const unsigned short CSS_PX = 5; - const unsigned short CSS_CM = 6; - const unsigned short CSS_MM = 7; - const unsigned short CSS_IN = 8; - const unsigned short CSS_PT = 9; - const unsigned short CSS_PC = 10; - const unsigned short CSS_DEG = 11; - const unsigned short CSS_RAD = 12; - const unsigned short CSS_GRAD = 13; - const unsigned short CSS_MS = 14; - const unsigned short CSS_S = 15; - const unsigned short CSS_HZ = 16; - const unsigned short CSS_KHZ = 17; - const unsigned short CSS_DIMENSION = 18; - const unsigned short CSS_STRING = 19; - const unsigned short CSS_URI = 20; - const unsigned short CSS_IDENT = 21; - const unsigned short CSS_ATTR = 22; - const unsigned short CSS_COUNTER = 23; - const unsigned short CSS_RECT = 24; - const unsigned short CSS_RGBCOLOR = 25; - - readonly attribute unsigned short primitiveType; - void setFloatValue(in unsigned short unitType, - in float floatValue) - raises(dom::DOMException); - float getFloatValue(in unsigned short unitType) - raises(dom::DOMException); - void setStringValue(in unsigned short stringType, - in DOMString stringValue) - raises(dom::DOMException); - DOMString getStringValue() - raises(dom::DOMException); - Counter getCounterValue() - raises(dom::DOMException); - Rect getRectValue() - raises(dom::DOMException); - RGBColor getRGBColorValue() - raises(dom::DOMException); - }; - - // Introduced in DOM Level 2: - interface CSSValueList : CSSValue { - readonly attribute unsigned long length; - CSSValue item(in unsigned long index); - }; - - // Introduced in DOM Level 2: - interface RGBColor { - readonly attribute CSSPrimitiveValue red; - readonly attribute CSSPrimitiveValue green; - readonly attribute CSSPrimitiveValue blue; - }; - - // Introduced in DOM Level 2: - interface Rect { - readonly attribute CSSPrimitiveValue top; - readonly attribute CSSPrimitiveValue right; - readonly attribute CSSPrimitiveValue bottom; - readonly attribute CSSPrimitiveValue left; - }; - - // Introduced in DOM Level 2: - interface Counter { - readonly attribute DOMString identifier; - readonly attribute DOMString listStyle; - readonly attribute DOMString separator; - }; - - // Introduced in DOM Level 2: - interface ElementCSSInlineStyle { - readonly attribute CSSStyleDeclaration style; - }; - - // Introduced in DOM Level 2: - interface CSS2Properties { - attribute DOMString azimuth; - // raises(dom::DOMException) on setting - - attribute DOMString background; - // raises(dom::DOMException) on setting - - attribute DOMString backgroundAttachment; - // raises(dom::DOMException) on setting - - attribute DOMString backgroundColor; - // raises(dom::DOMException) on setting - - attribute DOMString backgroundImage; - // raises(dom::DOMException) on setting - - attribute DOMString backgroundPosition; - // raises(dom::DOMException) on setting - - attribute DOMString backgroundRepeat; - // raises(dom::DOMException) on setting - - attribute DOMString border; - // raises(dom::DOMException) on setting - - attribute DOMString borderCollapse; - // raises(dom::DOMException) on setting - - attribute DOMString borderColor; - // raises(dom::DOMException) on setting - - attribute DOMString borderSpacing; - // raises(dom::DOMException) on setting - - attribute DOMString borderStyle; - // raises(dom::DOMException) on setting - - attribute DOMString borderTop; - // raises(dom::DOMException) on setting - - attribute DOMString borderRight; - // raises(dom::DOMException) on setting - - attribute DOMString borderBottom; - // raises(dom::DOMException) on setting - - attribute DOMString borderLeft; - // raises(dom::DOMException) on setting - - attribute DOMString borderTopColor; - // raises(dom::DOMException) on setting - - attribute DOMString borderRightColor; - // raises(dom::DOMException) on setting - - attribute DOMString borderBottomColor; - // raises(dom::DOMException) on setting - - attribute DOMString borderLeftColor; - // raises(dom::DOMException) on setting - - attribute DOMString borderTopStyle; - // raises(dom::DOMException) on setting - - attribute DOMString borderRightStyle; - // raises(dom::DOMException) on setting - - attribute DOMString borderBottomStyle; - // raises(dom::DOMException) on setting - - attribute DOMString borderLeftStyle; - // raises(dom::DOMException) on setting - - attribute DOMString borderTopWidth; - // raises(dom::DOMException) on setting - - attribute DOMString borderRightWidth; - // raises(dom::DOMException) on setting - - attribute DOMString borderBottomWidth; - // raises(dom::DOMException) on setting - - attribute DOMString borderLeftWidth; - // raises(dom::DOMException) on setting - - attribute DOMString borderWidth; - // raises(dom::DOMException) on setting - - attribute DOMString bottom; - // raises(dom::DOMException) on setting - - attribute DOMString captionSide; - // raises(dom::DOMException) on setting - - attribute DOMString clear; - // raises(dom::DOMException) on setting - - attribute DOMString clip; - // raises(dom::DOMException) on setting - - attribute DOMString color; - // raises(dom::DOMException) on setting - - attribute DOMString content; - // raises(dom::DOMException) on setting - - attribute DOMString counterIncrement; - // raises(dom::DOMException) on setting - - attribute DOMString counterReset; - // raises(dom::DOMException) on setting - - attribute DOMString cue; - // raises(dom::DOMException) on setting - - attribute DOMString cueAfter; - // raises(dom::DOMException) on setting - - attribute DOMString cueBefore; - // raises(dom::DOMException) on setting - - attribute DOMString cursor; - // raises(dom::DOMException) on setting - - attribute DOMString direction; - // raises(dom::DOMException) on setting - - attribute DOMString display; - // raises(dom::DOMException) on setting - - attribute DOMString elevation; - // raises(dom::DOMException) on setting - - attribute DOMString emptyCells; - // raises(dom::DOMException) on setting - - attribute DOMString cssFloat; - // raises(dom::DOMException) on setting - - attribute DOMString font; - // raises(dom::DOMException) on setting - - attribute DOMString fontFamily; - // raises(dom::DOMException) on setting - - attribute DOMString fontSize; - // raises(dom::DOMException) on setting - - attribute DOMString fontSizeAdjust; - // raises(dom::DOMException) on setting - - attribute DOMString fontStretch; - // raises(dom::DOMException) on setting - - attribute DOMString fontStyle; - // raises(dom::DOMException) on setting - - attribute DOMString fontVariant; - // raises(dom::DOMException) on setting - - attribute DOMString fontWeight; - // raises(dom::DOMException) on setting - - attribute DOMString height; - // raises(dom::DOMException) on setting - - attribute DOMString left; - // raises(dom::DOMException) on setting - - attribute DOMString letterSpacing; - // raises(dom::DOMException) on setting - - attribute DOMString lineHeight; - // raises(dom::DOMException) on setting - - attribute DOMString listStyle; - // raises(dom::DOMException) on setting - - attribute DOMString listStyleImage; - // raises(dom::DOMException) on setting - - attribute DOMString listStylePosition; - // raises(dom::DOMException) on setting - - attribute DOMString listStyleType; - // raises(dom::DOMException) on setting - - attribute DOMString margin; - // raises(dom::DOMException) on setting - - attribute DOMString marginTop; - // raises(dom::DOMException) on setting - - attribute DOMString marginRight; - // raises(dom::DOMException) on setting - - attribute DOMString marginBottom; - // raises(dom::DOMException) on setting - - attribute DOMString marginLeft; - // raises(dom::DOMException) on setting - - attribute DOMString markerOffset; - // raises(dom::DOMException) on setting - - attribute DOMString marks; - // raises(dom::DOMException) on setting - - attribute DOMString maxHeight; - // raises(dom::DOMException) on setting - - attribute DOMString maxWidth; - // raises(dom::DOMException) on setting - - attribute DOMString minHeight; - // raises(dom::DOMException) on setting - - attribute DOMString minWidth; - // raises(dom::DOMException) on setting - - attribute DOMString orphans; - // raises(dom::DOMException) on setting - - attribute DOMString outline; - // raises(dom::DOMException) on setting - - attribute DOMString outlineColor; - // raises(dom::DOMException) on setting - - attribute DOMString outlineStyle; - // raises(dom::DOMException) on setting - - attribute DOMString outlineWidth; - // raises(dom::DOMException) on setting - - attribute DOMString overflow; - // raises(dom::DOMException) on setting - - attribute DOMString padding; - // raises(dom::DOMException) on setting - - attribute DOMString paddingTop; - // raises(dom::DOMException) on setting - - attribute DOMString paddingRight; - // raises(dom::DOMException) on setting - - attribute DOMString paddingBottom; - // raises(dom::DOMException) on setting - - attribute DOMString paddingLeft; - // raises(dom::DOMException) on setting - - attribute DOMString page; - // raises(dom::DOMException) on setting - - attribute DOMString pageBreakAfter; - // raises(dom::DOMException) on setting - - attribute DOMString pageBreakBefore; - // raises(dom::DOMException) on setting - - attribute DOMString pageBreakInside; - // raises(dom::DOMException) on setting - - attribute DOMString pause; - // raises(dom::DOMException) on setting - - attribute DOMString pauseAfter; - // raises(dom::DOMException) on setting - - attribute DOMString pauseBefore; - // raises(dom::DOMException) on setting - - attribute DOMString pitch; - // raises(dom::DOMException) on setting - - attribute DOMString pitchRange; - // raises(dom::DOMException) on setting - - attribute DOMString playDuring; - // raises(dom::DOMException) on setting - - attribute DOMString position; - // raises(dom::DOMException) on setting - - attribute DOMString quotes; - // raises(dom::DOMException) on setting - - attribute DOMString richness; - // raises(dom::DOMException) on setting - - attribute DOMString right; - // raises(dom::DOMException) on setting - - attribute DOMString size; - // raises(dom::DOMException) on setting - - attribute DOMString speak; - // raises(dom::DOMException) on setting - - attribute DOMString speakHeader; - // raises(dom::DOMException) on setting - - attribute DOMString speakNumeral; - // raises(dom::DOMException) on setting - - attribute DOMString speakPunctuation; - // raises(dom::DOMException) on setting - - attribute DOMString speechRate; - // raises(dom::DOMException) on setting - - attribute DOMString stress; - // raises(dom::DOMException) on setting - - attribute DOMString tableLayout; - // raises(dom::DOMException) on setting - - attribute DOMString textAlign; - // raises(dom::DOMException) on setting - - attribute DOMString textDecoration; - // raises(dom::DOMException) on setting - - attribute DOMString textIndent; - // raises(dom::DOMException) on setting - - attribute DOMString textShadow; - // raises(dom::DOMException) on setting - - attribute DOMString textTransform; - // raises(dom::DOMException) on setting - - attribute DOMString top; - // raises(dom::DOMException) on setting - - attribute DOMString unicodeBidi; - // raises(dom::DOMException) on setting - - attribute DOMString verticalAlign; - // raises(dom::DOMException) on setting - - attribute DOMString visibility; - // raises(dom::DOMException) on setting - - attribute DOMString voiceFamily; - // raises(dom::DOMException) on setting - - attribute DOMString volume; - // raises(dom::DOMException) on setting - - attribute DOMString whiteSpace; - // raises(dom::DOMException) on setting - - attribute DOMString widows; - // raises(dom::DOMException) on setting - - attribute DOMString width; - // raises(dom::DOMException) on setting - - attribute DOMString wordSpacing; - // raises(dom::DOMException) on setting - - attribute DOMString zIndex; - // raises(dom::DOMException) on setting - - }; - - // Introduced in DOM Level 2: - interface CSSStyleSheet : stylesheets::StyleSheet { - readonly attribute CSSRule ownerRule; - readonly attribute CSSRuleList cssRules; - unsigned long insertRule(in DOMString rule, - in unsigned long index) - raises(dom::DOMException); - void deleteRule(in unsigned long index) - raises(dom::DOMException); - }; - - // Introduced in DOM Level 2: - interface ViewCSS : views::AbstractView { - CSSStyleDeclaration getComputedStyle(in Element elt, - in DOMString pseudoElt); - }; - - // Introduced in DOM Level 2: - interface DocumentCSS : stylesheets::DocumentStyle { - CSSStyleDeclaration getOverrideStyle(in Element elt, - in DOMString pseudoElt); - }; - - // Introduced in DOM Level 2: - interface DOMImplementationCSS : DOMImplementation { - CSSStyleSheet createCSSStyleSheet(in DOMString title, - in DOMString media) - raises(dom::DOMException); - }; -}; - -#endif // _CSS_IDL_ - diff --git a/src/dom/work/cssprop.txt b/src/dom/work/cssprop.txt deleted file mode 100644 index 36832f42b..000000000 --- a/src/dom/work/cssprop.txt +++ /dev/null @@ -1,123 +0,0 @@ -azimuth -background -backgroundAttachment -backgroundColor -backgroundImage -backgroundPosition -backgroundRepeat -border -borderCollapse -borderColor -borderSpacing -borderStyle -borderTop -borderRight -borderBottom -borderLeft -borderTopColor -borderRightColor -borderBottomColor -borderLeftColor -borderTopStyle -borderRightStyle -borderBottomStyle -borderLeftStyle -borderTopWidth -borderRightWidth -borderBottomWidth -borderLeftWidth -borderWidth -bottom -captionSide -clear -clip -color -content -counterIncrement -counterReset -cue -cueAfter -cueBefore -cursor -direction -display -elevation -emptyCells -cssFloat -font -fontFamily -fontSize -fontSizeAdjust -fontStretch -fontStyle -fontVariant -fontWeight -height -left -letterSpacing -lineHeight -listStyle -listStyleImage -listStylePosition -listStyleType -margin -marginTop -marginRight -marginBottom -marginLeft -markerOffset -marks -maxHeight -maxWidth -minHeight -minWidth -orphans -outline -outlineColor -outlineStyle -outlineWidth -overflow -padding -paddingTop -paddingRight -paddingBottom -paddingLeft -page -pageBreakAfter -pageBreakBefore -pageBreakInside -pause -pauseAfter -pauseBefore -pitch -pitchRange -playDuring -position -quotes -richness -right -size -speak -speakHeader -speakNumeral -speakPunctuation -speechRate -stress -tableLayout -textAlign -textDecoration -textIndent -textShadow -textTransform -top -unicodeBidi -verticalAlign -visibility -voiceFamily -volume -whiteSpace -widows -width -wordSpacing -zIndex - diff --git a/src/dom/work/dom.idl b/src/dom/work/dom.idl deleted file mode 100644 index 4c9dcbfe2..000000000 --- a/src/dom/work/dom.idl +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, - * - * (Massachusetts Institute of Technology, European Research Consortium for - * Informatics and Mathematics, Keio University). All Rights Reserved. This - * work is distributed under the W3C(r) Software License [1] in the hope that - * it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 - */ - -// File: http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/dom.idl - -#ifndef _DOM_IDL_ -#define _DOM_IDL_ - -#pragma prefix "w3c.org" -module dom -{ - - valuetype DOMString sequence<unsigned short>; - - typedef unsigned long long DOMTimeStamp; - - typedef any DOMUserData; - - typedef Object DOMObject; - - interface DOMImplementation; - interface DocumentType; - interface Document; - interface NodeList; - interface NamedNodeMap; - interface UserDataHandler; - interface Element; - interface TypeInfo; - interface DOMLocator; - - exception DOMException { - unsigned short code; - }; - // ExceptionCode - const unsigned short INDEX_SIZE_ERR = 1; - const unsigned short DOMSTRING_SIZE_ERR = 2; - const unsigned short HIERARCHY_REQUEST_ERR = 3; - const unsigned short WRONG_DOCUMENT_ERR = 4; - const unsigned short INVALID_CHARACTER_ERR = 5; - const unsigned short NO_DATA_ALLOWED_ERR = 6; - const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; - const unsigned short NOT_FOUND_ERR = 8; - const unsigned short NOT_SUPPORTED_ERR = 9; - const unsigned short INUSE_ATTRIBUTE_ERR = 10; - // Introduced in DOM Level 2: - const unsigned short INVALID_STATE_ERR = 11; - // Introduced in DOM Level 2: - const unsigned short SYNTAX_ERR = 12; - // Introduced in DOM Level 2: - const unsigned short INVALID_MODIFICATION_ERR = 13; - // Introduced in DOM Level 2: - const unsigned short NAMESPACE_ERR = 14; - // Introduced in DOM Level 2: - const unsigned short INVALID_ACCESS_ERR = 15; - // Introduced in DOM Level 3: - const unsigned short VALIDATION_ERR = 16; - // Introduced in DOM Level 3: - const unsigned short TYPE_MISMATCH_ERR = 17; - - - // Introduced in DOM Level 3: - interface DOMStringList { - DOMString item(in unsigned long index); - readonly attribute unsigned long length; - boolean contains(in DOMString str); - }; - - // Introduced in DOM Level 3: - interface NameList { - DOMString getName(in unsigned long index); - DOMString getNamespaceURI(in unsigned long index); - readonly attribute unsigned long length; - boolean contains(in DOMString str); - boolean containsNS(in DOMString namespaceURI, - in DOMString name); - }; - - // Introduced in DOM Level 3: - interface DOMImplementationList { - DOMImplementation item(in unsigned long index); - readonly attribute unsigned long length; - }; - - // Introduced in DOM Level 3: - interface DOMImplementationSource { - DOMImplementation getDOMImplementation(in DOMString features); - DOMImplementationList getDOMImplementationList(in DOMString features); - }; - - interface DOMImplementation { - boolean hasFeature(in DOMString feature, - in DOMString version); - // Introduced in DOM Level 2: - DocumentType createDocumentType(in DOMString qualifiedName, - in DOMString publicId, - in DOMString systemId) - raises(DOMException); - // Introduced in DOM Level 2: - Document createDocument(in DOMString namespaceURI, - in DOMString qualifiedName, - in DocumentType doctype) - raises(DOMException); - // Introduced in DOM Level 3: - DOMObject getFeature(in DOMString feature, - in DOMString version); - }; - - interface Node { - - // NodeType - const unsigned short ELEMENT_NODE = 1; - const unsigned short ATTRIBUTE_NODE = 2; - const unsigned short TEXT_NODE = 3; - const unsigned short CDATA_SECTION_NODE = 4; - const unsigned short ENTITY_REFERENCE_NODE = 5; - const unsigned short ENTITY_NODE = 6; - const unsigned short PROCESSING_INSTRUCTION_NODE = 7; - const unsigned short COMMENT_NODE = 8; - const unsigned short DOCUMENT_NODE = 9; - const unsigned short DOCUMENT_TYPE_NODE = 10; - const unsigned short DOCUMENT_FRAGMENT_NODE = 11; - const unsigned short NOTATION_NODE = 12; - - readonly attribute DOMString nodeName; - attribute DOMString nodeValue; - // raises(DOMException) on setting - // raises(DOMException) on retrieval - - readonly attribute unsigned short nodeType; - readonly attribute Node parentNode; - readonly attribute NodeList childNodes; - readonly attribute Node firstChild; - readonly attribute Node lastChild; - readonly attribute Node previousSibling; - readonly attribute Node nextSibling; - readonly attribute NamedNodeMap attributes; - // Modified in DOM Level 2: - readonly attribute Document ownerDocument; - // Modified in DOM Level 3: - Node insertBefore(in Node newChild, - in Node refChild) - raises(DOMException); - // Modified in DOM Level 3: - Node replaceChild(in Node newChild, - in Node oldChild) - raises(DOMException); - // Modified in DOM Level 3: - Node removeChild(in Node oldChild) - raises(DOMException); - // Modified in DOM Level 3: - Node appendChild(in Node newChild) - raises(DOMException); - boolean hasChildNodes(); - Node cloneNode(in boolean deep); - // Modified in DOM Level 3: - void normalize(); - // Introduced in DOM Level 2: - boolean isSupported(in DOMString feature, - in DOMString version); - // Introduced in DOM Level 2: - readonly attribute DOMString namespaceURI; - // Introduced in DOM Level 2: - attribute DOMString prefix; - // raises(DOMException) on setting - - // Introduced in DOM Level 2: - readonly attribute DOMString localName; - // Introduced in DOM Level 2: - boolean hasAttributes(); - // Introduced in DOM Level 3: - readonly attribute DOMString baseURI; - - // DocumentPosition - const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; - const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; - const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; - const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; - const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; - const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; - - // Introduced in DOM Level 3: - unsigned short compareDocumentPosition(in Node other) - raises(DOMException); - // Introduced in DOM Level 3: - attribute DOMString textContent; - // raises(DOMException) on setting - // raises(DOMException) on retrieval - - // Introduced in DOM Level 3: - boolean isSameNode(in Node other); - // Introduced in DOM Level 3: - DOMString lookupPrefix(in DOMString namespaceURI); - // Introduced in DOM Level 3: - boolean isDefaultNamespace(in DOMString namespaceURI); - // Introduced in DOM Level 3: - DOMString lookupNamespaceURI(in DOMString prefix); - // Introduced in DOM Level 3: - boolean isEqualNode(in Node arg); - // Introduced in DOM Level 3: - DOMObject getFeature(in DOMString feature, - in DOMString version); - // Introduced in DOM Level 3: - DOMUserData setUserData(in DOMString key, - in DOMUserData data, - in UserDataHandler handler); - // Introduced in DOM Level 3: - DOMUserData getUserData(in DOMString key); - }; - - interface NodeList { - Node item(in unsigned long index); - readonly attribute unsigned long length; - }; - - interface NamedNodeMap { - Node getNamedItem(in DOMString name); - Node setNamedItem(in Node arg) - raises(DOMException); - Node removeNamedItem(in DOMString name) - raises(DOMException); - Node item(in unsigned long index); - readonly attribute unsigned long length; - // Introduced in DOM Level 2: - Node getNamedItemNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 2: - Node setNamedItemNS(in Node arg) - raises(DOMException); - // Introduced in DOM Level 2: - Node removeNamedItemNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - }; - - interface CharacterData : Node { - attribute DOMString data; - // raises(DOMException) on setting - // raises(DOMException) on retrieval - - readonly attribute unsigned long length; - DOMString substringData(in unsigned long offset, - in unsigned long count) - raises(DOMException); - void appendData(in DOMString arg) - raises(DOMException); - void insertData(in unsigned long offset, - in DOMString arg) - raises(DOMException); - void deleteData(in unsigned long offset, - in unsigned long count) - raises(DOMException); - void replaceData(in unsigned long offset, - in unsigned long count, - in DOMString arg) - raises(DOMException); - }; - - interface Attr : Node { - readonly attribute DOMString name; - readonly attribute boolean specified; - attribute DOMString value; - // raises(DOMException) on setting - - // Introduced in DOM Level 2: - readonly attribute Element ownerElement; - // Introduced in DOM Level 3: - readonly attribute TypeInfo schemaTypeInfo; - // Introduced in DOM Level 3: - readonly attribute boolean isId; - }; - - interface Element : Node { - readonly attribute DOMString tagName; - DOMString getAttribute(in DOMString name); - void setAttribute(in DOMString name, - in DOMString value) - raises(DOMException); - void removeAttribute(in DOMString name) - raises(DOMException); - Attr getAttributeNode(in DOMString name); - Attr setAttributeNode(in Attr newAttr) - raises(DOMException); - Attr removeAttributeNode(in Attr oldAttr) - raises(DOMException); - NodeList getElementsByTagName(in DOMString name); - // Introduced in DOM Level 2: - DOMString getAttributeNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 2: - void setAttributeNS(in DOMString namespaceURI, - in DOMString qualifiedName, - in DOMString value) - raises(DOMException); - // Introduced in DOM Level 2: - void removeAttributeNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 2: - Attr getAttributeNodeNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 2: - Attr setAttributeNodeNS(in Attr newAttr) - raises(DOMException); - // Introduced in DOM Level 2: - NodeList getElementsByTagNameNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 2: - boolean hasAttribute(in DOMString name); - // Introduced in DOM Level 2: - boolean hasAttributeNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 3: - readonly attribute TypeInfo schemaTypeInfo; - // Introduced in DOM Level 3: - void setIdAttribute(in DOMString name, - in boolean isId) - raises(DOMException); - // Introduced in DOM Level 3: - void setIdAttributeNS(in DOMString namespaceURI, - in DOMString localName, - in boolean isId) - raises(DOMException); - // Introduced in DOM Level 3: - void setIdAttributeNode(in Attr idAttr, - in boolean isId) - raises(DOMException); - }; - - interface Text : CharacterData { - Text splitText(in unsigned long offset) - raises(DOMException); - // Introduced in DOM Level 3: - readonly attribute boolean isElementContentWhitespace; - // Introduced in DOM Level 3: - readonly attribute DOMString wholeText; - // Introduced in DOM Level 3: - Text replaceWholeText(in DOMString content) - raises(DOMException); - }; - - interface Comment : CharacterData { - }; - - // Introduced in DOM Level 3: - interface TypeInfo { - readonly attribute DOMString typeName; - readonly attribute DOMString typeNamespace; - - // DerivationMethods - const unsigned long DERIVATION_RESTRICTION = 0x00000001; - const unsigned long DERIVATION_EXTENSION = 0x00000002; - const unsigned long DERIVATION_UNION = 0x00000004; - const unsigned long DERIVATION_LIST = 0x00000008; - - boolean isDerivedFrom(in DOMString typeNamespaceArg, - in DOMString typeNameArg, - in unsigned long derivationMethod); - }; - - // Introduced in DOM Level 3: - interface UserDataHandler { - - // OperationType - const unsigned short NODE_CLONED = 1; - const unsigned short NODE_IMPORTED = 2; - const unsigned short NODE_DELETED = 3; - const unsigned short NODE_RENAMED = 4; - const unsigned short NODE_ADOPTED = 5; - - void handle(in unsigned short operation, - in DOMString key, - in DOMUserData data, - in Node src, - in Node dst); - }; - - // Introduced in DOM Level 3: - interface DOMError { - - // ErrorSeverity - const unsigned short SEVERITY_WARNING = 1; - const unsigned short SEVERITY_ERROR = 2; - const unsigned short SEVERITY_FATAL_ERROR = 3; - - readonly attribute unsigned short severity; - readonly attribute DOMString message; - readonly attribute DOMString type; - readonly attribute DOMObject relatedException; - readonly attribute DOMObject relatedData; - readonly attribute DOMLocator location; - }; - - // Introduced in DOM Level 3: - interface DOMErrorHandler { - boolean handleError(in DOMError error); - }; - - // Introduced in DOM Level 3: - interface DOMLocator { - readonly attribute long lineNumber; - readonly attribute long columnNumber; - readonly attribute long byteOffset; - readonly attribute long utf16Offset; - readonly attribute Node relatedNode; - readonly attribute DOMString uri; - }; - - // Introduced in DOM Level 3: - interface DOMConfiguration { - void setParameter(in DOMString name, - in DOMUserData value) - raises(DOMException); - DOMUserData getParameter(in DOMString name) - raises(DOMException); - boolean canSetParameter(in DOMString name, - in DOMUserData value); - readonly attribute DOMStringList parameterNames; - }; - - interface CDATASection : Text { - }; - - interface DocumentType : Node { - readonly attribute DOMString name; - readonly attribute NamedNodeMap entities; - readonly attribute NamedNodeMap notations; - // Introduced in DOM Level 2: - readonly attribute DOMString publicId; - // Introduced in DOM Level 2: - readonly attribute DOMString systemId; - // Introduced in DOM Level 2: - readonly attribute DOMString internalSubset; - }; - - interface Notation : Node { - readonly attribute DOMString publicId; - readonly attribute DOMString systemId; - }; - - interface Entity : Node { - readonly attribute DOMString publicId; - readonly attribute DOMString systemId; - readonly attribute DOMString notationName; - // Introduced in DOM Level 3: - readonly attribute DOMString inputEncoding; - // Introduced in DOM Level 3: - readonly attribute DOMString xmlEncoding; - // Introduced in DOM Level 3: - readonly attribute DOMString xmlVersion; - }; - - interface EntityReference : Node { - }; - - interface ProcessingInstruction : Node { - readonly attribute DOMString target; - attribute DOMString data; - // raises(DOMException) on setting - - }; - - interface DocumentFragment : Node { - }; - - interface Document : Node { - // Modified in DOM Level 3: - readonly attribute DocumentType doctype; - readonly attribute DOMImplementation implementation; - readonly attribute Element documentElement; - Element createElement(in DOMString tagName) - raises(DOMException); - DocumentFragment createDocumentFragment(); - Text createTextNode(in DOMString data); - Comment createComment(in DOMString data); - CDATASection createCDATASection(in DOMString data) - raises(DOMException); - ProcessingInstruction createProcessingInstruction(in DOMString target, - in DOMString data) - raises(DOMException); - Attr createAttribute(in DOMString name) - raises(DOMException); - EntityReference createEntityReference(in DOMString name) - raises(DOMException); - NodeList getElementsByTagName(in DOMString tagname); - // Introduced in DOM Level 2: - Node importNode(in Node importedNode, - in boolean deep) - raises(DOMException); - // Introduced in DOM Level 2: - Element createElementNS(in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - // Introduced in DOM Level 2: - Attr createAttributeNS(in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - // Introduced in DOM Level 2: - NodeList getElementsByTagNameNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - Element getElementById(in DOMString elementId); - // Introduced in DOM Level 3: - readonly attribute DOMString inputEncoding; - // Introduced in DOM Level 3: - readonly attribute DOMString xmlEncoding; - // Introduced in DOM Level 3: - attribute boolean xmlStandalone; - // raises(DOMException) on setting - - // Introduced in DOM Level 3: - attribute DOMString xmlVersion; - // raises(DOMException) on setting - - // Introduced in DOM Level 3: - attribute boolean strictErrorChecking; - // Introduced in DOM Level 3: - attribute DOMString documentURI; - // Introduced in DOM Level 3: - Node adoptNode(in Node source) - raises(DOMException); - // Introduced in DOM Level 3: - readonly attribute DOMConfiguration domConfig; - // Introduced in DOM Level 3: - void normalizeDocument(); - // Introduced in DOM Level 3: - Node renameNode(in Node n, - in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - }; -}; - -#endif // _DOM_IDL_ - diff --git a/src/dom/work/events.idl b/src/dom/work/events.idl deleted file mode 100644 index 5773dcaf6..000000000 --- a/src/dom/work/events.idl +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 2003 World Wide Web Consortium, - * - * (Massachusetts Institute of Technology, European Research Consortium for - * Informatics and Mathematics, Keio University). All Rights Reserved. This - * work is distributed under the W3C(r) Software License [1] in the hope that - * it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 - */ - -// File: http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.idl - -#ifndef _EVENTS_IDL_ -#define _EVENTS_IDL_ - -#include "dom.idl" -#include "views.idl" - -#pragma prefix "dom.w3c.org" -module events -{ - - typedef dom::DOMString DOMString; - typedef dom::DOMTimeStamp DOMTimeStamp; - typedef dom::DOMObject DOMObject; - typedef dom::Node Node; - - interface EventTarget; - interface EventListener; - - // Introduced in DOM Level 2: - exception EventException { - unsigned short code; - }; - // EventExceptionCode - const unsigned short UNSPECIFIED_EVENT_TYPE_ERR = 0; - // Introduced in DOM Level 3: - const unsigned short DISPATCH_REQUEST_ERR = 1; - - - // Introduced in DOM Level 2: - interface Event { - - // PhaseType - const unsigned short CAPTURING_PHASE = 1; - const unsigned short AT_TARGET = 2; - const unsigned short BUBBLING_PHASE = 3; - - readonly attribute DOMString type; - readonly attribute EventTarget target; - readonly attribute EventTarget currentTarget; - readonly attribute unsigned short eventPhase; - readonly attribute boolean bubbles; - readonly attribute boolean cancelable; - readonly attribute DOMTimeStamp timeStamp; - void stopPropagation(); - void preventDefault(); - void initEvent(in DOMString eventTypeArg, - in boolean canBubbleArg, - in boolean cancelableArg); - // Introduced in DOM Level 3: - readonly attribute DOMString namespaceURI; - // Introduced in DOM Level 3: - boolean isCustom(); - // Introduced in DOM Level 3: - void stopImmediatePropagation(); - // Introduced in DOM Level 3: - boolean isDefaultPrevented(); - // Introduced in DOM Level 3: - void initEventNS(in DOMString namespaceURIArg, - in DOMString eventTypeArg, - in boolean canBubbleArg, - in boolean cancelableArg); - }; - - // Introduced in DOM Level 2: - interface EventTarget { - void addEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - void removeEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - // Modified in DOM Level 3: - boolean dispatchEvent(in Event evt) - raises(EventException); - // Introduced in DOM Level 3: - void addEventListenerNS(in DOMString namespaceURI, - in DOMString type, - in EventListener listener, - in boolean useCapture, - in DOMObject evtGroup); - // Introduced in DOM Level 3: - void removeEventListenerNS(in DOMString namespaceURI, - in DOMString type, - in EventListener listener, - in boolean useCapture); - // Introduced in DOM Level 3: - boolean willTriggerNS(in DOMString namespaceURI, - in DOMString type); - // Introduced in DOM Level 3: - boolean hasEventListenerNS(in DOMString namespaceURI, - in DOMString type); - }; - - // Introduced in DOM Level 2: - interface EventListener { - void handleEvent(in Event evt); - }; - - // Introduced in DOM Level 2: - interface DocumentEvent { - Event createEvent(in DOMString eventType) - raises(dom::DOMException); - // Introduced in DOM Level 3: - boolean canDispatch(in DOMString namespaceURI, - in DOMString type); - }; - - // Introduced in DOM Level 3: - interface CustomEvent : Event { - void setDispatchState(in EventTarget target, - in unsigned short phase); - boolean isPropagationStopped(); - boolean isImmediatePropagationStopped(); - }; - - // Introduced in DOM Level 2: - interface UIEvent : Event { - readonly attribute views::AbstractView view; - readonly attribute long detail; - void initUIEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in long detailArg); - // Introduced in DOM Level 3: - void initUIEventNS(in DOMString namespaceURI, - in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in long detailArg); - }; - - // Introduced in DOM Level 3: - interface TextEvent : UIEvent { - readonly attribute DOMString data; - void initTextEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in DOMString dataArg); - void initTextEventNS(in DOMString namespaceURI, - in DOMString type, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in DOMString dataArg); - }; - - // Introduced in DOM Level 2: - interface MouseEvent : UIEvent { - readonly attribute long screenX; - readonly attribute long screenY; - readonly attribute long clientX; - readonly attribute long clientY; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean altKey; - readonly attribute boolean metaKey; - readonly attribute unsigned short button; - readonly attribute EventTarget relatedTarget; - void initMouseEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in long detailArg, - in long screenXArg, - in long screenYArg, - in long clientXArg, - in long clientYArg, - in boolean ctrlKeyArg, - in boolean altKeyArg, - in boolean shiftKeyArg, - in boolean metaKeyArg, - in unsigned short buttonArg, - in EventTarget relatedTargetArg); - // Introduced in DOM Level 3: - boolean getModifierState(in DOMString keyIdentifierArg); - // Introduced in DOM Level 3: - void initMouseEventNS(in DOMString namespaceURI, - in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in long detailArg, - in long screenXArg, - in long screenYArg, - in long clientXArg, - in long clientYArg, - in unsigned short buttonArg, - in EventTarget relatedTargetArg, - in DOMString modifiersList); - }; - - // Introduced in DOM Level 3: - interface KeyboardEvent : UIEvent { - - // KeyLocationCode - const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00; - const unsigned long DOM_KEY_LOCATION_LEFT = 0x01; - const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02; - const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03; - - readonly attribute DOMString keyIdentifier; - readonly attribute unsigned long keyLocation; - readonly attribute boolean ctrlKey; - readonly attribute boolean shiftKey; - readonly attribute boolean altKey; - readonly attribute boolean metaKey; - boolean getModifierState(in DOMString keyIdentifierArg); - void initKeyboardEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in DOMString keyIdentifierArg, - in unsigned long keyLocationArg, - in DOMString modifiersList); - void initKeyboardEventNS(in DOMString namespaceURI, - in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in views::AbstractView viewArg, - in DOMString keyIdentifierArg, - in unsigned long keyLocationArg, - in DOMString modifiersList); - }; - - // Introduced in DOM Level 2: - interface MutationEvent : Event { - - // attrChangeType - const unsigned short MODIFICATION = 1; - const unsigned short ADDITION = 2; - const unsigned short REMOVAL = 3; - - readonly attribute Node relatedNode; - readonly attribute DOMString prevValue; - readonly attribute DOMString newValue; - readonly attribute DOMString attrName; - readonly attribute unsigned short attrChange; - void initMutationEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in Node relatedNodeArg, - in DOMString prevValueArg, - in DOMString newValueArg, - in DOMString attrNameArg, - in unsigned short attrChangeArg); - // Introduced in DOM Level 3: - void initMutationEventNS(in DOMString namespaceURI, - in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in Node relatedNodeArg, - in DOMString prevValueArg, - in DOMString newValueArg, - in DOMString attrNameArg, - in unsigned short attrChangeArg); - }; - - // Introduced in DOM Level 3: - interface MutationNameEvent : MutationEvent { - readonly attribute DOMString prevNamespaceURI; - readonly attribute DOMString prevNodeName; - // Introduced in DOM Level 3: - void initMutationNameEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in Node relatedNodeArg, - in DOMString prevNamespaceURIArg, - in DOMString prevNodeNameArg); - // Introduced in DOM Level 3: - void initMutationNameEventNS(in DOMString namespaceURI, - in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in Node relatedNodeArg, - in DOMString prevNamespaceURIArg, - in DOMString prevNodeNameArg); - }; -}; - -#endif // _EVENTS_IDL_ - diff --git a/src/dom/work/idl.g b/src/dom/work/idl.g deleted file mode 100644 index ff70026a4..000000000 --- a/src/dom/work/idl.g +++ /dev/null @@ -1,1386 +0,0 @@ -header { - package org.apache.yoko.tools.processors.idl; - - import java.io.*; - import java.util.Vector; - import java.util.Hashtable; - } - -/** - * This is a complete parser for the IDL language as defined - * by the CORBA 3.0.2 specification. It will allow those who - * need an IDL parser to get up-and-running very quickly. - * Though IDL's syntax is very similar to C++, it is also - * much simpler, due in large part to the fact that it is - * a declarative-only language. - * - * Some things that are not included are: Symbol table construction - * (it is not necessary for parsing, btw) and preprocessing (for - * IDL compiler #pragma directives). You can use just about any - * C or C++ preprocessor, but there is an interesting semantic - * issue if you are going to generate code: In C, #include is - * a literal include, in IDL, #include is more like Java's import: - * It adds definitions to the scope of the parse, but included - * definitions are not generated. - * - * Jim Coker, jcoker@magelang.com - * Gary Duzan, gduzan@bbn.com - * Modified by Edell Nolan May 3, 2007: - * We originally used the corba grammar supplied on your site - * but it doesn't support forward declaration support for interfaces - * we have actually modified the grammar and fixed it. - */ -class IDLParser extends Parser; -options { - exportVocab=IDL; - buildAST=true; - k=4; -} - -specification - : (import_dcl)* (definition)+ - ; - - -definition - : ( type_dcl SEMI! - | const_dcl SEMI! - | except_dcl SEMI! - | (("abstract" | "local")? "interface") => interf SEMI! - | module SEMI! - | (("abstract" | "custom")? "valuetype") => value SEMI! - | type_id_dcl SEMI! - | type_prefix_dcl SEMI! - | (("abstract" | "custom")? "eventtype") => event SEMI! - | component SEMI! - | home_dcl SEMI! - ) - ; - -module - : "module"^ - identifier - LCURLY! d:definition_list RCURLY! - ; - -definition_list - : (definition)+ - ; - -interf - : ( interface_dcl - | forward_dcl - ) - ; - -// Grammar changed to differentiate between -// forward declared interfaces and empty interfaces -interface_dcl - : (( "abstract" | "local" )? - "interface"^ - identifier - ( interface_inheritance_spec )? - LCURLY interface_body RCURLY) - ; - -forward_dcl - : ( "abstract" | "local" )? - "interface"^ - identifier - ; - - -interface_body - : ( export )* - ; - -export - : ( type_dcl SEMI! - | const_dcl SEMI! - | except_dcl SEMI! - | attr_dcl SEMI! - | op_dcl SEMI! - | type_id_dcl SEMI! - | type_prefix_dcl SEMI! - ) - ; - - -interface_inheritance_spec - : COLON^ scoped_name_list - ; - -interface_name - : scoped_name - ; - -scoped_name_list - : scoped_name (COMMA! scoped_name)* - ; - - -scoped_name - : ( SCOPEOP^ )? IDENT^ /* identifier */ (SCOPEOP! identifier)* - ; - -value - : ( value_dcl - | value_abs_dcl - | value_box_dcl - | value_custom_dcl - | value_forward_dcl - ) - ; - -value_forward_dcl - : "valuetype"^ - identifier - ; - -value_box_dcl - : "valuetype"^ - identifier - type_spec - ; - -value_abs_dcl - : "abstract" - "valuetype"^ - identifier - ( value_abs_full_dcl - | // value_abs_forward_dcl - ) - ; - -value_abs_full_dcl - : value_inheritance_spec - LCURLY! ( export )* RCURLY! - ; - -// value_abs_forward_dcl -// : -// ; - -value_dcl - : value_header - LCURLY! ( value_element )* RCURLY! - ; - -value_custom_dcl - : "custom"^ - value_dcl - ; - -value_header - : "valuetype"^ - identifier - value_inheritance_spec - ; - -value_inheritance_spec -/* - : ( COLON ( "truncatable" )? - value_name ( COMMA! value_name )* - )? - ( "supports" interface_name ( COMMA! interface_name )* )? - ; -*/ - : ( value_value_inheritance_spec )? - ( value_interface_inheritance_spec )? - ; - -value_value_inheritance_spec - : COLON^ ( "truncatable" )? - value_name ( COMMA! value_name )* - ; - -value_interface_inheritance_spec - : "supports"^ interface_name ( COMMA! interface_name )* - ; - -value_name - : scoped_name - ; - -value_element - : ( export - | state_member - | init_dcl - ) - ; - -state_member - : ( "public" | "private" ) - type_spec declarators SEMI! - ; - -init_dcl - : "factory"^ identifier - LPAREN! (init_param_decls)? RPAREN! - (raises_expr)? - SEMI! - ; - -init_param_decls - : init_param_decl ( COMMA! init_param_decl )* - ; - -init_param_decl - : init_param_attribute - param_type_spec - simple_declarator - ; - -init_param_attribute - : "in" - ; - -const_dcl - : "const"^ const_type identifier ASSIGN! const_exp - ; - -const_type - : (integer_type) => integer_type - | char_type - | wide_char_type - | boolean_type - | floating_pt_type - | string_type - | wide_string_type - | fixed_pt_const_type - | scoped_name - | octet_type - ; - - -/* EXPRESSIONS */ - -const_exp - : or_expr - ; - -or_expr - : xor_expr - ( OR^ // or_op - xor_expr - )* - ; - -// or_op -// : OR -// ; - - -xor_expr - : and_expr - ( XOR^ // xor_op - and_expr - )* - ; - -// xor_op -// : XOR -// ; - -and_expr - : shift_expr - ( AND^ // and_op - shift_expr - )* - ; - -// and_op -// : AND -// ; - - -shift_expr - : add_expr - ( ( LSHIFT^ - | RSHIFT^ - ) // shift_op - add_expr - )* - ; - -// shift_op -// : LSHIFT -// | RSHIFT -// ; - - -add_expr - : mult_expr - ( ( PLUS^ - | MINUS^ - ) // add_op - mult_expr - )* - ; - -// add_op -// : PLUS -// | MINUS -// ; - -mult_expr - : unary_expr - ( ( STAR^ - | DIV^ - | MOD^ - ) // mult_op - unary_expr - )* - ; - -// mult_op -// : STAR -// | DIV -// | MOD -// ; - -unary_expr - : ( MINUS^ - | PLUS^ - | TILDE^ - ) // unary_operator - primary_expr - | primary_expr - ; - -// unary_operator -// : MINUS -// | PLUS -// | TILDE -// ; - -// Node of type TPrimaryExp serves to avoid inf. recursion on tree parse -primary_expr - : scoped_name - | literal - | LPAREN^ const_exp RPAREN - ; - -literal - : integer_literal - | string_literal - | wide_string_literal - | character_literal - | wide_character_literal - | fixed_pt_literal - | floating_pt_literal - | boolean_literal - ; - -boolean_literal - : "TRUE" - | "FALSE" - ; - -positive_int_const - : const_exp - ; - - -type_dcl - : "typedef"^ type_declarator - | (struct_type) => struct_type - | (union_type) => union_type - | enum_type - | "native"^ simple_declarator - | constr_forward_decl - ; - -type_declarator - : type_spec declarators - ; - -type_spec - : simple_type_spec - | constr_type_spec - ; - -simple_type_spec - : base_type_spec - | template_type_spec - | scoped_name - ; - -base_type_spec - : (floating_pt_type) => floating_pt_type - | integer_type - | char_type - | wide_char_type - | boolean_type - | octet_type - | any_type - | object_type - | value_base_type - ; - -template_type_spec - : sequence_type - | string_type - | wide_string_type - | fixed_pt_type - ; - -constr_type_spec - : struct_type - | union_type - | enum_type - ; - -declarators - : declarator (COMMA! declarator)* - ; - -declarator - : simple_declarator - | complex_declarator - ; - -simple_declarator - : identifier - ; - -complex_declarator - : array_declarator - ; - -floating_pt_type - : "float" - | "double" - | "long"^ "double" - ; - -integer_type - : signed_int - | unsigned_int - ; - -signed_int - : signed_short_int - | signed_long_int - | signed_longlong_int - ; - -signed_short_int - : "short" - ; - -signed_long_int - : "long" - ; - -signed_longlong_int - : "long" "long" - ; - -unsigned_int - : unsigned_short_int - | unsigned_long_int - | unsigned_longlong_int - ; - -unsigned_short_int - : "unsigned" "short" - ; - -unsigned_long_int - : "unsigned" "long" - ; - -unsigned_longlong_int - : "unsigned" "long" "long" - ; - -char_type - : "char" - ; - -wide_char_type - : "wchar" - ; - -boolean_type - : "boolean" - ; - -octet_type - : "octet" - ; - -any_type - : "any" - ; - -object_type - : "Object" - ; - -struct_type - : "struct"^ - identifier - LCURLY! member_list RCURLY! - ; - -member_list - : (member)+ - ; - -member - : type_spec declarators SEMI! - ; - -union_type - : "union"^ - identifier - "switch"! LPAREN! switch_type_spec RPAREN! - LCURLY! switch_body RCURLY! - ; - -switch_type_spec - : integer_type - | char_type - | boolean_type - | enum_type - | scoped_name - ; - -switch_body - : case_stmt_list - ; - -case_stmt_list - : (case_stmt)+ - ; - -case_stmt - : // case_label_list - ( "case"^ const_exp COLON! - | "default"^ COLON! - )+ - element_spec SEMI! - ; - -// case_label_list -// : (case_label)+ -// ; - - -// case_label -// : "case"^ const_exp COLON! -// | "default"^ COLON! -// ; - -element_spec - : type_spec declarator - ; - -enum_type - : "enum"^ identifier LCURLY! enumerator_list RCURLY! - ; - -enumerator_list - : enumerator (COMMA! enumerator)* - ; - -enumerator - : identifier - ; - -sequence_type - : "sequence"^ - LT! simple_type_spec opt_pos_int GT! - ; - -opt_pos_int - : (COMMA! positive_int_const)? - ; - -string_type - : "string"^ (LT! positive_int_const GT!)? - ; - -wide_string_type - : "wstring"^ (LT! positive_int_const GT!)? - ; - -array_declarator - : IDENT^ // identifier - (fixed_array_size)+ - ; - -fixed_array_size - : LBRACK! positive_int_const RBRACK! - ; - -attr_dcl - : readonly_attr_spec - | attr_spec - ; - -except_dcl - : "exception"^ - identifier - LCURLY! opt_member_list RCURLY! - ; - - -opt_member_list - : (member)* - ; - -op_dcl - : (op_attribute)? - op_type_spec - IDENT^ // identifier - parameter_dcls - (raises_expr)? - (context_expr)? - ; - -op_attribute - : "oneway" - ; - -op_type_spec - : param_type_spec - | "void" - ; - -parameter_dcls - : LPAREN! (param_dcl_list)? RPAREN! - ; - -param_dcl_list - : param_dcl (COMMA! param_dcl)* - ; - -param_dcl - : ("in"^ | "out"^ | "inout"^) // param_attribute - param_type_spec simple_declarator - ; - -// param_attribute -// : "in" -// | "out" -// | "inout" -// ; - -raises_expr - : "raises"^ LPAREN! scoped_name_list RPAREN! - ; - -context_expr - : "context"^ LPAREN! string_literal_list RPAREN! - ; - -string_literal_list - : string_literal (COMMA! string_literal)* - ; - -param_type_spec - : base_type_spec - | string_type - | wide_string_type - | scoped_name - ; - -fixed_pt_type - : "fixed"^ LT! positive_int_const COMMA! positive_int_const GT! - ; - -fixed_pt_const_type - : "fixed" - ; - -value_base_type - : "ValueBase" - ; - -constr_forward_decl - : "struct"^ identifier - | "union"^ identifier - ; - -import_dcl - : "import"^ imported_scope SEMI! - ; - -imported_scope - : scoped_name - | string_literal - ; - -type_id_dcl - : "typeid"^ - scoped_name - string_literal - ; - -type_prefix_dcl - : "typeprefix"^ - scoped_name - string_literal - ; - -readonly_attr_spec - : "readonly" "attribute"^ - param_type_spec - readonly_attr_declarator - ; - -readonly_attr_declarator - : simple_declarator - ( raises_expr - | (COMMA! simple_declarator)* - ) - ; - -attr_spec - : "attribute"^ param_type_spec attr_declarator - ; - -attr_declarator - : simple_declarator - ( ("getraises" | "setraises") => attr_raises_expr - | (COMMA! simple_declarator)* - ) - ; - -attr_raises_expr - : (get_excep_expr)? - (set_excep_expr)? - ; - -get_excep_expr - : "getraises"^ exception_list - ; - -set_excep_expr - : "setraises"^ exception_list - ; - -exception_list - : LPAREN! scoped_name (COMMA! scoped_name)* RPAREN! - ; - -// Component Stuff - -component - : "component"^ - identifier - (component_dcl)? - ; - -component_dcl - : (component_inheritance_spec)? - (supported_interface_spec)? - LCURLY! component_body RCURLY! - ; - -supported_interface_spec - : "supports"^ scoped_name ( COMMA! scoped_name )* - ; - -component_inheritance_spec - : COLON^ scoped_name - ; - -component_body - : (component_export)* - ; - -component_export - : ( provides_dcl SEMI! - | uses_dcl SEMI! - | emits_dcl SEMI! - | publishes_dcl SEMI! - | consumes_dcl SEMI! - | attr_dcl SEMI! - ) - ; - -provides_dcl - : "provides"^ interface_type identifier - ; - -interface_type - : ( scoped_name - | "Object" - ) - ; - -uses_dcl - : "uses"^ ("multiple")? interface_type identifier - ; - -emits_dcl - : "emits"^ scoped_name identifier - ; - -publishes_dcl - : "publishes"^ scoped_name identifier - ; - -consumes_dcl - : "consumes"^ scoped_name identifier - ; - -home_dcl - : home_header home_body - ; - -home_header - : "home"^ identifier - (home_inheritance_spec)? - (supported_interface_spec)? - "manages"! scoped_name - (primary_key_spec)? - ; - -home_inheritance_spec - : COLON^ scoped_name - ; - -primary_key_spec - : "primarykey"^ scoped_name - ; - -home_body - : LCURLY! (home_export)* RCURLY! - ; - -home_export - : ( export - | factory_dcl SEMI! - | finder_dcl SEMI! - ) - ; - -factory_dcl - : "factory"^ identifier - LPAREN! init_param_decls RPAREN! - (raises_expr)? - ; - -finder_dcl - : "finder"^ identifier - LPAREN! init_param_decls RPAREN! - (raises_expr)? - ; - -event - : ( event_abs - | event_custom - | event_dcl - ) - ; - -event_header - : "eventtype"^ - identifier - ; - -event_abs - : "abstract"^ - event_header - (event_abs_dcl)? - ; - -event_abs_dcl - : value_inheritance_spec - LCURLY! (export)* RCURLY! - ; - -event_custom - : "custom"^ - event_header - event_elem_dcl - ; - -event_dcl - : event_header - ( event_elem_dcl - | // event_forward_dcl - ) - ; - -event_elem_dcl - : value_inheritance_spec - LCURLY! (export)* RCURLY! - ; - -// event_forward_dcl -// : -// ; - -/* literals */ -integer_literal - : INT - | OCTAL - | HEX - ; - -string_literal - : (STRING_LITERAL)+ - ; - -wide_string_literal - : (WIDE_STRING_LITERAL)+ - ; - -character_literal - : CHAR_LITERAL - ; - -wide_character_literal - : WIDE_CHAR_LITERAL - ; - -fixed_pt_literal - : FIXED - ; - -floating_pt_literal - : f:FLOAT - ; - -identifier - : IDENT - ; - -/* IDL LEXICAL RULES */ -class IDLLexer extends Lexer; -options { - exportVocab=IDL; - charVocabulary='\u0000'..'\uFFFE'; - k=4; -} - -SEMI -options { - paraphrase = ";"; -} - : ';' - ; - -QUESTION -options { - paraphrase = "?"; -} - : '?' - ; - -LPAREN -options { - paraphrase = "("; -} - : '(' - ; - -RPAREN -options { - paraphrase = ")"; -} - : ')' - ; - -LBRACK -options { - paraphrase = "["; -} - : '[' - ; - -RBRACK -options { - paraphrase = "]"; -} - : ']' - ; - -LCURLY -options { - paraphrase = "{"; -} - : '{' - ; - -RCURLY -options { - paraphrase = "}"; -} - : '}' - ; - -OR -options { - paraphrase = "|"; -} - : '|' - ; - -XOR -options { - paraphrase = "^"; -} - : '^' - ; - -AND -options { - paraphrase = "&"; -} - : '&' - ; - -COLON -options { - paraphrase = ":"; -} - : ':' - ; - -COMMA -options { - paraphrase = ","; -} - : ',' - ; - -DOT -options { - paraphrase = "."; -} - : '.' - ; - -ASSIGN -options { - paraphrase = "="; -} - : '=' - ; - -NOT -options { - paraphrase = "!"; -} - : '!' - ; - -LT -options { - paraphrase = "<"; -} - : '<' - ; - -LSHIFT -options { - paraphrase = "<<"; -} - : "<<" - ; - -GT -options { - paraphrase = ">"; -} - : '>' - ; - -RSHIFT -options { - paraphrase = ">>"; -} - : ">>" - ; - -DIV -options { - paraphrase = "/"; -} - : '/' - ; - -PLUS -options { - paraphrase = "+"; -} - : '+' - ; - -MINUS -options { - paraphrase = "-"; -} - : '-' - ; - -TILDE -options { - paraphrase = "~"; -} - : '~' - ; - -STAR -options { - paraphrase = "*"; -} - : '*' - ; - -MOD -options { - paraphrase = "%"; -} - : '%' - ; - - -SCOPEOP -options { - paraphrase = "::"; -} - : "::" - ; - -WS -options { - paraphrase = "white space"; -} - : (' ' - | '\t' - | '\n' { newline(); } - | '\r') - { $setType(Token.SKIP); } - ; - - -PREPROC_DIRECTIVE -options { - paraphrase = "a preprocessor directive"; -} - - : - '#'! - (~'\n')* '\n'! - { $setType(Token.SKIP); newline(); } - ; - - -SL_COMMENT -options { - paraphrase = "a comment"; -} - - : - "//"! - (~'\n')* '\n' - { $setType(Token.SKIP); newline(); } - ; - -ML_COMMENT -options { - paraphrase = "a comment"; -} - : - "/*"! - ( - '\n' { newline(); } - | ('*')+ - ( '\n' { newline(); } - | ~('*' | '/' | '\n') - ) - | ~('*' | '\n') - )* - "*/"! - { $setType(Token.SKIP); } - ; - -CHAR_LITERAL -options { - paraphrase = "a character literal"; -} - : - '\''! - ( ESC | ~'\'' ) - '\''! - ; - -WIDE_CHAR_LITERAL -options { - paraphrase = "a wide character literal"; -} - : 'L'! CHAR_LITERAL - ; - -STRING_LITERAL -options { - paraphrase = "a string literal"; -} - : - '"'! - (ESC|~'"')* - '"'! - ; - - -WIDE_STRING_LITERAL -options { - paraphrase = "a wide string literal"; -} - : - 'L'! STRING_LITERAL - ; - -protected -ESC -options { - paraphrase = "an escape sequence"; -} - : '\\'! - ( 'n' {$setText("\n");} - | 't' {$setText("\t");} - | 'v' {$setText("\013");} - | 'b' {$setText("\b");} - | 'r' {$setText("\r");} - | 'f' {$setText("\r");} - | 'a' {$setText("\007");} - | '\\' {$setText("\\");} - | '?' {$setText("?");} - | '\'' {$setText("'");} - | '"' {$setText("\"");} - | OCTDIGIT - (options {greedy=true;}:OCTDIGIT - (options {greedy=true;}:OCTDIGIT)? - )? - {char realc = (char) Integer.valueOf($getText, 8).intValue(); $setText(realc);} - | 'x'! HEXDIGIT - (options {greedy=true;}:HEXDIGIT)? - {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);} - | 'u'! - HEXDIGIT - (options {greedy=true;}:HEXDIGIT - (options {greedy=true;}:HEXDIGIT - (options {greedy=true;}:HEXDIGIT)? - )? - )? - {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);} - ) - ; - -protected -VOCAB -options { - paraphrase = "an escaped character value"; -} - : '\3'..'\377' - ; - -protected -DIGIT -options { - paraphrase = "a digit"; -} - : '0'..'9' - ; - -protected -NONZERODIGIT -options { - paraphrase = "a non-zero digit"; -} - : '1'..'9' - ; - -protected -OCTDIGIT -options { - paraphrase = "an octal digit"; -} - : '0'..'7' - ; - -protected -HEXDIGIT -options { - paraphrase = "a hexadecimal digit"; -} - : ('0'..'9' | 'a'..'f' | 'A'..'F') - ; - -HEX -options { - paraphrase = "a hexadecimal value value"; -} - - : ("0x" | "0X") (HEXDIGIT)+ - ; - -INT -options { - paraphrase = "an integer value"; -} - : NONZERODIGIT (DIGIT)* // base-10 - ( '.' (DIGIT)* - ( (('e' | 'E') ('+' | '-')? (DIGIT)+) {$setType(FLOAT);} - | ('d' | 'D')! {$setType(FIXED);} - | {$setType(FLOAT);} - ) - | ('e' | 'E') ('+' | '-')? (DIGIT)+ {$setType(FLOAT);} - | ('d' | 'D')! {$setType(FIXED);} - )? - ; - -OCTAL -options { - paraphrase = "an octal value"; -} - : '0' - ( (DIGIT)+ - | FLOAT {$setType(FLOAT);} - | ('d' | 'D')! {$setType(FIXED);} - | {$setType(INT);} - ) - ; - - -FLOAT -options { - paraphrase = "a floating point value"; -} - - : '.' (DIGIT)+ - ( ('e' | 'E') ('+' | '-')? (DIGIT)+ - | ('d' | 'D')! {$setType(FIXED);} - )? - ; - -IDENT -options { - paraphrase = "an identifer"; - testLiterals = true; -} - - : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')* - ; - -ESCAPED_IDENT -options { - paraphrase = "an escaped identifer"; - testLiterals = false; // redundant, but explicit is good. -} - // NOTE: Adding a ! to the '_' doesn't seem to work, - // so we adjust _begin manually. - - : '_' ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')* - {_begin++;$setType(IDENT);} - ; - - diff --git a/src/dom/work/inkscape.css b/src/dom/work/inkscape.css deleted file mode 100644 index e73b15038..000000000 --- a/src/dom/work/inkscape.css +++ /dev/null @@ -1,493 +0,0 @@ -/* -* CSS for Inkscape Website (http://www.inkscape.org/) -* -* By: Tom von Schwerdtner | Etria LLP (http://www.etria.com/) -* -*/ - -body { - color: #000000; - background: #ffffff; - padding: 0px; - margin: 0px; - font-family: arial, Helvetica, 'Bitstream Vera Sans', 'Luxi Sans', Verdana, Sans-Serif; - font-size: 80%; -} - -a:link, a:visited, a:hover { - font-weight: bold; - color: #0081ac; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -a:visited { - color: #ac0011; -} - -div.top { - background:#0081ac; - width: 100%; - height: 100px; - border-bottom: 1px black solid; -} - -div.top a.logo, -div.top a.logo:link, -div.top a.logo:hover, -div.top a.logo:visited - { - color: #ffffff; - background: transparent; - border: none; - text-decoration: none; -} - -div.top h1 { - color: #ffffff; - background: transparent; - font-size: 40px; - font-family: arial; - margin: 0px; - padding: 20px; - float: left; -} - -img.logo { - float: right; - border: none; -} - -#menu { - float: left; - border: 1px #999999 solid; - width: 150px; - margin-left: 10px; - margin-top: 10px; - margin-bottom: 10px; -} - -#menu ul { - list-style: none; - padding: 0px; - margin: 0px; -} - -#menu li.sub { - color: #000000; - background: #d6d6d6; - font-weight: bold; - padding: 0px; -} - -#menu .title { - padding: 4px; - text-align: center; -} - -#menu ul.sub { - padding: 0px; - margin: 0px; - border-top: 1px #999999 solid; - border-bottom: 1px #999999 solid; - list-style: none; -} - -#menu li a { - display: block; - background: #f0f0f0; - color: #0081ac; - border-top: 1px #d6d6d6 solid; - border-bottom: 1px #d6d6d6 solid; - margin: 0px; - padding: 4px; - padding-left: 10px; - width: 100%; -} -#menu li a:visited { - color: #0081ac; -} - -html>body #menu li a { - width: auto; -} - -#menu li.item a:hover, ul.sub li.item a:hover { - display: block; - background: #ac0011; - /*background: #DC878F;*/ - color: #ffffff; - border-top: 1px #6F000B solid; - border-bottom: 1px #6F000B solid; - text-decoration: none; -} - -#sourceforge { - text-align: center; - border: none; -} - -html>body #sourceforge { - width: auto; -} - -div.content { - padding: 20px; - - /* this is a hack */ - margin-left: 160px; - margin-right: 20px; -} - - -#skipnav { - display: none; -} - -#togglecss { - position: absolute; - top: 110px; - right: 10px; -} - -div.news { -} - -div.news div.item { -} - -div.news div.item img { - margin: 10px; -} - -div.news div.item img.right { - float: right; - margin-right: 0px; -} - -div.news div.item img.left { - float: left; - margin-left: 0px; -} - -img.thumb { - border: 1px #999999 solid; -} - -div.news div.item h3 { - font-weight: bold; - border-left: 10px #999999 solid; - padding-left: 4px; - margin-bottom: 4px; - - clear: right; -} - -div.news div.item p { - margin-top: 0px; - margin-left: 20px; - margin-right: 20px; -} - -p { - text-align: justify; -} - -h2 { - border-bottom: 1px #000000 solid; - clear: right; -} - -pre { - border: 1px #006F02 solid; - background: #B0E4AE; - padding: 4px; -} - - -/* File Releases */ - -div.rss-files { -} - -div.rss-files div.file { - background: #f0f0f0; - color: #000000; - border: 1px #999999 solid; - padding: 2px; - margin: 20px; -} - -div.rss-files div.file div.title { - font-weight: bold; - padding: 4px; - padding-top: 2px; -} -div.rss-files div.file div.description { - font-weight: normal; - border: 1px #999999 solid; - background: #ffffff; - color: #000000; - padding: 4px; -} - -#footer { - text-align: center; - width: 100%; - border-top: 1px #000000 solid; - border-bottom: 1px #000000 solid; - padding-top: 4px; - padding-bottom: 4px; - background:#0081AC; - color: #ffffff; - clear: both; -} - -#footer img { - border: none; -} - -#footer a { - color: white; -} -/* We are overriding some earlier styles here, so this needs to be at the end - */ -/* -a.external:link, -a.external:visited, -a.external:hover, -#menu li a.external, -#menu li a.external:hover -{ - background-image: url('/images/globe.png'); - background-repeat: no-repeat; - background-position: center right; - padding-right: 18px; -} -*/ - -/* Doxygen Specific */ - -div.doxygen { -} - -div.doxygen pre { - background: #F8F8C6; - background: #fffff0; - color: #000000; - border: 1px #808000 solid; -} - -div.doxygen pre a:hover { -} - -div.doxygen pre .preprocessor { - font-weight: bold; - color: #006809; -} - -div.doxygen pre .keyword { - color: #68005F; -} - -div.doxygen pre .keywordflow { - color: #120053; - font-weight: bold; -} - -div.doxygen pre .keywordtype { - font-weight: bold; - color: #495300; -} - -div.doxygen pre .comment { - font-style: italic; - font-weight: bold; -} - - - - -table { - - margin-left: auto; - margin-right: auto; - width: 100%; - - clear: none; - - border-collapse: collapse; - - - background: none; - - -/* font-family: Arial, Helvetica, 'Bitstream Vera Sans', 'Luxi Sans', Verdana, Sans-Serif; */ - font-size: 13px; - -} - -td { - padding: 8px; - vertical-align: top; -} - - -table.roadmap { - background: #eee; -} - -table.roadmap td { - - border: 1px solid #999; - /* width: 50%; */ - - -} - -tr.header { - font-weight: bold; - background: #ddd; -} - -td.title { - text-align: center; - font-size: 16px; - font-weight: bold; - background: #ddd; -} - - - -img.float { - float: right; - - margin-top: 7px; - margin-left: 10px; - /* margin-right: 10px; */ - margin-bottom: 10px; -} - - - -/*@import: url(wiki.css)*/ - - - -/* FORM STUFF */ - -SELECT, option, textarea, input { - - color: #000000; - font-size: 10px; - text-decoration: none; - background: white; - border: 1px solid #666666; - - margin: 2px 0px 2px 0; - padding: 2px; - -} - -/* now make them all have nice hovers */ - - - -SELECT:hover, option:hover, textarea:hover, input:hover { - background: #ddd; -} - - -form.search { - /*display: inline; - background: #f0f0f0; - */ - - text-align: center; - - display: block; - background: #f0f0f0; - color: #0081ac; - border-top: 1px #d6d6d6 solid; - border-bottom: 1px #d6d6d6 solid; - margin: 0px; - padding: 4px; - padding-left: 10px; - - -} - -form.search:hover { - background: #ac0011; -} - - - -#post_news input -{ - width: 35%; -} - -#post_news textarea -{ - width: 100%; - height: 150px; -} - -input#login, -#post_news input#preview, -#post_news input#save, -#post_news input#reset -{ - width: 100px; -} - - -#post_news table -{ - padding: 0; -} - -#post_news td -{ - padding-left: 0; -} -#post_news table tr td.header -{ - width: 10%; - font-weight: bold; -} - -.alert -{ - color: red; -} - - -div.alert -{ - border: 1px solid red; - padding: 8px; -} - -.preview, -.message -{ - border: 1px solid #ccc; - padding: 8px; -} - - -#navbar -{ - padding: 8px; - background: #ccc; -} - -#navbar a -{ - padding-right: 12px; -} diff --git a/src/dom/work/ls.idl b/src/dom/work/ls.idl deleted file mode 100644 index db53ab79c..000000000 --- a/src/dom/work/ls.idl +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, - * - * (Massachusetts Institute of Technology, European Research Consortium for - * Informatics and Mathematics, Keio University). All Rights Reserved. This - * work is distributed under the W3C(r) Software License [1] in the hope that - * it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 - */ - -// File: http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/ls.idl - -#ifndef _LS_IDL_ -#define _LS_IDL_ - -#include "dom.idl" -#include "events.idl" -#include "traversal.idl" - -#pragma prefix "dom.w3c.org" -module ls -{ - - typedef Object LSInputStream; - - typedef Object LSOutputStream; - - typedef Object LSReader; - - typedef Object LSWriter; - - typedef dom::DOMString DOMString; - typedef dom::DOMConfiguration DOMConfiguration; - typedef dom::Node Node; - typedef dom::Document Document; - typedef dom::Element Element; - - interface LSParser; - interface LSSerializer; - interface LSInput; - interface LSOutput; - interface LSParserFilter; - interface LSSerializerFilter; - - exception LSException { - unsigned short code; - }; - // LSExceptionCode - const unsigned short PARSE_ERR = 81; - const unsigned short SERIALIZE_ERR = 82; - - - interface DOMImplementationLS { - - // DOMImplementationLSMode - const unsigned short MODE_SYNCHRONOUS = 1; - const unsigned short MODE_ASYNCHRONOUS = 2; - - LSParser createLSParser(in unsigned short mode, - in DOMString schemaType) - raises(dom::DOMException); - LSSerializer createLSSerializer(); - LSInput createLSInput(); - LSOutput createLSOutput(); - }; - - interface LSParser { - readonly attribute DOMConfiguration domConfig; - attribute LSParserFilter filter; - readonly attribute boolean async; - readonly attribute boolean busy; - Document parse(in LSInput input) - raises(dom::DOMException, - LSException); - Document parseURI(in DOMString uri) - raises(dom::DOMException, - LSException); - - // ACTION_TYPES - const unsigned short ACTION_APPEND_AS_CHILDREN = 1; - const unsigned short ACTION_REPLACE_CHILDREN = 2; - const unsigned short ACTION_INSERT_BEFORE = 3; - const unsigned short ACTION_INSERT_AFTER = 4; - const unsigned short ACTION_REPLACE = 5; - - Node parseWithContext(in LSInput input, - in Node contextArg, - in unsigned short action) - raises(dom::DOMException, - LSException); - void abort(); - }; - - interface LSInput { - // Depending on the language binding in use, - // this attribute may not be available. - attribute LSReader characterStream; - attribute LSInputStream byteStream; - attribute DOMString stringData; - attribute DOMString systemId; - attribute DOMString publicId; - attribute DOMString baseURI; - attribute DOMString encoding; - attribute boolean certifiedText; - }; - - interface LSResourceResolver { - LSInput resolveResource(in DOMString type, - in DOMString namespaceURI, - in DOMString publicId, - in DOMString systemId, - in DOMString baseURI); - }; - - interface LSParserFilter { - - // Constants returned by startElement and acceptNode - const short FILTER_ACCEPT = 1; - const short FILTER_REJECT = 2; - const short FILTER_SKIP = 3; - const short FILTER_INTERRUPT = 4; - - unsigned short startElement(in Element elementArg); - unsigned short acceptNode(in Node nodeArg); - readonly attribute unsigned long whatToShow; - }; - - interface LSSerializer { - readonly attribute DOMConfiguration domConfig; - attribute DOMString newLine; - attribute LSSerializerFilter filter; - boolean write(in Node nodeArg, - in LSOutput destination) - raises(LSException); - boolean writeToURI(in Node nodeArg, - in DOMString uri) - raises(LSException); - DOMString writeToString(in Node nodeArg) - raises(dom::DOMException, - LSException); - }; - - interface LSOutput { - // Depending on the language binding in use, - // this attribute may not be available. - attribute LSWriter characterStream; - attribute LSOutputStream byteStream; - attribute DOMString systemId; - attribute DOMString encoding; - }; - - interface LSProgressEvent : events::Event { - readonly attribute LSInput input; - readonly attribute unsigned long position; - readonly attribute unsigned long totalSize; - }; - - interface LSLoadEvent : events::Event { - readonly attribute Document newDocument; - readonly attribute LSInput input; - }; - - interface LSSerializerFilter : traversal::NodeFilter { - readonly attribute unsigned long whatToShow; - }; -}; - -#endif // _LS_IDL_ - diff --git a/src/dom/work/meyerweb.css b/src/dom/work/meyerweb.css deleted file mode 100644 index 9cce6b65e..000000000 --- a/src/dom/work/meyerweb.css +++ /dev/null @@ -1,181 +0,0 @@ -@import url(skel.css); - -/* generics */ - -* {font-size: 100%; padding: 0; margin: 0;} -body {font: 0.84em/1.333 Arial, sans-serif; margin: 0; padding: 0; - color: #202020; background: #FFF; - min-width: 40em; margin: 0 auto;} -a:link {color: #339;} -a:visited {color: #848;} -a img {border: none;} -h1 {font-size: 2em; margin: 2em 0 0.5em; padding: 0.25em 0;} -h2 {font-size: 1.5em; margin: 2em 0 0.33em; padding: 0.25em 0;} -h3 {font-size: 1.33em; margin: 2em 0 0.25em; padding: 0.125em 0;} -h4 {font-size: 1.1em; margin: 0.5em 0 0;} -h5 {font-size: 1em; margin: 0.5em 0 0;} -h6 {font-size: 0.85em; margin: 0.5em 0 0;} -p {margin: 0.33em 0 1em 0;} -ul, ol {margin: 1em 0; padding-left: 2.5em;} -dt {margin: 0.5em 0 0;} -dd {margin: 0.25em 0 0.5em 2.5em;} -pre, code, tt {font: 110% "Andale Mono", Courier, "Courier New", monospace;} -small {font-size: 85%;} -big {font-size: 115%;} -sup {font-size: smaller; vertical-align: 0.5em; line-height: 1px;} -img.pic {float: right; position: relative; margin: 0.25em 0 0.66em 1.5em;} -img.border {border: 3px double;} -img.standalone {display: block; margin: 0.5em auto; width: auto; max-width: 100%;} -p.standalone {text-align: center;} -p.standalone img {display: inline;} -.warning {background: #FF8; color: red; border: 2px solid; padding: 1em;} -.highlight {background: #B4D5FF; font-weight: bold;} - -table.chart {margin: 1em auto;} -table.chart caption {font-weight: bold; font-style: italic; font-size: 90%;} -table.chart th {text-align: left;} -table.chart thead th {border-bottom: 1px solid #CCC;} -table.chart th, table.chart td {border-bottom: 1px dotted #DDD;} -table.chart tbody th {padding-right: 1em;} - -/* masthead */ - -#sitemast {padding: 0; margin: 0; overflow: hidden; border-bottom: 1px solid #000; - height: 128px; width: 100%; position: relative; z-index: 1;} -#sitemast h1 {font-size: 2em; line-height: 1em; letter-spacing: 0.13em; - padding: 0; margin: 0; - position: absolute; left: 0; top: 100px; - /* hide-from-IE5/Mac hack \*/ - top: auto; bottom: 0; - /* end hack */} -#sitemast h1 a {padding: 0 0.25em;} -#sitemast h1 a, .panel a {text-decoration: none;} - -/* main content */ - -#main {margin: 2.25em 20em 0 12em; padding: 3.5em 0; - min-height: 30em;} -#main h2 {border-bottom: 1px solid #888; margin: 0; padding: 0; - font-size: 1.75em; line-height: 1;} -#main p.contact {margin: 0 1em; text-align: right; font-size: 90%;} - -#main p {line-height: 1.4;} -#main li {line-height: 1.33; margin-bottom: 0.33em;} -#main .compact li {line-height: normal; margin-bottom: 0;} -#main ul li {list-style: square;} -#main ol li {list-style: decimal;} - -#main blockquote {font-style: normal; margin: 1em 1em 1em 2em;} -#main blockquote em {font-style: italic; font-weight: inherit;} -#main blockquote p {margin: 0.33em 2.5% 0.33em 0 !important; - line-height: 1.2; text-indent: 2em;} -#main blockquote.book p {margin: 0 2.5% 0 0 !important;} -#main blockquote.lyric {font-style: italic; white-space: pre; - border: none; margin-left: 1em;} -#main blockquote.lyric p {text-indent: 0;} -.quoteattrib {margin: -0.75em 3em 0.66em; font-size: 87.5%;} -.quoteattrib cite {font-style: italic;} - -/* search bits */ - -#search {position: absolute; top: 129px; right: 0; - z-index: 10; - text-align: right; padding: 0.25em 0 1.25em 5px; - background: url(pix/logoogle2.gif) no-repeat 0% 100%;} -#search h4 {display: none;} -#search form {margin: 0; padding: 2px 1em 0;} -#search input[type="text"] {width: 14em; border: 2px inset #999;} -#search small {display: block; margin: 0 1.25em; padding: 0; - text-align: right; line-height: 1;} -#search small a {background: #FFF; color: #668; font-style: italic;} - -/* navbar */ - -#navigate {position: absolute; top: 129px; left: 0; right: 0; - padding: 0.25em 0 0.25em 1em; - z-index: 1; overflow: hidden; - height: auto; width: 85%; line-height: 2;} -#navigate h4 {display: none;} -#navigate ul, #navigate li {margin: 0; padding: 0;} -#navigate ul {padding-left: 0.5em;} - -#navlinks {float: left; width: 100%;} -#navlinks a {text-decoration: none;} -#navlinks li {float: left; list-style: none; margin-left: 1px;} -#navlinks li a {padding: 0.25em 1em; margin-right: 0.125em; - border-top: 0.75em solid #AAC; border-bottom: 1px dotted #FFF; - font-weight: bold; color: #668;} -#navlinks li ul {display: none; border: none;} -#navlinks li li a {font-weight: normal;} -#navlinks a:hover {border-top-color: #88A;} -#navlinks #otherLink {margin-left: 1.75em;} - -.arch #archLink a, -.css #cssLink a, -.tools #toolsLink a, -.write #writeLink a, -.speak #speakLink a, -.other #otherLink a -{border-color: #226 #FFF #FFF; background: #CCE; color: #226; font-style: italic;} - -/* 'sidebar' */ - -#extra {position: absolute; top: 129px; right: 0; z-index: 100; width: 18em; - font-size: 1em; line-height: 1.2; - padding: 1.75em 0 0; margin: 3em 0 0; - color: #5A5A5F;} -#extra a:link {color: #66A;} -#extra a:visited {color: #858;} - -#extra .panel {margin: 1em 0 0; padding: 1em 1em 0 3em; border: 1px dotted #FFF;} -#extra .panel h4, #extra .panel h5 {margin: 0 0 0.25em; padding: 0 0.5em 0 0; - font-size: 90%; line-height: 1; - border-bottom: 1px solid #AAA;} -#extra .panel ul {list-style: none; margin: 0 1em 0 0; padding: 0; font-size: 90%;} -#extra .panel li {margin-left: 1em; text-indent: -1em;} -#extra .panel .more {float: right; margin: -1.5em 1px 0 0.5em; - font-style: italic; text-align: right; font-size: smaller;} -#extra .panel .more a {padding-left: 15px; background: url(pix/morearr.gif) 0 66% no-repeat;} - -#extra #blogroll h5 {padding-right: 95px;} -#extra #blogroll ul {margin: 0.5em 1em 0 0;} -#extra #xfn-btn {float: right; margin: -20px 1px 0 5px;} - -#extra #excuse {text-align: center; padding: 0 0.25em 0.66em; margin: 2em 1em -2em 3em; - border: 1px solid #CCC;} -#extra #excuse h4 {display: inline; position: relative; top: -0.6em; - border: 0; padding: 0 0.25em; margin: 0; - background: #FFF; color: #666; - text-transform: capitalize; font-size: 1em; font-weight: normal;} -#extra #excuse p {margin: 0; padding: 0; color: #444;} - -#extra #extras {padding: 1em 0.5em 1em; margin: 2em 1em 0 3em; width: 13em; - color: #666; border: 1px solid #AAA; border-width: 1px 0;} -#extra #extras h4 {display: none;} -#extra #extras ul {margin: 0; text-align: center; list-style: none;} -#extra #extras li {margin-left: 0.25em; display: inline;} -#extra #extras a {margin-right: 0.25em;} - -/* miscellaneous */ - -#footer {margin: 3em 18em 0 12em; padding: 0.5em 0 3.5em; - border-top: 1px solid gray; - text-align: center; - color: gray; background: #FFF;} -#footer a {color: #558;} -#footer a:visited {color: #858;} -#footer p {line-height: 1; margin: 0; padding: 0.5em 0.25em 0; font-size: 0.85em; } - -#reading img {border: 1px solid silver;} -#extra #reading img {margin: 0.5em;} - -.book #main img.cover {float: right; margin: 1em 0 1em 2em; - border: 1px solid; border-color: #AAA #444 #444 #AAA;} - -/* Hack-o-rama! */ - -* html #navigate {padding-top: 0;} - -/*\*//*/ -body #search {width: 20em;} -/**/ diff --git a/src/dom/work/prop-css.txt b/src/dom/work/prop-css.txt deleted file mode 100644 index 882984137..000000000 --- a/src/dom/work/prop-css.txt +++ /dev/null @@ -1,1082 +0,0 @@ - -{ -"azimuth", -"<angle> | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards | inherit", -"center", -"", -"yes", -"", -"aural" -}, - - -{ -"background-attachment", -"scroll | fixed | inherit", -"scroll", -"", -"no", -"", -"visual" -}, - - -{ -"background-color", -"<color> | transparent | inherit", -"transparent", -"", -"no", -"", -"visual" -}, - - -{ -"background-image", -"<uri> | none | inherit", -"none", -"", -"no", -"", -"visual" -}, - - -{ -"background-position", -"[ [ <percentage> | <length> | left | center | right ] [ <percentage> | <length> | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit", -"0% 0%", -"", -"no", -"refer to the size of the box itself", -"visual" -}, - - -{ -"background-repeat", -"repeat | repeat-x | repeat-y | no-repeat | inherit", -"repeat", -"", -"no", -"", -"visual" -}, - - -{ -"background", -"['background-color' || 'background-image' || 'background-repeat' || 'background-attachment' || 'background-position'] | inherit", -"see individual properties", -"", -"no", -"allowed on 'background-position", -"visual" -}, - - -{ -"border-collapse", -"collapse | separate | inherit", -"separate", -"table' and 'inline-table' elements", -"yes", -"", -"visual" -}, - - -{ -"border-color", -"[ <color> | transparent ]{1,4} | inherit", -"see individual properties", -"", -"no", -"", -"visual" -}, - - -{ -"border-spacing", -"<length> <length>? | inherit", -"0", -"table' and 'inline-table' elements", -"yes", -"", -"visual" -}, - - -{ -"border-style", -"<border-style>{1,4} | inherit", -"see individual properties", -"", -"no", -"", -"visual" -}, - - -{ -"border-top' 'border-right' 'border-bottom' 'border-left", -"[ <border-width> || <border-style> || 'border-top-color' ] | inherit", -"see individual properties", -"", -"no", -"", -"visual" -}, - - -{ -"border-top-color' 'border-right-color' 'border-bottom-color' 'border-left-color", -"<color> | transparent | inherit", -"the value of the 'color' property", -"", -"no", -"", -"visual" -}, - - -{ -"border-top-style' 'border-right-style' 'border-bottom-style' 'border-left-style", -"<border-style> | inherit", -"none", -"", -"no", -"", -"visual" -}, - - -{ -"border-top-width' 'border-right-width' 'border-bottom-width' 'border-left-width", -"<border-width> | inherit", -"medium", -"", -"no", -"", -"visual" -}, - - -{ -"border-width", -"<border-width>{1,4} | inherit", -"see individual properties", -"", -"no", -"", -"visual" -}, - - -{ -"border", -"[ <border-width> || <border-style> || 'border-top-color' ] | inherit", -"see individual properties", -"", -"no", -"", -"visual" -}, - - -{ -"bottom", -"<length> | <percentage> | auto | inherit", -"auto", -"positioned elements", -"no", -"refer to height of containing block", -"visual" -}, - - -{ -"caption-side", -"top | bottom | inherit", -"top", -"table-caption' elements", -"yes", -"", -"visual" -}, - - -{ -"clear", -"none | left | right | both | inherit", -"none", -"block-level elements", -"no", -"", -"visual" -}, - - -{ -"clip", -"<shape> | auto | inherit", -"auto", -"absolutely positioned elements", -"no", -"", -"visual" -}, - - -{ -"color", -"<color> | inherit", -"depends on user agent", -"", -"yes", -"", -"visual" -}, - - -{ -"content", -"normal | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit", -"normal", -":before and :after pseudo-elements", -"no", -"", -"all " -}, - - -{ -"counter-increment", -"[ <identifier> <integer>? ]+ | none | inherit", -"none", -"", -"no", -"", -"all " -}, - - -{ -"counter-reset", -"[ <identifier> <integer>? ]+ | none | inherit", -"none", -"", -"no", -"", -"all " -}, - - -{ -"cue-after", -"<uri> | none | inherit", -"none", -"", -"no", -"", -"aural" -}, - - -{ -"cue-before", -"<uri> | none | inherit", -"none", -"", -"no", -"", -"aural" -}, - - -{ -"cue", -"[ 'cue-before' || 'cue-after' ] | inherit", -"see individual properties", -"", -"no", -"", -"aural" -}, - - -{ -"cursor", -"[ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress ] ] | inherit", -"auto", -"", -"yes", -"", -"visual, - interactive " -}, - - -{ -"direction", -"ltr | rtl | inherit", -"ltr", -"all elements, but see prose", -"yes", -"", -"visual" -}, - - -{ -"display", -"inline | block | list-item | run-in | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit", -"inline", -"", -"no", -"", -"all " -}, - - -{ -"elevation", -"<angle> | below | level | above | higher | lower | inherit", -"level", -"", -"yes", -"", -"aural" -}, - - -{ -"empty-cells", -"show | hide | inherit", -"show", -"table-cell' elements", -"yes", -"", -"visual" -}, - - -{ -"float", -"left | right | none | inherit", -"none", -"all, but see 9.7", -"no", -"", -"visual" -}, - - -{ -"font-family", -"[[ <family-name> | <generic-family> ] [, <family-name>| <generic-family>]* ] | inherit", -"depends on user agent", -"", -"yes", -"", -"visual" -}, - - -{ -"font-size", -"<absolute-size> | <relative-size> | <length> | <percentage> | inherit", -"medium", -"", -"yes", -"refer to parent element's font size", -"visual" -}, - - -{ -"font-style", -"normal | italic | oblique | inherit", -"normal", -"", -"yes", -"", -"visual" -}, - - -{ -"font-variant", -"normal | small-caps | inherit", -"normal", -"", -"yes", -"", -"visual" -}, - - -{ -"font-weight", -"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit", -"normal", -"", -"yes", -"", -"visual" -}, - - -{ -"font", -"[ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit", -"see individual properties", -"", -"yes", -"see individual properties", -"visual" -}, - - -{ -"height", -"<length> | <percentage> | auto | inherit", -"auto", -"all elements but non-replaced inline elements, table columns, and column groups", -"no", -"see prose", -"visual" -}, - - -{ -"left", -"<length> | <percentage> | auto | inherit", -"auto", -"positioned elements", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"letter-spacing", -"normal | <length> | inherit", -"normal", -"", -"yes", -"", -"visual" -}, - - -{ -"line-height", -"normal | <number> | <length> | <percentage> | inherit", -"normal", -"", -"yes", -"refer to the font size of the element itself", -"visual" -}, - - -{ -"list-style-image", -"<uri> | none | inherit", -"none", -"elements with 'display: list-item", -"yes", -"", -"visual" -}, - - -{ -"list-style-position", -"inside | outside | inherit", -"outside", -"elements with 'display: list-item", -"yes", -"", -"visual" -}, - - -{ -"list-style-type", -"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | none | inherit", -"disc", -"elements with 'display: list-item", -"yes", -"", -"visual" -}, - - -{ -"list-style", -"[ 'list-style-type' || 'list-style-position' || 'list-style-image' ] | inherit", -"see individual properties", -"elements with 'display: list-item", -"yes", -"", -"visual" -}, - - -{ -"margin-right' 'margin-left", -"<margin-width> | inherit", -"0", -"all elements except elements with table display types other than table and inline-table", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"margin-top' 'margin-bottom", -"<margin-width> | inherit", -"0", -"all elements except elements with table display types other than table and inline-table", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"margin", -"<margin-width>{1,4} | inherit", -"see individual properties", -"all elements except elements with table display types other than table and inline-table", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"max-height", -"<length> | <percentage> | none | inherit", -"none", -"all elements except non-replaced inline elements and table elements", -"no", -"see prose", -"visual" -}, - - -{ -"max-width", -"<length> | <percentage> | none | inherit", -"none", -"all elements except non-replaced inline elements and table elements", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"min-height", -"<length> | <percentage> | inherit", -"0", -"all elements except non-replaced inline elements and table elements", -"no", -"see prose", -"visual" -}, - - -{ -"min-width", -"<length> | <percentage> | inherit", -"0", -"all elements except non-replaced inline elements and table elements", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"orphans", -"<integer> | inherit", -"2", -"block-level elements", -"yes", -"", -"visual, paged " -}, - - -{ -"outline-color", -"<color> | invert | inherit", -"invert", -"", -"no", -"", -"visual, interactive " -}, - - -{ -"outline-style", -"<border-style> | inherit", -"none", -"", -"no", -"", -"visual, interactive " -}, - - -{ -"outline-width", -"<border-width> | inherit", -"medium", -"", -"no", -"", -"visual, interactive " -}, - - -{ -"outline", -"[ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit", -"see individual properties", -"", -"no", -"", -"visual, interactive " -}, - - -{ -"overflow", -"visible | hidden | scroll | auto | inherit", -"visible", -"block-level and replaced elements, table cells, inline blocks", -"no", -"", -"visual" -}, - - -{ -"padding-top' 'padding-right' 'padding-bottom' 'padding-left", -"<padding-width> | inherit", -"0", -"all elements except elements with table display types other than table, inline-table, and table-cell", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"padding", -"<padding-width>{1,4} | inherit", -"see individual properties", -"all elements except elements with table display types other than table, inline-table, and table-cell", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"page-break-after", -"auto | always | avoid | left | right | inherit", -"auto", -"block-level elements", -"no", -"", -"visual, - paged " -}, - - -{ -"page-break-before", -"auto | always | avoid | left | right | inherit", -"auto", -"block-level elements", -"no", -"", -"visual, - paged " -}, - - -{ -"page-break-inside", -"avoid | auto | inherit", -"auto", -"block-level elements", -"yes", -"", -"visual, - paged " -}, - - -{ -"pause-after", -"<time> | <percentage> | inherit", -"0", -"", -"no", -"see prose", -"aural" -}, - - -{ -"pause-before", -"<time> | <percentage> | inherit", -"0", -"", -"no", -"see prose", -"aural" -}, - - -{ -"pause", -"[ [<time> | <percentage>]{1,2} ] | inherit", -"see individual properties", -"", -"no", -"see descriptions of 'pause-before' and 'pause-after", -"aural" -}, - - -{ -"pitch-range", -"<number> | inherit", -"50", -"", -"yes", -"", -"aural" -}, - - -{ -"pitch", -"<frequency> | x-low | low | medium | high | x-high | inherit", -"medium", -"", -"yes", -"", -"aural" -}, - - -{ -"play-during", -"<uri> [ mix || repeat ]? | auto | none | inherit", -"auto", -"", -"no", -"", -"aural" -}, - - -{ -"position", -"static | relative | absolute | fixed | inherit", -"static", -"", -"no", -"", -"visual" -}, - - -{ -"quotes", -"[<string> <string>]+ | none | inherit", -"depends on user agent", -"", -"yes", -"", -"visual" -}, - - -{ -"richness", -"<number> | inherit", -"50", -"", -"yes", -"", -"aural" -}, - - -{ -"right", -"<length> | <percentage> | auto | inherit", -"auto", -"positioned elements", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"speak-header", -"once | always | inherit", -"once", -"elements that have table header information", -"yes", -"", -"aural" -}, - - -{ -"speak-numeral", -"digits | continuous | inherit", -"continuous", -"", -"yes", -"", -"aural" -}, - - -{ -"speak-punctuation", -"code | none | inherit", -"none", -"", -"yes", -"", -"aural" -}, - - -{ -"speak", -"normal | none | spell-out | inherit", -"normal", -"", -"yes", -"", -"aural" -}, - - -{ -"speech-rate", -"<number> | x-slow | slow | medium | fast | x-fast | faster | slower | inherit", -"medium", -"", -"yes", -"", -"aural" -}, - - -{ -"stress", -"<number> | inherit", -"50", -"", -"yes", -"", -"aural" -}, - - -{ -"table-layout", -"auto | fixed | inherit", -"auto", -"table' and 'inline-table' elements", -"no", -"", -"visual" -}, - - -{ -"text-align", -"left | right | center | justify | inherit", -"left' if 'direction' is 'ltr'; 'right' if 'direction' is 'rtl", -"block-level elements, table cells and inline blocks", -"yes", -"", -"visual" -}, - - -{ -"text-decoration", -"none | [ underline || overline || line-through || blink ] | inherit", -"none", -"", -"no (see prose)", -"", -"visual" -}, - - -{ -"text-indent", -"<length> | <percentage> | inherit", -"0", -"block-level elements, table cells and inline blocks", -"yes", -"refer to width of containing block", -"visual" -}, - - -{ -"text-transform", -"capitalize | uppercase | lowercase | none | inherit", -"none", -"", -"yes", -"", -"visual" -}, - - -{ -"top", -"<length> | <percentage> | auto | inherit", -"auto", -"positioned elements", -"no", -"refer to height of containing block", -"visual" -}, - - -{ -"unicode-bidi", -"normal | embed | bidi-override | inherit", -"normal", -"all elements, but see prose", -"no", -"", -"visual" -}, - - -{ -"vertical-align", -"baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage> | <length> | inherit", -"baseline", -"inline-level and 'table-cell' elements", -"no", -"refer to the 'line-height' of the element itself", -"visual" -}, - - -{ -"visibility", -"visible | hidden | collapse | inherit", -"visible", -"", -"yes", -"", -"visual" -}, - - -{ -"voice-family", -"[[<specific-voice> | <generic-voice> ],]* [<specific-voice> | <generic-voice> ] | inherit", -"depends on user agent", -"", -"yes", -"", -"aural" -}, - - -{ -"volume", -"<number> | <percentage> | silent | x-soft | soft | medium | loud | x-loud | inherit", -"medium", -"", -"yes", -"refer to inherited value", -"aural" -}, - - -{ -"white-space", -"normal | pre | nowrap | pre-wrap | pre-line | inherit", -"normal", -"", -"yes", -"", -"visual" -}, - - -{ -"widows", -"<integer> | inherit", -"2", -"block-level elements", -"yes", -"", -"visual, paged " -}, - - -{ -"width", -"<length> | <percentage> | auto | inherit", -"auto", -"all elements but non-replaced inline elements, table rows, and row groups", -"no", -"refer to width of containing block", -"visual" -}, - - -{ -"word-spacing", -"normal | <length> | inherit", -"normal", -"", -"yes", -"", -"visual" -}, - - -{ -"z-index", -"auto | <integer> | inherit", -"auto", -"positioned elements", -"no", -"", -"visual" -} - diff --git a/src/dom/work/prop-svg.txt b/src/dom/work/prop-svg.txt deleted file mode 100644 index 0d4984f25..000000000 --- a/src/dom/work/prop-svg.txt +++ /dev/null @@ -1,651 +0,0 @@ - -{ -"alignment-baseline", -"auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | inherit", -"see property description", -"'tspan', 'tref', 'altGlyph', 'textPath' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"baseline-shift", -"baseline | sub | super | <percentage> | <length> | inherit", -"baseline", -"tspan', 'tref', 'altGlyph', 'textPath' elements", -"no", -"refers to the 'line-height' of the 'text' element, which in the case of SVG is defined to be equal to the 'font-size", -"visual", -"yes (non-additive, 'set' and 'animate' elements only)" -}, - -{ -"clip", -"<shape> | auto | inherit", -"auto", -"elements which establish a new viewport, 'pattern' elements and 'marker' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"clip-path", -"<uri> | none | inherit", -"none", -"container elements and graphics elements", -"no", -"", -"visual", -"yes" -}, - -{ -"clip-rule", -"nonzero | evenodd | inherit", -"nonzero", -"graphics elements within a 'clipPath' element", -"yes", -"", -"visual", -"yes" -}, - -{ -"color", -"<color> | inherit", -"depends on user agent", -"elements to which properties 'fill', 'stroke', 'stop-color', 'flood-color', 'lighting-color' apply", -"yes", -"", -"visual", -"yes" -}, - -{ -"color-interpolation", -"auto | sRGB | linearRGB | inherit", -"sRGB", -"container elements, graphics elements and 'animateColor", -"yes", -"", -"visual", -"yes" -}, - -{ -"color-interpolation-filters", -"auto | sRGB | linearRGB | inherit", -"linearRGB", -"filter primitives", -"yes", -"", -"visual", -"yes" -}, - -{ -"color-profile", -"auto | sRGB | <name> | <uri> | inherit", -"auto", -"'image' elements that refer to raster images", -"yes", -"", -"visual", -"yes" -}, - -{ -"color-rendering", -"auto | optimizeSpeed | optimizeQuality | inherit", -"auto", -"container elements, graphics elements and 'animateColor", -"yes", -"", -"visual", -"yes" -}, - -{ -"cursor", -"[ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize| text | wait | help ] ] | inherit", -"auto", -"container elements and graphics elements", -"yes", -"", -"visual, interactive", -"yes" -}, - -{ -"direction", -"ltr | rtl | inherit", -"ltr", -"text content elements", -"yes", -"", -"visual", -"no" -}, - -{ -"display", -"inline | block | list-item | run-in | compact | marker | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit", -"inline", -"'svg', 'g', 'switch', 'a', 'foreignObject', graphics elements (including the 'text' element) and text sub-elements (i.e., 'tspan', 'tref', 'altGlyph', 'textPath')", -"no", -"", -"all", -"yes" -}, - -{ -"dominant-baseline", -"auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge | inherit", -"auto", -"text content elements", -"no", -"", -"visual", -"yes" -}, - -{ -"enable-background", -"accumulate | new [ <x> <y> <width> <height> ] | inherit", -"accumulate", -"container elements", -"no", -"", -"visual", -"no" -}, - -{ -"fill", -"<paint> (See Specifying paint)", -"black", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"fill-opacity", -"<opacity-value> | inherit", -"1", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"fill-rule", -"nonzero | evenodd | inherit", -"nonzero", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"filter", -"<uri> | none | inherit", -"none", -"container elements and graphics elements", -"no", -"", -"visual", -"yes" -}, - -{ -"flood-color", -"currentColor | <color> [icc-color(<name>[,<icccolorvalue>]*)] | inherit", -"black", -"'feFlood' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"flood-opacity", -"<opacity-value> | inherit", -"1", -"'feFlood' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"font", -"[ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit", -"see individual properties", -"text content elements", -"yes", -"allowed on 'font-size' and 'line-height' ('line-height' same as 'font-size' in SVG)", -"visual", -"yes (non-additive, 'set' and 'animate' elements only)" -}, - -{ -"font-family", -"[[ <family-name> | <generic-family> ],]* [ <family-name> | <generic-family>] | inherit", -"depends on user agent", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"font-size", -"<absolute-size> | <relative-size> | <length> | <percentage> | inherit", -"medium", -"text content elements", -"yes, the computed value is inherited", -"refer to parent element's font size", -"visual", -"yes" -}, - -{ -"font-size-adjust", -"<number> | none | inherit", -"none", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"font-stretch", -"normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit", -"normal", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"font-style", -"normal | italic | oblique | inherit", -"normal", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"font-variant", -"normal | small-caps | inherit", -"normal", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"font-weight", -"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit", -"normal", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"glyph-orientation-horizontal", -"<angle> | inherit", -"0deg", -"text content elements", -"yes", -"", -"visual", -"no" -}, - -{ -"glyph-orientation-vertical", -"auto | <angle> | inherit", -"auto", -"text content elements", -"yes", -"", -"visual", -"no" -}, - -{ -"image-rendering", -"auto | optimizeSpeed | optimizeQuality | inherit", -"auto", -"images", -"yes", -"", -"visual", -"yes" -}, - -{ -"kerning", -"auto | <length> | inherit", -"auto", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"letter-spacing", -"normal | <length> | inherit", -"normal", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"lighting-color", -"currentColor | <color> [icc-color(<name>[,<icccolorvalue>]*)] | inherit", -"white", -"feDiffuseLighting' and 'feSpecularLighting' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"marker", -"see individual properties", -"see individual properties", -"path', 'line', 'polyline' and 'polygon' elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"marker-end' 'marker-mid' 'marker-start", -"none | inherit | <uri>", -"none", -"path', 'line', 'polyline' and 'polygon' elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"mask", -"<uri> | none | inherit", -"none", -"container elements and graphics elements", -"no", -"", -"visual", -"yes" -}, - -{ -"opacity", -"<opacity-value> | inherit", -"1", -"container elements and graphics elements", -"no", -"", -"visual", -"yes" -}, - -{ -"overflow", -"visible | hidden | scroll | auto | inherit", -"see prose", -"elements which establish a new viewport, 'pattern' elements and 'marker' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"pointer-events", -"visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | none | inherit", -"visiblePainted", -"graphics elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"shape-rendering", -"auto | optimizeSpeed | crispEdges | geometricPrecision | inherit", -"auto", -"shapes", -"yes", -"", -"visual", -"yes" -}, - -{ -"stop-color", -"currentColor | <color> [icc-color(<name>[,<icccolorvalue>]*)] | inherit", -"black", -"stop' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"stop-opacity", -"<opacity-value> | inherit", -"1", -"stop' elements", -"no", -"", -"visual", -"yes" -}, - -{ -"stroke", -"<paint> (See Specifying paint)", -"none", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"stroke-dasharray", -"none | <dasharray> | inherit", -"none", -"shapes and text content elements", -"yes", -"", -"visual", -"" -}, - -{ -"stroke-dashoffset", -"<length> | inherit", -"0", -"shapes and text content elements", -"yes", -"see prose", -"visual", -"yes" -}, - -{ -"stroke-linecap", -"butt | round | square | inherit", -"butt", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"stroke-linejoin", -"miter | round | bevel | inherit", -"miter", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"stroke-miterlimit", -"<miterlimit> | inherit", -"4", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"stroke-opacity", -"<opacity-value> | inherit", -"1", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"stroke-width", -"<length> | inherit", -"1", -"shapes and text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"text-anchor", -"start | middle | end | inherit", -"start", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"text-decoration", -"none | [ underline || overline || line-through || blink ] | inherit", -"none", -"text content elements", -"no (see prose)", -"", -"visual", -"yes" -}, - -{ -"text-rendering", -"auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit", -"auto", -"'text' elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"unicode-bidi", -"normal | embed | bidi-override | inherit", -"normal", -"text content elements", -"no", -"", -"visual", -"no" -}, - -{ -"visibility", -"visible | hidden | collapse | inherit", -"visible", -"graphics elements (including the 'text' element) and text sub-elements (i.e., 'tspan', 'tref', 'altGlyph', 'textPath' and 'a')", -"yes", -"", -"visual", -"yes" -}, - -{ -"word-spacing", -"normal | <length> | inherit", -"normal", -"text content elements", -"yes", -"", -"visual", -"yes" -}, - -{ -"writing-mode", -"lr-tb | rl-tb | tb-rl | lr | rl | tb | inherit", -"lr-tb", -"'text' elements", -"yes", -"", -"visual", -"no" -}, - - diff --git a/src/dom/work/ranges.idl b/src/dom/work/ranges.idl deleted file mode 100644 index 205b1bab7..000000000 --- a/src/dom/work/ranges.idl +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -// File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/ranges.idl - -#ifndef _RANGES_IDL_ -#define _RANGES_IDL_ - -#include "dom.idl" - -#pragma prefix "dom.w3c.org" -module ranges -{ - - typedef dom::Node Node; - typedef dom::DocumentFragment DocumentFragment; - typedef dom::DOMString DOMString; - - // Introduced in DOM Level 2: - exception RangeException { - unsigned short code; - }; - // RangeExceptionCode - const unsigned short BAD_BOUNDARYPOINTS_ERR = 1; - const unsigned short INVALID_NODE_TYPE_ERR = 2; - - - // Introduced in DOM Level 2: - interface Range { - readonly attribute Node startContainer; - // raises(dom::DOMException) on retrieval - - readonly attribute long startOffset; - // raises(dom::DOMException) on retrieval - - readonly attribute Node endContainer; - // raises(dom::DOMException) on retrieval - - readonly attribute long endOffset; - // raises(dom::DOMException) on retrieval - - readonly attribute boolean collapsed; - // raises(dom::DOMException) on retrieval - - readonly attribute Node commonAncestorContainer; - // raises(dom::DOMException) on retrieval - - void setStart(in Node refNode, - in long offset) - raises(RangeException, - dom::DOMException); - void setEnd(in Node refNode, - in long offset) - raises(RangeException, - dom::DOMException); - void setStartBefore(in Node refNode) - raises(RangeException, - dom::DOMException); - void setStartAfter(in Node refNode) - raises(RangeException, - dom::DOMException); - void setEndBefore(in Node refNode) - raises(RangeException, - dom::DOMException); - void setEndAfter(in Node refNode) - raises(RangeException, - dom::DOMException); - void collapse(in boolean toStart) - raises(dom::DOMException); - void selectNode(in Node refNode) - raises(RangeException, - dom::DOMException); - void selectNodeContents(in Node refNode) - raises(RangeException, - dom::DOMException); - - // CompareHow - const unsigned short START_TO_START = 0; - const unsigned short START_TO_END = 1; - const unsigned short END_TO_END = 2; - const unsigned short END_TO_START = 3; - - short compareBoundaryPoints(in unsigned short how, - in Range sourceRange) - raises(dom::DOMException); - void deleteContents() - raises(dom::DOMException); - DocumentFragment extractContents() - raises(dom::DOMException); - DocumentFragment cloneContents() - raises(dom::DOMException); - void insertNode(in Node newNode) - raises(dom::DOMException, - RangeException); - void surroundContents(in Node newParent) - raises(dom::DOMException, - RangeException); - Range cloneRange() - raises(dom::DOMException); - DOMString toString() - raises(dom::DOMException); - void detach() - raises(dom::DOMException); - }; - - // Introduced in DOM Level 2: - interface DocumentRange { - Range createRange(); - }; -}; - -#endif // _RANGES_IDL_ - diff --git a/src/dom/work/sandb1.css b/src/dom/work/sandb1.css deleted file mode 100644 index 1da2686aa..000000000 --- a/src/dom/work/sandb1.css +++ /dev/null @@ -1,149 +0,0 @@ -@import url(base.css); - -/* -All images: -Copyright 2003 - Swartz & Bivens, P.L.L.C. -*/ - -html, body {width: 100%; height: 100% !important; font-size: 1em;} -body {margin: 0; padding: 0; font: 1em Verdana, Arial, Helvetica, sans-serif; position: relative;} - -#header {margin: 0; padding: 0 0 0.75em 0; border-bottom: 1px solid; - border-left: 1.5em solid;} -#header h1 {margin: 0; padding: 0.75em 0.5em 0 0; font-size: 1.5em; - font-family: Verdana, sans-serif; line-height: 0.8em; letter-spacing: -0.13em;} - -#main {padding: 0.6em 0 5em 25px; margin-right: 21%;} -#main h2, #main h3, #main h4, #main h5, #main h6 {line-height: 0.8em; margin: 1em 0 0; - border-bottom: 1px solid; } - - -#main p, #main ul, #main ol, #main dl {margin-right: 6%;} - - -p.desc {margin: 0.5em 0 1em 95px;} -a.pic {float: left; margin: -21px 0 0.5em; width: 80px;} -a.hlinks {text-decoration: none; border-bottom: 0.25em solid;} - -#nav {position: absolute; right: 0%; top: 3.2em; width: 20%; max-width: 200px; - padding: 0; margin: 0 0 0 1px; - font-family: Arial, sans-serif; - border-style: solid; - background-color: #4682B4; - border-width: 1px 2px 2px 1px; -} -#nav h4 {margin: 0; padding: 0.25em 0.5em 1px 0.25em; - font-size: 0.9em; font-style: italic; line-height: 0.7em; - letter-spacing: 1px; text-transform: lowercase; - border-style: dotted; border-width: 0px 0 1px 2px;} -#nav ul {margin: 0 0 1.5em 0; padding: 0.25em 0 0.5em 0; - list-style: none; font-size: 85%;} -#nav ul li {padding: 0.15em 0 0.1em 0.5em;} -#nav ul ul {padding: 0 0 0 1em; margin: 0; border-left: none; font-size: 90%; font-style: italic;} -#nav ul ul li {padding-top: 1px; text-indent: -0.5em;} -#nav ul li em {font-weight: bold; padding: 0; margin: 0; border-bottom: 1px dotted red; width: .5em; } -#nav ul ul em {font-weight: bold; padding: 0; margin: 0; border-bottom: 1px dotted red; width: .5em; } -#nav ul ul li em {font-weight: bold; padding: 0; margin: 0; border-bottom: 1px dotted red; width: .5em; } -#nav #select {font-weight: bold; font-style: italic; letter-spacing: 1px; text-transform: lowercase; - border-style: dotted; border-width: 1px 3px 1px 2px; border-right: none; margin-left: -1px;} - -#style li.sub:hover {margin-left: -10.2em; border: 1px solid gray; background: #DDB;} -#style li.sub:hover > a {color: #330;} -#style li.sub:hover > ul {top: 1.75em; left: -1px; background: #FEFEFC;} - -#style {position: absolute; right: 0%; top: 1.0em; - padding: 0; margin: 0; - font-family: Arial, sans-serif;} -#style h4 {margin: 0; padding: 0.25em 0.5em 1px 0.25em; - font-size: 0.9em; font-style: italic; line-height: 0.7em; - letter-spacing: 1px; text-transform: lowercase; - border-style: solid solid dotted; border-width: 1px 0 1px 2px;} -#style #sandb1 {font-weight: bold; font-style: italic; letter-spacing: 1px; text-transform: lowercase; - border: 1px dotted; border-top: none; margin-left: -1px;} - -#style li.sub:hover {margin-left: -10.2em; border: 1px solid gray; background: #DDB;} -#style li.sub:hover > a {color: #330;} -#style li.sub:hover > ul {top: 1.75em; left: -1px; background: #FEFEFC;} - -#footer {border-top: 2.5px double; margin: 0; padding: 0.25em; text-align: left; font-size: 75%;} -#footer p {margin: 0; padding: 0; text-align: center} -#footer img, #nav img {padding:0; margin: 0; border:0; vertical-align: middle; } - -img {border:0;} - -/* home styles */ - -body.home #main {padding-left: 120px;} -body.home #main img.pic {position: absolute; left: -1em; top: 6.25em; z-index: 100;} - - -/* colors and backgrounds */ - -body {background: #FFFFFF url(bigsbbg.gif) no-repeat fixed center; - color: #42384C;} - -#header, #nav ul, #nav #sandb1, #footer {border-color: #738CA6;} -#main h2, #main h2 a {border-color: #414066;} -#thoughts * {border-color: #5B5980;} - -#main a:link {color: #006691;} -#main a:hover {color: #006691; background-color: #ddeeff;} - -#header {background: #BAC5D1;} -#header h1 {background: #738CA6;} -#header h1 a {color: #343366;} - -#main h2 a {color: #00294C;} - -#nav {background: #BCCAE0;} -#nav h4 {border-color: #667F99; color: #343366; background: #B2BFD9;} -#nav ul {background: none;} -#nav ul ul {background: none;} - -#navlinks a:link {color: #4C6580;} -#navlinks a:visited, #stylelinks a {color: #818099;} -#nav a:hover {color: #334180;} -#style #sandb1 {background: #C7D4E6;} -#style #sandb1 a {color: #4D4C66;} - -#style a {font-size: 70%; background: transparent; color: #FFFFFF} -#style a:hover {font-size:70%; background: transparent; color: #683399} -#style a:visited {font-size:70%; background: transparent; color: #FFFFFF} -#style a span {display: none;} -#style a:hover span {display: block; position: absolute; bottom: 2px; left: 0; width: 265px; padding: 1px; margin: 1px; z-index: 100; color: #ffffff; background: #000066; font: 10px Verdana, sans-serif; text-align: center;} - -.sField { border-width:1px; border-style:solid; border-color:#ffffff; background-color:#333399;font-family: Arial, Helvetica, sans-serif;color: #ffffff; margin: 0; padding: 0; } -.sButton { border-width:1px; border-style:solid; border-color:#ffffff; background-color:#333399;font-family: Arial, Helvetica, sans-serif;color: #ffffff; margin: 0; padding: 0; } -.eField { border-width:1px; border-style:solid; border-color:#6495ED; background-color:#F0F8FF;font-family: Arial, Helvetica, sans-serif;color: #000000; } -.eButton { border-width:1px; border-style:solid; border-color:#6495ED; background-color:#F0F8FF;font-family: Arial, Helvetica, sans-serif;color: #000000;} -.mid { vertical-align: middle; } -.line { color: #6495ED; border-top: 3px solid #6495ED; border-bottom: 2px solid #000080; height: 5px; border-left: none; } - -input { font: 60% verdana,sans-serif; vertical-align: middle; } -.sField:hover, .sField:focus { background-color: #336699 } -.sButton:hover, .sButton:focus { background-color: #336699 } -.eField:hover, .eField:focus { background-color: #DFEFFF} -.eButton:hover, .eButton:focus { background-color: #DFEFFF } - -#bt {position: absolute; right: 0%; margin-right: 24%;} - -#gl { text-align: center; vertical-align: middle; margin: 0; padding: 0; } - - -#footer {color: #343366; background: #BAC5D1;} - - -a:visited {color: #4C6580; background: transparent;} - -#navlinks li a:hover:after, #navlinks li a:focus:after {content: " [" attr(accesskey) "] ";} - -acronym {border-bottom: 1px dashed #0063CC; cursor: help;} - - - -/* fix IE6 rendering bugs */ - -#header h1 {position: relative;} -#header>h1 {position: static;} - -html>body #main p, html>body #main h3, html>body #main dt, html>body #main ul, html>body #main li, html>body #main ol {background: url(bigsbbg2.gif) no-repeat fixed center;} diff --git a/src/dom/work/smil.idl b/src/dom/work/smil.idl deleted file mode 100644 index 29fd3754d..000000000 --- a/src/dom/work/smil.idl +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more - * details. - */ - -// File: smil.idl -#ifndef _SMIL_IDL_ -#define _SMIL_IDL_ - -#include "dom.idl" -#include "views.idl" -#include "events.idl" - -#pragma prefix "dom.w3c.org" -module smil -{ - typedef dom::DOMString DOMString; - typedef dom::Element Element; - typedef dom::NodeList NodeList; - typedef dom::Document Document; - - interface SMILRegionElement; - - interface ElementLayout { - attribute DOMString title; - // raises(dom::DOMException) on setting - - attribute DOMString backgroundColor; - // raises(dom::DOMException) on setting - - attribute long height; - // raises(dom::DOMException) on setting - - attribute long width; - // raises(dom::DOMException) on setting - - }; - - interface SMILRegionInterface { - attribute SMILRegionElement region; - }; - - interface Time { - readonly attribute boolean resolved; - readonly attribute double resolvedOffset; - // TimeTypes - const unsigned short SMIL_TIME_INDEFINITE = 0; - const unsigned short SMIL_TIME_OFFSET = 1; - const unsigned short SMIL_TIME_SYNC_BASED = 2; - const unsigned short SMIL_TIME_EVENT_BASED = 3; - const unsigned short SMIL_TIME_WALLCLOCK = 4; - const unsigned short SMIL_TIME_MEDIA_MARKER = 5; - - readonly attribute unsigned short timeType; - attribute double offset; - // raises(dom::DOMException) on setting - - attribute Element baseElement; - // raises(dom::DOMException) on setting - - attribute boolean baseBegin; - // raises(dom::DOMException) on setting - - attribute DOMString event; - // raises(dom::DOMException) on setting - - attribute DOMString marker; - // raises(dom::DOMException) on setting - - }; - - interface TimeList { - Time item(in unsigned long index); - readonly attribute unsigned long length; - }; - - interface ElementTime { - attribute TimeList begin; - // raises(dom::DOMException) on setting - - attribute TimeList end; - // raises(dom::DOMException) on setting - - attribute float dur; - // raises(dom::DOMException) on setting - - // restartTypes - const unsigned short RESTART_ALWAYS = 0; - const unsigned short RESTART_NEVER = 1; - const unsigned short RESTART_WHEN_NOT_ACTIVE = 2; - - attribute unsigned short restart; - // raises(dom::DOMException) on setting - - // fillTypes - const unsigned short FILL_REMOVE = 0; - const unsigned short FILL_FREEZE = 1; - - attribute unsigned short fill; - // raises(dom::DOMException) on setting - - attribute float repeatCount; - // raises(dom::DOMException) on setting - - attribute float repeatDur; - // raises(dom::DOMException) on setting - - boolean beginElement(); - boolean endElement(); - void pauseElement(); - void resumeElement(); - void seekElement(inout float seekTo); - }; - - interface ElementTimeManipulation { - attribute float speed; - // raises(dom::DOMException) on setting - - attribute float accelerate; - // raises(dom::DOMException) on setting - - attribute float decelerate; - // raises(dom::DOMException) on setting - - attribute boolean autoReverse; - // raises(dom::DOMException) on setting - - }; - - interface ElementTimeContainer : ElementTime { - readonly attribute NodeList timeChildren; - NodeList getActiveChildrenAt(in float instant); - }; - - interface ElementSyncBehavior { - readonly attribute DOMString syncBehavior; - readonly attribute float syncTolerance; - readonly attribute DOMString defaultSyncBehavior; - readonly attribute float defaultSyncTolerance; - readonly attribute boolean syncMaster; - }; - - interface ElementParallelTimeContainer : ElementTimeContainer { - attribute DOMString endSync; - // raises(dom::DOMException) on setting - - float getImplicitDuration(); - }; - - interface ElementSequentialTimeContainer : ElementTimeContainer { - }; - - interface ElementExclusiveTimeContainer : ElementTimeContainer { - attribute DOMString endSync; - // raises(dom::DOMException) on setting - - NodeList getPausedElements(); - }; - - interface ElementTimeControl { - boolean beginElement() - raises(dom::DOMException); - boolean beginElementAt(in float offset) - raises(dom::DOMException); - boolean endElement() - raises(dom::DOMException); - boolean endElementAt(in float offset) - raises(dom::DOMException); - }; - - interface ElementTargetAttributes { - attribute DOMString attributeName; - // attributeTypes - const unsigned short ATTRIBUTE_TYPE_AUTO = 0; - const unsigned short ATTRIBUTE_TYPE_CSS = 1; - const unsigned short ATTRIBUTE_TYPE_XML = 2; - - attribute unsigned short attributeType; - }; - - interface ElementTest { - attribute long systemBitrate; - // raises(dom::DOMException) on setting - - attribute boolean systemCaptions; - // raises(dom::DOMException) on setting - - attribute DOMString systemLanguage; - // raises(dom::DOMException) on setting - - readonly attribute boolean systemRequired; - readonly attribute boolean systemScreenSize; - readonly attribute boolean systemScreenDepth; - attribute DOMString systemOverdubOrSubtitle; - // raises(dom::DOMException) on setting - - attribute boolean systemAudioDesc; - // raises(dom::DOMException) on setting - - }; - - interface SMILDocument : Document, ElementSequentialTimeContainer { - }; - - interface SMILElement : Element { - attribute DOMString id; - // raises(dom::DOMException) on setting - - }; - - interface SMILLayoutElement : SMILElement { - readonly attribute DOMString type; - readonly attribute boolean resolved; - }; - - interface SMILTopLayoutElement : SMILElement, ElementLayout { - }; - - interface SMILRootLayoutElement : SMILElement, ElementLayout { - }; - - interface SMILRegionElement : SMILElement, ElementLayout { - attribute DOMString fit; - // raises(dom::DOMException) on setting - - attribute DOMString top; - // raises(dom::DOMException) on setting - - attribute long zIndex; - // raises(dom::DOMException) on setting - - }; - - interface TimeEvent : events::Event { - readonly attribute views::AbstractView view; - readonly attribute long detail; - void initTimeEvent(in DOMString typeArg, - in views::AbstractView viewArg, - in long detailArg); - }; - - interface SMILMediaElement : ElementTime, SMILElement { - attribute DOMString abstractAttr; - // raises(dom::DOMException) on setting - - attribute DOMString alt; - // raises(dom::DOMException) on setting - - attribute DOMString author; - // raises(dom::DOMException) on setting - - attribute DOMString clipBegin; - // raises(dom::DOMException) on setting - - attribute DOMString clipEnd; - // raises(dom::DOMException) on setting - - attribute DOMString copyright; - // raises(dom::DOMException) on setting - - attribute DOMString longdesc; - // raises(dom::DOMException) on setting - - attribute DOMString port; - // raises(dom::DOMException) on setting - - attribute DOMString readIndex; - // raises(dom::DOMException) on setting - - attribute DOMString rtpformat; - // raises(dom::DOMException) on setting - - attribute DOMString src; - // raises(dom::DOMException) on setting - - attribute DOMString stripRepeat; - // raises(dom::DOMException) on setting - - attribute DOMString title; - // raises(dom::DOMException) on setting - - attribute DOMString transport; - // raises(dom::DOMException) on setting - - attribute DOMString type; - // raises(dom::DOMException) on setting - - }; - - interface SMILRefElement : SMILMediaElement { - }; - - interface SMILAnimation : SMILElement, ElementTargetAttributes, ElementTime, ElementTimeControl { - // additiveTypes - const unsigned short ADDITIVE_REPLACE = 0; - const unsigned short ADDITIVE_SUM = 1; - - attribute unsigned short additive; - // raises(dom::DOMException) on setting - - // accumulateTypes - const unsigned short ACCUMULATE_NONE = 0; - const unsigned short ACCUMULATE_SUM = 1; - - attribute unsigned short accumulate; - // raises(dom::DOMException) on setting - - // calcModeTypes - const unsigned short CALCMODE_DISCRETE = 0; - const unsigned short CALCMODE_LINEAR = 1; - const unsigned short CALCMODE_PACED = 2; - const unsigned short CALCMODE_SPLINE = 3; - - attribute unsigned short calcMode; - // raises(dom::DOMException) on setting - - attribute DOMString keySplines; - // raises(dom::DOMException) on setting - - attribute TimeList keyTimes; - // raises(dom::DOMException) on setting - - attribute DOMString values; - // raises(dom::DOMException) on setting - - attribute DOMString from; - // raises(dom::DOMException) on setting - - attribute DOMString to; - // raises(dom::DOMException) on setting - - attribute DOMString by; - // raises(dom::DOMException) on setting - - }; - - interface SMILAnimateElement : SMILAnimation { - }; - - interface SMILSetElement : ElementTimeControl, ElementTime, ElementTargetAttributes, SMILElement { - attribute DOMString to; - }; - - interface SMILAnimateMotionElement : SMILAnimateElement { - attribute DOMString path; - // raises(dom::DOMException) on setting - - attribute DOMString origin; - // raises(dom::DOMException) on setting - - }; - - interface SMILAnimateColorElement : SMILAnimation { - }; - - interface SMILSwitchElement : SMILElement { - Element getSelectedElement(); - }; -}; - -#endif // _SMIL_IDL_ - diff --git a/src/dom/work/stylesheets.idl b/src/dom/work/stylesheets.idl deleted file mode 100644 index 1bc307370..000000000 --- a/src/dom/work/stylesheets.idl +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -// File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl - -#ifndef _STYLESHEETS_IDL_ -#define _STYLESHEETS_IDL_ - -#include "dom.idl" - -#pragma prefix "dom.w3c.org" -module stylesheets -{ - - typedef dom::DOMString DOMString; - typedef dom::Node Node; - - interface MediaList; - - // Introduced in DOM Level 2: - interface StyleSheet { - readonly attribute DOMString type; - attribute boolean disabled; - readonly attribute Node ownerNode; - readonly attribute StyleSheet parentStyleSheet; - readonly attribute DOMString href; - readonly attribute DOMString title; - readonly attribute MediaList media; - }; - - // Introduced in DOM Level 2: - interface StyleSheetList { - readonly attribute unsigned long length; - StyleSheet item(in unsigned long index); - }; - - // Introduced in DOM Level 2: - interface MediaList { - attribute DOMString mediaText; - // raises(dom::DOMException) on setting - - readonly attribute unsigned long length; - DOMString item(in unsigned long index); - void deleteMedium(in DOMString oldMedium) - raises(dom::DOMException); - void appendMedium(in DOMString newMedium) - raises(dom::DOMException); - }; - - // Introduced in DOM Level 2: - interface LinkStyle { - readonly attribute StyleSheet sheet; - }; - - // Introduced in DOM Level 2: - interface DocumentStyle { - readonly attribute StyleSheetList styleSheets; - }; -}; - -#endif // _STYLESHEETS_IDL_ - diff --git a/src/dom/work/svg.idl b/src/dom/work/svg.idl deleted file mode 100644 index 1a30dd3be..000000000 --- a/src/dom/work/svg.idl +++ /dev/null @@ -1,1751 +0,0 @@ -// File: svg.idl -#ifndef _SVG_IDL_ -#define _SVG_IDL_ - - -// For access to DOM2 core -#include "dom.idl" - -// For access to DOM2 events -#include "events.idl" - -// For access to those parts from DOM2 CSS OM used by SVG DOM. -#include "css.idl" - -// For access to those parts from DOM2 Views OM used by SVG DOM. -#include "views.idl" - -// For access to the SMIL OM used by SVG DOM. -#include "smil.idl" - -#pragma prefix "dom.w3c.org" -#pragma javaPackage "org.w3c.dom" -module svg -{ - typedef dom::DOMString DOMString; - typedef dom::DOMException DOMException; - typedef dom::Element Element; - typedef dom::Document Document; - typedef dom::NodeList NodeList; - - // Predeclarations - interface SVGElement; - interface SVGLangSpace; - interface SVGExternalResourcesRequired; - interface SVGTests; - interface SVGFitToViewBox; - interface SVGZoomAndPan; - interface SVGViewSpec; - interface SVGURIReference; - interface SVGPoint; - interface SVGMatrix; - interface SVGPreserveAspectRatio; - interface SVGAnimatedPreserveAspectRatio; - interface SVGTransformList; - interface SVGAnimatedTransformList; - interface SVGTransform; - interface SVGICCColor; - interface SVGColor; - interface SVGPaint; - interface SVGTransformable; - interface SVGDocument; - interface SVGSVGElement; - interface SVGElementInstance; - interface SVGElementInstanceList; - - - exception SVGException { - unsigned short code; - }; - - // SVGExceptionCode - const unsigned short SVG_WRONG_TYPE_ERR = 0; - const unsigned short SVG_INVALID_VALUE_ERR = 1; - const unsigned short SVG_MATRIX_NOT_INVERTABLE = 2; - - interface SVGElement : Element { - attribute DOMString id; - // raises DOMException on setting - attribute DOMString xmlbase; - // raises DOMException on setting - readonly attribute SVGSVGElement ownerSVGElement; - readonly attribute SVGElement viewportElement; - }; - - interface SVGAnimatedBoolean { - - attribute boolean baseVal; - // raises DOMException on setting - readonly attribute boolean animVal; - }; - - interface SVGAnimatedString { - - attribute DOMString baseVal; - // raises DOMException on setting - readonly attribute DOMString animVal; - }; - - interface SVGStringList { - - readonly attribute unsigned long numberOfItems; - - void clear ( ) - raises( DOMException ); - DOMString initialize ( in DOMString newItem ) - raises( DOMException, SVGException ); - DOMString getItem ( in unsigned long index ) - raises( DOMException ); - DOMString insertItemBefore ( in DOMString newItem, in unsigned long index ) - raises( DOMException, SVGException ); - DOMString replaceItem ( in DOMString newItem, in unsigned long index ) - raises( DOMException, SVGException ); - DOMString removeItem ( in unsigned long index ) - raises( DOMException ); - DOMString appendItem ( in DOMString newItem ) - raises( DOMException, SVGException ); - }; - - interface SVGAnimatedEnumeration { - - attribute unsigned short baseVal; - // raises DOMException on setting - readonly attribute unsigned short animVal; - }; - - interface SVGAnimatedInteger { - - attribute long baseVal; - // raises DOMException on setting - readonly attribute long animVal; - }; - - interface SVGNumber { - - attribute float value; - // raises DOMException on setting - }; - - interface SVGAnimatedNumber { - - attribute float baseVal; - // raises DOMException on setting - readonly attribute float animVal; - }; - - interface SVGNumberList { - - readonly attribute unsigned long numberOfItems; - - void clear ( ) - raises( DOMException ); - SVGNumber initialize ( in SVGNumber newItem ) - raises( DOMException, SVGException ); - SVGNumber getItem ( in unsigned long index ) - raises( DOMException ); - SVGNumber insertItemBefore ( in SVGNumber newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGNumber replaceItem ( in SVGNumber newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGNumber removeItem ( in unsigned long index ) - raises( DOMException ); - SVGNumber appendItem ( in SVGNumber newItem ) - raises( DOMException, SVGException ); - }; - - interface SVGAnimatedNumberList { - - readonly attribute SVGNumberList baseVal; - readonly attribute SVGNumberList animVal; - }; - - interface SVGLength { - - // Length Unit Types - const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0; - const unsigned short SVG_LENGTHTYPE_NUMBER = 1; - const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2; - const unsigned short SVG_LENGTHTYPE_EMS = 3; - const unsigned short SVG_LENGTHTYPE_EXS = 4; - const unsigned short SVG_LENGTHTYPE_PX = 5; - const unsigned short SVG_LENGTHTYPE_CM = 6; - const unsigned short SVG_LENGTHTYPE_MM = 7; - const unsigned short SVG_LENGTHTYPE_IN = 8; - const unsigned short SVG_LENGTHTYPE_PT = 9; - const unsigned short SVG_LENGTHTYPE_PC = 10; - - readonly attribute unsigned short unitType; - attribute float value; - // raises DOMException on setting - attribute float valueInSpecifiedUnits; - // raises DOMException on setting - attribute DOMString valueAsString; - // raises DOMException on setting - - void newValueSpecifiedUnits ( in unsigned short unitType, in float valueInSpecifiedUnits ); - void convertToSpecifiedUnits ( in unsigned short unitType ); - }; - - interface SVGAnimatedLength { - - readonly attribute SVGLength baseVal; - readonly attribute SVGLength animVal; - }; - - interface SVGLengthList { - - readonly attribute unsigned long numberOfItems; - - void clear ( ) - raises( DOMException ); - SVGLength initialize ( in SVGLength newItem ) - raises( DOMException, SVGException ); - SVGLength getItem ( in unsigned long index ) - raises( DOMException ); - SVGLength insertItemBefore ( in SVGLength newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGLength replaceItem ( in SVGLength newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGLength removeItem ( in unsigned long index ) - raises( DOMException ); - SVGLength appendItem ( in SVGLength newItem ) - raises( DOMException, SVGException ); - }; - - interface SVGAnimatedLengthList { - - readonly attribute SVGLengthList baseVal; - readonly attribute SVGLengthList animVal; - }; - - interface SVGAngle { - - // Angle Unit Types - const unsigned short SVG_ANGLETYPE_UNKNOWN = 0; - const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1; - const unsigned short SVG_ANGLETYPE_DEG = 2; - const unsigned short SVG_ANGLETYPE_RAD = 3; - const unsigned short SVG_ANGLETYPE_GRAD = 4; - - readonly attribute unsigned short unitType; - attribute float value; - // raises DOMException on setting - attribute float valueInSpecifiedUnits; - // raises DOMException on setting - attribute DOMString valueAsString; - // raises DOMException on setting - - void newValueSpecifiedUnits ( in unsigned short unitType, in float valueInSpecifiedUnits ); - void convertToSpecifiedUnits ( in unsigned short unitType ); - }; - - interface SVGAnimatedAngle { - - readonly attribute SVGAngle baseVal; - readonly attribute SVGAngle animVal; - }; - - interface SVGColor : css::CSSValue { - // Color Types - const unsigned short SVG_COLORTYPE_UNKNOWN = 0; - const unsigned short SVG_COLORTYPE_RGBCOLOR = 1; - const unsigned short SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2; - const unsigned short SVG_COLORTYPE_CURRENTCOLOR = 3; - - readonly attribute unsigned short colorType; - readonly attribute css::RGBColor rgbColor; - readonly attribute SVGICCColor iccColor; - - void setRGBColor ( in DOMString rgbColor ) - raises( SVGException ); - void setRGBColorICCColor ( in DOMString rgbColor, in DOMString iccColor ) - raises( SVGException ); - void setColor ( in unsigned short colorType, in DOMString rgbColor, in DOMString iccColor ) - raises( SVGException ); - }; - - interface SVGICCColor { - - attribute DOMString colorProfile; - // raises DOMException on setting - readonly attribute SVGNumberList colors; - }; - - interface SVGRect { - - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float width; - // raises DOMException on setting - attribute float height; - // raises DOMException on setting - }; - - interface SVGAnimatedRect { - - readonly attribute SVGRect baseVal; - readonly attribute SVGRect animVal; - }; - - interface SVGUnitTypes { - - // Unit Types - const unsigned short SVG_UNIT_TYPE_UNKNOWN = 0; - const unsigned short SVG_UNIT_TYPE_USERSPACEONUSE = 1; - const unsigned short SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2; - }; - - interface SVGStylable { - - readonly attribute SVGAnimatedString className; - readonly attribute css::CSSStyleDeclaration style; - - css::CSSValue getPresentationAttribute ( in DOMString name ); - }; - - interface SVGLocatable { - - readonly attribute SVGElement nearestViewportElement; - readonly attribute SVGElement farthestViewportElement; - - SVGRect getBBox ( ); - SVGMatrix getCTM ( ); - SVGMatrix getScreenCTM ( ); - SVGMatrix getTransformToElement ( in SVGElement element ) - raises( SVGException ); - }; - - interface SVGTransformable : SVGLocatable { - readonly attribute SVGAnimatedTransformList transform; - }; - - interface SVGTests { - - readonly attribute SVGStringList requiredFeatures; - readonly attribute SVGStringList requiredExtensions; - readonly attribute SVGStringList systemLanguage; - - boolean hasExtension ( in DOMString extension ); - }; - - interface SVGLangSpace { - - attribute DOMString xmllang; - // raises DOMException on setting - attribute DOMString xmlspace; - // raises DOMException on setting - }; - - interface SVGExternalResourcesRequired { - - readonly attribute SVGAnimatedBoolean externalResourcesRequired; - }; - - interface SVGFitToViewBox { - - readonly attribute SVGAnimatedRect viewBox; - readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio; - }; - - interface SVGZoomAndPan { - - // Zoom and Pan Types - const unsigned short SVG_ZOOMANDPAN_UNKNOWN = 0; - const unsigned short SVG_ZOOMANDPAN_DISABLE = 1; - const unsigned short SVG_ZOOMANDPAN_MAGNIFY = 2; - - attribute unsigned short zoomAndPan; - // raises DOMException on setting - }; - - interface SVGViewSpec : - SVGZoomAndPan, - SVGFitToViewBox { - - readonly attribute SVGTransformList transform; - readonly attribute SVGElement viewTarget; - readonly attribute DOMString viewBoxString; - readonly attribute DOMString preserveAspectRatioString; - readonly attribute DOMString transformString; - readonly attribute DOMString viewTargetString; - }; - - interface SVGURIReference { - - readonly attribute SVGAnimatedString href; - }; - - interface SVGCSSRule : css::CSSRule { - // Additional CSS RuleType to support ICC color specifications - const unsigned short COLOR_PROFILE_RULE = 7; - }; - - interface SVGRenderingIntent { - - // Rendering Intent Types - const unsigned short RENDERING_INTENT_UNKNOWN = 0; - const unsigned short RENDERING_INTENT_AUTO = 1; - const unsigned short RENDERING_INTENT_PERCEPTUAL = 2; - const unsigned short RENDERING_INTENT_RELATIVE_COLORIMETRIC = 3; - const unsigned short RENDERING_INTENT_SATURATION = 4; - const unsigned short RENDERING_INTENT_ABSOLUTE_COLORIMETRIC = 5; - }; - - interface SVGDocument : - Document, - events::DocumentEvent { - - readonly attribute DOMString title; - readonly attribute DOMString referrer; - readonly attribute DOMString domain; - readonly attribute DOMString URL; - readonly attribute SVGSVGElement rootElement; - }; - - interface SVGSVGElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGLocatable, - SVGFitToViewBox, - SVGZoomAndPan, - events::EventTarget, - events::DocumentEvent, - css::ViewCSS, - css::DocumentCSS { - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - attribute DOMString contentScriptType; - // raises DOMException on setting - attribute DOMString contentStyleType; - // raises DOMException on setting - readonly attribute SVGRect viewport; - readonly attribute float pixelUnitToMillimeterX; - readonly attribute float pixelUnitToMillimeterY; - readonly attribute float screenPixelToMillimeterX; - readonly attribute float screenPixelToMillimeterY; - attribute boolean useCurrentView; - // raises DOMException on setting - readonly attribute SVGViewSpec currentView; - attribute float currentScale; - // raises DOMException on setting - readonly attribute SVGPoint currentTranslate; - - unsigned long suspendRedraw ( in unsigned long max_wait_milliseconds ); - void unsuspendRedraw ( in unsigned long suspend_handle_id ) - raises( DOMException ); - void unsuspendRedrawAll ( ); - void forceRedraw ( ); - void pauseAnimations ( ); - void unpauseAnimations ( ); - boolean animationsPaused ( ); - float getCurrentTime ( ); - void setCurrentTime ( in float seconds ); - NodeList getIntersectionList ( in SVGRect rect, in SVGElement referenceElement ); - NodeList getEnclosureList ( in SVGRect rect, in SVGElement referenceElement ); - boolean checkIntersection ( in SVGElement element, in SVGRect rect ); - boolean checkEnclosure ( in SVGElement element, in SVGRect rect ); - void deselectAll ( ); - SVGNumber createSVGNumber ( ); - SVGLength createSVGLength ( ); - SVGAngle createSVGAngle ( ); - SVGPoint createSVGPoint ( ); - SVGMatrix createSVGMatrix ( ); - SVGRect createSVGRect ( ); - SVGTransform createSVGTransform ( ); - SVGTransform createSVGTransformFromMatrix ( in SVGMatrix matrix ); - Element getElementById ( in DOMString elementId ); - }; - - interface SVGGElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget {}; - - interface SVGDefsElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget {}; - - interface SVGDescElement : - SVGElement, - SVGLangSpace, - SVGStylable {}; - - interface SVGTitleElement : - SVGElement, - SVGLangSpace, - SVGStylable {}; - - interface SVGSymbolElement : - SVGElement, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGFitToViewBox, - events::EventTarget {}; - - interface SVGUseElement : - SVGElement, - SVGURIReference, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGElementInstance instanceRoot; - readonly attribute SVGElementInstance animatedInstanceRoot; - }; - - interface SVGElementInstance : events::EventTarget { - readonly attribute SVGElement correspondingElement; - readonly attribute SVGUseElement correspondingUseElement; - readonly attribute SVGElementInstance parentNode; - readonly attribute SVGElementInstanceList childNodes; - readonly attribute SVGElementInstance firstChild; - readonly attribute SVGElementInstance lastChild; - readonly attribute SVGElementInstance previousSibling; - readonly attribute SVGElementInstance nextSibling; - }; - - interface SVGElementInstanceList { - - readonly attribute unsigned long length; - - SVGElementInstance item ( in unsigned long index ); - }; - - interface SVGImageElement : - SVGElement, - SVGURIReference, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio; - }; - - interface SVGSwitchElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget {}; - - interface GetSVGDocument { - - SVGDocument getSVGDocument ( ) - raises( DOMException ); - }; - - interface SVGStyleElement : SVGElement { - attribute DOMString xmlspace; - // raises DOMException on setting - attribute DOMString type; - // raises DOMException on setting - attribute DOMString media; - // raises DOMException on setting - attribute DOMString title; - // raises DOMException on setting - }; - - interface SVGPoint { - - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - - SVGPoint matrixTransform ( in SVGMatrix matrix ); - }; - - interface SVGPointList { - - readonly attribute unsigned long numberOfItems; - - void clear ( ) - raises( DOMException ); - SVGPoint initialize ( in SVGPoint newItem ) - raises( DOMException, SVGException ); - SVGPoint getItem ( in unsigned long index ) - raises( DOMException ); - SVGPoint insertItemBefore ( in SVGPoint newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGPoint replaceItem ( in SVGPoint newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGPoint removeItem ( in unsigned long index ) - raises( DOMException ); - SVGPoint appendItem ( in SVGPoint newItem ) - raises( DOMException, SVGException ); - }; - - interface SVGMatrix { - - attribute float a; - // raises DOMException on setting - attribute float b; - // raises DOMException on setting - attribute float c; - // raises DOMException on setting - attribute float d; - // raises DOMException on setting - attribute float e; - // raises DOMException on setting - attribute float f; - // raises DOMException on setting - - SVGMatrix multiply ( in SVGMatrix secondMatrix ); - SVGMatrix inverse ( ) - raises( SVGException ); - SVGMatrix translate ( in float x, in float y ); - SVGMatrix scale ( in float scaleFactor ); - SVGMatrix scaleNonUniform ( in float scaleFactorX, in float scaleFactorY ); - SVGMatrix rotate ( in float angle ); - SVGMatrix rotateFromVector ( in float x, in float y ) - raises( SVGException ); - SVGMatrix flipX ( ); - SVGMatrix flipY ( ); - SVGMatrix skewX ( in float angle ); - SVGMatrix skewY ( in float angle ); - }; - - interface SVGTransform { - - // Transform Types - const unsigned short SVG_TRANSFORM_UNKNOWN = 0; - const unsigned short SVG_TRANSFORM_MATRIX = 1; - const unsigned short SVG_TRANSFORM_TRANSLATE = 2; - const unsigned short SVG_TRANSFORM_SCALE = 3; - const unsigned short SVG_TRANSFORM_ROTATE = 4; - const unsigned short SVG_TRANSFORM_SKEWX = 5; - const unsigned short SVG_TRANSFORM_SKEWY = 6; - - readonly attribute unsigned short type; - readonly attribute SVGMatrix matrix; - readonly attribute float angle; - - void setMatrix ( in SVGMatrix matrix ); - void setTranslate ( in float tx, in float ty ); - void setScale ( in float sx, in float sy ); - void setRotate ( in float angle, in float cx, in float cy ); - void setSkewX ( in float angle ); - void setSkewY ( in float angle ); - }; - - interface SVGTransformList { - - readonly attribute unsigned long numberOfItems; - - void clear ( ) - raises( DOMException ); - SVGTransform initialize ( in SVGTransform newItem ) - raises( DOMException, SVGException ); - SVGTransform getItem ( in unsigned long index ) - raises( DOMException ); - SVGTransform insertItemBefore ( in SVGTransform newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGTransform replaceItem ( in SVGTransform newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGTransform removeItem ( in unsigned long index ) - raises( DOMException ); - SVGTransform appendItem ( in SVGTransform newItem ) - raises( DOMException, SVGException ); - SVGTransform createSVGTransformFromMatrix ( in SVGMatrix matrix ); - SVGTransform consolidate ( ); - }; - - interface SVGAnimatedTransformList { - - readonly attribute SVGTransformList baseVal; - readonly attribute SVGTransformList animVal; - }; - - interface SVGPreserveAspectRatio { - - // Alignment Types - const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0; - const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1; - const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMIN = 2; - const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3; - const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4; - const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMID = 5; - const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMID = 6; - const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMID = 7; - const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMAX = 8; - const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9; - const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10; - // Meet-or-slice Types - const unsigned short SVG_MEETORSLICE_UNKNOWN = 0; - const unsigned short SVG_MEETORSLICE_MEET = 1; - const unsigned short SVG_MEETORSLICE_SLICE = 2; - - attribute unsigned short align; - // raises DOMException on setting - attribute unsigned short meetOrSlice; - // raises DOMException on setting - }; - - interface SVGAnimatedPreserveAspectRatio { - - readonly attribute SVGPreserveAspectRatio baseVal; - readonly attribute SVGPreserveAspectRatio animVal; - }; - - interface SVGPathSeg { - - // Path Segment Types - const unsigned short PATHSEG_UNKNOWN = 0; - const unsigned short PATHSEG_CLOSEPATH = 1; - const unsigned short PATHSEG_MOVETO_ABS = 2; - const unsigned short PATHSEG_MOVETO_REL = 3; - const unsigned short PATHSEG_LINETO_ABS = 4; - const unsigned short PATHSEG_LINETO_REL = 5; - const unsigned short PATHSEG_CURVETO_CUBIC_ABS = 6; - const unsigned short PATHSEG_CURVETO_CUBIC_REL = 7; - const unsigned short PATHSEG_CURVETO_QUADRATIC_ABS = 8; - const unsigned short PATHSEG_CURVETO_QUADRATIC_REL = 9; - const unsigned short PATHSEG_ARC_ABS = 10; - const unsigned short PATHSEG_ARC_REL = 11; - const unsigned short PATHSEG_LINETO_HORIZONTAL_ABS = 12; - const unsigned short PATHSEG_LINETO_HORIZONTAL_REL = 13; - const unsigned short PATHSEG_LINETO_VERTICAL_ABS = 14; - const unsigned short PATHSEG_LINETO_VERTICAL_REL = 15; - const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; - const unsigned short PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; - const unsigned short PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; - const unsigned short PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; - - readonly attribute unsigned short pathSegType; - readonly attribute DOMString pathSegTypeAsLetter; - }; - - interface SVGPathSegClosePath : SVGPathSeg {}; - - interface SVGPathSegMovetoAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegMovetoRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegLinetoAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegLinetoRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoCubicAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float x1; - // raises DOMException on setting - attribute float y1; - // raises DOMException on setting - attribute float x2; - // raises DOMException on setting - attribute float y2; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoCubicRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float x1; - // raises DOMException on setting - attribute float y1; - // raises DOMException on setting - attribute float x2; - // raises DOMException on setting - attribute float y2; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoQuadraticAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float x1; - // raises DOMException on setting - attribute float y1; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoQuadraticRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float x1; - // raises DOMException on setting - attribute float y1; - // raises DOMException on setting - }; - - interface SVGPathSegArcAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float r1; - // raises DOMException on setting - attribute float r2; - // raises DOMException on setting - attribute float angle; - // raises DOMException on setting - attribute boolean largeArcFlag; - // raises DOMException on setting - attribute boolean sweepFlag; - // raises DOMException on setting - }; - - interface SVGPathSegArcRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float r1; - // raises DOMException on setting - attribute float r2; - // raises DOMException on setting - attribute float angle; - // raises DOMException on setting - attribute boolean largeArcFlag; - // raises DOMException on setting - attribute boolean sweepFlag; - // raises DOMException on setting - }; - - interface SVGPathSegLinetoHorizontalAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - }; - - interface SVGPathSegLinetoHorizontalRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - }; - - interface SVGPathSegLinetoVerticalAbs : SVGPathSeg { - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegLinetoVerticalRel : SVGPathSeg { - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoCubicSmoothAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float x2; - // raises DOMException on setting - attribute float y2; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoCubicSmoothRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float x2; - // raises DOMException on setting - attribute float y2; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoQuadraticSmoothAbs : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegCurvetoQuadraticSmoothRel : SVGPathSeg { - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - }; - - interface SVGPathSegList { - - readonly attribute unsigned long numberOfItems; - - void clear ( ) - raises( DOMException ); - SVGPathSeg initialize ( in SVGPathSeg newItem ) - raises( DOMException, SVGException ); - SVGPathSeg getItem ( in unsigned long index ) - raises( DOMException ); - SVGPathSeg insertItemBefore ( in SVGPathSeg newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGPathSeg replaceItem ( in SVGPathSeg newItem, in unsigned long index ) - raises( DOMException, SVGException ); - SVGPathSeg removeItem ( in unsigned long index ) - raises( DOMException ); - SVGPathSeg appendItem ( in SVGPathSeg newItem ) - raises( DOMException, SVGException ); - }; - - interface SVGAnimatedPathData { - - readonly attribute SVGPathSegList pathSegList; - readonly attribute SVGPathSegList normalizedPathSegList; - readonly attribute SVGPathSegList animatedPathSegList; - readonly attribute SVGPathSegList animatedNormalizedPathSegList; - }; - - interface SVGPathElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget, - SVGAnimatedPathData { - - readonly attribute SVGAnimatedNumber pathLength; - - float getTotalLength ( ); - SVGPoint getPointAtLength ( in float distance ); - unsigned long getPathSegAtLength ( in float distance ); - SVGPathSegClosePath createSVGPathSegClosePath ( ); - SVGPathSegMovetoAbs createSVGPathSegMovetoAbs ( in float x, in float y ); - SVGPathSegMovetoRel createSVGPathSegMovetoRel ( in float x, in float y ); - SVGPathSegLinetoAbs createSVGPathSegLinetoAbs ( in float x, in float y ); - SVGPathSegLinetoRel createSVGPathSegLinetoRel ( in float x, in float y ); - SVGPathSegCurvetoCubicAbs createSVGPathSegCurvetoCubicAbs ( in float x, in float y, in float x1, in float y1, in float x2, in float y2 ); - SVGPathSegCurvetoCubicRel createSVGPathSegCurvetoCubicRel ( in float x, in float y, in float x1, in float y1, in float x2, in float y2 ); - SVGPathSegCurvetoQuadraticAbs createSVGPathSegCurvetoQuadraticAbs ( in float x, in float y, in float x1, in float y1 ); - SVGPathSegCurvetoQuadraticRel createSVGPathSegCurvetoQuadraticRel ( in float x, in float y, in float x1, in float y1 ); - SVGPathSegArcAbs createSVGPathSegArcAbs ( in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag ); - SVGPathSegArcRel createSVGPathSegArcRel ( in float x, in float y, in float r1, in float r2, in float angle, in boolean largeArcFlag, in boolean sweepFlag ); - SVGPathSegLinetoHorizontalAbs createSVGPathSegLinetoHorizontalAbs ( in float x ); - SVGPathSegLinetoHorizontalRel createSVGPathSegLinetoHorizontalRel ( in float x ); - SVGPathSegLinetoVerticalAbs createSVGPathSegLinetoVerticalAbs ( in float y ); - SVGPathSegLinetoVerticalRel createSVGPathSegLinetoVerticalRel ( in float y ); - SVGPathSegCurvetoCubicSmoothAbs createSVGPathSegCurvetoCubicSmoothAbs ( in float x, in float y, in float x2, in float y2 ); - SVGPathSegCurvetoCubicSmoothRel createSVGPathSegCurvetoCubicSmoothRel ( in float x, in float y, in float x2, in float y2 ); - SVGPathSegCurvetoQuadraticSmoothAbs createSVGPathSegCurvetoQuadraticSmoothAbs ( in float x, in float y ); - SVGPathSegCurvetoQuadraticSmoothRel createSVGPathSegCurvetoQuadraticSmoothRel ( in float x, in float y ); - }; - - interface SVGRectElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGAnimatedLength rx; - readonly attribute SVGAnimatedLength ry; - }; - - interface SVGCircleElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength cx; - readonly attribute SVGAnimatedLength cy; - readonly attribute SVGAnimatedLength r; - }; - - interface SVGEllipseElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength cx; - readonly attribute SVGAnimatedLength cy; - readonly attribute SVGAnimatedLength rx; - readonly attribute SVGAnimatedLength ry; - }; - - interface SVGLineElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength x1; - readonly attribute SVGAnimatedLength y1; - readonly attribute SVGAnimatedLength x2; - readonly attribute SVGAnimatedLength y2; - }; - - interface SVGAnimatedPoints { - - readonly attribute SVGPointList points; - readonly attribute SVGPointList animatedPoints; - }; - - interface SVGPolylineElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget, - SVGAnimatedPoints {}; - - interface SVGPolygonElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget, - SVGAnimatedPoints {}; - - interface SVGTextContentElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - events::EventTarget { - - // lengthAdjust Types - const unsigned short LENGTHADJUST_UNKNOWN = 0; - const unsigned short LENGTHADJUST_SPACING = 1; - const unsigned short LENGTHADJUST_SPACINGANDGLYPHS = 2; - - readonly attribute SVGAnimatedLength textLength; - readonly attribute SVGAnimatedEnumeration lengthAdjust; - - long getNumberOfChars ( ); - float getComputedTextLength ( ); - float getSubStringLength ( in unsigned long charnum, in unsigned long nchars ) - raises( DOMException ); - SVGPoint getStartPositionOfChar ( in unsigned long charnum ) - raises( DOMException ); - SVGPoint getEndPositionOfChar ( in unsigned long charnum ) - raises( DOMException ); - SVGRect getExtentOfChar ( in unsigned long charnum ) - raises( DOMException ); - float getRotationOfChar ( in unsigned long charnum ) - raises( DOMException ); - long getCharNumAtPosition ( in SVGPoint point ); - void selectSubString ( in unsigned long charnum, in unsigned long nchars ) - raises( DOMException ); - }; - - interface SVGTextPositioningElement : SVGTextContentElement { - readonly attribute SVGAnimatedLengthList x; - readonly attribute SVGAnimatedLengthList y; - readonly attribute SVGAnimatedLengthList dx; - readonly attribute SVGAnimatedLengthList dy; - readonly attribute SVGAnimatedNumberList rotate; - }; - - interface SVGTextElement : - SVGTextPositioningElement, - SVGTransformable {}; - - interface SVGTSpanElement : SVGTextPositioningElement {}; - - interface SVGTRefElement : - SVGTextPositioningElement, - SVGURIReference {}; - - interface SVGTextPathElement : - SVGTextContentElement, - SVGURIReference { - - // textPath Method Types - const unsigned short TEXTPATH_METHODTYPE_UNKNOWN = 0; - const unsigned short TEXTPATH_METHODTYPE_ALIGN = 1; - const unsigned short TEXTPATH_METHODTYPE_STRETCH = 2; - // textPath Spacing Types - const unsigned short TEXTPATH_SPACINGTYPE_UNKNOWN = 0; - const unsigned short TEXTPATH_SPACINGTYPE_AUTO = 1; - const unsigned short TEXTPATH_SPACINGTYPE_EXACT = 2; - - readonly attribute SVGAnimatedLength startOffset; - readonly attribute SVGAnimatedEnumeration method; - readonly attribute SVGAnimatedEnumeration spacing; - }; - - interface SVGAltGlyphElement : - SVGTextPositioningElement, - SVGURIReference { - - attribute DOMString glyphRef; - // raises DOMException on setting - attribute DOMString format; - // raises DOMException on setting - }; - - interface SVGAltGlyphDefElement : SVGElement {}; - - interface SVGAltGlyphItemElement : SVGElement {}; - - interface SVGGlyphRefElement : - SVGElement, - SVGURIReference, - SVGStylable { - - attribute DOMString glyphRef; - // raises DOMException on setting - attribute DOMString format; - // raises DOMException on setting - attribute float x; - // raises DOMException on setting - attribute float y; - // raises DOMException on setting - attribute float dx; - // raises DOMException on setting - attribute float dy; - // raises DOMException on setting - }; - - interface SVGPaint : SVGColor { - // Paint Types - const unsigned short SVG_PAINTTYPE_UNKNOWN = 0; - const unsigned short SVG_PAINTTYPE_RGBCOLOR = 1; - const unsigned short SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2; - const unsigned short SVG_PAINTTYPE_NONE = 101; - const unsigned short SVG_PAINTTYPE_CURRENTCOLOR = 102; - const unsigned short SVG_PAINTTYPE_URI_NONE = 103; - const unsigned short SVG_PAINTTYPE_URI_CURRENTCOLOR = 104; - const unsigned short SVG_PAINTTYPE_URI_RGBCOLOR = 105; - const unsigned short SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106; - const unsigned short SVG_PAINTTYPE_URI = 107; - - readonly attribute unsigned short paintType; - readonly attribute DOMString uri; - - void setUri ( in DOMString uri ); - void setPaint ( in unsigned short paintType, in DOMString uri, in DOMString rgbColor, in DOMString iccColor ) - raises( SVGException ); - }; - - interface SVGMarkerElement : - SVGElement, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGFitToViewBox { - - // Marker Unit Types - const unsigned short SVG_MARKERUNITS_UNKNOWN = 0; - const unsigned short SVG_MARKERUNITS_USERSPACEONUSE = 1; - const unsigned short SVG_MARKERUNITS_STROKEWIDTH = 2; - // Marker Orientation Types - const unsigned short SVG_MARKER_ORIENT_UNKNOWN = 0; - const unsigned short SVG_MARKER_ORIENT_AUTO = 1; - const unsigned short SVG_MARKER_ORIENT_ANGLE = 2; - - readonly attribute SVGAnimatedLength refX; - readonly attribute SVGAnimatedLength refY; - readonly attribute SVGAnimatedEnumeration markerUnits; - readonly attribute SVGAnimatedLength markerWidth; - readonly attribute SVGAnimatedLength markerHeight; - readonly attribute SVGAnimatedEnumeration orientType; - readonly attribute SVGAnimatedAngle orientAngle; - - void setOrientToAuto ( ); - void setOrientToAngle ( in SVGAngle angle ); - }; - - interface SVGColorProfileElement : - SVGElement, - SVGURIReference, - SVGRenderingIntent { - - attribute DOMString local; - // raises DOMException on setting - attribute DOMString name; - // raises DOMException on setting - attribute unsigned short renderingIntent; - // raises DOMException on setting - }; - - interface SVGColorProfileRule : - SVGCSSRule, - SVGRenderingIntent { - - attribute DOMString src; - // raises DOMException on setting - attribute DOMString name; - // raises DOMException on setting - attribute unsigned short renderingIntent; - // raises DOMException on setting - }; - - interface SVGGradientElement : - SVGElement, - SVGURIReference, - SVGExternalResourcesRequired, - SVGStylable, - SVGUnitTypes { - - // Spread Method Types - const unsigned short SVG_SPREADMETHOD_UNKNOWN = 0; - const unsigned short SVG_SPREADMETHOD_PAD = 1; - const unsigned short SVG_SPREADMETHOD_REFLECT = 2; - const unsigned short SVG_SPREADMETHOD_REPEAT = 3; - - readonly attribute SVGAnimatedEnumeration gradientUnits; - readonly attribute SVGAnimatedTransformList gradientTransform; - readonly attribute SVGAnimatedEnumeration spreadMethod; - }; - - interface SVGLinearGradientElement : SVGGradientElement { - readonly attribute SVGAnimatedLength x1; - readonly attribute SVGAnimatedLength y1; - readonly attribute SVGAnimatedLength x2; - readonly attribute SVGAnimatedLength y2; - }; - - interface SVGRadialGradientElement : SVGGradientElement { - readonly attribute SVGAnimatedLength cx; - readonly attribute SVGAnimatedLength cy; - readonly attribute SVGAnimatedLength r; - readonly attribute SVGAnimatedLength fx; - readonly attribute SVGAnimatedLength fy; - }; - - interface SVGStopElement : - SVGElement, - SVGStylable { - - readonly attribute SVGAnimatedNumber offset; - }; - - interface SVGPatternElement : - SVGElement, - SVGURIReference, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGFitToViewBox, - SVGUnitTypes { - - readonly attribute SVGAnimatedEnumeration patternUnits; - readonly attribute SVGAnimatedEnumeration patternContentUnits; - readonly attribute SVGAnimatedTransformList patternTransform; - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - }; - - interface SVGClipPathElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - SVGUnitTypes { - - readonly attribute SVGAnimatedEnumeration clipPathUnits; - }; - - interface SVGMaskElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGUnitTypes { - - readonly attribute SVGAnimatedEnumeration maskUnits; - readonly attribute SVGAnimatedEnumeration maskContentUnits; - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - }; - - interface SVGFilterElement : - SVGElement, - SVGURIReference, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGUnitTypes { - - readonly attribute SVGAnimatedEnumeration filterUnits; - readonly attribute SVGAnimatedEnumeration primitiveUnits; - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGAnimatedInteger filterResX; - readonly attribute SVGAnimatedInteger filterResY; - - void setFilterRes ( in unsigned long filterResX, in unsigned long filterResY ); - }; - - interface SVGFilterPrimitiveStandardAttributes : SVGStylable { - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGAnimatedString result; - }; - - interface SVGFEBlendElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Blend Mode Types - const unsigned short SVG_FEBLEND_MODE_UNKNOWN = 0; - const unsigned short SVG_FEBLEND_MODE_NORMAL = 1; - const unsigned short SVG_FEBLEND_MODE_MULTIPLY = 2; - const unsigned short SVG_FEBLEND_MODE_SCREEN = 3; - const unsigned short SVG_FEBLEND_MODE_DARKEN = 4; - const unsigned short SVG_FEBLEND_MODE_LIGHTEN = 5; - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedString in2; - readonly attribute SVGAnimatedEnumeration mode; - }; - - interface SVGFEColorMatrixElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Color Matrix Types - const unsigned short SVG_FECOLORMATRIX_TYPE_UNKNOWN = 0; - const unsigned short SVG_FECOLORMATRIX_TYPE_MATRIX = 1; - const unsigned short SVG_FECOLORMATRIX_TYPE_SATURATE = 2; - const unsigned short SVG_FECOLORMATRIX_TYPE_HUEROTATE = 3; - const unsigned short SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4; - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedEnumeration type; - readonly attribute SVGAnimatedNumberList values; - }; - - interface SVGFEComponentTransferElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - }; - - interface SVGComponentTransferFunctionElement : SVGElement { - // Component Transfer Types - const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0; - const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1; - const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2; - const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3; - const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4; - const unsigned short SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5; - - readonly attribute SVGAnimatedEnumeration type; - readonly attribute SVGAnimatedNumberList tableValues; - readonly attribute SVGAnimatedNumber slope; - readonly attribute SVGAnimatedNumber intercept; - readonly attribute SVGAnimatedNumber amplitude; - readonly attribute SVGAnimatedNumber exponent; - readonly attribute SVGAnimatedNumber offset; - }; - - interface SVGFEFuncRElement : SVGComponentTransferFunctionElement {}; - - interface SVGFEFuncGElement : SVGComponentTransferFunctionElement {}; - - interface SVGFEFuncBElement : SVGComponentTransferFunctionElement {}; - - interface SVGFEFuncAElement : SVGComponentTransferFunctionElement {}; - - interface SVGFECompositeElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Composite Operators - const unsigned short SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0; - const unsigned short SVG_FECOMPOSITE_OPERATOR_OVER = 1; - const unsigned short SVG_FECOMPOSITE_OPERATOR_IN = 2; - const unsigned short SVG_FECOMPOSITE_OPERATOR_OUT = 3; - const unsigned short SVG_FECOMPOSITE_OPERATOR_ATOP = 4; - const unsigned short SVG_FECOMPOSITE_OPERATOR_XOR = 5; - const unsigned short SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6; - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedString in2; - readonly attribute SVGAnimatedEnumeration operator; - readonly attribute SVGAnimatedNumber k1; - readonly attribute SVGAnimatedNumber k2; - readonly attribute SVGAnimatedNumber k3; - readonly attribute SVGAnimatedNumber k4; - }; - - interface SVGFEConvolveMatrixElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Edge Mode Values - const unsigned short SVG_EDGEMODE_UNKNOWN = 0; - const unsigned short SVG_EDGEMODE_DUPLICATE = 1; - const unsigned short SVG_EDGEMODE_WRAP = 2; - const unsigned short SVG_EDGEMODE_NONE = 3; - - readonly attribute SVGAnimatedInteger orderX; - readonly attribute SVGAnimatedInteger orderY; - readonly attribute SVGAnimatedNumberList kernelMatrix; - readonly attribute SVGAnimatedNumber divisor; - readonly attribute SVGAnimatedNumber bias; - readonly attribute SVGAnimatedInteger targetX; - readonly attribute SVGAnimatedInteger targetY; - readonly attribute SVGAnimatedEnumeration edgeMode; - readonly attribute SVGAnimatedLength kernelUnitLengthX; - readonly attribute SVGAnimatedLength kernelUnitLengthY; - readonly attribute SVGAnimatedBoolean preserveAlpha; - }; - - interface SVGFEDiffuseLightingElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedNumber surfaceScale; - readonly attribute SVGAnimatedNumber diffuseConstant; - }; - - interface SVGFEDistantLightElement : SVGElement { - readonly attribute SVGAnimatedNumber azimuth; - readonly attribute SVGAnimatedNumber elevation; - }; - - interface SVGFEPointLightElement : SVGElement { - readonly attribute SVGAnimatedNumber x; - readonly attribute SVGAnimatedNumber y; - readonly attribute SVGAnimatedNumber z; - }; - - interface SVGFESpotLightElement : SVGElement { - readonly attribute SVGAnimatedNumber x; - readonly attribute SVGAnimatedNumber y; - readonly attribute SVGAnimatedNumber z; - readonly attribute SVGAnimatedNumber pointsAtX; - readonly attribute SVGAnimatedNumber pointsAtY; - readonly attribute SVGAnimatedNumber pointsAtZ; - readonly attribute SVGAnimatedNumber specularExponent; - readonly attribute SVGAnimatedNumber limitingConeAngle; - }; - - interface SVGFEDisplacementMapElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Channel Selectors - const unsigned short SVG_CHANNEL_UNKNOWN = 0; - const unsigned short SVG_CHANNEL_R = 1; - const unsigned short SVG_CHANNEL_G = 2; - const unsigned short SVG_CHANNEL_B = 3; - const unsigned short SVG_CHANNEL_A = 4; - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedString in2; - readonly attribute SVGAnimatedNumber scale; - readonly attribute SVGAnimatedEnumeration xChannelSelector; - readonly attribute SVGAnimatedEnumeration yChannelSelector; - }; - - interface SVGFEFloodElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - }; - - interface SVGFEGaussianBlurElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedNumber stdDeviationX; - readonly attribute SVGAnimatedNumber stdDeviationY; - - void setStdDeviation ( in float stdDeviationX, in float stdDeviationY ); - }; - - interface SVGFEImageElement : - SVGElement, - SVGURIReference, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGFilterPrimitiveStandardAttributes {}; - - interface SVGFEMergeElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes {}; - - interface SVGFEMergeNodeElement : SVGElement { - readonly attribute SVGAnimatedString in1; - }; - - interface SVGFEMorphologyElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Morphology Operators - const unsigned short SVG_MORPHOLOGY_OPERATOR_UNKNOWN = 0; - const unsigned short SVG_MORPHOLOGY_OPERATOR_ERODE = 1; - const unsigned short SVG_MORPHOLOGY_OPERATOR_DILATE = 2; - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedEnumeration operator; - readonly attribute SVGAnimatedLength radiusX; - readonly attribute SVGAnimatedLength radiusY; - }; - - interface SVGFEOffsetElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedNumber dx; - readonly attribute SVGAnimatedNumber dy; - }; - - interface SVGFESpecularLightingElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - readonly attribute SVGAnimatedNumber surfaceScale; - readonly attribute SVGAnimatedNumber specularConstant; - readonly attribute SVGAnimatedNumber specularExponent; - }; - - interface SVGFETileElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - }; - - interface SVGFETurbulenceElement : - SVGElement, - SVGFilterPrimitiveStandardAttributes { - - // Turbulence Types - const unsigned short SVG_TURBULENCE_TYPE_UNKNOWN = 0; - const unsigned short SVG_TURBULENCE_TYPE_FRACTALNOISE = 1; - const unsigned short SVG_TURBULENCE_TYPE_TURBULENCE = 2; - // Stitch Options - const unsigned short SVG_STITCHTYPE_UNKNOWN = 0; - const unsigned short SVG_STITCHTYPE_STITCH = 1; - const unsigned short SVG_STITCHTYPE_NOSTITCH = 2; - - readonly attribute SVGAnimatedNumber baseFrequencyX; - readonly attribute SVGAnimatedNumber baseFrequencyY; - readonly attribute SVGAnimatedInteger numOctaves; - readonly attribute SVGAnimatedNumber seed; - readonly attribute SVGAnimatedEnumeration stitchTiles; - readonly attribute SVGAnimatedEnumeration type; - }; - - interface SVGCursorElement : - SVGElement, - SVGURIReference, - SVGTests, - SVGExternalResourcesRequired { - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - }; - - interface SVGAElement : - SVGElement, - SVGURIReference, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedString target; - }; - - interface SVGViewElement : - SVGElement, - SVGExternalResourcesRequired, - SVGFitToViewBox, - SVGZoomAndPan { - - readonly attribute SVGStringList viewTarget; - }; - - interface SVGScriptElement : - SVGElement, - SVGURIReference, - SVGExternalResourcesRequired { - - attribute DOMString type; - // raises DOMException on setting - }; - - interface SVGEvent : events::Event {}; - - interface SVGZoomEvent : events::UIEvent { - readonly attribute SVGRect zoomRectScreen; - readonly attribute float previousScale; - readonly attribute SVGPoint previousTranslate; - readonly attribute float newScale; - readonly attribute SVGPoint newTranslate; - }; - - interface SVGAnimationElement : - SVGElement, - SVGTests, - SVGExternalResourcesRequired, - smil::ElementTimeControl, - events::EventTarget { - - readonly attribute SVGElement targetElement; - - float getStartTime ( ); - float getCurrentTime ( ); - float getSimpleDuration ( ) - raises( DOMException ); - }; - - interface SVGAnimateElement : SVGAnimationElement {}; - - interface SVGSetElement : SVGAnimationElement {}; - - interface SVGAnimateMotionElement : SVGAnimationElement {}; - - interface SVGMPathElement : - SVGElement, - SVGURIReference, - SVGExternalResourcesRequired {}; - - interface SVGAnimateColorElement : SVGAnimationElement {}; - - interface SVGAnimateTransformElement : SVGAnimationElement {}; - - interface SVGFontElement : - SVGElement, - SVGExternalResourcesRequired, - SVGStylable {}; - - interface SVGGlyphElement : - SVGElement, - SVGStylable {}; - - interface SVGMissingGlyphElement : - SVGElement, - SVGStylable {}; - - interface SVGHKernElement : SVGElement {}; - - interface SVGVKernElement : SVGElement {}; - - interface SVGFontFaceElement : SVGElement {}; - - interface SVGFontFaceSrcElement : SVGElement {}; - - interface SVGFontFaceUriElement : SVGElement {}; - - interface SVGFontFaceFormatElement : SVGElement {}; - - interface SVGFontFaceNameElement : SVGElement {}; - - interface SVGDefinitionSrcElement : SVGElement {}; - - interface SVGMetadataElement : SVGElement {}; - - interface SVGForeignObjectElement : - SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - events::EventTarget { - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - }; - - -}; - -#endif // _SVG_IDL_ \ No newline at end of file diff --git a/src/dom/work/svg2.cpp b/src/dom/work/svg2.cpp deleted file mode 100644 index f0da61e09..000000000 --- a/src/dom/work/svg2.cpp +++ /dev/null @@ -1,7049 +0,0 @@ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright(C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or(at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================= - * NOTES - * - * This API follows: - * http://www.w3.org/TR/SVG11/svgdom.html - * - * This file defines the main SVG-DOM Node types. Other non-Node types are - * defined in svgtypes.h. - * - */ - -#include "svg.h" - -#include <math.h> - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace svg -{ - - - -//######################################################################## -//######################################################################## -//######################################################################## -//# I N T E R F A C E S -//######################################################################## -//######################################################################## -//######################################################################## - - - -/*######################################################################### -## SVGMatrix -#########################################################################*/ - -/** - * - */ -double SVGMatrix::getA() -{ - return a; -} - -/** - * - */ -void SVGMatrix::setA(double val) throw (DOMException) -{ - a = val; -} - -/** - * - */ -double SVGMatrix::getB() -{ - return b; -} - -/** - * - */ -void SVGMatrix::setB(double val) throw (DOMException) -{ - b = val; -} - -/** - * - */ -double SVGMatrix::getC() -{ - return c; -} - -/** - * - */ -void SVGMatrix::setC(double val) throw (DOMException) -{ - c = val; -} - -/** - * - */ -double SVGMatrix::getD() -{ - return d; -} - -/** - * - */ -void SVGMatrix::setD(double val) throw (DOMException) -{ - d = val; -} - -/** - * - */ -double SVGMatrix::getE() -{ - return e; -} - -/** - * - */ -void SVGMatrix::setE(double val) throw (DOMException) -{ - e = val; -} - -/** - * - */ -double SVGMatrix::getF() -{ - return f; -} - -/** - * - */ -void SVGMatrix::setF(double val) throw (DOMException) -{ - f = val; -} - - -/** - * Return the result of postmultiplying this matrix with another. - */ -SVGMatrix SVGMatrix::multiply(const SVGMatrix &other) -{ - SVGMatrix result; - result.a = a * other.a + c * other.b; - result.b = b * other.a + d * other.b; - result.c = a * other.c + c * other.d; - result.d = b * other.c + d * other.d; - result.e = a * other.e + c * other.f + e; - result.f = b * other.e + d * other.f + f; - return result; -} - -/** - * Calculate the inverse of this matrix - * - */ -SVGMatrix SVGMatrix::inverse() throw (SVGException) -{ - /*########################################### - The determinant of a 3x3 matrix E - (let's use our own notation for a bit) - - A B C - D E F - G H I - is - AEI - AFH - BDI + BFG + CDH - CEG - - Since in our affine transforms, G and H==0 and I==1, - this reduces to: - AE - BD - In SVG's naming scheme, that is: a * d - c * b . SIMPLE! - - In a similar method of attack, SVG's adjunct matrix is: - - d -c cf-ed - -b a eb-af - 0 0 ad-cb - - To get the inverse matrix, we divide the adjunct matrix by - the determinant. Notice that (ad-cb)/(ad-cb)==1. Very cool. - So what we end up with is this: - - a = d/(ad-cb) c = -c/(ad-cb) e = (cf-ed)/(ad-cb) - b = -b/(ad-cb) d = a/(ad-cb) f = (eb-af)/(ad-cb) - - (Since this would be in all SVG-DOM implementations, - somebody needed to document this! ^^) - #############################################*/ - - SVGMatrix result; - double determinant = a * d - c * b; - if (determinant < 1.0e-18)//invertible? - { - result.identity();//cop out - return result; - } - - double idet = 1.0 / determinant; - result.a = d * idet; - result.b = -b * idet; - result.c = -c * idet; - result.d = a * idet; - result.e = (c*f - e*d) * idet; - result.f = (e*b - a*f) * idet; - return result; -} - -/** - * Equivalent to multiplying by: - * | 1 0 x | - * | 0 1 y | - * | 0 0 1 | - * - */ -SVGMatrix SVGMatrix::translate(double x, double y) -{ - SVGMatrix result; - result.a = a; - result.b = b; - result.c = c; - result.d = d; - result.e = a * x + c * y + e; - result.f = b * x + d * y + f; - return result; -} - -/** - * Equivalent to multiplying by: - * | scale 0 0 | - * | 0 scale 0 | - * | 0 0 1 | - * - */ -:SVGMatrix SVGMatrix:scale(double scale) -{ - SVGMatrix result; - result.a = a * scale; - result.b = b * scale; - result.c = c * scale; - result.d = d * scale; - result.e = e; - result.f = f; - return result; -} - -/** - * Equivalent to multiplying by: - * | scaleX 0 0 | - * | 0 scaleY 0 | - * | 0 0 1 | - * - */ -SVGMatrix SVGMatrix::scaleNonUniform(double scaleX, - double scaleY) -{ - SVGMatrix result; - result.a = a * scaleX; - result.b = b * scaleX; - result.c = c * scaleY; - result.d = d * scaleY; - result.e = e; - result.f = f; - return result; -} - -/** - * Equivalent to multiplying by: - * | cos(a) -sin(a) 0 | - * | sin(a) cos(a) 0 | - * | 0 0 1 | - * - */ -SVGMatrix SVGMatrix::rotate (double angle) -{ - double sina = sin(angle); - double msina = -sina; - double cosa = cos(angle); - SVGMatrix result; - result.a = a * cosa + c * sina; - result.b = b * cosa + d + sina; - result.c = a * msina + c * cosa; - result.d = b * msina + d * cosa; - result.e = e; - result.f = f; - return result; -} - -/** - * Equivalent to multiplying by: - * | cos(a) -sin(a) 0 | - * | sin(a) cos(a) 0 | - * | 0 0 1 | - * In this case, angle 'a' is computed as the artangent - * of the slope y/x . It is negative if the slope is negative. - */ -SVGMatrix SVGMatrix::rotateFromVector(double x, double y) - throw (SVGException) -{ - double angle = atan(y / x); - if (y < 0.0) - angle = -angle; - SVGMatrix result; - double sina = sin(angle); - double msina = -sina; - double cosa = cos(angle); - result.a = a * cosa + c * sina; - result.b = b * cosa + d + sina; - result.c = a * msina + c * cosa; - result.d = b * msina + d * cosa; - result.e = e; - result.f = f; - return result; -} - -/** - * Equivalent to multiplying by: - * | -1 0 0 | - * | 0 1 0 | - * | 0 0 1 | - * - */ -SVGMatrix SVGMatrix::flipX() -{ - SVGMatrix result; - result.a = -a; - result.b = -b; - result.c = c; - result.d = d; - result.e = e; - result.f = f; - return result; -} - -/** - * Equivalent to multiplying by: - * | 1 0 0 | - * | 0 -1 0 | - * | 0 0 1 | - * - */ -SVGMatrix SVGMatrix::flipY() -{ - SVGMatrix result; - result.a = a; - result.b = b; - result.c = -c; - result.d = -d; - result.e = e; - result.f = f; - return result; -} - -/** - * | 1 tan(a) 0 | - * | 0 1 0 | - * | 0 0 1 | - * - */ -SVGMatrix SVGMatrix::skewX(double angle) -{ - double tana = tan(angle); - SVGMatrix result; - result.a = a; - result.b = b; - result.c = a * tana + c; - result.d = b * tana + d; - result.e = e; - result.f = f; - return result; -} - -/** - * Equivalent to multiplying by: - * | 1 0 0 | - * | tan(a) 1 0 | - * | 0 0 1 | - * - */ -SVGMatrix::SVGMatrix SVGMatrix::skewY(double angle) -{ - double tana = tan(angle); - SVGMatrix result; - result.a = a + c * tana; - result.b = b + d * tana; - result.c = c; - result.d = d; - result.e = e; - result.f = f; - return result; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGMatrix::SVGMatrix() -{ - identity(); -} - -/** - * - */ -SVGMatrix::SVGMatrix(double aArg, double bArg, double cArg, - double dArg, double eArg, double fArg) -{ - a = aArg; b = bArg; c = cArg; - d = dArg; e = eArg; f = fArg; -} - -/** - * Copy constructor - */ -SVGMatrix::SVGMatrix(const SVGMatrix &other) -{ - a = other.a; - b = other.b; - c = other.c; - d = other.d; - e = other.e; - f = other.f; -} - - - -/** - * - */ -SVGMatrix::~SVGMatrix() -{ -} - -/* - * Set to the identity matrix - */ -void SVGMatrix::identity() -{ - a = 1.0; - b = 0.0; - c = 0.0; - d = 1.0; - e = 0.0; - f = 0.0; -} - - -/*######################################################################### -## SVGTransform -#########################################################################*/ - -/** - * - */ -unsigned short SVGTransform::getType() -{ - return type; -} - - -/** - * - */ -SVGMatrix SVGTransform::getMatrix() -{ - return matrix; -} - -/** - * - */ -double SVGTransform::getAngle() -{ - return angle; -} - - -/** - * - */ -void SVGTransform::setMatrix(const SVGMatrix &matrixArg) -{ - type = SVG_TRANSFORM_MATRIX; - matrix = matrixArg; -} - -/** - * - */ -void SVGTransform::setTranslate(double tx, double ty) -{ - type = SVG_TRANSFORM_TRANSLATE; - matrix.setA(1.0); - matrix.setB(0.0); - matrix.setC(0.0); - matrix.setD(1.0); - matrix.setE(tx); - matrix.setF(ty); -} - -/** - * - */ -void SVGTransform::setScale(double sx, double sy) -{ - type = SVG_TRANSFORM_SCALE; - matrix.setA(sx); - matrix.setB(0.0); - matrix.setC(0.0); - matrix.setD(sy); - matrix.setE(0.0); - matrix.setF(0.0); -} - -/** - * - */ -void SVGTransform::setRotate(double angleArg, double cx, double cy) -{ - angle = angleArg; - setTranslate(cx, cy); - type = SVG_TRANSFORM_ROTATE; - matrix.rotate(angle); -} - -/** - * - */ -void SVGTransform::setSkewX(double angleArg) -{ - angle = angleArg; - type = SVG_TRANSFORM_SKEWX; - matrix.identity(); - matrix.skewX(angle); -} - -/** - * - */ -void SVGTransform::setSkewY(double angleArg) -{ - angle = angleArg; - type = SVG_TRANSFORM_SKEWY; - matrix.identity(); - matrix.skewY(angle); -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGTransform::SVGTransform() -{ - type = SVG_TRANSFORM_UNKNOWN; - angle = 0.0; -} - -/** - * - */ -SVGTransform::SVGTransform(const SVGTransform &other) -{ - type = other.type; - angle = other.angle; - matrix = other.matrix; -} - -/** - * - */ -~SVGTransform::SVGTransform() -{ -} - - - -/*######################################################################### -## SVGNumber -#########################################################################*/ - -/** - * - */ -double SVGNumber::getValue() -{ - return value; -} - -/** - * - */ -void SVGNumber::setValue(double val) throw (DOMException) -{ - value = val; -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGNumber::SVGNumber() -{ - value = 0.0; -} - -/** - * - */ -SVGNumber::SVGNumber(const SVGNumber &other) -{ - value = other.value; -} - -/** - * - */ -SVGNumber::~SVGNumber() -{ -} - - - -/*######################################################################### -## SVGLength -#########################################################################*/ - - -/** - * - */ -unsigned short SVGLength::getUnitType() -{ - return unitType; -} - -/** - * - */ -double SVGLength::getValue() -{ - return value; -} - -/** - * - */ -void SVGLength::setValue(double val) throw (DOMException) -{ - value = val; -} - -/** - * - */ -double SVGLength::getValueInSpecifiedUnits() -{ - double result = 0.0; - //fill this in - return result; -} - -/** - * - */ -void SVGLength::setValueInSpecifiedUnits(double /*val*/) - throw (DOMException) -{ - //fill this in -} - -/** - * - */ -DOMString SVGLength::getValueAsString() -{ - DOMString ret; - char buf[32]; - snprintf(buf, 31, "%f", value); - ret.append(buf); - return ret; -} - -/** - * - */ -void SVGLength::setValueAsString(const DOMString& /*val*/) - throw (DOMException) -{ -} - - -/** - * - */ -void SVGLength::newValueSpecifiedUnits (unsigned short /*unitType*/, double /*val*/) -{ -} - -/** - * - */ -void SVGLength::convertToSpecifiedUnits (unsigned short /*unitType*/) -{ -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGLength::SVGLength() -{ - unitType = SVG_LENGTHTYPE_UNKNOWN; - value = 0.0; -} - - -/** - * - */ -SVGLength::SVGLength(const SVGLength &other) -{ - unitType = other.unitType; - value = other.value; -} - -/** - * - */ -SVGLength::~SVGLength() -{ -} - - - - -/*######################################################################### -## SVGAngle -#########################################################################*/ - -/** - * - */ -unsigned short SVGAngle::getUnitType() -{ - return unitType; -} - -/** - * - */ -double SVGAngle::getValue() -{ - return value; -} - -/** - * - */ -void SVGAngle::setValue(double val) throw (DOMException) -{ - value = val; -} - -/** - * - */ -double SVGAngle::getValueInSpecifiedUnits() -{ - double result = 0.0; - //convert here - return result; -} - -/** - * - */ -void SVGAngle::setValueInSpecifiedUnits(double /*val*/) - throw (DOMException) -{ - //do conversion -} - -/** - * - */ -DOMString SVGAngle::getValueAsString() -{ - DOMString result; - char buf[32]; - snprintf(buf, 31, "%f", value); - result.append(buf); - return result; -} - -/** - * - */ -void SVGAngle::setValueAsString(const DOMString &/*val*/) - throw (DOMException) -{ - //convert here -} - - -/** - * - */ -void SVGAngle::newValueSpecifiedUnits (unsigned short /*unitType*/, - double /*valueInSpecifiedUnits*/) -{ - //convert here -} - -/** - * - */ -void SVGAngle::convertToSpecifiedUnits (unsigned short /*unitType*/) -{ - //convert here -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGAngle::SVGAngle() -{ - unitType = SVG_ANGLETYPE_UNKNOWN; - value = 0.0; -} - -/** - * - */ -SVGAngle::SVGAngle(const SVGAngle &other) -{ - unitType = other.unitType; - value = other.value; -} - -/** - * - */ -SVGAngle::~SVGAngle() -{ -} - - - - -/*######################################################################### -## SVGICCColor -#########################################################################*/ - - -/** - * - */ -DOMString SVGICCColor::getColorProfile() -{ - return colorProfile; -} - -/** - * - */ -void SVGICCColor::setColorProfile(const DOMString &val) throw (DOMException) -{ - colorProfile = val; -} - -/** - * - */ -SVGNumberList &SVGICCColor::getColors() -{ - return colors; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGICCColor::SVGICCColor() -{ -} - -/** - * - */ -SVGICCColor::SVGICCColor(const SVGICCColor &other) -{ - colorProfile = other.colorProfile; - colors = other.colors; -} - -/** - * - */ -SVGICCColor::~SVGICCColor() -{ -} - - - -/*######################################################################### -## SVGColor -#########################################################################*/ - - - -/** - * - */ -unsigned short SVGColor::getColorType() -{ - return colorType; -} - -/** - * - */ -css::RGBColor SVGColor::getRgbColor() -{ - css::RGBColor col; - return col; -} - -/** - * - */ -SVGICCColor SVGColor::getIccColor() -{ - SVGICCColor col; - return col; -} - - -/** - * - */ -void SVGColor::setRGBColor(const DOMString& /*rgbColor*/) - throw (SVGException) -{ -} - -/** - * - */ -void SVGColor::setRGBColorICCColor(const DOMString& /*rgbColor*/, - const DOMString& /*iccColor*/) - throw (SVGException) -{ -} - -/** - * - */ -void SVGColor::setColor (unsigned short /*colorType*/, - const DOMString& /*rgbColor*/, - const DOMString& /*iccColor*/) - throw (SVGException) -{ -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGColor::SVGColor() -{ - colorType = SVG_COLORTYPE_UNKNOWN; -} - -/** - * - */ -SVGColor::SVGColor(const SVGColor &other) : css::CSSValue(other) -{ - colorType = other.colorType; -} - -/** - * - */ -SVGColor::~SVGColor() -{ -} - - - -/*######################################################################### -## SVGRect -#########################################################################*/ - - -/** - * - */ -double SVGRect::getX() -{ - return x; -} - -/** - * - */ -void SVGRect::setX(double val) throw (DOMException) -{ - x = val; -} - -/** - * - */ -double SVGRect::getY() -{ - return y; -} - -/** - * - */ -void SVGRect::setY(double val) throw (DOMException) -{ - y = val; -} - -/** - * - */ -double SVGRect::getWidth() -{ - return width; -} - -/** - * - */ -void SVGRect::setWidth(double val) throw (DOMException) -{ - width = val; -} - -/** - * - */ -double SVGRect::getHeight() -{ - return height; -} - -/** - * - */ -void SVGRect::setHeight(double val) throw (DOMException) -{ - height = val; -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGRect::SVGRect() -{ - x = y = width = height = 0.0; -} - -/** - * - */ -SVGRect::SVGRect(const SVGRect &other) -{ - x = other.x; - y = other.y; - width = other.width; - height = other.height; -} - -/** - * - */ -SVGRect::~SVGRect() -{ -} - - - -/*######################################################################### -## SVGPoint -#########################################################################*/ - - -/** - * - */ -double SVGPoint::getX() -{ - return x; -} - -/** - * - */ -void SVGPoint::setX(double val) throw (DOMException) -{ - x = val; -} - -/** - * - */ -double SVGPoint::getY() -{ - return y; -} - -/** - * - */ -void SVGPoint::setY(double val) throw (DOMException) -{ - y = val; -} - -/** - * - */ -SVGPoint SVGPoint::matrixTransform(const SVGMatrix &/*matrix*/) -{ - SVGPoint point; - return point; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGPoint::SVGPoint() -{ - x = y = 0; -} - -/** - * - */ -SVGPoint::SVGPoint(const SVGPoint &other) -{ - x = other.x; - y = other.y; -} - -/** - * - */ -SVGPoint::~SVGPoint() -{ -} - - -/*######################################################################### -## SVGUnitTypes -#########################################################################*/ - -/** - * - */ -SVGUnitTypes::SVGUnitTypes() -{ -} - - - -/** - * - */ -SVGUnitTypes::~SVGUnitTypes() -{ -} - - -/*######################################################################### -## SVGStylable -#########################################################################*/ - - -/** - * - */ -SVGAnimatedString SVGStylable::getClassName() -{ - return className; -} - -/** - * - */ -css::CSSStyleDeclaration SVGStylable::getStyle() -{ - return style; -} - - -/** - * - */ -css::CSSValue SVGStylable::getPresentationAttribute(const DOMString& /*name*/) -{ - css::CSSValue val; - //perform a lookup - return val; -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGStylable::SVGStylable() -{ -} - -/** - * - */ -SVGStylable::SVGStylable(const SVGStylable &other) -{ - className = other.className; - style = other.style; -} - -/** - * - */ -SVGStylable::~SVGStylable() -{ -} - - - - -/*######################################################################### -## SVGLocatable -#########################################################################*/ - - -/** - * - */ -SVGElementPtr SVGLocatable::getNearestViewportElement() -{ - SVGElementPtr result; - return result; -} - -/** - * - */ -SVGElementPtr SVGLocatable::getFarthestViewportElement() -{ - SVGElementPtr result; - return result; -} - -/** - * - */ -SVGRect SVGLocatable::getBBox () -{ - return bbox; -} - -/** - * - */ -SVGMatrix SVGLocatable::getCTM () -{ - return ctm; -} - -/** - * - */ -SVGMatrix SVGLocatable::getScreenCTM () -{ - return screenCtm; -} - -/** - * - */ -SVGMatrix SVGLocatable::getTransformToElement (const SVGElement &/*element*/) - throw (SVGException) -{ - SVGMatrix result; - //do calculations - return result; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGLocatable::SVGLocatable() -{ -} - -/** - * - */ -SVGLocatable::SVGLocatable(const SVGLocatable &/*other*/) -{ -} - -/** - * - */ -SVGLocatable::~SVGLocatable() -{ -} - - -/*######################################################################### -## SVGTransformable -#########################################################################*/ - - -/** - * - */ -SVGAnimatedTransformList &SVGTransformable::getTransform() -{ - return transforms; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGTransformable::SVGTransformable() {} - -/** - * - */ -SVGTransformable::SVGTransformable(const SVGTransformable &other) : SVGLocatable(other) -{ - transforms = other.transforms; -} - -/** - * - */ -SVGTransformable::~SVGTransformable() -{ -} - - - - - - - -/*######################################################################### -## SVGTests -#########################################################################*/ - - -/** - * - */ -SVGStringList &SVGTests::getRequiredFeatures() -{ - return requiredFeatures; -} - -/** - * - */ -SVGStringList &SVGTests::getRequiredExtensions() -{ - return requiredExtensions; -} - -/** - * - */ -SVGStringList &SVGTests::getSystemLanguage() -{ - return systemLanguage; -} - - -/** - * - */ -bool SVGTests::hasExtension (const DOMString& /*extension*/) -{ - return false; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGTests::SVGTests() -{ -} - -/** - * - */ -SVGTests::SVGTests(const SVGTests &other) -{ - requiredFeatures = other.requiredFeatures; - requiredExtensions = other.requiredExtensions; - systemLanguage = other.systemLanguage; -} - -/** - * - */ -SVGTests::~SVGTests() -{ -} - - - -/*######################################################################### -## SVGLangSpace -#########################################################################*/ - - -/** - * - */ -DOMString SVGLangSpace::getXmllang() -{ - return xmlLang; -} - -/** - * - */ -void SVGLangSpace::setXmllang(const DOMString &val) throw (DOMException) -{ - xmlLang = val; -} - -/** - * - */ -DOMString SVGLangSpace::getXmlspace() -{ - return xmlSpace; -} - -/** - * - */ -void SVGLangSpace::setXmlspace(const DOMString &val) - throw (DOMException) -{ - xmlSpace = val; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGLangSpace::SVGLangSpace() -{ -} - -/** - * - */ -SVGLangSpace::SVGLangSpace(const SVGLangSpace &other) -{ - xmlLang = other.xmlLang; - xmlSpace = other.xmlSpace; -} - -/** - * - */ -SVGLangSpace::~SVGLangSpace() -{ -} - - - -/*######################################################################### -## SVGExternalResourcesRequired -#########################################################################*/ - -/** - * - */ -SVGAnimatedBoolean SVGExternalResourcesRequired::getExternalResourcesRequired() -{ - return required; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGExternalResourcesRequired::SVGExternalResourcesRequired() -{ -} - - -/** - * - */ -SVGExternalResourcesRequired::SVGExternalResourcesRequired( - const SVGExternalResourcesRequired &other) -{ - required = other.required; -} - -/** - * - */ -SVGExternalResourcesRequired::~SVGExternalResourcesRequired() {} - - -/*######################################################################### -## SVGPreserveAspectRatio -#########################################################################*/ - -/** - * - */ -unsigned short SVGPreserveAspectRatio::getAlign() -{ - return align; -} - -/** - * - */ -void SVGPreserveAspectRatio::setAlign(unsigned short val) throw (DOMException) -{ - align = val; -} - -/** - * - */ -unsigned short SVGPreserveAspectRatio::getMeetOrSlice() -{ - return meetOrSlice; -} - -/** - * - */ -void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short val) throw (DOMException) -{ - meetOrSlice = val; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGPreserveAspectRatio::SVGPreserveAspectRatio() -{ - align = SVG_PRESERVEASPECTRATIO_UNKNOWN; - meetOrSlice = SVG_MEETORSLICE_UNKNOWN; -} - -/** - * - */ -SVGPreserveAspectRatio::SVGPreserveAspectRatio(const SVGPreserveAspectRatio &other) -{ - align = other.align; - meetOrSlice = other.meetOrSlice; -} - -/** - * - */ -SVGPreserveAspectRatio::~SVGPreserveAspectRatio() -{ -} - - - -/*######################################################################### -## SVGFitToViewBox -#########################################################################*/ - - -/** - * - */ -SVGAnimatedRect SVGFitToViewBox::getViewBox() -{ - return viewBox; -} - -/** - * - */ -SVGAnimatedPreserveAspectRatio SVGFitToViewBox::getPreserveAspectRatio() -{ - return preserveAspectRatio; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGFitToViewBox::SVGFitToViewBox() -{ -} - -/** - * - */ - -SVGFitToViewBox::SVGFitToViewBox(const SVGFitToViewBox &other) -{ - viewBox = other.viewBox; - preserveAspectRatio = other.preserveAspectRatio; -} - -/** - * - */ -SVGFitToViewBox::~SVGFitToViewBox() -{ -} - -/*######################################################################### -## SVGZoomAndPan -#########################################################################*/ - -/** - * - */ -unsigned short SVGZoomAndPan::getZoomAndPan() -{ - return zoomAndPan; -} - -/** - * - */ -void SVGZoomAndPan::setZoomAndPan(unsigned short val) throw (DOMException) -{ - zoomAndPan = val; -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGZoomAndPan::SVGZoomAndPan() -{ - zoomAndPan = SVG_ZOOMANDPAN_UNKNOWN; -} - -/** - * - */ -SVGZoomAndPan::SVGZoomAndPan(const SVGZoomAndPan &other) -{ - zoomAndPan = other.zoomAndPan; -} - -/** - * - */ -SVGZoomAndPan::~SVGZoomAndPan() -{ -} - - -/*######################################################################### -## SVGViewSpec -#########################################################################*/ - -/** - * - */ -SVGTransformList SVGViewSpec::getTransform() -{ - return transform; -} - -/** - * - */ -SVGElementPtr SVGViewSpec::getViewTarget() -{ - return viewTarget; -} - -/** - * - */ -DOMString SVGViewSpec::getViewBoxString() -{ - DOMString ret; - return ret; -} - -/** - * - */ -DOMString SVGViewSpec::getPreserveAspectRatioString() -{ - DOMString ret; - return ret; -} - -/** - * - */ -DOMString SVGViewSpec::getTransformString() -{ - DOMString ret; - return ret; -} - -/** - * - */ -DOMString SVGViewSpec::getViewTargetString() -{ - DOMString ret; - return ret; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGViewSpec::SVGViewSpec() -{ - viewTarget = NULL; -} - -/** - * - */ -SVGViewSpec::SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other) -{ - viewTarget = other.viewTarget; - transform = other.transform; -} - -/** - * - */ -SVGViewSpec::~SVGViewSpec() -{ -} - - - -/*######################################################################### -## SVGURIReference -#########################################################################*/ - - -/** - * - */ -SVGAnimatedString SVGURIReference::getHref() -{ - return href; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGURIReference::SVGURIReference() -{ -} - -/** - * - */ -SVGURIReference::SVGURIReference(const SVGURIReference &other) -{ - href = other.href; -} - -/** - * - */ -SVGURIReference::~SVGURIReference() -{ -} - - - -/*######################################################################### -## SVGCSSRule -#########################################################################*/ - - - - -/*######################################################################### -## SVGRenderingIntent -#########################################################################*/ - - - - - -/*######################################################################### -## SVGPathSeg -#########################################################################*/ - -static const char *pathSegLetters[] = -{ - '@', // PATHSEG_UNKNOWN, - 'z', // PATHSEG_CLOSEPATH - 'M', // PATHSEG_MOVETO_ABS - 'm', // PATHSEG_MOVETO_REL, - 'L', // PATHSEG_LINETO_ABS - 'l', // PATHSEG_LINETO_REL - 'C', // PATHSEG_CURVETO_CUBIC_ABS - 'c', // PATHSEG_CURVETO_CUBIC_REL - 'Q', // PATHSEG_CURVETO_QUADRATIC_ABS, - 'q', // PATHSEG_CURVETO_QUADRATIC_REL - 'A', // PATHSEG_ARC_ABS - 'a', // PATHSEG_ARC_REL, - 'H', // PATHSEG_LINETO_HORIZONTAL_ABS, - 'h', // PATHSEG_LINETO_HORIZONTAL_REL - 'V', // PATHSEG_LINETO_VERTICAL_ABS - 'v', // PATHSEG_LINETO_VERTICAL_REL - 'S', // PATHSEG_CURVETO_CUBIC_SMOOTH_ABS - 's', // PATHSEG_CURVETO_CUBIC_SMOOTH_REL - 'T', // PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS - 't' // PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL -}; - - - -/** - * - */ -unsigned short getPathSegType() -{ - return type; -} - -/** - * - */ -DOMString getPathSegTypeAsLetter() -{ - int typ = type; - if (typ<0 || typ>PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL) - typ = PATHSEG_UNKNOWN; - char const ch = pathSegLetters[typ]; - DOMString letter = ch; - return letter; -} - - -/** - * - */ -unsigned short getPathSegType() -{ - return type; -} - -/** - * - */ -DOMString getPathSegTypeAsLetter() -{ - int typ = type; - if (typ<0 || typ>PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL) - typ = PATHSEG_UNKNOWN; - char const *ch = pathSegLetters[typ]; - DOMString letter = ch; - return letter; -} - -/** - * From the various subclasses - */ - -/** - * - */ -double SVGPathSeg::getX() -{ - return x; -} - -/** - * - */ -void SVGPathSeg::setX(double val) throw (DOMException) -{ - x = val; -} - -/** - * - */ -double SVGPathSeg::getX1() -{ - return x; -} - -/** - * - */ -void SVGPathSeg::setX1(double val) throw (DOMException) -{ - x = val; -} - -/** - * - */ -double SVGPathSeg::getX2() -{ - return x; -} - -/** - * - */ -void SVGPathSeg::setX2(double val) throw (DOMException) -{ - x = val; -} - -/** - * - */ -double SVGPathSeg::getY() -{ - return y; -} - -/** - * - */ -void SVGPathSeg::setY(double val) throw (DOMException) -{ - y = val; -} - -/** - * - */ -double SVGPathSeg::getY1() -{ - return y; -} - -/** - * - */ -void SVGPathSeg::setY1(double val) throw (DOMException) -{ - y = val; -} - -/** - * - */ -double SVGPathSeg::getY2() -{ - return y; -} - -/** - * - */ -void SVGPathSeg::setY2(double val) throw (DOMException) -{ - y = val; -} - -/** - * - */ -double SVGPathSeg::getR1() -{ - return r1; -} - -/** - * - */ -void SVGPathSeg::setR1(double val) throw (DOMException) -{ - r1 = val; -} - -/** - * - */ -double SVGPathSeg::getR2() -{ - return r2; -} - -/** - * - */ -void SVGPathSeg::setR2(double val) throw (DOMException) -{ - r2 = val; -} - -/** - * - */ -double SVGPathSeg::getAngle() -{ - return angle; -} - -/** - * - */ -void SVGPathSeg::setAngle(double val) throw (DOMException) -{ - angle = val; -} - -/** - * - */ -bool SVGPathSeg::getLargeArcFlag() -{ - return largeArcFlag; -} - -/** - * - */ -void SVGPathSeg::setLargeArcFlag(bool val) throw (DOMException) -{ - largeArcFlag = val; -} - -/** - * - */ -bool SVGPathSeg::getSweepFlag() -{ - return sweepFlag; -} - -/** - * - */ -void SVGPathSeg::setSweepFlag(bool val) throw (DOMException) -{ - sweepFlag = val; -} - - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGPathSeg::SVGPathSeg() -{ - init(); -} - -/** - * - */ -SVGPathSeg::SVGPathSeg(const SVGPathSeg &other) -{ - assign(other); -} - -/** - * - */ -SVGPathSeg &operator=(const SVGPathSeg &other) -{ - assign(other); - return *this; -} - -/** - * - */ -void SVGPathSeg::init() -{ - type = PATHSEG_UNKNOWN; - x = y = x1 = y1 = x2 = y2 = 0.0; - r1 = r2 = 0.0; - angle = 0.0; - largeArcFlag = false; - sweepFlag = false; -} - -/** - * - */ -void SVGPathSeg::assign(const SVGPathSeg &other) -{ - type = other.type; - x = other.x; - y = other.y; - x1 = other.x1; - y1 = other.y1; - x2 = other.x2; - y2 = other.y2; - r1 = other.r1; - r2 = other.r2; - angle = other.angle; - largeArcFlag = other.largeArcFlag; - sweepFlag = other.sweepFlag; -} - - -/** - * - */ -SVGPathSeg::~SVGPathSeg() -{ -} - - - - -/*######################################################################### -## SVGPaint -#########################################################################*/ - - -/** - * - */ -unsigned short SVGPaint::getPaintType() -{ return paintType; } - -/** - * - */ -DOMString SVGPaint::getUri() -{ return uri; } - -/** - * - */ -void SVGPaint::setUri(const DOMString& uriArg) -{ - uri = uriArg; -} - -/** - * - */ -void SVGPaint::setPaint (unsigned short paintTypeArg, - const DOMString& uriArg, - const DOMString& /*rgbColor*/, - const DOMString& /*iccColor*/) - throw (SVGException) -{ - paintType = paintTypeArg; - uri = uriArg; - //do something with rgbColor - //do something with iccColor; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGPaint::SVGPaint() -{ - uri = ""; - paintType = SVG_PAINTTYPE_UNKNOWN; -} - -/** - * - */ -SVGPaint::SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other) -{ - uri = ""; - paintType = SVG_PAINTTYPE_UNKNOWN; -} - -/** - * - */ -SVGPaint::~SVGPaint() {} - - -/*######################################################################### -## SVGColorProfileRule -#########################################################################*/ - - -/** - * - */ -DOMString SVGColorProfileRule::getSrc() -{ return src; } - -/** - * - */ -void SVGColorProfileRule::setSrc(const DOMString &val) throw (DOMException) -{ src = val; } - -/** - * - */ -DOMString SVGColorProfileRule::getName() -{ return name; } - -/** - * - */ -void SVGColorProfileRule::setName(const DOMString &val) throw (DOMException) -{ name = val; } - -/** - * - */ -unsigned short SVGColorProfileRule::getRenderingIntent() -{ return renderingIntent; } - -/** - * - */ -void SVGColorProfileRule::setRenderingIntent(unsigned short val) throw (DOMException) -{ renderingIntent = val; } - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGColorProfileRule::SVGColorProfileRule() -{ -} - -/** - * - */ -SVGColorProfileRule::SVGColorProfileRule(const SVGColorProfileRule &other) - : SVGCSSRule(other), SVGRenderingIntent(other) -{ - renderingIntent = other.renderingIntent; - src = other.src; - name = other.name; -} - -/** - * - */ -SVGColorProfileRule::~SVGColorProfileRule() -{ -} - - -/*######################################################################### -## SVGFilterPrimitiveStandardAttributes -#########################################################################*/ - -/** - * - */ -SVGAnimatedLength SVGFilterPrimitiveStandardAttributes::getX() -{ return x; } - -/** - * - */ -SVGAnimatedLength SVGFilterPrimitiveStandardAttributes::getY() -{ return y; } - -/** - * - */ -SVGAnimatedLength SVGFilterPrimitiveStandardAttributes::getWidth() -{ return width; } - -/** - * - */ -SVGAnimatedLength SVGFilterPrimitiveStandardAttributes::getHeight() -{ return height; } - -/** - * - */ -SVGAnimatedString SVGFilterPrimitiveStandardAttributes::getResult() -{ return result; } - - - -//################## -//# Non-API methods -//################## - - -/** - * - */ -SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes() -{ -} - -/** - * - */ -SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes( - const SVGFilterPrimitiveStandardAttributes &other) - : SVGStylable(other) -{ - x = other.x; - y = other.y; - width = other.width; - height = other.height; - result = other.result; -} - -/** - * - */ -SVGFilterPrimitiveStandardAttributes::~SVGFilterPrimitiveStandardAttributes() -{ -} - - -/*######################################################################### -## SVGEvent -#########################################################################*/ - -/** - * - */ -SVGEvent:SVGEvent() -{ -} - -/** - * - */ -SVGEvent:SVGEvent(const SVGEvent &other) : events::Event(other) -{ -} - -/** - * - */ -SVGEvent::~SVGEvent() -{ -} - - -/*######################################################################### -## SVGZoomEvent -#########################################################################*/ - -/** - * - */ -SVGRect SVGZoomEvent::getZoomRectScreen() -{ - return zoomRectScreen; -} - -/** - * - */ -double SVGZoomEvent::getPreviousScale() -{ - return previousScale; -} - -/** - * - */ -SVGPoint SVGZoomEvent::getPreviousTranslate() -{ - return previousTranslate; -} - -/** - * - */ -double SVGZoomEvent::getNewScale() -{ - return newScale; -} - -/** - * - */ -SVGPoint SVGZoomEvent::getNewTranslate() -{ - return newTranslate; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGZoomEvent::SVGZoomEvent() -{ -} - -/** - * - */ -SVGZoomEvent::SVGZoomEvent(const SVGZoomEvent &other) : - events::Event(other), events::UIEvent(other) -{ - zoomRectScreen = other.zoomRectScreen; - previousScale = other.previousScale; - previousTranslate = other.previousTranslate; - newScale = other.newScale; - newTranslate = other.newTranslate; -} - -/** - * - */ -SVGZoomEvent::~SVGZoomEvent() -{ -} - - -/*######################################################################### -## SVGElementInstance -#########################################################################*/ - - -/** - * - */ -SVGElementPtr SVGElementInstance::getCorrespondingElement() -{ - return correspondingElement; -} - -/** - * - */ -SVGUseElementPtr SVGElementInstance::getCorrespondingUseElement() -{ - return correspondingUseElement; -} - -/** - * - */ -SVGElementInstance SVGElementInstance::getParentNode() -{ - SVGElementInstance ret; - return ret; -} - -/** - * Since we are using stack types and this is a circular definition, - * we will instead implement this as a global function below: - * SVGElementInstanceList getChildNodes(const SVGElementInstance instance); - */ -//SVGElementInstanceList getChildNodes(); - -/** - * - */ -SVGElementInstance SVGElementInstance::getFirstChild() -{ - SVGElementInstance ret; - return ret; -} - -/** - * - */ -SVGElementInstance SVGElementInstance::getLastChild() -{ - SVGElementInstance ret; - return ret; -} - -/** - * - */ -SVGElementInstance SVGElementInstance::getPreviousSibling() -{ - SVGElementInstance ret; - return ret; -} - -/** - * - */ -SVGElementInstance SVGElementInstance::getNextSibling() -{ - SVGElementInstance ret; - return ret; -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGElementInstance::SVGElementInstance() -{ -} - -/** - * - */ -SVGElementInstance::SVGElementInstance(const SVGElementInstance &other) - : events::EventTarget(other) -{ -} - -/** - * - */ -SVGElementInstance::~SVGElementInstance() -{ -} - - -/*######################################################################### -## SVGElementInstanceList -#########################################################################*/ - -/** - * - */ -unsigned long SVGElementInstanceList::getLength() -{ return items.size(); } - -/** - * - */ -SVGElementInstance SVGElementInstanceList::item(unsigned long index) -{ - if (index >= items.size()) - { - SVGElementInstance ret; - return ret; - } - return items[index]; -} - -/** - * This static method replaces the circular definition of: - * SVGElementInstanceList SVGElementInstance::getChildNodes() - * - */ -static SVGElementInstanceList SVGElementInstanceList::getChildNodes(const SVGElementInstance &/*instance*/) -{ - SVGElementInstanceList list; - return list; -} - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGElementInstanceList::SVGElementInstanceList() -{ -} - -/** - * - */ -SVGElementInstanceList::SVGElementInstanceList(const SVGElementInstanceList &other) -{ - items = other.items; -} - -/** - * - */ -SVGElementInstanceList::~SVGElementInstanceList() -{ -} - - - - -/*######################################################################### -## SVGValue -#########################################################################*/ - -/** - * Constructor - */ -SVGValue() -{ - init(); -} - -/** - * Copy constructor - */ -SVGValue(const SVGValue &other) -{ - assign(other); -} - -/** - * Assignment - */ -SVGValue &operator=(const SVGValue &other) -{ - assign(other); - return *this; -} - -/** - * - */ -~SVGValue() -{ -} - -//########################### -// TYPES -//########################### - -/** - * Angle - */ -SVGValue::SVGValue(const SVGAngle &v) -{ - type = SVG_ANGLE; - angleval = v; -} - -SVGAngle SVGValue::angleValue() -{ - return algleval; -} - -/** - * Boolean - */ -SVGValue::SVGValue(bool v) -{ - type = SVG_BOOLEAN; - bval = v; -} - -bool SVGValue::booleanValue() -{ - return bval; -} - - -/** - * Enumeration - */ -SVGValue::SVGValue(short v) -{ - type = SVG_ENUMERATION; - eval = v; -} - -short SVGValue::enumerationValue() -{ - return eval; -} - -/** - * Integer - */ -SVGValue::SVGValue(long v) -{ - type = SVG_INTEGER; - ival = v; -} - -long SVGValue::integerValue() -{ - return ival; -} - -/** - * Length - */ -SVGValue::SVGValue(const SVGLength &v) -{ - type = SVG_LENGTH; - lengthval = v; -} - -SVGLength SVGValue::lengthValue() -{ - return lengthval; -} - -/** - * Number - */ -SVGValue::SVGValue(double v) -{ - type = SVG_NUMBER; - dval = v; -} - -double SVGValue::numberValue() -{ - return dval; -} - -/** - * Points - */ -SVGValue::SVGValue(const SVGPointList &v) -{ - type = SVG_POINTS; - plistval = v; -} - -SVGPointList SVGValue::pointListValue() -{ - return plistval; -} - - -/** - * PreserveAspectRatio - */ -SVGValue::SVGValue(const SVGPreserveAspectRatio &v) -{ - type = SVG_PRESERVE_ASPECT_RATIO; - parval = v; -} - -SVGPreserveAspectRatio SVGValue::preserveAspectRatioValue() -{ - return parval; -} - -/** - * Rect - */ -SVGValue::SVGValue(const SVGRect &v) -{ - type = SVG_RECT; - rectval = v; -} - -SVGRect SVGValue::rectValue() -{ - return rectval; -} - -/** - * String - */ -SVGValue::SVGValue(const DOMString &v) -{ - type = SVG_STRING; - sval = v; -} - -DOMString SVGValue::stringValue() -{ - return sval; -} - - -void SVGValue::init() -{ - type = SVG_NUMBER; - bval = false; - eval = 0; - ival = 0; - dval = 0.0; -} - -void SVGValue::assign(const SVGValue &other) -{ - type = other.type; - angleval = other.angleval; - bval = other.bval; - eval = other.eval; - ival = other.ival; - lengthval = other.lengthval; - dval = other.dval; - parval = other.parval; - rval = other.rval; - sval = other.sval; -} - - -/*######################################################################### -## SVGTransformList -#########################################################################*/ - - -/*######################################################################### -## SVGStringList -#########################################################################*/ - - -/*######################################################################### -## SVGNumberList -#########################################################################*/ - - -/*######################################################################### -## SVGLengthList -#########################################################################*/ - - -/*######################################################################### -## SVGPointList -#########################################################################*/ - -/*######################################################################### -## SVGPathSegList -#########################################################################*/ - -/*######################################################################### -## SVGValueList -#########################################################################*/ - - -/** - * - */ -unsigned long SVGValueList::getNumberOfItems() -{ - return items.size(); -} - -/** - * - */ -void SVGValueList::clear() throw (DOMException) -{ - items.clear(); -} - -/** - * - */ -SVGValue SVGValueList::initialize(const SVGValue& newItem) - throw (DOMException, SVGException) -{ - items.clear(); - items.push_back(newItem); - return newItem; -} - -/** - * - */ -SVGValue SVGValueList::getItem(unsigned long index) throw (DOMException) -{ - if (index >= items.size()) - return ""; - return items[index]; -} - -/** - * - */ -SVGValue SVGValueList::insertItemBefore(const SVGValue& newItem, - unsigned long index) - throw (DOMException, SVGException) -{ - if (index>=items.size()) - { - items.push_back(newItem); - } - else - { - std::vector<SVGValue>::iterator iter = items.begin() + index; - items.insert(iter, newItem); - } - return newItem; -} - -/** - * - */ -SVGValue SVGValueList::replaceItem (const SVGValue& newItem, - unsigned long index) - throw (DOMException, SVGException) -{ - if (index>=items.size()) - return ""; - std::vector<SVGValue>::iterator iter = items.begin() + index; - *iter = newItem; - return newItem; -} - -/** - * - */ -SVGValue SVGValueList::removeItem (unsigned long index) - throw (DOMException) -{ - if (index>=items.size()) - return ""; - std::vector<SVGValue>::iterator iter = items.begin() + index; - SVGValue oldval = *iter; - items.erase(iter); - return oldval; -} - -/** - * - */ -SVGValue SVGValueList::appendItem (const SVGValue& newItem) - throw (DOMException, SVGException) -{ - items.push_back(newItem); - return newItem; -} - - -/** - * Matrix - */ -SVGValue SVGValueList::createSVGTransformFromMatrix(const SVGValue &matrix) -{ -} - -/** - * Matrix - */ -SVGValue SVGValueList::consolidate() -{ -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGValueList::SVGValueList() -{ -} - -/** - * - */ -SVGValueList::SVGValueList(const SVGValueList &other) -{ - items = other.items; -} - -/** - * - */ -SVGValueList::~SVGValueList() -{ -} - - - - - -/*######################################################################### -## SVGAnimatedValue -#########################################################################*/ - - - - -/** - * - */ -SVGValue &SVGAnimatedValue::getBaseVal() -{ - return baseVal; -} - -/** - * - */ -void SVGAnimatedValue::setBaseVal(const SVGValue &val) throw (DOMException) -{ - baseVal = val; -} - -/** - * - */ -SVGValue &SVGAnimatedValue::getAnimVal() -{ - return animVal; -} - - -/** - * - */ -SVGAnimatedValue::SVGAnimatedValue() -{ - init(); -} - - -/** - * - */ -SVGAnimatedValue::SVGAnimatedValue(const SVGValue &v) -{ - init(); - baseVal = v; -} - - -/** - * - */ -SVGAnimatedValue::SVGAnimatedValue(const SVGValue &bv, const SVGValue &av) -{ - init(); - baseVal = bv; - animVal = av; -} - - -/** - * - */ -SVGAnimatedValue::SVGAnimatedValue(const SVGAnimatedValue &other) -{ - assign(other); -} - - -/** - * - */ -SVGAnimatedValue &SVGAnimatedValue::operator=(const SVGAnimatedValue &other) -{ - assign(other); - return *this; -} - - -/** - * - */ -SVGAnimatedValue &SVGAnimatedValue::operator=(const SVGValue &bv) -{ - init(); - baseVal = bv; -} - - -/** - * - */ -SVGAnimatedValue::~SVGAnimatedValue() -{ -} - - - -void SVGAnimatedValue::init() -{ -} - - -void SVGAnimatedValue::assign(const SVGAnimatedValue &other) -{ - baseVal = other.baseVal; - animVal = other.animVal; -} - - - - - - - - - - - - - - - - - - - - - -//######################################################################## -//######################################################################## -//######################################################################## -//# D O M -//######################################################################## -//######################################################################## -//######################################################################## - - - - - - - -/*######################################################################### -## SVGElement -#########################################################################*/ - - -//#################################################################### -//# BASE METHODS FOR SVGElement -//#################################################################### - -/** - * Get the value of the id attribute on the given element. - */ -DOMString getId() -{ -} - -/** - * Set the value of the id attribute on the given element. - */ -void setId(const DOMString &val) throw (DOMException) -{ -} - - -/** - * Corresponds to attribute xml:base on the given element. - */ -DOMString getXmlBase() -{ -} - - -/** - * Corresponds to attribute xml:base on the given element. - */ -void setXmlBase(const DOMString &val) throw (DOMException) -{ -} - -/** - * The nearest ancestor 'svg' element. Null if the given element is the - * outermost 'svg' element. - */ -SVGElementPtr getOwnerSVGElement() -{ -} - -/** - * The element which established the current viewport. Often, the nearest - * ancestor 'svg' element. Null if the given element is the outermost 'svg' - * element. - */ -SVGElementPtr getViewportElement() -{ -} - - -//#################################################################### -//#################################################################### -//# I N T E R F A C E S -//#################################################################### -//#################################################################### - -//#################################################################### -//# SVGAngle -//#################################################################### - -/** - * - */ -unsigned short getUnitType() -{ -} - -/** - * - */ -double getValue() -{ -} - -/** - * - */ -void setValue(double val) throw (DOMException) -{ -} - -/** - * - */ -double getValueInSpecifiedUnits() -{ -} - -/** - * - */ -void setValueInSpecifiedUnits(double /*val*/) throw (DOMException) -{ -} - -/** - * - */ -DOMString getValueAsString() -{ -} - -/** - * - */ -void setValueAsString(const DOMString &/*val*/) throw (DOMException) -{ -} - - -/** - * - */ -void newValueSpecifiedUnits(unsigned short /*unitType*/, - double /*valueInSpecifiedUnits*/) -{ -} - -/** - * - */ -void convertToSpecifiedUnits(unsigned short /*unitType*/) -{ -} - -//#################################################################### -//## The following animated types are rolled up into a single -//## SVGAnimatedValue interface -//#################################################################### - -//#################################################################### -//## SVGAnimatedAngle -//#################################################################### - -//#################################################################### -//## SVGAnimatedBoolean -//#################################################################### - -//#################################################################### -//## SVGAnimatedEnumeration -//#################################################################### - -//#################################################################### -//## SVGAnimatedInteger -//#################################################################### - -//#################################################################### -//## SVGAnimatedLength -//#################################################################### - -//#################################################################### -//## SVGAnimatedLengthList -//#################################################################### - -//#################################################################### -//## SVGAnimatedNumber -//#################################################################### - -//#################################################################### -//## SVGAnimatedNumberList -//#################################################################### - -//#################################################################### -//## SVGAnimatedPathData -//#################################################################### - -//#################################################################### -//## SVGAnimatedPoints -//#################################################################### - -//#################################################################### -//## SVGAnimatedPreserveAspectRatio -//#################################################################### - -//#################################################################### -//## SVGAnimatedRect -//#################################################################### - -//#################################################################### -//## SVGAnimatedString -//#################################################################### - -//#################################################################### -//## SVGAnimatedTransformList -//#################################################################### - -//#################################################################### -//# SVGAnimatedValue -//#################################################################### - -/** - * - */ -SVGValue &getBaseVal() -{ - return baseVal(); -} - -/** - * - */ -void setBaseVal(const SVGValue &val) throw (DOMException) -{ - baseVal = val; -} - -/** - * - */ -SVGValue &getAnimVal() -{ - return animVal; -} - - - -//#################################################################### -//# SVGColor -//#################################################################### - -/** - * From CSSValue - * A code defining the type of the value as defined above. - */ -unsigned short getCssValueType() -{ -} - -/** - * From CSSValue - * A string representation of the current value. - */ -DOMString getCssText() -{ -} - -/** - * From CSSValue - * A string representation of the current value. - * Note that setting implies parsing. - */ -void setCssText(const DOMString &val) throw (dom::DOMException) -{ -} - - -/** - * - */ -unsigned short getColorType() -{ -} - -/** - * - */ -css::RGBColor getRgbColor() -{ -} - -/** - * - */ -SVGICCColor getIccColor() -{ -} - - -/** - * - */ -void setRGBColor(const DOMString& /*rgbColor*/) throw (SVGException) -{ -} - -/** - * - */ -void setRGBColorICCColor(const DOMString& /*rgbColor*/, - const DOMString& /*iccColor*/) - throw (SVGException) -{ -} - -/** - * - */ -void setColor(unsigned short /*colorType*/, - const DOMString& /*rgbColor*/, - const DOMString& /*iccColor*/) - throw (SVGException) -{ -} - -//#################################################################### -//# SVGCSSRule -//#################################################################### - -/** - * From CSSRule - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an instance of - * the CSSRule interface to the specific derived interface implied by the type. - */ -unsigned short getType() -{ -} - -/** - * From CSSRule - * The parsable textual representation of the rule. This reflects the current - * state of the rule and not its initial value. - */ -DOMString getCssText() -{ -} - -/** - * From CSSRule - * The parsable textual representation of the rule. This reflects the current - * state of the rule and not its initial value. - * Note that setting involves reparsing. - */ -void setCssText(const DOMString &val) throw (DOMException) -{ -} - -/** - * From CSSRule - * The style sheet that contains this rule. - */ -css::CSSStyleSheet *getParentStyleSheet() -{ -} - -/** - * From CSSRule - * If this rule is contained inside another rule(e.g. a style rule inside an - * @media block), this is the containing rule. If this rule is not nested inside - * any other rules, this returns null. - */ -css::CSSRule *getParentRule() -{ -} - -//#################################################################### -//# SVGExternalResourcesRequired -//#################################################################### - -/** - * - */ -SVGAnimatedBoolean getExternalResourcesRequired() -{ -} - -//#################################################################### -//# SVGFitToViewBox -//#################################################################### - -/** - * - */ -SVGAnimatedRect getViewBox() -{ -} - -/** - * - */ -SVGAnimatedPreserveAspectRatio getPreserveAspectRatio() -{ -} - -//#################################################################### -//# SVGICCColor -//#################################################################### - -/** - * - */ -DOMString getColorProfile() -{ -} - -/** - * - */ -void setColorProfile(const DOMString &val) throw (DOMException) -{ -} - -/** - * - */ -SVGNumberList &getColors() -{ -} - -//#################################################################### -//# SVGLangSpace -//#################################################################### - -/** - * - */ -DOMString getXmllang() -{ -} - -/** - * - */ -void setXmllang(const DOMString &val) throw (DOMException) -{ -} - -/** - * - */ -DOMString getXmlspace() -{ -} - -/** - * - */ -void setXmlspace(const DOMString &val) throw (DOMException) -{ -} - -//#################################################################### -//# SVGLength -//#################################################################### - -/** - * - */ -unsigned short getUnitType() -{ -} - -/** - * - */ -double getValue() -{ -} - -/** - * - */ -void setValue(double val) throw (DOMException) -{ -} - -/** - * - */ -double getValueInSpecifiedUnits() -{ -} - -/** - * - */ -void setValueInSpecifiedUnits(double /*val*/) throw (DOMException) -{ -} - -/** - * - */ -DOMString getValueAsString() -{ -} - -/** - * - */ -void setValueAsString(const DOMString& /*val*/) throw (DOMException) -{ -} - - -/** - * - */ -void newValueSpecifiedUnits(unsigned short /*unitType*/, double /*val*/) -{ -} - -/** - * - */ -void convertToSpecifiedUnits(unsigned short /*unitType*/) -{ -} - - -//#################################################################### -//## SVGLengthList - see SVGValueList -//#################################################################### - - - -//#################################################################### -//# SVGLocatable -//#################################################################### - -/** - * - */ -SVGElementPtr getNearestViewportElement() -{ -} - -/** - * - */ -SVGElement *getFarthestViewportElement() -{ -} - -/** - * - */ -SVGRect getBBox() -{ -} - -/** - * - */ -SVGMatrix getCTM() -{ -} - -/** - * - */ -SVGMatrix getScreenCTM() -{ -} - -/** - * - */ -SVGMatrix getTransformToElement(const SVGElement &/*element*/) - throw (SVGException) -{ -} - -//#################################################################### -//# SVGNumber -//#################################################################### - -/** - * - */ -double getValue() -{ -} - -/** - * - */ -void setValue(double val) throw (DOMException) -{ -} - -//#################################################################### -//# SVGNumberList - see SVGValueList -//#################################################################### - - -//#################################################################### -//# SVGRect -//#################################################################### - -/** - * - */ -double getX() -{ -} - -/** - * - */ -void setX(double val) throw (DOMException) -{ -} - -/** - * - */ -double getY() -{ -} - -/** - * - */ -void setY(double val) throw (DOMException) -{ -} - -/** - * - */ -double getWidth() -{ -} - -/** - * - */ -void setWidth(double val) throw (DOMException) -{ -} - -/** - * - */ -double getHeight() -{ -} - -/** - * - */ -void setHeight(double val) throw (DOMException) -{ -} - -//#################################################################### -//# SVGRenderingIntent -//#################################################################### - -//#################################################################### -//# SVGStringList - see SVGValueList -//#################################################################### - -//#################################################################### -//# SVGStylable -//#################################################################### - -/** - * - */ -SVGAnimatedString getClassName() -{ -} - -/** - * - */ -css::CSSStyleDeclaration getStyle() -{ -} - -/** - * - */ -css::CSSValue getPresentationAttribute(const DOMString& /*name*/) -{ -} - -//#################################################################### -//# SVGTests -//#################################################################### - -/** - * - */ -SVGValueList &getRequiredFeatures() -{ -} - -/** - * - */ -SVGValueList &getRequiredExtensions() -{ -} - -/** - * - */ -SVGValueList &getSystemLanguage() -{ -} - -/** - * - */ -bool hasExtension(const DOMString& /*extension*/) -{ -} - -//#################################################################### -//# SVGTransformable -//#################################################################### - -/** - * - */ -SVGAnimatedList &getTransform() -{ -} - -//#################################################################### -//# SVGUnitTypes -//#################################################################### - -//#################################################################### -//# SVGURIReference -//#################################################################### - -/** - * - */ -SVGAnimatedValue getHref() -{ -} - -//#################################################################### -//## SVGValueList - consolidation of other lists -//#################################################################### - -/** - * - */ -unsigned long SVGElement::getNumberOfItems() -{ - return items.size(); -} - -/** - * - */ -void SVGElement::clear() throw (DOMException) -{ - items.clear(); -} - -/** - * - */ -SVGValue SVGElement::initialize(const SVGValue& newItem) - throw (DOMException, SVGException) -{ - items.clear(); - items.push_back(newItem); - return newItem; -} - -/** - * - */ -SVGValue SVGElement::getItem(unsigned long index) throw (DOMException) -{ - if (index >= items.size()) - return ""; - return items[index]; -} - -/** - * - */ -SVGValue SVGElement::insertItemBefore(const SVGValue& newItem, - unsigned long index) - throw (DOMException, SVGException) -{ - if (index>=items.size()) - { - items.push_back(newItem); - } - else - { - std::vector<SVGValue>::iterator iter = items.begin() + index; - items.insert(iter, newItem); - } - return newItem; -} - -/** - * - */ -SVGValue SVGElement::replaceItem (const SVGValue& newItem, - unsigned long index) - throw (DOMException, SVGException) -{ - if (index>=items.size()) - return ""; - std::vector<SVGValue>::iterator iter = items.begin() + index; - *iter = newItem; - return newItem; -} - -/** - * - */ -SVGValue SVGElement::removeItem (unsigned long index) - throw (DOMException) -{ - if (index>=items.size()) - return ""; - std::vector<SVGValue>::iterator iter = items.begin() + index; - SVGValue oldval = *iter; - items.erase(iter); - return oldval; -} - -/** - * - */ -SVGValue SVGElement::appendItem (const SVGValue& newItem) - throw (DOMException, SVGException) -{ - items.push_back(newItem); - return newItem; -} - - -/** - * Matrix - */ -SVGValue SVGElement::createSVGTransformFromMatrix(const SVGValue &matrix) -{ -} - -/** - * Matrix - */ -SVGValue SVGElement::consolidate() -{ -} - - -//#################################################################### -//# SVGViewSpec -//#################################################################### - -/** - * - */ -//SVGTransformList getTransform() -//{ -//} - -/** - * - */ -SVGElementPtr getViewTarget() -{ -} - -/** - * - */ -DOMString getViewBoxString() -{ -} - -/** - * - */ -DOMString getPreserveAspectRatioString() -{ -} - -/** - * - */ -DOMString getTransformString() -{ -} - -/** - * - */ -DOMString getViewTargetString() -{ -} - -//#################################################################### -//# SVGZoomAndPan -//#################################################################### - -/** - * - */ -unsigned short getZoomAndPan() -{ -} - -/** - * - */ -void setZoomAndPan(unsigned short val) throw (DOMException) -{ -} - -//#################################################################### -//#################################################################### -//# E L E M E N T S -//#################################################################### -//#################################################################### - -//#################################################################### -//# SVGAElement -//#################################################################### - - -/** - * - */ -SVGAnimatedString getTarget() -{ -} - - - -//#################################################################### -//# SVGAltGlyphElement -//#################################################################### - - -/** - * Get the attribute glyphRef on the given element. - */ -DOMString getGlyphRef() -{ -} - -/** - * Set the attribute glyphRef on the given element. - */ -void setGlyphRef(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute format on the given element. - */ -DOMString getFormat() -{ -} - -/** - * Set the attribute format on the given element. - */ -void setFormat(const DOMString &val) throw (DOMException) -{ -} - - -//#################################################################### -//# SVGAltGlyphDefElement -//#################################################################### - -//#################################################################### -//# SVGAltGlyphItemElement -//#################################################################### - - -//#################################################################### -//# SVGAnimateElement -//#################################################################### - - -//#################################################################### -//# SVGAnimateColorElement -//#################################################################### - -//#################################################################### -//# SVGAnimateMotionElement -//#################################################################### - - -//#################################################################### -//# SVGAnimateTransformElement -//#################################################################### - - -//#################################################################### -//# SVGAnimationElement -//#################################################################### - - -/** - * - */ -SVGElementPtr getTargetElement() -{ -} - -/** - * - */ -double getStartTime() -{ -} - -/** - * - */ -double getCurrentTime() -{ -} - -/** - * - */ -double getSimpleDuration() throw (DOMException) -{ -} - - - -//#################################################################### -//# SVGCircleElement -//#################################################################### - -/** - * Corresponds to attribute cx on the given 'circle' element. - */ -SVGAnimatedLength getCx() -{ -} - -/** - * Corresponds to attribute cy on the given 'circle' element. - */ -SVGAnimatedLength getCy() -{ -} - -/** - * Corresponds to attribute r on the given 'circle' element. - */ -SVGAnimatedLength getR() -{ -} - -//#################################################################### -//# SVGClipPathElement -//#################################################################### - - -/** - * Corresponds to attribute clipPathUnits on the given 'clipPath' element. - * Takes one of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getClipPathUnits() -{ -} - - - -//#################################################################### -//# SVGColorProfileElement -//#################################################################### - - -/** - * Get the attribute local on the given element. - */ -DOMString getLocal() -{ -} - -/** - * Set the attribute local on the given element. - */ -void setLocal(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute name on the given element. - */ -DOMString getName() -{ -} - -/** - * Set the attribute name on the given element. - */ -void setName(const DOMString &val) throw (DOMException) -{ -} - -/** - * Set the attribute rendering-intent on the given element. - * The type of rendering intent, identified by one of the - * SVGRenderingIntent constants. - */ -unsigned short getRenderingIntent() -{ -} - -/** - * Get the attribute rendering-intent on the given element. - */ -void setRenderingIntent(unsigned short val) throw (DOMException) -{ -} - - -//#################################################################### -//# SVGComponentTransferFunctionElement -//#################################################################### - -/** - * Corresponds to attribute type on the given element. Takes one - * of the Component Transfer Types. - */ -SVGAnimatedEnumeration getType() -{ -} - -/** - * Corresponds to attribute tableValues on the given element. - */ -SVGAnimatedNumberList getTableValues() -{ -} - -/** - * Corresponds to attribute slope on the given element. - */ -SVGAnimatedNumber getSlope() -{ -} - -/** - * Corresponds to attribute intercept on the given element. - */ -SVGAnimatedNumber getIntercept() -{ -} - -/** - * Corresponds to attribute amplitude on the given element. - */ -SVGAnimatedNumber getAmplitude() -{ -} - -/** - * Corresponds to attribute exponent on the given element. - */ -SVGAnimatedNumber getExponent() -{ -} - -/** - * Corresponds to attribute offset on the given element. - */ -SVGAnimatedNumber getOffset() -{ -} - -//#################################################################### -//# SVGCursorElement -//#################################################################### - -/** - * - */ -SVGAnimatedLength getX() -{ -} - -/** - * - */ -SVGAnimatedLength getY() -{ -} - - -//#################################################################### -//# SVGDefinitionSrcElement -//#################################################################### - -//#################################################################### -//# SVGDefsElement -//#################################################################### - -//#################################################################### -//# SVGDescElement -//#################################################################### - -//#################################################################### -//# SVGEllipseElement -//#################################################################### - -/** - * Corresponds to attribute cx on the given 'ellipse' element. - */ -SVGAnimatedLength getCx() -{ -} - -/** - * Corresponds to attribute cy on the given 'ellipse' element. - */ -SVGAnimatedLength getCy() -{ -} - -/** - * Corresponds to attribute rx on the given 'ellipse' element. - */ -SVGAnimatedLength getRx() -{ -} - -/** - * Corresponds to attribute ry on the given 'ellipse' element. - */ -SVGAnimatedLength getRy() -{ -} - - -//#################################################################### -//# SVGFEBlendElement -//#################################################################### - -/** - * Corresponds to attribute in on the given 'feBlend' element. - */ -SVGAnimatedString getIn1() -{ -} - -/** - * Corresponds to attribute in2 on the given 'feBlend' element. - */ -SVGAnimatedString getIn2() -{ -} - -/** - * Corresponds to attribute mode on the given 'feBlend' element. - * Takes one of the Blend Mode Types. - */ -SVGAnimatedEnumeration getMode() -{ -} - - -//#################################################################### -//# SVGFEColorMatrixElement -//#################################################################### - -/** - * Corresponds to attribute in on the given 'feColorMatrix' element. - */ -SVGAnimatedString getIn1() -{ -} - -/** - * Corresponds to attribute type on the given 'feColorMatrix' element. - * Takes one of the Color Matrix Types. - */ -SVGAnimatedEnumeration getType() -{ -} - -/** - * Corresponds to attribute values on the given 'feColorMatrix' element. - * Provides access to the contents of the values attribute. - */ -SVGAnimatedNumberList getValues() -{ -} - - -//#################################################################### -//# SVGFEComponentTransferElement -//#################################################################### - - -/** - * Corresponds to attribute in on the given 'feComponentTransfer' element. - */ -SVGAnimatedString getIn1() -{ -} - -//#################################################################### -//# SVGFECompositeElement -//#################################################################### - -/** - * Corresponds to attribute in on the given 'feComposite' element. - */ -SVGAnimatedString getIn1() -{ -} - -/** - * Corresponds to attribute in2 on the given 'feComposite' element. - */ -SVGAnimatedString getIn2() -{ -} - -/** - * Corresponds to attribute operator on the given 'feComposite' element. - * Takes one of the Composite Operators. - */ -SVGAnimatedEnumeration getOperator() -{ -} - -/** - * Corresponds to attribute k1 on the given 'feComposite' element. - */ -SVGAnimatedNumber getK1() -{ -} - -/** - * Corresponds to attribute k2 on the given 'feComposite' element. - */ -SVGAnimatedNumber getK2() -{ -} - -/** - * Corresponds to attribute k3 on the given 'feComposite' element. - */ -SVGAnimatedNumber getK3() -{ -} - -/** - * Corresponds to attribute k4 on the given 'feComposite' element. - */ -SVGAnimatedNumber getK4() -{ -} - - -//#################################################################### -//# SVGFEConvolveMatrixElement -//#################################################################### - - -/** - * Corresponds to attribute order on the given 'feConvolveMatrix' element. - */ -SVGAnimatedInteger getOrderX() -{ -} - -/** - * Corresponds to attribute order on the given 'feConvolveMatrix' element. - */ -SVGAnimatedInteger getOrderY() -{ -} - -/** - * Corresponds to attribute kernelMatrix on the given element. - */ -SVGAnimatedNumberList getKernelMatrix() -{ -} - -/** - * Corresponds to attribute divisor on the given 'feConvolveMatrix' element. - */ -SVGAnimatedNumber getDivisor() -{ -} - -/** - * Corresponds to attribute bias on the given 'feConvolveMatrix' element. - */ -SVGAnimatedNumber getBias() -{ -} - -/** - * Corresponds to attribute targetX on the given 'feConvolveMatrix' element. - */ -SVGAnimatedInteger getTargetX() -{ -} - -/** - * Corresponds to attribute targetY on the given 'feConvolveMatrix' element. - */ -SVGAnimatedInteger getTargetY() -{ -} - -/** - * Corresponds to attribute edgeMode on the given 'feConvolveMatrix' - * element. Takes one of the Edge Mode Types. - */ -SVGAnimatedEnumeration getEdgeMode() -{ -} - -/** - * Corresponds to attribute kernelUnitLength on the - * given 'feConvolveMatrix' element. - */ -SVGAnimatedLength getKernelUnitLengthX() -{ -} - -/** - * Corresponds to attribute kernelUnitLength on the given - * 'feConvolveMatrix' element. - */ -SVGAnimatedLength getKernelUnitLengthY() -{ -} - -/** - * Corresponds to attribute preserveAlpha on the - * given 'feConvolveMatrix' element. - */ -SVGAnimatedBoolean getPreserveAlpha() -{ -} - - - -//#################################################################### -//# SVGFEDiffuseLightingElement -//#################################################################### - - -/** - * Corresponds to attribute in on the given 'feDiffuseLighting' element. - */ -SVGAnimatedString getIn1() -{ -} - -/** - * Corresponds to attribute surfaceScale on the given - * 'feDiffuseLighting' element. - */ -SVGAnimatedNumber getSurfaceScale() -{ -} - -/** - * Corresponds to attribute diffuseConstant on the given - * 'feDiffuseLighting' element. - */ -SVGAnimatedNumber getDiffuseConstant() -{ -} - -/** - * Corresponds to attribute kernelUnitLength on the given - * 'feDiffuseLighting' element. - */ -SVGAnimatedNumber getKernelUnitLengthX() -{ -} - -/** - * Corresponds to attribute kernelUnitLength on the given - * 'feDiffuseLighting' element. - */ -SVGAnimatedNumber getKernelUnitLengthY() -{ -} - - - - -//#################################################################### -//# SVGFEDisplacementMapElement -//#################################################################### - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - -/** - * - */ -SVGAnimatedString getIn2() -{ -} - - -/** - * - */ -SVGAnimatedNumber getScale() -{ -} - -/** - * - */ -SVGAnimatedEnumeration getXChannelSelector() -{ -} - -/** - * - */ -SVGAnimatedEnumeration getYChannelSelector() -{ -} - -//#################################################################### -//# SVGFEDistantLightElement -//#################################################################### - - -/** - * Corresponds to attribute azimuth on the given 'feDistantLight' element. - */ -SVGAnimatedNumber getAzimuth() -{ -} - - -/** - * Corresponds to attribute elevation on the given 'feDistantLight' - * element - */ -SVGAnimatedNumber getElevation() -{ -} - - -//#################################################################### -//# SVGFEFloodElement -//#################################################################### - - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - - -//#################################################################### -//# SVGFEFuncAElement -//#################################################################### - -//#################################################################### -//# SVGFEFuncBElement -//#################################################################### - -//#################################################################### -//# SVGFEFuncGElement -//#################################################################### - -//#################################################################### -//# SVGFEFuncRElement -//#################################################################### - - -//#################################################################### -//# SVGFEGaussianBlurElement -//#################################################################### - - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - - -/** - * - */ -SVGAnimatedNumber getStdDeviationX() -{ -} - -/** - * - */ -SVGAnimatedNumber getStdDeviationY() -{ -} - - -/** - * - */ -void setStdDeviation(double stdDeviationX, double stdDeviationY) -{ -} - - -//#################################################################### -//# SVGFEImageElement -//#################################################################### - - -//#################################################################### -//# SVGFEMergeElement -//#################################################################### - -//#################################################################### -//# SVGFEMergeNodeElement -//#################################################################### - -//#################################################################### -//# SVGFEMorphologyElement -//#################################################################### - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - - -/** - * - */ -SVGAnimatedEnumeration getOperator() -{ -} - -/** - * - */ -SVGAnimatedLength getRadiusX() -{ -} - -/** - * - */ -SVGAnimatedLength getRadiusY() -{ -} - -//#################################################################### -//# SVGFEOffsetElement -//#################################################################### - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - -/** - * - */ -SVGAnimatedLength getDx() -{ -} - -/** - * - */ -SVGAnimatedLength getDy() -{ -} - - -//#################################################################### -//# SVGFEPointLightElement -//#################################################################### - -/** - * Corresponds to attribute x on the given 'fePointLight' element. - */ -SVGAnimatedNumber getX() -{ -} - -/** - * Corresponds to attribute y on the given 'fePointLight' element. - */ -SVGAnimatedNumber getY() -{ -} - -/** - * Corresponds to attribute z on the given 'fePointLight' element. - */ -SVGAnimatedNumber getZ() -{ -} - -//#################################################################### -//# SVGFESpecularLightingElement -//#################################################################### - - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - -/** - * - */ -SVGAnimatedNumber getSurfaceScale() -{ -} - -/** - * - */ -SVGAnimatedNumber getSpecularConstant() -{ -} - -/** - * - */ -SVGAnimatedNumber getSpecularExponent() -{ -} - - -//#################################################################### -//# SVGFESpotLightElement -//#################################################################### - -/** - * Corresponds to attribute x on the given 'feSpotLight' element. - */ -SVGAnimatedNumber getX() -{ -} - -/** - * Corresponds to attribute y on the given 'feSpotLight' element. - */ -SVGAnimatedNumber getY() -{ -} - -/** - * Corresponds to attribute z on the given 'feSpotLight' element. - */ -SVGAnimatedNumber getZ() -{ -} - -/** - * Corresponds to attribute pointsAtX on the given 'feSpotLight' element. - */ -SVGAnimatedNumber getPointsAtX() -{ -} - -/** - * Corresponds to attribute pointsAtY on the given 'feSpotLight' element. - */ -SVGAnimatedNumber getPointsAtY() -{ -} - -/** - * Corresponds to attribute pointsAtZ on the given 'feSpotLight' element. - */ -SVGAnimatedNumber getPointsAtZ() -{ -} - -/** - * Corresponds to attribute specularExponent on the - * given 'feSpotLight' element. - */ -SVGAnimatedNumber getSpecularExponent() -{ -} - -/** - * Corresponds to attribute limitingConeAngle on the - * given 'feSpotLight' element. - */ -SVGAnimatedNumber getLimitingConeAngle() -{ -} - - -//#################################################################### -//# SVGFETileElement -//#################################################################### - - -/** - * - */ -SVGAnimatedString getIn1() -{ -} - - -//#################################################################### -//# SVGFETurbulenceElement -//#################################################################### - - -/** - * - */ -SVGAnimatedNumber getBaseFrequencyX() -{ -} - -/** - * - */ -SVGAnimatedNumber getBaseFrequencyY() -{ -} - -/** - * - */ -SVGAnimatedInteger getNumOctaves() -{ -} - -/** - * - */ -SVGAnimatedNumber getSeed() -{ -} - -/** - * - */ -SVGAnimatedEnumeration getStitchTiles() -{ -} - -/** - * - */ -SVGAnimatedEnumeration getType() -{ -} - - - -//#################################################################### -//# SVGFilterElement -//#################################################################### - - -/** - * Corresponds to attribute filterUnits on the given 'filter' element. Takes one - * of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getFilterUnits() -{ -} - -/** - * Corresponds to attribute primitiveUnits on the given 'filter' element. Takes - * one of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getPrimitiveUnits() -{ -} - -/** - * - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute x on the given 'filter' element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute y on the given 'filter' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'filter' element. - */ -SVGAnimatedLength getHeight() -{ -} - - -/** - * Corresponds to attribute filterRes on the given 'filter' element. - * Contains the X component of attribute filterRes. - */ -SVGAnimatedInteger getFilterResX() -{ -} - -/** - * Corresponds to attribute filterRes on the given 'filter' element. - * Contains the Y component(possibly computed automatically) - * of attribute filterRes. - */ -SVGAnimatedInteger getFilterResY() -{ -} - -/** - * Sets the values for attribute filterRes. - */ -void setFilterRes(unsigned long filterResX, unsigned long filterResY) -{ -} - - -//#################################################################### -//# SVGFontElement -//#################################################################### - -//#################################################################### -//# SVGFontFaceElement -//#################################################################### - -//#################################################################### -//# SVGFontFaceFormatElement -//#################################################################### - -//#################################################################### -//# SVGFontFaceNameElement -//#################################################################### - -//#################################################################### -//# SVGFontFaceSrcElement -//#################################################################### - -//#################################################################### -//# SVGFontFaceUriElement -//#################################################################### - -//#################################################################### -//# SVGForeignObjectElement -//#################################################################### - -/** - * - */ -SVGAnimatedLength getX() -{ -} - -/** - * - */ -SVGAnimatedLength getY() -{ -} - -/** - * - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * - */ -SVGAnimatedLength getHeight() -{ -} - - - -//#################################################################### -//# SVGGlyphRefElement -//#################################################################### - - -/** - * Get the attribute glyphRef on the given element. - */ -DOMString getGlyphRef() -{ -} - -/** - * Set the attribute glyphRef on the given element. - */ -void setGlyphRef(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute format on the given element. - */ -DOMString getFormat() -{ -} - -/** - * Set the attribute format on the given element. - */ -void setFormat(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute x on the given element. - */ -double getX() -{ -} - -/** - * Set the attribute x on the given element. - */ -void setX(double val) throw (DOMException) -{ -} - -/** - * Get the attribute y on the given element. - */ -double getY() -{ -} - -/** - * Set the attribute y on the given element. - */ -void setY(double val) throw (DOMException) -{ -} - -/** - * Get the attribute dx on the given element. - */ -double getDx() -{ -} - -/** - * Set the attribute dx on the given element. - */ -void setDx(double val) throw (DOMException) -{ -} - -/** - * Get the attribute dy on the given element. - */ -double getDy() -{ -} - -/** - * Set the attribute dy on the given element. - */ -void setDy(double val) throw (DOMException) -{ -} - - -//#################################################################### -//# SVGGradientElement -//#################################################################### - -/** - * Corresponds to attribute gradientUnits on the given element. - * Takes one of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getGradientUnits() -{ -} - -/** - * Corresponds to attribute gradientTransform on the given element. - */ -SVGAnimatedTransformList getGradientTransform() -{ -} - -/** - * Corresponds to attribute spreadMethod on the given element. - * One of the Spread Method Types. - */ -SVGAnimatedEnumeration getSpreadMethod() -{ -} - - - -//#################################################################### -//# SVGHKernElement -//#################################################################### - -//#################################################################### -//# SVGImageElement -//#################################################################### - -/** - * Corresponds to attribute x on the given 'image' element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute y on the given 'image' element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute width on the given 'image' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'image' element. - */ -SVGAnimatedLength getHeight() -{ -} - - -/** - * Corresponds to attribute preserveAspectRatio on the given element. - */ -SVGAnimatedPreserveAspectRatio getPreserveAspectRatio() -{ -} - -//#################################################################### -//# SVGLinearGradientElement -//#################################################################### - -/** - * Corresponds to attribute x1 on the given 'linearGradient' element. - */ -SVGAnimatedLength getX1() -{ -} - -/** - * Corresponds to attribute y1 on the given 'linearGradient' element. - */ -SVGAnimatedLength getY1() -{ -} - -/** - * Corresponds to attribute x2 on the given 'linearGradient' element. - */ -SVGAnimatedLength getX2() -{ -} - -/** - * Corresponds to attribute y2 on the given 'linearGradient' element. - */ -SVGAnimatedLength getY2() -{ -} - - - -//#################################################################### -//# SVGLineElement -//#################################################################### - -/** - * Corresponds to attribute x1 on the given 'line' element. - */ -SVGAnimatedLength getX1() -{ -} - -/** - * Corresponds to attribute y1 on the given 'line' element. - */ -SVGAnimatedLength getY1() -{ -} - -/** - * Corresponds to attribute x2 on the given 'line' element. - */ -SVGAnimatedLength getX2() -{ -} - -/** - * Corresponds to attribute y2 on the given 'line' element. - */ -SVGAnimatedLength getY2() -{ -} - - -//#################################################################### -//# SVGMarkerElement -//#################################################################### - - -/** - * Corresponds to attribute refX on the given 'marker' element. - */ -SVGAnimatedLength getRefX() -{ -} - -/** - * Corresponds to attribute refY on the given 'marker' element. - */ -SVGAnimatedLength getRefY() -{ -} - -/** - * Corresponds to attribute markerUnits on the given 'marker' element. - * One of the Marker Units Types defined above. - */ -SVGAnimatedEnumeration getMarkerUnits() -{ -} - -/** - * Corresponds to attribute markerWidth on the given 'marker' element. - */ -SVGAnimatedLength getMarkerWidth() -{ -} - -/** - * Corresponds to attribute markerHeight on the given 'marker' element. - */ -SVGAnimatedLength getMarkerHeight() -{ -} - -/** - * Corresponds to attribute orient on the given 'marker' element. - * One of the Marker Orientation Types defined above. - */ -SVGAnimatedEnumeration getOrientType() -{ -} - -/** - * Corresponds to attribute orient on the given 'marker' element. - * If markerUnits is SVG_MARKER_ORIENT_ANGLE, the angle value for - * attribute orient ; otherwise, it will be set to zero. - */ -SVGAnimatedAngle getOrientAngle() -{ -} - - -/** - * Sets the value of attribute orient to 'auto'. - */ -void setOrientToAuto() -{ -} - -/** - * Sets the value of attribute orient to the given angle. - */ -void setOrientToAngle(const SVGAngle &angle) -{ -} - - -//#################################################################### -//# SVGMaskElement -//#################################################################### - - -/** - * Corresponds to attribute maskUnits on the given 'mask' element. Takes one of - * the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getMaskUnits() -{ -} - -/** - * Corresponds to attribute maskContentUnits on the given 'mask' element. Takes - * one of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getMaskContentUnits() -{ -} - -/** - * Corresponds to attribute x on the given 'mask' element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute y on the given 'mask' element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute width on the given 'mask' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'mask' element. - */ -SVGAnimatedLength getHeight() -{ -} - -//#################################################################### -//# SVGMetadataElement -//#################################################################### - -//#################################################################### -//# SVGMissingGlyphElement -//#################################################################### - -//#################################################################### -//# SVGMPathElement -//#################################################################### - -//#################################################################### -//# SVGPathElement -//#################################################################### - -/** - * Corresponds to attribute pathLength on the given 'path' element. - */ -SVGAnimatedNumber getPathLength() -{ -} - -/** - * Returns the user agent's computed value for the total length of the path using - * the user agent's distance-along-a-path algorithm, as a distance in the current - * user coordinate system. - */ -double getTotalLength() -{ -} - -/** - * Returns the(x,y) coordinate in user space which is distance units along the - * path, utilizing the user agent's distance-along-a-path algorithm. - */ -SVGPoint getPointAtLength(double distance) -{ -} - -/** - * Returns the index into pathSegList which is distance units along the path, - * utilizing the user agent's distance-along-a-path algorithm. - */ -unsigned long getPathSegAtLength(double distance) -{ -} - -/** - * Returns a stand-alone, parentless SVGPathSegClosePath object. - */ -SVGPathSeg createSVGPathSegClosePath() -{ - SVGPathSeg seg(PATHSEG_CLOSEPATH); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegMovetoAbs object. - */ -SVGPathSeg createSVGPathSegMovetoAbs(double x, double y) -{ - SVGPathSeg seg(PATHSEG_MOVETO_ABS); - seg.setX(x); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegMovetoRel object. - */ -SVGPathSeg createSVGPathSegMovetoRel(double x, double y) -{ - SVGPathSeg seg(PATHSEG_MOVETO_REL); - seg.setX(x); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegLinetoAbs object. - */ -SVGPathSeg createSVGPathSegLinetoAbs(double x, double y) -{ - SVGPathSeg seg(PATHSEG_LINETO_ABS); - seg.setX(x); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegLinetoRel object. - */ -SVGPathSeg createSVGPathSegLinetoRel(double x, double y) -{ - SVGPathSeg seg(PATHSEG_LINETO_REL); - seg.setX(x); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoCubicAbs object. - */ -SVGPathSeg createSVGPathSegCurvetoCubicAbs(double x, double y, - double x1, double y1, double x2, double y2) -{ - SVGPathSeg seg(PATHSEG_CURVETO_CUBIC_ABS); - seg.setX(x); - seg.setY(y); - seg.setX1(x1); - seg.setY1(y1); - seg.setX2(x2); - seg.setY2(y2); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoCubicRel object. - */ -SVGPathSeg createSVGPathSegCurvetoCubicRel(double x, double y, - double x1, double y1, double x2, double y2) -{ - SVGPathSeg seg(PATHSEG_CURVETO_CUBIC_REL); - seg.setX(x); - seg.setY(y); - seg.setX1(x1); - seg.setY1(y1); - seg.setX2(x2); - seg.setY2(y2); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoQuadraticAbs object. - */ -SVGPathSeg createSVGPathSegCurvetoQuadraticAbs(double x, double y, - double x1, double y1) -{ - SVGPathSeg seg(PATHSEG_CURVETO_QUADRATIC_ABS); - seg.setX(x); - seg.setY(y); - seg.setX1(x1); - seg.setY1(y1); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoQuadraticRel object. - */ -SVGPathSeg createSVGPathSegCurvetoQuadraticRel(double x, double y, - double x1, double y1) -{ - SVGPathSeg seg(PATHSEG_CURVETO_QUADRATIC_REL); - seg.setX(x); - seg.setY(y); - seg.setX1(x1); - seg.setY1(y1); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegArcAbs object. - */ -SVGPathSeg createSVGPathSegArcAbs(double x, double y, - double r1, double r2, double angle, - bool largeArcFlag, bool sweepFlag) -{ - SVGPathSeg seg(PATHSEG_ARC_ABS); - seg.setX(x); - seg.setY(y); - seg.setR1(r1); - seg.setR2(r2); - seg.setAngle(angle); - seg.setLargeArcFlag(largeArcFlag); - seg.setSweepFlag(sweepFlag); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegArcRel object. - */ -SVGPathSeg createSVGPathSegArcRel(double x, double y, double r1, - double r2, double angle, bool largeArcFlag, - bool sweepFlag) -{ - SVGPathSeg seg(PATHSEG_ARC_REL); - seg.setX(x); - seg.setY(y); - seg.setR1(r1); - seg.setR2(r2); - seg.setAngle(angle); - seg.setLargeArcFlag(largeArcFlag); - seg.setSweepFlag(sweepFlag); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegLinetoHorizontalAbs object. - */ -SVGPathSeg createSVGPathSegLinetoHorizontalAbs(double x) -{ - SVGPathSeg seg(PATHSEG_LINETO_HORIZONTAL_ABS); - seg.setX(x); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegLinetoHorizontalRel object. - */ -SVGPathSeg createSVGPathSegLinetoHorizontalRel(double x) -{ - SVGPathSeg seg(PATHSEG_LINETO_HORIZONTAL_REL); - seg.setX(x); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegLinetoVerticalAbs object. - */ -SVGPathSeg createSVGPathSegLinetoVerticalAbs(double y) -{ - SVGPathSeg seg(PATHSEG_LINETO_VERTICAL_ABS); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegLinetoVerticalRel object. - */ -SVGPathSeg createSVGPathSegLinetoVerticalRel(double y) -{ - SVGPathSeg seg(PATHSEG_LINETO_VERTICAL_REL); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoCubicSmoothAbs object. - */ -SVGPathSeg createSVGPathSegCurvetoCubicSmoothAbs(double x, double y, - double x2, double y2) -{ - SVGPathSeg seg(PATHSEG_CURVETO_CUBIC_SMOOTH_ABS); - seg.setX(x); - seg.setY(y); - seg.setX2(x2); - seg.setY2(y2); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoCubicSmoothRel object. - */ -SVGPathSeg createSVGPathSegCurvetoCubicSmoothRel(double x, double y, - double x2, double y2) -{ - SVGPathSeg seg(PATHSEG_CURVETO_CUBIC_SMOOTH_REL); - seg.setX(x); - seg.setY(y); - seg.setX2(x2); - seg.setY2(y2); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoQuadraticSmoothAbs - * object. - */ -SVGPathSeg createSVGPathSegCurvetoQuadraticSmoothAbs(double x, double y) -{ - SVGPathSeg seg(PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS); - seg.setX(x); - seg.setY(y); - return seg; -} - -/** - * Returns a stand-alone, parentless SVGPathSegCurvetoQuadraticSmoothRel - * object. - */ -SVGPathSeg createSVGPathSegCurvetoQuadraticSmoothRel(double x, double y) -{ - SVGPathSeg seg(PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL); - seg.setX(x); - seg.setY(y); - return seg; -} - - -//#################################################################### -//# SVGPatternElement -//#################################################################### - -/** - * Corresponds to attribute patternUnits on the given 'pattern' element. - * Takes one of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getPatternUnits() -{ -} - -/** - * Corresponds to attribute patternContentUnits on the given 'pattern' - * element. Takes one of the constants defined in SVGUnitTypes. - */ -SVGAnimatedEnumeration getPatternContentUnits() -{ -} - -/** - * Corresponds to attribute patternTransform on the given 'pattern' element. - */ -SVGAnimatedTransformList getPatternTransform() -{ -} - -/** - * Corresponds to attribute x on the given 'pattern' element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute width on the given 'pattern' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'pattern' element. - */ -SVGAnimatedLength getHeight() -{ -} - - -//#################################################################### -//# SVGPolyLineElement -//#################################################################### - -//#################################################################### -//# SVGPolygonElement -//#################################################################### - - -//#################################################################### -//# SVGRadialGradientElement -//#################################################################### - - -/** - * Corresponds to attribute cx on the given 'radialGradient' element. - */ -SVGAnimatedLength getCx() -{ -} - - -/** - * Corresponds to attribute cy on the given 'radialGradient' element. - */ -SVGAnimatedLength getCy() -{ -} - - -/** - * Corresponds to attribute r on the given 'radialGradient' element. - */ -SVGAnimatedLength getR() -{ -} - - -/** - * Corresponds to attribute fx on the given 'radialGradient' element. - */ -SVGAnimatedLength getFx() -{ -} - - -/** - * Corresponds to attribute fy on the given 'radialGradient' element. - */ -SVGAnimatedLength getFy() -{ -} - - -//#################################################################### -//# SVGRectElement -//#################################################################### - -/** - * Corresponds to attribute x on the given 'rect' element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute y on the given 'rect' element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute width on the given 'rect' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'rect' element. - */ -SVGAnimatedLength getHeight() -{ -} - - -/** - * Corresponds to attribute rx on the given 'rect' element. - */ -SVGAnimatedLength getRx() -{ -} - -/** - * Corresponds to attribute ry on the given 'rect' element. - */ -SVGAnimatedLength getRy() -{ -} - - -//#################################################################### -//# SVGScriptElement -//#################################################################### - -/** - * - */ -DOMString getType() -{ -} - -/** - * - */ -void setType(const DOMString &val) throw (DOMException) -{ -} - -//#################################################################### -//# SVGSetElement -//#################################################################### - -//#################################################################### -//# SVGStopElement -//#################################################################### - - -/** - * Corresponds to attribute offset on the given 'stop' element. - */ -SVGAnimatedNumber getOffset() -{ -} - - -//#################################################################### -//# SVGStyleElement -//#################################################################### - -/** - * Get the attribute xml:space on the given element. - */ -DOMString getXmlspace() -{ -} - -/** - * Set the attribute xml:space on the given element. - */ -void setXmlspace(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute type on the given 'style' element. - */ -DOMString getType() -{ -} - -/** - * Set the attribute type on the given 'style' element. - */ -void setType(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute media on the given 'style' element. - */ -DOMString getMedia() -{ -} - -/** - * Set the attribute media on the given 'style' element. - */ -void setMedia(const DOMString &val) throw (DOMException) -{ -} - -/** - * Get the attribute title on the given 'style' element. - */ -DOMString getTitle() -{ -} - -/** - * Set the attribute title on the given 'style' element. - */ -void setTitle(const DOMString &val) throw (DOMException) -{ -} - -//#################################################################### -//# SVGSymbolElement -//#################################################################### - -//#################################################################### -//# SVGSVGElement -//#################################################################### - -/** - * Corresponds to attribute x on the given 'svg' element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute y on the given 'svg' element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute width on the given 'svg' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'svg' element. - */ -SVGAnimatedLength getHeight() -{ -} - -/** - * Get the attribute contentScriptType on the given 'svg' element. - */ -DOMString getContentScriptType() -{ -} - -/** - * Set the attribute contentScriptType on the given 'svg' element. - */ -void setContentScriptType(const DOMString &val) throw (DOMException) -{ -} - - -/** - * Get the attribute contentStyleType on the given 'svg' element. - */ -DOMString getContentStyleType() -{ -} - -/** - * Set the attribute contentStyleType on the given 'svg' element. - */ -void setContentStyleType(const DOMString &val) throw (DOMException) -{ -} - -/** - * The position and size of the viewport(implicit or explicit) that corresponds - * to this 'svg' element. When the user agent is actually rendering the content, - * then the position and size values represent the actual values when rendering. - * The position and size values are unitless values in the coordinate system of - * the parent element. If no parent element exists(i.e., 'svg' element - * represents the root of the document tree), if this SVG document is embedded as - * part of another document(e.g., via the HTML 'object' element), then the - * position and size are unitless values in the coordinate system of the parent - * document.(If the parent uses CSS or XSL layout, then unitless values - * represent pixel units for the current CSS or XSL viewport, as described in the - * CSS2 specification.) If the parent element does not have a coordinate system, - * then the user agent should provide reasonable default values for this attribute. - */ -SVGRect getViewport() -{ -} - -/** - * Size of a pixel units(as defined by CSS2) along the x-axis of the viewport, - * which represents a unit somewhere in the range of 70dpi to 120dpi, and, on - * systems that support this, might actually match the characteristics of the - * target medium. On systems where it is impossible to know the size of a pixel, - * a suitable default pixel size is provided. - */ -double getPixelUnitToMillimeterX() -{ -} - -/** - * Corresponding size of a pixel unit along the y-axis of the viewport. - */ -double getPixelUnitToMillimeterY() -{ -} - -/** - * User interface(UI) events in DOM Level 2 indicate the screen positions at - * which the given UI event occurred. When the user agent actually knows the - * physical size of a "screen unit", this attribute will express that information -{ -} - * otherwise, user agents will provide a suitable default value such as .28mm. - */ -double getScreenPixelToMillimeterX() -{ -} - -/** - * Corresponding size of a screen pixel along the y-axis of the viewport. - */ -double getScreenPixelToMillimeterY() -{ -} - - -/** - * The initial view(i.e., before magnification and panning) of the current - * innermost SVG document fragment can be either the "standard" view(i.e., based - * on attributes on the 'svg' element such as fitBoxToViewport) or to a "custom" - * view(i.e., a hyperlink into a particular 'view' or other element - see - * Linking into SVG content: URI fragments and SVG views). If the initial view is - * the "standard" view, then this attribute is false. If the initial view is a - * "custom" view, then this attribute is true. - */ -bool getUseCurrentView() -{ -} - -/** - * Set the value above - */ -void setUseCurrentView(bool val) throw (DOMException) -{ -} - -/** - * The definition of the initial view(i.e., before magnification and panning) of - * the current innermost SVG document fragment. The meaning depends on the - * situation: - * - * * If the initial view was a "standard" view, then: - * o the values for viewBox, preserveAspectRatio and zoomAndPan within - * currentView will match the values for the corresponding DOM attributes that - * are on SVGSVGElement directly - * o the values for transform and viewTarget within currentView will be null - * * If the initial view was a link into a 'view' element, then: - * o the values for viewBox, preserveAspectRatio and zoomAndPan within - * currentView will correspond to the corresponding attributes for the given - * 'view' element - * o the values for transform and viewTarget within currentView will be null - * * If the initial view was a link into another element(i.e., other than a - * 'view'), then: - * o the values for viewBox, preserveAspectRatio and zoomAndPan within - * currentView will match the values for the corresponding DOM attributes that - * are on SVGSVGElement directly for the closest ancestor 'svg' element - * o the values for transform within currentView will be null - * o the viewTarget within currentView will represent the target of the link - * * If the initial view was a link into the SVG document fragment using an SVG - * view specification fragment identifier(i.e., #svgView(...)), then: - * o the values for viewBox, preserveAspectRatio, zoomAndPan, transform and - * viewTarget within currentView will correspond to the values from the SVG view - * specification fragment identifier - * - */ -SVGViewSpec getCurrentView() -{ -} - - -/** - * This attribute indicates the current scale factor relative to the initial view - * to take into account user magnification and panning operations, as described - * under Magnification and panning. DOM attributes currentScale and - * currentTranslate are equivalent to the 2x3 matrix [a b c d e f] = - * [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]. If - * "magnification" is enabled(i.e., zoomAndPan="magnify"), then the effect is as - * if an extra transformation were placed at the outermost level on the SVG - * document fragment(i.e., outside the outermost 'svg' element). - */ -double getCurrentScale() -{ -} - -/** - * Set the value above. - */ -void setCurrentScale(double val) throw (DOMException) -{ -} - -/** - * The corresponding translation factor that takes into account - * user "magnification". - */ -SVGPoint getCurrentTranslate() -{ -} - -/** - * Takes a time-out value which indicates that redraw shall not occur until:(a) - * the corresponding unsuspendRedraw(suspend_handle_id) call has been made,(b) - * an unsuspendRedrawAll() call has been made, or(c) its timer has timed out. In - * environments that do not support interactivity(e.g., print media), then - * redraw shall not be suspended. suspend_handle_id = - * suspendRedraw(max_wait_milliseconds) and unsuspendRedraw(suspend_handle_id) - * must be packaged as balanced pairs. When you want to suspend redraw actions as - * a collection of SVG DOM changes occur, then precede the changes to the SVG DOM - * with a method call similar to suspend_handle_id = - * suspendRedraw(max_wait_milliseconds) and follow the changes with a method call - * similar to unsuspendRedraw(suspend_handle_id). Note that multiple - * suspendRedraw calls can be used at once and that each such method call is - * treated independently of the other suspendRedraw method calls. - */ -unsigned long suspendRedraw(unsigned long max_wait_milliseconds) -{ -} - -/** - * Cancels a specified suspendRedraw() by providing a unique suspend_handle_id. - */ -void unsuspendRedraw(unsigned long suspend_handle_id) throw (DOMException) -{ -} - -/** - * Cancels all currently active suspendRedraw() method calls. This method is most - * useful at the very end of a set of SVG DOM calls to ensure that all pending - * suspendRedraw() method calls have been cancelled. - */ -void unsuspendRedrawAll() -{ -} - -/** - * In rendering environments supporting interactivity, forces the user agent to - * immediately redraw all regions of the viewport that require updating. - */ -void forceRedraw() -{ -} - -/** - * Suspends(i.e., pauses) all currently running animations that are defined - * within the SVG document fragment corresponding to this 'svg' element, causing - * the animation clock corresponding to this document fragment to stand still - * until it is unpaused. - */ -void pauseAnimations() -{ -} - -/** - * Unsuspends(i.e., unpauses) currently running animations that are defined - * within the SVG document fragment, causing the animation clock to continue from - * the time at which it was suspended. - */ -void unpauseAnimations() -{ -} - -/** - * Returns true if this SVG document fragment is in a paused state. - */ -bool animationsPaused() -{ -} - -/** - * Returns the current time in seconds relative to the start time for - * the current SVG document fragment. - */ -double getCurrentTime() -{ -} - -/** - * Adjusts the clock for this SVG document fragment, establishing - * a new current time. - */ -void setCurrentTime(double seconds) -{ -} - -/** - * Returns the list of graphics elements whose rendered content intersects the - * supplied rectangle, honoring the 'pointer-events' property value on each - * candidate graphics element. - */ -NodeList getIntersectionList(const SVGRect &rect, - const SVGElementPtr referenceElement) -{ -} - -/** - * Returns the list of graphics elements whose rendered content is entirely - * contained within the supplied rectangle, honoring the 'pointer-events' - * property value on each candidate graphics element. - */ -NodeList getEnclosureList(const SVGRect &rect, - const SVGElementPtr referenceElement) -{ -} - -/** - * Returns true if the rendered content of the given element intersects the - * supplied rectangle, honoring the 'pointer-events' property value on each - * candidate graphics element. - */ -bool checkIntersection(const SVGElementPtr element, const SVGRect &rect) -{ -} - -/** - * Returns true if the rendered content of the given element is entirely - * contained within the supplied rectangle, honoring the 'pointer-events' - * property value on each candidate graphics element. - */ -bool checkEnclosure(const SVGElementPtr element, const SVGRect &rect) -{ -} - -/** - * Unselects any selected objects, including any selections of text - * strings and type-in bars. - */ -void deselectAll() -{ -} - -/** - * Creates an SVGNumber object outside of any document trees. The object - * is initialized to a value of zero. - */ -SVGNumber createSVGNumber() -{ -} - -/** - * Creates an SVGLength object outside of any document trees. The object - * is initialized to the value of 0 user units. - */ -SVGLength createSVGLength() -{ -} - -/** - * Creates an SVGAngle object outside of any document trees. The object - * is initialized to the value 0 degrees(unitless). - */ -SVGAngle createSVGAngle() -{ -} - -/** - * Creates an SVGPoint object outside of any document trees. The object - * is initialized to the point(0,0) in the user coordinate system. - */ -SVGPoint createSVGPoint() -{ -} - -/** - * Creates an SVGMatrix object outside of any document trees. The object - * is initialized to the identity matrix. - */ -SVGMatrix createSVGMatrix() -{ -} - -/** - * Creates an SVGRect object outside of any document trees. The object - * is initialized such that all values are set to 0 user units. - */ -SVGRect createSVGRect() -{ -} - -/** - * Creates an SVGTransform object outside of any document trees. - * The object is initialized to an identity matrix transform - * (SVG_TRANSFORM_MATRIX). - */ -SVGTransform createSVGTransform() -{ -} - -/** - * Creates an SVGTransform object outside of any document trees. - * The object is initialized to the given matrix transform - * (i.e., SVG_TRANSFORM_MATRIX). - */ -SVGTransform createSVGTransformFromMatrix(const SVGMatrix &matrix) -{ -} - -/** - * Searches this SVG document fragment(i.e., the search is restricted to a - * subset of the document tree) for an Element whose id is given by elementId. If - * an Element is found, that Element is returned. If no such element exists, - * returns null. Behavior is not defined if more than one element has this id. - */ -ElementPtr getElementById(const DOMString& elementId) -{ -} - - -//#################################################################### -//# SVGTextElement -//#################################################################### - - -//#################################################################### -//# SVGTextContentElement -//#################################################################### - - -/** - * Corresponds to attribute textLength on the given element. - */ -SVGAnimatedLength getTextLength() -{ -} - - -/** - * Corresponds to attribute lengthAdjust on the given element. The value must be - * one of the length adjust constants specified above. - */ -SVGAnimatedEnumeration getLengthAdjust() -{ -} - - -/** - * Returns the total number of characters to be rendered within the current - * element. Includes characters which are included via a 'tref' reference. - */ -long getNumberOfChars() -{ -} - -/** - * The total sum of all of the advance values from rendering all of the - * characters within this element, including the advance value on the glyphs - *(horizontal or vertical), the effect of properties 'kerning', 'letter-spacing' - * and 'word-spacing' and adjustments due to attributes dx and dy on 'tspan' - * elements. For non-rendering environments, the user agent shall make reasonable - * assumptions about glyph metrics. - */ -double getComputedTextLength() -{ -} - -/** - * The total sum of all of the advance values from rendering the specified - * substring of the characters, including the advance value on the glyphs - *(horizontal or vertical), the effect of properties 'kerning', 'letter-spacing' - * and 'word-spacing' and adjustments due to attributes dx and dy on 'tspan' - * elements. For non-rendering environments, the user agent shall make reasonable - * assumptions about glyph metrics. - */ -double getSubStringLength(unsigned long charnum, unsigned long nchars) - throw (DOMException) -{ -} - -/** - * Returns the current text position before rendering the character in the user - * coordinate system for rendering the glyph(s) that correspond to the specified - * character. The current text position has already taken into account the - * effects of any inter-character adjustments due to properties 'kerning', - * 'letter-spacing' and 'word-spacing' and adjustments due to attributes x, y, dx - * and dy. If multiple consecutive characters are rendered inseparably(e.g., as - * a single glyph or a sequence of glyphs), then each of the inseparable - * characters will return the start position for the first glyph. - */ -SVGPoint getStartPositionOfChar(unsigned long charnum) throw (DOMException) -{ -} - -/** - * Returns the current text position after rendering the character in the user - * coordinate system for rendering the glyph(s) that correspond to the specified - * character. This current text position does not take into account the effects - * of any inter-character adjustments to prepare for the next character, such as - * properties 'kerning', 'letter-spacing' and 'word-spacing' and adjustments due - * to attributes x, y, dx and dy. If multiple consecutive characters are rendered - * inseparably(e.g., as a single glyph or a sequence of glyphs), then each of - * the inseparable characters will return the end position for the last glyph. - */ -SVGPoint getEndPositionOfChar(unsigned long charnum) throw (DOMException) -{ -} - -/** - * Returns a tightest rectangle which defines the minimum and maximum X and Y - * values in the user coordinate system for rendering the glyph(s) that - * correspond to the specified character. The calculations assume that all glyphs - * occupy the full standard glyph cell for the font. If multiple consecutive - * characters are rendered inseparably(e.g., as a single glyph or a sequence of - * glyphs), then each of the inseparable characters will return the same extent. - */ -SVGRect getExtentOfChar(unsigned long charnum) throw (DOMException) -{ -} - -/** - * Returns the rotation value relative to the current user coordinate system used - * to render the glyph(s) corresponding to the specified character. If multiple - * glyph(s) are used to render the given character and the glyphs each have - * different rotations(e.g., due to text-on-a-path), the user agent shall return - * an average value(e.g., the rotation angle at the midpoint along the path for - * all glyphs used to render this character). The rotation value represents the - * rotation that is supplemental to any rotation due to properties - * 'glyph-orientation-horizontal' and 'glyph-orientation-vertical'; thus, any - * glyph rotations due to these properties are not included into the returned - * rotation value. If multiple consecutive characters are rendered inseparably - *(e.g., as a single glyph or a sequence of glyphs), then each of the - * inseparable characters will return the same rotation value. - */ -double getRotationOfChar(unsigned long charnum) throw (DOMException) -{ -} - -/** - * Returns the index of the character whose corresponding glyph cell bounding box - * contains the specified point. The calculations assume that all glyphs occupy - * the full standard glyph cell for the font. If no such character exists, a - * value of -1 is returned. If multiple such characters exist, the character - * within the element whose glyphs were rendered last(i.e., take into account - * any reordering such as for bidirectional text) is used. If multiple - * consecutive characters are rendered inseparably(e.g., as a single glyph or a - * sequence of glyphs), then the user agent shall allocate an equal percentage of - * the text advance amount to each of the contributing characters in determining - * which of the characters is chosen. - */ -long getCharNumAtPosition(const SVGPoint &point) -{ -} - -/** - * Causes the specified substring to be selected just as if the user - * selected the substring interactively. - */ -void selectSubString(unsigned long charnum, unsigned long nchars) - throw (DOMException) -{ -} - - - - - -//#################################################################### -//# SVGTextPathElement -//#################################################################### - - -/** - * Corresponds to attribute startOffset on the given 'textPath' element. - */ -SVGAnimatedLength getStartOffset() -{ -} - -/** - * Corresponds to attribute method on the given 'textPath' element. The value - * must be one of the method type constants specified above. - */ -SVGAnimatedEnumeration getMethod() -{ -} - -/** - * Corresponds to attribute spacing on the given 'textPath' element. - * The value must be one of the spacing type constants specified above. - */ -SVGAnimatedEnumeration getSpacing() -{ -} - - -//#################################################################### -//# SVGTextPositioningElement -//#################################################################### - - -/** - * Corresponds to attribute x on the given element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute y on the given element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute dx on the given element. - */ -SVGAnimatedLength getDx() -{ -} - -/** - * Corresponds to attribute dy on the given element. - */ -SVGAnimatedLength getDy() -{ -} - - -/** - * Corresponds to attribute rotate on the given element. - */ -SVGAnimatedNumberList getRotate() -{ -} - - -//#################################################################### -//# SVGTitleElement -//#################################################################### - -//#################################################################### -//# SVGTRefElement -//#################################################################### - -//#################################################################### -//# SVGTSpanElement -//#################################################################### - -//#################################################################### -//# SVGSwitchElement -//#################################################################### - -//#################################################################### -//# SVGUseElement -//#################################################################### - -/** - * Corresponds to attribute x on the given 'use' element. - */ -SVGAnimatedLength getX() -{ -} - -/** - * Corresponds to attribute y on the given 'use' element. - */ -SVGAnimatedLength getY() -{ -} - -/** - * Corresponds to attribute width on the given 'use' element. - */ -SVGAnimatedLength getWidth() -{ -} - -/** - * Corresponds to attribute height on the given 'use' element. - */ -SVGAnimatedLength getHeight() -{ -} - -/** - * The root of the "instance tree". See description of SVGElementInstance for - * a discussion on the instance tree. - * */ -SVGElementInstance getInstanceRoot() -{ -} - -/** - * If the 'href' attribute is being animated, contains the current animated root - * of the "instance tree". If the 'href' attribute is not currently being - * animated, contains the same value as 'instanceRoot'. The root of the "instance - * tree". See description of SVGElementInstance for a discussion on the instance - * tree. - */ -SVGElementInstance getAnimatedInstanceRoot() -{ -} - - -//#################################################################### -//# SVGVKernElement -//#################################################################### - -//#################################################################### -//# SVGViewElement -//#################################################################### - - -/** - * - */ -SVGStringList getViewTarget(); - - - - -//################## -//# Non-API methods -//################## - - -/** - * - */ -SVGElement::~SVGElement() -{ -} - - - - -/*######################################################################### -## SVGDocument -#########################################################################*/ - - -/** - * The title of a document as specified by the title sub-element of the 'svg' - * root element(i.e., <svg><title>Here is the title...) - */ -DOMString SVGDocument::getTitle() -{ -} - -/** - * Returns the URI of the page that linked to this page. The value is an empty - * string if the user navigated to the page directly(not through a link, but, - * for example, via a bookmark). - */ -DOMString SVGDocument::getReferrer() -{ -} - - -/** - * The domain name of the server that served the document, or a null string if - * the server cannot be identified by a domain name. - */ -DOMString SVGDocument::getDomain() -{ -} - - -/** - * The complete URI of the document. - */ -DOMString SVGDocument::getURL() -{ -} - - -/** - * The root 'svg' element in the document hierarchy. - */ -SVGElementPtr SVGDocument::getRootElement() -{ -} - - -/** - * Overloaded from Document - * - */ -ElementPtr SVGDocument::createElement(const DOMString &tagName) -{ - ElementPtr ptr; - return ptr; -} - - -/** - * Overloaded from Document - * - */ -ElementPtr SVGDocument::createElementNS(const DOMString &tagName, - const DOMString &namespaceURI) -{ - ElementPtr ptr; - return ptr; -} - - -/** - * The root 'svg' element in the document hierarchy. - */ -SVGElementPtr SVGDocument::getRootElement() -{ -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -SVGDocument::~SVGDocument() -{ -} - - - -/*######################################################################### -## GetSVGDocument -#########################################################################*/ - - -/** - * Returns the SVGDocument object for the referenced SVG document. - */ -SVGDocumentPtr GetSVGDocument::getSVGDocument() - throw (DOMException) -{ - SVGDocumentPtr ptr; - return ptr; -} - -//################## -//# Non-API methods -//################## - -/** - * - */ -GetSVGDocument::~GetSVGDocument() -{ -} - - - - - - - -} //namespace svg -} //namespace dom -} //namespace w3c -} //namespace org - -#endif // __SVG_H__ -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/work/testdom.cpp b/src/dom/work/testdom.cpp deleted file mode 100644 index 41a831aaa..000000000 --- a/src/dom/work/testdom.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -#include "lsimpl.h" - -using namespace org::w3c::dom; - - -bool doTest(char *filename) -{ - - ls::DOMImplementationLSImpl domImpl; - ls::LSInput input = domImpl.createLSInput(); - ls::LSParser &parser = domImpl.createLSParser(0, ""); - - DOMString buf; - FILE *f = fopen(filename, "rb"); - if (!f) - { - printf("Cannot open %s for reading\n", filename); - return false; - } - while (!feof(f)) - { - int ch = fgetc(f); - buf.push_back(ch); - } - fclose(f); - input.setStringData(buf); - - printf("######## PARSE ######################################\n"); - DocumentPtr doc = parser.parse(input); - - if (!doc) - { - printf("parsing failed\n"); - return 0; - } - - //### OUTPUT - printf("######## SERIALIZE ##################################\n"); - ls::LSSerializer &serializer = domImpl.createLSSerializer(); - ls::LSOutput output = domImpl.createLSOutput(); - io::StdWriter writer; - output.setCharacterStream(&writer); - serializer.write(doc, output); - - printf("####### Namespace check\n"); - DOMString svgNamespace = "http://www.w3.org/2000/svg"; - NodeList list = doc->getElementsByTagNameNS(svgNamespace, "svg"); - int nodeCount = list.getLength(); - printf("Nodes:%d\n", nodeCount); - for (int i=0; igetElementsByTagNameNS(svgNamespace, "svg"); - int nodeCount = list.getLength(); - printf("Nodes:%d\n", nodeCount); - for (int i=0; i - - -typedef org::w3c::dom::Node Node; -typedef org::w3c::dom::NodePtr NodePtr; -typedef org::w3c::dom::NodeList NodeList; -typedef org::w3c::dom::DOMString DOMString; -typedef org::w3c::dom::Document Document; -typedef org::w3c::dom::DocumentPtr DocumentPtr; -typedef org::w3c::dom::io::StdWriter StdWriter; -typedef org::w3c::dom::ls::DOMImplementationLSImpl DOMImplementationLSImpl; -typedef org::w3c::dom::ls::LSSerializer LSSerializer; -typedef org::w3c::dom::ls::LSOutput LSOutput; -typedef org::w3c::dom::ls::LSInput LSInput; -typedef org::w3c::dom::ls::LSParser LSParser; -typedef org::w3c::dom::xpath::XPathParser XPathParser; - - - -typedef struct -{ - const char *xpathStr; - const char *desc; - const char *xml; -} XpathTest; - -XpathTest xpathTests[] = -{ - -{ -"/AAA", -"Select the root element AAA", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/CCC", -"Select all elements CCC which are children of the root element AAA", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/DDD/BBB", -"Select all elements BBB which are children of DDD which are children of the root element AAA", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB", -"Select all elements BBB", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//DDD/BBB", -"Select all elements BBB which are children of DDD", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/CCC/DDD/*", -"Select all elements enclosed by elements /AAA/CCC/DDD", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/*/*/*/BBB", -"Select all elements BBB which have 3 ancestors", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*", -"Select all elements", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/BBB[1]", -"Select the first BBB child of element AAA", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/BBB[last()]", -"Select the last BBB child of element AAA", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//@id", -"Select all attributes @id", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[@id]", -"Select BBB elements which have attribute id", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[@name]", -"Select BBB elements which have attribute name", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[@*]", -"Select BBB elements which have any attribute", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[not(@*)]", -"Select BBB elements without an attribute", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[@id='b1']", -"Select BBB elements which have attribute id with value b1", -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[@name='bbb']", -"Select BBB elements which have attribute name with value 'bbb'", -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[normalize-space(@name)='bbb']", -"Select BBB elements which have attribute name with value bbb, leading and trailing spaces are removed before comparison", -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[count(BBB)=2]", -"Select elements which have two children BBB", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[count(*)=2]", -"Select elements which have 2 children", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[count(*)=3]", -"Select elements which have 3 children", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[name()='BBB']", -"Select all elements with name BBB, equivalent with //BBB", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[starts-with(name(),'B')]", -"Select all elements name of which starts with letter B", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[contains(name(),'C')]", -"Select all elements name of which contain letter C", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[string-length(name()) = 3]", -"Select elements with three-letter name", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[string-length(name()) < 3]", -"Select elements name of which has one or two characters", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//*[string-length(name()) > 3]", -"Select elements with name longer than three characters", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC | //BBB", -"Select all elements CCC and BBB", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/EEE | //BBB", -"Select all elements BBB and elements EEE which are children of root element AAA", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/EEE | //DDD/CCC | /AAA | //BBB", -"Number of combinations is not restricted", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA", -"Equivalent of /child::AAA", -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/child::AAA", -"Equivalent of /AAA", -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/BBB", -"Equivalent of /child::AAA/child::BBB", -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/child::AAA/child::BBB", -"Equivalent of /AAA/BBB", -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/child::AAA/BBB", -"Both possibilities can be combined", -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/descendant::*", -"Select all descendants of document root and therefore all elements", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/BBB/descendant::*", -"Select all descendants of /AAA/BBB", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC/descendant::*", -"Select all elements which have CCC among its ancestors", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC/descendant::DDD", -"Select elements DDD which have CCC among its ancestors", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//DDD/parent::*", -"Select all parents of DDD element", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/BBB/DDD/CCC/EEE/ancestor::*", -"Select all elements given in this absolute path", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//FFF/ancestor::*", -"Select ancestors of FFF element", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/BBB/following-sibling::*", -"The following-sibling axis contains all the following siblings of the context node.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC/following-sibling::*", -"The following-sibling axis contains all the following siblings of the context node.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/XXX/preceding-sibling::*", -"The preceding-sibling axis contains all the preceding siblings of the context node.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC/preceding-sibling::*", -"The preceding-sibling axis contains all the preceding siblings of the context node", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/XXX/following::*", -"The following axis contains all nodes in the same document as the context " -"node that are after the context node in document order, " -"excluding any descendants and excluding attribute nodes and namespace nodes.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//ZZZ/following::*", -"The following axis contains all nodes in the same document as the context " -"node that are after the context node in document order, " -"excluding any descendants and excluding attribute nodes and namespace nodes.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/XXX/preceding::*", -"The preceding axis contains all nodes in the same document as the " -"context node that are before the context node in document order, " -"excluding any ancestors and excluding attribute nodes and namespace nodes", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/preceding::*", -"The preceding axis contains all nodes in the same document as the " -"context node that are before the context node in document order, " -"excluding any ancestors and excluding attribute nodes and namespace nodes", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/XXX/descendant-or-self::*", -"The descendant-or-self axis contains the " -"context node and the descendants of the context node", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC/descendant-or-self::*", -"The descendant-or-self axis contains the " -"context node and the descendants of the context node", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"/AAA/XXX/DDD/EEE/ancestor-or-self::*", -"The ancestor-or-self axis contains the context node and the " -"ancestors of the context node; thus, the ancestor-or-self axis " -"will always include the root node.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/ancestor-or-self::*", -"The ancestor-or-self axis contains the context node and the " -"ancestors of the context node; thus, the ancestor-or-self axis " -"will always include the root node.", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/ancestor::*", -"The ancestor, descendant, following, preceding and self axes partition a document", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/descendant::*", -"The ancestor, descendant, following, preceding and self axes partition a document", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/following::*", -"The ancestor, descendant, following, preceding and self axes partition a document", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/preceding::*", -"The ancestor, descendant, following, preceding and self axes partition a document", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/self::*", -"The ancestor, descendant, following, preceding and self axes partition a document", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//GGG/ancestor::* | //GGG/descendant::* | //GGG/following::* | //GGG/preceding::* | //GGG/self::*", -"The ancestor, descendant, following, preceding and self axes partition a document", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[position() mod 2 = 0 ]", -"Select even BBB elements", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//BBB[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]", -"Select middle BBB element(s)", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ -"//CCC[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]", -"Select middle CCC element(s)", -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -}, - -{ //end data -NULL, -NULL, -NULL, -} - -}; - - - -bool doStringTest(const char *str) -{ - XPathParser xp; - xp.setDebug(true); - - if (!xp.parse(str)) - return false; - - - return true; -} - - - -bool doStringTests() -{ - for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++) - { - if (!doStringTest(xpt->xpathStr)) - return false; - } - return true; -} - -bool dumpDoc(DocumentPtr doc) -{ - DOMImplementationLSImpl domImpl; - LSSerializer &serializer = domImpl.createLSSerializer(); - LSOutput output = domImpl.createLSOutput(); - StdWriter writer; - output.setCharacterStream(&writer); - serializer.write(doc, output); - - return true; -} - - -bool doXmlTest(XpathTest *xpt) -{ - printf("################################################################\n"); - - //### READ - DOMImplementationLSImpl domImpl; - LSInput input = domImpl.createLSInput(); - LSParser &parser = domImpl.createLSParser(0, ""); - input.setStringData(xpt->xml); - DocumentPtr doc = parser.parse(input); - - //### XPATH - XPathParser xp; - xp.setDebug(true); - - DOMString xpathStr = xpt->xpathStr; - NodeList list = xp.evaluate(doc, xpathStr); - for (unsigned int i=0 ; igetNodeName().c_str()); - } - - //dumpDoc(doc); - - return true; -} - -bool doXmlTests() -{ - for (XpathTest *xpt = xpathTests ; xpt->xpathStr ; xpt++) - { - if (!doXmlTest(xpt)) - return false; - } - return true; -} - -bool doTests() -{ - /* - if (!doStringTests()) - { - printf("## Failed string tests\n"); - return false; - } - */ - if (!doXmlTests()) - { - printf("## Failed xml tests\n"); - return false; - } - return true; -} - - - -int main(int argc, char **argv) -{ - doTests(); - return 0; -} diff --git a/src/dom/work/testzip.cpp b/src/dom/work/testzip.cpp deleted file mode 100644 index 9281d37ce..000000000 --- a/src/dom/work/testzip.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - - -#include "io/uristream.h" -#include "util/ziptool.h" - - - -bool doTest() -{ - org::w3c::dom::io::UriInputStream ins("file:work/test.odg"); - - std::vectorinbuf; - - while (true) - { - int ch = ins.get(); - if (ch < 0) - break; - inbuf.push_back(ch); - } - ZipFile zf; - if (!zf.readBuffer(inbuf)) - { - return false; - } - return true; -} - - -int main(int argc, char **argv) -{ - doTest(); -} - - diff --git a/src/dom/work/traversal.idl b/src/dom/work/traversal.idl deleted file mode 100644 index 660f4577d..000000000 --- a/src/dom/work/traversal.idl +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -// File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/traversal.idl - -#ifndef _TRAVERSAL_IDL_ -#define _TRAVERSAL_IDL_ - -#include "dom.idl" - -#pragma prefix "dom.w3c.org" -module traversal -{ - - typedef dom::Node Node; - - interface NodeFilter; - - // Introduced in DOM Level 2: - interface NodeIterator { - readonly attribute Node root; - readonly attribute unsigned long whatToShow; - readonly attribute NodeFilter filter; - readonly attribute boolean expandEntityReferences; - Node nextNode() - raises(dom::DOMException); - Node previousNode() - raises(dom::DOMException); - void detach(); - }; - - // Introduced in DOM Level 2: - interface NodeFilter { - - // Constants returned by acceptNode - const short FILTER_ACCEPT = 1; - const short FILTER_REJECT = 2; - const short FILTER_SKIP = 3; - - - // Constants for whatToShow - const unsigned long SHOW_ALL = 0xFFFFFFFF; - const unsigned long SHOW_ELEMENT = 0x00000001; - const unsigned long SHOW_ATTRIBUTE = 0x00000002; - const unsigned long SHOW_TEXT = 0x00000004; - const unsigned long SHOW_CDATA_SECTION = 0x00000008; - const unsigned long SHOW_ENTITY_REFERENCE = 0x00000010; - const unsigned long SHOW_ENTITY = 0x00000020; - const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x00000040; - const unsigned long SHOW_COMMENT = 0x00000080; - const unsigned long SHOW_DOCUMENT = 0x00000100; - const unsigned long SHOW_DOCUMENT_TYPE = 0x00000200; - const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400; - const unsigned long SHOW_NOTATION = 0x00000800; - - short acceptNode(in Node n); - }; - - // Introduced in DOM Level 2: - interface TreeWalker { - readonly attribute Node root; - readonly attribute unsigned long whatToShow; - readonly attribute NodeFilter filter; - readonly attribute boolean expandEntityReferences; - attribute Node currentNode; - // raises(dom::DOMException) on setting - - Node parentNode(); - Node firstChild(); - Node lastChild(); - Node previousSibling(); - Node nextSibling(); - Node previousNode(); - Node nextNode(); - }; - - // Introduced in DOM Level 2: - interface DocumentTraversal { - NodeIterator createNodeIterator(in Node root, - in unsigned long whatToShow, - in NodeFilter filter, - in boolean entityReferenceExpansion) - raises(dom::DOMException); - TreeWalker createTreeWalker(in Node root, - in unsigned long whatToShow, - in NodeFilter filter, - in boolean entityReferenceExpansion) - raises(dom::DOMException); - }; -}; - -#endif // _TRAVERSAL_IDL_ - diff --git a/src/dom/work/views.idl b/src/dom/work/views.idl deleted file mode 100644 index 7ae0c50a7..000000000 --- a/src/dom/work/views.idl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. - */ - -// File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Views-20001113/views.idl - -#ifndef _VIEWS_IDL_ -#define _VIEWS_IDL_ - -#include "dom.idl" - -#pragma prefix "dom.w3c.org" -module views -{ - - interface DocumentView; - - // Introduced in DOM Level 2: - interface AbstractView { - readonly attribute DocumentView document; - }; - - // Introduced in DOM Level 2: - interface DocumentView { - readonly attribute AbstractView defaultView; - }; -}; - -#endif // _VIEWS_IDL_ - diff --git a/src/dom/work/xpath.idl b/src/dom/work/xpath.idl deleted file mode 100644 index 066f064b0..000000000 --- a/src/dom/work/xpath.idl +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004 World Wide Web Consortium, - * - * (Massachusetts Institute of Technology, European Research Consortium for - * Informatics and Mathematics, Keio University). All Rights Reserved. This - * work is distributed under the W3C(r) Software License [1] in the hope that - * it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 - */ - -// File: http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/xpath.idl - -#ifndef _XPATH_IDL_ -#define _XPATH_IDL_ - -#include "dom.idl" - -#pragma prefix "dom.w3c.org" -module xpath -{ - - typedef dom::DOMString DOMString; - typedef dom::Node Node; - typedef dom::DOMObject DOMObject; - typedef dom::Element Element; - - interface XPathNSResolver; - interface XPathExpression; - - exception XPathException { - unsigned short code; - }; - // XPathExceptionCode - const unsigned short INVALID_EXPRESSION_ERR = 51; - const unsigned short TYPE_ERR = 52; - - - interface XPathEvaluator { - XPathExpression createExpression(in DOMString expression, - in XPathNSResolver resolver) - raises(XPathException, - dom::DOMException); - XPathNSResolver createNSResolver(in Node nodeResolver); - DOMObject evaluate(in DOMString expression, - in Node contextNode, - in XPathNSResolver resolver, - in unsigned short type, - in DOMObject result) - raises(XPathException, - dom::DOMException); - }; - - interface XPathExpression { - DOMObject evaluate(in Node contextNode, - in unsigned short type, - in DOMObject result) - raises(XPathException, - dom::DOMException); - }; - - interface XPathNSResolver { - DOMString lookupNamespaceURI(in DOMString prefix); - }; - - interface XPathResult { - - // XPathResultType - const unsigned short ANY_TYPE = 0; - const unsigned short NUMBER_TYPE = 1; - const unsigned short STRING_TYPE = 2; - const unsigned short BOOLEAN_TYPE = 3; - const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4; - const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5; - const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6; - const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7; - const unsigned short ANY_UNORDERED_NODE_TYPE = 8; - const unsigned short FIRST_ORDERED_NODE_TYPE = 9; - - readonly attribute unsigned short resultType; - readonly attribute double numberValue; - // raises(XPathException) on retrieval - - readonly attribute DOMString stringValue; - // raises(XPathException) on retrieval - - readonly attribute boolean booleanValue; - // raises(XPathException) on retrieval - - readonly attribute Node singleNodeValue; - // raises(XPathException) on retrieval - - readonly attribute boolean invalidIteratorState; - readonly attribute unsigned long snapshotLength; - // raises(XPathException) on retrieval - - Node iterateNext() - raises(XPathException, - dom::DOMException); - Node snapshotItem(in unsigned long index) - raises(XPathException); - }; - - interface XPathNamespace : Node { - - // XPathNodeType - const unsigned short XPATH_NAMESPACE_NODE = 13; - - readonly attribute Element ownerElement; - }; -}; - -#endif // _XPATH_IDL_ - diff --git a/src/dom/work/xpathtests.cpp b/src/dom/work/xpathtests.cpp deleted file mode 100644 index f34c62c80..000000000 --- a/src/dom/work/xpathtests.cpp +++ /dev/null @@ -1,1290 +0,0 @@ -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -typedef struct -{ - char *xpathStr; - char *desc; - char *xml; -} XpathTest; - -XpathTest xpathTests[] = -{ - -{ -"/AAA", -"Select the root element AAA", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/CCC", -"Select all elements CCC which are children of the root element AAA", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/DDD/BBB", -"Select all elements BBB which are children of DDD which are children of the root element AAA", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -"//BBB", -}, - -{ -"Select all elements BBB", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//DDD/BBB", -"Select all elements BBB which are children of DDD", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/CCC/DDD/*", -"Select all elements enclosed by elements /AAA/CCC/DDD", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/*/*/*/BBB", -"Select all elements BBB which have 3 ancestors", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*", -"Select all elements", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/BBB[1]", -"Select the first BBB child of element AAA", -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/BBB[last()]", -"Select the last BBB child of element AAA", -" " -" " -" " -" " -" " -" " -}, - -{ -"//@id", -"Select all attributes @id", -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[@id]", -"Select BBB elements which have attribute id", -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[@name]", -"Select BBB elements which have attribute name", -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[@*]", -"Select BBB elements which have any attribute", -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[not(@*)]", -"Select BBB elements without an attribute", -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[@id='b1']", -"Select BBB elements which have attribute id with value b1", -" " -" " -" " -" " -" " -}, - -{ -"//BBB[@name='bbb']", -"Select BBB elements which have attribute name with value 'bbb'", -" " -" " -" " -" " -" " -}, - -{ -"//BBB[normalize-space(@name)='bbb']", -"Select BBB elements which have attribute name with value bbb, leading and trailing spaces are removed before comparison", -" " -" " -" " -" " -" " -}, - -{ -"//*[count(BBB)=2]", -"Select elements which have two children BBB", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[count(*)=2]", -"Select elements which have 2 children", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[count(*)=3]", -"Select elements which have 3 children", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[name()='BBB']", -"Select all elements with name BBB, equivalent with //BBB", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[starts-with(name(),'B')]", -"Select all elements name of which starts with letter B", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[contains(name(),'C')]", -"Select all elements name of which contain letter C", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[string-length(name()) = 3]", -"Select elements with three-letter name", -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[string-length(name()) < 3]", -"Select elements name of which has one or two characters", -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//*[string-length(name()) > 3]", -"Select elements with name longer than three characters", -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC | //BBB", -"Select all elements CCC and BBB", -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/EEE | //BBB", -"Select all elements BBB and elements EEE which are children of root element AAA", -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/EEE | //DDD/CCC | /AAA | //BBB", -"Number of combinations is not restricted", -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA", -"Equivalent of /child::AAA", -" " -" " -" " -" " -}, - -{ -"/child::AAA", -"Equivalent of /AAA", -" " -" " -" " -" " -}, - -{ -"/AAA/BBB", -"Equivalent of /child::AAA/child::BBB", -" " -" " -" " -" " -}, - -{ -"/child::AAA/child::BBB", -"Equivalent of /AAA/BBB", -" " -" " -" " -" " -}, - -{ -"/child::AAA/BBB", -"Both possibilities can be combined", -" " -" " -" " -" " -}, - -{ -"/descendant::*", -"Select all descendants of document root and therefore all elements", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/BBB/descendant::*", -"Select all descendants of /AAA/BBB", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC/descendant::*", -"Select all elements which have CCC among its ancestors", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC/descendant::DDD", -"Select elements DDD which have CCC among its ancestors", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//DDD/parent::*", -"Select all parents of DDD element", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/BBB/DDD/CCC/EEE/ancestor::*", -"Select all elements given in this absolute path", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//FFF/ancestor::*", -"Select ancestors of FFF element", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/BBB/following-sibling::*", -"The following-sibling axis contains all the following siblings of the context node.", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC/following-sibling::*", -"The following-sibling axis contains all the following siblings of the context node.", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/XXX/preceding-sibling::*", -"The preceding-sibling axis contains all the preceding siblings of the context node.", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC/preceding-sibling::*", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/XXX/following::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//ZZZ/following::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/XXX/preceding::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/preceding::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/XXX/descendant-or-self::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC/descendant-or-self::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"/AAA/XXX/DDD/EEE/ancestor-or-self::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/ancestor-or-self::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/ancestor::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/descendant::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/following::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/preceding::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/self::*", -"Description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//GGG/ancestor::* | //GGG/descendant::* | //GGG/following::* | //GGG/preceding::* | //GGG/self::*", -"description", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[position() mod 2 = 0 ]", -"Select even BBB elements", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//BBB[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]", -"Select middle BBB element(s)", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -}, - -{ -"//CCC[ position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ]", -"Select middle CCC element(s)", -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -} - -}; //end - - -- cgit v1.2.3 From 1079b1b4c0331e5d4bd62f3c93349aec50f520f0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 23 Jun 2011 18:38:51 +0200 Subject: Update 2Geom to pull in integer rectangle class (bzr r10347.1.1) --- src/2geom/Makefile_insert | 1 + src/2geom/affine.cpp | 14 +- src/2geom/affine.h | 15 +- src/2geom/angle.h | 21 +- src/2geom/basic-intersection.h | 2 +- src/2geom/bezier-curve.cpp | 85 +++- src/2geom/bezier-curve.h | 117 +++--- src/2geom/bezier-to-sbasis.h | 6 +- src/2geom/bezier-utils.cpp | 11 +- src/2geom/bezier-utils.h | 18 +- src/2geom/bezier.h | 27 +- src/2geom/choose.h | 21 +- src/2geom/circle.h | 21 +- src/2geom/circulator.h | 9 +- src/2geom/concepts.h | 20 +- src/2geom/conic_section_clipper_impl.cpp | 23 +- src/2geom/conicsec.cpp | 5 +- src/2geom/conjugate_gradient.h | 6 +- src/2geom/convex-cover.h | 14 +- src/2geom/coord.h | 39 +- src/2geom/crossing.h | 10 +- src/2geom/curve.cpp | 5 +- src/2geom/curves.h | 7 +- src/2geom/d2-sbasis.h | 7 +- src/2geom/d2.h | 3 +- src/2geom/forward.h | 19 +- src/2geom/generic-interval.h | 342 ++++++++++++++++ src/2geom/generic-rect.h | 363 +++++++++++++++++ src/2geom/hvlinesegment.h | 30 +- src/2geom/int-interval.h | 63 +++ src/2geom/int-point.h | 157 ++++++++ src/2geom/int-rect.h | 74 ++++ src/2geom/interval.h | 280 ++----------- src/2geom/isnan.h | 116 ------ src/2geom/line.h | 31 +- src/2geom/linear.h | 2 +- src/2geom/math-utils.h | 49 ++- src/2geom/ord.h | 4 +- src/2geom/path-intersection.h | 4 +- src/2geom/path.h | 33 +- src/2geom/pathvector.h | 13 +- src/2geom/piecewise.h | 8 +- src/2geom/point.cpp | 48 ++- src/2geom/point.h | 94 +++-- src/2geom/poly.h | 5 +- src/2geom/quadtree.h | 4 +- src/2geom/ray.h | 241 ++++------- src/2geom/rect.cpp | 98 +++++ src/2geom/rect.h | 306 +++----------- src/2geom/region.h | 4 +- src/2geom/sbasis-2d.h | 4 +- src/2geom/sbasis-curve.h | 45 ++- src/2geom/sbasis-to-bezier.h | 4 +- src/2geom/sbasis.cpp | 2 +- src/2geom/sbasis.h | 2 +- src/2geom/sturm.h | 70 ---- src/2geom/svg-elliptical-arc.h | 14 +- src/2geom/sweep.h | 4 +- src/2geom/toposweep.cpp | 663 +++++++++++++++++++++++++++++++ src/2geom/toposweep.h | 222 +++++++++++ src/2geom/transforms.cpp | 4 +- src/2geom/transforms.h | 15 +- src/2geom/utils.h | 12 +- src/connector-context.cpp | 22 +- src/display/nr-arena-image.cpp | 2 +- src/display/nr-filter-composite.cpp | 1 - src/display/nr-filter-gaussian.cpp | 2 - src/dyna-draw-context.cpp | 2 +- src/eraser-context.cpp | 2 +- src/helper/recthull.h | 2 +- src/libcola/cola.cpp | 2 +- src/libcola/gradient_projection.cpp | 2 +- src/libnr/nr-point-fns.cpp | 2 +- src/libnr/nr-types.cpp | 3 +- src/libvpsc/generate-constraints.cpp | 2 +- src/live_effects/lpe-spiro.cpp | 1 - src/object-edit.cpp | 2 +- src/selection-chemistry.cpp | 2 +- src/selection.cpp | 2 +- src/sp-item.cpp | 2 +- src/spray-context.cpp | 1 - src/style.cpp | 1 - src/tweak-context.cpp | 1 - src/widgets/desktop-widget.cpp | 4 +- 84 files changed, 2751 insertions(+), 1265 deletions(-) create mode 100644 src/2geom/generic-interval.h create mode 100644 src/2geom/generic-rect.h create mode 100644 src/2geom/int-interval.h create mode 100644 src/2geom/int-point.h create mode 100644 src/2geom/int-rect.h delete mode 100644 src/2geom/isnan.h create mode 100644 src/2geom/rect.cpp delete mode 100644 src/2geom/sturm.h create mode 100644 src/2geom/toposweep.cpp create mode 100644 src/2geom/toposweep.h (limited to 'src') diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index 4f7c3b6ef..a668a2b3b 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -78,6 +78,7 @@ 2geom/quadtree.h \ 2geom/ray.h \ 2geom/rect.h \ + 2geom/rect.cpp \ 2geom/region.cpp \ 2geom/region.h \ 2geom/sbasis-2d.cpp \ diff --git a/src/2geom/affine.cpp b/src/2geom/affine.cpp index 925f43820..2a1f18d77 100644 --- a/src/2geom/affine.cpp +++ b/src/2geom/affine.cpp @@ -1,9 +1,3 @@ -#define __Geom_MATRIX_C__ - -/** \file - * Various matrix routines. Currently includes some Geom::Rotate etc. routines too. - */ - /* * Authors: * Lauris Kaplinski @@ -387,10 +381,10 @@ Coord Affine::descrim2() const { } /** @brief Calculate the descriminant. - * If the matrix doesn't contain a non-uniform scaling or shearing component, this value says - * how will the length any line segment change after applying this transformation - * to arbitrary objects on a plane (the new length will be - * @code line_seg.length() * m.descrim()) @endcode. + * If the matrix doesn't contain a shearing or non-uniform scaling component, this value says + * how will the length of any line segment change after applying this transformation + * to arbitrary objects on a plane. The new length will be + * @code line_seg.length() * m.descrim()) @endcode * @return \f$\sqrt{|\det A|}\f$. */ Coord Affine::descrim() const { return sqrt(descrim2()); diff --git a/src/2geom/affine.h b/src/2geom/affine.h index 277d8b4ee..b07fba0f7 100644 --- a/src/2geom/affine.h +++ b/src/2geom/affine.h @@ -1,7 +1,8 @@ -/** \file - * \brief 3x3 affine transformation matrix. +/** + * \file + * \brief 3x3 affine transformation matrix. *//* - * Main authors: + * Authors: * Lauris Kaplinski (Original NRAffine definition and related macros) * Nathan Hurst (Geom::Affine class version of the above) * Michael G. Sloan (reorganization and additions) @@ -10,8 +11,8 @@ * This code is in public domain. */ -#ifndef SEEN_LIB2GEOM_MATRIX_H -#define SEEN_LIB2GEOM_MATRIX_H +#ifndef SEEN_LIB2GEOM_AFFINE_H +#define SEEN_LIB2GEOM_AFFINE_H #include #include <2geom/forward.h> @@ -236,9 +237,9 @@ inline Affine Affine::identity() { return ret; // allow NRVO } -} /* namespace Geom */ +} // end namespace Geom -#endif /* !__Geom_MATRIX_H__ */ +#endif // LIB2GEOM_SEEN_AFFINE_H /* Local Variables: diff --git a/src/2geom/angle.h b/src/2geom/angle.h index 42e3531f3..bdf546989 100644 --- a/src/2geom/angle.h +++ b/src/2geom/angle.h @@ -107,11 +107,18 @@ public: if (ret < 0) ret += 360; return ret; } - + /** @brief Create an angle from its measure in radians. */ + static Angle from_radians(Coord d) { + Angle a(d); + return a; + } + /** @brief Create an angle from its measure in degrees. */ static Angle from_degrees(Coord d) { Angle a(d * M_PI / 180); return a; } + /** @brief Create an angle from its measure in degrees in clock convention. + * @see Angle::degreesClock() */ static Angle from_degrees_clock(Coord d) { // first make sure d is in [0, 360) d = std::fmod(d, 360.0); @@ -208,9 +215,12 @@ protected: bool _sweep; }; -inline double deg_to_rad(double deg) { return deg*M_PI/180.0;} - -inline double rad_to_deg(double rad) { return rad*180.0/M_PI;} +/** @brief Given an angle in degrees, return radians + * @relates Angle */ +inline Coord deg_to_rad(Coord deg) { return deg*M_PI/180.0;} +/** @brief Given an angle in radians, return degrees + * @relates Angle */ +inline Coord rad_to_deg(Coord rad) { return rad*180.0/M_PI;} /* * start_angle and angle must belong to [0, 2PI[ @@ -294,8 +304,7 @@ bool arc_contains (double a, double sa, double ia, double ea) } // end namespace Geom -#endif - +#endif // LIB2GEOM_SEEN_ANGLE_H /* Local Variables: diff --git a/src/2geom/basic-intersection.h b/src/2geom/basic-intersection.h index b07052449..5a813ae99 100644 --- a/src/2geom/basic-intersection.h +++ b/src/2geom/basic-intersection.h @@ -1,6 +1,6 @@ /** * \file - * \brief \todo brief description + * \brief Basic intersection routines * * Authors: * ? diff --git a/src/2geom/bezier-curve.cpp b/src/2geom/bezier-curve.cpp index bde0e3ef1..46aff8b49 100644 --- a/src/2geom/bezier-curve.cpp +++ b/src/2geom/bezier-curve.cpp @@ -1,8 +1,5 @@ -/** - * \file - * \brief Bezier curve +/* Bezier curve implementation * - *//* * Authors: * MenTaLguY * Marco Cecchetti @@ -41,7 +38,7 @@ namespace Geom /** * @class BezierCurve - * @brief Two-dimensional Bezier curve of arbitrary order. (this is an abstract class) + * @brief Two-dimensional Bezier curve of arbitrary order. * * Bezier curves are an expansion of the concept of linear interpolation to n points. * Linear segments in 2Geom are in fact Bezier curves of order 1. @@ -82,28 +79,40 @@ namespace Geom * have an intutive geometric interpretation. Because of this, they are frequently used * in vector graphics editors. * - * Every bezier curve is contained in its control polygon (the convex polygon composed + * Every Bezier curve is contained in its control polygon (the convex polygon composed * of its control points). This fact is useful for sweepline algorithms and intersection. * - * Bezier curves of order 1, 2 and 3 are common enough to have their own more specific subclasses: - * LineSegment, QuadraticBezier, and CubicBezier. - * Note that you cannot create a generic BezierCurve, you can only create a BezierCurve of a - * specific order, by creating a BezierCurveN. + * @par Implementation notes + * The order of a Bezier curve is immuable once it has been created. Normally, you should + * know the order at compile time and use the BezierCurveN template. If you need to determine + * the order at runtime, use the BezierCurve::create() function. It will create a BezierCurveN + * for orders 1, 2 and 3 (up to cubic Beziers), so you can later dynamic_cast + * to those types, and for higher orders it will create an instance of BezierCurve. * * @relates BezierCurveN * @ingroup Curves */ - /** +/** * @class BezierCurveN + * @brief Bezier curve with compile-time specified order. + * * @tparam degree unsigned value indicating the order of the bezier curve - * @brief Two-dimensional Bezier curve of specific order. * * @relates BezierCurve * @ingroup Curves */ - + +BezierCurve::BezierCurve(std::vector const &pts) +{ + inner = D2(Bezier::Order(pts.size()-1), Bezier::Order(pts.size()-1)); + for (unsigned d = 0; d < 2; ++d) { + for(unsigned i = 0; i <= pts.size(); i++) + inner[d][i] = pts[i][d]; + } +} + Coord BezierCurve::length(Coord tolerance) const { switch (order()) @@ -127,6 +136,48 @@ Coord BezierCurve::length(Coord tolerance) const } } +BezierCurve *BezierCurve::create(std::vector const &pts) +{ + switch (pts.size()) { + case 0: + case 1: + THROW_LOGICALERROR("BezierCurve::create: too few points in vector"); + return NULL; + case 2: + return new LineSegment(pts[0], pts[1]); + case 3: + return new QuadraticBezier(pts[0], pts[1], pts[2]); + case 4: + return new CubicBezier(pts[0], pts[1], pts[2], pts[3]); + default: + return new BezierCurve(pts); + } +} + +// optimized specializations for LineSegment + +template <> +Curve *BezierCurveN<1>::derivative() const { + double dx = inner[X][1] - inner[X][0], dy = inner[Y][1] - inner[Y][0]; + return new BezierCurveN<1>(Point(dx,dy),Point(dx,dy)); +} + +template<> +Coord BezierCurveN<1>::nearestPoint(Point const& p, Coord from, Coord to) const +{ + if ( from > to ) std::swap(from, to); + Point ip = pointAt(from); + Point fp = pointAt(to); + Point v = fp - ip; + Coord l2v = L2sq(v); + if (l2v == 0) return 0; + Coord t = dot( p - ip, v ) / l2v; + if ( t <= 0 ) return from; + else if ( t >= 1 ) return to; + else return from + t*(to-from); +} + + static Coord bezier_length_internal(std::vector &v1, Coord tolerance) { /* The Bezier length algorithm used in 2Geom utilizes a simple fact: @@ -178,7 +229,7 @@ static Coord bezier_length_internal(std::vector &v1, Coord tolerance) * After loop with i==2 * # # 2 3 4 * # 1 ? ? - * 0 ? ? -> wirte 0 to v2[2] + * 0 ? ? -> write 0 to v2[2] * ? ? * ? * @@ -204,7 +255,7 @@ static Coord bezier_length_internal(std::vector &v1, Coord tolerance) } /** @brief Compute the length of a bezier curve given by a vector of its control points - * @relates BezierCurve */ + * @relatesalso BezierCurve */ Coord bezier_length(std::vector const &points, Coord tolerance) { if (points.size() < 2) return 0.0; @@ -213,7 +264,7 @@ Coord bezier_length(std::vector const &points, Coord tolerance) } /** @brief Compute the length of a quadratic bezier curve given by its control points - * @relates QuadraticBezier */ + * @relatesalso QuadraticBezier */ Coord bezier_length(Point a0, Point a1, Point a2, Coord tolerance) { Coord lower = distance(a0, a2); @@ -231,7 +282,7 @@ Coord bezier_length(Point a0, Point a1, Point a2, Coord tolerance) } /** @brief Compute the length of a cubic bezier curve given by its control points - * @relates CubicBezier */ + * @relatesalso CubicBezier */ Coord bezier_length(Point a0, Point a1, Point a2, Point a3, Coord tolerance) { Coord lower = distance(a0, a3); diff --git a/src/2geom/bezier-curve.h b/src/2geom/bezier-curve.h index 40da6f366..d13ff8321 100644 --- a/src/2geom/bezier-curve.h +++ b/src/2geom/bezier-curve.h @@ -1,14 +1,13 @@ /** * \file * \brief Bezier curve - * *//* * Authors: * MenTaLguY * Marco Cecchetti * Krzysztof Kosiński * - * Copyright 2007-2009 Authors + * Copyright 2007-2011 Authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -47,10 +46,13 @@ namespace Geom class BezierCurve : public Curve { protected: D2 inner; + BezierCurve() {} + BezierCurve(BezierCurve const &b) : inner(b.inner) {} + BezierCurve(D2 const &b) : inner(b) {} + BezierCurve(Bezier const &x, Bezier const &y) : inner(x, y) {} + BezierCurve(std::vector const &pts); public: - /// No constructors allowed! - /// @name Access and modify control points /// @{ /** @brief Get the order of the Bezier curve. @@ -66,8 +68,10 @@ public: inner[X].setPoint(ix, v[X]); inner[Y].setPoint(ix, v[Y]); } - /** @brief Set new control points for this curve. - * @param ps Vector which must contain order() + 1 points. Note that the caller is responsible for checking the size of this vector. */ + /** @brief Set new control points. + * @param ps Vector which must contain order() + 1 points. + * Note that the caller is responsible for checking the size of this vector. + * @throws LogicalError Thrown when the size of the vector does not match the order. */ virtual void setPoints(std::vector const &ps) { // must be virtual, because HLineSegment will need to redefine it if (ps.size() != order() + 1) @@ -76,12 +80,18 @@ public: setPoint(i, ps[i]); } } - /** Access control points of the curve. - * @param ix The (zero-based) index of the control point. Note that the caller is responsible for checking that this value is <= order(). + /** @brief Access control points of the curve. + * @param ix The (zero-based) index of the control point. Note that the caller is responsible for checking that this value is <= order(). * @return The control point. No-reference return, use setPoint() to modify control points. */ Point const operator[](unsigned ix) const { return Point(inner[X][ix], inner[Y][ix]); } /// @} + /// @name Construct a Bezier curve with runtime-determined order. + /// @{ + /** @brief Construct a curve from a vector of control points. */ + static BezierCurve *create(std::vector const &pts); + /// @} + // implementation of virtual methods goes here #ifndef DOXYGEN_SHOULD_SKIP_THIS virtual Point initialPoint() const { return inner.at0(); } @@ -100,6 +110,27 @@ public: bounds_local(Geom::derivative(inner[Y]), i)); return OptRect(); } + virtual Curve *duplicate() const { + return new BezierCurve(*this); + } + virtual Curve *portion(Coord f, Coord t) const { + return new BezierCurve(Geom::portion(inner, f, t)); + } + virtual Curve *reverse() const { + return new BezierCurve(Geom::reverse(inner)); + } + virtual Curve *transformed(Affine const &m) const { + BezierCurve *ret = new BezierCurve(); + std::vector ps = points(); + for (unsigned i = 0; i <= order(); i++) { + ps[i] = ps[i] * m; + } + ret->setPoints(ps); + return ret; + } + virtual Curve *derivative() const { + return new BezierCurve(Geom::derivative(inner[X]), Geom::derivative(inner[Y])); + } virtual int degreesOfFreedom() const { return 2 * (order() + 1); } @@ -121,7 +152,7 @@ public: template static void assert_degree(BezierCurveN const *) {} - /// @name Construct the curve + /// @name Construct Bezier curves /// @{ /** @brief Construct a Bezier curve of the specified order with all points zero. */ BezierCurveN() { @@ -175,7 +206,19 @@ public: /// @} + /** @brief Divide a Bezier curve into two curves + * @param t Time value + * @return Pair of Bezier curves \f$(\mathbf{D}, \mathbf{E})\f$ such that + * \f$\mathbf{D}[ [0,1] ] = \mathbf{C}[ [0,t] ]\f$ and + * \f$\mathbf{E}[ [0,1] ] = \mathbf{C}[ [t,1] ]\f$ */ + std::pair subdivide(Coord t) const { + std::pair sx = inner[X].subdivide(t), sy = inner[Y].subdivide(t); + return std::make_pair( + BezierCurveN(sx.first, sy.first), + BezierCurveN(sx.second, sy.second)); + } +#ifndef DOXYGEN_SHOULD_SKIP_THIS virtual Curve *duplicate() const { return new BezierCurveN(*this); } @@ -207,31 +250,29 @@ public: } } virtual Curve *derivative() const; - - /** @brief Divide a Bezier curve into two curves - * @param t Time value - * @return Pair of Bezier curves \f$(\mathbf{D}, \mathbf{E})\f$ such that - * \f$\mathbf{D}[ [0,1] ] = \mathbf{C}[ [0,t] ]\f$ and - * \f$\mathbf{E}[ [0,1] ] = \mathbf{C}[ [t,1] ]\f$ */ - std::pair subdivide(Coord t) const { - std::pair sx = inner[X].subdivide(t), sy = inner[Y].subdivide(t); - return std::make_pair( - BezierCurveN(sx.first, sy.first), - BezierCurveN(sx.second, sy.second)); - } - - double nearestPoint( Point const& p, double from = 0, double to = 1 ) const { + + // the method below is defined so that LineSegment can specialize it + virtual Coord nearestPoint(Point const& p, Coord from = 0, Coord to = 1) const { return Curve::nearestPoint(p, from, to); } - +#endif }; // BezierCurveN<0> is meaningless; specialize it out -template<> class BezierCurveN<0> : public BezierCurveN<1> { public: BezierCurveN();}; +template<> class BezierCurveN<0> : public BezierCurveN<1> { private: BezierCurveN();}; -// provide convenient names for common degree bezier curves +/** @brief Line segment. + * Line segments are Bezier curves of order 1. They have only two control points, + * the starting point and the ending point. + * @ingroup Curves */ typedef BezierCurveN<1> LineSegment; + +/** @brief Quadratic (order 2) Bezier curve. + * @ingroup Curves */ typedef BezierCurveN<2> QuadraticBezier; + +/** @brief Cubic (order 3) Bezier curve. + * @ingroup Curves */ typedef BezierCurveN<3> CubicBezier; template @@ -239,28 +280,10 @@ inline Curve *BezierCurveN::derivative() const { return new BezierCurveN(Geom::derivative(inner[X]), Geom::derivative(inner[Y])); } -template <> -inline -Curve *BezierCurveN<1>::derivative() const { - double dx = inner[X][1] - inner[X][0], dy = inner[Y][1] - inner[Y][0]; - return new BezierCurveN<1>(Point(dx,dy),Point(dx,dy)); -} -template<> -inline -double LineSegment::nearestPoint(Point const& p, double from, double to) const -{ - if ( from > to ) std::swap(from, to); - Point ip = pointAt(from); - Point fp = pointAt(to); - Point v = fp - ip; - Coord l2v = L2sq(v); - if (l2v == 0) return 0; - Coord t = dot( p - ip, v ) / l2v; - if ( t <= 0 ) return from; - else if ( t >= 1 ) return to; - else return from + t*(to-from); -} +// optimized specializations for LineSegment +template <> Curve *BezierCurveN<1>::derivative() const; +template <> Coord BezierCurveN<1>::nearestPoint(Point const &, Coord, Coord) const; inline Point middle_point(LineSegment const& _segment) { return ( _segment.initialPoint() + _segment.finalPoint() ) / 2; diff --git a/src/2geom/bezier-to-sbasis.h b/src/2geom/bezier-to-sbasis.h index ba98a8a34..8cd4bf444 100644 --- a/src/2geom/bezier-to-sbasis.h +++ b/src/2geom/bezier-to-sbasis.h @@ -1,7 +1,7 @@ /** - * \file bezier-to-sbasis.h - * \brief \todo brief description - * + * \file + * \brief Conversion between Bezier control points and SBasis curves + *//* * Copyright 2006 Nathan Hurst * * This library is free software; you can redistribute it and/or diff --git a/src/2geom/bezier-utils.cpp b/src/2geom/bezier-utils.cpp index eb317940f..af07db707 100644 --- a/src/2geom/bezier-utils.cpp +++ b/src/2geom/bezier-utils.cpp @@ -1,9 +1,5 @@ -#define __SP_BEZIER_UTILS_C__ - -/** \file - * Bezier interpolation for inkscape drawing code. - */ -/* +/* Bezier interpolation for inkscape drawing code. + * * Original code published in: * An Algorithm for Automatically Fitting Digitized Curves * by Philip J. Schneider @@ -52,8 +48,7 @@ #endif #include <2geom/bezier-utils.h> - -#include <2geom/isnan.h> +#include <2geom/math-utils.h> #include namespace Geom { diff --git a/src/2geom/bezier-utils.h b/src/2geom/bezier-utils.h index 9689db82d..3e56e6e25 100644 --- a/src/2geom/bezier-utils.h +++ b/src/2geom/bezier-utils.h @@ -1,10 +1,7 @@ -#ifndef SEEN_GEOM_BEZIER_UTILS_H -#define SEEN_GEOM_BEZIER_UTILS_H - /** * \file - * \brief \todo brief description - * + * \brief Bezier fitting algorithms + *//* * An Algorithm for Automatically Fitting Digitized Curves * by Philip J. Schneider * from "Graphics Gems", Academic Press, 1990 @@ -41,11 +38,13 @@ * */ +#ifndef LIB2GEOM_SEEN_BEZIER_UTILS_H +#define LIB2GEOM_SEEN_BEZIER_UTILS_H + #include <2geom/point.h> -namespace Geom{ +namespace Geom { -/* Bezier approximation utils */ Point bezier_pt(unsigned degree, Point const V[], double t); int bezier_fit_cubic(Point bezier[], Point const data[], int len, double error); @@ -84,8 +83,9 @@ cubic_bezier_poly_coeff(iterator b, Point *pc) { } } -} -#endif /* !SEEN_GEOM_BEZIER_UTILS_H */ +} // end namespace Geom + +#endif // LIB2GEOM_SEEN_BEZIER_UTILS_H /* Local Variables: diff --git a/src/2geom/bezier.h b/src/2geom/bezier.h index a7d75da45..48a1dc750 100644 --- a/src/2geom/bezier.h +++ b/src/2geom/bezier.h @@ -1,10 +1,13 @@ /** - * \file bezier.h - * \brief \todo brief description + * @file + * @brief Bezier polynomial + *//* + * Authors: + * MenTaLguY + * Michael Sloan + * Nathan Hurst * - * Copyright 2007 MenTaLguY - * Copyright 2007 Michael Sloan - * Copyright 2007 Nathan Hurst + * Copyright 2007 Authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -31,15 +34,15 @@ * */ -#ifndef SEEN_BEZIER_H -#define SEEN_BEZIER_H +#ifndef LIB2GEOM_SEEN_BEZIER_H +#define LIB2GEOM_SEEN_BEZIER_H -#include <2geom/coord.h> #include -#include <2geom/isnan.h> +#include +#include <2geom/coord.h> +#include <2geom/math-utils.h> #include <2geom/d2.h> #include <2geom/solver.h> -#include namespace Geom { @@ -280,7 +283,7 @@ public: } std::vector roots(Interval const ivl) const { std::vector solutions; - find_bernstein_roots(&const_cast&>(c_)[0], order(), solutions, 0, ivl[0], ivl[1]); + find_bernstein_roots(&const_cast&>(c_)[0], order(), solutions, 0, ivl.min(), ivl.max()); return solutions; } }; @@ -407,7 +410,7 @@ inline std::ostream &operator<< (std::ostream &out_file, const Bezier & b) { } } -#endif //SEEN_BEZIER_H +#endif // LIB2GEOM_SEEN_BEZIER_H /* Local Variables: diff --git a/src/2geom/choose.h b/src/2geom/choose.h index 3fecf1ba2..64ce76f39 100644 --- a/src/2geom/choose.h +++ b/src/2geom/choose.h @@ -1,7 +1,7 @@ /** - * \file choose.h - * \brief \todo brief description - * + * \file + * \brief Calculation of binomial cefficients + *//* * Copyright 2006 Nathan Hurst * * This library is free software; you can redistribute it and/or @@ -29,10 +29,13 @@ * */ -#ifndef _CHOOSE_H -#define _CHOOSE_H +#ifndef LIB2GEOM_SEEN_CHOOSE_H +#define LIB2GEOM_SEEN_CHOOSE_H + #include +namespace Geom { + // XXX: Can we keep only the left terms easily? // this would more than halve the array // row index becomes n2 = n/2, row2 = n2*(n2+1)/2, row = row2*2+(n&1)?n2:0 @@ -121,13 +124,9 @@ class BinomialCoefficient container_type coefficients; }; +} // end namespace Geom - - - - - -#endif +#endif // LIB2GEOM_SEEN_CHOOSE_H /* Local Variables: diff --git a/src/2geom/circle.h b/src/2geom/circle.h index ec58e163a..67a638437 100644 --- a/src/2geom/circle.h +++ b/src/2geom/circle.h @@ -1,7 +1,7 @@ /** * \file - * \brief Circle Curve - * + * \brief Circles + *//* * Authors: * Marco Cecchetti * @@ -31,18 +31,15 @@ * the specific language governing rights and limitations. */ +#ifndef LIB2GEOM_SEEN_CIRCLE_H +#define LIB2GEOM_SEEN_CIRCLE_H -#ifndef _2GEOM_CIRCLE_H_ -#define _2GEOM_CIRCLE_H_ - - +#include #include <2geom/point.h> #include <2geom/exception.h> #include <2geom/path.h> -#include -namespace Geom -{ +namespace Geom { class EllipticalArc; @@ -115,13 +112,9 @@ class Circle Coord m_ray; }; - } // end namespace Geom - - -#endif // _2GEOM_CIRCLE_H_ - +#endif // LIB2GEOM_SEEN_CIRCLE_H /* Local Variables: diff --git a/src/2geom/circulator.h b/src/2geom/circulator.h index 1a70dc4d3..9671ce4a9 100644 --- a/src/2geom/circulator.h +++ b/src/2geom/circulator.h @@ -1,7 +1,7 @@ /** - * \file circulator.h - * \brief \todo brief description - * + * @file circulator.h + * @brief Circular iterator adapter + *//* * Copyright 2006 MenTaLguY * * This library is free software; you can redistribute it and/or @@ -36,6 +36,9 @@ namespace Geom { +/** @brief Circular iterator adapter + * This iterator adapter will loop indefinitely over a set of values + * from a random access container. */ template class Circulator { public: diff --git a/src/2geom/concepts.h b/src/2geom/concepts.h index a03538d42..c89c3a224 100644 --- a/src/2geom/concepts.h +++ b/src/2geom/concepts.h @@ -1,7 +1,7 @@ /** * \file - * \brief Declares various mathematical concepts, for restriction of template parameters - * + * \brief Template concepts used by 2Geom + *//* * Copyright 2007 Michael Sloan * * This library is free software; you can redistribute it and/or @@ -26,15 +26,15 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY * OF ANY KIND, either express or implied. See the LGPL or the MPL for * the specific language governing rights and limitations. - * */ -#ifndef SEEN_CONCEPTS_H -#define SEEN_CONCEPTS_H +#ifndef LIB2GEOM_SEEN_CONCEPTS_H +#define LIB2GEOM_SEEN_CONCEPTS_H #include <2geom/sbasis.h> #include <2geom/interval.h> #include <2geom/point.h> +#include <2geom/rect.h> #include #include #include <2geom/forward.h> @@ -49,7 +49,7 @@ template <> struct ResultTraits { typedef SBasis sb_type; }; -template <> struct ResultTraits { +template <> struct ResultTraits { typedef OptRect bounds_type; typedef D2 sb_type; }; @@ -130,7 +130,7 @@ struct ScalableConcept { } }; -template +template struct AddableConcept { T i, j; void constraints() { @@ -139,7 +139,7 @@ struct AddableConcept { } }; -template +template struct MultiplicableConcept { T i, j; void constraints() { @@ -147,9 +147,9 @@ struct MultiplicableConcept { } }; -}; +} // end namespace Geom -#endif //SEEN_CONCEPTS_H +#endif // LIB2GEOM_SEEN_CONCEPTS_H /* Local Variables: diff --git a/src/2geom/conic_section_clipper_impl.cpp b/src/2geom/conic_section_clipper_impl.cpp index edfafb11c..33a218a8c 100644 --- a/src/2geom/conic_section_clipper_impl.cpp +++ b/src/2geom/conic_section_clipper_impl.cpp @@ -1,6 +1,4 @@ -/** - * \file - * \brief Conic section clipping with respect to a rectangle +/* Conic section clipping with respect to a rectangle * * Authors: * Marco Cecchetti @@ -31,30 +29,13 @@ * the specific language governing rights and limitations. */ - - - #ifndef CLIP_WITH_CAIRO_SUPPORT #include <2geom/conic_section_clipper.h> #endif - - - namespace Geom { -struct lex_lesser -{ - bool operator() (const Point & P, const Point & Q) const - { - if (P[X] < Q[X]) return true; - if (P[X] == Q[X] && P[Y] < Q[Y]) return true; - return false; - } -}; - - /* * Find rectangle-conic crossing points. They are returned in the * "crossing_points" parameter. @@ -192,7 +173,7 @@ bool CLIPPER_CLASS::intersect (std::vector & crossing_points) const cpts.size()) // remove duplicates - std::sort (cpts.begin(), cpts.end(), lex_lesser()); + std::sort (cpts.begin(), cpts.end(), Point::LexOrder()); cpts.erase (std::unique (cpts.begin(), cpts.end()), cpts.end()); diff --git a/src/2geom/conicsec.cpp b/src/2geom/conicsec.cpp index 2a537a1f0..a7e8e0ad8 100644 --- a/src/2geom/conicsec.cpp +++ b/src/2geom/conicsec.cpp @@ -1,7 +1,4 @@ -/** - * \file - * \brief Circle Curve - * +/* * Authors: * Nathan Hurst * * This library is free software; you can redistribute it and/or diff --git a/src/2geom/convex-cover.h b/src/2geom/convex-cover.h index d5e2dee44..e4b5de200 100644 --- a/src/2geom/convex-cover.h +++ b/src/2geom/convex-cover.h @@ -1,9 +1,6 @@ -#ifndef GEOM_CONVEX_COVER_H -#define GEOM_CONVEX_COVER_H - /** * \file - * \brief \todo brief description + * \brief Dynamic convex hull structure * * Copyright 2006 Nathan Hurst * Copyright 2006 Michael G. Sloan @@ -33,15 +30,18 @@ * */ -/** A convex cover is a sequence of convex polygons that completely cover the path. For now a - * convex hull class is included here (the convex-hull header is wrong) - */ +#ifndef GEOM_CONVEX_COVER_H +#define GEOM_CONVEX_COVER_H #include <2geom/point.h> #include namespace Geom{ +/* A convex cover is a sequence of convex polygons that completely cover the path. For now a + * convex hull class is included here (the convex-hull header is wrong) + */ + /** ConvexHull * A convexhull is a convex region - every point between two points in the convex hull is also in * the convex hull. It is defined by a set of points travelling in a clockwise direction. We require the first point to be top most, and of the topmost, leftmost. diff --git a/src/2geom/coord.h b/src/2geom/coord.h index 9c42f6bfc..c7bbcdcd4 100644 --- a/src/2geom/coord.h +++ b/src/2geom/coord.h @@ -1,7 +1,7 @@ /** * \file * \brief Defines the Coord "real" type with sufficient precision for coordinates. - * + *//* * Copyright 2006 Nathan Hurst * * This library is free software; you can redistribute it and/or @@ -29,15 +29,16 @@ * */ -#ifndef SEEN_Geom_COORD_H -#define SEEN_Geom_COORD_H +#ifndef LIB2GEOM_SEEN_COORD_H +#define LIB2GEOM_SEEN_COORD_H #include #include +#include <2geom/forward.h> namespace Geom { -/** @brief Axis enum (X or Y). */ +/** @brief 2D axis enumeration (X or Y). */ enum Dim2 { X=0, Y=1 }; /** @@ -48,6 +49,7 @@ enum Dim2 { X=0, Y=1 }; * differences of on-canvas points. */ typedef double Coord; +typedef int IntCoord; const Coord EPSILON = 1e-5; //1e-18; @@ -57,13 +59,36 @@ inline Coord infinity() { return std::numeric_limits::infinity(); } inline bool are_near(Coord a, Coord b, double eps=EPSILON) { return a-b <= eps && a-b >= -eps; } inline bool rel_error_bound(Coord a, Coord b, double eps=EPSILON) { return a <= eps*b && a >= -eps*b; } +template +struct CoordTraits {}; -typedef long IntCoord; +template<> +struct CoordTraits { + typedef IntPoint PointType; + typedef IntInterval IntervalType; + typedef OptIntInterval OptIntervalType; + typedef IntRect RectType; + typedef OptIntRect OptRectType; + inline static bool contains(IntCoord low, IntCoord high, IntCoord testlow, IntCoord testhigh) { + return low <= testlow && testhigh < high; + } +}; -} /* namespace Geom */ +template<> +struct CoordTraits { + typedef Point PointType; + typedef Interval IntervalType; + typedef OptInterval OptIntervalType; + typedef Rect RectType; + typedef OptRect OptRectType; + inline static bool contains(Coord low, Coord high, Coord testlow, Coord testhigh) { + return low <= testlow && testhigh <= high; + } +}; +} // end namespace Geom -#endif /* !SEEN_Geom_COORD_H */ +#endif // LIB2GEOM_SEEN_COORD_H /* Local Variables: diff --git a/src/2geom/crossing.h b/src/2geom/crossing.h index 62e447450..75c75fc24 100644 --- a/src/2geom/crossing.h +++ b/src/2geom/crossing.h @@ -1,10 +1,10 @@ /** - * \file - * \brief \todo brief description - * + * @file + * @brief Structure representing the intersection of two curves + *//* * Authors: - * Michael Sloane - * Marco + * Michael Sloan + * Marco Cecchetti * * Copyright 2006-2008 authors * diff --git a/src/2geom/curve.cpp b/src/2geom/curve.cpp index 49e011a8b..fe9d607d8 100644 --- a/src/2geom/curve.cpp +++ b/src/2geom/curve.cpp @@ -1,8 +1,5 @@ -/** - * \file - * \brief Abstract curve type - implementation of default methods +/* Abstract curve type - implementation of default methods * - *//* * Authors: * MenTaLguY * Marco Cecchetti diff --git a/src/2geom/curves.h b/src/2geom/curves.h index 64cf3d4fb..319b1924d 100644 --- a/src/2geom/curves.h +++ b/src/2geom/curves.h @@ -32,9 +32,8 @@ * the specific language governing rights and limitations. */ -#ifndef _2GEOM_CURVES_H_ -#define _2GEOM_CURVES_H_ - +#ifndef LIB2GEOM_SEEN_CURVES_H +#define LIB2GEOM_SEEN_CURVES_H #include <2geom/curve.h> #include <2geom/sbasis-curve.h> @@ -43,7 +42,7 @@ #include <2geom/elliptical-arc.h> #include <2geom/svg-elliptical-arc.h> -#endif // _2GEOM_CURVES_H_ +#endif // LIB2GEOM_SEEN_CURVES_H /* Local Variables: diff --git a/src/2geom/d2-sbasis.h b/src/2geom/d2-sbasis.h index bd6c35805..95c0da4ed 100644 --- a/src/2geom/d2-sbasis.h +++ b/src/2geom/d2-sbasis.h @@ -1,11 +1,10 @@ /** * \file - * \brief Do not include this file \todo brief description + * \brief Do not include this file * * We don't actually want anyone to - * include this, other than D2.h. If somone else tries, D2 - * won't be defined. If it is, this will already be included. - * + * include this, other than D2.h. + *//* * Authors: * ? * diff --git a/src/2geom/d2.h b/src/2geom/d2.h index 3e4de430e..73330295b 100644 --- a/src/2geom/d2.h +++ b/src/2geom/d2.h @@ -1,7 +1,7 @@ /** * \file * \brief Lifts one dimensional objects into 2d - * + *//* * Copyright 2007 Michael Sloan * * This library is free software; you can redistribute it and/or @@ -426,7 +426,6 @@ inline std::ostream &operator<< (std::ostream &out_file, const Geom::D2 &in_d } //end namespace Geom -#include <2geom/rect.h> #include <2geom/d2-sbasis.h> namespace Geom{ diff --git a/src/2geom/forward.h b/src/2geom/forward.h index 399344dda..b1cad6f1f 100644 --- a/src/2geom/forward.h +++ b/src/2geom/forward.h @@ -41,11 +41,23 @@ namespace Geom { // basic types typedef double Coord; +typedef int IntCoord; class Point; -class Interval; -class OptInterval; +class IntPoint; class Line; class Ray; +template class GenericInterval; +template class GenericOptInterval; +class Interval; +typedef GenericOptInterval OptInterval; +typedef GenericInterval IntInterval; +typedef GenericOptInterval OptIntInterval; +template class GenericRect; +template class GenericOptRect; +class Rect; +typedef GenericOptRect OptRect; +typedef GenericRect IntRect; +typedef GenericOptRect OptIntRect; // fragments class Linear; @@ -90,9 +102,6 @@ class VShear; template class D2; template class Piecewise; -typedef D2 Rect; -class OptRect; - class Shape; class Region; class Hat; diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h new file mode 100644 index 000000000..d719c16c8 --- /dev/null +++ b/src/2geom/generic-interval.h @@ -0,0 +1,342 @@ +/** + * @file + * @brief Closed interval of generic values + *//* + * Copyright 2011 Krzysztof Kosiński + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#ifndef LIB2GEOM_SEEN_GENERIC_INTERVAL_H +#define LIB2GEOM_SEEN_GENERIC_INTERVAL_H + +#include +#include +#include +#include + +namespace Geom { + +template +class GenericOptInterval; + +/** + * @brief A range of numbers which is never empty. + * @ingroup Primitives + */ +template +class GenericInterval + : boost::equality_comparable< GenericInterval + , boost::additive< GenericInterval + , boost::additive< GenericInterval, C + , boost::orable< GenericInterval + > > > > +{ + typedef GenericInterval Self; +protected: + C _b[2]; +public: + /// @name Create intervals. + /// @{ + /** @brief Create an interval that contains only zero. */ + GenericInterval() { _b[0] = 0; _b[1] = 0; } + /** @brief Create an interval that contains a single point. */ + explicit GenericInterval(C u) { _b[0] = _b[1] = u; } + /** @brief Create an interval that contains all points between @c u and @c v. */ + GenericInterval(C u, C v) { + if (u <= v) { + _b[0] = u; _b[1] = v; + } else { + _b[0] = v; _b[1] = u; + } + } + + /** @brief Create an interval containing a range of values. + * The resulting interval will contain all values from the given range. + * The return type of iterators must be convertible to C. The given range + * must not be empty. For potentially empty ranges, see GenericOptInterval. + * @param start Beginning of the range + * @param end End of the range + * @return Interval that contains all values from [start, end). */ + template + static Self from_range(InputIterator start, InputIterator end) { + assert(start != end); + Self result(*start++); + for (; start != end; ++start) result.expandTo(*start); + return result; + } + /** @brief Create an interval from a C-style array of values it should contain. */ + static Self from_array(C const *c, unsigned n) { + Self result = from_range(c, c+n); + return result; + } + /// @} + + /// @name Inspect endpoints. + /// @{ + C min() const { return _b[0]; } + C max() const { return _b[1]; } + C extent() const { return max() - min(); } + C middle() const { return (max() + min()) * 0.5; } + bool isSingular() const { return min() == max(); } + /// @} + + /// @name Test coordinates and other intervals for inclusion. + /// @{ + /** @brief Check whether the interval includes this number. */ + bool contains(C val) const { + return CoordTraits::contains(min(), max(), val, val); + } + /** @brief Check whether the interval includes the given interval. */ + bool contains(Self const &val) const { + return CoordTraits::contains(min(), max(), val.min(), val.max()); + } + /** @brief Check whether the intervals have any common elements. */ + bool intersects(Self const &val) const { + return contains(val.min()) || contains(val.max()) || val.contains(*this); + } + /// @} + + /// @name Modify the interval. + /// @{ + //TODO: NaN handleage for the next two? + /** @brief Set the lower boundary of the interval. + * When the given number is larger than the interval's largest element, + * it will be reduced to the single number @c val. */ + void setMin(C val) { + if(val > _b[1]) { + _b[0] = _b[1] = val; + } else { + _b[0] = val; + } + } + /** @brief Set the upper boundary of the interval. + * When the given number is smaller than the interval's smallest element, + * it will be reduced to the single number @c val. */ + void setMax(C val) { + if(val < _b[0]) { + _b[1] = _b[0] = val; + } else { + _b[1] = val; + } + } + /** @brief Extend the interval to include the given number. */ + void expandTo(C val) { + if(val < _b[0]) _b[0] = val; + if(val > _b[1]) _b[1] = val; //no else, as we want to handle NaN + } + /** @brief Expand or shrink the interval in both directions by the given amount. + * After this method, the interval's length (extent) will be increased by + * amount * 2. Negative values can be given; they will shrink the interval. + * Shrinking by a value larger than half the interval's length will create a degenerate + * interval containing only the midpoint of the original. */ + void expandBy(C amount) { + _b[0] -= amount; + _b[1] += amount; + if (_b[0] > _b[1]) { + C halfway = (_b[0]+_b[1])/2; + _b[0] = _b[1] = halfway; + } + } + /** @brief Union the interval with another one. + * The resulting interval will contain all points of both intervals. + * It might also contain some points which didn't belong to either - this happens + * when the intervals did not have any common elements. */ + void unionWith(Self const &a) { + if(a._b[0] < _b[0]) _b[0] = a._b[0]; + if(a._b[1] > _b[1]) _b[1] = a._b[1]; + } + /// @} + + /// @name Operators + /// @{ + //IMPL: OffsetableConcept + //TODO: rename output_type to something else in the concept + typedef C output_type; + /** @brief Offset the interval by a specified amount */ + Self &operator+=(C amnt) { + _b[0] += amnt; _b[1] += amnt; + return *this; + } + /** @brief Offset the interval by the negation of the specified amount */ + Self &operator-=(C amnt) { + _b[0] -= amnt; _b[1] -= amnt; + return *this; + } + + /** @brief Return an interval mirrored about 0 */ + Self operator-() const { Self r(-_b[1], -_b[0]); return r; } + // IMPL: AddableConcept + /** @brief Add two intervals. + * Sum is defined as the set of points that can be obtained by adding any two values + * from both operands: \f$S = \{x \in A, y \in B: x + y\}\f$ */ + Self &operator+=(Self const &o) { + _b[0] += o._b[0]; + _b[1] += o._b[1]; + return *this; + } + /** @brief Subtract two intervals. + * Difference is defined as the set of points that can be obtained by subtracting + * any value from the second operand from any value from the first operand: + * \f$S = \{x \in A, y \in B: x - y\}\f$ */ + Self &operator-=(Self const &o) { + // equal to *this += -o + _b[0] -= o._b[1]; + _b[1] -= o._b[0]; + return *this; + } + /** @brief Union two intervals. + * Note that the intersection-and-assignment operator is not defined, + * because the result of an intersection can be empty, while Interval cannot. */ + Self &operator|=(Self const &o) { + unionWith(o); + return *this; + } + /** @brief Test for interval equality. */ + bool operator==(Self const &other) const { + return min() == other.min() && max() == other.max(); + } + /// @} +}; + +/** @brief Union two intervals + * @relates GenericInterval */ +template +inline GenericInterval unify(GenericInterval const &a, GenericInterval const &b) { + return a | b; +} + +/** + * @brief A range of numbers that can be empty. + * @ingroup Primitives + */ +template +class GenericOptInterval + : public boost::optional::IntervalType> + , boost::orable< GenericOptInterval, typename CoordTraits::OptIntervalType + , boost::andable< GenericOptInterval, typename CoordTraits::OptIntervalType + > > +{ + typedef typename CoordTraits::IntervalType CInterval; + typedef typename CoordTraits::OptIntervalType OptCInterval; + typedef boost::optional Base; +public: + /// @name Create optionally empty intervals of integers. + /// @{ + /** @brief Create an empty interval. */ + GenericOptInterval() : Base() {} + /** @brief Wrap an existing interval. */ + GenericOptInterval(GenericInterval const &a) : Base(CInterval(a)) {} + /** @brief Create an interval containing a single point. */ + GenericOptInterval(C u) : Base(CInterval(u)) {} + /** @brief Create an interval containing a range of numbers. */ + GenericOptInterval(C u, C v) : Base(CInterval(u,v)) {} + + /** @brief Create a possibly empty interval containing a range of values. + * The resulting interval will contain all values from the given range. + * The return type of iterators must be convertible to C. The given range + * may be empty. + * @param start Beginning of the range + * @param end End of the range + * @return Interval that contains all values from [start, end), or nothing if the range + * is empty. */ + template + static GenericOptInterval from_range(InputIterator start, InputIterator end) { + if (start == end) { + GenericOptInterval ret; + return ret; + } + GenericOptInterval ret(CInterval::from_range(start, end)); + return ret; + } + /// @} + + /** @brief Check whether this interval is empty. */ + bool isEmpty() { return !*this; }; + + /** @brief Union with another interval, gracefully handling empty ones. */ + void unionWith(GenericOptInterval const &a) { + if (*this) { // check that we are not empty + (*this)->unionWith(*a); + } else if (a) { + *this = *a; + } + } + void intersectWith(GenericOptInterval const &o) { + if (o && *this) { + if (!*this) return; + C u = std::max((*this)->min(), o->min()); + C v = std::min((*this)->max(), o->max()); + if (u <= v) { + *this = CInterval(u, v); + return; + } + } + (*static_cast(this)) = boost::none; + } + GenericOptInterval &operator|=(OptCInterval const &o) { + unionWith(o); + return *this; + } + GenericOptInterval &operator&=(OptCInterval const &o) { + intersectWith(o); + return *this; + } +}; + +/** @brief Intersect two intervals and return a possibly empty range of numbers + * @relates GenericOptInterval */ +template +inline GenericOptInterval intersect(GenericInterval const &a, GenericInterval const &b) { + return GenericOptInterval(a) & GenericOptInterval(b); +} +/** @brief Intersect two intervals and return a possibly empty range of numbers + * @relates GenericOptInterval */ +template +inline GenericOptInterval operator&(GenericInterval const &a, GenericInterval const &b) { + return GenericOptInterval(a) & GenericOptInterval(b); +} + +#ifdef _GLIBCXX_IOSTREAM +template +inline std::ostream &operator<< (std::ostream &os, + Geom::GenericInterval const &I) { + os << "Interval("< + * Krzysztof Kosiński + * Copyright 2007-2011 Authors + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, output to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + * Authors of original rect class: + * Lauris Kaplinski + * Nathan Hurst + * bulia byak + * MenTaLguY + */ + +#ifndef LIB2GEOM_SEEN_GENERIC_RECT_H +#define LIB2GEOM_SEEN_GENERIC_RECT_H + +#include + +namespace Geom { + +template +class GenericOptRect; + +/** + * @brief Axis aligned, non-empty, generic rectangle. + * @ingroup Primitives + */ +template +class GenericRect + : boost::additive< GenericRect, typename CoordTraits::PointType + , boost::equality_comparable< GenericRect + , boost::orable< GenericRect + , boost::orable< GenericRect, typename CoordTraits::OptRectType + > > > > +{ + typedef typename CoordTraits::IntervalType CInterval; + typedef typename CoordTraits::PointType CPoint; + typedef typename CoordTraits::RectType CRect; + typedef typename CoordTraits::OptRectType OptCRect; +protected: + CInterval f[2]; +public: + /// @name Create rectangles. + /// @{ + /** @brief Create a rectangle that contains only the point at (0,0). */ + GenericRect() { f[X] = f[Y] = Interval(); } + /** @brief Create a rectangle from X and Y intervals. */ + GenericRect(CInterval const &a, CInterval const &b) { + f[X] = a; + f[Y] = b; + } + /** @brief Create a rectangle from two points. */ + GenericRect(CPoint const &a, CPoint const &b) { + f[X] = Interval(a[X], b[X]); + f[Y] = Interval(a[Y], b[Y]); + } + /** @brief Create a rectangle from a range of points. + * The resulting rectangle will contain all ponts from the range. + * The return type of iterators must be convertible to Point. + * The range must not be empty. For possibly empty ranges, see OptRect. + * @param start Beginning of the range + * @param end End of the range + * @return Rectangle that contains all points from [start, end). */ + template + static GenericRect from_range(InputIterator start, InputIterator end) { + assert(start != end); + CPoint p1 = *start++; + GenericRect result(p1, p1); + for (; start != end; ++start) { + result.expandTo(*start); + } + return result; + } + /** @brief Create a rectangle from a C-style array of points it should contain. */ + static GenericRect from_array(CPoint const *c, unsigned n) { + GenericRect result = GenericRect::from_range(c, c+n); + return result; + } + /// @} + + /// @name Inspect dimensions. + /// @{ + CInterval &operator[](unsigned i) { return f[i]; } + CInterval const &operator[](unsigned i) const { return f[i]; } + + CPoint min() const { return CPoint(f[X].min(), f[Y].min()); } + CPoint max() const { return CPoint(f[X].max(), f[Y].max()); } + /** @brief Return the n-th corner of the rectangle. + * If the Y axis grows upwards, this returns corners in clockwise order + * starting from the lower left. If Y grows downwards, it returns the corners + * in counter-clockwise order starting from the upper left. */ + CPoint corner(unsigned i) const { + switch(i % 4) { + case 0: return CPoint(f[X].min(), f[Y].min()); + case 1: return CPoint(f[X].max(), f[Y].min()); + case 2: return CPoint(f[X].max(), f[Y].max()); + default: return CPoint(f[X].min(), f[Y].max()); + } + } + + //We should probably remove these - they're coord sys gnostic + /** @brief Return top coordinate of the rectangle (+Y is downwards). */ + C top() const { return f[Y].min(); } + /** @brief Return bottom coordinate of the rectangle (+Y is downwards). */ + C bottom() const { return f[Y].max(); } + /** @brief Return leftmost coordinate of the rectangle (+X is to the right). */ + C left() const { return f[X].min(); } + /** @brief Return rightmost coordinate of the rectangle (+X is to the right). */ + C right() const { return f[X].max(); } + + /** @brief Get the horizontal extent of the rectangle. */ + C width() const { return f[X].extent(); } + /** @brief Get the vertical extent of the rectangle. */ + C height() const { return f[Y].extent(); } + + /** @brief Get rectangle's width and height as a point. + * @return Point with X coordinate corresponding to the width and the Y coordinate + * corresponding to the height of the rectangle. */ + CPoint dimensions() const { return CPoint(f[X].extent(), f[Y].extent()); } + /** @brief Get the point in the geometric center of the rectangle. */ + CPoint midpoint() const { return CPoint(f[X].middle(), f[Y].middle()); } + + /** @brief Compute rectangle's area. */ + C area() const { return f[X].extent() * f[Y].extent(); } + /** @brief Check whether the rectangle has zero area. */ + bool hasZeroArea() const { return (area() == 0); } + + /** @brief Get the larger extent (width or height) of the rectangle. */ + C maxExtent() const { return std::max(f[X].extent(), f[Y].extent()); } + /** @brief Get the smaller extent (width or height) of the rectangle. */ + C minExtent() const { return std::min(f[X].extent(), f[Y].extent()); } + /// @} + + /// @name Test other rectangles and points for inclusion. + /// @{ + /** @brief Check whether the rectangles have any common points. */ + bool intersects(GenericRect const &r) const { + return f[X].intersects(r[X]) && f[Y].intersects(r[Y]); + } + /** @brief Check whether the rectangle includes all points in the given rectangle. */ + bool contains(GenericRect const &r) const { + return f[X].contains(r[X]) && f[Y].contains(r[Y]); + } + + /** @brief Check whether the rectangles have any common points. + * A non-empty rectangle will not intersect empty rectangles. */ + inline bool intersects(OptCRect const &r) const; + /** @brief Check whether the rectangle includes all points in the given rectangle. + * A non-empty rectangle will contain any empty rectangle. */ + inline bool contains(OptCRect const &r) const; + + /** @brief Check whether the given point is within the rectangle. */ + bool contains(CPoint const &p) const { + return f[X].contains(p[X]) && f[Y].contains(p[Y]); + } + /// @} + + /// @name Modify the rectangle. + /// @{ + /** @brief Enlarge the rectangle to contain the given point. */ + void expandTo(CPoint const &p) { + f[X].expandTo(p[X]); f[Y].expandTo(p[Y]); + } + /** @brief Enlarge the rectangle to contain the given rectangle. */ + void unionWith(GenericRect const &b) { + f[X].unionWith(b[X]); f[Y].unionWith(b[Y]); + } + /** @brief Enlarge the rectangle to contain the given rectangle. + * Unioning with an empty rectangle results in no changes. */ + void unionWith(OptCRect const &b); + + /** @brief Expand the rectangle in both directions by the specified amount. + * Note that this is different from scaling. Negative values wil shrink the + * rectangle. If -amount is larger than + * half of the width, the X interval will contain only the X coordinate + * of the midpoint; same for height. */ + void expandBy(C amount) { + f[X].expandBy(amount); f[Y].expandBy(amount); + } + /** @brief Expand the rectangle by the coordinates of the given point. + * This will expand the width by the X coordinate of the point in both directions + * and the height by Y coordinate of the point. Negative coordinate values will + * shrink the rectangle. If -p[X] is larger than half of the width, + * the X interval will contain only the X coordinate of the midpoint; same for height. */ + void expandBy(CPoint const &p) { + f[X].expandBy(p[X]); f[Y].expandBy(p[Y]); + } + /// @} + + /// @name Operators + /// @{ + /** @brief Offset the rectangle by a vector. */ + GenericRect &operator+=(CPoint const &p) { + f[X] += p[X]; + f[Y] += p[Y]; + return *this; + } + /** @brief Offset the rectangle by the negation of a vector. */ + GenericRect &operator-=(CPoint const &p) { + f[X] -= p[X]; + f[Y] -= p[Y]; + return *this; + } + /** @brief Union two rectangles. */ + GenericRect &operator|=(GenericRect const &o) { + unionWith(o); + return *this; + } + GenericRect &operator|=(OptCRect const &o) { + unionWith(o); + return *this; + } + /** @brief Test for equality of rectangles. */ + bool operator==(GenericRect const &o) const { return f[X] == o[X] && f[Y] == o[Y]; } + /// @} +}; + +/** + * @brief Axis-aligned generic rectangle that can be empty. + * @ingroup Primitives + */ +template +class GenericOptRect + : public boost::optional::RectType> + , boost::orable< GenericOptRect + , boost::andable< GenericOptRect + , boost::andable< GenericOptRect, typename CoordTraits::RectType + > > > +{ + typedef typename CoordTraits::IntervalType CInterval; + typedef typename CoordTraits::OptIntervalType OptCInterval; + typedef typename CoordTraits::PointType CPoint; + typedef typename CoordTraits::RectType CRect; + typedef typename CoordTraits::OptRectType OptCRect; + typedef boost::optional Base; +public: + GenericOptRect() : Base() {} + GenericOptRect(GenericRect const &a) : Base(CRect(a)) {} + GenericOptRect(CPoint const &a, CPoint const &b) : Base(CRect(a, b)) {} + /** + * Creates an empty OptRect when one of the argument intervals is empty. + */ + GenericOptRect(OptCInterval const &x_int, OptCInterval const &y_int) { + if (x_int && y_int) { + *this = CRect(*x_int, *y_int); + } + // else, stay empty. + } + + /** @brief Check for emptiness. */ + inline bool isEmpty() const { return !*this; }; + + bool intersects(CRect const &r) const { return r.intersects(*this); } + bool contains(CRect const &r) const { return *this && (*this)->contains(r); } + + bool intersects(OptCRect const &r) const { return *this && (*this)->intersects(r); } + bool contains(OptCRect const &r) const { return *this && (*this)->contains(r); } + + bool contains(CPoint const &p) const { return *this && (*this)->contains(p); } + + void unionWith(CRect const &b) { + if (*this) { + (*this)->unionWith(b); + } else { + *this = b; + } + } + void unionWith(OptCRect const &b) { + if (b) unionWith(*b); + } + void intersectWith(CRect const &b) { + if (!*this) return; + OptCInterval x = (**this)[X] & b[X], y = (**this)[Y] & b[Y]; + if (x && y) { + *this = CRect(*x, *y); + } else { + *(static_cast(this)) = boost::none; + } + } + void intersectWith(OptCRect const &b) { + if (b) { + intersectWith(*b); + } else { + *(static_cast(this)) = boost::none; + } + } + GenericOptRect &operator|=(OptCRect const &b) { + unionWith(b); + return *this; + } + GenericOptRect &operator&=(CRect const &b) { + intersectWith(b); + return *this; + } + GenericOptRect &operator&=(OptCRect const &b) { + intersectWith(b); + return *this; + } +}; + +template +inline void GenericRect::unionWith(OptCRect const &b) { + if (b) { + unionWith(*b); + } +} +template +inline bool GenericRect::intersects(OptCRect const &r) const { + return r && intersects(*r); +} +template +inline bool GenericRect::contains(OptCRect const &r) const { + return !r || contains(*r); +} + +#ifdef _GLIBCXX_IOSTREAM +template +inline std::ostream &operator<<(std::ostream &out, GenericRect const &r) { + out << "X: " << r[X] << " Y: " << r[Y]; + return out; +} +#endif + +} // end namespace Geom + +#endif // LIB2GEOM_SEEN_RECT_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/hvlinesegment.h b/src/2geom/hvlinesegment.h index 9419be8f6..05252468e 100644 --- a/src/2geom/hvlinesegment.h +++ b/src/2geom/hvlinesegment.h @@ -1,8 +1,11 @@ /** * \file - * \brief Horizontal and Vertical Line Segment - * - * Copyright 2008 Marco Cecchetti + * \brief Horizontal and vertical line segment + *//* + * Authors: + * Marco Cecchetti + * Krzysztof Kosiński + * Copyright 2008-2011 Authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -28,14 +31,11 @@ * the specific language governing rights and limitations. */ - -#ifndef _2GEOM_HVLINESEGMENT_H_ -#define _2GEOM_HVLINESEGMENT_H_ - +#ifndef LIB2GEOM_SEEN_HVLINESEGMENT_H +#define LIB2GEOM_SEEN_HVLINESEGMENT_H #include <2geom/bezier-curve.h> - namespace Geom { @@ -44,6 +44,7 @@ class AxisLineSegment : public LineSegment { public: static const Dim2 other_axis = static_cast((axis + 1) % 2); +#ifndef DOXYGEN_SHOULD_SKIP_THIS virtual void setInitial(Point const &p) { Point f = finalPoint(); f[axis] = p[axis]; @@ -106,10 +107,6 @@ public: if (d != axis) return initialPoint()[other_axis]; return initialPoint()[axis] + t * (finalPoint()[axis] - initialPoint()[axis]); } - - /** - * The size of the returned vector equals n+1. - */ virtual std::vector pointAndDerivatives(Coord t, unsigned n) const { std::vector result; result.push_back(pointAt(t)); @@ -124,6 +121,7 @@ public: } return result; } +#endif protected: AxisLineSegment(Point const &p0, Point const &p1) : LineSegment(p0, p1) {} AxisLineSegment() {} @@ -171,6 +169,7 @@ public: return result; } +#ifndef DOXYGEN_SHOULD_SKIP_THIS virtual Curve* duplicate() const { return new HLineSegment(*this); } virtual Curve *portion(Coord f, Coord t) const { Point ip = pointAt(f); @@ -195,6 +194,7 @@ public: Coord x = finalPoint()[X] - initialPoint()[X]; return new HLineSegment(x, x, 0); } +#endif }; // end class HLineSegment @@ -241,6 +241,7 @@ public: return result; } +#ifndef DOXYGEN_SHOULD_SKIP_THIS virtual Curve *duplicate() const { return new VLineSegment(*this); } virtual Curve *portion(Coord f, Coord t) const { Point ip = pointAt(f); @@ -264,13 +265,12 @@ public: Coord y = finalPoint()[Y] - initialPoint()[Y]; return new VLineSegment(0, y, y); } +#endif }; // end class VLineSegment } // end namespace Geom - -#endif // _2GEOM_HVLINESEGMENT_H_ - +#endif // LIB2GEOM_SEEN_HVLINESEGMENT_H /* Local Variables: diff --git a/src/2geom/int-interval.h b/src/2geom/int-interval.h new file mode 100644 index 000000000..0faf48d80 --- /dev/null +++ b/src/2geom/int-interval.h @@ -0,0 +1,63 @@ +/** + * \file + * \brief Closed interval of integer values + *//* + * Copyright 2011 Krzysztof Kosiński + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#ifndef LIB2GEOM_SEEN_INT_INTERVAL_H +#define LIB2GEOM_SEEN_INT_INTERVAL_H + +#include <2geom/coord.h> +#include <2geom/generic-interval.h> + +namespace Geom { + +/** + * @brief Range of integers that is never empty. + * @ingroup Primitives + */ +typedef GenericInterval IntInterval; + +/** + * @brief Range of integers that can be empty. + * @ingroup Primitives + */ +typedef GenericOptInterval OptIntInterval; + +} // namespace Geom +#endif // !LIB2GEOM_SEEN_INT_INTERVAL_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/int-point.h b/src/2geom/int-point.h new file mode 100644 index 000000000..cf2fe720f --- /dev/null +++ b/src/2geom/int-point.h @@ -0,0 +1,157 @@ +/** + * \file + * \brief Cartesian point / 2D vector with integer coordinates + *//* + * Copyright 2011 Krzysztof Kosiński + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#ifndef LIB2GEOM_SEEN_INT_POINT_H +#define LIB2GEOM_SEEN_INT_POINT_H + +#include +#include +#include <2geom/coord.h> + +namespace Geom { + +/** + * @brief Two-dimensional point with integer coordinates. + * + * This class is an exact equivalent of Point, except it stores integer coordinates. + * Integer points are useful in contexts related to rasterized graphics, for example + * for bounding boxes when rendering SVG. + * + * @see Point + * @ingroup Primitives */ +class IntPoint + : boost::additive< IntPoint + , boost::totally_ordered< IntPoint + > > +{ + IntCoord _pt[2]; +public: + /// @name Creating integer points + /// @{ + IntPoint() { } + IntPoint(IntCoord x, IntCoord y) { + _pt[X] = x; + _pt[Y] = y; + } + IntPoint(IntPoint const &p) { + _pt[X] = p._pt[X]; + _pt[Y] = p._pt[Y]; + } + IntPoint &operator=(IntPoint const &p) { + _pt[X] = p._pt[X]; + _pt[Y] = p._pt[Y]; + return *this; + } + /// @} + + /// @name Access the coordinates of a point + /// @{ + IntCoord operator[](unsigned i) const { + if ( i > Y ) throw std::out_of_range("index out of range"); + return _pt[i]; + } + IntCoord &operator[](unsigned i) { + if ( i > Y ) throw std::out_of_range("index out of range"); + return _pt[i]; + } + IntCoord operator[](Dim2 d) const { return _pt[d]; } + IntCoord &operator[](Dim2 d) { return _pt[d]; } + /// @} + + /// @name Vector-like arithmetic operations + /// @{ + IntPoint &operator+=(IntPoint const &o) { + _pt[X] += o._pt[X]; + _pt[Y] += o._pt[Y]; + return *this; + } + IntPoint &operator-=(IntPoint const &o) { + _pt[X] -= o._pt[X]; + _pt[Y] -= o._pt[Y]; + return *this; + } + /// @} + + /// @name Various utilities + /// @{ + /** @brief Equality operator. */ + bool operator==(IntPoint const &in_pnt) const { + return ((_pt[X] == in_pnt[X]) && (_pt[Y] == in_pnt[Y])); + } + /** @brief Lexicographical ordering for points. + * Y coordinate is regarded as more significant. When sorting according to this + * ordering, the points will be sorted according to the Y coordinate, and within + * points with the same Y coordinate according to the X coordinate. */ + bool operator<(IntPoint const &p) const { + return ( ( _pt[Y] < p[Y] ) || + (( _pt[Y] == p[Y] ) && ( _pt[X] < p[X] ))); + } + /// @} + + /** @brief Lexicographical ordering functor. */ + template struct LexOrder; + /** @brief Lexicographical ordering functor with runtime dimension. */ + class LexOrderRt { + public: + LexOrderRt(Dim2 d) : dim(d) {} + inline bool operator()(IntPoint const &a, IntPoint const &b); + private: + Dim2 dim; + }; +}; + +template<> struct IntPoint::LexOrder { + bool operator()(IntPoint const &a, IntPoint const &b) { + return a[X] < b[X] || (a[X] == b[X] && a[Y] < b[Y]); + } +}; +template<> struct IntPoint::LexOrder { + bool operator()(IntPoint const &a, IntPoint const &b) { + return a[Y] < b[Y] || (a[Y] == b[Y] && a[X] < b[X]); + } +}; +inline bool IntPoint::LexOrderRt::operator()(IntPoint const &a, IntPoint const &b) { + return dim ? IntPoint::LexOrder()(a, b) : IntPoint::LexOrder()(a, b); +} + +} // namespace Geom + +#endif // !SEEN_GEOM_INT_POINT_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/int-rect.h b/src/2geom/int-rect.h new file mode 100644 index 000000000..27fb06dfe --- /dev/null +++ b/src/2geom/int-rect.h @@ -0,0 +1,74 @@ +/** + * \file + * \brief Axis-aligned rectangle with integer coordinates + *//* + * Copyright 2011 Krzysztof Kosiński + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#ifndef LIB2GEOM_SEEN_INT_RECT_H +#define LIB2GEOM_SEEN_INT_RECT_H + +#include <2geom/coord.h> +#include <2geom/generic-rect.h> + +namespace Geom { + +typedef GenericRect IntRect; +typedef GenericOptRect OptIntRect; + +// the functions below do not work when defined generically +inline OptIntRect operator&(IntRect const &a, IntRect const &b) { + OptIntRect ret(a); + ret.intersectWith(b); + return ret; +} +inline OptIntRect intersect(IntRect const &a, IntRect const &b) { + return a & b; +} +inline OptIntRect intersect(OptIntRect const &a, OptIntRect const &b) { + return a & b; +} +inline IntRect unify(IntRect const &a, IntRect const &b) { + return a | b; +} +inline OptIntRect unify(OptIntRect const &a, OptIntRect const &b) { + return a | b; +} + +} // end namespace Geom + +#endif // !LIB2GEOM_SEEN_INT_RECT_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/interval.h b/src/2geom/interval.h index a790a6c3b..ee6d674d2 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -37,19 +37,24 @@ #ifndef LIB2GEOM_SEEN_INTERVAL_H #define LIB2GEOM_SEEN_INTERVAL_H -#include #include #include #include #include <2geom/coord.h> -#include <2geom/isnan.h> +#include <2geom/math-utils.h> +#include <2geom/generic-interval.h> +#include <2geom/int-interval.h> namespace Geom { -class OptInterval; +/** + * @brief Range of real numbers that can be empty. + * @ingroup Primitives + */ +typedef GenericOptInterval OptInterval; /** - * @brief Range of numbers that is never empty. + * @brief Range of real numbers that is never empty. * * Intervals are closed ranges \f$[a, b]\f$, which means they include their endpoints. * To use them as open ranges, you can use the interiorContains() methods. @@ -57,32 +62,24 @@ class OptInterval; * @ingroup Primitives */ class Interval - : boost::equality_comparable< Interval - , boost::additive< Interval + : public GenericInterval , boost::multipliable< Interval - , boost::arithmetic< Interval, Coord - , boost::orable< Interval - > > > > > + , boost::multipliable< Interval, Coord + > > { -private: - /// @invariant _b[0] <= _b[1] - Coord _b[2]; - + typedef GenericInterval Base; public: /// @name Create intervals. /// @{ /** @brief Create an interval that contains only zero. */ - explicit Interval() { _b[0] = 0; _b[1] = 0; } + Interval() {} /** @brief Create an interval that contains a single point. */ - explicit Interval(Coord u) { _b[0] = _b[1] = u; } + explicit Interval(Coord u) : Base(u) {} /** @brief Create an interval that contains all points between @c u and @c v. */ - Interval(Coord u, Coord v) { - if (u <= v) { - _b[0] = u; _b[1] = v; - } else { - _b[0] = v; _b[1] = u; - } - } + Interval(Coord u, Coord v) : Base(u,v) {} + /** @brief Convert from integer interval */ + Interval(IntInterval const &i) : Base(i.min(), i.max()) {} + Interval(Base const &b) : Base(b) {} /** @brief Create an interval containing a range of values. * The resulting interval will contain all values from the given range. @@ -93,9 +90,7 @@ public: * @return Interval that contains all values from [start, end). */ template static Interval from_range(InputIterator start, InputIterator end) { - assert(start != end); - Interval result(*start++); - for (; start != end; ++start) result.expandTo(*start); + Interval result = Base::from_range(start, end); return result; } /** @brief Create an interval from a C-style array of values it should contain. */ @@ -107,114 +102,38 @@ public: /// @name Inspect endpoints. /// @{ + /** @brief Access endpoints by value. + * @deprecated Use min() and max() instead */ Coord operator[](unsigned i) const { return _b[i]; } + /** @brief Access endpoints by reference. + * @deprecated Use min() and max() instead + * @todo Remove Interval index operator, which can be used to break the invariant */ Coord& operator[](unsigned i) { return _b[i]; } - Coord min() const { return _b[0]; } - Coord max() const { return _b[1]; } - Coord extent() const { return _b[1] - _b[0]; } - Coord middle() const { return (_b[1] + _b[0]) * 0.5; } - bool isSingular() const { return _b[0] == _b[1]; } bool isFinite() const { - return IS_FINITE(_b[0]) && IS_FINITE(_b[1]); + return IS_FINITE(min()) && IS_FINITE(max()); } /// @} /// @name Test coordinates and other intervals for inclusion. /// @{ - /** @brief Check whether the interval includes this number. */ - bool contains(Coord val) const { return _b[0] <= val && val <= _b[1]; } /** @brief Check whether the interior of the interval includes this number. * Interior means all numbers in the interval except its ends. */ - bool interiorContains(Coord val) const { return _b[0] < val && val < _b[1]; } - /** @brief Check whether the interval includes the given interval. */ - bool contains(Interval const &val) const { return _b[0] <= val._b[0] && val._b[1] <= _b[1]; } + bool interiorContains(Coord val) const { return min() < val && val < max(); } /** @brief Check whether the interior of the interval includes the given interval. * Interior means all numbers in the interval except its ends. */ - bool interiorContains(Interval const &val) const { return _b[0] < val._b[0] && val._b[1] < _b[1]; } - /** @brief Check whether the intervals have any common elements. */ - bool intersects(Interval const &val) const { - return contains(val._b[0]) || contains(val._b[1]) || val.contains(*this); - } + bool interiorContains(Interval const &val) const { return min() < val.min() && val.max() < max(); } /** @brief Check whether the interiors of the intervals have any common elements. */ bool interiorIntersects(Interval const &val) const { - return interiorContains(val._b[0]) || interiorContains(val._b[1]) || val.interiorContains(*this); - } - /// @} - - /// @name Modify the interval. - /// @{ - //TODO: NaN handleage for the next two? - /** @brief Set the lower boundary of the interval. - * When the given number is larger than the interval's largest element, - * it will be reduced to the single number @c val. */ - void setMin(Coord val) { - if(val > _b[1]) { - _b[0] = _b[1] = val; - } else { - _b[0] = val; - } - } - /** @brief Set the upper boundary of the interval. - * When the given number is smaller than the interval's smallest element, - * it will be reduced to the single number @c val. */ - void setMax(Coord val) { - if(val < _b[0]) { - _b[1] = _b[0] = val; - } else { - _b[1] = val; - } - } - /** @brief Extend the interval to include the given number. */ - void expandTo(Coord val) { - if(val < _b[0]) _b[0] = val; - if(val > _b[1]) _b[1] = val; //no else, as we want to handle NaN - } - /** @brief Expand or shrink the interval in both directions by the given amount. - * After this method, the interval's length (extent) will be increased by - * amount * 2. Negative values can be given; they will shrink the interval. - * Shrinking by a value larger than half the interval's length will create a degenerate - * interval containing only the midpoint of the original. */ - void expandBy(double amount) { - _b[0] -= amount; - _b[1] += amount; - if (_b[0] > _b[1]) { - Coord halfway = (_b[0]+_b[1])/2; - _b[0] = _b[1] = halfway; - } - } - /** @brief Union the interval with another one. - * The resulting interval will contain all points of both intervals. - * It might also contain some points which didn't belong to either - this happens - * when the intervals did not have any common elements. */ - void unionWith(const Interval & a) { - if(a._b[0] < _b[0]) _b[0] = a._b[0]; - if(a._b[1] > _b[1]) _b[1] = a._b[1]; + return interiorContains(val.min()) || interiorContains(val.max()) || val.interiorContains(*this); } /// @} /// @name Operators /// @{ - inline operator OptInterval(); - bool operator==(Interval const &other) const { return _b[0] == other._b[0] && _b[1] == other._b[1]; } - - //IMPL: OffsetableConcept - //TODO: rename output_type to something else in the concept - typedef Coord output_type; - /** @brief Offset the interval by a specified amount */ - Interval &operator+=(Coord amnt) { - _b[0] += amnt; _b[1] += amnt; - return *this; - } - /** @brief Offset the interval by the negation of the specified amount */ - Interval &operator-=(Coord amnt) { - _b[0] -= amnt; _b[1] -= amnt; - return *this; - } + inline operator OptInterval() { return OptInterval(*this); } // IMPL: ScalableConcept - /** @brief Return an interval mirrored about 0 */ - Interval operator-() const { return Interval(-_b[1], -_b[0]); } /** @brief Scale an interval */ Interval &operator*=(Coord s) { _b[0] *= s; @@ -229,25 +148,6 @@ public: if(s < 0) std::swap(_b[0], _b[1]); return *this; } - // IMPL: AddableConcept - /** @brief Add two intervals. - * Sum is defined as the set of points that can be obtained by adding any two values - * from both operands: \f$S = \{x \in A, y \in B: x + y\}\f$ */ - Interval &operator+=(Interval const &o) { - _b[0] += o._b[0]; - _b[1] += o._b[1]; - return *this; - } - /** @brief Subtract two intervals. - * Difference is defined as the set of points that can be obtained by subtracting - * any value from the second operand from any value from the first operand: - * \f$S = \{x \in A, y \in B: x - y\}\f$ */ - Interval &operator-=(Interval const &o) { - // equal to *this += -o - _b[0] -= o._b[1]; - _b[1] -= o._b[0]; - return *this; - } /** @brief Multiply two intervals. * Product is defined as the set of points that can be obtained by multiplying * any value from the second operand by any value from the first operand: @@ -261,121 +161,25 @@ public: expandTo(mx * o.max()); return *this; } - /** @brief Union two intervals. - * Note that intersection is only defined for OptIntervals, because the result - * of an intersection can be empty, while an Interval cannot. */ - Interval &operator|=(Interval const &o) { - unionWith(o); - return *this; - } /// @} -}; - -/** @brief Union two intervals - * @relates Interval */ -inline Interval unify(Interval const &a, Interval const &b) { - return a | b; -} - -/** - * @brief A range of numbers that can be empty. - * @ingroup Primitives - */ -class OptInterval - : public boost::optional - , boost::orable< OptInterval - , boost::andable< OptInterval - > > -{ -public: - /// @name Create optionally empty intervals. + + /// @name Rounding to integer values /// @{ - /** @brief Create an empty interval. */ - OptInterval() : boost::optional() {}; - /** @brief Wrap an existing interval. */ - OptInterval(Interval const &a) : boost::optional(a) {}; - /** @brief Create an interval containing a single point. */ - OptInterval(Coord u) : boost::optional(Interval(u)) {}; - /** @brief Create an interval containing a range of numbers. */ - OptInterval(Coord u, Coord v) : boost::optional(Interval(u,v)) {}; - - /** @brief Create a possibly empty interval containing a range of values. - * The resulting interval will contain all values from the given range. - * The return type of iterators must be convertible to double. The given range - * may be empty. - * @param start Beginning of the range - * @param end End of the range - * @return Interval that contains all values from [start, end), or nothing if the range - * is empty. */ - template - static OptInterval from_range(InputIterator start, InputIterator end) { - if (start == end) { - OptInterval ret; - return ret; - } - OptInterval ret(Interval::from_range(start, end)); + /** @brief Return the smallest integer interval which contains this one. */ + IntInterval roundOutwards() const { + IntInterval ret(floor(min()), ceil(max())); return ret; } - /// @} - - /** @brief Check whether this OptInterval is empty. */ - bool isEmpty() { return !*this; }; - - /** @brief Union with another interval, gracefully handling empty ones. */ - inline void unionWith(OptInterval const &a) { - if (a) { - if (*this) { // check that we are not empty - (*this)->unionWith(*a); - } else { - *this = a; - } - } - } - inline void intersectWith(OptInterval const &o) { - if (o && *this) { - Coord u, v; - u = std::max((*this)->min(), o->min()); - v = std::min((*this)->max(), o->max()); - if (u <= v) { - *this = Interval(u, v); - return; - } - } - (*static_cast*>(this)) = boost::none; - } - OptInterval &operator|=(OptInterval const &o) { - unionWith(o); - return *this; - } - OptInterval &operator&=(OptInterval const &o) { - intersectWith(o); - return *this; + /** @brief Return the largest integer interval which is contained in this one. */ + OptIntInterval roundInwards() const { + IntCoord u = ceil(min()), v = floor(max()); + if (u > v) { OptIntInterval e; return e; } + IntInterval ret(u, v); + return ret; } + /// @} }; -/** @brief Intersect two intervals and return a possibly empty range of numbers - * @relates OptInterval */ -inline OptInterval intersect(Interval const &a, Interval const &b) { - return OptInterval(a) & OptInterval(b); -} -/** @brief Intersect two intervals and return a possibly empty range of numbers - * @relates OptInterval */ -inline OptInterval operator&(Interval const &a, Interval const &b) { - return OptInterval(a) & OptInterval(b); -} - -inline Interval::operator OptInterval() { - return OptInterval(*this); -} - -#ifdef _GLIBCXX_IOSTREAM -inline std::ostream &operator<< (std::ostream &os, - const Geom::Interval &I) { - os << "Interval("< - * - * Copyright ?-? authors - * - * This library is free software; you can redistribute it and/or - * modify it either under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * (the "LGPL") or, at your option, under the terms of the Mozilla - * Public License Version 1.1 (the "MPL"). If you do not alter this - * notice, a recipient may use your version of this file under either - * the MPL or the LGPL. - * - * You should have received a copy of the LGPL along with this library - * in the file COPYING-LGPL-2.1; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * You should have received a copy of the MPL along with this library - * in the file COPYING-MPL-1.1 - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY - * OF ANY KIND, either express or implied. See the LGPL or the MPL for - * the specific language governing rights and limitations. - * - */ - -#ifndef _2GEOM_ISNAN_H__ -#define _2GEOM_ISNAN_H__ - -/* - * Temporary fix for various misdefinitions of isnan(). - * isnan() is becoming undef'd in some .h files. - * #include this last in your .cpp file to get it right. - * - * The problem is that isnan and isfinite are part of C99 but aren't part of - * the C++ standard (which predates C99). - * - * Authors: - * Inkscape groupies and obsessive-compulsives - * - * Copyright (C) 2004 authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - * - * 2005 modification hereby placed in public domain. Probably supercedes - * the 2004 copyright for the code itself. - */ - -#include -/* You might try changing the above to if you have problems. - * Whether you use math.h or cmath, you may need to edit the .cpp file - * and/or other .h files to use the same header file. - */ - -#if defined(__isnan) -# define IS_NAN(_a) (__isnan(_a)) -#elif defined(__APPLE__) && __GNUC__ == 3 -# define IS_NAN(_a) (__isnan(_a)) /* MacOSX/Darwin definition < 10.4 */ -#elif defined(WIN32) || defined(_isnan) -# define IS_NAN(_a) (_isnan(_a)) /* Win32 definition */ -#elif defined(isnan) || defined(__FreeBSD__) || defined(__osf__) -# define IS_NAN(_a) (isnan(_a)) /* GNU definition */ -#elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 -# define IS_NAN(_a) (isnan(_a)) /* GNU definition */ -#else -# define IS_NAN(_a) (std::isnan(_a)) -#endif -/* If the above doesn't work, then try (a != a). - * Also, please report a bug as per http://www.inkscape.org/report_bugs.php, - * giving information about what platform and compiler version you're using. - */ - - -#if defined(__isfinite) -# define IS_FINITE(_a) (__isfinite(_a)) -#elif defined(__APPLE__) && __GNUC__ == 3 -# define IS_FINITE(_a) (__isfinite(_a)) /* MacOSX/Darwin definition < 10.4 */ -#elif defined(__sgi) -# define IS_FINITE(_a) (_isfinite(_a)) -#elif defined(isfinite) -# define IS_FINITE(_a) (isfinite(_a)) -#elif defined(__osf__) -# define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a)) -#elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 -#include -#define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a)) -#else -# define IS_FINITE(_a) (std::isfinite(_a)) -#endif -/* If the above doesn't work, then try (finite(_a) && !IS_NAN(_a)) or - * (!IS_NAN((_a) - (_a))). - * Also, please report a bug as per http://www.inkscape.org/report_bugs.php, - * giving information about what platform and compiler version you're using. - */ - - -#endif /* _2GEOM_ISNAN_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/line.h b/src/2geom/line.h index ccb0ae6c5..f2d31ecc6 100644 --- a/src/2geom/line.h +++ b/src/2geom/line.h @@ -1,8 +1,11 @@ /** * \file - * \brief Infinite Straight Line - * - * Copyright 2008 Marco Cecchetti + * \brief Infinite straight line + *//* + * Authors: + * Marco Cecchetti + * Krzysztof Kosiński + * Copyright 2008-2011 Authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -28,22 +31,17 @@ * the specific language governing rights and limitations. */ -#ifndef _2GEOM_LINE_H_ -#define _2GEOM_LINE_H_ - +#ifndef LIB2GEOM_SEEN_LINE_H +#define LIB2GEOM_SEEN_LINE_H #include - +#include #include <2geom/bezier-curve.h> // for LineSegment #include <2geom/rect.h> #include <2geom/crossing.h> #include <2geom/exception.h> - #include <2geom/ray.h> -#include - - namespace Geom { @@ -226,8 +224,8 @@ public: * @return Ray starting at t and going in the direction of the versor */ Ray ray(Coord t) { Ray result; - result.origin(pointAt(t)); - result.versor(m_versor); + result.setOrigin(pointAt(t)); + result.setVersor(m_versor); return result; } @@ -448,17 +446,16 @@ OptCrossing intersection(LineSegment const& ls1, LineSegment const& ls2); } // end namespace Geom -#endif // _2GEOM_LINE_H_ +#endif // LIB2GEOM_SEEN_LINE_H /* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(substatement-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil - c-brace-offset:0 fill-column:99 End: - vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : */ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/linear.h b/src/2geom/linear.h index 1b6cca071..df6dd9904 100644 --- a/src/2geom/linear.h +++ b/src/2geom/linear.h @@ -35,7 +35,7 @@ #ifndef SEEN_LINEAR_H #define SEEN_LINEAR_H #include <2geom/interval.h> -#include <2geom/isnan.h> +#include <2geom/math-utils.h> //#define USE_SBASIS_OF diff --git a/src/2geom/math-utils.h b/src/2geom/math-utils.h index 2c348f54b..77280aa50 100644 --- a/src/2geom/math-utils.h +++ b/src/2geom/math-utils.h @@ -1,6 +1,3 @@ -#ifndef LIB2GEOM_MATH_UTILS_HEADER -#define LIB2GEOM_MATH_UTILS_HEADER - /** * \file * \brief Low level math functions and compatibility wrappers @@ -36,6 +33,9 @@ * */ +#ifndef LIB2GEOM_SEEN_MATH_UTILS_H +#define LIB2GEOM_SEEN_MATH_UTILS_H + #include "config.h" #include // sincos is usually only available in math.h #include @@ -92,10 +92,51 @@ inline void sincos(double angle, double &sin_, double &cos_) { #endif } -} +/* Temporary fix for various misdefinitions of isnan(). + * isnan() is becoming undef'd in some .h files. + * #include this last in your .cpp file to get it right. + * + * The problem is that isnan and isfinite are part of C99 but aren't part of + * the C++ standard (which predates C99). + */ + +#if defined(__isnan) +# define IS_NAN(_a) (__isnan(_a)) +#elif defined(__APPLE__) && __GNUC__ == 3 +# define IS_NAN(_a) (__isnan(_a)) /* MacOSX/Darwin definition < 10.4 */ +#elif defined(WIN32) || defined(_isnan) +# define IS_NAN(_a) (_isnan(_a)) /* Win32 definition */ +#elif defined(isnan) || defined(__FreeBSD__) || defined(__osf__) +# define IS_NAN(_a) (isnan(_a)) /* GNU definition */ +#elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 +# define IS_NAN(_a) (isnan(_a)) /* GNU definition */ +#else +# define IS_NAN(_a) (std::isnan(_a)) +#endif +/* If the above doesn't work, then try (a != a). */ + +#if defined(__isfinite) +# define IS_FINITE(_a) (__isfinite(_a)) +#elif defined(__APPLE__) && __GNUC__ == 3 +# define IS_FINITE(_a) (__isfinite(_a)) /* MacOSX/Darwin definition < 10.4 */ +#elif defined(__sgi) +# define IS_FINITE(_a) (_isfinite(_a)) +#elif defined(isfinite) +# define IS_FINITE(_a) (isfinite(_a)) +#elif defined(__osf__) +# define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a)) +#elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 +#include +#define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a)) +#else +# define IS_FINITE(_a) (std::isfinite(_a)) #endif +} // end namespace Geom + +#endif // LIB2GEOM_SEEN_MATH_UTILS_H + /* Local Variables: mode:c++ diff --git a/src/2geom/ord.h b/src/2geom/ord.h index ca91af579..ce524ebf7 100644 --- a/src/2geom/ord.h +++ b/src/2geom/ord.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Comparator template + *//* * Authors: * ? * diff --git a/src/2geom/path-intersection.h b/src/2geom/path-intersection.h index de2a5b02c..2470e44fb 100644 --- a/src/2geom/path-intersection.h +++ b/src/2geom/path-intersection.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Path intersection + *//* * Authors: * ? * diff --git a/src/2geom/path.h b/src/2geom/path.h index cbd449248..48d7acaaf 100644 --- a/src/2geom/path.h +++ b/src/2geom/path.h @@ -1,12 +1,12 @@ /** * \file * \brief Path - Series of continuous curves - * + *//* * Authors: - * MenTaLguY - * Marco Cecchetti + * MenTaLguY + * Marco Cecchetti * - * Copyright 2007-2008 authors + * Copyright 2007-2008 Authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -32,23 +32,16 @@ * the specific language governing rights and limitations. */ +#ifndef LIB2GEOM_SEEN_PATH_H +#define LIB2GEOM_SEEN_PATH_H - - -#ifndef SEEN_GEOM_PATH_H -#define SEEN_GEOM_PATH_H - - +#include +#include #include #include <2geom/curve.h> #include <2geom/bezier-curve.h> -#include -#include - - -namespace Geom -{ +namespace Geom { class Path; @@ -696,17 +689,13 @@ Coord nearest_point(Point const& p, Path const& c) namespace std { template <> -inline void swap(Geom::Path &a, Geom::Path &b) -{ +inline void swap(Geom::Path &a, Geom::Path &b) { a.swap(b); } } // end namespace std -#endif // SEEN_GEOM_PATH_H - - - +#endif // LIB2GEOM_SEEN_PATH_H /* Local Variables: diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h index 2f45b9d86..2b690a005 100644 --- a/src/2geom/pathvector.h +++ b/src/2geom/pathvector.h @@ -1,10 +1,9 @@ /** * \file - * \brief PathVector - std::vector containing Geom::Path + * \brief PathVector - std::vector containing Geom::Path. * This file provides a set of operations that can be performed on PathVector, * e.g. an affine transform. - */ -/* + *//* * Authors: * Johan Engelen * @@ -34,8 +33,8 @@ * the specific language governing rights and limitations. */ -#ifndef SEEN_GEOM_PATHVECTOR_H -#define SEEN_GEOM_PATHVECTOR_H +#ifndef LIB2GEOM_SEEN_PATHVECTOR_H +#define LIB2GEOM_SEEN_PATHVECTOR_H #include <2geom/forward.h> #include <2geom/path.h> @@ -122,11 +121,9 @@ Point pointAt(PathVector const & path_in, PathVectorPosition const pvp) { return path_in[pvp.path_nr].pointAt(pvp.t); } - - } // end namespace Geom -#endif // SEEN_GEOM_PATHVECTOR_H +#endif // LIB2GEOM_SEEN_PATHVECTOR_H /* Local Variables: diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index 19c66d8f0..837f33ea7 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -32,13 +32,13 @@ #ifndef SEEN_GEOM_PW_SB_H #define SEEN_GEOM_PW_SB_H -#include <2geom/sbasis.h> #include #include - -#include <2geom/concepts.h> -#include <2geom/isnan.h> #include +#include <2geom/concepts.h> +#include <2geom/math-utils.h> +#include <2geom/sbasis.h> + namespace Geom { /** diff --git a/src/2geom/point.cpp b/src/2geom/point.cpp index a9005ef61..cafc0fdba 100644 --- a/src/2geom/point.cpp +++ b/src/2geom/point.cpp @@ -1,3 +1,38 @@ +/** + * \file + * \brief Cartesian point / 2D vector and related operations + *//* + * Authors: + * Michael G. Sloan + * Nathan Hurst + * Krzysztof Kosiński + * + * Copyright (C) 2006-2009 Authors + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + #include #include #include <2geom/point.h> @@ -14,8 +49,8 @@ namespace Geom { * from the origin (point at 0,0) to the stored coordinates, * and has methods implementing several vector operations (like length()). * - * \par Operator note - * \par + * @par Operator note + * @par * Most operators are provided by Boost operator helpers, so they are not visible in this class. * If @a p, @a q, @a r denote points, @a s a floating-point scalar, and @a m a transformation matrix, * then the following operations are available: @@ -149,12 +184,11 @@ Point unit_vector(Point const &a) * that the origin (0, 0), its negation is returned. You can check whether * the points' vectors have the same direction (e.g. lie * on the same line passing through the origin) using - * @code abs(a).normalize() == abs(b).normalize() @endcode. + * @code abs(a).normalize() == abs(b).normalize() @endcode * To check with some margin of error, use - * @code are_near(abs(a).normalize(), abs(b).normalize()) @endcode. + * @code are_near(abs(a).normalize(), abs(b).normalize()) @endcode * Although naively this should take the absolute value of each coordinate, such an operation * is not very useful. - * @return \f$p' = (p_X, -p_Y)\f$ * @relates Point */ Point abs(Point const &b) { @@ -178,8 +212,8 @@ Point &Point::operator*=(Affine const &m) { return *this; } -/** @brief Snap the angle B - A - dir to miltiples of \f$2\pi/n\f$. - * The 'dir' argument must be normalized (have an unit length), otherwise the result +/** @brief Snap the angle B - A - dir to multiples of \f$2\pi/n\f$. + * The 'dir' argument must be normalized (have unit length), otherwise the result * is undefined. * @return Point with the same distance from A as B, with a snapped angle. * @post distance(A, B) == distance(A, result) diff --git a/src/2geom/point.h b/src/2geom/point.h index 3c6e12eff..69da8a4ae 100644 --- a/src/2geom/point.h +++ b/src/2geom/point.h @@ -42,7 +42,7 @@ #include #include <2geom/forward.h> #include <2geom/coord.h> -#include <2geom/isnan.h> //temporary fix for isnan() +#include <2geom/int-point.h> #include <2geom/math-utils.h> #include <2geom/utils.h> @@ -61,8 +61,9 @@ class Point > > > > > > > > > // this uses chaining so it looks weird, but works { Coord _pt[2]; - public: + /// @name Create points + /// @{ /** Construct a point on the origin. */ Point() { _pt[X] = _pt[Y] = 0; } @@ -71,6 +72,11 @@ public: Point(Coord x, Coord y) { _pt[X] = x; _pt[Y] = y; } + /** Construct from integer point. */ + Point(IntPoint const &p) { + _pt[X] = p[X]; + _pt[Y] = p[Y]; + } Point(Point const &p) { for (unsigned i = 0; i < 2; ++i) _pt[i] = p._pt[i]; @@ -80,6 +86,23 @@ public: _pt[i] = p._pt[i]; return *this; } + /** @brief Construct a point from its polar coordinates. + * The angle is specified in radians, in the mathematical convention (increasing + * counter-clockwise from +X). */ + static Point polar(Coord angle, Coord radius) { + Point ret(polar(angle)); + ret *= radius; + return ret; + } + /** @brief Construct an unit vector from its angle. + * The angle is specified in radians, in the mathematical convention (increasing + * counter-clockwise from +X). */ + static Point polar(Coord angle) { + Point ret; + sincos(angle, ret[Y], ret[X]); + return ret; + } + /// @} /// @name Access the coordinates of a point /// @{ @@ -157,57 +180,54 @@ public: } /// @} - /// @name Various utilities + /// @name Conversion to integer points /// @{ - /** @brief Lower the precision of the point. - * This will round both coordinates to multiples of \f$10^p\f$. */ - void round (int p = 0) { - _pt[X] = (Coord)(decimal_round((double)_pt[X], p)); - _pt[Y] = (Coord)(decimal_round((double)_pt[Y], p)); - return; + /** @brief Round to nearest integer coordinates. */ + IntPoint round() const { + IntPoint ret(::round(_pt[X]), ::round(_pt[Y])); + return ret; + } + /** @brief Round coordinates downwards. */ + IntPoint floor() const { + IntPoint ret(::floor(_pt[X]), ::floor(_pt[Y])); + return ret; + } + /** @brief Round coordinates upwards. */ + IntPoint ceil() const { + IntPoint ret(::ceil(_pt[X]), ::ceil(_pt[Y])); + return ret; } + /// @} - /** @brief Check whether both coordinates are finite. - * @return True if neither coordinate is infinite. */ + /// @name Various utilities + /// @{ + /** @brief Check whether both coordinates are finite. */ bool isFinite() const { for ( unsigned i = 0 ; i < 2 ; ++i ) { if(!IS_FINITE(_pt[i])) return false; } return true; } + /** @brief Check whether both coordinates are zero. */ + bool isZero() const { + return _pt[X] == 0 && _pt[Y] == 0; + } + /** @brief Check whether the length of the vector is close to 1. */ + bool isNormalized(Coord eps=EPSILON) const { + return are_near(length(), 1.0, eps); + } /** @brief Equality operator. * This tests for exact identity (as opposed to are_near()). Note that due to numerical * errors, this test might return false even if the points should be identical. */ bool operator==(const Point &in_pnt) const { - return ((_pt[X] == in_pnt[X]) && (_pt[Y] == in_pnt[Y])); + return (_pt[X] == in_pnt[X]) && (_pt[Y] == in_pnt[Y]); } /** @brief Lexicographical ordering for points. * Y coordinate is regarded as more significant. When sorting according to this * ordering, the points will be sorted according to the Y coordinate, and within * points with the same Y coordinate according to the X coordinate. */ bool operator<(const Point &p) const { - return ( ( _pt[Y] < p[Y] ) || - (( _pt[Y] == p[Y] ) && ( _pt[X] < p[X] ))); - } - /// @} - - /// @name Point factories - /// @{ - /** @brief Construct a point from its polar coordinates. - * The angle is specified in radians, in the mathematical convention (increasing - * counter-clockwise from +X). */ - static Point polar(Coord angle, Coord radius) { - Point ret(polar(angle)); - ret *= radius; - return ret; - } - /** @brief Construct an unit vector from its angle. - * The angle is specified in radians, in the mathematical convention (increasing - * counter-clockwise from +X). */ - static Point polar(Coord angle) { - Point ret; - sincos(angle, ret[Y], ret[X]); - return ret; + return _pt[Y] < p[Y] || (_pt[Y] == p[Y] && _pt[X] < p[X]); } /// @} @@ -315,7 +335,7 @@ inline Point lerp(double const t, Point const &a, Point const &b) * For perpendicular vectors, it is zero. For parallel ones, its absolute value is highest, * and the sign depends on whether they point in the same direction (+) or opposite ones (-). * @return \f$a \cdot b = a_X b_X + a_Y b_Y\f$. - * @relates Point*/ + * @relates Point */ inline Coord dot(Point const &a, Point const &b) { return a[0] * b[0] + a[1] * b[1]; @@ -349,8 +369,8 @@ Coord L1(Point const &p); Coord LInfty(Point const &p); bool is_zero(Point const &p); bool is_unit_vector(Point const &p); -extern double atan2(Point const &p); -extern double angle_between(Point const &a, Point const &b); +double atan2(Point const &p); +double angle_between(Point const &a, Point const &b); Point abs(Point const &b); Point constrain_angle(Point const &A, Point const &B, unsigned int n = 4, Geom::Point const &dir = Geom::Point(1,0)); diff --git a/src/2geom/poly.h b/src/2geom/poly.h index 3567bda6d..7d93d0a85 100644 --- a/src/2geom/poly.h +++ b/src/2geom/poly.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Polynomial in canonical (monomial) basis + *//* * Authors: * ? * @@ -34,7 +34,6 @@ #ifndef LIB2GEOM_SEEN_POLY_H #define LIB2GEOM_SEEN_POLY_H - #include #include #include diff --git a/src/2geom/quadtree.h b/src/2geom/quadtree.h index 01ea33ed7..949a9b898 100644 --- a/src/2geom/quadtree.h +++ b/src/2geom/quadtree.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Quad tree data structure + *//* * Authors: * ? * diff --git a/src/2geom/ray.h b/src/2geom/ray.h index 638b86195..75cc72005 100644 --- a/src/2geom/ray.h +++ b/src/2geom/ray.h @@ -1,7 +1,7 @@ /** * \file - * \brief Infinite Straight Ray - * + * \brief Infinite straight ray + *//* * Copyright 2008 Marco Cecchetti * * This library is free software; you can redistribute it and/or @@ -35,6 +35,7 @@ #include <2geom/point.h> #include <2geom/bezier-curve.h> // for LineSegment #include <2geom/exception.h> +#include <2geom/math-utils.h> namespace Geom { @@ -49,171 +50,88 @@ namespace Geom */ class Ray { private: - Point m_origin; - Point m_versor; + Point _origin; + Point _versor; public: - Ray() - : m_origin(0,0), m_versor(1,0) - { - } - - Ray(Point const& _origin, Coord angle ) - : m_origin(_origin), m_versor(std::cos(angle), std::sin(angle)) - { - } - - Ray(Point const& A, Point const& B) - { - setBy2Points(A, B); - } - - Point origin() const - { - return m_origin; - } - - Point versor() const - { - return m_versor; - } - - void origin(Point const& _point) - { - m_origin = _point; - } - - void versor(Point const& _versor) - { - m_versor = _versor; - } - - Coord angle() const - { - double a = std::atan2(m_versor[Y], m_versor[X]); - if (a < 0) a += 2*M_PI; - return a; - } - - void angle(Coord _angle) - { - m_versor[X] = std::cos(_angle); - m_versor[Y] = std::sin(_angle); - } - - void setBy2Points(Point const& A, Point const& B) - { - m_origin = A; - m_versor = B - A; - if ( are_near(m_versor, Point(0,0)) ) - m_versor = Point(0,0); - else - m_versor.normalize(); - } - - bool isDegenerate() const - { - return ( m_versor[X] == 0 && m_versor[Y] == 0 ); - } - - Point pointAt(Coord t) const - { - if (t < 0) THROW_RANGEERROR("Ray::pointAt, negative t value passed"); - return m_origin + m_versor * t; - } - - Coord valueAt(Coord t, Dim2 d) const - { - if (t < 0) - THROW_RANGEERROR("Ray::valueAt, negative t value passed"); - if (d < 0 || d > 1) - THROW_RANGEERROR("Ray::valueAt, dimension argument out of range"); - return m_origin[d] + m_versor[d] * t; - } - - std::vector roots(Coord v, Dim2 d) const - { - if (d < 0 || d > 1) - THROW_RANGEERROR("Ray::roots, dimension argument out of range"); - std::vector result; - if ( m_versor[d] != 0 ) - { - double t = (v - m_origin[d]) / m_versor[d]; - if (t >= 0) result.push_back(t); - } - // TODO: else ? - return result; - } - - // require are_near(_point, *this) - // on the contrary the result value is meaningless - Coord timeAt(Point const& _point) const - { - Coord t; - if ( m_versor[X] != 0 ) - { - t = (_point[X] - m_origin[X]) / m_versor[X]; - } - else if ( m_versor[Y] != 0 ) - { - t = (_point[Y] - m_origin[Y]) / m_versor[Y]; - } - else // degenerate case - { - t = 0; - } - return t; - } - - Coord nearestPoint(Point const& _point) const - { - if ( isDegenerate() ) return 0; - double t = dot( _point - m_origin, m_versor ); - if (t < 0) t = 0; - return t; - } - - Ray reverse() const - { - Ray result; - result.origin(m_origin); - result.versor(-m_versor); - return result; - } - - Curve* portion(Coord f, Coord t) const - { - LineSegment* seg = new LineSegment(pointAt(f), pointAt(t)); - return seg; - } - - LineSegment segment(Coord f, Coord t) const - { - return LineSegment(pointAt(f), pointAt(t)); - } - - Ray transformed(Affine const& m) const - { - return Ray(m_origin * m, (m_origin + m_versor) * m); - } -}; // end class ray + Ray() : _origin(0,0), _versor(1,0) {} + Ray(Point const& origin, Coord angle) + : _origin(origin) + { + sincos(angle, _versor[Y], _versor[X]); + } + Ray(Point const& A, Point const& B) { + setPoints(A, B); + } + Point origin() const { return _origin; } + Point versor() const { return _versor; } + void setOrigin(Point const &o) { _origin = o; } + void setVersor(Point const& v) { _versor = v; } + Coord angle() const { return std::atan2(_versor[Y], _versor[X]); } + void setAngle(Coord a) { sincos(a, _versor[Y], _versor[X]); } + void setPoints(Point const &a, Point const &b) { + _origin = a; + _versor = b - a; + if (are_near(_versor, Point(0,0)) ) + _versor = Point(0,0); + else + _versor.normalize(); + } + bool isDegenerate() const { + return ( _versor[X] == 0 && _versor[Y] == 0 ); + } + Point pointAt(Coord t) const { + return _origin + _versor * t; + } + Coord valueAt(Coord t, Dim2 d) const { + return _origin[d] + _versor[d] * t; + } + std::vector roots(Coord v, Dim2 d) const { + std::vector result; + if ( _versor[d] != 0 ) { + double t = (v - _origin[d]) / _versor[d]; + if (t >= 0) result.push_back(t); + } else if (_versor[(d+1)%2] == v) { + THROW_INFINITESOLUTIONS(); + } + return result; + } + Coord nearestPoint(Point const& point) const { + if ( isDegenerate() ) return 0; + double t = dot(point - _origin, _versor); + if (t < 0) t = 0; + return t; + } + Ray reverse() const { + Ray result; + result.setOrigin(_origin); + result.setVersor(-_versor); + return result; + } + Curve *portion(Coord f, Coord t) const { + return new LineSegment(pointAt(f), pointAt(t)); + } + LineSegment segment(Coord f, Coord t) const { + return LineSegment(pointAt(f), pointAt(t)); + } + Ray transformed(Affine const& m) const { + return Ray(_origin * m, (_origin + _versor) * m); + } +}; // end class Ray inline -double distance(Point const& _point, Ray const& _ray) -{ +double distance(Point const& _point, Ray const& _ray) { double t = _ray.nearestPoint(_point); return ::Geom::distance(_point, _ray.pointAt(t)); } inline -bool are_near(Point const& _point, Ray const& _ray, double eps = EPSILON) -{ +bool are_near(Point const& _point, Ray const& _ray, double eps = EPSILON) { return are_near(distance(_point, _ray), 0, eps); } inline -bool are_same(Ray const& r1, Ray const& r2, double eps = EPSILON) -{ +bool are_same(Ray const& r1, Ray const& r2, double eps = EPSILON) { return are_near(r1.versor(), r2.versor(), eps) && are_near(r1.origin(), r2.origin(), eps); } @@ -221,15 +139,13 @@ bool are_same(Ray const& r1, Ray const& r2, double eps = EPSILON) // evaluate the angle between r1 and r2 rotating r1 in cw or ccw direction on r2 // the returned value is an angle in the interval [0, 2PI[ inline -double angle_between(Ray const& r1, Ray const& r2, bool cw = true) -{ +double angle_between(Ray const& r1, Ray const& r2, bool cw = true) { double angle = angle_between(r1.versor(), r2.versor()); if (angle < 0) angle += 2*M_PI; if (!cw) angle = 2*M_PI - angle; return angle; } - inline Ray make_angle_bisector_ray(Ray const& r1, Ray const& r2) { @@ -243,22 +159,17 @@ Ray make_angle_bisector_ray(Ray const& r1, Ray const& r2) return Ray(r1.origin(), M); } - } // end namespace Geom - - -#endif /*_2GEOM_RAY_H_*/ - +#endif // LIB2GEOM_SEEN_RAY_H /* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(substatement-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil - c-brace-offset:0 fill-column:99 End: - vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : */ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/rect.cpp b/src/2geom/rect.cpp new file mode 100644 index 000000000..0cb842d29 --- /dev/null +++ b/src/2geom/rect.cpp @@ -0,0 +1,98 @@ +/* Axis-aligned rectangle + * + * Authors: + * Michael Sloan + * Krzysztof Kosiński + * Copyright 2007-2011 Authors + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#include <2geom/rect.h> + +namespace Geom { + +/** @brief Transform the rectangle by an affine. + * The result of the transformation might not be axis-aligned. The return value + * of this operation will be the smallest axis-aligned rectangle containing + * all points of the true result. */ +Rect &Rect::operator*=(Affine const &m) { + Point pts[4]; + for (unsigned i=0; i<4; ++i) pts[i] = corner(i) * m; + Coord minx = std::min(std::min(pts[0][X], pts[1][X]), std::min(pts[2][X], pts[3][X])); + Coord miny = std::min(std::min(pts[0][Y], pts[1][Y]), std::min(pts[2][Y], pts[3][Y])); + Coord maxx = std::max(std::max(pts[0][X], pts[1][X]), std::max(pts[2][X], pts[3][X])); + Coord maxy = std::max(std::max(pts[0][Y], pts[1][Y]), std::max(pts[2][Y], pts[3][Y])); + f[X].setMin(minx); f[X].setMax(maxx); + f[Y].setMin(miny); f[Y].setMax(maxy); + return *this; +} + +Coord distanceSq(Point const &p, Rect const &rect) +{ + double dx = 0, dy = 0; + if ( p[X] < rect.left() ) { + dx = p[X] - rect.left(); + } else if ( p[X] > rect.right() ) { + dx = rect.right() - p[X]; + } + if (p[Y] < rect.top() ) { + dy = rect.top() - p[Y]; + } else if ( p[Y] > rect.bottom() ) { + dy = p[Y] - rect.bottom(); + } + return dx*dx+dy*dy; +} + +/** @brief Returns the smallest distance between p and rect. + * @relates Rect */ +Coord distance(Point const &p, Rect const &rect) +{ + // copy of distanceSq, because we need to use hypot() + double dx = 0, dy = 0; + if ( p[X] < rect.left() ) { + dx = p[X] - rect.left(); + } else if ( p[X] > rect.right() ) { + dx = rect.right() - p[X]; + } + if (p[Y] < rect.top() ) { + dy = rect.top() - p[Y]; + } else if ( p[Y] > rect.bottom() ) { + dy = p[Y] - rect.bottom(); + } + return hypot(dx, dy); +} + +} // namespace Geom + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/2geom/rect.h b/src/2geom/rect.h index 65bb1bb76..72b659a81 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -2,7 +2,10 @@ * \file * \brief Axis-aligned rectangle *//* - * Copyright 2007 Michael Sloan + * Authors: + * Michael Sloan + * Krzysztof Kosiński + * Copyright 2007-2011 Authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -34,48 +37,41 @@ * MenTaLguY */ -#include <2geom/d2.h> - -#ifndef LIB2GEOM_RECT_H -#define LIB2GEOM_RECT_H +#ifndef LIB2GEOM_SEEN_RECT_H +#define LIB2GEOM_SEEN_RECT_H +#include #include <2geom/affine.h> -#include +#include <2geom/interval.h> +#include <2geom/int-rect.h> namespace Geom { /** - * @brief Axis-aligned, non-empty rectangle - convenience typedef + * @brief Axis-aligned rectangle that can be empty. * @ingroup Primitives */ -typedef D2 Rect; -class OptRect; - -inline Rect unify(Rect const &, Rect const &); +typedef GenericOptRect OptRect; /** * @brief Axis aligned, non-empty rectangle. * @ingroup Primitives */ -template<> -class D2 { -private: - Interval f[2]; +class Rect + : public GenericRect + , boost::multipliable< Rect, Affine > +{ + typedef GenericRect Base; public: /// @name Create rectangles. /// @{ /** @brief Create a rectangle that contains only the point at (0,0). */ - D2() { f[X] = f[Y] = Interval(); } + Rect() {} /** @brief Create a rectangle from X and Y intervals. */ - D2(Interval const &a, Interval const &b) { - f[X] = a; - f[Y] = b; - } + Rect(Interval const &a, Interval const &b) : Base(a,b) {} /** @brief Create a rectangle from two points. */ - D2(Point const & a, Point const & b) { - f[X] = Interval(a[X], b[X]); - f[Y] = Interval(a[Y], b[Y]); - } + Rect(Point const &a, Point const &b) : Base(a,b) {} + Rect(Base const &b) : Base(b) {} /** @brief Create a rectangle from a range of points. * The resulting rectangle will contain all ponts from the range. * The return type of iterators must be convertible to Point. @@ -85,12 +81,7 @@ public: * @return Rectangle that contains all points from [start, end). */ template static Rect from_range(InputIterator start, InputIterator end) { - assert(start != end); - Point p1 = *start++; - Rect result(p1, p1); - for (; start != end; ++start) { - result.expandTo(*start); - } + Rect result = Base::from_range(start, end); return result; } /** @brief Create a rectangle from a C-style array of points it should contain. */ @@ -102,260 +93,85 @@ public: /// @name Inspect dimensions. /// @{ - Interval& operator[](unsigned i) { return f[i]; } - Interval const & operator[](unsigned i) const { return f[i]; } - - Point min() const { return Point(f[X].min(), f[Y].min()); } - Point max() const { return Point(f[X].max(), f[Y].max()); } - /** @brief Return the n-th corner of the rectangle. - * If the Y axis grows upwards, this returns corners in clockwise order - * starting from the lower left. If Y grows downwards, it returns the corners - * in counter-clockwise order starting from the upper left. */ - Point corner(unsigned i) const { - switch(i % 4) { - case 0: return Point(f[X].min(), f[Y].min()); - case 1: return Point(f[X].max(), f[Y].min()); - case 2: return Point(f[X].max(), f[Y].max()); - default: return Point(f[X].min(), f[Y].max()); - } - } - - //We should probably remove these - they're coord sys gnostic - /** @brief Return top coordinate of the rectangle (+Y is downwards). */ - Coord top() const { return f[Y].min(); } - /** @brief Return bottom coordinate of the rectangle (+Y is downwards). */ - Coord bottom() const { return f[Y].max(); } - /** @brief Return leftmost coordinate of the rectangle (+X is to the right). */ - Coord left() const { return f[X].min(); } - /** @brief Return rightmost coordinate of the rectangle (+X is to the right). */ - Coord right() const { return f[X].max(); } - - Coord width() const { return f[X].extent(); } - Coord height() const { return f[Y].extent(); } - - /** @brief Get rectangle's width and height as a point. - * @return Point with X coordinate corresponding to the width and the Y coordinate - * corresponding to the height of the rectangle. */ - Point dimensions() const { return Point(f[X].extent(), f[Y].extent()); } - Point midpoint() const { return Point(f[X].middle(), f[Y].middle()); } - -/** - * \brief Compute the area of this rectangle. - * - * Note that a zero area rectangle is not empty - just as the interval [0,0] contains one point, the rectangle [0,0] x [0,0] contains 1 point and no area. - * \retval For a valid return value, the rect must be tested for emptyness first. - */ - /** @brief Compute rectangle's area. */ - Coord area() const { return f[X].extent() * f[Y].extent(); } /** @brief Check whether the rectangle has zero area up to specified tolerance. * @param eps Maximum value of the area to consider empty * @return True if rectangle has an area smaller than tolerance, false otherwise */ - bool hasZeroArea(double eps = EPSILON) const { return (area() <= eps); } - - /** @brief Get the larger extent (width or height) of the rectangle. */ - Coord maxExtent() const { return std::max(f[X].extent(), f[Y].extent()); } - /** @brief Get the smaller extent (width or height) of the rectangle. */ - Coord minExtent() const { return std::min(f[X].extent(), f[Y].extent()); } + bool hasZeroArea(Coord eps = EPSILON) const { return (area() <= eps); } /// @} /// @name Test other rectangles and points for inclusion. /// @{ - /** @brief Check whether the rectangles have any common points. */ - bool intersects(Rect const &r) const { - return f[X].intersects(r[X]) && f[Y].intersects(r[Y]); - } /** @brief Check whether the interiors of the rectangles have any common points. */ bool interiorIntersects(Rect const &r) const { return f[X].interiorIntersects(r[X]) && f[Y].interiorIntersects(r[Y]); } - /** @brief Check whether the rectangle includes all points in the given rectangle. */ - bool contains(Rect const &r) const { - return f[X].contains(r[X]) && f[Y].contains(r[Y]); - } /** @brief Check whether the interior includes all points in the given rectangle. * Interior of the rectangle is the entire rectangle without its borders. */ bool interiorContains(Rect const &r) const { return f[X].interiorContains(r[X]) && f[Y].interiorContains(r[Y]); } - - /** @brief Check whether the rectangles have any common points. - * A non-empty rectangle will not intersect empty rectangles. */ - inline bool intersects(OptRect const &r) const; - /** @brief Check whether the rectangle includes all points in the given rectangle. - * A non-empty rectangle will contain any empty rectangle. */ - inline bool contains(OptRect const &r) const; - /** @brief Check whether the interior includes all points in the given rectangle. - * The interior of a non-empty rectangle will contain any empty rectangle. */ inline bool interiorContains(OptRect const &r) const; + /// @} - /** @brief Check whether the given point is within the rectangle. */ - bool contains(Point const &p) const { - return f[X].contains(p[X]) && f[Y].contains(p[Y]); + /// @name Rounding to integer coordinates + /// @{ + /** @brief Return the smallest integer rectangle which contains this one. */ + IntRect roundOutwards() const { + IntRect ir(f[X].roundOutwards(), f[Y].roundOutwards()); + return ir; } - /** @brief Check whether the given point is in the rectangle's interior. - * This means the point must lie within the rectangle but not on its border. */ - bool interiorContains(Point const &p) const { - return f[X].interiorContains(p[X]) && f[Y].interiorContains(p[Y]); + /** @brief Return the largest integer rectangle which is contained in this one. */ + OptIntRect roundInwards() const { + OptIntRect oir(f[X].roundInwards(), f[Y].roundInwards()); + return oir; } /// @} - /// @name Modify the rectangle. + /// @name Operators /// @{ - /** @brief Enlarge the rectangle to contain the given point. */ - void expandTo(Point p) { - f[X].expandTo(p[X]); f[Y].expandTo(p[Y]); - } - /** @brief Enlarge the rectangle to contain the given rectangle. */ - void unionWith(Rect const &b) { - f[X].unionWith(b[X]); f[Y].unionWith(b[Y]); - } - /** @brief Enlarge the rectangle to contain the given rectangle. - * Unioning with an empty rectangle results in no changes. */ - void unionWith(OptRect const &b); - - //TODO: figure out how these work with negative values and OptRect - /** @brief Expand the rectangle in both directions by the specified amount. - * Note that this is different from scaling. Negative values wil shrink the - * rectangle. If -amount is larger than - * half of the width, the X interval will contain only the X coordinate - * of the midpoint; same for height. */ - void expandBy(Coord amount) { - f[X].expandBy(amount); f[Y].expandBy(amount); - } - /** @brief Expand the rectangle by the coordinates of the given point. - * This will expand the width by the X coordinate of the point in both directions - * and the height by Y coordinate of the point. Negative coordinate values will - * shrink the rectangle. If -p[X] is larger than half of the width, - * the X interval will contain only the X coordinate of the midpoint; same for height. */ - void expandBy(Point const p) { - f[X].expandBy(p[X]); f[Y].expandBy(p[Y]); - } + Rect &operator*=(Affine const &m); /// @} }; -inline Rect unify(Rect const & a, Rect const & b) { - return Rect(unify(a[X], b[X]), unify(a[Y], b[Y])); +Coord distanceSq(Point const &p, Rect const &rect); +Coord distance(Point const &p, Rect const &rect); + +inline bool Rect::interiorContains(OptRect const &r) const { + return !r || interiorContains(static_cast(*r)); } -inline Rect union_list(std::vector const &r) { - if(r.empty()) return Rect(Interval(0,0), Interval(0,0)); - Rect ret = r[0]; - for(unsigned i = 1; i < r.size(); i++) - ret.unionWith(r[i]); +// the functions below do not work when defined generically +inline OptRect operator&(Rect const &a, Rect const &b) { + OptRect ret(a); + ret.intersectWith(b); return ret; } - -inline -Coord distanceSq( Point const& p, Rect const& rect ) -{ - double dx = 0, dy = 0; - if ( p[X] < rect.left() ) - { - dx = p[X] - rect.left(); - } - else if ( p[X] > rect.right() ) - { - dx = rect.right() - p[X]; - } - if ( p[Y] < rect.top() ) - { - dy = rect.top() - p[Y]; - } - else if ( p[Y] > rect.bottom() ) - { - dy = p[Y] - rect.bottom(); - } - return dx*dx + dy*dy; +inline OptRect intersect(Rect const &a, Rect const &b) { + return a & b; } - -/** - * Returns the smallest distance between p and rect. - */ -inline -Coord distance( Point const& p, Rect const& rect ) -{ - return std::sqrt(distanceSq(p, rect)); +inline OptRect intersect(OptRect const &a, OptRect const &b) { + return a & b; } - -/** - * @brief Axis-aligned rectangle that can be empty. - * @ingroup Primitives - */ -class OptRect : public boost::optional { -public: - OptRect() : boost::optional() {}; - OptRect(Rect const &a) : boost::optional(a) {}; - - /** - * Creates an empty OptRect when one of the argument intervals is empty. - */ - OptRect(OptInterval const &x_int, OptInterval const &y_int) { - if (x_int && y_int) { - *this = Rect(*x_int, *y_int); - } - // else, stay empty. - } - - /** @brief Check for emptiness. */ - inline bool isEmpty() const { return (*this == false); }; - - bool intersects(Rect const &r) const { return r.intersects(*this); } - bool contains(Rect const &r) const { return *this && (*this)->contains(r); } - bool interiorContains(Rect const &r) const { return *this && (*this)->interiorContains(r); } - - bool intersects(OptRect const &r) const { return *this && (*this)->intersects(r); } - bool contains(OptRect const &r) const { return *this && (*this)->contains(r); } - bool interiorContains(OptRect const &r) const { return *this && (*this)->interiorContains(r); } - - bool contains(Point const &p) const { return *this && (*this)->contains(p); } - bool interiorContains(Point const &p) const { return *this && (*this)->contains(p); } - - inline void unionWith(OptRect const &b) { - if (*this) { // check that we are not empty - (*this)->unionWith(b); - } else { - *this = b; - } - } -}; - - -/** - * Returns the smallest rectangle that encloses both rectangles. - * An empty argument is assumed to be an empty rectangle - */ -inline OptRect unify(OptRect const & a, OptRect const & b) { - if (!a) { - return b; - } else if (!b) { - return a; - } else { - return unify(*a, *b); - } +inline Rect unify(Rect const &a, Rect const &b) { + return a | b; } - -inline OptRect intersect(Rect const & a, Rect const & b) { - return OptRect(intersect(a[X], b[X]), intersect(a[Y], b[Y])); +inline OptRect unify(OptRect const &a, OptRect const &b) { + return a | b; } -inline void Rect::unionWith(OptRect const &b) { - if (b) { - unionWith(*b); - } -} -inline bool Rect::intersects(OptRect const &r) const { - return r && intersects(*r); -} -inline bool Rect::contains(OptRect const &r) const { - return !r || contains(*r); -} -inline bool Rect::interiorContains(OptRect const &r) const { - return !r || interiorContains(*r); +/** @brief Union a list of rectangles + * @deprecated Use OptRect::from_range instead */ +inline Rect union_list(std::vector const &r) { + if(r.empty()) return Rect(Interval(0,0), Interval(0,0)); + Rect ret = r[0]; + for(unsigned i = 1; i < r.size(); i++) + ret.unionWith(r[i]); + return ret; } } // end namespace Geom -#endif //_2GEOM_RECT +#endif // LIB2GEOM_SEEN_RECT_H /* Local Variables: diff --git a/src/2geom/region.h b/src/2geom/region.h index e23d6a158..06a4f63e9 100644 --- a/src/2geom/region.h +++ b/src/2geom/region.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Uncrossed path for boolean algorithms + *//* * Authors: * ? * diff --git a/src/2geom/sbasis-2d.h b/src/2geom/sbasis-2d.h index f1218b028..00429e259 100644 --- a/src/2geom/sbasis-2d.h +++ b/src/2geom/sbasis-2d.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Obsolete 2D SBasis function class + *//* * Authors: * Nathan Hurst * JFBarraud diff --git a/src/2geom/sbasis-curve.h b/src/2geom/sbasis-curve.h index 22fe4fc1f..554b702e6 100644 --- a/src/2geom/sbasis-curve.h +++ b/src/2geom/sbasis-curve.h @@ -33,8 +33,8 @@ * the specific language governing rights and limitations. */ -#ifndef _2GEOM_SBASIS_CURVE_H_ -#define _2GEOM_SBASIS_CURVE_H_ +#ifndef LIB2GEOM_SEEN_SBASIS_CURVE_H +#define LIB2GEOM_SEEN_SBASIS_CURVE_H #include <2geom/curve.h> #include <2geom/nearest-point.h> @@ -45,24 +45,45 @@ namespace Geom /** @brief Symmetric power basis curve. * - * Symmetric power basis (S-basis for short) polynomials are a versatile numeric representation - * of arbitrary continuous curves. They combine the properties of Bezier curves - * (geometric interpretation of parameters, numerical stability near ends of the curve) - * and the monomial basis (fast evaluation). They are the main representation of curves + * Symmetric power basis (S-basis for short) polynomials are a versatile numeric + * representation of arbitrary continuous curves. They are the main representation of curves * in 2Geom. * + * S-basis is defined for odd degrees and composed of the following polynomials: + * \f{align*}{ + P_k^0(t) &= t^k (1-t)^{k+1} \\ + P_k^1(t) &= t^{k+1} (1-t)^k \f} + * This can be understood more easily with the help of the chart below. Each square + * represents a product of a specific number of \f$t\f$ and \f$(1-t)\f$ terms. Red dots + * are the canonical (monomial) basis, the green dots are the Bezier basis, and the blue + * dots are the S-basis, all of them of degree 7. + * + * @image html sbasis.png "Illustration of the monomial, Bezier and symmetric power bases" + * + * The S-Basis has several important properties: + * - S-basis polynomials are closed under multiplication. + * - Evaluation is fast, using a modified Horner scheme. + * - Degree change is as trivial as in the monomial basis. To elevate, just add extra + * zero coefficients. To reduce the degree, truncate the terms in the highest powers. + * Compare this with Bezier curves, where degree change is complicated. + * - Conversion between S-basis and Bezier basis is numerically stable. + * + * More in-depth information can be found in the following paper: + * J Sanchez-Reyes, "The symmetric analogue of the polynomial power basis". + * ACM Transactions on Graphics, Vol. 16, No. 3, July 1997, pages 319--357. + * http://portal.acm.org/citation.cfm?id=256162 + * * @ingroup Curves */ class SBasisCurve : public Curve { - private: - SBasisCurve(); D2 inner; public: explicit SBasisCurve(D2 const &sb) : inner(sb) {} explicit SBasisCurve(Curve const &other) : inner(other.toSBasis()) {} +#ifndef DOXYGEN_SHOULD_SKIP_THIS virtual Curve *duplicate() const { return new SBasisCurve(*this); } virtual Point initialPoint() const { return inner.at0(); } virtual Point finalPoint() const { return inner.at1(); } @@ -104,16 +125,12 @@ public: virtual int degreesOfFreedom() const { return inner[0].degreesOfFreedom() + inner[1].degreesOfFreedom(); } +#endif }; - } // end namespace Geom - -#endif // _2GEOM_SBASIS_CURVE_H_ - - - +#endif // LIB2GEOM_SEEN_SBASIS_CURVE_H /* Local Variables: diff --git a/src/2geom/sbasis-to-bezier.h b/src/2geom/sbasis-to-bezier.h index 5b88a40fa..819aa87d6 100644 --- a/src/2geom/sbasis-to-bezier.h +++ b/src/2geom/sbasis-to-bezier.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Conversion between SBasis and Bezier basis polynomials + *//* * Authors: * ? * diff --git a/src/2geom/sbasis.cpp b/src/2geom/sbasis.cpp index e313ad08d..89640af5c 100644 --- a/src/2geom/sbasis.cpp +++ b/src/2geom/sbasis.cpp @@ -34,7 +34,7 @@ #include #include <2geom/sbasis.h> -#include <2geom/isnan.h> +#include <2geom/math-utils.h> namespace Geom{ diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h index b1b0b6c2a..7a7e33fe4 100644 --- a/src/2geom/sbasis.h +++ b/src/2geom/sbasis.h @@ -345,7 +345,7 @@ SBasis compose_inverse(SBasis const &f, SBasis const &g, unsigned order=2, doubl \relates SBasis */ inline SBasis portion(const SBasis &t, double from, double to) { return compose(t, Linear(from, to)); } -inline SBasis portion(const SBasis &t, Interval ivl) { return compose(t, Linear(ivl[0], ivl[1])); } +inline SBasis portion(const SBasis &t, Interval ivl) { return compose(t, Linear(ivl.min(), ivl.max())); } // compute f(g) inline SBasis diff --git a/src/2geom/sturm.h b/src/2geom/sturm.h deleted file mode 100644 index 4fef1b954..000000000 --- a/src/2geom/sturm.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef LIB2GEOM_STURM_HEADER -#define LIB2GEOM_STURM_HEADER - -#include <2geom/poly.h> -#include <2geom/utils.h> - -namespace Geom { - -class sturm : public std::vector{ -public: - sturm(Poly const &X) { - push_back(X); - push_back(derivative(X)); - Poly Xi = back(); - Poly Xim1 = X; - std::cout << "sturm:\n" << Xim1 << std::endl; - std::cout << Xi << std::endl; - while(Xi.size() > 1) { - Poly r; - divide(Xim1, Xi, r); - std::cout << r << std::endl; - assert(r.size() < Xi.size()); - Xim1 = Xi; - Xi = -r; - assert(Xim1.size() > Xi.size()); - push_back(Xi); - } - } - - unsigned count_signs(double t) { - unsigned n_signs = 0;/* Number of sign-changes */ - const double big = 1e20; // a number such that practical polys would overflow on evaluation - if(t >= big) { - int old_sign = sgn((*this)[0].back()); - for (unsigned i = 1; i < size(); i++) { - int sign = sgn((*this)[i].back()); - if (sign != old_sign) - n_signs++; - old_sign = sign; - } - } else { - int old_sign = sgn((*this)[0].eval(t)); - for (unsigned i = 1; i < size(); i++) { - int sign = sgn((*this)[i].eval(t)); - if (sign != old_sign) - n_signs++; - old_sign = sign; - } - } - return n_signs; - } - - unsigned n_roots_between(double l, double r) { - return count_signs(l) - count_signs(r); - } -}; - -} //namespace Geom - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/svg-elliptical-arc.h b/src/2geom/svg-elliptical-arc.h index 79497cdb3..ba0a18257 100644 --- a/src/2geom/svg-elliptical-arc.h +++ b/src/2geom/svg-elliptical-arc.h @@ -1,7 +1,6 @@ /** * \file * \brief SVG 1.1-compliant elliptical arc curve - * *//* * Authors: * MenTaLguY @@ -35,8 +34,8 @@ */ -#ifndef _2GEOM_SVG_ELLIPTICAL_ARC_H_ -#define _2GEOM_SVG_ELLIPTICAL_ARC_H_ +#ifndef LIB2GEOM_SEEN_SVG_ELLIPTICAL_ARC_H +#define LIB2GEOM_SEEN_SVG_ELLIPTICAL_ARC_H #include <2geom/curve.h> #include <2geom/angle.h> @@ -49,8 +48,7 @@ #include <2geom/numeric/fitting-model.h> #include -namespace Geom -{ +namespace Geom { class SVGEllipticalArc : public EllipticalArc { public: @@ -267,13 +265,9 @@ class make_elliptical_arc bool svg_compliant; }; - } // end namespace Geom - - - -#endif /* _2GEOM_SVG_ELLIPTICAL_ARC_H_ */ +#endif // LIB2GEOM_SEEN_SVG_ELLIPTICAL_ARC_H /* Local Variables: diff --git a/src/2geom/sweep.h b/src/2geom/sweep.h index 1c73efee0..91371e6fb 100644 --- a/src/2geom/sweep.h +++ b/src/2geom/sweep.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Sweepline intersection of groups of rectangles + *//* * Authors: * ? * diff --git a/src/2geom/toposweep.cpp b/src/2geom/toposweep.cpp new file mode 100644 index 000000000..cfb91857c --- /dev/null +++ b/src/2geom/toposweep.cpp @@ -0,0 +1,663 @@ +#include <2geom/toposweep.h> + +#include <2geom/path-intersection.h> +#include <2geom/basic-intersection.h> + +//using namespace Geom; + +namespace Geom { + +TopoGraph::Edge &TopoGraph::Vertex::operator[](unsigned ix) { + ix %= degree(); + return ix < enters.size() ? enters[ix] : exits[ix - enters.size()]; +} + +TopoGraph::Edge TopoGraph::Vertex::operator[](unsigned ix) const { + ix %= degree(); + return ix < enters.size() ? enters[ix] : exits[ix - enters.size()]; +} + +void TopoGraph::Vertex::erase(unsigned ix) { + ix %= degree(); + if(ix < enters.size()) + enters.erase(enters.begin() + ix); + else + exits.erase(exits.begin() + (ix - enters.size())); +} + +void TopoGraph::Vertex::insert(unsigned ix, Edge v) { + ix %= degree(); + if(ix < enters.size()) + enters.insert(enters.begin() + ix, v); + else + exits.insert(exits.begin() + (ix - enters.size()), v); +} + +unsigned TopoGraph::Vertex::find_section(boost::shared_ptr
section) const { + unsigned i = 0; + for(; i < degree(); i++) + if((*this)[i].section == section) return i; + return i; +} + +TopoGraph::Edge TopoGraph::remove_edge(unsigned ix, unsigned jx) { + Vertex &v = vertices[ix]; + if(v.degree()) { + jx %= v.degree(); + Edge &ret = v[jx]; + v.erase(jx); + v = vertices[ret.other]; + if(v.degree()) { + v.erase(v.find_section(ret.section)); + return ret; + } + } + assert(0); +} + +void TopoGraph::cannonize() { + std::vector vix; + unsigned ix = 0; + for(unsigned i = 0; i < vertices.size(); i++) { + vix.push_back(ix); + if(vertices[i].degree() != 0) vertices[ix++] = vertices[i]; + } + + for(unsigned i = 0; i < ix; i++) + for(unsigned j = 0; j < vertices[i].degree(); j++) + vertices[i][j].other = vix[vertices[i][j].other]; +} + + +void TopoGraph::assert_invariants() const { + for(unsigned i = 0; i < vertices.size(); i++) { + for(unsigned j = 0; j < vertices[i].degree(); j++) { + Edge e = vertices[i][j]; + assert(e.other != i); + assert(are_near(e.section->fp, vertices[i].avg, tol) || are_near(e.section->tp, vertices[i].avg, tol)); + assert(!are_near(e.section->fp, e.section->tp, tol)); + assert(e.section.get()); + unsigned oix = vertices[e.other].find_section(e.section); + assert(oix != vertices[e.other].degree()); + } + } +} + +//near predicate utilized in process_splits +template +struct NearPredicate { bool operator()(T x, T y) { return are_near(x, y); } }; + +// ensures that f and t are elements of a vector, sorts and uniqueifies +// also asserts that no values fall outside of f and t +// if f is greater than t, the sort is in reverse +void process_splits(std::vector &splits, double f, double t) { + splits.push_back(f); + std::sort(splits.begin(), splits.end()); + while(are_near(splits.back(), t)) splits.erase(splits.end() - 1); + splits.push_back(t); + if(f > t) std::reverse(splits.begin(), splits.end()); + + //remove any splits which fall outside t / f + while(!splits.empty() && splits.front() != f) splits.erase(splits.begin()); + while(!splits.empty() && splits.back() != t) splits.erase(splits.end() - 1); + + std::vector::iterator end = std::unique(splits.begin(), splits.end(), NearPredicate()); + splits.resize(end - splits.begin()); +} + +// A little sugar for appending a list to another +template +void concatenate(T &a, T const &b) { a.insert(a.end(), b.begin(), b.end()); } + +//returns a list of monotonic sections of a path +//TODO: handle saddle points +std::vector > mono_sections(PathVector const &ps, Dim2 d) { + std::vector > monos; + for(unsigned i = 0; i < ps.size(); i++) { + //TODO: necessary? can we have empty paths? + if(ps[i].size()) { + for(unsigned j = 0; j < ps[i].size(); j++) { + //find the points of 0 derivative + Curve* deriv = ps[i][j].derivative(); + std::vector splits = deriv->roots(0, X); + concatenate(splits, deriv->roots(0, Y)); + delete deriv; + process_splits(splits, 0, 1); + //split on points of 0 derivative + for(unsigned k = 1; k < splits.size(); k++) + monos.push_back(boost::shared_ptr
(new Section(CurveIx(i,j), splits[k-1], splits[k], ps, d))); + } + } + } + return monos; +} + +//finds the t-value on a section, which corresponds to a particular horizontal or vertical line +//d indicates the dimension along which the roots is performed. +//-1 is returned if no root is found +double section_root(Section const &s, PathVector const &ps, double v, Dim2 d) { + std::vector roots = s.curve.get(ps).roots(v, d); + for(unsigned j = 0; j < roots.size(); j++) + if(Interval(s.f, s.t).contains(roots[j])) return roots[j]; + return -1; +} + +bool SectionSorter::section_order(Section const &a, double at, Section const &b, double bt) const { + Point ap = a.curve.get(ps).pointAt(at); + Point bp = b.curve.get(ps).pointAt(bt); + if(are_near(ap[dim], bp[dim], tol)) { + // since the sections are monotonic, if the endpoints are on opposite sides of this + // coincidence, the order is determinable + if(a.tp[dim] < ap[dim] && b.tp[dim] > bp[dim]) return true; + if(a.tp[dim] > ap[dim] && b.tp[dim] < bp[dim]) return false; + //TODO: sampling / higher derivatives when unit tangents match + Point ad = a.curve.get(ps).unitTangentAt(a.f); + Point bd = b.curve.get(ps).unitTangentAt(b.f); + // tangent can point backwards + if(ad[1-dim] < 0) ad = -ad; + if(bd[1-dim] < 0) bd = -bd; + return ad[dim] < bd[dim]; + } + return ap[dim] < bp[dim]; +} + +bool SectionSorter::operator()(Section const &a, Section const &b) const { + if(&a == &b) return false; + Rect ra = a.bbox(), rb = b.bbox(); + //TODO: should we use tol in these conditions? + if(ra[dim].max() <= rb[dim].min()) return true; + if(rb[dim].max() <= ra[dim].min()) return false; + //we know that the rects intersect on dim + //by referencing f / t we are assuming that the section was constructed with 1-dim + if(ra[1-dim].intersects(rb[1-dim])) { + if(are_near(a.fp[1-dim], b.fp[1-dim], tol)) { + return section_order(a, a.f > a.t ? a.f - 0.01 : a.f + 0.01, + b, b.f > b.t ? b.f - 0.01 : b.f + 0.01); + } else if(a.fp[1-dim] < b.fp[1-dim]) { + //b inside a + double ta = section_root(a, ps, b.fp[1-dim], Dim2(1-dim)); + //TODO: fix bug that necessitates this + if(ta == -1) ta = (a.t + a.f) / 2; + return section_order(a, ta, b, b.f); + } else { + //a inside b + double tb = section_root(b, ps, a.fp[1-dim], Dim2(1-dim)); + //TODO: fix bug that necessitates this + if(tb == -1) tb = (b.t + b.f) / 2; + return section_order(a, a.f, b, tb); + } + } + + return Point::LexOrderRt(dim)(a.fp, b.fp); +} + +// splits a section into pieces, as specified by an array of doubles, mutating the section to +// represent the first part, and returning the rest +//TODO: output iterator? +std::vector > split_section(boost::shared_ptr
s, PathVector const &ps, std::vector &cuts, Dim2 d) { + std::vector > ret; + + process_splits(cuts, s->f, s->t); + if(cuts.size() <= 2) return ret; + + s->t = cuts[1]; + s->tp = s->curve.get(ps)(cuts[1]); + assert(Point::LexOrderRt(d)(s->fp, s->tp)); + + ret.reserve(cuts.size() - 2); + for(int i = cuts.size() - 1; i > 1; i--) ret.push_back(boost::shared_ptr
(new Section(s->curve, cuts[i-1], cuts[i], ps, d))); + return ret; +} + +//merges the sorted lists a and b according to comparison z +template +void merge(X &a, X const &b, Z const &z) { + a.reserve(a.size() + b.size()); + unsigned start = a.size(); + concatenate(a, b); + std::inplace_merge(a.begin(), a.begin() + start, a.end(), z); +} + +//TODO: faster than linear +unsigned find_vertex(std::vector const &vertices, Point p, double tol) { + for(unsigned i = 0; i < vertices.size(); i++) + if(are_near(vertices[i].avg, p, tol)) return i; + return vertices.size(); +} + +//takes a vector of T pointers, and returns a vector of T with copies +template +std::vector deref_vector(std::vector > const &xs, unsigned from = 0) { + std::vector ret; + ret.reserve(xs.size() - from); + for(unsigned i = from; i < xs.size(); i++) + ret.push_back(T(*xs[i])); + return ret; +} + +//used to create reversed sorting predicates +template +struct ReverseAdapter { + typedef typename C::second_argument_type first_argument_type; + typedef typename C::first_argument_type second_argument_type; + typedef typename C::result_type result_type; + const C ∁ + ReverseAdapter(const C &c) : comp(c) {} + result_type operator()(const first_argument_type &a, const second_argument_type &b) const { return comp(b, a); } +}; + +//used to sort std::vector +template +struct DerefAdapter { + typedef typename boost::shared_ptr first_argument_type; + typedef typename boost::shared_ptr second_argument_type; + typedef typename C::result_type result_type; + const C ∁ + DerefAdapter(const C &c) : comp(c) {} + result_type operator()(const first_argument_type a, const second_argument_type b) const { + if(!a) return false; + if(!b) return true; + return comp(*a, *b); + } +}; + +struct EdgeSorter { + typedef TopoGraph::Edge first_argument_type; + typedef TopoGraph::Edge second_argument_type; + typedef bool result_type; + SectionSorter s; + EdgeSorter(const PathVector &rs, Dim2 d, double t) : s(rs, d, t) {} + bool operator()(TopoGraph::Edge const &e1, TopoGraph::Edge const &e2) const { return s(*e1.section, *e2.section); } +}; + +#ifdef SWEEP_GRAPH_DEBUG +//used for debugging purposes - each element represents a subsequent iteration of the algorithm. +std::vector > monoss; +std::vector > chopss; +std::vector > contexts; +#endif + +/* + 1) take item off sweep sorted todo + 2) find all of the to-values before the beginning of this section + 3) sort these lexicographically, process them in order, grouping other sections in the context, and constructing a vertex in one fell swoop. + 4) add our section into context, splitting on intersections + + 3 is novel, we perform it by storing + */ + +template +struct MergeIterator { + A const &a; + B &b; + Z const &z; + unsigned ai; + bool on_a; + MergeIterator(A const &av, B &bv, Z const &zv) : a(av), b(bv), z(zv), ai(0), on_a(b.empty() || z(a[0], b.back())) {} + MergeIterator &operator++() { + if(!done()) { + on_a = b.empty() ? true : (ai >= a.size() ? false : z(a[ai], b.back())); + if(on_a) { + ++ai; + if(ai >= a.size()) on_a = false; + } else { + b.erase(b.end()); + if(b.empty()) on_a = true; + } + } + return *this; + } + typename A::value_type operator*() { + assert(!done()); + return on_a ? a[ai] : b.back(); + } + bool done() { return b.empty() && ai >= a.size() - 1; } + typename A::value_type operator->() { assert(!done()); return on_a ? a[ai] : b.back(); } +}; + +void modify_windings(std::vector &windings, boost::shared_ptr
sec, Dim2 d) { + unsigned k = sec->curve.path; + if(k >= windings.size() || sec->fp[d] == sec->tp[d]) return; + if(sec->f < sec->t) windings[k]++; + if(sec->f > sec->t) windings[k]--; +} + +struct Context { + boost::shared_ptr
section; + int from_vert; + int to_vert; + Context(boost::shared_ptr
sect, int from) : section(sect), from_vert(from), to_vert(-1) {} +}; + +template +struct ContextAdapter { + typedef Context first_argument_type; + typedef typename C::second_argument_type second_argument_type; + typedef typename C::result_type result_type; + const C ∁ + ContextAdapter(const C &c) : comp(c) {} + result_type operator()(const Context &a, const second_argument_type &b) const { return comp(a.section, b); } +}; + +#define DINF std::numeric_limits::infinity() + +TopoGraph::TopoGraph(PathVector const &ps, Dim2 d, double t) : dim(d), tol(t) { + //s_sort = vertical section order + ContextAdapter > s_sort = DerefAdapter(SectionSorter(ps, (Dim2)(1-d), tol)); + //sweep_sort = horizontal sweep order + DerefAdapter sweep_sort = DerefAdapter(SweepSorter(d)); + //heap_sort = reverse horizontal sweep order + ReverseAdapter > heap_sort = ReverseAdapter >(sweep_sort); + //edge_sort = sorter for edges + EdgeSorter edge_sort = EdgeSorter(ps, (Dim2)(1-d), tol); + + std::vector > input_sections = mono_sections(ps, d), chops; + std::sort(input_sections.begin(), input_sections.end(), sweep_sort); + + std::vector context; + + vertices.reserve(input_sections.size()); + + //std::vector to_process; + + std::vector windings(ps.size(), 0); + for(MergeIterator > iter(input_sections, chops, sweep_sort); ; ++iter) { + //represents our position in the sweep, which controls what we finalize + //if we have no more to process, finish the rest by setting our position to infinity + Point lim; + if(iter.done()) lim[X] = lim[Y] = DINF; else lim = iter->fp; + + /* + //finalize vertices + for(unsigned i = 0; i < to_process.size(); i++) { + if(vertices[to_process[i]].avg[d] + tol < lim[d]) + for(unsigned j = 0; j < context.size(); j++) { + + } + } */ + + //find all sections to remove + for(int i = context.size() - 1; i >= 0; i--) { + boost::shared_ptr
sec = context[i].section; + if(Point::LexOrderRt(d)(lim, sec->tp)) { + //sec->tp is less than or equal to lim + if(context[i].to_vert == -1) { + //we need to create a new vertex; add everything that enters it + //Point avg; + //unsigned cnt; + std::vector enters; + std::fill(windings.begin(), windings.end(), 0); + for(unsigned j = 0; j < context.size(); j++) { + modify_windings(windings, context[j].section, d); + if(are_near(sec->tp, context[j].section->tp, tol)) { + assert(-1 == context[j].to_vert); + context[j].section->windings = windings; + context[j].to_vert = vertices.size(); + enters.push_back(Edge(context[j].section, context[j].from_vert)); + //avg += context[j].section->tp; + //cnt++; + } + } + //Vertex &v(avg / (double)cnt); + Vertex v(context[i].section->tp); + v.enters = enters; + vertices.push_back(v); + //to_process.push_back(vertices.size() - 1); + } + context.erase(context.begin() + i); + } + } + + if(!iter.done()) { + boost::shared_ptr
s = *iter; + + //create a new context, associate a beginning vertex, and insert it in the proper location + unsigned ix = find_vertex(vertices, s->fp, tol); + if(ix == vertices.size()) { + vertices.push_back(Vertex(s->fp)); + //to_process.push_back(vertices.size() - 1); + } + unsigned context_ix = std::lower_bound(context.begin(), context.end(), s, s_sort) - context.begin(); + + context.insert(context.begin() + context_ix, Context(s, ix)); + + Interval si = Interval(s->fp[1-d], s->tp[1-d]); + + // Now we intersect with neighbors - do a sweep! + std::vector this_splits; + for(unsigned i = 0; i < context.size(); i++) { + if(context[i].section == context[context_ix].section) continue; + + boost::shared_ptr
sec = context[i].section; + + if(!si.intersects(Interval(sec->fp[1-d], sec->tp[1-d]))) continue; + + std::vector other_splits; + Crossings xs = mono_intersect(s->curve.get(ps), Interval(s->f, s->t), + sec->curve.get(ps), Interval(sec->f, sec->t)); + if(xs.empty()) continue; + + for(unsigned j = 0; j < xs.size(); j++) { + this_splits.push_back(xs[j].ta); + other_splits.push_back(xs[j].tb); + } + merge(chops, split_section(sec, ps, other_splits, d), heap_sort); + } + if(!this_splits.empty()) + merge(chops, split_section(context[context_ix].section, ps, this_splits, d), heap_sort); + + std::sort(chops.begin(), chops.end(), heap_sort); + + if(context[context_ix].section->tp[d] - context[context_ix].section->fp[d] <= tol) { + if(!are_near(context[context_ix].section->tp, context[context_ix].section->fp, tol)) { + ix = find_vertex(vertices, context[context_ix].section->tp, tol); + if(ix != vertices.size()) { + boost::shared_ptr
sec = context[context_ix].section; + Edge e(sec, context[context_ix].from_vert); + + std::vector::iterator it = std::lower_bound(vertices[ix].enters.begin(), vertices[ix].enters.end(), e, edge_sort); + + if(vertices[ix].enters.empty()) { + std::fill(windings.begin(), windings.end(), 0); + for(unsigned j = 0; j <= context_ix; j++) modify_windings(windings, context[j].section, d); + } else if(it == vertices[ix].enters.end()) { + windings = (it-1)->section->windings; + modify_windings(windings, (it-1)->section, d); + } else { + windings = it->section->windings; + } + + sec->windings = windings; + modify_windings(windings, sec, d); + + for(std::vector::iterator it2 = it; it2 != vertices[ix].enters.end(); ++it2) { + it2->section->windings = windings; + modify_windings(windings, it2->section, d); + } + + vertices[ix].enters.insert(it, e); + context.erase(context.begin() + context_ix); + } + } else context.erase(context.begin() + context_ix); + } + } + + #ifdef SWEEP_GRAPH_DEBUG + std::vector
rem; + for(unsigned i = iter.ai + 1; i < iter.a.size(); i++) rem.push_back(*iter.a[i]); + monoss.push_back(rem); + chopss.push_back(deref_vector(iter.b)); + rem.clear(); + for(unsigned i = 0; i < context.size(); i++) rem.push_back(*context[i].section); + contexts.push_back(rem); + #endif + + if(iter.done() && context.empty()) return; + } +} + +void trim_whiskers(TopoGraph &g) { + std::vector affected; + + for(unsigned i = 0; i < g.size(); i++) + if(g[i].degree() == 1) affected.push_back(i); + + while(!affected.empty()) { + unsigned j = 0; + for(unsigned i = 0; i < affected.size(); i++) + if(g[affected[i]].degree() == 1) + affected[j++] = g.remove_edge(affected[i], 0).other; + affected.resize(j); + } +} + +void add_edge_at(TopoGraph &g, unsigned ix, boost::shared_ptr
s, TopoGraph::Edge jx, bool before = true) { + TopoGraph::Vertex &v = g[ix]; + for(unsigned i = 0; i < v.enters.size(); i++) { + if(v.enters[i].section == s) { + v.enters.insert(v.enters.begin() + (before ? i : i + 1), jx); + return; + } + } + for(unsigned i = 0; i < v.exits.size(); i++) { + if(v.exits[i].section == s) { + v.exits.insert(v.exits.begin() + (before ? i : i + 1), jx); + return; + } + } + //TODO: fix the fall through to here + //assert(false); +} + +void double_whiskers(TopoGraph &g) { + for(unsigned i = 0; i < g.size(); i++) { + if(g[i].degree() == 1) { + unsigned j = i; + TopoGraph::Edge e = g[i][0]; + while(true) { + TopoGraph::Edge next_edge = g[j][1 - g[j].find_section(e.section)]; + boost::shared_ptr
new_section = boost::shared_ptr
(new Section(*e.section)); + add_edge_at(g, j, e.section, TopoGraph::Edge(new_section, e.other), false); + add_edge_at(g, e.other, e.section, TopoGraph::Edge(new_section, j), true); + + if(g[e.other].degree() == 3) { + j = e.other; + e = next_edge; + } else break; + } + } + } +} + +/* +void remove_degenerate(TopoGraph &g) { + for(unsigned i = 0; i < g.size(); i++) { + for(int j = g[i].degree(); j >= 0; j--) { + if(g[i][j].other == i) + } + } +}*/ + +/* +void remove_vestigial(TopoGraph &g) { + for(unsigned i = 0; i < g.size(); i++) { + if(g[i].enters.size() == 1 && g[i].exits.size() == 1) { + TopoGraph::Edge &e1 = g[i][0], &e2 = g[i][1]; + if(e1.section == e2.section) { + //vestigial vert + Section *new_section = new Section(e1.section->curve, + e1.section->f, e2.section->t, + e1.section->fp, e2.section->tp); + + e1.other + + Vertex *v1 = e1.other, *v2 = e2.other; + v1->lookup_section(e1.section) = Edge(new_section, v2); + v2->lookup_section(e2.section) = Edge(new_section, v1); + g.erase(g.begin() + i); + } + } + } +}*/ + +//planar area finding +//linear on number of edges +Areas traverse_areas(TopoGraph const &g) { + Areas ret; + + //stores which edges we've visited + std::vector > visited; + for(unsigned i = 0; i < g.size(); i++) visited.push_back(std::vector(g[i].degree(), false)); + + for(unsigned vix = 0; vix < g.size(); vix++) { + while(true) { + //find an unvisited edge to start on + + unsigned e_ix = std::find(visited[vix].begin(), visited[vix].end(), false) - visited[vix].begin(); + if(e_ix == g[vix].degree()) break; + + unsigned start = e_ix; + unsigned cur = vix; + + Area area; + //std::vector > before(visited); + while(cur < g.size() && !visited[cur][e_ix]) { + visited[cur][e_ix] = true; + + TopoGraph::Edge e = g[cur][e_ix]; + + area.push_back(e.section); + + //go to clockwise edge + cur = e.other; + unsigned deg = g[cur].degree(); + e_ix = g[cur].find_section(e.section); + + if(deg == 1 || e_ix == deg) { + visited[cur][e_ix] = true; + break; + } + + e_ix = (e_ix + 1) % deg; + + if(cur == vix && start == e_ix) break; + } + //if(vix == cur && start == e_ix) { + ret.push_back(area); + //} else visited = before; + } + } + return ret; +} + +void remove_area_whiskers(Areas &areas) { + for(int i = areas.size() - 1; i >= 0; i--) + if(areas[i].size() == 2 && *areas[i][0] == *areas[i][1]) + areas.erase(areas.begin() + i); +} + +Path area_to_path(PathVector const &ps, Area const &area) { + Path ret; + if(area.size() == 0) return ret; + Point prev = area[0]->fp; + for(unsigned i = 0; i < area.size(); i++) { + bool forward = are_near(area[i]->fp, prev, 0.01); + Curve *curv = area[i]->curve.get(ps).portion( + forward ? area[i]->f : area[i]->t, + forward ? area[i]->t : area[i]->f); + ret.append(*curv, Path::STITCH_DISCONTINUOUS); + delete curv; + prev = forward ? area[i]->tp : area[i]->fp; + } + return ret; +} + +PathVector areas_to_paths(PathVector const &ps, Areas const &areas) { + std::vector ret; + ret.reserve(areas.size()); + for(unsigned i = 0; i < areas.size(); i++) + ret.push_back(area_to_path(ps, areas[i])); + return ret; +} + +} // end namespace Geom diff --git a/src/2geom/toposweep.h b/src/2geom/toposweep.h new file mode 100644 index 000000000..428115dd3 --- /dev/null +++ b/src/2geom/toposweep.h @@ -0,0 +1,222 @@ + +/** + * \file + * \brief TopoSweep - topology / graph representation of a PathVector, for boolean operations and related tasks + * + * Authors: + * Michael Sloan + * Nathan Hurst + * + * Copyright 2007-2009 authors + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#ifndef SEEN_GEOM_TOPOSWEEP_H +#define SEEN_GEOM_TOPOSWEEP_H + +#include <2geom/coord.h> +#include <2geom/point.h> +#include <2geom/pathvector.h> +#include <2geom/rect.h> +#include <2geom/path.h> +#include <2geom/curve.h> + +#include + +namespace Geom { + +// indicates a particular curve in a pathvector +struct CurveIx { + unsigned path, ix; + CurveIx(unsigned p, unsigned i) : path(p), ix(i) {} + // retrieves the indicated curve from the pathvector + Curve const &get(PathVector const &ps) const { + return ps[path][ix]; + } + bool operator==(CurveIx const &other) const { + return other.path == path && other.ix == ix; + } +}; + +// represents a monotonic section of a path +struct Section { + CurveIx curve; + double f, t; + Point fp, tp; + std::vector windings; + Section(CurveIx cix, double fd, double td, Point fdp, Point tdp) : curve(cix), f(fd), t(td), fp(fdp), tp(tdp) { } + Section(CurveIx cix, double fd, double td, PathVector ps, Dim2 d) : curve(cix), f(fd), t(td) { + fp = curve.get(ps).pointAt(f), tp = curve.get(ps).pointAt(t); + if (Point::LexOrderRt(d)(tp, fp)) { + //swap from and to, since tp is left or above fp + std::swap(f, t); + std::swap(fp, tp); + } + } + Rect bbox() const { return Rect(fp, tp); } + bool operator==(Section const &other) const { + return (curve == other.curve) && (f == other.f) && (t == other.t); + } +}; + +class TopoGraph { + public: + + // Represents an e double tol;dge on a vertex + class Edge { + public: + boost::shared_ptr
section; // section associated with this edge + unsigned other; // index of the vertex this edge points to + Edge(boost::shared_ptr
s, unsigned o) : section(s), other(o) {} + }; + + // Represents a vertex in the graph, in terms of a point and edges which enter and exit. + // A vertex has an "avg" point, which is a representative point for the vertex. All + // edges have an endpoint tol away. + class Vertex { + public: + std::vector enters, exits; // indexes of the enter / exit edges + Point avg; + Vertex(Point p) : avg(p) {} + inline unsigned degree() const { return enters.size() + exits.size(); } + Edge operator[](unsigned ix) const; + Edge &operator[](unsigned ix); + void erase(unsigned ix); + void insert(unsigned ix, Edge e); + unsigned find_section(boost::shared_ptr
section) const; + }; + + TopoGraph(PathVector const &ps, Dim2 d, double t); + + unsigned size() const { return vertices.size(); } + + Vertex &operator[](unsigned ix) { return vertices[ix]; } + Vertex const &operator[](unsigned ix) const { return vertices[ix]; } + + //removes both edges, and returns the vertices[ix][jx] one + Edge remove_edge(unsigned ix, unsigned jx); + + //returns a graph with all zero degree vertices and unused edges removed + void cannonize(); + + //checks invariants + void assert_invariants() const; + + std::vector vertices; + Dim2 dim; + double tol; +}; + +//TODO: convert to classes +typedef std::vector > Area; +typedef std::vector Areas; + +//TopoGraph sweep_graph(PathVector const &ps, Dim2 d = X, double tol = 0.00001); + +void trim_whiskers(TopoGraph &g); +void double_whiskers(TopoGraph &g); +//void remove_degenerate(TopoGraph &g); +//void remove_vestigial(TopoGraph &g); +//Areas traverse_areas(TopoGraph const &g); + + +void remove_area_whiskers(Areas &areas); +PathVector areas_to_paths(PathVector const &ps, Areas const &areas); + +class SectionSorter { + const PathVector &ps; + Dim2 dim; + double tol; + bool section_order(Section const &a, double at, Section const &b, double bt) const; + public: + typedef Section first_argument_type; + typedef Section second_argument_type; + typedef bool result_type; + + SectionSorter(const PathVector &rs, Dim2 d, double t = 0.00001) : ps(rs), dim(d), tol(t) {} + bool operator()(Section const &a, Section const &b) const; +}; + +//sorter used to create the initial sweep of sections, such that they are dealt with in order +struct SweepSorter { + typedef Section first_argument_type; + typedef Section second_argument_type; + typedef bool result_type; + Dim2 dim; + SweepSorter(Dim2 d) : dim(d) {} + bool operator()(const Section &a, const Section &b) const { + return Point::LexOrderRt(dim)(a.fp, b.fp); + } +}; + +struct UnionOp { + unsigned ix; + bool nz1, nz2; + UnionOp(unsigned i, bool a, bool b) : ix(i), nz1(a), nz2(b) {} + bool operator()(std::vector const &windings) const { + int w1 = 0, w2 = 0; + for(unsigned j = 0; j < ix; j++) w1 += windings[j]; + for(unsigned j = ix; j < windings.size(); j++) w2 += windings[j]; + return (nz1 ? w1 : w1 % 2) != 0 || (nz2 ? w2 : w2 % 2) != 0; + } +}; + +//returns all areas for which the winding -> bool function yields true +template +Areas filter_areas(PathVector const &ps, Areas const & areas, Z const &z) { + Areas ret; + SweepSorter sorty = SweepSorter(Y); + SectionSorter sortx = SectionSorter(ps, X); + for(unsigned i = 0; i < areas.size(); i++) { + if(areas[i].size() < 2) continue; + //find a representative section + unsigned rj = 0; + bool rev = are_near(areas[i][0]->fp, areas[i][1]->tp); + for(unsigned j = 1; j < areas[i].size(); j++) + if(sorty(*areas[i][rj], *areas[i][j])) rj = j; + if(sortx(*areas[i][rj], *areas[i][(rj+areas[i].size() - 1) % areas[i].size()])) { + rj = 0; + for(unsigned j = 1; j < areas[i].size(); j++) + if(sorty(*areas[i][j], *areas[i][rj])) rj = j; + } + if(z(areas[i][rj]->windings)) ret.push_back(areas[i]); + } + return ret; +} + +} // end namespace Geom + +#endif // SEEN_GEOM_TOPOSWEEP_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/transforms.cpp b/src/2geom/transforms.cpp index 3a1866c13..2658719c4 100644 --- a/src/2geom/transforms.cpp +++ b/src/2geom/transforms.cpp @@ -60,12 +60,12 @@ Point &Point::operator*=(Rotate const &r) } Point &Point::operator*=(HShear const &h) { - _pt[X] += h.f * _pt[Y]; + _pt[X] += h.f * _pt[X]; return *this; } Point &Point::operator*=(VShear const &v) { - _pt[Y] += v.f * _pt[X]; + _pt[Y] += v.f * _pt[Y]; return *this; } diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 48d4b1dba..9623bed26 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -32,12 +32,12 @@ * the specific language governing rights and limitations. */ -#ifndef SEEN_Geom_TRANSFORMS_H -#define SEEN_Geom_TRANSFORMS_H +#ifndef LIB2GEOM_SEEN_TRANSFORMS_H +#define LIB2GEOM_SEEN_TRANSFORMS_H +#include #include <2geom/forward.h> #include <2geom/affine.h> -#include namespace Geom { @@ -66,7 +66,8 @@ struct TransformConcept { } }; -/** @brief Base template for transforms. */ +/** @brief Base template for transforms. + * This class is an implementation detail and should not be used directly. */ template class TransformOperations : boost::equality_comparable< T @@ -198,6 +199,7 @@ public: }; /** @brief Common base for shearing transforms. + * This class is an implementation detail and should not be used directly. * @ingroup Transforms */ template class ShearBase @@ -259,10 +261,9 @@ inline Translate pow(Translate const &t, int n) { //TODO: matrix to trans/scale/rotate -} /* namespace Geom */ - +} // end namespace Geom -#endif /* !SEEN_Geom_TRANSFORMS_H */ +#endif // LIB2GEOM_SEEN_TRANSFORMS_H /* Local Variables: diff --git a/src/2geom/utils.h b/src/2geom/utils.h index e90a4623b..6a72d42c4 100644 --- a/src/2geom/utils.h +++ b/src/2geom/utils.h @@ -1,10 +1,7 @@ -#ifndef LIB2GEOM_UTILS_HEADER -#define LIB2GEOM_UTILS_HEADER - /** * \file * \brief Various utility functions. - * + *//* * Copyright 2007 Johan Engelen * Copyright 2006 Michael G. Sloan * @@ -33,6 +30,9 @@ * */ +#ifndef SEEN_LIB2GEOM_UTILS_H +#define SEEN_LIB2GEOM_UTILS_H + #include #include @@ -59,9 +59,9 @@ struct MultipliableNoncommutative : B } }; -} +} // end namespace Geom -#endif +#endif // SEEN_LIB2GEOM_UTILS_H /* Local Variables: diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 251b41066..2aa9c41ee 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1306,12 +1306,12 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { - cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, false); - cc->clickeditem->setAttribute("inkscape:connection-start-point", cpid, false); + cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, NULL); + cc->clickeditem->setAttribute("inkscape:connection-start-point", cpid, NULL); } else { - cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, false); - cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, false); + cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, NULL); + cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, NULL); } g_free(shape_label); } @@ -1451,23 +1451,23 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) bool connection = false; cc->newconn->setAttribute( "inkscape:connector-type", - cc->isOrthogonal ? "orthogonal" : "polyline", false ); + cc->isOrthogonal ? "orthogonal" : "polyline", NULL ); cc->newconn->setAttribute( "inkscape:connector-curvature", - Glib::Ascii::dtostr(cc->curvature).c_str(), false ); + Glib::Ascii::dtostr(cc->curvature).c_str(), NULL ); if (cc->shref) { - cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, false); + cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, NULL); if (cc->scpid) { - cc->newconn->setAttribute( "inkscape:connection-start-point", cc->scpid, false); + cc->newconn->setAttribute( "inkscape:connection-start-point", cc->scpid, NULL); } connection = true; } if (cc->ehref) { - cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, false); + cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, NULL); if (cc->ecpid) { - cc->newconn->setAttribute( "inkscape:connection-end-point", cc->ecpid, false); + cc->newconn->setAttribute( "inkscape:connection-end-point", cc->ecpid, NULL); } connection = true; } @@ -1950,7 +1950,7 @@ void cc_selection_set_avoid(bool const set_avoid) char const *value = (set_avoid) ? "true" : NULL; if (cc_item_is_shape(item)) { - item->setAttribute("inkscape:connector-avoid", value, false); + item->setAttribute("inkscape:connector-avoid", value, NULL); item->avoidRef->handleSettingChange(); changes++; } diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 36d733eb8..a943a6214 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -301,7 +301,7 @@ nr_arena_image_rect (NRArenaImage *image) Geom::Point p(image->ox, image->oy); Geom::Point wh(vw, vh); Geom::Rect view(p, p+wh); - Geom::OptRect res = Geom::intersect(r, view); + Geom::OptRect res = r & view; r = res ? *res : r; } diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index d4cf47af4..694ccaec5 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -11,7 +11,6 @@ #include -#include "2geom/isnan.h" #include "display/cairo-templates.h" #include "display/cairo-utils.h" #include "display/nr-filter-composite.h" diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 326c37160..884e832ef 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -25,8 +25,6 @@ #include #endif //HAVE_OPENMP -#include "2geom/isnan.h" - #include "display/cairo-utils.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-gaussian.h" diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index aa7d840bc..a3a665b1c 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -34,7 +34,7 @@ #include "svg/svg.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" -#include <2geom/isnan.h> +#include <2geom/math-utils.h> #include <2geom/pathvector.h> #include <2geom/bezier-utils.h> #include "display/curve.h" diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 8ac765b9e..de6c7d86f 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -62,7 +62,7 @@ #include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "livarot/Shape.h" -#include <2geom/isnan.h> +#include <2geom/math-utils.h> #include <2geom/pathvector.h> #include "eraser-context.h" diff --git a/src/helper/recthull.h b/src/helper/recthull.h index a9cad4466..d82450ce8 100644 --- a/src/helper/recthull.h +++ b/src/helper/recthull.h @@ -38,7 +38,7 @@ public: void add(Rect const &r) { // Note that this is a hack. when convexhull actually works // you will need to add all four points. - _bounds = unify(_bounds, r); + _bounds.unionWith(r); } void add(RectHull const &h) { if (h._bounds) { diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 2a3b525a7..62771ece2 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -2,7 +2,7 @@ #include "conjugate_gradient.h" #include "straightener.h" #include "shortest_paths.h" -#include "2geom/isnan.h" +#include <2geom/math-utils.h> namespace cola { diff --git a/src/libcola/gradient_projection.cpp b/src/libcola/gradient_projection.cpp index fb8702ec7..47109a4b0 100644 --- a/src/libcola/gradient_projection.cpp +++ b/src/libcola/gradient_projection.cpp @@ -17,7 +17,7 @@ #include #include "gradient_projection.h" #include -#include "2geom/isnan.h" +#include <2geom/math-utils.h> #include "isinf.h" #include diff --git a/src/libnr/nr-point-fns.cpp b/src/libnr/nr-point-fns.cpp index cd6d6927b..ac58eddb7 100644 --- a/src/libnr/nr-point-fns.cpp +++ b/src/libnr/nr-point-fns.cpp @@ -1,5 +1,5 @@ #include -#include <2geom/isnan.h> +#include <2geom/math-utils.h> using NR::Point; diff --git a/src/libnr/nr-types.cpp b/src/libnr/nr-types.cpp index 0231c91d5..5da5d5cf6 100644 --- a/src/libnr/nr-types.cpp +++ b/src/libnr/nr-types.cpp @@ -3,8 +3,7 @@ */ #include - -#include "2geom/isnan.h" +#include <2geom/math-utils.h> /** Scales this vector to make it a unit vector (within rounding error). * diff --git a/src/libvpsc/generate-constraints.cpp b/src/libvpsc/generate-constraints.cpp index c57966e26..0c35ab51c 100644 --- a/src/libvpsc/generate-constraints.cpp +++ b/src/libvpsc/generate-constraints.cpp @@ -16,7 +16,7 @@ #include "generate-constraints.h" #include "constraint.h" -#include "2geom/isnan.h" /* Include last */ +#include <2geom/math-utils.h> using std::set; using std::vector; diff --git a/src/live_effects/lpe-spiro.cpp b/src/live_effects/lpe-spiro.cpp index 54554ebb2..22974fe13 100644 --- a/src/live_effects/lpe-spiro.cpp +++ b/src/live_effects/lpe-spiro.cpp @@ -12,7 +12,6 @@ #include <2geom/affine.h> #include <2geom/bezier-curve.h> #include <2geom/hvlinesegment.h> -#include <2geom/isnan.h> #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 553c125a3..743ef573a 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -35,7 +35,7 @@ #include #include "object-edit.h" #include "xml/repr.h" -#include "2geom/isnan.h" +#include <2geom/math-utils.h> #define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 6f385b8f5..9b88077e7 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -777,7 +777,7 @@ enclose_items(GSList const *items) Geom::OptRect r; for (GSList const *i = items; i; i = i->next) { - r = Geom::unify(r, ((SPItem *) i->data)->getBboxDesktop()); + r.unionWith(((SPItem *) i->data)->getBboxDesktop()); } return r; } diff --git a/src/selection.cpp b/src/selection.cpp index 7564fad3a..3c4ccccf2 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -375,7 +375,7 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect bbox; for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox = unify(bbox, SP_ITEM(i->data)->getBboxDesktop(type)); + bbox.unionWith(SP_ITEM(i->data)->getBboxDesktop(type)); } return bbox; } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 7e5f5f96a..424107426 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -825,7 +825,7 @@ void SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transfor // would therefore be translated into empty Geom::OptRect() (see bug https://bugs.launchpad.net/inkscape/+bug/168684) Geom::OptRect temp_bbox_new = Geom::Rect(Geom::Point(temp_bbox.x0, temp_bbox.y0), Geom::Point(temp_bbox.x1, temp_bbox.y1)); - bbox = Geom::unify(bbox, temp_bbox_new); + bbox.unionWith(temp_bbox_new); } // DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 36c135924..aa14e6ee5 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -56,7 +56,6 @@ #include "display/canvas-arena.h" #include "display/curve.h" #include "livarot/Shape.h" -#include <2geom/isnan.h> #include <2geom/transforms.h> #include "preferences.h" #include "style.h" diff --git a/src/style.cpp b/src/style.cpp index bb25a5f46..37a784e2a 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -42,7 +42,6 @@ #include "xml/repr.h" #include "xml/simple-document.h" #include "unit-constants.h" -#include "2geom/isnan.h" #include "macros.h" #include "preferences.h" diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index faa08ee91..022869c69 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -63,7 +63,6 @@ #include "display/canvas-arena.h" #include "display/curve.h" #include "livarot/Shape.h" -#include <2geom/isnan.h> #include <2geom/transforms.h> #include "preferences.h" #include "style.h" diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 0d890fa86..6f3b4dcb9 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1161,7 +1161,7 @@ bool SPDesktopWidget::showInfoDialog( Glib::ustring const &message ) GTK_BUTTONS_OK, "%s", message.c_str()); gtk_window_set_title( GTK_WINDOW(dialog), _("Note:")); // probably want to take this as a parameter. - gint response = gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } return result; @@ -1887,7 +1887,7 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()), Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) ); - Geom::OptRect deskarea = Geom::unify(darea, doc->getRoot()->getBboxDesktop()); + Geom::OptRect deskarea = darea | doc->getRoot()->getBboxDesktop(); /* Canvas region we always show unconditionally */ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64), -- cgit v1.2.3 From 72bd9c478ce6305e872f43ed9ac714ade8ac1cca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 24 Jun 2011 02:10:07 +0000 Subject: update file lists (bzr r10348) --- src/dom/CMakeLists.txt | 2 -- src/ui/CMakeLists.txt | 3 --- 2 files changed, 5 deletions(-) (limited to 'src') diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index b328418c7..c90b204f0 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -69,8 +69,6 @@ set(dom_SRC io/bufferstream.h io/domstream.h io/gzipstream.h - io/httpclient.h - io/socket.h io/stringstream.h io/uristream.h diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 30b72437f..9bbdd861e 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -166,9 +166,6 @@ set(ui_SRC dialog/tracedialog.h dialog/transformation.h dialog/undo-history.h - dialog/whiteboard-connect.h - dialog/whiteboard-sharewithchat.h - dialog/whiteboard-sharewithuser.h tool/commit-events.h tool/control-point-selection.h -- cgit v1.2.3 From be8f9d57bfd58257cd4a41642aa2d4be69610fd0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 23 Jun 2011 19:28:36 +0200 Subject: Filters. Fix for a crash introduced with revision 10313. (bzr r10349) --- src/extension/internal/filter/experimental.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index f60a6b414..96485ad97 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -301,7 +301,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) * Dilatation (1.->50., default 6) -> color2 (n-1th value) * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) - * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) + * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) @@ -379,7 +379,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream smooth; std::ostringstream dilat; std::ostringstream erosion; - std::ostringstream transluscent; + std::ostringstream translucent; std::ostringstream offset; std::ostringstream blur; std::ostringstream bdilat; @@ -401,10 +401,10 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) smooth << ext->get_param_float("smooth"); dilat << ext->get_param_float("dilat"); erosion << (- ext->get_param_float("erosion")); - if (ext->get_param_bool("transluscent")) - transluscent << "merge1"; + if (ext->get_param_bool("translucent")) + translucent << "merge1"; else - transluscent << "color5"; + translucent << "color5"; offset << ext->get_param_int("offset"); blur << ext->get_param_float("blur"); @@ -462,7 +462,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), transluscent.str().c_str()); + "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str()); return _filter; }; /* Drawing filter */ -- cgit v1.2.3 From ab143333746e25648b253f13c0539adff089b1b6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 24 Jun 2011 00:22:07 +0200 Subject: Remove more of libnr (bzr r10347.1.2) --- src/2geom/Makefile_insert | 2 +- src/2geom/d2-sbasis.h | 10 +- src/2geom/d2.h | 5 +- src/2geom/generic-rect.h | 31 +++- src/2geom/point-l.h | 86 --------- src/axis-manip.h | 2 +- src/box3d-context.cpp | 22 +-- src/desktop-events.cpp | 18 +- src/desktop.cpp | 1 + src/dialogs/clonetiler.cpp | 1 + src/display/canvas-axonomgrid.cpp | 25 +-- src/display/canvas-grid.cpp | 12 +- src/display/guideline.cpp | 12 +- src/display/nr-arena-glyphs.cpp | 8 +- src/display/nr-arena-group.cpp | 2 +- src/display/nr-arena-item.h | 2 + src/display/nr-arena-shape.cpp | 16 +- src/display/nr-arena-shape.h | 1 + src/display/nr-arena.cpp | 1 + src/display/nr-filter-displacement-map.cpp | 189 -------------------- src/display/nr-filter-turbulence.cpp | 1 - src/display/nr-filter-turbulence.h | 1 - src/display/nr-filter-units.cpp | 17 +- src/display/nr-filter-units.h | 2 +- src/display/nr-filter.cpp | 8 +- src/display/sp-canvas.cpp | 10 +- src/display/sp-canvas.h | 2 +- src/document.cpp | 3 +- src/draw-context.h | 2 +- src/dropper-context.cpp | 9 +- src/extension/implementation/implementation.h | 2 +- src/gradient-chemistry.cpp | 4 +- src/gradient-context.cpp | 6 +- src/graphlayout.cpp | 1 + src/helper/geom.cpp | 10 +- src/helper/geom.h | 4 +- src/helper/pixbuf-ops.cpp | 1 + src/helper/png-write.cpp | 1 + src/libnr/Makefile_insert | 13 +- src/libnr/in-svg-plane.h | 5 +- src/libnr/libnr.def | 89 ---------- src/libnr/nr-convert2geom.h | 34 +--- src/libnr/nr-coord.h | 29 --- src/libnr/nr-dim2.h | 22 --- src/libnr/nr-forward.h | 10 -- src/libnr/nr-i-coord.h | 25 --- src/libnr/nr-point-fns-test.h | 139 --------------- src/libnr/nr-point-fns.cpp | 91 ++-------- src/libnr/nr-point-fns.h | 95 +--------- src/libnr/nr-point-l.h | 103 ----------- src/libnr/nr-point-ops.h | 88 ---------- src/libnr/nr-point.h | 155 ---------------- src/libnr/nr-rect-l.cpp | 20 --- src/libnr/nr-rect-l.h | 124 +------------ src/libnr/nr-rect-ops.h | 51 ------ src/libnr/nr-rect.cpp | 198 ++------------------- src/libnr/nr-rect.h | 243 ++------------------------ src/libnr/nr-render.h | 25 --- src/libnr/nr-types-test.h | 142 --------------- src/libnr/nr-types.cpp | 67 ------- src/libnr/nr-types.h | 39 ----- src/libnr/nr-values.cpp | 9 +- src/libnr/nr-values.h | 5 +- src/libnr/nr_config.h.mingw | 12 -- src/libnr/nr_config.h.win32 | 14 -- src/livarot/Path.h | 3 +- src/livarot/PathSimplify.cpp | 1 + src/livarot/Shape.cpp | 6 +- src/livarot/Shape.h | 2 +- src/livarot/path-description.h | 2 +- src/livarot/sweep-event.h | 2 +- src/livarot/sweep-tree.h | 2 +- src/marker.cpp | 1 + src/object-edit.cpp | 4 +- src/pen-context.cpp | 3 +- src/pencil-context.cpp | 12 +- src/rect-context.cpp | 4 +- src/rect-context.h | 2 +- src/removeoverlap.cpp | 3 +- src/selection.cpp | 2 +- src/snap.cpp | 3 +- src/sp-conn-end-pair.h | 1 - src/sp-flowtext.cpp | 5 +- src/sp-image.cpp | 3 +- src/sp-item.cpp | 2 +- src/sp-mask.cpp | 3 +- src/sp-namedview.cpp | 4 +- src/sp-offset.cpp | 2 +- src/sp-root.cpp | 1 + src/sp-text.h | 1 - src/spiral-context.cpp | 8 +- src/spiral-context.h | 2 +- src/spray-context.h | 2 +- src/star-context.cpp | 6 +- src/star-context.h | 2 +- src/svg-view.cpp | 1 + src/tweak-context.h | 2 +- src/ui/cache/svg_preview_cache.cpp | 1 + src/ui/dialog/align-and-distribute.cpp | 6 +- src/ui/dialog/align-and-distribute.h | 1 - src/ui/dialog/tile.cpp | 1 + src/ui/dialog/transformation.cpp | 1 + src/ui/view/edit-widget-interface.h | 2 +- src/ui/view/view.cpp | 2 +- src/ui/widget/page-sizer.cpp | 1 + src/ui/widget/rotateable.cpp | 7 +- src/ui/widget/ruler.h | 2 +- src/unclump.cpp | 1 + src/widgets/dash-selector.cpp | 4 +- src/widgets/desktop-widget.cpp | 7 +- src/widgets/desktop-widget.h | 2 +- src/widgets/icon.cpp | 1 + src/widgets/toolbox.cpp | 8 +- 113 files changed, 284 insertions(+), 2237 deletions(-) delete mode 100644 src/2geom/point-l.h delete mode 100644 src/libnr/libnr.def delete mode 100644 src/libnr/nr-coord.h delete mode 100644 src/libnr/nr-dim2.h delete mode 100644 src/libnr/nr-i-coord.h delete mode 100644 src/libnr/nr-point-fns-test.h delete mode 100644 src/libnr/nr-point-l.h delete mode 100644 src/libnr/nr-point-ops.h delete mode 100644 src/libnr/nr-point.h delete mode 100644 src/libnr/nr-rect-ops.h delete mode 100644 src/libnr/nr-render.h delete mode 100644 src/libnr/nr-types-test.h delete mode 100644 src/libnr/nr-types.cpp delete mode 100644 src/libnr/nr-types.h delete mode 100644 src/libnr/nr_config.h.mingw delete mode 100644 src/libnr/nr_config.h.win32 (limited to 'src') diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index a668a2b3b..08bcbff45 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -77,8 +77,8 @@ 2geom/quadtree.cpp \ 2geom/quadtree.h \ 2geom/ray.h \ - 2geom/rect.h \ 2geom/rect.cpp \ + 2geom/rect.h \ 2geom/region.cpp \ 2geom/region.h \ 2geom/sbasis-2d.cpp \ diff --git a/src/2geom/d2-sbasis.h b/src/2geom/d2-sbasis.h index 95c0da4ed..e61067e1b 100644 --- a/src/2geom/d2-sbasis.h +++ b/src/2geom/d2-sbasis.h @@ -35,11 +35,11 @@ * */ -#ifdef _2GEOM_D2 /*This is intentional: we don't actually want anyone to - include this, other than D2.h. If somone else tries, D2 - won't be defined. If it is, this will already be included. */ -#ifndef __2GEOM_SBASIS_CURVE_H -#define __2GEOM_SBASIS_CURVE_H +#ifdef SEEN_LIB2GEOM_D2_H /*This is intentional: we don't actually want anyone to + include this, other than D2.h. If somone else tries, D2 + won't be defined. If it is, this will already be included. */ +#ifndef SEEN_LIB2GEOM_D2_SBASIS_H +#define SEEN_LIB2GEOM_D2_SBASIS_H #include <2geom/sbasis.h> #include <2geom/sbasis-2d.h> diff --git a/src/2geom/d2.h b/src/2geom/d2.h index 73330295b..4a4f45a63 100644 --- a/src/2geom/d2.h +++ b/src/2geom/d2.h @@ -29,12 +29,13 @@ * */ -#ifndef _2GEOM_D2 //If this is change, change the guard in rect.h as well. -#define _2GEOM_D2 +#ifndef SEEN_LIB2GEOM_D2_H +#define SEEN_LIB2GEOM_D2_H #include <2geom/point.h> #include <2geom/interval.h> #include <2geom/affine.h> +#include <2geom/rect.h> #include #include <2geom/concepts.h> diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index cc0d7d42e..9a839d735 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -69,7 +69,7 @@ public: /// @name Create rectangles. /// @{ /** @brief Create a rectangle that contains only the point at (0,0). */ - GenericRect() { f[X] = f[Y] = Interval(); } + GenericRect() { f[X] = f[Y] = CInterval(); } /** @brief Create a rectangle from X and Y intervals. */ GenericRect(CInterval const &a, CInterval const &b) { f[X] = a; @@ -102,6 +102,25 @@ public: GenericRect result = GenericRect::from_range(c, c+n); return result; } + /** @brief Create rectangle from origin and dimensions. */ + static GenericRect from_xywh(C x, C y, C w, C h) { + CPoint xy(x, y); + CPoint wh(w, h); + GenericRect result(xy, xy + wh); + return result; + } + /** @brief Create rectangle from origin and dimensions. */ + static GenericRect from_xywh(CPoint const &xy, CPoint const &wh) { + GenericRect result(xy, xy + wh); + return result; + } + /** @brief Create rectangle from two points. */ + static GenericRect from_xyxy(C x0, C x1, C y0, C y1) { + CPoint p0(x0, y0); + CPoint p1(x1, y1); + GenericRect result(p0, p1); + return result; + } /// @} /// @name Inspect dimensions. @@ -183,6 +202,16 @@ public: /// @name Modify the rectangle. /// @{ + /** @brief Set the upper left point of the rectangle. */ + void setMin(CPoint const &p) { + f[X].setMin(p[X]); + f[Y].setMin(p[Y]); + } + /** @brief Set the lower right point of the rectangle. */ + void setMax(CPoint const &p) { + f[X].setMax(p[X]); + f[Y].setMax(p[Y]); + } /** @brief Enlarge the rectangle to contain the given point. */ void expandTo(CPoint const &p) { f[X].expandTo(p[X]); f[Y].expandTo(p[Y]); diff --git a/src/2geom/point-l.h b/src/2geom/point-l.h deleted file mode 100644 index d57314a19..000000000 --- a/src/2geom/point-l.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef SEEN_Geom_POINT_L_H -#define SEEN_Geom_POINT_L_H - -#include -#include <2geom/point.h> - -namespace Geom { - -typedef long ICoord; - -class IPoint { - ICoord _pt[2]; - - public: - IPoint() { } - - IPoint(ICoord x, ICoord y) { - _pt[X] = x; - _pt[Y] = y; - } - - IPoint(NRPointL const &p) { - _pt[X] = p.x; - _pt[Y] = p.y; - } - - IPoint(IPoint const &p) { - for (unsigned i = 0; i < 2; ++i) { - _pt[i] = p._pt[i]; - } - } - - IPoint &operator=(IPoint const &p) { - for (unsigned i = 0; i < 2; ++i) { - _pt[i] = p._pt[i]; - } - return *this; - } - - operator Point() { - return Point(_pt[X], _pt[Y]); - } - - ICoord operator[](unsigned i) const throw(std::out_of_range) { - if ( i > Y ) throw std::out_of_range("index out of range"); - return _pt[i]; - } - - ICoord &operator[](unsigned i) throw(std::out_of_range) { - if ( i > Y ) throw std::out_of_range("index out of range"); - return _pt[i]; - } - - ICoord operator[](Dim2 d) const throw() { return _pt[d]; } - ICoord &operator[](Dim2 d) throw() { return _pt[d]; } - - IPoint &operator+=(IPoint const &o) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] += o._pt[i]; - } - return *this; - } - - IPoint &operator-=(IPoint const &o) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] -= o._pt[i]; - } - return *this; - } -}; - - -} // namespace Geom - -#endif /* !SEEN_Geom_POINT_L_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/axis-manip.h b/src/axis-manip.h index 835f67a97..d81da4164 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -12,8 +12,8 @@ #ifndef SEEN_AXIS_MANIP_H #define SEEN_AXIS_MANIP_H +#include #include -#include "libnr/nr-point.h" namespace Proj { diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 90f1707b9..fad7c0761 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -301,11 +301,11 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven m.setup(desktop, true, bc->item); m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); - bc->center = from_2geom(button_dt); + bc->center = button_dt; - bc->drag_origin = from_2geom(button_dt); - bc->drag_ptB = from_2geom(button_dt); - bc->drag_ptC = from_2geom(button_dt); + bc->drag_origin = button_dt; + bc->drag_ptB = button_dt; + bc->drag_ptC = button_dt; // This can happen after saving when the last remaining perspective was purged and must be recreated. if (!cur_persp) { @@ -314,7 +314,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } /* Projective preimages of clicked point under current perspective */ - bc->drag_origin_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(button_dt), 0, Proj::Z); + bc->drag_origin_proj = cur_persp->perspective_impl->tmat.preimage (button_dt, 0, Proj::Z); bc->drag_ptB_proj = bc->drag_origin_proj; bc->drag_ptC_proj = bc->drag_origin_proj; bc->drag_ptC_proj.normalize(); @@ -358,10 +358,10 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } if (!bc->extruded) { - bc->drag_ptB = from_2geom(motion_dt); - bc->drag_ptC = from_2geom(motion_dt); + bc->drag_ptB = motion_dt; + bc->drag_ptC = motion_dt; - bc->drag_ptB_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(motion_dt), 0, Proj::Z); + bc->drag_ptB_proj = cur_persp->perspective_impl->tmat.preimage (motion_dt, 0, Proj::Z); bc->drag_ptC_proj = bc->drag_ptB_proj; bc->drag_ptC_proj.normalize(); bc->drag_ptC_proj[Proj::Z] = 0.25; @@ -371,15 +371,15 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven if (!bc->ctrl_dragged) { /* snapping */ Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, document->getCurrentPersp3D()); - bc->drag_ptC = pline.closest_to (from_2geom(motion_dt)); + bc->drag_ptC = pline.closest_to (motion_dt); bc->drag_ptB_proj.normalize(); bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X); } else { - bc->drag_ptC = from_2geom(motion_dt); + bc->drag_ptC = motion_dt; bc->drag_ptB_proj.normalize(); - bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(motion_dt), bc->drag_ptB_proj[Proj::X], Proj::X); + bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X); } m.freeSnapReturnByRef(bc->drag_ptC, Inkscape::SNAPSOURCE_NODE_HANDLE); } diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index eb2b3a093..df1bf0c7a 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -155,9 +155,9 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge m.unSetup(); } - sp_guideline_set_position(SP_GUIDELINE(guide), from_2geom(event_dt)); - desktop->set_coordinate_status(to_2geom(event_dt)); - desktop->setPosition(to_2geom(event_dt)); + sp_guideline_set_position(SP_GUIDELINE(guide), event_dt); + desktop->set_coordinate_status(event_dt); + desktop->setPosition(event_dt); } break; case GDK_BUTTON_RELEASE: @@ -186,13 +186,13 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); sp_repr_set_point(repr, "orientation", normal); - sp_repr_set_point(repr, "position", from_2geom(event_dt)); + sp_repr_set_point(repr, "position", event_dt); desktop->namedview->appendChild(repr); Inkscape::GC::release(repr); DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create guide")); } - desktop->set_coordinate_status(from_2geom(event_dt)); + desktop->set_coordinate_status(event_dt); } default: break; @@ -345,8 +345,8 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) break; } moved = true; - desktop->set_coordinate_status(from_2geom(motion_dt)); - desktop->setPosition(from_2geom(motion_dt)); + desktop->set_coordinate_status(motion_dt); + desktop->setPosition(motion_dt); ret = TRUE; } @@ -429,8 +429,8 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) _("Delete guide")); } moved = false; - desktop->set_coordinate_status(from_2geom(event_dt)); - desktop->setPosition (from_2geom(event_dt)); + desktop->set_coordinate_status(event_dt); + desktop->setPosition (event_dt); } drag_type = SP_DRAG_NONE; sp_canvas_item_ungrab(item, event->button.time); diff --git a/src/desktop.cpp b/src/desktop.cpp index f12f83ca6..181a19e1b 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -57,6 +57,7 @@ #include #include +#include <2geom/transforms.h> #include <2geom/rect.h> #include "macros.h" #include "inkscape-private.h" diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 60ec4f9f7..b9e490dcf 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -17,6 +17,7 @@ #include #include #include +#include <2geom/transforms.h> #include "desktop.h" #include "desktop-handles.h" diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index a9893f09d..daad2d515 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -33,6 +33,7 @@ #include "svg/svg-color.h" #include "util/mathfns.h" #include "xml/node-event-vector.h" +#include "round.h" #define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params @@ -549,13 +550,13 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // x-axis always goes from topleft to bottomright. (0,0) - (1,1) gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ; gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.y0; - gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw ); + gint const xlinestart = round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw ); gint xlinenum = xlinestart; // lines starting on left side. for (y = xstart_y_sc; y < buf->rect.y1; y += lyw, xlinenum++) { gint const x0 = buf->rect.x0; - gint const y0 = (gint) Inkscape::round(y); - gint const x1 = x0 + (gint) Inkscape::round( (buf->rect.y1 - y) / tan_angle[X] ); + gint const y0 = round(y); + gint const x1 = x0 + round( (buf->rect.y1 - y) / tan_angle[X] ); gint const y1 = buf->rect.y1; if (!scaled && (xlinenum % empspacing) != 0) { @@ -570,8 +571,8 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) for (x = xstart_x_sc; x < buf->rect.x1; x += lxw_x, xlinenum--) { gint const y0 = buf->rect.y0; gint const y1 = buf->rect.y1; - gint const x0 = (gint) Inkscape::round(x); - gint const x1 = x0 + (gint) Inkscape::round( (y1 - y0) / tan_angle[X] ); + 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); @@ -582,10 +583,10 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // y-axis lines (vertical) gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X]; - gint const ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[Geom::X]) / spacing_ylines); + gint const ylinestart = round((ystart_x_sc - ow[Geom::X]) / spacing_ylines); gint ylinenum = ylinestart; for (x = ystart_x_sc; x < buf->rect.x1; x += spacing_ylines, ylinenum++) { - gint const x0 = (gint) Inkscape::round(x); + gint const x0 = round(x); if (!scaled && (ylinenum % empspacing) != 0) { sp_grid_vline (buf, x0, buf->rect.y0, buf->rect.y1 - 1, color); @@ -597,13 +598,13 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // z-axis always goes from bottomleft to topright. (0,1) - (1,0) gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ; gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.y0; - gint const zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw ); + gint const zlinestart = round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw ); gint zlinenum = zlinestart; // lines starting from left side for (y = zstart_y_sc; y < buf->rect.y1; y += lyw, zlinenum++) { gint const x0 = buf->rect.x0; - gint const y0 = (gint) Inkscape::round(y); - gint const x1 = x0 + (gint) Inkscape::round( (y - buf->rect.y0 ) / tan_angle[Z] ); + gint const y0 = round(y); + gint const x1 = x0 + round( (y - buf->rect.y0 ) / tan_angle[Z] ); gint const y1 = buf->rect.y0; if (!scaled && (zlinenum % empspacing) != 0) { @@ -617,8 +618,8 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) for (x = zstart_x_sc; x < buf->rect.x1; x += lxw_z, zlinenum++) { gint const y0 = buf->rect.y1; gint const y1 = buf->rect.y0; - gint const x0 = (gint) Inkscape::round(x); - gint const x1 = x0 + (gint) Inkscape::round( (buf->rect.y1 - buf->rect.y0) / tan_angle[Z] ); + gint const x0 = round(x); + gint const x1 = x0 + round( (buf->rect.y1 - buf->rect.y0) / tan_angle[Z] ); if (!scaled && (zlinenum % empspacing) != 0) { sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 82ea036f6..52963ce6b 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -918,9 +918,9 @@ void CanvasXYGrid::Render (SPCanvasBuf *buf) { gdouble const sxg = floor ((buf->rect.x0 - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X]; - gint const xlinestart = (gint) Inkscape::round((sxg - ow[Geom::X]) / sw[Geom::X]); + gint const xlinestart = round((sxg - ow[Geom::X]) / sw[Geom::X]); gdouble const syg = floor ((buf->rect.y0 - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y]; - gint const ylinestart = (gint) Inkscape::round((syg - ow[Geom::Y]) / sw[Geom::Y]); + gint const ylinestart = round((syg - ow[Geom::Y]) / sw[Geom::Y]); //set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -941,7 +941,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) gint ylinenum; gdouble y; for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) { - gint const y0 = (gint) Inkscape::round(y); + gint const y0 = round(y); if (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) { grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color); } else { @@ -952,7 +952,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) gint xlinenum; gdouble x; for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) { - gint const ix = (gint) Inkscape::round(x); + gint const ix = round(x); if (!scaled[Geom::X] && (xlinenum % empspacing) != 0) { grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color); } else { @@ -963,12 +963,12 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) gint ylinenum; gdouble y; for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) { - gint const iy = (gint) Inkscape::round(y); + gint const iy = round(y); gint xlinenum; gdouble x; for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) { - gint const ix = (gint) Inkscape::round(x); + gint const ix = round(x); if ( (!scaled[Geom::X] && (xlinenum % empspacing) != 0) || (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) || ((scaled[Geom::X] || scaled[Geom::Y]) && no_emp_when_zoomed_out) ) diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index c761fa74e..c1c3e7740 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -112,8 +112,8 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); cairo_set_font_size(buf->ct, 10); - int px = (int) Inkscape::round(gl->point_on_line[Geom::X]); - int py = (int) Inkscape::round(gl->point_on_line[Geom::Y]); + int px = round(gl->point_on_line[Geom::X]); + int py = round(gl->point_on_line[Geom::Y]); if (gl->label) { cairo_save(buf->ct); @@ -126,12 +126,12 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) } if (gl->is_vertical()) { - int position = (int) Inkscape::round(gl->point_on_line[Geom::X]); + int position = round(gl->point_on_line[Geom::X]); cairo_move_to(buf->ct, position + 0.5, buf->rect.y0 + 0.5); cairo_line_to(buf->ct, position + 0.5, buf->rect.y1 - 0.5); cairo_stroke(buf->ct); } else if (gl->is_horizontal()) { - int position = (int) Inkscape::round(gl->point_on_line[Geom::Y]); + int position = round(gl->point_on_line[Geom::Y]); cairo_move_to(buf->ct, buf->rect.x0 + 0.5, position + 0.5); cairo_line_to(buf->ct, buf->rect.x1 - 0.5, position + 0.5); cairo_stroke(buf->ct); @@ -193,9 +193,9 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, sp_canvas_item_request_update(SP_CANVAS_ITEM (gl->origin)); if (gl->is_horizontal()) { - sp_canvas_update_bbox (item, -1000000, (int) Inkscape::round(gl->point_on_line[Geom::Y] - 16), 1000000, (int) Inkscape::round(gl->point_on_line[Geom::Y] + 1)); + sp_canvas_update_bbox (item, -1000000, round(gl->point_on_line[Geom::Y] - 16), 1000000, round(gl->point_on_line[Geom::Y] + 1)); } else if (gl->is_vertical()) { - sp_canvas_update_bbox (item, (int) Inkscape::round(gl->point_on_line[Geom::X]), -1000000, (int) Inkscape::round(gl->point_on_line[Geom::X] + 16), 1000000); + sp_canvas_update_bbox (item, round(gl->point_on_line[Geom::X]), -1000000, round(gl->point_on_line[Geom::X] + 16), 1000000); } else { //TODO: labels in angled guidelines are not showing up for some reason. sp_canvas_update_bbox (item, -1000000, -1000000, 1000000, 1000000); diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index dbac07596..0e20f0ddb 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -135,10 +135,10 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s } if (b) { - item->bbox.x0 = static_cast(floor(b->left())); - item->bbox.y0 = static_cast(floor(b->top())); - item->bbox.x1 = static_cast(ceil (b->right())); - item->bbox.y1 = static_cast(ceil (b->bottom())); + item->bbox.x0 = floor(b->left()); + item->bbox.y0 = floor(b->top()); + item->bbox.x1 = ceil (b->right()); + item->bbox.y1 = ceil (b->bottom()); } else { item->bbox.x0 = 0; item->bbox.y0 = 0; diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 97f92d02d..d1e6869aa 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -176,7 +176,7 @@ nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int } if (beststate & NR_ARENA_ITEM_STATE_BBOX) { - nr_rect_l_set_empty (&item->bbox); + item->bbox = NR_RECT_L_EMPTY; for (NRArenaItem *child = group->children; child != NULL; child = child->next) { if (child->visible) nr_rect_l_union (&item->bbox, &item->bbox, &child->drawbox); diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 0fc4cbe48..d65a75ed8 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -15,6 +15,8 @@ #include #include <2geom/affine.h> +#include <2geom/rect.h> +#include "libnr/nr-forward.h" #include "libnr/nr-rect-l.h" #include "libnr/nr-object.h" #include "gc-soft-ptr.h" diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index eb7a30e58..ff87b5134 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -223,10 +223,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); if (boundingbox) { - item->bbox.x0 = static_cast(floor((*boundingbox)[0][0])); // Floor gives the coordinate in which the point resides - item->bbox.y0 = static_cast(floor((*boundingbox)[1][0])); - item->bbox.x1 = static_cast(ceil ((*boundingbox)[0][1])); // Ceil gives the first coordinate beyond the point - item->bbox.y1 = static_cast(ceil ((*boundingbox)[1][1])); + item->bbox.x0 = floor((*boundingbox)[0][0]); // Floor gives the coordinate in which the point resides + item->bbox.y0 = floor((*boundingbox)[1][0]); + item->bbox.x1 = ceil ((*boundingbox)[0][1]); // Ceil gives the first coordinate beyond the point + item->bbox.y1 = ceil ((*boundingbox)[1][1]); } else { item->bbox = NR_RECT_L_EMPTY; } @@ -274,10 +274,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g /// \todo just write item->bbox = boundingbox if (boundingbox) { - shape->approx_bbox.x0 = static_cast(floor((*boundingbox)[0][0])); - shape->approx_bbox.y0 = static_cast(floor((*boundingbox)[1][0])); - shape->approx_bbox.x1 = static_cast(ceil ((*boundingbox)[0][1])); - shape->approx_bbox.y1 = static_cast(ceil ((*boundingbox)[1][1])); + shape->approx_bbox.x0 = floor(boundingbox->left()); + shape->approx_bbox.y0 = floor(boundingbox->top()); + shape->approx_bbox.x1 = ceil (boundingbox->right()); + shape->approx_bbox.y1 = ceil (boundingbox->bottom()); } else { shape->approx_bbox = NR_RECT_L_EMPTY; } diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index 2ee0d24c8..7b86f7f59 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -22,6 +22,7 @@ #include "forward.h" #include "nr-arena-item.h" #include "nr-style.h" +#include "libnr/nr-rect.h" NRType nr_arena_shape_get_type (void); diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index 43edb6918..ce62a81dc 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -18,6 +18,7 @@ #include "nr-filter-types.h" #include "preferences.h" #include "color.h" +#include "libnr/nr-rect.h" static void nr_arena_class_init (NRArenaClass *klass); static void nr_arena_init (NRArena *arena); diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index fdaf2c887..15200223b 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -28,128 +28,6 @@ FilterPrimitive * FilterDisplacementMap::create() { FilterDisplacementMap::~FilterDisplacementMap() {} -#if 0 -struct pixel_t { - unsigned char channels[4]; - inline unsigned char operator[](int c) const { return channels[c]; } - inline unsigned char& operator[](int c) { return channels[c]; } - static inline pixel_t blank() { - pixel_t p; - for(unsigned int i=0; i<4; i++) { - p[i] = 0; - } - return p; - } -}; - -static inline pixel_t pixelValue(NRPixBlock const* pb, int x, int y) { - if ( x < pb->area.x0 || x >= pb->area.x1 || y < pb->area.y0 || y >= pb->area.y1 ) return pixel_t::blank(); // This assumes anything outside the defined range is (0,0,0,0) - pixel_t const* rowData = reinterpret_cast(NR_PIXBLOCK_PX(pb) + (y-pb->area.y0)*pb->rs); - return rowData[x-pb->area.x0]; -} - -template -static pixel_t interpolatePixels(NRPixBlock const* pb, double x, double y) { - // NOTE: The values of x and y are shifted by -0.5 (the "true" values would be x+0.5 and y+0.5). - // This is done because otherwise the pixel values first have to be shifted by +0.5 and then by -0.5 again... - unsigned int const sfl = 8u; - unsigned int const sf = 1u<(round(sf * (x - xi))), - yf = static_cast(round(sf * (y - yi))); - pixel_t p00 = pixelValue(pb, xi+0, yi+0); - pixel_t p01 = pixelValue(pb, xi+1, yi+0); - pixel_t p10 = pixelValue(pb, xi+0, yi+1); - pixel_t p11 = pixelValue(pb, xi+1, yi+1); - - /* It's a good idea to interpolate premultiplied colors: - * - * Consider two pixels, one being rgba(255,0,0,0), which is fully transparent, - * and the other being rgba(0,0,255,255), or blue (fully opaque). - * If these two colors are interpolated the expected result would be bluish pixels - * containing no red. - * - * However, if our final alpha value is zero, then the RGB values aren't really determinate. - * We might as well avoid premultiplication in this case, which still gives us a fully - * transparent result, but with interpolated RGB parts. */ - - pixel_t r; - if (PREMULTIPLIED) { - /* Premultiplied, so do simple interpolation. */ - for (unsigned i = 0; i != 4; ++i) { - // y0,y1 have range [0,a*sf] - unsigned const y0 = sf*p00[i] + xf*((unsigned int)p01[i]-(unsigned int)p00[i]); - unsigned const y1 = sf*p10[i] + xf*((unsigned int)p11[i]-(unsigned int)p10[i]); - - unsigned const ri = sf*y0 + yf*(y1-y0); // range [0,a*sf*sf] - r[i] = (ri + sf2h)>>(2*sfl); // range [0,a] - } - } else { - /* First calculate interpolated alpha value. */ - unsigned const y0 = sf*p00[3] + xf*((unsigned int)p01[3]-(unsigned int)p00[3]); // range [0,a*sf] - unsigned const y1 = sf*p10[3] + xf*((unsigned int)p11[3]-(unsigned int)p10[3]); - unsigned const ra = sf*y0 + yf*(y1-y0); // range [0,a*sf*sf] - - if (ra==0) { - /* Fully transparent, so do simple interpolation. */ - for (unsigned i = 0; i != 3; ++i) { - // y0,y1 have range [0,255*sf] - unsigned const y0 = sf*p00[i] + xf*((unsigned int)p01[i]-(unsigned int)p00[i]); - unsigned const y1 = sf*p10[i] + xf*((unsigned int)p11[i]-(unsigned int)p10[i]); - - unsigned const ri = sf*y0 + yf*(y1-y0); // range [0,255*sf*sf] - r[i] = (ri + sf2h)>>(2*sfl); // range [0,255] - } - r[3] = 0; - } else { - /* Do premultiplication ourselves. */ - for (unsigned i = 0; i != 3; ++i) { - // Premultiplied versions. Range [0,255*a]. - unsigned const c00 = p00[i]*p00[3]; - unsigned const c01 = p01[i]*p01[3]; - unsigned const c10 = p10[i]*p10[3]; - unsigned const c11 = p11[i]*p11[3]; - - // Interpolation. - unsigned const y0 = sf*c00 + xf*(c01-c00); // range [0,255*a*sf] - unsigned const y1 = sf*c10 + xf*(c11-c10); // range [0,255*a*sf] - unsigned const ri = sf*y0 + yf*(y1-y0); // range [0,255*a*sf*sf] - r[i] = (ri + ra/2) / ra; // range [0,255] - } - r[3] = (ra + sf2h)>>(2*sfl); // range [0,a] - } - } - - return r; -} - -template -static void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map, int Xchannel, int Ychannel, NRPixBlock* out, double scalex, double scaley) { - bool Xneedsdemul = MAP_PREMULTIPLIED && Xchannel<3; - bool Yneedsdemul = MAP_PREMULTIPLIED && Ychannel<3; - if (!Xneedsdemul) scalex /= 255.0; - if (!Yneedsdemul) scaley /= 255.0; - - for (int yout=out->area.y0; yout < out->area.y1; yout++){ - pixel_t const* mapRowData = reinterpret_cast(NR_PIXBLOCK_PX(map) + (yout-map->area.y0)*map->rs); - pixel_t* outRowData = reinterpret_cast(NR_PIXBLOCK_PX(out) + (yout-out->area.y0)*out->rs); - for (int xout=out->area.x0; xout < out->area.x1; xout++){ - pixel_t const mapValue = mapRowData[xout-map->area.x0]; - - double xtex = xout + (Xneedsdemul ? // Although the value of the pixel corresponds to the MIDDLE of the pixel, no +0.5 is needed because we're interpolating pixels anyway (so to get the actual pixel locations 0.5 would have to be subtracted again). - (mapValue[3]==0?0:(scalex * (mapValue[Xchannel] - mapValue[3]*0.5) / mapValue[3])) : - (scalex * (mapValue[Xchannel] - 127.5))); - double ytex = yout + (Yneedsdemul ? - (mapValue[3]==0?0:(scaley * (mapValue[Ychannel] - mapValue[3]*0.5) / mapValue[3])) : - (scaley * (mapValue[Ychannel] - 127.5))); - - outRowData[xout-out->area.x0] = interpolatePixels(texture, xtex, ytex); - } - } -} -#endif - struct Displace { Displace(cairo_surface_t *texture, cairo_surface_t *map, unsigned xch, unsigned ych, double scalex, double scaley) @@ -206,73 +84,6 @@ void FilterDisplacementMap::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -/* -int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) { - NRPixBlock *texture = slot.get(_input); - NRPixBlock *map = slot.get(_input2); - - // Bail out if either one of source images is missing - if (!map || !texture) { - g_warning("Missing source image for feDisplacementMap (map=%d texture=%d)", _input, _input2); - return 1; - } - - NR::IRect area = units.get_pixblock_filterarea_paraller(); - int x0 = std::max(map->area.x0,area.min()[NR::X]); - int y0 = std::max(map->area.y0,area.min()[NR::Y]); - int x1 = std::min(map->area.x1,area.max()[NR::X]); - int y1 = std::min(map->area.y1,area.max()[NR::Y]); - - //TODO: check whether we really need this check: - if (x1 <= x0 || y1 <= y0) return 0; //nothing to do! - - if (texture->mode != NR_PIXBLOCK_MODE_R8G8B8A8N && texture->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - g_warning("Source images without an alpha channel are not supported by feDisplacementMap at the moment."); - return 1; - } - - NRPixBlock *out = new NRPixBlock; - nr_pixblock_setup_fast(out, texture->mode, x0, y0, x1, y1, true); - - // convert to a suitable format - bool free_map_on_exit = false; - if (map->mode != NR_PIXBLOCK_MODE_R8G8B8A8N && map->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) { - NRPixBlock *original_map = map; - map = new NRPixBlock; - nr_pixblock_setup_fast(map, NR_PIXBLOCK_MODE_R8G8B8A8N, - original_map->area.x0, original_map->area.y0, - original_map->area.x1, original_map->area.y1, - false); - nr_blit_pixblock_pixblock(map, original_map); - free_map_on_exit = true; - } - bool map_premultiplied = (map->mode == NR_PIXBLOCK_MODE_R8G8B8A8P); - bool data_premultiplied = (out->mode == NR_PIXBLOCK_MODE_R8G8B8A8P); - - Geom::Affine trans = units.get_matrix_primitiveunits2pb(); - double scalex = scale * trans.expansionX(); - double scaley = scale * trans.expansionY(); - - if (map_premultiplied && data_premultiplied) { - performDisplacement(texture, map, Xchannel, Ychannel, out, scalex, scaley); - } else if (map_premultiplied && !data_premultiplied) { - performDisplacement(texture, map, Xchannel, Ychannel, out, scalex, scaley); - } else if (data_premultiplied) { - performDisplacement(texture, map, Xchannel, Ychannel, out, scalex, scaley); - } else { - performDisplacement(texture, map, Xchannel, Ychannel, out, scalex, scaley); - } - - if (free_map_on_exit) { - nr_pixblock_release(map); - delete map; - } - - out->empty = FALSE; - slot.set(_output, out); - return 0; -}*/ - void FilterDisplacementMap::set_input(int slot) { _input = slot; } diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index f3b03c024..60d5ce872 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -299,7 +299,6 @@ FilterTurbulence::FilterTurbulence() , numOctaves(1) , seed(0) , updated(false) - , updated_area(NR::IPoint(), NR::IPoint()) , fTileWidth(10) //guessed , fTileHeight(10) //guessed , fTileX(1) //guessed diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 50161b6be..8d3639543 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -64,7 +64,6 @@ private: bool stitchTiles; FilterTurbulenceType type; bool updated; - NR::IRect updated_area; unsigned char *pix_data; double fTileWidth; diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp index b1c475c41..a8686545a 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -158,22 +158,13 @@ Geom::Affine FilterUnits::get_matrix_user2primitiveunits() const { return get_matrix_user2units(primitiveUnits); } -NR::IRect FilterUnits::get_pixblock_filterarea_paraller() const { +Geom::IntRect FilterUnits::get_pixblock_filterarea_paraller() const { g_assert(filter_area); - int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; Geom::Affine u2pb = get_matrix_user2pb(); - - for (int i = 0 ; i < 4 ; i++) { - Geom::Point p = filter_area->corner(i); - p *= u2pb; - if (p[X] < min_x) min_x = (int)std::floor(p[X]); - if (p[X] > max_x) max_x = (int)std::ceil(p[X]); - if (p[Y] < min_y) min_y = (int)std::floor(p[Y]); - if (p[Y] > max_y) max_y = (int)std::ceil(p[Y]); - } - NR::IRect ret(NR::IPoint(min_x, min_y), NR::IPoint(max_x, max_y)); - return ret; + Geom::Rect r = *filter_area * u2pb; + Geom::IntRect ir = r.roundOutwards(); + return ir; } FilterUnits& FilterUnits::operator=(FilterUnits const &other) { diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index 2fc3e5533..1cb4fdbce 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -133,7 +133,7 @@ public: * NOTE: use only in filters, that define TRAIT_PARALLER in * get_input_traits. The filter effects area may not be representable * by simple rectangle otherwise. */ - NR::IRect get_pixblock_filterarea_paraller() const; + Geom::IntRect get_pixblock_filterarea_paraller() const; FilterUnits& operator=(FilterUnits const &other); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 55190b00c..a0997cc1b 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -238,10 +238,10 @@ void Filter::compute_drawbox(NRArenaItem const *item, NRRectL &item_bbox) { Geom::Rect enlarged = filter_effect_area(tmp_bbox); enlarged = enlarged * item->ctm; - item_bbox.x0 = (NR::ICoord) floor(enlarged.min()[X]); - item_bbox.y0 = (NR::ICoord) floor(enlarged.min()[Y]); - item_bbox.x1 = (NR::ICoord) ceil(enlarged.max()[X]); - item_bbox.y1 = (NR::ICoord) ceil(enlarged.max()[Y]); + item_bbox.x0 = floor(enlarged.min()[X]); + item_bbox.y0 = floor(enlarged.min()[Y]); + item_bbox.x1 = ceil(enlarged.max()[X]); + item_bbox.y1 = ceil(enlarged.max()[Y]); } Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 472c9ada5..977452834 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -2306,13 +2306,15 @@ Geom::Rect SPCanvas::getViewbox() const } /** - * Return canvas window coordinates as IRect (a rectangle defined by integers). + * Return canvas window coordinates as integer rectangle. */ -NR::IRect SPCanvas::getViewboxIntegers() const +Geom::IntRect SPCanvas::getViewboxIntegers() const { GtkWidget const *w = GTK_WIDGET(this); - return NR::IRect(NR::IPoint(x0, y0), - NR::IPoint(x0 + w->allocation.width, y0 + w->allocation.height)); + Geom::IntRect ret; + ret.setMin(Geom::IntPoint(x0, y0)); + ret.setMax(Geom::IntPoint(x0 + w->allocation.width, y0 + w->allocation.height)); + return ret; } inline int sp_canvas_tile_floor(int x) diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 7a6b3295e..32747e7c5 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -149,7 +149,7 @@ struct SPCanvas { bool is_scrolling; Geom::Rect getViewbox() const; - NR::IRect getViewboxIntegers() const; + Geom::IntRect getViewboxIntegers() const; }; GtkWidget *sp_canvas_new_aa(); diff --git a/src/document.cpp b/src/document.cpp index 90fc4c635..5bcf1bf40 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -40,6 +40,7 @@ #include #include #include +#include <2geom/transforms.h> #include "desktop.h" #include "dir-util.h" @@ -647,7 +648,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) - - to_2geom(rect_with_margins.min())); + - rect_with_margins.min()); root->translateChildItems(tr); if(nv) { diff --git a/src/draw-context.h b/src/draw-context.h index 4266bdea4..17540649b 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -16,9 +16,9 @@ #include #include +#include <2geom/point.h> #include "event-context.h" #include -#include #include "live_effects/effect.h" /* Freehand context */ diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index e30d6b1e8..9fbbcdc27 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -15,11 +15,10 @@ # include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include <2geom/transforms.h> #include "macros.h" #include "display/canvas-bpath.h" diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index b9e417feb..bd3edb43b 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -19,9 +19,9 @@ #include "forward.h" #include "extension/extension-forward.h" #include "libnr/nr-forward.h" -#include "libnr/nr-point.h" #include "xml/node.h" #include <2geom/forward.h> +#include <2geom/point.h> namespace Inkscape { namespace Extension { diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 676e9aa94..642ddba5b 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1013,7 +1013,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po Geom::Point p (0, 0); if (!gradient) - return from_2geom(p); + return p; if (SP_IS_LINEARGRADIENT(gradient)) { SPLinearGradient *lg = SP_LINEARGRADIENT(gradient); @@ -1071,7 +1071,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po } } p *= Geom::Affine(gradient->gradientTransform) * (Geom::Affine)item->i2d_affine(); - return from_2geom(p); + return p; } diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 922a9b16e..86c86d2dc 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -548,9 +548,9 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) dragging = true; - Geom::Point button_dt = to_2geom(desktop->w2d(button_w)); + Geom::Point button_dt = desktop->w2d(button_w); if (event->button.state & GDK_SHIFT_MASK) { - Inkscape::Rubberband::get(desktop)->start(desktop, from_2geom(button_dt)); + Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); } else { // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to // enable Ctrl+doubleclick of exactly the selected item(s) @@ -561,7 +561,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) m.setup(desktop); m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); - rc->origin = from_2geom(button_dt); + rc->origin = button_dt; } ret = TRUE; diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 4f536beb3..41e523b86 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -19,6 +19,7 @@ #include #include #include +#include <2geom/transforms.h> #include "desktop.h" #include "inkscape.h" diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 64aa8bc48..fdfbdb9d3 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -511,15 +511,15 @@ namespace Geom { bool transform_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon) { return - NR_DF_TEST_CLOSE(m0[0], m1[0], epsilon) && - NR_DF_TEST_CLOSE(m0[1], m1[1], epsilon) && - NR_DF_TEST_CLOSE(m0[2], m1[2], epsilon) && - NR_DF_TEST_CLOSE(m0[3], m1[3], epsilon); + Geom::are_near(m0[0], m1[0], epsilon) && + Geom::are_near(m0[1], m1[1], epsilon) && + Geom::are_near(m0[2], m1[2], epsilon) && + Geom::are_near(m0[3], m1[3], epsilon); } bool translate_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon) { - return NR_DF_TEST_CLOSE(m0[4], m1[4], epsilon) && NR_DF_TEST_CLOSE(m0[5], m1[5], epsilon); + return Geom::are_near(m0[4], m1[4], epsilon) && Geom::are_near(m0[5], m1[5], epsilon); } diff --git a/src/helper/geom.h b/src/helper/geom.h index b1015b185..630d67aba 100644 --- a/src/helper/geom.h +++ b/src/helper/geom.h @@ -13,8 +13,8 @@ */ #include <2geom/forward.h> -#include -#include +#include <2geom/rect.h> +#include <2geom/affine.h> Geom::OptRect bounds_fast_transformed(Geom::PathVector const & pv, Geom::Affine const & t); Geom::OptRect bounds_exact_transformed(Geom::PathVector const & pv, Geom::Affine const & t); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index f6796f2ad..226042337 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -18,6 +18,7 @@ #include #include #include +#include <2geom/transforms.h> #include "interface.h" #include "helper/png-write.h" diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 4667f631b..5a20ac363 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -18,6 +18,7 @@ #include "interface.h" #include <2geom/rect.h> +#include <2geom/transforms.h> #include #include #include "png-write.h" diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 1027e0600..57d82c8ef 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -3,25 +3,16 @@ ink_common_sources += \ libnr/in-svg-plane.h \ libnr/nr-convert2geom.h \ - libnr/nr-coord.h \ - libnr/nr-dim2.h \ libnr/nr-forward.h \ - libnr/nr-i-coord.h \ libnr/nr-macros.h \ libnr/nr-object.cpp \ libnr/nr-object.h \ - libnr/nr-point-fns.cpp \ - libnr/nr-point-fns.h \ - libnr/nr-point-l.h \ - libnr/nr-point-ops.h \ - libnr/nr-point.h \ + libnr/nr-point-fns.cpp \ + libnr/nr-point-fns.h \ libnr/nr-rect-l.cpp \ libnr/nr-rect-l.h \ libnr/nr-rect.cpp \ libnr/nr-rect.h \ - libnr/nr-rect-ops.h \ - libnr/nr-types.cpp \ - libnr/nr-types.h \ libnr/nr-values.cpp \ libnr/nr-values.h diff --git a/src/libnr/in-svg-plane.h b/src/libnr/in-svg-plane.h index c1937f0fc..68c9e92a0 100644 --- a/src/libnr/in-svg-plane.h +++ b/src/libnr/in-svg-plane.h @@ -1,8 +1,7 @@ #ifndef SEEN_LIBNR_IN_SVG_PLANE_H #define SEEN_LIBNR_IN_SVG_PLANE_H -#include "libnr/nr-point-fns.h" - +#include <2geom/point.h> /** * Returns true iff the coordinates of \a p are finite, non-NaN, and "small enough". Currently we @@ -13,7 +12,7 @@ * in SVG Tiny (which uses fixed-point arithmetic). */ inline bool -in_svg_plane(NR::Point const p) +in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; } diff --git a/src/libnr/libnr.def b/src/libnr/libnr.def deleted file mode 100644 index d8f224ca9..000000000 --- a/src/libnr/libnr.def +++ /dev/null @@ -1,89 +0,0 @@ -EXPORTS - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM - nr_R8G8B8A8_N_EMPTY_A8_RGBA32 - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_N_A8 - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P - nr_R8G8B8A8_N_EMPTY_R8G8B8A8_P_A8 - nr_R8G8B8A8_N_R8G8B8A8_N_A8_RGBA32 - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_A8 - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P - nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_P_A8 - nr_R8G8B8A8_P_EMPTY_A8_RGBA32 - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_N_A8 - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P - nr_R8G8B8A8_P_EMPTY_R8G8B8A8_P_A8 - nr_R8G8B8A8_P_R8G8B8A8_P_A8_RGBA32 - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_A8 - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P - nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_P_A8 -; nr_R8G8B8_EMPTY_A8_RGBA32 - nr_R8G8B8_R8G8B8_A8_RGBA32 - nr_R8G8B8_R8G8B8_R8G8B8A8_N - nr_R8G8B8_R8G8B8_R8G8B8A8_P - nr_active_object_add_listener - nr_active_object_get_type - nr_active_object_remove_listener_by_data - nr_blit_pixblock_mask_rgba32 - nr_blit_pixblock_pixblock_alpha - nr_blit_pixblock_pixblock_mask - nr_compose_pixblock_pixblock_pixel - nr_emit_fail_warning - nr_flat_free_list - nr_flat_free_one - nr_flat_insert_sorted - nr_flat_new_full - nr_lgradient_renderer_setup - nr_matrix_invert - nr_matrix_set_rotate - nr_matrix_set_scale - nr_matrix_set_translate - nr_matrix_multiply - nr_object_check_instance_cast - nr_object_check_instance_type - nr_object_delete - nr_object_get_type - nr_object_new - nr_object_ref - nr_object_register_type - nr_object_release - nr_object_setup - nr_object_unref - nr_path_duplicate_transform - nr_path_matrix_bbox_nion - nr_path_matrix_point_bbox_wind_distance - nr_pixblock_draw_line_rgba32 - nr_pixblock_free - nr_pixblock_new - nr_pixblock_release - nr_pixblock_render_gray_noise - nr_pixblock_render_svp_mask_or - nr_pixblock_setup - nr_pixblock_setup_extern - nr_pixblock_setup_fast - nr_pixelstore_16K_free - nr_pixelstore_16K_new - nr_pixelstore_4K_free - nr_pixelstore_4K_new - nr_pixelstore_64K_free - nr_pixelstore_64K_new - nr_rect_d_intersect - nr_rect_d_matrix_transform - nr_rect_d_union - nr_rect_l_intersect - nr_rect_l_union - nr_rgradient_renderer_setup - nr_svp_bbox - nr_svp_free - nr_svp_point_distance - nr_svp_point_wind - nr_type_is_a - nr_vertex_free_list - nr_vertex_free_one - nr_vertex_new - nr_vertex_new_xy - nr_vertex_reverse_list diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h index 75098ce2b..7e2423ea6 100644 --- a/src/libnr/nr-convert2geom.h +++ b/src/libnr/nr-convert2geom.h @@ -10,34 +10,14 @@ */ #include -#include -#include <2geom/affine.h> -#include <2geom/d2.h> -#include <2geom/transforms.h> -#include <2geom/point.h> +#include <2geom/rect.h> -inline Geom::Point to_2geom(NR::Point const & _pt) { - return Geom::Point(_pt[0], _pt[1]); -} -inline NR::Point from_2geom(Geom::Point const & _pt) { - return NR::Point(_pt[0], _pt[1]); -} - -inline Geom::Rect to_2geom(NR::Rect const & rect) { - Geom::Rect rect2geom(to_2geom(rect.min()), to_2geom(rect.max())); - return rect2geom; -} -inline NR::Rect from_2geom(Geom::Rect const & rect2geom) { - NR::Rect rect(rect2geom.min(), rect2geom.max()); - return rect; -} -inline Geom::OptRect to_2geom(boost::optional const & rect) { - Geom::OptRect rect2geom; - if (!rect) { - return rect2geom; - } - rect2geom = to_2geom(*rect); - return rect2geom; +inline Geom::OptRect to_2geom(NRRect const *nr) { + Geom::OptRect ret; + if (!nr) return ret; + if (nr->x1 < nr->x0 || nr->y1 < nr->y0) return ret; + ret = Geom::Rect(Geom::Point(nr->x0, nr->y0), Geom::Point(nr->x1, nr->y1)); + return ret; } #endif diff --git a/src/libnr/nr-coord.h b/src/libnr/nr-coord.h deleted file mode 100644 index e094caeb3..000000000 --- a/src/libnr/nr-coord.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SEEN_NR_COORD_H -#define SEEN_NR_COORD_H - -namespace NR { - -/** - * A "real" type with sufficient precision for coordinates. - * - * You may safely assume that double (or even float) provides enough precision for storing - * on-canvas points, and hence that double provides enough precision for dot products of - * differences of on-canvas points. - */ -typedef double Coord; - -} /* namespace NR */ - - -#endif /* !SEEN_NR_COORD_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-dim2.h b/src/libnr/nr-dim2.h deleted file mode 100644 index c068bc220..000000000 --- a/src/libnr/nr-dim2.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SEEN_NR_DIM2_H -#define SEEN_NR_DIM2_H - -namespace NR { - -enum Dim2 { X=0, Y }; - -} /* namespace NR */ - - -#endif /* !SEEN_NR_DIM2_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-forward.h b/src/libnr/nr-forward.h index 82e29030c..4895ad407 100644 --- a/src/libnr/nr-forward.h +++ b/src/libnr/nr-forward.h @@ -10,20 +10,10 @@ * This code is in public domain */ -namespace NR { -class Matrix; -class Point; -class Rect; -class rotate; -class scale; -class translate; -} - struct NRPixBlock; struct NRRect; struct NRRectL; - #endif /* diff --git a/src/libnr/nr-i-coord.h b/src/libnr/nr-i-coord.h deleted file mode 100644 index a19d2ca46..000000000 --- a/src/libnr/nr-i-coord.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef SEEN_NR_I_COORD_H -#define SEEN_NR_I_COORD_H - -#include - -namespace NR { - -/** An integer type with sufficient precision for coordinates. */ -typedef gint32 ICoord; - -} /* namespace NR */ - - -#endif /* !SEEN_NR_I_COORD_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-point-fns-test.h b/src/libnr/nr-point-fns-test.h deleted file mode 100644 index df166660c..000000000 --- a/src/libnr/nr-point-fns-test.h +++ /dev/null @@ -1,139 +0,0 @@ -// nr-point-fns-test.h -#include - -#include -#include -#include -#include - -#include "libnr/nr-point-fns.h" -#include "2geom/isnan.h" - -class NrPointFnsTest : public CxxTest::TestSuite -{ -public: - NrPointFnsTest() : - setupValid(true), - p3n4( 3.0, -4.0 ), - p0( 0.0, 0.0 ), - small( pow( 2.0, -1070 ) ), - inf( 1e400 ), - nan( inf - inf ), - small_left( -small, 0.0 ), - small_n3_4( -3.0 * small, 4.0 * small ), - part_nan( 3., nan ), - inf_left( -inf, 5.0 ) - { - TS_ASSERT( IS_NAN(nan) ); - TS_ASSERT( !IS_NAN(small) ); - - setupValid &= IS_NAN(nan); - setupValid &= !IS_NAN(small); - } - virtual ~NrPointFnsTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrPointFnsTest *createSuite() { return new NrPointFnsTest(); } - static void destroySuite( NrPointFnsTest *suite ) { delete suite; } - -// Called before each test in this suite - void setUp() - { - TS_ASSERT( setupValid ); - } - - bool setupValid; - NR::Point const p3n4; - NR::Point const p0; - double const small; - double const inf; - double const nan; - - NR::Point const small_left; - NR::Point const small_n3_4; - NR::Point const part_nan; - NR::Point const inf_left; - - - void testL1(void) - { - TS_ASSERT_EQUALS( NR::L1(p0), 0.0 ); - TS_ASSERT_EQUALS( NR::L1(p3n4), 7.0 ); - TS_ASSERT_EQUALS( NR::L1(small_left), small ); - TS_ASSERT_EQUALS( NR::L1(inf_left), inf ); - TS_ASSERT_EQUALS( NR::L1(small_n3_4), 7.0 * small ); - TS_ASSERT(IS_NAN(NR::L1(part_nan))); - } - - void testL2(void) - { - TS_ASSERT_EQUALS( NR::L2(p0), 0.0 ); - TS_ASSERT_EQUALS( NR::L2(p3n4), 5.0 ); - TS_ASSERT_EQUALS( NR::L2(small_left), small ); - TS_ASSERT_EQUALS( NR::L2(inf_left), inf ); - TS_ASSERT_EQUALS( NR::L2(small_n3_4), 5.0 * small ); - TS_ASSERT( IS_NAN(NR::L2(part_nan)) ); - } - - void testLInfty(void) - { - TS_ASSERT_EQUALS( NR::LInfty(p0), 0.0 ); - TS_ASSERT_EQUALS( NR::LInfty(p3n4), 4.0 ); - TS_ASSERT_EQUALS( NR::LInfty(small_left), small ); - TS_ASSERT_EQUALS( NR::LInfty(inf_left), inf ); - TS_ASSERT_EQUALS( NR::LInfty(small_n3_4), 4.0 * small ); - TS_ASSERT( IS_NAN(NR::LInfty(part_nan)) ); - } - - void testIsZero(void) - { - TS_ASSERT( NR::is_zero(p0) ); - TS_ASSERT( !NR::is_zero(p3n4) ); - TS_ASSERT( !NR::is_zero(small_left) ); - TS_ASSERT( !NR::is_zero(inf_left) ); - TS_ASSERT( !NR::is_zero(small_n3_4) ); - TS_ASSERT( !NR::is_zero(part_nan) ); - } - - void testAtan2(void) - { - TS_ASSERT_EQUALS( NR::atan2(p3n4), atan2(-4.0, 3.0) ); - TS_ASSERT_EQUALS( NR::atan2(small_left), atan2(0.0, -1.0) ); - TS_ASSERT_EQUALS( NR::atan2(small_n3_4), atan2(4.0, -3.0) ); - } - - void testUnitVector(void) - { - TS_ASSERT_EQUALS( NR::unit_vector(p3n4), NR::Point(.6, -0.8) ); - TS_ASSERT_EQUALS( NR::unit_vector(small_left), NR::Point(-1.0, 0.0) ); - TS_ASSERT_EQUALS( NR::unit_vector(small_n3_4), NR::Point(-.6, 0.8) ); - } - - void testIsUnitVector(void) - { - TS_ASSERT( !NR::is_unit_vector(p3n4) ); - TS_ASSERT( !NR::is_unit_vector(small_left) ); - TS_ASSERT( !NR::is_unit_vector(small_n3_4) ); - TS_ASSERT( !NR::is_unit_vector(part_nan) ); - TS_ASSERT( !NR::is_unit_vector(inf_left) ); - TS_ASSERT( !NR::is_unit_vector(NR::Point(.5, 0.5)) ); - TS_ASSERT( NR::is_unit_vector(NR::Point(.6, -0.8)) ); - TS_ASSERT( NR::is_unit_vector(NR::Point(-.6, 0.8)) ); - TS_ASSERT( NR::is_unit_vector(NR::Point(-1.0, 0.0)) ); - TS_ASSERT( NR::is_unit_vector(NR::Point(1.0, 0.0)) ); - TS_ASSERT( NR::is_unit_vector(NR::Point(0.0, -1.0)) ); - TS_ASSERT( NR::is_unit_vector(NR::Point(0.0, 1.0)) ); - } -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-point-fns.cpp b/src/libnr/nr-point-fns.cpp index ac58eddb7..a2e74c112 100644 --- a/src/libnr/nr-point-fns.cpp +++ b/src/libnr/nr-point-fns.cpp @@ -1,72 +1,11 @@ -#include -#include <2geom/math-utils.h> +#include "libnr/nr-point-fns.h" -using NR::Point; - -/** Compute the L infinity, or maximum, norm of \a p. */ -NR::Coord NR::LInfty(Point const &p) { - NR::Coord const a(fabs(p[0])); - NR::Coord const b(fabs(p[1])); - return ( a < b || IS_NAN(b) - ? b - : a ); -} - -/** Returns true iff p is a zero vector, i.e.\ Point(0, 0). - * - * (NaN is considered non-zero.) - */ -bool -NR::is_zero(Point const &p) -{ - return ( p[0] == 0 && - p[1] == 0 ); -} - -bool -NR::is_unit_vector(Point const &p) -{ - return fabs(1.0 - L2(p)) <= 1e-4; - /* The tolerance of 1e-4 is somewhat arbitrary. NR::Point::normalize is believed to return - points well within this tolerance. I'm not aware of any callers that want a small - tolerance; most callers would be ok with a tolerance of 0.25. */ -} - -NR::Coord NR::atan2(Point const p) { - return std::atan2(p[NR::Y], p[NR::X]); -} - -/** Returns a version of \a a scaled to be a unit vector (within rounding error). - * - * The current version tries to handle infinite coordinates gracefully, - * but it's not clear that any callers need that. - * - * \pre a != Point(0, 0). - * \pre Neither coordinate is NaN. - * \post L2(ret) very near 1.0. - */ -Point NR::unit_vector(Point const &a) -{ - Point ret(a); - ret.normalize(); - return ret; -} - -NR::Point abs(NR::Point const &b) -{ - NR::Point ret; - for ( int i = 0 ; i < 2 ; i++ ) { - ret[i] = fabs(b[i]); - } - return ret; -} - -NR::Point -snap_vector_midpoint (NR::Point p, NR::Point begin, NR::Point end, double snap) +Geom::Point +snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap) { - double length = NR::L2(end - begin); - NR::Point be = (end - begin) / length; - double r = NR::dot(p - begin, be); + double length = Geom::distance(begin, end); + Geom::Point be = (end - begin) / length; + double r = Geom::dot(p - begin, be); if (r < 0.0) return begin; if (r > length) return end; @@ -78,11 +17,11 @@ snap_vector_midpoint (NR::Point p, NR::Point begin, NR::Point end, double snap) } double -get_offset_between_points (NR::Point p, NR::Point begin, NR::Point end) +get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end) { - double length = NR::L2(end - begin); - NR::Point be = (end - begin) / length; - double r = NR::dot(p - begin, be); + double length = Geom::distance(begin, end); + Geom::Point be = (end - begin) / length; + double r = Geom::dot(p - begin, be); if (r < 0.0) return 0.0; if (r > length) return 1.0; @@ -90,8 +29,8 @@ get_offset_between_points (NR::Point p, NR::Point begin, NR::Point end) return (r / length); } -NR::Point -project_on_linesegment(NR::Point const p, NR::Point const p1, NR::Point const p2) +Geom::Point +project_on_linesegment(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2) { // p_proj = projection of p on the linesegment running from p1 to p2 // p_proj = p1 + u (p2 - p1) @@ -104,9 +43,9 @@ project_on_linesegment(NR::Point const p, NR::Point const p1, NR::Point const p2 return p; } - NR::Point const d1(p-p1); // delta 1 - NR::Point const d2(p2-p1); // delta 2 - double const u = (d1[NR::X] * d2[NR::X] + d1[NR::Y] * d2[NR::Y]) / (NR::L2(d2) * NR::L2(d2)); + Geom::Point d1(p-p1); // delta 1 + Geom::Point d2(p2-p1); // delta 2 + double u = Geom::dot(d1, d2) / Geom::L2sq(d2); return (p1 + u*(p2-p1)); } diff --git a/src/libnr/nr-point-fns.h b/src/libnr/nr-point-fns.h index 05c4f718c..b26c969aa 100644 --- a/src/libnr/nr-point-fns.h +++ b/src/libnr/nr-point-fns.h @@ -1,100 +1,13 @@ #ifndef __NR_POINT_OPS_H__ #define __NR_POINT_OPS_H__ -#include -#include -#include +#include <2geom/point.h> -namespace NR { +Geom::Point snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap); -/** Compute the L1 norm, or manhattan distance, of \a p. */ -inline Coord L1(Point const &p) { - Coord d = 0; - for ( int i = 0 ; i < 2 ; i++ ) { - d += fabs(p[i]); - } - return d; -} +double get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end); -/** Compute the L2, or euclidean, norm of \a p. */ -inline Coord L2(Point const &p) { - return hypot(p[0], p[1]); -} - -extern double LInfty(Point const &p); - -bool is_zero(Point const &p); - -bool is_unit_vector(Point const &p); - -extern double atan2(Point const p); - -inline bool point_equalp(Point const &a, Point const &b, double const eps) -{ - return ( NR_DF_TEST_CLOSE(a[X], b[X], eps) && - NR_DF_TEST_CLOSE(a[Y], b[Y], eps) ); -} - -/** Returns p * NR::rotate_degrees(90), but more efficient. - * - * Angle direction in Inkscape code: If you use the traditional mathematics convention that y - * increases upwards, then positive angles are anticlockwise as per the mathematics convention. If - * you take the common non-mathematical convention that y increases downwards, then positive angles - * are clockwise, as is common outside of mathematics. - * - * There is no rot_neg90 function: use -rot90(p) instead. - */ -inline Point rot90(Point const &p) -{ - return Point(-p[Y], p[X]); -} - -/** Given two points and a parameter t \in [0, 1], return a point - * proportionally from a to b by t. */ -inline Point Lerp(double const t, Point const a, Point const b) -{ - return ( ( 1 - t ) * a - + t * b ); -} - -Point unit_vector(Point const &a); - -inline Coord dot(Point const &a, Point const &b) -{ - Coord ret = 0; - for ( int i = 0 ; i < 2 ; i++ ) { - ret += a[i] * b[i]; - } - return ret; -} - -inline Coord distance (Point const &a, Point const &b) -{ - Coord ret = 0; - for ( int i = 0 ; i < 2 ; i++ ) { - ret += (a[i] - b[i]) * (a[i] - b[i]); - } - return sqrt (ret); -} - -/** Defined as dot(a, b.cw()). */ -inline Coord cross(Point const &a, Point const &b) -{ - Coord ret = 0; - ret -= a[0] * b[1]; - ret += a[1] * b[0]; - return ret; -} - -Point abs(Point const &b); - -} /* namespace NR */ - -NR::Point snap_vector_midpoint (NR::Point p, NR::Point begin, NR::Point end, double snap); - -double get_offset_between_points (NR::Point p, NR::Point begin, NR::Point end); - -NR::Point project_on_linesegment(NR::Point const p, NR::Point const p1, NR::Point const p2); +Geom::Point project_on_linesegment(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2); #endif /* !__NR_POINT_OPS_H__ */ diff --git a/src/libnr/nr-point-l.h b/src/libnr/nr-point-l.h deleted file mode 100644 index 9bfe2c790..000000000 --- a/src/libnr/nr-point-l.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef SEEN_NR_POINT_L_H -#define SEEN_NR_POINT_L_H - -#include -#include -#include - -struct NRPointL { - NR::ICoord x, y; -}; - -namespace NR { - -class IPoint { -public: - IPoint() - { } - - IPoint(ICoord x, ICoord y) { - _pt[X] = x; - _pt[Y] = y; - } - - IPoint(NRPointL const &p) { - _pt[X] = p.x; - _pt[Y] = p.y; - } - - IPoint(IPoint const &p) { - for (unsigned i = 0; i < 2; ++i) { - _pt[i] = p._pt[i]; - } - } - - IPoint &operator=(IPoint const &p) { - for (unsigned i = 0; i < 2; ++i) { - _pt[i] = p._pt[i]; - } - return *this; - } - - operator Point() { - return Point(_pt[X], _pt[Y]); - } - - ICoord operator[](unsigned i) const throw(std::out_of_range) { - if ( i > Y ) { - throw std::out_of_range("index out of range"); - } - return _pt[i]; - } - - ICoord &operator[](unsigned i) throw(std::out_of_range) { - if ( i > Y ) { - throw std::out_of_range("index out of range"); - } - return _pt[i]; - } - - ICoord operator[](Dim2 d) const throw() { return _pt[d]; } - ICoord &operator[](Dim2 d) throw() { return _pt[d]; } - - IPoint &operator+=(IPoint const &o) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] += o._pt[i]; - } - return *this; - } - - IPoint &operator-=(IPoint const &o) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] -= o._pt[i]; - } - return *this; - } - - bool operator==(IPoint const &other) const { - return _pt[X] == other[X] && _pt[Y] == other[Y]; - } - - bool operator!=(IPoint const &other) const { - return _pt[X] != other[X] || _pt[Y] != other[Y]; - } - -private: - ICoord _pt[2]; -}; - - -} // namespace NR - -#endif /* !SEEN_NR_POINT_L_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-point-ops.h b/src/libnr/nr-point-ops.h deleted file mode 100644 index aba981803..000000000 --- a/src/libnr/nr-point-ops.h +++ /dev/null @@ -1,88 +0,0 @@ -/* operator functions for NR::Point. */ -#ifndef SEEN_NR_POINT_OPS_H -#define SEEN_NR_POINT_OPS_H - -#include - -namespace NR { - -inline Point operator+(Point const &a, Point const &b) -{ - Point ret; - for (int i = 0; i < 2; i++) { - ret[i] = a[i] + b[i]; - } - return ret; -} - -inline Point operator-(Point const &a, Point const &b) -{ - Point ret; - for (int i = 0; i < 2; i++) { - ret[i] = a[i] - b[i]; - } - return ret; -} - -/** This is a rotation (sort of). */ -inline Point operator^(Point const &a, Point const &b) -{ - Point const ret(a[0] * b[0] - a[1] * b[1], - a[1] * b[0] + a[0] * b[1]); - return ret; -} - -inline Point operator-(Point const &a) -{ - Point ret; - for(unsigned i = 0; i < 2; i++) { - ret[i] = -a[i]; - } - return ret; -} - -inline Point operator*(double const s, Point const &b) -{ - Point ret; - for(int i = 0; i < 2; i++) { - ret[i] = s * b[i]; - } - return ret; -} - -inline Point operator/(Point const &b, double const d) -{ - Point ret; - for(int i = 0; i < 2; i++) { - ret[i] = b[i] / d; - } - return ret; -} - - -inline bool operator==(Point const &a, Point const &b) -{ - return ( ( a[X] == b[X] ) && ( a[Y] == b[Y] ) ); -} - -inline bool operator!=(Point const &a, Point const &b) -{ - return ( ( a[X] != b[X] ) || ( a[Y] != b[Y] ) ); -} - - -} /* namespace NR */ - - -#endif /* !SEEN_NR_POINT_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-point.h b/src/libnr/nr-point.h deleted file mode 100644 index 19add7dd1..000000000 --- a/src/libnr/nr-point.h +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef SEEN_NR_POINT_H -#define SEEN_NR_POINT_H - -/** \file - * Cartesian point class. - */ - -//#include -//#include -#include -//#include - -#include -#include -#include - -//#include "round.h" -#include "decimal-round.h" - -#include <2geom/point.h> - -namespace NR { - -/// Cartesian point. -class Point { -public: - inline Point() - { _pt[X] = _pt[Y] = 0; } - - inline Point(Coord x, Coord y) { - _pt[X] = x; - _pt[Y] = y; - } - - inline Point(Point const &p) { - for (unsigned i = 0; i < 2; ++i) { - _pt[i] = p._pt[i]; - } - } - - inline Point(Geom::Point const &p) { - _pt[X] = p[Geom::X]; - _pt[Y] = p[Geom::Y]; - } - - inline Point &operator=(Point const &p) { - for (unsigned i = 0; i < 2; ++i) { - _pt[i] = p._pt[i]; - } - return *this; - } - - inline Coord operator[](unsigned i) const { - return _pt[i]; - } - - inline Coord &operator[](unsigned i) { - return _pt[i]; - } - - Coord operator[](Dim2 d) const throw() { return _pt[d]; } - Coord &operator[](Dim2 d) throw() { return _pt[d]; } - - /** Return a point like this point but rotated -90 degrees. - (If the y axis grows downwards and the x axis grows to the - right, then this is 90 degrees counter-clockwise.) - **/ - Point ccw() const { - return Point(_pt[Y], -_pt[X]); - } - - /** Return a point like this point but rotated +90 degrees. - (If the y axis grows downwards and the x axis grows to the - right, then this is 90 degrees clockwise.) - **/ - Point cw() const { - return Point(-_pt[Y], _pt[X]); - } - - /** - \brief A function to lower the precision of the point - \param places The number of decimal places that should be in - the final number. - */ - inline void round (int places = 0) { - _pt[X] = (Coord)(Inkscape::decimal_round((double)_pt[X], places)); - _pt[Y] = (Coord)(Inkscape::decimal_round((double)_pt[Y], places)); - return; - } - - void normalize(); - - inline Point &operator+=(Point const &o) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] += o._pt[i]; - } - return *this; - } - - inline Point &operator-=(Point const &o) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] -= o._pt[i]; - } - return *this; - } - - inline Point &operator/=(double const s) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] /= s; - } - return *this; - } - - inline Point &operator*=(double const s) { - for ( unsigned i = 0 ; i < 2 ; ++i ) { - _pt[i] *= s; - } - return *this; - } - - Point &operator*=(Matrix const &m); - - inline int operator == (const Point &in_pnt) { - return ((_pt[X] == in_pnt[X]) && (_pt[Y] == in_pnt[Y])); - } - - friend inline std::ostream &operator<< (std::ostream &out_file, const NR::Point &in_pnt); - - inline operator Geom::Point() const { return Geom::Point(_pt[X], _pt[Y]); } - -private: - Coord _pt[2]; -}; - -/** A function to print out the Point. It just prints out the coords - on the given output stream */ -inline std::ostream &operator<< (std::ostream &out_file, const NR::Point &in_pnt) { - out_file << "X: " << in_pnt[X] << " Y: " << in_pnt[Y]; - return out_file; -} - -} /* namespace NR */ - -#endif /* !SEEN_NR_POINT_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rect-l.cpp b/src/libnr/nr-rect-l.cpp index 9d1f80988..08910a1d6 100644 --- a/src/libnr/nr-rect-l.cpp +++ b/src/libnr/nr-rect-l.cpp @@ -1,23 +1,3 @@ -#include - -boost::optional NRRectL::upgrade() const { - if (nr_rect_l_test_empty_ptr(this)) { - return boost::optional(); - } else { - return NR::Rect(NR::Point(x0, y0), NR::Point(x1, y1)); - } -} - -namespace NR { - -IRect::IRect(Rect const &r) : - _min(int(floor(r.min()[X])), int(floor(r.min()[Y]))), - _max(int(ceil(r.min()[X])), int(ceil(r.min()[Y]))) -{ -} - -} - /* Local Variables: mode:c++ diff --git a/src/libnr/nr-rect-l.h b/src/libnr/nr-rect-l.h index 3493fa8f4..6e82bb790 100644 --- a/src/libnr/nr-rect-l.h +++ b/src/libnr/nr-rect-l.h @@ -1,132 +1,12 @@ #ifndef SEEN_NR_RECT_L_H #define SEEN_NR_RECT_L_H -#include -#include -#include -#include +#include struct NRRectL { - boost::optional upgrade() const; - NR::ICoord x0, y0, x1, y1; + gint32 x0, y0, x1, y1; }; - -namespace NR { - - -class IRect { -public: - IRect(const NRRectL& r) : _min(r.x0, r.y0), _max(r.x1, r.y1) {} - IRect(const IRect& r) : _min(r._min), _max(r._max) {} - IRect(const IPoint &p0, const IPoint &p1) : _min(p0), _max(p1) {} - - /** as not all Rects are representable by IRects this gives the smallest IRect that contains - * r. */ - IRect(const Rect& r); - - operator Rect() { - return Rect(Point(_min), Point(_max)); - } - - const IPoint &min() const { return _min; } - const IPoint &max() const { return _max; } - - /** returns a vector from min to max. */ - IPoint dimensions() const; - - /** does this rectangle have zero area? */ - bool isEmpty() const { - return isEmpty() && isEmpty(); - } - - bool intersects(const IRect &r) const { - return intersects(r) && intersects(r); - } - bool contains(const IRect &r) const { - return contains(r) && contains(r); - } - bool contains(const IPoint &p) const { - return contains(p) && contains(p); - } - - ICoord maxExtent() const { - return MAX(extent(), extent()); - } - - ICoord extent(Dim2 axis) const { - switch (axis) { - case X: return extent(); - case Y: return extent(); - }; - } - - ICoord extent(unsigned i) const throw(std::out_of_range) { - switch (i) { - case 0: return extent(); - case 1: return extent(); - default: throw std::out_of_range("Dimension out of range"); - }; - } - - /** Translates the rectangle by p. */ - void offset(IPoint p); - - /** Makes this rectangle large enough to include the point p. */ - void expandTo(IPoint p); - - /** Makes this rectangle large enough to include the rectangle r. */ - void expandTo(const IRect &r); - - /** Returns the set of points shared by both rectangles. */ - static boost::optional intersection(const IRect &a, const IRect &b); - - /** Returns the smallest rectangle that encloses both rectangles. */ - static IRect union_bounds(const IRect &a, const IRect &b); - - bool operator==(const IRect &other) const { - return (min() == other.min()) && (max() == other.max()); - } - - bool operator!=(const IRect &other) const { - return (min() != other.min()) || (max() != other.max()); - } - -private: - IRect() {} - - template - ICoord extent() const { - return _max[axis] - _min[axis]; - } - - template - bool isEmpty() const { - return !( _min[axis] < _max[axis] ); - } - - template - bool intersects(const IRect &r) const { - return _max[axis] >= r._min[axis] && _min[axis] <= r._max[axis]; - } - - template - bool contains(const IRect &r) const { - return contains(r._min) && contains(r._max); - } - - template - bool contains(const IPoint &p) const { - return p[axis] >= _min[axis] && p[axis] <= _max[axis]; - } - - IPoint _min, _max; -}; - - - -} // namespace NR - #endif /* !SEEN_NR_RECT_L_H */ /* diff --git a/src/libnr/nr-rect-ops.h b/src/libnr/nr-rect-ops.h deleted file mode 100644 index 870091a94..000000000 --- a/src/libnr/nr-rect-ops.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SEEN_NR_RECT_OPS_H -#define SEEN_NR_RECT_OPS_H - -/* - * Rect operators - * - * Copyright 2004 MenTaLguY , - * bulia byak - * - * This code is licensed under the GNU GPL; see COPYING for more information. - */ - -#include - -namespace NR { - -inline Rect expand(Rect const &r, double by) { - NR::Point const p(by, by); - return Rect(r.min() + p, r.max() - p); -} - -inline Rect expand(Rect const &r, NR::Point by) { - return Rect(r.min() + by, r.max() - by); -} - -#if 0 -inline ConvexHull operator*(Rect const &r, Matrix const &m) { - /* FIXME: no mention of m. Should probably be made non-inline. */ - ConvexHull points(r.corner(0)); - for ( unsigned i = 1 ; i < 4 ; i++ ) { - points.add(r.corner(i)); - } - return points; -} -#endif - -} /* namespace NR */ - - -#endif /* !SEEN_NR_RECT_OPS_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp index 8e3672e03..67857ad49 100644 --- a/src/libnr/nr-rect.cpp +++ b/src/libnr/nr-rect.cpp @@ -9,25 +9,9 @@ * This code is in public domain */ -#include "nr-rect-l.h" #include -#include "nr-point-ops.h" - -NRRect::NRRect(NR::Rect const &rect) -: x0(rect.min()[NR::X]), y0(rect.min()[NR::Y]), - x1(rect.max()[NR::X]), y1(rect.max()[NR::Y]) -{} - -NRRect::NRRect(boost::optional const &rect) { - if (rect) { - x0 = rect->min()[NR::X]; - y0 = rect->min()[NR::Y]; - x1 = rect->max()[NR::X]; - y1 = rect->max()[NR::Y]; - } else { - nr_rect_d_set_empty(this); - } -} +#include "nr-rect.h" +#include "nr-rect-l.h" NRRect::NRRect(Geom::OptRect const &rect) { if (rect) { @@ -36,20 +20,12 @@ NRRect::NRRect(Geom::OptRect const &rect) { x1 = rect->max()[Geom::X]; y1 = rect->max()[Geom::Y]; } else { - nr_rect_d_set_empty(this); - } -} - -boost::optional NRRect::upgrade() const { - if (nr_rect_d_test_empty_ptr(this)) { - return boost::optional(); - } else { - return NR::Rect(NR::Point(x0, y0), NR::Point(x1, y1)); + *this = NR_RECT_EMPTY; } } Geom::OptRect NRRect::upgrade_2geom() const { - if (nr_rect_d_test_empty_ptr(this)) { + if (x0 > x1 || y0 > y1) { return Geom::OptRect(); } else { return Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)); @@ -65,7 +41,7 @@ Geom::OptRect NRRect::upgrade_2geom() const { NRRectL *nr_rect_l_intersect(NRRectL *d, const NRRectL *r0, const NRRectL *r1) { - NR::ICoord t; + gint32 t; t = std::max(r0->x0, r1->x0); d->x1 = std::min(r0->x1, r1->x1); d->x0 = t; @@ -79,7 +55,7 @@ NRRectL *nr_rect_l_intersect(NRRectL *d, const NRRectL *r0, const NRRectL *r1) NRRect * nr_rect_d_intersect (NRRect *d, const NRRect *r0, const NRRect *r1) { - NR::Coord t; + gint32 t; t = MAX (r0->x0, r1->x0); d->x1 = MIN (r0->x1, r1->x1); d->x0 = t; @@ -100,7 +76,7 @@ nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1) bool inside4 = nr_rect_l_test_inside(r1, r0->x0, r0->y1); if (inside1 && inside2 && inside3) { - nr_rect_l_set_empty (d); + *d = NR_RECT_L_EMPTY; } else if (inside1 && inside2) { d->x0 = r0->x0; @@ -136,7 +112,7 @@ nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1) return d; } -NR::ICoord nr_rect_l_area(NRRectL *r) +gint32 nr_rect_l_area(NRRectL *r) { if (!r || NR_RECT_DFLS_TEST_EMPTY (r)) { return 0; @@ -149,7 +125,7 @@ nr_rect_d_union (NRRect *d, const NRRect *r0, const NRRect *r1) { if (NR_RECT_DFLS_TEST_EMPTY (r0)) { if (NR_RECT_DFLS_TEST_EMPTY (r1)) { - nr_rect_d_set_empty (d); + *d = NR_RECT_EMPTY; } else { *d = *r1; } @@ -157,7 +133,7 @@ nr_rect_d_union (NRRect *d, const NRRect *r0, const NRRect *r1) if (NR_RECT_DFLS_TEST_EMPTY (r1)) { *d = *r0; } else { - NR::Coord t; + double t; t = MIN (r0->x0, r1->x0); d->x1 = MAX (r0->x1, r1->x1); d->x0 = t; @@ -174,7 +150,7 @@ nr_rect_l_union (NRRectL *d, const NRRectL *r0, const NRRectL *r1) { if (NR_RECT_DFLS_TEST_EMPTY (r0)) { if (NR_RECT_DFLS_TEST_EMPTY (r1)) { - nr_rect_l_set_empty (d); + *d = NR_RECT_L_EMPTY; } else { *d = *r1; } @@ -182,7 +158,7 @@ nr_rect_l_union (NRRectL *d, const NRRectL *r0, const NRRectL *r1) if (NR_RECT_DFLS_TEST_EMPTY (r1)) { *d = *r0; } else { - NR::ICoord t; + double t; t = MIN (r0->x0, r1->x0); d->x1 = MAX (r0->x1, r1->x1); d->x0 = t; @@ -195,16 +171,13 @@ nr_rect_l_union (NRRectL *d, const NRRectL *r0, const NRRectL *r1) } NRRect * -nr_rect_union_pt(NRRect *dst, NR::Point const &p) +nr_rect_union_pt(NRRect *dst, Geom::Point const &p) { - using NR::X; - using NR::Y; - - return nr_rect_d_union_xy(dst, p[X], p[Y]); + return nr_rect_d_union_xy(dst, p[Geom::X], p[Geom::Y]); } NRRect * -nr_rect_d_union_xy (NRRect *d, NR::Coord x, NR::Coord y) +nr_rect_d_union_xy (NRRect *d, double x, double y) { if ((d->x0 <= d->x1) && (d->y0 <= d->y1)) { d->x0 = MIN (d->x0, x); @@ -218,147 +191,6 @@ nr_rect_d_union_xy (NRRect *d, NR::Coord x, NR::Coord y) return d; } -// TODO investigate for removal: -NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *const /*s*/, NR::Matrix const & /*m*/) -{ - // defunct - /* - using NR::X; - using NR::Y; - - if (nr_rect_d_test_empty_ptr(s)) { - nr_rect_d_set_empty(d); - } else { - NR::Point const c00(NR::Point(s->x0, s->y0) * m); - NR::Point const c01(NR::Point(s->x0, s->y1) * m); - NR::Point const c10(NR::Point(s->x1, s->y0) * m); - NR::Point const c11(NR::Point(s->x1, s->y1) * m); - d->x0 = std::min(std::min(c00[X], c01[X]), - std::min(c10[X], c11[X])); - d->y0 = std::min(std::min(c00[Y], c01[Y]), - std::min(c10[Y], c11[Y])); - d->x1 = std::max(std::max(c00[X], c01[X]), - std::max(c10[X], c11[X])); - d->y1 = std::max(std::max(c00[Y], c01[Y]), - std::max(c10[Y], c11[Y])); - }*/ - return d; -} - -NRRect * -nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NR::Matrix const *m) -{ - return nr_rect_d_matrix_transform(d, s, *m); -} - -/** Enlarges the rectangle given amount of pixels to all directions */ -NRRectL * -nr_rect_l_enlarge(NRRectL *d, int amount) -{ - d->x0 -= amount; - d->y0 -= amount; - d->x1 += amount; - d->y1 += amount; - return d; -} - -namespace NR { - -Rect::Rect(const Point &p0, const Point &p1) -: _min(std::min(p0[X], p1[X]), std::min(p0[Y], p1[Y])), - _max(std::max(p0[X], p1[X]), std::max(p0[Y], p1[Y])) -{} - -/** returns the four corners of the rectangle in the correct winding order */ -Point Rect::corner(unsigned i) const { - switch (i % 4) { - case 0: - return _min; - case 1: - return Point(_max[X], _min[Y]); - case 2: - return _max; - default: /* i.e. 3 */ - return Point(_min[X], _max[Y]); - } -} - -/** returns the midpoint of this rectangle */ -Point Rect::midpoint() const { - return ( _min + _max ) / 2; -} - -Point Rect::cornerFarthestFrom(Point const &p) const { - Point m = midpoint(); - unsigned i = 0; - if (p[X] < m[X]) { - i = 1; - } - if (p[Y] < m[Y]) { - i = 3 - i; - } - return corner(i); -} - -/** returns a vector from topleft to bottom right. */ -Point Rect::dimensions() const { - return _max - _min; -} - -/** Translates the rectangle by p. */ -void Rect::offset(Point p) { - _min += p; - _max += p; -} - -/** Makes this rectangle large enough to include the point p. */ -void Rect::expandTo(Point p) { - for ( int i=0 ; i < 2 ; i++ ) { - _min[i] = std::min(_min[i], p[i]); - _max[i] = std::max(_max[i], p[i]); - } -} - -void Rect::growBy(double size) { - for ( unsigned d = 0 ; d < 2 ; d++ ) { - _min[d] -= size; - _max[d] += size; - if ( _min[d] > _max[d] ) { - _min[d] = _max[d] = ( _min[d] + _max[d] ) / 2; - } - } -} - -/** Returns the set of points shared by both rectangles. */ -boost::optional intersection(boost::optional const & a, boost::optional const & b) { - if ( !a || !b ) { - return boost::optional(); - } else { - Rect r; - for ( int i=0 ; i < 2 ; i++ ) { - r._min[i] = std::max(a->_min[i], b->_min[i]); - r._max[i] = std::min(a->_max[i], b->_max[i]); - if ( r._min[i] > r._max[i] ) { - return boost::optional(); - } - } - return r; - } -} - -/** returns the smallest rectangle containing both rectangles */ -Rect union_bounds(Rect const &a, Rect const &b) { - Rect r; - for ( int i=0 ; i < 2 ; i++ ) { - r._min[i] = std::min(a._min[i], b._min[i]); - r._max[i] = std::max(a._max[i], b._max[i]); - } - return r; -} - -} // namespace NR - - /* Local Variables: mode:c++ diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h index aa5921309..4931b3e10 100644 --- a/src/libnr/nr-rect.h +++ b/src/libnr/nr-rect.h @@ -3,8 +3,7 @@ /** \file * Definitions of NRRect and NR::Rect types, and some associated functions \& macros. - */ -/* + *//* * Authors: * Lauris Kaplinski * Nathan Hurst @@ -13,251 +12,33 @@ * This code is in public domain */ - #include #include +#include #include +#include <2geom/rect.h> +#include "libnr/nr-forward.h" #include "libnr/nr-values.h" -#include -#include -#include -#include -#include "libnr/nr-point-ops.h" #include "libnr/nr-macros.h" -#include -#include -#include <2geom/rect.h> - -namespace NR { - -class Matrix; - -/** A rectangle is always aligned to the X and Y axis. This means it - * can be defined using only 4 coordinates, and determining - * intersection is very efficient. The points inside a rectangle are - * min[dim] <= _pt[dim] <= max[dim]. A rectangle may be empty, in the - * sense of having zero area, but it will always contain at least one - * point. Infinities are also permitted. - */ -class Rect { -public: - Rect() : _min(-_inf(), -_inf()), _max(_inf(), _inf()) {} - Rect(Point const &p0, Point const &p1); - - Point const &min() const { return _min; } - Point const &max() const { return _max; } - - /** returns the four corners of the rectangle in order - * (clockwise if +Y is up, anticlockwise if +Y is down) */ - Point corner(unsigned i) const; - - /** returns a vector from min to max. */ - Point dimensions() const; - - /** returns the midpoint of this rect. */ - Point midpoint() const; - - Point cornerFarthestFrom(Point const &p) const; - - /** True iff either width or height is less than \a epsilon. */ - bool isEmpty(double epsilon=1e-6) const { - return isEmpty(epsilon) || isEmpty(epsilon); - } - - bool intersects(Rect const &r) const { - return intersects(r) && intersects(r); - } - bool contains(Rect const &r) const { - return contains(r) && contains(r); - } - bool contains(Point const &p) const { - return contains(p) && contains(p); - } - - double area() const { - return extent() * extent(); - } - - double maxExtent() const { - return MAX(extent(), extent()); - } - - double extent(Dim2 const axis) const { - switch (axis) { - case X: return extent(); - case Y: return extent(); - default: g_error("invalid axis value %d", (int) axis); return 0; - }; - } - - double extent(unsigned i) const throw(std::out_of_range) { - switch (i) { - case 0: return extent(); - case 1: return extent(); - default: throw std::out_of_range("Dimension out of range"); - }; - } - - /** - \brief Remove some precision from the Rect - \param places The number of decimal places left in the end - - This function just calls round on the \c _min and \c _max points. - */ - inline void round(int places = 0) { - _min.round(places); - _max.round(places); - return; - } - - /** Translates the rectangle by p. */ - void offset(Point p); - - /** Makes this rectangle large enough to include the point p. */ - void expandTo(Point p); - - /** Makes this rectangle large enough to include the rectangle r. */ - void expandTo(Rect const &r); - - inline void move_left (gdouble by) { - _min[NR::X] += by; - } - inline void move_right (gdouble by) { - _max[NR::X] += by; - } - inline void move_top (gdouble by) { - _min[NR::Y] += by; - } - inline void move_bottom (gdouble by) { - _max[NR::Y] += by; - } - - void growBy (gdouble by); - - /** Scales the rect by s, with origin at 0, 0 */ - inline Rect operator*(double const s) const { - return Rect(s * min(), s * max()); - } - - inline bool operator==(Rect const &in_rect) { - return ((this->min() == in_rect.min()) && (this->max() == in_rect.max())); - } - - friend inline std::ostream &operator<<(std::ostream &out_file, NR::Rect const &in_rect); - -private: -// Rect(Nothing) : _min(1, 1), _max(-1, -1) {} - - static double _inf() { - return std::numeric_limits::infinity(); - } - - template - double extent() const { - return _max[axis] - _min[axis]; - } - - template - bool isEmpty(double epsilon) const { - return extent() < epsilon; - } - - template - bool intersects(Rect const &r) const { - return _max[axis] >= r._min[axis] && _min[axis] <= r._max[axis]; - } - - template - bool contains(Rect const &r) const { - return contains(r._min) && contains(r._max); - } - - template - bool contains(Point const &p) const { - return p[axis] >= _min[axis] && p[axis] <= _max[axis]; - } - - Point _min, _max; - - friend boost::optional intersection(boost::optional const &, boost::optional const &); - friend Rect union_bounds(Rect const &, Rect const &); -}; - -/** Returns the set of points shared by both rectangles. */ -boost::optional intersection(boost::optional const & a, boost::optional const & b); - -/** Returns the smallest rectangle that encloses both rectangles. */ -Rect union_bounds(Rect const &a, Rect const &b); -inline Rect union_bounds(boost::optional const & a, Rect const &b) { - if (a) { - return union_bounds(*a, b); - } else { - return b; - } -} -inline Rect union_bounds(Rect const &a, boost::optional const & b) { - if (b) { - return union_bounds(a, *b); - } else { - return a; - } -} -inline boost::optional union_bounds(boost::optional const & a, boost::optional const & b) -{ - if (!a) { - return b; - } else if (!b) { - return a; - } else { - return union_bounds(*a, *b); - } -} - -/** A function to print out the rectange if sent to an output - stream. */ -inline std::ostream -&operator<<(std::ostream &out_file, NR::Rect const &in_rect) -{ - out_file << "Rectangle:\n"; - out_file << "\tMin Point -> " << in_rect.min() << "\n"; - out_file << "\tMax Point -> " << in_rect.max() << "\n"; - - return out_file; -} - -} /* namespace NR */ /* legacy rect stuff */ - /* NULL rect is infinite */ struct NRRect { NRRect() : x0(0), y0(0), x1(0), y1(0) {} - NRRect(NR::Coord xmin, NR::Coord ymin, NR::Coord xmax, NR::Coord ymax) + NRRect(double xmin, double ymin, double xmax, double ymax) : x0(xmin), y0(ymin), x1(xmax), y1(ymax) {} - explicit NRRect(NR::Rect const &rect); - explicit NRRect(boost::optional const &rect); - operator boost::optional() const { return upgrade(); } - boost::optional upgrade() const; explicit NRRect(Geom::OptRect const &rect); operator Geom::OptRect() const { return upgrade_2geom(); } Geom::OptRect upgrade_2geom() const; - NR::Coord x0, y0, x1, y1; + double x0, y0, x1, y1; }; -#define nr_rect_d_set_empty(r) (*(r) = NR_RECT_EMPTY) -#define nr_rect_l_set_empty(r) (*(r) = NR_RECT_L_EMPTY) - -/** "Empty" here includes the case of zero width or zero height. */ -// TODO convert to static overloaded functions (pointer and ref) once performance can be tested: -#define nr_rect_d_test_empty_ptr(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r)) -#define nr_rect_d_test_empty(r) NR_RECT_DFLS_TEST_EMPTY_REF(r) - // TODO convert to static overloaded functions (pointer and ref) once performance can be tested: #define nr_rect_l_test_empty_ptr(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r)) #define nr_rect_l_test_empty(r) NR_RECT_DFLS_TEST_EMPTY_REF(r) @@ -282,7 +63,7 @@ struct NRRect { NRRectL *nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1); // returns the area of r -NR::ICoord nr_rect_l_area(NRRectL *r); +gint32 nr_rect_l_area(NRRectL *r); /* NULL values are OK for r0 and r1, but not for d */ NRRect *nr_rect_d_intersect(NRRect *d, NRRect const *r0, NRRect const *r1); @@ -291,13 +72,9 @@ NRRectL *nr_rect_l_intersect(NRRectL *d, NRRectL const *r0, NRRectL const *r1); NRRect *nr_rect_d_union(NRRect *d, NRRect const *r0, NRRect const *r1); NRRectL *nr_rect_l_union(NRRectL *d, NRRectL const *r0, NRRectL const *r1); -NRRect *nr_rect_union_pt(NRRect *dst, NR::Point const &p); -NRRect *nr_rect_d_union_xy(NRRect *d, NR::Coord x, NR::Coord y); -NRRectL *nr_rect_l_union_xy(NRRectL *d, NR::ICoord x, NR::ICoord y); - -NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NR::Matrix const &m); -NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NR::Matrix const *m); -NRRectL *nr_rect_l_enlarge(NRRectL *d, int amount); +NRRect *nr_rect_union_pt(NRRect *dst, Geom::Point const &p); +NRRect *nr_rect_d_union_xy(NRRect *d, double x, double y); +NRRectL *nr_rect_l_union_xy(NRRectL *d, gint32 x, gint32 y); #endif /* !LIBNR_NR_RECT_H_SEEN */ diff --git a/src/libnr/nr-render.h b/src/libnr/nr-render.h deleted file mode 100644 index 84215b7a3..000000000 --- a/src/libnr/nr-render.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __NR_RENDER_H__ -#define __NR_RENDER_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -struct NRRenderer; - -typedef void (* NRRenderFunc) (NRRenderer *r, NRPixBlock *pb, NRPixBlock *m); - -struct NRRenderer { - NRRenderFunc render; -}; - -#define nr_render(r,pb,m) ((NRRenderer *) (r))->render ((NRRenderer *) (r), (pb), (m)) - -#endif diff --git a/src/libnr/nr-types-test.h b/src/libnr/nr-types-test.h deleted file mode 100644 index 77550351f..000000000 --- a/src/libnr/nr-types-test.h +++ /dev/null @@ -1,142 +0,0 @@ -// nr-types-test.h -#include - -#include "libnr/nr-types.h" -#include "libnr/nr-point-fns.h" -#include - -class NrTypesTest : public CxxTest::TestSuite -{ -public: - NrTypesTest() : - a( 1.5, 2.0 ), - b(-2.0, 3.0), - ab(-0.5, 5.0), - small(pow(2.0, -1070)), - small_left(-small, 0.0), - smallish_3_neg4(3.0 * small, -4.0 * small) - {} - virtual ~NrTypesTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static NrTypesTest *createSuite() { return new NrTypesTest(); } - static void destroySuite( NrTypesTest *suite ) { delete suite; } - - NR::Point const a; - NR::Point const b; - NR::Point const ab; - double const small; - NR::Point const small_left; - NR::Point const smallish_3_neg4; - - - void testXYValues( void ) - { - TS_ASSERT_EQUALS( NR::X, 0 ); - TS_ASSERT_EQUALS( NR::Y, 1 ); - } - - void testXYCtorAndArrayConst(void) - { - TS_ASSERT_EQUALS( a[NR::X], 1.5 ); - TS_ASSERT_EQUALS( a[NR::Y], 2.0 ); - } - - void testCopyCtor(void) - { - NR::Point a_copy(a); - - TS_ASSERT_EQUALS( a, a_copy ); - TS_ASSERT( !(a != a_copy) ); - } - - void testNonConstArrayOperator(void) - { - NR::Point a_copy(a); - a_copy[NR::X] = -2.0; - TS_ASSERT_DIFFERS( a_copy, a ); - TS_ASSERT_DIFFERS( a_copy, b ); - a_copy[NR::Y] = 3.0; - TS_ASSERT_EQUALS( a_copy, b ); - } - - void testBinaryPlusMinus(void) - { - TS_ASSERT_DIFFERS( a, b ); - TS_ASSERT_EQUALS( a + b, ab ); - TS_ASSERT_EQUALS( ab - a, b ); - TS_ASSERT_EQUALS( ab - b, a ); - TS_ASSERT_DIFFERS( ab + a, b ); - } - - void testUnaryMinus(void) - { - TS_ASSERT_EQUALS( -a, NR::Point(-a[NR::X], -a[NR::Y]) ); - } - - void tetScaleDivide(void) - { - TS_ASSERT_EQUALS( -a, -1.0 * a ); - TS_ASSERT_EQUALS( a + a + a, 3.0 * a ); - TS_ASSERT_EQUALS( a / .5, 2.0 * a ); - } - - void testDot(void) - { - TS_ASSERT_EQUALS( dot(a, b), ( a[NR::X] * b[NR::X] + - a[NR::Y] * b[NR::Y] ) ); - TS_ASSERT_EQUALS( dot(a, NR::rot90(a)), 0.0 ); - TS_ASSERT_EQUALS( dot(-a, NR::rot90(a)), 0.0 ); - } - - void testL1L2LInftyNorms(void) - { - // TODO look at TS_ASSERT_DELTA - - TS_ASSERT_EQUALS( L1(small_left), small ); - TS_ASSERT_EQUALS( L2(small_left), small ); - TS_ASSERT_EQUALS( LInfty(small_left), small ); - - TS_ASSERT_EQUALS( L1(smallish_3_neg4), 7.0 * small ); - TS_ASSERT_EQUALS( L2(smallish_3_neg4), 5.0 * small ); - TS_ASSERT_EQUALS( LInfty(smallish_3_neg4), 4.0 * small ); - } - - void testOperatorPlusEquals(void) - { - NR::Point x(a); - x += b; - TS_ASSERT_EQUALS( x, ab ); - } - - void tetOperatorDivEquals(void) - { - NR::Point x(a); - x /= .5; - TS_ASSERT_EQUALS( x, a + a ); - } - - void testNormalize(void) - { - NR::Point x(small_left); - x.normalize(); - TS_ASSERT_EQUALS( x, NR::Point(-1.0, 0.0) ); - - x = smallish_3_neg4; - x.normalize(); - TS_ASSERT_EQUALS( x, NR::Point(0.6, -0.8) ); - } - -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-types.cpp b/src/libnr/nr-types.cpp deleted file mode 100644 index 5da5d5cf6..000000000 --- a/src/libnr/nr-types.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/** \file - * Implements NR::Point::normalize() - */ - -#include -#include <2geom/math-utils.h> - -/** Scales this vector to make it a unit vector (within rounding error). - * - * The current version tries to handle infinite coordinates gracefully, - * but it's not clear that any callers need that. - * - * \pre *this != Point(0, 0). - * \pre Neither coordinate is NaN. - * \post L2(*this) very near 1.0. - */ -void NR::Point::normalize() { - double len = hypot(_pt[0], _pt[1]); - g_return_if_fail(len != 0); - g_return_if_fail(!IS_NAN(len)); - static double const inf = 1e400; - if(len != inf) { - *this /= len; - } else { - unsigned n_inf_coords = 0; - /* Delay updating pt in case neither coord is infinite. */ - NR::Point tmp; - for ( unsigned i = 0 ; i < 2 ; ++i ) { - if ( _pt[i] == inf ) { - ++n_inf_coords; - tmp[i] = 1.0; - } else if ( _pt[i] == -inf ) { - ++n_inf_coords; - tmp[i] = -1.0; - } else { - tmp[i] = 0.0; - } - } - switch (n_inf_coords) { - case 0: - /* Can happen if both coords are near +/-DBL_MAX. */ - *this /= 4.0; - len = hypot(_pt[0], _pt[1]); - g_assert(len != inf); - *this /= len; - break; - - case 1: - *this = tmp; - break; - - case 2: - *this = sqrt(0.5) * tmp; - break; - } - } -} -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-types.h b/src/libnr/nr-types.h deleted file mode 100644 index 685c29342..000000000 --- a/src/libnr/nr-types.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __NR_TYPES_H__ -#define __NR_TYPES_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * Class-ifying NRPoint, Nathan Hurst - * - * This code is in public domain - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* !__NR_TYPES_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-values.cpp b/src/libnr/nr-values.cpp index 9193eff3b..5238353d4 100644 --- a/src/libnr/nr-values.cpp +++ b/src/libnr/nr-values.cpp @@ -1,7 +1,8 @@ #define __NR_VALUES_C__ -#include +#include "libnr/nr-values.h" #include "libnr/nr-rect.h" +#include "libnr/nr-rect-l.h" /* The following predefined objects are for reference @@ -10,11 +11,9 @@ and comparison. NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE); NRRectL NR_RECT_L_EMPTY = {NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L}; -NRRectL NR_RECT_S_EMPTY = - {NR_HUGE_S, NR_HUGE_S, -NR_HUGE_S, -NR_HUGE_S}; /** component_vectors[i] is like $e_i$ in common mathematical usage; or equivalently $I_i$ (where $I$ is the identity matrix). */ -NR::Point const component_vectors[] = {NR::Point(1., 0.), - NR::Point(0., 1.)}; +Geom::Point const component_vectors[] = {Geom::Point(1., 0.), + Geom::Point(0., 1.)}; diff --git a/src/libnr/nr-values.h b/src/libnr/nr-values.h index f85fca690..07faec9fa 100644 --- a/src/libnr/nr-values.h +++ b/src/libnr/nr-values.h @@ -11,12 +11,12 @@ */ #include +#include <2geom/point.h> #define NR_EPSILON 1e-18 #define NR_HUGE 1e18 #define NR_HUGE_L (0x7fffffff) -#define NR_HUGE_S (0x7fff) /* The following predefined objects are for reference @@ -24,11 +24,10 @@ and comparison. They are defined in nr-values.cpp */ extern NRRect NR_RECT_EMPTY; extern NRRectL NR_RECT_L_EMPTY; -extern NRRectL NR_RECT_S_EMPTY; /** component_vectors[i] has 1.0 at position i, and 0.0 elsewhere (i.e. in the other position). */ -extern NR::Point const component_vectors[2]; +extern Geom::Point const component_vectors[2]; #endif diff --git a/src/libnr/nr_config.h.mingw b/src/libnr/nr_config.h.mingw deleted file mode 100644 index 6992cc6fc..000000000 --- a/src/libnr/nr_config.h.mingw +++ /dev/null @@ -1,12 +0,0 @@ -#define NR_SIZEOF_CHAR 1 -#define NR_SIZEOF_SHORT 2 -#define NR_SIZEOF_INT 4 -#define NR_SIZEOF_LONG 4 - -typedef signed char NRByte; -typedef unsigned char NRUByte; -typedef signed short NRShort; -typedef unsigned short NRUShort; -typedef signed int NRLong; -typedef unsigned long NRULong; - diff --git a/src/libnr/nr_config.h.win32 b/src/libnr/nr_config.h.win32 deleted file mode 100644 index e0bfbda3f..000000000 --- a/src/libnr/nr_config.h.win32 +++ /dev/null @@ -1,14 +0,0 @@ -#define NR_SIZEOF_CHAR 1 -#define NR_SIZEOF_SHORT 2 -#define NR_SIZEOF_INT 4 -#define NR_SIZEOF_LONG 4 - -typedef signed char NRByte; -typedef unsigned char NRUByte; -typedef signed short NRShort; -typedef unsigned short NRUShort; -typedef signed int NRLong; -typedef unsigned long NRULong; - - - diff --git a/src/livarot/Path.h b/src/livarot/Path.h index b8041c63a..78e90c34f 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -12,9 +12,8 @@ #include #include "LivarotDefs.h" #include "livarot/livarot-forward.h" -#include "libnr/nr-point.h" #include -#include <2geom/forward.h> +#include <2geom/point.h> struct SPStyle; diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index fb2aa55e2..fe1981e4d 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -7,6 +7,7 @@ */ #include +#include <2geom/affine.h> #include "livarot/Path.h" #include "livarot/path-description.h" diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index 9107844be..d24e4b99d 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -2225,7 +2225,7 @@ double distance(Shape const *s, Geom::Point const &p) if ( el > 0.001 ) { double const npr = Geom::dot(d, e); if ( npr > 0 && npr < el ) { - double const nl = fabs( NR::cross(d, e) ); + double const nl = fabs( Geom::cross(d, e) ); double ndot = nl * nl / el; if ( ndot < bdot ) { bdot = ndot; @@ -2271,7 +2271,7 @@ bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const double const max_l1 = max_l2 * M_SQRT2; for (int i = 0; i < s->numberOfPoints(); i++) { Geom::Point const offset( p - s->getPoint(i).x ); - double const l1 = NR::L1(offset); + double const l1 = Geom::L1(offset); if ( (l1 <= max_l2) || ((l1 <= max_l1) && (Geom::L2(offset) <= max_l2)) ) { return true; } @@ -2288,7 +2288,7 @@ bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const Geom::Point const e_unit(e / el); double const npr = Geom::dot(d, e_unit); if ( npr > 0 && npr < el ) { - double const nl = fabs(NR::cross(d, e_unit)); + double const nl = fabs(Geom::cross(d, e_unit)); if ( nl <= max_l2 ) { return true; } diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index 5649ff9e4..158977897 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -14,8 +14,8 @@ #include #include #include +#include <2geom/point.h> -#include "libnr/nr-point.h" #include "livarot/livarot-forward.h" #include "livarot/LivarotDefs.h" diff --git a/src/livarot/path-description.h b/src/livarot/path-description.h index 1d0dfb57e..e9818b55b 100644 --- a/src/livarot/path-description.h +++ b/src/livarot/path-description.h @@ -1,8 +1,8 @@ #ifndef SEEN_INKSCAPE_LIVAROT_PATH_DESCRIPTION_H #define SEEN_INKSCAPE_LIVAROT_PATH_DESCRIPTION_H +#include <2geom/point.h> #include "svg/stringstream.h" -#include "libnr/nr-point.h" // path description commands /* FIXME: these should be unnecessary once the refactoring of the path diff --git a/src/livarot/sweep-event.h b/src/livarot/sweep-event.h index dab006101..5df952731 100644 --- a/src/livarot/sweep-event.h +++ b/src/livarot/sweep-event.h @@ -4,7 +4,7 @@ * Intersection events. */ -#include +#include <2geom/point.h> class SweepTree; diff --git a/src/livarot/sweep-tree.h b/src/livarot/sweep-tree.h index 4a2efe5ec..bbb027b24 100644 --- a/src/livarot/sweep-tree.h +++ b/src/livarot/sweep-tree.h @@ -1,8 +1,8 @@ #ifndef INKSCAPE_LIVAROT_SWEEP_TREE_H #define INKSCAPE_LIVAROT_SWEEP_TREE_H -#include "libnr/nr-point.h" #include "livarot/AVL.h" +#include <2geom/point.h> class Shape; class SweepEvent; diff --git a/src/marker.cpp b/src/marker.cpp index e82d3d952..2354d686c 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -19,6 +19,7 @@ #include "libnr/nr-convert2geom.h" #include <2geom/affine.h> +#include <2geom/transforms.h> #include "svg/svg.h" #include "display/nr-arena-group.h" #include "xml/repr.h" diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 743ef573a..28c8d44db 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -959,7 +959,7 @@ StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origi Geom::Point const s = snap_knot_position(p); - Geom::Point d = s - to_2geom(star->center); + Geom::Point d = s - star->center; double arg1 = atan2(d); double darg1 = arg1 - star->arg[0]; @@ -986,7 +986,7 @@ StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origi Geom::Point const s = snap_knot_position(p); if (star->flatsided == false) { - Geom::Point d = s - to_2geom(star->center); + Geom::Point d = s - star->center; double arg1 = atan2(d); double darg1 = arg1 - star->arg[1]; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 64137d56f..19e0351a3 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -38,7 +38,6 @@ #include "display/sp-ctrlline.h" #include "display/sodipodi-ctrl.h" #include -#include "libnr/nr-point-ops.h" #include "helper/units.h" #include "macros.h" #include "context-fns.h" @@ -913,7 +912,7 @@ pen_redraw_all (SPPenContext *const pc) if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); if ( cubic && - (*cubic)[2] != to_2geom(pc->p[0]) ) + (*cubic)[2] != pc->p[0] ) { Geom::Point p2 = (*cubic)[2]; SP_CTRL(pc->c0)->moveto(p2); diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index a873eb6fc..57205a436 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -57,10 +57,10 @@ static gint pencil_handle_button_release(SPPencilContext *const pc, GdkEventButt static gint pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state); static gint pencil_handle_key_release(SPPencilContext *const pc, guint const keyval, guint const state); -static void spdc_set_startpoint(SPPencilContext *pc, Geom::Point const p); -static void spdc_set_endpoint(SPPencilContext *pc, Geom::Point const p); +static void spdc_set_startpoint(SPPencilContext *pc, Geom::Point const &p); +static void spdc_set_endpoint(SPPencilContext *pc, Geom::Point const &p); static void spdc_finish_endpoint(SPPencilContext *pc); -static void spdc_add_freehand_point(SPPencilContext *pc, Geom::Point p, guint state); +static void spdc_add_freehand_point(SPPencilContext *pc, Geom::Point const &p, guint state); static void fit_and_split(SPPencilContext *pc); static void interpolate(SPPencilContext *pc); static void sketch_interpolate(SPPencilContext *pc); @@ -644,7 +644,7 @@ pencil_handle_key_release(SPPencilContext *const pc, guint const keyval, guint c * Reset points and set new starting point. */ static void -spdc_set_startpoint(SPPencilContext *const pc, Geom::Point const p) +spdc_set_startpoint(SPPencilContext *const pc, Geom::Point const &p) { pc->npoints = 0; pc->red_curve_is_valid = false; @@ -664,7 +664,7 @@ spdc_set_startpoint(SPPencilContext *const pc, Geom::Point const p) * We change RED curve. */ static void -spdc_set_endpoint(SPPencilContext *const pc, Geom::Point const p) +spdc_set_endpoint(SPPencilContext *const pc, Geom::Point const &p) { if (pc->npoints == 0) { return; @@ -716,7 +716,7 @@ spdc_finish_endpoint(SPPencilContext *const pc) static void -spdc_add_freehand_point(SPPencilContext *pc, Geom::Point p, guint /*state*/) +spdc_add_freehand_point(SPPencilContext *pc, Geom::Point const &p, guint /*state*/) { g_assert( pc->npoints > 0 ); g_return_if_fail(unsigned(pc->npoints) < G_N_ELEMENTS(pc->p)); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index bcb1bf734..be4f1c71d 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -281,14 +281,14 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent /* Position center */ Geom::Point button_dt(desktop->w2d(button_w)); - rc->center = from_2geom(button_dt); + rc->center = button_dt; /* Snap center */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); - rc->center = from_2geom(button_dt); + rc->center = button_dt; sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), ( GDK_KEY_PRESS_MASK | diff --git a/src/rect-context.h b/src/rect-context.h index db7cd605b..00caf5d96 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -16,8 +16,8 @@ #include #include +#include <2geom/point.h> #include "event-context.h" -#include "libnr/nr-point.h" #define SP_TYPE_RECT_CONTEXT (sp_rect_context_get_type ()) #define SP_RECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_RECT_CONTEXT, SPRectContext)) diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index b01ae5228..a503fea35 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -10,12 +10,13 @@ * * Released under GNU LGPL. Read the file 'COPYING' for more information. */ +#include +#include <2geom/transforms.h> #include "util/glib-list-iterators.h" #include "sp-item.h" #include "sp-item-transform.h" #include "libvpsc/generate-constraints.h" #include "libvpsc/remove_rectangle_overlap.h" -#include using vpsc::Rectangle; diff --git a/src/selection.cpp b/src/selection.cpp index 3c4ccccf2..3007a3d1f 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -403,7 +403,7 @@ NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { Geom::OptRect Selection::boundsInDocument(SPItem::BBoxType type) const { NRRect r; - return to_2geom(boundsInDocument(&r, type)->upgrade()); + return to_2geom(boundsInDocument(&r, type)); } /** Extract the position of the center from the first selected object */ diff --git a/src/snap.cpp b/src/snap.cpp index f8fe8e3fa..922dfd530 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -19,6 +19,7 @@ */ #include +#include <2geom/transforms.h> #include "sp-namedview.h" #include "snap.h" @@ -293,7 +294,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position // doesn't tell us anything about which node to snap success = true; - nearest_multiple = s.getPoint() - to_2geom(grid->origin); + nearest_multiple = s.getPoint() - grid->origin; nearest_distance = s.getSnapDistance(); bestSnappedPoint = s; } diff --git a/src/sp-conn-end-pair.h b/src/sp-conn-end-pair.h index 6e62b9839..98096a246 100644 --- a/src/sp-conn-end-pair.h +++ b/src/sp-conn-end-pair.h @@ -14,7 +14,6 @@ #include #include "forward.h" -#include "libnr/nr-point.h" #include #include #include diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index d7bc0053f..9db0d29b2 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -361,7 +361,10 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) if (!bbox_maybe) { return; } - bbox = NRRect(from_2geom(*bbox_maybe)); + bbox.x0 = bbox_maybe->min()[Geom::X]; + bbox.y0 = bbox_maybe->min()[Geom::Y]; + bbox.x1 = bbox_maybe->max()[Geom::X]; + bbox.y1 = bbox_maybe->max()[Geom::Y]; NRRect dbox; dbox.x0 = 0.0; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f98a6c8e3..3f1c19295 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -25,6 +25,7 @@ #include #include #include <2geom/rect.h> +#include <2geom/transforms.h> #include #include "display/nr-arena-image.h" @@ -1497,7 +1498,7 @@ static void sp_image_set_curve( SPImage *image ) } else { NRRect rect; sp_image_bbox(image, &rect, Geom::identity(), 0); - Geom::Rect rect2 = to_2geom(*rect.upgrade()); + Geom::Rect rect2 = *to_2geom(&rect); SPCurve *c = SPCurve::new_from_rect(rect2, true); if (image->curve) { diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 424107426..8e1a4d92c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -299,7 +299,7 @@ Geom::Point SPItem::getCenter() const { Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { - return to_2geom(bbox->midpoint()) + Geom::Point (transform_center_x, transform_center_y); + return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y); } else { return Geom::Point(0, 0); // something's wrong! } diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 76efb6b4b..38599188f 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -13,10 +13,11 @@ #include #include +#include <2geom/transforms.h> #include "display/nr-arena.h" #include "display/nr-arena-group.h" -#include +#include "xml/repr.h" #include "enums.h" #include "attributes.h" diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 1feb644ad..35a159192 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -17,6 +17,7 @@ #include "config.h" #include #include +#include <2geom/transforms.h> #include "display/canvas-grid.h" #include "display/guideline.h" @@ -1099,8 +1100,7 @@ void SPNamedView::translateGuides(Geom::Translate const &tr) { for (GSList *l = guides; l != NULL; l = l->next) { SPGuide &guide = *SP_GUIDE(l->data); Geom::Point point_on_line = guide.point_on_line; - point_on_line[0] += tr[0]; - point_on_line[1] += tr[1]; + point_on_line *= tr; sp_guide_moveto(guide, point_on_line, true); } } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 460421492..0dd65c7b9 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -844,7 +844,7 @@ sp_offset_distance_to_original (SPOffset * offset, Geom::Point px) { // we have a new minimum distance // now we need to wheck if px is inside or outside (for the sign) - nx = px - to_2geom(theRes->getPoint(i).x); + nx = px - theRes->getPoint(i).x; double nlen = sqrt (dot(nx , nx)); nx /= nlen; int pb, cb, fb; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index b1eef65d2..7d72b7695 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -19,6 +19,7 @@ #include #include +#include <2geom/transforms.h> #include "svg/svg.h" #include "display/nr-arena-group.h" diff --git a/src/sp-text.h b/src/sp-text.h index c98721ec9..cd103aa2a 100644 --- a/src/sp-text.h +++ b/src/sp-text.h @@ -19,7 +19,6 @@ #include "sp-item.h" #include "sp-string.h" #include "text-tag-attributes.h" -#include "libnr/nr-point.h" #include "libnrtype/Layout-TNG.h" diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 754885192..a5e1fbc17 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -53,7 +53,7 @@ static void sp_spiral_context_set(SPEventContext *ec, Inkscape::Preferences::Ent static gint sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event); -static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state); +static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point const &p, guint state); static void sp_spiral_finish(SPSpiralContext *sc); static void sp_spiral_cancel(SPSpiralContext *sc); @@ -275,7 +275,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) m.setup(desktop, true, sc->item); m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); - sp_spiral_drag(sc, from_2geom(motion_dt), event->motion.state); + sp_spiral_drag(sc, motion_dt, event->motion.state); gobble_motion_events(GDK_BUTTON1_MASK); @@ -399,7 +399,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) return ret; } -static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) +static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point const &p, guint state) { SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop; @@ -430,7 +430,7 @@ static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, sc->item); - Geom::Point pt2g = to_2geom(p); + Geom::Point pt2g = p; m.freeSnapReturnByRef(pt2g, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); Geom::Point const p0 = desktop->dt2doc(sc->center); diff --git a/src/spiral-context.h b/src/spiral-context.h index 6d689c49c..d877e6ae4 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -18,8 +18,8 @@ #include #include #include +#include <2geom/point.h> #include "event-context.h" -#include "libnr/nr-point.h" #define SP_TYPE_SPIRAL_CONTEXT (sp_spiral_context_get_type ()) #define SP_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContext)) diff --git a/src/spray-context.h b/src/spray-context.h index f6d9a9c0b..fc2340b5e 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -18,8 +18,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/point.h> #include "event-context.h" -#include //#include "ui/widget/spray-option.h" #include "ui/dialog/dialog.h" diff --git a/src/star-context.cpp b/src/star-context.cpp index 9f4afb94c..bc0376a20 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -225,9 +225,9 @@ sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val) Glib::ustring path = val->getEntryName(); if (path == "magnitude") { - sc->magnitude = NR_CLAMP(val->getInt(5), 3, 1024); + sc->magnitude = CLAMP(val->getInt(5), 3, 1024); } else if (path == "proportion") { - sc->proportion = NR_CLAMP(val->getDouble(0.5), 0.01, 2.0); + sc->proportion = CLAMP(val->getDouble(0.5), 0.01, 2.0); } else if (path == "isflatsided") { sc->isflatsided = val->getBool(); } else if (path == "rounded") { @@ -446,7 +446,7 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state) /* Snap corner point with no constraints */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, sc->item); - Geom::Point pt2g = to_2geom(p); + Geom::Point pt2g = p; m.freeSnapReturnByRef(pt2g, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); Geom::Point const p0 = desktop->dt2doc(sc->center); diff --git a/src/star-context.h b/src/star-context.h index b66e2dd15..c7cba2bf0 100644 --- a/src/star-context.h +++ b/src/star-context.h @@ -16,8 +16,8 @@ #include #include +#include <2geom/point.h> #include "event-context.h" -#include "libnr/nr-point.h" #define SP_TYPE_STAR_CONTEXT (sp_star_context_get_type ()) #define SP_STAR_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_STAR_CONTEXT, SPStarContext)) diff --git a/src/svg-view.cpp b/src/svg-view.cpp index b35375736..44c874150 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -13,6 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/transforms.h> #include "display/canvas-arena.h" #include "document.h" #include "sp-item.h" diff --git a/src/tweak-context.h b/src/tweak-context.h index 5fbd078ef..d77605a82 100644 --- a/src/tweak-context.h +++ b/src/tweak-context.h @@ -13,7 +13,7 @@ */ #include "event-context.h" -#include +#include <2geom/point.h> #define SP_TYPE_TWEAK_CONTEXT (sp_tweak_context_get_type()) #define SP_TWEAK_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_TWEAK_CONTEXT, SPTweakContext)) diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index fd7070bab..c631631fb 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -21,6 +21,7 @@ #include #include +#include <2geom/transforms.h> #include "sp-namedview.h" #include "selection.h" #include "inkscape.h" diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index a2169c0b3..f7cb06263 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -20,8 +20,8 @@ # include #endif +#include <2geom/transforms.h> #include "ui/widget/spinbutton.h" - #include "desktop-handles.h" #include "unclump.h" #include "document.h" @@ -357,7 +357,7 @@ private : it < sorted.end(); it ++ ) { - if (!NR_DF_TEST_CLOSE (pos, it->bbox.min()[_orientation], 1e-6)) { + if (!Geom::are_near(pos, it->bbox.min()[_orientation], 1e-6)) { Geom::Point t(0.0, 0.0); t[_orientation] = pos - it->bbox.min()[_orientation]; sp_item_move_rel(it->item, Geom::Translate(t)); @@ -380,7 +380,7 @@ private : //new anchor position float pos = sorted.front().anchor + i * step; //Don't move if we are really close - if (!NR_DF_TEST_CLOSE (pos, it.anchor, 1e-6)) { + if (!Geom::are_near(pos, it.anchor, 1e-6)) { //Compute translation Geom::Point t(0.0, 0.0); t[_orientation] = pos - it.anchor; diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 7c99d67c7..99b96463c 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -25,7 +25,6 @@ #include #include #include -#include "libnr/nr-dim2.h" #include "libnr/nr-rect.h" diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index ae17214bf..7c7413ce5 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -21,6 +21,7 @@ #include //for GTK_RESPONSE* types #include #include +#include <2geom/transforms.h> #include "verbs.h" #include "preferences.h" diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 901d02240..92c8bd349 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -16,6 +16,7 @@ #include #include +#include <2geom/transforms.h> #include "document.h" #include "desktop-handles.h" diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 4ff4f92f9..577beb5ce 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -16,9 +16,9 @@ #ifndef INKSCAPE_UI_VIEW_EDIT_WIDGET_IFACE_H #define INKSCAPE_UI_VIEW_EDIT_WIDGET_IFACE_H -#include "libnr/nr-point.h" #include "message.h" #include +#include <2geom/point.h> namespace Inkscape { namespace UI { namespace Widget { class Dock; } } } diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index f05e024d1..dc6307ab0 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -16,7 +16,7 @@ # include "config.h" #endif -#include "libnr/nr-point.h" +#include <2geom/point.h> #include "document.h" #include "view.h" #include "message-stack.h" diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 672e1415b..626be7625 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include <2geom/transforms.h> #include "desktop-handles.h" #include "document.h" diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 396280aee..23d5363ef 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -9,13 +9,12 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#include "event-context.h" -#include "rotateable.h" -#include "libnr/nr-point.h" -#include "libnr/nr-point-fns.h" #include #include #include +#include <2geom/point.h> +#include "event-context.h" +#include "rotateable.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/ruler.h b/src/ui/widget/ruler.h index c315418d8..afe3a4ba7 100644 --- a/src/ui/widget/ruler.h +++ b/src/ui/widget/ruler.h @@ -13,7 +13,7 @@ */ #include -#include "libnr/nr-point.h" +#include <2geom/point.h> struct SPCanvasItem; struct SPDesktop; diff --git a/src/unclump.cpp b/src/unclump.cpp index d027a6986..baeeaff76 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -12,6 +12,7 @@ #include #include +#include <2geom/transforms.h> #include "sp-item.h" diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp index dead653de..3339c64d3 100644 --- a/src/widgets/dash-selector.cpp +++ b/src/widgets/dash-selector.cpp @@ -22,9 +22,9 @@ #include #include -#include #include #include +#include <2geom/coord.h> #include "style.h" #include "dialogs/dialog-events.h" @@ -144,7 +144,7 @@ SPDashSelector::set_dash (int ndash, double *dash, double o) if (np == ndash) { int j; for (j = 0; j < ndash; j++) { - if (!NR_DF_TEST_CLOSE (dash[j], pattern[j], delta)) + if (!Geom::are_near(dash[j], pattern[j], delta)) break; } if (j == ndash) { diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 6f3b4dcb9..797525838 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -24,8 +24,9 @@ # include "config.h" #endif -#include #include +#include +#include <2geom/rect.h> #include "box3d-context.h" #include "color-profile-fns.h" @@ -1522,7 +1523,7 @@ sp_desktop_widget_update_hruler (SPDesktopWidget *dtw) * the latter is used for drawing e.g. the grids and guides. Only when the viewbox * coincides with the pixel buffer, everything will line up nicely. */ - NR::IRect viewbox = dtw->canvas->getViewboxIntegers(); + Geom::IntRect viewbox = dtw->canvas->getViewboxIntegers(); double const scale = dtw->desktop->current_zoom(); double s = viewbox.min()[Geom::X] / scale - dtw->ruler_origin[Geom::X]; @@ -1538,7 +1539,7 @@ sp_desktop_widget_update_vruler (SPDesktopWidget *dtw) * the latter is used for drawing e.g. the grids and guides. Only when the viewbox * coincides with the pixel buffer, everything will line up nicely. */ - NR::IRect viewbox = dtw->canvas->getViewboxIntegers(); + Geom::IntRect viewbox = dtw->canvas->getViewboxIntegers(); double const scale = dtw->desktop->current_zoom(); double s = viewbox.min()[Geom::Y] / -scale - dtw->ruler_origin[Geom::Y]; diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 6c5af0aac..165367954 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -14,7 +14,6 @@ #include -#include "libnr/nr-point.h" #include "forward.h" #include "sp-object.h" #include "message.h" @@ -23,6 +22,7 @@ #include #include +#include <2geom/point.h> // forward declaration typedef struct _EgeColorProfTracker EgeColorProfTracker; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 450c5f0d9..95cb23a22 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -23,6 +23,7 @@ #include #include #include +#include <2geom/transforms.h> #include "path-prefix.h" #include "preferences.h" diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 01308104e..d0ff38592 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -6777,11 +6777,11 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) unsigned writing_mode = item->style->writing_mode.value; // below, variable names suggest horizontal move, but we check the writing direction // and move in the corresponding axis - int axis; + Geom::Dim2 axis; if (writing_mode == SP_CSS_WRITING_MODE_LR_TB || writing_mode == SP_CSS_WRITING_MODE_RL_TB) { - axis = NR::X; + axis = Geom::X; } else { - axis = NR::Y; + axis = Geom::Y; } Geom::OptRect bbox @@ -6834,7 +6834,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) } } Geom::Point XY = SP_TEXT(item)->attributes.firstXY(); - if (axis == NR::X) { + if (axis == Geom::X) { XY = XY + Geom::Point (move, 0); } else { XY = XY + Geom::Point (0, move); -- cgit v1.2.3 From c213160c0dc2ad5807c23947ae61c8fc93f32b3e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 24 Jun 2011 00:33:00 +0200 Subject: Fix problems in GenericRect constructors (bzr r10347.1.3) --- src/2geom/generic-rect.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index 9a839d735..d60c4bb0f 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -77,8 +77,13 @@ public: } /** @brief Create a rectangle from two points. */ GenericRect(CPoint const &a, CPoint const &b) { - f[X] = Interval(a[X], b[X]); - f[Y] = Interval(a[Y], b[Y]); + f[X] = CInterval(a[X], b[X]); + f[Y] = CInterval(a[Y], b[Y]); + } + /** @brief Create rectangle from coordinates of two points. */ + GenericRect(C x0, C y0, C x1, C y1) { + f[X] = CInterval(x0, x1); + f[Y] = CInterval(y0, y1); } /** @brief Create a rectangle from a range of points. * The resulting rectangle will contain all ponts from the range. @@ -114,13 +119,6 @@ public: GenericRect result(xy, xy + wh); return result; } - /** @brief Create rectangle from two points. */ - static GenericRect from_xyxy(C x0, C x1, C y0, C y1) { - CPoint p0(x0, y0); - CPoint p1(x1, y1); - GenericRect result(p0, p1); - return result; - } /// @} /// @name Inspect dimensions. -- cgit v1.2.3 From c54a3678d2b0c1c3052d4689ef1ab3a6b23db979 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 23 Jun 2011 23:58:06 +0100 Subject: Replace deprecated gtk_radio_button_group symbol (bzr r10350.1.1) --- src/dialogs/clonetiler.cpp | 16 ++++++++-------- src/dialogs/text-edit.cpp | 8 ++++---- src/widgets/paint-selector.cpp | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 60ec4f9f7..43dbf4e60 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -2514,7 +2514,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); clonetiler_table_attach (table, radio, 0.0, 2, 1); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2522,7 +2522,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); clonetiler_table_attach (table, radio, 0.0, 1, 2); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2530,7 +2530,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); clonetiler_table_attach (table, radio, 0.0, 2, 2); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2538,7 +2538,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); clonetiler_table_attach (table, radio, 0.0, 3, 2); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2546,7 +2546,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); clonetiler_table_attach (table, radio, 0.0, 1, 3); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2554,7 +2554,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); clonetiler_table_attach (table, radio, 0.0, 2, 3); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2562,7 +2562,7 @@ void clonetiler_dialog(void) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); clonetiler_table_attach (table, radio, 0.0, 3, 3); g_signal_connect (G_OBJECT (radio), "toggled", @@ -2785,7 +2785,7 @@ void clonetiler_dialog(void) gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); clonetiler_table_attach (table, radio, 0.0, 2, 1); g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 76ad3bcc3..35db8e14c 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -251,7 +251,7 @@ sp_text_edit_dialog (void) { // TODO - replace with Inkscape-specific call GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_CENTER, GTK_ICON_SIZE_LARGE_TOOLBAR ); - GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); + GtkWidget *b = gtk_radio_button_new (gtk_radio_button_get_group (GTK_RADIO_BUTTON (group))); /* TRANSLATORS: `Center' here is a verb. */ gtk_widget_set_tooltip_text (b, _("Center lines")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); @@ -266,7 +266,7 @@ sp_text_edit_dialog (void) { // TODO - replace with Inkscape-specific call GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_RIGHT, GTK_ICON_SIZE_LARGE_TOOLBAR ); - GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); + GtkWidget *b = gtk_radio_button_new (gtk_radio_button_get_group (GTK_RADIO_BUTTON (group))); gtk_widget_set_tooltip_text (b, _("Align lines right")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); @@ -280,7 +280,7 @@ sp_text_edit_dialog (void) { // TODO - replace with Inkscape-specific call GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_FILL, GTK_ICON_SIZE_LARGE_TOOLBAR ); - GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); + GtkWidget *b = gtk_radio_button_new (gtk_radio_button_get_group (GTK_RADIO_BUTTON (group))); gtk_widget_set_tooltip_text (b, _("Justify lines")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); @@ -316,7 +316,7 @@ sp_text_edit_dialog (void) { GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL ); - GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); + GtkWidget *b = gtk_radio_button_new (gtk_radio_button_get_group (GTK_RADIO_BUTTON (group))); gtk_widget_set_tooltip_text (b, _("Vertical text")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 642837e61..f9ec4208f 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -257,7 +257,7 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->evenodd, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(psel->evenodd), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel); - psel->nonzero = gtk_radio_button_new(gtk_radio_button_group(GTK_RADIO_BUTTON(psel->evenodd))); + psel->nonzero = gtk_radio_button_new(gtk_radio_button_get_group(GTK_RADIO_BUTTON(psel->evenodd))); gtk_button_set_relief(GTK_BUTTON(psel->nonzero), GTK_RELIEF_NONE); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(psel->nonzero), FALSE); // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty -- cgit v1.2.3 From 653db8249ff01454821f2a2326317f4df9c7ab23 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 24 Jun 2011 01:00:22 +0200 Subject: Pull 2Geom revision 2013 (extra constructors for Rect). (bzr r10347.1.4) --- src/2geom/rect.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/2geom/rect.h b/src/2geom/rect.h index 72b659a81..e9f6cbeb7 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -71,6 +71,7 @@ public: Rect(Interval const &a, Interval const &b) : Base(a,b) {} /** @brief Create a rectangle from two points. */ Rect(Point const &a, Point const &b) : Base(a,b) {} + Rect(Coord x0, Coord y0, Coord x1, Coord y1) : Base(x0, y0, x1, y1) {} Rect(Base const &b) : Base(b) {} /** @brief Create a rectangle from a range of points. * The resulting rectangle will contain all ponts from the range. @@ -89,6 +90,14 @@ public: Rect result = Rect::from_range(c, c+n); return result; } + static Rect from_xywh(Coord x, Coord y, Coord w, Coord h) { + Rect result = Base::from_xywh(x, y, w, h); + return result; + } + static Rect from_xywh(Point const &o, Point const &dim) { + Rect result = Base::from_xywh(o, dim); + return result; + } /// @} /// @name Inspect dimensions. -- cgit v1.2.3 From f27307a481f64c0b2d70f02eb3828910981c02e0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 24 Jun 2011 00:42:12 +0100 Subject: Remove/replace deprecated gtk_window_set_policy symbol (bzr r10350.1.2) --- src/dialogs/text-edit.cpp | 2 -- src/dialogs/xml-tree.cpp | 2 +- src/inkview.cpp | 1 - src/interface.cpp | 4 +--- 4 files changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 35db8e14c..6d9985529 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -186,8 +186,6 @@ sp_text_edit_dialog (void) g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg ); g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg ); - gtk_window_set_policy (GTK_WINDOW (dlg), TRUE, TRUE, FALSE); - // box containing the notebook and the bottom buttons GtkWidget *mainvb = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (dlg), mainvb); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index c50c07e80..1b979b490 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -1317,7 +1317,7 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/) window = sp_window_new(NULL, TRUE); gtk_container_set_border_width(GTK_CONTAINER(window), 4); gtk_window_set_title(GTK_WINDOW(window), _("New element node...")); - gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE); + gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(dlg)); gtk_window_set_modal(GTK_WINDOW(window), TRUE); diff --git a/src/inkview.cpp b/src/inkview.cpp index 173427aae..09169f5be 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -312,7 +312,6 @@ main (int argc, const char **argv) gtk_window_set_default_size (GTK_WINDOW (w), MIN ((int)(ss.doc)->getWidth (), (int)gdk_screen_width () - 64), MIN ((int)(ss.doc)->getHeight (), (int)gdk_screen_height () - 64)); - gtk_window_set_policy (GTK_WINDOW (w), TRUE, TRUE, FALSE); ss.window = w; g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss); diff --git a/src/interface.cpp b/src/interface.cpp index 11882ddf9..209f32fd7 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -216,9 +216,7 @@ sp_create_window(SPViewWidget *vw, gboolean editable) } } - } else { - gtk_window_set_policy(GTK_WINDOW(win->gobj()), TRUE, TRUE, TRUE); - } + } if ( completeDropTargets == 0 || completeDropTargetsCount == 0 ) { -- cgit v1.2.3 From 4d8bf28dbebbc70325c75c0501ed192ae330c63b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 24 Jun 2011 11:23:41 +0100 Subject: Switch to GObject (bzr r10350.1.3) --- src/arc-context.cpp | 2 +- src/arc-context.h | 2 +- src/box3d-context.cpp | 2 +- src/box3d-context.h | 2 +- src/desktop.cpp | 4 +-- src/desktop.h | 4 +-- src/display/canvas-arena.cpp | 22 ++++++++------- src/display/canvas-arena.h | 2 +- src/display/canvas-bpath.cpp | 22 ++++++++------- src/display/canvas-bpath.h | 2 +- src/display/canvas-grid.cpp | 24 ++++++++-------- src/display/canvas-grid.h | 2 +- src/display/canvas-text.cpp | 22 ++++++++------- src/display/canvas-text.h | 2 +- src/display/gnome-canvas-acetate.cpp | 20 +++++++------ src/display/gnome-canvas-acetate.h | 2 +- src/display/sodipodi-ctrl.cpp | 4 +-- src/display/sodipodi-ctrl.h | 2 +- src/display/sodipodi-ctrlrect.h | 2 +- src/display/sp-canvas-item.h | 2 +- src/display/sp-canvas.cpp | 2 +- src/flood-context.cpp | 2 +- src/flood-context.h | 2 +- src/gradient-context.cpp | 2 +- src/gradient-context.h | 2 +- src/libgdl/gdl-dock-item-grip.c | 2 +- src/libgdl/gdl-dock-item.c | 4 +-- src/libgdl/gdl-dock.c | 4 +-- src/rect-context.cpp | 2 +- src/rect-context.h | 2 +- src/select-context.cpp | 2 +- src/select-context.h | 2 +- src/spiral-context.cpp | 2 +- src/spiral-context.h | 2 +- src/spray-context.cpp | 2 +- src/spray-context.h | 2 +- src/star-context.cpp | 2 +- src/star-context.h | 2 +- src/svg-view-widget.h | 2 +- src/text-context.h | 2 +- src/tweak-context.cpp | 2 +- src/tweak-context.h | 2 +- src/ui/view/view-widget.cpp | 25 ++++++++--------- src/widgets/desktop-widget.cpp | 2 +- src/widgets/desktop-widget.h | 2 +- src/widgets/font-selector.h | 2 +- src/widgets/gradient-image.cpp | 24 ++++++++-------- src/widgets/gradient-image.h | 2 +- src/widgets/paint-selector.cpp | 2 +- src/widgets/paint-selector.h | 2 +- src/widgets/ruler.cpp | 54 +++++++++++++++--------------------- src/widgets/ruler.h | 4 +-- src/widgets/sp-attribute-widget.cpp | 4 +-- src/widgets/sp-attribute-widget.h | 4 +-- src/widgets/sp-color-notebook.cpp | 2 +- src/widgets/sp-color-slider.cpp | 24 ++++++++-------- src/widgets/sp-color-slider.h | 2 +- src/widgets/sp-widget.cpp | 27 +++++++++--------- src/widgets/sp-widget.h | 2 +- src/widgets/sp-xmlview-attr-list.h | 2 +- src/widgets/sp-xmlview-content.cpp | 2 +- src/widgets/sp-xmlview-content.h | 2 +- src/widgets/sp-xmlview-tree.cpp | 24 ++++++++-------- src/widgets/sp-xmlview-tree.h | 2 +- 64 files changed, 202 insertions(+), 208 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 76b064f06..6e5b935f1 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -63,7 +63,7 @@ static void sp_arc_cancel(SPArcContext *ec); static SPEventContextClass *parent_class; -GtkType sp_arc_context_get_type() +GType sp_arc_context_get_type() { static GType type = 0; if (!type) { diff --git a/src/arc-context.h b/src/arc-context.h index ddce10801..46a6e1dce 100644 --- a/src/arc-context.h +++ b/src/arc-context.h @@ -45,7 +45,7 @@ struct SPArcContextClass { /* Standard Gtk function */ -GtkType sp_arc_context_get_type(void); +GType sp_arc_context_get_type(void); #endif /* !SEEN_ARC_CONTEXT_H */ diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 90f1707b9..8bba30eb9 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -66,7 +66,7 @@ static void sp_box3d_finish(Box3DContext *bc); static SPEventContextClass *parent_class; -GtkType sp_box3d_context_get_type() +GType sp_box3d_context_get_type() { static GType type = 0; if (!type) { diff --git a/src/box3d-context.h b/src/box3d-context.h index 74d244423..ccf0ef712 100644 --- a/src/box3d-context.h +++ b/src/box3d-context.h @@ -66,7 +66,7 @@ struct Box3DContextClass { /* Standard Gtk function */ -GtkType sp_box3d_context_get_type (void); +GType sp_box3d_context_get_type (void); void sp_box3d_context_update_lines(SPEventContext *ec); diff --git a/src/desktop.cpp b/src/desktop.cpp index f12f83ca6..d05c94790 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -648,7 +648,7 @@ SPDesktop::change_document (SPDocument *theDocument) * Make desktop switch event contexts. */ void -SPDesktop::set_event_context (GtkType type, const gchar *config) +SPDesktop::set_event_context (GType type, const gchar *config) { SPEventContext *ec; while (event_context) { @@ -679,7 +679,7 @@ SPDesktop::set_event_context (GtkType type, const gchar *config) * Push event context onto desktop's context stack. */ void -SPDesktop::push_event_context (GtkType type, const gchar *config, unsigned int key) +SPDesktop::push_event_context (GType type, const gchar *config, unsigned int key) { SPEventContext *ref, *ec; diff --git a/src/desktop.h b/src/desktop.h index 2581f2859..ed0a99dea 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -240,8 +240,8 @@ public: void activate_guides (bool activate); void change_document (SPDocument *document); - void set_event_context (GtkType type, const gchar *config); - void push_event_context (GtkType type, const gchar *config, unsigned int key); + void set_event_context (GType type, const gchar *config); + void push_event_context (GType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const; diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 72062ce99..5f3d961f7 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -48,20 +48,22 @@ NRArenaEventVector carenaev = { static SPCanvasItemClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; -GtkType +GType sp_canvas_arena_get_type (void) { - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar *)"SPCanvasArena", - sizeof (SPCanvasArena), + GTypeInfo info = { sizeof (SPCanvasArenaClass), - (GtkClassInitFunc) sp_canvas_arena_class_init, - (GtkObjectInitFunc) sp_canvas_arena_init, - NULL, NULL, NULL - }; - type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info); + NULL, NULL, + (GClassInitFunc) sp_canvas_arena_class_init, + NULL, NULL, + sizeof (SPCanvasArena), + 0, + (GInstanceInitFunc) sp_canvas_arena_init, + NULL + }; + type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCanvasArena", &info, (GTypeFlags)0); } return type; } diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index ef065a03b..4cfeccb5a 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -53,7 +53,7 @@ struct _SPCanvasArenaClass { gint (* arena_event) (SPCanvasArena *carena, NRArenaItem *item, GdkEvent *event); }; -GtkType sp_canvas_arena_get_type (void); +GType sp_canvas_arena_get_type (void); void sp_canvas_arena_set_pick_delta (SPCanvasArena *ca, gdouble delta); void sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky); diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index f86743744..815892878 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -38,20 +38,22 @@ static double sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvas static SPCanvasItemClass *parent_class; -GtkType +GType sp_canvas_bpath_get_type (void) { - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar *)"SPCanvasBPath", - sizeof (SPCanvasBPath), + GTypeInfo info = { sizeof (SPCanvasBPathClass), - (GtkClassInitFunc) sp_canvas_bpath_class_init, - (GtkObjectInitFunc) sp_canvas_bpath_init, - NULL, NULL, NULL - }; - type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info); + NULL, NULL, + (GClassInitFunc) sp_canvas_bpath_class_init, + NULL, NULL, + sizeof (SPCanvasBPath), + 0, + (GInstanceInitFunc) sp_canvas_bpath_init, + NULL + }; + type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCanvasBPath", &info, (GTypeFlags)0); } return type; } diff --git a/src/display/canvas-bpath.h b/src/display/canvas-bpath.h index ad19797c2..752ed73ea 100644 --- a/src/display/canvas-bpath.h +++ b/src/display/canvas-bpath.h @@ -90,7 +90,7 @@ struct SPCanvasBPathClass { SPCanvasItemClass parent_class; }; -GtkType sp_canvas_bpath_get_type (void); +GType sp_canvas_bpath_get_type (void); SPCanvasItem *sp_canvas_bpath_new (SPCanvasGroup *parent, SPCurve *curve); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 82ea036f6..9a12a1d90 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -58,22 +58,24 @@ static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass * parent_class; -GtkType +GType grid_canvasitem_get_type (void) { - static GtkType grid_canvasitem_type = 0; + static GType grid_canvasitem_type = 0; if (!grid_canvasitem_type) { - GtkTypeInfo grid_canvasitem_info = { - (gchar *)"GridCanvasItem", - sizeof (GridCanvasItem), + GTypeInfo grid_canvasitem_info = { sizeof (GridCanvasItemClass), - (GtkClassInitFunc) grid_canvasitem_class_init, - (GtkObjectInitFunc) grid_canvasitem_init, - NULL, NULL, - (GtkClassInitFunc) NULL - }; - grid_canvasitem_type = gtk_type_unique (sp_canvas_item_get_type (), &grid_canvasitem_info); + NULL, NULL, + (GClassInitFunc) grid_canvasitem_class_init, + NULL, NULL, + sizeof (GridCanvasItem), + 0, + (GInstanceInitFunc) grid_canvasitem_init, + NULL + }; + + grid_canvasitem_type = g_type_register_static (sp_canvas_item_get_type (), "GridCanvasItem", &grid_canvasitem_info, (GTypeFlags)0); } return grid_canvasitem_type; } diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index f42fecad7..160e4a4e2 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -57,7 +57,7 @@ struct GridCanvasItemClass { }; /* Standard Gtk function */ -GtkType grid_canvasitem_get_type (void); +GType grid_canvasitem_get_type (void); diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 842425f50..690015ecd 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -36,21 +36,23 @@ static void sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass *parent_class_ct; -GtkType +GType sp_canvastext_get_type (void) { - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar *)"SPCanvasText", - sizeof (SPCanvasText), + GTypeInfo info = { sizeof (SPCanvasTextClass), - (GtkClassInitFunc) sp_canvastext_class_init, - (GtkObjectInitFunc) sp_canvastext_init, - NULL, NULL, NULL - }; - type = gtk_type_unique (SP_TYPE_CANVAS_ITEM, &info); + NULL, NULL, + (GClassInitFunc) sp_canvastext_class_init, + NULL, NULL, + sizeof (SPCanvasText), + 0, + (GInstanceInitFunc) sp_canvastext_init, + NULL + }; + type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCanvasText", &info, (GTypeFlags)0); } return type; } diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index 30ddc1557..85333d84e 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -52,7 +52,7 @@ struct SPCanvasText : public SPCanvasItem { }; struct SPCanvasTextClass : public SPCanvasItemClass{}; -GtkType sp_canvastext_get_type (void); +GType sp_canvastext_get_type (void); SPCanvasItem *sp_canvastext_new(SPCanvasGroup *parent, SPDesktop *desktop, Geom::Point pos, gchar const *text); diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index b86892e32..67cc66950 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -25,20 +25,22 @@ static double sp_canvas_acetate_point (SPCanvasItem *item, Geom::Point p, SPCanv static SPCanvasItemClass *parent_class; -GtkType +GType sp_canvas_acetate_get_type (void) { - static GtkType acetate_type = 0; + static GType acetate_type = 0; if (!acetate_type) { - GtkTypeInfo acetate_info = { - (gchar *)"SPCanvasAcetate", - sizeof (SPCanvasAcetate), + GTypeInfo acetate_info = { sizeof (SPCanvasAcetateClass), - (GtkClassInitFunc) sp_canvas_acetate_class_init, - (GtkObjectInitFunc) sp_canvas_acetate_init, - NULL, NULL, NULL + NULL, NULL, + (GClassInitFunc) sp_canvas_acetate_class_init, + NULL, NULL, + sizeof (SPCanvasAcetate), + 0, + (GInstanceInitFunc) sp_canvas_acetate_init, + NULL }; - acetate_type = gtk_type_unique (sp_canvas_item_get_type (), &acetate_info); + acetate_type = g_type_register_static (sp_canvas_item_get_type (), "SPCanvasAcetate", &acetate_info, (GTypeFlags)0); } return acetate_type; } diff --git a/src/display/gnome-canvas-acetate.h b/src/display/gnome-canvas-acetate.h index 756c663ca..ed6c99811 100644 --- a/src/display/gnome-canvas-acetate.h +++ b/src/display/gnome-canvas-acetate.h @@ -34,7 +34,7 @@ struct SPCanvasAcetateClass { SPCanvasItemClass parent_class; }; -GtkType sp_canvas_acetate_get_type (void); +GType sp_canvas_acetate_get_type (void); diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 5e939ffee..fe2a78a8f 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -40,10 +40,10 @@ static double sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **a static SPCanvasItemClass *parent_class; -GtkType +GType sp_ctrl_get_type (void) { - static GtkType ctrl_type = 0; + static GType ctrl_type = 0; if (!ctrl_type) { static GTypeInfo const ctrl_info = { sizeof (SPCtrlClass), diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 3bf0889c7..4f114eac6 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -62,7 +62,7 @@ struct SPCtrlClass : public SPCanvasItemClass{ /* Standard Gtk function */ -GtkType sp_ctrl_get_type (void); +GType sp_ctrl_get_type (void); #endif /* !INKSCAPE_CTRL_H */ diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 945deabc4..e69b6ba68 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -57,7 +57,7 @@ private: struct SPCtrlRectClass : public SPCanvasItemClass {}; -GtkType sp_ctrlrect_get_type(); +GType sp_ctrlrect_get_type(); #endif // SEEN_RUBBERBAND_H diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index f62dc34a7..51e9a740e 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -67,7 +67,7 @@ struct _SPCanvasItemClass : public GtkObjectClass { int (* event) (SPCanvasItem *item, GdkEvent *event); }; -SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GtkType type, const gchar *first_arg_name, ...); +SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, const gchar *first_arg_name, ...); G_END_DECLS diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 472c9ada5..0d56b0175 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -169,7 +169,7 @@ sp_canvas_item_init (SPCanvasItem *item) * Constructs new SPCanvasItem on SPCanvasGroup. */ SPCanvasItem * -sp_canvas_item_new (SPCanvasGroup *parent, GtkType type, gchar const *first_arg_name, ...) +sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_name, ...) { va_list args; diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 73e82607a..90278ac95 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -84,7 +84,7 @@ static void sp_flood_finish(SPFloodContext *rc); static SPEventContextClass *parent_class; -GtkType sp_flood_context_get_type() +GType sp_flood_context_get_type() { static GType type = 0; if (!type) { diff --git a/src/flood-context.h b/src/flood-context.h index 6847c19be..0cab0f7c5 100644 --- a/src/flood-context.h +++ b/src/flood-context.h @@ -46,7 +46,7 @@ struct SPFloodContextClass { /* Standard Gtk function */ -GtkType sp_flood_context_get_type (void); +GType sp_flood_context_get_type (void); GList* flood_channels_dropdown_items_list (void); GList* flood_autogap_dropdown_items_list (void); diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 922a9b16e..a237bb3c6 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -63,7 +63,7 @@ static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint static SPEventContextClass *parent_class; -GtkType sp_gradient_context_get_type() +GType sp_gradient_context_get_type() { static GType type = 0; if (!type) { diff --git a/src/gradient-context.h b/src/gradient-context.h index 1ed14cf3f..bdd7208b6 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -49,7 +49,7 @@ struct SPGradientContextClass { }; /* Standard Gtk function */ -GtkType sp_gradient_context_get_type(); +GType sp_gradient_context_get_type(); void sp_gradient_context_select_next (SPEventContext *event_context); void sp_gradient_context_select_prev (SPEventContext *event_context); diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index c51b782b3..089eeb685 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -653,7 +653,7 @@ gdl_dock_item_grip_forall (GtkContainer *container, } } -static GtkType +static GType gdl_dock_item_grip_child_type (GtkContainer *container) { return G_TYPE_NONE; diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index b0d97a06d..3d746fa7c 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -79,7 +79,7 @@ static void gdl_dock_item_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); -static GtkType gdl_dock_item_child_type (GtkContainer *container); +static GType gdl_dock_item_child_type (GtkContainer *container); static void gdl_dock_item_set_focus_child (GtkContainer *container, GtkWidget *widget, @@ -684,7 +684,7 @@ gdl_dock_item_forall (GtkContainer *container, (* callback) (item->child, callback_data); } -static GtkType +static GType gdl_dock_item_child_type (GtkContainer *container) { g_return_val_if_fail (GDL_IS_DOCK_ITEM (container), G_TYPE_NONE); diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index c366ed69b..5f0d7c66d 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -79,7 +79,7 @@ static void gdl_dock_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); -static GtkType gdl_dock_child_type (GtkContainer *container); +static GType gdl_dock_child_type (GtkContainer *container); static void gdl_dock_detach (GdlDockObject *object, gboolean recursive); @@ -750,7 +750,7 @@ gdl_dock_forall (GtkContainer *container, (*callback) (GTK_WIDGET (dock->root), callback_data); } -static GtkType +static GType gdl_dock_child_type (GtkContainer *container) { return GDL_TYPE_DOCK_ITEM; diff --git a/src/rect-context.cpp b/src/rect-context.cpp index bcb1bf734..7f32e09fa 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -65,7 +65,7 @@ static void sp_rect_cancel(SPRectContext *rc); static SPEventContextClass *parent_class; -GtkType sp_rect_context_get_type() +GType sp_rect_context_get_type() { static GType type = 0; if (!type) { diff --git a/src/rect-context.h b/src/rect-context.h index db7cd605b..e5d160788 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -46,6 +46,6 @@ struct SPRectContextClass { /* Standard Gtk function */ -GtkType sp_rect_context_get_type (void); +GType sp_rect_context_get_type (void); #endif diff --git a/src/select-context.cpp b/src/select-context.cpp index 640aae9ee..143fb1ae2 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -69,7 +69,7 @@ static gint xp = 0, yp = 0; // where drag started static gint tolerance = 0; static bool within_tolerance = false; -GtkType +GType sp_select_context_get_type(void) { static GType type = 0; diff --git a/src/select-context.h b/src/select-context.h index 934892d40..d579f7ebc 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -55,6 +55,6 @@ struct SPSelectContextClass { /* Standard Gtk function */ -GtkType sp_select_context_get_type (void); +GType sp_select_context_get_type (void); #endif diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 754885192..cbe7166c5 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -59,7 +59,7 @@ static void sp_spiral_cancel(SPSpiralContext *sc); static SPEventContextClass *parent_class; -GtkType +GType sp_spiral_context_get_type() { static GType type = 0; diff --git a/src/spiral-context.h b/src/spiral-context.h index 6d689c49c..dd447dbfe 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -48,6 +48,6 @@ struct SPSpiralContextClass { /* Standard Gtk function */ -GtkType sp_spiral_context_get_type (void); +GType sp_spiral_context_get_type (void); #endif diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 36c135924..be0cb627f 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -98,7 +98,7 @@ inline double NormalDistribution(double mu, double sigma) return mu + sigma * sqrt( -2.0 * log(g_random_double_range(0, 1)) ) * cos( 2.0*M_PI*g_random_double_range(0, 1) ); } -GtkType sp_spray_context_get_type(void) +GType sp_spray_context_get_type(void) { static GType type = 0; if (!type) { diff --git a/src/spray-context.h b/src/spray-context.h index f6d9a9c0b..247c07130 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -99,7 +99,7 @@ struct SPSprayContextClass SPEventContextClass parent_class; }; -GtkType sp_spray_context_get_type(void); +GType sp_spray_context_get_type(void); #endif diff --git a/src/star-context.cpp b/src/star-context.cpp index 9f4afb94c..17a8e915f 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -64,7 +64,7 @@ static void sp_star_cancel(SPStarContext * sc); static SPEventContextClass * parent_class; -GtkType +GType sp_star_context_get_type (void) { static GType type = 0; diff --git a/src/star-context.h b/src/star-context.h index b66e2dd15..d9ab8ce8f 100644 --- a/src/star-context.h +++ b/src/star-context.h @@ -52,6 +52,6 @@ struct SPStarContextClass { SPEventContextClass parent_class; }; -GtkType sp_star_context_get_type (void); +GType sp_star_context_get_type (void); #endif diff --git a/src/svg-view-widget.h b/src/svg-view-widget.h index 1a8697fdf..46def687b 100644 --- a/src/svg-view-widget.h +++ b/src/svg-view-widget.h @@ -27,7 +27,7 @@ class SPSVGSPViewWidgetClass; #define SP_IS_SVG_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SVG_VIEW_WIDGET)) #define SP_IS_SVG_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SVG_VIEW_WIDGET)) -GtkType sp_svg_view_widget_get_type (void); +GType sp_svg_view_widget_get_type (void); GtkWidget *sp_svg_view_widget_new (SPDocument *doc); diff --git a/src/text-context.h b/src/text-context.h index 0d7a93ef0..a140c2f08 100644 --- a/src/text-context.h +++ b/src/text-context.h @@ -80,7 +80,7 @@ struct SPTextContextClass { }; /* Standard Gtk function */ -GtkType sp_text_context_get_type (void); +GType sp_text_context_get_type (void); bool sp_text_paste_inline(SPEventContext *ec); Glib::ustring sp_text_get_selected_text(SPEventContext const *ec); diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index faa08ee91..b4f13d16f 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -90,7 +90,7 @@ static gint sp_tweak_context_root_handler(SPEventContext *ec, GdkEvent *event); static SPEventContextClass *parent_class; -GtkType +GType sp_tweak_context_get_type(void) { static GType type = 0; diff --git a/src/tweak-context.h b/src/tweak-context.h index 5fbd078ef..f7f1fcf7d 100644 --- a/src/tweak-context.h +++ b/src/tweak-context.h @@ -86,7 +86,7 @@ struct SPTweakContextClass SPEventContextClass parent_class; }; -GtkType sp_tweak_context_get_type(void); +GType sp_tweak_context_get_type(void); #endif diff --git a/src/ui/view/view-widget.cpp b/src/ui/view/view-widget.cpp index cf0f55f2c..f87bc8edd 100644 --- a/src/ui/view/view-widget.cpp +++ b/src/ui/view/view-widget.cpp @@ -27,22 +27,21 @@ static GtkEventBoxClass *widget_parent_class; /** * Registers the SPViewWidget class with Glib and returns its type number. */ -GtkType sp_view_widget_get_type(void) +GType sp_view_widget_get_type(void) { - static GtkType type = 0; - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar*) "SPViewWidget", - sizeof(SPViewWidget), + GTypeInfo info = { sizeof(SPViewWidgetClass), - (GtkClassInitFunc) sp_view_widget_class_init, - (GtkObjectInitFunc) sp_view_widget_init, - NULL, NULL, NULL - }; - type = gtk_type_unique(GTK_TYPE_EVENT_BOX, &info); + NULL, NULL, + (GClassInitFunc) sp_view_widget_class_init, + NULL, NULL, + sizeof(SPViewWidget), + 0, + (GInstanceInitFunc) sp_view_widget_init, + NULL + }; + type = g_type_register_static (GTK_TYPE_EVENT_BOX, "SPViewWidget", &info, (GTypeFlags)0); } return type; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 0d890fa86..3c2d60638 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -254,7 +254,7 @@ static GTimer *overallTimer = 0; */ GType SPDesktopWidget::getType(void) { - static GtkType type = 0; + static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPDesktopWidgetClass), diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 6c5af0aac..fdf651287 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -238,7 +238,7 @@ struct SPDesktopWidget { Inkscape::UI::Widget::Dock* getDock(); - static GtkType getType(); + static GType getType(); static SPDesktopWidget* createInstance(SPNamedView *namedview); void updateNamedview(); diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index febd4a34a..3fc425f65 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -27,7 +27,7 @@ struct SPFontSelector; /* SPFontSelector */ -GtkType sp_font_selector_get_type (void); +GType sp_font_selector_get_type (void); GtkWidget *sp_font_selector_new (void); diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 115935f50..eb4ab789d 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -36,24 +36,22 @@ static void sp_gradient_image_update (SPGradientImage *img); static GtkWidgetClass *parent_class; -GtkType +GType sp_gradient_image_get_type (void) { - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz - - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar*) "SPGradientImage", - sizeof (SPGradientImage), + GTypeInfo info = { sizeof (SPGradientImageClass), - (GtkClassInitFunc) sp_gradient_image_class_init, - (GtkObjectInitFunc) sp_gradient_image_init, - NULL, NULL, NULL + NULL, NULL, + (GClassInitFunc) sp_gradient_image_class_init, + NULL, NULL, + sizeof (SPGradientImage), + 0, + (GInstanceInitFunc) sp_gradient_image_init, + NULL }; - type = gtk_type_unique (GTK_TYPE_WIDGET, &info); + type = g_type_register_static (GTK_TYPE_WIDGET, "SPGradientImage", &info, (GTypeFlags)0); } return type; } diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h index ae5d40f56..0fbed879f 100644 --- a/src/widgets/gradient-image.h +++ b/src/widgets/gradient-image.h @@ -40,7 +40,7 @@ struct SPGradientImageClass { GtkWidgetClass parent_class; }; -GtkType sp_gradient_image_get_type (void); +GType sp_gradient_image_get_type (void); GtkWidget *sp_gradient_image_new (SPGradient *gradient); void sp_gradient_image_set_gradient (SPGradientImage *gi, SPGradient *gr); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index f9ec4208f..6b3e0c4b5 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -134,7 +134,7 @@ static SPGradientSelector *getGradientFromData(SPPaintSelector const *psel) GType sp_paint_selector_get_type(void) { - static GtkType type = 0; + static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPPaintSelectorClass), diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index c0e44683b..ebcac380f 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -114,7 +114,7 @@ struct SPPaintSelectorClass { void (* fillrule_changed) (SPPaintSelector *psel, SPPaintSelector::FillRule fillrule); }; -GtkType sp_paint_selector_get_type (void); +GType sp_paint_selector_get_type (void); SPPaintSelector *sp_paint_selector_new(FillOrStroke kind); diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index 704d395f7..f3f4164a5 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -37,30 +37,25 @@ static gint sp_hruler_motion_notify (GtkWidget *widget, GdkEventMotion *eve static GtkWidgetClass *hruler_parent_class; -GtkType +GType sp_hruler_get_type (void) { - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz - - static GtkType hruler_type = 0; + static GType hruler_type = 0; if (!hruler_type) { - static const GtkTypeInfo hruler_info = - { - (gchar*) "SPHRuler", - sizeof (SPHRuler), + static const GTypeInfo hruler_info = { sizeof (SPHRulerClass), - (GtkClassInitFunc) sp_hruler_class_init, - (GtkObjectInitFunc) sp_hruler_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, + NULL, NULL, + (GClassInitFunc) sp_hruler_class_init, + NULL, NULL, + sizeof (SPHRuler), + 0, + (GInstanceInitFunc) sp_hruler_init, + NULL }; - hruler_type = gtk_type_unique (gtk_ruler_get_type (), &hruler_info); + hruler_type = g_type_register_static (gtk_ruler_get_type (), "SPHRuler", &hruler_info, (GTypeFlags)0); } return hruler_type; @@ -128,30 +123,25 @@ static void sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisiti static GtkWidgetClass *vruler_parent_class; -GtkType +GType sp_vruler_get_type (void) { - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz - - static GtkType vruler_type = 0; + static GType vruler_type = 0; if (!vruler_type) { - static const GtkTypeInfo vruler_info = - { - (gchar*) "SPVRuler", - sizeof (SPVRuler), + static const GTypeInfo vruler_info = { sizeof (SPVRulerClass), - (GtkClassInitFunc) sp_vruler_class_init, - (GtkObjectInitFunc) sp_vruler_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, + NULL, NULL, + (GClassInitFunc) sp_vruler_class_init, + NULL, NULL, + sizeof (SPVRuler), + 0, + (GInstanceInitFunc) sp_vruler_init, + NULL }; - vruler_type = gtk_type_unique (gtk_ruler_get_type (), &vruler_info); + vruler_type = g_type_register_static (gtk_ruler_get_type (), "SPVRuler", &vruler_info, (GTypeFlags)0); } return vruler_type; diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h index 3c55b39c4..a774f12ef 100644 --- a/src/widgets/ruler.h +++ b/src/widgets/ruler.h @@ -38,7 +38,7 @@ struct SPHRulerClass }; -GtkType sp_hruler_get_type (void); +GType sp_hruler_get_type (void); GtkWidget* sp_hruler_new (void); @@ -63,7 +63,7 @@ struct SPVRulerClass }; -GtkType sp_vruler_get_type (void); +GType sp_vruler_get_type (void); GtkWidget* sp_vruler_new (void); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 66ccb27f2..61863f31b 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -42,7 +42,7 @@ static GtkEntryClass *parent_class; GType sp_attribute_widget_get_type(void) { - static GtkType type = 0; + static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPAttributeWidgetClass), @@ -361,7 +361,7 @@ static GtkVBoxClass *table_parent_class; GType sp_attribute_table_get_type(void) { - static GtkType type = 0; + static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPAttributeTableClass), diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 5d23e6754..d5445c8bb 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -64,7 +64,7 @@ struct SPAttributeWidgetClass { GtkEntryClass entry_class; }; -GtkType sp_attribute_widget_get_type (void); +GType sp_attribute_widget_get_type (void); GtkWidget *sp_attribute_widget_new (SPObject *object, const gchar *attribute); GtkWidget *sp_attribute_widget_new_repr (Inkscape::XML::Node *repr, const gchar *attribute); @@ -99,7 +99,7 @@ struct SPAttributeTableClass { GtkEntryClass entry_class; }; -GtkType sp_attribute_table_get_type (void); +GType sp_attribute_table_get_type (void); GtkWidget *sp_attribute_table_new ( SPObject *object, gint num_attr, const gchar **labels, diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 06e990dfb..e3e28979d 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -62,7 +62,7 @@ static SPColorSelectorClass *parent_class; GType sp_color_notebook_get_type(void) { - static GtkType type = 0; + static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPColorNotebookClass), diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 7b365bc73..152f81324 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -54,24 +54,22 @@ static const guchar *sp_color_slider_render_map (gint x0, gint y0, gint width, g static GtkWidgetClass *parent_class; static guint slider_signals[LAST_SIGNAL] = {0}; -GtkType +GType sp_color_slider_get_type (void) { - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz - - static GtkType type = 0; + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar*) "SPColorSlider", - sizeof (SPColorSlider), + GTypeInfo info = { sizeof (SPColorSliderClass), - (GtkClassInitFunc) sp_color_slider_class_init, - (GtkObjectInitFunc) sp_color_slider_init, - NULL, NULL, NULL + NULL, NULL, + (GClassInitFunc) sp_color_slider_class_init, + NULL, NULL, + sizeof (SPColorSlider), + 0, + (GInstanceInitFunc) sp_color_slider_init, + NULL }; - type = gtk_type_unique (GTK_TYPE_WIDGET, &info); + type = g_type_register_static (GTK_TYPE_WIDGET, "SPColorSlider", &info, (GTypeFlags)0); } return type; } diff --git a/src/widgets/sp-color-slider.h b/src/widgets/sp-color-slider.h index b8cfaf869..591d8368a 100644 --- a/src/widgets/sp-color-slider.h +++ b/src/widgets/sp-color-slider.h @@ -53,7 +53,7 @@ struct SPColorSliderClass { void (* changed) (SPColorSlider *slider); }; -GtkType sp_color_slider_get_type (void); +GType sp_color_slider_get_type (void); GtkWidget *sp_color_slider_new (GtkAdjustment *adjustment); diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index d5877db99..141f4afc1 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -43,24 +43,25 @@ static void sp_widget_set_selection (Inkscape::Application *inkscape, Inkscape:: static GtkBinClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; -GtkType +GType sp_widget_get_type (void) { - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz - - static GtkType type = 0; + static GType type = 0; if (!type) { - static const GtkTypeInfo info = { - (gchar*) "SPWidget", - sizeof (SPWidget), + static const GTypeInfo info = { sizeof (SPWidgetClass), - (GtkClassInitFunc) sp_widget_class_init, - (GtkObjectInitFunc) sp_widget_init, - NULL, NULL, NULL + NULL, NULL, + (GClassInitFunc) sp_widget_class_init, + NULL, NULL, + sizeof (SPWidget), + 0, + (GInstanceInitFunc) sp_widget_init, + NULL }; - type = gtk_type_unique (GTK_TYPE_BIN, &info); + type = g_type_register_static (GTK_TYPE_BIN, + "SPWidget", + &info, + (GTypeFlags)0); } return type; } diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index decd9c056..66320cd4d 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -42,7 +42,7 @@ struct SPWidgetClass { void (* set_selection) (SPWidget *spw, Inkscape::Selection *selection); }; -GtkType sp_widget_get_type (void); +GType sp_widget_get_type (void); /* fixme: Think (Lauris) */ /* Generic constructor for global widget */ diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h index de79c7a37..9479dd77a 100644 --- a/src/widgets/sp-xmlview-attr-list.h +++ b/src/widgets/sp-xmlview-attr-list.h @@ -38,7 +38,7 @@ struct SPXMLViewAttrListClass void (* row_changed) (SPXMLViewAttrList *list, gint row); }; -GtkType sp_xmlview_attr_list_get_type (void); +GType sp_xmlview_attr_list_get_type (void); GtkWidget * sp_xmlview_attr_list_new (Inkscape::XML::Node * repr); #define SP_XMLVIEW_ATTR_LIST_GET_REPR(list) (SP_XMLVIEW_ATTR_LIST (list)->repr) diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index 75d68d25c..804bc1737 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -80,7 +80,7 @@ sp_xmlview_content_set_repr (SPXMLViewContent * text, Inkscape::XML::Node * repr GType sp_xmlview_content_get_type(void) { - static GtkType type = 0; + static GType type = 0; if (!type) { GTypeInfo info = { diff --git a/src/widgets/sp-xmlview-content.h b/src/widgets/sp-xmlview-content.h index fe26891d0..941ef0be1 100644 --- a/src/widgets/sp-xmlview-content.h +++ b/src/widgets/sp-xmlview-content.h @@ -41,7 +41,7 @@ struct SPXMLViewContentClass GtkTextViewClass parent_class; }; -GtkType sp_xmlview_content_get_type (void); +GType sp_xmlview_content_get_type (void); GtkWidget * sp_xmlview_content_new (Inkscape::XML::Node * repr); #define SP_XMLVIEW_CONTENT_GET_REPR(text) (SP_XMLVIEW_CONTENT (text)->repr) diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index b757123b5..e1779b620 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -125,25 +125,23 @@ sp_xmlview_tree_set_repr (SPXMLViewTree * tree, Inkscape::XML::Node * repr) gtk_clist_thaw (GTK_CLIST (tree)); } -GtkType +GType sp_xmlview_tree_get_type (void) { - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz - - static GtkType type = 0; + static GType type = 0; if (!type) { - static const GtkTypeInfo info = { - (gchar*) "SPXMLViewTree", - sizeof (SPXMLViewTree), + static const GTypeInfo info = { sizeof (SPXMLViewTreeClass), - (GtkClassInitFunc) sp_xmlview_tree_class_init, - (GtkObjectInitFunc) sp_xmlview_tree_init, - NULL, NULL, NULL + NULL, NULL, + (GClassInitFunc) sp_xmlview_tree_class_init, + NULL, NULL, + sizeof (SPXMLViewTree), + 0, + (GInstanceInitFunc) sp_xmlview_tree_init, + NULL }; - type = gtk_type_unique (GTK_TYPE_CTREE, &info); + type = g_type_register_static (GTK_TYPE_CTREE, "SPXMLViewTree", &info, (GTypeFlags)0); } return type; diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index 2b04e79eb..5d228f982 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -40,7 +40,7 @@ struct SPXMLViewTreeClass GtkCTreeClass parent_class; }; -GtkType sp_xmlview_tree_get_type (void); +GType sp_xmlview_tree_get_type (void); GtkWidget * sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * factory, void * data); #define SP_XMLVIEW_TREE_REPR(tree) (SP_XMLVIEW_TREE (tree)->repr) -- cgit v1.2.3 From 12f967180a02081dd72d340a630919c00b76078e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 24 Jun 2011 17:16:43 +0200 Subject: Document. Fix for bug #680347 (page margins can't be reset with single click of Resize). (bzr r10355) --- src/ui/widget/page-sizer.cpp | 32 +++++++++++++++++++------------- src/ui/widget/page-sizer.h | 1 + 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 672e1415b..5d71a4b38 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -235,7 +235,7 @@ PageSizer::PageSizer(Registry & _wr) _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr), _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr), _marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr), - + _lockMarginUpdate(false), _widgetRegistry(&_wr) { //# Set up the Paper Size combo box @@ -464,18 +464,20 @@ PageSizer::setDim (double w, double h, bool changeList) void PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) { - double value = 0.0; - if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) { - _marginTop.setValue(value); - } - if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) { - _marginLeft.setValue(value); - } - if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) { - _marginRight.setValue(value); - } - if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) { - _marginBottom.setValue(value); + if (!_lockMarginUpdate) { + double value = 0.0; + if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) { + _marginTop.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) { + _marginLeft.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) { + _marginRight.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) { + _marginBottom.setValue(value); + } } } @@ -537,14 +539,18 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() SPDocument *doc; SPNamedView *nv; Inkscape::XML::Node *nv_repr; + if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP)) && (nv = sp_document_namedview(doc, 0)) && (nv_repr = nv->getRepr())) { + _lockMarginUpdate = true; sp_repr_set_svg_double(nv_repr, "fit-margin-top", _marginTop.getValue()); sp_repr_set_svg_double(nv_repr, "fit-margin-left", _marginLeft.getValue()); sp_repr_set_svg_double(nv_repr, "fit-margin-right", _marginRight.getValue()); sp_repr_set_svg_double(nv_repr, "fit-margin-bottom", _marginBottom.getValue()); + _lockMarginUpdate = false; } + Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING ); if (verb) { SPAction *action = verb->get_action(dt); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 2072aeccd..cb7f8a069 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -219,6 +219,7 @@ protected: RegisteredScalar _marginBottom; Gtk::Alignment _fitPageButtonAlign; Gtk::Button _fitPageButton; + bool _lockMarginUpdate; //callback void on_value_changed(); -- cgit v1.2.3 From 8ec8f62daf1a195ea1b1c8e837cee1e5d8be8d02 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 24 Jun 2011 16:12:35 -0700 Subject: Removed outdated callback function. (bzr r10356) --- src/widgets/toolbox.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 01308104e..fb91bfb53 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -4633,12 +4633,6 @@ static void sp_spray_standard_deviation_value_changed( GtkAdjustment *adj, GObje prefs->setDouble( "/tools/spray/standard_deviation", adj->value ); } -static void sp_spray_pressure_state_changed( GtkToggleAction *act, gpointer /*data*/ ) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool("/tools/spray/usepressure", gtk_toggle_action_get_active(act)); -} - static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject * /*tbl*/ ) { int mode = ege_select_one_action_get_active( act ); -- cgit v1.2.3 From 71f63ec3d5ccb82e8617da524d741221e35847ca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Jun 2011 14:48:35 +0000 Subject: added a Modules cmake dir, only use for find_package, reference cmake include paths explicitly. (bzr r10358) --- src/helper/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index 8137487e2..1d6a82e41 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -1,5 +1,5 @@ -include(UseGlibMarshal) +include(${CMAKE_SOURCE_DIR}/CMakeScripts/UseGlibMarshal.cmake) GLIB_MARSHAL(sp_marshal sp-marshal "${CMAKE_CURRENT_BINARY_DIR}/helper") @@ -46,5 +46,7 @@ set(helper_SRC window.h ) +set_source_files_properties(sp_marshal_SRC PROPERTIES GENERATED true) + # add_inkscape_lib(helper_LIB "${helper_SRC}") add_inkscape_source("${helper_SRC}") -- cgit v1.2.3 From dcf765f3dcbff2e65428e0f002bb5ea3648940f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 Jun 2011 15:35:01 +0000 Subject: warning cleanup (no functional changes) - enclose && / || with brackets to avoid ambiguity. - don't cast from booleans to pointers. (bzr r10359) --- src/connector-context.cpp | 22 +++++++++++----------- src/extension/effect.cpp | 2 +- src/gradient-drag.cpp | 2 +- src/libavoid/vpsc.cpp | 2 +- src/libcola/straightener.cpp | 6 +++--- src/libcroco/cr-parser.c | 2 +- src/libvpsc/block.cpp | 2 +- src/widgets/desktop-widget.h | 2 +- src/widgets/toolbox.cpp | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 251b41066..2aa9c41ee 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1306,12 +1306,12 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { - cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, false); - cc->clickeditem->setAttribute("inkscape:connection-start-point", cpid, false); + cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, NULL); + cc->clickeditem->setAttribute("inkscape:connection-start-point", cpid, NULL); } else { - cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, false); - cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, false); + cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, NULL); + cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, NULL); } g_free(shape_label); } @@ -1451,23 +1451,23 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) bool connection = false; cc->newconn->setAttribute( "inkscape:connector-type", - cc->isOrthogonal ? "orthogonal" : "polyline", false ); + cc->isOrthogonal ? "orthogonal" : "polyline", NULL ); cc->newconn->setAttribute( "inkscape:connector-curvature", - Glib::Ascii::dtostr(cc->curvature).c_str(), false ); + Glib::Ascii::dtostr(cc->curvature).c_str(), NULL ); if (cc->shref) { - cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, false); + cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, NULL); if (cc->scpid) { - cc->newconn->setAttribute( "inkscape:connection-start-point", cc->scpid, false); + cc->newconn->setAttribute( "inkscape:connection-start-point", cc->scpid, NULL); } connection = true; } if (cc->ehref) { - cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, false); + cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, NULL); if (cc->ecpid) { - cc->newconn->setAttribute( "inkscape:connection-end-point", cc->ecpid, false); + cc->newconn->setAttribute( "inkscape:connection-end-point", cc->ecpid, NULL); } connection = true; } @@ -1950,7 +1950,7 @@ void cc_selection_set_avoid(bool const set_avoid) char const *value = (set_avoid) ? "true" : NULL; if (cc_item_is_shape(item)) { - item->setAttribute("inkscape:connector-avoid", value, false); + item->setAttribute("inkscape:connector-avoid", value, NULL); item->avoidRef->handleSettingChange(); changes++; } diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 51aa42da6..e01eb760a 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -324,7 +324,7 @@ Effect::set_last_effect (Effect * in_effect) Inkscape::XML::Node * Effect::find_menu (Inkscape::XML::Node * menustruct, const gchar *name) { - if (menustruct == NULL) return false; + if (menustruct == NULL) return NULL; for (Inkscape::XML::Node * child = menustruct; child != NULL; child = child->next()) { diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 8f7effe43..142ae2a98 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1962,7 +1962,7 @@ GrDrag::deleteSelected (bool just_one) { if (!selected) return; - SPDocument *document = false; + SPDocument *document = NULL; struct StructStopInfo { SPStop * spstop; diff --git a/src/libavoid/vpsc.cpp b/src/libavoid/vpsc.cpp index 19d360375..1646ddaaa 100644 --- a/src/libavoid/vpsc.cpp +++ b/src/libavoid/vpsc.cpp @@ -422,7 +422,7 @@ Constraint* IncSolver::mostViolated(Constraints &l) { // downwards. There is always at least 1 element in the // vector because of search. // TODO check this logic and add parens: - if((deletePoint != end) && ((minSlack < ZERO_UPPERBOUND) && !v->active || v->equality)) { + if((deletePoint != end) && (((minSlack < ZERO_UPPERBOUND) && !v->active) || v->equality)) { *deletePoint = l[l.size()-1]; l.resize(l.size()-1); } diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index e237c03c3..7c73cb9e9 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -108,7 +108,7 @@ namespace straightener { int compare_events(const void *a, const void *b) { Event *ea=*(Event**)a; Event *eb=*(Event**)b; - if(ea->v!=NULL&&ea->v==eb->v||ea->e!=NULL&&ea->e==eb->e) { + if((ea->v!=NULL&&ea->v==eb->v)||(ea->e!=NULL&&ea->e==eb->e)) { // when comparing opening and closing from object // open must come first if(ea->type==Open) return -1; @@ -263,8 +263,8 @@ namespace straightener { // node is on an edge Edge *edge=(*i)->edge; if(!edge->isEnd(v->id) - &&(l!=NULL&&!edge->isEnd(l->id)||l==NULL) - &&(r!=NULL&&!edge->isEnd(r->id)||r==NULL)) { + &&((l!=NULL&&!edge->isEnd(l->id))||l==NULL) + &&((r!=NULL&&!edge->isEnd(r->id))||r==NULL)) { if(lastNode!=NULL) { //printf(" Rule A: Constraint: v%d +g <= v%d\n",lastNode->id,(*i)->id); cs.push_back(createConstraint(lastNode,*i,dim)); diff --git a/src/libcroco/cr-parser.c b/src/libcroco/cr-parser.c index 5b0a56f32..a8e2de5a3 100644 --- a/src/libcroco/cr-parser.c +++ b/src/libcroco/cr-parser.c @@ -2408,7 +2408,7 @@ cr_parser_parse_stylesheet (CRParser * a_this) import_string, NULL, &location) ; - if ((PRIVATE (a_this)->sac_handler->resolve_import == TRUE)) { + if (PRIVATE (a_this)->sac_handler->resolve_import == TRUE) { /* *TODO: resolve the *import rule. diff --git a/src/libvpsc/block.cpp b/src/libvpsc/block.cpp index 221df536a..0bd662f28 100644 --- a/src/libvpsc/block.cpp +++ b/src/libvpsc/block.cpp @@ -72,7 +72,7 @@ void Block::setUpConstraintHeap(PairingHeap* &h,bool in) { for (Cit j=cs->begin();j!=cs->end();++j) { Constraint *c=*j; c->timeStamp=blockTimeCtr; - if (c->left->block != this && in || c->right->block != this && !in) { + if ((c->left->block != this && in) || (c->right->block != this && !in)) { h->insert(c); } } diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index fdf651287..79994a299 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -246,7 +246,7 @@ struct SPDesktopWidget { private: GtkWidget *tool_toolbox; GtkWidget *aux_toolbox; - GtkWidget *commands_toolbox,; + GtkWidget *commands_toolbox; GtkWidget *snap_toolbox; static void init(SPDesktopWidget *widget); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index fb91bfb53..a5d81d9bf 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -8015,7 +8015,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl if (cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-type", - value, false); + value, NULL); item->avoidRef->handleSettingChange(); modmade = true; } @@ -8064,7 +8064,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) if (cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-curvature", - value, false); + value, NULL); item->avoidRef->handleSettingChange(); modmade = true; } -- cgit v1.2.3 From 97e3f0bddec251f7e8644fb14f35352a1ef5167b Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 25 Jun 2011 15:47:10 -0700 Subject: Removed questionable cast. (bzr r10360) --- src/ui/widget/registered-widget.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 560c63dd4..6d5cc920a 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -62,8 +62,7 @@ public: bool is_updating() {if (_wr) return _wr->isUpdating(); else return false;} - // provide automatic 'upcast' for ease of use. (do it 'dynamic_cast' instead of 'static' because who knows what W is) - operator const Gtk::Widget () { return dynamic_cast(this); } + operator const Gtk::Widget() { return *this; } protected: RegisteredWidget() : W() { construct(); } -- cgit v1.2.3 From 7c088bec1835a753cebd2282ec7f25bfc79f4311 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 25 Jun 2011 15:47:58 -0700 Subject: Removed questionable operator altogether. (bzr r10361) --- src/ui/widget/registered-widget.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 6d5cc920a..f05eb176a 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -62,8 +62,6 @@ public: bool is_updating() {if (_wr) return _wr->isUpdating(); else return false;} - operator const Gtk::Widget() { return *this; } - protected: RegisteredWidget() : W() { construct(); } template< typename A > -- cgit v1.2.3 From 2307efdeb1fac805166b4f0be1c6c72e0ddd7b40 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 26 Jun 2011 00:01:48 +0100 Subject: Gtk cleanup: GTK_WIDGET_IS_SENSITIVE (bzr r10350.1.4) --- src/ege-adjustment-action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 6b0ffd1ab..9f8356495 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -987,7 +987,7 @@ static gboolean process_tab( GtkWidget* widget, int direction ) GList* subChildren = gtk_container_get_children( GTK_CONTAINER(child) ); if ( subChildren ) { GList* last = g_list_last(subChildren); - if ( last && GTK_IS_SPIN_BUTTON(last->data) && GTK_WIDGET_IS_SENSITIVE( GTK_WIDGET(last->data) ) ) { + if ( last && GTK_IS_SPIN_BUTTON(last->data) && gtk_widget_is_sensitive( GTK_WIDGET(last->data) ) ) { gtk_widget_grab_focus( GTK_WIDGET(last->data) ); handled = TRUE; mid = 0; /* to stop loop */ -- cgit v1.2.3 From 59e1bb938278f59e0e2dbc2d179230b5f73467b6 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 26 Jun 2011 00:29:40 +0100 Subject: Gtk cleanup: gtk_object_set_data (bzr r10350.1.5) --- src/dialogs/export.cpp | 60 +++++++++++++++++++-------------------- src/dialogs/find.cpp | 18 ++++++------ src/dialogs/item-properties.cpp | 40 +++++++++++++------------- src/dialogs/spellcheck.cpp | 6 ++-- src/helper/unit-menu.cpp | 2 +- src/ui/context-menu.cpp | 32 ++++++++++----------- src/ui/widget/selected-style.cpp | 2 +- src/widgets/desktop-widget.cpp | 2 +- src/widgets/gradient-toolbar.cpp | 6 ++-- src/widgets/gradient-vector.cpp | 8 +++--- src/widgets/paint-selector.cpp | 20 ++++++------- src/widgets/sp-color-scales.cpp | 2 +- src/widgets/spinbutton-events.cpp | 16 +++++------ src/widgets/spw-utilities.cpp | 16 +++++------ src/widgets/toolbox.cpp | 6 ++-- 15 files changed, 118 insertions(+), 118 deletions(-) (limited to 'src') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index b076c0f96..f278a0573 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -217,8 +217,8 @@ sp_export_spinbutton_new ( gchar const *key, float val, float min, float max, GCallback cb, GtkWidget *dlg ) { GtkObject *adj = gtk_adjustment_new( val, min, max, step, page, 0 ); - gtk_object_set_data( adj, "key", const_cast(key) ); - gtk_object_set_data( GTK_OBJECT (dlg), (const gchar *)key, adj ); + g_object_set_data( G_OBJECT (adj), "key", const_cast(key) ); + g_object_set_data( G_OBJECT (dlg), (const gchar *)key, adj ); if (us) { sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us), @@ -289,7 +289,7 @@ sp_export_dialog_area_box (GtkWidget * dlg) unitbox->pack_end(*us, false, false, 0); Gtk::Label* l = new Gtk::Label(_("Units:")); unitbox->pack_end(*l, false, false, 3); - gtk_object_set_data (GTK_OBJECT (dlg), "units", us->gobj()); + g_object_set_data (G_OBJECT (dlg), "units", us->gobj()); Gtk::HBox* togglebox = new Gtk::HBox(true, 0); @@ -297,7 +297,7 @@ sp_export_dialog_area_box (GtkWidget * dlg) for (int i = 0; i < SELECTION_NUMBER_OF; i++) { b = new Gtk::ToggleButton(_(selection_labels[i]), true); b->set_data("key", GINT_TO_POINTER(i)); - gtk_object_set_data (GTK_OBJECT (dlg), selection_names[i], b->gobj()); + g_object_set_data (G_OBJECT (dlg), selection_names[i], b->gobj()); togglebox->pack_start(*b, false, true, 0); g_signal_connect ( G_OBJECT (b->gobj()), "clicked", G_CALLBACK (sp_export_area_toggled), dlg ); @@ -457,7 +457,7 @@ sp_export_dialog (void) Gtk::VBox *vb_singleexport = new Gtk::VBox(false, 0); vb_singleexport->set_border_width(0); vb->pack_start(*vb_singleexport); - gtk_object_set_data(GTK_OBJECT(dlg), "vb_singleexport", vb_singleexport); + g_object_set_data(G_OBJECT(dlg), "vb_singleexport", vb_singleexport); /* Export area frame */ { @@ -602,8 +602,8 @@ sp_export_dialog (void) hb->pack_start (*fe, true, true, 0); file_box->add(*hb); - gtk_object_set_data (GTK_OBJECT (dlg), "filename", fe->gobj()); - gtk_object_set_data (GTK_OBJECT (dlg), "filename-modified", (gpointer)FALSE); + g_object_set_data (G_OBJECT (dlg), "filename", fe->gobj()); + g_object_set_data (G_OBJECT (dlg), "filename-modified", (gpointer)FALSE); original_name = g_strdup(fe->get_text().c_str()); // pressing enter in the filename field is the same as clicking export: g_signal_connect ( G_OBJECT (fe->gobj()), "activate", @@ -621,7 +621,7 @@ sp_export_dialog (void) Gtk::HBox* batch_box = new Gtk::HBox(FALSE, 5); GtkWidget *be = gtk_check_button_new_with_mnemonic(_("B_atch export all selected objects")); gtk_widget_set_sensitive(GTK_WIDGET(be), TRUE); - gtk_object_set_data(GTK_OBJECT(dlg), "batch_checkbox", be); + g_object_set_data(G_OBJECT(dlg), "batch_checkbox", be); batch_box->pack_start(*Glib::wrap(be), false, false); gtk_widget_set_tooltip_text(be, _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)")); batch_box->show_all(); @@ -633,7 +633,7 @@ sp_export_dialog (void) Gtk::HBox* hide_box = new Gtk::HBox(FALSE, 5); GtkWidget *he = gtk_check_button_new_with_mnemonic(_("Hide a_ll except selected")); gtk_widget_set_sensitive(GTK_WIDGET(he), TRUE); - gtk_object_set_data(GTK_OBJECT(dlg), "hide_checkbox", he); + g_object_set_data(G_OBJECT(dlg), "hide_checkbox", he); hide_box->pack_start(*Glib::wrap(he), false, false); gtk_widget_set_tooltip_text(he, _("In the exported image, hide all objects except those that are selected")); hide_box->show_all(); @@ -831,7 +831,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) } /* Turn off the currently active button unless it's us */ - gtk_object_set_data(GTK_OBJECT(base), "selection-type", (gpointer)key); + g_object_set_data(G_OBJECT(base), "selection-type", (gpointer)key); if (old_key != key) { gtk_toggle_button_set_active @@ -1232,7 +1232,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) selections and all that */ g_free(original_name); original_name = g_strdup(filename_ext); - gtk_object_set_data (GTK_OBJECT (base), "filename-modified", (gpointer)FALSE); + g_object_set_data (G_OBJECT (base), "filename-modified", (gpointer)FALSE); gtk_widget_destroy (prog_dlg); g_object_set_data (G_OBJECT (base), "cancel", (gpointer) 0); @@ -1541,7 +1541,7 @@ sp_export_detect_size(GtkObject * base) { selection_type old = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gtk_object_get_data(base, selection_names[old])), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gtk_object_get_data(base, selection_names[key])), TRUE); - gtk_object_set_data(GTK_OBJECT(base), "selection-type", (gpointer)key); + g_object_set_data(G_OBJECT(base), "selection-type", (gpointer)key); return; } /* sp_export_detect_size */ @@ -1561,7 +1561,7 @@ sp_export_area_x_value_changed (GtkAdjustment *adj, GtkObject *base) return; } - gtk_object_set_data ( base, "update", GUINT_TO_POINTER (TRUE) ); + g_object_set_data ( G_OBJECT(base), "update", GUINT_TO_POINTER (TRUE) ); x0 = sp_export_value_get_px (base, "x0"); x1 = sp_export_value_get_px (base, "x1"); @@ -1588,7 +1588,7 @@ sp_export_area_x_value_changed (GtkAdjustment *adj, GtkObject *base) sp_export_detect_size(base); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data ( G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_area_x_value_changed() @@ -1608,7 +1608,7 @@ sp_export_area_y_value_changed (GtkAdjustment *adj, GtkObject *base) return; } - gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE)); + g_object_set_data ( G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE)); y0 = sp_export_value_get_px (base, "y0"); y1 = sp_export_value_get_px (base, "y1"); @@ -1634,7 +1634,7 @@ sp_export_area_y_value_changed (GtkAdjustment *adj, GtkObject *base) sp_export_detect_size(base); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data ( G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_area_y_value_changed() @@ -1653,7 +1653,7 @@ sp_export_area_width_value_changed (GtkAdjustment */*adj*/, GtkObject *base) return; } - gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE)); + g_object_set_data ( G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE)); x0 = sp_export_value_get_px (base, "x0"); x1 = sp_export_value_get_px (base, "x1"); @@ -1671,7 +1671,7 @@ sp_export_area_width_value_changed (GtkAdjustment */*adj*/, GtkObject *base) sp_export_value_set_px (base, "x1", x0 + width); sp_export_value_set (base, "bmwidth", bmwidth); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_area_width_value_changed() @@ -1691,7 +1691,7 @@ sp_export_area_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) return; } - gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE)); y0 = sp_export_value_get_px (base, "y0"); y1 = sp_export_value_get_px (base, "y1"); @@ -1708,7 +1708,7 @@ sp_export_area_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) sp_export_value_set_px (base, "y1", y0 + height); sp_export_value_set (base, "bmheight", bmheight); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_area_height_value_changed() @@ -1773,7 +1773,7 @@ sp_export_bitmap_width_value_changed (GtkAdjustment */*adj*/, GtkObject *base) return; } - gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE)); x0 = sp_export_value_get_px (base, "x0"); x1 = sp_export_value_get_px (base, "x1"); @@ -1789,7 +1789,7 @@ sp_export_bitmap_width_value_changed (GtkAdjustment */*adj*/, GtkObject *base) sp_export_set_image_y (base); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_bitmap_width_value_changed() @@ -1808,7 +1808,7 @@ sp_export_bitmap_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) return; } - gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE)); y0 = sp_export_value_get_px (base, "y0"); y1 = sp_export_value_get_px (base, "y1"); @@ -1824,7 +1824,7 @@ sp_export_bitmap_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) sp_export_set_image_x (base); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_bitmap_width_value_changed() @@ -1870,7 +1870,7 @@ sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base) return; } - gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE)); x0 = sp_export_value_get_px (base, "x0"); x1 = sp_export_value_get_px (base, "x1"); @@ -1895,7 +1895,7 @@ sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base) sp_export_set_image_y (base); - gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE)); return; } // end of sp_export_xdpi_value_changed() @@ -1923,12 +1923,12 @@ sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base) static void sp_export_set_area ( GtkObject *base, double x0, double y0, double x1, double y1 ) { - gtk_object_set_data ( base, "update", GUINT_TO_POINTER (TRUE) ); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE) ); sp_export_value_set_px (base, "x1", x1); sp_export_value_set_px (base, "y1", y1); sp_export_value_set_px (base, "x0", x0); sp_export_value_set_px (base, "y0", y0); - gtk_object_set_data ( base, "update", GUINT_TO_POINTER (FALSE) ); + g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE) ); sp_export_area_x_value_changed ((GtkAdjustment *)gtk_object_get_data (base, "x1"), base); sp_export_area_y_value_changed ((GtkAdjustment *)gtk_object_get_data (base, "y1"), base); @@ -2037,10 +2037,10 @@ sp_export_filename_modified (GtkObject * object, gpointer data) GtkWidget * export_dialog = (GtkWidget *)data; if (!strcmp(original_name, gtk_entry_get_text(GTK_ENTRY(text_entry)))) { - gtk_object_set_data (GTK_OBJECT (export_dialog), "filename-modified", (gpointer)FALSE); + g_object_set_data (G_OBJECT (export_dialog), "filename-modified", (gpointer)FALSE); // printf("Modified: FALSE\n"); } else { - gtk_object_set_data (GTK_OBJECT (export_dialog), "filename-modified", (gpointer)TRUE); + g_object_set_data (G_OBJECT (export_dialog), "filename-modified", (gpointer)TRUE); // printf("Modified: TRUE\n"); } diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index 62c551523..dae2dc373 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -423,7 +423,7 @@ sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, cons GtkWidget *tf = gtk_entry_new (); gtk_entry_set_max_length (GTK_ENTRY (tf), 64); gtk_box_pack_start (GTK_BOX (hb), tf, TRUE, TRUE, 0); - gtk_object_set_data (GTK_OBJECT (dlg), id, tf); + g_object_set_data (G_OBJECT (dlg), id, tf); gtk_widget_set_tooltip_text (tf, tip); g_signal_connect ( G_OBJECT (tf), "activate", G_CALLBACK (sp_find_dialog_find), dlg ); gtk_label_set_mnemonic_widget (GTK_LABEL(l), tf); @@ -494,7 +494,7 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active, GtkWidget *b = gtk_check_button_new_with_label (label); gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, active); - gtk_object_set_data (GTK_OBJECT (w), data, b); + g_object_set_data (G_OBJECT (w), data, b); gtk_widget_set_tooltip_text (b, tip); if (toggled) g_signal_connect (G_OBJECT (b), "toggled", G_CALLBACK (toggled), w); @@ -592,7 +592,7 @@ sp_find_types () gtk_box_pack_start (GTK_BOX (hb), c, FALSE, FALSE, 0); } - gtk_object_set_data (GTK_OBJECT (vb), "shapes-pane", hb); + g_object_set_data (G_OBJECT (vb), "shapes-pane", hb); gtk_box_pack_start (GTK_BOX (vb_all), hb, FALSE, FALSE, 0); gtk_widget_hide_all (hb); @@ -633,7 +633,7 @@ sp_find_types () } gtk_box_pack_start (GTK_BOX (vb), vb_all, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (vb), "all-pane", vb_all); + g_object_set_data (G_OBJECT (vb), "all-pane", vb_all); gtk_widget_hide_all (vb_all); } @@ -699,7 +699,7 @@ sp_find_dialog_old (void) gtk_widget_show_all (vb); GtkWidget *types = sp_find_types (); - gtk_object_set_data (GTK_OBJECT (dlg), "types", types); + g_object_set_data (G_OBJECT (dlg), "types", types); gtk_box_pack_start (GTK_BOX (vb), types, FALSE, FALSE, 0); { @@ -711,7 +711,7 @@ sp_find_dialog_old (void) GtkWidget *b = gtk_check_button_new_with_mnemonic (_("Search in s_election")); gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); - gtk_object_set_data (GTK_OBJECT (dlg), "inselection", b); + g_object_set_data (G_OBJECT (dlg), "inselection", b); gtk_widget_set_tooltip_text (b, _("Limit search to the current selection")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } @@ -720,7 +720,7 @@ sp_find_dialog_old (void) GtkWidget *b = gtk_check_button_new_with_mnemonic (_("Search in current _layer")); gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); - gtk_object_set_data (GTK_OBJECT (dlg), "inlayer", b); + g_object_set_data (G_OBJECT (dlg), "inlayer", b); gtk_widget_set_tooltip_text (b, _("Limit search to the current layer")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } @@ -729,7 +729,7 @@ sp_find_dialog_old (void) GtkWidget *b = gtk_check_button_new_with_mnemonic (_("Include _hidden")); gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); - gtk_object_set_data (GTK_OBJECT (dlg), "includehidden", b); + g_object_set_data (G_OBJECT (dlg), "includehidden", b); gtk_widget_set_tooltip_text (b, _("Include hidden objects in search")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } @@ -738,7 +738,7 @@ sp_find_dialog_old (void) GtkWidget *b = gtk_check_button_new_with_mnemonic (_("Include l_ocked")); gtk_widget_show (b); gtk_toggle_button_set_active ((GtkToggleButton *) b, FALSE); - gtk_object_set_data (GTK_OBJECT (dlg), "includelocked", b); + g_object_set_data (G_OBJECT (dlg), "includelocked", b); gtk_widget_set_tooltip_text (b, _("Include locked objects in search")); gtk_box_pack_start (GTK_BOX (vb), b, FALSE, FALSE, 0); } diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 3f757e81f..34e7746fa 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -114,7 +114,7 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), l, 0, 1, 0, 1, (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_object_set_data (GTK_OBJECT (spw), "id_label", l); + g_object_set_data (G_OBJECT (spw), "id_label", l); /* Create the entry box for the object id */ tf = gtk_entry_new (); @@ -123,7 +123,7 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), tf, 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_object_set_data (GTK_OBJECT (spw), "id", tf); + g_object_set_data (G_OBJECT (spw), "id", tf); gtk_label_set_mnemonic_widget (GTK_LABEL(l), tf); // pressing enter in the id field is the same as clicking Set: @@ -137,7 +137,7 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), l, 0, 1, 1, 2, (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_object_set_data (GTK_OBJECT (spw), "label_label", l); + g_object_set_data (G_OBJECT (spw), "label_label", l); /* Create the entry box for the object label */ tf = gtk_entry_new (); @@ -146,7 +146,7 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), tf, 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_object_set_data (GTK_OBJECT (spw), "label", tf); + g_object_set_data (G_OBJECT (spw), "label", tf); gtk_label_set_mnemonic_widget (GTK_LABEL(l), tf); // pressing enter in the label field is the same as clicking Set: @@ -158,7 +158,7 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), l, 0, 1, 2, 3, (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_object_set_data (GTK_OBJECT (spw), "title_label", l); + g_object_set_data (G_OBJECT (spw), "title_label", l); /* Create the entry box for the object title */ tf = gtk_entry_new (); @@ -167,7 +167,7 @@ sp_item_widget_new (void) gtk_table_attach ( GTK_TABLE (t), tf, 1, 3, 2, 3, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); - gtk_object_set_data (GTK_OBJECT (spw), "title", tf); + g_object_set_data (G_OBJECT (spw), "title", tf); gtk_label_set_mnemonic_widget (GTK_LABEL(l), tf); /* Create the frame for the object description */ @@ -184,14 +184,14 @@ sp_item_widget_new (void) gtk_widget_set_sensitive (GTK_WIDGET (textframe), FALSE); gtk_container_add (GTK_CONTAINER (f), textframe); gtk_frame_set_shadow_type (GTK_FRAME (textframe), GTK_SHADOW_IN); - gtk_object_set_data(GTK_OBJECT(spw), "desc_frame", textframe); + g_object_set_data(G_OBJECT(spw), "desc_frame", textframe); tf = gtk_text_view_new(); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tf), GTK_WRAP_WORD); desc_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tf)); gtk_text_buffer_set_text(desc_buffer, "", -1); gtk_container_add (GTK_CONTAINER (textframe), tf); - gtk_object_set_data (GTK_OBJECT (spw), "desc", tf); + g_object_set_data (G_OBJECT (spw), "desc", tf); gtk_label_set_mnemonic_widget (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (f))), tf); /* Check boxes */ @@ -208,7 +208,7 @@ sp_item_widget_new (void) (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)0, 0, 0 ); g_signal_connect (G_OBJECT(cb), "toggled", G_CALLBACK(sp_item_widget_hidden_toggled), spw); - gtk_object_set_data(GTK_OBJECT(spw), "hidden", cb); + g_object_set_data(G_OBJECT(spw), "hidden", cb); /* Button for setting the object's id, label, title and description. */ pb = gtk_button_new_with_mnemonic (_("_Set")); @@ -227,13 +227,13 @@ sp_item_widget_new (void) g_signal_connect ( G_OBJECT (cb), "toggled", G_CALLBACK (sp_item_widget_sensitivity_toggled), spw ); - gtk_object_set_data (GTK_OBJECT (spw), "sensitive", cb); + g_object_set_data (G_OBJECT (spw), "sensitive", cb); /* Create the frame for interactivity options */ int_label = gtk_label_new_with_mnemonic (_("_Interactivity")); int_expander = gtk_expander_new (NULL); gtk_expander_set_label_widget (GTK_EXPANDER (int_expander),int_label); - gtk_object_set_data (GTK_OBJECT (spw), "interactivity", int_expander); + g_object_set_data (G_OBJECT (spw), "interactivity", int_expander); gtk_box_pack_start (GTK_BOX (vb), int_expander, FALSE, FALSE, 0); @@ -285,7 +285,7 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) gtk_widget_set_sensitive (GTK_WIDGET (spw), TRUE); } - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); SPItem *item = selection->singleItem(); @@ -362,13 +362,13 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) int_table = sp_attribute_table_new (obj, 10, int_labels, int_labels); gtk_widget_show_all (int_table); - gtk_object_set_data(GTK_OBJECT(spw), "interactivity_table", int_table); + g_object_set_data(G_OBJECT(spw), "interactivity_table", int_table); gtk_container_add (GTK_CONTAINER (w), int_table); } - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } // end of sp_item_widget_setup() @@ -384,14 +384,14 @@ sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); item->setLocked(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))? _("Lock object") : _("Unlock object")); - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } void @@ -403,14 +403,14 @@ sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); item->setExplicitlyHidden(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))? _("Hide object") : _("Unhide object")); - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } static void @@ -422,7 +422,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); g_return_if_fail (item != NULL); - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); /* Retrieve the label widget for the object's id */ GtkWidget *id_entry = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id")); @@ -477,7 +477,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) _("Set object description")); g_free(desc); - gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } // end of sp_item_widget_label_changed() diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 1d475a5c3..ebe87ede9 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -191,7 +191,7 @@ sp_spellcheck_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, con gtk_widget_set_tooltip_text (b, tip); gtk_box_pack_start (GTK_BOX (hb), b, TRUE, TRUE, 0); g_signal_connect ( G_OBJECT (b), "clicked", G_CALLBACK (function), dlg ); - gtk_object_set_data (GTK_OBJECT (dlg), cookie, b); + g_object_set_data (G_OBJECT (dlg), cookie, b); gtk_widget_show (b); } @@ -935,7 +935,7 @@ sp_spellcheck_dialog (void) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); GtkWidget *l = gtk_label_new (NULL); - gtk_object_set_data (GTK_OBJECT (dlg), "banner", l); + g_object_set_data (G_OBJECT (dlg), "banner", l); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); } @@ -948,7 +948,7 @@ sp_spellcheck_dialog (void) GtkListStore *model = gtk_list_store_new (1, G_TYPE_STRING); GtkWidget *tree_view = gtk_tree_view_new (); - gtk_object_set_data (GTK_OBJECT (dlg), "suggestions", tree_view); + g_object_set_data (G_OBJECT (dlg), "suggestions", tree_view); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), tree_view); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index bcc8589e2..80ea216b3 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -232,7 +232,7 @@ spus_rebuild_menu(SPUnitSelector *us) // i = gtk_menu_item_new_with_label((us->abbr) ? (us->plural) ? u->abbr_plural : u->abbr : (us->plural) ? u->plural : u->name); GtkWidget *i = gtk_menu_item_new_with_label( u->abbr ); - gtk_object_set_data(GTK_OBJECT(i), "unit", (gpointer) u); + g_object_set_data(G_OBJECT(i), "unit", (gpointer) u); g_signal_connect(G_OBJECT(i), "activate", G_CALLBACK(spus_unit_activate), us); sp_set_font_size_smaller (i); diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index a45b8ceaa..a5d882192 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -110,7 +110,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Object Properties...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); @@ -123,21 +123,21 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) if (sp_desktop_selection(desktop)->includes(item)) { gtk_widget_set_sensitive(w, FALSE); } else { - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_this), item); } gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Create link */ w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_create_link), item); gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item)); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Set mask */ w = gtk_menu_item_new_with_mnemonic(_("Set Mask")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_mask), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); @@ -148,7 +148,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_menu_append(GTK_MENU(m), w); /* Release mask */ w = gtk_menu_item_new_with_mnemonic(_("Release Mask")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_mask), item); if (item && item->mask_ref && item->mask_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); @@ -159,7 +159,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_menu_append(GTK_MENU(m), w); /* Set Clip */ w = gtk_menu_item_new_with_mnemonic(_("Set _Clip")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_clip), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); @@ -170,7 +170,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_menu_append(GTK_MENU(m), w); /* Release Clip */ w = gtk_menu_item_new_with_mnemonic(_("Release C_lip")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_clip), item); if (item && item->clip_ref && item->clip_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); @@ -311,7 +311,7 @@ sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* "Ungroup" */ w = gtk_menu_item_new_with_mnemonic(_("_Ungroup")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_group_ungroup_activate), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(menu), w); @@ -351,7 +351,7 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Link _Properties...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); @@ -362,7 +362,7 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_menu_append(GTK_MENU(m), w); /* Reset transformations */ w = gtk_menu_item_new_with_mnemonic(_("_Remove Link")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_remove), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); @@ -410,13 +410,13 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Image _Properties...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_properties), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_edit), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); @@ -533,7 +533,7 @@ sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); @@ -589,21 +589,21 @@ sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Fill and Stroke dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Edit Text dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Text and Font...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_text_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); /* Spellcheck dialog */ w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); + g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_spellcheck_settings), item); gtk_widget_show(w); gtk_menu_append(GTK_MENU(m), w); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index ae8cd564e..0aa65b1a9 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -412,7 +412,7 @@ void SelectedStyle::setDesktop(SPDesktop *desktop) { _desktop = desktop; - gtk_object_set_data (GTK_OBJECT(_opacity_sb.gobj()), "dtw", _desktop->canvas); + g_object_set_data (G_OBJECT(_opacity_sb.gobj()), "dtw", _desktop->canvas); Inkscape::Selection *selection = sp_desktop_selection (desktop); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 3c2d60638..98c678194 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -497,7 +497,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (dtw->zoom_status), GTK_UPDATE_ALWAYS); g_signal_connect (G_OBJECT (dtw->zoom_status), "input", G_CALLBACK (sp_dtw_zoom_input), dtw); g_signal_connect (G_OBJECT (dtw->zoom_status), "output", G_CALLBACK (sp_dtw_zoom_output), dtw); - gtk_object_set_data (GTK_OBJECT (dtw->zoom_status), "dtw", dtw->canvas); + g_object_set_data (G_OBJECT (dtw->zoom_status), "dtw", dtw->canvas); g_signal_connect (G_OBJECT (dtw->zoom_status), "focus-in-event", G_CALLBACK (spinbutton_focus_in), dtw->zoom_status); g_signal_connect (G_OBJECT (dtw->zoom_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->zoom_status); dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "value_changed", G_CALLBACK (sp_dtw_zoom_value_changed), dtw); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 9186044de..96dadcc26 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -467,7 +467,7 @@ GtkWidget * gr_change_widget(SPDesktop *desktop) gr_read_selection (selection, ev? ev->get_drag() : 0, gr_selected, gr_multi, spr_selected, spr_multi); GtkWidget *widget = gtk_hbox_new(FALSE, FALSE); - gtk_object_set_data(GTK_OBJECT(widget), "dtw", desktop->canvas); + g_object_set_data(G_OBJECT(widget), "dtw", desktop->canvas); g_object_set_data (G_OBJECT (widget), "desktop", desktop); GtkWidget *om = gr_vector_list (desktop, selection->isEmpty(), gr_selected, gr_multi); @@ -537,8 +537,8 @@ sp_gradient_toolbox_new(SPDesktop *desktop) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); GtkWidget *tbl = gtk_toolbar_new(); - gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas); - gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop); + g_object_set_data(G_OBJECT(tbl), "dtw", desktop->canvas); + g_object_set_data(G_OBJECT(tbl), "desktop", desktop); sp_toolbox_add_label(tbl, _("New:")); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index a58b22d7c..008bff266 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -797,7 +797,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s update_stop_list(GTK_WIDGET(mnu), gradient, NULL); g_signal_connect(G_OBJECT(mnu), "changed", G_CALLBACK(sp_grad_edit_select), vb); gtk_widget_show(mnu); - gtk_object_set_data(GTK_OBJECT(vb), "stopmenu", mnu); + g_object_set_data(G_OBJECT(vb), "stopmenu", mnu); gtk_box_pack_start(GTK_BOX(vb), mnu, FALSE, FALSE, 0); /* Add and Remove buttons */ @@ -830,7 +830,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s /* Adjustment */ GtkAdjustment *Offset_adj = NULL; Offset_adj= (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 1.0, 0.01, 0.01, 0.0); - gtk_object_set_data(GTK_OBJECT(vb), "offset", Offset_adj); + g_object_set_data(G_OBJECT(vb), "offset", Offset_adj); GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(mnu))); SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "stop")); gtk_adjustment_set_value(Offset_adj, stop->offset); @@ -840,14 +840,14 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE ); gtk_widget_show(slider); gtk_box_pack_start(GTK_BOX(hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); - gtk_object_set_data(GTK_OBJECT(vb), "offslide", slider); + g_object_set_data(G_OBJECT(vb), "offslide", slider); /* Spinbutton */ GtkWidget *sbtn = gtk_spin_button_new(GTK_ADJUSTMENT(Offset_adj), 0.01, 2); sp_dialog_defocus_on_enter(sbtn); gtk_widget_show(sbtn); gtk_box_pack_start(GTK_BOX(hb),sbtn, FALSE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); - gtk_object_set_data(GTK_OBJECT(vb), "offspn", sbtn); + g_object_set_data(G_OBJECT(vb), "offspn", sbtn); if (stop->offset>0 && stop->offset<1) { gtk_widget_set_sensitive(slider, TRUE); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 6b3e0c4b5..e771c60c7 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -251,7 +251,7 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(psel->evenodd), FALSE); // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty gtk_widget_set_tooltip_text(psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)")); - gtk_object_set_data(GTK_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_EVENODD)); + g_object_set_data(G_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_EVENODD)); w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_EVEN_ODD); gtk_container_add(GTK_CONTAINER(psel->evenodd), w); gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->evenodd, FALSE, FALSE, 0); @@ -262,7 +262,7 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(psel->nonzero), FALSE); // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty gtk_widget_set_tooltip_text(psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)")); - gtk_object_set_data(GTK_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_NONZERO)); + g_object_set_data(G_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_NONZERO)); w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_NONZERO); gtk_container_add(GTK_CONTAINER(psel->nonzero), w); gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->nonzero, FALSE, FALSE, 0); @@ -307,7 +307,7 @@ static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gtk_button_set_relief(GTK_BUTTON(b), GTK_RELIEF_NONE); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(b), FALSE); - gtk_object_set_data(GTK_OBJECT(b), "mode", GUINT_TO_POINTER(mode)); + g_object_set_data(G_OBJECT(b), "mode", GUINT_TO_POINTER(mode)); w = sp_icon_new(Inkscape::ICON_SIZE_BUTTON, pixmap); gtk_widget_show(w); @@ -658,7 +658,7 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec /* Color selector */ csel = sp_color_selector_new( SP_TYPE_COLOR_NOTEBOOK ); gtk_widget_show(csel); - gtk_object_set_data(GTK_OBJECT(vb), "color-selector", csel); + g_object_set_data(G_OBJECT(vb), "color-selector", csel); gtk_box_pack_start(GTK_BOX(vb), csel, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(csel), "grabbed", G_CALLBACK(sp_paint_selector_color_grabbed), psel); g_signal_connect(G_OBJECT(csel), "dragged", G_CALLBACK(sp_paint_selector_color_dragged), psel); @@ -729,7 +729,7 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe /* Pack everything to frame */ gtk_container_add(GTK_CONTAINER(psel->frame), gsel); psel->selector = gsel; - gtk_object_set_data(GTK_OBJECT(psel->selector), "gradient-selector", gsel); + g_object_set_data(G_OBJECT(psel->selector), "gradient-selector", gsel); } /* Actually we have to set option menu history here */ @@ -945,7 +945,7 @@ void SPPaintSelector::updatePatternList( SPPattern *pattern ) if (pattern && !gtk_object_get_data(GTK_OBJECT(mnu), "update")) { - gtk_object_set_data(GTK_OBJECT(mnu), "update", GINT_TO_POINTER(TRUE)); + g_object_set_data(G_OBJECT(mnu), "update", GINT_TO_POINTER(TRUE)); gchar const *patname = pattern->getRepr()->attribute("id"); @@ -967,7 +967,7 @@ void SPPaintSelector::updatePatternList( SPPattern *pattern ) gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), patpos); - gtk_object_set_data(GTK_OBJECT(mnu), "update", GINT_TO_POINTER(FALSE)); + g_object_set_data(G_OBJECT(mnu), "update", GINT_TO_POINTER(FALSE)); } //gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), 0); } @@ -999,7 +999,7 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel ink_pattern_menu(mnu); g_signal_connect(G_OBJECT(mnu), "changed", G_CALLBACK(sp_psel_pattern_change), psel); g_signal_connect(G_OBJECT(mnu), "destroy", G_CALLBACK(sp_psel_pattern_destroy), psel); - gtk_object_set_data(GTK_OBJECT(psel), "patternmenu", mnu); + g_object_set_data(G_OBJECT(psel), "patternmenu", mnu); g_object_ref( G_OBJECT(mnu)); gtk_container_add(GTK_CONTAINER(hb), mnu); @@ -1020,7 +1020,7 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel gtk_container_add(GTK_CONTAINER(psel->frame), tbl); psel->selector = tbl; - gtk_object_set_data(GTK_OBJECT(psel->selector), "pattern-selector", tbl); + g_object_set_data(G_OBJECT(psel->selector), "pattern-selector", tbl); gtk_frame_set_label(GTK_FRAME(psel->frame), _("Pattern fill")); } @@ -1095,7 +1095,7 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele // Pack everything to frame gtk_container_add(GTK_CONTAINER(psel->frame), GTK_WIDGET(swatchsel->gobj())); psel->selector = GTK_WIDGET(swatchsel->gobj()); - gtk_object_set_data(GTK_OBJECT(psel->selector), "swatch-selector", swatchsel); + g_object_set_data(G_OBJECT(psel->selector), "swatch-selector", swatchsel); gtk_frame_set_label(GTK_FRAME(psel->frame), _("Swatch fill")); } diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 25162dead..2b80fac9a 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -166,7 +166,7 @@ void ColorScales::init() gtk_table_attach (GTK_TABLE (t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); /* Attach channel value to adjustment */ - gtk_object_set_data (GTK_OBJECT (_a[i]), "channel", GINT_TO_POINTER (i)); + g_object_set_data (G_OBJECT (_a[i]), "channel", GINT_TO_POINTER (i)); /* Signals */ g_signal_connect (G_OBJECT (_a[i]), "value_changed", G_CALLBACK (_adjustmentAnyChanged), _csel); diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp index 4b60ce812..70fa3a54d 100644 --- a/src/widgets/spinbutton-events.cpp +++ b/src/widgets/spinbutton-events.cpp @@ -35,7 +35,7 @@ spinbutton_focus_in (GtkWidget *w, GdkEventKey */*event*/, gpointer /*data*/) *ini = gtk_spin_button_get_value (GTK_SPIN_BUTTON(w)); // remember it - gtk_object_set_data (GTK_OBJECT (w), "ini", ini); + g_object_set_data (G_OBJECT (w), "ini", ini); return FALSE; // I didn't consume the event } @@ -53,7 +53,7 @@ spinbutton_defocus (GtkObject *container) // defocus spinbuttons by moving focus to the canvas, unless "stay" is on gboolean stay = GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (container), "stay")); if (stay) { - gtk_object_set_data (GTK_OBJECT (container), "stay", GINT_TO_POINTER (FALSE)); + g_object_set_data (G_OBJECT (container), "stay", GINT_TO_POINTER (FALSE)); } else { GtkWidget *canvas = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (container), "dtw"); if (canvas) { @@ -82,7 +82,7 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) case GDK_Tab: case GDK_ISO_Left_Tab: // set the flag meaning "do not leave toolbar when changing value" - gtk_object_set_data (GTK_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); return FALSE; // I didn't consume the event break; @@ -91,7 +91,7 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) case GDK_Up: case GDK_KP_Up: - gtk_object_set_data (GTK_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); v += SPIN_STEP; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); @@ -99,7 +99,7 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) break; case GDK_Down: case GDK_KP_Down: - gtk_object_set_data (GTK_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); v -= SPIN_STEP; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); @@ -107,7 +107,7 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) break; case GDK_Page_Up: case GDK_KP_Page_Up: - gtk_object_set_data (GTK_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); v += SPIN_PAGE_STEP; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); @@ -115,7 +115,7 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) break; case GDK_Page_Down: case GDK_KP_Page_Down: - gtk_object_set_data (GTK_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w)); v -= SPIN_PAGE_STEP; gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v); @@ -123,7 +123,7 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data) break; case GDK_z: case GDK_Z: - gtk_object_set_data (GTK_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); + g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE)); if (event->state & GDK_CONTROL_MASK) { spinbutton_undo (w); return TRUE; // I consumed the event diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index aec1e2e11..a5c60c382 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -97,8 +97,8 @@ GtkWidget *spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *vbox, g_assert (b != NULL); gtk_widget_show (b); gtk_box_pack_start (GTK_BOX (vbox), b, FALSE, FALSE, 0); - gtk_object_set_data (GTK_OBJECT (b), "key", key); - gtk_object_set_data (GTK_OBJECT (dialog), key, b); + g_object_set_data (G_OBJECT (b), "key", key); + g_object_set_data (G_OBJECT (dialog), key, b); g_signal_connect (G_OBJECT (b), "toggled", cb, dialog); return b; } @@ -128,8 +128,8 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table, gtk_widget_show (b); gtk_table_attach (GTK_TABLE (table), b, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); - gtk_object_set_data (GTK_OBJECT (b), "key", key); - gtk_object_set_data (GTK_OBJECT (dialog), key, b); + g_object_set_data (G_OBJECT (b), "key", key); + g_object_set_data (G_OBJECT (dialog), key, b); g_signal_connect (G_OBJECT (b), "toggled", cb, dialog); if (insensitive == 1) { gtk_widget_set_sensitive (b, FALSE); @@ -156,7 +156,7 @@ spw_dropdown(GtkWidget * dialog, GtkWidget * table, gtk_widget_show (selector); gtk_table_attach (GTK_TABLE (table), selector, 1, 2, row, row+1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0); - gtk_object_set_data (GTK_OBJECT (dialog), key, selector); + g_object_set_data (G_OBJECT (dialog), key, selector); return selector; } @@ -181,9 +181,9 @@ spw_unit_selector(GtkWidget * dialog, GtkWidget * table, a = gtk_adjustment_new (0.0, can_be_negative?-1e6:0, 1e6, 1.0, 10.0, 10.0); g_assert(a != NULL); - gtk_object_set_data (GTK_OBJECT (a), "key", key); - gtk_object_set_data (GTK_OBJECT (a), "unit_selector", us); - gtk_object_set_data (GTK_OBJECT (dialog), key, a); + g_object_set_data (G_OBJECT (a), "key", key); + g_object_set_data (G_OBJECT (a), "unit_selector", us); + g_object_set_data (G_OBJECT (dialog), key, a); sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (us), GTK_ADJUSTMENT (a)); sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 4); g_assert(sb != NULL); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 01308104e..d2751a24b 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2560,8 +2560,8 @@ void ToolboxFactory::showAuxToolbox(GtkWidget *toolbox_toplevel) static GtkWidget *sp_empty_toolbox_new(SPDesktop *desktop) { GtkWidget *tbl = gtk_toolbar_new(); - gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas); - gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop); + g_object_set_data(G_OBJECT(tbl), "dtw", desktop->canvas); + g_object_set_data(G_OBJECT(tbl), "desktop", desktop); gtk_widget_show_all(tbl); sp_set_font_size_smaller (tbl); @@ -2948,7 +2948,7 @@ void sp_toolbox_add_label(GtkWidget *tbl, gchar const *title, bool wide) } else { gtk_box_pack_start(GTK_BOX(tbl), boxl, FALSE, FALSE, 0); } - gtk_object_set_data(GTK_OBJECT(tbl), "mode_label", l); + g_object_set_data(G_OBJECT(tbl), "mode_label", l); } -- cgit v1.2.3 From e9ac7d48112f36db332905fcc3692c44641f4a66 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 26 Jun 2011 00:37:12 +0100 Subject: Gtk cleanup: GTK_WIDGET_HAS_FOCUS (bzr r10350.1.6) --- src/ege-adjustment-action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 9f8356495..45a44ae0c 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -779,7 +779,7 @@ static GtkWidget* create_menu_item( GtkAction* action ) void value_changed_cb( GtkSpinButton* spin, EgeAdjustmentAction* act ) { - if ( GTK_WIDGET_HAS_FOCUS( GTK_WIDGET(spin) ) ) { + if ( gtk_widget_has_focus( GTK_WIDGET(spin) ) ) { ege_adjustment_action_defocus( act ); } } -- cgit v1.2.3 From f5437faac0a6b2d95f6acad0dd3a03c1759bc255 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 26 Jun 2011 01:30:49 +0100 Subject: Gtk cleanup: gtk_menu_append (bzr r10350.1.7) --- src/dialogs/clonetiler.cpp | 2 +- src/interface.cpp | 10 +++++----- src/ui/context-menu.cpp | 36 ++++++++++++++++++------------------ src/widgets/gradient-selector.cpp | 6 +++--- src/widgets/gradient-toolbar.cpp | 10 +++++----- src/widgets/gradient-vector.cpp | 12 ++++++------ src/widgets/paint-selector.cpp | 6 +++--- src/widgets/sp-color-notebook.cpp | 2 +- 8 files changed, 42 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 43dbf4e60..df9ea3be7 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1864,7 +1864,7 @@ void clonetiler_dialog(void) G_CALLBACK (clonetiler_symgroup_changed), GINT_TO_POINTER (sg.group) ); - gtk_menu_append (GTK_MENU (m), item); + gtk_menu_shell_append(GTK_MENU_SHELL (m), item); } gtk_option_menu_set_menu (GTK_OPTION_MENU (om), m); diff --git a/src/interface.cpp b/src/interface.cpp index 209f32fd7..c7946cf18 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -456,7 +456,7 @@ sp_ui_menu_append_item( GtkMenu *menu, gchar const *stock, g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL); } - gtk_menu_append(GTK_MENU(menu), item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); return item; @@ -562,7 +562,7 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape:: } gtk_widget_show(item); - gtk_menu_append(GTK_MENU(menu), item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); return item; @@ -953,7 +953,7 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI: GtkWidget *item = gtk_menu_item_new_with_label(string); gtk_widget_set_sensitive(item, false); gtk_widget_show(item); - gtk_menu_append(GTK_MENU(menu), item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); } continue; } @@ -964,7 +964,7 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI: || !strcmp(menu_pntr->name(), "seperator")) { GtkWidget *item = gtk_separator_menu_item_new(); gtk_widget_show(item); - gtk_menu_append(GTK_MENU(menu), item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); continue; } if (!strcmp(menu_pntr->name(), "template-list")) { @@ -993,7 +993,7 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI: GtkWidget *recent_item = gtk_menu_item_new_with_mnemonic(_("Open _Recent")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent_item), recent_menu); - gtk_menu_append(GTK_MENU(menu), GTK_WIDGET(recent_item)); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(recent_item)); // this will just sit and update the list's item count static MaxRecentObserver *mro = new MaxRecentObserver(recent_menu); prefs->addObserver(*mro); diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index a5d882192..2f41b3fde 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -113,11 +113,11 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_properties), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Separator */ w = gtk_menu_item_new(); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Select item */ w = gtk_menu_item_new_with_mnemonic(_("_Select This")); if (sp_desktop_selection(desktop)->includes(item)) { @@ -127,14 +127,14 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_this), item); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Create link */ w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_create_link), item); gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item)); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Set mask */ w = gtk_menu_item_new_with_mnemonic(_("Set Mask")); g_object_set_data(G_OBJECT(w), "desktop", desktop); @@ -145,7 +145,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_widget_set_sensitive(w, TRUE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Release mask */ w = gtk_menu_item_new_with_mnemonic(_("Release Mask")); g_object_set_data(G_OBJECT(w), "desktop", desktop); @@ -156,7 +156,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_widget_set_sensitive(w, FALSE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Set Clip */ w = gtk_menu_item_new_with_mnemonic(_("Set _Clip")); g_object_set_data(G_OBJECT(w), "desktop", desktop); @@ -167,7 +167,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_widget_set_sensitive(w, TRUE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Release Clip */ w = gtk_menu_item_new_with_mnemonic(_("Release C_lip")); g_object_set_data(G_OBJECT(w), "desktop", desktop); @@ -178,7 +178,7 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) gtk_widget_set_sensitive(w, FALSE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } @@ -314,7 +314,7 @@ sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_group_ungroup_activate), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(menu), w); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), w); } static void @@ -354,18 +354,18 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_properties), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Select item */ w = gtk_menu_item_new_with_mnemonic(_("_Follow Link")); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_follow), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Reset transformations */ w = gtk_menu_item_new_with_mnemonic(_("_Remove Link")); g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_remove), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } static void @@ -413,13 +413,13 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_properties), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_edit), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); Inkscape::XML::Node *ir = object->getRepr(); const gchar *href = ir->attribute("xlink:href"); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { @@ -536,7 +536,7 @@ sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } /* Edit Text entry */ @@ -592,21 +592,21 @@ sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Edit Text dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Text and Font...")); g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_text_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Spellcheck dialog */ w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g...")); g_object_set_data(G_OBJECT(w), "desktop", desktop); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_spellcheck_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } /* Local Variables: diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index a3110ed5b..c6b867595 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -171,17 +171,17 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) GtkWidget *m = gtk_menu_new(); GtkWidget *mi = gtk_menu_item_new_with_label(_("none")); - gtk_menu_append (GTK_MENU (m), mi); + gtk_menu_shell_append(GTK_MENU_SHELL (m), mi); g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_PAD)); g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel); mi = gtk_menu_item_new_with_label (_("reflected")); g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_REFLECT)); g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel); - gtk_menu_append (GTK_MENU (m), mi); + gtk_menu_shell_append(GTK_MENU_SHELL (m), mi); mi = gtk_menu_item_new_with_label (_("direct")); g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_REPEAT)); g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel); - gtk_menu_append (GTK_MENU (m), mi); + gtk_menu_shell_append(GTK_MENU_SHELL (m), mi); gtk_widget_show_all (m); gtk_option_menu_set_menu( GTK_OPTION_MENU(sel->spread), m ); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 96dadcc26..6d4f6fae0 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -193,7 +193,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient * gtk_container_add (GTK_CONTAINER (i), l); gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); + gtk_menu_shell_append(GTK_MENU_SHELL (m), i); gtk_widget_set_sensitive (om, FALSE); } else if (selection_empty) { // Document has gradients, but nothing is currently selected. @@ -203,7 +203,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient * gtk_container_add (GTK_CONTAINER (i), l); gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); + gtk_menu_shell_append(GTK_MENU_SHELL (m), i); gtk_widget_set_sensitive (om, FALSE); } else { @@ -214,7 +214,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient * gtk_container_add (GTK_CONTAINER (i), l); gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); + gtk_menu_shell_append(GTK_MENU_SHELL (m), i); } if (gr_multi) { @@ -224,7 +224,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient * gtk_container_add (GTK_CONTAINER (i), l); gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); + gtk_menu_shell_append(GTK_MENU_SHELL (m), i); } while (gl) { @@ -250,7 +250,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient * gtk_container_add (GTK_CONTAINER (i), hb); - gtk_menu_append (GTK_MENU (m), i); + gtk_menu_shell_append(GTK_MENU_SHELL (m), i); if (gradient == gr_selected) { pos = idx; diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 008bff266..ceb6f5c06 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -274,19 +274,19 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) GtkWidget *i; i = gtk_menu_item_new_with_label(_("No document selected")); gtk_widget_show(i); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); gtk_widget_set_sensitive(gvs->menu, FALSE); } else if (!gl) { GtkWidget *i; i = gtk_menu_item_new_with_label(_("No gradients in document")); gtk_widget_show(i); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); gtk_widget_set_sensitive(gvs->menu, FALSE); } else if (!gvs->gr) { GtkWidget *i; i = gtk_menu_item_new_with_label(_("No gradient selected")); gtk_widget_show(i); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); gtk_widget_set_sensitive(gvs->menu, FALSE); } else { while (gl) { @@ -320,7 +320,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) gtk_container_add(GTK_CONTAINER(i), w); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); if (gr == gvs->gr) { pos = idx; @@ -551,7 +551,7 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_ if (!sl) { GtkWidget *i = gtk_menu_item_new_with_label(_("No stops in gradient")); gtk_widget_show(i); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); gtk_widget_set_sensitive(mnu, FALSE); } else { @@ -574,7 +574,7 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_ gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, 0); gtk_widget_show(hb); gtk_container_add(GTK_CONTAINER(i), hb); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); } } diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index e771c60c7..60ce6beff 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -830,7 +830,7 @@ sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source* gtk_widget_show(hb); gtk_container_add(GTK_CONTAINER(i), hb); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); } } @@ -887,7 +887,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc) gchar const *patid = ""; g_object_set_data (G_OBJECT(i), "pattern", (void *) patid); gtk_widget_show(i); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); } // suck in from patterns.svg @@ -911,7 +911,7 @@ ink_pattern_menu(GtkWidget *mnu) GtkWidget *i; i = gtk_menu_item_new_with_label(_("No document selected")); gtk_widget_show(i); - gtk_menu_append(GTK_MENU(m), i); + gtk_menu_shell_append(GTK_MENU_SHELL(m), i); gtk_widget_set_sensitive(mnu, FALSE); } else { diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index e3e28979d..0379fa141 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -294,7 +294,7 @@ void ColorNotebook::init() GtkWidget *item = gtk_check_menu_item_new_with_label (_(entry->name)); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), entry->enabledFull); gtk_widget_show (item); - gtk_menu_append (menu, item); + gtk_menu_shell_append (GTK_MENU_SHELL(menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_color_notebook_menuitem_response), -- cgit v1.2.3 From 49998c62a04c371d3b9951daa6447cd1de8ba7f8 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 26 Jun 2011 02:00:32 +0100 Subject: Gtk cleanup: gtk_object_get_data (bzr r10350.1.8) --- src/desktop-events.cpp | 2 +- src/dialogs/clonetiler.cpp | 6 +-- src/dialogs/export.cpp | 102 +++++++++++++++++++------------------- src/dialogs/find.cpp | 54 ++++++++++---------- src/dialogs/item-properties.cpp | 46 ++++++++--------- src/dialogs/spellcheck.cpp | 14 +++--- src/helper/unit-menu.cpp | 2 +- src/ui/context-menu.cpp | 24 ++++----- src/widgets/desktop-widget.cpp | 14 +++--- src/widgets/gradient-vector.cpp | 2 +- src/widgets/paint-selector.cpp | 14 +++--- src/widgets/sp-color-scales.cpp | 2 +- src/widgets/spinbutton-events.cpp | 8 +-- src/widgets/spw-utilities.cpp | 4 +- src/widgets/toolbox.cpp | 30 +++++------ 15 files changed, 162 insertions(+), 162 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index eb2b3a093..bbc7d10c5 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -231,7 +231,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) gint ret = FALSE; SPGuide *guide = SP_GUIDE(data); - SPDesktop *desktop = static_cast(gtk_object_get_data(GTK_OBJECT(item->canvas), "SPDesktop")); + SPDesktop *desktop = static_cast(g_object_get_data(G_OBJECT(item->canvas), "SPDesktop")); switch (event->type) { case GDK_2BUTTON_PRESS: diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index df9ea3be7..79a378710 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1588,21 +1588,21 @@ static void clonetiler_reset_recursive(GtkWidget *w) { if (w && GTK_IS_OBJECT(w)) { { - int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "zeroable")); + int r = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(w), "zeroable")); if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w)); gtk_adjustment_set_value (a, 0); } } { - int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "oneable")); + int r = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(w), "oneable")); if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w)); gtk_adjustment_set_value (a, 1); } } { - int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "uncheckable")); + int r = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(w), "uncheckable")); if (r && GTK_IS_TOGGLE_BUTTON(w)) { // checkbox gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(w), FALSE); } diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index f278a0573..77447b658 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -388,7 +388,7 @@ gchar* create_filepath_from_id (const gchar *id, const gchar *file_entry_text) { static void batch_export_clicked (GtkWidget *widget, GtkObject *base) { - Gtk::Widget *vb_singleexport = (Gtk::Widget *)gtk_object_get_data(base, "vb_singleexport"); + Gtk::Widget *vb_singleexport = (Gtk::Widget *)g_object_get_data(G_OBJECT(base), "vb_singleexport"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) { vb_singleexport->set_sensitive(false); } else { @@ -678,8 +678,8 @@ static void sp_export_update_checkbuttons (GtkObject *base) { gint num = g_slist_length((GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()); - GtkWidget *be = (GtkWidget *)gtk_object_get_data(base, "batch_checkbox"); - GtkWidget *he = (GtkWidget *)gtk_object_get_data(base, "hide_checkbox"); + GtkWidget *be = (GtkWidget *)g_object_get_data(G_OBJECT(base), "batch_checkbox"); + GtkWidget *he = (GtkWidget *)g_object_get_data(G_OBJECT(base), "hide_checkbox"); if (num >= 2) { gtk_widget_set_sensitive (be, true); gtk_button_set_label (GTK_BUTTON(be), g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -744,25 +744,25 @@ sp_export_selection_changed ( Inkscape::Application *inkscape, GtkObject *base ) { selection_type current_key; - current_key = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); + current_key = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); if ((current_key == SELECTION_DRAWING || current_key == SELECTION_PAGE) && (sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false && was_empty) { gtk_toggle_button_set_active - ( GTK_TOGGLE_BUTTON ( gtk_object_get_data (base, selection_names[SELECTION_SELECTION])), + ( GTK_TOGGLE_BUTTON ( g_object_get_data (G_OBJECT(base), selection_names[SELECTION_SELECTION])), TRUE ); } was_empty = (sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty(); - current_key = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); + current_key = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); if (inkscape && SP_IS_INKSCAPE (inkscape) && selection && SELECTION_CUSTOM != current_key) { GtkToggleButton * button; - button = (GtkToggleButton *)gtk_object_get_data(base, selection_names[current_key]); + button = (GtkToggleButton *)g_object_get_data(G_OBJECT(base), selection_names[current_key]); sp_export_area_toggled(button, base); } @@ -776,7 +776,7 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, GtkObject *base ) { selection_type current_key; - current_key = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); + current_key = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); switch (current_key) { case SELECTION_DRAWING: @@ -811,12 +811,12 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, static void sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) { - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; selection_type key, old_key; - key = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (tb), "key"))); - old_key = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); + key = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT (tb), "key"))); + old_key = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); /* Ignore all "turned off" events unless we're the only active button */ if (!gtk_toggle_button_get_active (tb) ) { @@ -835,7 +835,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) if (old_key != key) { gtk_toggle_button_set_active - ( GTK_TOGGLE_BUTTON ( gtk_object_get_data (base, selection_names[old_key])), + ( GTK_TOGGLE_BUTTON ( g_object_get_data (G_OBJECT(base), selection_names[old_key])), FALSE ); } @@ -898,12 +898,12 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) } // end of if ( SP_ACTIVE_DESKTOP ) - if (SP_ACTIVE_DESKTOP && !gtk_object_get_data(GTK_OBJECT(base), "filename-modified")) { + if (SP_ACTIVE_DESKTOP && !g_object_get_data(G_OBJECT(base), "filename-modified")) { GtkWidget * file_entry; const gchar * filename = NULL; float xdpi = 0.0, ydpi = 0.0; - file_entry = (GtkWidget *)gtk_object_get_data (base, "filename"); + file_entry = (GtkWidget *)g_object_get_data (G_OBJECT(base), "filename"); switch (key) { case SELECTION_PAGE: @@ -1089,8 +1089,8 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) SPNamedView *nv = sp_desktop_namedview(SP_ACTIVE_DESKTOP); SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - GtkWidget *be = (GtkWidget *)gtk_object_get_data(base, "batch_checkbox"); - GtkWidget *he = (GtkWidget *)gtk_object_get_data(base, "hide_checkbox"); + GtkWidget *be = (GtkWidget *)g_object_get_data(G_OBJECT(base), "batch_checkbox"); + GtkWidget *he = (GtkWidget *)g_object_get_data(G_OBJECT(base), "hide_checkbox"); bool hide = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (he)); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (be))) { // Batch export of selected objects @@ -1162,7 +1162,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } else { - GtkWidget *fe = (GtkWidget *)gtk_object_get_data(base, "filename"); + GtkWidget *fe = (GtkWidget *)g_object_get_data(G_OBJECT(base), "filename"); gchar const *filename = gtk_entry_get_text(GTK_ENTRY(fe)); float const x0 = sp_export_value_get_px(base, "x0"); @@ -1238,7 +1238,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) g_object_set_data (G_OBJECT (base), "cancel", (gpointer) 0); /* Setup the values in the document */ - switch ((selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type")))) { + switch ((selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type")))) { case SELECTION_PAGE: case SELECTION_DRAWING: { SPDocument * doc = SP_ACTIVE_DOCUMENT; @@ -1475,7 +1475,7 @@ sp_export_detect_size(GtkObject * base) { Geom::Rect current_bbox(x, y); //std::cout << "Current " << current_bbox; - this_test[0] = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); + this_test[0] = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); for (int i = 0; i < SELECTION_NUMBER_OF; i++) { this_test[i + 1] = test_order[i]; } @@ -1538,9 +1538,9 @@ sp_export_detect_size(GtkObject * base) { /* We're now using a custom size, not a fixed one */ /* printf("Detecting state: %s\n", selection_names[key]); */ - selection_type old = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type"))); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gtk_object_get_data(base, selection_names[old])), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gtk_object_get_data(base, selection_names[key])), TRUE); + selection_type old = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(g_object_get_data(G_OBJECT(base), selection_names[old])), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(g_object_get_data(G_OBJECT(base), selection_names[key])), TRUE); g_object_set_data(G_OBJECT(base), "selection-type", (gpointer)key); return; @@ -1552,11 +1552,11 @@ sp_export_area_x_value_changed (GtkAdjustment *adj, GtkObject *base) { float x0, x1, xdpi, width; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1572,7 +1572,7 @@ sp_export_area_x_value_changed (GtkAdjustment *adj, GtkObject *base) if (width < SP_EXPORT_MIN_SIZE) { const gchar *key; width = SP_EXPORT_MIN_SIZE; - key = (const gchar *)gtk_object_get_data (GTK_OBJECT (adj), "key"); + key = (const gchar *)g_object_get_data(G_OBJECT (adj), "key"); if (!strcmp (key, "x0")) { x1 = x0 + width * DPI_BASE / xdpi; @@ -1599,11 +1599,11 @@ sp_export_area_y_value_changed (GtkAdjustment *adj, GtkObject *base) { float y0, y1, ydpi, height; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1619,7 +1619,7 @@ sp_export_area_y_value_changed (GtkAdjustment *adj, GtkObject *base) if (height < SP_EXPORT_MIN_SIZE) { const gchar *key; height = SP_EXPORT_MIN_SIZE; - key = (const gchar *)gtk_object_get_data (GTK_OBJECT (adj), "key"); + key = (const gchar *)g_object_get_data(G_OBJECT (adj), "key"); if (!strcmp (key, "y0")) { y1 = y0 + height * DPI_BASE / ydpi; sp_export_value_set_px (base, "y1", y1); @@ -1645,11 +1645,11 @@ sp_export_area_width_value_changed (GtkAdjustment */*adj*/, GtkObject *base) { float x0, x1, xdpi, width, bmwidth; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) { + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1683,11 +1683,11 @@ sp_export_area_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) float y0, y1, ydpi, height, bmheight; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) { + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1765,11 +1765,11 @@ sp_export_bitmap_width_value_changed (GtkAdjustment */*adj*/, GtkObject *base) { float x0, x1, bmwidth, xdpi; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) { + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1800,11 +1800,11 @@ sp_export_bitmap_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) { float y0, y1, bmheight, xdpi; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) { + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1862,11 +1862,11 @@ sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base) { float x0, x1, xdpi, bmwidth; - if (gtk_object_get_data (base, "update")) + if (g_object_get_data (G_OBJECT(base), "update")) return; - if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data - (base, "units"))) { + if (sp_unit_selector_update_test ((SPUnitSelector *)g_object_get_data + (G_OBJECT(base), "units"))) { return; } @@ -1930,8 +1930,8 @@ sp_export_set_area ( GtkObject *base, double x0, double y0, double x1, double y1 sp_export_value_set_px (base, "y0", y0); g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (FALSE) ); - sp_export_area_x_value_changed ((GtkAdjustment *)gtk_object_get_data (base, "x1"), base); - sp_export_area_y_value_changed ((GtkAdjustment *)gtk_object_get_data (base, "y1"), base); + sp_export_area_x_value_changed ((GtkAdjustment *)g_object_get_data (G_OBJECT(base), "x1"), base); + sp_export_area_y_value_changed ((GtkAdjustment *)g_object_get_data (G_OBJECT(base), "y1"), base); return; } @@ -1951,7 +1951,7 @@ sp_export_value_set ( GtkObject *base, const gchar *key, double val ) { GtkAdjustment *adj; - adj = (GtkAdjustment *)gtk_object_get_data (base, key); + adj = (GtkAdjustment *)g_object_get_data (G_OBJECT(base), key); gtk_adjustment_set_value (adj, val); } @@ -1970,7 +1970,7 @@ sp_export_value_set ( GtkObject *base, const gchar *key, double val ) static void sp_export_value_set_px (GtkObject *base, const gchar *key, double val) { - const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)gtk_object_get_data (base, "units") ); + const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)g_object_get_data (G_OBJECT(base), "units") ); sp_export_value_set (base, key, sp_pixels_get_units (val, *unit)); @@ -1991,7 +1991,7 @@ sp_export_value_get ( GtkObject *base, const gchar *key ) { GtkAdjustment *adj; - adj = (GtkAdjustment *)gtk_object_get_data (base, key); + adj = (GtkAdjustment *)g_object_get_data (G_OBJECT(base), key); return adj->value; } @@ -2012,7 +2012,7 @@ static float sp_export_value_get_px ( GtkObject *base, const gchar *key ) { float value = sp_export_value_get(base, key); - const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)gtk_object_get_data (base, "units")); + const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)g_object_get_data (G_OBJECT(base), "units")); return sp_units_get_pixels (value, *unit); } // end of sp_export_value_get_px() diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index dae2dc373..b30671114 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -193,7 +193,7 @@ bool item_attr_match(SPItem *item, const gchar *name, bool exact) GSList * filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_function)(SPItem *, const gchar *, bool), bool exact) { - GtkWidget *widget = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (dlg), field)); + GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), field)); const gchar *text = gtk_entry_get_text (GTK_ENTRY(widget)); if (strlen (text) != 0) { @@ -215,7 +215,7 @@ filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_funct bool type_checkbox (GtkWidget *widget, const gchar *data) { - return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (widget), data))); + return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (widget), data))); } bool @@ -260,9 +260,9 @@ item_type_match (SPItem *item, GtkWidget *widget) GSList * filter_types (GSList *l, GObject *dlg, bool (*match_function)(SPItem *, GtkWidget *)) { - GtkWidget *widget = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (dlg), "types")); + GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), "types")); - GtkWidget *alltypes = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (widget), "all")); + GtkWidget *alltypes = GTK_WIDGET (g_object_get_data(G_OBJECT (widget), "all")); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (alltypes))) return l; @@ -341,18 +341,18 @@ void sp_find_dialog_find(GObject *, GObject *dlg) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - bool hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includehidden"))); - bool locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includelocked"))); + bool hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (dlg), "includehidden"))); + bool locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (dlg), "includelocked"))); GSList *l = NULL; - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inselection")))) { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (dlg), "inselection")))) { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (dlg), "inlayer")))) { l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked); } else { l = all_selection_items (desktop->selection, l, NULL, hidden, locked); } } else { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (dlg), "inlayer")))) { l = all_items (desktop->currentLayer(), l, hidden, locked); } else { l = all_items(sp_desktop_document(desktop)->getRoot(), l, hidden, locked); @@ -389,7 +389,7 @@ void sp_find_dialog_find(GObject *, GObject *dlg) void sp_find_reset_searchfield (GObject *dlg, const gchar *field) { - GtkWidget *widget = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (dlg), field)); + GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), field)); gtk_entry_set_text (GTK_ENTRY(widget), ""); } @@ -402,8 +402,8 @@ sp_find_dialog_reset (GObject *, GObject *dlg) sp_find_reset_searchfield (dlg, "style"); sp_find_reset_searchfield (dlg, "attr"); - GtkWidget *types = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (dlg), "types")); - GtkToggleButton *tb = GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (types), "all")); + GtkWidget *types = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), "types")); + GtkToggleButton *tb = GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (types), "all")); gtk_toggle_button_toggled (tb); gtk_toggle_button_set_active (tb, TRUE); } @@ -444,22 +444,22 @@ sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gch void toggle_alltypes (GtkToggleButton *tb, gpointer data) { - GtkWidget *alltypes_pane = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (data), "all-pane")); + GtkWidget *alltypes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "all-pane")); if (gtk_toggle_button_get_active (tb)) { gtk_widget_hide_all (alltypes_pane); } else { gtk_widget_show_all (alltypes_pane); // excplicit toggle to make sure its handler gets called, no matter what was the original state - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "shapes"))); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "shapes")), TRUE); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "paths")), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "texts")), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "groups")), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "clones")), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "images")), TRUE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "offsets")), TRUE); + gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "shapes"))); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "shapes")), TRUE); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "paths")), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "texts")), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "groups")), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "clones")), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "images")), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "offsets")), TRUE); } sp_find_squeeze_window(); } @@ -467,15 +467,15 @@ toggle_alltypes (GtkToggleButton *tb, gpointer data) void toggle_shapes (GtkToggleButton *tb, gpointer data) { - GtkWidget *shapes_pane = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (data), "shapes-pane")); + GtkWidget *shapes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "shapes-pane")); if (gtk_toggle_button_get_active (tb)) { gtk_widget_hide_all (shapes_pane); } else { gtk_widget_show_all (shapes_pane); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "rects")), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "ellipses")), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "stars")), FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (data), "spirals")), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "rects")), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "ellipses")), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "stars")), FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "spirals")), FALSE); } sp_find_squeeze_window(); } diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 34e7746fa..0c81d8b3c 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -275,7 +275,7 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) { g_assert (selection != NULL); - if (gtk_object_get_data (GTK_OBJECT (spw), "blocked")) + if (g_object_get_data(G_OBJECT (spw), "blocked")) return; if (!selection->singleItem()) { @@ -290,46 +290,46 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) SPItem *item = selection->singleItem(); /* Sensitive */ - GtkWidget *w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "sensitive")); + GtkWidget *w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "sensitive")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), item->isLocked()); /* Hidden */ - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "hidden")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "hidden")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), item->isExplicitlyHidden()); if (item->cloned) { /* ID */ - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "id")); gtk_entry_set_text (GTK_ENTRY (w), ""); gtk_widget_set_sensitive (w, FALSE); - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "id_label")); gtk_label_set_text (GTK_LABEL (w), _("Ref")); /* Label */ - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "label")); gtk_entry_set_text (GTK_ENTRY (w), ""); gtk_widget_set_sensitive (w, FALSE); - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label_label")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "label_label")); gtk_label_set_text (GTK_LABEL (w), _("Ref")); } else { SPObject *obj = (SPObject*)item; /* ID */ - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "id")); gtk_entry_set_text (GTK_ENTRY (w), obj->getId()); gtk_widget_set_sensitive (w, TRUE); - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "id_label")); gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_ID:")); /* Label */ - w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "label")); gtk_entry_set_text (GTK_ENTRY (w), obj->defaultLabel()); gtk_widget_set_sensitive (w, TRUE); /* Title */ - w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "title")); gchar *title = obj->title(); if (title) { gtk_entry_set_text(GTK_ENTRY(w), title); @@ -339,7 +339,7 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) gtk_widget_set_sensitive(w, TRUE); /* Description */ - w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "desc")); GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w)); gchar *desc = obj->desc(); if (desc) { @@ -348,12 +348,12 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) } else { gtk_text_buffer_set_text(buf, "", 0); } - w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc_frame")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "desc_frame")); gtk_widget_set_sensitive(w, TRUE); - w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity")); + w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "interactivity")); - GtkWidget* int_table = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity_table")); + GtkWidget* int_table = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "interactivity_table")); if (int_table){ gtk_container_remove(GTK_CONTAINER(w), int_table); } @@ -378,7 +378,7 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) static void sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) { - if (gtk_object_get_data (GTK_OBJECT (spw), "blocked")) + if (g_object_get_data(G_OBJECT (spw), "blocked")) return; SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); @@ -397,7 +397,7 @@ sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) void sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) { - if (gtk_object_get_data (GTK_OBJECT (spw), "blocked")) + if (g_object_get_data(G_OBJECT (spw), "blocked")) return; SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); @@ -416,7 +416,7 @@ sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) static void sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) { - if (gtk_object_get_data (GTK_OBJECT (spw), "blocked")) + if (g_object_get_data(G_OBJECT (spw), "blocked")) return; SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); @@ -425,10 +425,10 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE)); /* Retrieve the label widget for the object's id */ - GtkWidget *id_entry = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id")); + GtkWidget *id_entry = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "id")); gchar *id = (gchar *) gtk_entry_get_text (GTK_ENTRY (id_entry)); g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_'); - GtkWidget *id_label = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label")); + GtkWidget *id_label = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "id_label")); if (!strcmp (id, item->getId())) { gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_ID:")); } else if (!*id || !isalnum (*id)) { @@ -445,7 +445,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) } /* Retrieve the label widget for the object's label */ - GtkWidget *label_entry = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label")); + GtkWidget *label_entry = GTK_WIDGET(g_object_get_data(G_OBJECT (spw), "label")); gchar *label = (gchar *)gtk_entry_get_text (GTK_ENTRY (label_entry)); g_assert(label != NULL); @@ -460,14 +460,14 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) } /* Retrieve the title */ - GtkWidget *w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title")); + GtkWidget *w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "title")); gchar *title = (gchar *)gtk_entry_get_text(GTK_ENTRY (w)); if (obj->setTitle(title)) DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object title")); /* Retrieve the description */ - GtkTextView *tv = GTK_TEXT_VIEW(gtk_object_get_data(GTK_OBJECT(spw), "desc")); + GtkTextView *tv = GTK_TEXT_VIEW(g_object_get_data(G_OBJECT(spw), "desc")); GtkTextBuffer *buf = gtk_text_view_get_buffer(tv); GtkTextIter start, end; gtk_text_buffer_get_bounds(buf, &start, &end); diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index ebe87ede9..5de0bc6fe 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -287,7 +287,7 @@ SPItem *spellcheck_get_text (SPObject *root) void spellcheck_sensitive (const gchar *cookie, gboolean gray) { - GtkWidget *l = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (dlg), cookie)); + GtkWidget *l = GTK_WIDGET(g_object_get_data(G_OBJECT (dlg), cookie)); gtk_widget_set_sensitive(l, gray); } @@ -445,7 +445,7 @@ spellcheck_finished () spellcheck_sensitive("b_start", TRUE); { - GtkWidget *l = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (dlg), "banner")); + GtkWidget *l = GTK_WIDGET(g_object_get_data(G_OBJECT (dlg), "banner")); gchar *label; if (_stops) label = g_strdup_printf(_("Finished, %d words added to dictionary"), _adds); @@ -557,7 +557,7 @@ spellcheck_next_word() // display it in window { - GtkWidget *l = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (dlg), "banner")); + GtkWidget *l = GTK_WIDGET(g_object_get_data(G_OBJECT (dlg), "banner")); Glib::ustring langs = _lang; if (_lang2) langs = langs + ", " + _lang2; @@ -641,7 +641,7 @@ spellcheck_next_word() // get suggestions { GtkTreeView *tree_view = - GTK_TREE_VIEW(gtk_object_get_data (GTK_OBJECT (dlg), "suggestions")); + GTK_TREE_VIEW(g_object_get_data(G_OBJECT (dlg), "suggestions")); GtkListStore *model = gtk_list_store_new (1, G_TYPE_STRING); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); @@ -714,7 +714,7 @@ spellcheck_delete_last_rect () void do_spellcheck () { - GtkWidget *l = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (dlg), "banner")); + GtkWidget *l = GTK_WIDGET(g_object_get_data(G_OBJECT (dlg), "banner")); gtk_label_set_markup (GTK_LABEL(l), _("Checking...")); gtk_widget_queue_draw(GTK_WIDGET(dlg)); gdk_window_process_updates(GTK_WIDGET(dlg)->window, TRUE); @@ -770,7 +770,7 @@ sp_spellcheck_accept (GObject *, GObject *dlg) { // insert chosen suggestion GtkTreeView *tv = - GTK_TREE_VIEW(gtk_object_get_data (GTK_OBJECT (dlg), "suggestions")); + GTK_TREE_VIEW(g_object_get_data(G_OBJECT (dlg), "suggestions")); GtkTreeSelection *ts = gtk_tree_view_get_selection(tv); GtkTreeModel *model = 0; GtkTreeIter iter; @@ -820,7 +820,7 @@ sp_spellcheck_add (GObject */*obj*/, GObject */*dlg*/) { _adds++; GtkComboBox *cbox = - GTK_COMBO_BOX(gtk_object_get_data (GTK_OBJECT (dlg), "addto_langs")); + GTK_COMBO_BOX(g_object_get_data(G_OBJECT (dlg), "addto_langs")); gint num = gtk_combo_box_get_active(cbox); switch (num) { case 0: diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index 80ea216b3..dc65c3d14 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -163,7 +163,7 @@ sp_unit_selector_get_unit(SPUnitSelector const *us) static void spus_unit_activate(GtkWidget *widget, SPUnitSelector *us) { - SPUnit const *unit = (SPUnit const *) gtk_object_get_data(GTK_OBJECT(widget), "unit"); + SPUnit const *unit = (SPUnit const *) g_object_get_data(G_OBJECT(widget), "unit"); g_return_if_fail(unit != NULL); #ifdef UNIT_SELECTOR_VERBOSE diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 2f41b3fde..4d2c242a6 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -189,7 +189,7 @@ sp_item_properties(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_desktop_selection(desktop)->set(item); @@ -205,7 +205,7 @@ sp_set_mask(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_set_mask(desktop, false, false); @@ -219,7 +219,7 @@ sp_release_mask(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_unset_mask(desktop, false); @@ -233,7 +233,7 @@ sp_set_clip(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_set_mask(desktop, true, false); @@ -247,7 +247,7 @@ sp_release_clip(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_unset_mask(desktop, true); @@ -261,7 +261,7 @@ sp_item_select_this(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_desktop_selection(desktop)->set(item); @@ -273,7 +273,7 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); g_assert(!SP_IS_ANCHOR(item)); - SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); @@ -325,7 +325,7 @@ sp_item_group_ungroup_activate(GtkMenuItem *menuitem, SPGroup *group) g_assert(SP_IS_GROUP(group)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); children = NULL; @@ -495,7 +495,7 @@ static void sp_image_image_edit(GtkMenuItem *menuitem, SPAnchor *anchor) if ( errThing ) { g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message); - SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, errThing->message); g_error_free(errThing); errThing = 0; @@ -511,7 +511,7 @@ sp_fill_settings(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { @@ -548,7 +548,7 @@ sp_text_settings(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { @@ -567,7 +567,7 @@ sp_spellcheck_settings(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 98c678194..e7bc3691b 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -629,7 +629,7 @@ sp_desktop_widget_destroy (GtkObject *object) void SPDesktopWidget::updateTitle(gchar const* uri) { - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (window) { gchar const *fname = ( TRUE @@ -907,7 +907,7 @@ SPDesktopWidget::shutdown() switch (response) { case GTK_RESPONSE_YES: { - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); doc->doRef(); sp_namedview_document_from_window(desktop); @@ -968,7 +968,7 @@ SPDesktopWidget::shutdown() { doc->doRef(); - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (sp_file_save_dialog(*window, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG)) { doc->doUnref(); @@ -1080,7 +1080,7 @@ SPDesktopWidget::getWindowGeometry (gint &x, gint &y, gint &w, gint &h) gboolean vis = gtk_widget_get_visible (GTK_WIDGET(this)); (void)vis; // TODO figure out why it is here but not used. - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (window) { @@ -1092,7 +1092,7 @@ SPDesktopWidget::getWindowGeometry (gint &x, gint &y, gint &w, gint &h) void SPDesktopWidget::setWindowPosition (Geom::Point p) { - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (window) { @@ -1103,7 +1103,7 @@ SPDesktopWidget::setWindowPosition (Geom::Point p) void SPDesktopWidget::setWindowSize (gint w, gint h) { - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (window) { @@ -1121,7 +1121,7 @@ SPDesktopWidget::setWindowSize (gint w, gint h) void SPDesktopWidget::setWindowTransient (void *p, int transient_policy) { - Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); + Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (window) { GtkWindow *w = (GtkWindow *) window->gobj(); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index ceb6f5c06..310002b54 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -610,7 +610,7 @@ static void sp_grad_edit_select(GtkOptionMenu *mnu, GtkWidget *tbl) GtkWidget *offspin = GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "offspn")); GtkWidget *offslide =GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "offslide")); - GtkAdjustment *adj = static_cast(gtk_object_get_data(GTK_OBJECT(tbl), "offset")); + GtkAdjustment *adj = static_cast(g_object_get_data(G_OBJECT(tbl), "offset")); bool isEndStop = false; diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 60ce6beff..fa4684825 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -127,7 +127,7 @@ static SPGradientSelector *getGradientFromData(SPPaintSelector const *psel) grad = swatchsel->getGradientSelector(); } } else { - grad = reinterpret_cast(gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector")); + grad = reinterpret_cast(g_object_get_data(G_OBJECT(psel->selector), "gradient-selector")); } return grad; } @@ -323,7 +323,7 @@ static void sp_paint_selector_style_button_toggled(GtkToggleButton *tb, SPPaintSelector *psel) { if (!psel->update && gtk_toggle_button_get_active(tb)) { - psel->setMode(static_cast(GPOINTER_TO_UINT(gtk_object_get_data(GTK_OBJECT(tb), "mode")))); + psel->setMode(static_cast(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(tb), "mode")))); } } @@ -440,7 +440,7 @@ void SPPaintSelector::setColorAlpha(SPColor const &color, float alpha) setMode(MODE_COLOR_RGB); } - csel = reinterpret_cast(gtk_object_get_data(GTK_OBJECT(selector), "color-selector")); + csel = reinterpret_cast(g_object_get_data(G_OBJECT(selector), "color-selector")); rgba = color.toRGBA32( alpha ); csel->base->setColorAlpha( color, alpha ); } @@ -646,7 +646,7 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec if ((psel->mode == SPPaintSelector::MODE_COLOR_RGB) || (psel->mode == SPPaintSelector::MODE_COLOR_CMYK)) { /* Already have color selector */ - csel = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(psel->selector), "color-selector"); + csel = (GtkWidget*)g_object_get_data(G_OBJECT(psel->selector), "color-selector"); } else { sp_paint_selector_clear_frame(psel); @@ -716,7 +716,7 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe if ((psel->mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (psel->mode == SPPaintSelector::MODE_GRADIENT_RADIAL)) { /* Already have gradient selector */ - gsel = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector"); + gsel = (GtkWidget*)g_object_get_data(G_OBJECT(psel->selector), "gradient-selector"); } else { sp_paint_selector_clear_frame(psel); /* Create new gradient selector */ @@ -943,7 +943,7 @@ void SPPaintSelector::updatePatternList( SPPattern *pattern ) /* Set history */ - if (pattern && !gtk_object_get_data(GTK_OBJECT(mnu), "update")) { + if (pattern && !g_object_get_data(G_OBJECT(mnu), "update")) { g_object_set_data(G_OBJECT(mnu), "update", GINT_TO_POINTER(TRUE)); @@ -984,7 +984,7 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel if (psel->mode == SPPaintSelector::MODE_PATTERN) { /* Already have pattern menu */ - tbl = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(psel->selector), "pattern-selector"); + tbl = (GtkWidget*)g_object_get_data(G_OBJECT(psel->selector), "pattern-selector"); } else { sp_paint_selector_clear_frame(psel); diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 2b80fac9a..146ea9e1e 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -538,7 +538,7 @@ guint ColorScales::getSubmode() const void ColorScales::_adjustmentAnyChanged( GtkAdjustment *adjustment, SPColorScales *cs ) { - gint channel = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (adjustment), "channel")); + gint channel = GPOINTER_TO_INT (g_object_get_data(G_OBJECT (adjustment), "channel")); _adjustmentChanged(cs, channel); } diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp index 70fa3a54d..994d954cc 100644 --- a/src/widgets/spinbutton-events.cpp +++ b/src/widgets/spinbutton-events.cpp @@ -27,7 +27,7 @@ spinbutton_focus_in (GtkWidget *w, GdkEventKey */*event*/, gpointer /*data*/) { gdouble *ini; - ini = (gdouble *) gtk_object_get_data (GTK_OBJECT (w), "ini"); + ini = (gdouble *) g_object_get_data(G_OBJECT (w), "ini"); if (ini) g_free (ini); // free the old value if any // retrieve the value @@ -43,7 +43,7 @@ spinbutton_focus_in (GtkWidget *w, GdkEventKey */*event*/, gpointer /*data*/) void spinbutton_undo (GtkWidget *w) { - gdouble *ini = (gdouble *) gtk_object_get_data (GTK_OBJECT (w), "ini"); + gdouble *ini = (gdouble *) g_object_get_data(G_OBJECT (w), "ini"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), *ini); } @@ -51,11 +51,11 @@ void spinbutton_defocus (GtkObject *container) { // defocus spinbuttons by moving focus to the canvas, unless "stay" is on - gboolean stay = GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (container), "stay")); + gboolean stay = GPOINTER_TO_INT(g_object_get_data(G_OBJECT (container), "stay")); if (stay) { g_object_set_data (G_OBJECT (container), "stay", GINT_TO_POINTER (FALSE)); } else { - GtkWidget *canvas = (GtkWidget *) gtk_object_get_data (GTK_OBJECT (container), "dtw"); + GtkWidget *canvas = (GtkWidget *) g_object_get_data(G_OBJECT (container), "dtw"); if (canvas) { gtk_widget_grab_focus (GTK_WIDGET(canvas)); } diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index a5c60c382..2225f2c57 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -235,7 +235,7 @@ sp_search_by_data_recursive (GtkWidget *w, gpointer key) gpointer r = NULL; if (w && GTK_IS_OBJECT(w)) { - r = gtk_object_get_data (GTK_OBJECT(w), (gchar *) key); + r = g_object_get_data(G_OBJECT(w), (gchar *) key); } if (r) return r; @@ -260,7 +260,7 @@ sp_search_by_value_recursive (GtkWidget *w, gchar *key, gchar *value) GtkWidget *child; if (w && GTK_IS_OBJECT(w)) { - r = (gchar *) gtk_object_get_data (GTK_OBJECT(w), key); + r = (gchar *) g_object_get_data(G_OBJECT(w), key); } if (r && !strcmp (r, value)) return w; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index d2751a24b..dc3fc3eb1 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2808,10 +2808,10 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n bool isFlatSided = prefs->getBool("/tools/shapes/star/isflatsided", true); if (!strcmp(name, "inkscape:randomized")) { - adj = GTK_ADJUSTMENT( gtk_object_get_data(GTK_OBJECT(tbl), "randomized") ); + adj = GTK_ADJUSTMENT( g_object_get_data(G_OBJECT(tbl), "randomized") ); gtk_adjustment_set_value(adj, sp_repr_get_double_attribute(repr, "inkscape:randomized", 0.0)); } else if (!strcmp(name, "inkscape:rounded")) { - adj = GTK_ADJUSTMENT( gtk_object_get_data(GTK_OBJECT(tbl), "rounded") ); + adj = GTK_ADJUSTMENT( g_object_get_data(G_OBJECT(tbl), "rounded") ); gtk_adjustment_set_value(adj, sp_repr_get_double_attribute(repr, "inkscape:rounded", 0.0)); } else if (!strcmp(name, "inkscape:flatsided")) { GtkAction* prop_action = GTK_ACTION( g_object_get_data(G_OBJECT(tbl), "prop_action") ); @@ -2825,7 +2825,7 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n gtk_action_set_sensitive( prop_action, FALSE ); } } else if ((!strcmp(name, "sodipodi:r1") || !strcmp(name, "sodipodi:r2")) && (!isFlatSided) ) { - adj = (GtkAdjustment*)gtk_object_get_data(GTK_OBJECT(tbl), "proportion"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(tbl), "proportion"); gdouble r1 = sp_repr_get_double_attribute(repr, "sodipodi:r1", 1.0); gdouble r2 = sp_repr_get_double_attribute(repr, "sodipodi:r2", 1.0); if (r2 < r1) { @@ -2834,7 +2834,7 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n gtk_adjustment_set_value(adj, r1/r2); } } else if (!strcmp(name, "sodipodi:sides")) { - adj = (GtkAdjustment*)gtk_object_get_data(GTK_OBJECT(tbl), "magnitude"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(tbl), "magnitude"); gtk_adjustment_set_value(adj, sp_repr_get_int_attribute(repr, "sodipodi:sides", 0)); } @@ -3480,21 +3480,21 @@ static void box3d_resync_toolbar(Inkscape::XML::Node *persp_repr, GObject *data) return; } { - adj = GTK_ADJUSTMENT(gtk_object_get_data(GTK_OBJECT(tbl), "box3d_angle_x")); + adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "box3d_angle_x")); act = GTK_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_angle_x_action")); tact = &INK_TOGGLE_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_vp_x_state_action"))->action; box3d_set_button_and_adjustment(persp, Proj::X, adj, act, tact); } { - adj = GTK_ADJUSTMENT(gtk_object_get_data(GTK_OBJECT(tbl), "box3d_angle_y")); + adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "box3d_angle_y")); act = GTK_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_angle_y_action")); tact = &INK_TOGGLE_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_vp_y_state_action"))->action; box3d_set_button_and_adjustment(persp, Proj::Y, adj, act, tact); } { - adj = GTK_ADJUSTMENT(gtk_object_get_data(GTK_OBJECT(tbl), "box3d_angle_z")); + adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "box3d_angle_z")); act = GTK_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_angle_z_action")); tact = &INK_TOGGLE_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_vp_z_state_action"))->action; @@ -3861,15 +3861,15 @@ static void sp_spl_tb_defaults(GtkWidget * /*widget*/, GtkObject *obj) gdouble exp = 1.0; gdouble t0 = 0.0; - adj = (GtkAdjustment*)gtk_object_get_data(obj, "revolution"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "revolution"); gtk_adjustment_set_value(adj, rev); gtk_adjustment_value_changed(adj); - adj = (GtkAdjustment*)gtk_object_get_data(obj, "expansion"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "expansion"); gtk_adjustment_set_value(adj, exp); gtk_adjustment_value_changed(adj); - adj = (GtkAdjustment*)gtk_object_get_data(obj, "t0"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "t0"); gtk_adjustment_set_value(adj, t0); gtk_adjustment_value_changed(adj); @@ -3895,13 +3895,13 @@ static void spiral_tb_event_attr_changed(Inkscape::XML::Node *repr, g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE)); GtkAdjustment *adj; - adj = (GtkAdjustment*)gtk_object_get_data(GTK_OBJECT(tbl), "revolution"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(tbl), "revolution"); gtk_adjustment_set_value(adj, (sp_repr_get_double_attribute(repr, "sodipodi:revolution", 3.0))); - adj = (GtkAdjustment*)gtk_object_get_data(GTK_OBJECT(tbl), "expansion"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(tbl), "expansion"); gtk_adjustment_set_value(adj, (sp_repr_get_double_attribute(repr, "sodipodi:expansion", 1.0))); - adj = (GtkAdjustment*)gtk_object_get_data(GTK_OBJECT(tbl), "t0"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(tbl), "t0"); gtk_adjustment_set_value(adj, (sp_repr_get_double_attribute(repr, "sodipodi:t0", 0.0))); g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE)); @@ -4186,7 +4186,7 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GtkObject *obj) // fixme: make settable gdouble tolerance = 4; - adj = (GtkAdjustment*)gtk_object_get_data(obj, "tolerance"); + adj = (GtkAdjustment*)g_object_get_data(G_OBJECT(obj), "tolerance"); gtk_adjustment_set_value(adj, tolerance); gtk_adjustment_value_changed(adj); @@ -8186,7 +8186,7 @@ static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr, if ( !g_object_get_data(G_OBJECT(tbl), "freeze") && (strcmp(name, "inkscape:connector-spacing") == 0) ) { - GtkAdjustment *adj = static_cast(gtk_object_get_data(GTK_OBJECT(tbl), "spacing")); + GtkAdjustment *adj = static_cast(g_object_get_data(G_OBJECT(tbl), "spacing")); gdouble spacing = defaultConnSpacing; sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing); -- cgit v1.2.3 From 75493cd96255c87027c1de0cf721271f45146be9 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 25 Jun 2011 23:57:27 -0700 Subject: Whitespace cleanup. (bzr r10366) --- src/libcola/cola.h | 129 +++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/libcola/cola.h b/src/libcola/cola.h index eda64cb5f..136c527b6 100644 --- a/src/libcola/cola.h +++ b/src/libcola/cola.h @@ -32,12 +32,13 @@ namespace cola { void moveRectangles(double x, double y); Rectangle* getBoundingBox(); }; + // for a graph of n nodes, return connected components void connectedComponents( const vector &rs, const vector &es, const SimpleConstraints &scx, - const SimpleConstraints &scy, + const SimpleConstraints &scy, vector &components); // move the contents of each component so that the components do not @@ -48,11 +49,11 @@ namespace cola { // will be altered to prefer points u-b-v are in a linear arrangement // such that b is placed at u+t(v-u). struct LinearConstraint { - LinearConstraint(unsigned u, unsigned v, unsigned b, double w, + LinearConstraint(unsigned u, unsigned v, unsigned b, double w, double frac_ub, double frac_bv, - double* X, double* Y) + double* X, double* Y) : u(u),v(v),b(b),w(w),frac_ub(frac_ub),frac_bv(frac_bv), - tAtProjection(true) + tAtProjection(true) { assert(frac_ub<=1.0); assert(frac_bv<=1.0); @@ -88,7 +89,7 @@ namespace cola { dvv=t*t; dvb=-t; dbb=1; - //printf("New LC: t=%f\n",t); + //printf("New LC: t=%f\n",t); } unsigned u; unsigned v; @@ -108,61 +109,63 @@ namespace cola { double frac_bv; bool tAtProjection; }; + typedef vector LinearConstraints; - - class TestConvergence { - public: - double old_stress; - TestConvergence(const double& tolerance = 0.001, const unsigned maxiterations = 1000) - : tolerance(tolerance), - maxiterations(maxiterations) { reset(); } - virtual ~TestConvergence() {} - - virtual bool operator()(double new_stress, double* X, double* Y) { - //std::cout<<"iteration="< Date: Sun, 26 Jun 2011 11:23:06 +0100 Subject: Gtk cleanup: gtk_signal_connect_while_alive (bzr r10350.1.9) --- src/dialogs/xml-tree.cpp | 110 ++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 1b979b490..1a003c9c7 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -275,9 +275,6 @@ void sp_xml_tree_dialog() g_signal_connect_after( G_OBJECT(tree), "tree_move", G_CALLBACK(after_tree_move), NULL); - /* TODO: replace gtk_signal_connect_while_alive() with something - * else... - */ toolbar = gtk_toolbar_new(); gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0); @@ -291,17 +288,17 @@ void sp_xml_tree_dialog() G_CALLBACK(cmd_new_element_node), NULL); - gtk_signal_connect_while_alive( GTK_OBJECT(tree), + g_signal_connect_object (G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_element), button, - GTK_OBJECT(button)); + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), + g_signal_connect_object (G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), button, - GTK_OBJECT(button)); + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -312,17 +309,17 @@ void sp_xml_tree_dialog() G_CALLBACK(cmd_new_text_node), NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_element), button, - GTK_OBJECT(button)); + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), button, - GTK_OBJECT(button)); + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -333,15 +330,16 @@ void sp_xml_tree_dialog() G_CALLBACK(cmd_duplicate_node), NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_mutable), button, - GTK_OBJECT(button)); + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -353,12 +351,14 @@ void sp_xml_tree_dialog() INKSCAPE_ICON_XML_NODE_DELETE ), G_CALLBACK(cmd_delete_node), NULL ); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_mutable), - button, GTK_OBJECT(button)); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + button, + (GConnectFlags)0); + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); @@ -368,13 +368,15 @@ void sp_xml_tree_dialog() gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_IN), G_CALLBACK(cmd_unindent_node), NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_has_grandparent), - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -382,36 +384,42 @@ void sp_xml_tree_dialog() _("Indent node"), NULL, gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN), G_CALLBACK(cmd_indent_node), NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_indentable), - button, GTK_OBJECT(button)); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + button, + (GConnectFlags)0); + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_disable, - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "^", _("Raise node"), NULL, gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_IN), G_CALLBACK(cmd_raise_node), NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_not_first_child), - button, GTK_OBJECT(button)); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + button, + (GConnectFlags)0); + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "v", _("Lower node"), NULL, gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN), G_CALLBACK(cmd_lower_node), NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_not_last_child), - button, GTK_OBJECT(button)); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + button, + (GConnectFlags)0); + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, GTK_OBJECT(button)); + button, + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, TRUE, 0); @@ -453,17 +461,17 @@ void sp_xml_tree_dialog() INKSCAPE_ICON_XML_ATTRIBUTE_DELETE ), (GCallback) cmd_delete_attr, NULL); - gtk_signal_connect_while_alive(GTK_OBJECT(attributes), "select_row", + g_signal_connect_object(G_OBJECT(attributes), "select_row", (GCallback) on_attr_select_row_enable, button, - GTK_OBJECT(button)); + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(attributes), "unselect_row", + g_signal_connect_object(G_OBJECT(attributes), "unselect_row", (GCallback) on_attr_unselect_row_disable, button, - GTK_OBJECT(button)); + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_disable, button, - GTK_OBJECT(button)); + (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -573,23 +581,27 @@ void sp_xml_tree_dialog() gtk_widget_show_all(GTK_WIDGET(dlg)); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", (GCallback) on_tree_select_row_show_if_element, - attr_container, GTK_OBJECT(attr_container)); + attr_container, + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_hide, - attr_container, GTK_OBJECT(attr_container)); + attr_container, + (GConnectFlags)0); gtk_widget_hide(attr_container); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_select_row", + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", (GCallback) on_tree_select_row_show_if_text, - text_container, GTK_OBJECT(text_container)); + text_container, + (GConnectFlags)0); - gtk_signal_connect_while_alive(GTK_OBJECT(tree), "tree_unselect_row", + g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_hide, - text_container, GTK_OBJECT(text_container)); + text_container, + (GConnectFlags)0); gtk_widget_hide(text_container); -- cgit v1.2.3 From bdf703831ff93438d49324ab842052ccaf390a5d Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 26 Jun 2011 22:00:36 +0200 Subject: =?UTF-8?q?-=20Add=20a=20third=20group=20of=20snap=20sources/targe?= =?UTF-8?q?ts,=20called=20=C2=A8others=C2=A8=20(before=20we=20had=20only?= =?UTF-8?q?=20=C2=A8bounding=20box=C2=A8=20and=20nodes=20(see=20bug=20#788?= =?UTF-8?q?178)=20-=20Fix=20the=20display=20of=20the=20snap=20source=20-?= =?UTF-8?q?=20Fix=20snapping=20of=20guides=20to=20other=20guides=20&=20gri?= =?UTF-8?q?ds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r10372) --- src/attributes-test.h | 1 + src/attributes.cpp | 2 ++ src/attributes.h | 1 + src/display/canvas-axonomgrid.cpp | 2 +- src/display/canvas-grid.cpp | 2 +- src/display/snap-indicator.cpp | 6 ---- src/gradient-context.cpp | 2 +- src/object-snapper.cpp | 37 ++++++++++++------------ src/seltrans.cpp | 2 +- src/snap-enums.h | 8 ++--- src/snap-preferences.cpp | 27 +++++++++++++---- src/snap-preferences.h | 4 ++- src/snap.cpp | 4 +-- src/sp-ellipse.cpp | 4 +-- src/sp-namedview.cpp | 61 ++++++++++++++++++++------------------- src/sp-rect.cpp | 2 +- src/sp-shape.cpp | 2 +- src/sp-spiral.cpp | 2 +- src/sp-star.cpp | 2 +- src/text-context.cpp | 2 +- src/ui/icon-names.h | 2 ++ src/widgets/toolbox.cpp | 27 ++++++++++++++--- 22 files changed, 119 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/attributes-test.h b/src/attributes-test.h index 14696b845..6a9570c37 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -349,6 +349,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:snap-global", true}, {"inkscape:snap-bbox", true}, {"inkscape:snap-nodes", true}, + {"inkscape:snap-others", true}, {"inkscape:snap-from-guide", true}, {"inkscape:snap-center", true}, {"inkscape:snap-smooth-nodes", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index 118a90482..334c3447c 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -94,6 +94,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_SNAP_GLOBAL, "inkscape:snap-global"}, {SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"}, {SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"}, + {SP_ATTR_INKSCAPE_SNAP_OTHERS, "inkscape:snap-others"}, {SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, "inkscape:snap-from-guide"}, {SP_ATTR_INKSCAPE_SNAP_CENTER, "inkscape:snap-center"}, {SP_ATTR_INKSCAPE_SNAP_GRIDS, "inkscape:snap-grids"}, @@ -495,6 +496,7 @@ sp_attribute_lookup(gchar const *key) propdict = g_hash_table_new(g_str_hash, g_str_equal); for (i = 1; i < n_attrs; i++) { g_assert(props[i].code == static_cast< gint >(i) ); + // If this g_assert fails, then the sort order of SPAttributeEnum does not match the order in props[]! g_hash_table_insert(propdict, const_cast(static_cast(props[i].name)), GINT_TO_POINTER(props[i].code)); diff --git a/src/attributes.h b/src/attributes.h index 3755268d0..afa396507 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -94,6 +94,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_GLOBAL, SP_ATTR_INKSCAPE_SNAP_BBOX, SP_ATTR_INKSCAPE_SNAP_NODES, + SP_ATTR_INKSCAPE_SNAP_OTHERS, SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, SP_ATTR_INKSCAPE_SNAP_CENTER, SP_ATTR_INKSCAPE_SNAP_GRIDS, diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index a9893f09d..dbf7b424d 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -769,7 +769,7 @@ void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Poi bool CanvasAxonomGridSnapper::ThisSnapperMightSnap() const { - return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeBBoxOrNodes(); + return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeAny(); } diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 9a12a1d90..2a9e50e3d 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1072,7 +1072,7 @@ void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point c */ bool CanvasXYGridSnapper::ThisSnapperMightSnap() const { - return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeBBoxOrNodes(); + return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeAny(); } } // namespace Inkscape diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index c3198cd37..ec4b7e28f 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -138,9 +138,6 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_ELLIPSE_QUADRANT_POINT: target_name = _("quadrant point"); break; - case SNAPTARGET_CENTER: - target_name = _("center"); - break; case SNAPTARGET_CORNER: target_name = _("corner"); break; @@ -206,9 +203,6 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPSOURCE_ELLIPSE_QUADRANT_POINT: source_name = _("Quadrant point"); break; - case SNAPSOURCE_CENTER: - source_name = _("Center"); - break; case SNAPSOURCE_CORNER: source_name = _("Corner"); break; diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index a237bb3c6..33b82b9f4 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -602,7 +602,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point const motion_dt = event_context->desktop->w2d(motion_w); - m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE)); + m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_OTHER_HANDLE)); m.unSetup(); } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 682c26869..3088accd2 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -181,7 +181,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & Inkscape::SNAPSOURCE_OTHER_CATEGORY; + bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; // A point considered for snapping should be either a node, a bbox corner or a guide. Pick only ONE! g_assert(!((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))); @@ -359,7 +359,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX; bool p_is_a_node = source_type & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_other = source_type & Inkscape::SNAPSOURCE_OTHER_CATEGORY; + bool p_is_other = source_type & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; if (_snapmanager->snapprefs.getSnapToBBoxPath()) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -369,7 +369,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } // Consider the page border for snapping - if (_snapmanager->snapprefs.getSnapToPageBorder() && _snapmanager->snapprefs.getSnapModeBBoxOrNodes()) { + if (_snapmanager->snapprefs.getSnapToPageBorder() && _snapmanager->snapprefs.getSnapModeAny()) { Geom::PathVector *border_path = _getBorderPathv(); if (border_path != NULL) { _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); @@ -394,7 +394,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, //Build a list of all paths considered for snapping to //Add the item's path to snap to - if (_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode()) { + if (_snapmanager->snapprefs.getSnapToItemPath() && (_snapmanager->snapprefs.getSnapModeNode() || _snapmanager->snapprefs.getSnapModeOthers())) { if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node)) { // Snapping to the path of characters is very cool, but for a large // chunk of text this will take ages! So limit snapping to text paths @@ -438,7 +438,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } //Add the item's bounding box to snap to - if (_snapmanager->snapprefs.getSnapToBBoxPath() && _snapmanager->snapprefs.getSnapModeBBox()) { + if (_snapmanager->snapprefs.getSnapToBBoxPath() && (_snapmanager->snapprefs.getSnapModeBBox() || _snapmanager->snapprefs.getSnapModeOthers())) { if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) { // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time @@ -572,7 +572,6 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, // Now we can finally do the real snapping, using the paths collected above g_assert(_snapmanager->getDesktop() != NULL); - Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p_proj_on_constraint); Geom::Point direction_vector = c.getDirection(); if (!is_zero(direction_vector)) { @@ -674,16 +673,16 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() || - _snapmanager->snapprefs.getSnapObjectMidpoints() + _snapmanager->snapprefs.getSnapLineMidpoints() )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( _snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && ( + )) || (_snapmanager->snapprefs.getSnapModeAny() && ( _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapToPageBorder() - )); + _snapmanager->snapprefs.getSnapToPageBorder() || + _snapmanager->snapprefs.getSnapObjectMidpoints() + )) ; if (snap_nodes) { _snapNodes(sc, p, unselected_nodes); @@ -691,7 +690,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, if ((_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath()) || (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath()) || - (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && _snapmanager->snapprefs.getSnapToPageBorder())) { + (_snapmanager->snapprefs.getSnapModeAny() && _snapmanager->snapprefs.getSnapToPageBorder())) { unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size(); if (n > 0) { /* While editing a path in the node tool, findCandidates must ignore that path because @@ -741,14 +740,14 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() || - _snapmanager->snapprefs.getSnapObjectMidpoints() + _snapmanager->snapprefs.getSnapLineMidpoints() )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( _snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && ( + )) || (_snapmanager->snapprefs.getSnapModeAny() && ( _snapmanager->snapprefs.getIncludeItemCenter() || + _snapmanager->snapprefs.getSnapObjectMidpoints() || _snapmanager->snapprefs.getSnapToPageBorder() )); @@ -800,16 +799,16 @@ bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const _snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() || - _snapmanager->snapprefs.getSnapObjectMidpoints() + _snapmanager->snapprefs.getSnapLineMidpoints() )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && ( + )) || (_snapmanager->snapprefs.getSnapModeAny() && ( _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getIncludeItemCenter() + _snapmanager->snapprefs.getIncludeItemCenter() || + _snapmanager->snapprefs.getSnapObjectMidpoints() )); return (_snap_enabled && snap_to_something); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index bb333caca..f95a204a9 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -359,7 +359,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // points immediately. if (prefs->getBool("/options/snapclosestonly/value", false)) { - if (m.snapprefs.getSnapModeNode()) { + if (m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers()) { m.keepClosestPointOnly(_snap_points, p); } else { _snap_points.clear(); // don't keep any point diff --git a/src/snap-enums.h b/src/snap-enums.h index aa5db9328..8988589a1 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -39,7 +39,6 @@ enum SnapTargetType { SNAPTARGET_PAGE_CORNER, SNAPTARGET_CONVEX_HULL_CORNER, SNAPTARGET_ELLIPSE_QUADRANT_POINT, - SNAPTARGET_CENTER, // of ellipse SNAPTARGET_CORNER, // of image or of rectangle SNAPTARGET_TEXT_BASELINE, SNAPTARGET_CONSTRAINED_ANGLE, @@ -66,16 +65,15 @@ enum SnapSourceType { SNAPSOURCE_CONVEX_HULL_CORNER, SNAPSOURCE_ELLIPSE_QUADRANT_POINT, SNAPSOURCE_NODE_HANDLE, // eg. nodes in the path editor, handles of stars or rectangles, etc. (tied to a stroke) - SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, polygon, etc. //------------------------------------------------------------------- // Other points (e.g. guides, gradient knots) will snap to both bounding boxes and nodes - SNAPSOURCE_OTHER_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_OTHERS_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two SNAPSOURCE_ROTATION_CENTER, - SNAPSOURCE_CENTER, // of ellipse + SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, ellipses, polygon, etc. SNAPSOURCE_GUIDE, SNAPSOURCE_GUIDE_ORIGIN, SNAPSOURCE_TEXT_BASELINE, - SNAPSOURCE_OTHER_HANDLE, // eg. the handle of a gradient of a connector (ie not being tied to a stroke) + SNAPSOURCE_OTHER_HANDLE, // eg. the handle of a gradient or of a connector (ie not being tied to a stroke) SNAPSOURCE_GRID_PITCH, // eg. when pasting or alt-dragging in the selector tool; not realy a snap source }; diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 15c976466..816320145 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -27,7 +27,7 @@ Inkscape::SnapPreferences::SnapPreferences() : _snap_to_page_border(false), _strict_snapping(true) { - setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHER_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab + setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab } /* @@ -68,11 +68,26 @@ bool Inkscape::SnapPreferences::getSnapModeNode() const return (_snap_from & Inkscape::SNAPSOURCE_NODE_CATEGORY); } -bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const +void Inkscape::SnapPreferences::setSnapModeOthers(bool enabled) { - return (_snap_from & (Inkscape::SNAPSOURCE_BBOX_CATEGORY | Inkscape::SNAPSOURCE_NODE_CATEGORY) ); + if (enabled) { + _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHERS_CATEGORY); + } else { + _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); + } +} + +bool Inkscape::SnapPreferences::getSnapModeOthers() const +{ + return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } + +//bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const +//{ +// return (_snap_from & (Inkscape::SNAPSOURCE_BBOX_CATEGORY | Inkscape::SNAPSOURCE_NODE_CATEGORY) ); +//} + bool Inkscape::SnapPreferences::getSnapModeAny() const { return (_snap_from != 0); @@ -81,15 +96,15 @@ bool Inkscape::SnapPreferences::getSnapModeAny() const void Inkscape::SnapPreferences::setSnapModeGuide(bool enabled) { if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHER_CATEGORY); + _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHER_CATEGORY); + _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } } bool Inkscape::SnapPreferences::getSnapModeGuide() const { - return (_snap_from & Inkscape::SNAPSOURCE_OTHER_CATEGORY); + return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } /** diff --git a/src/snap-preferences.h b/src/snap-preferences.h index cc8f24503..4f3ad6ce6 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -26,10 +26,12 @@ public: void setSnapModeBBox(bool enabled); void setSnapModeNode(bool enabled); + void setSnapModeOthers(bool enabled); void setSnapModeGuide(bool enabled); bool getSnapModeBBox() const; bool getSnapModeNode() const; - bool getSnapModeBBoxOrNodes() const; + bool getSnapModeOthers() const; + //bool getSnapModeBBoxOrNodes() const; bool getSnapModeAny() const; bool getSnapModeGuide() const; diff --git a/src/snap.cpp b/src/snap.cpp index f8fe8e3fa..bf1613d2c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -916,7 +916,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // We might still need to apply a constraint though, if we tried a constrained snap. And // in case of a free snap we might have use for the transformed point, so let's return that // point, whether it's constrained or not - if (best_snapped_point.isOtherSnapBetter(snapped_point, true)) { + if (best_snapped_point.isOtherSnapBetter(snapped_point, true) || points.size() == 1) { // .. so we must keep track of the best non-snapped constrained point best_transformation = result; best_snapped_point = snapped_point; @@ -1440,7 +1440,7 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons if (prefs->getBool("/options/snapclosestonly/value")) { bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = p.getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHER_CATEGORY; + bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; g_assert(_desktop != NULL); if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index cf5927fc8..7ebedb816 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -276,7 +276,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide())) { + if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { return; } @@ -317,7 +317,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && slice && ellipse->closed) || snapprefs->getSnapObjectMidpoints()) { pt = Geom::Point(cx, cy) * i2d; - p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_CENTER, Inkscape::SNAPTARGET_CENTER)); + p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } // And if we have a slice, also snap to the endpoints diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 1feb644ad..515658d0b 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -251,6 +251,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: object->readAttr( "inkscape:snap-global" ); object->readAttr( "inkscape:snap-bbox" ); object->readAttr( "inkscape:snap-nodes" ); + object->readAttr( "inkscape:snap-others" ); object->readAttr( "inkscape:snap-from-guide" ); object->readAttr( "inkscape:snap-center" ); object->readAttr( "inkscape:snap-smooth-nodes" ); @@ -308,8 +309,6 @@ static void sp_namedview_release(SPObject *object) static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value) { SPNamedView *nv = SP_NAMEDVIEW(object); - // TODO investigate why we grab this and then never use it - SPUnit const &px = sp_unit_get_by_id(SP_UNIT_PX); switch (key) { case SP_ATTR_VIEWONLY: @@ -334,17 +333,17 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GRIDTOLERANCE: - nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_GUIDETOLERANCE: - nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_OBJECTTOLERANCE: - nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_GUIDECOLOR: nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); if (value) { @@ -451,9 +450,9 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED: - nv->window_maximized = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->window_maximized = value ? atoi(value) : 0; + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_GLOBAL: nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -466,18 +465,22 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_INKSCAPE_SNAP_OTHERS: + nv->snap_manager.snapprefs.setSnapModeOthers(value ? sp_str_to_bool(value) : TRUE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_CENTER: nv->snap_manager.snapprefs.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GRIDS: - nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: - nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -487,17 +490,17 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; + nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 94a453ae6..db5a62f8f 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -567,7 +567,7 @@ static void sp_rect_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide())) { + if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { return; } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index ea79b6cee..24b6b8025 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1190,7 +1190,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide())) { + if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { return; } diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 05c6bc9cd..a772e057d 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -529,7 +529,7 @@ static void sp_spiral_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide())) { + if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { return; } diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 39efe2537..17ddf7279 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -557,7 +557,7 @@ static void sp_star_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide())) { + if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { return; } diff --git a/src/text-context.cpp b/src/text-context.cpp index b709d4d24..3ef346ebe 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -675,7 +675,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point motion_dt(desktop->w2d(motion_w)); - m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE)); + m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_OTHER_HANDLE)); m.unSetup(); } break; diff --git a/src/ui/icon-names.h b/src/ui/icon-names.h index f7c16b0ed..cf459b563 100644 --- a/src/ui/icon-names.h +++ b/src/ui/icon-names.h @@ -458,6 +458,8 @@ "snap-nodes" #define INKSCAPE_ICON_SNAP_NODES_CENTER \ "snap-nodes-center" +#define INKSCAPE_ICON_SNAP_OTHERS \ + "snap-nodes-others" #define INKSCAPE_ICON_SNAP_NODES_CUSP \ "snap-nodes-cusp" #define INKSCAPE_ICON_SNAP_NODES_INTERSECTION \ diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index bfdd4a916..7789484fd 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2176,6 +2176,10 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.getSnapIntersectionCS(); sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); break; + case SP_ATTR_INKSCAPE_SNAP_OTHERS: + v = nv->snap_manager.snapprefs.getSnapModeOthers(); + sp_repr_set_boolean(repr, "inkscape:snap-others", !v); + break; case SP_ATTR_INKSCAPE_SNAP_CENTER: v = nv->snap_manager.snapprefs.getIncludeItemCenter(); sp_repr_set_boolean(repr, "inkscape:snap-center", !v); @@ -2244,6 +2248,8 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) " " " " " " + " " + " " " " " " " " @@ -2369,6 +2375,14 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); } + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromOthers", + _("Others"), _("Snap other points (centers, guide origins, gradient handles, etc.)"), INKSCAPE_ICON_SNAP_OTHERS, secondarySize, SP_ATTR_INKSCAPE_SNAP_OTHERS); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromObjectCenters", _("Object Centers"), _("Snap from and to centers of objects"), @@ -2476,7 +2490,8 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev Glib::RefPtr act7 = mainActions->get_action("ToggleSnapToItemNode"); Glib::RefPtr act8 = mainActions->get_action("ToggleSnapToSmoothNodes"); Glib::RefPtr act9 = mainActions->get_action("ToggleSnapToFromLineMidpoints"); - Glib::RefPtr act10 = mainActions->get_action("ToggleSnapToFromObjectCenters"); + Glib::RefPtr act10 = mainActions->get_action("ToggleSnapFromOthers"); + Glib::RefPtr act10b = mainActions->get_action("ToggleSnapToFromObjectCenters"); Glib::RefPtr act11 = mainActions->get_action("ToggleSnapToFromRotationCenter"); Glib::RefPtr act12 = mainActions->get_action("ToggleSnapToPageBorder"); //Glib::RefPtr act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); @@ -2524,10 +2539,14 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_action_set_sensitive(GTK_ACTION(act8->gobj()), c1 && c3); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.getSnapLineMidpoints()); gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints()); - gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1 && c3); + + bool const c5 = nv->snap_manager.snapprefs.getSnapModeOthers(); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), c5); + gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints()); + gtk_action_set_sensitive(GTK_ACTION(act10b->gobj()), c1 && c5); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter()); - gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c3); + gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.getSnapToPageBorder()); gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1); -- cgit v1.2.3 From babd2b5943341cf5731c4c7fa037267e10c68bab Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 27 Jun 2011 00:11:01 +0200 Subject: LPE PowerStroke: add linecap (let's see how well this behaves, it has some bugs/features) (bzr r10373) --- src/live_effects/lpe-powerstroke.cpp | 98 ++++++++++++++++++++++++++++++------ src/live_effects/lpe-powerstroke.h | 5 +- 2 files changed, 86 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 82f4ccdea..cd692f402 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -3,9 +3,9 @@ * @brief PowerStroke LPE implementation. Creates curves with modifiable stroke width. */ /* Authors: - * Johan Engelen + * Johan Engelen * - * Copyright (C) 2010 Authors + * Copyright (C) 2010-2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -20,6 +20,7 @@ #include <2geom/sbasis-geometric.h> #include <2geom/transforms.h> #include <2geom/bezier-utils.h> +#include <2geom/svg-elliptical-arc.h> #include "live_effects/bezctx.h" #include "live_effects/bezctx_intf.h" @@ -275,11 +276,24 @@ static const Util::EnumData InterpolatorTypeData[] = { }; static const Util::EnumDataConverter InterpolatorTypeConverter(InterpolatorTypeData, sizeof(InterpolatorTypeData)/sizeof(*InterpolatorTypeData)); +enum LineCapType { + LINECAP_BUTT, + LINECAP_ROUND, + LINECAP_SHARP +}; +static const Util::EnumData LineCapTypeData[] = { + {LINECAP_BUTT , N_("Butt"), "Butt"}, + {LINECAP_ROUND , N_("Round"), "Round"}, + {LINECAP_SHARP , N_("Sharp"), "Sharp"} +}; +static const Util::EnumDataConverter LineCapTypeConverter(LineCapTypeData, sizeof(LineCapTypeData)/sizeof(*LineCapTypeData)); + LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true), - interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN) + interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), + linecap_type(_("Line cap type"), _("Determines the shape of the path ends."), "linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) { show_orig_path = true; @@ -288,6 +302,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&offset_points) ); registerParameter( dynamic_cast(&sort_points) ); registerParameter( dynamic_cast(&interpolator_type) ); + registerParameter( dynamic_cast(&linecap_type) ); } LPEPowerStroke::~LPEPowerStroke() @@ -332,35 +347,88 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & Piecewise > output; if (!closed_path) { + LineCapType linecap = static_cast(linecap_type.get_value()); + // perhaps use std::list instead of std::vector? std::vector ts(offset_points.data().size() + 2); - // first and last point coincide with input path (for now at least) - ts.front() = Point(pwd2_in.domain().min(),0); - ts.back() = Point(pwd2_in.domain().max(),0); for (unsigned int i = 0; i < offset_points.data().size(); ++i) { ts.at(i+1) = offset_points.data().at(i); } - if (sort_points) { - sort(ts.begin(), ts.end(), compare_offsets); + sort(ts.begin()+1, ts.end()-1, compare_offsets); + } + switch (linecap) { + case LINECAP_SHARP: + // first and last point coincide with input path to make sharp points on ends + ts.front() = Point(pwd2_in.domain().min(),0); + ts.back() = Point(pwd2_in.domain().max(),0); + break; + case LINECAP_BUTT: + case LINECAP_ROUND: + default: + // first and last point have same distance from path as second and second to last points, respectively. + ts.front() = Point(pwd2_in.domain().min(), (*(ts.begin()+1))[Geom::Y] ); + ts.back() = Point(pwd2_in.domain().max(), (*(ts.end()-2))[Geom::Y] ); + break; } // create stroke path where points (x,y) := (t, offset) Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); Geom::Path strokepath = interpolator->interpolateToPath(ts); - Geom::Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); delete interpolator; - strokepath.append(mirroredpath, Geom::Path::STITCH_DISCONTINUOUS); - strokepath.close(); + switch (linecap) { + case LINECAP_SHARP: + case LINECAP_BUTT: + { + Geom::Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); + strokepath.append(mirroredpath, Geom::Path::STITCH_DISCONTINUOUS); + strokepath.close(); - D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); - Piecewise x = Piecewise(patternd2[0]); - Piecewise y = Piecewise(patternd2[1]); + D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); + Piecewise x = Piecewise(patternd2[0]); + Piecewise y = Piecewise(patternd2[1]); - output = compose(pwd2_in,x) + y*compose(n,x); + output = compose(pwd2_in,x) + y*compose(n,x); + break; + } + case LINECAP_ROUND: + default: + { + D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); + Piecewise x = Piecewise(patternd2[0]); + Piecewise y = Piecewise(patternd2[1]); + + // find time values for which x lies outside path domain + // and only take portion of x and y that lies within those time values + std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); + std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); + if ( !rtsmin.empty() && !rtsmax.empty() ) { + x = portion(x, rtsmin.at(0), rtsmax.at(0)); + y = portion(y, rtsmin.at(0), rtsmax.at(0)); + } + + output = compose(pwd2_in,x) + y*compose(n,x); + x = reverse(x); + y = reverse(y); + Piecewise > mirrorpath = compose(pwd2_in,x) - y*compose(n,x); + + double radius1 = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); + Geom::SVGEllipticalArc cap1(output.lastValue(), radius1, radius1, M_PI/2., false, false, mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap1.toSBasis())); + + output.continuousConcat(mirrorpath); + + double radius2 = 0.5 * distance(output.firstValue(), output.lastValue()); + Geom::SVGEllipticalArc cap2(output.lastValue(), radius2, radius2, M_PI/2., false, false, output.firstValue()); + output.continuousConcat(Piecewise >(cap2.toSBasis())); + + break; + } + } } else { // path is closed + // linecap parameter can be ignored // perhaps use std::list instead of std::vector? std::vector ts = offset_points.data(); diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 7a1f3829a..6f34e16e2 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -2,9 +2,9 @@ * @brief PowerStroke LPE effect, see lpe-powerstroke.cpp. */ /* Authors: - * Johan Engelen + * Johan Engelen * - * Copyright (C) 2010 Authors + * Copyright (C) 2010-2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -33,6 +33,7 @@ private: PowerStrokePointArrayParam offset_points; BoolParam sort_points; EnumParam interpolator_type; + EnumParam linecap_type; LPEPowerStroke(const LPEPowerStroke&); LPEPowerStroke& operator=(const LPEPowerStroke&); -- cgit v1.2.3 From 419fa66edd4abd4a1227030b75ca163335891548 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 26 Jun 2011 23:32:42 -0700 Subject: Remove "using namespace" from libcola headers. (bzr r10374) --- src/libcola/cola.cpp | 52 +++++++++++++++++++-------------------- src/libcola/cola.h | 34 ++++++++++++------------- src/libcola/gradient_projection.h | 44 ++++++++++++++++----------------- src/libcola/shortest_paths.h | 23 +++++++++-------- src/libcola/straightener.cpp | 2 ++ src/libcola/straightener.h | 26 ++++++++++---------- 6 files changed, 92 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 2a3b525a7..e2a233b5e 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -4,6 +4,8 @@ #include "shortest_paths.h" #include "2geom/isnan.h" +using namespace std; + namespace cola { /** @@ -16,8 +18,8 @@ inline double dummy_var_euclidean_dist(GradientProjection* gpx, GradientProjecti } ConstrainedMajorizationLayout ::ConstrainedMajorizationLayout( - vector& rs, - vector& es, + std::vector& rs, + std::vector& es, double* eweights, double idealLength, TestConvergence& done) @@ -85,10 +87,10 @@ ConstrainedMajorizationLayout for(Cluster::iterator vit=c->begin(); vit!=c->end(); ++vit) { double pos = coords[k][*vit]; - minPos=min(pos,minPos); - maxPos=max(pos,maxPos); - p->leftof.push_back(make_pair(*vit,0)); - p->rightof.push_back(make_pair(*vit,0)); + minPos = std::min(pos, minPos); + maxPos = std::max(pos, maxPos); + p->leftof.push_back(std::make_pair(*vit,0)); + p->rightof.push_back(std::make_pair(*vit,0)); } p->place_l = minPos; p->place_r = maxPos; @@ -108,7 +110,7 @@ void ConstrainedMajorizationLayout::majlayout( double** Dij, GradientProjection* gp, double* coords) { double b[n]; - fill(b,b+n,0); + std::fill(b,b+n,0); majlayout(Dij,gp,coords,b); } void ConstrainedMajorizationLayout::majlayout( @@ -123,7 +125,7 @@ void ConstrainedMajorizationLayout::majlayout( for (unsigned j = 0; j < lapSize; j++) { if (j == i) continue; dist_ij = euclidean_distance(i, j); - if (dist_ij > 1e-30 && Dij[i][j] > 1e-30) { /* skip zero distances */ + if (dist_ij > 1e-30 && Dij[i][j] > 1e-30) { /* skip zero distances */ /* calculate L_ij := w_{ij}*d_{ij}/dist_{ij} */ L_ij = 1.0 / (dist_ij * Dij[i][j]); degree -= L_ij; @@ -216,11 +218,11 @@ bool ConstrainedMajorizationLayout::run() { return true; } static bool straightenToProjection=true; -void ConstrainedMajorizationLayout::straighten(vector& sedges, Dim dim) { - vector snodes; - for (unsigned i=0;i& sedges, Dim dim) { + std::vector snodes; + for (unsigned i=0;i& sedg LinearConstraints linearConstraints; for(unsigned i=0;inodePath(snodes); - vector& path=sedges[i]->path; + std::vector& path=sedges[i]->path; // take u and v as the ends of the line //unsigned u=path[0]; //unsigned v=path[path.size()-1]; @@ -267,7 +269,7 @@ void ConstrainedMajorizationLayout::straighten(vector& sedg //cout << "Generated "<& sedg double wbv=edge_length*c->frac_bv; dist_ub=euclidean_distance(c->u,c->b)*wub; dist_bv=euclidean_distance(c->b,c->v)*wbv; - wub=max(wub,0.00001); - wbv=max(wbv,0.00001); - dist_ub=max(dist_ub,0.00001); - dist_bv=max(dist_bv,0.00001); + wub = std::max(wub,0.00001); + wbv = std::max(wbv,0.00001); + dist_ub = std::max(dist_ub,0.00001); + dist_bv = std::max(dist_bv,0.00001); wub=1/(wub*wub); wbv=1/(wbv*wbv); Q[c->u][c->u]-=wub; @@ -306,8 +308,8 @@ void ConstrainedMajorizationLayout::straighten(vector& sedg - coords[c->b] / dist_ub - coords[c->b] / dist_bv; } } - GradientProjection gp(dim,n,Q,coords,tol,100, - (AlignmentConstraints*)NULL,false,(vpsc::Rectangle**)NULL,(PageBoundaryConstraints*)NULL,&cs); + GradientProjection gp(dim,n,Q,coords,tol,100, + (AlignmentConstraints*)NULL,false,(vpsc::Rectangle**)NULL,(PageBoundaryConstraints*)NULL,&cs); constrainedLayout = true; majlayout(Dij,&gp,coords,b); for(unsigned i=0;i* straightenEdges) { + std::vector* straightenEdges) { constrainedLayout = true; this->avoidOverlaps = avoidOverlaps; if(cs) { clusters=cs; } - gpX=new GradientProjection( - HORIZONTAL,n,Q,X,tol,100,acsx,avoidOverlaps,boundingBoxes,pbcx,scx); - gpY=new GradientProjection( - VERTICAL,n,Q,Y,tol,100,acsy,avoidOverlaps,boundingBoxes,pbcy,scy); + gpX = new GradientProjection(HORIZONTAL,n,Q,X,tol,100,acsx,avoidOverlaps,boundingBoxes,pbcx,scx); + gpY = new GradientProjection(VERTICAL,n,Q,Y,tol,100,acsy,avoidOverlaps,boundingBoxes,pbcy,scy); this->straightenEdges = straightenEdges; } } // namespace cola diff --git a/src/libcola/cola.h b/src/libcola/cola.h index 136c527b6..e1f19994e 100644 --- a/src/libcola/cola.h +++ b/src/libcola/cola.h @@ -12,21 +12,21 @@ #include "straightener.h" -typedef vector Cluster; -typedef vector Clusters; +typedef std::vector Cluster; +typedef std::vector Clusters; namespace vpsc { class Rectangle; } namespace cola { using vpsc::Rectangle; - typedef pair Edge; + typedef std::pair Edge; // a graph component with a list of node_ids giving indices for some larger list of nodes // for the nodes in this component, and a list of edges - node indices relative to this component class Component { public: - vector node_ids; - vector rects; - vector edges; + std::vector node_ids; + std::vector rects; + std::vector edges; SimpleConstraints scx, scy; virtual ~Component(); void moveRectangles(double x, double y); @@ -35,15 +35,15 @@ namespace cola { // for a graph of n nodes, return connected components void connectedComponents( - const vector &rs, - const vector &es, + const std::vector &rs, + const std::vector &es, const SimpleConstraints &scx, const SimpleConstraints &scy, - vector &components); + std::vector &components); // move the contents of each component so that the components do not // overlap. - void separateComponents(const vector &components); + void separateComponents(const std::vector &components); // defines references to three variables for which the goal function // will be altered to prefer points u-b-v are in a linear arrangement @@ -110,7 +110,7 @@ namespace cola { bool tAtProjection; }; - typedef vector LinearConstraints; + typedef std::vector LinearConstraints; class TestConvergence { public: @@ -150,8 +150,8 @@ static TestConvergence defaultTest(0.0001,100); class ConstrainedMajorizationLayout { public: ConstrainedMajorizationLayout( - vector& rs, - vector& es, + std::vector& rs, + std::vector& es, double* eweights, double idealLength, TestConvergence& done=defaultTest); @@ -171,7 +171,7 @@ public: SimpleConstraints* scx = NULL, SimpleConstraints* scy = NULL, Clusters* cs = NULL, - vector* straightenEdges = NULL); + std::vector* straightenEdges = NULL); void addLinearConstraints(LinearConstraints* linearConstraints); @@ -195,7 +195,7 @@ public: delete [] Y; } bool run(); - void straighten(vector&, Dim); + void straighten(std::vector&, Dim); bool avoidOverlaps; bool constrainedLayout; private: @@ -214,14 +214,14 @@ public: double** Q; // quadratic terms matrix used in computations double** Dij; double tol; - TestConvergence& done; + TestConvergence& done; Rectangle** boundingBoxes; double *X, *Y; Clusters* clusters; double edge_length; LinearConstraints *linearConstraints; GradientProjection *gpX, *gpY; - vector* straightenEdges; + std::vector* straightenEdges; }; } diff --git a/src/libcola/gradient_projection.h b/src/libcola/gradient_projection.h index 4ef68fc2e..9907cdb13 100644 --- a/src/libcola/gradient_projection.h +++ b/src/libcola/gradient_projection.h @@ -9,11 +9,9 @@ #include #include -using namespace std; - -typedef vector Constraints; -typedef vector Variables; -typedef vector > OffsetList; +typedef std::vector Constraints; +typedef std::vector Variables; +typedef std::vector > OffsetList; class SimpleConstraint { public: @@ -23,7 +21,7 @@ public: unsigned right; double gap; }; -typedef vector SimpleConstraints; +typedef std::vector SimpleConstraints; class AlignmentConstraint { friend class GradientProjection; public: @@ -37,7 +35,7 @@ public: private: vpsc::Variable* variable; }; -typedef vector AlignmentConstraints; +typedef std::vector AlignmentConstraints; class PageBoundaryConstraints { public: @@ -63,7 +61,7 @@ private: double weight; }; -typedef vector > CList; +typedef std::vector > CList; /** * A DummyVarPair is a pair of variables with an ideal distance between them and which have no * other interaction with other variables apart from through constraints. This means that @@ -170,19 +168,19 @@ friend class GradientProjection; double old_place_l; // old_place is where the descent vec g was computed double old_place_r; }; -typedef vector DummyVars; +typedef std::vector DummyVars; enum Dim { HORIZONTAL, VERTICAL }; class GradientProjection { public: - GradientProjection( + GradientProjection( const Dim k, - unsigned n, - double** A, - double* x, - double tol, - unsigned max_iterations, + unsigned n, + double** A, + double* x, + double tol, + unsigned max_iterations, AlignmentConstraints* acs=NULL, bool nonOverlapConstraints=false, vpsc::Rectangle** rs=NULL, @@ -222,7 +220,7 @@ public: if(!gcs.empty() || nonOverlapConstraints) { constrained=true; } - } + } virtual ~GradientProjection() { delete [] g; delete [] d; @@ -236,16 +234,16 @@ public: } } void clearDummyVars(); - unsigned solve(double* b); + unsigned solve(double* b); DummyVars dummy_vars; // special vars that must be considered in Lapl. private: vpsc::IncSolver* setupVPSC(); void destroyVPSC(vpsc::IncSolver *vpsc); Dim k; - unsigned n; // number of actual vars - double** A; // Graph laplacian matrix + unsigned n; // number of actual vars + double** A; // Graph laplacian matrix double* place; - Variables vars; // all variables + Variables vars; // all variables // computations Constraints gcs; /* global constraints - persist throughout all iterations */ @@ -255,9 +253,9 @@ private: double tolerance; AlignmentConstraints* acs; unsigned max_iterations; - double* g; /* gradient */ - double* d; - double* old_place; + double* g; /* gradient */ + double* d; + double* old_place; bool constrained; }; diff --git a/src/libcola/shortest_paths.h b/src/libcola/shortest_paths.h index 20107caf0..f376b631c 100644 --- a/src/libcola/shortest_paths.h +++ b/src/libcola/shortest_paths.h @@ -1,7 +1,7 @@ // vim: set cindent // vim: ts=4 sw=4 et tw=0 wm=0 #include -using namespace std; + template class PairNode; namespace shortest_paths { @@ -9,20 +9,23 @@ namespace shortest_paths { struct Node { unsigned id; double d; - Node* p; // predecessor - vector neighbours; - vector nweights; - PairNode* qnode; + Node *p; // predecessor + std::vector neighbours; + std::vector nweights; + PairNode *qnode; }; inline bool compareNodes(Node *const &u, Node *const &v) { - return u->d < v->d; + return u->d < v->d; } -typedef pair Edge; +typedef std::pair Edge; + void floyd_warshall(unsigned n, double** D, - vector& es,double* eweights); + std::vector& es,double* eweights); + void johnsons(unsigned n, double** D, - vector& es, double* eweights); + std::vector& es, double* eweights); + void dijkstra(unsigned s, unsigned n, double* d, - vector& es, double* eweights); + std::vector& es, double* eweights); } diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index 7c73cb9e9..7a1020781 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -25,6 +25,8 @@ using std::set; using std::vector; using std::list; +using std::pair; +using std::make_pair; namespace straightener { diff --git a/src/libcola/straightener.h b/src/libcola/straightener.h index 934be45ba..b1ce665f4 100644 --- a/src/libcola/straightener.h +++ b/src/libcola/straightener.h @@ -18,10 +18,10 @@ namespace straightener { xmin=ymin=DBL_MAX; xmax=ymax=-DBL_MAX; for(unsigned i=0;i dummyNodes; - vector path; + std::vector dummyNodes; + std::vector path; Edge(unsigned id, unsigned start, unsigned end, Route* route) : id(id), startNode(start), endNode(end), route(route) { @@ -54,7 +54,7 @@ namespace straightener { if(startNode==n||endNode==n) return true; return false; } - void nodePath(vector& nodes); + void nodePath(std::vector& nodes); void createRouteFromPath(double* X, double* Y) { Route* r=new Route(path.size()); for(unsigned i=0;i& xs) { + void xpos(double y, std::vector& xs) { // search line segments for intersection points with y pos for(unsigned i=1;in;i++) { double ax=route->xs[i-1], bx=route->xs[i], ay=route->ys[i-1], by=route->ys[i]; @@ -74,7 +74,7 @@ namespace straightener { } } } - void ypos(double x, vector& ys) { + void ypos(double x, std::vector& ys) { // search line segments for intersection points with x pos for(unsigned i=1;in;i++) { double ax=route->xs[i-1], bx=route->xs[i], ay=route->ys[i-1], by=route->ys[i]; @@ -104,8 +104,8 @@ namespace straightener { edge(NULL),dummy(false),weight(-0.1),open(false) { } private: friend void sortNeighbours(Node* v, Node* l, Node* r, - double conjpos, vector& openEdges, - vector& L,vector& nodes, Dim dim); + double conjpos, std::vector& openEdges, + std::vector& L, std::vector& nodes, Dim dim); Node(unsigned id, double x, double y, Edge* e) : id(id),x(x),y(y), width(4), height(width), xmin(x-width/2),xmax(x+width/2), @@ -126,8 +126,8 @@ namespace straightener { } }; typedef std::set NodeSet; - void generateConstraints(vector& nodes, vector& edges,vector& cs, Dim dim); - void nodePath(Edge& e,vector& nodes, vector& path); + void generateConstraints(std::vector& nodes, std::vector& edges, std::vector& cs, Dim dim); + void nodePath(Edge& e, std::vector& nodes, std::vector& path); } #endif -- cgit v1.2.3 From f3d189bf9df552fe8ba657380ef6f3316bf5afa8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 27 Jun 2011 19:15:55 +0200 Subject: fix crasher Fixed bugs: - https://launchpad.net/bugs/802212 (bzr r10375) --- src/sp-conn-end-pair.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 3cc022c39..e22145425 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -224,7 +224,7 @@ SPConnEndPair::getEndpoints(Geom::Point endPts[]) const { g_assert(h2attItem[h]->avoidRef); endPts[h] = h2attItem[h]->avoidRef->getConnectionPointPos(_connEnd[h]->type, _connEnd[h]->id); } - else + else if (!curve->is_empty()) { if (h == 0) { endPts[h] = *(curve->first_point())*i2d; -- cgit v1.2.3 From 0ef9a2a418fa95af850ce36fb469676c86464296 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 27 Jun 2011 20:57:12 +0200 Subject: Inkview. Fix for bug #771365 (Inkview rendering with incorrect scaling when slide showing multiple files). (bzr r10376) --- src/svg-view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/svg-view.cpp b/src/svg-view.cpp index b35375736..5deff7421 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -198,6 +198,8 @@ SPSVGView::setDocument (SPDocument *document) g_signal_connect (G_OBJECT (_drawing), "arena_event", G_CALLBACK (arena_handler), this); } + View::setDocument (document); + if (document) { NRArenaItem *ai = SP_ITEM( document->getRoot() )->invoke_show( SP_CANVAS_ARENA (_drawing)->arena, @@ -210,8 +212,6 @@ SPSVGView::setDocument (SPDocument *document) doRescale (!_rescale); } - - View::setDocument (document); } /** -- cgit v1.2.3 From a5ebfe58030589c92d1616b8b9f98614076ac853 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 27 Jun 2011 21:43:16 +0200 Subject: The measurement tool now snaps too (bzr r10377) --- src/measure-context.cpp | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index bc766872b..8cb30f983 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -36,6 +36,10 @@ #include <2geom/path-intersection.h> #include <2geom/pathvector.h> #include <2geom/crossing.h> +#include <2geom/angle.h> +#include "snap.h" +#include "sp-namedview.h" + static void sp_measure_context_class_init(SPMeasureContextClass *klass); static void sp_measure_context_init(SPMeasureContext *measure_context); @@ -184,16 +188,32 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv ret = TRUE; } + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + m.freeSnapReturnByRef(start_point, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, + NULL, event->button.time); mc->grabbed = SP_CANVAS_ITEM(desktop->acetate); break; } case GDK_MOTION_NOTIFY: { - if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) { + if (!((event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning)) { + if (!(event->motion.state & GDK_SHIFT_MASK)) { + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const motion_dt(desktop->w2d(motion_w)); + + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + + m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_OTHER_HANDLE)); + m.unSetup(); + } + } else { ret = TRUE; if ( within_tolerance @@ -217,9 +237,16 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv Geom::Point const motion_dt(desktop->w2d(motion_w)); Geom::Point end_point = motion_dt; - //rotation constraint - if (event->motion.state & GDK_CONTROL_MASK) + if (event->motion.state & GDK_CONTROL_MASK) { spdc_endpoint_snap_rotation(event_context, end_point, start_point, event->motion.state); + } else { + if (!(event->motion.state & GDK_SHIFT_MASK)) { + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + m.freeSnapReturnByRef(end_point, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); + } + } //draw control line SPCanvasItem * control_line = NULL; @@ -247,6 +274,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv points.push_back(desktop->d2w(start_point + (i/NPOINTS)*(end_point-start_point))); } +// TODO: Felipe, why don't you simply iterate over all items, and test whether their bounding boxes intersect +// with the measurement line, instead of interpolating? E.g. bbox_of_measurement_line.intersects(*bbox_of_item). +// That's also how the object-snapper works, see _findCandidates() in object-snapper.cpp. + //select elements crossed by line segment: GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); SPItem* item; @@ -355,7 +386,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } char* angle_str = (char*) malloc(sizeof(char)*20); - sprintf(angle_str, "%.2f °", angle * 180/3.1415 ); + sprintf(angle_str, "%.2f °", angle * 180/M_PI ); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); sp_canvastext_set_rgba32 (SP_CANVASTEXT(canvas_tooltip), 0x337f33ff, 0xffffffff); @@ -374,6 +405,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv case GDK_BUTTON_RELEASE: { + sp_event_context_discard_delayed_snap_event(event_context); + //clear all temporary canvas items related to the measurement tool. unsigned int idx; for (idx=0; idx Date: Tue, 28 Jun 2011 00:15:56 +0100 Subject: Rm a few instances of deprecated GtkNotebookPage. gtkmm-2.4 still uses it (bzr r10350.1.10) --- src/libgdl/gdl-dock-notebook.c | 6 +++--- src/libgdl/gdl-switcher.c | 5 +---- src/widgets/sp-color-notebook.cpp | 6 +++--- src/widgets/sp-color-notebook.h | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c index 6fb931ac7..79bebd1f2 100644 --- a/src/libgdl/gdl-dock-notebook.c +++ b/src/libgdl/gdl-dock-notebook.c @@ -60,7 +60,7 @@ static void gdl_dock_notebook_dock (GdlDockObject *object, GValue *other_data); static void gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, - GtkNotebookPage *page, + GtkWidget *page, gint page_num, gpointer data); @@ -261,7 +261,7 @@ gdl_dock_notebook_destroy (GtkObject *object) static void gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, - GtkNotebookPage *page, + GtkWidget *page, gint page_num, gpointer data) { @@ -281,7 +281,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, /* activate new label */ tablabel = gtk_notebook_get_tab_label ( - nb, gtk_notebook_get_nth_page (nb, page_num)); + nb, page); if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel)) gdl_dock_tablabel_activate (GDL_DOCK_TABLABEL (tablabel)); diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 65e8b98fe..779895056 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -615,15 +615,12 @@ gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec, } static void -gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkNotebookPage *page, +gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkWidget *page_widget, gint page_num, GdlSwitcher *switcher) { - GtkWidget *page_widget; - GtkWidget *tablabel; gint switcher_id; /* Change switcher button */ - page_widget = gtk_notebook_get_nth_page (nb, page_num); switcher_id = gdl_switcher_get_page_id (page_widget); gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id); } diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 0379fa141..c252dc65e 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -102,7 +102,7 @@ sp_color_notebook_class_init (SPColorNotebookClass *klass) static void sp_color_notebook_switch_page(GtkNotebook *notebook, - GtkNotebookPage *page, + GtkWidget *page, guint page_num, SPColorNotebook *colorbook) { @@ -111,14 +111,14 @@ sp_color_notebook_switch_page(GtkNotebook *notebook, ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base); nb->switchPage( notebook, page, page_num ); - // remember the page we seitched to + // remember the page we switched to Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/colorselector/page", page_num); } } void ColorNotebook::switchPage(GtkNotebook*, - GtkNotebookPage*, + GtkWidget*, guint page_num) { SPColorSelector* csel; diff --git a/src/widgets/sp-color-notebook.h b/src/widgets/sp-color-notebook.h index 8d2988636..85b4315ed 100644 --- a/src/widgets/sp-color-notebook.h +++ b/src/widgets/sp-color-notebook.h @@ -31,7 +31,7 @@ public: virtual void init(); SPColorSelector* getCurrentSelector(); - void switchPage( GtkNotebook *notebook, GtkNotebookPage *page, guint page_num ); + void switchPage( GtkNotebook *notebook, GtkWidget *page, guint page_num ); GtkWidget* addPage( GType page_type, guint submode ); void removePage( GType page_type, guint submode ); -- cgit v1.2.3 From 127af81759014adc35174d0349302ed52410fa6f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 28 Jun 2011 02:13:50 -0700 Subject: Fixed missing initializers, mismatching function with too many parameters, and misc warnings. (bzr r10380) --- src/libgdl/gdl-dock-item.c | 35 +++++++++++++++++++++++------------ src/libgdl/gdl-dock-master.c | 11 ++++++++++- src/libgdl/gdl-dock-notebook.c | 9 +++++++-- src/libgdl/gdl-dock-object.c | 7 ++++++- src/libgdl/gdl-dock.c | 38 +++++++++++++++++++++++++++----------- src/libgdl/gdl-switcher.c | 18 +++++++++++++----- src/libgdl/gdl-tools.h | 4 +++- 7 files changed, 89 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 3d746fa7c..138265034 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -82,8 +82,7 @@ static void gdl_dock_item_forall (GtkContainer *container, static GType gdl_dock_item_child_type (GtkContainer *container); static void gdl_dock_item_set_focus_child (GtkContainer *container, - GtkWidget *widget, - gpointer callback_data); + GtkWidget *widget); static void gdl_dock_item_size_request (GtkWidget *widget, GtkRequisition *requisition); @@ -697,13 +696,13 @@ gdl_dock_item_child_type (GtkContainer *container) static void gdl_dock_item_set_focus_child (GtkContainer *container, - GtkWidget *child, - gpointer callback_data) + GtkWidget *child) { g_return_if_fail (GDL_IS_DOCK_ITEM (container)); - if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child) + if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child) { (* GTK_CONTAINER_CLASS (parent_class)->set_focus_child) (container, child); + } gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container)); } @@ -920,6 +919,8 @@ static void gdl_dock_item_style_set (GtkWidget *widget, GtkStyle *previous_style) { + (void)previous_style; + g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); @@ -1454,9 +1455,10 @@ static void gdl_dock_item_detach_menu (GtkWidget *widget, GtkMenu *menu) { - GdlDockItem *item; - - item = GDL_DOCK_ITEM (widget); + GdlDockItem *item = GDL_DOCK_ITEM(widget); + + (void)menu; + item->_priv->menu = NULL; } @@ -1539,12 +1541,13 @@ gdl_dock_item_tab_button (GtkWidget *widget, GdkEventButton *event, gpointer data) { - GdlDockItem *item; + GdlDockItem *item = GDL_DOCK_ITEM(data); - item = GDL_DOCK_ITEM (data); + (void)widget; - if (!GDL_DOCK_ITEM_NOT_LOCKED (item)) + if (!GDL_DOCK_ITEM_NOT_LOCKED (item)) { return; + } switch (event->button) { case 1: @@ -1577,7 +1580,9 @@ gdl_dock_item_hide_cb (GtkWidget *widget, GdlDockItem *item) { GdlDockMaster *master; - + + (void)widget; + g_return_if_fail (item != NULL); master = GDL_DOCK_OBJECT_GET_MASTER (item); @@ -1590,6 +1595,8 @@ gdl_dock_item_lock_cb (GtkWidget *widget, { g_return_if_fail (item != NULL); + (void)widget; + gdl_dock_item_lock (item); } @@ -1599,6 +1606,8 @@ gdl_dock_item_unlock_cb (GtkWidget *widget, { g_return_if_fail (item != NULL); + (void)widget; + gdl_dock_item_unlock (item); } @@ -1705,6 +1714,8 @@ gdl_dock_item_dock_to (GdlDockItem *item, GdlDockPlacement position, gint docking_param) { + (void)docking_param; + g_return_if_fail (item != NULL); g_return_if_fail (item != target); g_return_if_fail (target != NULL || position == GDL_DOCK_FLOATING); diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c index 1c362ed16..4b36e4f8b 100644 --- a/src/libgdl/gdl-dock-master.c +++ b/src/libgdl/gdl-dock-master.c @@ -262,6 +262,7 @@ ht_foreach_build_slist (gpointer key, gpointer value, GSList **slist) { + (void)key; *slist = g_slist_prepend (*slist, value); } @@ -718,7 +719,11 @@ item_dock_cb (GdlDockObject *object, gpointer user_data) { GdlDockMaster *master = user_data; - + + (void)object; + (void)position; + (void)other_data; + g_return_if_fail (requestor && GDL_IS_DOCK_OBJECT (requestor)); g_return_if_fail (master && GDL_IS_DOCK_MASTER (master)); @@ -740,6 +745,8 @@ item_detach_cb (GdlDockObject *object, { GdlDockMaster *master = user_data; + (void)recursive; + g_return_if_fail (object && GDL_IS_DOCK_OBJECT (object)); g_return_if_fail (master && GDL_IS_DOCK_MASTER (master)); @@ -760,6 +767,8 @@ item_notify_cb (GdlDockObject *object, gint locked = COMPUTE_LOCKED (master); gboolean item_locked; + (void)pspec; + g_object_get (object, "locked", &item_locked, NULL); if (item_locked) { diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c index 79bebd1f2..f6e0aeeef 100644 --- a/src/libgdl/gdl-dock-notebook.c +++ b/src/libgdl/gdl-dock-notebook.c @@ -157,6 +157,7 @@ gdl_dock_notebook_notify_cb (GObject *g_object, gpointer user_data) { g_return_if_fail (user_data != NULL && GDL_IS_DOCK_NOTEBOOK (user_data)); + (void)g_object; /* chain the notify signal */ g_object_notify (G_OBJECT (user_data), pspec->name); @@ -167,10 +168,12 @@ gdl_dock_notebook_button_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - if (event->type == GDK_BUTTON_PRESS) + (void)widget; + if (event->type == GDK_BUTTON_PRESS) { GDL_DOCK_ITEM_SET_FLAGS (user_data, GDL_DOCK_USER_ACTION); - else + } else { GDL_DOCK_ITEM_UNSET_FLAGS (user_data, GDL_DOCK_USER_ACTION); + } return FALSE; } @@ -267,6 +270,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, { GdlDockNotebook *notebook; GtkWidget *tablabel; + (void)page_num; notebook = GDL_DOCK_NOTEBOOK (data); @@ -332,6 +336,7 @@ gdl_dock_notebook_forall (GtkContainer *container, static GType gdl_dock_notebook_child_type (GtkContainer *container) { + (void)container; return GDL_TYPE_DOCK_ITEM; } diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index dadf072a0..233d03b3b 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -289,6 +289,7 @@ static void gdl_dock_object_foreach_detach (GdlDockObject *object, gpointer user_data) { + (void)user_data; gdl_dock_object_detach (object, TRUE); } @@ -431,6 +432,9 @@ gdl_dock_object_dock_unimplemented (GdlDockObject *object, GdlDockPlacement position, GValue *other_data) { + (void)requestor; + (void)position; + (void)other_data; g_warning (_("Call to gdl_dock_object_dock in a dock object %p " "(object type is %s) which hasn't implemented this method"), object, G_OBJECT_TYPE_NAME (object)); @@ -440,6 +444,7 @@ static void gdl_dock_object_real_present (GdlDockObject *object, GdlDockObject *child) { + (void)child; gtk_widget_show (GTK_WIDGET (object)); } @@ -830,7 +835,7 @@ gdl_dock_param_get_type (void) static GType our_type = 0; if (our_type == 0) { - GTypeInfo tinfo = { 0, }; + GTypeInfo tinfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; our_type = g_type_register_static (G_TYPE_STRING, "GdlDockParam", &tinfo, 0); /* register known transform functions */ diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index 5f0d7c66d..d80a47a1f 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -275,6 +275,8 @@ gdl_dock_floating_configure_event_cb (GtkWidget *widget, { GdlDock *dock; + (void)widget; + g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK (user_data), TRUE); dock = GDL_DOCK (user_data); @@ -510,7 +512,10 @@ gdl_dock_notify_cb (GObject *object, gpointer user_data) { GdlDock *dock; - + + (void)pspec; + (void)user_data; + g_return_if_fail (object != NULL || GDL_IS_DOCK (object)); dock = GDL_DOCK (object); @@ -561,7 +566,7 @@ gdl_dock_size_request (GtkWidget *widget, border_width = container->border_width; /* make request to root */ - if (dock->root && gtk_widget_get_visible (dock->root)) + if (dock->root && gtk_widget_get_visible( GTK_WIDGET(dock->root) )) gtk_widget_size_request (GTK_WIDGET (dock->root), requisition); else { requisition->width = 0; @@ -597,8 +602,9 @@ gdl_dock_size_allocate (GtkWidget *widget, allocation->width = MAX (1, allocation->width - 2 * border_width); allocation->height = MAX (1, allocation->height - 2 * border_width); - if (dock->root && gtk_widget_get_visible (dock->root)) + if (dock->root && gtk_widget_get_visible( GTK_WIDGET(dock->root) )) { gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation); + } } static void @@ -740,6 +746,8 @@ gdl_dock_forall (GtkContainer *container, { GdlDock *dock; + (void)include_internals; + g_return_if_fail (container != NULL); g_return_if_fail (GDL_IS_DOCK (container)); g_return_if_fail (callback != NULL); @@ -753,6 +761,7 @@ gdl_dock_forall (GtkContainer *container, static GType gdl_dock_child_type (GtkContainer *container) { + (void)container; return GDL_TYPE_DOCK_ITEM; } @@ -927,15 +936,16 @@ gdl_dock_dock (GdlDockObject *object, /* Realize the item (create its corresponding GdkWindow) when GdlDock has been realized. */ - if (gtk_widget_get_realized (dock)) + if ( gtk_widget_get_realized( GTK_WIDGET(dock) )) { gtk_widget_realize (widget); - + } + /* Map the widget if it's visible and the parent is visible and has been mapped. This is done to make sure that the GdkWindow is visible. */ - if (gtk_widget_get_visible (dock) && + if (gtk_widget_get_visible( GTK_WIDGET(dock) ) && gtk_widget_get_visible (widget)) { - if (gtk_widget_get_mapped (dock)) + if (gtk_widget_get_mapped( GTK_WIDGET(dock) )) gtk_widget_map (widget); /* Make the widget resize. */ @@ -1023,8 +1033,11 @@ gdl_dock_present (GdlDockObject *object, { GdlDock *dock = GDL_DOCK (object); - if (dock->_priv->floating) + (void)child; + + if (dock->_priv->floating) { gtk_window_present (GTK_WINDOW (dock->_priv->window)); + } } @@ -1097,6 +1110,8 @@ gdl_dock_select_larger_item (GdlDockItem *dock_item_1, gint level /* for debugging */) { GtkRequisition size_1, size_2; + + (void)level; g_return_val_if_fail (dock_item_1 != NULL, dock_item_2); g_return_val_if_fail (dock_item_2 != NULL, dock_item_1); @@ -1218,7 +1233,7 @@ gdl_dock_add_item (GdlDock *dock, /* Non-floating item. */ if (dock->root) { GdlDockPlacement local_placement; - GtkRequisition preferred_size; + /* GtkRequisition preferred_size; */ best_dock_item = gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->root), @@ -1258,10 +1273,11 @@ gdl_dock_add_floating_item (GdlDock *dock, "floaty", y, NULL)); - if (gtk_widget_get_visible (dock)) { + if (gtk_widget_get_visible( GTK_WIDGET(dock) )) { gtk_widget_show (GTK_WIDGET (new_dock)); - if (gtk_widget_get_mapped (dock)) + if (gtk_widget_get_mapped( GTK_WIDGET(dock) )) { gtk_widget_map (GTK_WIDGET (new_dock)); + } /* Make the widget resize. */ gtk_widget_queue_resize (GTK_WIDGET (new_dock)); diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 779895056..eccd66ce2 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -609,6 +609,8 @@ gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec, GdlSwitcher *switcher) { gboolean show_tabs; + (void)g_object; + (void)pspec; g_return_if_fail (switcher != NULL && GDL_IS_SWITCHER (switcher)); show_tabs = gtk_notebook_get_show_tabs (GTK_NOTEBOOK (switcher)); gdl_switcher_set_show_buttons (switcher, !show_tabs); @@ -619,7 +621,9 @@ gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkWidget *page_widget, gint page_num, GdlSwitcher *switcher) { gint switcher_id; - + + (void)nb; + (void)page_num; /* Change switcher button */ switcher_id = gdl_switcher_get_page_id (page_widget); gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id); @@ -630,7 +634,9 @@ gdl_switcher_page_added_cb (GtkNotebook *nb, GtkWidget *page, gint page_num, GdlSwitcher *switcher) { gint switcher_id; - + + (void)nb; + (void)page_num; switcher_id = gdl_switcher_get_page_id (page); gdl_switcher_add_button (GDL_SWITCHER (switcher), NULL, NULL, NULL, NULL, @@ -676,6 +682,7 @@ gdl_switcher_class_init (GdlSwitcherClass *klass) GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); + (void)notebook_class; container_class->forall = gdl_switcher_forall; container_class->remove = gdl_switcher_remove; @@ -755,12 +762,13 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, gtk_container_add (GTK_CONTAINER (button_widget), hbox); gtk_widget_show (hbox); - if (stock_id) + if (stock_id) { icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); - else if (pixbuf_icon) + } else if (pixbuf_icon) { icon_widget = gtk_image_new_from_pixbuf (pixbuf_icon); - else + } else { icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON); + } gtk_widget_show (icon_widget); diff --git a/src/libgdl/gdl-tools.h b/src/libgdl/gdl-tools.h index 0cfc9fb95..2cc68c035 100644 --- a/src/libgdl/gdl-tools.h +++ b/src/libgdl/gdl-tools.h @@ -104,6 +104,7 @@ static void type_as_function ## _class_init_trampoline (gpointer klass, \ gpointer data) \ { \ + (void)data; \ parent_class = (parent_type ## Class *)g_type_class_ref ( \ parent_type_macro); \ type_as_function ## _class_init ((type ## Class *)klass); \ @@ -122,7 +123,8 @@ type_as_function ## _get_type (void) NULL, /* class_data */ \ sizeof (type), \ 0, /* n_preallocs */ \ - (GInstanceInitFunc) type_as_function ## _instance_init \ + (GInstanceInitFunc) type_as_function ## _instance_init , \ + NULL, /* value_table */ \ }; \ object_type = register_type_macro \ (type, type_as_function, corba_type, \ -- cgit v1.2.3 From b0b8046a08a7d4d1cd21b5a0a531d9cfe7167f44 Mon Sep 17 00:00:00 2001 From: Gellule Xg Date: Mon, 27 Jun 2011 20:50:49 -1000 Subject: If GTK built with QUARTZ backend, no need to expect DISPLAY to be set to start the GUI version. Fixed bugs: - https://launchpad.net/bugs/251982 (bzr r10380.1.1) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 26774fd66..1614e97f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -641,7 +641,7 @@ main(int argc, char **argv) gboolean use_gui; -#ifndef WIN32 +#if !defined(WIN32) && !defined(GDK_WINDOWING_QUARTZ) use_gui = (g_getenv("DISPLAY") != NULL); #else use_gui = TRUE; -- cgit v1.2.3 From 3c55244d2a6df1645e9af8dfe05b71fb737a2903 Mon Sep 17 00:00:00 2001 From: Gellule Xg Date: Mon, 27 Jun 2011 21:21:00 -1000 Subject: Replaced a 'reshow_with_initial_size' by a simple 'resize', to address what looks like a GTK/QUARTZ backend issue, without functionality loss. Fixed bugs: - https://launchpad.net/bugs/487144 (bzr r10381.2.1) --- src/widgets/desktop-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index e7bc3691b..028138a10 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1108,7 +1108,7 @@ SPDesktopWidget::setWindowSize (gint w, gint h) if (window) { window->set_default_size (w, h); - window->reshow_with_initial_size (); + window->resize (w, h); } } -- cgit v1.2.3 From edefef351ab6a4772e976a6227d44fd8707cf207 Mon Sep 17 00:00:00 2001 From: Gellule Xg Date: Tue, 28 Jun 2011 21:00:22 -1000 Subject: As the comment says testing for a float to be equal to zero is not safe, hence the use of an ad-hoc epsilon instead. This was causing a crash with connectors where the size of the convex would change depending on calculation accuracy. This fixes part c) of bug #640985 (bzr r10384.1.1) --- src/2geom/convex-cover.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/convex-cover.cpp b/src/2geom/convex-cover.cpp index 21a5c3107..d50accadf 100644 --- a/src/2geom/convex-cover.cpp +++ b/src/2geom/convex-cover.cpp @@ -145,7 +145,7 @@ ConvexHull::graham_scan() { double o = SignedTriangleArea(boundary[stac-2], boundary[stac-1], boundary[i]); - if(o == 0) { // colinear - dangerous... + if(fabs(o) < 1e-8) { // colinear - dangerous... stac--; } else if(o < 0) { // anticlockwise } else { // remove concavity -- cgit v1.2.3 From a56335650da902734f5d27b9a8d743c60a0e9fd6 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 29 Jun 2011 02:43:07 -0700 Subject: Fixed initialization issue plus a few warnings. (bzr r10386) --- src/2geom/path-intersection.cpp | 2 -- src/libgdl/gdl-dock-bar.c | 2 ++ src/libgdl/gdl-dock-item-grip.c | 12 ++++++++++-- src/libgdl/gdl-dock-paned.c | 2 ++ src/libgdl/gdl-dock-placeholder.c | 12 ++++++++++-- src/libgdl/gdl-dock-tablabel.c | 1 + 6 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/2geom/path-intersection.cpp b/src/2geom/path-intersection.cpp index 58ee6232b..7aa662abb 100644 --- a/src/2geom/path-intersection.cpp +++ b/src/2geom/path-intersection.cpp @@ -228,8 +228,6 @@ intersect_polish_f (const gsl_vector * x, void *params, static void intersect_polish_root (Curve const &A, double &s, Curve const &B, double &t) { - int status; - size_t iter = 0; std::vector as, bs; as = A.pointAndDerivatives(s, 2); bs = B.pointAndDerivatives(t, 2); diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 1e694eec5..2b230fc54 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -246,6 +246,7 @@ gdl_dock_bar_item_clicked (GtkWidget *button, { GdlDockBar *dockbar; GdlDockObject *controller; + (void)button; g_return_if_fail (item != NULL); @@ -394,6 +395,7 @@ static void gdl_dock_bar_layout_changed_cb (GdlDockMaster *master, GdlDockBar *dockbar) { + (void)master; update_dock_items (dockbar, FALSE); } diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 089eeb685..f4f628b5d 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -132,7 +132,6 @@ gdl_dock_item_grip_expose (GtkWidget *widget, gint layout_height; gint text_x; gint text_y; - gboolean item_or_child_has_focus; grip = GDL_DOCK_ITEM_GRIP (widget); gdl_dock_item_grip_get_title_area (grip, &title_area); @@ -201,6 +200,7 @@ gdl_dock_item_grip_item_notify (GObject *master, { GdlDockItemGrip *grip; gboolean cursor; + (void)master; grip = GDL_DOCK_ITEM_GRIP (data); @@ -318,6 +318,7 @@ static void gdl_dock_item_grip_close_clicked (GtkWidget *widget, GdlDockItemGrip *grip) { + (void)widget; g_return_if_fail (grip->item != NULL); gdl_dock_item_hide_item (grip->item); @@ -327,6 +328,7 @@ static void gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, GdlDockItemGrip *grip) { + (void)widget; g_return_if_fail (grip->item != NULL); gdl_dock_item_iconify_item (grip->item); @@ -556,8 +558,9 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, { GdlDockItemGrip *grip; GtkContainer *container; - GtkRequisition button_requisition = { 0, }; + GtkRequisition button_requisition; GtkAllocation child_allocation; + memset(&button_requisition, 0, sizeof(button_requisition)); g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); g_return_if_fail (allocation != NULL); @@ -625,6 +628,8 @@ static void gdl_dock_item_grip_add (GtkContainer *container, GtkWidget *widget) { + (void)container; + (void)widget; g_warning ("gtk_container_add not implemented for GdlDockItemGrip"); } @@ -632,6 +637,8 @@ static void gdl_dock_item_grip_remove (GtkContainer *container, GtkWidget *widget) { + (void)container; + (void)widget; g_warning ("gtk_container_remove not implemented for GdlDockItemGrip"); } @@ -656,6 +663,7 @@ gdl_dock_item_grip_forall (GtkContainer *container, static GType gdl_dock_item_grip_child_type (GtkContainer *container) { + (void)container; return G_TYPE_NONE; } diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c index 70273c886..5d0ac17ed 100644 --- a/src/libgdl/gdl-dock-paned.c +++ b/src/libgdl/gdl-dock-paned.c @@ -205,6 +205,7 @@ gdl_dock_paned_notify_cb (GObject *g_object, gpointer user_data) { GdlDockPaned *paned; + (void)g_object; g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data)); @@ -255,6 +256,7 @@ gdl_dock_paned_button_cb (GtkWidget *widget, gpointer user_data) { GdlDockPaned *paned; + (void)widget; g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data), FALSE); diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index e1785ae83..ca7763a55 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -352,6 +352,7 @@ gdl_dock_placeholder_detach (GdlDockObject *object, gboolean recursive) { GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object); + (void)recursive; /* disconnect handlers */ disconnect_host (ph); @@ -366,6 +367,7 @@ gdl_dock_placeholder_detach (GdlDockObject *object, static void gdl_dock_placeholder_reduce (GdlDockObject *object) { + (void)object; /* placeholders are not reduced */ return; } @@ -532,6 +534,8 @@ static void gdl_dock_placeholder_present (GdlDockObject *object, GdlDockObject *child) { + (void)object; + (void)child; /* do nothing */ return; } @@ -574,7 +578,8 @@ gdl_dock_placeholder_weak_notify (gpointer data, GObject *old_object) { GdlDockPlaceholder *ph; - + (void)old_object; + g_return_if_fail (data != NULL && GDL_IS_DOCK_PLACEHOLDER (data)); ph = GDL_DOCK_PLACEHOLDER (data); @@ -606,6 +611,7 @@ detach_cb (GdlDockObject *object, { GdlDockPlaceholder *ph; GdlDockObject *new_host, *obj; + (void)recursive; g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data)); @@ -735,7 +741,9 @@ dock_cb (GdlDockObject *object, { GdlDockPlacement pos = GDL_DOCK_NONE; GdlDockPlaceholder *ph; - + (void)position; + (void)other_data; + g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data)); ph = GDL_DOCK_PLACEHOLDER (user_data); g_return_if_fail (ph->_priv->host == object); diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c index 790bf7612..fb233fc3e 100644 --- a/src/libgdl/gdl-dock-tablabel.c +++ b/src/libgdl/gdl-dock-tablabel.c @@ -254,6 +254,7 @@ gdl_dock_tablabel_item_notify (GObject *master, gboolean locked; gchar *label; GtkBin *bin; + (void)pspec; g_object_get (master, "locked", &locked, -- cgit v1.2.3 From 53e7e03e0c4eb66e2664440e093474d27168711b Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 29 Jun 2011 20:45:59 +0200 Subject: Filters. New Edge detect custom filter and new options for the Drop shadow filter. (bzr r10388) --- src/extension/internal/filter/filter-all.cpp | 4 + src/extension/internal/filter/image.h | 113 +++++++++++++++++++++++++++ src/extension/internal/filter/shadows.h | 92 +++++++++++++++++----- 3 files changed, 189 insertions(+), 20 deletions(-) create mode 100644 src/extension/internal/filter/image.h (limited to 'src') diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 280dc9563..6ee849925 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -11,6 +11,7 @@ #include "abc.h" #include "color.h" #include "drop-shadow.h" +#include "image.h" #include "morphology.h" #include "shadows.h" #include "snow.h" @@ -57,6 +58,9 @@ Filter::filters_all (void ) Solarize::init(); Tritone::init(); + // Image + EdgeDetect::init(); + // Morphology Crosssmooth::init(); diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h new file mode 100644 index 000000000..480e836bd --- /dev/null +++ b/src/extension/internal/filter/image.h @@ -0,0 +1,113 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ +/* Change the 'IMAGE' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Image filters + * Edge detect + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Edge detect filter. + + Detect color edges in object. + + Filter's parameters: + * Detection type (enum, default Full) -> convolve (kernelMatrix) + * Level (0.01->10., default 1.) -> convolve (divisor) + * Inverted (boolean, default false) -> convolve (bias) +*/ +class EdgeDetect : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + EdgeDetect ( ) : Filter() { }; + virtual ~EdgeDetect ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Edge detect, custom (Image)") "\n" + "org.inkscape.effect.filter.EdgeDetect\n" + "\n" + "<_item value=\"all\">All\n" + "<_item value=\"vertical\">Vertical lines\n" + "<_item value=\"horizontal\">Horizontal lines\n" + "\n" + "1.0\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Detect color edges in object") "\n" + "\n" + "\n", new EdgeDetect()); + }; + +}; + +gchar const * +EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream matrix; + std::ostringstream inverted; + std::ostringstream level; + + const gchar *type = ext->get_param_enum("type"); + + level << ext->get_param_float("level"); + + if ((g_ascii_strcasecmp("vertical", type) == 0)) { + matrix << "0 0 0 1 -2 1 0 0 0"; + } else if ((g_ascii_strcasecmp("horizontal", type) == 0)) { + matrix << "0 1 0 0 -2 0 0 1 0"; + } else { + matrix << "1 1 1 1 -8 1 1 1 1"; + } + + if (ext->get_param_bool("inverted")) { + inverted << "1"; + } else { + inverted << "0"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); + + return _filter; +}; + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'IMAGE' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ */ diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index e29092ae9..e775d8398 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -7,7 +7,7 @@ * Ivan Louette (filters) * Nicolas Dufour (UI) * - * Color filters + * Shadow filters * Drop shadow * * Released under GNU GPL, read the file 'COPYING' for more information @@ -34,7 +34,12 @@ namespace Filter { * Blur radius (0.->200., default 3) -> blur (stdDeviation) * Horizontal offset (-50.->50., default 6.0) -> offset (dx) * Vertical offset (-50.->50., default 6.0) -> offset (dy) + * Blur type (enum, default outer) -> + outer = composite1 (operator="in"), composite2 (operator="over", in1="SourceGraphic", in2="offset") + inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic") + cutout = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") * Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color) + * Use object's color (boolean, default false) -> composite1 (in1, in2) */ class ColorizableDropShadow : public Inkscape::Extension::Internal::Filter::Filter { protected: @@ -47,21 +52,33 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drop shadow, custom (Shadows and Glows)") "\n" - "org.inkscape.effect.filter.ColorDropShadow\n" - "3.0\n" - "6.0\n" - "6.0\n" - "127\n" - "\n" - "all\n" - "\n" - "\n" - "\n" + "" N_("Drop shadow, custom (Shadows and Glows)") "\n" + "org.inkscape.effect.filter.ColorDropShadow\n" + "\n" + "\n" + "3.0\n" + "6.0\n" + "6.0\n" + "\n" + "<_item value=\"outer\">Outer\n" + "<_item value=\"inner\">Inner\n" + "<_item value=\"cutout\">Cutout\n" + "\n" + "\n" + "\n" + "127\n" + "false\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" "\n" - "\n" - "" N_("Colorizable Drop shadow") "\n" - "\n" + "\n" + "" N_("Colorizable Drop shadow") "\n" + "\n" "\n", new ColorizableDropShadow()); }; @@ -79,9 +96,15 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream b; std::ostringstream x; std::ostringstream y; - + std::ostringstream comp1in1; + std::ostringstream comp1in2; + std::ostringstream comp1op; + std::ostringstream comp2in1; + std::ostringstream comp2in2; + std::ostringstream comp2op; + + const gchar *type = ext->get_param_enum("type"); guint32 color = ext->get_param_color("color"); - blur << ext->get_param_float("blur"); x << ext->get_param_float("xoffset"); y << ext->get_param_float("yoffset"); @@ -90,14 +113,43 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); + if (ext->get_param_bool("objcolor")) { + comp1in1 << "SourceGraphic"; + comp1in2 << "flood"; + } else { + comp1in1 << "flood"; + comp1in2 << "SourceGraphic"; + } + + if ((g_ascii_strcasecmp("outer", type) == 0)) { + comp1op << "in"; + comp2op << "over"; + comp2in1 << "SourceGraphic"; + comp2in2 << "offset"; + } else if ((g_ascii_strcasecmp("inner", type) == 0)) { + comp1op << "out"; + comp2op << "atop"; + comp2in1 << "offset"; + comp2in2 << "SourceGraphic"; + } else { + comp1op << "in"; + comp2op << "out"; + comp2in1 << "offset"; + comp2in2 << "SourceGraphic"; + } + + _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" - "\n" - "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blur.str().c_str(), x.str().c_str(), y.str().c_str()); + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + comp1in1.str().c_str(), comp1in2.str().c_str(), comp1op.str().c_str(), + blur.str().c_str(), x.str().c_str(), y.str().c_str(), + comp2in1.str().c_str(), comp2in2.str().c_str(), comp2op.str().c_str()); return _filter; }; -- cgit v1.2.3 From 825d19f13b89ee5e2cc93391f6a86adf2bb12fa3 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 29 Jun 2011 21:27:23 +0200 Subject: Filters. Typos in the recently modified and added filters. Translations. POT files and French translation update. (bzr r10389) --- src/extension/internal/filter/image.h | 6 +++--- src/extension/internal/filter/shadows.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 480e836bd..926c56a4d 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -49,9 +49,9 @@ public: "" N_("Edge detect, custom (Image)") "\n" "org.inkscape.effect.filter.EdgeDetect\n" "\n" - "<_item value=\"all\">All\n" - "<_item value=\"vertical\">Vertical lines\n" - "<_item value=\"horizontal\">Horizontal lines\n" + "<_item value=\"all\">" N_("All") "\n" + "<_item value=\"vertical\">" N_("Vertical lines") "\n" + "<_item value=\"horizontal\">" N_("Horizontal lines") "\n" "\n" "1.0\n" "false\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index e775d8398..bfc6cace6 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -55,17 +55,17 @@ public: "" N_("Drop shadow, custom (Shadows and Glows)") "\n" "org.inkscape.effect.filter.ColorDropShadow\n" "\n" - "\n" + "\n" "3.0\n" "6.0\n" "6.0\n" "\n" - "<_item value=\"outer\">Outer\n" - "<_item value=\"inner\">Inner\n" - "<_item value=\"cutout\">Cutout\n" + "<_item value=\"outer\">" N_("Outer") "\n" + "<_item value=\"inner\">" N_("Inner") "\n" + "<_item value=\"cutout\">" N_("Cutout") "\n" "\n" "\n" - "\n" + "\n" "127\n" "false\n" "\n" -- cgit v1.2.3 From 1ab058e143e91cf7c3202cd65c940128b0ac00ee Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 29 Jun 2011 20:36:46 +0100 Subject: Corrected gdl pointer type error (bzr r10350.1.11) --- src/libgdl/gdl-dock-item-grip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 089eeb685..fc8ff11da 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -127,12 +127,11 @@ gdl_dock_item_grip_expose (GtkWidget *widget, GdlDockItemGrip *grip; GdkRectangle title_area; GdkRectangle expose_area; - GtkStyle *bg_style; + GdkGC *bg_style; gint layout_width; gint layout_height; gint text_x; gint text_y; - gboolean item_or_child_has_focus; grip = GDL_DOCK_ITEM_GRIP (widget); gdl_dock_item_grip_get_title_area (grip, &title_area); @@ -143,6 +142,7 @@ gdl_dock_item_grip_expose (GtkWidget *widget, gtk_widget_get_style (widget)->dark_gc[widget->state] : gtk_widget_get_style (widget)->mid_gc[widget->state]); + gdk_draw_rectangle (GDK_DRAWABLE (widget->window), bg_style, TRUE, 1, 0, widget->allocation.width - 1, widget->allocation.height); -- cgit v1.2.3 From d3e1979329c38de8e9973d9ef44a262d55c4436d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 30 Jun 2011 10:08:22 +0100 Subject: Minimise GTK version changes in text-edit dialog (bzr r10390.1.1) --- src/dialogs/text-edit.cpp | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 6d9985529..277ea92bc 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -346,42 +346,24 @@ sp_text_edit_dialog (void) #if GTK_CHECK_VERSION(2, 24,0) GtkWidget *c = gtk_combo_box_text_new_with_entry (); #else - GtkWidget *c = gtk_combo_new (); - gtk_combo_set_value_in_list ((GtkCombo *) c, FALSE, FALSE); - gtk_combo_set_use_arrows ((GtkCombo *) c, TRUE); - gtk_combo_set_use_arrows_always ((GtkCombo *) c, TRUE); + GtkWidget *c = gtk_combo_box_entry_new_text (); #endif gtk_widget_set_size_request (c, 90, -1); + { /* Setup strings */ + for (int i = 0; spacings[i]; i++) { //This would introduce dependency on gtk version 2.24 which is currently not available in // Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) //This conditional and its #else block can be deleted in the future. #if GTK_CHECK_VERSION(2, 24,0) - { /* Setup strings */ - for (int i = 0; spacings[i]; i++) { gtk_combo_box_text_append_text((GtkComboBoxText *) c, spacings[i]); - } - } #else - { /* Setup strings */ - GList *sl = NULL; - for (int i = 0; spacings[i]; i++) { - sl = g_list_prepend (sl, (void *) spacings[i]); + gtk_combo_box_append_text((GtkComboBox *) c, spacings[i]); +#endif } - sl = g_list_reverse (sl); - gtk_combo_set_popdown_strings ((GtkCombo *) c, sl); - g_list_free (sl); } -#endif -//This would introduce dependency on gtk version 2.24 which is currently not available in -// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) -//This conditional and its #else block can be deleted in the future. -#if GTK_CHECK_VERSION(2, 24,0) g_signal_connect ( (GObject *) c, -#else - g_signal_connect ( (GObject *) ((GtkCombo *) c)->entry, -#endif "changed", (GCallback) sp_text_edit_dialog_line_spacing_changed, dlg ); @@ -640,7 +622,7 @@ sp_get_text_dialog_style () #if GTK_CHECK_VERSION(2, 24,0) const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) combo); #else - const char *sstr = gtk_entry_get_text ((GtkEntry *) ((GtkCombo *) (combo))->entry); + const gchar *sstr = gtk_entry_get_text ((GtkEntry *) (gtk_bin_get_child (GTK_BIN (combo)))); #endif sp_repr_css_set_property (css, "line-height", sstr); @@ -766,9 +748,6 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, str = sp_te_get_string_multiline (text); if (str) { - int pos; - pos = 0; - if (items == 1) { gtk_text_buffer_set_text (tb, str, strlen (str)); gtk_text_buffer_set_modified (tb, FALSE); @@ -853,14 +832,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, else height = query->line_height.computed; gchar *sstr = g_strdup_printf ("%d%%", (int) floor(height * 100 + 0.5)); -//This would introduce dependency on gtk version 2.24 which is currently not available in -// Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011) -//This conditional and its #else block can be deleted in the future. -#if GTK_CHECK_VERSION(2, 24,0) gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) (combo)), sstr); -#else - gtk_entry_set_text ((GtkEntry *) ((GtkCombo *) (combo))->entry, sstr); -#endif g_free(sstr); sp_style_unref(query); -- cgit v1.2.3 From 8911d9a8ca0c7f4ef1476b2f056adf2afa4e99cd Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 30 Jun 2011 22:46:15 +0200 Subject: Implement decent snapping to text (baseline & anchor), and provide a toggle button for this (as requested in LP bug #727281 ) (bzr r10392) --- src/attributes-test.h | 1 + src/attributes.cpp | 1 + src/attributes.h | 1 + src/display/snap-indicator.cpp | 7 +- src/libnrtype/Layout-TNG-OutIter.cpp | 21 ++++ src/libnrtype/Layout-TNG.h | 2 + src/object-snapper.cpp | 230 ++++++++++++++++++++--------------- src/object-snapper.h | 1 + src/snap-enums.h | 69 ++++++----- src/snap-preferences.cpp | 7 +- src/snap-preferences.h | 4 +- src/sp-flowtext.cpp | 18 +-- src/sp-namedview.cpp | 5 + src/sp-text.cpp | 18 +-- src/ui/icon-names.h | 2 + src/widgets/toolbox.cpp | 18 +++ 16 files changed, 253 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/attributes-test.h b/src/attributes-test.h index 6a9570c37..dee29975e 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -355,6 +355,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:snap-smooth-nodes", true}, {"inkscape:snap-midpoints", true}, {"inkscape:snap-object-midpoints", true}, + {"inkscape:snap-text-baseline", true}, {"inkscape:snap-bbox-edge-midpoints", true}, {"inkscape:snap-bbox-midpoints", true}, //{"inkscape:snap-intersection-grid-guide", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index 334c3447c..47b261038 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -102,6 +102,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES, "inkscape:snap-smooth-nodes"}, {SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS, "inkscape:snap-midpoints"}, {SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS, "inkscape:snap-object-midpoints"}, + {SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE, "inkscape:snap-text-baseline"}, {SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, "inkscape:snap-bbox-edge-midpoints"}, {SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, "inkscape:snap-bbox-midpoints"}, {SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, "inkscape:snap-intersection-paths"}, diff --git a/src/attributes.h b/src/attributes.h index afa396507..2dec8b351 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -102,6 +102,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS, + SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, //SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE, diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index ec4b7e28f..e351a1145 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -141,6 +141,9 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_CORNER: target_name = _("corner"); break; + case SNAPTARGET_TEXT_ANCHOR: + target_name = _("text anchor"); + break; case SNAPTARGET_TEXT_BASELINE: target_name = _("text baseline"); break; @@ -206,8 +209,8 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPSOURCE_CORNER: source_name = _("Corner"); break; - case SNAPSOURCE_TEXT_BASELINE: - source_name = _("Text baseline"); + case SNAPSOURCE_TEXT_ANCHOR: + source_name = _("Text anchor"); break; case SNAPSOURCE_GRID_PITCH: source_name = _("Multiple of grid spacing"); diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index 4d461a486..1d300b210 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -13,6 +13,7 @@ #include "font-instance.h" #include "svg/svg-length.h" #include <2geom/transforms.h> +#include <2geom/line.h> #include "style.h" namespace Inkscape { @@ -250,6 +251,26 @@ boost::optional Layout::baselineAnchorPoint() const } } +Geom::Path Layout::baseline() const +{ + iterator pos = this->begin(); + Geom::Point left_pt = this->characterAnchorPoint(pos); + pos.thisEndOfLine(); + Geom::Point right_pt = this->characterAnchorPoint(pos); + + if (this->_blockProgression() == LEFT_TO_RIGHT || this->_blockProgression() == RIGHT_TO_LEFT) { + left_pt = Geom::Point(left_pt[Geom::Y], left_pt[Geom::X]); + right_pt = Geom::Point(right_pt[Geom::Y], right_pt[Geom::X]); + } + + Geom::Path baseline; + baseline.start(left_pt); + baseline.appendNew(right_pt); + + return baseline; +} + + Geom::Point Layout::chunkAnchorPoint(iterator const &it) const { unsigned chunk_index; diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 7d0c58c3e..6ab02c0e3 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -486,6 +486,8 @@ public: For rightmost text, the rightmost... you probably got it by now ;-)*/ boost::optional baselineAnchorPoint() const; + Geom::Path baseline() const; + /** This is that value to apply to the x,y attributes of tspan role=line elements, and hence it takes alignment into account. */ Geom::Point chunkAnchorPoint(iterator const &it) const; diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 3088accd2..1944f7ffa 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -183,7 +183,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; - // A point considered for snapping should be either a node, a bbox corner or a guide. Pick only ONE! + // A point considered for snapping should be either a node, a bbox corner or a guide/other. Pick only ONE! g_assert(!((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))); if (_snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()) { @@ -282,27 +282,30 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, SnappedPoint s; bool success = false; + bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); for (std::vector::const_iterator k = _points_to_snap_to->begin(); k != _points_to_snap_to->end(); k++) { - Geom::Point target_pt = (*k).getPoint(); - Geom::Coord dist = NR_HUGE; - if (!c.isUndefined()) { - // We're snapping to nodes along a constraint only, so find out if this node - // is at the constraint, while allowing for a small margin - if (Geom::L2(target_pt - c.projection(target_pt)) > 1e-9) { - // The distance from the target point to its projection on the constraint - // is too large, so this point is not on the constraint. Skip it! - continue; + if (_allowSourceToSnapToTarget(p.getSourceType(), (*k).getTargetType(), strict_snapping)) { + Geom::Point target_pt = (*k).getPoint(); + Geom::Coord dist = NR_HUGE; + if (!c.isUndefined()) { + // We're snapping to nodes along a constraint only, so find out if this node + // is at the constraint, while allowing for a small margin + if (Geom::L2(target_pt - c.projection(target_pt)) > 1e-9) { + // The distance from the target point to its projection on the constraint + // is too large, so this point is not on the constraint. Skip it! + continue; + } + dist = Geom::L2(target_pt - p_proj_on_constraint); + } else { + // Free (unconstrained) snapping + dist = Geom::L2(target_pt - p.getPoint()); } - dist = Geom::L2(target_pt - p_proj_on_constraint); - } else { - // Free (unconstrained) snapping - dist = Geom::L2(target_pt - p.getPoint()); - } - if (dist < getSnapperTolerance() && dist < s.getSnapDistance()) { - s = SnappedPoint(target_pt, p.getSourceType(), p.getSourceNum(), (*k).getTargetType(), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox()); - success = true; + if (dist < getSnapperTolerance() && dist < s.getSnapDistance()) { + s = SnappedPoint(target_pt, p.getSourceType(), p.getSourceNum(), (*k).getTargetType(), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox()); + success = true; + } } } @@ -394,44 +397,46 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, //Build a list of all paths considered for snapping to //Add the item's path to snap to - if (_snapmanager->snapprefs.getSnapToItemPath() && (_snapmanager->snapprefs.getSnapModeNode() || _snapmanager->snapprefs.getSnapModeOthers())) { + if ((_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode()) || + (_snapmanager->snapprefs.getSnapTextBaseline() && (_snapmanager->snapprefs.getSnapModeNode() || _snapmanager->snapprefs.getSnapToItemPath())) ) { if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node)) { - // Snapping to the path of characters is very cool, but for a large - // chunk of text this will take ages! So limit snapping to text paths - // containing max. 240 characters. Snapping the bbox will not be affected - bool very_lenghty_prose = false; if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { - very_lenghty_prose = sp_text_get_length(SP_TEXT(root_item)) > 240; - } - // On my AMD 3000+, the snapping lag becomes annoying at approx. 240 chars - // which corresponds to a lag of 500 msec. This is for snapping a rect - // to a single line of text. - - // Snapping for example to a traced bitmap is also very stressing for - // the CPU, so we'll only snap to paths having no more than 500 nodes - // This also leads to a lag of approx. 500 msec (in my lousy test set-up). - bool very_complex_path = false; - if (SP_IS_PATH(root_item)) { - very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; - } - - if (!very_lenghty_prose && !very_complex_path && root_item) { - SPCurve *curve = NULL; - if (SP_IS_SHAPE(root_item)) { - curve = SP_SHAPE(root_item)->getCurve(); - } else if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { - curve = te_get_layout(root_item)->convertToCurves(); + if (_snapmanager->snapprefs.getSnapTextBaseline()) { + // Snap to the text baseline + Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) root_item); + if (layout != NULL && layout->outputExists()) { + Geom::PathVector *pv = new Geom::PathVector(); + pv->push_back(layout->baseline() * root_item->i2d_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt()); + _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_TEXT_BASELINE, Geom::OptRect())); + } + } + } else { + // Snapping for example to a traced bitmap is very stressing for + // the CPU, so we'll only snap to paths having no more than 500 nodes + // This also leads to a lag of approx. 500 msec (in my lousy test set-up). + bool very_complex_path = false; + if (SP_IS_PATH(root_item)) { + very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; } - if (curve) { - // We will get our own copy of the pathvector, which must be freed at some point - // Geom::PathVector *pv = pathvector_for_curve(root_item, curve, true, true, Geom::identity(), (*i).additional_affine); + if (!very_complex_path && root_item && (_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode())) { + SPCurve *curve = NULL; + if (SP_IS_SHAPE(root_item)) { + curve = SP_SHAPE(root_item)->getCurve(); + }/* else if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { + curve = te_get_layout(root_item)->convertToCurves(); + }*/ + if (curve) { + // We will get our own copy of the pathvector, which must be freed at some point + + // Geom::PathVector *pv = pathvector_for_curve(root_item, curve, true, true, Geom::identity(), (*i).additional_affine); - Geom::PathVector *pv = new Geom::PathVector(curve->get_pathvector()); - (*pv) *= root_item->i2d_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); + Geom::PathVector *pv = new Geom::PathVector(curve->get_pathvector()); + (*pv) *= root_item->i2d_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. - curve->unref(); + _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. + curve->unref(); + } } } } @@ -490,54 +495,58 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, int num_path = 0; int num_segm = 0; - for (std::vector::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { - bool const being_edited = node_tool_active && (*it_p).currently_being_edited; - //if true then this pathvector it_pv is currently being edited in the node tool - - for(Geom::PathVector::iterator it_pv = (it_p->path_vector)->begin(); it_pv != (it_p->path_vector)->end(); ++it_pv) { - // Find a nearest point for each curve within this path - // n curves will return n time values with 0 <= t <= 1 - std::vector anp = (*it_pv).nearestPointPerCurve(p_doc); + bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); - std::vector::const_iterator np = anp.begin(); - unsigned int index = 0; - for (; np != anp.end(); np++, index++) { - Geom::Curve const *curve = &((*it_pv).at_index(index)); - Geom::Point const sp_doc = curve->pointAt(*np); - - bool c1 = true; - bool c2 = true; - if (being_edited) { - /* If the path is being edited, then we should only snap though to stationary pieces of the path - * and not to the pieces that are being dragged around. This way we avoid - * self-snapping. For this we check whether the nodes at both ends of the current - * piece are unselected; if they are then this piece must be stationary - */ - g_assert(unselected_nodes != NULL); - Geom::Point start_pt = _snapmanager->getDesktop()->doc2dt(curve->pointAt(0)); - Geom::Point end_pt = _snapmanager->getDesktop()->doc2dt(curve->pointAt(1)); - c1 = isUnselectedNode(start_pt, unselected_nodes); - c2 = isUnselectedNode(end_pt, unselected_nodes); - /* Unfortunately, this might yield false positives for coincident nodes. Inkscape might therefore mistakenly - * snap to path segments that are not stationary. There are at least two possible ways to overcome this: - * - Linking the individual nodes of the SPPath we have here, to the nodes of the NodePath::SubPath class as being - * used in sp_nodepath_selected_nodes_move. This class has a member variable called "selected". For this the nodes - * should be in the exact same order for both classes, so we can index them - * - Replacing the SPPath being used here by the the NodePath::SubPath class; but how? - */ - } + for (std::vector::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { + if (_allowSourceToSnapToTarget(p.getSourceType(), (*it_p).target_type, strict_snapping)) { + bool const being_edited = node_tool_active && (*it_p).currently_being_edited; + //if true then this pathvector it_pv is currently being edited in the node tool + + for(Geom::PathVector::iterator it_pv = (it_p->path_vector)->begin(); it_pv != (it_p->path_vector)->end(); ++it_pv) { + // Find a nearest point for each curve within this path + // n curves will return n time values with 0 <= t <= 1 + std::vector anp = (*it_pv).nearestPointPerCurve(p_doc); + + std::vector::const_iterator np = anp.begin(); + unsigned int index = 0; + for (; np != anp.end(); np++, index++) { + Geom::Curve const *curve = &((*it_pv).at_index(index)); + Geom::Point const sp_doc = curve->pointAt(*np); + + bool c1 = true; + bool c2 = true; + if (being_edited) { + /* If the path is being edited, then we should only snap though to stationary pieces of the path + * and not to the pieces that are being dragged around. This way we avoid + * self-snapping. For this we check whether the nodes at both ends of the current + * piece are unselected; if they are then this piece must be stationary + */ + g_assert(unselected_nodes != NULL); + Geom::Point start_pt = _snapmanager->getDesktop()->doc2dt(curve->pointAt(0)); + Geom::Point end_pt = _snapmanager->getDesktop()->doc2dt(curve->pointAt(1)); + c1 = isUnselectedNode(start_pt, unselected_nodes); + c2 = isUnselectedNode(end_pt, unselected_nodes); + /* Unfortunately, this might yield false positives for coincident nodes. Inkscape might therefore mistakenly + * snap to path segments that are not stationary. There are at least two possible ways to overcome this: + * - Linking the individual nodes of the SPPath we have here, to the nodes of the NodePath::SubPath class as being + * used in sp_nodepath_selected_nodes_move. This class has a member variable called "selected". For this the nodes + * should be in the exact same order for both classes, so we can index them + * - Replacing the SPPath being used here by the the NodePath::SubPath class; but how? + */ + } - Geom::Point const sp_dt = _snapmanager->getDesktop()->doc2dt(sp_doc); - if (!being_edited || (c1 && c2)) { - Geom::Coord const dist = Geom::distance(sp_doc, p_doc); - if (dist < getSnapperTolerance()) { - sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + Geom::Point const sp_dt = _snapmanager->getDesktop()->doc2dt(sp_doc); + if (!being_edited || (c1 && c2)) { + Geom::Coord const dist = Geom::distance(sp_doc, p_doc); + if (dist < getSnapperTolerance()) { + sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + } } } - } - num_segm++; - } // End of: for (Geom::PathVector::iterator ....) - num_path++; + num_segm++; + } // End of: for (Geom::PathVector::iterator ....) + num_path++; + } } } @@ -599,10 +608,12 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, } // Length of constraint_path will always be one + bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); + // Find all intersections of the constrained path with the snap target candidates std::vector intersections; for (std::vector::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { - if (k->path_vector) { + if (k->path_vector && _allowSourceToSnapToTarget(p.getSourceType(), (*k).target_type, strict_snapping)) { // Do the intersection math Geom::CrossingSet cs = Geom::crossings(constraint_path, *(k->path_vector)); // Store the results as intersection points @@ -681,7 +692,8 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, )) || (_snapmanager->snapprefs.getSnapModeAny() && ( _snapmanager->snapprefs.getIncludeItemCenter() || _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getSnapObjectMidpoints() + _snapmanager->snapprefs.getSnapObjectMidpoints() || + _snapmanager->snapprefs.getSnapTextBaseline() )) ; if (snap_nodes) { @@ -690,7 +702,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, if ((_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath()) || (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath()) || - (_snapmanager->snapprefs.getSnapModeAny() && _snapmanager->snapprefs.getSnapToPageBorder())) { + _snapmanager->snapprefs.getSnapModeAny()) { unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size(); if (n > 0) { /* While editing a path in the node tool, findCandidates must ignore that path because @@ -748,7 +760,8 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, )) || (_snapmanager->snapprefs.getSnapModeAny() && ( _snapmanager->snapprefs.getIncludeItemCenter() || _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapToPageBorder() + _snapmanager->snapprefs.getSnapToPageBorder() || + _snapmanager->snapprefs.getSnapTextBaseline() )); if (snap_nodes) { @@ -808,7 +821,8 @@ bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const )) || (_snapmanager->snapprefs.getSnapModeAny() && ( _snapmanager->snapprefs.getSnapToPageBorder() || _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapObjectMidpoints() + _snapmanager->snapprefs.getSnapObjectMidpoints() || + _snapmanager->snapprefs.getSnapTextBaseline() )); return (_snap_enabled && snap_to_something); @@ -873,6 +887,24 @@ void Inkscape::getBBoxPoints(Geom::OptRect const bbox, } } +bool Inkscape::ObjectSnapper::_allowSourceToSnapToTarget(SnapSourceType source, SnapTargetType target, bool strict_snapping) const +{ + bool allow_this_pair_to_snap = false; + + if (strict_snapping) { // bounding boxes will not snap to nodes/paths and vice versa + int source_cat = source & (SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY); + int target_cat = target & (SNAPTARGET_BBOX_CATEGORY | SNAPTARGET_NODE_CATEGORY | SNAPTARGET_OTHERS_CATEGORY); + if (source_cat == target_cat || source_cat == SNAPSOURCE_OTHERS_CATEGORY || target_cat == SNAPTARGET_OTHERS_CATEGORY) { + allow_this_pair_to_snap = true; + } + } else { // anything will snap to anything + allow_this_pair_to_snap = true; + } + + return allow_this_pair_to_snap; +} + + /* Local Variables: mode:c++ diff --git a/src/object-snapper.h b/src/object-snapper.h index 6e3cc620f..00fb18923 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -106,6 +106,7 @@ private: Geom::PathVector* _getBorderPathv() const; Geom::PathVector* _getPathvFromRect(Geom::Rect const rect) const; void _getBorderNodes(std::vector *points) const; + bool _allowSourceToSnapToTarget(SnapSourceType source, SnapTargetType target, bool strict_snapping) const; }; // end of ObjectSnapper class diff --git a/src/snap-enums.h b/src/snap-enums.h index 8988589a1..6ef021fc0 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -15,36 +15,6 @@ namespace Inkscape { -enum SnapTargetType { - SNAPTARGET_UNDEFINED = 0, - SNAPTARGET_GRID, - SNAPTARGET_GRID_INTERSECTION, - SNAPTARGET_GUIDE, - SNAPTARGET_GUIDE_INTERSECTION, - SNAPTARGET_GUIDE_ORIGIN, - SNAPTARGET_GRID_GUIDE_INTERSECTION, - SNAPTARGET_NODE_SMOOTH, - SNAPTARGET_NODE_CUSP, - SNAPTARGET_LINE_MIDPOINT, - SNAPTARGET_OBJECT_MIDPOINT, - SNAPTARGET_ROTATION_CENTER, - SNAPTARGET_HANDLE, - SNAPTARGET_PATH, - SNAPTARGET_PATH_INTERSECTION, - SNAPTARGET_BBOX_CORNER, - SNAPTARGET_BBOX_EDGE, - SNAPTARGET_BBOX_EDGE_MIDPOINT, - SNAPTARGET_BBOX_MIDPOINT, - SNAPTARGET_PAGE_BORDER, - SNAPTARGET_PAGE_CORNER, - SNAPTARGET_CONVEX_HULL_CORNER, - SNAPTARGET_ELLIPSE_QUADRANT_POINT, - SNAPTARGET_CORNER, // of image or of rectangle - SNAPTARGET_TEXT_BASELINE, - SNAPTARGET_CONSTRAINED_ANGLE, - SNAPTARGET_CONSTRAINT -}; - enum SnapSourceType { SNAPSOURCE_UNDEFINED = 0, //------------------------------------------------------------------- @@ -72,10 +42,47 @@ enum SnapSourceType { SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, ellipses, polygon, etc. SNAPSOURCE_GUIDE, SNAPSOURCE_GUIDE_ORIGIN, - SNAPSOURCE_TEXT_BASELINE, + SNAPSOURCE_TEXT_ANCHOR, SNAPSOURCE_OTHER_HANDLE, // eg. the handle of a gradient or of a connector (ie not being tied to a stroke) SNAPSOURCE_GRID_PITCH, // eg. when pasting or alt-dragging in the selector tool; not realy a snap source }; +enum SnapTargetType { + SNAPTARGET_UNDEFINED = 0, + //------------------------------------------------------------------- + SNAPTARGET_BBOX_CATEGORY = 256, // will be used as a flag and must therefore be a power of two + SNAPTARGET_BBOX_CORNER, + SNAPTARGET_BBOX_EDGE, + SNAPTARGET_BBOX_EDGE_MIDPOINT, + SNAPTARGET_BBOX_MIDPOINT, + //------------------------------------------------------------------- + SNAPTARGET_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two + SNAPTARGET_NODE_SMOOTH, + SNAPTARGET_NODE_CUSP, + SNAPTARGET_LINE_MIDPOINT, + SNAPTARGET_PATH, + SNAPTARGET_PATH_INTERSECTION, + SNAPTARGET_ELLIPSE_QUADRANT_POINT, + SNAPTARGET_CORNER, // of image or of rectangle + //------------------------------------------------------------------- + SNAPTARGET_OTHERS_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two + SNAPTARGET_GRID, + SNAPTARGET_GRID_INTERSECTION, + SNAPTARGET_GUIDE, + SNAPTARGET_GUIDE_INTERSECTION, + SNAPTARGET_GUIDE_ORIGIN, + SNAPTARGET_GRID_GUIDE_INTERSECTION, + SNAPTARGET_OBJECT_MIDPOINT, + SNAPTARGET_ROTATION_CENTER, + SNAPTARGET_HANDLE, + SNAPTARGET_PAGE_BORDER, + SNAPTARGET_PAGE_CORNER, + SNAPTARGET_CONVEX_HULL_CORNER, + SNAPTARGET_TEXT_ANCHOR, + SNAPTARGET_TEXT_BASELINE, + SNAPTARGET_CONSTRAINED_ANGLE, + SNAPTARGET_CONSTRAINT +}; + } #endif /* SNAPENUMS_H_ */ diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 816320145..fba9beb43 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -32,10 +32,11 @@ Inkscape::SnapPreferences::SnapPreferences() : /* * The snappers have too many parameters to adjust individually. Therefore only - * two snapping modes are presented to the user: snapping bounding box corners (to + * three snapping modes are presented to the user: snapping bounding box corners (to * other bounding boxes, grids or guides), and/or snapping nodes (to other nodes, - * paths, grids or guides). To select either of these modes (or both), use the - * methods defined below: setSnapModeBBox() and setSnapModeNode(). + * paths, grids or guides), and or snapping to/from others (e.g. grids, guide, text, etc) + * To select either of these three modes (or all), use the + * methods defined below: setSnapModeBBox(), setSnapModeNode(), or setSnapModeOthers() * * */ diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 4f3ad6ce6..8e8ebc9cf 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -40,6 +40,7 @@ public: void setSnapSmoothNodes(bool enabled) {_smoothNodes = enabled;} void setSnapLineMidpoints(bool enabled) {_line_midpoints = enabled;} void setSnapObjectMidpoints(bool enabled) {_object_midpoints = enabled;} + void setSnapTextBaseline(bool enabled) {_text_baseline = enabled;} void setSnapBBoxEdgeMidpoints(bool enabled) {_bbox_edge_midpoints = enabled;} void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;} bool getSnapIntersectionGG() const {return _intersectionGG;} @@ -47,6 +48,7 @@ public: bool getSnapSmoothNodes() const {return _smoothNodes;} bool getSnapLineMidpoints() const {return _line_midpoints;} bool getSnapObjectMidpoints() const {return _object_midpoints;} + bool getSnapTextBaseline() const {return _text_baseline;} bool getSnapBBoxEdgeMidpoints() const {return _bbox_edge_midpoints;} bool getSnapBBoxMidpoints() const {return _bbox_midpoints;} @@ -89,7 +91,6 @@ public: void setGuideTolerance(gdouble val) {_guide_tolerance = val;} void setObjectTolerance(gdouble val) {_object_tolerance = val;} - private: bool _include_item_center; //If true, snapping nodes will also snap the item's center bool _intersectionGG; //Consider snapping to intersections of grid and guides @@ -97,6 +98,7 @@ private: bool _smoothNodes; bool _line_midpoints; bool _object_midpoints; // the midpoint of shapes (e.g. a circle, rect, polygon) or of any other shape (at [h/2, w/2]) + bool _text_baseline; // both anchor point and baseline of the text bool _bbox_edge_midpoints; bool _bbox_midpoints; bool _snap_to_grids; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index d7bc0053f..3413999a9 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -388,15 +388,17 @@ static gchar *sp_flowtext_description(SPItem *item) } } -static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - // Choose a point on the baseline for snapping from or to, with the horizontal position - // of this point depending on the text alignment (left vs. right) - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); - if (layout != NULL && layout->outputExists()) { - boost::optional pt = layout->baselineAnchorPoint(); - if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + if (snapprefs->getSnapTextBaseline()) { + // Choose a point on the baseline for snapping from or to, with the horizontal position + // of this point depending on the text alignment (left vs. right) + Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); + if (layout != NULL && layout->outputExists()) { + boost::optional pt = layout->baselineAnchorPoint(); + if (pt) { + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); + } } } } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 515658d0b..97fd97570 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -257,6 +257,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: object->readAttr( "inkscape:snap-smooth-nodes" ); object->readAttr( "inkscape:snap-midpoints" ); object->readAttr( "inkscape:snap-object-midpoints" ); + object->readAttr( "inkscape:snap-text-baseline" ); object->readAttr( "inkscape:snap-bbox-edge-midpoints" ); object->readAttr( "inkscape:snap-bbox-midpoints" ); object->readAttr( "inkscape:snap-to-guides" ); @@ -493,6 +494,10 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: + nv->snap_manager.snapprefs.setSnapTextBaseline(value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 3f30c2422..f7ba7592b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -441,15 +441,17 @@ static char * sp_text_description(SPItem *item) return ret; } -static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - // Choose a point on the baseline for snapping from or to, with the horizontal position - // of this point depending on the text alignment (left vs. right) - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); - if (layout != NULL && layout->outputExists()) { - boost::optional pt = layout->baselineAnchorPoint(); - if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + if (snapprefs->getSnapTextBaseline()) { + // Choose a point on the baseline for snapping from or to, with the horizontal position + // of this point depending on the text alignment (left vs. right) + Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); + if (layout != NULL && layout->outputExists()) { + boost::optional pt = layout->baselineAnchorPoint(); + if (pt) { + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); + } } } } diff --git a/src/ui/icon-names.h b/src/ui/icon-names.h index cf459b563..8935b1def 100644 --- a/src/ui/icon-names.h +++ b/src/ui/icon-names.h @@ -470,6 +470,8 @@ "snap-nodes-path" #define INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER \ "snap-nodes-rotation-center" +#define INKSCAPE_ICON_SNAP_TEXT_BASELINE \ + "snap-text-baseline" #define INKSCAPE_ICON_SNAP_NODES_SMOOTH \ "snap-nodes-smooth" #define INKSCAPE_ICON_SNAP_PAGE \ diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 7789484fd..5d065c3e9 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2208,6 +2208,10 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.getSnapObjectMidpoints(); sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v); break; + case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: + v = nv->snap_manager.snapprefs.getSnapTextBaseline(); + sp_repr_set_boolean(repr, "inkscape:snap-text-baseline", !v); + break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: v = nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints(); sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v); @@ -2252,6 +2256,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) " " " " " " + " " " " " " " " @@ -2401,6 +2406,16 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); } + { + InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromTextBaseline", + _("Text baseline"), _("Snap from and to text anchors and baselines"), + INKSCAPE_ICON_SNAP_TEXT_BASELINE, secondarySize, SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE); + + gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); + } + + { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPageBorder", _("Page border"), _("Snap to the page border"), INKSCAPE_ICON_SNAP_PAGE, @@ -2493,6 +2508,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev Glib::RefPtr act10 = mainActions->get_action("ToggleSnapFromOthers"); Glib::RefPtr act10b = mainActions->get_action("ToggleSnapToFromObjectCenters"); Glib::RefPtr act11 = mainActions->get_action("ToggleSnapToFromRotationCenter"); + Glib::RefPtr act11b = mainActions->get_action("ToggleSnapToFromTextBaseline"); Glib::RefPtr act12 = mainActions->get_action("ToggleSnapToPageBorder"); //Glib::RefPtr act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); Glib::RefPtr act14 = mainActions->get_action("ToggleSnapToGrids"); @@ -2547,6 +2563,8 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_action_set_sensitive(GTK_ACTION(act10b->gobj()), c1 && c5); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter()); gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11b->gobj()), nv->snap_manager.snapprefs.getSnapTextBaseline()); + gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.getSnapToPageBorder()); gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1); -- cgit v1.2.3 From e1278f8d1a67c682e0750b3b6ae7636957bb7382 Mon Sep 17 00:00:00 2001 From: Gellule Xg Date: Thu, 30 Jun 2011 17:07:08 -1000 Subject: Give a chance to a shape to have an up to date curve before approximating it with points. Fixes connector bug #640985. Fixed bugs: - https://launchpad.net/bugs/640985 (bzr r10393) --- src/conn-avoid-ref.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 4c6139672..fad11bb89 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -491,6 +491,7 @@ static std::vector approxItemWithPoints(SPItem const *item, const G } else if (SP_IS_SHAPE(item)) { + SP_SHAPE(item)->setShape(); SPCurve* item_curve = SP_SHAPE(item)->getCurve(); // make sure it has an associated curve if (item_curve) -- cgit v1.2.3 From 5d78ed8682cb5f5a0092adba82f1b133fbc887a8 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 1 Jul 2011 23:05:43 +0200 Subject: Gradient context: Don't try to snap when no gradient will be drawn (i.e. when no item has been selected) (bzr r10394) --- src/gradient-context.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 33b82b9f4..8b4d2bc37 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -557,10 +557,12 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (!(event->button.state & GDK_CONTROL_MASK)) event_context->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE); - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); - m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); - m.unSetup(); + if (!selection->isEmpty()) { + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); + m.unSetup(); + } rc->origin = from_2geom(button_dt); } @@ -595,7 +597,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } else { - if (!drag->mouseOver()) { + if (!drag->mouseOver() && !selection->isEmpty()) { SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); -- cgit v1.2.3 From f3bf09df146ade30f8c5dffbccc8d7331327076a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 1 Jul 2011 22:08:17 +0100 Subject: Remove some deprecated Gtk+ headers (bzr r10395) --- src/widgets/font-selector.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 965910ba2..b3846e1b8 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -26,13 +26,6 @@ #include <2geom/transforms.h> #include -#include -#include -#include -#include -#include -#include -#include #include -- cgit v1.2.3 From 3095feac587524a45c12f3a084f6bc14e4f10cad Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 2 Jul 2011 00:36:32 +0100 Subject: Migrate clonetiler to GtkComboBox (bzr r10390.1.2) --- src/dialogs/clonetiler.cpp | 58 ++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 79a378710..e79de069a 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1556,10 +1556,10 @@ static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double return hb; } -static void clonetiler_symgroup_changed(GtkMenuItem */*item*/, gpointer data) +static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint group_new = GPOINTER_TO_INT (data); + gint group_new = gtk_combo_box_get_active (cb); prefs->setInt(prefs_path + "symmetrygroup", group_new); } @@ -1811,21 +1811,14 @@ void clonetiler_dialog(void) // Symmetry { GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); - - GtkWidget *om = gtk_option_menu_new (); - /* TRANSLATORS: For the following 17 symmetry groups, see + + /* TRANSLATORS: For the following 17 symmetry groups, see * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary). */ - gtk_widget_set_tooltip_text (om, _("Select one of the 17 symmetry groups for the tiling")); - gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN); - - GtkWidget *m = gtk_menu_new (); - int current = prefs->getInt(prefs_path + "symmetrygroup", 0); - struct SymGroups { - int group; + gint group; gchar const *label; } const sym_groups[] = { // TRANSLATORS: "translation" means "shift" / "displacement" here. @@ -1850,25 +1843,40 @@ void clonetiler_dialog(void) {TILE_P6M, _("P6M: reflection + 60° rotation")}, }; - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { + gint current = prefs->getInt(prefs_path + "symmetrygroup", 0); + + // Create a list structure containing all the data to be displayed in + // the symmetry group combo box. + GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); + GtkTreeIter iter; + + for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { SymGroups const &sg = sym_groups[j]; - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), sg.label); - gtk_misc_set_alignment (GTK_MISC(l), 0, 0.5); + // Add the description of the symgroup to a new row + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + 0, sg.label, + -1); + } - GtkWidget *item = gtk_menu_item_new (); - gtk_container_add (GTK_CONTAINER (item), l); + // Add a new combo box widget with the list of symmetry groups to the vbox + GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling")); + gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN); - g_signal_connect ( G_OBJECT (item), "activate", - G_CALLBACK (clonetiler_symgroup_changed), - GINT_TO_POINTER (sg.group) ); + // Specify the rendering of data from the list in a combo box cell + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "markup", 0, + NULL); - gtk_menu_shell_append(GTK_MENU_SHELL (m), item); - } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); - gtk_option_menu_set_menu (GTK_OPTION_MENU (om), m); - gtk_option_menu_set_history ( GTK_OPTION_MENU (om), current); + g_signal_connect (G_OBJECT (combo), "changed", + G_CALLBACK (clonetiler_symgroup_changed), + NULL); } table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); -- cgit v1.2.3 From 2045221082a4aed0dcbbd71d36393a2498396a10 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Jul 2011 09:58:37 +0000 Subject: added missing header (bzr r10397) --- src/2geom/CMakeLists.txt | 3 +++ src/CMakeLists.txt | 5 ++++- src/dom/CMakeLists.txt | 1 + src/extension/CMakeLists.txt | 1 + src/filters/CMakeLists.txt | 1 + src/libcroco/CMakeLists.txt | 3 +++ src/libnr/CMakeLists.txt | 1 + src/libnrtype/CMakeLists.txt | 3 +++ src/livarot/CMakeLists.txt | 3 +++ src/live_effects/CMakeLists.txt | 1 + src/svg/CMakeLists.txt | 3 +++ src/util/CMakeLists.txt | 3 +++ src/widgets/CMakeLists.txt | 3 +++ src/xml/CMakeLists.txt | 3 +++ 14 files changed, 33 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index c04718e79..bc3f64bdc 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -46,6 +46,9 @@ set(2geom_SRC transforms.cpp utils.cpp + + # ------- + # Headers affine.h angle.h basic-intersection.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c508e36d9..2e83a1604 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,7 +74,10 @@ set(sp_SRC sp-use.cpp spiral-context.cpp splivarot.cpp - + + + # ------- + # Headers sp-anchor.h sp-animation.h sp-clippath.h diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index c90b204f0..df2411b13 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -32,6 +32,7 @@ set(dom_SRC util/thread.cpp util/ziptool.cpp + # ------- # Headers css.h diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 5ccb5c984..c9c466bb0 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -118,6 +118,7 @@ set(extension_SRC internal/filter/drop-shadow.h internal/filter/experimental.h internal/filter/filter.h + internal/filter/image.h internal/filter/morphology.h internal/filter/shadows.h internal/filter/snow.h diff --git a/src/filters/CMakeLists.txt b/src/filters/CMakeLists.txt index 7c698777d..50d4bc33a 100644 --- a/src/filters/CMakeLists.txt +++ b/src/filters/CMakeLists.txt @@ -22,6 +22,7 @@ set(filters_SRC tile.cpp turbulence.cpp + # ------- # Headers blend.h diff --git a/src/libcroco/CMakeLists.txt b/src/libcroco/CMakeLists.txt index 890f58825..af7f49654 100644 --- a/src/libcroco/CMakeLists.txt +++ b/src/libcroco/CMakeLists.txt @@ -28,6 +28,9 @@ set(libcroco_SRC cr-token.c cr-utils.c + + # ------- + # Headers cr-additional-sel.h cr-attr-sel.h cr-cascade.h diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index b310068c0..b83358ae0 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -13,6 +13,7 @@ set(nr_SRC nr-values.cpp # testnr.cpp + # ------- # Headers # in-svg-plane-test.h diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 3d52e2c4e..1b28eb8e4 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -14,6 +14,9 @@ set(nrtype_SRC nr-type-primitives.cpp TextWrapper.cpp + + # ------- + # Headers FontFactory.h Layout-TNG-Scanline-Maker.h Layout-TNG.h diff --git a/src/livarot/CMakeLists.txt b/src/livarot/CMakeLists.txt index 1890bd1a7..83e0f40c8 100644 --- a/src/livarot/CMakeLists.txt +++ b/src/livarot/CMakeLists.txt @@ -21,6 +21,9 @@ set(livarot_SRC sweep-tree.cpp sweep-tree-list.cpp + + # ------- + # Headers AVL.h AlphaLigne.h BitLigne.h diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 3bca16715..01cd7f25f 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -53,6 +53,7 @@ set(live_effects_SRC parameter/unit.cpp parameter/vector.cpp + # ------- # Headers bezctx.h diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index 9a721969a..943c3088f 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -14,6 +14,9 @@ set(svg_SRC svg-path.cpp # test-stubs.cpp + + # ------- + # Headers css-ostringstream-test.h css-ostringstream.h path-string.h diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 5c8411437..cfccfa94d 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -6,6 +6,9 @@ set(util_SRC share.cpp units.cpp + + # ------- + # Headers accumulators.h compose.hpp copy.h diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 1a203afc6..418cc5c6f 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -34,6 +34,9 @@ set(widgets_SRC swatch-selector.cpp toolbox.cpp + + # ------- + # Headers button.h dash-selector.h desktop-widget.h diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index d7a0e197d..4f86599de 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -17,6 +17,9 @@ set(xml_SRC helper-observer.cpp rebase-hrefs.cpp + + # ------- + # Headers attribute-record.h comment-node.h composite-node-observer.h -- cgit v1.2.3 From 353dc258f73b43bbd6b49d1c4331facd45bfd773 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Jul 2011 12:08:37 +0000 Subject: compatibility for building with clang, this failed for 2 reasons. - redefining the variable 'i' - the comparison between iterators didn't work. double checked this is the only use of shadowed 'i' so this has no functional changes. (bzr r10398) --- src/graphlayout.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 4f536beb3..2717c376a 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -156,11 +156,12 @@ void graphlayout(GSList const *const items) { ++i) { SPItem *iu=*i; - map::iterator i=nodelookup.find(iu->getId()); - if(i==nodelookup.end()) { + map::iterator i_iter=nodelookup.find(iu->getId()); + map::iterator i_iter_end=nodelookup.end(); + if(i_iter==i_iter_end) { continue; } - unsigned u=i->second; + unsigned u=i_iter->second; GSList *nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); list connectors; -- cgit v1.2.3 From 07c8dea2b0361314ac4bbf0e45dd4c33ce11f206 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 1 Jul 2011 23:11:08 -0700 Subject: Applying patch from Campbell Barton to help building on other than gcc. (bzr r10399) --- src/2geom/solve-bezier-parametric.cpp | 12 ++++++------ src/box3d.cpp | 7 +++++-- src/display/nr-filter-gaussian.cpp | 8 ++++---- src/libcola/shortest_paths.cpp | 18 ++++++++++-------- 4 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/2geom/solve-bezier-parametric.cpp b/src/2geom/solve-bezier-parametric.cpp index 76cf65e17..437f073a3 100644 --- a/src/2geom/solve-bezier-parametric.cpp +++ b/src/2geom/solve-bezier-parametric.cpp @@ -68,13 +68,13 @@ find_parametric_bezier_roots(Geom::Point const *w, /* The control points */ break; } - /* Otherwise, solve recursively after subdividing control polygon */ - Geom::Point Left[degree+1], /* New left and right */ - Right[degree+1]; /* control polygons */ - Bezier(w, degree, 0.5, Left, Right); + // Otherwise, solve recursively after subdividing control polygon + std::vector Left(degree + 1); // New left and right + std::vector Right(degree + 1); // control polygons + Bezier(w, degree, 0.5, &Left[0], &Right[0]); total_subs ++; - find_parametric_bezier_roots(Left, degree, solutions, depth+1); - find_parametric_bezier_roots(Right, degree, solutions, depth+1); + find_parametric_bezier_roots(&Left[0], degree, solutions, depth + 1); + find_parametric_bezier_roots(&Right[0], degree, solutions, depth + 1); } diff --git a/src/box3d.cpp b/src/box3d.cpp index ac5814e4d..1a9c26b26 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -426,6 +426,9 @@ box3d_get_center_screen (SPBox3D *box) { static double remember_snap_threshold = 30; static guint remember_snap_index = 0; +// constant for sizing the array of points to be considered: +static const int MAX_POINT_COUNT = 4; + static Proj::Pt3 box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &start_pt) { double z_coord = start_pt[Proj::Z]; @@ -455,7 +458,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta Box3D::Line diag2(A, E); // diag2 is only taken into account if id equals -1, i.e., if we are snapping the center int num_snap_lines = (id != -1) ? 3 : 4; - Geom::Point snap_pts[num_snap_lines]; + Geom::Point snap_pts[MAX_POINT_COUNT]; snap_pts[0] = pl1.closest_to (pt); snap_pts[1] = pl2.closest_to (pt); @@ -467,7 +470,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta gdouble const zoom = inkscape_active_desktop()->current_zoom(); // determine the distances to all potential snapping points - double snap_dists[num_snap_lines]; + double snap_dists[MAX_POINT_COUNT]; for (int i = 0; i < num_snap_lines; ++i) { snap_dists[i] = Geom::L2 (snap_pts[i] - pt) * zoom; } diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 326c37160..14e305f96 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -525,8 +525,8 @@ gaussian_pass_FIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_su { int scr_len = _effect_area_scr(deviation); // Filter kernel for x direction - FIRValue kernel[scr_len+1]; - _make_kernel(kernel, deviation); + std::vector kernel(scr_len + 1); + _make_kernel(&kernel[0], deviation); int stride = cairo_image_surface_get_stride(src); int w = cairo_image_surface_get_width(src); @@ -539,13 +539,13 @@ gaussian_pass_FIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_su filter2D_FIR( cairo_image_surface_get_data(dest), d == Geom::X ? 1 : stride, d == Geom::X ? stride : 1, cairo_image_surface_get_data(src), d == Geom::X ? 1 : stride, d == Geom::X ? stride : 1, - w, h, kernel, scr_len, num_threads); + w, h, &kernel[0], scr_len, num_threads); break; case CAIRO_FORMAT_ARGB32: ///< Premultiplied 8 bit RGBA filter2D_FIR( cairo_image_surface_get_data(dest), d == Geom::X ? 4 : stride, d == Geom::X ? stride : 4, cairo_image_surface_get_data(src), d == Geom::X ? 4 : stride, d == Geom::X ? stride : 4, - w, h, kernel, scr_len, num_threads); + w, h, &kernel[0], scr_len, num_threads); break; default: assert(false); diff --git a/src/libcola/shortest_paths.cpp b/src/libcola/shortest_paths.cpp index 4f4183b07..ebc2c93de 100644 --- a/src/libcola/shortest_paths.cpp +++ b/src/libcola/shortest_paths.cpp @@ -73,6 +73,7 @@ void dijkstra( } } } + void dijkstra( unsigned s, unsigned n, @@ -80,21 +81,22 @@ void dijkstra( vector& es, double* eweights) { - assert(s vs(n); + dijkstra_init(&vs[0], es, eweights); + dijkstra(s, n, &vs[0], d); } + void johnsons( unsigned n, double** D, vector& es, double* eweights) { - Node vs[n]; - dijkstra_init(vs,es,eweights); - for(unsigned k=0;k vs(n); + dijkstra_init(&vs[0], es, eweights); + for (unsigned k = 0; k < n; k++) { + dijkstra(k,n,&vs[0],D[k]); } } } -- cgit v1.2.3 From 3f65497cec234309706ed240a8986f48cdf1a8b7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 1 Jul 2011 23:26:50 -0700 Subject: Removed outdated and undesired "I'm in this cpp, so change your behavior" macros. (bzr r10400) --- src/display/nr-filter-gaussian.cpp | 2 -- src/display/nr-filter-primitive.cpp | 2 -- src/display/nr-filter.cpp | 2 -- src/display/nr-light.cpp | 2 -- src/filters/merge.cpp | 2 -- src/filters/tile.cpp | 2 -- src/snap-preferences.cpp | 2 -- 7 files changed, 14 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 14e305f96..fca066ad4 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -1,5 +1,3 @@ -#define __NR_FILTER_GAUSSIAN_CPP__ - /* * Gaussian blur renderer * diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index b544d6df0..539e3e952 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -1,5 +1,3 @@ -#define __NR_FILTER_PRIMITIVE_CPP__ - /* * SVG filters rendering * diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 55190b00c..6e0aa1a42 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -1,5 +1,3 @@ -#define __NR_FILTER_CPP__ - /* * SVG filters rendering * diff --git a/src/display/nr-light.cpp b/src/display/nr-light.cpp index 65912470d..6331d1546 100644 --- a/src/display/nr-light.cpp +++ b/src/display/nr-light.cpp @@ -1,5 +1,3 @@ -#define __NR_LIGHT_CPP__ - /* * Light rendering helpers * diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 47830c38b..b5a6d7dad 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -1,5 +1,3 @@ -#define __SP_FEMERGE_CPP__ - /** \file * SVG implementation. * diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp index c3555ee7c..42a59ede8 100644 --- a/src/filters/tile.cpp +++ b/src/filters/tile.cpp @@ -1,5 +1,3 @@ -#define __SP_FETILE_CPP__ - /** \file * SVG implementation. * diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index fba9beb43..4859b111e 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -1,5 +1,3 @@ -#define __SNAPPREFERENCES_CPP__ - /** * \file snap-preferences.cpp * \brief Storing of snapping preferences -- cgit v1.2.3 From cb302be5567e13d38c794debb7a68bbf5f4abd1e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 2 Jul 2011 12:17:50 +0100 Subject: GTK+ cleaning: gtk_type_new (bzr r10390.1.3) --- src/display/sp-canvas.cpp | 9 +++------ src/helper/unit-menu.cpp | 9 ++------- src/svg-view-widget.cpp | 2 +- src/widgets/font-selector.cpp | 2 +- src/widgets/gradient-image.cpp | 2 +- src/widgets/gradient-selector.cpp | 2 +- src/widgets/gradient-vector.cpp | 2 +- src/widgets/paint-selector.cpp | 8 ++------ src/widgets/ruler.cpp | 9 +++------ src/widgets/sp-attribute-widget.cpp | 16 +++++----------- src/widgets/sp-color-gtkselector.cpp | 2 +- src/widgets/sp-color-icc-selector.cpp | 2 +- src/widgets/sp-color-notebook.cpp | 2 +- src/widgets/sp-color-scales.cpp | 2 +- src/widgets/sp-color-slider.cpp | 2 +- src/widgets/sp-color-wheel-selector.cpp | 2 +- src/widgets/sp-widget.cpp | 2 +- src/widgets/sp-xmlview-content.cpp | 2 +- 18 files changed, 28 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0d56b0175..ecc3051cc 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -177,7 +177,7 @@ sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_na g_return_val_if_fail (SP_IS_CANVAS_GROUP (parent), NULL); g_return_val_if_fail (gtk_type_is_a (type, sp_canvas_item_get_type ()), NULL); - SPCanvasItem *item = SP_CANVAS_ITEM (gtk_type_new (type)); + SPCanvasItem *item = SP_CANVAS_ITEM (g_object_new (type, NULL)); va_start (args, first_arg_name); sp_canvas_item_construct (item, parent, first_arg_name, args); @@ -1025,7 +1025,7 @@ sp_canvas_init (SPCanvas *canvas) canvas->pick_event.crossing.y = 0; /* Create the root item as a special case */ - canvas->root = SP_CANVAS_ITEM (gtk_type_new (sp_canvas_group_get_type ())); + canvas->root = SP_CANVAS_ITEM (g_object_new (sp_canvas_group_get_type (), NULL)); canvas->root->canvas = canvas; gtk_object_ref (GTK_OBJECT (canvas->root)); @@ -1125,7 +1125,7 @@ static void track_latency(GdkEvent const *event) { GtkWidget * sp_canvas_new_aa (void) { - SPCanvas *canvas = (SPCanvas *)gtk_type_new (sp_canvas_get_type ()); + SPCanvas *canvas = (SPCanvas *)g_object_new (sp_canvas_get_type (), NULL); return (GtkWidget *) canvas; } @@ -1464,9 +1464,6 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event) && (canvas->current_item != NULL) && !canvas->left_grabbed_item) { GdkEvent new_event; - SPCanvasItem *item; - - item = canvas->current_item; new_event = canvas->pick_event; new_event.type = GDK_LEAVE_NOTIFY; diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index dc65c3d14..4b72a7566 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -79,12 +79,7 @@ GType sp_unit_selector_get_type(void) static void sp_unit_selector_class_init(SPUnitSelectorClass *klass) { - GObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = G_OBJECT_CLASS(klass); - widget_class = GTK_WIDGET_CLASS(klass); - + GObjectClass *object_class = G_OBJECT_CLASS(klass); unit_selector_parent_class = (GtkHBoxClass*)gtk_type_class(GTK_TYPE_HBOX); signals[SET_UNIT] = g_signal_new("set_unit", @@ -138,7 +133,7 @@ sp_unit_selector_finalize(GObject *object) GtkWidget * sp_unit_selector_new(guint bases) { - SPUnitSelector *us = (SPUnitSelector*)gtk_type_new(SP_TYPE_UNIT_SELECTOR); + SPUnitSelector *us = (SPUnitSelector*)g_object_new(SP_TYPE_UNIT_SELECTOR, NULL); sp_unit_selector_set_bases(us, bases); diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index 639216d1f..333875550 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -212,7 +212,7 @@ sp_svg_view_widget_new (SPDocument *doc) g_return_val_if_fail (doc != NULL, NULL); - widget = (GtkWidget*)gtk_type_new (SP_TYPE_SVG_VIEW_WIDGET); + widget = (GtkWidget*)g_object_new (SP_TYPE_SVG_VIEW_WIDGET, NULL); reinterpret_cast(SP_VIEW_WIDGET_VIEW (widget))->setDocument (doc); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 965910ba2..eee0113c8 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -391,7 +391,7 @@ static void sp_font_selector_emit_set (SPFontSelector *fsel) GtkWidget *sp_font_selector_new() { - SPFontSelector *fsel = (SPFontSelector*) gtk_type_new(SP_TYPE_FONT_SELECTOR); + SPFontSelector *fsel = (SPFontSelector*) g_object_new(SP_TYPE_FONT_SELECTOR, NULL); return (GtkWidget *) fsel; } diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index eb4ab789d..37f74997d 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -144,7 +144,7 @@ sp_gradient_image_new (SPGradient *gradient) { SPGradientImage *image; - image = (SPGradientImage*)gtk_type_new (SP_TYPE_GRADIENT_IMAGE); + image = (SPGradientImage*)g_object_new (SP_TYPE_GRADIENT_IMAGE, NULL); sp_gradient_image_set_gradient (image, gradient); diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index c6b867595..0b7764674 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -212,7 +212,7 @@ sp_gradient_selector_new (void) { SPGradientSelector *sel; - sel = (SPGradientSelector*)gtk_type_new (SP_TYPE_GRADIENT_SELECTOR); + sel = (SPGradientSelector*)g_object_new (SP_TYPE_GRADIENT_SELECTOR, NULL); return (GtkWidget *) sel; } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 310002b54..63d4bcee0 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -165,7 +165,7 @@ GtkWidget *sp_gradient_vector_selector_new(SPDocument *doc, SPGradient *gr) g_return_val_if_fail(!gr || SP_IS_GRADIENT(gr), NULL); g_return_val_if_fail(!gr || (gr->document == doc), NULL); - gvs = static_cast(gtk_type_new(SP_TYPE_GRADIENT_VECTOR_SELECTOR)); + gvs = static_cast(g_object_new(SP_TYPE_GRADIENT_VECTOR_SELECTOR, NULL)); if (doc) { sp_gradient_vector_selector_set_gradient(SP_GRADIENT_VECTOR_SELECTOR(gvs), doc, gr); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index fa4684825..4baabdfd9 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -156,11 +156,7 @@ GType sp_paint_selector_get_type(void) static void sp_paint_selector_class_init(SPPaintSelectorClass *klass) { - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; + GtkObjectClass *object_class = (GtkObjectClass *) klass; parent_class = (GtkVBoxClass*)gtk_type_class(GTK_TYPE_VBOX); @@ -352,7 +348,7 @@ sp_paint_selector_show_fillrule(SPPaintSelector *psel, bool is_fill) SPPaintSelector *sp_paint_selector_new(FillOrStroke kind) { - SPPaintSelector *psel = static_cast(gtk_type_new(SP_TYPE_PAINT_SELECTOR)); + SPPaintSelector *psel = static_cast(g_object_new(SP_TYPE_PAINT_SELECTOR, NULL)); psel->setMode(SPPaintSelector::MODE_MULTIPLE); diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index f3f4164a5..7744f5433 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -91,7 +91,7 @@ sp_hruler_init (SPHRuler *hruler) GtkWidget* sp_hruler_new (void) { - return GTK_WIDGET (gtk_type_new (sp_hruler_get_type ())); + return GTK_WIDGET (g_object_new (sp_hruler_get_type (), NULL)); } static gint @@ -179,7 +179,7 @@ sp_vruler_init (SPVRuler *vruler) GtkWidget* sp_vruler_new (void) { - return GTK_WIDGET (gtk_type_new (sp_vruler_get_type ())); + return GTK_WIDGET (g_object_new (sp_vruler_get_type (), NULL)); } @@ -212,8 +212,7 @@ static void sp_ruler_common_draw_ticks (GtkRuler *ruler) { GtkWidget *widget; - GdkGC *gc, *bg_gc; - PangoFontDescription *pango_desc; + GdkGC *gc; PangoContext *pango_context; PangoLayout *pango_layout; gint i, j, tick_index; @@ -242,9 +241,7 @@ sp_ruler_common_draw_ticks (GtkRuler *ruler) g_object_get(G_OBJECT(ruler), "orientation", &orientation, NULL); widget = GTK_WIDGET (ruler); gc = widget->style->fg_gc[GTK_STATE_NORMAL]; - bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - pango_desc = widget->style->font_desc; pango_context = gtk_widget_get_pango_context (widget); pango_layout = pango_layout_new (pango_context); PangoFontDescription *fs = pango_font_description_new (); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 61863f31b..494a9997b 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -67,11 +67,9 @@ static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) { GtkObjectClass *object_class; - GtkWidgetClass *widget_class; GtkEditableClass *editable_class; object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); editable_class = GTK_EDITABLE_CLASS (klass); parent_class = (GtkEntryClass*)gtk_type_class (GTK_TYPE_ENTRY); @@ -177,7 +175,7 @@ sp_attribute_widget_new ( SPObject *object, const gchar *attribute ) g_return_val_if_fail (!object || SP_IS_OBJECT (object), NULL); g_return_val_if_fail (!object || attribute, NULL); - spaw = (SPAttributeWidget*)gtk_type_new (SP_TYPE_ATTRIBUTE_WIDGET); + spaw = (SPAttributeWidget*)g_object_new (SP_TYPE_ATTRIBUTE_WIDGET, NULL); sp_attribute_widget_set_object (spaw, object, attribute); @@ -192,7 +190,7 @@ sp_attribute_widget_new_repr ( Inkscape::XML::Node *repr, const gchar *attribute { SPAttributeWidget *spaw; - spaw = (SPAttributeWidget*)gtk_type_new (SP_TYPE_ATTRIBUTE_WIDGET); + spaw = (SPAttributeWidget*)g_object_new (SP_TYPE_ATTRIBUTE_WIDGET, NULL); sp_attribute_widget_set_repr (spaw, repr, attribute); @@ -385,11 +383,7 @@ GType sp_attribute_table_get_type(void) static void sp_attribute_table_class_init (SPAttributeTableClass *klass) { - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); table_parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX); @@ -472,7 +466,7 @@ sp_attribute_table_new ( SPObject *object, g_return_val_if_fail (!object || (num_attr > 0), NULL); g_return_val_if_fail (!num_attr || (labels && attributes), NULL); - spat = (SPAttributeTable*)gtk_type_new (SP_TYPE_ATTRIBUTE_TABLE); + spat = (SPAttributeTable*)g_object_new (SP_TYPE_ATTRIBUTE_TABLE, NULL); sp_attribute_table_set_object (spat, object, num_attr, labels, attributes); @@ -492,7 +486,7 @@ sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, g_return_val_if_fail (!num_attr || (labels && attributes), NULL); - spat = (SPAttributeTable*)gtk_type_new (SP_TYPE_ATTRIBUTE_TABLE); + spat = (SPAttributeTable*)g_object_new (SP_TYPE_ATTRIBUTE_TABLE, NULL); sp_attribute_table_set_repr (spat, repr, num_attr, labels, attributes); diff --git a/src/widgets/sp-color-gtkselector.cpp b/src/widgets/sp-color-gtkselector.cpp index 10254321a..60a63d8c4 100644 --- a/src/widgets/sp-color-gtkselector.cpp +++ b/src/widgets/sp-color-gtkselector.cpp @@ -113,7 +113,7 @@ sp_color_gtkselector_new( GType ) { SPColorGtkselector *csel; - csel = (SPColorGtkselector*)gtk_type_new (SP_TYPE_COLOR_GTKSELECTOR); + csel = (SPColorGtkselector*)g_object_new (SP_TYPE_COLOR_GTKSELECTOR, NULL); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 3a2c7fbed..94f450e50 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -432,7 +432,7 @@ sp_color_icc_selector_new (void) { SPColorICCSelector *csel; - csel = (SPColorICCSelector*)gtk_type_new (SP_TYPE_COLOR_ICC_SELECTOR); + csel = (SPColorICCSelector*)g_object_new (SP_TYPE_COLOR_ICC_SELECTOR, NULL); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index c252dc65e..c347a1fca 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -431,7 +431,7 @@ sp_color_notebook_new (void) { SPColorNotebook *colorbook; - colorbook = (SPColorNotebook*)gtk_type_new (SP_TYPE_COLOR_NOTEBOOK); + colorbook = (SPColorNotebook*)g_object_new (SP_TYPE_COLOR_NOTEBOOK, NULL); return GTK_WIDGET (colorbook); } diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 146ea9e1e..c07e44aa6 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -206,7 +206,7 @@ sp_color_scales_new (void) { SPColorScales *csel; - csel = (SPColorScales*)gtk_type_new (SP_TYPE_COLOR_SCALES); + csel = (SPColorScales*)g_object_new (SP_TYPE_COLOR_SCALES, NULL); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 152f81324..19bc73946 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -321,7 +321,7 @@ sp_color_slider_new (GtkAdjustment *adjustment) { SPColorSlider *slider; - slider = (SPColorSlider*)gtk_type_new (SP_TYPE_COLOR_SLIDER); + slider = (SPColorSlider*)g_object_new (SP_TYPE_COLOR_SLIDER, NULL); sp_color_slider_set_adjustment (slider, adjustment); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 4bbda79a6..18fc76a2d 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -241,7 +241,7 @@ sp_color_wheel_selector_new (void) { SPColorWheelSelector *csel; - csel = (SPColorWheelSelector*)gtk_type_new (SP_TYPE_COLOR_WHEEL_SELECTOR); + csel = (SPColorWheelSelector*)g_object_new (SP_TYPE_COLOR_WHEEL_SELECTOR, NULL); return GTK_WIDGET (csel); } diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 141f4afc1..8f9c6a6d7 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -222,7 +222,7 @@ sp_widget_new_global (Inkscape::Application *inkscape) { SPWidget *spw; - spw = (SPWidget*)gtk_type_new (SP_TYPE_WIDGET); + spw = (SPWidget*)g_object_new (SP_TYPE_WIDGET, NULL); if (!sp_widget_construct_global (spw, inkscape)) { gtk_object_unref (GTK_OBJECT (spw)); diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index 804bc1737..605fbeb06 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -46,7 +46,7 @@ sp_xmlview_content_new (Inkscape::XML::Node * repr) SPXMLViewContent *text; tb = gtk_text_buffer_new (NULL); - text = (SPXMLViewContent*)gtk_type_new (SP_TYPE_XMLVIEW_CONTENT); + text = (SPXMLViewContent*)g_object_new (SP_TYPE_XMLVIEW_CONTENT, NULL); gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), tb); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text), GTK_WRAP_CHAR); -- cgit v1.2.3 From b60e03e0f4bec6b4fbe205328f375217de476b31 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 2 Jul 2011 12:22:47 +0100 Subject: GTK+ cleanup: gtk_type_new (bzr r10402) --- src/ui/widget/svg-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/svg-canvas.cpp b/src/ui/widget/svg-canvas.cpp index 7d37ec355..f0eb24a10 100644 --- a/src/ui/widget/svg-canvas.cpp +++ b/src/ui/widget/svg-canvas.cpp @@ -22,7 +22,7 @@ namespace Widget { SVGCanvas::SVGCanvas() { - void *canvas = gtk_type_new (sp_canvas_get_type ()); + void *canvas = g_object_new (sp_canvas_get_type (), NULL); _spcanvas = static_cast(canvas); _widget = Glib::wrap (static_cast (canvas)); _dt = 0; -- cgit v1.2.3 From 98d4e7826b44154cbe89747a1d27f033fb012755 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 2 Jul 2011 15:07:10 +0200 Subject: Be accurate when changing width/height in the toolbar, in case geometric bounding boxes are used (bzr r10403) --- src/widgets/select-toolbar.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 7012badf8..eb9b2805d 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -242,7 +242,14 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) gdouble strokewidth = stroke_average_width (selection->itemList()); int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; - Geom::Affine scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1); + Geom::Affine scaler; + if (bbox_type == SPItem::APPROXIMATE_BBOX) { + // get_scale_transform_with_stroke() is intended for VISUAL (or APPROXIMATE) bounding boxes, not geometrical ones! + scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1); + } else { + // we'll trick it into using a geometrical bounding box though, by setting the stroke width to zero + scaler = get_scale_transform_with_stroke (*bbox, 0, false, x0, y0, x1, y1); + } sp_selection_apply_affine(selection, scaler); DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT, -- cgit v1.2.3 From 7f9142e88f1770c5e8c344153a17ca0668e60cdc Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 2 Jul 2011 08:36:54 -0700 Subject: Fix problem with merged code where a pointer to a plain C GTK+ object was cast to a pointer to a C++ gtkmm object. Fixes bug 804243. Fixed bugs: - https://launchpad.net/bugs/804243 (bzr r10404) --- src/widgets/gradient-vector.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 63d4bcee0..bf1c38119 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -562,10 +562,9 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_ gtk_widget_show(i); g_object_set_data(G_OBJECT(i), "stop", stop); GtkWidget *hb = gtk_hbox_new(FALSE, 4); - GtkWidget *cpv = GTK_WIDGET(Gtk::manage( - new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)))->gobj()); - gtk_widget_show(cpv); - gtk_container_add( GTK_CONTAINER(hb), cpv ); + Gtk::Widget *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop))); + cpv->show(); + gtk_container_add( GTK_CONTAINER(hb), cpv->gobj() ); g_object_set_data( G_OBJECT(i), "preview", cpv ); Inkscape::XML::Node *repr = reinterpret_cast(sl->data)->getRepr(); GtkWidget *l = gtk_label_new(repr->attribute("id")); -- cgit v1.2.3 From f496d58be9dbd47dc75cdb0cd65e4f68bfd33f62 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 2 Jul 2011 19:55:23 +0100 Subject: GTK+ cleanup: gtk_object_set (bzr r10405) --- src/display/sp-canvas-item.h | 2 +- src/knot.cpp | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 51e9a740e..9dbec547e 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -72,7 +72,7 @@ SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, const gchar G_END_DECLS -#define sp_canvas_item_set gtk_object_set +#define sp_canvas_item_set g_object_set void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Affine const &aff); diff --git a/src/knot.cpp b/src/knot.cpp index 638b31007..1ffb5269c 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -649,12 +649,12 @@ void sp_knot_update_ctrl(SPKnot *knot) return; } - gtk_object_set(GTK_OBJECT(knot->item), "shape", knot->shape, NULL); - gtk_object_set(GTK_OBJECT(knot->item), "mode", knot->mode, NULL); - gtk_object_set(GTK_OBJECT(knot->item), "size", (gdouble) knot->size, NULL); - gtk_object_set(GTK_OBJECT(knot->item), "anchor", knot->anchor, NULL); + g_object_set(knot->item, "shape", knot->shape, NULL); + g_object_set(knot->item, "mode", knot->mode, NULL); + g_object_set(knot->item, "size", (gdouble) knot->size, NULL); + g_object_set(knot->item, "anchor", knot->anchor, NULL); if (knot->pixbuf) { - gtk_object_set(GTK_OBJECT (knot->item), "pixbuf", knot->pixbuf, NULL); + g_object_set(knot->item, "pixbuf", knot->pixbuf, NULL); } sp_knot_set_ctrl_state(knot); @@ -666,29 +666,29 @@ void sp_knot_update_ctrl(SPKnot *knot) static void sp_knot_set_ctrl_state(SPKnot *knot) { if (knot->flags & SP_KNOT_DRAGGING) { - gtk_object_set(GTK_OBJECT (knot->item), + g_object_set(knot->item, "fill_color", knot->fill[SP_KNOT_STATE_DRAGGING], NULL); - gtk_object_set(GTK_OBJECT (knot->item), + g_object_set(knot->item, "stroke_color", knot->stroke[SP_KNOT_STATE_DRAGGING], NULL); } else if (knot->flags & SP_KNOT_MOUSEOVER) { - gtk_object_set(GTK_OBJECT(knot->item), + g_object_set(knot->item, "fill_color", knot->fill[SP_KNOT_STATE_MOUSEOVER], NULL); - gtk_object_set(GTK_OBJECT(knot->item), + g_object_set(knot->item, "stroke_color", knot->stroke[SP_KNOT_STATE_MOUSEOVER], NULL); } else { - gtk_object_set(GTK_OBJECT(knot->item), + g_object_set(knot->item, "fill_color", knot->fill[SP_KNOT_STATE_NORMAL], NULL); - gtk_object_set(GTK_OBJECT(knot->item), + g_object_set(knot->item, "stroke_color", knot->stroke[SP_KNOT_STATE_NORMAL], NULL); -- cgit v1.2.3 From 32cbae2ea15712efd9a36f43f7690268c1767e52 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 11:43:53 +0100 Subject: GTK+ cleanup: gtk_type_class (bzr r10407) --- src/display/canvas-arena.cpp | 2 +- src/display/canvas-bpath.cpp | 2 +- src/display/canvas-grid.cpp | 2 +- src/display/canvas-text.cpp | 2 +- src/display/gnome-canvas-acetate.cpp | 2 +- src/display/sodipodi-ctrl.cpp | 2 +- src/display/sodipodi-ctrlrect.cpp | 2 +- src/display/sp-canvas.cpp | 4 ++-- src/display/sp-ctrlline.cpp | 2 +- src/display/sp-ctrlpoint.cpp | 2 +- src/display/sp-ctrlquadr.cpp | 2 +- src/helper/unit-menu.cpp | 2 +- src/svg-view-widget.cpp | 12 ++++-------- src/ui/view/view-widget.cpp | 2 +- src/widgets/desktop-widget.cpp | 2 +- src/widgets/font-selector.cpp | 2 +- src/widgets/gradient-image.cpp | 2 +- src/widgets/gradient-selector.cpp | 2 +- src/widgets/gradient-vector.cpp | 2 +- src/widgets/paint-selector.cpp | 2 +- src/widgets/ruler.cpp | 4 ++-- src/widgets/sp-attribute-widget.cpp | 4 ++-- src/widgets/sp-color-notebook.cpp | 2 +- src/widgets/sp-color-selector.cpp | 2 +- src/widgets/sp-color-slider.cpp | 16 +--------------- src/widgets/sp-widget.cpp | 2 +- src/widgets/sp-xmlview-attr-list.cpp | 2 +- src/widgets/sp-xmlview-content.cpp | 2 +- src/widgets/sp-xmlview-tree.cpp | 2 +- 29 files changed, 35 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 5f3d961f7..6930e4d7c 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -77,7 +77,7 @@ sp_canvas_arena_class_init (SPCanvasArenaClass *klass) object_class = (GtkObjectClass *) klass; item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); signals[ARENA_EVENT] = g_signal_new ("arena_event", G_TYPE_FROM_CLASS(object_class), diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 815892878..306b523ca 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -67,7 +67,7 @@ sp_canvas_bpath_class_init (SPCanvasBPathClass *klass) object_class = GTK_OBJECT_CLASS (klass); item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_canvas_bpath_destroy; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 2a9e50e3d..e1673c8ef 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -89,7 +89,7 @@ grid_canvasitem_class_init (GridCanvasItemClass *klass) object_class = (GtkObjectClass *) klass; item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ()); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = grid_canvasitem_destroy; diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 690015ecd..683e2f93c 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -63,7 +63,7 @@ sp_canvastext_class_init (SPCanvasTextClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class_ct = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); + parent_class_ct = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_canvastext_destroy; diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index 67cc66950..bdda3a120 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -54,7 +54,7 @@ sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) object_class = (GtkObjectClass *) klass; item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ()); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_canvas_acetate_destroy; diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index fe2a78a8f..0ff7ca9f5 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -71,7 +71,7 @@ sp_ctrl_class_init (SPCtrlClass *klass) object_class = (GtkObjectClass *) klass; item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass *)gtk_type_class (sp_canvas_item_get_type ()); + parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass); gtk_object_add_arg_type ("SPCtrl::shape", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_SHAPE); gtk_object_add_arg_type ("SPCtrl::mode", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MODE); diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index 592d45bc0..b516456e9 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -64,7 +64,7 @@ static void sp_ctrlrect_class_init(SPCtrlRectClass *c) GtkObjectClass *object_class = (GtkObjectClass *) c; SPCanvasItemClass *item_class = (SPCanvasItemClass *) c; - parent_class = (SPCanvasItemClass*) gtk_type_class(sp_canvas_item_get_type()); + parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c); object_class->destroy = sp_ctrlrect_destroy; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ecc3051cc..e1f165003 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -727,7 +727,7 @@ sp_canvas_group_class_init (SPCanvasGroupClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - group_parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ()); + group_parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_canvas_group_destroy; @@ -989,7 +989,7 @@ sp_canvas_class_init (SPCanvasClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; - canvas_parent_class = (GtkWidgetClass *)gtk_type_class (GTK_TYPE_WIDGET); + canvas_parent_class = (GtkWidgetClass *)g_type_class_peek_parent (klass); object_class->destroy = sp_canvas_destroy; diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index 6c763abdf..c185234d4 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -65,7 +65,7 @@ sp_ctrlline_class_init (SPCtrlLineClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_ctrlline_destroy; diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp index c33cdeeb9..1cf7dded0 100644 --- a/src/display/sp-ctrlpoint.cpp +++ b/src/display/sp-ctrlpoint.cpp @@ -56,7 +56,7 @@ sp_ctrlpoint_class_init (SPCtrlPointClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_ctrlpoint_destroy; diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index 0701d0b10..b39886178 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -64,7 +64,7 @@ sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)gtk_type_class (SP_TYPE_CANVAS_ITEM); + parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_ctrlquadr_destroy; diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index 4b72a7566..a87ac4abd 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -80,7 +80,7 @@ static void sp_unit_selector_class_init(SPUnitSelectorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - unit_selector_parent_class = (GtkHBoxClass*)gtk_type_class(GTK_TYPE_HBOX); + unit_selector_parent_class = (GtkHBoxClass*)g_type_class_peek_parent(klass); signals[SET_UNIT] = g_signal_new("set_unit", G_TYPE_FROM_CLASS(klass), diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index 333875550..cda1ed546 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -63,15 +63,11 @@ GType sp_svg_view_widget_get_type(void) static void sp_svg_view_widget_class_init (SPSVGSPViewWidgetClass *klass) { - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - SPViewWidgetClass *vw_class; + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + SPViewWidgetClass *vw_class = SP_VIEW_WIDGET_CLASS (klass); - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - vw_class = SP_VIEW_WIDGET_CLASS (klass); - - widget_parent_class = (SPViewWidgetClass*)gtk_type_class (SP_TYPE_VIEW_WIDGET); + widget_parent_class = (SPViewWidgetClass *)g_type_class_peek_parent (klass); object_class->destroy = sp_svg_view_widget_destroy; diff --git a/src/ui/view/view-widget.cpp b/src/ui/view/view-widget.cpp index f87bc8edd..d43877569 100644 --- a/src/ui/view/view-widget.cpp +++ b/src/ui/view/view-widget.cpp @@ -54,7 +54,7 @@ static void sp_view_widget_class_init(SPViewWidgetClass *vwc) { GtkObjectClass *object_class = GTK_OBJECT_CLASS(vwc); - widget_parent_class = (GtkEventBoxClass*) gtk_type_class(GTK_TYPE_EVENT_BOX); + widget_parent_class = (GtkEventBoxClass*) g_type_class_peek_parent(vwc); object_class->destroy = sp_view_widget_destroy; } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 028138a10..52008625a 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -281,7 +281,7 @@ GType SPDesktopWidget::getType(void) static void sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) { - dtw_parent_class = (SPViewWidgetClass*)gtk_type_class (SP_TYPE_VIEW_WIDGET); + dtw_parent_class = (SPViewWidgetClass*)g_type_class_peek_parent (klass); GtkObjectClass *object_class = (GtkObjectClass *) klass; GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 3f015790a..a9340a291 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -121,7 +121,7 @@ static void sp_font_selector_class_init(SPFontSelectorClass *c) { GtkObjectClass *object_class = (GtkObjectClass *) c; - fs_parent_class = (GtkHBoxClass* )gtk_type_class(GTK_TYPE_HBOX); + fs_parent_class = (GtkHBoxClass* )g_type_class_peek_parent (c); fs_signals[FONT_SET] = gtk_signal_new ("font_set", GTK_RUN_FIRST, diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 37f74997d..1aeb43c91 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -65,7 +65,7 @@ sp_gradient_image_class_init (SPGradientImageClass *klass) object_class = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; - parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET); + parent_class = (GtkWidgetClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_gradient_image_destroy; diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 0b7764674..a6e9be581 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -83,7 +83,7 @@ sp_gradient_selector_class_init (SPGradientSelectorClass *klass) object_class = (GtkObjectClass *) klass; - parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX); + parent_class = (GtkVBoxClass*)g_type_class_peek_parent (klass); signals[GRABBED] = g_signal_new ("grabbed", G_TYPE_FROM_CLASS(object_class), diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index bf1c38119..8c39b52dd 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -102,7 +102,7 @@ static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass object_class = GTK_OBJECT_CLASS(klass); - parent_class = static_cast(gtk_type_class(GTK_TYPE_VBOX)); + parent_class = static_cast(g_type_class_peek_parent(klass)); signals[VECTOR_SET] = g_signal_new( "vector_set", G_TYPE_FROM_CLASS(object_class), diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 4baabdfd9..9f2a30e32 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -158,7 +158,7 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) { GtkObjectClass *object_class = (GtkObjectClass *) klass; - parent_class = (GtkVBoxClass*)gtk_type_class(GTK_TYPE_VBOX); + parent_class = (GtkVBoxClass*)g_type_class_peek_parent(klass); psel_signals[MODE_CHANGED] = g_signal_new("mode_changed", G_TYPE_FROM_CLASS(object_class), diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index 7744f5433..60e460cda 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -67,7 +67,7 @@ sp_hruler_class_init (SPHRulerClass *klass) GtkWidgetClass *widget_class; GtkRulerClass *ruler_class; - hruler_parent_class = (GtkWidgetClass *) gtk_type_class (GTK_TYPE_RULER); + hruler_parent_class = (GtkWidgetClass *) g_type_class_peek_parent (klass); widget_class = (GtkWidgetClass*) klass; ruler_class = (GtkRulerClass*) klass; @@ -153,7 +153,7 @@ sp_vruler_class_init (SPVRulerClass *klass) GtkWidgetClass *widget_class; GtkRulerClass *ruler_class; - vruler_parent_class = (GtkWidgetClass *) gtk_type_class (GTK_TYPE_RULER); + vruler_parent_class = (GtkWidgetClass *) g_type_class_peek_parent (klass); widget_class = (GtkWidgetClass*) klass; ruler_class = (GtkRulerClass*) klass; diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 494a9997b..f7cd308b2 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -72,7 +72,7 @@ sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) object_class = GTK_OBJECT_CLASS (klass); editable_class = GTK_EDITABLE_CLASS (klass); - parent_class = (GtkEntryClass*)gtk_type_class (GTK_TYPE_ENTRY); + parent_class = (GtkEntryClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_attribute_widget_destroy; @@ -385,7 +385,7 @@ sp_attribute_table_class_init (SPAttributeTableClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - table_parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX); + table_parent_class = (GtkVBoxClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_attribute_table_destroy; diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index c347a1fca..377abf219 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -231,7 +231,7 @@ void ColorNotebook::init() if (!g_type_is_a (selector_types[i], SP_TYPE_COLOR_NOTEBOOK)) { guint howmany = 1; - gpointer klass = gtk_type_class (selector_types[i]); + gpointer klass = g_type_class_ref (selector_types[i]); if ( klass && SP_IS_COLOR_SELECTOR_CLASS (klass) ) { SPColorSelectorClass *ck = SP_COLOR_SELECTOR_CLASS (klass); diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index bf3564d2e..b017ed923 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -68,7 +68,7 @@ void sp_color_selector_class_init( SPColorSelectorClass *klass ) object_class = GTK_OBJECT_CLASS(klass); widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_VBOX_CLASS( gtk_type_class(GTK_TYPE_VBOX) ); + parent_class = GTK_VBOX_CLASS( g_type_class_peek_parent(klass) ); csel_signals[GRABBED] = g_signal_new( "grabbed", G_TYPE_FROM_CLASS(object_class), diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 19bc73946..8fcbdf9af 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -83,7 +83,7 @@ sp_color_slider_class_init (SPColorSliderClass *klass) object_class = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; - parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET); + parent_class = (GtkWidgetClass*)g_type_class_peek_parent (klass); slider_signals[GRABBED] = g_signal_new ("grabbed", G_TYPE_FROM_CLASS(object_class), @@ -182,12 +182,9 @@ sp_color_slider_destroy (GtkObject *object) static void sp_color_slider_realize (GtkWidget *widget) { - SPColorSlider *slider; GdkWindowAttr attributes; gint attributes_mask; - slider = SP_COLOR_SLIDER (widget); - gtk_widget_set_realized (widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; @@ -216,10 +213,6 @@ sp_color_slider_realize (GtkWidget *widget) static void sp_color_slider_size_request (GtkWidget *widget, GtkRequisition *requisition) { - SPColorSlider *slider; - - slider = SP_COLOR_SLIDER (widget); - requisition->width = SLIDER_WIDTH + widget->style->xthickness * 2; requisition->height = SLIDER_HEIGHT + widget->style->ythickness * 2; } @@ -227,10 +220,6 @@ sp_color_slider_size_request (GtkWidget *widget, GtkRequisition *requisition) static void sp_color_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - SPColorSlider *slider; - - slider = SP_COLOR_SLIDER (widget); - widget->allocation = *allocation; if (gtk_widget_get_realized (widget)) { @@ -247,9 +236,6 @@ sp_color_slider_expose (GtkWidget *widget, GdkEventExpose *event) slider = SP_COLOR_SLIDER (widget); if (gtk_widget_is_drawable (widget)) { - gint width, height; - width = widget->allocation.width; - height = widget->allocation.height; sp_color_slider_paint (slider, &event->area); } diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 8f9c6a6d7..ef8a6c03c 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -75,7 +75,7 @@ sp_widget_class_init (SPWidgetClass *klass) object_class = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; - parent_class = (GtkBinClass*)gtk_type_class (GTK_TYPE_BIN); + parent_class = (GtkBinClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_widget_destroy; diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index 535a4b534..9aa46a399 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -108,7 +108,7 @@ sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass) object_class = (GtkObjectClass *) klass; object_class->destroy = sp_xmlview_attr_list_destroy; - parent_class = (GtkCListClass*)gtk_type_class (GTK_TYPE_CLIST); + parent_class = (GtkCListClass*)g_type_class_peek_parent (klass); g_signal_new ( "row-value-changed", G_TYPE_FROM_CLASS(klass), diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index 605fbeb06..1f35f2373 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -108,7 +108,7 @@ sp_xmlview_content_class_init (SPXMLViewContentClass * klass) object_class = (GtkObjectClass *) klass; - parent_class = (GtkTextViewClass*)gtk_type_class (GTK_TYPE_TEXT_VIEW); + parent_class = (GtkTextViewClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_xmlview_content_destroy; } diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index e1779b620..b867b1044 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -153,7 +153,7 @@ sp_xmlview_tree_class_init (SPXMLViewTreeClass * klass) GtkObjectClass * object_class; object_class = (GtkObjectClass *) klass; - parent_class = (GtkCTreeClass *) gtk_type_class (GTK_TYPE_CTREE); + parent_class = (GtkCTreeClass *) g_type_class_peek_parent (klass); GTK_CTREE_CLASS (object_class)->tree_move = tree_move; -- cgit v1.2.3 From 47c46197429cbac90b21b1759cd7cddd179566f7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 11:56:21 +0100 Subject: GTK+ cleanup: gtk_widget_ref (bzr r10408) --- src/libgdl/gdl-dock-item.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 138265034..3c508c0cd 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -936,10 +936,6 @@ static void gdl_dock_item_paint (GtkWidget *widget, GdkEventExpose *event) { - GdlDockItem *item; - - item = GDL_DOCK_ITEM (widget); - gtk_paint_box (widget->style, widget->window, gtk_widget_get_state (widget), @@ -1579,13 +1575,10 @@ static void gdl_dock_item_hide_cb (GtkWidget *widget, GdlDockItem *item) { - GdlDockMaster *master; - (void)widget; g_return_if_fail (item != NULL); - master = GDL_DOCK_OBJECT_GET_MASTER (item); gdl_dock_item_hide_item (item); } @@ -1798,7 +1791,7 @@ gdl_dock_item_set_tablabel (GdlDockItem *item, } if (tablabel) { - gtk_widget_ref (tablabel); + g_object_ref (G_OBJECT (tablabel)); gtk_object_sink (GTK_OBJECT (tablabel)); item->_priv->tab_label = tablabel; if (GDL_IS_DOCK_TABLABEL (tablabel)) { -- cgit v1.2.3 From 8937e3c24816408a5d7332e3780e4798bf8a4104 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 12:15:24 +0100 Subject: GTK+ cleanup: gtk_action_connect_proxy (bzr r10409) --- src/ege-select-one-action.cpp | 2 +- src/ink-comboboxentry-action.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index ea08f1c06..e0130a68d 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -735,7 +735,7 @@ GtkWidget* create_tool_item( GtkAction* action ) g_signal_connect( G_OBJECT(ract), "changed", G_CALLBACK( proxy_action_chagned_cb ), act ); sub = gtk_action_create_tool_item( GTK_ACTION(ract) ); - gtk_action_connect_proxy( GTK_ACTION(ract), sub ); + gtk_activatable_set_related_action( GTK_ACTIVATABLE (sub), GTK_ACTION(ract) ); gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip ); gtk_box_pack_start( GTK_BOX(holder), sub, FALSE, FALSE, 0 ); diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 49ab343c2..5147b04a8 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -402,7 +402,7 @@ GtkWidget* create_tool_item( GtkAction* action ) } - gtk_action_connect_proxy( GTK_ACTION( action ), item ); + gtk_activatable_set_related_action( GTK_ACTIVATABLE (item), GTK_ACTION( action ) ); gtk_widget_show_all( item ); } else { -- cgit v1.2.3 From 185fb937f1f5512d522f29c55353cc205f2da148 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 12:22:36 +0100 Subject: GTK+ cleanup: gtk_box_pack_start_defaults (bzr r10410) --- src/libgdl/gdl-dock-bar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 2b230fc54..663378b7f 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -302,7 +302,7 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar, label = gtk_label_new (name); if (dockbar->_priv->orientation == GTK_ORIENTATION_VERTICAL) gtk_label_set_angle (GTK_LABEL (label), 90); - gtk_box_pack_start_defaults (GTK_BOX (box), label); + gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); } /* FIXME: For now AUTO behaves same as BOTH */ @@ -320,7 +320,7 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar, image = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_SMALL_TOOLBAR); } - gtk_box_pack_start_defaults (GTK_BOX (box), image); + gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0); } gtk_container_add (GTK_CONTAINER (button), box); -- cgit v1.2.3 From 1cbae999d86d7804a6c9cfe8a6f8de7c4a8a4c2c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 12:48:35 +0100 Subject: GTK+ cleanup: gtk_object_sink (bzr r10411) --- src/display/sp-canvas.cpp | 4 ++-- src/libgdl/gdl-dock-item.c | 14 +++++--------- src/libgdl/gdl-dock-master.c | 3 +-- src/libgdl/gdl-dock-object.c | 2 +- src/widgets/sp-color-slider.cpp | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index e1f165003..3e8a4880c 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -884,7 +884,7 @@ static void group_add (SPCanvasGroup *group, SPCanvasItem *item) { gtk_object_ref (GTK_OBJECT (item)); - gtk_object_sink (GTK_OBJECT (item)); + g_object_ref_sink (item); if (!group->items) { group->items = g_list_append (group->items, item); @@ -1029,7 +1029,7 @@ sp_canvas_init (SPCanvas *canvas) canvas->root->canvas = canvas; gtk_object_ref (GTK_OBJECT (canvas->root)); - gtk_object_sink (GTK_OBJECT (canvas->root)); + g_object_ref_sink (canvas->root); canvas->need_repick = TRUE; diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 3c508c0cd..c01737636 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -1786,13 +1786,12 @@ gdl_dock_item_set_tablabel (GdlDockItem *item, NULL, item); g_object_set (item->_priv->tab_label, "item", NULL, NULL); } - gtk_widget_unref (item->_priv->tab_label); + g_object_unref (item->_priv->tab_label); item->_priv->tab_label = NULL; } if (tablabel) { - g_object_ref (G_OBJECT (tablabel)); - gtk_object_sink (GTK_OBJECT (tablabel)); + g_object_ref_sink (G_OBJECT (tablabel)); item->_priv->tab_label = tablabel; if (GDL_IS_DOCK_TABLABEL (tablabel)) { g_object_set (tablabel, "item", item, NULL); @@ -1887,8 +1886,7 @@ gdl_dock_item_hide_item (GdlDockItem *item) "floatx", x, "floaty", y, NULL)); - g_object_ref (item->_priv->ph); - gtk_object_sink (GTK_OBJECT (item->_priv->ph)); + g_object_ref_sink (item->_priv->ph); } gdl_dock_object_freeze (GDL_DOCK_OBJECT (item)); @@ -1992,8 +1990,7 @@ gdl_dock_item_set_default_position (GdlDockItem *item, if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) { if (GDL_IS_DOCK_PLACEHOLDER (reference)) { - g_object_ref (reference); - gtk_object_sink (GTK_OBJECT (reference)); + g_object_ref_sink (reference); item->_priv->ph = GDL_DOCK_PLACEHOLDER (reference); } else { item->_priv->ph = GDL_DOCK_PLACEHOLDER ( @@ -2001,8 +1998,7 @@ gdl_dock_item_set_default_position (GdlDockItem *item, "sticky", TRUE, "host", reference, NULL)); - g_object_ref (item->_priv->ph); - gtk_object_sink (GTK_OBJECT (item->_priv->ph)); + g_object_ref_sink (item->_priv->ph); } } } diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c index 4b36e4f8b..78cbf69ec 100644 --- a/src/libgdl/gdl-dock-master.c +++ b/src/libgdl/gdl-dock-master.c @@ -807,8 +807,7 @@ gdl_dock_master_add (GdlDockMaster *master, master, object, object->name, found_object); } else { - g_object_ref (object); - gtk_object_sink (GTK_OBJECT (object)); + g_object_ref_sink (object); g_hash_table_insert (master->dock_objects, g_strdup (object->name), object); } } diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 233d03b3b..9bdcd18ed 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -416,7 +416,7 @@ gdl_dock_object_real_reduce (GdlDockObject *object) g_object_unref (child); } /* sink the widget, so any automatic floating widget is destroyed */ - gtk_object_sink (GTK_OBJECT (object)); + g_object_ref_sink (object); /* don't reenter */ object->reduce_pending = FALSE; gdl_dock_object_thaw (object); diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 8fcbdf9af..ad21e9031 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -334,7 +334,7 @@ void sp_color_slider_set_adjustment(SPColorSlider *slider, GtkAdjustment *adjust slider->adjustment = adjustment; gtk_object_ref (GTK_OBJECT (adjustment)); - gtk_object_sink (GTK_OBJECT (adjustment)); + g_object_ref_sink (adjustment); g_signal_connect (G_OBJECT (adjustment), "changed", G_CALLBACK (sp_color_slider_adjustment_changed), slider); -- cgit v1.2.3 From f7c10de0c22d6bc367d6791e98aa12065b797a56 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 13:07:22 +0100 Subject: GTK+ cleanup: gtk_timeout_add (bzr r10412) --- src/text-context.cpp | 2 +- src/ui/dialog/dock-behavior.cpp | 2 +- src/ui/dialog/floating-behavior.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/text-context.cpp b/src/text-context.cpp index 3ef346ebe..89944a602 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -215,7 +215,7 @@ sp_text_context_setup(SPEventContext *ec) SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0); sp_canvas_item_hide(tc->frame); - tc->timeout = gtk_timeout_add(timeout, (GtkFunction) sp_text_context_timeout, ec); + tc->timeout = g_timeout_add(timeout, (GSourceFunc) sp_text_context_timeout, ec); tc->imc = gtk_im_multicontext_new(); if (tc->imc) { diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 47cbab485..25fa1739a 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -262,7 +262,7 @@ DockBehavior::onDesktopActivated(SPDesktop *desktop) } // we're done, allow next retransientizing not sooner than after 120 msec - gtk_timeout_add (120, (GtkFunction) sp_retransientize_again, (gpointer) floating_win); + g_timeout_add (120, (GSourceFunc) sp_retransientize_again, (gpointer) floating_win); } } diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 35cc88090..6a086e0a1 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -220,7 +220,7 @@ FloatingBehavior::onDesktopActivated (SPDesktop *desktop) } // we're done, allow next retransientizing not sooner than after 120 msec - gtk_timeout_add (120, (GtkFunction) sp_retransientize_again, (gpointer) _d); + g_timeout_add (120, (GSourceFunc) sp_retransientize_again, (gpointer) _d); } -- cgit v1.2.3 From 1e42fa6eb9150761c2f089a0650afcc96f21b992 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 13:35:29 +0100 Subject: GTK+ cleanup: gtk_timeout_remove (bzr r10413) --- src/text-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/text-context.cpp b/src/text-context.cpp index 89944a602..a27ad3ee4 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -297,7 +297,7 @@ sp_text_context_finish(SPEventContext *ec) } if (tc->timeout) { - gtk_timeout_remove(tc->timeout); + g_source_remove(tc->timeout); tc->timeout = 0; } -- cgit v1.2.3 From 4d613dc583b96ea9205cd06f229956d6ec56c9e6 Mon Sep 17 00:00:00 2001 From: Nick Drobchenko Date: Tue, 5 Jul 2011 19:12:43 +0400 Subject: Gcodetools have been upgraded to v. 1.7. (bzr r10417) --- ...PLEASE DON'T MAKE CHANGES IN THESE FILES.README | 14 +- src/CMakeLists.txt | 1196 ++++++++++---------- src/dom/mingwenv.bat | 4 +- src/inkscape-manifest.xml | 18 +- src/inkview-manifest.xml | 18 +- src/inkview.rc | 58 +- src/libvpsc/CMakeLists.txt | 58 +- 7 files changed, 683 insertions(+), 683 deletions(-) (limited to 'src') diff --git a/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README b/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README index fdb2212ae..9e4585078 100644 --- a/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README +++ b/src/2geom/!PLEASE DON'T MAKE CHANGES IN THESE FILES.README @@ -1,8 +1,8 @@ -All code files in this directory are *direct* copies of the files in 2geom's svn. -If you want to change the code, please change it in 2geom, then copy the files here. -Otherwise, I will probably miss that you changed something in Inkscape's copy, and -destroy your changes by copying 2geom's files over it during the next time I update -Inkscape's copy of 2geom. - - Johan Engelen - +All code files in this directory are *direct* copies of the files in 2geom's svn. +If you want to change the code, please change it in 2geom, then copy the files here. +Otherwise, I will probably miss that you changed something in Inkscape's copy, and +destroy your changes by copying 2geom's files over it during the next time I update +Inkscape's copy of 2geom. + - Johan Engelen + 2geom's SVN = https://lib2geom.svn.sourceforge.net/svnroot/lib2geom/lib2geom/trunk \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e83a1604..580d65b0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,598 +1,598 @@ - -# ----------------------------------------------------------------------------- -# Define the main source -# ----------------------------------------------------------------------------- - -set(main_SRC - main.cpp -) - -set(sp_SRC - sp-anchor.cpp - # sp-animation.cpp - sp-clippath.cpp - sp-conn-end-pair.cpp - sp-conn-end.cpp - sp-cursor.cpp - sp-defs.cpp - sp-desc.cpp - sp-ellipse.cpp - sp-filter-primitive.cpp - sp-filter-reference.cpp - sp-filter.cpp - sp-flowdiv.cpp - sp-flowregion.cpp - sp-flowtext.cpp - sp-font-face.cpp - sp-font.cpp - sp-glyph-kerning.cpp - sp-glyph.cpp - sp-gradient-reference.cpp - sp-gradient.cpp - sp-guide.cpp - sp-image.cpp - sp-item-group.cpp - sp-item-notify-moveto.cpp - sp-item-rm-unsatisfied-cns.cpp - sp-item-transform.cpp - sp-item-update-cns.cpp - sp-item.cpp - sp-line.cpp - sp-lpe-item.cpp - sp-mask.cpp - sp-metadata.cpp - sp-metrics.cpp - sp-missing-glyph.cpp - sp-namedview.cpp - sp-object-group.cpp - sp-object-repr.cpp - sp-object.cpp - sp-offset.cpp - sp-paint-server.cpp - sp-path.cpp - sp-pattern.cpp - sp-polygon.cpp - sp-polyline.cpp - sp-rect.cpp - sp-root.cpp - sp-script.cpp - sp-shape.cpp - # sp-skeleton.cpp - sp-spiral.cpp - sp-star.cpp - sp-stop.cpp - sp-string.cpp - sp-style-elem.cpp - sp-switch.cpp - sp-symbol.cpp - sp-text.cpp - sp-title.cpp - sp-tref-reference.cpp - sp-tref.cpp - sp-tspan.cpp - sp-use-reference.cpp - sp-use.cpp - spiral-context.cpp - splivarot.cpp - - - # ------- - # Headers - sp-anchor.h - sp-animation.h - sp-clippath.h - sp-conn-end-pair.h - sp-conn-end.h - sp-cursor.h - sp-defs.h - sp-desc.h - sp-ellipse.h - sp-filter-primitive.h - sp-filter-reference.h - sp-filter-units.h - sp-filter.h - sp-flowdiv.h - sp-flowregion.h - sp-flowtext.h - sp-font-face.h - sp-font.h - sp-glyph-kerning.h - sp-glyph.h - sp-gradient-fns.h - sp-gradient-reference.h - sp-gradient-spread.h - sp-gradient-test.h - sp-gradient-units.h - sp-gradient-vector.h - sp-gradient.h - sp-guide-attachment.h - sp-guide-constraint.h - sp-guide.h - sp-image.h - sp-item-group.h - sp-item-notify-moveto.h - sp-item-rm-unsatisfied-cns.h - sp-item-transform.h - sp-item-update-cns.h - sp-item.h - sp-line.h - sp-linear-gradient-fns.h - sp-linear-gradient.h - sp-lpe-item.h - sp-marker-loc.h - sp-mask.h - sp-metadata.h - sp-metric.h - sp-metrics.h - sp-missing-glyph.h - sp-namedview.h - sp-object-group.h - sp-object-repr.h - sp-object.h - sp-offset.h - sp-paint-server-reference.h - sp-paint-server.h - sp-path.h - sp-pattern.h - sp-polygon.h - sp-polyline.h - sp-radial-gradient-fns.h - sp-radial-gradient.h - sp-rect.h - sp-root.h - sp-script.h - sp-shape.h - # sp-skeleton.h - sp-spiral.h - sp-star.h - sp-stop.h - sp-string.h - sp-style-elem-test.h - sp-style-elem.h - sp-switch.h - sp-symbol.h - sp-text.h - sp-textpath.h - sp-title.h - sp-tref-reference.h - sp-tref.h - sp-tspan.h - sp-use-reference.h - sp-use.h -) - -set(inkscape_SRC - arc-context.cpp - attributes.cpp - axis-manip.cpp - box3d-context.cpp - box3d-side.cpp - box3d.cpp - color-profile.cpp - color.cpp - common-context.cpp - composite-undo-stack-observer.cpp - conditions.cpp - conn-avoid-ref.cpp - connection-points.cpp - connector-context.cpp - console-output-undo-observer.cpp - context-fns.cpp - desktop-events.cpp - desktop-handles.cpp - desktop-style.cpp - desktop.cpp - device-manager.cpp - dir-util.cpp - document-subset.cpp - document-undo.cpp - document.cpp - doxygen-main.cpp - draw-anchor.cpp - draw-context.cpp - dropper-context.cpp - dyna-draw-context.cpp - ege-adjustment-action.cpp - ege-color-prof-tracker.cpp - ege-output-action.cpp - ege-select-one-action.cpp - eraser-context.cpp - event-context.cpp - event-log.cpp - extract-uri.cpp - file.cpp - filter-chemistry.cpp - filter-enums.cpp - fixes.cpp - flood-context.cpp - gc-anchored.cpp - gc-finalized.cpp - gc.cpp - gradient-chemistry.cpp - gradient-context.cpp - gradient-drag.cpp - graphlayout.cpp - guide-snapper.cpp - help.cpp - id-clash.cpp - ige-mac-menu.c - ink-action.cpp - ink-comboboxentry-action.cpp - inkscape.cpp - inkscape.rc - interface.cpp - knot-holder-entity.cpp - knot.cpp - knotholder.cpp - layer-fns.cpp - layer-manager.cpp - line-geometry.cpp - line-snapper.cpp - lpe-tool-context.cpp - main-cmdlineact.cpp - marker.cpp - measure-context.cpp - media.cpp - message-context.cpp - message-stack.cpp - mod360.cpp - object-edit.cpp - object-hierarchy.cpp - object-snapper.cpp - path-chemistry.cpp - pen-context.cpp - pencil-context.cpp - persp3d-reference.cpp - persp3d.cpp - perspective-line.cpp - preferences.cpp - prefix.cpp - print.cpp - profile-manager.cpp - proj_pt.cpp - rdf.cpp - rect-context.cpp - removeoverlap.cpp - resource-manager.cpp - rubberband.cpp - satisfied-guide-cns.cpp - selcue.cpp - select-context.cpp - selection-chemistry.cpp - selection-describer.cpp - selection.cpp - seltrans-handles.cpp - seltrans.cpp - shape-editor.cpp - shortcuts.cpp - snap-preferences.cpp - snap.cpp - snapped-curve.cpp - snapped-line.cpp - snapped-point.cpp - snapper.cpp - spray-context.cpp - star-context.cpp - style.cpp - svg-view-widget.cpp - svg-view.cpp - text-chemistry.cpp - text-context.cpp - text-editing.cpp - tools-switch.cpp - transf_mat_3x4.cpp - tweak-context.cpp - unclump.cpp - unicoderange.cpp - uri-references.cpp - uri.cpp - vanishing-point.cpp - verbs.cpp - version.cpp - zoom-context.cpp - - - # ------- - # Headers - MultiPrinter.h - PylogFormatter.h - TRPIFormatter.h - approx-equal.h - arc-context.h - attributes-test.h - attributes.h - axis-manip.h - bad-uri-exception.h - box3d-context.h - box3d-side.h - box3d.h - color-profile-fns.h - color-profile-test.h - color-profile.h - color-rgba.h - color.h - common-context.h - composite-undo-stack-observer.h - conditions.h - conn-avoid-ref.h - connection-points.h - connection-pool.h - connector-context.h - console-output-undo-observer.h - context-fns.h - decimal-round.h - desktop-events.h - desktop-handles.h - desktop-style.h - desktop.h - device-manager.h - dir-util-test.h - dir-util.h - document-private.h - document-subset.h - document-undo.h - document.h - draw-anchor.h - draw-context.h - dropper-context.h - dyna-draw-context.h - ege-adjustment-action.h - ege-color-prof-tracker.h - ege-output-action.h - ege-select-one-action.h - enums.h - eraser-context.h - event-context.h - event-log.h - event.h - extract-uri-test.h - extract-uri.h - file.h - fill-or-stroke.h - filter-chemistry.h - filter-enums.h - flood-context.h - forward.h - gc-alloc.h - gc-allocator.h - gc-anchored.h - gc-core.h - gc-finalized.h - gc-managed.h - gc-soft-ptr.h - gradient-chemistry.h - gradient-context.h - gradient-drag.h - graphlayout.h - guide-snapper.h - help.h - helper-fns.h - icon-size.h - id-clash.h - ige-mac-menu.h - ink-action.h - ink-comboboxentry-action.h - inkscape-private.h - inkscape-version.h - inkscape.h - interface.h - isinf.h - isnormal.h - knot-enums.h - knot-holder-entity.h - knot.h - knotholder.h - layer-fns.h - layer-manager.h - line-geometry.h - line-snapper.h - lpe-tool-context.h - macros.h - main-cmdlineact.h - marker-test.h - marker.h - measure-context.h - media.h - memeq.h - menus-skeleton.h - message-context.h - message-stack.h - message.h - mod360-test.h - mod360.h - modifier-fns.h - number-opt-number.h - object-edit.h - object-hierarchy.h - object-snapper.h - path-chemistry.h - path-prefix.h - pen-context.h - pencil-context.h - persp3d-reference.h - persp3d.h - perspective-line.h - preferences-skeleton.h - preferences-test.h - preferences.h - prefix.h - print.h - profile-manager.h - proj_pt.h - rdf.h - rect-context.h - registrytool.h - remove-last.h - removeoverlap.h - require-config.h - resource-manager.h - round-test.h - round.h - rubberband.h - satisfied-guide-cns.h - selcue.h - select-context.h - selection-chemistry.h - selection-describer.h - selection.h - seltrans-handles.h - seltrans.h - shape-editor.h - shortcuts.h - snap-candidate.h - snap-enums.h - snap-preferences.h - snap.h - snapped-curve.h - snapped-line.h - snapped-point.h - snapper.h - spiral-context.h - splivarot.h - spray-context.h - star-context.h - streq.h - strneq.h - style-test.h - style.h - svg-profile.h - svg-view-widget.h - svg-view.h - syseq.h - test-helpers.h - text-chemistry.h - text-context.h - text-editing.h - text-tag-attributes.h - tools-switch.h - transf_mat_3x4.h - tweak-context.h - unclump.h - undo-stack-observer.h - unicoderange.h - unit-constants.h - uri-references.h - uri.h - vanishing-point.h - verbs-test.h - verbs.h - version.h - zoom-context.h -) - -if(WIN32) - list(APPEND inkscape_SRC - registrytool.cpp - #deptool.cpp - winmain.cpp - ) -endif() - - -# ----------------------------------------------------------------------------- -# Generate version file -# ----------------------------------------------------------------------------- - -# a custom target that is always built -add_custom_target( - inkscape_version ALL - DEPENDS ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp) - -# creates inkscape-version.cpp using cmake script -add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp - COMMAND ${CMAKE_COMMAND} - -DINKSCAPE_SOURCE_DIR=${CMAKE_SOURCE_DIR} - -DINKSCAPE_BINARY_DIR=${CMAKE_BINARY_DIR} - -P ${CMAKE_SOURCE_DIR}/CMakeScripts/inkscape-version.cmake) - -# buildinfo.h is a generated file -set_source_files_properties( - ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp - PROPERTIES GENERATED TRUE) - -list(APPEND inkscape_SRC - ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp -) - - -# ----------------------------------------------------------------------------- -# Load in subdirectories -# ----------------------------------------------------------------------------- - -# All folders for internal inkscape -# these call add_inkscape_source -add_subdirectory(bind) -add_subdirectory(debug) -add_subdirectory(dialogs) -add_subdirectory(display) -add_subdirectory(dom) -add_subdirectory(extension) -add_subdirectory(filters) -add_subdirectory(helper) -add_subdirectory(io) -add_subdirectory(live_effects) -add_subdirectory(svg) -add_subdirectory(trace) -add_subdirectory(ui) -add_subdirectory(util) -add_subdirectory(widgets) -add_subdirectory(xml) -add_subdirectory(2geom) - - -# Directories containing lists files that describe building internal libraries -add_subdirectory(libavoid) -add_subdirectory(libcola) -add_subdirectory(libcroco) -add_subdirectory(libgdl) -add_subdirectory(libvpsc) -add_subdirectory(livarot) -add_subdirectory(libnr) -add_subdirectory(libnrtype) - - -get_property(inkscape_global_SRC GLOBAL PROPERTY inkscape_global_SRC) - -set(inkscape_SRC - ${inkscape_global_SRC} - ${inkscape_SRC} -) - -# ----------------------------------------------------------------------------- -# Setup the executable -# ----------------------------------------------------------------------------- -add_inkscape_lib(sp_LIB "${sp_SRC}") -add_inkscape_lib(inkscape_LIB "${inkscape_SRC}") - -# make executable for INKSCAPE -add_executable(inkscape ${main_SRC}) - -add_dependencies(inkscape inkscape_version) - -target_link_libraries(inkscape - # order from automake - sp_LIB - inkscape_LIB - sp_LIB # annoying, we need both! - - nr_LIB - nrtype_LIB - - dom_LIB - croco_LIB - avoid_LIB - gdl_LIB - cola_LIB - vpsc_LIB - livarot_LIB - 2geom_LIB - - ${INKSCAPE_LIBS} -) - -# TODO -# make executable for INKVIEW -#add_executable(inkview inkview.cpp) -# ... - + +# ----------------------------------------------------------------------------- +# Define the main source +# ----------------------------------------------------------------------------- + +set(main_SRC + main.cpp +) + +set(sp_SRC + sp-anchor.cpp + # sp-animation.cpp + sp-clippath.cpp + sp-conn-end-pair.cpp + sp-conn-end.cpp + sp-cursor.cpp + sp-defs.cpp + sp-desc.cpp + sp-ellipse.cpp + sp-filter-primitive.cpp + sp-filter-reference.cpp + sp-filter.cpp + sp-flowdiv.cpp + sp-flowregion.cpp + sp-flowtext.cpp + sp-font-face.cpp + sp-font.cpp + sp-glyph-kerning.cpp + sp-glyph.cpp + sp-gradient-reference.cpp + sp-gradient.cpp + sp-guide.cpp + sp-image.cpp + sp-item-group.cpp + sp-item-notify-moveto.cpp + sp-item-rm-unsatisfied-cns.cpp + sp-item-transform.cpp + sp-item-update-cns.cpp + sp-item.cpp + sp-line.cpp + sp-lpe-item.cpp + sp-mask.cpp + sp-metadata.cpp + sp-metrics.cpp + sp-missing-glyph.cpp + sp-namedview.cpp + sp-object-group.cpp + sp-object-repr.cpp + sp-object.cpp + sp-offset.cpp + sp-paint-server.cpp + sp-path.cpp + sp-pattern.cpp + sp-polygon.cpp + sp-polyline.cpp + sp-rect.cpp + sp-root.cpp + sp-script.cpp + sp-shape.cpp + # sp-skeleton.cpp + sp-spiral.cpp + sp-star.cpp + sp-stop.cpp + sp-string.cpp + sp-style-elem.cpp + sp-switch.cpp + sp-symbol.cpp + sp-text.cpp + sp-title.cpp + sp-tref-reference.cpp + sp-tref.cpp + sp-tspan.cpp + sp-use-reference.cpp + sp-use.cpp + spiral-context.cpp + splivarot.cpp + + + # ------- + # Headers + sp-anchor.h + sp-animation.h + sp-clippath.h + sp-conn-end-pair.h + sp-conn-end.h + sp-cursor.h + sp-defs.h + sp-desc.h + sp-ellipse.h + sp-filter-primitive.h + sp-filter-reference.h + sp-filter-units.h + sp-filter.h + sp-flowdiv.h + sp-flowregion.h + sp-flowtext.h + sp-font-face.h + sp-font.h + sp-glyph-kerning.h + sp-glyph.h + sp-gradient-fns.h + sp-gradient-reference.h + sp-gradient-spread.h + sp-gradient-test.h + sp-gradient-units.h + sp-gradient-vector.h + sp-gradient.h + sp-guide-attachment.h + sp-guide-constraint.h + sp-guide.h + sp-image.h + sp-item-group.h + sp-item-notify-moveto.h + sp-item-rm-unsatisfied-cns.h + sp-item-transform.h + sp-item-update-cns.h + sp-item.h + sp-line.h + sp-linear-gradient-fns.h + sp-linear-gradient.h + sp-lpe-item.h + sp-marker-loc.h + sp-mask.h + sp-metadata.h + sp-metric.h + sp-metrics.h + sp-missing-glyph.h + sp-namedview.h + sp-object-group.h + sp-object-repr.h + sp-object.h + sp-offset.h + sp-paint-server-reference.h + sp-paint-server.h + sp-path.h + sp-pattern.h + sp-polygon.h + sp-polyline.h + sp-radial-gradient-fns.h + sp-radial-gradient.h + sp-rect.h + sp-root.h + sp-script.h + sp-shape.h + # sp-skeleton.h + sp-spiral.h + sp-star.h + sp-stop.h + sp-string.h + sp-style-elem-test.h + sp-style-elem.h + sp-switch.h + sp-symbol.h + sp-text.h + sp-textpath.h + sp-title.h + sp-tref-reference.h + sp-tref.h + sp-tspan.h + sp-use-reference.h + sp-use.h +) + +set(inkscape_SRC + arc-context.cpp + attributes.cpp + axis-manip.cpp + box3d-context.cpp + box3d-side.cpp + box3d.cpp + color-profile.cpp + color.cpp + common-context.cpp + composite-undo-stack-observer.cpp + conditions.cpp + conn-avoid-ref.cpp + connection-points.cpp + connector-context.cpp + console-output-undo-observer.cpp + context-fns.cpp + desktop-events.cpp + desktop-handles.cpp + desktop-style.cpp + desktop.cpp + device-manager.cpp + dir-util.cpp + document-subset.cpp + document-undo.cpp + document.cpp + doxygen-main.cpp + draw-anchor.cpp + draw-context.cpp + dropper-context.cpp + dyna-draw-context.cpp + ege-adjustment-action.cpp + ege-color-prof-tracker.cpp + ege-output-action.cpp + ege-select-one-action.cpp + eraser-context.cpp + event-context.cpp + event-log.cpp + extract-uri.cpp + file.cpp + filter-chemistry.cpp + filter-enums.cpp + fixes.cpp + flood-context.cpp + gc-anchored.cpp + gc-finalized.cpp + gc.cpp + gradient-chemistry.cpp + gradient-context.cpp + gradient-drag.cpp + graphlayout.cpp + guide-snapper.cpp + help.cpp + id-clash.cpp + ige-mac-menu.c + ink-action.cpp + ink-comboboxentry-action.cpp + inkscape.cpp + inkscape.rc + interface.cpp + knot-holder-entity.cpp + knot.cpp + knotholder.cpp + layer-fns.cpp + layer-manager.cpp + line-geometry.cpp + line-snapper.cpp + lpe-tool-context.cpp + main-cmdlineact.cpp + marker.cpp + measure-context.cpp + media.cpp + message-context.cpp + message-stack.cpp + mod360.cpp + object-edit.cpp + object-hierarchy.cpp + object-snapper.cpp + path-chemistry.cpp + pen-context.cpp + pencil-context.cpp + persp3d-reference.cpp + persp3d.cpp + perspective-line.cpp + preferences.cpp + prefix.cpp + print.cpp + profile-manager.cpp + proj_pt.cpp + rdf.cpp + rect-context.cpp + removeoverlap.cpp + resource-manager.cpp + rubberband.cpp + satisfied-guide-cns.cpp + selcue.cpp + select-context.cpp + selection-chemistry.cpp + selection-describer.cpp + selection.cpp + seltrans-handles.cpp + seltrans.cpp + shape-editor.cpp + shortcuts.cpp + snap-preferences.cpp + snap.cpp + snapped-curve.cpp + snapped-line.cpp + snapped-point.cpp + snapper.cpp + spray-context.cpp + star-context.cpp + style.cpp + svg-view-widget.cpp + svg-view.cpp + text-chemistry.cpp + text-context.cpp + text-editing.cpp + tools-switch.cpp + transf_mat_3x4.cpp + tweak-context.cpp + unclump.cpp + unicoderange.cpp + uri-references.cpp + uri.cpp + vanishing-point.cpp + verbs.cpp + version.cpp + zoom-context.cpp + + + # ------- + # Headers + MultiPrinter.h + PylogFormatter.h + TRPIFormatter.h + approx-equal.h + arc-context.h + attributes-test.h + attributes.h + axis-manip.h + bad-uri-exception.h + box3d-context.h + box3d-side.h + box3d.h + color-profile-fns.h + color-profile-test.h + color-profile.h + color-rgba.h + color.h + common-context.h + composite-undo-stack-observer.h + conditions.h + conn-avoid-ref.h + connection-points.h + connection-pool.h + connector-context.h + console-output-undo-observer.h + context-fns.h + decimal-round.h + desktop-events.h + desktop-handles.h + desktop-style.h + desktop.h + device-manager.h + dir-util-test.h + dir-util.h + document-private.h + document-subset.h + document-undo.h + document.h + draw-anchor.h + draw-context.h + dropper-context.h + dyna-draw-context.h + ege-adjustment-action.h + ege-color-prof-tracker.h + ege-output-action.h + ege-select-one-action.h + enums.h + eraser-context.h + event-context.h + event-log.h + event.h + extract-uri-test.h + extract-uri.h + file.h + fill-or-stroke.h + filter-chemistry.h + filter-enums.h + flood-context.h + forward.h + gc-alloc.h + gc-allocator.h + gc-anchored.h + gc-core.h + gc-finalized.h + gc-managed.h + gc-soft-ptr.h + gradient-chemistry.h + gradient-context.h + gradient-drag.h + graphlayout.h + guide-snapper.h + help.h + helper-fns.h + icon-size.h + id-clash.h + ige-mac-menu.h + ink-action.h + ink-comboboxentry-action.h + inkscape-private.h + inkscape-version.h + inkscape.h + interface.h + isinf.h + isnormal.h + knot-enums.h + knot-holder-entity.h + knot.h + knotholder.h + layer-fns.h + layer-manager.h + line-geometry.h + line-snapper.h + lpe-tool-context.h + macros.h + main-cmdlineact.h + marker-test.h + marker.h + measure-context.h + media.h + memeq.h + menus-skeleton.h + message-context.h + message-stack.h + message.h + mod360-test.h + mod360.h + modifier-fns.h + number-opt-number.h + object-edit.h + object-hierarchy.h + object-snapper.h + path-chemistry.h + path-prefix.h + pen-context.h + pencil-context.h + persp3d-reference.h + persp3d.h + perspective-line.h + preferences-skeleton.h + preferences-test.h + preferences.h + prefix.h + print.h + profile-manager.h + proj_pt.h + rdf.h + rect-context.h + registrytool.h + remove-last.h + removeoverlap.h + require-config.h + resource-manager.h + round-test.h + round.h + rubberband.h + satisfied-guide-cns.h + selcue.h + select-context.h + selection-chemistry.h + selection-describer.h + selection.h + seltrans-handles.h + seltrans.h + shape-editor.h + shortcuts.h + snap-candidate.h + snap-enums.h + snap-preferences.h + snap.h + snapped-curve.h + snapped-line.h + snapped-point.h + snapper.h + spiral-context.h + splivarot.h + spray-context.h + star-context.h + streq.h + strneq.h + style-test.h + style.h + svg-profile.h + svg-view-widget.h + svg-view.h + syseq.h + test-helpers.h + text-chemistry.h + text-context.h + text-editing.h + text-tag-attributes.h + tools-switch.h + transf_mat_3x4.h + tweak-context.h + unclump.h + undo-stack-observer.h + unicoderange.h + unit-constants.h + uri-references.h + uri.h + vanishing-point.h + verbs-test.h + verbs.h + version.h + zoom-context.h +) + +if(WIN32) + list(APPEND inkscape_SRC + registrytool.cpp + #deptool.cpp + winmain.cpp + ) +endif() + + +# ----------------------------------------------------------------------------- +# Generate version file +# ----------------------------------------------------------------------------- + +# a custom target that is always built +add_custom_target( + inkscape_version ALL + DEPENDS ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp) + +# creates inkscape-version.cpp using cmake script +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp + COMMAND ${CMAKE_COMMAND} + -DINKSCAPE_SOURCE_DIR=${CMAKE_SOURCE_DIR} + -DINKSCAPE_BINARY_DIR=${CMAKE_BINARY_DIR} + -P ${CMAKE_SOURCE_DIR}/CMakeScripts/inkscape-version.cmake) + +# buildinfo.h is a generated file +set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp + PROPERTIES GENERATED TRUE) + +list(APPEND inkscape_SRC + ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp +) + + +# ----------------------------------------------------------------------------- +# Load in subdirectories +# ----------------------------------------------------------------------------- + +# All folders for internal inkscape +# these call add_inkscape_source +add_subdirectory(bind) +add_subdirectory(debug) +add_subdirectory(dialogs) +add_subdirectory(display) +add_subdirectory(dom) +add_subdirectory(extension) +add_subdirectory(filters) +add_subdirectory(helper) +add_subdirectory(io) +add_subdirectory(live_effects) +add_subdirectory(svg) +add_subdirectory(trace) +add_subdirectory(ui) +add_subdirectory(util) +add_subdirectory(widgets) +add_subdirectory(xml) +add_subdirectory(2geom) + + +# Directories containing lists files that describe building internal libraries +add_subdirectory(libavoid) +add_subdirectory(libcola) +add_subdirectory(libcroco) +add_subdirectory(libgdl) +add_subdirectory(libvpsc) +add_subdirectory(livarot) +add_subdirectory(libnr) +add_subdirectory(libnrtype) + + +get_property(inkscape_global_SRC GLOBAL PROPERTY inkscape_global_SRC) + +set(inkscape_SRC + ${inkscape_global_SRC} + ${inkscape_SRC} +) + +# ----------------------------------------------------------------------------- +# Setup the executable +# ----------------------------------------------------------------------------- +add_inkscape_lib(sp_LIB "${sp_SRC}") +add_inkscape_lib(inkscape_LIB "${inkscape_SRC}") + +# make executable for INKSCAPE +add_executable(inkscape ${main_SRC}) + +add_dependencies(inkscape inkscape_version) + +target_link_libraries(inkscape + # order from automake + sp_LIB + inkscape_LIB + sp_LIB # annoying, we need both! + + nr_LIB + nrtype_LIB + + dom_LIB + croco_LIB + avoid_LIB + gdl_LIB + cola_LIB + vpsc_LIB + livarot_LIB + 2geom_LIB + + ${INKSCAPE_LIBS} +) + +# TODO +# make executable for INKVIEW +#add_executable(inkview inkview.cpp) +# ... + diff --git a/src/dom/mingwenv.bat b/src/dom/mingwenv.bat index 996566e7b..48e8bf096 100644 --- a/src/dom/mingwenv.bat +++ b/src/dom/mingwenv.bat @@ -1,2 +1,2 @@ -set PATH=c:\mingw\bin;%PATH% -set RM=del +set PATH=c:\mingw\bin;%PATH% +set RM=del diff --git a/src/inkscape-manifest.xml b/src/inkscape-manifest.xml index fd2f19e43..f9ca4617f 100644 --- a/src/inkscape-manifest.xml +++ b/src/inkscape-manifest.xml @@ -1,10 +1,10 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/src/inkview-manifest.xml b/src/inkview-manifest.xml index fd2f19e43..f9ca4617f 100644 --- a/src/inkview-manifest.xml +++ b/src/inkview-manifest.xml @@ -1,10 +1,10 @@ - - - - - - - + + + + + + + \ No newline at end of file diff --git a/src/inkview.rc b/src/inkview.rc index b2d3da7bc..83bb89ba4 100644 --- a/src/inkview.rc +++ b/src/inkview.rc @@ -1,29 +1,29 @@ - -APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" -1 24 DISCARDABLE "./inkview-manifest.xml" - -1 VERSIONINFO - FILEVERSION 0,48,0,9 - PRODUCTVERSION 0,48,0,9 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040901b5" - BEGIN - VALUE "Comments", "Published under the GNU GPL" - VALUE "CompanyName", "inkscape.org" - VALUE "FileDescription", "Inkview" - VALUE "FileVersion", "0.48+devel" - VALUE "InternalName", "Inkview" - VALUE "LegalCopyright", "© 2010 Inkscape" - VALUE "ProductName", "Inkview" - VALUE "ProductVersion", "0.48+devel" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 1033, 437 - END -END - -1000 BITMAP "./show-preview.bmp" + +APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" +1 24 DISCARDABLE "./inkview-manifest.xml" + +1 VERSIONINFO + FILEVERSION 0,48,0,9 + PRODUCTVERSION 0,48,0,9 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040901b5" + BEGIN + VALUE "Comments", "Published under the GNU GPL" + VALUE "CompanyName", "inkscape.org" + VALUE "FileDescription", "Inkview" + VALUE "FileVersion", "0.48+devel" + VALUE "InternalName", "Inkview" + VALUE "LegalCopyright", "© 2010 Inkscape" + VALUE "ProductName", "Inkview" + VALUE "ProductVersion", "0.48+devel" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 1033, 437 + END +END + +1000 BITMAP "./show-preview.bmp" diff --git a/src/libvpsc/CMakeLists.txt b/src/libvpsc/CMakeLists.txt index 8db059b5d..4099900b5 100644 --- a/src/libvpsc/CMakeLists.txt +++ b/src/libvpsc/CMakeLists.txt @@ -1,29 +1,29 @@ - -set(libvpsc_SRC - block.cpp - blocks.cpp - constraint.cpp - csolve_VPSC.cpp - generate-constraints.cpp - remove_rectangle_overlap.cpp - solve_VPSC.cpp - variable.cpp - pairingheap/PairingHeap.cpp - - - # ------- - # Headers - block.h - blocks.h - constraint.h - csolve_VPSC.h - generate-constraints.h - pairingheap/PairingHeap.h - pairingheap/dsexceptions.h - placement_SolveVPSC.h - remove_rectangle_overlap.h - solve_VPSC.h - variable.h -) - -add_inkscape_lib(vpsc_LIB "${libvpsc_SRC}") + +set(libvpsc_SRC + block.cpp + blocks.cpp + constraint.cpp + csolve_VPSC.cpp + generate-constraints.cpp + remove_rectangle_overlap.cpp + solve_VPSC.cpp + variable.cpp + pairingheap/PairingHeap.cpp + + + # ------- + # Headers + block.h + blocks.h + constraint.h + csolve_VPSC.h + generate-constraints.h + pairingheap/PairingHeap.h + pairingheap/dsexceptions.h + placement_SolveVPSC.h + remove_rectangle_overlap.h + solve_VPSC.h + variable.h +) + +add_inkscape_lib(vpsc_LIB "${libvpsc_SRC}") -- cgit v1.2.3 From 0c8f976a2b5dcd83343efddb842bedcf16de4433 Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Tue, 5 Jul 2011 13:22:31 -0700 Subject: Fix build and clean makefile (bzr r10418) --- src/Makefile.am | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 40ecc1ec7..7925dcd7e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -118,8 +118,6 @@ include extension/script/Makefile_insert include filters/Makefile_insert include helper/Makefile_insert include io/Makefile_insert -#include pedro/Makefile_insert -#include jabber_whiteboard/Makefile_insert include libcroco/Makefile_insert include libgdl/Makefile_insert include libnr/Makefile_insert -- cgit v1.2.3 From 7f1450da45f207e4e30d88f14a68ec4b201d1922 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 5 Jul 2011 23:01:58 +0100 Subject: Text edit dialog: Apply button should grab default only after adding to window Fixed bugs: - https://launchpad.net/bugs/805644 (bzr r10419) --- src/dialogs/text-edit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 277ea92bc..16166d97e 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -450,11 +450,11 @@ sp_text_edit_dialog (void) { GtkWidget *b = gtk_button_new_from_stock (GTK_STOCK_APPLY); - gtk_widget_set_can_default (b, TRUE); - gtk_widget_grab_default (b); g_signal_connect ( G_OBJECT (b), "clicked", G_CALLBACK (sp_text_edit_dialog_apply), dlg ); gtk_box_pack_end ( GTK_BOX (hb), b, FALSE, FALSE, 0 ); + gtk_widget_set_can_default (b, TRUE); + gtk_widget_grab_default (b); g_object_set_data (G_OBJECT (dlg), "apply", b); } -- cgit v1.2.3 From b40f9bd37abc96d579f930dee9e6fb95031d74f0 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 6 Jul 2011 00:26:32 -0700 Subject: Refactoring color profile to bring more internal. Help to prep for optional lcms2 support. (bzr r10420) --- src/color-profile-fns.h | 1 - src/color-profile.cpp | 261 ++++++++++++++++++++++----------- src/color-profile.h | 32 ++-- src/interface.cpp | 4 - src/ui/dialog/document-properties.cpp | 60 +++----- src/ui/dialog/inkscape-preferences.cpp | 4 +- src/widgets/sp-color-icc-selector.h | 8 +- src/widgets/sp-color-notebook.cpp | 3 +- 8 files changed, 213 insertions(+), 160 deletions(-) (limited to 'src') diff --git a/src/color-profile-fns.h b/src/color-profile-fns.h index defc58f2c..3d22417f6 100644 --- a/src/color-profile-fns.h +++ b/src/color-profile-fns.h @@ -38,7 +38,6 @@ std::vector colorprofile_get_display_names(); std::vector colorprofile_get_softproof_names(); Glib::ustring get_path_for_profile(Glib::ustring const& name); -void colorprofile_load_profiles(bool force_refresh = false); #endif diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 4dc4d5bd8..7c9e83e3c 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -24,6 +24,10 @@ #include #endif +#if ENABLE_LCMS +#include +#endif // ENABLE_LCMS + #include "xml/repr.h" #include "color.h" #include "color-profile.h" @@ -42,12 +46,15 @@ using Inkscape::ColorProfile; using Inkscape::ColorProfileClass; +using Inkscape::ColorProfileImpl; -namespace Inkscape +namespace { #if ENABLE_LCMS -static cmsHPROFILE colorprofile_get_system_profile_handle(); -static cmsHPROFILE colorprofile_get_proof_profile_handle(); +cmsHPROFILE getSystemProfileHandle(); +cmsHPROFILE getProofProfileHandle(); +void loadProfiles(); +Glib::ustring getNameFromProfile(cmsHPROFILE profile); #endif // ENABLE_LCMS } @@ -93,20 +100,57 @@ extern guint update_in_progress; static SPObjectClass *cprof_parent_class; + +class ColorProfileImpl { +public: + static cmsHPROFILE _sRGBProf; + static cmsHPROFILE _NullProf; + + ColorProfileImpl(); + #if ENABLE_LCMS + static DWORD _getInputFormat( icColorSpaceSignature space ); + + static cmsHPROFILE getNULLProfile(); + static cmsHPROFILE getSRGBProfile(); -cmsHPROFILE ColorProfile::_sRGBProf = 0; + void _clearProfile(); -cmsHPROFILE ColorProfile::getSRGBProfile() { + cmsHPROFILE _profHandle; + icProfileClassSignature _profileClass; + icColorSpaceSignature _profileSpace; + cmsHTRANSFORM _transf; + cmsHTRANSFORM _revTransf; + cmsHTRANSFORM _gamutTransf; +#endif // ENABLE_LCMS +}; + +ColorProfileImpl::ColorProfileImpl() : +#if ENABLE_LCMS + _profHandle(0), + _profileClass(icSigInputClass), + _profileSpace(icSigRgbData), + _transf(0), + _revTransf(0), + _gamutTransf(0) +#endif // ENABLE_LCMS +{ +} + +#if ENABLE_LCMS + +cmsHPROFILE ColorProfileImpl::_sRGBProf = 0; + +cmsHPROFILE ColorProfileImpl::getSRGBProfile() { if ( !_sRGBProf ) { _sRGBProf = cmsCreate_sRGBProfile(); } - return _sRGBProf; + return ColorProfileImpl::_sRGBProf; } -cmsHPROFILE ColorProfile::_NullProf = 0; +cmsHPROFILE ColorProfileImpl::_NullProf = 0; -cmsHPROFILE ColorProfile::getNULLProfile() { +cmsHPROFILE ColorProfileImpl::getNULLProfile() { if ( !_NullProf ) { _NullProf = cmsCreateNULLProfile(); } @@ -162,19 +206,13 @@ void ColorProfile::classInit( ColorProfileClass *klass ) */ void ColorProfile::init( ColorProfile *cprof ) { + cprof->impl = new ColorProfileImpl(); + cprof->href = 0; cprof->local = 0; cprof->name = 0; cprof->intentStr = 0; cprof->rendering_intent = Inkscape::RENDERING_INTENT_UNKNOWN; -#if ENABLE_LCMS - cprof->profHandle = 0; - cprof->_profileClass = icSigInputClass; - cprof->_profileSpace = icSigRgbData; - cprof->_transf = 0; - cprof->_revTransf = 0; - cprof->_gamutTransf = 0; -#endif // ENABLE_LCMS } /** @@ -209,12 +247,15 @@ void ColorProfile::release( SPObject *object ) } #if ENABLE_LCMS - cprof->_clearProfile(); + cprof->impl->_clearProfile(); #endif // ENABLE_LCMS + + delete cprof->impl; + cprof->impl = 0; } #if ENABLE_LCMS -void ColorProfile::_clearProfile() +void ColorProfileImpl::_clearProfile() { _profileSpace = icSigRgbData; @@ -230,9 +271,9 @@ void ColorProfile::_clearProfile() cmsDeleteTransform( _gamutTransf ); _gamutTransf = 0; } - if ( profHandle ) { - cmsCloseProfile( profHandle ); - profHandle = 0; + if ( _profHandle ) { + cmsCloseProfile( _profHandle ); + _profHandle = 0; } } #endif // ENABLE_LCMS @@ -309,13 +350,13 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value ) // the w3c specs. All absolute and relative issues are considered org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri); gchar* fullname = g_uri_unescape_string(cprofUri.getNativePath().c_str(), ""); - cprof->_clearProfile(); - cprof->profHandle = cmsOpenProfileFromFile( fullname, "r" ); - if ( cprof->profHandle ) { - cprof->_profileSpace = cmsGetColorSpace( cprof->profHandle ); - cprof->_profileClass = cmsGetDeviceClass( cprof->profHandle ); + cprof->impl->_clearProfile(); + cprof->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); + if ( cprof->impl->_profHandle ) { + cprof->impl->_profileSpace = cmsGetColorSpace( cprof->impl->_profHandle ); + cprof->impl->_profileClass = cmsGetDeviceClass( cprof->impl->_profHandle ); } - DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->profHandle ); + DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->impl->_profHandle ); g_free(escaped); escaped = 0; g_free(fullname); @@ -423,7 +464,7 @@ struct MapMap { DWORD inForm; }; -DWORD ColorProfile::_getInputFormat( icColorSpaceSignature space ) +DWORD ColorProfileImpl::_getInputFormat( icColorSpaceSignature space ) { MapMap possible[] = { {icSigXYZData, TYPE_XYZ_16}, @@ -498,7 +539,7 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte SPObject* thing = bruteFind( document, name ); if ( thing ) { - prof = COLORPROFILE(thing)->profHandle; + prof = COLORPROFILE(thing)->impl->_profHandle; } if ( intent ) { @@ -510,35 +551,43 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte return prof; } +icColorSpaceSignature ColorProfile::getColorSpace() const { + return impl->_profileSpace; +} + +icProfileClassSignature ColorProfile::getProfileClass() const { + return impl->_profileClass; +} + cmsHTRANSFORM ColorProfile::getTransfToSRGB8() { - if ( !_transf && profHandle ) { + if ( !impl->_transf && impl->_profHandle ) { int intent = getLcmsIntent(rendering_intent); - _transf = cmsCreateTransform( profHandle, _getInputFormat(_profileSpace), getSRGBProfile(), TYPE_BGRA_8, intent, 0 ); + impl->_transf = cmsCreateTransform( impl->_profHandle, ColorProfileImpl::_getInputFormat(impl->_profileSpace), ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, intent, 0 ); } - return _transf; + return impl->_transf; } cmsHTRANSFORM ColorProfile::getTransfFromSRGB8() { - if ( !_revTransf && profHandle ) { + if ( !impl->_revTransf && impl->_profHandle ) { int intent = getLcmsIntent(rendering_intent); - _revTransf = cmsCreateTransform( getSRGBProfile(), TYPE_BGRA_8, profHandle, _getInputFormat(_profileSpace), intent, 0 ); + impl->_revTransf = cmsCreateTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, impl->_profHandle, ColorProfileImpl::_getInputFormat(impl->_profileSpace), intent, 0 ); } - return _revTransf; + return impl->_revTransf; } cmsHTRANSFORM ColorProfile::getTransfGamutCheck() { - if ( !_gamutTransf ) { - _gamutTransf = cmsCreateProofingTransform(getSRGBProfile(), TYPE_BGRA_8, getNULLProfile(), TYPE_GRAY_8, profHandle, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING)); + if ( !impl->_gamutTransf ) { + impl->_gamutTransf = cmsCreateProofingTransform(ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, ColorProfileImpl::getNULLProfile(), TYPE_GRAY_8, impl->_profHandle, INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING)); } - return _gamutTransf; + return impl->_gamutTransf; } bool ColorProfile::GamutCheck(SPColor color){ BYTE outofgamut = 0; - + guint32 val = color.toRGBA32(0); guchar check_color[4] = { SP_RGBA32_R_U(val), @@ -586,7 +635,7 @@ static std::vector knownProfiles; std::vector Inkscape::colorprofile_get_display_names() { - colorprofile_load_profiles(); + loadProfiles(); std::vector result; for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { @@ -600,7 +649,7 @@ std::vector Inkscape::colorprofile_get_display_names() std::vector Inkscape::colorprofile_get_softproof_names() { - colorprofile_load_profiles(); + loadProfiles(); std::vector result; for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { @@ -614,7 +663,7 @@ std::vector Inkscape::colorprofile_get_softproof_names() Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name) { - colorprofile_load_profiles(); + loadProfiles(); Glib::ustring result; for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { @@ -628,7 +677,7 @@ Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name) } #endif // ENABLE_LCMS -std::list ColorProfile::getBaseProfileDirs() { +std::vector ColorProfile::getBaseProfileDirs() { #if ENABLE_LCMS static bool warnSet = false; if (!warnSet) { @@ -636,7 +685,7 @@ std::list ColorProfile::getBaseProfileDirs() { warnSet = true; } #endif // ENABLE_LCMS - std::list sources; + std::vector sources; gchar* base = profile_path("XXX"); { @@ -662,10 +711,10 @@ std::list ColorProfile::getBaseProfileDirs() { // On OS X: { bool onOSX = false; - std::list possible; + std::vector possible; possible.push_back("/System/Library/ColorSync/Profiles"); possible.push_back("/Library/ColorSync/Profiles"); - for ( std::list::const_iterator it = possible.begin(); it != possible.end(); ++it ) { + for ( std::vector::const_iterator it = possible.begin(); it != possible.end(); ++it ) { if ( g_file_test(it->c_str(), G_FILE_TEST_EXISTS) && g_file_test(it->c_str(), G_FILE_TEST_IS_DIR) ) { sources.push_back(it->c_str()); onOSX = true; @@ -738,11 +787,15 @@ static bool isIccFile( gchar const *filepath ) return isIccFile; } -std::list ColorProfile::getProfileFiles() +std::vector ColorProfile::getProfileFiles() { - std::list files; + std::vector files; - std::list sources = ColorProfile::getBaseProfileDirs(); + std::list sources; + { + std::vector tmp = ColorProfile::getBaseProfileDirs(); + sources.insert(sources.begin(), tmp.begin(), tmp.end()); + } for ( std::list::const_iterator it = sources.begin(); it != sources.end(); ++it ) { if ( g_file_test( it->c_str(), G_FILE_TEST_EXISTS ) && g_file_test( it->c_str(), G_FILE_TEST_IS_DIR ) ) { GError *err = 0; @@ -775,7 +828,28 @@ std::list ColorProfile::getProfileFiles() } #if ENABLE_LCMS +#endif // ENABLE_LCMS + +std::vector > ColorProfile::getProfileFilesWithNames() +{ + std::vector > result; + +#if ENABLE_LCMS + std::vector files = getProfileFiles(); + for ( std::vector::const_iterator it = files.begin(); it != files.end(); ++it ) { + cmsHPROFILE hProfile = cmsOpenProfileFromFile(it->c_str(), "r"); + if ( hProfile ) { + Glib::ustring name = getNameFromProfile(hProfile); + result.push_back( std::make_pair(*it, name) ); + cmsCloseProfile(hProfile); + } + } +#endif // ENABLE_LCMS + + return result; +} +#if ENABLE_LCMS int errorHandlerCB(int ErrorCode, const char *ErrorText) { g_message("lcms: Error %d; %s", ErrorCode, ErrorText); @@ -783,9 +857,28 @@ int errorHandlerCB(int ErrorCode, const char *ErrorText) return 1; } -/* This function loads or refreshes data in knownProfiles. - * Call it at the start of every call that requires this data. */ -void Inkscape::colorprofile_load_profiles(bool force_refresh) +namespace +{ +Glib::ustring getNameFromProfile(cmsHPROFILE profile) +{ + gchar const *name = 0; + if ( profile ) { + name = cmsTakeProductDesc(profile); + if ( !name ) { + name = cmsTakeProductName(profile); + } + if ( name && !g_utf8_validate(name, -1, NULL) ) { + name = _("(invalid UTF-8 string)"); + } + } + return (name) ? name : _("None"); +} + +/** + * This function loads or refreshes data in knownProfiles. + * Call it at the start of every call that requires this data. + */ +void loadProfiles() { static bool error_handler_set = false; if (!error_handler_set) { @@ -794,32 +887,34 @@ void Inkscape::colorprofile_load_profiles(bool force_refresh) } static bool profiles_searched = false; - if (profiles_searched && !force_refresh) return; + if ( !profiles_searched ) { + knownProfiles.clear(); + std::vector files = ColorProfile::getProfileFiles(); - knownProfiles.clear(); - std::list files = ColorProfile::getProfileFiles(); - - for ( std::list::const_iterator it = files.begin(); it != files.end(); ++it ) { - cmsHPROFILE prof = cmsOpenProfileFromFile( it->c_str(), "r" ); - if ( prof ) { - ProfileInfo info( prof, Glib::filename_to_utf8( it->c_str() ) ); - cmsCloseProfile( prof ); - - bool sameName = false; - for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { - if ( it->getName() == info.getName() ) { - sameName = true; - break; + for ( std::vector::const_iterator it = files.begin(); it != files.end(); ++it ) { + cmsHPROFILE prof = cmsOpenProfileFromFile( it->c_str(), "r" ); + if ( prof ) { + ProfileInfo info( prof, Glib::filename_to_utf8( it->c_str() ) ); + cmsCloseProfile( prof ); + prof = 0; + + bool sameName = false; + for ( std::vector::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) { + if ( it->getName() == info.getName() ) { + sameName = true; + break; + } } - } - if ( !sameName ) { - knownProfiles.push_back(info); + if ( !sameName ) { + knownProfiles.push_back(info); + } } } + profiles_searched = true; } - profiles_searched = true; } +} // namespace static bool gamutWarn = false; static Gdk::Color lastGamutColor("#808080"); @@ -831,12 +926,13 @@ static int lastIntent = INTENT_PERCEPTUAL; static int lastProofIntent = INTENT_PERCEPTUAL; static cmsHTRANSFORM transf = 0; -cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle() +namespace { +cmsHPROFILE getSystemProfileHandle() { static cmsHPROFILE theOne = 0; static Glib::ustring lastURI; - colorprofile_load_profiles(); + loadProfiles(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring uri = prefs->getString("/options/displayprofile/uri"); @@ -884,12 +980,12 @@ cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle() } -cmsHPROFILE Inkscape::colorprofile_get_proof_profile_handle() +cmsHPROFILE getProofProfileHandle() { static cmsHPROFILE theOne = 0; static Glib::ustring lastURI; - colorprofile_load_profiles(); + loadProfiles(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool which = prefs->getBool( "/options/softproof/enable"); @@ -942,6 +1038,7 @@ cmsHPROFILE Inkscape::colorprofile_get_proof_profile_handle() return theOne; } +} // namespace static void free_transforms(); @@ -988,8 +1085,8 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_transform() } // Fetch these now, as they might clear the transform as a side effect. - cmsHPROFILE hprof = Inkscape::colorprofile_get_system_profile_handle(); - cmsHPROFILE proofProf = hprof ? Inkscape::colorprofile_get_proof_profile_handle() : 0; + cmsHPROFILE hprof = getSystemProfileHandle(); + cmsHPROFILE proofProf = hprof ? getProofProfileHandle() : 0; if ( !transf ) { if ( hprof && proofProf ) { @@ -1006,9 +1103,9 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_transform() dwFlags |= cmsFLAGS_PRESERVEBLACK; } #endif // defined(cmsFLAGS_PRESERVEBLACK) - transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags ); + transf = cmsCreateProofingTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags ); } else if ( hprof ) { - transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, hprof, TYPE_BGRA_8, intent, 0 ); + transf = cmsCreateTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, hprof, TYPE_BGRA_8, intent, 0 ); } } @@ -1149,7 +1246,7 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_per( Glib::ustring const& id ) } // Fetch these now, as they might clear the transform as a side effect. - cmsHPROFILE proofProf = item.hprof ? Inkscape::colorprofile_get_proof_profile_handle() : 0; + cmsHPROFILE proofProf = item.hprof ? getProofProfileHandle() : 0; if ( !item.transf ) { if ( item.hprof && proofProf ) { @@ -1166,9 +1263,9 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_per( Glib::ustring const& id ) dwFlags |= cmsFLAGS_PRESERVEBLACK; } #endif // defined(cmsFLAGS_PRESERVEBLACK) - item.transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags ); + item.transf = cmsCreateProofingTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, proofProf, intent, proofIntent, dwFlags ); } else if ( item.hprof ) { - item.transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, intent, 0 ); + item.transf = cmsCreateTransform( ColorProfileImpl::getSRGBProfile(), TYPE_BGRA_8, item.hprof, TYPE_BGRA_8, intent, 0 ); } } diff --git a/src/color-profile.h b/src/color-profile.h index e1dd298bd..a1b83bbef 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -23,6 +23,8 @@ enum { RENDERING_INTENT_ABSOLUTE_COLORIMETRIC = 5 }; +class ColorProfileImpl; + /// The SPColorProfile vtable. struct ColorProfileClass { SPObjectClass parent_class; @@ -30,17 +32,17 @@ struct ColorProfileClass { /** Color Profile. */ struct ColorProfile : public SPObject { + friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* ); + static GType getType(); static void classInit( ColorProfileClass *klass ); - static std::list getBaseProfileDirs(); - static std::list getProfileFiles(); + static std::vector getBaseProfileDirs(); + static std::vector getProfileFiles(); + static std::vector > getProfileFilesWithNames(); #if ENABLE_LCMS - static cmsHPROFILE getSRGBProfile(); - static cmsHPROFILE getNULLProfile(); - - icColorSpaceSignature getColorSpace() const {return _profileSpace;} - icProfileClassSignature getProfileClass() const {return _profileClass;} + icColorSpaceSignature getColorSpace() const; + icProfileClassSignature getProfileClass() const; cmsHTRANSFORM getTransfToSRGB8(); cmsHTRANSFORM getTransfFromSRGB8(); cmsHTRANSFORM getTransfGamutCheck(); @@ -53,9 +55,6 @@ struct ColorProfile : public SPObject { gchar* name; gchar* intentStr; guint rendering_intent; -#if ENABLE_LCMS - cmsHPROFILE profHandle; -#endif // ENABLE_LCMS private: static void init( ColorProfile *cprof ); @@ -64,19 +63,8 @@ private: static void build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ); static void set( SPObject *object, unsigned key, gchar const *value ); static Inkscape::XML::Node *write( SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags ); -#if ENABLE_LCMS - static DWORD _getInputFormat( icColorSpaceSignature space ); - void _clearProfile(); - static cmsHPROFILE _sRGBProf; - static cmsHPROFILE _NullProf; - - icProfileClassSignature _profileClass; - icColorSpaceSignature _profileSpace; - cmsHTRANSFORM _transf; - cmsHTRANSFORM _revTransf; - cmsHTRANSFORM _gamutTransf; -#endif // ENABLE_LCMS + ColorProfileImpl *impl; }; } // namespace Inkscape diff --git a/src/interface.cpp b/src/interface.cpp index c7946cf18..9aa5cad31 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -56,10 +56,6 @@ #include "message-context.h" #include "ui/uxmanager.h" -// Added for color drag-n-drop -#if ENABLE_LCMS -#include "lcms.h" -#endif // ENABLE_LCMS #include "display/sp-canvas.h" #include "color.h" #include "svg/svg-color.h" diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 569dd2311..5d32839cb 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -43,8 +43,6 @@ #include "xml/repr.h" #if ENABLE_LCMS -#include -//#include "color-profile-fns.h" #include "color-profile.h" #endif // ENABLE_LCMS @@ -309,53 +307,29 @@ DocumentProperties::build_snap() } #if ENABLE_LCMS -static void -lcms_profile_get_name (cmsHPROFILE profile, const gchar **name) -{ - if (profile) - { - *name = cmsTakeProductDesc (profile); - - if (! *name) - *name = cmsTakeProductName (profile); - - if (*name && ! g_utf8_validate (*name, -1, NULL)) - *name = _("(invalid UTF-8 string)"); - } - else - { - *name = _("None"); - } -} - -void -DocumentProperties::populate_available_profiles(){ +void DocumentProperties::populate_available_profiles(){ Glib::ListHandle children = _menu.get_children(); for ( Glib::ListHandle::iterator it2 = children.begin(); it2 != children.end(); ++it2 ) { _menu.remove(**it2); delete(*it2); } - std::list files = ColorProfile::getProfileFiles(); - for ( std::list::const_iterator it = files.begin(); it != files.end(); ++it ) { - cmsHPROFILE hProfile = cmsOpenProfileFromFile(it->c_str(), "r"); - if ( hProfile ){ - const gchar* name = 0; - lcms_profile_get_name(hProfile, &name); - Gtk::MenuItem* mi = manage(new Gtk::MenuItem()); - mi->set_data("filepath", g_strdup(it->c_str())); - mi->set_data("name", g_strdup(name)); - Gtk::HBox *hbox = manage(new Gtk::HBox()); - hbox->show(); - Gtk::Label* lbl = manage(new Gtk::Label(name)); - lbl->show(); - hbox->pack_start(*lbl, true, true, 0); - mi->add(*hbox); - mi->show_all(); - _menu.append(*mi); -// g_free((void*)name); - cmsCloseProfile(hProfile); - } + std::vector > pairs = ColorProfile::getProfileFilesWithNames(); + for ( std::vector >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) { + Glib::ustring file = it->first; + Glib::ustring name = it->second; + + Gtk::MenuItem* mi = manage(new Gtk::MenuItem()); + mi->set_data("filepath", g_strdup(file.c_str())); + mi->set_data("name", g_strdup(name.c_str())); + Gtk::HBox *hbox = manage(new Gtk::HBox()); + hbox->show(); + Gtk::Label* lbl = manage(new Gtk::Label(name)); + lbl->show(); + hbox->pack_start(*lbl, true, true, 0); + mi->add(*hbox); + mi->show_all(); + _menu.append(*mi); } _menu.show_all(); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 3c272e691..aa3c18aaa 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -906,8 +906,8 @@ void InkscapePreferences::initPageCMS() _page_cms.add_group_header( _("Display adjustment")); Glib::ustring tmpStr; - std::list sources = ColorProfile::getBaseProfileDirs(); - for ( std::list::const_iterator it = sources.begin(); it != sources.end(); ++it ) { + std::vector sources = ColorProfile::getBaseProfileDirs(); + for ( std::vector::const_iterator it = sources.begin(); it != sources.end(); ++it ) { gchar* part = g_strdup_printf( "\n%s", it->c_str() ); tmpStr += part; g_free(part); diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index 9238e3f68..a3915cd48 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -8,11 +8,9 @@ #include "sp-color-slider.h" #include "sp-color-selector.h" -#if ENABLE_LCMS -#include "color-profile.h" -#endif // ENABLE_LCMS - - +namespace Inkscape { +struct ColorProfile; +} struct SPColorICCSelector; struct SPColorICCSelectorClass; diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 377abf219..d041f85df 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -37,6 +37,7 @@ #include "../inkscape.h" #include "../document.h" #include "../profile-manager.h" +#include "color-profile.h" struct SPColorNotebookTracker { const gchar* name; @@ -529,7 +530,7 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) if (color.icc){ Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); if ( target_profile ) - gtk_widget_set_sensitive (_box_outofgamut, target_profile->GamutCheck(color)); + gtk_widget_set_sensitive(_box_outofgamut, target_profile->GamutCheck(color)); } /* update too-much-ink icon */ -- cgit v1.2.3 From aa7a997188b7f69017897a93bd153048df6b1dbc Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 6 Jul 2011 22:59:33 +0200 Subject: Fix mixed up colors when exporting images with bitmaps to PDF and other Cairo formats. Fixes LP #804311 Fixed bugs: - https://launchpad.net/bugs/804311 (bzr r10421) --- src/extension/internal/cairo-render-context.cpp | 65 +++---------------------- src/extension/internal/cairo-render-context.h | 2 +- src/extension/internal/cairo-renderer.cpp | 16 +++--- 3 files changed, 14 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 1c1dac028..22b68b0ca 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1419,7 +1419,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con return true; } -bool CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsigned int rs, +bool CairoRenderContext::renderImage(GdkPixbuf *pb, Geom::Affine const *image_transform, SPStyle const * /*style*/) { g_assert( _is_valid ); @@ -1428,63 +1428,18 @@ bool CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, return true; } - guchar* px_rgba = NULL; - guint64 size = 4L * (guint64)w * (guint64)h; + int w = gdk_pixbuf_get_width (pb); + int h = gdk_pixbuf_get_height (pb); - if(size < (guint64)G_MAXSIZE) { - px_rgba = (guchar*)g_try_malloc(4 * w * h); - if (!px_rgba) { - g_warning ("Could not allocate %lu bytes for pixel buffer!", (long unsigned) size); - return false; - } - } else { - g_warning ("the requested memory exceeds the system limit"); - return false; - } - - - float opacity; - if (_state->merge_opacity) - opacity = _state->opacity; - else - opacity = 1.0; - - // make a copy of the original pixbuf with premultiplied alpha - // if we pass the original pixbuf it will get messed up - /// @todo optimize this code, it costs a lot of time - for (unsigned i = 0; i < h; i++) { - guchar const *src = px + i * rs; - guint32 *dst = (guint32 *)(px_rgba + i * rs); - for (unsigned j = 0; j < w; j++) { - guchar r, g, b, alpha_dst; - - // calculate opacity-modified alpha - alpha_dst = src[3]; - if ((opacity != 1.0) && _vector_based_target) - alpha_dst = (guchar)ceil((float)alpha_dst * opacity); - - // premul alpha (needed because this will be undone by cairo-pdf) - r = src[0]*alpha_dst/255; - g = src[1]*alpha_dst/255; - b = src[2]*alpha_dst/255; - - *dst = (((alpha_dst) << 24) | (((r)) << 16) | (((g)) << 8) | (b)); - - dst++; // pointer to 4byte variables - src += 4; // pointer to 1byte variables - } - } + // TODO: reenable merge_opacity if useful + float opacity = _state->opacity; - cairo_surface_t *image_surface = cairo_image_surface_create_for_data(px_rgba, CAIRO_FORMAT_ARGB32, w, h, w * 4); + cairo_surface_t *image_surface = ink_cairo_surface_create_for_argb32_pixbuf(pb); if (cairo_surface_status(image_surface)) { TRACE(("Image surface creation failed:\n%s\n", cairo_status_to_string(cairo_surface_status(image_surface)))); return false; } - // setup automatic freeing of the image data when destroying the surface - static cairo_user_data_key_t key; - cairo_surface_set_user_data(image_surface, &key, px_rgba, (cairo_destroy_func_t)g_free); - cairo_save(_cr); // scaling by width & height is not needed because it will be done by Cairo @@ -1499,16 +1454,10 @@ bool CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, cairo_rectangle(_cr, 0, 0, w, h); cairo_clip(_cr); } - - if (_vector_based_target) - cairo_paint(_cr); - else - cairo_paint_with_alpha(_cr, opacity); + cairo_paint_with_alpha(_cr, opacity); cairo_restore(_cr); - cairo_surface_destroy(image_surface); - return true; } diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 68a3c6537..d4117ff7e 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -139,7 +139,7 @@ public: /* Rendering methods */ bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox); - bool renderImage(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, + bool renderImage(GdkPixbuf *pb, Geom::Affine const *image_transform, SPStyle const *style); bool renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix, std::vector const &glyphtext, SPStyle const *style); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index bbafd7e94..6118a7ae9 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -41,6 +41,7 @@ #include "display/nr-arena-group.h" #include "display/curve.h" #include "display/canvas-bpath.h" +#include "display/cairo-utils.h" #include "sp-item.h" #include "sp-item-group.h" #include "style.h" @@ -345,18 +346,15 @@ static void sp_flowtext_render(SPItem *item, CairoRenderContext *ctx) static void sp_image_render(SPItem *item, CairoRenderContext *ctx) { SPImage *image; - guchar *px; - int w, h, rs; + int w, h; image = SP_IMAGE (item); if (!image->pixbuf) return; if ((image->width.computed <= 0.0) || (image->height.computed <= 0.0)) return; - px = gdk_pixbuf_get_pixels (image->pixbuf); w = gdk_pixbuf_get_width (image->pixbuf); h = gdk_pixbuf_get_height (image->pixbuf); - rs = gdk_pixbuf_get_rowstride (image->pixbuf); double x = image->x.computed; double y = image->y.computed; @@ -376,7 +374,7 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) Geom::Scale s(width / (double)w, height / (double)h); Geom::Affine t(s * tp); - ctx->renderImage (px, w, h, rs, &t, item->style); + ctx->renderImage (image->pixbuf, &t, item->style); } static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) @@ -516,11 +514,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) if (pb) { TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL )); - unsigned char *px = gdk_pixbuf_get_pixels (pb); - unsigned int w = gdk_pixbuf_get_width(pb); - unsigned int h = gdk_pixbuf_get_height(pb); - unsigned int rs = gdk_pixbuf_get_rowstride(pb); - ctx->renderImage(px, w, h, rs, &t, item->style); + // TODO this is stupid - we just converted to pixbuf format when generating the bitmap! + convert_pixbuf_normal_to_argb32(pb); + ctx->renderImage(pb, &t, item->style); gdk_pixbuf_unref(pb); pb = 0; } -- cgit v1.2.3 From 83a4acd5c2c92c42d9ae1d60bccffb4f9f39886d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 6 Jul 2011 23:13:12 +0200 Subject: Fix outline mode for text objects (LP #802354). Fixed bugs: - https://launchpad.net/bugs/802354 (bzr r10422) --- src/display/nr-arena-glyphs.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index dbac07596..089d6de40 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -294,26 +294,26 @@ static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, } if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - + cairo_save(ct); guint32 rgba = item->arena->outlinecolor; ink_cairo_set_source_rgba32(ct, rgba); cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode - - NRRect temp(area->x0, area->y0, area->x1, area->y1); - Geom::OptRect area_2geom = temp.upgrade_2geom(); + cairo_new_path(ct); + ink_cairo_transform(ct, ggroup->ctm); for (child = group->children; child != NULL; child = child->next) { NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); Geom::PathVector const * pathv = g->font->PathVector(g->glyph); - Geom::Affine transform = g->g_transform * group->ctm; + Geom::Affine transform = g->g_transform; - cairo_new_path(ct); + cairo_save(ct); ink_cairo_transform(ct, transform); feed_pathvector_to_cairo (ct, *pathv); cairo_fill(ct); + cairo_restore(ct); } - + cairo_restore(ct); return item->state; } -- cgit v1.2.3 From dd472649acce56329d8d5a6f26b0319828f39a2c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 6 Jul 2011 23:47:14 +0200 Subject: Fix regression in swatch display (LP #804930). Fixed bugs: - https://launchpad.net/bugs/804930 (bzr r10423) --- src/ui/dialog/color-item.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 89245575c..3463aa496 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -517,11 +517,13 @@ void ColorItem::_regenPreview(EekPreview * preview) (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB() ); } else { - double w; - cairo_pattern_get_linear_points(_pattern, NULL, NULL, &w, NULL); - int width = ceil(w); + // These correspond to PREVIEW_PIXBUF_WIDTH and VBLOCK from swatches.cpp + // TODO: the pattern to draw should be in the widget that draws the preview, + // so the preview can be scalable + int w = 128; + int h = 16; - cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, 1); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); cairo_t *ct = cairo_create(s); cairo_set_source(ct, _pattern); cairo_paint(ct); @@ -530,7 +532,7 @@ void ColorItem::_regenPreview(EekPreview * preview) GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, TRUE, 8, - width, 1, cairo_image_surface_get_stride(s), + w, h, cairo_image_surface_get_stride(s), (GdkPixbufDestroyNotify) cairo_surface_destroy, NULL); convert_pixbuf_argb32_to_normal(pixbuf); eek_preview_set_pixbuf( preview, pixbuf ); -- cgit v1.2.3 From 262ed2816e1faa073e8ca16b7d474100c8a9cf4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Jul 2011 04:15:46 +0000 Subject: fix for building without LCMS (bzr r10425) --- src/color-profile.cpp | 5 ++++- src/color-profile.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 7c9e83e3c..c2267d827 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -103,8 +103,10 @@ static SPObjectClass *cprof_parent_class; class ColorProfileImpl { public: +#if ENABLE_LCMS static cmsHPROFILE _sRGBProf; static cmsHPROFILE _NullProf; +#endif // ENABLE_LCMS ColorProfileImpl(); @@ -125,8 +127,9 @@ public: #endif // ENABLE_LCMS }; -ColorProfileImpl::ColorProfileImpl() : +ColorProfileImpl::ColorProfileImpl() #if ENABLE_LCMS + : _profHandle(0), _profileClass(icSigInputClass), _profileSpace(icSigRgbData), diff --git a/src/color-profile.h b/src/color-profile.h index a1b83bbef..28096cd20 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -32,8 +32,9 @@ struct ColorProfileClass { /** Color Profile. */ struct ColorProfile : public SPObject { +#if ENABLE_LCMS friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* ); - +#endif // ENABLE_LCMS static GType getType(); static void classInit( ColorProfileClass *klass ); -- cgit v1.2.3 From 6844f54c33f5783d6ca3cf065748bec84203b171 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Fri, 8 Jul 2011 16:22:58 -0300 Subject: auto-maximize the inkscape extension error dialog so that it is easier to read the error log (bzr r10427) --- src/extension/implementation/script.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 2f3e2cd65..e7599d996 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -855,6 +855,7 @@ void Script::checkStderr (const Glib::ustring &data, vbox->pack_start(*scrollwindow, true, true, 5 /* fix these */); + warning.maximize(); warning.run(); return; -- cgit v1.2.3 From a3e406b2ceafb8fb6b44db0a7816a083d7b3c8ee Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 9 Jul 2011 02:52:06 +0200 Subject: Add SPCanvasArena caching layer. Currently breaks for clipped groups that contain filtered objects (Cairo clipping bug?) (bzr r10347.1.6) --- src/2geom/int-rect.h | 2 + src/display/canvas-arena.cpp | 154 ++++++++++++++++++++++++++++++++++++------ src/display/canvas-arena.h | 4 ++ src/display/nr-arena-item.cpp | 4 +- src/display/sp-canvas-item.h | 4 +- src/display/sp-canvas.cpp | 30 +++++++- src/libnr/nr-rect-l.cpp | 49 ++++++++++++++ src/libnr/nr-rect-l.h | 7 ++ src/libnr/nr-values.cpp | 3 +- 9 files changed, 232 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/2geom/int-rect.h b/src/2geom/int-rect.h index 27fb06dfe..a143b3ac5 100644 --- a/src/2geom/int-rect.h +++ b/src/2geom/int-rect.h @@ -32,6 +32,8 @@ #define LIB2GEOM_SEEN_INT_RECT_H #include <2geom/coord.h> +#include <2geom/int-point.h> +#include <2geom/int-interval.h> #include <2geom/generic-rect.h> namespace Geom { diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 6930e4d7c..dd4a4ed5c 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -31,7 +31,10 @@ static void sp_canvas_arena_destroy(GtkObject *object); static void sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf); +static void sp_canvas_arena_render_cache (SPCanvasItem *item, Geom::IntRect const &area); +static void sp_canvas_arena_dirty_cache (SPCanvasArena *arena, NRRectL *area); static double sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); +static void sp_canvas_arena_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event); static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event); @@ -93,6 +96,7 @@ sp_canvas_arena_class_init (SPCanvasArenaClass *klass) item_class->render = sp_canvas_arena_render; item_class->point = sp_canvas_arena_point; item_class->event = sp_canvas_arena_event; + item_class->visible_area_changed = sp_canvas_arena_visible_area_changed; } static void @@ -106,6 +110,9 @@ sp_canvas_arena_init (SPCanvasArena *arena) nr_arena_group_set_transparent (NR_ARENA_GROUP (arena->root), TRUE); arena->active = NULL; + arena->cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); + arena->cache_area = Geom::IntRect::from_xywh(0,0,1,1); + arena->dirty = cairo_region_create(); nr_active_object_add_listener ((NRActiveObject *) arena->arena, (NRObjectEventVector *) &carenaev, sizeof (carenaev), arena); } @@ -131,6 +138,11 @@ sp_canvas_arena_destroy (GtkObject *object) nr_object_unref ((NRObject *) arena->arena); arena->arena = NULL; } + if (arena->cache) { + cairo_surface_destroy(arena->cache); + arena->cache = NULL; + } + cairo_region_destroy(arena->dirty); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -187,33 +199,74 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) { - gint bw, bh; - SPCanvasArena *arena = SP_CANVAS_ARENA (item); //SPCanvas *canvas = item->canvas; - nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, - NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, - NR_ARENA_ITEM_STATE_NONE); + //nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, + // NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, + // NR_ARENA_ITEM_STATE_NONE); + + Geom::OptIntRect r = buf->rect; + if (!r || r->hasZeroArea()) return; + + cairo_rectangle_int_t crect; + crect.x = r->left(); + crect.y = r->top(); + crect.width = r->width(); + crect.height = r->height(); + if (cairo_region_contains_rectangle(arena->dirty, &crect) != CAIRO_REGION_OVERLAP_OUT) { + sp_canvas_arena_render_cache(item, *r); + cairo_region_subtract_rectangle(arena->dirty, &crect); + } - sp_canvas_prepare_buffer(buf); + cairo_save(buf->ct); + cairo_translate(buf->ct, -r->left(), -r->top()); + //cairo_rectangle(buf->ct, r->left(), r->top(), r->width(), r->height()); + //cairo_clip(buf->ct); + cairo_set_source_surface(buf->ct, arena->cache, arena->cache_area.left(), arena->cache_area.top()); + cairo_paint(buf->ct); + //nr_arena_item_invoke_render (buf->ct, arena->root, &area, NULL, 0); + cairo_restore(buf->ct); +} - bw = buf->rect.x1 - buf->rect.x0; - bh = buf->rect.y1 - buf->rect.y0; - if ((bw < 1) || (bh < 1)) return; +static void sp_canvas_arena_render_cache (SPCanvasItem *item, Geom::IntRect const &area) +{ + SPCanvasArena *arena = SP_CANVAS_ARENA (item); + + Geom::OptIntRect r = Geom::intersect(arena->cache_area, area); + if (!r || r->hasZeroArea()) return; // nothing to do + + cairo_t *ct = cairo_create(arena->cache); + cairo_translate(ct, -arena->cache_area.left(), -arena->cache_area.top()); + + // clear area to paint + cairo_rectangle(ct, area.left(), area.top(), area.width(), area.height()); + cairo_clip(ct); + cairo_save(ct); + cairo_set_source_rgba(ct, 0,0,0,0); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_restore(ct); + + NRRectL nr_area(r); - NRRectL area; + nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, + NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, + NR_ARENA_ITEM_STATE_NONE); + nr_arena_item_invoke_render (ct, arena->root, &nr_area, NULL, 0); - area.x0 = buf->rect.x0; - area.y0 = buf->rect.y0; - area.x1 = buf->rect.x1; - area.y1 = buf->rect.y1; + cairo_destroy(ct); +} - sp_canvas_prepare_buffer(buf); - cairo_save(buf->ct); - cairo_translate(buf->ct, -area.x0, -area.y0); - nr_arena_item_invoke_render (buf->ct, arena->root, &area, NULL, 0); - cairo_restore(buf->ct); +static void +sp_canvas_arena_dirty_cache (SPCanvasArena *arena, NRRectL *area) +{ + cairo_rectangle_int_t rect; + rect.x = area->x0; + rect.y = area->y0; + rect.width = area->x1 - area->x0; + rect.height = area->y1 - area->y0; + cairo_region_union_rectangle(arena->dirty, &rect); } static double @@ -237,6 +290,67 @@ sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ return 1e18; } +static void +sp_canvas_arena_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area) +{ + SPCanvasArena *arena = SP_CANVAS_ARENA(item); + + cairo_surface_t *new_cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + new_area.width(), new_area.height()); + cairo_t *ct = cairo_create(new_cache); + cairo_set_source_surface(ct, arena->cache, old_area.left() - new_area.left(), old_area.top() - new_area.top()); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + cairo_destroy(ct); + cairo_surface_destroy(arena->cache); + arena->cache = new_cache; + arena->cache_area = new_area; + + cairo_rectangle_int_t crect; + crect.x = new_area.left(); + crect.y = new_area.top(); + crect.width = new_area.width(); + crect.height = new_area.height(); + cairo_region_intersect_rectangle(arena->dirty, &crect); + + // invalidate newly exposed areas + /* + * +----------------------+ + * | top strip | + * +-------+------+-------+ + * | | | | + * | left | old | right | + * | strip | area | strip | + * | | | | + * +-------+------+-------+ + * | bottom strip | + * +----------------------+ + */ + + // top strip + if (new_area.top() < old_area.top()) { + NRRectL top_strip(new_area.left(), new_area.top(), new_area.right(), old_area.top()); + sp_canvas_arena_dirty_cache(arena, &top_strip); + } + // left strip + if (new_area.left() < old_area.left()) { + NRRectL left_strip(new_area.left(), std::max(new_area.top(), old_area.top()), + old_area.left(), std::min(new_area.bottom(), old_area.bottom())); + sp_canvas_arena_dirty_cache(arena, &left_strip); + } + // right strip + if (new_area.right() > old_area.right()) { + NRRectL right_strip(old_area.right(), std::max(new_area.top(), old_area.top()), + new_area.right(), std::min(new_area.bottom(), old_area.bottom())); + sp_canvas_arena_dirty_cache(arena, &right_strip); + } + // bottom strip + if (new_area.bottom() > old_area.bottom()) { + NRRectL bottom_strip(new_area.left(), old_area.bottom(), new_area.right(), new_area.bottom()); + sp_canvas_arena_dirty_cache(arena, &bottom_strip); + } +} + static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) { @@ -336,6 +450,8 @@ sp_canvas_arena_request_update (NRArena */*arena*/, NRArenaItem */*item*/, void static void sp_canvas_arena_request_render (NRArena */*arena*/, NRRectL *area, void *data) { + if (!area) return; + sp_canvas_arena_dirty_cache (SP_CANVAS_ARENA(data), area); sp_canvas_request_redraw (SP_CANVAS_ITEM (data)->canvas, area->x0, area->y0, area->x1, area->y1); } diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 4cfeccb5a..220976da0 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -45,6 +45,10 @@ struct _SPCanvasArena { /* fixme: */ NRArenaItem *picked; gdouble delta; + + Geom::IntRect cache_area; + cairo_surface_t *cache; + cairo_region_t *dirty; }; struct _SPCanvasArenaClass { diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 526882921..9c7af1077 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -21,6 +21,7 @@ #include "display/cairo-utils.h" #include "display/cairo-templates.h" +#include "display/canvas-arena.h" #include "nr-arena.h" #include "nr-arena-item.h" #include "gc-core.h" @@ -482,7 +483,8 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // apply filter if (item->filter && filter) { - item->filter->render(item, ct, area, this_ct, &carea); + NRRectL bgarea(item->arena->canvasarena->cache_area); + item->filter->render(item, ct, &bgarea, this_ct, &carea); } if (needs_intermediate_rendering) { diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 9dbec547e..4c731e56b 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -24,8 +24,7 @@ #include #include #include - -#include "2geom/rect.h" +#include <2geom/rect.h> G_BEGIN_DECLS @@ -65,6 +64,7 @@ struct _SPCanvasItemClass : public GtkObjectClass { double (* point) (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); int (* event) (SPCanvasItem *item, GdkEvent *event); + void (* visible_area_changed) (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); }; SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, const gchar *first_arg_name, ...); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 23c6a430e..29729ef6c 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -691,6 +691,7 @@ static void sp_canvas_group_destroy (GtkObject *object); static void sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf); +static void sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); static SPCanvasItemClass *group_parent_class; @@ -734,6 +735,7 @@ sp_canvas_group_class_init (SPCanvasGroupClass *klass) item_class->update = sp_canvas_group_update; item_class->render = sp_canvas_group_render; item_class->point = sp_canvas_group_point; + item_class->visible_area_changed = sp_canvas_group_visible_area_changed; } /** @@ -877,6 +879,20 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf) } } +static void +sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area) +{ + SPCanvasGroup *group = SP_CANVAS_GROUP (item); + + for (GList *list = group->items; list; list = list->next) { + SPCanvasItem *child = (SPCanvasItem *)list->data; + if (child->flags & SP_CANVAS_ITEM_VISIBLE) { + if (SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed) + SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed (child, old_area, new_area); + } + } +} + /** * Adds an item to a canvas group. */ @@ -1218,8 +1234,16 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { SPCanvas *canvas = SP_CANVAS (widget); + Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + widget->allocation.width, widget->allocation.height); + Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + allocation->width, allocation->height); + /* Schedule redraw of new region */ sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); + if (allocation->width > widget->allocation.width) { sp_canvas_request_redraw (canvas, canvas->x0 + widget->allocation.width, @@ -2152,12 +2176,17 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, int dx = ix - canvas->x0; // dx and dy specify the displacement (scroll) of the int dy = iy - canvas->y0; // canvas w.r.t its previous position + Geom::IntRect old_area = canvas->getViewboxIntegers(); + Geom::IntRect new_area = old_area + Geom::IntPoint(dx, dy); + canvas->dx0 = cx; // here the 'd' stands for double, not delta! canvas->dy0 = cy; canvas->x0 = ix; canvas->y0 = iy; sp_canvas_resize_tiles (canvas, canvas->x0, canvas->y0, canvas->x0+canvas->widget.allocation.width, canvas->y0+canvas->widget.allocation.height); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); if (!clear) { // scrolling without zoom; redraw only the newly exposed areas @@ -2170,7 +2199,6 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, } else { // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw } - } /** diff --git a/src/libnr/nr-rect-l.cpp b/src/libnr/nr-rect-l.cpp index 08910a1d6..1cb268266 100644 --- a/src/libnr/nr-rect-l.cpp +++ b/src/libnr/nr-rect-l.cpp @@ -1,3 +1,52 @@ +#include "libnr/nr-rect-l.h" + +NRRectL::NRRectL() +{ + x0 = G_MAXINT32; + y0 = G_MAXINT32; + x1 = G_MININT32; + y1 = G_MININT32; +} + +NRRectL::NRRectL(gint32 xmin, gint32 ymin, gint32 xmax, gint32 ymax) +{ + x0 = xmin; + y0 = ymin; + x1 = xmax; + y1 = ymax; +} + +NRRectL::NRRectL(Geom::OptIntRect const &r) +{ + if (r) { + x0 = r->left(); + y0 = r->top(); + x1 = r->right(); + y1 = r->bottom(); + } else { + x0 = G_MAXINT32; + y0 = G_MAXINT32; + x1 = G_MININT32; + y1 = G_MININT32; + } +} + +NRRectL::NRRectL(Geom::IntRect const &r) +{ + x0 = r.left(); + y0 = r.top(); + x1 = r.right(); + y1 = r.bottom(); +} + +Geom::OptIntRect NRRectL::upgrade_2geom() const +{ + Geom::OptIntRect ret; + if (x0 > x1 || y0 > y1) return ret; + ret = Geom::IntRect(x0, y0, x1, y1); + return ret; +} + /* Local Variables: mode:c++ diff --git a/src/libnr/nr-rect-l.h b/src/libnr/nr-rect-l.h index 6e82bb790..c4c5f5a6d 100644 --- a/src/libnr/nr-rect-l.h +++ b/src/libnr/nr-rect-l.h @@ -2,9 +2,16 @@ #define SEEN_NR_RECT_L_H #include +#include <2geom/int-rect.h> struct NRRectL { gint32 x0, y0, x1, y1; + NRRectL(); + NRRectL(gint32 xmin, gint32 ymin, gint32 xmax, gint32 ymax); + explicit NRRectL(Geom::IntRect const &r); + explicit NRRectL(Geom::OptIntRect const &r); + operator Geom::OptIntRect() const { Geom::OptIntRect r = upgrade_2geom(); return r; } + Geom::OptIntRect upgrade_2geom() const; }; #endif /* !SEEN_NR_RECT_L_H */ diff --git a/src/libnr/nr-values.cpp b/src/libnr/nr-values.cpp index 5238353d4..06f33b13f 100644 --- a/src/libnr/nr-values.cpp +++ b/src/libnr/nr-values.cpp @@ -9,8 +9,7 @@ The following predefined objects are for reference and comparison. */ NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE); -NRRectL NR_RECT_L_EMPTY = - {NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L}; +NRRectL NR_RECT_L_EMPTY(NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L); /** component_vectors[i] is like $e_i$ in common mathematical usage; or equivalently $I_i$ (where $I$ is the identity matrix). */ -- cgit v1.2.3 From 2994e0b96e7d5d6d198b3d8139e4134f9d454229 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 9 Jul 2011 02:18:40 -0700 Subject: Next step in refactoring color management. More to come. (bzr r10429) --- src/CMakeLists.txt | 2 ++ src/Makefile_insert | 3 +- src/cms-color-types.h | 58 +++++++++++++++++++++++++++++++++++ src/color-profile-cms-fns.h | 51 ++++++++++++++++++++++++++++++ src/color-profile-fns.h | 16 ++++------ src/color-profile.cpp | 42 ++++++++++++++++++++++--- src/color-profile.h | 23 +++++++++----- src/display/sp-canvas.cpp | 2 +- src/sp-image.cpp | 1 + src/sp-object-repr.cpp | 2 +- src/sp-object.cpp | 2 +- src/svg/svg-color.cpp | 10 ++++-- src/widgets/sp-color-icc-selector.cpp | 11 ++++--- src/widgets/sp-color-notebook.cpp | 9 ++++-- 14 files changed, 195 insertions(+), 37 deletions(-) create mode 100644 src/cms-color-types.h create mode 100644 src/color-profile-cms-fns.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 580d65b0c..11a307037 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -306,7 +306,9 @@ set(inkscape_SRC box3d-context.h box3d-side.h box3d.h + cms-color-types.h color-profile-fns.h + color-profile-cms-fns.h color-profile-test.h color-profile.h color-rgba.h diff --git a/src/Makefile_insert b/src/Makefile_insert index 7d48dba93..d4f96fc87 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -12,9 +12,10 @@ ink_common_sources += \ box3d.cpp box3d.h \ box3d-side.cpp box3d-side.h \ brokenimage.xpm \ + cms-color-types.h \ color.cpp color.h \ color-profile.cpp color-profile.h \ - color-profile-fns.h \ + color-profile-fns.h color-profile-cms-fns.h \ color-rgba.h \ common-context.cpp common-context.h \ composite-undo-stack-observer.cpp \ diff --git a/src/cms-color-types.h b/src/cms-color-types.h new file mode 100644 index 000000000..74fdac12c --- /dev/null +++ b/src/cms-color-types.h @@ -0,0 +1,58 @@ +#ifndef SEEN_CMS_COLOR_TYPES_H +#define SEEN_CMS_COLOR_TYPES_H + +/** \file + * A simple abstraction to provide opaque compatibility with either lcms or lcms2. + */ + +#include + + +typedef void * cmsHPROFILE; +typedef void * cmsHTRANSFORM; + +namespace Inkscape { + +/** + * Opaque holder of a 32-bit signature type. + */ +class FourCCSig { +public: + FourCCSig( FourCCSig const &other ) : value(other.value) {}; + +protected: + FourCCSig( guint32 value ) : value(value) {}; + + guint32 value; +}; + +class ColorSpaceSig : public FourCCSig { +public: + ColorSpaceSig( ColorSpaceSig const &other ) : FourCCSig(other) {}; + +protected: + ColorSpaceSig( guint32 value ) : FourCCSig(value) {}; +}; + +class ColorProfileClassSig : public FourCCSig { +public: + ColorProfileClassSig( ColorProfileClassSig const &other ) : FourCCSig(other) {}; + +protected: + ColorProfileClassSig( guint32 value ) : FourCCSig(value) {}; +}; + +} // namespace Inkscape + +#endif // SEEN_CMS_COLOR_TYPES_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/color-profile-cms-fns.h b/src/color-profile-cms-fns.h new file mode 100644 index 000000000..fe0eed392 --- /dev/null +++ b/src/color-profile-cms-fns.h @@ -0,0 +1,51 @@ +#ifndef SEEN_COLOR_PROFILE_CMS_FNS_H +#define SEEN_COLOR_PROFILE_CMS_FNS_H + +#if ENABLE_LCMS +#include +#endif // ENABLE_LCMS + +#include "cms-color-types.h" + +namespace Inkscape { + +#if ENABLE_LCMS + +// Note: these can later be adjusted to adapt for lcms2: + +class ColorSpaceSigWrapper : public ColorSpaceSig { +public : + ColorSpaceSigWrapper( icColorSpaceSignature sig ) : ColorSpaceSig( static_cast(sig) ) {} + ColorSpaceSigWrapper( ColorSpaceSig const &other ) : ColorSpaceSig( other ) {} + + operator icColorSpaceSignature() const { return static_cast(value); } +}; + +class ColorProfileClassSigWrapper : public ColorProfileClassSig { +public : + ColorProfileClassSigWrapper( icProfileClassSignature sig ) : ColorProfileClassSig( static_cast(sig) ) {} + ColorProfileClassSigWrapper( ColorProfileClassSig const &other ) : ColorProfileClassSig( other ) {} + + operator icProfileClassSignature() const { return static_cast(value); } +}; + +icColorSpaceSignature asICColorSpaceSig(ColorSpaceSig const & sig); +icProfileClassSignature asICColorProfileClassSig(ColorProfileClassSig const & sig); + +#endif // ENABLE_LCMS + +} // namespace Inkscape + + +#endif // !SEEN_COLOR_PROFILE_CMS_FNS_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/color-profile-fns.h b/src/color-profile-fns.h index 3d22417f6..0588ce89e 100644 --- a/src/color-profile-fns.h +++ b/src/color-profile-fns.h @@ -10,8 +10,8 @@ #if ENABLE_LCMS #include #include -#include #endif // ENABLE_LCMS +#include "cms-color-types.h" class SPDocument; @@ -23,8 +23,6 @@ class Node; class ColorProfile; -GType colorprofile_get_type(); - #if ENABLE_LCMS cmsHPROFILE colorprofile_get_handle( SPDocument* document, guint* intent, gchar const* name ); @@ -39,15 +37,13 @@ std::vector colorprofile_get_softproof_names(); Glib::ustring get_path_for_profile(Glib::ustring const& name); -#endif +void colorprofile_cmsDoTransform(cmsHTRANSFORM transform, void *inBuf, void *outBuf, unsigned int size); -} // namespace Inkscape +bool colorprofile_isPrintColorSpace(ColorProfile const *profile); -#define COLORPROFILE_TYPE (Inkscape::colorprofile_get_type()) -#define COLORPROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COLORPROFILE_TYPE, Inkscape::ColorProfile)) -#define COLORPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), COLORPROFILE_TYPE, Inkscape::ColorProfileClass)) -#define IS_COLORPROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), COLORPROFILE_TYPE)) -#define IS_COLORPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), COLORPROFILE_TYPE)) +#endif // ENABLE_LCMS + +} // namespace Inkscape #endif // !SEEN_COLOR_PROFILE_FNS_H diff --git a/src/color-profile.cpp b/src/color-profile.cpp index c2267d827..4bc37fdf8 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -32,6 +32,7 @@ #include "color.h" #include "color-profile.h" #include "color-profile-fns.h" +#include "color-profile-cms-fns.h" #include "attributes.h" #include "inkscape.h" #include "document.h" @@ -100,7 +101,6 @@ extern guint update_in_progress; static SPObjectClass *cprof_parent_class; - class ColorProfileImpl { public: #if ENABLE_LCMS @@ -127,6 +127,22 @@ public: #endif // ENABLE_LCMS }; + + +namespace Inkscape { + +icColorSpaceSignature asICColorSpaceSig(ColorSpaceSig const & sig) +{ + return ColorSpaceSigWrapper(sig); +} + +icProfileClassSignature asICColorProfileClassSig(ColorProfileClassSig const & sig) +{ + return ColorProfileClassSigWrapper(sig); +} + +} // namespace Inkscape + ColorProfileImpl::ColorProfileImpl() #if ENABLE_LCMS : @@ -554,12 +570,12 @@ cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* inte return prof; } -icColorSpaceSignature ColorProfile::getColorSpace() const { - return impl->_profileSpace; +Inkscape::ColorSpaceSig ColorProfile::getColorSpace() const { + return ColorSpaceSigWrapper(impl->_profileSpace); } -icProfileClassSignature ColorProfile::getProfileClass() const { - return impl->_profileClass; +Inkscape::ColorProfileClassSig ColorProfile::getProfileClass() const { + return ColorProfileClassSigWrapper(impl->_profileClass); } cmsHTRANSFORM ColorProfile::getTransfToSRGB8() @@ -678,6 +694,22 @@ Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name) return result; } + +void Inkscape::colorprofile_cmsDoTransform(cmsHTRANSFORM transform, void *inBuf, void *outBuf, unsigned int size) +{ + cmsDoTransform(transform, inBuf, outBuf, size); +} + +bool Inkscape::colorprofile_isPrintColorSpace(ColorProfile const *profile) +{ + bool isPrint = false; + if ( profile ) { + ColorSpaceSigWrapper colorspace = profile->getColorSpace(); + isPrint = (colorspace == icSigCmykData) || (colorspace == icSigCmyData); + } + return isPrint; +} + #endif // ENABLE_LCMS std::vector ColorProfile::getBaseProfileDirs() { diff --git a/src/color-profile.h b/src/color-profile.h index 28096cd20..1b06b6a78 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -5,12 +5,11 @@ * SPColorProfile: SVG implementation */ +#include #include #include #include -#if ENABLE_LCMS -#include -#endif // ENABLE_LCMS +#include "cms-color-types.h" namespace Inkscape { @@ -25,6 +24,7 @@ enum { class ColorProfileImpl; + /// The SPColorProfile vtable. struct ColorProfileClass { SPObjectClass parent_class; @@ -32,9 +32,8 @@ struct ColorProfileClass { /** Color Profile. */ struct ColorProfile : public SPObject { -#if ENABLE_LCMS friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* ); -#endif // ENABLE_LCMS + static GType getType(); static void classInit( ColorProfileClass *klass ); @@ -42,8 +41,10 @@ struct ColorProfile : public SPObject { static std::vector getProfileFiles(); static std::vector > getProfileFilesWithNames(); #if ENABLE_LCMS - icColorSpaceSignature getColorSpace() const; - icProfileClassSignature getProfileClass() const; + //icColorSpaceSignature getColorSpace() const; + ColorSpaceSig getColorSpace() const; + //icProfileClassSignature getProfileClass() const; + ColorProfileClassSig getProfileClass() const; cmsHTRANSFORM getTransfToSRGB8(); cmsHTRANSFORM getTransfFromSRGB8(); cmsHTRANSFORM getTransfGamutCheck(); @@ -68,8 +69,16 @@ private: ColorProfileImpl *impl; }; +GType colorprofile_get_type(); + } // namespace Inkscape +#define COLORPROFILE_TYPE (Inkscape::colorprofile_get_type()) +#define COLORPROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COLORPROFILE_TYPE, Inkscape::ColorProfile)) +#define COLORPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), COLORPROFILE_TYPE, Inkscape::ColorProfileClass)) +#define IS_COLORPROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), COLORPROFILE_TYPE)) +#define IS_COLORPROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), COLORPROFILE_TYPE)) + #endif // !SEEN_COLOR_PROFILE_H /* diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 3e8a4880c..ea39d3435 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1683,7 +1683,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int int stride = cairo_image_surface_get_stride(imgs); for (int i=0; icolorProfile.c_str()); gchar const** names = 0; gchar const** tips = 0; guint const* scales = 0; - getThings( prof->getColorSpace(), names, tips, scales ); + getThings( asICColorSpaceSig(prof->getColorSpace()), names, tips, scales ); - guint count = _cmsChannelsOf( prof->getColorSpace() ); - if (count>4) count=4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) + guint count = _cmsChannelsOf( asICColorSpaceSig(prof->getColorSpace()) ); + if (count > 4) { + count = 4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) + } for (guint i=0;icolors[i])*256.0) * (gdouble)scales[i]); g_message("input[%d]: %d",i, color_in[i]); diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 94f450e50..9e5291cc4 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -16,6 +16,7 @@ #if ENABLE_LCMS #include "color-profile-fns.h" +#include "color-profile-cms-fns.h" #include "color-profile.h" #ifdef DEBUG_LCMS @@ -497,12 +498,12 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) #ifdef DEBUG_LCMS g_message("got on out [%04x] [%04x] [%04x] [%04x]", post[0], post[1], post[2], post[3]); #endif // DEBUG_LCMS - guint count = _cmsChannelsOf( newProf->getColorSpace() ); + guint count = _cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); gchar const** names = 0; gchar const** tips = 0; guint const* scales = 0; - getThings( newProf->getColorSpace(), names, tips, scales ); + getThings( asICColorSpaceSig(newProf->getColorSpace()), names, tips, scales ); for ( guint i = 0; i < count; i++ ) { gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)scales[i]; @@ -680,12 +681,12 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) if ( profile ) { _prof = SP_ACTIVE_DOCUMENT->profileManager->find(profile->colorProfile.c_str()); - if ( _prof && _prof->getProfileClass() != icSigNamedColorClass ) { - _profChannelCount = _cmsChannelsOf( _prof->getColorSpace() ); + if ( _prof && (asICColorProfileClassSig(_prof->getProfileClass()) != icSigNamedColorClass) ) { + _profChannelCount = _cmsChannelsOf( asICColorSpaceSig(_prof->getColorSpace()) ); gchar const** names = 0; gchar const** tips = 0; - getThings( _prof->getColorSpace(), names, tips, _fooScales ); + getThings( asICColorSpaceSig(_prof->getColorSpace()), names, tips, _fooScales ); if ( profChanged ) { for ( guint i = 0; i < _profChannelCount; i++ ) { diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index d041f85df..546f7838b 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -1,5 +1,3 @@ -#define __SP_COLOR_NOTEBOOK_C__ - /* * A notebook with RGB, CMYK, CMS, HSL, and Wheel pages * @@ -38,6 +36,11 @@ #include "../document.h" #include "../profile-manager.h" #include "color-profile.h" +#include "color-profile-fns.h" +#if ENABLE_LCMS +//#include "lcms.h" +//#include "color-profile-cms-fns.h" +#endif // ENABLE_LCMS struct SPColorNotebookTracker { const gchar* name; @@ -537,7 +540,7 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) gtk_widget_set_sensitive (_box_toomuchink, false); if (color.icc){ Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); - if ( prof && ( (prof->getColorSpace() == icSigCmykData) || (prof->getColorSpace() == icSigCmyData) ) ) { + if ( prof && colorprofile_isPrintColorSpace(prof) ) { gtk_widget_show(GTK_WIDGET(_box_toomuchink)); double ink_sum = 0; for (unsigned int i=0; icolors.size(); i++){ -- cgit v1.2.3 From 351ad21da89e374b88b2214977f6e67ce4795ff0 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jul 2011 15:26:35 +0100 Subject: Merge upstream GDL 0.7.8 changes (bzr r10430) --- src/libgdl/Makefile_insert | 2 +- src/libgdl/gdl-combo-button.c | 383 ++++++++++ src/libgdl/gdl-combo-button.h | 65 ++ src/libgdl/gdl-data-frame.c | 297 ++++++++ src/libgdl/gdl-data-frame.h | 72 ++ src/libgdl/gdl-data-model-test.c | 240 +++++++ src/libgdl/gdl-data-model-test.h | 32 + src/libgdl/gdl-data-model.c | 160 +++++ src/libgdl/gdl-data-model.h | 105 +++ src/libgdl/gdl-data-row.c | 604 ++++++++++++++++ src/libgdl/gdl-data-row.h | 90 +++ src/libgdl/gdl-data-view.c | 526 ++++++++++++++ src/libgdl/gdl-data-view.h | 71 ++ src/libgdl/gdl-dock-item-grip.c | 4 +- src/libgdl/gdl-dock-item.c | 47 +- src/libgdl/gdl-dock-layout.c | 1411 +++++++++++++++++++++++++++++++++++++ src/libgdl/gdl-dock-layout.h | 98 +++ src/libgdl/gdl-dock-object.c | 37 +- src/libgdl/gdl-dock-placeholder.c | 4 +- src/libgdl/gdl-icons.c | 267 +++++++ src/libgdl/gdl-icons.h | 61 ++ src/libgdl/gdl-switcher.c | 12 +- src/libgdl/gdl.h | 39 + src/libgdl/libgdl.h | 37 - src/libgdl/libgdltypebuiltins.h | 2 +- src/libgdl/test-combo-button.c | 111 +++ src/libgdl/test-dataview.c | 43 ++ src/libgdl/test-dock.c | 311 ++++++++ src/ui/dialog/dock-behavior.h | 2 +- src/ui/widget/dock-item.h | 2 +- src/ui/widget/dock.h | 2 +- 31 files changed, 5068 insertions(+), 69 deletions(-) create mode 100644 src/libgdl/gdl-combo-button.c create mode 100644 src/libgdl/gdl-combo-button.h create mode 100644 src/libgdl/gdl-data-frame.c create mode 100644 src/libgdl/gdl-data-frame.h create mode 100644 src/libgdl/gdl-data-model-test.c create mode 100644 src/libgdl/gdl-data-model-test.h create mode 100644 src/libgdl/gdl-data-model.c create mode 100644 src/libgdl/gdl-data-model.h create mode 100644 src/libgdl/gdl-data-row.c create mode 100644 src/libgdl/gdl-data-row.h create mode 100644 src/libgdl/gdl-data-view.c create mode 100644 src/libgdl/gdl-data-view.h create mode 100644 src/libgdl/gdl-dock-layout.c create mode 100644 src/libgdl/gdl-dock-layout.h create mode 100644 src/libgdl/gdl-icons.c create mode 100644 src/libgdl/gdl-icons.h create mode 100644 src/libgdl/gdl.h delete mode 100644 src/libgdl/libgdl.h create mode 100644 src/libgdl/test-combo-button.c create mode 100644 src/libgdl/test-dataview.c create mode 100644 src/libgdl/test-dock.c (limited to 'src') diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert index 5869633ea..2276aa801 100644 --- a/src/libgdl/Makefile_insert +++ b/src/libgdl/Makefile_insert @@ -40,4 +40,4 @@ libgdl_libgdl_a_SOURCES = \ libgdl/libgdltypebuiltins.c \ libgdl/libgdlmarshal.h \ libgdl/libgdlmarshal.c \ - libgdl/libgdl.h + libgdl/gdl.h diff --git a/src/libgdl/gdl-combo-button.c b/src/libgdl/gdl-combo-button.c new file mode 100644 index 000000000..6414a8110 --- /dev/null +++ b/src/libgdl/gdl-combo-button.c @@ -0,0 +1,383 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * gdl-combo-button.c + * + * Copyright (C) 2003 Jeroen Zwartepoorte + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include "gdl-tools.h" +#include "gdl-combo-button.h" + +struct _GdlComboButtonPrivate { + GtkWidget *default_button; + GtkWidget *image; + GtkWidget *label; + GtkWidget *menu_button; + GtkWidget *menu; + gboolean menu_popped_up; +}; + +GDL_CLASS_BOILERPLATE (GdlComboButton, gdl_combo_button, GtkHBox, GTK_TYPE_HBOX); + +static void +default_button_clicked_cb (GtkButton *button, + gpointer user_data) +{ + GdlComboButton *combo; + GdlComboButtonPrivate *priv; + + combo = GDL_COMBO_BUTTON (user_data); + priv = combo->priv; + + if (!priv->menu_popped_up) + g_signal_emit_by_name (G_OBJECT (combo), + "activate-default", NULL); +} + +static gboolean +default_button_press_event_cb (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + + if (event->type == GDK_BUTTON_PRESS && event->button == 1) { + GTK_BUTTON (priv->menu_button)->button_down = TRUE; + gtk_button_pressed (GTK_BUTTON (priv->menu_button)); + } + + return FALSE; +} + +static gboolean +default_button_release_event_cb (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + + if (event->button == 1) { + gtk_button_released (GTK_BUTTON (priv->menu_button)); + } + + return FALSE; +} + +static gboolean +button_enter_notify_cb (GtkWidget *widget, + GdkEventCrossing *event, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + + if (event->detail != GDK_NOTIFY_INFERIOR) { + GTK_BUTTON (priv->default_button)->in_button = TRUE; + GTK_BUTTON (priv->menu_button)->in_button = TRUE; + gtk_button_enter (GTK_BUTTON (priv->default_button)); + gtk_button_enter (GTK_BUTTON (priv->menu_button)); + } + + return TRUE; +} + +static gboolean +button_leave_notify_cb (GtkWidget *widget, + GdkEventCrossing *event, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + + if (priv->menu_popped_up) + return TRUE; + + if (event->detail != GDK_NOTIFY_INFERIOR) { + GTK_BUTTON (priv->default_button)->in_button = FALSE; + GTK_BUTTON (priv->menu_button)->in_button = FALSE; + gtk_button_leave (GTK_BUTTON (priv->default_button)); + gtk_button_leave (GTK_BUTTON (priv->menu_button)); + } + + return TRUE; +} + +static void +menu_position_func (GtkMenu *menu, + gint *x_return, + gint *y_return, + gboolean *push_in, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + GtkAllocation *allocation; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + allocation = &(priv->default_button->allocation); + + gdk_window_get_origin (priv->default_button->window, x_return, y_return); + + *x_return += allocation->x; + *y_return += allocation->height; +} + +static gboolean +menu_button_press_event_cb (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + + if (event->type == GDK_BUTTON_PRESS && + (event->button == 1 || event->button == 3)) { + GTK_BUTTON (priv->menu_button)->button_down = TRUE; + + gtk_button_pressed (GTK_BUTTON (priv->menu_button)); + + priv->menu_popped_up = TRUE; + gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, + menu_position_func, combo_button, + event->button, event->time); + } + + return TRUE; +} + +static void +menu_deactivate_cb (GtkMenuShell *menu_shell, + gpointer user_data) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (user_data); + priv = combo_button->priv; + + priv->menu_popped_up = FALSE; + + GTK_BUTTON (priv->menu_button)->button_down = FALSE; + GTK_BUTTON (priv->menu_button)->in_button = FALSE; + GTK_BUTTON (priv->default_button)->in_button = FALSE; + gtk_button_leave (GTK_BUTTON (priv->menu_button)); + gtk_button_leave (GTK_BUTTON (priv->default_button)); + gtk_button_clicked (GTK_BUTTON (priv->menu_button)); +} + +static void +menu_detacher (GtkWidget *widget, + GtkMenu *menu) +{ + GdlComboButton *combo_button; + + combo_button = GDL_COMBO_BUTTON (widget); + + g_signal_handlers_disconnect_by_func (G_OBJECT (menu), + menu_deactivate_cb, + combo_button); + combo_button->priv->menu = NULL; +} + +static void +gdl_combo_button_destroy (GtkObject *object) +{ + GdlComboButton *combo_button; + GdlComboButtonPrivate *priv; + + combo_button = GDL_COMBO_BUTTON (object); + priv = combo_button->priv; + + if (priv) { + g_free (priv); + combo_button->priv = NULL; + } + + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void +gdl_combo_button_class_init (GdlComboButtonClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + parent_class = g_type_class_peek_parent (klass); + object_class = GTK_OBJECT_CLASS (klass); + widget_class = GTK_WIDGET_CLASS (klass); + + object_class->destroy = gdl_combo_button_destroy; + + g_signal_new ("activate-default", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GdlComboButtonClass, activate_default), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); +} + +static void +gdl_combo_button_instance_init (GdlComboButton *combo_button) +{ + GdlComboButtonPrivate *priv; + GtkWidget *hbox, *align, *arrow; + + priv = g_new (GdlComboButtonPrivate, 1); + combo_button->priv = priv; + + priv->menu = NULL; + priv->menu_popped_up = FALSE; + + priv->default_button = gtk_button_new (); + gtk_button_set_relief (GTK_BUTTON (priv->default_button), GTK_RELIEF_NONE); + + /* Following code copied from gtk_button_construct_child. */ + priv->label = gtk_label_new (""); + gtk_label_set_use_underline (GTK_LABEL (priv->label), TRUE); + gtk_label_set_mnemonic_widget (GTK_LABEL (priv->label), + priv->default_button); + + priv->image = gtk_image_new (); + hbox = gtk_hbox_new (FALSE, 2); + + align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); + + gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (hbox), priv->label, FALSE, FALSE, 0); + + gtk_container_add (GTK_CONTAINER (priv->default_button), align); + gtk_container_add (GTK_CONTAINER (align), hbox); + /* End copied block. */ + + gtk_box_pack_start (GTK_BOX (combo_button), priv->default_button, + FALSE, FALSE, 0); + gtk_widget_show_all (priv->default_button); + + priv->menu_button = gtk_button_new (); + gtk_button_set_relief (GTK_BUTTON (priv->menu_button), GTK_RELIEF_NONE); + arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); + gtk_container_add (GTK_CONTAINER (priv->menu_button), arrow); + gtk_box_pack_start (GTK_BOX (combo_button), priv->menu_button, FALSE, + FALSE, 0); + gtk_widget_show_all (priv->menu_button); + + /* Default button. */ + g_signal_connect (G_OBJECT (priv->default_button), "clicked", + G_CALLBACK (default_button_clicked_cb), combo_button); + g_signal_connect (G_OBJECT (priv->default_button), "button_press_event", + G_CALLBACK (default_button_press_event_cb), combo_button); + g_signal_connect (G_OBJECT (priv->default_button), "button_release_event", + G_CALLBACK (default_button_release_event_cb), combo_button); + g_signal_connect (G_OBJECT (priv->default_button), "enter_notify_event", + G_CALLBACK (button_enter_notify_cb), combo_button); + g_signal_connect (G_OBJECT (priv->default_button), "leave_notify_event", + G_CALLBACK (button_leave_notify_cb), combo_button); + + /* Menu button. */ + g_signal_connect (G_OBJECT (priv->menu_button), "button_press_event", + G_CALLBACK (menu_button_press_event_cb), combo_button); + g_signal_connect (G_OBJECT (priv->menu_button), "enter_notify_event", + G_CALLBACK (button_enter_notify_cb), combo_button); + g_signal_connect (G_OBJECT (priv->menu_button), "leave_notify_event", + G_CALLBACK (button_leave_notify_cb), combo_button); +} + +GtkWidget * +gdl_combo_button_new (void) +{ + GtkWidget *combo_button; + + combo_button = GTK_WIDGET (g_object_new (GDL_TYPE_COMBO_BUTTON, NULL)); + + return combo_button; +} + +void +gdl_combo_button_set_icon (GdlComboButton *combo_button, + GdkPixbuf *pixbuf) +{ + GdlComboButtonPrivate *priv; + + g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button)); + g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); + + priv = combo_button->priv; + + gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf); +} + +void +gdl_combo_button_set_label (GdlComboButton *combo_button, + const gchar *label) +{ + GdlComboButtonPrivate *priv; + + g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button)); + g_return_if_fail (label != NULL); + + priv = combo_button->priv; + + gtk_label_set_text (GTK_LABEL (priv->label), label); +} + +void +gdl_combo_button_set_menu (GdlComboButton *combo_button, + GtkMenu *menu) +{ + GdlComboButtonPrivate *priv; + + g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button)); + g_return_if_fail (GTK_IS_MENU (menu)); + + priv = combo_button->priv; + + if (priv->menu != NULL) + gtk_menu_detach (GTK_MENU (priv->menu)); + + priv->menu = GTK_WIDGET (menu); + if (menu == NULL) + return; + + gtk_menu_attach_to_widget (menu, GTK_WIDGET (combo_button), menu_detacher); + + g_signal_connect (G_OBJECT (menu), "deactivate", + G_CALLBACK (menu_deactivate_cb), combo_button); +} diff --git a/src/libgdl/gdl-combo-button.h b/src/libgdl/gdl-combo-button.h new file mode 100644 index 000000000..6e80af0b6 --- /dev/null +++ b/src/libgdl/gdl-combo-button.h @@ -0,0 +1,65 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * gdl-combo-button.h + * + * Copyright (C) 2003 Jeroen Zwartepoorte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _GDL_COMBO_BUTTON_H_ +#define _GDL_COMBO_BUTTON_H_ + +#include +#include +#include + +G_BEGIN_DECLS + +#define GDL_TYPE_COMBO_BUTTON (gdl_combo_button_get_type ()) +#define GDL_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_COMBO_BUTTON, GdlComboButton)) +#define GDL_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_COMBO_BUTTON, GdlComboButtonClass)) +#define GDL_IS_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_COMBO_BUTTON)) +#define GDL_IS_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_COMBO_BUTTON)) + +typedef struct _GdlComboButton GdlComboButton; +typedef struct _GdlComboButtonPrivate GdlComboButtonPrivate; +typedef struct _GdlComboButtonClass GdlComboButtonClass; + +struct _GdlComboButton { + GtkHBox parent; + + GdlComboButtonPrivate *priv; +}; + +struct _GdlComboButtonClass { + GtkHBoxClass parent_class; + + /* Signals. */ + void (* activate_default) (GdlComboButton *combo_button); +}; + +GType gdl_combo_button_get_type (void); +GtkWidget *gdl_combo_button_new (void); + +void gdl_combo_button_set_icon (GdlComboButton *combo_button, + GdkPixbuf *pixbuf); +void gdl_combo_button_set_label (GdlComboButton *combo_button, + const gchar *label); +void gdl_combo_button_set_menu (GdlComboButton *combo_button, + GtkMenu *menu); + +G_END_DECLS + +#endif /* _GDL_COMBO_BUTTON_H_ */ diff --git a/src/libgdl/gdl-data-frame.c b/src/libgdl/gdl-data-frame.c new file mode 100644 index 000000000..d6fb19533 --- /dev/null +++ b/src/libgdl/gdl-data-frame.c @@ -0,0 +1,297 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-i18n.h" +#include "gdl-tools.h" +#include + +#include "gdl-data-view.h" +#include "gdl-data-frame.h" +#include "gdl-data-model.h" +#include "gdl-data-row.h" + +struct _GdlDataFramePrivate { + GdkRectangle shadow_r; + GdkRectangle frame_r; + GdkRectangle titlebar_r; + GdkRectangle title_r; + GdkRectangle close_r; + GdkRectangle row_r; + + int shadow_offset; + int titlebar_height; + char *title; + + GdlDataRow *row; + + PangoLayout *layout; + + gboolean selected; +}; + +static void gdl_data_frame_class_init (GdlDataFrameClass *klass); +static void gdl_data_frame_instance_init (GdlDataFrame *obj); +static void gdl_data_frame_finalize (GObject *object); + +GDL_CLASS_BOILERPLATE (GdlDataFrame, gdl_data_frame, GObject, G_TYPE_OBJECT); + +#define PAD 2 +#define BORDER 1 + +#define CENTERY(r1, r2) { r1.y = ((r2.y + (r2.height / 2)) - (r1.height / 2)); } + +void +gdl_data_frame_layout (GdlDataFrame *frame) +{ + GdkPixbuf *close_pixbuf; + /* Sizes */ + if (frame->priv->row) { + gdl_data_row_get_size (frame->priv->row, + NULL, NULL, + &frame->priv->row_r.width, + &frame->priv->row_r.height); + } else { + frame->priv->row_r.height = frame->priv->row_r.width = 0; + } + + if (frame->priv->layout) { + pango_layout_get_pixel_size (frame->priv->layout, + &frame->priv->title_r.width, + &frame->priv->title_r.height); + } else { + frame->priv->title_r.width = frame->priv->title_r.height = 0; + } + + close_pixbuf = gdl_data_view_get_close_pixbuf (frame->view); + if (close_pixbuf) { + frame->priv->close_r.width = + gdk_pixbuf_get_width (close_pixbuf); + frame->priv->close_r.height = + gdk_pixbuf_get_width (close_pixbuf); + } else { + frame->priv->close_r.width = frame->priv->close_r.height = 0; + } + + frame->priv->titlebar_r.height = MAX (frame->priv->titlebar_height, + frame->priv->title_r.height); + frame->priv->titlebar_r.height = MAX (frame->priv->titlebar_r.height, + frame->priv->close_r.height); + + frame->priv->frame_r.width = 2 * BORDER + 3 * PAD + frame->priv->title_r.width + frame->priv->close_r.width; + frame->priv->frame_r.width = MAX (frame->priv->frame_r.width, + frame->priv->row_r.width + 2 * BORDER + 2 * PAD); + frame->priv->frame_r.height = frame->priv->row_r.height + frame->priv->titlebar_r.height + 2 * PAD + 2 * BORDER; + frame->priv->titlebar_r.width = frame->priv->frame_r.width - BORDER; + frame->priv->shadow_r.width = frame->priv->frame_r.width; + frame->priv->shadow_r.height = frame->priv->frame_r.height; + + /* Locations */ + frame->priv->frame_r.x = frame->area.x; + frame->priv->frame_r.y = frame->area.y; + + frame->priv->shadow_r.x = frame->priv->frame_r.x + frame->priv->shadow_offset; + frame->priv->shadow_r.y = frame->priv->frame_r.y + frame->priv->shadow_offset; + frame->priv->titlebar_r.x = frame->priv->frame_r.x + BORDER; + frame->priv->titlebar_r.y = frame->priv->frame_r.y + BORDER; + frame->priv->title_r.x = frame->priv->frame_r.x + BORDER + PAD; + CENTERY (frame->priv->title_r, frame->priv->titlebar_r); + frame->priv->close_r.x = (frame->priv->frame_r.x + frame->priv->frame_r.width) - (frame->priv->close_r.width + BORDER + PAD); + CENTERY (frame->priv->close_r, frame->priv->titlebar_r); + + if (frame->priv->row) { + frame->priv->row_r.x = frame->priv->frame_r.x + BORDER + PAD; + frame->priv->row_r.y = frame->priv->titlebar_r.y + frame->priv->titlebar_r.height + PAD; + gdl_data_row_layout (frame->priv->row, &frame->priv->row_r); + } else { + frame->priv->row_r.x = frame->priv->row_r.y = 0; + } + + frame->area.width = frame->priv->frame_r.width + frame->priv->shadow_offset; + frame->area.height = frame->priv->frame_r.height + frame->priv->shadow_offset; +} + +#if 0 /* not used */ +static void +change_layout (GdlDataFrame *frame) +{ + char *text = frame->priv->title ? frame->priv->title : "?"; + pango_layout_set_text (frame->priv->layout, text, strlen (text)); +} +#endif + +#define EXPLODE(r) (r).x, (r).y, (r).width, (r).height + +void +gdl_data_frame_draw (GdlDataFrame *frame, GdkDrawable *drawable, + GdkRectangle *expose_area) +{ + GdkRectangle inter; + guint8 state = + frame->priv->selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL; + + gdk_draw_rectangle (drawable, + GTK_WIDGET (frame->view)->style->dark_gc[state], + TRUE, + EXPLODE (frame->priv->shadow_r)); + gdk_draw_rectangle (drawable, + GTK_WIDGET (frame->view)->style->base_gc[GTK_STATE_NORMAL], + TRUE, + EXPLODE (frame->priv->frame_r)); + gdk_draw_rectangle (drawable, + GTK_WIDGET (frame->view)->style->black_gc, + FALSE, + EXPLODE (frame->priv->frame_r)); + gdk_draw_rectangle (drawable, + GTK_WIDGET (frame->view)->style->bg_gc[state], + TRUE, + EXPLODE (frame->priv->titlebar_r)); + gdk_draw_layout (drawable, + GTK_WIDGET (frame->view)->style->fg_gc[state], + frame->priv->title_r.x, frame->priv->title_r.y, + frame->priv->layout); + + if (gdk_rectangle_intersect (expose_area, &frame->priv->close_r, &inter)) { + GdkPixbuf *pixbuf = gdl_data_view_get_close_pixbuf (frame->view); + gdk_draw_pixbuf (drawable, NULL, pixbuf, + 0, 0, + inter.x - frame->priv->close_r.x, + inter.y - frame->priv->close_r.y, + gdk_pixbuf_get_width (pixbuf), + gdk_pixbuf_get_height (pixbuf), + GDK_RGB_DITHER_NORMAL, 0, 0); + } + + if (frame->priv->row) { + if (gdk_rectangle_intersect (expose_area, &frame->priv->row_r, + &inter)) { + gdl_data_row_render (frame->priv->row, drawable, + &inter, + frame->priv->selected ? GTK_CELL_RENDERER_SELECTED : 0); + } + } +} + +void +gdl_data_frame_class_init (GdlDataFrameClass *klass) +{ + GObjectClass *gobject_class = (GObjectClass *)klass; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class->finalize = gdl_data_frame_finalize; +} + +void +gdl_data_frame_instance_init (GdlDataFrame *frame) +{ + frame->priv = g_new0 (GdlDataFramePrivate, 1); + frame->area.x = frame->area.y = 0; + frame->priv->shadow_offset = 3; + frame->priv->titlebar_height = 20; + + frame->area.height = frame->area.width = 100; +} + +void +gdl_data_frame_finalize (GObject *object) +{ + GdlDataFrame *frame = GDL_DATA_FRAME (object); + + if (frame->priv) { + g_free (frame->priv->title); + g_object_unref (frame->priv->layout); + g_object_unref (frame->priv->row); + + g_free (frame->priv); + frame->priv = NULL; + } + GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); +} + +void +gdl_data_frame_set_selected (GdlDataFrame *frame, + gboolean val) +{ + frame->priv->selected = val; + + gdk_window_invalidate_rect (GTK_LAYOUT (frame->view)->bin_window, + &frame->priv->frame_r, + TRUE); +} + +gboolean +gdl_data_frame_button_press (GdlDataFrame *frame, + GdkEventButton *event) +{ + return FALSE; +} + +void +gdl_data_frame_set_position (GdlDataFrame *frame, + int x, + int y) +{ + frame->area.x = x; + frame->area.y = y; + + gdl_data_frame_layout (frame); +} + +static void +setup_layout (GdlDataFrame *frame) +{ + PangoFontDescription *font_desc = + pango_font_description_copy (GTK_WIDGET (frame->view)->style->font_desc); + + pango_font_description_set_weight (font_desc, + PANGO_WEIGHT_BOLD); + + frame->priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (frame->view), + frame->priv->title ? frame->priv->title : "?"); + pango_layout_set_font_description (frame->priv->layout, + font_desc); + pango_font_description_free (font_desc); +} + + +GdlDataFrame * +gdl_data_frame_new (GdlDataView *view, + GdlDataRow *row) +{ + GdlDataFrame *frame; + frame = GDL_DATA_FRAME (g_object_new (GDL_TYPE_DATA_FRAME, NULL)); + + frame->view = view; + + frame->priv->row = row; + frame->priv->title = g_strdup (gdl_data_row_get_title (row)); + + setup_layout (frame); + + gdl_data_frame_layout (frame); + + return frame; +} diff --git a/src/libgdl/gdl-data-frame.h b/src/libgdl/gdl-data-frame.h new file mode 100644 index 000000000..740c38293 --- /dev/null +++ b/src/libgdl/gdl-data-frame.h @@ -0,0 +1,72 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GDL_DATA_FRAME_H +#define GDL_DATA_FRAME_H + +#include +#include + +G_BEGIN_DECLS + +#define GDL_TYPE_DATA_FRAME (gdl_data_frame_get_type ()) +#define GDL_DATA_FRAME(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrame)) +#define GDL_DATA_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_DATA_VIEW_FRAM, GdlDataFrame)) +#define GDL_IS_DATA_FRAME(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DATA_FRAME)) +#define GDL_IS_DATA_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_FRAME)) +#define GDL_DATA_FRAME_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrameClass)) + +typedef struct _GdlDataFrame GdlDataFrame; +typedef struct _GdlDataFramePrivate GdlDataFramePrivate; +typedef struct _GdlDataFrameClass GdlDataFrameClass; + +struct _GdlDataFrame { + GObject parent; + + GdlDataView *view; + GdkRectangle area; + + GdlDataFramePrivate *priv; +}; + +struct _GdlDataFrameClass { + GObjectClass parent_class; +}; + +GType gdl_data_frame_get_type (void); +GdlDataFrame *gdl_data_frame_new (GdlDataView *view, + GdlDataRow *row); +void gdl_data_frame_layout (GdlDataFrame *frame); +void gdl_data_frame_draw (GdlDataFrame *item, + GdkDrawable *drawable, + GdkRectangle *expose_area); +void gdl_data_frame_set_selected (GdlDataFrame *frame, + gboolean val); +gboolean gdl_data_frame_button_press (GdlDataFrame *frame, + GdkEventButton *event); +void gdl_data_frame_set_position (GdlDataFrame *frame, + int x, + int y); + +G_END_DECLS + +#endif diff --git a/src/libgdl/gdl-data-model-test.c b/src/libgdl/gdl-data-model-test.c new file mode 100644 index 000000000..ec6ed4d50 --- /dev/null +++ b/src/libgdl/gdl-data-model-test.c @@ -0,0 +1,240 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-i18n.h" + +#include "gdl-data-model-test.h" +#include "gdl-data-model.h" + +#include +#include +#include + +GObjectClass *parent_class; + +typedef struct _DataItem { + char *name; + char *value; + char *path; + struct _DataItem *children; +} DataItem; + +DataItem data1[] = { + { "foo1", "foo1", "0:0", NULL}, + { "bar1", "bar1", "0:1", NULL }, + { "baz1", "baz1", "0:2", NULL }, + { NULL, NULL, NULL, NULL } + +}; +DataItem data2[] = { + { "foo2", "foo2", "1:0", NULL }, + { "bar2", "bar2", "1:1", NULL }, + { "baz2", "baz2", "1:2", NULL }, + { NULL, NULL, NULL, NULL } + +}; + +DataItem data5[] = { + { "1", "1", "2:2:1:0", NULL }, + { "2", "2", "2:2:1:1", NULL }, + { "3", "3", "2:2:1:2", NULL }, + { "4", "4", "2:2:1:3", NULL }, + { "5", "5", "2:2:1:4", NULL }, + { "6", "6", "2:2:1:5", NULL }, + { NULL, NULL, NULL, NULL } + +}; +DataItem data4[] = { + { "foo4", "foo4", "2:2:0", NULL }, + { "bar4", "[...]", "2:2:1", data5 }, + { "baz4", "baz4", "2:2:2", NULL }, + { NULL, NULL, NULL, NULL } + +}; +DataItem data3[] = { + { "foo foo", "foo3", "2:0", NULL }, + { "bar3", "1", "2:1", NULL }, + { "baz3", "{...}", "2:2", data4 }, + { NULL, NULL, NULL, NULL } + +}; + +DataItem root[] = { + { "test-data", "value1", "0", NULL } , + { "test-data2", "value2", "1", NULL } , + { "test-data3", "{...}", "2", data3 } , + { NULL, NULL, NULL } +}; + +static gboolean +get_iter (GdlDataModel *dm, GdlDataIter *iter, GtkTreePath *path) +{ + int *i = gtk_tree_path_get_indices (path); + int n = gtk_tree_path_get_depth (path); + DataItem *item; + + g_assert (i); + item = &root[*i++]; + + while (--n) { + item = &item->children[*i++]; + } + + iter->data1 = item; + + return TRUE; +} + +static GtkTreePath * +get_path (GdlDataModel *dm, GdlDataIter *iter) +{ + DataItem *item = iter->data1; + return gtk_tree_path_new_from_string (item->path); +} + +static void +get_name (GdlDataModel *dm, GdlDataIter *iter, char **name) +{ + DataItem *item = iter->data1; + *name = item->name; +} + +static void +get_value (GdlDataModel *dm, GdlDataIter *iter, GValue *value) +{ + DataItem *item = iter->data1; + if (strcmp (item->name, "bar3")) { + g_value_init (value, G_TYPE_STRING); + g_value_set_string (value, item->value); + } else { + g_value_init (value, G_TYPE_BOOLEAN); + g_value_set_boolean (value, !strcmp (item->value, "1")); + } +} + +static void +get_renderer (GdlDataModel *dm, GdlDataIter *iter, + GtkCellRenderer **renderer, char **field, + gboolean *is_editable) +{ + DataItem *item = iter->data1; + if (!strcmp (item->name, "bar3")) { + *renderer = g_object_new (gtk_cell_renderer_toggle_get_type (), + "activatable", TRUE, NULL); + *field = "active"; + } else { + *renderer = g_object_new (gtk_cell_renderer_text_get_type (), + "editable", TRUE, NULL); + *field = "text"; + } + *is_editable = (item->children == NULL); +} + +static gboolean +iter_next (GdlDataModel *dm, GdlDataIter *iter) +{ + DataItem *item = iter->data1; + item++; + if (item->name) { + iter->data1 = item; + return TRUE; + } else { + return FALSE; + } +} + +static gboolean +iter_children (GdlDataModel *dm, GdlDataIter *iter, GdlDataIter *parent) +{ + DataItem *item = parent->data1; + + item = &item->children[0]; + if (item) { + iter->data1 = item; + return TRUE; + } else { + return FALSE; + } +} + +static gboolean +iter_has_child (GdlDataModel *dm, GdlDataIter *iter) +{ + DataItem *item = iter->data1; + if (item->children) { + return TRUE; + } else { + return FALSE; + } +} + + +static void +gdl_data_model_test_instance_init (GdlDataModelTest *model) +{ +} + +static void +gdl_data_model_test_finalize (GObject *object) +{ + (*parent_class->finalize) (object); +} + +static void +gdl_data_model_test_class_init (GdlDataModelTestClass *klass) +{ + GObjectClass *object_class; + parent_class = g_type_class_peek_parent (klass); + object_class = (GObjectClass *)klass; + object_class->finalize = gdl_data_model_test_finalize; +} + +static void +gdl_data_model_test_data_model_init (GdlDataModelIface *iface) +{ + iface->get_iter = get_iter; + iface->get_path = get_path; + iface->get_name = get_name; + iface->get_value = get_value; + iface->get_renderer = get_renderer; + iface->iter_next = iter_next; + iface->iter_children = iter_children; + iface->iter_has_child = iter_has_child; +} + +GType +gdl_data_model_test_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo data_model_test_info = { + sizeof (GdlDataModelTestClass), + NULL, NULL, + (GClassInitFunc) gdl_data_model_test_class_init, + NULL, NULL, + sizeof (GdlDataModelTest), 0, + (GInstanceInitFunc) gdl_data_model_test_instance_init + }; + + static const GInterfaceInfo data_model_info = { + (GInterfaceInitFunc) gdl_data_model_test_data_model_init, + NULL, NULL + }; + + type = g_type_register_static (G_TYPE_OBJECT, + "GdlDataModelTest", + &data_model_test_info, 0); + g_type_add_interface_static (type, + GDL_TYPE_DATA_MODEL, + &data_model_info); + } + return type; +} + +GdlDataModelTest * +gdl_data_model_test_new (void) +{ + return GDL_DATA_MODEL_TEST (g_object_new (gdl_data_model_test_get_type (), NULL)); +} diff --git a/src/libgdl/gdl-data-model-test.h b/src/libgdl/gdl-data-model-test.h new file mode 100644 index 000000000..c8add8daf --- /dev/null +++ b/src/libgdl/gdl-data-model-test.h @@ -0,0 +1,32 @@ +#ifndef GDL_DATA_MODEL_TEST_H +#define GDL_DATA_MODEL_TEST_H + +#include +#include "gdl-data-model.h" + +G_BEGIN_DECLS + +#define GDL_TYPE_DATA_MODEL_TEST (gdl_data_model_test_get_type ()) +#define GDL_DATA_MODEL_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_MODEL_TEST, GdlDataModelTest)) +#define GDL_IS_DATA_MODEL_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_MODEL_TEST)) + + +typedef struct _GdlDataModelTest GdlDataModelTest; +typedef struct _GdlDataModelTestClass GdlDataModelTestClass; + +struct _GdlDataModelTest { + GObject parent; + + int stamp; +}; + +struct _GdlDataModelTestClass { + GObjectClass parent_class; +}; + +GType gdl_data_model_test_get_type (void); +GdlDataModelTest *gdl_data_model_test_new (void); + +G_END_DECLS + +#endif diff --git a/src/libgdl/gdl-data-model.c b/src/libgdl/gdl-data-model.c new file mode 100644 index 000000000..69fbb93d5 --- /dev/null +++ b/src/libgdl/gdl-data-model.c @@ -0,0 +1,160 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-data-model.h" + +gboolean +gdl_data_model_get_iter (GdlDataModel *dm, + GdlDataIter *iter, + GtkTreePath *path) +{ + g_return_val_if_fail (dm != NULL, FALSE); + g_return_val_if_fail (iter != NULL, FALSE); + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_iter != NULL, + FALSE); + + return (*GDL_DATA_MODEL_GET_IFACE (dm)->get_iter) (dm, iter, path); +} + +GtkTreePath * +gdl_data_model_get_path (GdlDataModel *dm, + GdlDataIter *iter) +{ + g_return_val_if_fail (dm != NULL, NULL); + g_return_val_if_fail (iter != NULL, NULL); + g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_path != NULL, + NULL); + + return (*GDL_DATA_MODEL_GET_IFACE (dm)->get_path) (dm, iter); +} + +void +gdl_data_model_get_name (GdlDataModel *dm, + GdlDataIter *iter, + char **name) +{ + g_return_if_fail (dm != NULL); + g_return_if_fail (iter != NULL); + g_return_if_fail (name != NULL); + g_return_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_name != NULL); + + (*GDL_DATA_MODEL_GET_IFACE (dm)->get_name) (dm, iter, name); +} + +void +gdl_data_model_get_value (GdlDataModel *dm, + GdlDataIter *iter, + GValue *value) +{ + g_return_if_fail (dm != NULL); + g_return_if_fail (iter != NULL); + g_return_if_fail (value != NULL); + g_return_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_value != NULL); + + (*GDL_DATA_MODEL_GET_IFACE (dm)->get_value) (dm, iter, value); +} + +void +gdl_data_model_get_renderer (GdlDataModel *dm, + GdlDataIter *iter, + GtkCellRenderer **renderer, + char **field, + gboolean *is_editable) +{ + g_return_if_fail (dm != NULL); + g_return_if_fail (iter != NULL); + g_return_if_fail (renderer != NULL); + g_return_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_renderer != NULL); + + (*GDL_DATA_MODEL_GET_IFACE (dm)->get_renderer) (dm, iter, + renderer, field, + is_editable); +} + +gboolean +gdl_data_model_iter_next (GdlDataModel *dm, + GdlDataIter *iter) +{ + g_return_val_if_fail (dm != NULL, FALSE); + g_return_val_if_fail (iter != NULL, FALSE); + g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->iter_next != NULL, FALSE); + + return (*GDL_DATA_MODEL_GET_IFACE (dm)->iter_next) (dm, iter); +} + +gboolean +gdl_data_model_iter_children (GdlDataModel *dm, + GdlDataIter *iter, + GdlDataIter *parent) +{ + g_return_val_if_fail (dm != NULL, FALSE); + g_return_val_if_fail (iter != NULL, FALSE); + g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->iter_children != NULL, FALSE); + + return (*GDL_DATA_MODEL_GET_IFACE (dm)->iter_children) (dm, iter, parent); +} + +gboolean +gdl_data_model_iter_has_child (GdlDataModel *dm, + GdlDataIter *iter) +{ + g_return_val_if_fail (dm != NULL, FALSE); + g_return_val_if_fail (iter != NULL, FALSE); + g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->iter_has_child != NULL, FALSE); + + return (*GDL_DATA_MODEL_GET_IFACE (dm)->iter_has_child) (dm, iter); +} + +static void +gdl_data_model_base_init (gpointer g_class) +{ + static gboolean initialized = FALSE; + + if (!initialized) { + } +} + +GType +gdl_data_model_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (GdlDataModelIface), + gdl_data_model_base_init, + NULL, NULL, NULL, NULL, 0, 0, NULL + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "GdlDataModel", + &info, 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + } + + return type; +} diff --git a/src/libgdl/gdl-data-model.h b/src/libgdl/gdl-data-model.h new file mode 100644 index 000000000..521a65d0c --- /dev/null +++ b/src/libgdl/gdl-data-model.h @@ -0,0 +1,105 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GDL_DATA_MODEL_H +#define GDL_DATA_MODEL_H + +#include +#include + +/* Using GtkTreePath to save time */ +#include +#include + +G_BEGIN_DECLS + +#define GDL_TYPE_DATA_MODEL (gdl_data_model_get_type ()) +#define GDL_DATA_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_MODEL, GdlDataModel)) +#define GDL_IS_DATA_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_MODEL)) +#define GDL_DATA_MODEL_GET_IFACE(obj) ((GdlDataModelIface *)g_type_interface_peek (((GTypeInstance *)GDL_DATA_MODEL (obj))->g_class, GDL_TYPE_DATA_MODEL)) + +typedef struct _GdlDataModel GdlDataModel; +typedef struct _GdlDataIter GdlDataIter; +typedef struct _GdlDataModelIface GdlDataModelIface; + +struct _GdlDataIter { + int stamp; + + gpointer data1; + gpointer data2; + gpointer data3; +}; + +struct _GdlDataModelIface { + GTypeInterface g_iface; + + /* Signals */ + void (*path_changed) (GdlDataModel *dm, GtkTreePath *path); + void (*path_inserted) (GdlDataModel *dm, GtkTreePath *path); + void (*path_deleted) (GdlDataModel *dm, GtkTreePath *path); + + /* Virtual Table */ + gboolean (*get_iter) (GdlDataModel *dm, GdlDataIter *iter, + GtkTreePath *path); + GtkTreePath* (*get_path) (GdlDataModel *dm, GdlDataIter *iter); + + void (*get_name) (GdlDataModel *dm, GdlDataIter *iter, + char **name); + void (*get_value) (GdlDataModel *dm, GdlDataIter *iter, + GValue *value); + void (*get_renderer) (GdlDataModel *dm, GdlDataIter *iter, + GtkCellRenderer **renderer, char **field, + gboolean *is_editable); + gboolean (*iter_next) (GdlDataModel *dm, GdlDataIter *iter); + gboolean (*iter_children) (GdlDataModel *dm, GdlDataIter *iter, + GdlDataIter *parent); + gboolean (*iter_has_child) (GdlDataModel *dm, GdlDataIter *iter); +}; + +GType gdl_data_model_get_type (void); +gboolean gdl_data_model_get_iter (GdlDataModel *dm, + GdlDataIter *iter, + GtkTreePath *path); +GtkTreePath *gdl_data_model_get_path (GdlDataModel *dm, + GdlDataIter *iter); +void gdl_data_model_get_name (GdlDataModel *dm, + GdlDataIter *iter, + char **name); +void gdl_data_model_get_value (GdlDataModel *dm, + GdlDataIter *iter, + GValue *value); +void gdl_data_model_get_renderer (GdlDataModel *dm, + GdlDataIter *iter, + GtkCellRenderer **renderer, + char **field, + gboolean *is_editable); +gboolean gdl_data_model_iter_next (GdlDataModel *dm, + GdlDataIter *iter); +gboolean gdl_data_model_iter_children (GdlDataModel *dm, + GdlDataIter *iter, + GdlDataIter *children); +gboolean gdl_data_model_iter_has_child (GdlDataModel *dm, + GdlDataIter *iter); + +G_END_DECLS + +#endif diff --git a/src/libgdl/gdl-data-row.c b/src/libgdl/gdl-data-row.c new file mode 100644 index 000000000..666c658fe --- /dev/null +++ b/src/libgdl/gdl-data-row.c @@ -0,0 +1,604 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-i18n.h" +#include "gdl-tools.h" +#include "gdl-data-row.h" +#include "gdl-data-model.h" + +#include +#include + +struct _GdlDataRowPrivate { + GdlDataModel *model; + GtkTreePath *path; + GdlDataView *view; + + char *name; + + /* area_r + * +- title_r + * | +- name_r + * | +- sep_r + * +- data_r + * +- expand_r + * +- cell_r + */ + + GdkRectangle area_r; + + GdkRectangle title_r; + GdkRectangle name_r; + GdkRectangle sep_r; + + GdkRectangle data_r; + GdkRectangle expand_r; + GdkRectangle cell_r; + + gboolean multi; + GtkCellRenderer *cell; + GList *subrows; + + char *renderer_field; + + gboolean expanded; + gboolean focused; + gboolean editable; + + int split; + int child_split; + gboolean selected; +}; + +GDL_CLASS_BOILERPLATE (GdlDataRow, gdl_data_row, GObject, G_TYPE_OBJECT); + + +static void +expand (GdlDataRow *row) +{ + GdlDataIter iter; + gboolean valid; + + if (gdl_data_model_get_iter (row->priv->model, &iter, row->priv->path)) { + valid = gdl_data_model_iter_children (row->priv->model, + &iter, &iter); + while (valid) { + GdlDataRow *new_row; + GtkTreePath *path; + + path = gdl_data_model_get_path (row->priv->model, + &iter); + new_row = gdl_data_row_new (row->priv->view, + path); + row->priv->subrows = + g_list_prepend (row->priv->subrows, new_row); + gtk_tree_path_free (path); + + valid = gdl_data_model_iter_next (row->priv->model, + &iter); + } + row->priv->subrows = g_list_reverse (row->priv->subrows); + + row->priv->expanded = TRUE; + gdl_data_view_layout (GDL_DATA_VIEW (row->priv->view)); + gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); + } +} + +static void +contract (GdlDataRow *row) +{ + GList *l; + for (l = row->priv->subrows; l != NULL; l = l->next) { + g_object_unref (G_OBJECT (l->data)); + } + g_list_free (row->priv->subrows); + row->priv->subrows = NULL; + + row->priv->expanded = FALSE; + gdl_data_view_layout (GDL_DATA_VIEW (row->priv->view)); + gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); +} + +static void +load_path (GdlDataRow *row) +{ + GdlDataIter iter; + + /* Make sure the path has been unloaded */ + g_return_if_fail (row->priv->name == NULL); + g_return_if_fail (row->priv->cell == NULL); + + if (gdl_data_model_get_iter (row->priv->model, + &iter, row->priv->path)) { + GValue val = { 0, }; + char *str; + + gdl_data_model_get_name (row->priv->model, &iter, + &str); + row->priv->name = g_strdup (str); + + if (gdl_data_model_iter_has_child (row->priv->model, &iter)) { + row->priv->multi = TRUE; + } + + gdl_data_model_get_renderer (row->priv->model, &iter, + &row->priv->cell, + &str, + &row->priv->editable); + g_object_ref (GTK_OBJECT (row->priv->cell)); + gtk_object_sink (GTK_OBJECT (row->priv->cell)); + + row->priv->renderer_field = g_strdup (str); + gdl_data_model_get_value (row->priv->model, &iter, &val); + + g_object_set_property (G_OBJECT (row->priv->cell), + row->priv->renderer_field, + &val); + g_value_unset (&val); + } +} + +static void +unload_path (GdlDataRow *row) +{ + if (row->priv->renderer_field) { + g_free (row->priv->renderer_field); + row->priv->renderer_field = NULL; + } + + if (row->priv->name) { + g_free (row->priv->name); + row->priv->name = NULL; + } + + if (row->priv->cell) { + g_object_unref (row->priv->cell); + row->priv->cell = NULL; + } + + if (row->priv->subrows) { + GList *l; + for (l = row->priv->subrows; l != NULL; l = l->next) { + g_object_unref (G_OBJECT (l->data)); + } + g_list_free (row->priv->subrows); + row->priv->subrows = NULL; + } +} + +static void +gdl_data_row_instance_init (GdlDataRow *row) +{ + row->priv = g_new0 (GdlDataRowPrivate, 1); +} + +static void +gdl_data_row_finalize (GObject *object) +{ + GdlDataRow *row = GDL_DATA_ROW (object); + if (row->priv) { + unload_path (row); + + if (row->priv->path) { + gtk_tree_path_free (row->priv->path); + row->priv->path = NULL; + } + + + g_object_unref (row->priv->model); + + g_free (row->priv); + row->priv = NULL; + } +} + +static void +gdl_data_row_class_init (GdlDataRowClass *klass) +{ + GObjectClass *gobject_class = (GObjectClass*) klass; + gobject_class->finalize = gdl_data_row_finalize; + + parent_class = g_type_class_peek_parent (klass); +} + +GdlDataRow * +gdl_data_row_new (GdlDataView *view, + GtkTreePath *path) +{ + GdlDataRow *row; + + row = GDL_DATA_ROW (g_object_new (gdl_data_row_get_type (), + NULL)); + + row->priv->view = view; + row->priv->model = g_object_ref (view->model); + row->priv->path = gtk_tree_path_copy (path); + load_path (row); + + return row; +} + + +#define PAD 3 + +static void +layout_row (GdlDataRow *row, + int x, int y, int width, int height) +{ + PangoLayout *layout; + + /* sizes */ + + layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), + row->priv->name); + pango_layout_get_pixel_size (layout, + &row->priv->name_r.width, + &row->priv->name_r.height); + g_object_unref (layout); + + layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), "="); + pango_layout_get_pixel_size (layout, + &row->priv->sep_r.width, + &row->priv->sep_r.height); + g_object_unref (layout); + + row->priv->title_r.width = + MAX (row->priv->name_r.width + row->priv->sep_r.width + PAD, + row->priv->split); + row->priv->title_r.height = + MAX (row->priv->name_r.height, row->priv->sep_r.width); + + if (row->priv->cell) { + gtk_cell_renderer_get_size (row->priv->cell, + GTK_WIDGET (row->priv->view), + NULL, NULL, NULL, + &row->priv->cell_r.width, + &row->priv->cell_r.height); + } else { + row->priv->cell_r.width = row->priv->cell_r.height = 0; + } + + row->priv->data_r.width = row->priv->cell_r.width; + row->priv->data_r.height = row->priv->cell_r.height; + + if (row->priv->multi) { + row->priv->expand_r.width = 10; + row->priv->expand_r.height = 10; + + row->priv->data_r.width += row->priv->expand_r.width; + row->priv->data_r.height = MAX (row->priv->expand_r.height, + row->priv->data_r.height); + + if (row->priv->expanded) { + GList *l; + int name_w = 0, data_w = 0; + for (l = row->priv->subrows; l != NULL; l = l->next) { + int w1, w2, h; + gdl_data_row_get_size (GDL_DATA_ROW (l->data), + &w1, &w2, NULL, &h); + name_w = MAX (name_w, w1); + data_w = MAX (data_w, w2); + row->priv->data_r.height += h; + } + row->priv->child_split = name_w; + row->priv->data_r.width = + MAX (name_w + data_w + 3 * PAD, + row->priv->data_r.width); + row->priv->data_r.height += 2 * PAD; + } + } + + row->priv->area_r.width = MAX (width, + row->priv->data_r.width + row->priv->title_r.width + PAD); + + row->priv->area_r.height = MAX (height, + (MAX (row->priv->data_r.height, + row->priv->title_r.height))); + + /* Positions */ + + row->priv->area_r.x = x; + row->priv->area_r.y = y; + + row->priv->title_r.x = x; + row->priv->title_r.y = y + ((row->priv->area_r.height) / 2) - (row->priv->title_r.height / 2); + + row->priv->name_r.x = x; + row->priv->name_r.y = y + ((row->priv->area_r.height) / 2) - (row->priv->name_r.height / 2); + + row->priv->sep_r.x = row->priv->title_r.x + row->priv->title_r.width - row->priv->sep_r.width; + row->priv->sep_r.y = y + ((row->priv->area_r.height) / 2) - (row->priv->sep_r.height / 2); + + row->priv->data_r.x = row->priv->title_r.x + row->priv->title_r.width + PAD; + row->priv->data_r.y = y; + + /* Readjust the data area size to fit */ + row->priv->data_r.width = row->priv->area_r.width - (row->priv->title_r.width + PAD); + row->priv->data_r.height = row->priv->area_r.height; + + if (row->priv->multi) { + row->priv->expand_r.x = row->priv->data_r.x; + row->priv->expand_r.y = row->priv->data_r.y + ((row->priv->cell_r.height) / 2) - (row->priv->expand_r.height / 2); + + row->priv->cell_r.y = row->priv->data_r.y; + row->priv->cell_r.height = MAX (row->priv->expand_r.height, row->priv->cell_r.height); + row->priv->cell_r.width = (row->priv->data_r.width - row->priv->expand_r.width); + + row->priv->cell_r.x = row->priv->expand_r.x + row->priv->expand_r.width; + } else { + row->priv->cell_r = row->priv->data_r; + } +} + +void +gdl_data_row_get_size (GdlDataRow *row, int *sep_width, + int *cell_width, int *total_width, int *height) +{ + layout_row (row, 0, 0, 0, 0); + + if (sep_width) { + *sep_width = row->priv->name_r.width + row->priv->sep_r.width + PAD; + } + + if (cell_width) *cell_width = row->priv->data_r.width; + if (total_width) *total_width = row->priv->area_r.width; + if (height) *height = row->priv->area_r.height; +} + +void +gdl_data_row_set_show_name (GdlDataRow *row, gboolean show_name) +{ +} + +void +gdl_data_row_layout (GdlDataRow *row, GdkRectangle *alloc) +{ + layout_row (row, alloc->x, alloc->y, alloc->width, alloc->height); + + if (row->priv->multi && row->priv->expanded) { + GList *l; + GdkRectangle sub; + sub.y = row->priv->expand_r.y + row->priv->expand_r.width + PAD; + sub.x = row->priv->data_r.x + PAD; + sub.width = row->priv->data_r.width - 2 * PAD; + sub.height = row->priv->data_r.height - 2 * PAD; + + for (l = row->priv->subrows; l != NULL; l = l->next) { + gdl_data_row_get_size (GDL_DATA_ROW (l->data), + NULL, NULL, NULL, &sub.height); + gdl_data_row_set_split (GDL_DATA_ROW (l->data), + row->priv->child_split); + gdl_data_row_layout (GDL_DATA_ROW (l->data), + &sub); + sub.y += sub.height; + } + } +} + +#if 0 +#define DRAWR(r) { gdk_draw_rectangle (drawable, GTK_WIDGET (row->priv->view)->style->text_gc[GTK_STATE_NORMAL],FALSE,row->priv->r.x,row->priv->r.y,row->priv->r.width, row->priv->r.height); } +#else +#define DRAWR(r) +#endif + + +void +gdl_data_row_render (GdlDataRow *row, GdkDrawable *drawable, + GdkRectangle *expose_area, + GtkCellRendererState flags) +{ + PangoLayout *layout; + + guint state = GTK_STATE_NORMAL; + + if (row->priv->selected) { + if (flags & GTK_CELL_RENDERER_SELECTED) + state = GTK_STATE_SELECTED; + else + state = GTK_STATE_ACTIVE; + gtk_paint_flat_box (GTK_WIDGET (row->priv->view)->style, + drawable, state, + GTK_SHADOW_NONE, expose_area, + GTK_WIDGET (row->priv->view), "cell_even", + row->priv->area_r.x, row->priv->area_r.y, + row->priv->area_r.width + 1, + row->priv->area_r.height + 1); + + } + + layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), + row->priv->name); + gdk_draw_layout (drawable, + GTK_WIDGET (row->priv->view)->style->text_gc[state], + row->priv->name_r.x, row->priv->name_r.y, layout); + g_object_unref (layout); + DRAWR(name_r); + + layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), "="); + gdk_draw_layout (drawable, + GTK_WIDGET (row->priv->view)->style->text_gc[state], + row->priv->sep_r.x, row->priv->sep_r.y, layout); + g_object_unref (layout); + DRAWR(sep_r); + DRAWR(title_r); + + if (row->priv->cell) { + if (row->priv->focused) { + gtk_paint_focus (GTK_WIDGET (row->priv->view)->style, + drawable, + GTK_WIDGET_STATE (GTK_WIDGET (row->priv->view)), + NULL, GTK_WIDGET (row->priv->view), + "treeview", + row->priv->cell_r.x - 1, + row->priv->cell_r.y - 1, + row->priv->cell_r.width + 2, + row->priv->cell_r.height + 2); + } + + gtk_cell_renderer_render (row->priv->cell, + drawable, GTK_WIDGET (row->priv->view), + &row->priv->area_r, + &row->priv->cell_r, + expose_area, + row->priv->selected ? GTK_CELL_RENDERER_SELECTED : 0); + DRAWR(cell_r); + } + if (row->priv->multi) { + gtk_paint_expander (GTK_WIDGET (row->priv->view)->style, + drawable, + GTK_WIDGET_STATE (GTK_WIDGET (row->priv->view)), + expose_area, + GTK_WIDGET (row->priv->view), + "gdldataview", + row->priv->expand_r.x + row->priv->expand_r.width / 2, + row->priv->expand_r.y + row->priv->expand_r.height / 2, + row->priv->expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED); + DRAWR(expand_r); + + if (row->priv->expanded) { + GList *l; + + for (l = row->priv->subrows; l != NULL; l = l->next) { + gdl_data_row_render (GDL_DATA_ROW (l->data), + drawable, + expose_area, flags); + } + } + gdk_draw_rectangle (drawable, + GTK_WIDGET (row->priv->view)->style->text_gc[GTK_STATE_NORMAL], + FALSE, + row->priv->data_r.x, + row->priv->data_r.y, + row->priv->data_r.width, + row->priv->data_r.height); + } + DRAWR(data_r); +} + + +GdlDataRow * +gdl_data_row_at (GdlDataRow *row, int x, int y) +{ + if (!GDL_POINT_IN (x, y, &row->priv->area_r)) { + return NULL; + } + + if (row->priv->multi && row->priv->expanded) { + GList *l; + for (l = row->priv->subrows; l != NULL; l = l->next) { + GdlDataRow *ret = gdl_data_row_at (GDL_DATA_ROW (l->data), x, y); + if (ret) + return ret; + } + } + + return row; +} + +static gboolean +button_press_event (GdlDataRow *row, GdkEventButton *event, + GtkCellEditable **editable_widget) +{ + if (editable_widget) + *editable_widget = NULL; + + if (GDL_POINT_IN (event->x, event->y, &row->priv->expand_r)) { + if (row->priv->expanded) + contract (row); + else + expand (row); + } + + if (GDL_POINT_IN (event->x, event->y, &row->priv->cell_r) + && row->priv->editable) { + g_return_val_if_fail (editable_widget, FALSE); + *editable_widget = gtk_cell_renderer_start_editing + (row->priv->cell, + (GdkEvent*)event, + GTK_WIDGET (row->priv->view), + "1:2:3", + &row->priv->area_r, + &row->priv->cell_r, + GTK_CELL_RENDERER_SELECTED); + } + + return FALSE; + +} + + +gboolean +gdl_data_row_event (GdlDataRow *row, GdkEvent *event, + GtkCellEditable **editable_widget) +{ + switch (((GdkEventAny *)event)->type) { + case GDK_BUTTON_PRESS: + return button_press_event (row, + (GdkEventButton *)event, + editable_widget); + default: + break; + } + return FALSE; +} + +void +gdl_data_row_get_cell_area (GdlDataRow *row, + GdkRectangle *rect) +{ + *rect = row->priv->cell_r; +} + +void +gdl_data_row_set_split (GdlDataRow *row, int split) +{ + row->priv->split = split; +} + +void +gdl_data_row_set_selected (GdlDataRow *row, gboolean selected) +{ + row->priv->selected = selected; + + /* FIXME: invalidate here */ + gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); +} + +void +gdl_data_row_set_focused (GdlDataRow *row, gboolean focused) +{ + row->priv->focused = focused; + + /* FIXME: invalidate here */ + gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); +} + +const char * +gdl_data_row_get_title (GdlDataRow *row) +{ + return row->priv->name; +} diff --git a/src/libgdl/gdl-data-row.h b/src/libgdl/gdl-data-row.h new file mode 100644 index 000000000..d4928958d --- /dev/null +++ b/src/libgdl/gdl-data-row.h @@ -0,0 +1,90 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GDL_DATA_ROW_H +#define GDL_DATA_ROW_H + +#include + +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define GDL_TYPE_DATA_ROW (gdl_data_row_get_type ()) +#define GDL_DATA_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_ROW, GdlDataRow)) +#define GDL_DATA_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DATA_ROW, GdlDataRowClass)) +#define GDL_IS_DATA_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_ROW)) +#define GDL_IS_DATA_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_ROW)) + +typedef struct _GdlDataRow GdlDataRow; +typedef struct _GdlDataRowClass GdlDataRowClass; +typedef struct _GdlDataRowPrivate GdlDataRowPrivate; + +struct _GdlDataRow { + GObject parent; + + GdlDataRowPrivate *priv; +}; + +struct _GdlDataRowClass { + GObjectClass parent_class; +}; + +GType gdl_data_row_get_type (void); +GdlDataRow *gdl_data_row_new (GdlDataView *view, + GtkTreePath *path); +void gdl_data_row_get_size (GdlDataRow *row, + int *text_w, + int *cell_w, + int *total_width, + int *height); +void gdl_data_row_set_show_name (GdlDataRow *row, + gboolean show_name); +void gdl_data_row_layout (GdlDataRow *row, + GdkRectangle *alloc); +void gdl_data_row_render (GdlDataRow *row, + GdkDrawable *drawable, + GdkRectangle *expose_area, + GtkCellRendererState flags); +GdlDataRow *gdl_data_row_at (GdlDataRow *row, + int x, + int y); +gboolean gdl_data_row_event (GdlDataRow *row, + GdkEvent *event, + GtkCellEditable **editable_widget); +void gdl_data_row_get_cell_area (GdlDataRow *row, + GdkRectangle *rect); +void gdl_data_row_set_split (GdlDataRow *row, + int split); +void gdl_data_row_set_selected (GdlDataRow *row, + gboolean selected); +void gdl_data_row_set_focused (GdlDataRow *row, + gboolean focused); +const char *gdl_data_row_get_title (GdlDataRow *row); + + +G_END_DECLS + +#endif diff --git a/src/libgdl/gdl-data-view.c b/src/libgdl/gdl-data-view.c new file mode 100644 index 000000000..81e1795f7 --- /dev/null +++ b/src/libgdl/gdl-data-view.c @@ -0,0 +1,526 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-i18n.h" +#include "gdl-tools.h" +#include "gdl-data-view.h" +#include "gdl-data-frame.h" + +#include "tree-expand.xpm" +#include "tree-contract.xpm" + +struct _GdlDataViewPrivate { + GList *frames; + GList *rows; + GList *widgets; + + GdlDataFrame *selected_frame; + GdlDataRow *selected_row; + + GtkCellEditable *editable; + + GdkPixbuf *close_pixbuf; + GdkPixbuf *expand_pixbuf; + GdkPixbuf *contract_pixbuf; +}; + +typedef struct { + GtkWidget *widget; + int x, y, height, width; +} ChildWidget; + +static void gdl_data_view_instance_init (GdlDataView *dv); +static void gdl_data_view_class_init (GdlDataViewClass *klass); + +GDL_CLASS_BOILERPLATE (GdlDataView, gdl_data_view, GtkLayout, GTK_TYPE_LAYOUT); + + +#define GRID_SPACING 15 + +static void +paint_grid (GtkWidget *widget, GdkDrawable *drawable, + int offset_x, int offset_y, int width, int height) +{ + GdlDataView *dv; + int x; + int y; + + g_return_if_fail (GDL_IS_DATA_VIEW (widget)); + dv = GDL_DATA_VIEW (widget); + + x = offset_x + ((GRID_SPACING - (offset_x % GRID_SPACING)) % GRID_SPACING); + + /* Draw grid points */ + for (; x < width; x += GRID_SPACING) { + y = offset_y + ((GRID_SPACING - (offset_y % GRID_SPACING)) % GRID_SPACING); + + for (; y < height; y += GRID_SPACING) { + gdk_draw_point (drawable, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + x, y); + } + } +} + +static void +expose_frames (GdlDataView *view, GdkEventExpose *event) +{ + GList *l; + + for (l = view->priv->frames; l != NULL; l = l->next) { + GdkRectangle intersect; + GdlDataFrame *frame = GDL_DATA_FRAME (l->data); + if (gdk_rectangle_intersect (&frame->area, + &event->area, + &intersect)) { + gdl_data_frame_draw (GDL_DATA_FRAME (l->data), + GTK_LAYOUT(view)->bin_window, + &intersect); + } + } +} + +static void +expose_widgets (GdlDataView *view, GdkEventExpose *event) +{ + GList *l; + + for (l = view->priv->widgets; l != NULL; l = l->next) { + ChildWidget *child = l->data; + gtk_container_propagate_expose (GTK_CONTAINER (view), + child->widget, event); + } +} + +static gboolean +gdl_data_view_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + if (GTK_WIDGET_DRAWABLE (widget)) { + if (event->window == GTK_LAYOUT (widget)->bin_window) { + paint_grid (widget, GTK_LAYOUT (widget)->bin_window, + event->area.x, event->area.y, + event->area.width, event->area.height); + expose_frames (GDL_DATA_VIEW (widget), event); + expose_widgets (GDL_DATA_VIEW (widget), event); + return TRUE; + } else { + GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + } + } + + return FALSE; +} + +static GdlDataFrame * +frame_at (GdlDataView *dv, int x, int y) +{ + GList *l; + for (l = dv->priv->frames; l != NULL; l = l->next) { + GdlDataFrame *frame = l->data; + if (x >= frame->area.x && x <= frame->area.x + frame->area.width + && y >= frame->area.y && y <= frame->area.y + frame->area.height) { + return frame; + } + } + return NULL; +} + +static GdlDataRow * +row_at (GdlDataView *view, int x, int y) +{ + GList *l; + GdlDataRow *ret = NULL; + for (l = view->priv->rows; l != NULL; l = l->next) { + GdlDataRow *row = l->data; + ret = gdl_data_row_at (row, x, y); + if (ret) break; + } + return ret; +} + +static void +gdl_data_view_put (GdlDataView *view, GtkWidget *widget, + int x, int y, int width, int height) +{ + ChildWidget *child = g_new0 (ChildWidget, 1); + + child->widget = widget; + child->x = x; + child->y = y; + child->width = width; + child->height = height; + + view->priv->widgets = g_list_append (view->priv->widgets, child); + + if (GTK_WIDGET_REALIZED (view)) { + gtk_widget_set_parent_window (child->widget, + GTK_LAYOUT (view)->bin_window); + } + + gtk_widget_set_parent (child->widget, GTK_WIDGET (view)); +} + +static void +stop_editing (GdlDataView *dv) +{ + if (dv->priv->editable) { + gtk_cell_editable_editing_done (dv->priv->editable); + gtk_cell_editable_remove_widget (dv->priv->editable); + } +} + +static void +remove_widget_cb (GtkCellEditable *cell_editable, GdlDataView *view) +{ + if (view->priv->editable) { + view->priv->editable = NULL; + gdl_data_row_set_focused (view->priv->selected_row, FALSE); + gtk_widget_grab_focus (GTK_WIDGET (view)); + gtk_container_remove (GTK_CONTAINER (view), + GTK_WIDGET (cell_editable)); + } +} + +static gboolean +button_press_event_cb (GdlDataView *dv, GdkEventButton *event, gpointer data) +{ + GdlDataFrame *frame; + GdlDataRow *row; + gboolean ret = FALSE; + + stop_editing (dv); + + if (event->type == GDK_BUTTON_PRESS) { + frame = frame_at (dv, event->x, event->y); + if (frame) { + if (dv->priv->selected_frame) { + gdl_data_frame_set_selected (dv->priv->selected_frame, FALSE); + } + gdl_data_frame_set_selected (frame, TRUE); + dv->priv->selected_frame = frame; + } + + row = row_at (dv, event->x, event->y); + if (row) { + GtkCellEditable *editable; + + if (dv->priv->selected_row) { + gdl_data_row_set_selected (dv->priv->selected_row, + FALSE); + } + dv->priv->selected_row = row; + gdl_data_row_set_selected (row, TRUE); + ret = gdl_data_row_event (row, (GdkEvent*)event, + &editable); + if (editable) { + GdkRectangle area; + dv->priv->editable = editable; + gtk_cell_editable_start_editing (editable, + (GdkEvent*)event); + + gdl_data_row_get_cell_area (row, &area); + gdl_data_view_put (dv, + GTK_WIDGET (editable), + area.x, + area.y, + area.width, + area.height); + + gtk_widget_grab_focus (GTK_WIDGET (editable)); + dv->priv->editable = editable; + gdl_data_row_set_focused (row, TRUE); + + g_signal_connect + (G_OBJECT (editable), + "remove_widget", + G_CALLBACK (remove_widget_cb), dv); + } + } + } + + return ret; +} + +static void +gdl_data_view_instance_init (GdlDataView *dv) +{ + GTK_WIDGET_SET_FLAGS (dv, GTK_CAN_FOCUS); + dv->priv = g_new0 (GdlDataViewPrivate, 1); + + g_signal_connect (G_OBJECT (dv), "button_press_event", + G_CALLBACK (button_press_event_cb), + NULL); + + dv->priv->close_pixbuf = gtk_widget_render_icon (GTK_WIDGET (dv), + "gtk-close", + GTK_ICON_SIZE_MENU, + "gdl-data-view-close"); + + dv->priv->expand_pixbuf = + gdk_pixbuf_new_from_xpm_data ((const char **)tree_expand_xpm); + + dv->priv->contract_pixbuf = + gdk_pixbuf_new_from_xpm_data ((const char **)tree_contract_xpm); +} + +static void +gdl_data_view_realize (GtkWidget *widget) +{ + GList *l; + GdlDataView *view = GDL_DATA_VIEW (widget); + + GDL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget)); + + for (l = view->priv->widgets; l != NULL; l = l->next) { + ChildWidget *child = l->data; + gtk_widget_set_parent_window (child->widget, + GTK_LAYOUT (view)->bin_window); + } +} + +static void +gdl_data_view_size_request (GtkWidget *widget, GtkRequisition *req) +{ + GList *l; + + req->width = req->height = 0; + + for (l = GDL_DATA_VIEW (widget)->priv->widgets; l != NULL; l = l->next) { + GtkRequisition child_req; + ChildWidget *child = l->data; + + gtk_widget_size_request (child->widget, &child_req); + } +} + + +static void +gdl_data_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc) +{ + GdlDataView *view = GDL_DATA_VIEW (widget); + GList *l; +; + for (l = view->priv->widgets; l != NULL; l = l->next) { + ChildWidget *child = l->data; + GtkAllocation child_alloc; + + child_alloc.x = child->x; + child_alloc.y = child->y; + child_alloc.width = child->width; + child_alloc.height = child->height; + + gtk_widget_size_allocate (child->widget, &child_alloc); + } + GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, alloc)); +} + +static void +gdl_data_view_forall (GtkContainer *container, gboolean include_internals, + GtkCallback callback, gpointer callback_data) +{ + GdlDataView *view = GDL_DATA_VIEW (container); + GList *l; + + for (l = view->priv->widgets; l != NULL; l = l->next) { + ChildWidget *child = l->data; + (*callback) (child->widget, callback_data); + } +} + +static void +gdl_data_view_remove (GtkContainer *container, GtkWidget *widget) +{ + GList *l; + GdlDataView *view = GDL_DATA_VIEW (container); + + for (l = view->priv->widgets; l != NULL; l = l->next) { + ChildWidget *child = l->data; + if (child->widget == widget) { + gtk_widget_unparent (widget); + view->priv->widgets = + g_list_remove_link (view->priv->widgets, l); + g_list_free_1 (l); + g_free (child); + return; + } + } +} + +static void +gdl_data_view_destroy (GtkObject *obj) +{ + GdlDataView *dv = GDL_DATA_VIEW (obj); + + stop_editing (dv); + + if (dv->priv) { + GList *l; + for (l = dv->priv->frames; l != NULL; l = l->next) { + g_object_unref (G_OBJECT (l->data)); + } + g_list_free (dv->priv->frames); + + g_object_unref (dv->priv->close_pixbuf); + g_object_unref (dv->priv->expand_pixbuf); + g_object_unref (dv->priv->contract_pixbuf); + + g_free (dv->priv); + dv->priv = NULL; + } + GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (obj)); +} + +static void +gdl_data_view_class_init (GdlDataViewClass *klass) +{ + GtkObjectClass *object_class = (GtkObjectClass *)klass; + GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; + GtkContainerClass *container_class = (GtkContainerClass *)klass; + + parent_class = gtk_type_class (GTK_TYPE_LAYOUT); + + container_class->forall = gdl_data_view_forall; + container_class->remove = gdl_data_view_remove; + + widget_class->expose_event = gdl_data_view_expose; + widget_class->realize = gdl_data_view_realize; + /* FIXME: unrealize */ + widget_class->size_request = gdl_data_view_size_request; + widget_class->size_allocate = gdl_data_view_size_allocate; + object_class->destroy = gdl_data_view_destroy; + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("expander-size", + _("Expander Size"), + _("Size of the expander arrow."), + 0, + G_MAXINT, + 10, + G_PARAM_READABLE)); +} + +GtkWidget * +gdl_data_view_new (void) +{ + GdlDataView *dv; + dv = g_object_new (gdl_data_view_get_type (), NULL); + return GTK_WIDGET (dv); +} + +void +gdl_data_view_set_model (GdlDataView *dv, GdlDataModel *model) +{ + GtkTreePath *path; + GdlDataIter iter; + gboolean iter_valid; + int x = 5; + + dv->model = model; + + path = gtk_tree_path_new_from_string ("0"); + + iter_valid = gdl_data_model_get_iter (model, &iter, path); + gtk_tree_path_free (path); + + while (iter_valid) { + GdlDataFrame *frame; + GdlDataRow *row; + + path = gdl_data_model_get_path (model, &iter); + + row = gdl_data_row_new (dv, path); + frame = gdl_data_frame_new (dv, row); + gdl_data_frame_set_position (frame, x, 5); + + dv->priv->frames = g_list_append (dv->priv->frames, + frame); + dv->priv->rows = g_list_append (dv->priv->rows, row); + + gtk_tree_path_free (path); + + x += 150; + + iter_valid = gdl_data_model_iter_next (model, &iter); + } +} + +void +gdl_data_view_layout (GdlDataView *view) +{ + GList *l; + for (l = view->priv->frames; l != NULL; l = l->next) { + gdl_data_frame_layout (GDL_DATA_FRAME (l->data)); + } +} + +GdkPixbuf * +gdl_data_view_get_close_pixbuf (GdlDataView *view) +{ + return view->priv->close_pixbuf; +} + +void +gdl_data_view_set_close_pixbuf (GdlDataView *view, GdkPixbuf *pixbuf) +{ + if (view->priv->close_pixbuf) { + g_object_unref (view->priv->close_pixbuf); + } + + view->priv->close_pixbuf = g_object_ref (pixbuf); +} + +GdkPixbuf * +gdl_data_view_get_expand_pixbuf (GdlDataView *view) +{ + return view->priv->expand_pixbuf; +} + +void +gdl_data_view_set_expand_pixbuf (GdlDataView *view, GdkPixbuf *pixbuf) +{ + if (view->priv->expand_pixbuf) { + g_object_unref (view->priv->expand_pixbuf); + } + + view->priv->expand_pixbuf = g_object_ref (pixbuf); +} + +GdkPixbuf * +gdl_data_view_get_contract_pixbuf (GdlDataView *view) +{ + return view->priv->contract_pixbuf; +} + +void +gdl_data_view_set_contract_pixbuf (GdlDataView *view, GdkPixbuf *pixbuf) +{ + if (view->priv->contract_pixbuf) { + g_object_unref (view->priv->contract_pixbuf); + } + + view->priv->contract_pixbuf = g_object_ref (pixbuf); +} diff --git a/src/libgdl/gdl-data-view.h b/src/libgdl/gdl-data-view.h new file mode 100644 index 000000000..a29132074 --- /dev/null +++ b/src/libgdl/gdl-data-view.h @@ -0,0 +1,71 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2001 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GDL_DATA_VIEW_H +#define GDL_DATA_VIEW_H + +#include +#include + +G_BEGIN_DECLS + +#define GDL_TYPE_DATA_VIEW (gdl_data_view_get_type ()) +#define GDL_DATA_VIEW(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DATA_VIEW, GdlDataView)) +#define GDL_DATA_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) +#define GDL_IS_DATA_VIEW(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DATA_VIEW)) +#define GDL_IS_DATA_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_VIEW)) +#define GDL_DATA_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) + +typedef struct _GdlDataView GdlDataView; +typedef struct _GdlDataViewClass GdlDataViewClass; +typedef struct _GdlDataViewPrivate GdlDataViewPrivate; + +#define GDL_POINT_IN(x1,y1,r) ((x1) >= (r)->x && x1 < (r)->x + (r)->width && (y1) >= (r)->y && y1 < (r)->y + (r)->height) + +struct _GdlDataView { + GtkLayout layout; + + GdlDataModel *model; + + GdlDataViewPrivate *priv; +}; + +struct _GdlDataViewClass { + GtkLayoutClass parent_class; +}; + +GtkType gdl_data_view_get_type (void); +GtkWidget *gdl_data_view_new (void); +void gdl_data_view_set_model (GdlDataView *view, + GdlDataModel *model); +void gdl_data_view_layout (GdlDataView *view); +GdkPixbuf *gdl_data_view_get_close_pixbuf (GdlDataView *view); +void gdl_data_view_set_close_pixbuf (GdlDataView *view, + GdkPixbuf *pixbuf); +GdkPixbuf *gdl_data_view_get_expand_pixbuf (GdlDataView *view); +void gdl_data_view_set_expand_pixbuf (GdlDataView *view, + GdkPixbuf *pixbuf); +GdkPixbuf *gdl_data_view_get_contract_pixbuf (GdlDataView *view); +void gdl_data_view_set_contract_pixbuf (GdlDataView *view, + GdkPixbuf *pixbuf); + +#endif diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 2513313ef..2101d9621 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -293,10 +293,10 @@ gdl_dock_item_grip_set_property (GObject *object, case PROP_ITEM: grip->item = g_value_get_object (value); if (grip->item) { - g_signal_connect (grip->item, "notify::long_name", + g_signal_connect (grip->item, "notify::long-name", G_CALLBACK (gdl_dock_item_grip_item_notify), grip); - g_signal_connect (grip->item, "notify::stock_id", + g_signal_connect (grip->item, "notify::stock-id", G_CALLBACK (gdl_dock_item_grip_item_notify), grip); g_signal_connect (grip->item, "notify::behavior", diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index c01737636..db31ade30 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -1257,8 +1257,9 @@ gdl_dock_item_dock (GdlDockObject *object, GdlDockPlacement position, GValue *other_data) { - GdlDockObject *new_parent, *parent; - gboolean add_ourselves_first; + GdlDockObject *new_parent = NULL; + GdlDockObject *parent, *requestor_parent; + gboolean add_ourselves_first = FALSE; guint available_space=0; gint pref_size=-1; @@ -1372,11 +1373,16 @@ gdl_dock_item_dock (GdlDockObject *object, pref_size = req.width; break; case GDL_DOCK_CENTER: - new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"), - "preferred-width", object_req.width, - "preferred-height", object_req.height, - NULL); - add_ourselves_first = TRUE; + /* If the parent is already a DockNotebook, we don't need + to create a new one. */ + if (!GDL_IS_DOCK_NOTEBOOK (parent)) + { + new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"), + "preferred-width", object_req.width, + "preferred-height", object_req.height, + NULL); + add_ourselves_first = TRUE; + } break; default: { @@ -1396,9 +1402,12 @@ gdl_dock_item_dock (GdlDockObject *object, gdl_dock_object_freeze (parent); /* ref ourselves since we could be destroyed when detached */ - g_object_ref (object); - GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW); - gdl_dock_object_detach (object, FALSE); + if (new_parent) + { + g_object_ref (object); + GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW); + gdl_dock_object_detach (object, FALSE); + } /* freeze the new parent, so reduce won't get called before it's actually added to our parent */ @@ -1424,7 +1433,14 @@ gdl_dock_item_dock (GdlDockObject *object, /* show automatic object */ if (gtk_widget_get_visible (GTK_WIDGET (object))) + { gtk_widget_show (GTK_WIDGET (new_parent)); + GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW); + gdl_dock_object_thaw (new_parent); + } + else // If the parent is already a DockNotebook, we don't need + // to create a new one. + gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor)); /* use extra docking parameter */ if (position != GDL_DOCK_CENTER && other_data && @@ -1437,10 +1453,17 @@ gdl_dock_item_dock (GdlDockObject *object, g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL); } - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW); g_object_unref (object); - gdl_dock_object_thaw (new_parent); + requestor_parent = gdl_dock_object_get_parent_object (requestor); + if (GDL_IS_DOCK_NOTEBOOK (requestor_parent)) + { + /* Activate the page we just added */ + GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor)); + gtk_notebook_set_page (GTK_NOTEBOOK (notebook->child), + gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor))); + } + if (parent) gdl_dock_object_thaw (parent); diff --git a/src/libgdl/gdl-dock-layout.c b/src/libgdl/gdl-dock-layout.c new file mode 100644 index 000000000..c3b0a4dac --- /dev/null +++ b/src/libgdl/gdl-dock-layout.c @@ -0,0 +1,1411 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2002 Gustavo Giráldez + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-i18n.h" +#include +#include +#include +#include +#include + +#include "gdl-dock-layout.h" +#include "gdl-tools.h" +#include "gdl-dock-placeholder.h" + + +/* ----- Private variables ----- */ + +enum { + PROP_0, + PROP_MASTER, + PROP_DIRTY +}; + +#define ROOT_ELEMENT "dock-layout" +#define DEFAULT_LAYOUT "__default__" +#define LAYOUT_ELEMENT_NAME "layout" +#define NAME_ATTRIBUTE_NAME "name" + +#define LAYOUT_GLADE_FILE "layout.glade" + +enum { + COLUMN_NAME, + COLUMN_SHOW, + COLUMN_LOCKED, + COLUMN_ITEM +}; + +#define COLUMN_EDITABLE COLUMN_SHOW + +struct _GdlDockLayoutPrivate { + xmlDocPtr doc; + + /* layout list models */ + GtkListStore *items_model; + GtkListStore *layouts_model; + + /* idle control */ + gboolean idle_save_pending; +}; + +typedef struct _GdlDockLayoutUIData GdlDockLayoutUIData; + +struct _GdlDockLayoutUIData { + GdlDockLayout *layout; + GtkWidget *locked_check; + GtkTreeSelection *selection; +}; + + +/* ----- Private prototypes ----- */ + +static void gdl_dock_layout_class_init (GdlDockLayoutClass *klass); + +static void gdl_dock_layout_instance_init (GdlDockLayout *layout); + +static void gdl_dock_layout_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); + +static void gdl_dock_layout_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +static void gdl_dock_layout_dispose (GObject *object); + +static void gdl_dock_layout_build_doc (GdlDockLayout *layout); + +static xmlNodePtr gdl_dock_layout_find_layout (GdlDockLayout *layout, + const gchar *name); + +static void gdl_dock_layout_build_models (GdlDockLayout *layout); + + +/* ----- Private implementation ----- */ + +GDL_CLASS_BOILERPLATE (GdlDockLayout, gdl_dock_layout, GObject, G_TYPE_OBJECT); + +static void +gdl_dock_layout_class_init (GdlDockLayoutClass *klass) +{ + GObjectClass *g_object_class = (GObjectClass *) klass; + + g_object_class->set_property = gdl_dock_layout_set_property; + g_object_class->get_property = gdl_dock_layout_get_property; + g_object_class->dispose = gdl_dock_layout_dispose; + + g_object_class_install_property ( + g_object_class, PROP_MASTER, + g_param_spec_object ("master", _("Master"), + _("GdlDockMaster object which the layout object " + "is attached to"), + GDL_TYPE_DOCK_MASTER, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + g_object_class, PROP_DIRTY, + g_param_spec_boolean ("dirty", _("Dirty"), + _("True if the layouts have changed and need to be " + "saved to a file"), + FALSE, + G_PARAM_READABLE)); +} + +static void +gdl_dock_layout_instance_init (GdlDockLayout *layout) +{ + layout->master = NULL; + layout->dirty = FALSE; + layout->_priv = g_new0 (GdlDockLayoutPrivate, 1); + layout->_priv->idle_save_pending = FALSE; + + gdl_dock_layout_build_models (layout); +} + +static void +gdl_dock_layout_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GdlDockLayout *layout = GDL_DOCK_LAYOUT (object); + + switch (prop_id) { + case PROP_MASTER: + gdl_dock_layout_attach (layout, g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + }; +} + +static void +gdl_dock_layout_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GdlDockLayout *layout = GDL_DOCK_LAYOUT (object); + + switch (prop_id) { + case PROP_MASTER: + g_value_set_object (value, layout->master); + break; + case PROP_DIRTY: + g_value_set_boolean (value, layout->dirty); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + }; +} + +static void +gdl_dock_layout_dispose (GObject *object) +{ + GdlDockLayout *layout; + + g_return_if_fail (object != NULL); + g_return_if_fail (GDL_IS_DOCK_LAYOUT (object)); + + layout = GDL_DOCK_LAYOUT (object); + + if (layout->master) + gdl_dock_layout_attach (layout, NULL); + + if (layout->_priv) { + if (layout->_priv->idle_save_pending) { + layout->_priv->idle_save_pending = FALSE; + g_idle_remove_by_data (layout); + } + + if (layout->_priv->doc) { + xmlFreeDoc (layout->_priv->doc); + layout->_priv->doc = NULL; + } + + if (layout->_priv->items_model) { + g_object_unref (layout->_priv->items_model); + g_object_unref (layout->_priv->layouts_model); + layout->_priv->items_model = NULL; + layout->_priv->layouts_model = NULL; + } + + xmlFreeDoc(layout->_priv->doc); + g_free (layout->_priv); + layout->_priv = NULL; + } +} + +static void +gdl_dock_layout_build_doc (GdlDockLayout *layout) +{ + g_return_if_fail (layout->_priv->doc == NULL); + + layout->_priv->doc = xmlNewDoc (BAD_CAST "1.0"); + layout->_priv->doc->children = xmlNewDocNode (layout->_priv->doc, NULL, + BAD_CAST ROOT_ELEMENT, NULL); +} + +static xmlNodePtr +gdl_dock_layout_find_layout (GdlDockLayout *layout, + const gchar *name) +{ + xmlNodePtr node; + gboolean found = FALSE; + + g_return_val_if_fail (layout != NULL, NULL); + + if (!layout->_priv->doc) + return NULL; + + /* get document root */ + node = layout->_priv->doc->children; + for (node = node->children; node; node = node->next) { + xmlChar *layout_name; + + if (strcmp ((char*)node->name, LAYOUT_ELEMENT_NAME)) + /* skip non-layout element */ + continue; + + /* we want the first layout */ + if (!name) + break; + + layout_name = xmlGetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME); + if (!strcmp (name, (char*)layout_name)) + found = TRUE; + xmlFree (layout_name); + + if (found) + break; + }; + return node; +} + +static void +gdl_dock_layout_build_models (GdlDockLayout *layout) +{ + if (!layout->_priv->items_model) { + layout->_priv->items_model = gtk_list_store_new (4, + G_TYPE_STRING, + G_TYPE_BOOLEAN, + G_TYPE_BOOLEAN, + G_TYPE_POINTER); + gtk_tree_sortable_set_sort_column_id ( + GTK_TREE_SORTABLE (layout->_priv->items_model), + COLUMN_NAME, GTK_SORT_ASCENDING); + } + + if (!layout->_priv->layouts_model) { + layout->_priv->layouts_model = gtk_list_store_new (2, G_TYPE_STRING, + G_TYPE_BOOLEAN); + gtk_tree_sortable_set_sort_column_id ( + GTK_TREE_SORTABLE (layout->_priv->layouts_model), + COLUMN_NAME, GTK_SORT_ASCENDING); + } +} + +static void +build_list (GdlDockObject *object, GList **list) +{ + /* add only items, not toplevels */ + if (GDL_IS_DOCK_ITEM (object)) + *list = g_list_prepend (*list, object); +} + +static void +update_items_model (GdlDockLayout *layout) +{ + GList *items, *l; + GtkTreeIter iter; + GtkListStore *store; + gchar *long_name; + gboolean locked; + + g_return_if_fail (layout != NULL); + g_return_if_fail (layout->_priv->items_model != NULL); + + if (!layout->master) + return; + + /* build items list */ + items = NULL; + gdl_dock_master_foreach (layout->master, (GFunc) build_list, &items); + + /* walk the current model */ + store = layout->_priv->items_model; + + /* update items model data after a layout load */ + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { + gboolean valid = TRUE; + + while (valid) { + GdlDockItem *item; + + gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, + COLUMN_ITEM, &item, + -1); + if (item) { + /* look for the object in the items list */ + for (l = items; l && l->data != item; l = l->next); + + if (l) { + /* found, update data */ + g_object_get (item, + "long-name", &long_name, + "locked", &locked, + NULL); + gtk_list_store_set (store, &iter, + COLUMN_NAME, long_name, + COLUMN_SHOW, GDL_DOCK_OBJECT_ATTACHED (item), + COLUMN_LOCKED, locked, + -1); + g_free (long_name); + + /* remove the item from the linked list and keep on walking the model */ + items = g_list_delete_link (items, l); + valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter); + + } else { + /* not found, which means the item has been removed */ + valid = gtk_list_store_remove (store, &iter); + + } + + } else { + /* not a valid row */ + valid = gtk_list_store_remove (store, &iter); + } + } + } + + /* add any remaining objects */ + for (l = items; l; l = l->next) { + GdlDockObject *object = l->data; + + g_object_get (object, + "long-name", &long_name, + "locked", &locked, + NULL); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COLUMN_ITEM, object, + COLUMN_NAME, long_name, + COLUMN_SHOW, GDL_DOCK_OBJECT_ATTACHED (object), + COLUMN_LOCKED, locked, + -1); + g_free (long_name); + } + + g_list_free (items); +} + +static void +update_layouts_model (GdlDockLayout *layout) +{ + GList *items, *l; + GtkTreeIter iter; + + g_return_if_fail (layout != NULL); + g_return_if_fail (layout->_priv->layouts_model != NULL); + + /* build layouts list */ + gtk_list_store_clear (layout->_priv->layouts_model); + items = gdl_dock_layout_get_layouts (layout, FALSE); + for (l = items; l; l = l->next) { + gtk_list_store_append (layout->_priv->layouts_model, &iter); + gtk_list_store_set (layout->_priv->layouts_model, &iter, + COLUMN_NAME, l->data, COLUMN_EDITABLE, TRUE, + -1); + g_free (l->data); + }; + g_list_free (items); +} + + +/* ------- UI functions & callbacks ------ */ + +static void +load_layout_cb (GtkWidget *w, + gpointer data) +{ + GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; + + GtkTreeModel *model; + GtkTreeIter iter; + GdlDockLayout *layout = ui_data->layout; + gchar *name; + + g_return_if_fail (layout != NULL); + + if (gtk_tree_selection_get_selected (ui_data->selection, &model, &iter)) { + gtk_tree_model_get (model, &iter, + COLUMN_NAME, &name, + -1); + gdl_dock_layout_load_layout (layout, name); + g_free (name); + } +} + +static void +delete_layout_cb (GtkWidget *w, gpointer data) +{ + GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; + + GtkTreeModel *model; + GtkTreeIter iter; + GdlDockLayout *layout = ui_data->layout; + gchar *name; + + g_return_if_fail (layout != NULL); + + if (gtk_tree_selection_get_selected (ui_data->selection, &model, &iter)) { + gtk_tree_model_get (model, &iter, + COLUMN_NAME, &name, + -1); + gdl_dock_layout_delete_layout (layout, name); + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + g_free (name); + }; +} + +static void +show_toggled_cb (GtkCellRendererToggle *renderer, + gchar *path_str, + gpointer data) +{ + GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; + + GdlDockLayout *layout = ui_data->layout; + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path = gtk_tree_path_new_from_string (path_str); + gboolean value; + GdlDockItem *item; + + g_return_if_fail (layout != NULL); + + model = GTK_TREE_MODEL (layout->_priv->items_model); + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + COLUMN_SHOW, &value, + COLUMN_ITEM, &item, + -1); + + value = !value; + if (value) + gdl_dock_item_show_item (item); + else + gdl_dock_item_hide_item (item); + + gtk_tree_path_free (path); +} + +static void +all_locked_toggled_cb (GtkWidget *widget, + gpointer data) +{ + GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; + GdlDockMaster *master; + gboolean locked; + + g_return_if_fail (ui_data->layout != NULL); + master = ui_data->layout->master; + g_return_if_fail (master != NULL); + + locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + g_object_set (master, "locked", locked ? 1 : 0, NULL); +} + +static void +layout_ui_destroyed (GtkWidget *widget, + gpointer user_data) +{ + GdlDockLayoutUIData *ui_data; + + /* widget is the GtkContainer */ + ui_data = g_object_get_data (G_OBJECT (widget), "ui_data"); + if (ui_data) { + if (ui_data->layout) { + if (ui_data->layout->master) + /* disconnet the notify handler */ + g_signal_handlers_disconnect_matched (ui_data->layout->master, + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + ui_data); + + g_object_remove_weak_pointer (G_OBJECT (ui_data->layout), + (gpointer *) &ui_data->layout); + ui_data->layout = NULL; + } + g_object_set_data (G_OBJECT (widget), "ui_data", NULL); + g_free (ui_data); + } +} + +static void +master_locked_notify_cb (GdlDockMaster *master, + GParamSpec *pspec, + gpointer user_data) +{ + GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) user_data; + gint locked; + + g_object_get (master, "locked", &locked, NULL); + if (locked == -1) { + gtk_toggle_button_set_inconsistent ( + GTK_TOGGLE_BUTTON (ui_data->locked_check), TRUE); + } + else { + gtk_toggle_button_set_inconsistent ( + GTK_TOGGLE_BUTTON (ui_data->locked_check), FALSE); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (ui_data->locked_check), (locked == 1)); + } +} + +static GladeXML * +load_interface (const gchar *top_widget) +{ + GladeXML *gui; + gchar *gui_file; + + /* load ui */ + gui_file = g_build_filename (GDL_GLADEDIR, LAYOUT_GLADE_FILE, NULL); + gui = glade_xml_new (gui_file, top_widget, GETTEXT_PACKAGE); + g_free (gui_file); + if (!gui) { + /* FIXME: pop up an error dialog */ + g_warning (_("Could not load layout user interface file '%s'"), + LAYOUT_GLADE_FILE); + return NULL; + }; + return gui; +} + +static GtkWidget * +gdl_dock_layout_construct_items_ui (GdlDockLayout *layout) +{ + GladeXML *gui; + GtkWidget *container; + GtkWidget *items_list; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + GdlDockLayoutUIData *ui_data; + + /* load the interface if it wasn't provided */ + gui = load_interface ("items_vbox"); + + if (!gui) + return NULL; + + /* get the container */ + container = glade_xml_get_widget (gui, "items_vbox"); + + ui_data = g_new0 (GdlDockLayoutUIData, 1); + ui_data->layout = layout; + g_object_add_weak_pointer (G_OBJECT (layout), + (gpointer *) &ui_data->layout); + g_object_set_data (G_OBJECT (container), "ui_data", ui_data); + + /* get ui widget references */ + ui_data->locked_check = glade_xml_get_widget (gui, "locked_check"); + items_list = glade_xml_get_widget (gui, "items_list"); + + /* locked check connections */ + g_signal_connect (ui_data->locked_check, "toggled", + (GCallback) all_locked_toggled_cb, ui_data); + if (layout->master) { + g_signal_connect (layout->master, "notify::locked", + (GCallback) master_locked_notify_cb, ui_data); + /* force update now */ + master_locked_notify_cb (layout->master, NULL, ui_data); + } + + /* set models */ + gtk_tree_view_set_model (GTK_TREE_VIEW (items_list), + GTK_TREE_MODEL (layout->_priv->items_model)); + + /* construct list views */ + renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect (renderer, "toggled", + G_CALLBACK (show_toggled_cb), ui_data); + column = gtk_tree_view_column_new_with_attributes (_("Visible"), + renderer, + "active", COLUMN_SHOW, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column); + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Item"), + renderer, + "text", COLUMN_NAME, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column); + + /* connect signals */ + g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL); + + g_object_unref (gui); + + return container; +} + +static void +cell_edited_cb (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + GdlDockLayoutUIData *ui_data = data; + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gchar *name; + xmlNodePtr node; + + model = GTK_TREE_MODEL (ui_data->layout->_priv->layouts_model); + path = gtk_tree_path_new_from_string (path_string); + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, COLUMN_NAME, &name, -1); + + node = gdl_dock_layout_find_layout (ui_data->layout, name); + g_free (name); + g_return_if_fail (node != NULL); + + xmlSetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME, BAD_CAST new_text); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NAME, new_text, + COLUMN_EDITABLE, TRUE, -1); + + gdl_dock_layout_save_layout (ui_data->layout, new_text); + + gtk_tree_path_free (path); +} + +static GtkWidget * +gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) +{ + GladeXML *gui; + GtkWidget *container; + GtkWidget *layouts_list; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + GdlDockLayoutUIData *ui_data; + + /* load the interface if it wasn't provided */ + gui = load_interface ("layouts_vbox"); + + if (!gui) + return NULL; + + /* get the container */ + container = glade_xml_get_widget (gui, "layouts_vbox"); + + ui_data = g_new0 (GdlDockLayoutUIData, 1); + ui_data->layout = layout; + g_object_add_weak_pointer (G_OBJECT (layout), + (gpointer *) &ui_data->layout); + g_object_set_data (G_OBJECT (container), "ui-data", ui_data); + + /* get ui widget references */ + layouts_list = glade_xml_get_widget (gui, "layouts_list"); + + /* set models */ + gtk_tree_view_set_model (GTK_TREE_VIEW (layouts_list), + GTK_TREE_MODEL (layout->_priv->layouts_model)); + + /* construct list views */ + renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (renderer), "edited", + G_CALLBACK (cell_edited_cb), ui_data); + column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, + "text", COLUMN_NAME, + "editable", COLUMN_EDITABLE, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (layouts_list), column); + + ui_data->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (layouts_list)); + + /* connect signals */ + glade_xml_signal_connect_data (gui, "on_load_button_clicked", + GTK_SIGNAL_FUNC (load_layout_cb), ui_data); + glade_xml_signal_connect_data (gui, "on_delete_button_clicked", + GTK_SIGNAL_FUNC (delete_layout_cb), ui_data); + + g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL); + + g_object_unref (gui); + + return container; +} + +static GtkWidget * +gdl_dock_layout_construct_ui (GdlDockLayout *layout) +{ + GtkWidget *container, *child; + + container = gtk_notebook_new (); + gtk_widget_show (container); + + child = gdl_dock_layout_construct_items_ui (layout); + if (child) + gtk_notebook_append_page (GTK_NOTEBOOK (container), + child, + gtk_label_new (_("Dock items"))); + + child = gdl_dock_layout_construct_layouts_ui (layout); + if (child) + gtk_notebook_append_page (GTK_NOTEBOOK (container), + child, + gtk_label_new (_("Saved layouts"))); + + gtk_notebook_set_current_page (GTK_NOTEBOOK (container), 0); + + return container; +} + +/* ----- Save & Load layout functions --------- */ + +#define GDL_DOCK_PARAM_CONSTRUCTION(p) \ + (((p)->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) != 0) + +static GdlDockObject * +gdl_dock_layout_setup_object (GdlDockMaster *master, + xmlNodePtr node, + gint *n_after_params, + GParameter **after_params) +{ + GdlDockObject *object = NULL; + GType object_type; + xmlChar *object_name; + GObjectClass *object_class = NULL; + + GParamSpec **props; + guint n_props, i; + GParameter *params = NULL; + gint n_params = 0; + GValue serialized = { 0, }; + + object_name = xmlGetProp (node, BAD_CAST GDL_DOCK_NAME_PROPERTY); + if (object_name && strlen ((char*)object_name) > 0) { + /* the object must already be bound to the master */ + object = gdl_dock_master_get_object (master, (char*)object_name); + + xmlFree (object_name); + object_type = object ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE; + } + else { + /* the object should be automatic, so create it by + retrieving the object type from the dock registry */ + object_type = gdl_dock_object_type_from_nick ((char*)node->name); + if (object_type == G_TYPE_NONE) { + g_warning (_("While loading layout: don't know how to create " + "a dock object whose nick is '%s'"), node->name); + } + } + + if (object_type == G_TYPE_NONE || !G_TYPE_IS_CLASSED (object_type)) + return NULL; + + object_class = g_type_class_ref (object_type); + props = g_object_class_list_properties (object_class, &n_props); + + /* create parameter slots */ + /* extra parameter is the master */ + params = g_new0 (GParameter, n_props + 1); + *after_params = g_new0 (GParameter, n_props); + *n_after_params = 0; + + /* initialize value used for transformations */ + g_value_init (&serialized, GDL_TYPE_DOCK_PARAM); + + for (i = 0; i < n_props; i++) { + xmlChar *xml_prop; + + /* process all exported properties, skip + GDL_DOCK_NAME_PROPERTY, since named items should + already by in the master */ + if (!(props [i]->flags & GDL_DOCK_PARAM_EXPORT) || + !strcmp (props [i]->name, GDL_DOCK_NAME_PROPERTY)) + continue; + + /* get the property from xml if there is one */ + xml_prop = xmlGetProp (node, BAD_CAST props [i]->name); + if (xml_prop) { + g_value_set_static_string (&serialized, (char*)xml_prop); + + if (!GDL_DOCK_PARAM_CONSTRUCTION (props [i]) && + (props [i]->flags & GDL_DOCK_PARAM_AFTER)) { + (*after_params) [*n_after_params].name = props [i]->name; + g_value_init (&((* after_params) [*n_after_params].value), + props [i]->value_type); + g_value_transform (&serialized, + &((* after_params) [*n_after_params].value)); + (*n_after_params)++; + } + else if (!object || (!GDL_DOCK_PARAM_CONSTRUCTION (props [i]) && object)) { + params [n_params].name = props [i]->name; + g_value_init (&(params [n_params].value), props [i]->value_type); + g_value_transform (&serialized, &(params [n_params].value)); + n_params++; + } + xmlFree (xml_prop); + } + } + g_value_unset (&serialized); + g_free (props); + + if (!object) { + params [n_params].name = GDL_DOCK_MASTER_PROPERTY; + g_value_init (¶ms [n_params].value, GDL_TYPE_DOCK_MASTER); + g_value_set_object (¶ms [n_params].value, master); + n_params++; + + /* construct the object if we have to */ + /* set the master, so toplevels are created correctly and + other objects are bound */ + object = g_object_newv (object_type, n_params, params); + } + else { + /* set the parameters to the existing object */ + for (i = 0; i < n_params; i++) + g_object_set_property (G_OBJECT (object), + params [i].name, + ¶ms [i].value); + } + + /* free the parameters (names are static/const strings) */ + for (i = 0; i < n_params; i++) + g_value_unset (¶ms [i].value); + g_free (params); + + /* finally unref object class */ + g_type_class_unref (object_class); + + return object; +} + +static void +gdl_dock_layout_recursive_build (GdlDockMaster *master, + xmlNodePtr parent_node, + GdlDockObject *parent) +{ + GdlDockObject *object; + xmlNodePtr node; + + g_return_if_fail (master != NULL && parent_node != NULL); + + /* if parent is NULL we should build toplevels */ + for (node = parent_node->children; node; node = node->next) { + GParameter *after_params = NULL; + gint n_after_params = 0, i; + + object = gdl_dock_layout_setup_object (master, node, + &n_after_params, + &after_params); + + if (object) { + gdl_dock_object_freeze (object); + + /* recurse here to catch placeholders */ + gdl_dock_layout_recursive_build (master, node, object); + + if (GDL_IS_DOCK_PLACEHOLDER (object)) + /* placeholders are later attached to the parent */ + gdl_dock_object_detach (object, FALSE); + + /* apply "after" parameters */ + for (i = 0; i < n_after_params; i++) { + g_object_set_property (G_OBJECT (object), + after_params [i].name, + &after_params [i].value); + /* unset and free the value */ + g_value_unset (&after_params [i].value); + } + g_free (after_params); + + /* add the object to the parent */ + if (parent) { + if (GDL_IS_DOCK_PLACEHOLDER (object)) + gdl_dock_placeholder_attach (GDL_DOCK_PLACEHOLDER (object), + parent); + else if (gdl_dock_object_is_compound (parent)) { + gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (object)); + if (GTK_WIDGET_VISIBLE (parent)) + gtk_widget_show (GTK_WIDGET (object)); + } + } + else { + GdlDockObject *controller = gdl_dock_master_get_controller (master); + if (controller != object && GTK_WIDGET_VISIBLE (controller)) + gtk_widget_show (GTK_WIDGET (object)); + } + + /* call reduce just in case any child is missing */ + if (gdl_dock_object_is_compound (object)) + gdl_dock_object_reduce (object); + + gdl_dock_object_thaw (object); + } + } +} + +static void +_gdl_dock_layout_foreach_detach (GdlDockObject *object) +{ + gdl_dock_object_detach (object, TRUE); +} + +static void +gdl_dock_layout_foreach_toplevel_detach (GdlDockObject *object) +{ + gtk_container_foreach (GTK_CONTAINER (object), + (GtkCallback) _gdl_dock_layout_foreach_detach, + NULL); +} + +static void +gdl_dock_layout_load (GdlDockMaster *master, xmlNodePtr node) +{ + g_return_if_fail (master != NULL && node != NULL); + + /* start by detaching all items from the toplevels */ + gdl_dock_master_foreach_toplevel (master, TRUE, + (GFunc) gdl_dock_layout_foreach_toplevel_detach, + NULL); + + gdl_dock_layout_recursive_build (master, node, NULL); +} + +static void +gdl_dock_layout_foreach_object_save (GdlDockObject *object, + gpointer user_data) +{ + struct { + xmlNodePtr where; + GHashTable *placeholders; + } *info = user_data, info_child; + + xmlNodePtr node; + guint n_props, i; + GParamSpec **props; + GValue attr = { 0, }; + + g_return_if_fail (object != NULL && GDL_IS_DOCK_OBJECT (object)); + g_return_if_fail (info->where != NULL); + + node = xmlNewChild (info->where, + NULL, /* ns */ + BAD_CAST gdl_dock_object_nick_from_type (G_TYPE_FROM_INSTANCE (object)), + BAD_CAST NULL); /* contents */ + + /* get object exported attributes */ + props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), + &n_props); + g_value_init (&attr, GDL_TYPE_DOCK_PARAM); + for (i = 0; i < n_props; i++) { + GParamSpec *p = props [i]; + + if (p->flags & GDL_DOCK_PARAM_EXPORT) { + GValue v = { 0, }; + + /* export this parameter */ + /* get the parameter value */ + g_value_init (&v, p->value_type); + g_object_get_property (G_OBJECT (object), + p->name, + &v); + + /* only save the object "name" if it is set + (i.e. don't save the empty string) */ + if (strcmp (p->name, GDL_DOCK_NAME_PROPERTY) || + g_value_get_string (&v)) { + if (g_value_transform (&v, &attr)) + xmlSetProp (node, BAD_CAST p->name, BAD_CAST g_value_get_string (&attr)); + } + + /* free the parameter value */ + g_value_unset (&v); + } + } + g_value_unset (&attr); + g_free (props); + + info_child = *info; + info_child.where = node; + + /* save placeholders for the object */ + if (info->placeholders && !GDL_IS_DOCK_PLACEHOLDER (object)) { + GList *lph = g_hash_table_lookup (info->placeholders, object); + for (; lph; lph = lph->next) + gdl_dock_layout_foreach_object_save (GDL_DOCK_OBJECT (lph->data), + (gpointer) &info_child); + } + + /* recurse the object if appropiate */ + if (gdl_dock_object_is_compound (object)) { + gtk_container_foreach (GTK_CONTAINER (object), + (GtkCallback) gdl_dock_layout_foreach_object_save, + (gpointer) &info_child); + } +} + +static void +add_placeholder (GdlDockObject *object, + GHashTable *placeholders) +{ + if (GDL_IS_DOCK_PLACEHOLDER (object)) { + GdlDockObject *host; + GList *l; + + g_object_get (object, "host", &host, NULL); + if (host) { + l = g_hash_table_lookup (placeholders, host); + /* add the current placeholder to the list of placeholders + for that host */ + if (l) + g_hash_table_steal (placeholders, host); + + l = g_list_prepend (l, object); + g_hash_table_insert (placeholders, host, l); + g_object_unref (host); + } + } +} + +static void +gdl_dock_layout_save (GdlDockMaster *master, + xmlNodePtr where) +{ + struct { + xmlNodePtr where; + GHashTable *placeholders; + } info; + + GHashTable *placeholders; + + g_return_if_fail (master != NULL && where != NULL); + + /* build the placeholder's hash: the hash keeps lists of + * placeholders associated to each object, so that we can save the + * placeholders when we are saving the object (since placeholders + * don't show up in the normal widget hierarchy) */ + placeholders = g_hash_table_new_full (g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify) g_list_free); + gdl_dock_master_foreach (master, (GFunc) add_placeholder, placeholders); + + /* save the layout recursively */ + info.where = where; + info.placeholders = placeholders; + + gdl_dock_master_foreach_toplevel (master, TRUE, + (GFunc) gdl_dock_layout_foreach_object_save, + (gpointer) &info); + + g_hash_table_destroy (placeholders); +} + + +/* ----- Public interface ----- */ + +GdlDockLayout * +gdl_dock_layout_new (GdlDock *dock) +{ + GdlDockMaster *master = NULL; + + /* get the master of the given dock */ + if (dock) + master = GDL_DOCK_OBJECT_GET_MASTER (dock); + + return g_object_new (GDL_TYPE_DOCK_LAYOUT, + "master", master, + NULL); +} + +static gboolean +gdl_dock_layout_idle_save (GdlDockLayout *layout) +{ + /* save default layout */ + gdl_dock_layout_save_layout (layout, NULL); + + layout->_priv->idle_save_pending = FALSE; + + return FALSE; +} + +static void +gdl_dock_layout_layout_changed_cb (GdlDockMaster *master, + GdlDockLayout *layout) +{ + /* update model */ + update_items_model (layout); + + if (!layout->_priv->idle_save_pending) { + g_idle_add ((GSourceFunc) gdl_dock_layout_idle_save, layout); + layout->_priv->idle_save_pending = TRUE; + } +} + +void +gdl_dock_layout_attach (GdlDockLayout *layout, + GdlDockMaster *master) +{ + g_return_if_fail (layout != NULL); + g_return_if_fail (master == NULL || GDL_IS_DOCK_MASTER (master)); + + if (layout->master) { + g_signal_handlers_disconnect_matched (layout->master, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, layout); + g_object_unref (layout->master); + } + + gtk_list_store_clear (layout->_priv->items_model); + + layout->master = master; + if (layout->master) { + g_object_ref (layout->master); + g_signal_connect (layout->master, "layout-changed", + (GCallback) gdl_dock_layout_layout_changed_cb, + layout); + } + + update_items_model (layout); +} + +gboolean +gdl_dock_layout_load_layout (GdlDockLayout *layout, + const gchar *name) +{ + xmlNodePtr node; + gchar *layout_name; + + g_return_val_if_fail (layout != NULL, FALSE); + + if (!layout->_priv->doc || !layout->master) + return FALSE; + + if (!name) + layout_name = DEFAULT_LAYOUT; + else + layout_name = (gchar *) name; + + node = gdl_dock_layout_find_layout (layout, layout_name); + if (!node && !name) + /* return the first layout if the default name failed to load */ + node = gdl_dock_layout_find_layout (layout, NULL); + + if (node) { + gdl_dock_layout_load (layout->master, node); + return TRUE; + } else + return FALSE; +} + +void +gdl_dock_layout_save_layout (GdlDockLayout *layout, + const gchar *name) +{ + xmlNodePtr node; + gchar *layout_name; + + g_return_if_fail (layout != NULL); + g_return_if_fail (layout->master != NULL); + + if (!layout->_priv->doc) + gdl_dock_layout_build_doc (layout); + + if (!name) + layout_name = DEFAULT_LAYOUT; + else + layout_name = (gchar *) name; + + /* delete any previously node with the same name */ + node = gdl_dock_layout_find_layout (layout, layout_name); + if (node) { + xmlUnlinkNode (node); + xmlFreeNode (node); + }; + + /* create the new node */ + node = xmlNewChild (layout->_priv->doc->children, NULL, + BAD_CAST LAYOUT_ELEMENT_NAME, NULL); + xmlSetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME, BAD_CAST layout_name); + + /* save the layout */ + gdl_dock_layout_save (layout->master, node); + layout->dirty = TRUE; + g_object_notify (G_OBJECT (layout), "dirty"); +} + +void +gdl_dock_layout_delete_layout (GdlDockLayout *layout, + const gchar *name) +{ + xmlNodePtr node; + + g_return_if_fail (layout != NULL); + + /* don't allow the deletion of the default layout */ + if (!name || !strcmp (DEFAULT_LAYOUT, name)) + return; + + node = gdl_dock_layout_find_layout (layout, name); + if (node) { + xmlUnlinkNode (node); + xmlFreeNode (node); + layout->dirty = TRUE; + g_object_notify (G_OBJECT (layout), "dirty"); + } +} + +void +gdl_dock_layout_run_manager (GdlDockLayout *layout) +{ + GtkWidget *dialog, *container; + GtkWidget *parent = NULL; + + g_return_if_fail (layout != NULL); + + if (!layout->master) + /* not attached to a dock yet */ + return; + + container = gdl_dock_layout_construct_ui (layout); + if (!container) + return; + + parent = GTK_WIDGET (gdl_dock_master_get_controller (layout->master)); + if (parent) + parent = gtk_widget_get_toplevel (parent); + + dialog = gtk_dialog_new_with_buttons (_("Layout managment"), + parent ? GTK_WINDOW (parent) : NULL, + GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, + NULL); + + gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 300); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), container); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + gtk_widget_destroy (dialog); +} + +gboolean +gdl_dock_layout_load_from_file (GdlDockLayout *layout, + const gchar *filename) +{ + gboolean retval = FALSE; + + if (layout->_priv->doc) { + xmlFreeDoc (layout->_priv->doc); + layout->_priv->doc = NULL; + layout->dirty = FALSE; + g_object_notify (G_OBJECT (layout), "dirty"); + } + + /* FIXME: cannot open symlinks */ + if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { + layout->_priv->doc = xmlParseFile (filename); + if (layout->_priv->doc) { + xmlNodePtr root = layout->_priv->doc->children; + /* minimum validation: test the root element */ + if (root && !strcmp ((char*)root->name, ROOT_ELEMENT)) { + update_layouts_model (layout); + retval = TRUE; + } else { + xmlFreeDoc (layout->_priv->doc); + layout->_priv->doc = NULL; + } + } + } + + return retval; +} + +gboolean +gdl_dock_layout_save_to_file (GdlDockLayout *layout, + const gchar *filename) +{ + FILE *file_handle; + int bytes; + gboolean retval = FALSE; + + g_return_val_if_fail (layout != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + + /* if there is still no xml doc, create an empty one */ + if (!layout->_priv->doc) + gdl_dock_layout_build_doc (layout); + + file_handle = fopen (filename, "w"); + if (file_handle) { + bytes = xmlDocDump (file_handle, layout->_priv->doc); + if (bytes >= 0) { + layout->dirty = FALSE; + g_object_notify (G_OBJECT (layout), "dirty"); + retval = TRUE; + }; + fclose (file_handle); + }; + + return retval; +} + +gboolean +gdl_dock_layout_is_dirty (GdlDockLayout *layout) +{ + g_return_val_if_fail (layout != NULL, FALSE); + + return layout->dirty; +}; + +GList * +gdl_dock_layout_get_layouts (GdlDockLayout *layout, + gboolean include_default) +{ + GList *retval = NULL; + xmlNodePtr node; + + g_return_val_if_fail (layout != NULL, NULL); + + if (!layout->_priv->doc) + return NULL; + + node = layout->_priv->doc->children; + for (node = node->children; node; node = node->next) { + xmlChar *name; + + if (strcmp ((char*)node->name, LAYOUT_ELEMENT_NAME)) + continue; + + name = xmlGetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME); + if (include_default || strcmp ((char*)name, DEFAULT_LAYOUT)) + retval = g_list_prepend (retval, g_strdup ((char*)name)); + xmlFree (name); + }; + retval = g_list_reverse (retval); + + return retval; +} + +GtkWidget * +gdl_dock_layout_get_ui (GdlDockLayout *layout) +{ + GtkWidget *ui; + + g_return_val_if_fail (layout != NULL, NULL); + ui = gdl_dock_layout_construct_ui (layout); + + return ui; +} + +GtkWidget * +gdl_dock_layout_get_items_ui (GdlDockLayout *layout) +{ + GtkWidget *ui; + + g_return_val_if_fail (layout != NULL, NULL); + ui = gdl_dock_layout_construct_items_ui (layout); + + return ui; +} + +GtkWidget * +gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout) +{ + GtkWidget *ui; + + g_return_val_if_fail (layout != NULL, NULL); + ui = gdl_dock_layout_construct_layouts_ui (layout); + + return ui; +} diff --git a/src/libgdl/gdl-dock-layout.h b/src/libgdl/gdl-dock-layout.h new file mode 100644 index 000000000..2ce5d13b3 --- /dev/null +++ b/src/libgdl/gdl-dock-layout.h @@ -0,0 +1,98 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 2002 Gustavo Giráldez + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __GDL_DOCK_LAYOUT_H__ +#define __GDL_DOCK_LAYOUT_H__ + +#include +#include "libgdl/gdl-dock-master.h" +#include "libgdl/gdl-dock.h" + +G_BEGIN_DECLS + +/* standard macros */ +#define GDL_TYPE_DOCK_LAYOUT (gdl_dock_layout_get_type ()) +#define GDL_DOCK_LAYOUT(object) (GTK_CHECK_CAST ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayout)) +#define GDL_DOCK_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) +#define GDL_IS_DOCK_LAYOUT(object) (GTK_CHECK_TYPE ((object), GDL_TYPE_DOCK_LAYOUT)) +#define GDL_IS_DOCK_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_LAYOUT)) +#define GDL_DOCK_LAYOUT_GET_CLASS(object) (GTK_CHECK_GET_CLASS ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) + +/* data types & structures */ +typedef struct _GdlDockLayout GdlDockLayout; +typedef struct _GdlDockLayoutClass GdlDockLayoutClass; +typedef struct _GdlDockLayoutPrivate GdlDockLayoutPrivate; + +struct _GdlDockLayout { + GObject g_object; + + gboolean dirty; + GdlDockMaster *master; + + GdlDockLayoutPrivate *_priv; +}; + +struct _GdlDockLayoutClass { + GObjectClass g_object_class; +}; + + +/* public interface */ + +GType gdl_dock_layout_get_type (void); + +GdlDockLayout *gdl_dock_layout_new (GdlDock *dock); + +void gdl_dock_layout_attach (GdlDockLayout *layout, + GdlDockMaster *master); + +gboolean gdl_dock_layout_load_layout (GdlDockLayout *layout, + const gchar *name); + +void gdl_dock_layout_save_layout (GdlDockLayout *layout, + const gchar *name); + +void gdl_dock_layout_delete_layout (GdlDockLayout *layout, + const gchar *name); + +GList *gdl_dock_layout_get_layouts (GdlDockLayout *layout, + gboolean include_default); + +void gdl_dock_layout_run_manager (GdlDockLayout *layout); + +gboolean gdl_dock_layout_load_from_file (GdlDockLayout *layout, + const gchar *filename); + +gboolean gdl_dock_layout_save_to_file (GdlDockLayout *layout, + const gchar *filename); + +gboolean gdl_dock_layout_is_dirty (GdlDockLayout *layout); + +GtkWidget *gdl_dock_layout_get_ui (GdlDockLayout *layout); +GtkWidget *gdl_dock_layout_get_items_ui (GdlDockLayout *layout); +GtkWidget *gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout); + +G_END_DECLS + +#endif + + diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 9bdcd18ed..129cc28d9 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -396,6 +396,7 @@ gdl_dock_object_real_reduce (GdlDockObject *object) children = gtk_container_get_children (GTK_CONTAINER (object)); if (g_list_length (children) <= 1) { GList *l; + GList *dchildren = NULL; /* detach ourselves and then re-attach our children to our current parent. if we are not currently attached, the @@ -403,18 +404,41 @@ gdl_dock_object_real_reduce (GdlDockObject *object) if (parent) gdl_dock_object_freeze (parent); gdl_dock_object_freeze (object); - gdl_dock_object_detach (object, FALSE); + /* Detach the children before detaching this object, since in this + * way the children can have access to the whole object hierarchy. + * Set the InDetach flag now, so the children know that this object + * is going to be detached. */ + + + GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_DETACH); + for (l = children; l; l = l->next) { - GdlDockObject *child = GDL_DOCK_OBJECT (l->data); + GdlDockObject *child; + + if (!GDL_IS_DOCK_OBJECT (l->data)) + continue; + + child = GDL_DOCK_OBJECT (l->data); g_object_ref (child); - GDL_DOCK_OBJECT_SET_FLAGS (child, GDL_DOCK_IN_REFLOW); gdl_dock_object_detach (child, FALSE); + GDL_DOCK_OBJECT_SET_FLAGS (child, GDL_DOCK_IN_REFLOW); if (parent) - gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (child)); + dchildren = g_list_append (dchildren, child); GDL_DOCK_OBJECT_UNSET_FLAGS (child, GDL_DOCK_IN_REFLOW); - g_object_unref (child); } + /* Now it can be detached */ + gdl_dock_object_detach (object, FALSE); + + /* After detaching the reduced object, we can add the + children (the only child in fact) to the new parent */ + for (l = dchildren; l; l = l->next) { + gtk_container_add (GTK_CONTAINER (parent), l->data); + g_object_unref (l->data); + } + g_list_free (dchildren); + + /* sink the widget, so any automatic floating widget is destroyed */ g_object_ref_sink (object); /* don't reenter */ @@ -469,6 +493,9 @@ gdl_dock_object_detach (GdlDockObject *object, { g_return_if_fail (object != NULL); + if (!GDL_IS_DOCK_OBJECT (object)) + return; + if (!GDL_DOCK_OBJECT_ATTACHED (object)) return; diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index ca7763a55..33934e2e0 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -189,14 +189,14 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) g_object_class_install_property ( g_object_class, PROP_FLOAT_X, g_param_spec_int ("floatx", _("X-Coordinate"), - _("X coordinate for dock when floating"), + _("X-Coordinate for dock when floating"), -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | GDL_DOCK_PARAM_EXPORT)); g_object_class_install_property ( g_object_class, PROP_FLOAT_Y, g_param_spec_int ("floaty", _("Y-Coordinate"), - _("Y coordinate for dock when floating"), + _("Y-Coordinate for dock when floating"), -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | GDL_DOCK_PARAM_EXPORT)); diff --git a/src/libgdl/gdl-icons.c b/src/libgdl/gdl-icons.c new file mode 100644 index 000000000..2af2a8a9a --- /dev/null +++ b/src/libgdl/gdl-icons.c @@ -0,0 +1,267 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* gdl-icons.c + * + * Copyright (C) 2000-2001 Dave Camp + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Dave Camp, Jeroen Zwartepoorte + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gdl-i18n.h" +#include "gdl-tools.h" +#include +#include +#include +#include "gdl-icons.h" + +enum { + PROP_BOGUS, + PROP_ICON_SIZE, +}; + +#define GDL_ICONS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDL_TYPE_ICONS, GdlIconsPrivate)) + +typedef struct _GdlIconsPrivate GdlIconsPrivate; + +struct _GdlIconsPrivate { + int icon_size; + + GtkIconTheme *icon_theme; + GHashTable *icons; +}; + +GDL_CLASS_BOILERPLATE (GdlIcons, gdl_icons, GObject, G_TYPE_OBJECT); + +static void +gdl_icons_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_ICON_SIZE: + g_value_set_int (value, priv->icon_size); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gdl_icons_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_ICON_SIZE: + priv->icon_size = g_value_get_int (value); + g_hash_table_destroy (priv->icons); + priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gdk_pixbuf_unref); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +theme_changed_cb (GtkIconTheme *theme, + gpointer user_data) +{ + GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (user_data); + + g_hash_table_destroy (priv->icons); + priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gdk_pixbuf_unref); +} + +static void +gdl_icons_dispose (GObject *object) +{ + GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (object); + + if (priv->icon_theme) { + /* Don't do that - look a GTK+ docs */ + /* g_object_unref (priv->icon_theme); */ + priv->icon_theme = NULL; + } + + if (priv->icons) { + g_hash_table_destroy (priv->icons); + priv->icons = NULL; + } +} + +static void +gdl_icons_class_init (GdlIconsClass *klass) +{ + GObjectClass *object_class = (GObjectClass *) klass; + + parent_class = g_type_class_peek_parent (klass); + + object_class->dispose = gdl_icons_dispose; + object_class->get_property = gdl_icons_get_property; + object_class->set_property = gdl_icons_set_property; + + g_object_class_install_property (object_class, PROP_ICON_SIZE, + g_param_spec_int ("icon-size", + _("Icon size"), + _("Icon size"), + 12, 256, 24, + G_PARAM_READWRITE)); + + g_type_class_add_private (object_class, sizeof (GdlIconsPrivate)); +} + +static void +gdl_icons_instance_init (GdlIcons *icons) +{ + GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (icons); + + priv->icon_theme = gtk_icon_theme_get_default (); + /* gtk_icon_theme_get_default() does not ref the returned object */ + /* but API docs state the you should NOT ref it */ + /* g_object_ref (priv->icon_theme);*/ + g_signal_connect_object (G_OBJECT (priv->icon_theme), "changed", + G_CALLBACK (theme_changed_cb), icons, 0); + priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) gdk_pixbuf_unref); +} + +GdlIcons * +gdl_icons_new (int icon_size) +{ + return GDL_ICONS (g_object_new (GDL_TYPE_ICONS, + "icon-size", icon_size, + NULL)); +} + +GdkPixbuf * +gdl_icons_get_folder_icon (GdlIcons *icons) +{ + g_return_val_if_fail (icons != NULL, NULL); + g_return_val_if_fail (GDL_IS_ICONS (icons), NULL); + + return gdl_icons_get_mime_icon (icons, "application/directory-normal"); +} + +GdkPixbuf * +gdl_icons_get_uri_icon (GdlIcons *icons, + const char *uri) +{ + GnomeVFSFileInfo *info; + GdkPixbuf *pixbuf; + + g_return_val_if_fail (icons != NULL, NULL); + g_return_val_if_fail (GDL_IS_ICONS (icons), NULL); + g_return_val_if_fail (uri != NULL, NULL); + + info = gnome_vfs_file_info_new (); + gnome_vfs_get_file_info (uri, info, + GNOME_VFS_FILE_INFO_FOLLOW_LINKS | + GNOME_VFS_FILE_INFO_GET_MIME_TYPE | + GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE); + if (info->mime_type) + pixbuf = gdl_icons_get_mime_icon (icons, info->mime_type); + else + pixbuf = gdl_icons_get_mime_icon (icons, "gnome-fs-regular"); + gnome_vfs_file_info_unref (info); + + return pixbuf; +} + +GdkPixbuf * +gdl_icons_get_mime_icon (GdlIcons *icons, + const char *mime_type) +{ + GdkPixbuf *pixbuf; + char *icon_name; + + g_return_val_if_fail (icons != NULL, NULL); + g_return_val_if_fail (GDL_IS_ICONS (icons), NULL); + g_return_val_if_fail (mime_type != NULL, NULL); + + GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (icons); + + pixbuf = g_hash_table_lookup (priv->icons, mime_type); + if (pixbuf != NULL) { + g_object_ref (G_OBJECT (pixbuf)); + return pixbuf; + } + + if (!strcmp (mime_type, "application/directory-normal")) { + icon_name = g_strdup ("gnome-fs-directory"); + } else { + icon_name = gnome_icon_lookup (priv->icon_theme, + NULL, + NULL, + NULL, + NULL, + mime_type, + GNOME_ICON_LOOKUP_FLAGS_NONE, + NULL); + } + + if (!icon_name) { + /* Return regular icon if one doesn't exist for mime type. */ + if (!strcmp (mime_type, "gnome-fs-regular")) + return NULL; + else + return gdl_icons_get_mime_icon (icons, "gnome-fs-regular"); + } else { + if (!gtk_icon_theme_has_icon (priv->icon_theme, icon_name)) { + g_free (icon_name); + if (!strcmp (mime_type, "gnome-fs-regular")) + return NULL; + else + return gdl_icons_get_mime_icon (icons, "gnome-fs-regular"); + } else { + pixbuf = gtk_icon_theme_load_icon (priv->icon_theme, + icon_name, + priv->icon_size, + 0, /* lookup flags */ + NULL); + g_free (icon_name); + + if (pixbuf == NULL) { + if (!strcmp (mime_type, "gnome-fs-regular")) + return NULL; + else + return gdl_icons_get_mime_icon (icons, + "gnome-fs-regular"); + } + } + } + + g_hash_table_insert (priv->icons, g_strdup (mime_type), pixbuf); + g_object_ref (pixbuf); + + return pixbuf; +} diff --git a/src/libgdl/gdl-icons.h b/src/libgdl/gdl-icons.h new file mode 100644 index 000000000..79f3bba85 --- /dev/null +++ b/src/libgdl/gdl-icons.h @@ -0,0 +1,61 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* gdl-icons.h + * + * Copyright (C) 2000-2001 JP Rosevear + * 2000 Dave Camp + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: JP Rosevear, Dave Camp, Jeroen Zwartepoorte + */ + +#ifndef _GDL_ICONS_H_ +#define _GDL_ICONS_H_ + +#include +#include + +G_BEGIN_DECLS + +#define GDL_TYPE_ICONS (gdl_icons_get_type ()) +#define GDL_ICONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_ICONS, GdlIcons)) +#define GDL_ICONS_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_ICONS, GdlIconsClass)) +#define GDL_IS_ICONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_ICONS)) +#define GDL_IS_ICONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_ICONS)) + +typedef struct _GdlIcons GdlIcons; +typedef struct _GdlIconsClass GdlIconsClass; + +struct _GdlIcons { + GObject parent; +}; + +struct _GdlIconsClass { + GObjectClass parent_class; +}; + +GType gdl_icons_get_type (void); +GdlIcons *gdl_icons_new (int icon_size); + +GdkPixbuf *gdl_icons_get_folder_icon (GdlIcons *icons); +GdkPixbuf *gdl_icons_get_uri_icon (GdlIcons *icons, + const char *uri); +GdkPixbuf *gdl_icons_get_mime_icon (GdlIcons *icons, + const char *mime_type); + +G_END_DECLS + +#endif /* _GDL_ICONS_H_ */ diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index eccd66ce2..24ec72126 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -55,7 +55,7 @@ static void gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *stock_id, const GdkPixbuf *pixbuf_icon, gint switcher_id); -static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); +/* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */ static void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id); static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id); static void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show); @@ -514,7 +514,7 @@ gdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event) } } return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS, expose_event, - (widget, event), FALSE); + (widget, event), FALSE); } static void @@ -678,11 +678,9 @@ gdl_switcher_select_page (GdlSwitcher *switcher, gint id) static void gdl_switcher_class_init (GdlSwitcherClass *klass) { - GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); - (void)notebook_class; container_class->forall = gdl_switcher_forall; container_class->remove = gdl_switcher_remove; @@ -763,11 +761,11 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, gtk_widget_show (hbox); if (stock_id) { - icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); + icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU); } else if (pixbuf_icon) { icon_widget = gtk_image_new_from_pixbuf (pixbuf_icon); } else { - icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON); + icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); } gtk_widget_show (icon_widget); @@ -810,6 +808,7 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, gtk_widget_queue_resize (GTK_WIDGET (switcher)); } +#if 0 static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id) { @@ -827,6 +826,7 @@ gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id) } gtk_widget_queue_resize (GTK_WIDGET (switcher)); } +#endif static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id) diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h new file mode 100644 index 000000000..e47dc310d --- /dev/null +++ b/src/libgdl/gdl.h @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * This file is part of the GNOME Devtools Libraries. + * + * Copyright (C) 1999-2000 Dave Camp + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GDL_H__ +#define __GDL_H__ + +#include "libgdl/gdl-tools.h" +#include "libgdl/gdl-dock-object.h" +#include "libgdl/gdl-dock-master.h" +#include "libgdl/gdl-dock.h" +#include "libgdl/gdl-dock-item.h" +#include "libgdl/gdl-dock-layout.h" +#include "libgdl/gdl-dock-paned.h" +#include "libgdl/gdl-dock-notebook.h" +#include "libgdl/gdl-dock-tablabel.h" +#include "libgdl/gdl-dock-bar.h" +#include "libgdl/gdl-combo-button.h" +#include "libgdl/gdl-switcher.h" + +#endif diff --git a/src/libgdl/libgdl.h b/src/libgdl/libgdl.h deleted file mode 100644 index 5ee84e1ae..000000000 --- a/src/libgdl/libgdl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 1999-2000 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GDL_H__ -#define __GDL_H__ - -#include "libgdl/gdl-tools.h" -#include "libgdl/gdl-dock-object.h" -#include "libgdl/gdl-dock-master.h" -#include "libgdl/gdl-dock.h" -#include "libgdl/gdl-dock-item.h" -#include "libgdl/gdl-dock-paned.h" -#include "libgdl/gdl-dock-notebook.h" -#include "libgdl/gdl-dock-tablabel.h" -#include "libgdl/gdl-dock-bar.h" -#include "libgdl/gdl-switcher.h" - -#endif diff --git a/src/libgdl/libgdltypebuiltins.h b/src/libgdl/libgdltypebuiltins.h index 8be5decb1..f5e6ea17b 100644 --- a/src/libgdl/libgdltypebuiltins.h +++ b/src/libgdl/libgdltypebuiltins.h @@ -4,7 +4,7 @@ #ifndef __LIBGDLTYPEBUILTINS_H__ #define __LIBGDLTYPEBUILTINS_H__ 1 -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" G_BEGIN_DECLS diff --git a/src/libgdl/test-combo-button.c b/src/libgdl/test-combo-button.c new file mode 100644 index 000000000..35ce3fff3 --- /dev/null +++ b/src/libgdl/test-combo-button.c @@ -0,0 +1,111 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* test-combo-button.c + * + * Copyright (C) 2003 Jeroen Zwartepoorte + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include "gdl-combo-button.h" + +static void +combo_button_activate_default_cb (GdlComboButton *combo, + gpointer data) +{ + g_message ("combo_button_activate_default_cb"); +} + +int +main (int argc, char **argv) +{ + GtkWidget *window, *hbox, *combo, *menu, *menuitem; + GdkPixbuf *icon; + + gtk_init (&argc, &argv); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (G_OBJECT (window), "delete_event", + G_CALLBACK (gtk_main_quit), NULL); + gtk_window_set_title (GTK_WINDOW (window), "Combo button test"); + gtk_window_set_resizable (GTK_WINDOW (window), FALSE); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), hbox); + + combo = gtk_button_new_from_stock (GTK_STOCK_OPEN); + gtk_button_set_relief (GTK_BUTTON (combo), GTK_RELIEF_NONE); + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); + + menu = gtk_menu_new (); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + gtk_widget_show_all (menu); + + combo = gdl_combo_button_new (); + gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Run"); + gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu)); + icon = gtk_widget_render_icon (combo, GTK_STOCK_EXECUTE, + GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); + gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon); + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); + + g_signal_connect (combo, "activate_default", + G_CALLBACK (combo_button_activate_default_cb), NULL); + + combo = gtk_button_new_from_stock (GTK_STOCK_SAVE); + gtk_button_set_relief (GTK_BUTTON (combo), GTK_RELIEF_NONE); + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); + + menu = gtk_menu_new (); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + gtk_widget_show_all (menu); + + combo = gdl_combo_button_new (); + gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Open"); + gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu)); + icon = gtk_widget_render_icon (combo, GTK_STOCK_OPEN, + GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); + gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon); + gtk_widget_set_sensitive (combo, FALSE); + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); + + g_signal_connect (combo, "activate_default", + G_CALLBACK (combo_button_activate_default_cb), NULL); + + menu = gtk_menu_new (); + combo = gdl_combo_button_new (); + gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Open"); + gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu)); + icon = gtk_widget_render_icon (combo, GTK_STOCK_OPEN, + GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); + gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon); + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); + + gtk_widget_show_all (window); + + gtk_main (); + + return 0; +} diff --git a/src/libgdl/test-dataview.c b/src/libgdl/test-dataview.c new file mode 100644 index 000000000..bc89cbd4f --- /dev/null +++ b/src/libgdl/test-dataview.c @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "gdl-data-view.h" +#include "gdl-data-model-test.h" + +int +main (int argc, char *argv[]) +{ + GtkWidget *win; + GtkWidget *view; + GdlDataModel *model; + GtkWidget *vbox; + + gtk_init (&argc, &argv); + + win = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size (GTK_WINDOW (win), 500, 200); + + vbox = gtk_vbox_new (FALSE, 5); + + view = gdl_data_view_new (); + + gtk_layout_set_hadjustment (GTK_LAYOUT (view), NULL); + gtk_layout_set_vadjustment (GTK_LAYOUT (view), NULL); + + + model = GDL_DATA_MODEL (gdl_data_model_test_new ()); + gdl_data_view_set_model (GDL_DATA_VIEW (view), + model); + + gtk_box_pack_start (GTK_BOX (vbox), view, TRUE, TRUE, 0); + + gtk_container_add (GTK_CONTAINER (win), vbox); + + gtk_widget_show_all (win); + gtk_widget_grab_focus (GTK_WIDGET (view)); + + gtk_main (); + + return 0; +} diff --git a/src/libgdl/test-dock.c b/src/libgdl/test-dock.c new file mode 100644 index 000000000..1e9c80111 --- /dev/null +++ b/src/libgdl/test-dock.c @@ -0,0 +1,311 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "gdl-tools.h" + +#include "gdl-dock.h" +#include "gdl-dock-item.h" +#include "gdl-dock-notebook.h" +#include "gdl-dock-layout.h" +#include "gdl-dock-placeholder.h" +#include "gdl-dock-bar.h" +#include "gdl-switcher.h" + +#include + +/* ---- end of debugging code */ + +static void +on_style_button_toggled (GtkRadioButton *button, GdlDock *dock) +{ + gboolean active; + GdlDockMaster *master = GDL_DOCK_OBJECT_GET_MASTER (dock); + GdlSwitcherStyle style = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), + "__style_id")); + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + if (active) { + g_object_set (master, "switcher-style", style, NULL); + } +} + +static GtkWidget * +create_style_button (GtkWidget *dock, GtkWidget *box, GtkWidget *group, + GdlSwitcherStyle style, const gchar *style_text) +{ + GdlSwitcherStyle current_style; + GtkWidget *button1; + GdlDockMaster *master = GDL_DOCK_OBJECT_GET_MASTER (dock); + + g_object_get (master, "switcher-style", ¤t_style, NULL); + button1 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (group), + style_text); + gtk_widget_show (button1); + g_object_set_data (G_OBJECT (button1), "__style_id", + GINT_TO_POINTER (style)); + if (current_style == style) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button1), TRUE); + } + g_signal_connect (button1, "toggled", + G_CALLBACK (on_style_button_toggled), + dock); + gtk_box_pack_start (GTK_BOX (box), button1, FALSE, FALSE, 0); + return button1; +} + +static GtkWidget * +create_styles_item (GtkWidget *dock) +{ + GtkWidget *vbox1; + GtkWidget *group; + + vbox1 = gtk_vbox_new (FALSE, 0); + gtk_widget_show (vbox1); + + group = create_style_button (dock, vbox1, NULL, + GDL_SWITCHER_STYLE_ICON, "Only icon"); + group = create_style_button (dock, vbox1, group, + GDL_SWITCHER_STYLE_TEXT, "Only text"); + group = create_style_button (dock, vbox1, group, + GDL_SWITCHER_STYLE_BOTH, + "Both icons and texts"); + group = create_style_button (dock, vbox1, group, + GDL_SWITCHER_STYLE_TOOLBAR, + "Desktop toolbar style"); + group = create_style_button (dock, vbox1, group, + GDL_SWITCHER_STYLE_TABS, + "Notebook tabs"); + return vbox1; +} + +static GtkWidget * +create_item (const gchar *button_title) +{ + GtkWidget *vbox1; + GtkWidget *button1; + + vbox1 = gtk_vbox_new (FALSE, 0); + gtk_widget_show (vbox1); + + button1 = gtk_button_new_with_label (button_title); + gtk_widget_show (button1); + gtk_box_pack_start (GTK_BOX (vbox1), button1, TRUE, TRUE, 0); + + return vbox1; +} + +/* creates a simple widget with a textbox inside */ +static GtkWidget * +create_text_item () +{ + GtkWidget *vbox1; + GtkWidget *scrolledwindow1; + GtkWidget *text; + + vbox1 = gtk_vbox_new (FALSE, 0); + gtk_widget_show (vbox1); + + scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_show (scrolledwindow1); + gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), + GTK_SHADOW_ETCHED_IN); + text = gtk_text_view_new (); + g_object_set (text, "wrap-mode", GTK_WRAP_WORD, NULL); + gtk_widget_show (text); + gtk_container_add (GTK_CONTAINER (scrolledwindow1), text); + + return vbox1; +} + +static void +button_dump_cb (GtkWidget *button, gpointer data) +{ + /* Dump XML tree. */ + gdl_dock_layout_save_to_file (GDL_DOCK_LAYOUT (data), "layout.xml"); + g_spawn_command_line_async ("cat layout.xml", NULL); +} + +static void +run_layout_manager_cb (GtkWidget *w, gpointer data) +{ + GdlDockLayout *layout = GDL_DOCK_LAYOUT (data); + gdl_dock_layout_run_manager (layout); +} + +static void +save_layout_cb (GtkWidget *w, gpointer data) +{ + GdlDockLayout *layout = GDL_DOCK_LAYOUT (data); + GtkWidget *dialog, *hbox, *label, *entry; + gint response; + + dialog = gtk_dialog_new_with_buttons ("New Layout", + NULL, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, + GTK_RESPONSE_OK, + NULL); + + hbox = gtk_hbox_new (FALSE, 8); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new ("Name:"); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + + gtk_widget_show_all (hbox); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (response == GTK_RESPONSE_OK) { + const gchar *name = gtk_entry_get_text (GTK_ENTRY (entry)); + gdl_dock_layout_save_layout (layout, name); + } + + gtk_widget_destroy (dialog); +} + +int +main (int argc, char **argv) +{ + GtkWidget *item1, *item2, *item3; + GtkWidget *items [4]; + GtkWidget *win, *table, *button, *box; + int i; + GdlDockLayout *layout; + GtkWidget *dock, *dockbar; + + gtk_init (&argc, &argv); + + /*gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);*/ + + /* window creation */ + win = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (win, "delete_event", + G_CALLBACK (gtk_main_quit), NULL); + gtk_window_set_title (GTK_WINDOW (win), "Docking widget test"); + gtk_window_set_default_size (GTK_WINDOW (win), 400, 400); + + /* table */ + table = gtk_vbox_new (FALSE, 5); + gtk_container_add (GTK_CONTAINER (win), table); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); + + /* create the dock */ + dock = gdl_dock_new (); + + /* ... and the layout manager */ + layout = gdl_dock_layout_new (GDL_DOCK (dock)); + + /* create the dockbar */ + dockbar = gdl_dock_bar_new (GDL_DOCK (dock)); + gdl_dock_bar_set_style(GDL_DOCK_BAR(dockbar), GDL_DOCK_BAR_TEXT); + + box = gtk_hbox_new (FALSE, 5); + gtk_box_pack_start (GTK_BOX (table), box, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (box), dockbar, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (box), dock, TRUE, TRUE, 0); + + /* create the dock items */ + item1 = gdl_dock_item_new ("item1", "Item #1", GDL_DOCK_ITEM_BEH_LOCKED); + gtk_container_add (GTK_CONTAINER (item1), create_text_item ()); + gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (item1), + GDL_DOCK_TOP); + gtk_widget_show (item1); + + item2 = gdl_dock_item_new_with_stock ("item2", "Item #2: Select the switcher style for notebooks", + GTK_STOCK_EXECUTE, + GDL_DOCK_ITEM_BEH_NORMAL); + g_object_set (item2, "resize", FALSE, NULL); + gtk_container_add (GTK_CONTAINER (item2), create_styles_item (dock)); + gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (item2), + GDL_DOCK_RIGHT); + gtk_widget_show (item2); + + item3 = gdl_dock_item_new_with_stock ("item3", "Item #3 has accented characters (áéíóúñ)", + GTK_STOCK_CONVERT, + GDL_DOCK_ITEM_BEH_NORMAL | + GDL_DOCK_ITEM_BEH_CANT_CLOSE); + gtk_container_add (GTK_CONTAINER (item3), create_item ("Button 3")); + gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (item3), + GDL_DOCK_BOTTOM); + gtk_widget_show (item3); + + items [0] = gdl_dock_item_new_with_stock ("Item #4", "Item #4", + GTK_STOCK_JUSTIFY_FILL, + GDL_DOCK_ITEM_BEH_NORMAL | + GDL_DOCK_ITEM_BEH_CANT_ICONIFY); + gtk_container_add (GTK_CONTAINER (items [0]), create_text_item ()); + gtk_widget_show (items [0]); + gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (items [0]), GDL_DOCK_BOTTOM); + for (i = 1; i < 3; i++) { + gchar name[10]; + + snprintf (name, sizeof (name), "Item #%d", i + 4); + items [i] = gdl_dock_item_new_with_stock (name, name, GTK_STOCK_NEW, + GDL_DOCK_ITEM_BEH_NORMAL); + gtk_container_add (GTK_CONTAINER (items [i]), create_text_item ()); + gtk_widget_show (items [i]); + + gdl_dock_object_dock (GDL_DOCK_OBJECT (items [0]), + GDL_DOCK_OBJECT (items [i]), + GDL_DOCK_CENTER, NULL); + }; + + /* tests: manually dock and move around some of the items */ + gdl_dock_item_dock_to (GDL_DOCK_ITEM (item3), GDL_DOCK_ITEM (item1), + GDL_DOCK_TOP, -1); + + gdl_dock_item_dock_to (GDL_DOCK_ITEM (item2), GDL_DOCK_ITEM (item3), + GDL_DOCK_RIGHT, -1); + + gdl_dock_item_dock_to (GDL_DOCK_ITEM (item2), GDL_DOCK_ITEM (item3), + GDL_DOCK_LEFT, -1); + + gdl_dock_item_dock_to (GDL_DOCK_ITEM (item2), NULL, + GDL_DOCK_FLOATING, -1); + + box = gtk_hbox_new (TRUE, 5); + gtk_box_pack_end (GTK_BOX (table), box, FALSE, FALSE, 0); + + button = gtk_button_new_from_stock (GTK_STOCK_SAVE); + g_signal_connect (button, "clicked", + G_CALLBACK (save_layout_cb), layout); + gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0); + + button = gtk_button_new_with_label ("Layout Manager"); + g_signal_connect (button, "clicked", + G_CALLBACK (run_layout_manager_cb), layout); + gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0); + + button = gtk_button_new_with_label ("Dump XML"); + g_signal_connect (button, "clicked", + G_CALLBACK (button_dump_cb), layout); + gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0); + + gtk_widget_show_all (win); + + gdl_dock_placeholder_new ("ph1", GDL_DOCK_OBJECT (dock), GDL_DOCK_TOP, FALSE); + gdl_dock_placeholder_new ("ph2", GDL_DOCK_OBJECT (dock), GDL_DOCK_BOTTOM, FALSE); + gdl_dock_placeholder_new ("ph3", GDL_DOCK_OBJECT (dock), GDL_DOCK_LEFT, FALSE); + gdl_dock_placeholder_new ("ph4", GDL_DOCK_OBJECT (dock), GDL_DOCK_RIGHT, FALSE); + + gtk_main (); + + g_object_unref (layout); + + return 0; +} diff --git a/src/ui/dialog/dock-behavior.h b/src/ui/dialog/dock-behavior.h index b865af545..98c111719 100644 --- a/src/ui/dialog/dock-behavior.h +++ b/src/ui/dialog/dock-behavior.h @@ -21,7 +21,7 @@ #include "ui/widget/dock-item.h" -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" #include "behavior.h" diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 79d69d862..1780b7525 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -19,7 +19,7 @@ #include #include -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h index 5836cf83f..bd5685348 100644 --- a/src/ui/widget/dock.h +++ b/src/ui/widget/dock.h @@ -20,7 +20,7 @@ #include "ui/widget/dock-item.h" -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" namespace Inkscape { namespace UI { -- cgit v1.2.3 From 076ea1e5cfd8f4c78638e71405a7dda8de7aa17f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jul 2011 15:48:49 +0100 Subject: Merge upstream GDL 0.7.9 changes (bzr r10431) --- src/libgdl/gdl-dock-item.c | 2 +- src/libgdl/gdl-tools.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index db31ade30..c8151fe95 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -301,7 +301,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) g_object_class, PROP_RESIZE, g_param_spec_boolean ("resize", _("Resizable"), _("If set, the dock item can be resized when " - "docked in a panel"), + "docked in a GtkPanel widget"), TRUE, G_PARAM_READWRITE)); diff --git a/src/libgdl/gdl-tools.h b/src/libgdl/gdl-tools.h index 2cc68c035..4e515b23b 100644 --- a/src/libgdl/gdl-tools.h +++ b/src/libgdl/gdl-tools.h @@ -79,9 +79,10 @@ G_BEGIN_DECLS #endif /* DO_GDL_TRACE */ -/** +/* * Class boilerplate and base class call macros copied from * bonobo/bonobo-macros.h. Original copyright follows. + * * * Author: * Darin Adler -- cgit v1.2.3 From f733c171b830be2914f2473dcac2ed5787ad8317 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jul 2011 15:58:25 +0100 Subject: Merge upstream GDL 0.7.10 changes (bzr r10432) --- src/libgdl/gdl-dock-item-grip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 2101d9621..0c202812c 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -214,9 +214,11 @@ gdl_dock_item_grip_item_notify (GObject *master, ensure_title_and_icon_pixbuf (grip); } else if (strcmp (pspec->name, "long-name") == 0) { + if (grip->_priv->title_layout) { + g_object_unref (grip->_priv->title_layout); + grip->_priv->title_layout = NULL; + } g_free (grip->_priv->title); - g_object_unref (grip->_priv->title_layout); - grip->_priv->title_layout = NULL; grip->_priv->title = NULL; ensure_title_and_icon_pixbuf (grip); gtk_widget_queue_draw (GTK_WIDGET (grip)); -- cgit v1.2.3 From ec4f9f3344866d4a36d11cec8250289be6999f61 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jul 2011 16:19:38 +0100 Subject: Merge upstream GDL 2.23.90 changes (bzr r10433) --- src/libgdl/gdl-data-frame.h | 10 +++++----- src/libgdl/gdl-data-view.h | 12 ++++++------ src/libgdl/gdl-dock-item-grip.c | 4 ++-- src/libgdl/gdl-dock-item.c | 2 +- src/libgdl/gdl-dock-layout.c | 4 ++-- src/libgdl/gdl-dock-layout.h | 10 +++++----- src/libgdl/gdl-switcher.c | 23 +++++++++++++++++++---- 7 files changed, 40 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-data-frame.h b/src/libgdl/gdl-data-frame.h index 740c38293..7daeb5b12 100644 --- a/src/libgdl/gdl-data-frame.h +++ b/src/libgdl/gdl-data-frame.h @@ -29,11 +29,11 @@ G_BEGIN_DECLS #define GDL_TYPE_DATA_FRAME (gdl_data_frame_get_type ()) -#define GDL_DATA_FRAME(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrame)) -#define GDL_DATA_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_DATA_VIEW_FRAM, GdlDataFrame)) -#define GDL_IS_DATA_FRAME(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DATA_FRAME)) -#define GDL_IS_DATA_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_FRAME)) -#define GDL_DATA_FRAME_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrameClass)) +#define GDL_DATA_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrame)) +#define GDL_DATA_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_DATA_VIEW_FRAM, GdlDataFrame)) +#define GDL_IS_DATA_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_FRAME)) +#define GDL_IS_DATA_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_FRAME)) +#define GDL_DATA_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrameClass)) typedef struct _GdlDataFrame GdlDataFrame; typedef struct _GdlDataFramePrivate GdlDataFramePrivate; diff --git a/src/libgdl/gdl-data-view.h b/src/libgdl/gdl-data-view.h index a29132074..3a5db02f4 100644 --- a/src/libgdl/gdl-data-view.h +++ b/src/libgdl/gdl-data-view.h @@ -29,11 +29,11 @@ G_BEGIN_DECLS #define GDL_TYPE_DATA_VIEW (gdl_data_view_get_type ()) -#define GDL_DATA_VIEW(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DATA_VIEW, GdlDataView)) -#define GDL_DATA_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) -#define GDL_IS_DATA_VIEW(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DATA_VIEW)) -#define GDL_IS_DATA_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_VIEW)) -#define GDL_DATA_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) +#define GDL_DATA_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_VIEW, GdlDataView)) +#define GDL_DATA_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) +#define GDL_IS_DATA_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_VIEW)) +#define GDL_IS_DATA_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_VIEW)) +#define GDL_DATA_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) typedef struct _GdlDataView GdlDataView; typedef struct _GdlDataViewClass GdlDataViewClass; @@ -53,7 +53,7 @@ struct _GdlDataViewClass { GtkLayoutClass parent_class; }; -GtkType gdl_data_view_get_type (void); +GType gdl_data_view_get_type (void); GtkWidget *gdl_data_view_new (void); void gdl_data_view_set_model (GdlDataView *view, GdlDataModel *model); diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 0c202812c..91b88e782 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -386,9 +386,9 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip); gtk_widget_set_tooltip_text (grip->_priv->iconify_button, - _("Iconify")); + _("Iconify this dock")); gtk_widget_set_tooltip_text (grip->_priv->close_button, - _("Close")); + _("Close this dock")); } static void diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index c8151fe95..d2c36b18a 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -1460,7 +1460,7 @@ gdl_dock_item_dock (GdlDockObject *object, { /* Activate the page we just added */ GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor)); - gtk_notebook_set_page (GTK_NOTEBOOK (notebook->child), + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook->child), gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor))); } diff --git a/src/libgdl/gdl-dock-layout.c b/src/libgdl/gdl-dock-layout.c index c3b0a4dac..a0f0a3e3a 100644 --- a/src/libgdl/gdl-dock-layout.c +++ b/src/libgdl/gdl-dock-layout.c @@ -715,9 +715,9 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) /* connect signals */ glade_xml_signal_connect_data (gui, "on_load_button_clicked", - GTK_SIGNAL_FUNC (load_layout_cb), ui_data); + G_CALLBACK (load_layout_cb), ui_data); glade_xml_signal_connect_data (gui, "on_delete_button_clicked", - GTK_SIGNAL_FUNC (delete_layout_cb), ui_data); + G_CALLBACK (delete_layout_cb), ui_data); g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL); diff --git a/src/libgdl/gdl-dock-layout.h b/src/libgdl/gdl-dock-layout.h index 2ce5d13b3..82dce5de8 100644 --- a/src/libgdl/gdl-dock-layout.h +++ b/src/libgdl/gdl-dock-layout.h @@ -31,11 +31,11 @@ G_BEGIN_DECLS /* standard macros */ #define GDL_TYPE_DOCK_LAYOUT (gdl_dock_layout_get_type ()) -#define GDL_DOCK_LAYOUT(object) (GTK_CHECK_CAST ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayout)) -#define GDL_DOCK_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) -#define GDL_IS_DOCK_LAYOUT(object) (GTK_CHECK_TYPE ((object), GDL_TYPE_DOCK_LAYOUT)) -#define GDL_IS_DOCK_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_LAYOUT)) -#define GDL_DOCK_LAYOUT_GET_CLASS(object) (GTK_CHECK_GET_CLASS ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) +#define GDL_DOCK_LAYOUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayout)) +#define GDL_DOCK_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) +#define GDL_IS_DOCK_LAYOUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDL_TYPE_DOCK_LAYOUT)) +#define GDL_IS_DOCK_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_LAYOUT)) +#define GDL_DOCK_LAYOUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) /* data types & structures */ typedef struct _GdlDockLayout GdlDockLayout; diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 24ec72126..c67b4464b 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -702,6 +702,15 @@ gdl_switcher_class_init (GdlSwitcherClass *klass) GDL_TYPE_SWITCHER_STYLE, GDL_SWITCHER_STYLE_BOTH, G_PARAM_READWRITE)); + + gtk_rc_parse_string ("style \"gdl-button-style\"\n" + "{\n" + "GtkWidget::focus-padding = 1\n" + "GtkWidget::focus-line-width = 1\n" + "xthickness = 0\n" + "ythickness = 0\n" + "}\n" + "widget \"*.gdl-button\" style \"gdl-button-style\""); } static void @@ -743,6 +752,7 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, const gchar *tooltips, const gchar *stock_id, const GdkPixbuf *pixbuf_icon, gint switcher_id) { + GtkWidget *event_box; GtkWidget *button_widget; GtkWidget *hbox; GtkWidget *icon_widget; @@ -750,6 +760,8 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, GtkWidget *arrow; button_widget = gtk_toggle_button_new (); + gtk_widget_set_name (button_widget, "gdl-button"); + gtk_button_set_relief (GTK_BUTTON(button_widget), GTK_RELIEF_HALF); if (switcher->priv->show) gtk_widget_show (button_widget); g_signal_connect (button_widget, "toggled", @@ -779,8 +791,11 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, } gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); gtk_widget_show (label_widget); - gtk_widget_set_tooltip_text (button_widget, tooltips); - + + + gtk_widget_set_tooltip_text (button_widget, + tooltips); + switch (INTERNAL_MODE (switcher)) { case GDL_SWITCHER_STYLE_TEXT: gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); @@ -801,10 +816,10 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, switcher->priv->buttons = g_slist_append (switcher->priv->buttons, button_new (button_widget, label_widget, - icon_widget, + icon_widget, arrow, hbox, switcher_id)); + gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher)); - gtk_widget_queue_resize (GTK_WIDGET (switcher)); } -- cgit v1.2.3 From e7672f3910efca2b9be29d8f6362578cb16cf59e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jul 2011 19:44:28 +0100 Subject: Merge upstream GDL 2.24.0 changes (bzr r10434) --- src/libgdl/gdl-data-frame.c | 297 ------------------- src/libgdl/gdl-data-frame.h | 72 ----- src/libgdl/gdl-data-model-test.c | 240 ---------------- src/libgdl/gdl-data-model-test.h | 32 --- src/libgdl/gdl-data-model.c | 160 ----------- src/libgdl/gdl-data-model.h | 105 ------- src/libgdl/gdl-data-row.c | 604 --------------------------------------- src/libgdl/gdl-data-row.h | 90 ------ src/libgdl/gdl-data-view.c | 526 ---------------------------------- src/libgdl/gdl-data-view.h | 71 ----- src/libgdl/gdl-icons.c | 267 ----------------- src/libgdl/gdl-icons.h | 61 ---- src/libgdl/test-dataview.c | 43 --- 13 files changed, 2568 deletions(-) delete mode 100644 src/libgdl/gdl-data-frame.c delete mode 100644 src/libgdl/gdl-data-frame.h delete mode 100644 src/libgdl/gdl-data-model-test.c delete mode 100644 src/libgdl/gdl-data-model-test.h delete mode 100644 src/libgdl/gdl-data-model.c delete mode 100644 src/libgdl/gdl-data-model.h delete mode 100644 src/libgdl/gdl-data-row.c delete mode 100644 src/libgdl/gdl-data-row.h delete mode 100644 src/libgdl/gdl-data-view.c delete mode 100644 src/libgdl/gdl-data-view.h delete mode 100644 src/libgdl/gdl-icons.c delete mode 100644 src/libgdl/gdl-icons.h delete mode 100644 src/libgdl/test-dataview.c (limited to 'src') diff --git a/src/libgdl/gdl-data-frame.c b/src/libgdl/gdl-data-frame.c deleted file mode 100644 index d6fb19533..000000000 --- a/src/libgdl/gdl-data-frame.c +++ /dev/null @@ -1,297 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-i18n.h" -#include "gdl-tools.h" -#include - -#include "gdl-data-view.h" -#include "gdl-data-frame.h" -#include "gdl-data-model.h" -#include "gdl-data-row.h" - -struct _GdlDataFramePrivate { - GdkRectangle shadow_r; - GdkRectangle frame_r; - GdkRectangle titlebar_r; - GdkRectangle title_r; - GdkRectangle close_r; - GdkRectangle row_r; - - int shadow_offset; - int titlebar_height; - char *title; - - GdlDataRow *row; - - PangoLayout *layout; - - gboolean selected; -}; - -static void gdl_data_frame_class_init (GdlDataFrameClass *klass); -static void gdl_data_frame_instance_init (GdlDataFrame *obj); -static void gdl_data_frame_finalize (GObject *object); - -GDL_CLASS_BOILERPLATE (GdlDataFrame, gdl_data_frame, GObject, G_TYPE_OBJECT); - -#define PAD 2 -#define BORDER 1 - -#define CENTERY(r1, r2) { r1.y = ((r2.y + (r2.height / 2)) - (r1.height / 2)); } - -void -gdl_data_frame_layout (GdlDataFrame *frame) -{ - GdkPixbuf *close_pixbuf; - /* Sizes */ - if (frame->priv->row) { - gdl_data_row_get_size (frame->priv->row, - NULL, NULL, - &frame->priv->row_r.width, - &frame->priv->row_r.height); - } else { - frame->priv->row_r.height = frame->priv->row_r.width = 0; - } - - if (frame->priv->layout) { - pango_layout_get_pixel_size (frame->priv->layout, - &frame->priv->title_r.width, - &frame->priv->title_r.height); - } else { - frame->priv->title_r.width = frame->priv->title_r.height = 0; - } - - close_pixbuf = gdl_data_view_get_close_pixbuf (frame->view); - if (close_pixbuf) { - frame->priv->close_r.width = - gdk_pixbuf_get_width (close_pixbuf); - frame->priv->close_r.height = - gdk_pixbuf_get_width (close_pixbuf); - } else { - frame->priv->close_r.width = frame->priv->close_r.height = 0; - } - - frame->priv->titlebar_r.height = MAX (frame->priv->titlebar_height, - frame->priv->title_r.height); - frame->priv->titlebar_r.height = MAX (frame->priv->titlebar_r.height, - frame->priv->close_r.height); - - frame->priv->frame_r.width = 2 * BORDER + 3 * PAD + frame->priv->title_r.width + frame->priv->close_r.width; - frame->priv->frame_r.width = MAX (frame->priv->frame_r.width, - frame->priv->row_r.width + 2 * BORDER + 2 * PAD); - frame->priv->frame_r.height = frame->priv->row_r.height + frame->priv->titlebar_r.height + 2 * PAD + 2 * BORDER; - frame->priv->titlebar_r.width = frame->priv->frame_r.width - BORDER; - frame->priv->shadow_r.width = frame->priv->frame_r.width; - frame->priv->shadow_r.height = frame->priv->frame_r.height; - - /* Locations */ - frame->priv->frame_r.x = frame->area.x; - frame->priv->frame_r.y = frame->area.y; - - frame->priv->shadow_r.x = frame->priv->frame_r.x + frame->priv->shadow_offset; - frame->priv->shadow_r.y = frame->priv->frame_r.y + frame->priv->shadow_offset; - frame->priv->titlebar_r.x = frame->priv->frame_r.x + BORDER; - frame->priv->titlebar_r.y = frame->priv->frame_r.y + BORDER; - frame->priv->title_r.x = frame->priv->frame_r.x + BORDER + PAD; - CENTERY (frame->priv->title_r, frame->priv->titlebar_r); - frame->priv->close_r.x = (frame->priv->frame_r.x + frame->priv->frame_r.width) - (frame->priv->close_r.width + BORDER + PAD); - CENTERY (frame->priv->close_r, frame->priv->titlebar_r); - - if (frame->priv->row) { - frame->priv->row_r.x = frame->priv->frame_r.x + BORDER + PAD; - frame->priv->row_r.y = frame->priv->titlebar_r.y + frame->priv->titlebar_r.height + PAD; - gdl_data_row_layout (frame->priv->row, &frame->priv->row_r); - } else { - frame->priv->row_r.x = frame->priv->row_r.y = 0; - } - - frame->area.width = frame->priv->frame_r.width + frame->priv->shadow_offset; - frame->area.height = frame->priv->frame_r.height + frame->priv->shadow_offset; -} - -#if 0 /* not used */ -static void -change_layout (GdlDataFrame *frame) -{ - char *text = frame->priv->title ? frame->priv->title : "?"; - pango_layout_set_text (frame->priv->layout, text, strlen (text)); -} -#endif - -#define EXPLODE(r) (r).x, (r).y, (r).width, (r).height - -void -gdl_data_frame_draw (GdlDataFrame *frame, GdkDrawable *drawable, - GdkRectangle *expose_area) -{ - GdkRectangle inter; - guint8 state = - frame->priv->selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL; - - gdk_draw_rectangle (drawable, - GTK_WIDGET (frame->view)->style->dark_gc[state], - TRUE, - EXPLODE (frame->priv->shadow_r)); - gdk_draw_rectangle (drawable, - GTK_WIDGET (frame->view)->style->base_gc[GTK_STATE_NORMAL], - TRUE, - EXPLODE (frame->priv->frame_r)); - gdk_draw_rectangle (drawable, - GTK_WIDGET (frame->view)->style->black_gc, - FALSE, - EXPLODE (frame->priv->frame_r)); - gdk_draw_rectangle (drawable, - GTK_WIDGET (frame->view)->style->bg_gc[state], - TRUE, - EXPLODE (frame->priv->titlebar_r)); - gdk_draw_layout (drawable, - GTK_WIDGET (frame->view)->style->fg_gc[state], - frame->priv->title_r.x, frame->priv->title_r.y, - frame->priv->layout); - - if (gdk_rectangle_intersect (expose_area, &frame->priv->close_r, &inter)) { - GdkPixbuf *pixbuf = gdl_data_view_get_close_pixbuf (frame->view); - gdk_draw_pixbuf (drawable, NULL, pixbuf, - 0, 0, - inter.x - frame->priv->close_r.x, - inter.y - frame->priv->close_r.y, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NORMAL, 0, 0); - } - - if (frame->priv->row) { - if (gdk_rectangle_intersect (expose_area, &frame->priv->row_r, - &inter)) { - gdl_data_row_render (frame->priv->row, drawable, - &inter, - frame->priv->selected ? GTK_CELL_RENDERER_SELECTED : 0); - } - } -} - -void -gdl_data_frame_class_init (GdlDataFrameClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *)klass; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->finalize = gdl_data_frame_finalize; -} - -void -gdl_data_frame_instance_init (GdlDataFrame *frame) -{ - frame->priv = g_new0 (GdlDataFramePrivate, 1); - frame->area.x = frame->area.y = 0; - frame->priv->shadow_offset = 3; - frame->priv->titlebar_height = 20; - - frame->area.height = frame->area.width = 100; -} - -void -gdl_data_frame_finalize (GObject *object) -{ - GdlDataFrame *frame = GDL_DATA_FRAME (object); - - if (frame->priv) { - g_free (frame->priv->title); - g_object_unref (frame->priv->layout); - g_object_unref (frame->priv->row); - - g_free (frame->priv); - frame->priv = NULL; - } - GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -void -gdl_data_frame_set_selected (GdlDataFrame *frame, - gboolean val) -{ - frame->priv->selected = val; - - gdk_window_invalidate_rect (GTK_LAYOUT (frame->view)->bin_window, - &frame->priv->frame_r, - TRUE); -} - -gboolean -gdl_data_frame_button_press (GdlDataFrame *frame, - GdkEventButton *event) -{ - return FALSE; -} - -void -gdl_data_frame_set_position (GdlDataFrame *frame, - int x, - int y) -{ - frame->area.x = x; - frame->area.y = y; - - gdl_data_frame_layout (frame); -} - -static void -setup_layout (GdlDataFrame *frame) -{ - PangoFontDescription *font_desc = - pango_font_description_copy (GTK_WIDGET (frame->view)->style->font_desc); - - pango_font_description_set_weight (font_desc, - PANGO_WEIGHT_BOLD); - - frame->priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (frame->view), - frame->priv->title ? frame->priv->title : "?"); - pango_layout_set_font_description (frame->priv->layout, - font_desc); - pango_font_description_free (font_desc); -} - - -GdlDataFrame * -gdl_data_frame_new (GdlDataView *view, - GdlDataRow *row) -{ - GdlDataFrame *frame; - frame = GDL_DATA_FRAME (g_object_new (GDL_TYPE_DATA_FRAME, NULL)); - - frame->view = view; - - frame->priv->row = row; - frame->priv->title = g_strdup (gdl_data_row_get_title (row)); - - setup_layout (frame); - - gdl_data_frame_layout (frame); - - return frame; -} diff --git a/src/libgdl/gdl-data-frame.h b/src/libgdl/gdl-data-frame.h deleted file mode 100644 index 7daeb5b12..000000000 --- a/src/libgdl/gdl-data-frame.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef GDL_DATA_FRAME_H -#define GDL_DATA_FRAME_H - -#include -#include - -G_BEGIN_DECLS - -#define GDL_TYPE_DATA_FRAME (gdl_data_frame_get_type ()) -#define GDL_DATA_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrame)) -#define GDL_DATA_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_DATA_VIEW_FRAM, GdlDataFrame)) -#define GDL_IS_DATA_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_FRAME)) -#define GDL_IS_DATA_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_FRAME)) -#define GDL_DATA_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DATA_FRAME, GdlDataFrameClass)) - -typedef struct _GdlDataFrame GdlDataFrame; -typedef struct _GdlDataFramePrivate GdlDataFramePrivate; -typedef struct _GdlDataFrameClass GdlDataFrameClass; - -struct _GdlDataFrame { - GObject parent; - - GdlDataView *view; - GdkRectangle area; - - GdlDataFramePrivate *priv; -}; - -struct _GdlDataFrameClass { - GObjectClass parent_class; -}; - -GType gdl_data_frame_get_type (void); -GdlDataFrame *gdl_data_frame_new (GdlDataView *view, - GdlDataRow *row); -void gdl_data_frame_layout (GdlDataFrame *frame); -void gdl_data_frame_draw (GdlDataFrame *item, - GdkDrawable *drawable, - GdkRectangle *expose_area); -void gdl_data_frame_set_selected (GdlDataFrame *frame, - gboolean val); -gboolean gdl_data_frame_button_press (GdlDataFrame *frame, - GdkEventButton *event); -void gdl_data_frame_set_position (GdlDataFrame *frame, - int x, - int y); - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-data-model-test.c b/src/libgdl/gdl-data-model-test.c deleted file mode 100644 index ec6ed4d50..000000000 --- a/src/libgdl/gdl-data-model-test.c +++ /dev/null @@ -1,240 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-i18n.h" - -#include "gdl-data-model-test.h" -#include "gdl-data-model.h" - -#include -#include -#include - -GObjectClass *parent_class; - -typedef struct _DataItem { - char *name; - char *value; - char *path; - struct _DataItem *children; -} DataItem; - -DataItem data1[] = { - { "foo1", "foo1", "0:0", NULL}, - { "bar1", "bar1", "0:1", NULL }, - { "baz1", "baz1", "0:2", NULL }, - { NULL, NULL, NULL, NULL } - -}; -DataItem data2[] = { - { "foo2", "foo2", "1:0", NULL }, - { "bar2", "bar2", "1:1", NULL }, - { "baz2", "baz2", "1:2", NULL }, - { NULL, NULL, NULL, NULL } - -}; - -DataItem data5[] = { - { "1", "1", "2:2:1:0", NULL }, - { "2", "2", "2:2:1:1", NULL }, - { "3", "3", "2:2:1:2", NULL }, - { "4", "4", "2:2:1:3", NULL }, - { "5", "5", "2:2:1:4", NULL }, - { "6", "6", "2:2:1:5", NULL }, - { NULL, NULL, NULL, NULL } - -}; -DataItem data4[] = { - { "foo4", "foo4", "2:2:0", NULL }, - { "bar4", "[...]", "2:2:1", data5 }, - { "baz4", "baz4", "2:2:2", NULL }, - { NULL, NULL, NULL, NULL } - -}; -DataItem data3[] = { - { "foo foo", "foo3", "2:0", NULL }, - { "bar3", "1", "2:1", NULL }, - { "baz3", "{...}", "2:2", data4 }, - { NULL, NULL, NULL, NULL } - -}; - -DataItem root[] = { - { "test-data", "value1", "0", NULL } , - { "test-data2", "value2", "1", NULL } , - { "test-data3", "{...}", "2", data3 } , - { NULL, NULL, NULL } -}; - -static gboolean -get_iter (GdlDataModel *dm, GdlDataIter *iter, GtkTreePath *path) -{ - int *i = gtk_tree_path_get_indices (path); - int n = gtk_tree_path_get_depth (path); - DataItem *item; - - g_assert (i); - item = &root[*i++]; - - while (--n) { - item = &item->children[*i++]; - } - - iter->data1 = item; - - return TRUE; -} - -static GtkTreePath * -get_path (GdlDataModel *dm, GdlDataIter *iter) -{ - DataItem *item = iter->data1; - return gtk_tree_path_new_from_string (item->path); -} - -static void -get_name (GdlDataModel *dm, GdlDataIter *iter, char **name) -{ - DataItem *item = iter->data1; - *name = item->name; -} - -static void -get_value (GdlDataModel *dm, GdlDataIter *iter, GValue *value) -{ - DataItem *item = iter->data1; - if (strcmp (item->name, "bar3")) { - g_value_init (value, G_TYPE_STRING); - g_value_set_string (value, item->value); - } else { - g_value_init (value, G_TYPE_BOOLEAN); - g_value_set_boolean (value, !strcmp (item->value, "1")); - } -} - -static void -get_renderer (GdlDataModel *dm, GdlDataIter *iter, - GtkCellRenderer **renderer, char **field, - gboolean *is_editable) -{ - DataItem *item = iter->data1; - if (!strcmp (item->name, "bar3")) { - *renderer = g_object_new (gtk_cell_renderer_toggle_get_type (), - "activatable", TRUE, NULL); - *field = "active"; - } else { - *renderer = g_object_new (gtk_cell_renderer_text_get_type (), - "editable", TRUE, NULL); - *field = "text"; - } - *is_editable = (item->children == NULL); -} - -static gboolean -iter_next (GdlDataModel *dm, GdlDataIter *iter) -{ - DataItem *item = iter->data1; - item++; - if (item->name) { - iter->data1 = item; - return TRUE; - } else { - return FALSE; - } -} - -static gboolean -iter_children (GdlDataModel *dm, GdlDataIter *iter, GdlDataIter *parent) -{ - DataItem *item = parent->data1; - - item = &item->children[0]; - if (item) { - iter->data1 = item; - return TRUE; - } else { - return FALSE; - } -} - -static gboolean -iter_has_child (GdlDataModel *dm, GdlDataIter *iter) -{ - DataItem *item = iter->data1; - if (item->children) { - return TRUE; - } else { - return FALSE; - } -} - - -static void -gdl_data_model_test_instance_init (GdlDataModelTest *model) -{ -} - -static void -gdl_data_model_test_finalize (GObject *object) -{ - (*parent_class->finalize) (object); -} - -static void -gdl_data_model_test_class_init (GdlDataModelTestClass *klass) -{ - GObjectClass *object_class; - parent_class = g_type_class_peek_parent (klass); - object_class = (GObjectClass *)klass; - object_class->finalize = gdl_data_model_test_finalize; -} - -static void -gdl_data_model_test_data_model_init (GdlDataModelIface *iface) -{ - iface->get_iter = get_iter; - iface->get_path = get_path; - iface->get_name = get_name; - iface->get_value = get_value; - iface->get_renderer = get_renderer; - iface->iter_next = iter_next; - iface->iter_children = iter_children; - iface->iter_has_child = iter_has_child; -} - -GType -gdl_data_model_test_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo data_model_test_info = { - sizeof (GdlDataModelTestClass), - NULL, NULL, - (GClassInitFunc) gdl_data_model_test_class_init, - NULL, NULL, - sizeof (GdlDataModelTest), 0, - (GInstanceInitFunc) gdl_data_model_test_instance_init - }; - - static const GInterfaceInfo data_model_info = { - (GInterfaceInitFunc) gdl_data_model_test_data_model_init, - NULL, NULL - }; - - type = g_type_register_static (G_TYPE_OBJECT, - "GdlDataModelTest", - &data_model_test_info, 0); - g_type_add_interface_static (type, - GDL_TYPE_DATA_MODEL, - &data_model_info); - } - return type; -} - -GdlDataModelTest * -gdl_data_model_test_new (void) -{ - return GDL_DATA_MODEL_TEST (g_object_new (gdl_data_model_test_get_type (), NULL)); -} diff --git a/src/libgdl/gdl-data-model-test.h b/src/libgdl/gdl-data-model-test.h deleted file mode 100644 index c8add8daf..000000000 --- a/src/libgdl/gdl-data-model-test.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef GDL_DATA_MODEL_TEST_H -#define GDL_DATA_MODEL_TEST_H - -#include -#include "gdl-data-model.h" - -G_BEGIN_DECLS - -#define GDL_TYPE_DATA_MODEL_TEST (gdl_data_model_test_get_type ()) -#define GDL_DATA_MODEL_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_MODEL_TEST, GdlDataModelTest)) -#define GDL_IS_DATA_MODEL_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_MODEL_TEST)) - - -typedef struct _GdlDataModelTest GdlDataModelTest; -typedef struct _GdlDataModelTestClass GdlDataModelTestClass; - -struct _GdlDataModelTest { - GObject parent; - - int stamp; -}; - -struct _GdlDataModelTestClass { - GObjectClass parent_class; -}; - -GType gdl_data_model_test_get_type (void); -GdlDataModelTest *gdl_data_model_test_new (void); - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-data-model.c b/src/libgdl/gdl-data-model.c deleted file mode 100644 index 69fbb93d5..000000000 --- a/src/libgdl/gdl-data-model.c +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-data-model.h" - -gboolean -gdl_data_model_get_iter (GdlDataModel *dm, - GdlDataIter *iter, - GtkTreePath *path) -{ - g_return_val_if_fail (dm != NULL, FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_iter != NULL, - FALSE); - - return (*GDL_DATA_MODEL_GET_IFACE (dm)->get_iter) (dm, iter, path); -} - -GtkTreePath * -gdl_data_model_get_path (GdlDataModel *dm, - GdlDataIter *iter) -{ - g_return_val_if_fail (dm != NULL, NULL); - g_return_val_if_fail (iter != NULL, NULL); - g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_path != NULL, - NULL); - - return (*GDL_DATA_MODEL_GET_IFACE (dm)->get_path) (dm, iter); -} - -void -gdl_data_model_get_name (GdlDataModel *dm, - GdlDataIter *iter, - char **name) -{ - g_return_if_fail (dm != NULL); - g_return_if_fail (iter != NULL); - g_return_if_fail (name != NULL); - g_return_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_name != NULL); - - (*GDL_DATA_MODEL_GET_IFACE (dm)->get_name) (dm, iter, name); -} - -void -gdl_data_model_get_value (GdlDataModel *dm, - GdlDataIter *iter, - GValue *value) -{ - g_return_if_fail (dm != NULL); - g_return_if_fail (iter != NULL); - g_return_if_fail (value != NULL); - g_return_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_value != NULL); - - (*GDL_DATA_MODEL_GET_IFACE (dm)->get_value) (dm, iter, value); -} - -void -gdl_data_model_get_renderer (GdlDataModel *dm, - GdlDataIter *iter, - GtkCellRenderer **renderer, - char **field, - gboolean *is_editable) -{ - g_return_if_fail (dm != NULL); - g_return_if_fail (iter != NULL); - g_return_if_fail (renderer != NULL); - g_return_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->get_renderer != NULL); - - (*GDL_DATA_MODEL_GET_IFACE (dm)->get_renderer) (dm, iter, - renderer, field, - is_editable); -} - -gboolean -gdl_data_model_iter_next (GdlDataModel *dm, - GdlDataIter *iter) -{ - g_return_val_if_fail (dm != NULL, FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->iter_next != NULL, FALSE); - - return (*GDL_DATA_MODEL_GET_IFACE (dm)->iter_next) (dm, iter); -} - -gboolean -gdl_data_model_iter_children (GdlDataModel *dm, - GdlDataIter *iter, - GdlDataIter *parent) -{ - g_return_val_if_fail (dm != NULL, FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->iter_children != NULL, FALSE); - - return (*GDL_DATA_MODEL_GET_IFACE (dm)->iter_children) (dm, iter, parent); -} - -gboolean -gdl_data_model_iter_has_child (GdlDataModel *dm, - GdlDataIter *iter) -{ - g_return_val_if_fail (dm != NULL, FALSE); - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (GDL_DATA_MODEL_GET_IFACE (dm)->iter_has_child != NULL, FALSE); - - return (*GDL_DATA_MODEL_GET_IFACE (dm)->iter_has_child) (dm, iter); -} - -static void -gdl_data_model_base_init (gpointer g_class) -{ - static gboolean initialized = FALSE; - - if (!initialized) { - } -} - -GType -gdl_data_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (GdlDataModelIface), - gdl_data_model_base_init, - NULL, NULL, NULL, NULL, 0, 0, NULL - }; - - type = g_type_register_static (G_TYPE_INTERFACE, - "GdlDataModel", - &info, 0); - g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); - } - - return type; -} diff --git a/src/libgdl/gdl-data-model.h b/src/libgdl/gdl-data-model.h deleted file mode 100644 index 521a65d0c..000000000 --- a/src/libgdl/gdl-data-model.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef GDL_DATA_MODEL_H -#define GDL_DATA_MODEL_H - -#include -#include - -/* Using GtkTreePath to save time */ -#include -#include - -G_BEGIN_DECLS - -#define GDL_TYPE_DATA_MODEL (gdl_data_model_get_type ()) -#define GDL_DATA_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_MODEL, GdlDataModel)) -#define GDL_IS_DATA_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_MODEL)) -#define GDL_DATA_MODEL_GET_IFACE(obj) ((GdlDataModelIface *)g_type_interface_peek (((GTypeInstance *)GDL_DATA_MODEL (obj))->g_class, GDL_TYPE_DATA_MODEL)) - -typedef struct _GdlDataModel GdlDataModel; -typedef struct _GdlDataIter GdlDataIter; -typedef struct _GdlDataModelIface GdlDataModelIface; - -struct _GdlDataIter { - int stamp; - - gpointer data1; - gpointer data2; - gpointer data3; -}; - -struct _GdlDataModelIface { - GTypeInterface g_iface; - - /* Signals */ - void (*path_changed) (GdlDataModel *dm, GtkTreePath *path); - void (*path_inserted) (GdlDataModel *dm, GtkTreePath *path); - void (*path_deleted) (GdlDataModel *dm, GtkTreePath *path); - - /* Virtual Table */ - gboolean (*get_iter) (GdlDataModel *dm, GdlDataIter *iter, - GtkTreePath *path); - GtkTreePath* (*get_path) (GdlDataModel *dm, GdlDataIter *iter); - - void (*get_name) (GdlDataModel *dm, GdlDataIter *iter, - char **name); - void (*get_value) (GdlDataModel *dm, GdlDataIter *iter, - GValue *value); - void (*get_renderer) (GdlDataModel *dm, GdlDataIter *iter, - GtkCellRenderer **renderer, char **field, - gboolean *is_editable); - gboolean (*iter_next) (GdlDataModel *dm, GdlDataIter *iter); - gboolean (*iter_children) (GdlDataModel *dm, GdlDataIter *iter, - GdlDataIter *parent); - gboolean (*iter_has_child) (GdlDataModel *dm, GdlDataIter *iter); -}; - -GType gdl_data_model_get_type (void); -gboolean gdl_data_model_get_iter (GdlDataModel *dm, - GdlDataIter *iter, - GtkTreePath *path); -GtkTreePath *gdl_data_model_get_path (GdlDataModel *dm, - GdlDataIter *iter); -void gdl_data_model_get_name (GdlDataModel *dm, - GdlDataIter *iter, - char **name); -void gdl_data_model_get_value (GdlDataModel *dm, - GdlDataIter *iter, - GValue *value); -void gdl_data_model_get_renderer (GdlDataModel *dm, - GdlDataIter *iter, - GtkCellRenderer **renderer, - char **field, - gboolean *is_editable); -gboolean gdl_data_model_iter_next (GdlDataModel *dm, - GdlDataIter *iter); -gboolean gdl_data_model_iter_children (GdlDataModel *dm, - GdlDataIter *iter, - GdlDataIter *children); -gboolean gdl_data_model_iter_has_child (GdlDataModel *dm, - GdlDataIter *iter); - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-data-row.c b/src/libgdl/gdl-data-row.c deleted file mode 100644 index 666c658fe..000000000 --- a/src/libgdl/gdl-data-row.c +++ /dev/null @@ -1,604 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-i18n.h" -#include "gdl-tools.h" -#include "gdl-data-row.h" -#include "gdl-data-model.h" - -#include -#include - -struct _GdlDataRowPrivate { - GdlDataModel *model; - GtkTreePath *path; - GdlDataView *view; - - char *name; - - /* area_r - * +- title_r - * | +- name_r - * | +- sep_r - * +- data_r - * +- expand_r - * +- cell_r - */ - - GdkRectangle area_r; - - GdkRectangle title_r; - GdkRectangle name_r; - GdkRectangle sep_r; - - GdkRectangle data_r; - GdkRectangle expand_r; - GdkRectangle cell_r; - - gboolean multi; - GtkCellRenderer *cell; - GList *subrows; - - char *renderer_field; - - gboolean expanded; - gboolean focused; - gboolean editable; - - int split; - int child_split; - gboolean selected; -}; - -GDL_CLASS_BOILERPLATE (GdlDataRow, gdl_data_row, GObject, G_TYPE_OBJECT); - - -static void -expand (GdlDataRow *row) -{ - GdlDataIter iter; - gboolean valid; - - if (gdl_data_model_get_iter (row->priv->model, &iter, row->priv->path)) { - valid = gdl_data_model_iter_children (row->priv->model, - &iter, &iter); - while (valid) { - GdlDataRow *new_row; - GtkTreePath *path; - - path = gdl_data_model_get_path (row->priv->model, - &iter); - new_row = gdl_data_row_new (row->priv->view, - path); - row->priv->subrows = - g_list_prepend (row->priv->subrows, new_row); - gtk_tree_path_free (path); - - valid = gdl_data_model_iter_next (row->priv->model, - &iter); - } - row->priv->subrows = g_list_reverse (row->priv->subrows); - - row->priv->expanded = TRUE; - gdl_data_view_layout (GDL_DATA_VIEW (row->priv->view)); - gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); - } -} - -static void -contract (GdlDataRow *row) -{ - GList *l; - for (l = row->priv->subrows; l != NULL; l = l->next) { - g_object_unref (G_OBJECT (l->data)); - } - g_list_free (row->priv->subrows); - row->priv->subrows = NULL; - - row->priv->expanded = FALSE; - gdl_data_view_layout (GDL_DATA_VIEW (row->priv->view)); - gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); -} - -static void -load_path (GdlDataRow *row) -{ - GdlDataIter iter; - - /* Make sure the path has been unloaded */ - g_return_if_fail (row->priv->name == NULL); - g_return_if_fail (row->priv->cell == NULL); - - if (gdl_data_model_get_iter (row->priv->model, - &iter, row->priv->path)) { - GValue val = { 0, }; - char *str; - - gdl_data_model_get_name (row->priv->model, &iter, - &str); - row->priv->name = g_strdup (str); - - if (gdl_data_model_iter_has_child (row->priv->model, &iter)) { - row->priv->multi = TRUE; - } - - gdl_data_model_get_renderer (row->priv->model, &iter, - &row->priv->cell, - &str, - &row->priv->editable); - g_object_ref (GTK_OBJECT (row->priv->cell)); - gtk_object_sink (GTK_OBJECT (row->priv->cell)); - - row->priv->renderer_field = g_strdup (str); - gdl_data_model_get_value (row->priv->model, &iter, &val); - - g_object_set_property (G_OBJECT (row->priv->cell), - row->priv->renderer_field, - &val); - g_value_unset (&val); - } -} - -static void -unload_path (GdlDataRow *row) -{ - if (row->priv->renderer_field) { - g_free (row->priv->renderer_field); - row->priv->renderer_field = NULL; - } - - if (row->priv->name) { - g_free (row->priv->name); - row->priv->name = NULL; - } - - if (row->priv->cell) { - g_object_unref (row->priv->cell); - row->priv->cell = NULL; - } - - if (row->priv->subrows) { - GList *l; - for (l = row->priv->subrows; l != NULL; l = l->next) { - g_object_unref (G_OBJECT (l->data)); - } - g_list_free (row->priv->subrows); - row->priv->subrows = NULL; - } -} - -static void -gdl_data_row_instance_init (GdlDataRow *row) -{ - row->priv = g_new0 (GdlDataRowPrivate, 1); -} - -static void -gdl_data_row_finalize (GObject *object) -{ - GdlDataRow *row = GDL_DATA_ROW (object); - if (row->priv) { - unload_path (row); - - if (row->priv->path) { - gtk_tree_path_free (row->priv->path); - row->priv->path = NULL; - } - - - g_object_unref (row->priv->model); - - g_free (row->priv); - row->priv = NULL; - } -} - -static void -gdl_data_row_class_init (GdlDataRowClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass*) klass; - gobject_class->finalize = gdl_data_row_finalize; - - parent_class = g_type_class_peek_parent (klass); -} - -GdlDataRow * -gdl_data_row_new (GdlDataView *view, - GtkTreePath *path) -{ - GdlDataRow *row; - - row = GDL_DATA_ROW (g_object_new (gdl_data_row_get_type (), - NULL)); - - row->priv->view = view; - row->priv->model = g_object_ref (view->model); - row->priv->path = gtk_tree_path_copy (path); - load_path (row); - - return row; -} - - -#define PAD 3 - -static void -layout_row (GdlDataRow *row, - int x, int y, int width, int height) -{ - PangoLayout *layout; - - /* sizes */ - - layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), - row->priv->name); - pango_layout_get_pixel_size (layout, - &row->priv->name_r.width, - &row->priv->name_r.height); - g_object_unref (layout); - - layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), "="); - pango_layout_get_pixel_size (layout, - &row->priv->sep_r.width, - &row->priv->sep_r.height); - g_object_unref (layout); - - row->priv->title_r.width = - MAX (row->priv->name_r.width + row->priv->sep_r.width + PAD, - row->priv->split); - row->priv->title_r.height = - MAX (row->priv->name_r.height, row->priv->sep_r.width); - - if (row->priv->cell) { - gtk_cell_renderer_get_size (row->priv->cell, - GTK_WIDGET (row->priv->view), - NULL, NULL, NULL, - &row->priv->cell_r.width, - &row->priv->cell_r.height); - } else { - row->priv->cell_r.width = row->priv->cell_r.height = 0; - } - - row->priv->data_r.width = row->priv->cell_r.width; - row->priv->data_r.height = row->priv->cell_r.height; - - if (row->priv->multi) { - row->priv->expand_r.width = 10; - row->priv->expand_r.height = 10; - - row->priv->data_r.width += row->priv->expand_r.width; - row->priv->data_r.height = MAX (row->priv->expand_r.height, - row->priv->data_r.height); - - if (row->priv->expanded) { - GList *l; - int name_w = 0, data_w = 0; - for (l = row->priv->subrows; l != NULL; l = l->next) { - int w1, w2, h; - gdl_data_row_get_size (GDL_DATA_ROW (l->data), - &w1, &w2, NULL, &h); - name_w = MAX (name_w, w1); - data_w = MAX (data_w, w2); - row->priv->data_r.height += h; - } - row->priv->child_split = name_w; - row->priv->data_r.width = - MAX (name_w + data_w + 3 * PAD, - row->priv->data_r.width); - row->priv->data_r.height += 2 * PAD; - } - } - - row->priv->area_r.width = MAX (width, - row->priv->data_r.width + row->priv->title_r.width + PAD); - - row->priv->area_r.height = MAX (height, - (MAX (row->priv->data_r.height, - row->priv->title_r.height))); - - /* Positions */ - - row->priv->area_r.x = x; - row->priv->area_r.y = y; - - row->priv->title_r.x = x; - row->priv->title_r.y = y + ((row->priv->area_r.height) / 2) - (row->priv->title_r.height / 2); - - row->priv->name_r.x = x; - row->priv->name_r.y = y + ((row->priv->area_r.height) / 2) - (row->priv->name_r.height / 2); - - row->priv->sep_r.x = row->priv->title_r.x + row->priv->title_r.width - row->priv->sep_r.width; - row->priv->sep_r.y = y + ((row->priv->area_r.height) / 2) - (row->priv->sep_r.height / 2); - - row->priv->data_r.x = row->priv->title_r.x + row->priv->title_r.width + PAD; - row->priv->data_r.y = y; - - /* Readjust the data area size to fit */ - row->priv->data_r.width = row->priv->area_r.width - (row->priv->title_r.width + PAD); - row->priv->data_r.height = row->priv->area_r.height; - - if (row->priv->multi) { - row->priv->expand_r.x = row->priv->data_r.x; - row->priv->expand_r.y = row->priv->data_r.y + ((row->priv->cell_r.height) / 2) - (row->priv->expand_r.height / 2); - - row->priv->cell_r.y = row->priv->data_r.y; - row->priv->cell_r.height = MAX (row->priv->expand_r.height, row->priv->cell_r.height); - row->priv->cell_r.width = (row->priv->data_r.width - row->priv->expand_r.width); - - row->priv->cell_r.x = row->priv->expand_r.x + row->priv->expand_r.width; - } else { - row->priv->cell_r = row->priv->data_r; - } -} - -void -gdl_data_row_get_size (GdlDataRow *row, int *sep_width, - int *cell_width, int *total_width, int *height) -{ - layout_row (row, 0, 0, 0, 0); - - if (sep_width) { - *sep_width = row->priv->name_r.width + row->priv->sep_r.width + PAD; - } - - if (cell_width) *cell_width = row->priv->data_r.width; - if (total_width) *total_width = row->priv->area_r.width; - if (height) *height = row->priv->area_r.height; -} - -void -gdl_data_row_set_show_name (GdlDataRow *row, gboolean show_name) -{ -} - -void -gdl_data_row_layout (GdlDataRow *row, GdkRectangle *alloc) -{ - layout_row (row, alloc->x, alloc->y, alloc->width, alloc->height); - - if (row->priv->multi && row->priv->expanded) { - GList *l; - GdkRectangle sub; - sub.y = row->priv->expand_r.y + row->priv->expand_r.width + PAD; - sub.x = row->priv->data_r.x + PAD; - sub.width = row->priv->data_r.width - 2 * PAD; - sub.height = row->priv->data_r.height - 2 * PAD; - - for (l = row->priv->subrows; l != NULL; l = l->next) { - gdl_data_row_get_size (GDL_DATA_ROW (l->data), - NULL, NULL, NULL, &sub.height); - gdl_data_row_set_split (GDL_DATA_ROW (l->data), - row->priv->child_split); - gdl_data_row_layout (GDL_DATA_ROW (l->data), - &sub); - sub.y += sub.height; - } - } -} - -#if 0 -#define DRAWR(r) { gdk_draw_rectangle (drawable, GTK_WIDGET (row->priv->view)->style->text_gc[GTK_STATE_NORMAL],FALSE,row->priv->r.x,row->priv->r.y,row->priv->r.width, row->priv->r.height); } -#else -#define DRAWR(r) -#endif - - -void -gdl_data_row_render (GdlDataRow *row, GdkDrawable *drawable, - GdkRectangle *expose_area, - GtkCellRendererState flags) -{ - PangoLayout *layout; - - guint state = GTK_STATE_NORMAL; - - if (row->priv->selected) { - if (flags & GTK_CELL_RENDERER_SELECTED) - state = GTK_STATE_SELECTED; - else - state = GTK_STATE_ACTIVE; - gtk_paint_flat_box (GTK_WIDGET (row->priv->view)->style, - drawable, state, - GTK_SHADOW_NONE, expose_area, - GTK_WIDGET (row->priv->view), "cell_even", - row->priv->area_r.x, row->priv->area_r.y, - row->priv->area_r.width + 1, - row->priv->area_r.height + 1); - - } - - layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), - row->priv->name); - gdk_draw_layout (drawable, - GTK_WIDGET (row->priv->view)->style->text_gc[state], - row->priv->name_r.x, row->priv->name_r.y, layout); - g_object_unref (layout); - DRAWR(name_r); - - layout = gtk_widget_create_pango_layout (GTK_WIDGET (row->priv->view), "="); - gdk_draw_layout (drawable, - GTK_WIDGET (row->priv->view)->style->text_gc[state], - row->priv->sep_r.x, row->priv->sep_r.y, layout); - g_object_unref (layout); - DRAWR(sep_r); - DRAWR(title_r); - - if (row->priv->cell) { - if (row->priv->focused) { - gtk_paint_focus (GTK_WIDGET (row->priv->view)->style, - drawable, - GTK_WIDGET_STATE (GTK_WIDGET (row->priv->view)), - NULL, GTK_WIDGET (row->priv->view), - "treeview", - row->priv->cell_r.x - 1, - row->priv->cell_r.y - 1, - row->priv->cell_r.width + 2, - row->priv->cell_r.height + 2); - } - - gtk_cell_renderer_render (row->priv->cell, - drawable, GTK_WIDGET (row->priv->view), - &row->priv->area_r, - &row->priv->cell_r, - expose_area, - row->priv->selected ? GTK_CELL_RENDERER_SELECTED : 0); - DRAWR(cell_r); - } - if (row->priv->multi) { - gtk_paint_expander (GTK_WIDGET (row->priv->view)->style, - drawable, - GTK_WIDGET_STATE (GTK_WIDGET (row->priv->view)), - expose_area, - GTK_WIDGET (row->priv->view), - "gdldataview", - row->priv->expand_r.x + row->priv->expand_r.width / 2, - row->priv->expand_r.y + row->priv->expand_r.height / 2, - row->priv->expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED); - DRAWR(expand_r); - - if (row->priv->expanded) { - GList *l; - - for (l = row->priv->subrows; l != NULL; l = l->next) { - gdl_data_row_render (GDL_DATA_ROW (l->data), - drawable, - expose_area, flags); - } - } - gdk_draw_rectangle (drawable, - GTK_WIDGET (row->priv->view)->style->text_gc[GTK_STATE_NORMAL], - FALSE, - row->priv->data_r.x, - row->priv->data_r.y, - row->priv->data_r.width, - row->priv->data_r.height); - } - DRAWR(data_r); -} - - -GdlDataRow * -gdl_data_row_at (GdlDataRow *row, int x, int y) -{ - if (!GDL_POINT_IN (x, y, &row->priv->area_r)) { - return NULL; - } - - if (row->priv->multi && row->priv->expanded) { - GList *l; - for (l = row->priv->subrows; l != NULL; l = l->next) { - GdlDataRow *ret = gdl_data_row_at (GDL_DATA_ROW (l->data), x, y); - if (ret) - return ret; - } - } - - return row; -} - -static gboolean -button_press_event (GdlDataRow *row, GdkEventButton *event, - GtkCellEditable **editable_widget) -{ - if (editable_widget) - *editable_widget = NULL; - - if (GDL_POINT_IN (event->x, event->y, &row->priv->expand_r)) { - if (row->priv->expanded) - contract (row); - else - expand (row); - } - - if (GDL_POINT_IN (event->x, event->y, &row->priv->cell_r) - && row->priv->editable) { - g_return_val_if_fail (editable_widget, FALSE); - *editable_widget = gtk_cell_renderer_start_editing - (row->priv->cell, - (GdkEvent*)event, - GTK_WIDGET (row->priv->view), - "1:2:3", - &row->priv->area_r, - &row->priv->cell_r, - GTK_CELL_RENDERER_SELECTED); - } - - return FALSE; - -} - - -gboolean -gdl_data_row_event (GdlDataRow *row, GdkEvent *event, - GtkCellEditable **editable_widget) -{ - switch (((GdkEventAny *)event)->type) { - case GDK_BUTTON_PRESS: - return button_press_event (row, - (GdkEventButton *)event, - editable_widget); - default: - break; - } - return FALSE; -} - -void -gdl_data_row_get_cell_area (GdlDataRow *row, - GdkRectangle *rect) -{ - *rect = row->priv->cell_r; -} - -void -gdl_data_row_set_split (GdlDataRow *row, int split) -{ - row->priv->split = split; -} - -void -gdl_data_row_set_selected (GdlDataRow *row, gboolean selected) -{ - row->priv->selected = selected; - - /* FIXME: invalidate here */ - gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); -} - -void -gdl_data_row_set_focused (GdlDataRow *row, gboolean focused) -{ - row->priv->focused = focused; - - /* FIXME: invalidate here */ - gtk_widget_queue_draw (GTK_WIDGET (row->priv->view)); -} - -const char * -gdl_data_row_get_title (GdlDataRow *row) -{ - return row->priv->name; -} diff --git a/src/libgdl/gdl-data-row.h b/src/libgdl/gdl-data-row.h deleted file mode 100644 index d4928958d..000000000 --- a/src/libgdl/gdl-data-row.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef GDL_DATA_ROW_H -#define GDL_DATA_ROW_H - -#include - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define GDL_TYPE_DATA_ROW (gdl_data_row_get_type ()) -#define GDL_DATA_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_ROW, GdlDataRow)) -#define GDL_DATA_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DATA_ROW, GdlDataRowClass)) -#define GDL_IS_DATA_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_ROW)) -#define GDL_IS_DATA_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_ROW)) - -typedef struct _GdlDataRow GdlDataRow; -typedef struct _GdlDataRowClass GdlDataRowClass; -typedef struct _GdlDataRowPrivate GdlDataRowPrivate; - -struct _GdlDataRow { - GObject parent; - - GdlDataRowPrivate *priv; -}; - -struct _GdlDataRowClass { - GObjectClass parent_class; -}; - -GType gdl_data_row_get_type (void); -GdlDataRow *gdl_data_row_new (GdlDataView *view, - GtkTreePath *path); -void gdl_data_row_get_size (GdlDataRow *row, - int *text_w, - int *cell_w, - int *total_width, - int *height); -void gdl_data_row_set_show_name (GdlDataRow *row, - gboolean show_name); -void gdl_data_row_layout (GdlDataRow *row, - GdkRectangle *alloc); -void gdl_data_row_render (GdlDataRow *row, - GdkDrawable *drawable, - GdkRectangle *expose_area, - GtkCellRendererState flags); -GdlDataRow *gdl_data_row_at (GdlDataRow *row, - int x, - int y); -gboolean gdl_data_row_event (GdlDataRow *row, - GdkEvent *event, - GtkCellEditable **editable_widget); -void gdl_data_row_get_cell_area (GdlDataRow *row, - GdkRectangle *rect); -void gdl_data_row_set_split (GdlDataRow *row, - int split); -void gdl_data_row_set_selected (GdlDataRow *row, - gboolean selected); -void gdl_data_row_set_focused (GdlDataRow *row, - gboolean focused); -const char *gdl_data_row_get_title (GdlDataRow *row); - - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-data-view.c b/src/libgdl/gdl-data-view.c deleted file mode 100644 index 81e1795f7..000000000 --- a/src/libgdl/gdl-data-view.c +++ /dev/null @@ -1,526 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-i18n.h" -#include "gdl-tools.h" -#include "gdl-data-view.h" -#include "gdl-data-frame.h" - -#include "tree-expand.xpm" -#include "tree-contract.xpm" - -struct _GdlDataViewPrivate { - GList *frames; - GList *rows; - GList *widgets; - - GdlDataFrame *selected_frame; - GdlDataRow *selected_row; - - GtkCellEditable *editable; - - GdkPixbuf *close_pixbuf; - GdkPixbuf *expand_pixbuf; - GdkPixbuf *contract_pixbuf; -}; - -typedef struct { - GtkWidget *widget; - int x, y, height, width; -} ChildWidget; - -static void gdl_data_view_instance_init (GdlDataView *dv); -static void gdl_data_view_class_init (GdlDataViewClass *klass); - -GDL_CLASS_BOILERPLATE (GdlDataView, gdl_data_view, GtkLayout, GTK_TYPE_LAYOUT); - - -#define GRID_SPACING 15 - -static void -paint_grid (GtkWidget *widget, GdkDrawable *drawable, - int offset_x, int offset_y, int width, int height) -{ - GdlDataView *dv; - int x; - int y; - - g_return_if_fail (GDL_IS_DATA_VIEW (widget)); - dv = GDL_DATA_VIEW (widget); - - x = offset_x + ((GRID_SPACING - (offset_x % GRID_SPACING)) % GRID_SPACING); - - /* Draw grid points */ - for (; x < width; x += GRID_SPACING) { - y = offset_y + ((GRID_SPACING - (offset_y % GRID_SPACING)) % GRID_SPACING); - - for (; y < height; y += GRID_SPACING) { - gdk_draw_point (drawable, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - x, y); - } - } -} - -static void -expose_frames (GdlDataView *view, GdkEventExpose *event) -{ - GList *l; - - for (l = view->priv->frames; l != NULL; l = l->next) { - GdkRectangle intersect; - GdlDataFrame *frame = GDL_DATA_FRAME (l->data); - if (gdk_rectangle_intersect (&frame->area, - &event->area, - &intersect)) { - gdl_data_frame_draw (GDL_DATA_FRAME (l->data), - GTK_LAYOUT(view)->bin_window, - &intersect); - } - } -} - -static void -expose_widgets (GdlDataView *view, GdkEventExpose *event) -{ - GList *l; - - for (l = view->priv->widgets; l != NULL; l = l->next) { - ChildWidget *child = l->data; - gtk_container_propagate_expose (GTK_CONTAINER (view), - child->widget, event); - } -} - -static gboolean -gdl_data_view_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - if (GTK_WIDGET_DRAWABLE (widget)) { - if (event->window == GTK_LAYOUT (widget)->bin_window) { - paint_grid (widget, GTK_LAYOUT (widget)->bin_window, - event->area.x, event->area.y, - event->area.width, event->area.height); - expose_frames (GDL_DATA_VIEW (widget), event); - expose_widgets (GDL_DATA_VIEW (widget), event); - return TRUE; - } else { - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - } - } - - return FALSE; -} - -static GdlDataFrame * -frame_at (GdlDataView *dv, int x, int y) -{ - GList *l; - for (l = dv->priv->frames; l != NULL; l = l->next) { - GdlDataFrame *frame = l->data; - if (x >= frame->area.x && x <= frame->area.x + frame->area.width - && y >= frame->area.y && y <= frame->area.y + frame->area.height) { - return frame; - } - } - return NULL; -} - -static GdlDataRow * -row_at (GdlDataView *view, int x, int y) -{ - GList *l; - GdlDataRow *ret = NULL; - for (l = view->priv->rows; l != NULL; l = l->next) { - GdlDataRow *row = l->data; - ret = gdl_data_row_at (row, x, y); - if (ret) break; - } - return ret; -} - -static void -gdl_data_view_put (GdlDataView *view, GtkWidget *widget, - int x, int y, int width, int height) -{ - ChildWidget *child = g_new0 (ChildWidget, 1); - - child->widget = widget; - child->x = x; - child->y = y; - child->width = width; - child->height = height; - - view->priv->widgets = g_list_append (view->priv->widgets, child); - - if (GTK_WIDGET_REALIZED (view)) { - gtk_widget_set_parent_window (child->widget, - GTK_LAYOUT (view)->bin_window); - } - - gtk_widget_set_parent (child->widget, GTK_WIDGET (view)); -} - -static void -stop_editing (GdlDataView *dv) -{ - if (dv->priv->editable) { - gtk_cell_editable_editing_done (dv->priv->editable); - gtk_cell_editable_remove_widget (dv->priv->editable); - } -} - -static void -remove_widget_cb (GtkCellEditable *cell_editable, GdlDataView *view) -{ - if (view->priv->editable) { - view->priv->editable = NULL; - gdl_data_row_set_focused (view->priv->selected_row, FALSE); - gtk_widget_grab_focus (GTK_WIDGET (view)); - gtk_container_remove (GTK_CONTAINER (view), - GTK_WIDGET (cell_editable)); - } -} - -static gboolean -button_press_event_cb (GdlDataView *dv, GdkEventButton *event, gpointer data) -{ - GdlDataFrame *frame; - GdlDataRow *row; - gboolean ret = FALSE; - - stop_editing (dv); - - if (event->type == GDK_BUTTON_PRESS) { - frame = frame_at (dv, event->x, event->y); - if (frame) { - if (dv->priv->selected_frame) { - gdl_data_frame_set_selected (dv->priv->selected_frame, FALSE); - } - gdl_data_frame_set_selected (frame, TRUE); - dv->priv->selected_frame = frame; - } - - row = row_at (dv, event->x, event->y); - if (row) { - GtkCellEditable *editable; - - if (dv->priv->selected_row) { - gdl_data_row_set_selected (dv->priv->selected_row, - FALSE); - } - dv->priv->selected_row = row; - gdl_data_row_set_selected (row, TRUE); - ret = gdl_data_row_event (row, (GdkEvent*)event, - &editable); - if (editable) { - GdkRectangle area; - dv->priv->editable = editable; - gtk_cell_editable_start_editing (editable, - (GdkEvent*)event); - - gdl_data_row_get_cell_area (row, &area); - gdl_data_view_put (dv, - GTK_WIDGET (editable), - area.x, - area.y, - area.width, - area.height); - - gtk_widget_grab_focus (GTK_WIDGET (editable)); - dv->priv->editable = editable; - gdl_data_row_set_focused (row, TRUE); - - g_signal_connect - (G_OBJECT (editable), - "remove_widget", - G_CALLBACK (remove_widget_cb), dv); - } - } - } - - return ret; -} - -static void -gdl_data_view_instance_init (GdlDataView *dv) -{ - GTK_WIDGET_SET_FLAGS (dv, GTK_CAN_FOCUS); - dv->priv = g_new0 (GdlDataViewPrivate, 1); - - g_signal_connect (G_OBJECT (dv), "button_press_event", - G_CALLBACK (button_press_event_cb), - NULL); - - dv->priv->close_pixbuf = gtk_widget_render_icon (GTK_WIDGET (dv), - "gtk-close", - GTK_ICON_SIZE_MENU, - "gdl-data-view-close"); - - dv->priv->expand_pixbuf = - gdk_pixbuf_new_from_xpm_data ((const char **)tree_expand_xpm); - - dv->priv->contract_pixbuf = - gdk_pixbuf_new_from_xpm_data ((const char **)tree_contract_xpm); -} - -static void -gdl_data_view_realize (GtkWidget *widget) -{ - GList *l; - GdlDataView *view = GDL_DATA_VIEW (widget); - - GDL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget)); - - for (l = view->priv->widgets; l != NULL; l = l->next) { - ChildWidget *child = l->data; - gtk_widget_set_parent_window (child->widget, - GTK_LAYOUT (view)->bin_window); - } -} - -static void -gdl_data_view_size_request (GtkWidget *widget, GtkRequisition *req) -{ - GList *l; - - req->width = req->height = 0; - - for (l = GDL_DATA_VIEW (widget)->priv->widgets; l != NULL; l = l->next) { - GtkRequisition child_req; - ChildWidget *child = l->data; - - gtk_widget_size_request (child->widget, &child_req); - } -} - - -static void -gdl_data_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc) -{ - GdlDataView *view = GDL_DATA_VIEW (widget); - GList *l; -; - for (l = view->priv->widgets; l != NULL; l = l->next) { - ChildWidget *child = l->data; - GtkAllocation child_alloc; - - child_alloc.x = child->x; - child_alloc.y = child->y; - child_alloc.width = child->width; - child_alloc.height = child->height; - - gtk_widget_size_allocate (child->widget, &child_alloc); - } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, alloc)); -} - -static void -gdl_data_view_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - GdlDataView *view = GDL_DATA_VIEW (container); - GList *l; - - for (l = view->priv->widgets; l != NULL; l = l->next) { - ChildWidget *child = l->data; - (*callback) (child->widget, callback_data); - } -} - -static void -gdl_data_view_remove (GtkContainer *container, GtkWidget *widget) -{ - GList *l; - GdlDataView *view = GDL_DATA_VIEW (container); - - for (l = view->priv->widgets; l != NULL; l = l->next) { - ChildWidget *child = l->data; - if (child->widget == widget) { - gtk_widget_unparent (widget); - view->priv->widgets = - g_list_remove_link (view->priv->widgets, l); - g_list_free_1 (l); - g_free (child); - return; - } - } -} - -static void -gdl_data_view_destroy (GtkObject *obj) -{ - GdlDataView *dv = GDL_DATA_VIEW (obj); - - stop_editing (dv); - - if (dv->priv) { - GList *l; - for (l = dv->priv->frames; l != NULL; l = l->next) { - g_object_unref (G_OBJECT (l->data)); - } - g_list_free (dv->priv->frames); - - g_object_unref (dv->priv->close_pixbuf); - g_object_unref (dv->priv->expand_pixbuf); - g_object_unref (dv->priv->contract_pixbuf); - - g_free (dv->priv); - dv->priv = NULL; - } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (obj)); -} - -static void -gdl_data_view_class_init (GdlDataViewClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *)klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; - GtkContainerClass *container_class = (GtkContainerClass *)klass; - - parent_class = gtk_type_class (GTK_TYPE_LAYOUT); - - container_class->forall = gdl_data_view_forall; - container_class->remove = gdl_data_view_remove; - - widget_class->expose_event = gdl_data_view_expose; - widget_class->realize = gdl_data_view_realize; - /* FIXME: unrealize */ - widget_class->size_request = gdl_data_view_size_request; - widget_class->size_allocate = gdl_data_view_size_allocate; - object_class->destroy = gdl_data_view_destroy; - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("expander-size", - _("Expander Size"), - _("Size of the expander arrow."), - 0, - G_MAXINT, - 10, - G_PARAM_READABLE)); -} - -GtkWidget * -gdl_data_view_new (void) -{ - GdlDataView *dv; - dv = g_object_new (gdl_data_view_get_type (), NULL); - return GTK_WIDGET (dv); -} - -void -gdl_data_view_set_model (GdlDataView *dv, GdlDataModel *model) -{ - GtkTreePath *path; - GdlDataIter iter; - gboolean iter_valid; - int x = 5; - - dv->model = model; - - path = gtk_tree_path_new_from_string ("0"); - - iter_valid = gdl_data_model_get_iter (model, &iter, path); - gtk_tree_path_free (path); - - while (iter_valid) { - GdlDataFrame *frame; - GdlDataRow *row; - - path = gdl_data_model_get_path (model, &iter); - - row = gdl_data_row_new (dv, path); - frame = gdl_data_frame_new (dv, row); - gdl_data_frame_set_position (frame, x, 5); - - dv->priv->frames = g_list_append (dv->priv->frames, - frame); - dv->priv->rows = g_list_append (dv->priv->rows, row); - - gtk_tree_path_free (path); - - x += 150; - - iter_valid = gdl_data_model_iter_next (model, &iter); - } -} - -void -gdl_data_view_layout (GdlDataView *view) -{ - GList *l; - for (l = view->priv->frames; l != NULL; l = l->next) { - gdl_data_frame_layout (GDL_DATA_FRAME (l->data)); - } -} - -GdkPixbuf * -gdl_data_view_get_close_pixbuf (GdlDataView *view) -{ - return view->priv->close_pixbuf; -} - -void -gdl_data_view_set_close_pixbuf (GdlDataView *view, GdkPixbuf *pixbuf) -{ - if (view->priv->close_pixbuf) { - g_object_unref (view->priv->close_pixbuf); - } - - view->priv->close_pixbuf = g_object_ref (pixbuf); -} - -GdkPixbuf * -gdl_data_view_get_expand_pixbuf (GdlDataView *view) -{ - return view->priv->expand_pixbuf; -} - -void -gdl_data_view_set_expand_pixbuf (GdlDataView *view, GdkPixbuf *pixbuf) -{ - if (view->priv->expand_pixbuf) { - g_object_unref (view->priv->expand_pixbuf); - } - - view->priv->expand_pixbuf = g_object_ref (pixbuf); -} - -GdkPixbuf * -gdl_data_view_get_contract_pixbuf (GdlDataView *view) -{ - return view->priv->contract_pixbuf; -} - -void -gdl_data_view_set_contract_pixbuf (GdlDataView *view, GdkPixbuf *pixbuf) -{ - if (view->priv->contract_pixbuf) { - g_object_unref (view->priv->contract_pixbuf); - } - - view->priv->contract_pixbuf = g_object_ref (pixbuf); -} diff --git a/src/libgdl/gdl-data-view.h b/src/libgdl/gdl-data-view.h deleted file mode 100644 index 3a5db02f4..000000000 --- a/src/libgdl/gdl-data-view.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2001 Dave Camp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef GDL_DATA_VIEW_H -#define GDL_DATA_VIEW_H - -#include -#include - -G_BEGIN_DECLS - -#define GDL_TYPE_DATA_VIEW (gdl_data_view_get_type ()) -#define GDL_DATA_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DATA_VIEW, GdlDataView)) -#define GDL_DATA_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) -#define GDL_IS_DATA_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DATA_VIEW)) -#define GDL_IS_DATA_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DATA_VIEW)) -#define GDL_DATA_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DATA_VIEW, GdlDataViewClass)) - -typedef struct _GdlDataView GdlDataView; -typedef struct _GdlDataViewClass GdlDataViewClass; -typedef struct _GdlDataViewPrivate GdlDataViewPrivate; - -#define GDL_POINT_IN(x1,y1,r) ((x1) >= (r)->x && x1 < (r)->x + (r)->width && (y1) >= (r)->y && y1 < (r)->y + (r)->height) - -struct _GdlDataView { - GtkLayout layout; - - GdlDataModel *model; - - GdlDataViewPrivate *priv; -}; - -struct _GdlDataViewClass { - GtkLayoutClass parent_class; -}; - -GType gdl_data_view_get_type (void); -GtkWidget *gdl_data_view_new (void); -void gdl_data_view_set_model (GdlDataView *view, - GdlDataModel *model); -void gdl_data_view_layout (GdlDataView *view); -GdkPixbuf *gdl_data_view_get_close_pixbuf (GdlDataView *view); -void gdl_data_view_set_close_pixbuf (GdlDataView *view, - GdkPixbuf *pixbuf); -GdkPixbuf *gdl_data_view_get_expand_pixbuf (GdlDataView *view); -void gdl_data_view_set_expand_pixbuf (GdlDataView *view, - GdkPixbuf *pixbuf); -GdkPixbuf *gdl_data_view_get_contract_pixbuf (GdlDataView *view); -void gdl_data_view_set_contract_pixbuf (GdlDataView *view, - GdkPixbuf *pixbuf); - -#endif diff --git a/src/libgdl/gdl-icons.c b/src/libgdl/gdl-icons.c deleted file mode 100644 index 2af2a8a9a..000000000 --- a/src/libgdl/gdl-icons.c +++ /dev/null @@ -1,267 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* gdl-icons.c - * - * Copyright (C) 2000-2001 Dave Camp - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Dave Camp, Jeroen Zwartepoorte - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-i18n.h" -#include "gdl-tools.h" -#include -#include -#include -#include "gdl-icons.h" - -enum { - PROP_BOGUS, - PROP_ICON_SIZE, -}; - -#define GDL_ICONS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDL_TYPE_ICONS, GdlIconsPrivate)) - -typedef struct _GdlIconsPrivate GdlIconsPrivate; - -struct _GdlIconsPrivate { - int icon_size; - - GtkIconTheme *icon_theme; - GHashTable *icons; -}; - -GDL_CLASS_BOILERPLATE (GdlIcons, gdl_icons, GObject, G_TYPE_OBJECT); - -static void -gdl_icons_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_ICON_SIZE: - g_value_set_int (value, priv->icon_size); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_icons_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_ICON_SIZE: - priv->icon_size = g_value_get_int (value); - g_hash_table_destroy (priv->icons); - priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) gdk_pixbuf_unref); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -theme_changed_cb (GtkIconTheme *theme, - gpointer user_data) -{ - GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (user_data); - - g_hash_table_destroy (priv->icons); - priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) gdk_pixbuf_unref); -} - -static void -gdl_icons_dispose (GObject *object) -{ - GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (object); - - if (priv->icon_theme) { - /* Don't do that - look a GTK+ docs */ - /* g_object_unref (priv->icon_theme); */ - priv->icon_theme = NULL; - } - - if (priv->icons) { - g_hash_table_destroy (priv->icons); - priv->icons = NULL; - } -} - -static void -gdl_icons_class_init (GdlIconsClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = gdl_icons_dispose; - object_class->get_property = gdl_icons_get_property; - object_class->set_property = gdl_icons_set_property; - - g_object_class_install_property (object_class, PROP_ICON_SIZE, - g_param_spec_int ("icon-size", - _("Icon size"), - _("Icon size"), - 12, 256, 24, - G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GdlIconsPrivate)); -} - -static void -gdl_icons_instance_init (GdlIcons *icons) -{ - GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (icons); - - priv->icon_theme = gtk_icon_theme_get_default (); - /* gtk_icon_theme_get_default() does not ref the returned object */ - /* but API docs state the you should NOT ref it */ - /* g_object_ref (priv->icon_theme);*/ - g_signal_connect_object (G_OBJECT (priv->icon_theme), "changed", - G_CALLBACK (theme_changed_cb), icons, 0); - priv->icons = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) gdk_pixbuf_unref); -} - -GdlIcons * -gdl_icons_new (int icon_size) -{ - return GDL_ICONS (g_object_new (GDL_TYPE_ICONS, - "icon-size", icon_size, - NULL)); -} - -GdkPixbuf * -gdl_icons_get_folder_icon (GdlIcons *icons) -{ - g_return_val_if_fail (icons != NULL, NULL); - g_return_val_if_fail (GDL_IS_ICONS (icons), NULL); - - return gdl_icons_get_mime_icon (icons, "application/directory-normal"); -} - -GdkPixbuf * -gdl_icons_get_uri_icon (GdlIcons *icons, - const char *uri) -{ - GnomeVFSFileInfo *info; - GdkPixbuf *pixbuf; - - g_return_val_if_fail (icons != NULL, NULL); - g_return_val_if_fail (GDL_IS_ICONS (icons), NULL); - g_return_val_if_fail (uri != NULL, NULL); - - info = gnome_vfs_file_info_new (); - gnome_vfs_get_file_info (uri, info, - GNOME_VFS_FILE_INFO_FOLLOW_LINKS | - GNOME_VFS_FILE_INFO_GET_MIME_TYPE | - GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE); - if (info->mime_type) - pixbuf = gdl_icons_get_mime_icon (icons, info->mime_type); - else - pixbuf = gdl_icons_get_mime_icon (icons, "gnome-fs-regular"); - gnome_vfs_file_info_unref (info); - - return pixbuf; -} - -GdkPixbuf * -gdl_icons_get_mime_icon (GdlIcons *icons, - const char *mime_type) -{ - GdkPixbuf *pixbuf; - char *icon_name; - - g_return_val_if_fail (icons != NULL, NULL); - g_return_val_if_fail (GDL_IS_ICONS (icons), NULL); - g_return_val_if_fail (mime_type != NULL, NULL); - - GdlIconsPrivate *priv = GDL_ICONS_GET_PRIVATE (icons); - - pixbuf = g_hash_table_lookup (priv->icons, mime_type); - if (pixbuf != NULL) { - g_object_ref (G_OBJECT (pixbuf)); - return pixbuf; - } - - if (!strcmp (mime_type, "application/directory-normal")) { - icon_name = g_strdup ("gnome-fs-directory"); - } else { - icon_name = gnome_icon_lookup (priv->icon_theme, - NULL, - NULL, - NULL, - NULL, - mime_type, - GNOME_ICON_LOOKUP_FLAGS_NONE, - NULL); - } - - if (!icon_name) { - /* Return regular icon if one doesn't exist for mime type. */ - if (!strcmp (mime_type, "gnome-fs-regular")) - return NULL; - else - return gdl_icons_get_mime_icon (icons, "gnome-fs-regular"); - } else { - if (!gtk_icon_theme_has_icon (priv->icon_theme, icon_name)) { - g_free (icon_name); - if (!strcmp (mime_type, "gnome-fs-regular")) - return NULL; - else - return gdl_icons_get_mime_icon (icons, "gnome-fs-regular"); - } else { - pixbuf = gtk_icon_theme_load_icon (priv->icon_theme, - icon_name, - priv->icon_size, - 0, /* lookup flags */ - NULL); - g_free (icon_name); - - if (pixbuf == NULL) { - if (!strcmp (mime_type, "gnome-fs-regular")) - return NULL; - else - return gdl_icons_get_mime_icon (icons, - "gnome-fs-regular"); - } - } - } - - g_hash_table_insert (priv->icons, g_strdup (mime_type), pixbuf); - g_object_ref (pixbuf); - - return pixbuf; -} diff --git a/src/libgdl/gdl-icons.h b/src/libgdl/gdl-icons.h deleted file mode 100644 index 79f3bba85..000000000 --- a/src/libgdl/gdl-icons.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* gdl-icons.h - * - * Copyright (C) 2000-2001 JP Rosevear - * 2000 Dave Camp - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: JP Rosevear, Dave Camp, Jeroen Zwartepoorte - */ - -#ifndef _GDL_ICONS_H_ -#define _GDL_ICONS_H_ - -#include -#include - -G_BEGIN_DECLS - -#define GDL_TYPE_ICONS (gdl_icons_get_type ()) -#define GDL_ICONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_ICONS, GdlIcons)) -#define GDL_ICONS_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_ICONS, GdlIconsClass)) -#define GDL_IS_ICONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_ICONS)) -#define GDL_IS_ICONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_ICONS)) - -typedef struct _GdlIcons GdlIcons; -typedef struct _GdlIconsClass GdlIconsClass; - -struct _GdlIcons { - GObject parent; -}; - -struct _GdlIconsClass { - GObjectClass parent_class; -}; - -GType gdl_icons_get_type (void); -GdlIcons *gdl_icons_new (int icon_size); - -GdkPixbuf *gdl_icons_get_folder_icon (GdlIcons *icons); -GdkPixbuf *gdl_icons_get_uri_icon (GdlIcons *icons, - const char *uri); -GdkPixbuf *gdl_icons_get_mime_icon (GdlIcons *icons, - const char *mime_type); - -G_END_DECLS - -#endif /* _GDL_ICONS_H_ */ diff --git a/src/libgdl/test-dataview.c b/src/libgdl/test-dataview.c deleted file mode 100644 index bc89cbd4f..000000000 --- a/src/libgdl/test-dataview.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -#include "gdl-data-view.h" -#include "gdl-data-model-test.h" - -int -main (int argc, char *argv[]) -{ - GtkWidget *win; - GtkWidget *view; - GdlDataModel *model; - GtkWidget *vbox; - - gtk_init (&argc, &argv); - - win = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (win), 500, 200); - - vbox = gtk_vbox_new (FALSE, 5); - - view = gdl_data_view_new (); - - gtk_layout_set_hadjustment (GTK_LAYOUT (view), NULL); - gtk_layout_set_vadjustment (GTK_LAYOUT (view), NULL); - - - model = GDL_DATA_MODEL (gdl_data_model_test_new ()); - gdl_data_view_set_model (GDL_DATA_VIEW (view), - model); - - gtk_box_pack_start (GTK_BOX (vbox), view, TRUE, TRUE, 0); - - gtk_container_add (GTK_CONTAINER (win), vbox); - - gtk_widget_show_all (win); - gtk_widget_grab_focus (GTK_WIDGET (view)); - - gtk_main (); - - return 0; -} -- cgit v1.2.3 From 3fb6de18c5d4b6a5f4fb08dfdb94cb39e8cd3844 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Jul 2011 20:07:46 +0100 Subject: Merge upstream GDL 2.26.0 changes (bzr r10435) --- src/libgdl/gdl-combo-button.h | 4 +- src/libgdl/gdl-dock-bar.h | 1 - src/libgdl/gdl-dock-item-grip.c | 99 ++++++++------- src/libgdl/gdl-dock-item.c | 261 ++++++++++++++++++++++++++++++++++------ src/libgdl/gdl-dock.c | 2 + src/libgdl/gdl-stock.c | 2 +- src/libgdl/gdl-switcher.c | 2 +- 7 files changed, 283 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-combo-button.h b/src/libgdl/gdl-combo-button.h index 6e80af0b6..2f9c3ca2c 100644 --- a/src/libgdl/gdl-combo-button.h +++ b/src/libgdl/gdl-combo-button.h @@ -21,9 +21,7 @@ #ifndef _GDL_COMBO_BUTTON_H_ #define _GDL_COMBO_BUTTON_H_ -#include -#include -#include +#include G_BEGIN_DECLS diff --git a/src/libgdl/gdl-dock-bar.h b/src/libgdl/gdl-dock-bar.h index 798dded20..ca6da1d26 100644 --- a/src/libgdl/gdl-dock-bar.h +++ b/src/libgdl/gdl-dock-bar.h @@ -23,7 +23,6 @@ #define __GDL_DOCK_BAR_H__ #include -#include "libgdl/gdl-dock.h" G_BEGIN_DECLS diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 91b88e782..7f7d17ab2 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -42,7 +42,7 @@ struct _GdlDockItemGripPrivate { }; GDL_CLASS_BOILERPLATE (GdlDockItemGrip, gdl_dock_item_grip, - GtkContainer, GTK_TYPE_CONTAINER); + GtkContainer, GTK_TYPE_CONTAINER); /* must be called after size_allocate */ static void @@ -122,7 +122,7 @@ ensure_title_and_icon_pixbuf (GdlDockItemGrip *grip) static gint gdl_dock_item_grip_expose (GtkWidget *widget, - GdkEventExpose *event) + GdkEventExpose *event) { GdlDockItemGrip *grip; GdkRectangle title_area; @@ -172,7 +172,7 @@ gdl_dock_item_grip_expose (GtkWidget *widget, 0, 0, pixbuf_rect.x, pixbuf_rect.y, pixbuf_rect.width, pixbuf_rect.height, GDK_RGB_DITHER_NONE, 0, 0); - } + } } if (gdk_rectangle_intersect (&title_area, &event->area, &expose_area)) { @@ -221,15 +221,15 @@ gdl_dock_item_grip_item_notify (GObject *master, g_free (grip->_priv->title); grip->_priv->title = NULL; ensure_title_and_icon_pixbuf (grip); - gtk_widget_queue_draw (GTK_WIDGET (grip)); + gtk_widget_queue_draw (GTK_WIDGET (grip)); } else if (strcmp (pspec->name, "behavior") == 0) { - cursor = FALSE; + cursor = FALSE; if (grip->_priv->close_button) { if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) { gtk_widget_hide (GTK_WIDGET (grip->_priv->close_button)); } else { gtk_widget_show (GTK_WIDGET (grip->_priv->close_button)); - cursor = TRUE; + cursor = TRUE; } } if (grip->_priv->iconify_button) { @@ -237,10 +237,10 @@ gdl_dock_item_grip_item_notify (GObject *master, gtk_widget_hide (GTK_WIDGET (grip->_priv->iconify_button)); } else { gtk_widget_show (GTK_WIDGET (grip->_priv->iconify_button)); - cursor = TRUE; + cursor = TRUE; } } - if (grip->title_window && !cursor) + if (grip->title_window && !cursor) gdk_window_set_cursor (grip->title_window, NULL); } @@ -301,9 +301,9 @@ gdl_dock_item_grip_set_property (GObject *object, g_signal_connect (grip->item, "notify::stock-id", G_CALLBACK (gdl_dock_item_grip_item_notify), grip); - g_signal_connect (grip->item, "notify::behavior", - G_CALLBACK (gdl_dock_item_grip_item_notify), - grip); + g_signal_connect (grip->item, "notify::behavior", + G_CALLBACK (gdl_dock_item_grip_item_notify), + grip); if (!GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && grip->_priv->close_button) gtk_widget_show (grip->_priv->close_button); @@ -353,6 +353,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) grip->_priv->icon_pixbuf = NULL; grip->_priv->title_layout = NULL; + /* create the close button */ gtk_widget_push_composite_child (); grip->_priv->close_button = gtk_button_new (); gtk_widget_pop_composite_child (); @@ -369,6 +370,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) g_signal_connect (G_OBJECT (grip->_priv->close_button), "clicked", G_CALLBACK (gdl_dock_item_grip_close_clicked), grip); + /* create the iconify button */ gtk_widget_push_composite_child (); grip->_priv->iconify_button = gtk_button_new (); gtk_widget_pop_composite_child (); @@ -385,6 +387,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked", G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip); + /* set tooltips on the buttons */ gtk_widget_set_tooltip_text (grip->_priv->iconify_button, _("Iconify this dock")); gtk_widget_set_tooltip_text (grip->_priv->close_button, @@ -426,15 +429,14 @@ gdl_dock_item_grip_realize (GtkWidget *widget) gdk_window_set_user_data (grip->title_window, widget); - if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) - cursor = NULL; - else if (GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) - cursor = NULL; - else - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), + if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && + GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) + cursor = NULL; + else + cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_HAND2); gdk_window_set_cursor (grip->title_window, cursor); - if (cursor) + if (cursor) gdk_cursor_unref (cursor); } } @@ -497,15 +499,17 @@ gdl_dock_item_grip_size_request (GtkWidget *widget, pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &layout_height); gtk_widget_size_request (grip->_priv->close_button, &child_requisition); - - requisition->width += child_requisition.width; layout_height = MAX (layout_height, child_requisition.height); + if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) { + requisition->width += child_requisition.width; + } gtk_widget_size_request (grip->_priv->iconify_button, &child_requisition); - - requisition->width += child_requisition.width; layout_height = MAX (layout_height, child_requisition.height); - + if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { + requisition->width += child_requisition.width; + } + requisition->height += layout_height; if (grip->_priv->icon_pixbuf) { @@ -579,33 +583,35 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, child_allocation.x = allocation->x + allocation->width - container->border_width; child_allocation.y = allocation->y + container->border_width; - gtk_widget_size_request (grip->_priv->close_button, &button_requisition); - - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) - child_allocation.x -= button_requisition.width; + if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) { + gtk_widget_size_request (grip->_priv->close_button, &button_requisition); - child_allocation.width = button_requisition.width; - child_allocation.height = button_requisition.height; - - gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x += button_requisition.width; + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) + child_allocation.x -= button_requisition.width; + child_allocation.width = button_requisition.width; + child_allocation.height = button_requisition.height; + + gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation); - gtk_widget_size_request (grip->_priv->iconify_button, &button_requisition); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + child_allocation.x += button_requisition.width; + } - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) - child_allocation.x -= button_requisition.width; + if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { + gtk_widget_size_request (grip->_priv->iconify_button, &button_requisition); - child_allocation.width = button_requisition.width; - child_allocation.height = button_requisition.height; + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) + child_allocation.x -= button_requisition.width; - gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation); + child_allocation.width = button_requisition.width; + child_allocation.height = button_requisition.height; - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x += button_requisition.width; + gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation); + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + child_allocation.x += button_requisition.width; + } if (grip->title_window) { GdkRectangle area; @@ -712,6 +718,15 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass) gdl_stock_init (); } +/* ----- Public interface ----- */ + +/** + * gdl_dock_item_grip_new: + * @item: The dock item that will "own" this grip widget. + * + * Creates a new GDL dock item grip object. + * Returns: The newly created dock item grip widget. + **/ GtkWidget * gdl_dock_item_grip_new (GdlDockItem *item) { diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index d2c36b18a..86f729c61 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -281,6 +281,16 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) /* properties */ + /** + * GdlDockItem:orientation: + * + * The orientation of the docking item. If the orientation is set to + * #GTK_ORIENTATION_VERTICAL, the grip widget will be shown along + * the top of the edge of item (if it is not hidden). If the + * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip + * widget will be shown down the left edge of the item (even if the + * widget text direction is set to RTL). + */ g_object_class_install_property ( g_object_class, PROP_ORIENTATION, g_param_spec_enum ("orientation", _("Orientation"), @@ -339,6 +349,12 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) /* signals */ + /** + * GdlDockItem::dock-drag-begin: + * @item: The dock item which is being dragged. + * + * Signals that the dock item has begun to be dragged. + **/ gdl_dock_item_signals [DOCK_DRAG_BEGIN] = g_signal_new ("dock-drag-begin", G_TYPE_FROM_CLASS (klass), @@ -349,7 +365,15 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) gdl_marshal_VOID__VOID, G_TYPE_NONE, 0); - + + /** + * GdlDockItem::dock-drag-motion: + * @item: The dock item which is being dragged. + * @x: The x-position that the dock item has been dragged to. + * @y: The y-position that the dock item has been dragged to. + * + * Signals that a dock item dragging motion event has occured. + **/ gdl_dock_item_signals [DOCK_DRAG_MOTION] = g_signal_new ("dock-drag-motion", G_TYPE_FROM_CLASS (klass), @@ -363,6 +387,14 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) G_TYPE_INT, G_TYPE_INT); + /** + * GdlDockItem::dock-drag-end: + * @item: The dock item which is no longer being dragged. + * @cancel: This value is set to TRUE if the drag was cancelled by + * the user. #cancel is set to FALSE if the drag was accepted. + * + * Signals that the dock item dragging has ended. + **/ gdl_dock_item_signals [DOCK_DRAG_END] = g_signal_new ("dock_drag_end", G_TYPE_FROM_CLASS (klass), @@ -1401,60 +1433,64 @@ gdl_dock_item_dock (GdlDockObject *object, if (parent) gdl_dock_object_freeze (parent); - /* ref ourselves since we could be destroyed when detached */ + if (new_parent) { + /* ref ourselves since we could be destroyed when detached */ g_object_ref (object); GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW); gdl_dock_object_detach (object, FALSE); - } - /* freeze the new parent, so reduce won't get called before it's - actually added to our parent */ - gdl_dock_object_freeze (new_parent); + /* freeze the new parent, so reduce won't get called before it's + actually added to our parent */ + gdl_dock_object_freeze (new_parent); - /* bind the new parent to our master, so the following adds work */ - gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object))); + /* bind the new parent to our master, so the following adds work */ + gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object))); - /* add the objects */ - if (add_ourselves_first) { - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object)); - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor)); - splitpos = available_space - pref_size; - } else { - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor)); - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object)); - splitpos = pref_size; - } + /* add the objects */ + if (add_ourselves_first) { + gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object)); + gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor)); + splitpos = available_space - pref_size; + } else { + gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor)); + gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object)); + splitpos = pref_size; + } - /* add the new parent to the parent */ - if (parent) - gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent)); + /* add the new parent to the parent */ + if (parent) + gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent)); - /* show automatic object */ - if (gtk_widget_get_visible (GTK_WIDGET (object))) - { - gtk_widget_show (GTK_WIDGET (new_parent)); - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW); + /* show automatic object */ + if (gtk_widget_get_visible (GTK_WIDGET (object))) + { + gtk_widget_show (GTK_WIDGET (new_parent)); + GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW); + } gdl_dock_object_thaw (new_parent); + + /* use extra docking parameter */ + if (position != GDL_DOCK_CENTER && other_data && + G_VALUE_HOLDS (other_data, G_TYPE_UINT)) { + + g_object_set (G_OBJECT (new_parent), + "position", g_value_get_uint (other_data), + NULL); + } else if (splitpos > 0 && splitpos < available_space) { + g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL); + } + + g_object_unref (object); } - else // If the parent is already a DockNotebook, we don't need - // to create a new one. + else + { + /* If the parent is already a DockNotebook, we don't need + to create a new one. */ gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor)); - - /* use extra docking parameter */ - if (position != GDL_DOCK_CENTER && other_data && - G_VALUE_HOLDS (other_data, G_TYPE_UINT)) { - - g_object_set (G_OBJECT (new_parent), - "position", g_value_get_uint (other_data), - NULL); - } else if (splitpos > 0 && splitpos < available_space) { - g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL); } - g_object_unref (object); - requestor_parent = gdl_dock_object_get_parent_object (requestor); if (GDL_IS_DOCK_NOTEBOOK (requestor_parent)) { @@ -1665,6 +1701,17 @@ gdl_dock_item_real_set_orientation (GdlDockItem *item, /* ----- Public interface ----- */ +/** + * gdl_dock_item_new: + * @name: Unique name for identifying the dock object. + * @long_name: Human readable name for the dock object. + * @behavior: General behavior for the dock item (i.e. whether it can + * float, if it's locked, etc.), as specified by + * #GdlDockItemBehavior flags. + * + * Creates a new dock item widget. + * Returns: The newly created dock item grip widget. + **/ GtkWidget * gdl_dock_item_new (const gchar *name, const gchar *long_name, @@ -1682,6 +1729,18 @@ gdl_dock_item_new (const gchar *name, return GTK_WIDGET (item); } +/** + * gdl_dock_item_new_with_stock: + * @name: Unique name for identifying the dock object. + * @long_name: Human readable name for the dock object. + * @stock_id: Stock icon for the dock object. + * @behavior: General behavior for the dock item (i.e. whether it can + * float, if it's locked, etc.), as specified by + * #GdlDockItemBehavior flags. + * + * Creates a new dock item grip widget with a given stock id. + * Returns: The newly created dock item grip widget. + **/ GtkWidget * gdl_dock_item_new_with_stock (const gchar *name, const gchar *long_name, @@ -1724,6 +1783,15 @@ gdl_dock_item_new_with_pixbuf_icon (const gchar *name, } /* convenient function (and to preserve source compat) */ +/** + * gdl_dock_item_dock_to: + * @item: The dock item that will be relocated to the dock position. + * @target: The dock item that will be used as the point of reference. + * @position: The position to dock #item, relative to #target. + * @docking_param: This value is unused, and will be ignored. + * + * Relocates a dock item to a new location relative to another dock item. + **/ void gdl_dock_item_dock_to (GdlDockItem *item, GdlDockItem *target, @@ -1761,6 +1829,18 @@ gdl_dock_item_dock_to (GdlDockItem *item, position, NULL); } +/** + * gdl_dock_item_set_orientation: + * @item: The dock item which will get it's orientation set. + * @orientation: The orientation to set the item to. If the orientation + * is set to #GTK_ORIENTATION_VERTICAL, the grip widget will be shown + * along the top of the edge of item (if it is not hidden). If the + * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip widget + * will be shown down the left edge of the item (even if the widget + * text direction is set to RTL). + * + * This function sets the layout of the dock item. + **/ void gdl_dock_item_set_orientation (GdlDockItem *item, GtkOrientation orientation) @@ -1785,6 +1865,16 @@ gdl_dock_item_set_orientation (GdlDockItem *item, } } +/** + * gdl_dock_item_get_tablabel: + * @item: The dock item from which to get the tab label widget. + * + * Gets the current tab label widget. Note that this label widget is + * only visible when the "switcher-style" property of the #GdlDockMaster + * is set to #GDL_SWITCHER_STYLE_TABS + * + * Returns: Returns the tab label widget. + **/ GtkWidget * gdl_dock_item_get_tablabel (GdlDockItem *item) { @@ -1794,6 +1884,15 @@ gdl_dock_item_get_tablabel (GdlDockItem *item) return item->_priv->tab_label; } +/** + * gdl_dock_item_set_tablabel: + * @item: The dock item which will get it's tab label widget set. + * @tablabel: The widget that will become the tab label. + * + * Replaces the current tab label widget with another widget. Note that + * this label widget is only visible when the "switcher-style" property + * of the #GdlDockMaster is set to #GDL_SWITCHER_STYLE_TABS + **/ void gdl_dock_item_set_tablabel (GdlDockItem *item, GtkWidget *tablabel) @@ -1825,6 +1924,12 @@ gdl_dock_item_set_tablabel (GdlDockItem *item, } } +/** + * gdl_dock_item_hide_grip: + * @item: The dock item to hide the grip of. + * + * This function hides the dock item's grip widget. + **/ void gdl_dock_item_hide_grip (GdlDockItem *item) { @@ -1836,6 +1941,12 @@ gdl_dock_item_hide_grip (GdlDockItem *item) g_warning ("Grips always show unless GDL_DOCK_ITEM_BEH_NO_GRIP is set\n" ); } +/** + * gdl_dock_item_show_grip: + * @item: The dock item to show the grip of. + * + * This function shows the dock item's grip widget. + **/ void gdl_dock_item_show_grip (GdlDockItem *item) { @@ -1847,6 +1958,14 @@ gdl_dock_item_show_grip (GdlDockItem *item) } /* convenient function (and to preserve source compat) */ +/** + * gdl_dock_item_bind: + * @item: The item to bind. + * @dock: The #GdlDock widget to bind it to. Note that this widget must + * be a type of #GdlDock. + * + * Binds this dock item to a new dock master. + **/ void gdl_dock_item_bind (GdlDockItem *item, GtkWidget *dock) @@ -1859,6 +1978,12 @@ gdl_dock_item_bind (GdlDockItem *item, } /* convenient function (and to preserve source compat) */ +/** + * gdl_dock_item_unbind: + * @item: The item to unbind. + * + * Unbinds this dock item from it's dock master. + **/ void gdl_dock_item_unbind (GdlDockItem *item) { @@ -1867,6 +1992,15 @@ gdl_dock_item_unbind (GdlDockItem *item) gdl_dock_object_unbind (GDL_DOCK_OBJECT (item)); } +/** + * gdl_dock_item_hide_item: + * @item: The dock item to hide. + * + * This function hides the dock item. When dock items are hidden they + * are completely removed from the layout. + * + * The dock item close button causes the panel to be hidden. + **/ void gdl_dock_item_hide_item (GdlDockItem *item) { @@ -1928,6 +2062,15 @@ gdl_dock_item_hide_item (GdlDockItem *item) gdl_dock_object_thaw (GDL_DOCK_OBJECT (item)); } +/** + * gdl_dock_item_iconify_item: + * @item: The dock item to iconify. + * + * This function iconifies the dock item. When dock items are iconified + * they are hidden, and appear only as icons in dock bars. + * + * The dock item iconify button causes the panel to be iconified. + **/ void gdl_dock_item_iconify_item (GdlDockItem *item) { @@ -1937,6 +2080,13 @@ gdl_dock_item_iconify_item (GdlDockItem *item) gdl_dock_item_hide_item (item); } +/** + * gdl_dock_item_show_item: + * @item: The dock item to show. + * + * This function shows the dock item. When dock items are shown, they + * are displayed in their normal layout position. + **/ void gdl_dock_item_show_item (GdlDockItem *item) { @@ -1988,18 +2138,41 @@ gdl_dock_item_show_item (GdlDockItem *item) gtk_widget_show (GTK_WIDGET (item)); } +/** + * gdl_dock_item_lock: + * @item: The dock item to lock. + * + * This function locks the dock item. When locked the dock item cannot + * be dragged around and it doesn't show a grip. + **/ void gdl_dock_item_lock (GdlDockItem *item) { g_object_set (item, "locked", TRUE, NULL); } +/** + * gdl_dock_item_unlock: + * @item: The dock item to unlock. + * + * This function unlocks the dock item. When unlocked the dock item can + * be dragged around and can show a grip. + **/ void gdl_dock_item_unlock (GdlDockItem *item) { g_object_set (item, "locked", FALSE, NULL); } +/** + * gdl_dock_item_set_default_position: + * @item: The dock item + * @reference: The GdlDockObject which is the default dock for @item + * + * This method has only an effect when you add you dock_item with + * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign + * it a default position. + **/ void gdl_dock_item_set_default_position (GdlDockItem *item, GdlDockObject *reference) @@ -2026,6 +2199,14 @@ gdl_dock_item_set_default_position (GdlDockItem *item, } } +/** + * gdl_dock_item_preferred_size: + * @item: The dock item to get the preferred size of. + * @req: A pointer to a #GtkRequisition into which the preferred size + * will be written. + * + * Gets the preferred size of the dock item in pixels. + **/ void gdl_dock_item_preferred_size (GdlDockItem *item, GtkRequisition *req) diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index d80a47a1f..3b0dc4e6b 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -1139,6 +1139,8 @@ gdl_dock_select_larger_item (GdlDockItem *dock_item_1, return ((size_1.width * size_1.height) >= (size_2.width * size_2.height)? dock_item_1 : dock_item_2); + } else if (placement == GDL_DOCK_NONE) { + return dock_item_1; } else { g_warning ("Should not reach here: %s:%d", __FUNCTION__, __LINE__); } diff --git a/src/libgdl/gdl-stock.c b/src/libgdl/gdl-stock.c index dc86e523b..4cb7bf929 100644 --- a/src/libgdl/gdl-stock.c +++ b/src/libgdl/gdl-stock.c @@ -59,7 +59,7 @@ icon_set_from_data (GtkIconSet *set, pixbuf = gdk_pixbuf_new_from_inline (data_size, icon_data, FALSE, &err); if (err) { - g_warning ("%s",err->message); + g_warning ("%s", err->message); g_error_free (err); err = NULL; g_object_unref (source); diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index c67b4464b..fea3218ae 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -216,7 +216,7 @@ button_toggled_callback (GtkToggleButton *toggle_button, static int layout_buttons (GdlSwitcher *switcher) { - GtkRequisition client_requisition; + GtkRequisition client_requisition = {0,}; GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation; GdlSwitcherStyle switcher_style; gboolean icons_only; -- cgit v1.2.3 From f8a34926de0258e7b82ec5336aa394834f42b55b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 10 Jul 2011 01:03:55 +0200 Subject: Redesign the rendering pipeline. Clipping paths are now rasterized. This fixes breakage related to clipped groups and correctly handles nested clipping paths. Also add the ability to use text objects as clipping paths. (bzr r10347.1.7) --- src/display/nr-arena-glyphs.cpp | 31 +++--- src/display/nr-arena-group.cpp | 1 - src/display/nr-arena-item.cpp | 206 ++++++++++++++++++++++++---------------- src/display/nr-arena-shape.cpp | 25 +++-- 4 files changed, 154 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 0e20f0ddb..185551d31 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -282,7 +282,8 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s } -static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock * /*pb*/, unsigned int /*flags*/) +static unsigned int +nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock * /*pb*/, unsigned int /*flags*/) { NRArenaItem *child = 0; @@ -309,9 +310,11 @@ static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, Geom::Affine transform = g->g_transform * group->ctm; cairo_new_path(ct); + cairo_save(ct); ink_cairo_transform(ct, transform); feed_pathvector_to_cairo (ct, *pathv); cairo_fill(ct); + cairo_restore(ct); } return item->state; @@ -352,20 +355,26 @@ static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, return item->state; } -static unsigned int nr_arena_glyphs_group_clip(cairo_t * /*ct*/, NRArenaItem *item, NRRectL * /*area*/) +static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/) { - //NRArenaGroup *group = NR_ARENA_GROUP(item); + NRArenaGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); + + cairo_save(ct); + ink_cairo_transform(ct, ggroup->ctm); - guint ret = item->state; + for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { + NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); + Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); - // Render children fill mask - /* - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - ret = nr_arena_glyphs_fill_mask(NR_ARENA_GLYPHS(child), area, pb); - if (!(ret & NR_ARENA_ITEM_STATE_RENDER)) return ret; - }*/ + cairo_save(ct); + ink_cairo_transform(ct, g->g_transform); + feed_pathvector_to_cairo(ct, pathv); + cairo_fill(ct); + cairo_restore(ct); + } + cairo_restore(ct); - return ret; + return item->state; } static NRArenaItem * diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index d1e6869aa..5f11c1a6b 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -237,7 +237,6 @@ nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) unsigned int ret = item->state; - /* Just compose children into parent buffer */ for (NRArenaItem *child = group->children; child != NULL; child = child->next) { ret = nr_arena_item_invoke_clip (ct, child, area); if (ret & NR_ARENA_ITEM_STATE_INVALID) break; diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 9c7af1077..534591f82 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -392,119 +392,138 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area using namespace Inkscape; - // clipping and masks - unsigned int state; - - cairo_t *this_ct = ct; - NRRectL *this_area = const_cast(area); + unsigned state; + unsigned retstate; + // determine whether this shape needs intermediate rendering. bool needs_intermediate_rendering = false; bool &nir = needs_intermediate_rendering; bool needs_opacity = (item->opacity != 255 && !item->render_opacity); // this item needs an intermediate rendering if: - nir |= (item->mask != NULL); // 1. it has a mask - nir |= (item->filter != NULL && filter); // 2. it has a filter - nir |= needs_opacity; // 3. it is non-opaque + nir |= (item->clip != NULL); // 1. it has a clipping path + nir |= (item->mask != NULL); // 2. it has a mask + nir |= (item->filter != NULL && filter); // 3. it has a filter + nir |= needs_opacity; // 4. it is non-opaque double opacity = static_cast(item->opacity) / 255.0; - if (needs_intermediate_rendering) { - cairo_surface_t *intermediate = cairo_surface_create_similar( - cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, - carea.x1 - carea.x0, carea.y1 - carea.y0); - this_ct = cairo_create(intermediate); - cairo_translate(this_ct, -carea.x0, -carea.y0); - this_area = &carea; - cairo_surface_destroy(intermediate); // the surface will be held in memory by this_ct - } else { - cairo_reference(this_ct); - } - - // The pipeline needs to be different for filters. - // First we render the item into an intermediate surface. Then the filter rotates - // the surface to user coordinates (if necessary) and runs the rendering. - // Once that's done we retrieve the result, rotating it back to screen coords. - // Clipping and masking happens after the filter result is ready. - if (item->filter && filter) { - } - - Cairo::Context cct(this_ct, true); - Cairo::Context base_ct(ct); - Cairo::RefPtr mask; - CairoSave clipsave(ct); // RAII for save / restore - CairoGroup maskgroup(this_ct); // RAII for push_group / pop_group - CairoGroup drawgroup(this_ct); - CairoGroup maskopacitygroup(this_ct); + /* How the rendering is done. + * + * There is one intermediate surface onto which the object is rendered. + * Clipping, masking and opacity are done with a mask. + * Here are the algorithms: + * a) no clip, no mask, no opacity: direct rendering. + * b) clip, no mask, no opacity: clipping path is rendered and used as a mask. + * c) no clip, mask, no opacity: mask is rendered, luminance is converted to alpha, + * then it is used as a mask. + * d) no clip, no mask, opacity: paint_with_alpha is used. + * e) clip, mask, no opacity: mask is rendered and its luminance is converted to alpha, + * then the clip is composited with it using the IN operator, the result is used + * as a mask. + * f) clip, no mask, opacity: clipping path is rendered with alpha corresponding + * to the opacity value and used as a mask. + * g) no clip, mask, opacity: like e), but the converted mask is composited with + * an uniform fill + * h) clip, mask, opacity: converted mask is composited with the clipping path + * rendered with alpha corresponding to the opacity using the IN operator + */ - // always clip the base context, not the one on the intermediate surface - // this is because filters must be done before clipping - if (item->clip) { - clipsave.save(); - state = nr_arena_item_invoke_clip(ct, item->clip, const_cast(area)); + // handle case a). + if (!needs_intermediate_rendering) { + state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } - base_ct.clip(); + return item->state | NR_ARENA_ITEM_STATE_RENDER; } - // render mask on the intermediate context and store it + cairo_surface_t *intermediate = cairo_surface_create_similar( + cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, + carea.x1 - carea.x0, carea.y1 - carea.y0); + cairo_t *ict = cairo_create(intermediate); + cairo_translate(ict, -carea.x0, -carea.y0); + + // now ict draws on the intermediate surface and carea is its area. + // 1. Render the mask if present. Otherwise initialize the intermediate surface to opaque. if (item->mask) { - maskgroup.push_with_content(CAIRO_CONTENT_COLOR_ALPHA); - // handle opacity of a masked object by composing it with the mask - if (needs_opacity) { - maskopacitygroup.push(); - } - state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (this_ct, item->mask, this_area, pb, flags); + state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ict, item->mask, &carea, NULL, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; + retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); + goto cleanup; } - if (needs_opacity) { - maskopacitygroup.pop_to_source(); - cct.paint_with_alpha(opacity); + ink_cairo_surface_filter(intermediate, intermediate, MaskLuminanceToAlpha()); + } else { + cairo_set_source_rgba(ict, 0,0,0,1); + cairo_paint(ict); + } + + // 2. Render clipping path and composite it with mask + if (item->clip) { + cairo_push_group_with_content(ict, CAIRO_CONTENT_ALPHA); + cairo_set_source_rgba(ict, 0,0,0,opacity); + // Since clip can be combined with opacity, the result could be incorrect + // for overlapping children. To fix this we use the SOURCE operator + // instead of the default OVER + cairo_set_operator(ict, CAIRO_OPERATOR_SOURCE); + state = nr_arena_item_invoke_clip(ict, item->clip, const_cast(area)); + cairo_pop_group_to_source(ict); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); + goto cleanup; } - mask = maskgroup.popmm(); - // convert luminance to alpha - cairo_pattern_t *p = mask->cobj(); - cairo_surface_t *s; - cairo_pattern_get_surface(p, &s); - ink_cairo_surface_filter(s, s, MaskLuminanceToAlpha()); + cairo_set_operator(ict, CAIRO_OPERATOR_IN); + cairo_paint(ict); + cairo_set_operator(ict, CAIRO_OPERATOR_OVER); } - // render the object (possibly to the intermediate surface) - state = NR_ARENA_ITEM_VIRTUAL (item, render) (this_ct, item, this_area, pb, flags); + // 3. Render object itself + cairo_push_group_with_content(ict, CAIRO_CONTENT_COLOR_ALPHA); + state = NR_ARENA_ITEM_VIRTUAL (item, render) (ict, item, &carea, pb, flags); + cairo_pop_group_to_source(ict); if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; + retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); + goto cleanup; } - // apply filter + // 4. Apply filter if (item->filter && filter) { + // TODO: creating the Cairo context here only to pass it to the filter renderer, + // which calls cairo_get_target almost immediately, is rather silly. + // See whether creating the context can be avoided. + // Could also be fixed in Cairo by fixing cairo_get_target() to return + // the intermediate surface when a group is pushed. + cairo_pattern_t *obj = cairo_get_source(ict); + cairo_surface_t *objs; + cairo_pattern_get_surface(obj, &objs); + cairo_t *tct = cairo_create(objs); + cairo_translate(tct, -carea.x0, -carea.y0); NRRectL bgarea(item->arena->canvasarena->cache_area); - item->filter->render(item, ct, &bgarea, this_ct, &carea); + item->filter->render(item, ct, &bgarea, tct, &carea); + cairo_destroy(tct); } - if (needs_intermediate_rendering) { - cairo_surface_t *intermediate = cairo_get_target(this_ct); - cairo_set_source_surface(ct, intermediate, carea.x0, carea.y0); - if (mask) { - cairo_mask(ct, mask->cobj()); - // opacity of masked objects is handled by premultiplying the mask - } else { - // opacity of non-masked objects must be rendered explicitly - if (needs_opacity) { - cairo_paint_with_alpha(ct, opacity); - } else { - cairo_paint(ct); - } - } - cairo_set_source_rgba(ct,0,0,0,0); + // 5. Render object inside the composited mask + clip + cairo_set_operator(ict, CAIRO_OPERATOR_IN); + if (needs_opacity && !item->clip) { + cairo_paint_with_alpha(ict, opacity); + } else { + cairo_paint(ict); } - return item->state | NR_ARENA_ITEM_STATE_RENDER; + // 6. Paint the completed rendering onto the base context + cairo_set_source_surface(ct, intermediate, carea.x0, carea.y0); + cairo_paint(ct); + cairo_set_source_rgba(ct, 0,0,0,0); + + retstate = item->state | NR_ARENA_ITEM_STATE_RENDER; + + cleanup: + cairo_destroy(ict); + cairo_surface_destroy(intermediate); + + return retstate; } unsigned int @@ -530,15 +549,34 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) (&item->bbox)->y0, (&item->bbox)->x1, (&item->bbox)->y1); #endif + unsigned retstate = 0; + + // The item itself has a clipping path + // Render the clipping path onto a temporary surface, then composite it with the item + // using the IN operator + if (item->clip) { + cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); + // The source could have had opacity set, but push_group implicitly saves state + cairo_set_source_rgba(ct, 0,0,0,1); + nr_arena_item_invoke_clip(ct, item->clip, area); + } + if (item->visible && nr_rect_l_test_intersect_ptr(area, &item->bbox)) { /* Need render that item */ if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) { - return ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> + retstate = ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> clip (ct, item, area); } } + + if (item->clip) { + cairo_pop_group_to_source(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_IN); + cairo_paint(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + } - return item->state; + return retstate; } NRArenaItem * diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index ff87b5134..9bece05b5 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -396,22 +396,21 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/) { - guint result = 0; - - // NOTE: for now this is incorrect, because it doesn't honor clip-rule, - // and will be incorrect for nested clipping paths. NRArenaShape *shape = NR_ARENA_SHAPE(item); if (!shape->curve) { - result = item->state; - } else { - cairo_save(ct); - ink_cairo_transform(ct, shape->ctm); - feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); - cairo_restore(ct); - - result = item->state; + return item->state; } - return result; + + // TODO: Handling of the clip-rule property / CSS attribute. + // Once the required bits are in SPStyle, this is as trivial as adding a single + // call to cairo_set_fill_rule() before cairo_fill(). + cairo_save(ct); + ink_cairo_transform(ct, shape->ctm); + feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); + cairo_fill(ct); + cairo_restore(ct); + + return item->state; } static NRArenaItem * -- cgit v1.2.3 From 55fd3861b1b1cc012225ce351bc7f4bfa891e740 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 10 Jul 2011 01:56:02 +0100 Subject: Merge upstream GDL: GNOME_2_30_0 (bzr r10436) --- src/libgdl/Makefile_insert | 4 +- src/libgdl/gdl-combo-button.c | 383 --------------------- src/libgdl/gdl-combo-button.h | 63 ---- src/libgdl/gdl-dock-item-button-image.c | 169 +++++++++ src/libgdl/gdl-dock-item-button-image.h | 70 ++++ src/libgdl/gdl-dock-item-grip.c | 584 +++++++++++++++++--------------- src/libgdl/gdl-dock-item-grip.h | 33 +- src/libgdl/gdl-dock-item.c | 47 +++ src/libgdl/gdl-dock-item.h | 19 +- src/libgdl/gdl-dock-layout.c | 208 +++++++----- src/libgdl/gdl-dock-master.c | 2 + src/libgdl/gdl-dock-master.h | 9 + src/libgdl/gdl-dock-notebook.c | 6 +- src/libgdl/gdl-dock-object.h | 2 +- src/libgdl/gdl-dock-paned.c | 1 + src/libgdl/gdl-dock-placeholder.c | 5 +- src/libgdl/gdl-dock-placeholder.h | 2 +- src/libgdl/gdl-dock.c | 15 - src/libgdl/gdl-stock.c | 126 ------- src/libgdl/gdl-stock.h | 37 -- src/libgdl/gdl-switcher.c | 206 +++-------- src/libgdl/gdl-switcher.h | 24 +- src/libgdl/gdl.h | 33 +- src/libgdl/test-dock.c | 3 + 24 files changed, 861 insertions(+), 1190 deletions(-) delete mode 100644 src/libgdl/gdl-combo-button.c delete mode 100644 src/libgdl/gdl-combo-button.h create mode 100644 src/libgdl/gdl-dock-item-button-image.c create mode 100644 src/libgdl/gdl-dock-item-button-image.h delete mode 100644 src/libgdl/gdl-stock.c delete mode 100644 src/libgdl/gdl-stock.h (limited to 'src') diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert index 2276aa801..e151fd5d6 100644 --- a/src/libgdl/Makefile_insert +++ b/src/libgdl/Makefile_insert @@ -16,7 +16,6 @@ libgdl_libgdl_a_SOURCES = \ libgdl/gdl-dock-tablabel.h \ libgdl/gdl-dock-placeholder.h \ libgdl/gdl-dock-bar.h \ - libgdl/gdl-stock.h \ libgdl/gdl-stock-icons.h \ libgdl/gdl-i18n.h \ libgdl/gdl-i18n.c \ @@ -24,6 +23,8 @@ libgdl_libgdl_a_SOURCES = \ libgdl/gdl-dock-master.c \ libgdl/gdl-dock.c \ libgdl/gdl-dock-item.c \ + libgdl/gdl-dock-item-button-image.c \ + libgdl/gdl-dock-item-button-image.h \ libgdl/gdl-dock-item-grip.h \ libgdl/gdl-dock-item-grip.c \ libgdl/gdl-dock-notebook.c \ @@ -31,7 +32,6 @@ libgdl_libgdl_a_SOURCES = \ libgdl/gdl-dock-tablabel.c \ libgdl/gdl-dock-placeholder.c \ libgdl/gdl-dock-bar.c \ - libgdl/gdl-stock.c \ libgdl/gdl-switcher.h \ libgdl/gdl-switcher.c \ libgdl/gdl-win32.h \ diff --git a/src/libgdl/gdl-combo-button.c b/src/libgdl/gdl-combo-button.c deleted file mode 100644 index 6414a8110..000000000 --- a/src/libgdl/gdl-combo-button.c +++ /dev/null @@ -1,383 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * gdl-combo-button.c - * - * Copyright (C) 2003 Jeroen Zwartepoorte - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "gdl-tools.h" -#include "gdl-combo-button.h" - -struct _GdlComboButtonPrivate { - GtkWidget *default_button; - GtkWidget *image; - GtkWidget *label; - GtkWidget *menu_button; - GtkWidget *menu; - gboolean menu_popped_up; -}; - -GDL_CLASS_BOILERPLATE (GdlComboButton, gdl_combo_button, GtkHBox, GTK_TYPE_HBOX); - -static void -default_button_clicked_cb (GtkButton *button, - gpointer user_data) -{ - GdlComboButton *combo; - GdlComboButtonPrivate *priv; - - combo = GDL_COMBO_BUTTON (user_data); - priv = combo->priv; - - if (!priv->menu_popped_up) - g_signal_emit_by_name (G_OBJECT (combo), - "activate-default", NULL); -} - -static gboolean -default_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - - if (event->type == GDK_BUTTON_PRESS && event->button == 1) { - GTK_BUTTON (priv->menu_button)->button_down = TRUE; - gtk_button_pressed (GTK_BUTTON (priv->menu_button)); - } - - return FALSE; -} - -static gboolean -default_button_release_event_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - - if (event->button == 1) { - gtk_button_released (GTK_BUTTON (priv->menu_button)); - } - - return FALSE; -} - -static gboolean -button_enter_notify_cb (GtkWidget *widget, - GdkEventCrossing *event, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - - if (event->detail != GDK_NOTIFY_INFERIOR) { - GTK_BUTTON (priv->default_button)->in_button = TRUE; - GTK_BUTTON (priv->menu_button)->in_button = TRUE; - gtk_button_enter (GTK_BUTTON (priv->default_button)); - gtk_button_enter (GTK_BUTTON (priv->menu_button)); - } - - return TRUE; -} - -static gboolean -button_leave_notify_cb (GtkWidget *widget, - GdkEventCrossing *event, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - - if (priv->menu_popped_up) - return TRUE; - - if (event->detail != GDK_NOTIFY_INFERIOR) { - GTK_BUTTON (priv->default_button)->in_button = FALSE; - GTK_BUTTON (priv->menu_button)->in_button = FALSE; - gtk_button_leave (GTK_BUTTON (priv->default_button)); - gtk_button_leave (GTK_BUTTON (priv->menu_button)); - } - - return TRUE; -} - -static void -menu_position_func (GtkMenu *menu, - gint *x_return, - gint *y_return, - gboolean *push_in, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - GtkAllocation *allocation; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - allocation = &(priv->default_button->allocation); - - gdk_window_get_origin (priv->default_button->window, x_return, y_return); - - *x_return += allocation->x; - *y_return += allocation->height; -} - -static gboolean -menu_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - - if (event->type == GDK_BUTTON_PRESS && - (event->button == 1 || event->button == 3)) { - GTK_BUTTON (priv->menu_button)->button_down = TRUE; - - gtk_button_pressed (GTK_BUTTON (priv->menu_button)); - - priv->menu_popped_up = TRUE; - gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, - menu_position_func, combo_button, - event->button, event->time); - } - - return TRUE; -} - -static void -menu_deactivate_cb (GtkMenuShell *menu_shell, - gpointer user_data) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (user_data); - priv = combo_button->priv; - - priv->menu_popped_up = FALSE; - - GTK_BUTTON (priv->menu_button)->button_down = FALSE; - GTK_BUTTON (priv->menu_button)->in_button = FALSE; - GTK_BUTTON (priv->default_button)->in_button = FALSE; - gtk_button_leave (GTK_BUTTON (priv->menu_button)); - gtk_button_leave (GTK_BUTTON (priv->default_button)); - gtk_button_clicked (GTK_BUTTON (priv->menu_button)); -} - -static void -menu_detacher (GtkWidget *widget, - GtkMenu *menu) -{ - GdlComboButton *combo_button; - - combo_button = GDL_COMBO_BUTTON (widget); - - g_signal_handlers_disconnect_by_func (G_OBJECT (menu), - menu_deactivate_cb, - combo_button); - combo_button->priv->menu = NULL; -} - -static void -gdl_combo_button_destroy (GtkObject *object) -{ - GdlComboButton *combo_button; - GdlComboButtonPrivate *priv; - - combo_button = GDL_COMBO_BUTTON (object); - priv = combo_button->priv; - - if (priv) { - g_free (priv); - combo_button->priv = NULL; - } - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -gdl_combo_button_class_init (GdlComboButtonClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - parent_class = g_type_class_peek_parent (klass); - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - - object_class->destroy = gdl_combo_button_destroy; - - g_signal_new ("activate-default", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdlComboButtonClass, activate_default), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -gdl_combo_button_instance_init (GdlComboButton *combo_button) -{ - GdlComboButtonPrivate *priv; - GtkWidget *hbox, *align, *arrow; - - priv = g_new (GdlComboButtonPrivate, 1); - combo_button->priv = priv; - - priv->menu = NULL; - priv->menu_popped_up = FALSE; - - priv->default_button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (priv->default_button), GTK_RELIEF_NONE); - - /* Following code copied from gtk_button_construct_child. */ - priv->label = gtk_label_new (""); - gtk_label_set_use_underline (GTK_LABEL (priv->label), TRUE); - gtk_label_set_mnemonic_widget (GTK_LABEL (priv->label), - priv->default_button); - - priv->image = gtk_image_new (); - hbox = gtk_hbox_new (FALSE, 2); - - align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); - - gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbox), priv->label, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (priv->default_button), align); - gtk_container_add (GTK_CONTAINER (align), hbox); - /* End copied block. */ - - gtk_box_pack_start (GTK_BOX (combo_button), priv->default_button, - FALSE, FALSE, 0); - gtk_widget_show_all (priv->default_button); - - priv->menu_button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (priv->menu_button), GTK_RELIEF_NONE); - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (priv->menu_button), arrow); - gtk_box_pack_start (GTK_BOX (combo_button), priv->menu_button, FALSE, - FALSE, 0); - gtk_widget_show_all (priv->menu_button); - - /* Default button. */ - g_signal_connect (G_OBJECT (priv->default_button), "clicked", - G_CALLBACK (default_button_clicked_cb), combo_button); - g_signal_connect (G_OBJECT (priv->default_button), "button_press_event", - G_CALLBACK (default_button_press_event_cb), combo_button); - g_signal_connect (G_OBJECT (priv->default_button), "button_release_event", - G_CALLBACK (default_button_release_event_cb), combo_button); - g_signal_connect (G_OBJECT (priv->default_button), "enter_notify_event", - G_CALLBACK (button_enter_notify_cb), combo_button); - g_signal_connect (G_OBJECT (priv->default_button), "leave_notify_event", - G_CALLBACK (button_leave_notify_cb), combo_button); - - /* Menu button. */ - g_signal_connect (G_OBJECT (priv->menu_button), "button_press_event", - G_CALLBACK (menu_button_press_event_cb), combo_button); - g_signal_connect (G_OBJECT (priv->menu_button), "enter_notify_event", - G_CALLBACK (button_enter_notify_cb), combo_button); - g_signal_connect (G_OBJECT (priv->menu_button), "leave_notify_event", - G_CALLBACK (button_leave_notify_cb), combo_button); -} - -GtkWidget * -gdl_combo_button_new (void) -{ - GtkWidget *combo_button; - - combo_button = GTK_WIDGET (g_object_new (GDL_TYPE_COMBO_BUTTON, NULL)); - - return combo_button; -} - -void -gdl_combo_button_set_icon (GdlComboButton *combo_button, - GdkPixbuf *pixbuf) -{ - GdlComboButtonPrivate *priv; - - g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button)); - g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); - - priv = combo_button->priv; - - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf); -} - -void -gdl_combo_button_set_label (GdlComboButton *combo_button, - const gchar *label) -{ - GdlComboButtonPrivate *priv; - - g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button)); - g_return_if_fail (label != NULL); - - priv = combo_button->priv; - - gtk_label_set_text (GTK_LABEL (priv->label), label); -} - -void -gdl_combo_button_set_menu (GdlComboButton *combo_button, - GtkMenu *menu) -{ - GdlComboButtonPrivate *priv; - - g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button)); - g_return_if_fail (GTK_IS_MENU (menu)); - - priv = combo_button->priv; - - if (priv->menu != NULL) - gtk_menu_detach (GTK_MENU (priv->menu)); - - priv->menu = GTK_WIDGET (menu); - if (menu == NULL) - return; - - gtk_menu_attach_to_widget (menu, GTK_WIDGET (combo_button), menu_detacher); - - g_signal_connect (G_OBJECT (menu), "deactivate", - G_CALLBACK (menu_deactivate_cb), combo_button); -} diff --git a/src/libgdl/gdl-combo-button.h b/src/libgdl/gdl-combo-button.h deleted file mode 100644 index 2f9c3ca2c..000000000 --- a/src/libgdl/gdl-combo-button.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * gdl-combo-button.h - * - * Copyright (C) 2003 Jeroen Zwartepoorte - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _GDL_COMBO_BUTTON_H_ -#define _GDL_COMBO_BUTTON_H_ - -#include - -G_BEGIN_DECLS - -#define GDL_TYPE_COMBO_BUTTON (gdl_combo_button_get_type ()) -#define GDL_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_COMBO_BUTTON, GdlComboButton)) -#define GDL_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_COMBO_BUTTON, GdlComboButtonClass)) -#define GDL_IS_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_COMBO_BUTTON)) -#define GDL_IS_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_COMBO_BUTTON)) - -typedef struct _GdlComboButton GdlComboButton; -typedef struct _GdlComboButtonPrivate GdlComboButtonPrivate; -typedef struct _GdlComboButtonClass GdlComboButtonClass; - -struct _GdlComboButton { - GtkHBox parent; - - GdlComboButtonPrivate *priv; -}; - -struct _GdlComboButtonClass { - GtkHBoxClass parent_class; - - /* Signals. */ - void (* activate_default) (GdlComboButton *combo_button); -}; - -GType gdl_combo_button_get_type (void); -GtkWidget *gdl_combo_button_new (void); - -void gdl_combo_button_set_icon (GdlComboButton *combo_button, - GdkPixbuf *pixbuf); -void gdl_combo_button_set_label (GdlComboButton *combo_button, - const gchar *label); -void gdl_combo_button_set_menu (GdlComboButton *combo_button, - GtkMenu *menu); - -G_END_DECLS - -#endif /* _GDL_COMBO_BUTTON_H_ */ diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c new file mode 100644 index 000000000..f115c652c --- /dev/null +++ b/src/libgdl/gdl-dock-item-button-image.c @@ -0,0 +1,169 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * gdl-dock-item-button-image.c + * + * Author: Joel Holdsworth + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "gdl-dock-item-button-image.h" + +#include +#include "gdl-tools.h" + +#define ICON_SIZE 12 + +GDL_CLASS_BOILERPLATE (GdlDockItemButtonImage, + gdl_dock_item_button_image, + GtkWidget, GTK_TYPE_WIDGET); + +static gint +gdl_dock_item_button_image_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + GdlDockItemButtonImage *button_image; + GtkStyle *style; + GdkColor *color; + + g_return_val_if_fail (widget != NULL, 0); + button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget); + + cairo_t *cr = gdk_cairo_create (event->window); + cairo_translate (cr, event->area.x, event->area.y); + + /* Set up the pen */ + cairo_set_line_width(cr, 1.0); + + style = gtk_widget_get_style (widget); + g_return_if_fail (style != NULL); + color = &style->fg[GTK_STATE_NORMAL]; + cairo_set_source_rgba(cr, color->red / 65535.0, + color->green / 65535.0, color->blue / 65535.0, 0.55); + + /* Draw the icon border */ + cairo_move_to (cr, 10.5, 2.5); + cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0); + cairo_line_to (cr, 12.5, 10.5); + cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI); + cairo_line_to (cr, 4.5, 12.5); + cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI); + cairo_line_to (cr, 2.5, 4.5); + cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI); + cairo_close_path (cr); + + cairo_stroke (cr); + + /* Draw the icon */ + cairo_new_path (cr); + + switch(button_image->image_type) { + case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE: + cairo_move_to (cr, 4.0, 5.5); + cairo_line_to (cr, 4.0, 5.5); + cairo_line_to (cr, 6.0, 7.5); + cairo_line_to (cr, 4.0, 9.5); + cairo_line_to (cr, 5.5, 11.0); + cairo_line_to (cr, 7.5, 9.0); + cairo_line_to (cr, 9.5, 11.0); + cairo_line_to (cr, 11.0, 9.5); + cairo_line_to (cr, 9.0, 7.5); + cairo_line_to (cr, 11.0, 5.5); + cairo_line_to (cr, 9.5, 4.0); + cairo_line_to (cr, 7.5, 6.0); + cairo_line_to (cr, 5.5, 4.0); + cairo_close_path (cr); + break; + + case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY: + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { + cairo_move_to (cr, 4.5, 7.5); + cairo_line_to (cr, 10.0, 4.75); + cairo_line_to (cr, 10.0, 10.25); + cairo_close_path (cr); + } else { + cairo_move_to (cr, 10.5, 7.5); + cairo_line_to (cr, 5, 4.75); + cairo_line_to (cr, 5, 10.25); + cairo_close_path (cr); + } + break; + + default: + break; + } + + cairo_fill (cr); + + /* Finish up */ + cairo_destroy (cr); + + return 0; +} + +static void +gdl_dock_item_button_image_instance_init ( + GdlDockItemButtonImage *button_image) +{ + GTK_WIDGET_SET_FLAGS (button_image, GTK_NO_WINDOW); +} + +static void +gdl_dock_item_button_image_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + g_return_if_fail (GDL_IS_DOCK_ITEM_BUTTON_IMAGE (widget)); + g_return_if_fail (requisition != NULL); + + requisition->width = ICON_SIZE; + requisition->height = ICON_SIZE; +} + +static void +gdl_dock_item_button_image_class_init ( + GdlDockItemButtonImageClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + widget_class->expose_event = + gdl_dock_item_button_image_expose; + widget_class->size_request = + gdl_dock_item_button_image_size_request; +} + +/* ----- Public interface ----- */ + +/** + * gdl_dock_item_button_image_new: + * @param image_type: Specifies what type of image the widget should + * display + * + * Creates a new GDL dock button image object. + * Returns: The newly created dock item button image widget. + **/ +GtkWidget* +gdl_dock_item_button_image_new (GdlDockItemButtonImageType image_type) +{ + GdlDockItemButtonImage *button_image = g_object_new ( + GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, NULL); + button_image->image_type = image_type; + + return GTK_WIDGET (button_image); +} diff --git a/src/libgdl/gdl-dock-item-button-image.h b/src/libgdl/gdl-dock-item-button-image.h new file mode 100644 index 000000000..ce0c6faaf --- /dev/null +++ b/src/libgdl/gdl-dock-item-button-image.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * gdl-dock-item-button-image.h + * + * Author: Joel Holdsworth + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ +#define _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ + +#include + +G_BEGIN_DECLS + +/* Standard Macros */ +#define GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE \ + (gdl_dock_item_button_image_get_type()) +#define GDL_DOCK_ITEM_BUTTON_IMAGE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImage)) +#define GDL_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass)) +#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE)) +#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE)) +#define GDL_DOCK_ITEM_BUTTON_IMAGE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass)) + +/* Data Types & Structures */ +typedef enum { + GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE, + GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY +} GdlDockItemButtonImageType; + +typedef struct _GdlDockItemButtonImage GdlDockItemButtonImage; +typedef struct _GdlDockItemButtonImageClass GdlDockItemButtonImageClass; + +struct _GdlDockItemButtonImage { + GtkWidget parent; + + GdlDockItemButtonImageType image_type; +}; + +struct _GdlDockItemButtonImageClass { + GtkWidgetClass parent_class; +}; + +/* Data Public Functions */ +GType gdl_dock_item_button_image_get_type (void); +GtkWidget *gdl_dock_item_button_image_new ( + GdlDockItemButtonImageType image_type); + +G_END_DECLS + +#endif /* _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ */ diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 7f7d17ab2..c5eb6f370 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -1,13 +1,30 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/** +/* * gdl-dock-item-grip.c * - * Based on bonobo-dock-item-grip. Original copyright notice follows. + * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc. + * + * Based on BonoboDockItemGrip. Original copyright notice follows. + * + * Copyright (C) 1998 Ettore Perazzoli + * Copyright (C) 1998 Elliot Lee + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * All rights reserved. * - * Author: - * Michael Meeks + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * Copyright (C) 2002 Sun Microsystems, Inc. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -20,10 +37,12 @@ #include #include "gdl-dock-item.h" #include "gdl-dock-item-grip.h" -#include "gdl-stock.h" +#include "gdl-dock-item-button-image.h" +#include "gdl-switcher.h" #include "gdl-tools.h" #define ALIGN_BORDER 5 +#define DRAG_HANDLE_SIZE 10 enum { PROP_0, @@ -31,93 +50,64 @@ enum { }; struct _GdlDockItemGripPrivate { + GtkWidget *label; + GtkWidget *close_button; GtkWidget *iconify_button; - - gboolean icon_pixbuf_valid; - GdkPixbuf *icon_pixbuf; - - gchar *title; - PangoLayout *title_layout; + + gboolean handle_shown; }; GDL_CLASS_BOILERPLATE (GdlDockItemGrip, gdl_dock_item_grip, GtkContainer, GTK_TYPE_CONTAINER); - -/* must be called after size_allocate */ -static void -gdl_dock_item_grip_get_title_area (GdlDockItemGrip *grip, - GdkRectangle *area) -{ - GtkWidget *widget = GTK_WIDGET (grip); - gint border = GTK_CONTAINER (grip)->border_width; - gint alloc_height; - - area->width = (widget->allocation.width - 2 * border - ALIGN_BORDER); - - pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &alloc_height); - - alloc_height = MAX (grip->_priv->close_button->allocation.height, alloc_height); - alloc_height = MAX (grip->_priv->iconify_button->allocation.height, alloc_height); - if (gtk_widget_get_visible (grip->_priv->close_button)) { - area->width -= grip->_priv->close_button->allocation.width; - } - if (gtk_widget_get_visible (grip->_priv->iconify_button)) { - area->width -= grip->_priv->iconify_button->allocation.width; - } - - area->x = widget->allocation.x + border + ALIGN_BORDER; - area->y = widget->allocation.y + border; - area->height = alloc_height; - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - area->x += (widget->allocation.width - 2 * border) - area->width; -} - -static void -ensure_title_and_icon_pixbuf (GdlDockItemGrip *grip) + +GtkWidget* +gdl_dock_item_create_label_widget(GdlDockItemGrip *grip) { - gchar *stock_id; + GtkHBox *label_box; + GtkImage *image; + GtkLabel *label; + gchar *stock_id = NULL; + gchar *title = NULL; GdkPixbuf *pixbuf; + + label_box = (GtkHBox*)gtk_hbox_new (FALSE, 0); - g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (grip)); - - /* get long name property from the dock object */ - if (!grip->_priv->title) { - g_object_get (G_OBJECT (grip->item), "long-name", &grip->_priv->title, NULL); - if (!grip->_priv->title) - grip->_priv->title = g_strdup (""); - } - - /* retrieve stock pixbuf, if any */ - if (!grip->_priv->icon_pixbuf_valid) { - g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL); + g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL); + g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL); + if(stock_id) { + image = GTK_IMAGE(gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU)); - if (stock_id) { - grip->_priv->icon_pixbuf = gtk_widget_render_icon (GTK_WIDGET (grip), - stock_id, - GTK_ICON_SIZE_MENU, ""); - g_free (stock_id); - grip->_priv->icon_pixbuf_valid = TRUE; - } + gtk_widget_show (GTK_WIDGET(image)); + gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0); + + g_free (stock_id); + } + else if (pixbuf) { + image = GTK_IMAGE(gtk_image_new_from_pixbuf (pixbuf)); + + gtk_widget_show (GTK_WIDGET(image)); + gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0); } - - /* retrieve pixbuf icon, if any */ - if (!grip->_priv->icon_pixbuf_valid) { - g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL); - if (pixbuf) { - grip->_priv->icon_pixbuf = pixbuf; - grip->_priv->icon_pixbuf_valid = TRUE; + g_object_get (G_OBJECT (grip->item), "long-name", &title, NULL); + if (title) { + label = GTK_LABEL(gtk_label_new(title)); + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); + gtk_label_set_justify(label, GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_widget_show (GTK_WIDGET(label)); + + if (gtk_widget_get_direction (GTK_WIDGET(grip)) == GTK_TEXT_DIR_RTL) { + gtk_box_pack_end(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1); + } else { + gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1); } + + g_free(title); } - - /* create layout: the actual text is reset at size_allocate */ - if (!grip->_priv->title_layout) { - grip->_priv->title_layout = gtk_widget_create_pango_layout (GTK_WIDGET (grip), - grip->_priv->title); - pango_layout_set_single_paragraph_mode (grip->_priv->title_layout, TRUE); - } + + return GTK_WIDGET(label_box); } static gint @@ -125,6 +115,14 @@ gdl_dock_item_grip_expose (GtkWidget *widget, GdkEventExpose *event) { GdlDockItemGrip *grip; +/*<<<<<<< HEAD */ + GdkRectangle handle_area; + GdkRectangle expose_area; + + grip = GDL_DOCK_ITEM_GRIP (widget); + + if(grip->_priv->handle_shown) { +/*======= GdkRectangle title_area; GdkRectangle expose_area; GdkGC *bg_style; @@ -134,11 +132,11 @@ gdl_dock_item_grip_expose (GtkWidget *widget, gint text_y; grip = GDL_DOCK_ITEM_GRIP (widget); - gdl_dock_item_grip_get_title_area (grip, &title_area); + gdl_dock_item_grip_get_title_area (grip, &title_area); */ /* draw background, highlight it if the dock item or any of its * descendants have focus */ - bg_style = (gdl_dock_item_or_child_has_focus (grip->item) ? +/* bg_style = (gdl_dock_item_or_child_has_focus (grip->item) ? gtk_widget_get_style (widget)->dark_gc[widget->state] : gtk_widget_get_style (widget)->mid_gc[widget->state]); @@ -148,51 +146,35 @@ gdl_dock_item_grip_expose (GtkWidget *widget, if (grip->_priv->icon_pixbuf) { GdkRectangle pixbuf_rect; +>>>>>>> gdl-2.26.0-with-inkscape */ - pixbuf_rect.width = gdk_pixbuf_get_width (grip->_priv->icon_pixbuf); - pixbuf_rect.height = gdk_pixbuf_get_height (grip->_priv->icon_pixbuf); - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) { - pixbuf_rect.x = title_area.x + title_area.width - pixbuf_rect.width; + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { + handle_area.x = widget->allocation.x; + handle_area.y = widget->allocation.y; + handle_area.width = DRAG_HANDLE_SIZE; + handle_area.height = widget->allocation.height; } else { - pixbuf_rect.x = title_area.x; - title_area.x += pixbuf_rect.width + 1; + handle_area.x = widget->allocation.x + widget->allocation.width + - DRAG_HANDLE_SIZE; + handle_area.y = widget->allocation.y; + handle_area.width = DRAG_HANDLE_SIZE; + handle_area.height = widget->allocation.height; } - /* shrink title area by the pixbuf width plus a 1px spacing */ - title_area.width -= pixbuf_rect.width + 1; - pixbuf_rect.y = title_area.y + (title_area.height - pixbuf_rect.height) / 2; - - if (gdk_rectangle_intersect (&event->area, &pixbuf_rect, &expose_area)) { - GdkGC *gc; - GtkStyle *style; - - style = gtk_widget_get_style (widget); - gc = style->bg_gc[widget->state]; - gdk_draw_pixbuf (GDK_DRAWABLE (widget->window), gc, - grip->_priv->icon_pixbuf, - 0, 0, pixbuf_rect.x, pixbuf_rect.y, - pixbuf_rect.width, pixbuf_rect.height, - GDK_RGB_DITHER_NONE, 0, 0); - } - } - if (gdk_rectangle_intersect (&title_area, &event->area, &expose_area)) { - pango_layout_get_pixel_size (grip->_priv->title_layout, &layout_width, - &layout_height); + if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) { - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - text_x = title_area.x + title_area.width - layout_width; - else - text_x = title_area.x; - - text_y = title_area.y + (title_area.height - layout_height) / 2; - - gtk_paint_layout (widget->style, widget->window, widget->state, TRUE, - &expose_area, widget, NULL, text_x, text_y, - grip->_priv->title_layout); + gtk_paint_handle (widget->style, widget->window, widget->state, + GTK_SHADOW_NONE, &expose_area, widget, + "handlebox", handle_area.x, handle_area.y, + handle_area.width, handle_area.height, + GTK_ORIENTATION_VERTICAL); + + } + } return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); -} +} static void gdl_dock_item_grip_item_notify (GObject *master, @@ -205,23 +187,12 @@ gdl_dock_item_grip_item_notify (GObject *master, grip = GDL_DOCK_ITEM_GRIP (data); - if (strcmp (pspec->name, "stock-id") == 0) { - if (grip->_priv->icon_pixbuf) { - g_object_unref (grip->_priv->icon_pixbuf); - grip->_priv->icon_pixbuf = NULL; - } - grip->_priv->icon_pixbuf_valid = FALSE; - ensure_title_and_icon_pixbuf (grip); - - } else if (strcmp (pspec->name, "long-name") == 0) { - if (grip->_priv->title_layout) { - g_object_unref (grip->_priv->title_layout); - grip->_priv->title_layout = NULL; - } - g_free (grip->_priv->title); - grip->_priv->title = NULL; - ensure_title_and_icon_pixbuf (grip); - gtk_widget_queue_draw (GTK_WIDGET (grip)); + if ((strcmp (pspec->name, "stock-id") == 0) || + (strcmp (pspec->name, "long-name") == 0)) { + + gdl_dock_item_grip_set_label (grip, + gdl_dock_item_create_label_widget(grip)); + } else if (strcmp (pspec->name, "behavior") == 0) { cursor = FALSE; if (grip->_priv->close_button) { @@ -250,20 +221,13 @@ static void gdl_dock_item_grip_destroy (GtkObject *object) { GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (object); - + if (grip->_priv) { GdlDockItemGripPrivate *priv = grip->_priv; - if (priv->title_layout) { - g_object_unref (priv->title_layout); - priv->title_layout = NULL; - } - g_free (priv->title); - priv->title = NULL; - - if (priv->icon_pixbuf) { - g_object_unref (priv->icon_pixbuf); - priv->icon_pixbuf = NULL; + if (priv->label) { + gtk_widget_unparent(grip->_priv->label); + priv->label = NULL; } if (grip->item) @@ -275,7 +239,7 @@ gdl_dock_item_grip_destroy (GtkObject *object) grip->_priv = NULL; g_free (priv); } - + GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); } @@ -331,10 +295,34 @@ static void gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, GdlDockItemGrip *grip) { + GtkWidget *parent; + (void)widget; g_return_if_fail (grip->item != NULL); - gdl_dock_item_iconify_item (grip->item); + parent = gtk_widget_get_parent (GTK_WIDGET (grip->item)); + if (GDL_IS_SWITCHER (parent)) + { + /* Note: We can not use gtk_container_foreach (parent) here because + * during iconificatoin, the internal children changes in parent. + * Instead we keep a list of items to iconify and iconify them + * one by one. + */ + GList *node; + GList *items = + gtk_container_get_children (GTK_CONTAINER (parent)); + for (node = items; node != NULL; node = node->next) + { + GdlDockItem *item = GDL_DOCK_ITEM (node->data); + if (!GDL_DOCK_ITEM_CANT_ICONIFY (item)) + gdl_dock_item_iconify_item (item); + } + g_list_free (items); + } + else + { + gdl_dock_item_iconify_item (grip->item); + } /* Workaround to unhighlight the iconify button. */ GTK_BUTTON (grip->_priv->iconify_button)->in_button = FALSE; @@ -349,10 +337,9 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE); grip->_priv = g_new0 (GdlDockItemGripPrivate, 1); - grip->_priv->icon_pixbuf_valid = FALSE; - grip->_priv->icon_pixbuf = NULL; - grip->_priv->title_layout = NULL; - + grip->_priv->label = NULL; + grip->_priv->handle_shown = FALSE; + /* create the close button */ gtk_widget_push_composite_child (); grip->_priv->close_button = gtk_button_new (); @@ -363,7 +350,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE); gtk_widget_show (grip->_priv->close_button); - image = gtk_image_new_from_stock (GDL_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE); gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image); gtk_widget_show (image); @@ -380,7 +367,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE); gtk_widget_show (grip->_priv->iconify_button); - image = gtk_image_new_from_stock (GDL_STOCK_MENU_RIGHT, GTK_ICON_SIZE_MENU); + image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY); gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image); gtk_widget_show (image); @@ -401,33 +388,36 @@ gdl_dock_item_grip_realize (GtkWidget *widget) GTK_WIDGET_CLASS (parent_class)->realize (widget); + g_return_if_fail (grip->_priv != NULL); + if (!grip->title_window) { GdkWindowAttr attributes; - GdkRectangle area; GdkCursor *cursor; - ensure_title_and_icon_pixbuf (grip); - gdl_dock_item_grip_get_title_area (grip, &area); - - attributes.x = area.x; - attributes.y = area.y; - attributes.width = area.width; - attributes.height = area.height; - attributes.window_type = GDK_WINDOW_TEMP; - attributes.wclass = GDK_INPUT_ONLY; - attributes.override_redirect = TRUE; - attributes.event_mask = (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_MOTION_MASK | - gtk_widget_get_events (widget)); + g_return_if_fail (grip->_priv->label != NULL); + + attributes.x = grip->_priv->label->allocation.x; + attributes.y = grip->_priv->label->allocation.y; + attributes.width = grip->_priv->label->allocation.width; + attributes.height = grip->_priv->label->allocation.height; + attributes.window_type = GDK_WINDOW_CHILD; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.event_mask = GDK_ALL_EVENTS_MASK; grip->title_window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, - (GDK_WA_X | - GDK_WA_Y | - GDK_WA_NOREDIR)); + &attributes, (GDK_WA_X | GDK_WA_Y)); + + gdk_window_set_user_data (grip->title_window, grip); + + /* Unref the ref from parent realize for NO_WINDOW */ + g_object_unref (widget->window); + + /* Need to ref widget->window, because parent unrealize unrefs it */ + widget->window = g_object_ref (grip->title_window); + GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW); - gdk_window_set_user_data (grip->title_window, widget); + /* Unset the background so as to make the colour match the parent window */ + gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, NULL); if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) @@ -447,6 +437,7 @@ gdl_dock_item_grip_unrealize (GtkWidget *widget) GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); if (grip->title_window) { + GTK_WIDGET_SET_FLAGS(widget, GTK_NO_WINDOW); gdk_window_set_user_data (grip->title_window, NULL); gdk_window_destroy (grip->title_window); grip->title_window = NULL; @@ -484,7 +475,7 @@ gdl_dock_item_grip_size_request (GtkWidget *widget, GtkRequisition child_requisition; GtkContainer *container; GdlDockItemGrip *grip; - gint layout_height; + gint layout_height = 0; g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); g_return_if_fail (requisition != NULL); @@ -492,11 +483,11 @@ gdl_dock_item_grip_size_request (GtkWidget *widget, container = GTK_CONTAINER (widget); grip = GDL_DOCK_ITEM_GRIP (widget); - requisition->width = container->border_width * 2 + ALIGN_BORDER; + requisition->width = container->border_width * 2/* + ALIGN_BORDER*/; requisition->height = container->border_width * 2; - ensure_title_and_icon_pixbuf (grip); - pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &layout_height); + if(grip->_priv->handle_shown) + requisition->width += DRAG_HANDLE_SIZE; gtk_widget_size_request (grip->_priv->close_button, &child_requisition); layout_height = MAX (layout_height, child_requisition.height); @@ -509,54 +500,12 @@ gdl_dock_item_grip_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { requisition->width += child_requisition.width; } - - requisition->height += layout_height; - - if (grip->_priv->icon_pixbuf) { - requisition->width += gdk_pixbuf_get_width (grip->_priv->icon_pixbuf) + 1; - } -} - -#define ELLIPSIS "..." - -static void -ellipsize_layout (PangoLayout *layout, gint width) -{ - PangoLayoutLine *line; - PangoLayout *ell; - gint h, w, ell_w, x; - GString *text; - - if (width <= 0) { - pango_layout_set_text (layout, "", -1); - return; - } - - pango_layout_get_pixel_size (layout, &w, &h); - if (w <= width) return; + + gtk_widget_size_request (grip->_priv->label, &child_requisition); + requisition->width += child_requisition.width; + layout_height = MAX (layout_height, child_requisition.height); - /* calculate ellipsis width */ - ell = pango_layout_copy (layout); - pango_layout_set_text (ell, ELLIPSIS, -1); - pango_layout_get_pixel_size (ell, &ell_w, NULL); - g_object_unref (ell); - - if (width < ell_w) { - /* not even ellipsis fits, so hide the text */ - pango_layout_set_text (layout, "", -1); - return; - } - - /* shrink total available width by the width of the ellipsis */ - width -= ell_w; - line = pango_layout_get_line (layout, 0); - text = g_string_new (pango_layout_get_text (layout)); - if (pango_layout_line_x_to_index (line, width * PANGO_SCALE, &x, NULL)) { - g_string_set_size (text, x); - g_string_append (text, ELLIPSIS); - pango_layout_set_text (layout, text->str, -1); - } - g_string_free (text, TRUE); + requisition->height += layout_height; } static void @@ -565,9 +514,10 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, { GdlDockItemGrip *grip; GtkContainer *container; - GtkRequisition button_requisition; + GtkRequisition close_requisition = { 0, }; + GtkRequisition iconify_requisition = { 0, }; GtkAllocation child_allocation; - memset(&button_requisition, 0, sizeof(button_requisition)); + GdkRectangle label_area; g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); g_return_if_fail (allocation != NULL); @@ -577,59 +527,96 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + gtk_widget_size_request (grip->_priv->close_button, + &close_requisition); + gtk_widget_size_request (grip->_priv->iconify_button, + &iconify_requisition); + + /* Calculate the Minimum Width where buttons will fit */ + int min_width = close_requisition.width + iconify_requisition.width + + container->border_width * 2; + if(grip->_priv->handle_shown) + min_width += DRAG_HANDLE_SIZE; + const gboolean space_for_buttons = (allocation->width >= min_width); + + /* Set up the rolling child_allocation rectangle */ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + container->border_width + ALIGN_BORDER; + child_allocation.x = container->border_width/* + ALIGN_BORDER*/; else - child_allocation.x = allocation->x + allocation->width - container->border_width; - child_allocation.y = allocation->y + container->border_width; + child_allocation.x = allocation->width - container->border_width; + child_allocation.y = container->border_width; + /* Layout Close Button */ if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) { - gtk_widget_size_request (grip->_priv->close_button, &button_requisition); - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) - child_allocation.x -= button_requisition.width; - - child_allocation.width = button_requisition.width; - child_allocation.height = button_requisition.height; + if(space_for_buttons) { + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) + child_allocation.x -= close_requisition.width; + + child_allocation.width = close_requisition.width; + child_allocation.height = close_requisition.height; + } else { + child_allocation.width = 0; + } gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x += button_requisition.width; + child_allocation.x += close_requisition.width; } + /* Layout Iconify Button */ if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { - gtk_widget_size_request (grip->_priv->iconify_button, &button_requisition); - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) - child_allocation.x -= button_requisition.width; + if(space_for_buttons) { + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) + child_allocation.x -= iconify_requisition.width; - child_allocation.width = button_requisition.width; - child_allocation.height = button_requisition.height; + child_allocation.width = iconify_requisition.width; + child_allocation.height = iconify_requisition.height; + } else { + child_allocation.width = 0; + } gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x += button_requisition.width; + child_allocation.x += iconify_requisition.width; } - if (grip->title_window) { - GdkRectangle area; + /* Layout the Grip Handle*/ + if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { + child_allocation.width = child_allocation.x; + child_allocation.x = container->border_width/* + ALIGN_BORDER*/; - /* set layout text */ - ensure_title_and_icon_pixbuf (grip); - pango_layout_set_text (grip->_priv->title_layout, grip->_priv->title, -1); - - gdl_dock_item_grip_get_title_area (grip, &area); - - gdk_window_move_resize (grip->title_window, - area.x, area.y, area.width, area.height); - - if (grip->_priv->icon_pixbuf) - area.width -= gdk_pixbuf_get_width (grip->_priv->icon_pixbuf) + 1; + if(grip->_priv->handle_shown) { + child_allocation.x += DRAG_HANDLE_SIZE; + child_allocation.width -= DRAG_HANDLE_SIZE; + } + + } else { + child_allocation.width = allocation->width - + (child_allocation.x - allocation->x)/* - ALIGN_BORDER*/; - /* ellipsize title if it doesn't fit the title area */ - ellipsize_layout (grip->_priv->title_layout, area.width); + if(grip->_priv->handle_shown) + child_allocation.width -= DRAG_HANDLE_SIZE; + } + + if(child_allocation.width < 0) + child_allocation.width = 0; + + child_allocation.y = container->border_width; + child_allocation.height = allocation->height - container->border_width * 2; + if(grip->_priv->label) { + gtk_widget_size_allocate (grip->_priv->label, &child_allocation); + } + + if (grip->title_window) { + gdk_window_move_resize (grip->title_window, + allocation->x, + allocation->y, + allocation->width, + allocation->height); } } @@ -646,9 +633,8 @@ static void gdl_dock_item_grip_remove (GtkContainer *container, GtkWidget *widget) { - (void)container; (void)widget; - g_warning ("gtk_container_remove not implemented for GdlDockItemGrip"); + gdl_dock_item_grip_set_label (GDL_DOCK_ITEM_GRIP (container), NULL); } static void @@ -660,12 +646,17 @@ gdl_dock_item_grip_forall (GtkContainer *container, GdlDockItemGrip *grip; g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (container)); - grip = GDL_DOCK_ITEM_GRIP (container); + + if (grip->_priv) { + if(grip->_priv->label) { + (* callback) (grip->_priv->label, callback_data); + } - if (include_internals) { - (* callback) (grip->_priv->close_button, callback_data); - (* callback) (grip->_priv->iconify_button, callback_data); + if (include_internals) { + (* callback) (grip->_priv->close_button, callback_data); + (* callback) (grip->_priv->iconify_button, callback_data); + } } } @@ -713,9 +704,12 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass) _("Dockitem which 'owns' this grip"), GDL_TYPE_DOCK_ITEM, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); +} - /* initialize stock images */ - gdl_stock_init (); +static void +gdl_dock_item_grip_showhide_handle (GdlDockItemGrip *grip) +{ + gtk_widget_queue_resize (GTK_WIDGET (grip)); } /* ----- Public interface ----- */ @@ -735,3 +729,61 @@ gdl_dock_item_grip_new (GdlDockItem *item) return GTK_WIDGET (grip); } + +/** + * gdl_dock_item_grip_set_label: + * @grip: The grip that will get it's label widget set. + * @label: The widget that will become the label. + * + * Replaces the current label widget with another widget. + **/ +void +gdl_dock_item_grip_set_label (GdlDockItemGrip *grip, + GtkWidget *label) +{ + g_return_if_fail (grip != NULL); + + if (grip->_priv->label) { + gtk_widget_unparent(grip->_priv->label); + g_object_unref (grip->_priv->label); + grip->_priv->label = NULL; + } + + if (label) { + g_object_ref (label); + gtk_widget_set_parent (label, GTK_WIDGET (grip)); + gtk_widget_show (label); + grip->_priv->label = label; + } +} +/** + * gdl_dock_item_grip_hide_handle: + * @item: The dock item grip to hide the handle of. + * + * This function hides the dock item's grip widget handle hatching. + **/ +void +gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip) +{ + g_return_if_fail (grip != NULL); + if (grip->_priv->handle_shown) { + grip->_priv->handle_shown = FALSE; + gdl_dock_item_grip_showhide_handle (grip); + }; +} + +/** + * gdl_dock_item_grip_show_handle: + * @grip: The dock item grip to show the handle of. + * + * This function shows the dock item's grip widget handle hatching. + **/ +void +gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip) +{ + g_return_if_fail (grip != NULL); + if (!grip->_priv->handle_shown) { + grip->_priv->handle_shown = TRUE; + gdl_dock_item_grip_showhide_handle (grip); + }; +} diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h index 4dfdd7ab3..a44ef91fb 100644 --- a/src/libgdl/gdl-dock-item-grip.h +++ b/src/libgdl/gdl-dock-item-grip.h @@ -1,13 +1,30 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/** +/* * gdl-dock-item-grip.h - * - * Based on bonobo-dock-item-grip. Original copyright notice follows. * - * Author: - * Michael Meeks + * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc. * - * Copyright (C) 2002 Sun Microsystems, Inc. + * Based on BonoboDockItemGrip. Original copyright notice follows. + * + * Copyright (C) 1998 Ettore Perazzoli + * Copyright (C) 1998 Elliot Lee + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifndef _GDL_DOCK_ITEM_GRIP_H_ @@ -50,6 +67,10 @@ struct _GdlDockItemGripClass { GType gdl_dock_item_grip_get_type (void); GtkWidget *gdl_dock_item_grip_new (GdlDockItem *item); +void gdl_dock_item_grip_set_label (GdlDockItemGrip *grip, + GtkWidget *label); +void gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip); +void gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip); G_END_DECLS diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 86f729c61..0c0d765df 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -163,6 +163,7 @@ enum { DOCK_DRAG_BEGIN, DOCK_DRAG_MOTION, DOCK_DRAG_END, + SELECTED, MOVE_FOCUS_CHILD, LAST_SIGNAL }; @@ -407,6 +408,22 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) 1, G_TYPE_BOOLEAN); + /** + * GdlDockItem::selected: + * + * Signals that this dock has been selected from a switcher. + */ + gdl_dock_item_signals [SELECTED] = + g_signal_new ("selected", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + gdl_dock_item_signals [MOVE_FOCUS_CHILD] = g_signal_new ("move_focus_child", G_TYPE_FROM_CLASS (klass), @@ -1924,6 +1941,23 @@ gdl_dock_item_set_tablabel (GdlDockItem *item, } } +/** + * gdl_dock_item_get_grip: + * @item: The dock item from which to to get the grip of. + * + * This function returns the dock item's grip label widget. + * + * Returns: Returns the current label widget. + **/ +GtkWidget * +gdl_dock_item_get_grip(GdlDockItem *item) +{ + g_return_if_fail (item != NULL); + g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL); + + return item->_priv->grip; +} + /** * gdl_dock_item_hide_grip: * @item: The dock item to hide the grip of. @@ -1957,6 +1991,19 @@ gdl_dock_item_show_grip (GdlDockItem *item) }; } +/** + * gdl_dock_item_notify_selected: + * @item: the dock item to emit a selected signal on. + * + * This function emits the selected signal. It is to be used by #GdlSwitcher + * to let clients know that this item has been switched to. + **/ +void +gdl_dock_item_notify_selected (GdlDockItem *item) +{ + g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0); +} + /* convenient function (and to preserve source compat) */ /** * gdl_dock_item_bind: diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h index 6c0029d13..d97fdf6fd 100644 --- a/src/libgdl/gdl-dock-item.h +++ b/src/libgdl/gdl-dock-item.h @@ -93,17 +93,16 @@ struct _GdlDockItemClass { gboolean has_grip; /* virtuals */ - void (* dock_drag_begin) (GdlDockItem *item); - void (* dock_drag_motion) (GdlDockItem *item, - gint x, - gint y); - void (* dock_drag_end) (GdlDockItem *item, - gboolean cancelled); + void (* dock_drag_begin) (GdlDockItem *item); + void (* dock_drag_motion) (GdlDockItem *item, + gint x, + gint y); + void (* dock_drag_end) (GdlDockItem *item, + gboolean cancelled); void (* move_focus_child) (GdlDockItem *item, GtkDirectionType direction); - - void (* set_orientation) (GdlDockItem *item, - GtkOrientation orientation); + void (* set_orientation) (GdlDockItem *item, + GtkOrientation orientation); }; /* additional macros */ @@ -163,8 +162,10 @@ void gdl_dock_item_set_orientation (GdlDockItem *item, GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item); void gdl_dock_item_set_tablabel (GdlDockItem *item, GtkWidget *tablabel); +GtkWidget *gdl_dock_item_get_grip (GdlDockItem *item); void gdl_dock_item_hide_grip (GdlDockItem *item); void gdl_dock_item_show_grip (GdlDockItem *item); +void gdl_dock_item_notify_selected (GdlDockItem *item); /* bind and unbind items to a dock */ void gdl_dock_item_bind (GdlDockItem *item, diff --git a/src/libgdl/gdl-dock-layout.c b/src/libgdl/gdl-dock-layout.c index a0f0a3e3a..7c5279507 100644 --- a/src/libgdl/gdl-dock-layout.c +++ b/src/libgdl/gdl-dock-layout.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "gdl-dock-layout.h" #include "gdl-tools.h" @@ -48,7 +47,7 @@ enum { #define LAYOUT_ELEMENT_NAME "layout" #define NAME_ATTRIBUTE_NAME "name" -#define LAYOUT_GLADE_FILE "layout.glade" +#define LAYOUT_UI_FILE "layout.ui" enum { COLUMN_NAME, @@ -548,20 +547,23 @@ master_locked_notify_cb (GdlDockMaster *master, } } -static GladeXML * -load_interface (const gchar *top_widget) +static GtkBuilder * +load_interface () { - GladeXML *gui; + GtkBuilder *gui; gchar *gui_file; + GError* error = NULL; /* load ui */ - gui_file = g_build_filename (GDL_GLADEDIR, LAYOUT_GLADE_FILE, NULL); - gui = glade_xml_new (gui_file, top_widget, GETTEXT_PACKAGE); + gui_file = g_build_filename (GDL_UIDIR, LAYOUT_UI_FILE, NULL); + gui = gtk_builder_new(); + gtk_builder_add_from_file (gui, gui_file, &error); g_free (gui_file); - if (!gui) { - /* FIXME: pop up an error dialog */ + if (error) { g_warning (_("Could not load layout user interface file '%s'"), - LAYOUT_GLADE_FILE); + LAYOUT_UI_FILE); + g_object_unref (gui); + g_error_free (error); return NULL; }; return gui; @@ -570,8 +572,8 @@ load_interface (const gchar *top_widget) static GtkWidget * gdl_dock_layout_construct_items_ui (GdlDockLayout *layout) { - GladeXML *gui; - GtkWidget *container; + GtkBuilder *gui; + GtkWidget *dialog; GtkWidget *items_list; GtkCellRenderer *renderer; GtkTreeViewColumn *column; @@ -579,23 +581,23 @@ gdl_dock_layout_construct_items_ui (GdlDockLayout *layout) GdlDockLayoutUIData *ui_data; /* load the interface if it wasn't provided */ - gui = load_interface ("items_vbox"); + gui = load_interface (); if (!gui) return NULL; /* get the container */ - container = glade_xml_get_widget (gui, "items_vbox"); + dialog = GTK_WIDGET (gtk_builder_get_object (gui, "layout_dialog")); ui_data = g_new0 (GdlDockLayoutUIData, 1); ui_data->layout = layout; g_object_add_weak_pointer (G_OBJECT (layout), (gpointer *) &ui_data->layout); - g_object_set_data (G_OBJECT (container), "ui_data", ui_data); + g_object_set_data (G_OBJECT (dialog), "ui_data", ui_data); /* get ui widget references */ - ui_data->locked_check = glade_xml_get_widget (gui, "locked_check"); - items_list = glade_xml_get_widget (gui, "items_list"); + ui_data->locked_check = GTK_WIDGET (gtk_builder_get_object (gui, "locked_check")); + items_list = GTK_WIDGET (gtk_builder_get_object(gui, "items_list")); /* locked check connections */ g_signal_connect (ui_data->locked_check, "toggled", @@ -629,11 +631,11 @@ gdl_dock_layout_construct_items_ui (GdlDockLayout *layout) gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column); /* connect signals */ - g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL); + g_signal_connect (dialog, "destroy", (GCallback) layout_ui_destroyed, NULL); g_object_unref (gui); - return container; + return dialog; } static void @@ -671,22 +673,24 @@ cell_edited_cb (GtkCellRendererText *cell, static GtkWidget * gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) { - GladeXML *gui; + GtkBuilder *gui; GtkWidget *container; GtkWidget *layouts_list; GtkCellRenderer *renderer; GtkTreeViewColumn *column; + GtkWidget *load_button; + GtkWidget *delete_button; GdlDockLayoutUIData *ui_data; /* load the interface if it wasn't provided */ - gui = load_interface ("layouts_vbox"); + gui = load_interface (); if (!gui) return NULL; /* get the container */ - container = glade_xml_get_widget (gui, "layouts_vbox"); + container = GTK_WIDGET (gtk_builder_get_object(gui, "layouts_vbox")); ui_data = g_new0 (GdlDockLayoutUIData, 1); ui_data->layout = layout; @@ -695,7 +699,7 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) g_object_set_data (G_OBJECT (container), "ui-data", ui_data); /* get ui widget references */ - layouts_list = glade_xml_get_widget (gui, "layouts_list"); + layouts_list = GTK_WIDGET (gtk_builder_get_object(gui, "layouts_list")); /* set models */ gtk_tree_view_set_model (GTK_TREE_VIEW (layouts_list), @@ -714,10 +718,12 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) ui_data->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (layouts_list)); /* connect signals */ - glade_xml_signal_connect_data (gui, "on_load_button_clicked", - G_CALLBACK (load_layout_cb), ui_data); - glade_xml_signal_connect_data (gui, "on_delete_button_clicked", - G_CALLBACK (delete_layout_cb), ui_data); + load_button = GTK_WIDGET (gtk_builder_get_object(gui, "load_button")); + delete_button = GTK_WIDGET (gtk_builder_get_object(gui, "delete_button")); + + g_signal_connect (load_button, "clicked", (GCallback) load_layout_cb, ui_data); + g_signal_connect (delete_button, "clicked", (GCallback) delete_layout_cb, ui_data); + g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL); @@ -726,31 +732,6 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) return container; } -static GtkWidget * -gdl_dock_layout_construct_ui (GdlDockLayout *layout) -{ - GtkWidget *container, *child; - - container = gtk_notebook_new (); - gtk_widget_show (container); - - child = gdl_dock_layout_construct_items_ui (layout); - if (child) - gtk_notebook_append_page (GTK_NOTEBOOK (container), - child, - gtk_label_new (_("Dock items"))); - - child = gdl_dock_layout_construct_layouts_ui (layout); - if (child) - gtk_notebook_append_page (GTK_NOTEBOOK (container), - child, - gtk_label_new (_("Saved layouts"))); - - gtk_notebook_set_current_page (GTK_NOTEBOOK (container), 0); - - return container; -} - /* ----- Save & Load layout functions --------- */ #define GDL_DOCK_PARAM_CONSTRUCTION(p) \ @@ -1095,6 +1076,13 @@ gdl_dock_layout_save (GdlDockMaster *master, /* ----- Public interface ----- */ +/** + * gdl_dock_layout_new: + * @dock: The dock item. + * Creates a new #GdlDockLayout + * + * Returns: New #GdlDockLayout item. + */ GdlDockLayout * gdl_dock_layout_new (GdlDock *dock) { @@ -1133,6 +1121,15 @@ gdl_dock_layout_layout_changed_cb (GdlDockMaster *master, } } + +/** + * gdl_dock_layout_attach: + * @layout: The layout item + * @master: The master item to which the layout will be attached + * + * Attach the @layout to the @master and delete the reference to + * the master that the layout attached previously + */ void gdl_dock_layout_attach (GdlDockLayout *layout, GdlDockMaster *master) @@ -1159,6 +1156,17 @@ gdl_dock_layout_attach (GdlDockLayout *layout, update_items_model (layout); } +/** +* gdl_dock_layout_load_layout: +* @layout: The dock item. +* @name: The name of the layout to load. +* +* Loads the layout with the given name to the memory. +* This will set #GdlDockLayout:dirty to %TRUE. +* +* See also gdl_dock_layout_load_from_file() +* Returns: %TRUE if layout successfully loaded else %FALSE +*/ gboolean gdl_dock_layout_load_layout (GdlDockLayout *layout, const gchar *name) @@ -1188,6 +1196,17 @@ gdl_dock_layout_load_layout (GdlDockLayout *layout, return FALSE; } +/** +* gdl_dock_layout_save_layout: +* @layout: The dock item. +* @name: The name of the layout to save. +* +* Saves the @layout with the given name to the memory. +* This will set #GdlDockLayout:dirty to %TRUE. +* +* See also gdl_dock_layout_save_to_file(). +*/ + void gdl_dock_layout_save_layout (GdlDockLayout *layout, const gchar *name) @@ -1224,6 +1243,15 @@ gdl_dock_layout_save_layout (GdlDockLayout *layout, g_object_notify (G_OBJECT (layout), "dirty"); } +/** +* gdl_dock_layout_delete_layout: +* @layout: The dock item. +* @name: The name of the layout to delete. +* +* Deletes the layout with the given name from the memory. +* This will set #GdlDockLayout:dirty to %TRUE. +*/ + void gdl_dock_layout_delete_layout (GdlDockLayout *layout, const gchar *name) @@ -1245,10 +1273,17 @@ gdl_dock_layout_delete_layout (GdlDockLayout *layout, } } +/** +* gdl_dock_layout_run_manager: +* @layout: The dock item. +* +* Runs the layout manager. +*/ + void gdl_dock_layout_run_manager (GdlDockLayout *layout) { - GtkWidget *dialog, *container; + GtkWidget *dialog; GtkWidget *parent = NULL; g_return_if_fail (layout != NULL); @@ -1257,28 +1292,24 @@ gdl_dock_layout_run_manager (GdlDockLayout *layout) /* not attached to a dock yet */ return; - container = gdl_dock_layout_construct_ui (layout); - if (!container) - return; - - parent = GTK_WIDGET (gdl_dock_master_get_controller (layout->master)); - if (parent) - parent = gtk_widget_get_toplevel (parent); - - dialog = gtk_dialog_new_with_buttons (_("Layout managment"), - parent ? GTK_WINDOW (parent) : NULL, - GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 300); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), container); + dialog = gdl_dock_layout_construct_items_ui (layout); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } +/** +* gdl_dock_layout_load_from_file: +* @layout: The layout item. +* @filename: The name of the file to load. +* +* Loads the layout from file with the given @filename. +* This will set #GdlDockLayout:dirty to %FALSE. +* +* Returns: %TRUE if @layout successfully loaded else %FALSE +*/ + gboolean gdl_dock_layout_load_from_file (GdlDockLayout *layout, const gchar *filename) @@ -1311,6 +1342,16 @@ gdl_dock_layout_load_from_file (GdlDockLayout *layout, return retval; } +/** + * gdl_dock_layout_save_to_file: + * @layout: The layout item. + * @filename: Name of the file we want to save in layout + * + * This function saves the current layout in XML format to + * the file with the given @filename. + * + * Returns: %TRUE if @layout successfuly save to the file, otherwise %FALSE. + */ gboolean gdl_dock_layout_save_to_file (GdlDockLayout *layout, const gchar *filename) @@ -1340,6 +1381,13 @@ gdl_dock_layout_save_to_file (GdlDockLayout *layout, return retval; } +/** + * gdl_dock_layout_is_dirty: + * @layout: The layout item. + * + * Checks whether the XML tree in memory is different from the file where the layout was saved. + * Returns: %TRUE is the layout in the memory is different from the file, else %FALSE. + */ gboolean gdl_dock_layout_is_dirty (GdlDockLayout *layout) { @@ -1377,28 +1425,6 @@ gdl_dock_layout_get_layouts (GdlDockLayout *layout, return retval; } -GtkWidget * -gdl_dock_layout_get_ui (GdlDockLayout *layout) -{ - GtkWidget *ui; - - g_return_val_if_fail (layout != NULL, NULL); - ui = gdl_dock_layout_construct_ui (layout); - - return ui; -} - -GtkWidget * -gdl_dock_layout_get_items_ui (GdlDockLayout *layout) -{ - GtkWidget *ui; - - g_return_val_if_fail (layout != NULL, NULL); - ui = gdl_dock_layout_construct_items_ui (layout); - - return ui; -} - GtkWidget * gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout) { diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c index 78cbf69ec..57d0618ec 100644 --- a/src/libgdl/gdl-dock-master.c +++ b/src/libgdl/gdl-dock-master.c @@ -31,6 +31,8 @@ #include "gdl-dock-master.h" #include "gdl-dock.h" #include "gdl-dock-item.h" +#include "gdl-dock-notebook.h" +#include "gdl-switcher.h" #include "libgdlmarshal.h" #include "libgdltypebuiltins.h" #ifdef WIN32 diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h index 3268e68b5..266ca7ee4 100644 --- a/src/libgdl/gdl-dock-master.h +++ b/src/libgdl/gdl-dock-master.h @@ -44,6 +44,15 @@ typedef struct _GdlDockMaster GdlDockMaster; typedef struct _GdlDockMasterClass GdlDockMasterClass; typedef struct _GdlDockMasterPrivate GdlDockMasterPrivate; +typedef enum { + GDL_SWITCHER_STYLE_TEXT, + GDL_SWITCHER_STYLE_ICON, + GDL_SWITCHER_STYLE_BOTH, + GDL_SWITCHER_STYLE_TOOLBAR, + GDL_SWITCHER_STYLE_TABS, + GDL_SWITCHER_STYLE_NONE +} GdlSwitcherStyle; + struct _GdlDockMaster { GObject object; diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c index f6e0aeeef..3db3fab3f 100644 --- a/src/libgdl/gdl-dock-notebook.c +++ b/src/libgdl/gdl-dock-notebook.c @@ -270,7 +270,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, { GdlDockNotebook *notebook; GtkWidget *tablabel; - (void)page_num; + GdlDockItem *item; notebook = GDL_DOCK_NOTEBOOK (data); @@ -293,6 +293,10 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, GDL_DOCK_OBJECT (notebook)->master) g_signal_emit_by_name (GDL_DOCK_OBJECT (notebook)->master, "layout-changed"); + + /* Signal that a new dock item has been selected */ + item = GDL_DOCK_ITEM (gtk_notebook_get_nth_page (nb, page_num)); + gdl_dock_item_notify_selected (item); } static void diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h index 6ac36a44c..d1c27ffbd 100644 --- a/src/libgdl/gdl-dock-object.h +++ b/src/libgdl/gdl-dock-object.h @@ -221,7 +221,7 @@ GType gdl_dock_object_set_type_for_nick (const gchar *nick, __PRETTY_FUNCTION__, \ G_OBJECT_TYPE_NAME (object), object, \ G_OBJECT (object)->ref_count, \ - (GTK_IS_OBJECT (object) && GTK_OBJECT_FLOATING (object)) ? "(float)" : "", \ + (GTK_IS_OBJECT (object) && g_object_is_floating (object)) ? "(float)" : "", \ GDL_IS_DOCK_OBJECT (object) ? GDL_DOCK_OBJECT (object)->freeze_count : -1, \ ##args); } G_STMT_END diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c index 5d0ac17ed..141770aa2 100644 --- a/src/libgdl/gdl-dock-paned.c +++ b/src/libgdl/gdl-dock-paned.c @@ -710,6 +710,7 @@ gdl_dock_paned_dock (GdlDockObject *object, } else { gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor)); + gtk_widget_show (GTK_WIDGET (requestor)); GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED); } } diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index 33934e2e0..7a86ebe81 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -30,6 +30,7 @@ #include "gdl-tools.h" #include "gdl-dock-placeholder.h" #include "gdl-dock-item.h" +#include "gdl-dock-paned.h" #include "gdl-dock-master.h" #include "libgdltypebuiltins.h" @@ -494,7 +495,7 @@ gdl_dock_placeholder_dock (GdlDockObject *object, GdlDockObject *toplevel; if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph))) { - g_warning ("%s",_("Attempt to dock a dock object to an unbound placeholder")); + g_warning ("%s", _("Attempt to dock a dock object to an unbound placeholder")); return; } @@ -543,7 +544,7 @@ gdl_dock_placeholder_present (GdlDockObject *object, /* ----- Public interface ----- */ GtkWidget * -gdl_dock_placeholder_new (gchar *name, +gdl_dock_placeholder_new (const gchar *name, GdlDockObject *object, GdlDockPlacement position, gboolean sticky) diff --git a/src/libgdl/gdl-dock-placeholder.h b/src/libgdl/gdl-dock-placeholder.h index aeb55da67..c7e57e204 100644 --- a/src/libgdl/gdl-dock-placeholder.h +++ b/src/libgdl/gdl-dock-placeholder.h @@ -55,7 +55,7 @@ struct _GdlDockPlaceholderClass { GType gdl_dock_placeholder_get_type (void); -GtkWidget *gdl_dock_placeholder_new (gchar *name, +GtkWidget *gdl_dock_placeholder_new (const gchar *name, GdlDockObject *object, GdlDockPlacement position, gboolean sticky); diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index 3b0dc4e6b..47a4f5b3d 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -349,21 +349,6 @@ gdl_dock_constructor (GType type, g_signal_connect (dock, "notify::long-name", (GCallback) gdl_dock_notify_cb, NULL); - /* set transient for the first dock if that is a non-floating dock */ - controller = gdl_dock_master_get_controller (master); - if (controller && GDL_IS_DOCK (controller)) { - gboolean first_is_floating; - g_object_get (controller, "floating", &first_is_floating, NULL); - if (!first_is_floating) { - GtkWidget *toplevel = - gtk_widget_get_toplevel (GTK_WIDGET (controller)); - - if (GTK_IS_WINDOW (toplevel)) - gtk_window_set_transient_for (GTK_WINDOW (dock->_priv->window), - GTK_WINDOW (toplevel)); - } - } - gtk_container_add (GTK_CONTAINER (dock->_priv->window), GTK_WIDGET (dock)); g_signal_connect (dock->_priv->window, "delete_event", diff --git a/src/libgdl/gdl-stock.c b/src/libgdl/gdl-stock.c deleted file mode 100644 index 4cb7bf929..000000000 --- a/src/libgdl/gdl-stock.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * gdl-stock.c - * - * Copyright (C) 2003 Jeroen Zwartepoorte - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "gdl-stock.h" -#include "gdl-stock-icons.h" - -static GtkIconFactory *gdl_stock_factory = NULL; - -static struct { - const gchar *stock_id; - const guint8 *icon_data; - const guint data_size; -} -gdl_icons[] = -{ - { GDL_STOCK_CLOSE, stock_close_icon, sizeof (stock_close_icon) }, - { GDL_STOCK_MENU_LEFT, stock_menu_left_icon, sizeof (stock_menu_left_icon) }, - { GDL_STOCK_MENU_RIGHT, stock_menu_right_icon, sizeof (stock_menu_right_icon) } -}; - -static void -icon_set_from_data (GtkIconSet *set, - const guint8 *icon_data, - const guint data_size, - GtkIconSize size, - gboolean fallback) -{ - GtkIconSource *source; - GdkPixbuf *pixbuf; - GError *err = NULL; - - source = gtk_icon_source_new (); - - gtk_icon_source_set_size (source, size); - gtk_icon_source_set_size_wildcarded (source, FALSE); - - pixbuf = gdk_pixbuf_new_from_inline (data_size, icon_data, FALSE, &err); - if (err) { - g_warning ("%s", err->message); - g_error_free (err); - err = NULL; - g_object_unref (source); - return; - } - - gtk_icon_source_set_pixbuf (source, pixbuf); - - g_object_unref (pixbuf); - - gtk_icon_set_add_source (set, source); - - if (fallback) { - gtk_icon_source_set_size_wildcarded (source, TRUE); - gtk_icon_set_add_source (set, source); - } - - gtk_icon_source_free (source); -} - -static void -add_icon (GtkIconFactory *factory, - const gchar *stock_id, - const guint8 *icon_data, - const guint data_size) -{ - GtkIconSet *set; - gboolean fallback = FALSE; - - set = gtk_icon_factory_lookup (factory, stock_id); - - if (!set) { - set = gtk_icon_set_new (); - gtk_icon_factory_add (factory, stock_id, set); - gtk_icon_set_unref (set); - - fallback = TRUE; - } - - icon_set_from_data (set, icon_data, data_size, GTK_ICON_SIZE_MENU, fallback); -} - -void -gdl_stock_init (void) -{ - static gboolean initialized = FALSE; - gint i; - - if (initialized) - return; - - gdl_stock_factory = gtk_icon_factory_new (); - - for (i = 0; i < G_N_ELEMENTS (gdl_icons); i++) { - add_icon (gdl_stock_factory, - gdl_icons[i].stock_id, - gdl_icons[i].icon_data, - gdl_icons[i].data_size); - } - - gtk_icon_factory_add_default (gdl_stock_factory); - - initialized = TRUE; -} diff --git a/src/libgdl/gdl-stock.h b/src/libgdl/gdl-stock.h deleted file mode 100644 index cb6f7abb9..000000000 --- a/src/libgdl/gdl-stock.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * gdl-stock.h - * - * Copyright (C) 2003 Jeroen Zwartepoorte - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_STOCK_H__ -#define __GDL_STOCK_H__ - -#include // G_BEGIN_DECLS - -G_BEGIN_DECLS - -#define GDL_STOCK_CLOSE "gdl-close" -#define GDL_STOCK_MENU_LEFT "gdl-menu-left" -#define GDL_STOCK_MENU_RIGHT "gdl-menu-right" - -void gdl_stock_init (void); - -G_END_DECLS - -#endif /* __GDL_STOCK_H__ */ diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index fea3218ae..65013e390 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -4,20 +4,22 @@ * Copyright (C) 2003 Ettore Perazzoli, * 2007 Naba Kumar * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Library General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * + * * Copied and adapted from ESidebar.[ch] from evolution * * Authors: Ettore Perazzoli @@ -36,10 +38,6 @@ #include -#if HAVE_GNOME -#include -#endif - static void gdl_switcher_set_property (GObject *object, guint prop_id, const GValue *value, @@ -608,12 +606,6 @@ static void gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec, GdlSwitcher *switcher) { - gboolean show_tabs; - (void)g_object; - (void)pspec; - g_return_if_fail (switcher != NULL && GDL_IS_SWITCHER (switcher)); - show_tabs = gtk_notebook_get_show_tabs (GTK_NOTEBOOK (switcher)); - gdl_switcher_set_show_buttons (switcher, !show_tabs); } static void @@ -879,179 +871,87 @@ gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page, } static void -set_switcher_style_internal (GdlSwitcher *switcher, - GdlSwitcherStyle switcher_style ) +set_switcher_style_toolbar (GdlSwitcher *switcher, + GdlSwitcherStyle switcher_style) { GSList *p; - if (switcher_style == GDL_SWITCHER_STYLE_TABS && - switcher->priv->show == FALSE) + if (switcher_style == GDL_SWITCHER_STYLE_NONE + || switcher_style == GDL_SWITCHER_STYLE_TABS) return; - if (switcher_style == GDL_SWITCHER_STYLE_TABS) - { - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE); - return; - } - - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE); - + if (switcher_style == GDL_SWITCHER_STYLE_TOOLBAR) + switcher_style = GDL_SWITCHER_STYLE_BOTH; + if (switcher_style == INTERNAL_MODE (switcher)) return; - + + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE); + for (p = switcher->priv->buttons; p != NULL; p = p->next) { Button *button = p->data; gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow); + + if (gtk_widget_get_parent (button->icon)) + gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon); + if (gtk_widget_get_parent (button->label)) + gtk_container_remove (GTK_CONTAINER (button->hbox), button->label); + switch (switcher_style) { case GDL_SWITCHER_STYLE_TEXT: - gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon); - if (INTERNAL_MODE (switcher) - == GDL_SWITCHER_STYLE_ICON) { - gtk_box_pack_start (GTK_BOX (button->hbox), button->label, - TRUE, TRUE, 0); - gtk_widget_show (button->label); - } + gtk_box_pack_start (GTK_BOX (button->hbox), button->label, + TRUE, TRUE, 0); + gtk_widget_show (button->label); break; + case GDL_SWITCHER_STYLE_ICON: - gtk_container_remove(GTK_CONTAINER (button->hbox), button->label); - if (INTERNAL_MODE (switcher) - == GDL_SWITCHER_STYLE_TEXT) { - gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, - TRUE, TRUE, 0); - gtk_widget_show (button->icon); - } else - gtk_container_child_set (GTK_CONTAINER (button->hbox), - button->icon, "expand", TRUE, NULL); + gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, + TRUE, TRUE, 0); + gtk_widget_show (button->icon); break; - case GDL_SWITCHER_STYLE_BOTH: - if (INTERNAL_MODE (switcher) - == GDL_SWITCHER_STYLE_TEXT) { - gtk_container_remove (GTK_CONTAINER (button->hbox), - button->label); - gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, - FALSE, TRUE, 0); - gtk_widget_show (button->icon); - } else { - gtk_container_child_set (GTK_CONTAINER (button->hbox), - button->icon, "expand", FALSE, NULL); - } - gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, - TRUE, 0); + case GDL_SWITCHER_STYLE_BOTH: + gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, + FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (button->hbox), button->label, + TRUE, TRUE, 0); + gtk_widget_show (button->icon); gtk_widget_show (button->label); break; + default: break; } - gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow, FALSE, - FALSE, 0); - } -} - -#if HAVE_GNOME -static GConfEnumStringPair toolbar_styles[] = { - { GDL_SWITCHER_STYLE_TEXT, "text" }, - { GDL_SWITCHER_STYLE_ICON, "icons" }, - { GDL_SWITCHER_STYLE_BOTH, "both" }, - { GDL_SWITCHER_STYLE_BOTH, "both-horiz" }, - { GDL_SWITCHER_STYLE_BOTH, "both_horiz" }, - { -1, NULL } -}; - -static void -style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry, - void *data) -{ - GdlSwitcher *switcher = data; - char *val; - int switcher_style; - - val = gconf_client_get_string (gconf, - "/desktop/gnome/interface/toolbar_style", - NULL); - if (val == NULL || !gconf_string_to_enum (toolbar_styles, val, - &switcher_style)) - switcher_style = GDL_SWITCHER_STYLE_BOTH; - g_free(val); - set_switcher_style_internal (GDL_SWITCHER (switcher), switcher_style); - switcher->priv->toolbar_style = switcher_style; + gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow, + FALSE, FALSE, 0); + } - gtk_widget_queue_resize (GTK_WIDGET (switcher)); + gdl_switcher_set_show_buttons (switcher, TRUE); } static void gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style) { - GConfClient *gconf_client = gconf_client_get_default (); - - if (switcher_style == GDL_SWITCHER_STYLE_TABS && - switcher->priv->show == FALSE) - return; - - if (switcher->priv->switcher_style == switcher_style && - switcher->priv->show == TRUE) + if (switcher->priv->switcher_style == switcher_style) return; - if (switcher->priv->switcher_style == GDL_SWITCHER_STYLE_TOOLBAR) { - if (switcher->priv->style_changed_id) { - gconf_client_notify_remove (gconf_client, - switcher->priv->style_changed_id); - switcher->priv->style_changed_id = 0; - } + if (switcher_style == GDL_SWITCHER_STYLE_NONE) { + gdl_switcher_set_show_buttons (switcher, FALSE); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE); } - - if (switcher_style != GDL_SWITCHER_STYLE_TOOLBAR) { - set_switcher_style_internal (switcher, switcher_style); - - gtk_widget_queue_resize (GTK_WIDGET (switcher)); - } else { - /* This is a little bit tricky, toolbar style is more - * of a meta-style where the actual style is dictated by - * the gnome toolbar setting, so that is why we have - * the is_toolbar_style bool - it tracks the toolbar - * style while the switcher_style member is the actual look and - * feel */ - switcher->priv->style_changed_id = - gconf_client_notify_add (gconf_client, - "/desktop/gnome/interface/toolbar_style", - style_changed_notify, switcher, - NULL, NULL); - style_changed_notify (gconf_client, 0, NULL, switcher); + else if (switcher_style == GDL_SWITCHER_STYLE_TABS) { + gdl_switcher_set_show_buttons (switcher, FALSE); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE); } - - g_object_unref (gconf_client); - - if (switcher_style != GDL_SWITCHER_STYLE_TABS) - switcher->priv->switcher_style = switcher_style; -} - -#else /* HAVE_GNOME */ - -static void -gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style) -{ - if (switcher_style == GDL_SWITCHER_STYLE_TABS && - switcher->priv->show == FALSE) - return; - - if (switcher->priv->switcher_style == switcher_style && - switcher->priv->show == TRUE) - return; + else + set_switcher_style_toolbar (switcher, switcher_style); - set_switcher_style_internal (switcher, - ((switcher_style == - GDL_SWITCHER_STYLE_TOOLBAR)? - GDL_SWITCHER_STYLE_BOTH : switcher_style)); gtk_widget_queue_resize (GTK_WIDGET (switcher)); - - if (switcher_style != GDL_SWITCHER_STYLE_TABS) - switcher->priv->switcher_style = switcher_style; + switcher->priv->switcher_style = switcher_style; } -#endif /* HAVE_GNOME */ - static void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show) { diff --git a/src/libgdl/gdl-switcher.h b/src/libgdl/gdl-switcher.h index 9c33f8bbf..991f2da20 100644 --- a/src/libgdl/gdl-switcher.h +++ b/src/libgdl/gdl-switcher.h @@ -4,20 +4,22 @@ * Copyright (C) 2003 Ettore Perazzoli * 2007 Naba Kumar * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. +* This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Library General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * + * * Authors: Ettore Perazzoli * Naba Kumar */ @@ -39,14 +41,6 @@ typedef struct _GdlSwitcher GdlSwitcher; typedef struct _GdlSwitcherPrivate GdlSwitcherPrivate; typedef struct _GdlSwitcherClass GdlSwitcherClass; -typedef enum { - GDL_SWITCHER_STYLE_TEXT, - GDL_SWITCHER_STYLE_ICON, - GDL_SWITCHER_STYLE_BOTH, - GDL_SWITCHER_STYLE_TOOLBAR, - GDL_SWITCHER_STYLE_TABS -} GdlSwitcherStyle; - struct _GdlSwitcher { GtkNotebook parent; diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h index e47dc310d..467b2b67e 100644 --- a/src/libgdl/gdl.h +++ b/src/libgdl/gdl.h @@ -1,23 +1,22 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * * This file is part of the GNOME Devtools Libraries. - * + * * Copyright (C) 1999-2000 Dave Camp * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GDL_H__ @@ -28,12 +27,8 @@ #include "libgdl/gdl-dock-master.h" #include "libgdl/gdl-dock.h" #include "libgdl/gdl-dock-item.h" +#include "libgdl/gdl-dock-item-grip.h" #include "libgdl/gdl-dock-layout.h" -#include "libgdl/gdl-dock-paned.h" -#include "libgdl/gdl-dock-notebook.h" -#include "libgdl/gdl-dock-tablabel.h" #include "libgdl/gdl-dock-bar.h" -#include "libgdl/gdl-combo-button.h" -#include "libgdl/gdl-switcher.h" #endif diff --git a/src/libgdl/test-dock.c b/src/libgdl/test-dock.c index 1e9c80111..abaecf703 100644 --- a/src/libgdl/test-dock.c +++ b/src/libgdl/test-dock.c @@ -81,6 +81,9 @@ create_styles_item (GtkWidget *dock) group = create_style_button (dock, vbox1, group, GDL_SWITCHER_STYLE_TABS, "Notebook tabs"); + group = create_style_button (dock, vbox1, group, + GDL_SWITCHER_STYLE_NONE, + "None of the above"); return vbox1; } -- cgit v1.2.3 From 3099a49e82622b42547088666099f33d0d55b1ad Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 10 Jul 2011 05:33:59 +0200 Subject: Implement handling of the clip-rule property. Partially based on a patch by Andrew Lutomirski. Fixed bugs: - https://launchpad.net/bugs/171243 (bzr r10347.1.8) --- src/display/nr-arena-glyphs.cpp | 10 +++++++++- src/display/nr-arena-group.cpp | 14 +++++++++++++- src/display/nr-arena-shape.cpp | 12 +++++++++--- src/sp-clippath.cpp | 11 +++++++++-- src/style.cpp | 30 ++++++++++++++++++++++++++++-- src/style.h | 4 +++- 6 files changed, 71 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 185551d31..b76e87a78 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -360,6 +360,14 @@ static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, N NRArenaGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); cairo_save(ct); + // handle clip-rule + if (ggroup->style) { + if (ggroup->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + } else { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + } + } ink_cairo_transform(ct, ggroup->ctm); for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { @@ -369,9 +377,9 @@ static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, N cairo_save(ct); ink_cairo_transform(ct, g->g_transform); feed_pathvector_to_cairo(ct, pathv); - cairo_fill(ct); cairo_restore(ct); } + cairo_fill(ct); cairo_restore(ct); return item->state; diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 5f11c1a6b..714c4ecff 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -12,6 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "display/canvas-bpath.h" #include "display/nr-arena-group.h" #include "display/nr-filter.h" #include "display/nr-filter-types.h" @@ -234,14 +235,25 @@ static unsigned int nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) { NRArenaGroup *group = NR_ARENA_GROUP (item); - unsigned int ret = item->state; + cairo_save(ct); + + // handle clip-rule + if (group->style) { + if (group->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + } else { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + } + } + for (NRArenaItem *child = group->children; child != NULL; child = child->next) { ret = nr_arena_item_invoke_clip (ct, child, area); if (ret & NR_ARENA_ITEM_STATE_INVALID) break; } + cairo_restore(ct); return ret; } diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 9bece05b5..6d65611bf 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -21,6 +21,7 @@ #include <2geom/svg-path-parser.h> #include "display/cairo-utils.h" #include "display/canvas-arena.h" +#include "display/canvas-bpath.h" #include "display/curve.h" #include "display/nr-arena.h" #include "display/nr-arena-shape.h" @@ -401,10 +402,15 @@ static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*are return item->state; } - // TODO: Handling of the clip-rule property / CSS attribute. - // Once the required bits are in SPStyle, this is as trivial as adding a single - // call to cairo_set_fill_rule() before cairo_fill(). cairo_save(ct); + // handle clip-rule + if (shape->style) { + if (shape->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + } else { + cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + } + } ink_cairo_transform(ct, shape->ctm); feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); cairo_fill(ct); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 147ece167..48e466628 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -89,6 +89,7 @@ void SPClipPath::build(SPObject *object, SPDocument *document, Inkscape::XML::No if (((SPObjectClass *) SPClipPathClass::static_parent_class)->build) ((SPObjectClass *) SPClipPathClass::static_parent_class)->build(object, document, repr); + object->readAttr( "style" ); object->readAttr( "clipPathUnits" ); /* Register ourselves */ @@ -132,8 +133,13 @@ void SPClipPath::set(SPObject *object, unsigned int key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) SPClipPathClass::static_parent_class)->set) { - ((SPObjectClass *) SPClipPathClass::static_parent_class)->set(object, key, value); + if (SP_ATTRIBUTE_IS_CSS(key)) { + sp_style_read_from_object(object->style, object); + object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } else { + if (((SPObjectClass *) SPClipPathClass::static_parent_class)->set) { + ((SPObjectClass *) SPClipPathClass::static_parent_class)->set(object, key, value); + } } break; } @@ -258,6 +264,7 @@ NRArenaItem *SPClipPath::show(NRArena *arena, unsigned int key) t[5] = display->bbox.y0; nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), &t); } + nr_arena_group_set_style(NR_ARENA_GROUP(ai), this->style); return ai; } diff --git a/src/style.cpp b/src/style.cpp index 37a784e2a..e66c15494 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -335,6 +335,12 @@ static SPStyleEnum const enum_enable_background[] = { {NULL, -1} }; +static SPStyleEnum const enum_clip_rule[] = { + {"nonzero", SP_WIND_RULE_NONZERO}, + {"evenodd", SP_WIND_RULE_EVENODD}, + {NULL, -1} +}; + /** * Release callback. */ @@ -767,6 +773,9 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) SPS_READ_PENUM_IF_UNSET(&style->enable_background, repr, "enable-background", enum_enable_background, true); + /* clip-rule */ + SPS_READ_PENUM_IF_UNSET(&style->clip_rule, repr, "clip-rule", enum_clip_rule, true); + /* 3. Merge from parent */ if (object) { if (object->parent) { @@ -1020,7 +1029,9 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) style->object->getRepr()->setAttribute("clip-path", val); break; case SP_PROP_CLIP_RULE: - g_warning("Unimplemented style property SP_PROP_CLIP_RULE: value: %s", val); + if (!style->clip_rule.set) { + sp_style_read_ienum(&style->clip_rule, val, enum_clip_rule, true); + } break; case SP_PROP_MASK: /** \todo @@ -1645,6 +1656,11 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) if(style->enable_background.inherit) { style->enable_background.value = parent->enable_background.value; } + + /* Clipping */ + if (!style->clip_rule.set || style->clip_rule.inherit) { + style->clip_rule.computed = parent->clip_rule.computed; + } } template @@ -1906,7 +1922,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare /* Enum values that don't have any relative settings (other than `inherit'). */ { SPIEnum SPStyle::*const fields[] = { - //nyi: SPStyle::clip_rule, + &SPStyle::clip_rule, //nyi: SPStyle::color_interpolation, //nyi: SPStyle::color_interpolation_filters, //nyi: SPStyle::color_rendering, @@ -2446,6 +2462,9 @@ sp_style_write_string(SPStyle const *const style, guint const flags) p += sp_style_write_ienum(p, c + BMAX - p, "enable-background", enum_enable_background, &style->enable_background, NULL, flags); + /* clipping */ + p += sp_style_write_ienum(p, c + BMAX - p, "clip-rule", enum_clip_rule, &style->clip_rule, NULL, flags); + /* fixme: */ p += sp_text_style_write(p, c + BMAX - p, style->text, flags); @@ -2592,6 +2611,8 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to) p += sp_text_style_write(p, c + BMAX - p, from->text, SP_STYLE_FLAG_IFDIFF); + p += sp_style_write_ienum(p, c + BMAX - p, "clip-rule", enum_clip_rule, &from->clip_rule, &to->clip_rule, SP_STYLE_FLAG_IFDIFF); + /** \todo * The reason we use IFSET rather than IFDIFF is the belief that the IFDIFF * flag is mainly only for attributes that don't handle explicit unset well. @@ -2783,6 +2804,8 @@ sp_style_clear(SPStyle *style) style->enable_background.value = SP_CSS_BACKGROUND_ACCUMULATE; style->enable_background.set = false; style->enable_background.inherit = false; + + style->clip_rule.value = style->clip_rule.computed = SP_WIND_RULE_NONZERO; } @@ -4178,6 +4201,9 @@ sp_style_unset_property_attrs(SPObject *o) if (style->enable_background.set) { repr->setAttribute("enable-background", NULL); } + if (style->clip_rule.set) { + repr->setAttribute("clip-rule", NULL); + } } /** diff --git a/src/style.h b/src/style.h index a12db388a..3ca1d4dbc 100644 --- a/src/style.h +++ b/src/style.h @@ -327,9 +327,11 @@ struct SPStyle { unsigned cursor_set : 1; unsigned overflow_set : 1; unsigned clip_path_set : 1; - unsigned clip_rule_set : 1; unsigned mask_set : 1; + /** clip-rule: 0 nonzero, 1 evenodd */ + SPIEnum clip_rule; + /** display */ SPIEnum display; -- cgit v1.2.3 From 0d0a5d5453e43fb95e7ff54a59666f72b1c3178d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 10 Jul 2011 05:37:31 +0200 Subject: Remove irrelevant clip-rule handling bit from NRArenaGroup. (bzr r10347.1.9) --- src/display/nr-arena-group.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 714c4ecff..1a67a8404 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -237,23 +237,11 @@ nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) NRArenaGroup *group = NR_ARENA_GROUP (item); unsigned int ret = item->state; - cairo_save(ct); - - // handle clip-rule - if (group->style) { - if (group->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); - } else { - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); - } - } - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { ret = nr_arena_item_invoke_clip (ct, child, area); if (ret & NR_ARENA_ITEM_STATE_INVALID) break; } - cairo_restore(ct); return ret; } -- cgit v1.2.3 From df7bda1a8b9d4a1c6f0fd4b82cdeb614eb1ea8d2 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 10 Jul 2011 00:13:05 -0700 Subject: Refactored to abstract lcms usage more. Added CMSSystem class. (bzr r10437) --- src/CMakeLists.txt | 2 +- src/Makefile_insert | 3 +- src/cms-system.h | 60 ++++++++++++++++++++++++++++++++++ src/color-profile-fns.h | 60 ---------------------------------- src/color-profile.cpp | 31 +++++++++++------- src/color-profile.h | 1 + src/display/sp-canvas.cpp | 10 +++--- src/sp-image.cpp | 10 +++--- src/svg/svg-color.cpp | 17 ++++------ src/ui/dialog/inkscape-preferences.cpp | 15 +++++---- src/widgets/desktop-widget.cpp | 8 ++--- src/widgets/sp-color-icc-selector.cpp | 10 ++++-- src/widgets/sp-color-notebook.cpp | 10 +++--- 13 files changed, 124 insertions(+), 113 deletions(-) create mode 100644 src/cms-system.h delete mode 100644 src/color-profile-fns.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 11a307037..038e7bb73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -307,7 +307,7 @@ set(inkscape_SRC box3d-side.h box3d.h cms-color-types.h - color-profile-fns.h + cms-system.h color-profile-cms-fns.h color-profile-test.h color-profile.h diff --git a/src/Makefile_insert b/src/Makefile_insert index d4f96fc87..2cb689740 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -13,9 +13,10 @@ ink_common_sources += \ box3d-side.cpp box3d-side.h \ brokenimage.xpm \ cms-color-types.h \ + cms-system.h \ color.cpp color.h \ color-profile.cpp color-profile.h \ - color-profile-fns.h color-profile-cms-fns.h \ + color-profile-cms-fns.h \ color-rgba.h \ common-context.cpp common-context.h \ composite-undo-stack-observer.cpp \ diff --git a/src/cms-system.h b/src/cms-system.h new file mode 100644 index 000000000..1f75f8619 --- /dev/null +++ b/src/cms-system.h @@ -0,0 +1,60 @@ +#ifndef SEEN_COLOR_PROFILE_FNS_H +#define SEEN_COLOR_PROFILE_FNS_H + +/** \file + * Macros and fn declarations related to linear gradients. + */ + +#include +#include +#include +#include +#include "cms-color-types.h" + +class SPDocument; + +namespace Inkscape { + +class ColorProfile; + +class CMSSystem { +public: + static cmsHPROFILE getHandle( SPDocument* document, guint* intent, gchar const* name ); + + static cmsHTRANSFORM getDisplayTransform(); + + static Glib::ustring getDisplayId( int screen, int monitor ); + + static Glib::ustring setDisplayPer( gpointer buf, guint bufLen, int screen, int monitor ); + + static cmsHTRANSFORM getDisplayPer( Glib::ustring const& id ); + + static std::vector getDisplayNames(); + + static std::vector getSoftproofNames(); + + static Glib::ustring getPathForProfile(Glib::ustring const& name); + + static void doTransform(cmsHTRANSFORM transform, void *inBuf, void *outBuf, unsigned int size); + + static bool isPrintColorSpace(ColorProfile const *profile); + + static gint getChannelCount(ColorProfile const *profile); +}; + + +} // namespace Inkscape + + +#endif // !SEEN_COLOR_PROFILE_FNS_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/color-profile-fns.h b/src/color-profile-fns.h deleted file mode 100644 index 0588ce89e..000000000 --- a/src/color-profile-fns.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef SEEN_COLOR_PROFILE_FNS_H -#define SEEN_COLOR_PROFILE_FNS_H - -/** \file - * Macros and fn declarations related to linear gradients. - */ - -#include -#include -#if ENABLE_LCMS -#include -#include -#endif // ENABLE_LCMS -#include "cms-color-types.h" - -class SPDocument; - -namespace Inkscape { - -namespace XML { -class Node; -} // namespace XML - -class ColorProfile; - -#if ENABLE_LCMS - -cmsHPROFILE colorprofile_get_handle( SPDocument* document, guint* intent, gchar const* name ); -cmsHTRANSFORM colorprofile_get_display_transform(); - -Glib::ustring colorprofile_get_display_id( int screen, int monitor ); -Glib::ustring colorprofile_set_display_per( gpointer buf, guint bufLen, int screen, int monitor ); -cmsHTRANSFORM colorprofile_get_display_per( Glib::ustring const& id ); - -std::vector colorprofile_get_display_names(); -std::vector colorprofile_get_softproof_names(); - -Glib::ustring get_path_for_profile(Glib::ustring const& name); - -void colorprofile_cmsDoTransform(cmsHTRANSFORM transform, void *inBuf, void *outBuf, unsigned int size); - -bool colorprofile_isPrintColorSpace(ColorProfile const *profile); - -#endif // ENABLE_LCMS - -} // namespace Inkscape - - -#endif // !SEEN_COLOR_PROFILE_FNS_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 4bc37fdf8..f858f7f70 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -31,7 +31,7 @@ #include "xml/repr.h" #include "color.h" #include "color-profile.h" -#include "color-profile-fns.h" +#include "cms-system.h" #include "color-profile-cms-fns.h" #include "attributes.h" #include "inkscape.h" @@ -552,7 +552,7 @@ static SPObject* bruteFind( SPDocument* document, gchar const* name ) return result; } -cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* intent, gchar const* name ) +cmsHPROFILE Inkscape::CMSSystem::getHandle( SPDocument* document, guint* intent, gchar const* name ) { cmsHPROFILE prof = 0; @@ -652,7 +652,7 @@ ProfileInfo::ProfileInfo( cmsHPROFILE prof, Glib::ustring const & path ) static std::vector knownProfiles; -std::vector Inkscape::colorprofile_get_display_names() +std::vector Inkscape::CMSSystem::getDisplayNames() { loadProfiles(); std::vector result; @@ -666,7 +666,7 @@ std::vector Inkscape::colorprofile_get_display_names() return result; } -std::vector Inkscape::colorprofile_get_softproof_names() +std::vector Inkscape::CMSSystem::getSoftproofNames() { loadProfiles(); std::vector result; @@ -680,7 +680,7 @@ std::vector Inkscape::colorprofile_get_softproof_names() return result; } -Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name) +Glib::ustring Inkscape::CMSSystem::getPathForProfile(Glib::ustring const& name) { loadProfiles(); Glib::ustring result; @@ -695,12 +695,12 @@ Glib::ustring Inkscape::get_path_for_profile(Glib::ustring const& name) return result; } -void Inkscape::colorprofile_cmsDoTransform(cmsHTRANSFORM transform, void *inBuf, void *outBuf, unsigned int size) +void Inkscape::CMSSystem::doTransform(cmsHTRANSFORM transform, void *inBuf, void *outBuf, unsigned int size) { cmsDoTransform(transform, inBuf, outBuf, size); } -bool Inkscape::colorprofile_isPrintColorSpace(ColorProfile const *profile) +bool Inkscape::CMSSystem::isPrintColorSpace(ColorProfile const *profile) { bool isPrint = false; if ( profile ) { @@ -710,6 +710,15 @@ bool Inkscape::colorprofile_isPrintColorSpace(ColorProfile const *profile) return isPrint; } +gint Inkscape::CMSSystem::getChannelCount(ColorProfile const *profile) +{ + gint count = 0; + if ( profile ) { + count = _cmsChannelsOf( asICColorSpaceSig(profile->getColorSpace()) ); + } + return count; +} + #endif // ENABLE_LCMS std::vector ColorProfile::getBaseProfileDirs() { @@ -1077,7 +1086,7 @@ cmsHPROFILE getProofProfileHandle() static void free_transforms(); -cmsHTRANSFORM Inkscape::colorprofile_get_display_transform() +cmsHTRANSFORM Inkscape::CMSSystem::getDisplayTransform() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); @@ -1188,7 +1197,7 @@ void free_transforms() } } -Glib::ustring Inkscape::colorprofile_get_display_id( int screen, int monitor ) +Glib::ustring Inkscape::CMSSystem::getDisplayId( int screen, int monitor ) { Glib::ustring id; @@ -1203,7 +1212,7 @@ Glib::ustring Inkscape::colorprofile_get_display_id( int screen, int monitor ) return id; } -Glib::ustring Inkscape::colorprofile_set_display_per( gpointer buf, guint bufLen, int screen, int monitor ) +Glib::ustring Inkscape::CMSSystem::setDisplayPer( gpointer buf, guint bufLen, int screen, int monitor ) { Glib::ustring id; @@ -1236,7 +1245,7 @@ Glib::ustring Inkscape::colorprofile_set_display_per( gpointer buf, guint bufLen return id; } -cmsHTRANSFORM Inkscape::colorprofile_get_display_per( Glib::ustring const& id ) +cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id ) { cmsHTRANSFORM result = 0; if ( id.empty() ) { diff --git a/src/color-profile.h b/src/color-profile.h index 1b06b6a78..a9724defc 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -33,6 +33,7 @@ struct ColorProfileClass { /** Color Profile. */ struct ColorProfile : public SPObject { friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* ); + friend class CMSSystem; static GType getType(); static void classInit( ColorProfileClass *klass ); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ea39d3435..37998437d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -30,9 +30,7 @@ #include "preferences.h" #include "inkscape.h" #include "sodipodi-ctrlrect.h" -#if ENABLE_LCMS -#include "color-profile-fns.h" -#endif // ENABLE_LCMS +#include "cms-system.h" #include "display/rendermode.h" #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" @@ -1672,9 +1670,9 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); if ( fromDisplay ) { - transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" ); + transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ? *(canvas->cms_key) : "" ); } else { - transf = Inkscape::colorprofile_get_display_transform(); + transf = Inkscape::CMSSystem::getDisplayTransform(); } if (transf) { @@ -1683,7 +1681,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i //#define DEBUG_LCMS #ifdef DEBUG_LCMS @@ -849,9 +849,9 @@ static void sp_image_update( SPObject *object, SPCtx *ctx, unsigned int flags ) DEBUG_MESSAGE( lcmsFive, "in 's sp_image_update. About to call colorprofile_get_handle()" ); #endif // DEBUG_LCMS guint profIntent = Inkscape::RENDERING_INTENT_UNKNOWN; - cmsHPROFILE prof = Inkscape::colorprofile_get_handle( object->document, - &profIntent, - image->color_profile ); + cmsHPROFILE prof = Inkscape::CMSSystem::getHandle( object->document, + &profIntent, + image->color_profile ); if ( prof ) { icProfileClassSignature profileClass = cmsGetDeviceClass( prof ); if ( profileClass != icSigNamedColorClass ) { diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 3605bde55..9293564d5 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -1,5 +1,3 @@ -#define __SP_SVG_COLOR_C__ - /** * \file * Reading \& writing of SVG/CSS colors. @@ -37,17 +35,16 @@ #include "svg-icc-color.h" #if ENABLE_LCMS -#include #include "color.h" #include "color-profile.h" #include "document.h" #include "inkscape.h" #include "profile-manager.h" -#include "color-profile-cms-fns.h" #endif // ENABLE_LCMS -#include "color-profile-fns.h" +#include "cms-system.h" using std::sprintf; +using Inkscape::CMSSystem; struct SPSVGColor { unsigned long rgb; @@ -467,7 +464,7 @@ sp_svg_create_color_hash() #if ENABLE_LCMS //helper function borrowed from src/widgets/sp-color-icc-selector.cpp: -void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ); +void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const**& tippies, guint const*& scalies ); void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b){ guchar color_out[4]; @@ -481,18 +478,18 @@ g_message("profile name: %s", icc->colorProfile.c_str()); gchar const** names = 0; gchar const** tips = 0; guint const* scales = 0; - getThings( asICColorSpaceSig(prof->getColorSpace()), names, tips, scales ); + getThings( prof, names, tips, scales ); - guint count = _cmsChannelsOf( asICColorSpaceSig(prof->getColorSpace()) ); + gint count = CMSSystem::getChannelCount( prof ); if (count > 4) { count = 4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) } - for (guint i=0;icolors[i])*256.0) * (gdouble)scales[i]); g_message("input[%d]: %d",i, color_in[i]); } - cmsDoTransform( trans, color_in, color_out, 1 ); + CMSSystem::doTransform( trans, color_in, color_out, 1 ); g_message("transform to sRGB done"); } *r = color_out[0]; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index aa3c18aaa..d11ffd565 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -41,7 +41,7 @@ #include "ui/widget/spinbutton.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" -#include "color-profile-fns.h" +#include "cms-system.h" #include "color-profile.h" #include "display/canvas-grid.h" #include "path-prefix.h" @@ -62,6 +62,7 @@ using Inkscape::UI::Widget::PrefCheckButton; using Inkscape::UI::Widget::PrefRadioButton; using Inkscape::UI::Widget::PrefSpinButton; using Inkscape::UI::Widget::StyleSwatch; +using Inkscape::CMSSystem; InkscapePreferences::InkscapePreferences() @@ -858,7 +859,7 @@ static void profileComboChanged( Gtk::ComboBoxText* combo ) } else { Glib::ustring active = combo->get_active_text(); - Glib::ustring path = get_path_for_profile(active); + Glib::ustring path = CMSSystem::getPathForProfile(active); if ( !path.empty() ) { prefs->setString("/options/displayprofile/uri", path); } @@ -868,7 +869,7 @@ static void profileComboChanged( Gtk::ComboBoxText* combo ) static void proofComboChanged( Gtk::ComboBoxText* combo ) { Glib::ustring active = combo->get_active_text(); - Glib::ustring path = get_path_for_profile(active); + Glib::ustring path = CMSSystem::getPathForProfile(active); if ( !path.empty() ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -975,7 +976,7 @@ void InkscapePreferences::initPageCMS() #if ENABLE_LCMS { - std::vector names = ::Inkscape::colorprofile_get_display_names(); + std::vector names = ::Inkscape::CMSSystem::getDisplayNames(); Glib::ustring current = prefs->getString( "/options/displayprofile/uri" ); gint index = 0; @@ -983,7 +984,7 @@ void InkscapePreferences::initPageCMS() index++; for ( std::vector::iterator it = names.begin(); it != names.end(); ++it ) { _cms_display_profile.append_text( *it ); - Glib::ustring path = get_path_for_profile(*it); + Glib::ustring path = CMSSystem::getPathForProfile(*it); if ( !path.empty() && path == current ) { _cms_display_profile.set_active(index); } @@ -993,12 +994,12 @@ void InkscapePreferences::initPageCMS() _cms_display_profile.set_active(0); } - names = ::Inkscape::colorprofile_get_softproof_names(); + names = ::Inkscape::CMSSystem::getSoftproofNames(); current = prefs->getString("/options/softproof/uri"); index = 0; for ( std::vector::iterator it = names.begin(); it != names.end(); ++it ) { _cms_proof_profile.append_text( *it ); - Glib::ustring path = get_path_for_profile(*it); + Glib::ustring path = CMSSystem::getPathForProfile(*it); if ( !path.empty() && path == current ) { _cms_proof_profile.set_active(index); } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 52008625a..34c3ab75a 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -28,7 +28,7 @@ #include #include "box3d-context.h" -#include "color-profile-fns.h" +#include "cms-system.h" #include "conn-avoid-ref.h" #include "desktop-events.h" #include "desktop-handles.h" @@ -193,7 +193,7 @@ void CMSPrefWatcher::hook(EgeColorProfTracker */*tracker*/, gint screen, gint mo guint len = 0; ege_color_prof_tracker_get_profile_for( screen, monitor, reinterpret_cast(&buf), &len ); - Glib::ustring id = Inkscape::colorprofile_set_display_per( buf, len, screen, monitor ); + Glib::ustring id = Inkscape::CMSSystem::setDisplayPer( buf, len, screen, monitor ); #endif // ENABLE_LCMS } @@ -540,7 +540,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if ENABLE_LCMS bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); if ( fromDisplay ) { - Glib::ustring id = Inkscape::colorprofile_get_display_id( 0, 0 ); + Glib::ustring id = Inkscape::CMSSystem::getDisplayId( 0, 0 ); bool enabled = false; if ( dtw->canvas->cms_key ) { @@ -805,7 +805,7 @@ void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidge GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(dtw)); gint screenNum = gdk_screen_get_number(screen); gint monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_toplevel(GTK_WIDGET(dtw))->window); - Glib::ustring id = Inkscape::colorprofile_get_display_id( screenNum, monitor ); + Glib::ustring id = Inkscape::CMSSystem::getDisplayId( screenNum, monitor ); bool enabled = false; if ( dtw->canvas->cms_key ) { *(dtw->canvas->cms_key) = id; diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 9e5291cc4..888cc2629 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -15,9 +15,9 @@ #define noDEBUG_LCMS #if ENABLE_LCMS -#include "color-profile-fns.h" -#include "color-profile-cms-fns.h" #include "color-profile.h" +#include "cms-system.h" +#include "color-profile-cms-fns.h" #ifdef DEBUG_LCMS #include "preferences.h" @@ -259,6 +259,12 @@ void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guin tippies = tips[index]; scalies = scales[index]; } + + +void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) { + getThings( asICColorSpaceSig(prof->getColorSpace()), namers, tippies, scalies ); +} + #endif // ENABLE_LCMS diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 546f7838b..1324e0b16 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -36,11 +36,9 @@ #include "../document.h" #include "../profile-manager.h" #include "color-profile.h" -#include "color-profile-fns.h" -#if ENABLE_LCMS -//#include "lcms.h" -//#include "color-profile-cms-fns.h" -#endif // ENABLE_LCMS +#include "cms-system.h" + +using Inkscape::CMSSystem; struct SPColorNotebookTracker { const gchar* name; @@ -540,7 +538,7 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) gtk_widget_set_sensitive (_box_toomuchink, false); if (color.icc){ Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str()); - if ( prof && colorprofile_isPrintColorSpace(prof) ) { + if ( prof && CMSSystem::isPrintColorSpace(prof) ) { gtk_widget_show(GTK_WIDGET(_box_toomuchink)); double ink_sum = 0; for (unsigned int i=0; icolors.size(); i++){ -- cgit v1.2.3 From 61b9edb0a77f71d669a621ef2c58f1d1ea6f463d Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 10 Jul 2011 01:48:48 -0700 Subject: Update for non-LCMS builds. (bzr r10438) --- src/color-profile.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/color-profile.cpp b/src/color-profile.cpp index f858f7f70..41c9d4c63 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -131,6 +131,7 @@ public: namespace Inkscape { +#ifdef ENABLE_LCMS icColorSpaceSignature asICColorSpaceSig(ColorSpaceSig const & sig) { return ColorSpaceSigWrapper(sig); @@ -140,6 +141,7 @@ icProfileClassSignature asICColorProfileClassSig(ColorProfileClassSig const & si { return ColorProfileClassSigWrapper(sig); } +#endif // ENABLE_LCMS } // namespace Inkscape -- cgit v1.2.3 From 12f47cac056804dd53cc334b27c7b1b0f55ab5b6 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 10 Jul 2011 11:01:19 +0200 Subject: Allow em and ex as units on font-size. (bzr r10437.1.1) --- src/libnrtype/Layout-TNG-Input.cpp | 2 +- src/style.cpp | 133 +++++++++++++++++++++---------------- src/style.h | 11 +-- 3 files changed, 83 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index 45bc0c89b..c5ea3969d 100644 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -135,7 +135,7 @@ float Layout::InputStreamTextSource::styleComputeFontSize() const if (this_style->font_size.set && !this_style->font_size.inherit) { switch (this_style->font_size.type) { case SP_FONT_SIZE_LITERAL: { - switch(this_style->font_size.value) { // these multipliers are straight out of the CSS spec + switch(this_style->font_size.literal) { // these multipliers are straight out of the CSS spec case SP_CSS_FONT_SIZE_XX_SMALL: return medium_font_size * inherit_multiplier * (3.0/5.0); case SP_CSS_FONT_SIZE_X_SMALL: return medium_font_size * inherit_multiplier * (3.0/4.0); case SP_CSS_FONT_SIZE_SMALL: return medium_font_size * inherit_multiplier * (8.0/9.0); diff --git a/src/style.cpp b/src/style.cpp index bb25a5f46..699b087dd 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -1343,11 +1343,11 @@ sp_style_merge_font_size_from_parent(SPIFontSize &child, SPIFontSize const &pare * fixme: SVG and CSS do not specify clearly, whether we should use * user or screen coordinates (Lauris) */ - if (child.value < SP_CSS_FONT_SIZE_SMALLER) { - child.computed = font_size_table[child.value]; - } else if (child.value == SP_CSS_FONT_SIZE_SMALLER) { + if (child.literal < SP_CSS_FONT_SIZE_SMALLER) { + child.computed = font_size_table[child.literal]; + } else if (child.literal == SP_CSS_FONT_SIZE_SMALLER) { child.computed = parent.computed / 1.2; - } else if (child.value == SP_CSS_FONT_SIZE_LARGER) { + } else if (child.literal == SP_CSS_FONT_SIZE_LARGER) { child.computed = parent.computed * 1.2; } else { /* Illegal value */ @@ -1355,7 +1355,21 @@ sp_style_merge_font_size_from_parent(SPIFontSize &child, SPIFontSize const &pare } else if (child.type == SP_FONT_SIZE_PERCENTAGE) { /* Unlike most other lengths, percentage for font size is relative to parent computed value * rather than viewport. */ - child.computed = parent.computed * SP_F8_16_TO_FLOAT(child.value); + child.computed = parent.computed * child.value; + } else if (child.type == SP_FONT_SIZE_LENGTH) { + switch (child.unit) { + case SP_CSS_UNIT_EM: + /* Relative to parent font size */ + child.computed = parent.computed * child.value; + break; + case SP_CSS_UNIT_EX: + /* Relative to parent font size */ + child.computed = parent.computed * child.value * 0.5; /* Hack */ + break; + default: + /* No change */ + break; + } } } @@ -1790,7 +1804,7 @@ get_relative_font_size_frac(SPIFontSize const &font_size) { switch (font_size.type) { case SP_FONT_SIZE_LITERAL: { - switch (font_size.value) { + switch (font_size.literal) { case SP_CSS_FONT_SIZE_SMALLER: return 5.0 / 6.0; @@ -1803,10 +1817,20 @@ get_relative_font_size_frac(SPIFontSize const &font_size) } case SP_FONT_SIZE_PERCENTAGE: - return SP_F8_16_TO_FLOAT(font_size.value); + return font_size.value; + + case SP_FONT_SIZE_LENGTH: { + switch (font_size.unit ) { + case SP_CSS_UNIT_EM: + return font_size.value; + + case SP_CSS_UNIT_EX: + return font_size.value * 0.5; - case SP_FONT_SIZE_LENGTH: - g_assert_not_reached(); + default: + g_assert_not_reached(); + } + } } g_assert_not_reached(); } @@ -1853,20 +1877,29 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare { /* font-size. Note that we update the computed font-size of style, to assist in em calculations later in this function. */ + if (parent->font_size.set && !parent->font_size.inherit) { + /* Parent has defined font-size */ + if (!style->font_size.set || style->font_size.inherit) { /* font_size inherits the computed value, so we can use the parent value * verbatim. */ style->font_size = parent->font_size; - } else if ( style->font_size.type == SP_FONT_SIZE_LENGTH ) { + + } else if ( style->font_size.type == SP_FONT_SIZE_LENGTH && + style->font_size.unit != SP_CSS_UNIT_EM && + style->font_size.unit != SP_CSS_UNIT_EX ) { + /* Child already has absolute size (stored in computed value), so do nothing. */ + } else if ( style->font_size.type == SP_FONT_SIZE_LITERAL - && style->font_size.value < SP_CSS_FONT_SIZE_SMALLER ) { + && style->font_size.literal < SP_CSS_FONT_SIZE_SMALLER ) { /* Child already has absolute size, but we ensure that the computed value is up-to-date. */ - unsigned const ix = style->font_size.value; + unsigned const ix = style->font_size.literal; g_assert(ix < G_N_ELEMENTS(font_size_table)); style->font_size.computed = font_size_table[ix]; + } else { /* Child has relative size. */ double const child_frac(get_relative_font_size_frac(style->font_size)); @@ -1875,17 +1908,26 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare style->font_size.computed = parent->font_size.computed * child_frac; if ( ( parent->font_size.type == SP_FONT_SIZE_LITERAL - && parent->font_size.value < SP_CSS_FONT_SIZE_SMALLER ) - || parent->font_size.type == SP_FONT_SIZE_LENGTH ) - { + && parent->font_size.literal < SP_CSS_FONT_SIZE_SMALLER ) || + ( parent->font_size.type == SP_FONT_SIZE_LENGTH && + parent->font_size.unit != SP_CSS_UNIT_EM && + parent->font_size.unit != SP_CSS_UNIT_EX ) ) { + /* Absolute value. */ style->font_size.type = SP_FONT_SIZE_LENGTH; - /* .value is unused for SP_FONT_SIZE_LENGTH. */ + /* .value is unused for non ex/em SP_FONT_SIZE_LENGTH. */ + } else { /* Relative value. */ + double const parent_frac(get_relative_font_size_frac(parent->font_size)); - style->font_size.type = SP_FONT_SIZE_PERCENTAGE; - style->font_size.value = SP_F8_16_FROM_FLOAT(parent_frac * child_frac); + if( style->font_size.type == SP_FONT_SIZE_LENGTH ) { + /* Value in terms of ex/em */ + style->font_size.value *= parent_frac; + } else { + style->font_size.value = parent_frac * child_frac; + style->font_size.type = SP_FONT_SIZE_PERCENTAGE; + } } } } @@ -2677,7 +2719,7 @@ sp_style_clear(SPStyle *style) style->font_size.set = FALSE; style->font_size.type = SP_FONT_SIZE_LITERAL; - style->font_size.value = SP_CSS_FONT_SIZE_MEDIUM; + style->font_size.literal = SP_CSS_FONT_SIZE_MEDIUM; style->font_size.computed = 12.0; style->font_style.set = FALSE; style->font_style.value = style->font_style.computed = SP_CSS_FONT_STYLE_NORMAL; @@ -3008,6 +3050,7 @@ sp_style_read_ienum(SPIEnum *val, gchar const *str, SPStyleEnum const *dict, } } } + return; } @@ -3284,52 +3327,26 @@ sp_style_read_ifontsize(SPIFontSize *val, gchar const *str) val->set = TRUE; val->inherit = FALSE; val->type = SP_FONT_SIZE_LITERAL; - val->value = enum_font_size[i].value; + val->literal = enum_font_size[i].value; return; } } /* Invalid */ return; } else { - gdouble value; - gchar *e; - /* fixme: Move this to standard place (Lauris) */ - value = g_ascii_strtod(str, &e); - if ((gchar const *) e != str) { - if (!*e) { - /* Userspace */ - } else if (!strcmp(e, "px")) { - /* Userspace */ - } else if (!strcmp(e, "pt")) { - /* Userspace * DEVICESCALE */ - value *= PX_PER_PT; - } else if (!strcmp(e, "pc")) { - /* 12pt */ - value *= PX_PER_PT * 12.0; - } else if (!strcmp(e, "mm")) { - value *= PX_PER_MM; - } else if (!strcmp(e, "cm")) { - value *= PX_PER_CM; - } else if (!strcmp(e, "in")) { - value *= PX_PER_IN; - } else if (!strcmp(e, "%")) { - /* Percentage */ - val->set = TRUE; - val->inherit = FALSE; - val->type = SP_FONT_SIZE_PERCENTAGE; - val->value = SP_F8_16_FROM_FLOAT(value / 100.0); - return; - } else { - /* Invalid */ - return; - } - /* Length */ - val->set = TRUE; - val->inherit = FALSE; + SPILength length; + sp_style_read_ilength(&length, str); + val->set = length.set; + val->inherit = length.inherit; + val->unit = length.unit; + val->value = length.value; + val->computed = length.computed; + if( val->unit == SP_CSS_UNIT_PERCENT ) { + val->type = SP_FONT_SIZE_PERCENTAGE; + } else { val->type = SP_FONT_SIZE_LENGTH; - val->computed = value; - return; } + return; } } @@ -3935,7 +3952,7 @@ sp_style_write_ifontsize(gchar *p, gint const len, gchar const *key, return g_strlcpy(p, os.str().c_str(), len); } else if (val->type == SP_FONT_SIZE_PERCENTAGE) { Inkscape::CSSOStringStream os; - os << key << ":" << (SP_F8_16_TO_FLOAT(val->value) * 100.0) << "%;"; + os << key << ":" << (val->value * 100.0) << "%;"; return g_strlcpy(p, os.str().c_str(), len); } } diff --git a/src/style.h b/src/style.h index a12db388a..d82a0dd5e 100644 --- a/src/style.h +++ b/src/style.h @@ -206,21 +206,24 @@ enum { SP_BASELINE_SHIFT_PERCENTAGE }; -#define SP_FONT_SIZE ((1 << 24) - 1) - +/* +Not used anymore, originally for SPIFontSize #define SP_F8_16_TO_FLOAT(v) ((gdouble) (v) / (1 << 16)) #define SP_F8_16_FROM_FLOAT(v) ((int) ((v) * ((1 << 16) + 0.9999))) +*/ #define SP_STYLE_FLAG_IFSET (1 << 0) #define SP_STYLE_FLAG_IFDIFF (1 << 1) #define SP_STYLE_FLAG_ALWAYS (1 << 2) -/// Fontsize type internal to SPStyle. +/// Fontsize type internal to SPStyle (also used by libnrtype/Layout-TNG-Input.cpp). struct SPIFontSize { unsigned set : 1; unsigned inherit : 1; unsigned type : 2; - unsigned value : 24; + unsigned unit : 4; + unsigned literal: 4; + float value; float computed; }; -- cgit v1.2.3 From 7b0a658e33d7b7a7f0313bef2fdaf8ed32af1c7e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 10 Jul 2011 18:54:41 +0100 Subject: Remove --export-dynamic linker flag (bzr r10430.1.1) --- src/Makefile.am | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7925dcd7e..5a50eb36f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -208,11 +208,7 @@ libinkscape_a_SOURCES = $(ink_common_sources) inkscape_SOURCES += main.cpp $(win32_sources) inkscape_LDADD = $(all_libs) -if EXPORT_DYNAMIC_DIRECT -inkscape_LDFLAGS = --export-dynamic $(kdeldflags) $(mwindows) -else -inkscape_LDFLAGS = -Wl,--export-dynamic $(kdeldflags) $(mwindows) -endif +inkscape_LDFLAGS = $(kdeldflags) $(mwindows) inkview_SOURCES += inkview.cpp $(win32_sources) inkview_LDADD = $(all_libs) -- cgit v1.2.3 From 79cb3f5ae387630b9f696c17d99de984c00a43e3 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 10 Jul 2011 20:13:40 +0200 Subject: i18n. Adding new GCode Tool extensions (see Bug #731177). i18n. Fix typo in the ABC custom predefined filters (see Bug #806055). Translations. inkscape.pot and fr.po update. (bzr r10437.1.3) --- src/extension/internal/filter/abc.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h index 8368d3f3b..cf2bc8927 100755 --- a/src/extension/internal/filter/abc.h +++ b/src/extension/internal/filter/abc.h @@ -218,7 +218,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) * Smoothness (0.->10., default 6.) -> blur (stdDeviation) * Elevation (0->360, default 25) -> feDistantLight (elevation) * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lightning color (guint, default -1 [white]) -> diffuse (lighting-color) + * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) */ class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { @@ -237,7 +237,7 @@ public: "6\n" "25\n" "235\n" - "-1\n" + "-1\n" "\n" "all\n" "\n" @@ -355,7 +355,7 @@ Feather::get_filter_text (Inkscape::Extension::Extension * ext) * Brightness (0.0->5., default .9) -> specular (specularConstant) * Elevation (0->360, default 60) -> feDistantLight (elevation) * Azimuth (0->360, default 225) -> feDistantLight (azimuth) - * Lightning color (guint, default -1 [white]) -> specular (lighting-color) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) */ class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { @@ -375,7 +375,7 @@ public: "0.9\n" "60\n" "225\n" - "-1\n" + "-1\n" "\n" "all\n" "\n" @@ -795,7 +795,7 @@ Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) * Brightness (0.0->5., default 1.) -> specular (specularConstant) * Elevation (0->360, default 45) -> feDistantLight (elevation) * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lightning color (guint, default -1 [white]) -> specular (lighting-color) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) */ class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { @@ -815,7 +815,7 @@ public: "1\n" "45\n" "235\n" - "-1\n" + "-1\n" "\n" "all\n" "\n" -- cgit v1.2.3 From dd5da66df059871c546f4d09b9d2eb92e71b74b7 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 10 Jul 2011 21:40:56 +0200 Subject: Selector's toolbar: changing the dimensions of the visual bounding box of selection of multiple objects having different stroke widths has been fixed (bug #212768, #190557, ...) Fixed bugs: - https://launchpad.net/bugs/212768 - https://launchpad.net/bugs/190557 (bzr r10437.1.5) --- src/seltrans.cpp | 4 +- src/snap-preferences.cpp | 2 +- src/snap-preferences.h | 2 +- src/sp-item-transform.cpp | 273 ++++++++++++++++++++++++++++++++++------- src/sp-item-transform.h | 3 +- src/widgets/select-toolbar.cpp | 42 ++++--- 6 files changed, 260 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index f95a204a9..f6a702ed9 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1566,7 +1566,7 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand // Calculate the absolute affine while taking into account the scaling of the stroke width Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs->getBool("/options/transform/stroke", true); - Geom::Affine abs_affine = get_scale_transform_with_stroke (*_bbox, _strokewidth, transform_stroke, + Geom::Affine abs_affine = get_scale_transform_with_uniform_stroke (*_bbox, _strokewidth, transform_stroke, new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]); // Calculate the scaled geometrical bbox @@ -1613,7 +1613,7 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_ strokewidth = _strokewidth; } - _absolute_affine = get_scale_transform_with_stroke (*_approximate_bbox, strokewidth, transform_stroke, + _absolute_affine = get_scale_transform_with_uniform_stroke (*_approximate_bbox, strokewidth, transform_stroke, new_bbox_min[Geom::X], new_bbox_min[Geom::Y], new_bbox_max[Geom::X], new_bbox_max[Geom::Y]); // return the new handle position diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 4859b111e..b98726a86 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -5,7 +5,7 @@ * Authors: * Diederik van Lierop * - * Copyright (C) 2008 Authors + * Copyright (C) 2008 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 8e8ebc9cf..35d05c40e 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -8,7 +8,7 @@ * Authors: * Diederik van Lierop * - * Copyright (C) 2008 - 2010 Authors + * Copyright (C) 2008 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index ae55a5c50..45d965e44 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -7,8 +7,9 @@ * bulia byak * Johan Engelen * Abhishek Sharma + * Diederik van Lierop * - * Copyright (C) 1999-2008 authors + * Copyright (C) 1999-2011 authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -67,46 +68,76 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) { - item->set_i2d_affine(item->i2d_affine() * tr); + item->set_i2d_affine(item->i2d_affine() * tr); - item->doWriteTransform(item->getRepr(), item->transform); + item->doWriteTransform(item->getRepr(), item->transform); } -/* -** Returns the matrix you need to apply to an object with given visual bbox and strokewidth to -scale/move it to the new visual bbox x0/y0/x1/y1. Takes into account the "scale stroke" -preference value passed to it. Has to solve a quadratic equation to make sure -the goal is met exactly and the stroke scaling is obeyed. +/** + * \brief Calculate the affine transformation required to transform one visual bounding box into another, accounting for a uniform strokewidth + * + * PS: This function will only return accurate results for the visual bounding box of a selection of one of more objects, all having + * the same strokewidth. If the stroke width varies from object to object in this selection, then the function + * get_scale_transform_with_unequal_stroke() should be called instead + * + * When scaling or stretching an object using the selector, e.g. by dragging the handles or by entering a value, we will + * need to calculate the affine transformation for the old dimensions to the new dimensions. When using a geometric bounding + * box this is very straightforward, but when using a visual bounding box this become more tricky as we need to account for + * the strokewidth, which is either constant or scales width the area of the object. This function takes care of the calculation + * of the affine transformation: + * \param bbox_visual Current visual bounding box + * \param strokewidth Strokewidth + * \param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box + * \param x0 Coordinate of the target visual bounding box + * \param y0 Coordinate of the target visual bounding box + * \param x1 Coordinate of the target visual bounding box + * \param y1 Coordinate of the target visual bounding box + * PS: we have to pass each coordinate individually, to find out if we are mirroring the object; Using a Geom::Rect() instead is + not possible here because it will only allow for a positive width and height, and therefore cannot mirror + * \return */ Geom::Affine -get_scale_transform_with_stroke (Geom::Rect const &bbox_param, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { - Geom::Rect bbox (bbox_param); - - Geom::Affine p2o = Geom::Translate (-bbox.min()); + Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); - Geom::Affine scale = Geom::Scale (1, 1); // scale component - Geom::Affine unbudge = Geom::Translate (0, 0); // move component to compensate for the drift caused by stroke width change + Geom::Affine scale = Geom::Scale (1, 1); + Geom::Affine unbudge = Geom::Translate (0, 0); // moves the object(s) to compensate for the drift caused by stroke width change + + // 1) We start with a visual bounding box (w0, h0) which we want to transfer into another visual bounding box (w1, h1) + // 2) The stroke is r0, equal for all edges + // 3) Given this visual bounding box we can calculate the geometric bounding box by subtracting half the stroke from each side; + // -> The width and height of the geometric bounding box will therefore be (w0 - 2*0.5*r0) and (h0 - 2*0.5*r0) - gdouble w0 = bbox[Geom::X].extent(); // will return a value >= 0, as required further down the road - gdouble h0 = bbox[Geom::Y].extent(); + gdouble w0 = bbox_visual.width(); // will return a value >= 0, as required further down the road + gdouble h0 = bbox_visual.height(); + gdouble r0 = fabs(strokewidth); + + // We also know the width and height of the new visual bounding box gdouble w1 = x1 - x0; // can have any sign gdouble h1 = y1 - y0; - gdouble r0 = strokewidth; + // The new visual bounding box will have a stroke r1 + + // We will now try to calculate the affine transformation required to transform the first visual bounding box into + // the second one, while accounting for strokewidth - if (bbox.hasZeroArea()) { - Geom::Affine move = Geom::Translate(x0 - bbox.min()[Geom::X], y0 - bbox.min()[Geom::Y]); - return (move); // cannot scale from empty boxes at all, so only translate + if (bbox_visual.hasZeroArea()) { // Obviously we cannot scale from empty visual bounding boxes at all, so we will only translate in such a case + Geom::Affine move = Geom::Translate(x0 - bbox_visual.min()[Geom::X], y0 - bbox_visual.min()[Geom::Y]); + return (move); } - Geom::Affine direct = Geom::Scale(w1 / w0, h1 / h0); + Geom::Affine direct = Geom::Scale(w1 / w0, h1 / h0); // Scaling of the visual bounding box + // Although the area of the visual bounding box is not zero, we can still have a geometric + // bounding box with one or both sides having zero length. We can't handle this and will therefore + // simply return the scaling of the visual bounding box, without accounting for any stroke scaling if (fabs(w0 - r0) < 1e-6 || fabs(h0 - r0) < 1e-6 || (!transform_stroke && (fabs(w1 - r0) < 1e-6 || fabs(h1 - r0) < 1e-6))) { - return (p2o * direct * o2n); // can't solve the equation: one of the dimensions is equal to stroke width, so return the straightforward scaler + return (p2o * direct * o2n); } + // Here starts the calculation you've been waiting for; first do some preparation int flip_x = (w1 > 0) ? 1 : -1; int flip_y = (h1 > 0) ? 1 : -1; @@ -115,43 +146,201 @@ get_scale_transform_with_stroke (Geom::Rect const &bbox_param, gdouble strokewid w1 = fabs(w1); h1 = fabs(h1); r0 = fabs(r0); - // w0 and h0 will always be positive due to the definition extent() + // w0 and h0 will always be positive due to the definition of the width() and height() methods. - gdouble ratio_x = (w1 - r0) / (w0 - r0); + gdouble ratio_x = (w1 - r0) / (w0 - r0); // Only valid when the stroke is kept constant, in which case r1 = r0 gdouble ratio_y = (h1 - r0) / (h0 - r0); - + + // Calculating the scaling of the geometric bounding box if the stroke is kept constant Geom::Affine direct_constant_r = Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); - if (transform_stroke && r0 != 0 && r0 != Geom::infinity()) { // there's stroke, and we need to scale it - // These coefficients are obtained from the assumption that scaling applies to the - // non-stroked "shape proper" and that stroke scale is scaled by the expansion of that - // matrix. We're trying to solve this equation: - // r1 = r0 * sqrt (((w1-r0)/(w0-r0))*((h1-r0)/(h0-r0))) - // The operant of the sqrt() must be positive, which is ensured by the fabs() a few lines above + // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find + if (transform_stroke && r0 != 0 && r0 != Geom::infinity()) { // Check if there's stroke, and we need to scale it + /* Initial area of the geometric bounding box: A0 = (w0-r0)*(h0-r0) + * Desired area of the geometric bounding box: A1 = (w1-r1)*(h1-r1) + * This is how the stroke should scale: r1^2 / A1 = r0^2 / A0 + * So therefore we will need to solve this equation: + * + * r1^2 * (w0-r0) * (h1-r1) = r0^2 * (w1-r1) * (h0-r0) + * + * This is a quadratic equation in r1, of which the roots can be found using the ABC formula + * */ gdouble A = -w0*h0 + r0*(w0 + h0); gdouble B = -(w1 + h1) * r0*r0; gdouble C = w1 * h1 * r0*r0; if (B*B - 4*A*C > 0) { + // Of the two roots, I verified experimentally that this is the one we need gdouble r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); - //gdouble r2 = (-B + sqrt (B*B - 4*A*C))/(2*A); - //std::cout << "r0" << r0 << " r1" << r1 << " r2" << r2 << "\n"; - // - // If w1 < 0 then the scale will be wrong if we just do - // gdouble scale_x = (w1 - r1)/(w0 - r0); - // Here we also need the absolute values of w0, w1, h0, h1, and r1 + // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); + // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier gdouble scale_x = (w1 - r1)/(w0 - r0); gdouble scale_y = (h1 - r1)/(h0 - r0); + // Now we account for mirroring by flipping if needed scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); + // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); - } else { + } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? scale *= direct; } - } else { - if (r0 == 0 || r0 == Geom::infinity()) { // no stroke to scale - scale *= direct; - } else {// nonscaling strokewidth + } else { // The stroke should not be scaled, or is zero + if (!transform_stroke) { // Nonscaling strokewidth scale *= direct_constant_r; unbudge *= Geom::Translate (flip_x * 0.5 * r0 * (1 - ratio_x), flip_y * 0.5 * r0 * (1 - ratio_y)); + } else { // Strokewidth is zero or infinite + scale *= direct; + } + } + + return (p2o * scale * unbudge * o2n); +} + +/** + * \brief Calculate the affine transformation required to transform one visual bounding box into another, accounting for a VARIABLE strokewidth + * + * Note: Please try to understand get_scale_transform_with_uniform_stroke() first, and read all it's comments carefully. This function + * (get_scale_transform_with_unequal_stroke) is a bit different because it will allow for a strokewidth that's different for each + * side of the visual bounding box. Such a situation will arise when transforming the visual bounding box of a selection of objects, + * each having a different stroke width. In fact this function is a generalized version of get_scale_transform_with_uniform_stroke(), but + * will not (yet) replace it because it has not been tested as carefully, and because the old function is can serve as an introduction to + * understand the new one. + * + * When scaling or stretching an object using the selector, e.g. by dragging the handles or by entering a value, we will + * need to calculate the affine transformation for the old dimensions to the new dimensions. When using a geometric bounding + * box this is very straightforward, but when using a visual bounding box this become more tricky as we need to account for + * the strokewidth, which is either constant or scales width the area of the object. This function takes care of the calculation + * of the affine transformation: + * + * \param bbox_visual Current visual bounding box + * \param bbox_geometric Current geometric bounding box (allows for calculating the strokewidth of each edge) + * \param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box + * \param x0 Coordinate of the target visual bounding box + * \param y0 Coordinate of the target visual bounding box + * \param x1 Coordinate of the target visual bounding box + * \param y1 Coordinate of the target visual bounding box + PS: we have to pass each coordinate individually, to find out if we are mirroring the object; Using a Geom::Rect() instead is + not possible here because it will only allow for a positive width and height, and therefore cannot mirror + * \return +*/ + +Geom::Affine +get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +{ + Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); + Geom::Affine o2n = Geom::Translate (x0, y0); + + Geom::Affine scale = Geom::Scale (1, 1); + Geom::Affine unbudge = Geom::Translate (0, 0); // moves the object(s) to compensate for the drift caused by stroke width change + + // 1) We start with a visual bounding box (w0, h0) which we want to transfer into another visual bounding box (w1, h1) + // 2) We will also know the geometric bounding box, which can be used to calculate the strokewidth. The strokewidth will however + // be different for each of the four sides (left/right/top/bottom: r0l, r0r, r0t, r0b) + + gdouble w0 = bbox_visual.width(); // will return a value >= 0, as required further down the road + gdouble h0 = bbox_visual.height(); + + // We also know the width and height of the new visual bounding box + gdouble w1 = x1 - x0; // can have any sign + gdouble h1 = y1 - y0; + // The new visual bounding box will have strokes r1l, r1r, r1t, and r1b + + // We will now try to calculate the affine transformation required to transform the first visual bounding box into + // the second one, while accounting for strokewidth + gdouble r0w = w0 - bbox_geom.width(); // r0w is the average strokewidth of the left and right edges, i.e. 0.5*(r0l + r0r) + gdouble r0h = h0 - bbox_geom.height(); // r0h is the average strokewidth of the top and bottom edges, i.e. 0.5*(r0t + r0b) + + // Check whether the stroke is not negative; should not be possible, but just in case: + g_assert(r0w >= 0); + g_assert(r0h >= 0); + + if (bbox_visual.hasZeroArea()) { // Obviously we cannot scale from empty visual bounding boxes at all, so we will only translate in such a case + Geom::Affine move = Geom::Translate(x0 - bbox_visual.min()[Geom::X], y0 - bbox_visual.min()[Geom::Y]); + return (move); + } + + Geom::Affine direct = Geom::Scale(w1 / w0, h1 / h0); + + // Although the area of the visual bounding box is not zero, we can still have a geometric + // bounding box with one or both sides having zero length. We can't handle this and will therefore + // simply return the scaling of the visual bounding box, without accounting for any stroke scaling + if (fabs(w0 - r0w) < 1e-6 || fabs(h0 - r0h) < 1e-6 || (!transform_stroke && (fabs(w1 - r0w) < 1e-6 || fabs(h1 - r0h) < 1e-6))) { + return (p2o * direct * o2n); + } + + // Here starts the calculation you've been waiting for; first do some preparation + int flip_x = (w1 > 0) ? 1 : -1; + int flip_y = (h1 > 0) ? 1 : -1; + + // w1 and h1 will be negative when mirroring, but if so then e.g. w1-r0 won't make sense + // Therefore we will use the absolute values from this point on + w1 = fabs(w1); + h1 = fabs(h1); + // w0 and h0 will always be positive due to the definition of the width() and height() methods. + + gdouble ratio_x = (w1 - r0w) / (w0 - r0w); // Only valid when the stroke is kept constant, in which case r1 = r0 + gdouble ratio_y = (h1 - r0h) / (h0 - r0h); + + // Calculating the scaling of the geometric bounding box if the stroke is kept constant + Geom::Affine direct_constant_r = Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); + + // The calculation of the new strokewidth will only use the average stroke for each of the dimensions; To find the new stroke for each + // of the edges individually though, we will use the boundary condition that the ratio of the left/right strokewidth will not change due to the + // scaling. The same holds for the ratio of the top/bottom strokewidth. + gdouble stroke_ratio_w = fabs(r0w) < 1e-6 ? 1 : (bbox_geom[Geom::X].min() - bbox_visual[Geom::X].min())/r0w; + gdouble stroke_ratio_h = fabs(r0h) < 1e-6 ? 1 : (bbox_geom[Geom::Y].min() - bbox_visual[Geom::Y].min())/r0h; + + // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find + if (transform_stroke && r0w != 0 && r0w != Geom::infinity() && r0h != 0 && r0h != Geom::infinity()) { // Check if there's stroke, and we need to scale it + /* Initial area of the geometric bounding box: A0 = (w0-r0w)*(h0-r0h) + * Desired area of the geometric bounding box: A1 = (w1-r1w)*(h1-r1h) + * This is how the stroke should scale: r1w^2 = A1/A0 * r0w^2, AND + * r1h^2 = A1/A0 * r0h^2 + * Now we have to solve this set of two equations and find r1w and r1h; this too complicated to do by hand, + * so I used wxMaxima for that (http://wxmaxima.sourceforge.net/). These lines can be copied into Maxima + * + * A1: (w1-r1w)*(h1-r1h); + * s: A1/A0; + * expr1a: r1w^2 = s*r0w^2; + * expr1b: r1h^2 = s*r0h^2; + * sol: solve([expr1a, expr1b], [r1h, r1w]); + * sol[1][1]; sol[2][1]; sol[3][1]; sol[4][1]; + * sol[1][2]; sol[2][2]; sol[3][2]; sol[4][2]; + * + * PS1: The last two lines are only needed for readability of the output, and can be omitted if desired + * PS2: A0 is known beforehand and assumed to be constant, instead of using A0 = (w0-r0w)*(h0-r0h). This reduces the + * length of the results significantly + * PS3: You'll get 8 solutions, 4 for each of the strokewidths r1w and r1h. Some experiments quickly showed which of the solutions + * lead to meaningful strokewidths + * */ + gdouble r0h2 = r0h*r0h; + gdouble r0h3 = r0h2*r0h; + gdouble r0w2 = r0w*r0w; + gdouble w12 = w1*w1; + gdouble h12 = h1*h1; + gdouble A0 = bbox_geom.area(); + gdouble A02 = A0*A0; + + gdouble operant = 4*h1*w1*A0+r0h2*w12-2*h1*r0h*r0w*w1+h12*r0w2; + if (operant >= 0) { + // Of the eight roots, I verified experimentally that these are the two we need + gdouble r1h= fabs((r0h*sqrt(operant)-r0h2*w1-h1*r0h*r0w)/(2*A0-2*r0h*r0w)); + gdouble r1w= fabs(-((h1*r0w*A0+r0h2*r0w*w1)*sqrt(operant)+(-3*h1*r0h*r0w*w1-h12*r0w2)*A0-r0h3*r0w*w12+h1*r0h2*r0w2*w1)/((r0h*A0-r0h2*r0w)*sqrt(operant)-2*h1*A02+(3*h1*r0h*r0w-r0h2*w1)*A0+r0h3*r0w*w1-h1*r0h2*r0w2)); + // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); + // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier + gdouble scale_x = (w1 - r1w)/(w0 - r0w); + gdouble scale_y = (h1 - r1h)/(h0 - r0h); + // Now we account for mirroring by flipping if needed + scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); + // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed + unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * (r0w * scale_x - r1w), -flip_y * stroke_ratio_h * (r0h * scale_y - r1h)); + } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? + scale *= direct; + } + } else { // The stroke should not be scaled, or is zero (or infinite) + if (!transform_stroke) { + scale *= direct_constant_r; + unbudge *= Geom::Translate (flip_x * stroke_ratio_w * r0w * (1 - ratio_x), flip_y * stroke_ratio_h * r0h * (1 - ratio_y)); + } else { // can't calculate, because apparently strokewidth is zero or infinite + scale *= direct; } } diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 552b23e2f..47e0ec0ec 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -9,7 +9,8 @@ void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); void sp_item_skew_rel (SPItem *item, double skewX, double skewY); void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); -Geom::Affine get_scale_transform_with_stroke (Geom::Rect const &bbox, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index eb9b2805d..ba32dc321 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -159,12 +159,16 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) document->ensureUpToDate (); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + Geom::OptRect bbox_vis = selection->bounds(SPItem::APPROXIMATE_BBOX); + Geom::OptRect bbox_geom = selection->bounds(SPItem::GEOMETRIC_BBOX); + int prefs_bbox = prefs->getInt("/tools/bounding_box"); - SPItem::BBoxType bbox_type = (prefs_bbox ==0)? + SPItem::BBoxType bbox_type = (prefs_bbox == 0)? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; - Geom::OptRect bbox = selection->bounds(bbox_type); + Geom::OptRect bbox_user = selection->bounds(bbox_type); - if ( !bbox ) { + if ( !bbox_user ) { g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE)); return; } @@ -186,35 +190,35 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) x0 = sp_units_get_pixels (a_x->value, unit); y0 = sp_units_get_pixels (a_y->value, unit); x1 = x0 + sp_units_get_pixels (a_w->value, unit); - xrel = sp_units_get_pixels (a_w->value, unit) / bbox->dimensions()[Geom::X]; + xrel = sp_units_get_pixels (a_w->value, unit) / bbox_user->dimensions()[Geom::X]; y1 = y0 + sp_units_get_pixels (a_h->value, unit); - yrel = sp_units_get_pixels (a_h->value, unit) / bbox->dimensions()[Geom::Y]; + yrel = sp_units_get_pixels (a_h->value, unit) / bbox_user->dimensions()[Geom::Y]; } else { double const x0_propn = a_x->value * unit.unittobase; - x0 = bbox->min()[Geom::X] * x0_propn; + x0 = bbox_user->min()[Geom::X] * x0_propn; double const y0_propn = a_y->value * unit.unittobase; - y0 = y0_propn * bbox->min()[Geom::Y]; + y0 = y0_propn * bbox_user->min()[Geom::Y]; xrel = a_w->value * unit.unittobase; - x1 = x0 + xrel * bbox->dimensions()[Geom::X]; + x1 = x0 + xrel * bbox_user->dimensions()[Geom::X]; yrel = a_h->value * unit.unittobase; - y1 = y0 + yrel * bbox->dimensions()[Geom::Y]; + y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y]; } // Keep proportions if lock is on GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(G_OBJECT(spw), "lock") ); if ( gtk_toggle_action_get_active(lock) ) { if (adj == a_h) { - x1 = x0 + yrel * bbox->dimensions()[Geom::X]; + x1 = x0 + yrel * bbox_user->dimensions()[Geom::X]; } else if (adj == a_w) { - y1 = y0 + xrel * bbox->dimensions()[Geom::Y]; + y1 = y0 + xrel * bbox_user->dimensions()[Geom::Y]; } } // scales and moves, in px - double mh = fabs(x0 - bbox->min()[Geom::X]); - double sh = fabs(x1 - bbox->max()[Geom::X]); - double mv = fabs(y0 - bbox->min()[Geom::Y]); - double sv = fabs(y1 - bbox->max()[Geom::Y]); + double mh = fabs(x0 - bbox_user->min()[Geom::X]); + double sh = fabs(x1 - bbox_user->max()[Geom::X]); + double mv = fabs(y0 - bbox_user->min()[Geom::Y]); + double sv = fabs(y1 - bbox_user->max()[Geom::Y]); // unless the unit is %, convert the scales and moves to the unit if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { @@ -244,11 +248,11 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) Geom::Affine scaler; if (bbox_type == SPItem::APPROXIMATE_BBOX) { - // get_scale_transform_with_stroke() is intended for VISUAL (or APPROXIMATE) bounding boxes, not geometrical ones! - scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1); + scaler = get_scale_transform_with_unequal_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1); } else { - // we'll trick it into using a geometrical bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_with_stroke (*bbox, 0, false, x0, y0, x1, y1); + // get_scale_transform_with_stroke() is intended for VISUAL (or APPROXIMATE) bounding boxes, not geometrical ones! + // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero + scaler = get_scale_transform_with_uniform_stroke (*bbox_user, 0, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); -- cgit v1.2.3 From d35cc479f65a013531ca49b53af8dc9e32671c81 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 11 Jul 2011 01:05:04 +0200 Subject: Simplify rendering of masked / clipped / translucent items. Handle nested clipping paths correctly. (bzr r10347.1.10) --- src/display/nr-arena-item.cpp | 105 ++++++++++++++++++----------------------- src/display/nr-filter-slot.cpp | 2 +- src/display/nr-filter.cpp | 2 +- 3 files changed, 48 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 534591f82..f3de7a66a 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -410,26 +410,17 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area /* How the rendering is done. * - * There is one intermediate surface onto which the object is rendered. - * Clipping, masking and opacity are done with a mask. - * Here are the algorithms: - * a) no clip, no mask, no opacity: direct rendering. - * b) clip, no mask, no opacity: clipping path is rendered and used as a mask. - * c) no clip, mask, no opacity: mask is rendered, luminance is converted to alpha, - * then it is used as a mask. - * d) no clip, no mask, opacity: paint_with_alpha is used. - * e) clip, mask, no opacity: mask is rendered and its luminance is converted to alpha, - * then the clip is composited with it using the IN operator, the result is used - * as a mask. - * f) clip, no mask, opacity: clipping path is rendered with alpha corresponding - * to the opacity value and used as a mask. - * g) no clip, mask, opacity: like e), but the converted mask is composited with - * an uniform fill - * h) clip, mask, opacity: converted mask is composited with the clipping path - * rendered with alpha corresponding to the opacity using the IN operator + * Clipping, masking and opacity are done by rendering them to a surface + * and then compositing the object's rendering onto it with the IN operator. + * The object itself is rendered to a group. + * + * Opacity is done by rendering the clipping path with an alpha + * value corresponding to the opacity. If there is no clipping path, + * the entire intermediate surface is painted with alpha corresponding + * to the opacity value. */ - // handle case a). + // short-circuit the simple case. if (!needs_intermediate_rendering) { state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, pb, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { @@ -440,82 +431,74 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area } cairo_surface_t *intermediate = cairo_surface_create_similar( - cairo_get_target(ct), CAIRO_CONTENT_COLOR_ALPHA, + cairo_get_group_target(ct), CAIRO_CONTENT_COLOR_ALPHA, carea.x1 - carea.x0, carea.y1 - carea.y0); cairo_t *ict = cairo_create(intermediate); cairo_translate(ict, -carea.x0, -carea.y0); - // now ict draws on the intermediate surface and carea is its area. - // 1. Render the mask if present. Otherwise initialize the intermediate surface to opaque. - if (item->mask) { - state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ict, item->mask, &carea, NULL, flags); + // 1. Render clipping path with alpha = opacity. + cairo_set_source_rgba(ict, 0,0,0,opacity); + // Since clip can be combined with opacity, the result could be incorrect + // for overlapping clip children. To fix this we use the SOURCE operator + // instead of the default OVER. + cairo_set_operator(ict, CAIRO_OPERATOR_SOURCE); + if (item->clip) { + state = nr_arena_item_invoke_clip(ict, item->clip, const_cast(area)); if (state & NR_ARENA_ITEM_STATE_INVALID) { retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); goto cleanup; } - ink_cairo_surface_filter(intermediate, intermediate, MaskLuminanceToAlpha()); } else { - cairo_set_source_rgba(ict, 0,0,0,1); + // if there is no clipping path, fill the entire surface with alpha = opacity. cairo_paint(ict); } + // reset back to default + cairo_set_operator(ict, CAIRO_OPERATOR_OVER); - // 2. Render clipping path and composite it with mask - if (item->clip) { - cairo_push_group_with_content(ict, CAIRO_CONTENT_ALPHA); - cairo_set_source_rgba(ict, 0,0,0,opacity); - // Since clip can be combined with opacity, the result could be incorrect - // for overlapping children. To fix this we use the SOURCE operator - // instead of the default OVER - cairo_set_operator(ict, CAIRO_OPERATOR_SOURCE); - state = nr_arena_item_invoke_clip(ict, item->clip, const_cast(area)); - cairo_pop_group_to_source(ict); + // 2. Render the mask if present and compose it with the clipping path + opacity. + if (item->mask) { + cairo_push_group(ict); + state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ict, item->mask, &carea, NULL, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); goto cleanup; } + cairo_surface_t *mask_s = cairo_get_group_target(ict); + // Convert mask's luminance to alpha + ink_cairo_surface_filter(mask_s, mask_s, MaskLuminanceToAlpha()); + cairo_pop_group_to_source(ict); cairo_set_operator(ict, CAIRO_OPERATOR_IN); cairo_paint(ict); cairo_set_operator(ict, CAIRO_OPERATOR_OVER); } - // 3. Render object itself - cairo_push_group_with_content(ict, CAIRO_CONTENT_COLOR_ALPHA); + // 3. Render object itself. + cairo_push_group(ict); state = NR_ARENA_ITEM_VIRTUAL (item, render) (ict, item, &carea, pb, flags); - cairo_pop_group_to_source(ict); if (state & NR_ARENA_ITEM_STATE_INVALID) { retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); goto cleanup; } - // 4. Apply filter + // 4. Apply filter. if (item->filter && filter) { - // TODO: creating the Cairo context here only to pass it to the filter renderer, - // which calls cairo_get_target almost immediately, is rather silly. - // See whether creating the context can be avoided. - // Could also be fixed in Cairo by fixing cairo_get_target() to return - // the intermediate surface when a group is pushed. - cairo_pattern_t *obj = cairo_get_source(ict); - cairo_surface_t *objs; - cairo_pattern_get_surface(obj, &objs); - cairo_t *tct = cairo_create(objs); - cairo_translate(tct, -carea.x0, -carea.y0); NRRectL bgarea(item->arena->canvasarena->cache_area); - item->filter->render(item, ct, &bgarea, tct, &carea); - cairo_destroy(tct); + item->filter->render(item, ct, &bgarea, ict, &carea); + // Note that because the object was rendered to a group, + // the internals of the filter need to use cairo_get_group_target() + // instead of cairo_get_target(). } // 5. Render object inside the composited mask + clip + cairo_pop_group_to_source(ict); cairo_set_operator(ict, CAIRO_OPERATOR_IN); - if (needs_opacity && !item->clip) { - cairo_paint_with_alpha(ict, opacity); - } else { - cairo_paint(ict); - } + cairo_paint(ict); // 6. Paint the completed rendering onto the base context cairo_set_source_surface(ct, intermediate, carea.x0, carea.y0); cairo_paint(ct); cairo_set_source_rgba(ct, 0,0,0,0); + // the call above is to clear a ref on the intermediate surface held by ct retstate = item->state | NR_ARENA_ITEM_STATE_RENDER; @@ -551,14 +534,16 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) unsigned retstate = 0; - // The item itself has a clipping path - // Render the clipping path onto a temporary surface, then composite it with the item + // The item used as the clipping path itself has a clipping path. + // Render this item's clipping path onto a temporary surface, then composite it with the item // using the IN operator if (item->clip) { cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); - // The source could have had opacity set, but push_group implicitly saves state + cairo_save(ct); cairo_set_source_rgba(ct, 0,0,0,1); nr_arena_item_invoke_clip(ct, item->clip, area); + cairo_restore(ct); + cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); } if (item->visible && nr_rect_l_test_intersect_ptr(area, &item->bbox)) { @@ -573,7 +558,9 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) cairo_pop_group_to_source(ct); cairo_set_operator(ct, CAIRO_OPERATOR_IN); cairo_paint(ct); + cairo_pop_group_to_source(ct); cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); } return retstate; diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index ce07ff086..3464fda66 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -156,7 +156,7 @@ cairo_surface_t *FilterSlot::_get_transformed_background() { Geom::Affine trans = _units.get_matrix_display2pb(); - cairo_surface_t *bg = cairo_get_target(_background_ct); + cairo_surface_t *bg = cairo_get_group_target(_background_ct); cairo_surface_t *tbg = cairo_surface_create_similar( bg, cairo_surface_get_content(bg), _slot_w, _slot_h); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 10b4084ed..963d98654 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -160,7 +160,7 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea } } - FilterSlot slot(const_cast(item), bgct, bgarea, cairo_get_target(graphic), area, units); + FilterSlot slot(const_cast(item), bgct, bgarea, cairo_get_group_target(graphic), area, units); slot.set_quality(filterquality); slot.set_blurquality(blurquality); -- cgit v1.2.3 From 476773dea7a4bf2136beba4b31f44a0dca16fa40 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 11 Jul 2011 09:19:35 +0100 Subject: Drop some unused gdl files that cause build failure on Windows (bzr r10440) --- src/libgdl/gdl-dock-layout.c | 1437 ---------------------------------------- src/libgdl/gdl-dock-layout.h | 98 --- src/libgdl/gdl.h | 1 - src/libgdl/test-combo-button.c | 111 ---- src/libgdl/test-dock.c | 314 --------- 5 files changed, 1961 deletions(-) delete mode 100644 src/libgdl/gdl-dock-layout.c delete mode 100644 src/libgdl/gdl-dock-layout.h delete mode 100644 src/libgdl/test-combo-button.c delete mode 100644 src/libgdl/test-dock.c (limited to 'src') diff --git a/src/libgdl/gdl-dock-layout.c b/src/libgdl/gdl-dock-layout.c deleted file mode 100644 index 7c5279507..000000000 --- a/src/libgdl/gdl-dock-layout.c +++ /dev/null @@ -1,1437 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "gdl-i18n.h" -#include -#include -#include -#include - -#include "gdl-dock-layout.h" -#include "gdl-tools.h" -#include "gdl-dock-placeholder.h" - - -/* ----- Private variables ----- */ - -enum { - PROP_0, - PROP_MASTER, - PROP_DIRTY -}; - -#define ROOT_ELEMENT "dock-layout" -#define DEFAULT_LAYOUT "__default__" -#define LAYOUT_ELEMENT_NAME "layout" -#define NAME_ATTRIBUTE_NAME "name" - -#define LAYOUT_UI_FILE "layout.ui" - -enum { - COLUMN_NAME, - COLUMN_SHOW, - COLUMN_LOCKED, - COLUMN_ITEM -}; - -#define COLUMN_EDITABLE COLUMN_SHOW - -struct _GdlDockLayoutPrivate { - xmlDocPtr doc; - - /* layout list models */ - GtkListStore *items_model; - GtkListStore *layouts_model; - - /* idle control */ - gboolean idle_save_pending; -}; - -typedef struct _GdlDockLayoutUIData GdlDockLayoutUIData; - -struct _GdlDockLayoutUIData { - GdlDockLayout *layout; - GtkWidget *locked_check; - GtkTreeSelection *selection; -}; - - -/* ----- Private prototypes ----- */ - -static void gdl_dock_layout_class_init (GdlDockLayoutClass *klass); - -static void gdl_dock_layout_instance_init (GdlDockLayout *layout); - -static void gdl_dock_layout_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void gdl_dock_layout_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_dock_layout_dispose (GObject *object); - -static void gdl_dock_layout_build_doc (GdlDockLayout *layout); - -static xmlNodePtr gdl_dock_layout_find_layout (GdlDockLayout *layout, - const gchar *name); - -static void gdl_dock_layout_build_models (GdlDockLayout *layout); - - -/* ----- Private implementation ----- */ - -GDL_CLASS_BOILERPLATE (GdlDockLayout, gdl_dock_layout, GObject, G_TYPE_OBJECT); - -static void -gdl_dock_layout_class_init (GdlDockLayoutClass *klass) -{ - GObjectClass *g_object_class = (GObjectClass *) klass; - - g_object_class->set_property = gdl_dock_layout_set_property; - g_object_class->get_property = gdl_dock_layout_get_property; - g_object_class->dispose = gdl_dock_layout_dispose; - - g_object_class_install_property ( - g_object_class, PROP_MASTER, - g_param_spec_object ("master", _("Master"), - _("GdlDockMaster object which the layout object " - "is attached to"), - GDL_TYPE_DOCK_MASTER, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_DIRTY, - g_param_spec_boolean ("dirty", _("Dirty"), - _("True if the layouts have changed and need to be " - "saved to a file"), - FALSE, - G_PARAM_READABLE)); -} - -static void -gdl_dock_layout_instance_init (GdlDockLayout *layout) -{ - layout->master = NULL; - layout->dirty = FALSE; - layout->_priv = g_new0 (GdlDockLayoutPrivate, 1); - layout->_priv->idle_save_pending = FALSE; - - gdl_dock_layout_build_models (layout); -} - -static void -gdl_dock_layout_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockLayout *layout = GDL_DOCK_LAYOUT (object); - - switch (prop_id) { - case PROP_MASTER: - gdl_dock_layout_attach (layout, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - }; -} - -static void -gdl_dock_layout_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockLayout *layout = GDL_DOCK_LAYOUT (object); - - switch (prop_id) { - case PROP_MASTER: - g_value_set_object (value, layout->master); - break; - case PROP_DIRTY: - g_value_set_boolean (value, layout->dirty); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - }; -} - -static void -gdl_dock_layout_dispose (GObject *object) -{ - GdlDockLayout *layout; - - g_return_if_fail (object != NULL); - g_return_if_fail (GDL_IS_DOCK_LAYOUT (object)); - - layout = GDL_DOCK_LAYOUT (object); - - if (layout->master) - gdl_dock_layout_attach (layout, NULL); - - if (layout->_priv) { - if (layout->_priv->idle_save_pending) { - layout->_priv->idle_save_pending = FALSE; - g_idle_remove_by_data (layout); - } - - if (layout->_priv->doc) { - xmlFreeDoc (layout->_priv->doc); - layout->_priv->doc = NULL; - } - - if (layout->_priv->items_model) { - g_object_unref (layout->_priv->items_model); - g_object_unref (layout->_priv->layouts_model); - layout->_priv->items_model = NULL; - layout->_priv->layouts_model = NULL; - } - - xmlFreeDoc(layout->_priv->doc); - g_free (layout->_priv); - layout->_priv = NULL; - } -} - -static void -gdl_dock_layout_build_doc (GdlDockLayout *layout) -{ - g_return_if_fail (layout->_priv->doc == NULL); - - layout->_priv->doc = xmlNewDoc (BAD_CAST "1.0"); - layout->_priv->doc->children = xmlNewDocNode (layout->_priv->doc, NULL, - BAD_CAST ROOT_ELEMENT, NULL); -} - -static xmlNodePtr -gdl_dock_layout_find_layout (GdlDockLayout *layout, - const gchar *name) -{ - xmlNodePtr node; - gboolean found = FALSE; - - g_return_val_if_fail (layout != NULL, NULL); - - if (!layout->_priv->doc) - return NULL; - - /* get document root */ - node = layout->_priv->doc->children; - for (node = node->children; node; node = node->next) { - xmlChar *layout_name; - - if (strcmp ((char*)node->name, LAYOUT_ELEMENT_NAME)) - /* skip non-layout element */ - continue; - - /* we want the first layout */ - if (!name) - break; - - layout_name = xmlGetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME); - if (!strcmp (name, (char*)layout_name)) - found = TRUE; - xmlFree (layout_name); - - if (found) - break; - }; - return node; -} - -static void -gdl_dock_layout_build_models (GdlDockLayout *layout) -{ - if (!layout->_priv->items_model) { - layout->_priv->items_model = gtk_list_store_new (4, - G_TYPE_STRING, - G_TYPE_BOOLEAN, - G_TYPE_BOOLEAN, - G_TYPE_POINTER); - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (layout->_priv->items_model), - COLUMN_NAME, GTK_SORT_ASCENDING); - } - - if (!layout->_priv->layouts_model) { - layout->_priv->layouts_model = gtk_list_store_new (2, G_TYPE_STRING, - G_TYPE_BOOLEAN); - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (layout->_priv->layouts_model), - COLUMN_NAME, GTK_SORT_ASCENDING); - } -} - -static void -build_list (GdlDockObject *object, GList **list) -{ - /* add only items, not toplevels */ - if (GDL_IS_DOCK_ITEM (object)) - *list = g_list_prepend (*list, object); -} - -static void -update_items_model (GdlDockLayout *layout) -{ - GList *items, *l; - GtkTreeIter iter; - GtkListStore *store; - gchar *long_name; - gboolean locked; - - g_return_if_fail (layout != NULL); - g_return_if_fail (layout->_priv->items_model != NULL); - - if (!layout->master) - return; - - /* build items list */ - items = NULL; - gdl_dock_master_foreach (layout->master, (GFunc) build_list, &items); - - /* walk the current model */ - store = layout->_priv->items_model; - - /* update items model data after a layout load */ - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { - gboolean valid = TRUE; - - while (valid) { - GdlDockItem *item; - - gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, - COLUMN_ITEM, &item, - -1); - if (item) { - /* look for the object in the items list */ - for (l = items; l && l->data != item; l = l->next); - - if (l) { - /* found, update data */ - g_object_get (item, - "long-name", &long_name, - "locked", &locked, - NULL); - gtk_list_store_set (store, &iter, - COLUMN_NAME, long_name, - COLUMN_SHOW, GDL_DOCK_OBJECT_ATTACHED (item), - COLUMN_LOCKED, locked, - -1); - g_free (long_name); - - /* remove the item from the linked list and keep on walking the model */ - items = g_list_delete_link (items, l); - valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter); - - } else { - /* not found, which means the item has been removed */ - valid = gtk_list_store_remove (store, &iter); - - } - - } else { - /* not a valid row */ - valid = gtk_list_store_remove (store, &iter); - } - } - } - - /* add any remaining objects */ - for (l = items; l; l = l->next) { - GdlDockObject *object = l->data; - - g_object_get (object, - "long-name", &long_name, - "locked", &locked, - NULL); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COLUMN_ITEM, object, - COLUMN_NAME, long_name, - COLUMN_SHOW, GDL_DOCK_OBJECT_ATTACHED (object), - COLUMN_LOCKED, locked, - -1); - g_free (long_name); - } - - g_list_free (items); -} - -static void -update_layouts_model (GdlDockLayout *layout) -{ - GList *items, *l; - GtkTreeIter iter; - - g_return_if_fail (layout != NULL); - g_return_if_fail (layout->_priv->layouts_model != NULL); - - /* build layouts list */ - gtk_list_store_clear (layout->_priv->layouts_model); - items = gdl_dock_layout_get_layouts (layout, FALSE); - for (l = items; l; l = l->next) { - gtk_list_store_append (layout->_priv->layouts_model, &iter); - gtk_list_store_set (layout->_priv->layouts_model, &iter, - COLUMN_NAME, l->data, COLUMN_EDITABLE, TRUE, - -1); - g_free (l->data); - }; - g_list_free (items); -} - - -/* ------- UI functions & callbacks ------ */ - -static void -load_layout_cb (GtkWidget *w, - gpointer data) -{ - GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; - - GtkTreeModel *model; - GtkTreeIter iter; - GdlDockLayout *layout = ui_data->layout; - gchar *name; - - g_return_if_fail (layout != NULL); - - if (gtk_tree_selection_get_selected (ui_data->selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, - COLUMN_NAME, &name, - -1); - gdl_dock_layout_load_layout (layout, name); - g_free (name); - } -} - -static void -delete_layout_cb (GtkWidget *w, gpointer data) -{ - GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; - - GtkTreeModel *model; - GtkTreeIter iter; - GdlDockLayout *layout = ui_data->layout; - gchar *name; - - g_return_if_fail (layout != NULL); - - if (gtk_tree_selection_get_selected (ui_data->selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, - COLUMN_NAME, &name, - -1); - gdl_dock_layout_delete_layout (layout, name); - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - g_free (name); - }; -} - -static void -show_toggled_cb (GtkCellRendererToggle *renderer, - gchar *path_str, - gpointer data) -{ - GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; - - GdlDockLayout *layout = ui_data->layout; - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreePath *path = gtk_tree_path_new_from_string (path_str); - gboolean value; - GdlDockItem *item; - - g_return_if_fail (layout != NULL); - - model = GTK_TREE_MODEL (layout->_priv->items_model); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, - COLUMN_SHOW, &value, - COLUMN_ITEM, &item, - -1); - - value = !value; - if (value) - gdl_dock_item_show_item (item); - else - gdl_dock_item_hide_item (item); - - gtk_tree_path_free (path); -} - -static void -all_locked_toggled_cb (GtkWidget *widget, - gpointer data) -{ - GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) data; - GdlDockMaster *master; - gboolean locked; - - g_return_if_fail (ui_data->layout != NULL); - master = ui_data->layout->master; - g_return_if_fail (master != NULL); - - locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - g_object_set (master, "locked", locked ? 1 : 0, NULL); -} - -static void -layout_ui_destroyed (GtkWidget *widget, - gpointer user_data) -{ - GdlDockLayoutUIData *ui_data; - - /* widget is the GtkContainer */ - ui_data = g_object_get_data (G_OBJECT (widget), "ui_data"); - if (ui_data) { - if (ui_data->layout) { - if (ui_data->layout->master) - /* disconnet the notify handler */ - g_signal_handlers_disconnect_matched (ui_data->layout->master, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - ui_data); - - g_object_remove_weak_pointer (G_OBJECT (ui_data->layout), - (gpointer *) &ui_data->layout); - ui_data->layout = NULL; - } - g_object_set_data (G_OBJECT (widget), "ui_data", NULL); - g_free (ui_data); - } -} - -static void -master_locked_notify_cb (GdlDockMaster *master, - GParamSpec *pspec, - gpointer user_data) -{ - GdlDockLayoutUIData *ui_data = (GdlDockLayoutUIData *) user_data; - gint locked; - - g_object_get (master, "locked", &locked, NULL); - if (locked == -1) { - gtk_toggle_button_set_inconsistent ( - GTK_TOGGLE_BUTTON (ui_data->locked_check), TRUE); - } - else { - gtk_toggle_button_set_inconsistent ( - GTK_TOGGLE_BUTTON (ui_data->locked_check), FALSE); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (ui_data->locked_check), (locked == 1)); - } -} - -static GtkBuilder * -load_interface () -{ - GtkBuilder *gui; - gchar *gui_file; - GError* error = NULL; - - /* load ui */ - gui_file = g_build_filename (GDL_UIDIR, LAYOUT_UI_FILE, NULL); - gui = gtk_builder_new(); - gtk_builder_add_from_file (gui, gui_file, &error); - g_free (gui_file); - if (error) { - g_warning (_("Could not load layout user interface file '%s'"), - LAYOUT_UI_FILE); - g_object_unref (gui); - g_error_free (error); - return NULL; - }; - return gui; -} - -static GtkWidget * -gdl_dock_layout_construct_items_ui (GdlDockLayout *layout) -{ - GtkBuilder *gui; - GtkWidget *dialog; - GtkWidget *items_list; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - - GdlDockLayoutUIData *ui_data; - - /* load the interface if it wasn't provided */ - gui = load_interface (); - - if (!gui) - return NULL; - - /* get the container */ - dialog = GTK_WIDGET (gtk_builder_get_object (gui, "layout_dialog")); - - ui_data = g_new0 (GdlDockLayoutUIData, 1); - ui_data->layout = layout; - g_object_add_weak_pointer (G_OBJECT (layout), - (gpointer *) &ui_data->layout); - g_object_set_data (G_OBJECT (dialog), "ui_data", ui_data); - - /* get ui widget references */ - ui_data->locked_check = GTK_WIDGET (gtk_builder_get_object (gui, "locked_check")); - items_list = GTK_WIDGET (gtk_builder_get_object(gui, "items_list")); - - /* locked check connections */ - g_signal_connect (ui_data->locked_check, "toggled", - (GCallback) all_locked_toggled_cb, ui_data); - if (layout->master) { - g_signal_connect (layout->master, "notify::locked", - (GCallback) master_locked_notify_cb, ui_data); - /* force update now */ - master_locked_notify_cb (layout->master, NULL, ui_data); - } - - /* set models */ - gtk_tree_view_set_model (GTK_TREE_VIEW (items_list), - GTK_TREE_MODEL (layout->_priv->items_model)); - - /* construct list views */ - renderer = gtk_cell_renderer_toggle_new (); - g_signal_connect (renderer, "toggled", - G_CALLBACK (show_toggled_cb), ui_data); - column = gtk_tree_view_column_new_with_attributes (_("Visible"), - renderer, - "active", COLUMN_SHOW, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column); - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Item"), - renderer, - "text", COLUMN_NAME, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column); - - /* connect signals */ - g_signal_connect (dialog, "destroy", (GCallback) layout_ui_destroyed, NULL); - - g_object_unref (gui); - - return dialog; -} - -static void -cell_edited_cb (GtkCellRendererText *cell, - const gchar *path_string, - const gchar *new_text, - gpointer data) -{ - GdlDockLayoutUIData *ui_data = data; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gchar *name; - xmlNodePtr node; - - model = GTK_TREE_MODEL (ui_data->layout->_priv->layouts_model); - path = gtk_tree_path_new_from_string (path_string); - - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, COLUMN_NAME, &name, -1); - - node = gdl_dock_layout_find_layout (ui_data->layout, name); - g_free (name); - g_return_if_fail (node != NULL); - - xmlSetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME, BAD_CAST new_text); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NAME, new_text, - COLUMN_EDITABLE, TRUE, -1); - - gdl_dock_layout_save_layout (ui_data->layout, new_text); - - gtk_tree_path_free (path); -} - -static GtkWidget * -gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout) -{ - GtkBuilder *gui; - GtkWidget *container; - GtkWidget *layouts_list; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkWidget *load_button; - GtkWidget *delete_button; - - GdlDockLayoutUIData *ui_data; - - /* load the interface if it wasn't provided */ - gui = load_interface (); - - if (!gui) - return NULL; - - /* get the container */ - container = GTK_WIDGET (gtk_builder_get_object(gui, "layouts_vbox")); - - ui_data = g_new0 (GdlDockLayoutUIData, 1); - ui_data->layout = layout; - g_object_add_weak_pointer (G_OBJECT (layout), - (gpointer *) &ui_data->layout); - g_object_set_data (G_OBJECT (container), "ui-data", ui_data); - - /* get ui widget references */ - layouts_list = GTK_WIDGET (gtk_builder_get_object(gui, "layouts_list")); - - /* set models */ - gtk_tree_view_set_model (GTK_TREE_VIEW (layouts_list), - GTK_TREE_MODEL (layout->_priv->layouts_model)); - - /* construct list views */ - renderer = gtk_cell_renderer_text_new (); - g_signal_connect (G_OBJECT (renderer), "edited", - G_CALLBACK (cell_edited_cb), ui_data); - column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, - "text", COLUMN_NAME, - "editable", COLUMN_EDITABLE, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (layouts_list), column); - - ui_data->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (layouts_list)); - - /* connect signals */ - load_button = GTK_WIDGET (gtk_builder_get_object(gui, "load_button")); - delete_button = GTK_WIDGET (gtk_builder_get_object(gui, "delete_button")); - - g_signal_connect (load_button, "clicked", (GCallback) load_layout_cb, ui_data); - g_signal_connect (delete_button, "clicked", (GCallback) delete_layout_cb, ui_data); - - - g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL); - - g_object_unref (gui); - - return container; -} - -/* ----- Save & Load layout functions --------- */ - -#define GDL_DOCK_PARAM_CONSTRUCTION(p) \ - (((p)->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) != 0) - -static GdlDockObject * -gdl_dock_layout_setup_object (GdlDockMaster *master, - xmlNodePtr node, - gint *n_after_params, - GParameter **after_params) -{ - GdlDockObject *object = NULL; - GType object_type; - xmlChar *object_name; - GObjectClass *object_class = NULL; - - GParamSpec **props; - guint n_props, i; - GParameter *params = NULL; - gint n_params = 0; - GValue serialized = { 0, }; - - object_name = xmlGetProp (node, BAD_CAST GDL_DOCK_NAME_PROPERTY); - if (object_name && strlen ((char*)object_name) > 0) { - /* the object must already be bound to the master */ - object = gdl_dock_master_get_object (master, (char*)object_name); - - xmlFree (object_name); - object_type = object ? G_TYPE_FROM_INSTANCE (object) : G_TYPE_NONE; - } - else { - /* the object should be automatic, so create it by - retrieving the object type from the dock registry */ - object_type = gdl_dock_object_type_from_nick ((char*)node->name); - if (object_type == G_TYPE_NONE) { - g_warning (_("While loading layout: don't know how to create " - "a dock object whose nick is '%s'"), node->name); - } - } - - if (object_type == G_TYPE_NONE || !G_TYPE_IS_CLASSED (object_type)) - return NULL; - - object_class = g_type_class_ref (object_type); - props = g_object_class_list_properties (object_class, &n_props); - - /* create parameter slots */ - /* extra parameter is the master */ - params = g_new0 (GParameter, n_props + 1); - *after_params = g_new0 (GParameter, n_props); - *n_after_params = 0; - - /* initialize value used for transformations */ - g_value_init (&serialized, GDL_TYPE_DOCK_PARAM); - - for (i = 0; i < n_props; i++) { - xmlChar *xml_prop; - - /* process all exported properties, skip - GDL_DOCK_NAME_PROPERTY, since named items should - already by in the master */ - if (!(props [i]->flags & GDL_DOCK_PARAM_EXPORT) || - !strcmp (props [i]->name, GDL_DOCK_NAME_PROPERTY)) - continue; - - /* get the property from xml if there is one */ - xml_prop = xmlGetProp (node, BAD_CAST props [i]->name); - if (xml_prop) { - g_value_set_static_string (&serialized, (char*)xml_prop); - - if (!GDL_DOCK_PARAM_CONSTRUCTION (props [i]) && - (props [i]->flags & GDL_DOCK_PARAM_AFTER)) { - (*after_params) [*n_after_params].name = props [i]->name; - g_value_init (&((* after_params) [*n_after_params].value), - props [i]->value_type); - g_value_transform (&serialized, - &((* after_params) [*n_after_params].value)); - (*n_after_params)++; - } - else if (!object || (!GDL_DOCK_PARAM_CONSTRUCTION (props [i]) && object)) { - params [n_params].name = props [i]->name; - g_value_init (&(params [n_params].value), props [i]->value_type); - g_value_transform (&serialized, &(params [n_params].value)); - n_params++; - } - xmlFree (xml_prop); - } - } - g_value_unset (&serialized); - g_free (props); - - if (!object) { - params [n_params].name = GDL_DOCK_MASTER_PROPERTY; - g_value_init (¶ms [n_params].value, GDL_TYPE_DOCK_MASTER); - g_value_set_object (¶ms [n_params].value, master); - n_params++; - - /* construct the object if we have to */ - /* set the master, so toplevels are created correctly and - other objects are bound */ - object = g_object_newv (object_type, n_params, params); - } - else { - /* set the parameters to the existing object */ - for (i = 0; i < n_params; i++) - g_object_set_property (G_OBJECT (object), - params [i].name, - ¶ms [i].value); - } - - /* free the parameters (names are static/const strings) */ - for (i = 0; i < n_params; i++) - g_value_unset (¶ms [i].value); - g_free (params); - - /* finally unref object class */ - g_type_class_unref (object_class); - - return object; -} - -static void -gdl_dock_layout_recursive_build (GdlDockMaster *master, - xmlNodePtr parent_node, - GdlDockObject *parent) -{ - GdlDockObject *object; - xmlNodePtr node; - - g_return_if_fail (master != NULL && parent_node != NULL); - - /* if parent is NULL we should build toplevels */ - for (node = parent_node->children; node; node = node->next) { - GParameter *after_params = NULL; - gint n_after_params = 0, i; - - object = gdl_dock_layout_setup_object (master, node, - &n_after_params, - &after_params); - - if (object) { - gdl_dock_object_freeze (object); - - /* recurse here to catch placeholders */ - gdl_dock_layout_recursive_build (master, node, object); - - if (GDL_IS_DOCK_PLACEHOLDER (object)) - /* placeholders are later attached to the parent */ - gdl_dock_object_detach (object, FALSE); - - /* apply "after" parameters */ - for (i = 0; i < n_after_params; i++) { - g_object_set_property (G_OBJECT (object), - after_params [i].name, - &after_params [i].value); - /* unset and free the value */ - g_value_unset (&after_params [i].value); - } - g_free (after_params); - - /* add the object to the parent */ - if (parent) { - if (GDL_IS_DOCK_PLACEHOLDER (object)) - gdl_dock_placeholder_attach (GDL_DOCK_PLACEHOLDER (object), - parent); - else if (gdl_dock_object_is_compound (parent)) { - gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (object)); - if (GTK_WIDGET_VISIBLE (parent)) - gtk_widget_show (GTK_WIDGET (object)); - } - } - else { - GdlDockObject *controller = gdl_dock_master_get_controller (master); - if (controller != object && GTK_WIDGET_VISIBLE (controller)) - gtk_widget_show (GTK_WIDGET (object)); - } - - /* call reduce just in case any child is missing */ - if (gdl_dock_object_is_compound (object)) - gdl_dock_object_reduce (object); - - gdl_dock_object_thaw (object); - } - } -} - -static void -_gdl_dock_layout_foreach_detach (GdlDockObject *object) -{ - gdl_dock_object_detach (object, TRUE); -} - -static void -gdl_dock_layout_foreach_toplevel_detach (GdlDockObject *object) -{ - gtk_container_foreach (GTK_CONTAINER (object), - (GtkCallback) _gdl_dock_layout_foreach_detach, - NULL); -} - -static void -gdl_dock_layout_load (GdlDockMaster *master, xmlNodePtr node) -{ - g_return_if_fail (master != NULL && node != NULL); - - /* start by detaching all items from the toplevels */ - gdl_dock_master_foreach_toplevel (master, TRUE, - (GFunc) gdl_dock_layout_foreach_toplevel_detach, - NULL); - - gdl_dock_layout_recursive_build (master, node, NULL); -} - -static void -gdl_dock_layout_foreach_object_save (GdlDockObject *object, - gpointer user_data) -{ - struct { - xmlNodePtr where; - GHashTable *placeholders; - } *info = user_data, info_child; - - xmlNodePtr node; - guint n_props, i; - GParamSpec **props; - GValue attr = { 0, }; - - g_return_if_fail (object != NULL && GDL_IS_DOCK_OBJECT (object)); - g_return_if_fail (info->where != NULL); - - node = xmlNewChild (info->where, - NULL, /* ns */ - BAD_CAST gdl_dock_object_nick_from_type (G_TYPE_FROM_INSTANCE (object)), - BAD_CAST NULL); /* contents */ - - /* get object exported attributes */ - props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), - &n_props); - g_value_init (&attr, GDL_TYPE_DOCK_PARAM); - for (i = 0; i < n_props; i++) { - GParamSpec *p = props [i]; - - if (p->flags & GDL_DOCK_PARAM_EXPORT) { - GValue v = { 0, }; - - /* export this parameter */ - /* get the parameter value */ - g_value_init (&v, p->value_type); - g_object_get_property (G_OBJECT (object), - p->name, - &v); - - /* only save the object "name" if it is set - (i.e. don't save the empty string) */ - if (strcmp (p->name, GDL_DOCK_NAME_PROPERTY) || - g_value_get_string (&v)) { - if (g_value_transform (&v, &attr)) - xmlSetProp (node, BAD_CAST p->name, BAD_CAST g_value_get_string (&attr)); - } - - /* free the parameter value */ - g_value_unset (&v); - } - } - g_value_unset (&attr); - g_free (props); - - info_child = *info; - info_child.where = node; - - /* save placeholders for the object */ - if (info->placeholders && !GDL_IS_DOCK_PLACEHOLDER (object)) { - GList *lph = g_hash_table_lookup (info->placeholders, object); - for (; lph; lph = lph->next) - gdl_dock_layout_foreach_object_save (GDL_DOCK_OBJECT (lph->data), - (gpointer) &info_child); - } - - /* recurse the object if appropiate */ - if (gdl_dock_object_is_compound (object)) { - gtk_container_foreach (GTK_CONTAINER (object), - (GtkCallback) gdl_dock_layout_foreach_object_save, - (gpointer) &info_child); - } -} - -static void -add_placeholder (GdlDockObject *object, - GHashTable *placeholders) -{ - if (GDL_IS_DOCK_PLACEHOLDER (object)) { - GdlDockObject *host; - GList *l; - - g_object_get (object, "host", &host, NULL); - if (host) { - l = g_hash_table_lookup (placeholders, host); - /* add the current placeholder to the list of placeholders - for that host */ - if (l) - g_hash_table_steal (placeholders, host); - - l = g_list_prepend (l, object); - g_hash_table_insert (placeholders, host, l); - g_object_unref (host); - } - } -} - -static void -gdl_dock_layout_save (GdlDockMaster *master, - xmlNodePtr where) -{ - struct { - xmlNodePtr where; - GHashTable *placeholders; - } info; - - GHashTable *placeholders; - - g_return_if_fail (master != NULL && where != NULL); - - /* build the placeholder's hash: the hash keeps lists of - * placeholders associated to each object, so that we can save the - * placeholders when we are saving the object (since placeholders - * don't show up in the normal widget hierarchy) */ - placeholders = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify) g_list_free); - gdl_dock_master_foreach (master, (GFunc) add_placeholder, placeholders); - - /* save the layout recursively */ - info.where = where; - info.placeholders = placeholders; - - gdl_dock_master_foreach_toplevel (master, TRUE, - (GFunc) gdl_dock_layout_foreach_object_save, - (gpointer) &info); - - g_hash_table_destroy (placeholders); -} - - -/* ----- Public interface ----- */ - -/** - * gdl_dock_layout_new: - * @dock: The dock item. - * Creates a new #GdlDockLayout - * - * Returns: New #GdlDockLayout item. - */ -GdlDockLayout * -gdl_dock_layout_new (GdlDock *dock) -{ - GdlDockMaster *master = NULL; - - /* get the master of the given dock */ - if (dock) - master = GDL_DOCK_OBJECT_GET_MASTER (dock); - - return g_object_new (GDL_TYPE_DOCK_LAYOUT, - "master", master, - NULL); -} - -static gboolean -gdl_dock_layout_idle_save (GdlDockLayout *layout) -{ - /* save default layout */ - gdl_dock_layout_save_layout (layout, NULL); - - layout->_priv->idle_save_pending = FALSE; - - return FALSE; -} - -static void -gdl_dock_layout_layout_changed_cb (GdlDockMaster *master, - GdlDockLayout *layout) -{ - /* update model */ - update_items_model (layout); - - if (!layout->_priv->idle_save_pending) { - g_idle_add ((GSourceFunc) gdl_dock_layout_idle_save, layout); - layout->_priv->idle_save_pending = TRUE; - } -} - - -/** - * gdl_dock_layout_attach: - * @layout: The layout item - * @master: The master item to which the layout will be attached - * - * Attach the @layout to the @master and delete the reference to - * the master that the layout attached previously - */ -void -gdl_dock_layout_attach (GdlDockLayout *layout, - GdlDockMaster *master) -{ - g_return_if_fail (layout != NULL); - g_return_if_fail (master == NULL || GDL_IS_DOCK_MASTER (master)); - - if (layout->master) { - g_signal_handlers_disconnect_matched (layout->master, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, layout); - g_object_unref (layout->master); - } - - gtk_list_store_clear (layout->_priv->items_model); - - layout->master = master; - if (layout->master) { - g_object_ref (layout->master); - g_signal_connect (layout->master, "layout-changed", - (GCallback) gdl_dock_layout_layout_changed_cb, - layout); - } - - update_items_model (layout); -} - -/** -* gdl_dock_layout_load_layout: -* @layout: The dock item. -* @name: The name of the layout to load. -* -* Loads the layout with the given name to the memory. -* This will set #GdlDockLayout:dirty to %TRUE. -* -* See also gdl_dock_layout_load_from_file() -* Returns: %TRUE if layout successfully loaded else %FALSE -*/ -gboolean -gdl_dock_layout_load_layout (GdlDockLayout *layout, - const gchar *name) -{ - xmlNodePtr node; - gchar *layout_name; - - g_return_val_if_fail (layout != NULL, FALSE); - - if (!layout->_priv->doc || !layout->master) - return FALSE; - - if (!name) - layout_name = DEFAULT_LAYOUT; - else - layout_name = (gchar *) name; - - node = gdl_dock_layout_find_layout (layout, layout_name); - if (!node && !name) - /* return the first layout if the default name failed to load */ - node = gdl_dock_layout_find_layout (layout, NULL); - - if (node) { - gdl_dock_layout_load (layout->master, node); - return TRUE; - } else - return FALSE; -} - -/** -* gdl_dock_layout_save_layout: -* @layout: The dock item. -* @name: The name of the layout to save. -* -* Saves the @layout with the given name to the memory. -* This will set #GdlDockLayout:dirty to %TRUE. -* -* See also gdl_dock_layout_save_to_file(). -*/ - -void -gdl_dock_layout_save_layout (GdlDockLayout *layout, - const gchar *name) -{ - xmlNodePtr node; - gchar *layout_name; - - g_return_if_fail (layout != NULL); - g_return_if_fail (layout->master != NULL); - - if (!layout->_priv->doc) - gdl_dock_layout_build_doc (layout); - - if (!name) - layout_name = DEFAULT_LAYOUT; - else - layout_name = (gchar *) name; - - /* delete any previously node with the same name */ - node = gdl_dock_layout_find_layout (layout, layout_name); - if (node) { - xmlUnlinkNode (node); - xmlFreeNode (node); - }; - - /* create the new node */ - node = xmlNewChild (layout->_priv->doc->children, NULL, - BAD_CAST LAYOUT_ELEMENT_NAME, NULL); - xmlSetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME, BAD_CAST layout_name); - - /* save the layout */ - gdl_dock_layout_save (layout->master, node); - layout->dirty = TRUE; - g_object_notify (G_OBJECT (layout), "dirty"); -} - -/** -* gdl_dock_layout_delete_layout: -* @layout: The dock item. -* @name: The name of the layout to delete. -* -* Deletes the layout with the given name from the memory. -* This will set #GdlDockLayout:dirty to %TRUE. -*/ - -void -gdl_dock_layout_delete_layout (GdlDockLayout *layout, - const gchar *name) -{ - xmlNodePtr node; - - g_return_if_fail (layout != NULL); - - /* don't allow the deletion of the default layout */ - if (!name || !strcmp (DEFAULT_LAYOUT, name)) - return; - - node = gdl_dock_layout_find_layout (layout, name); - if (node) { - xmlUnlinkNode (node); - xmlFreeNode (node); - layout->dirty = TRUE; - g_object_notify (G_OBJECT (layout), "dirty"); - } -} - -/** -* gdl_dock_layout_run_manager: -* @layout: The dock item. -* -* Runs the layout manager. -*/ - -void -gdl_dock_layout_run_manager (GdlDockLayout *layout) -{ - GtkWidget *dialog; - GtkWidget *parent = NULL; - - g_return_if_fail (layout != NULL); - - if (!layout->master) - /* not attached to a dock yet */ - return; - - dialog = gdl_dock_layout_construct_items_ui (layout); - - gtk_dialog_run (GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); -} - -/** -* gdl_dock_layout_load_from_file: -* @layout: The layout item. -* @filename: The name of the file to load. -* -* Loads the layout from file with the given @filename. -* This will set #GdlDockLayout:dirty to %FALSE. -* -* Returns: %TRUE if @layout successfully loaded else %FALSE -*/ - -gboolean -gdl_dock_layout_load_from_file (GdlDockLayout *layout, - const gchar *filename) -{ - gboolean retval = FALSE; - - if (layout->_priv->doc) { - xmlFreeDoc (layout->_priv->doc); - layout->_priv->doc = NULL; - layout->dirty = FALSE; - g_object_notify (G_OBJECT (layout), "dirty"); - } - - /* FIXME: cannot open symlinks */ - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) { - layout->_priv->doc = xmlParseFile (filename); - if (layout->_priv->doc) { - xmlNodePtr root = layout->_priv->doc->children; - /* minimum validation: test the root element */ - if (root && !strcmp ((char*)root->name, ROOT_ELEMENT)) { - update_layouts_model (layout); - retval = TRUE; - } else { - xmlFreeDoc (layout->_priv->doc); - layout->_priv->doc = NULL; - } - } - } - - return retval; -} - -/** - * gdl_dock_layout_save_to_file: - * @layout: The layout item. - * @filename: Name of the file we want to save in layout - * - * This function saves the current layout in XML format to - * the file with the given @filename. - * - * Returns: %TRUE if @layout successfuly save to the file, otherwise %FALSE. - */ -gboolean -gdl_dock_layout_save_to_file (GdlDockLayout *layout, - const gchar *filename) -{ - FILE *file_handle; - int bytes; - gboolean retval = FALSE; - - g_return_val_if_fail (layout != NULL, FALSE); - g_return_val_if_fail (filename != NULL, FALSE); - - /* if there is still no xml doc, create an empty one */ - if (!layout->_priv->doc) - gdl_dock_layout_build_doc (layout); - - file_handle = fopen (filename, "w"); - if (file_handle) { - bytes = xmlDocDump (file_handle, layout->_priv->doc); - if (bytes >= 0) { - layout->dirty = FALSE; - g_object_notify (G_OBJECT (layout), "dirty"); - retval = TRUE; - }; - fclose (file_handle); - }; - - return retval; -} - -/** - * gdl_dock_layout_is_dirty: - * @layout: The layout item. - * - * Checks whether the XML tree in memory is different from the file where the layout was saved. - * Returns: %TRUE is the layout in the memory is different from the file, else %FALSE. - */ -gboolean -gdl_dock_layout_is_dirty (GdlDockLayout *layout) -{ - g_return_val_if_fail (layout != NULL, FALSE); - - return layout->dirty; -}; - -GList * -gdl_dock_layout_get_layouts (GdlDockLayout *layout, - gboolean include_default) -{ - GList *retval = NULL; - xmlNodePtr node; - - g_return_val_if_fail (layout != NULL, NULL); - - if (!layout->_priv->doc) - return NULL; - - node = layout->_priv->doc->children; - for (node = node->children; node; node = node->next) { - xmlChar *name; - - if (strcmp ((char*)node->name, LAYOUT_ELEMENT_NAME)) - continue; - - name = xmlGetProp (node, BAD_CAST NAME_ATTRIBUTE_NAME); - if (include_default || strcmp ((char*)name, DEFAULT_LAYOUT)) - retval = g_list_prepend (retval, g_strdup ((char*)name)); - xmlFree (name); - }; - retval = g_list_reverse (retval); - - return retval; -} - -GtkWidget * -gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout) -{ - GtkWidget *ui; - - g_return_val_if_fail (layout != NULL, NULL); - ui = gdl_dock_layout_construct_layouts_ui (layout); - - return ui; -} diff --git a/src/libgdl/gdl-dock-layout.h b/src/libgdl/gdl-dock-layout.h deleted file mode 100644 index 82dce5de8..000000000 --- a/src/libgdl/gdl-dock-layout.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __GDL_DOCK_LAYOUT_H__ -#define __GDL_DOCK_LAYOUT_H__ - -#include -#include "libgdl/gdl-dock-master.h" -#include "libgdl/gdl-dock.h" - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_LAYOUT (gdl_dock_layout_get_type ()) -#define GDL_DOCK_LAYOUT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayout)) -#define GDL_DOCK_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) -#define GDL_IS_DOCK_LAYOUT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDL_TYPE_DOCK_LAYOUT)) -#define GDL_IS_DOCK_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_LAYOUT)) -#define GDL_DOCK_LAYOUT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GDL_TYPE_DOCK_LAYOUT, GdlDockLayoutClass)) - -/* data types & structures */ -typedef struct _GdlDockLayout GdlDockLayout; -typedef struct _GdlDockLayoutClass GdlDockLayoutClass; -typedef struct _GdlDockLayoutPrivate GdlDockLayoutPrivate; - -struct _GdlDockLayout { - GObject g_object; - - gboolean dirty; - GdlDockMaster *master; - - GdlDockLayoutPrivate *_priv; -}; - -struct _GdlDockLayoutClass { - GObjectClass g_object_class; -}; - - -/* public interface */ - -GType gdl_dock_layout_get_type (void); - -GdlDockLayout *gdl_dock_layout_new (GdlDock *dock); - -void gdl_dock_layout_attach (GdlDockLayout *layout, - GdlDockMaster *master); - -gboolean gdl_dock_layout_load_layout (GdlDockLayout *layout, - const gchar *name); - -void gdl_dock_layout_save_layout (GdlDockLayout *layout, - const gchar *name); - -void gdl_dock_layout_delete_layout (GdlDockLayout *layout, - const gchar *name); - -GList *gdl_dock_layout_get_layouts (GdlDockLayout *layout, - gboolean include_default); - -void gdl_dock_layout_run_manager (GdlDockLayout *layout); - -gboolean gdl_dock_layout_load_from_file (GdlDockLayout *layout, - const gchar *filename); - -gboolean gdl_dock_layout_save_to_file (GdlDockLayout *layout, - const gchar *filename); - -gboolean gdl_dock_layout_is_dirty (GdlDockLayout *layout); - -GtkWidget *gdl_dock_layout_get_ui (GdlDockLayout *layout); -GtkWidget *gdl_dock_layout_get_items_ui (GdlDockLayout *layout); -GtkWidget *gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout); - -G_END_DECLS - -#endif - - diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h index 467b2b67e..d136b9295 100644 --- a/src/libgdl/gdl.h +++ b/src/libgdl/gdl.h @@ -28,7 +28,6 @@ #include "libgdl/gdl-dock.h" #include "libgdl/gdl-dock-item.h" #include "libgdl/gdl-dock-item-grip.h" -#include "libgdl/gdl-dock-layout.h" #include "libgdl/gdl-dock-bar.h" #endif diff --git a/src/libgdl/test-combo-button.c b/src/libgdl/test-combo-button.c deleted file mode 100644 index 35ce3fff3..000000000 --- a/src/libgdl/test-combo-button.c +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* test-combo-button.c - * - * Copyright (C) 2003 Jeroen Zwartepoorte - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "gdl-combo-button.h" - -static void -combo_button_activate_default_cb (GdlComboButton *combo, - gpointer data) -{ - g_message ("combo_button_activate_default_cb"); -} - -int -main (int argc, char **argv) -{ - GtkWidget *window, *hbox, *combo, *menu, *menuitem; - GdkPixbuf *icon; - - gtk_init (&argc, &argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (gtk_main_quit), NULL); - gtk_window_set_title (GTK_WINDOW (window), "Combo button test"); - gtk_window_set_resizable (GTK_WINDOW (window), FALSE); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), hbox); - - combo = gtk_button_new_from_stock (GTK_STOCK_OPEN); - gtk_button_set_relief (GTK_BUTTON (combo), GTK_RELIEF_NONE); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - - menu = gtk_menu_new (); - menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - gtk_widget_show_all (menu); - - combo = gdl_combo_button_new (); - gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Run"); - gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu)); - icon = gtk_widget_render_icon (combo, GTK_STOCK_EXECUTE, - GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); - gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - - g_signal_connect (combo, "activate_default", - G_CALLBACK (combo_button_activate_default_cb), NULL); - - combo = gtk_button_new_from_stock (GTK_STOCK_SAVE); - gtk_button_set_relief (GTK_BUTTON (combo), GTK_RELIEF_NONE); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - - menu = gtk_menu_new (); - menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - gtk_widget_show_all (menu); - - combo = gdl_combo_button_new (); - gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Open"); - gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu)); - icon = gtk_widget_render_icon (combo, GTK_STOCK_OPEN, - GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); - gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon); - gtk_widget_set_sensitive (combo, FALSE); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - - g_signal_connect (combo, "activate_default", - G_CALLBACK (combo_button_activate_default_cb), NULL); - - menu = gtk_menu_new (); - combo = gdl_combo_button_new (); - gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Open"); - gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu)); - icon = gtk_widget_render_icon (combo, GTK_STOCK_OPEN, - GTK_ICON_SIZE_LARGE_TOOLBAR, NULL); - gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon); - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - - gtk_widget_show_all (window); - - gtk_main (); - - return 0; -} diff --git a/src/libgdl/test-dock.c b/src/libgdl/test-dock.c deleted file mode 100644 index abaecf703..000000000 --- a/src/libgdl/test-dock.c +++ /dev/null @@ -1,314 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include "gdl-tools.h" - -#include "gdl-dock.h" -#include "gdl-dock-item.h" -#include "gdl-dock-notebook.h" -#include "gdl-dock-layout.h" -#include "gdl-dock-placeholder.h" -#include "gdl-dock-bar.h" -#include "gdl-switcher.h" - -#include - -/* ---- end of debugging code */ - -static void -on_style_button_toggled (GtkRadioButton *button, GdlDock *dock) -{ - gboolean active; - GdlDockMaster *master = GDL_DOCK_OBJECT_GET_MASTER (dock); - GdlSwitcherStyle style = - GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), - "__style_id")); - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - if (active) { - g_object_set (master, "switcher-style", style, NULL); - } -} - -static GtkWidget * -create_style_button (GtkWidget *dock, GtkWidget *box, GtkWidget *group, - GdlSwitcherStyle style, const gchar *style_text) -{ - GdlSwitcherStyle current_style; - GtkWidget *button1; - GdlDockMaster *master = GDL_DOCK_OBJECT_GET_MASTER (dock); - - g_object_get (master, "switcher-style", ¤t_style, NULL); - button1 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (group), - style_text); - gtk_widget_show (button1); - g_object_set_data (G_OBJECT (button1), "__style_id", - GINT_TO_POINTER (style)); - if (current_style == style) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button1), TRUE); - } - g_signal_connect (button1, "toggled", - G_CALLBACK (on_style_button_toggled), - dock); - gtk_box_pack_start (GTK_BOX (box), button1, FALSE, FALSE, 0); - return button1; -} - -static GtkWidget * -create_styles_item (GtkWidget *dock) -{ - GtkWidget *vbox1; - GtkWidget *group; - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox1); - - group = create_style_button (dock, vbox1, NULL, - GDL_SWITCHER_STYLE_ICON, "Only icon"); - group = create_style_button (dock, vbox1, group, - GDL_SWITCHER_STYLE_TEXT, "Only text"); - group = create_style_button (dock, vbox1, group, - GDL_SWITCHER_STYLE_BOTH, - "Both icons and texts"); - group = create_style_button (dock, vbox1, group, - GDL_SWITCHER_STYLE_TOOLBAR, - "Desktop toolbar style"); - group = create_style_button (dock, vbox1, group, - GDL_SWITCHER_STYLE_TABS, - "Notebook tabs"); - group = create_style_button (dock, vbox1, group, - GDL_SWITCHER_STYLE_NONE, - "None of the above"); - return vbox1; -} - -static GtkWidget * -create_item (const gchar *button_title) -{ - GtkWidget *vbox1; - GtkWidget *button1; - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox1); - - button1 = gtk_button_new_with_label (button_title); - gtk_widget_show (button1); - gtk_box_pack_start (GTK_BOX (vbox1), button1, TRUE, TRUE, 0); - - return vbox1; -} - -/* creates a simple widget with a textbox inside */ -static GtkWidget * -create_text_item () -{ - GtkWidget *vbox1; - GtkWidget *scrolledwindow1; - GtkWidget *text; - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox1); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow1); - gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), - GTK_SHADOW_ETCHED_IN); - text = gtk_text_view_new (); - g_object_set (text, "wrap-mode", GTK_WRAP_WORD, NULL); - gtk_widget_show (text); - gtk_container_add (GTK_CONTAINER (scrolledwindow1), text); - - return vbox1; -} - -static void -button_dump_cb (GtkWidget *button, gpointer data) -{ - /* Dump XML tree. */ - gdl_dock_layout_save_to_file (GDL_DOCK_LAYOUT (data), "layout.xml"); - g_spawn_command_line_async ("cat layout.xml", NULL); -} - -static void -run_layout_manager_cb (GtkWidget *w, gpointer data) -{ - GdlDockLayout *layout = GDL_DOCK_LAYOUT (data); - gdl_dock_layout_run_manager (layout); -} - -static void -save_layout_cb (GtkWidget *w, gpointer data) -{ - GdlDockLayout *layout = GDL_DOCK_LAYOUT (data); - GtkWidget *dialog, *hbox, *label, *entry; - gint response; - - dialog = gtk_dialog_new_with_buttons ("New Layout", - NULL, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - NULL); - - hbox = gtk_hbox_new (FALSE, 8); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new ("Name:"); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - - gtk_widget_show_all (hbox); - response = gtk_dialog_run (GTK_DIALOG (dialog)); - - if (response == GTK_RESPONSE_OK) { - const gchar *name = gtk_entry_get_text (GTK_ENTRY (entry)); - gdl_dock_layout_save_layout (layout, name); - } - - gtk_widget_destroy (dialog); -} - -int -main (int argc, char **argv) -{ - GtkWidget *item1, *item2, *item3; - GtkWidget *items [4]; - GtkWidget *win, *table, *button, *box; - int i; - GdlDockLayout *layout; - GtkWidget *dock, *dockbar; - - gtk_init (&argc, &argv); - - /*gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);*/ - - /* window creation */ - win = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (win, "delete_event", - G_CALLBACK (gtk_main_quit), NULL); - gtk_window_set_title (GTK_WINDOW (win), "Docking widget test"); - gtk_window_set_default_size (GTK_WINDOW (win), 400, 400); - - /* table */ - table = gtk_vbox_new (FALSE, 5); - gtk_container_add (GTK_CONTAINER (win), table); - gtk_container_set_border_width (GTK_CONTAINER (table), 10); - - /* create the dock */ - dock = gdl_dock_new (); - - /* ... and the layout manager */ - layout = gdl_dock_layout_new (GDL_DOCK (dock)); - - /* create the dockbar */ - dockbar = gdl_dock_bar_new (GDL_DOCK (dock)); - gdl_dock_bar_set_style(GDL_DOCK_BAR(dockbar), GDL_DOCK_BAR_TEXT); - - box = gtk_hbox_new (FALSE, 5); - gtk_box_pack_start (GTK_BOX (table), box, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (box), dockbar, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (box), dock, TRUE, TRUE, 0); - - /* create the dock items */ - item1 = gdl_dock_item_new ("item1", "Item #1", GDL_DOCK_ITEM_BEH_LOCKED); - gtk_container_add (GTK_CONTAINER (item1), create_text_item ()); - gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (item1), - GDL_DOCK_TOP); - gtk_widget_show (item1); - - item2 = gdl_dock_item_new_with_stock ("item2", "Item #2: Select the switcher style for notebooks", - GTK_STOCK_EXECUTE, - GDL_DOCK_ITEM_BEH_NORMAL); - g_object_set (item2, "resize", FALSE, NULL); - gtk_container_add (GTK_CONTAINER (item2), create_styles_item (dock)); - gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (item2), - GDL_DOCK_RIGHT); - gtk_widget_show (item2); - - item3 = gdl_dock_item_new_with_stock ("item3", "Item #3 has accented characters (áéíóúñ)", - GTK_STOCK_CONVERT, - GDL_DOCK_ITEM_BEH_NORMAL | - GDL_DOCK_ITEM_BEH_CANT_CLOSE); - gtk_container_add (GTK_CONTAINER (item3), create_item ("Button 3")); - gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (item3), - GDL_DOCK_BOTTOM); - gtk_widget_show (item3); - - items [0] = gdl_dock_item_new_with_stock ("Item #4", "Item #4", - GTK_STOCK_JUSTIFY_FILL, - GDL_DOCK_ITEM_BEH_NORMAL | - GDL_DOCK_ITEM_BEH_CANT_ICONIFY); - gtk_container_add (GTK_CONTAINER (items [0]), create_text_item ()); - gtk_widget_show (items [0]); - gdl_dock_add_item (GDL_DOCK (dock), GDL_DOCK_ITEM (items [0]), GDL_DOCK_BOTTOM); - for (i = 1; i < 3; i++) { - gchar name[10]; - - snprintf (name, sizeof (name), "Item #%d", i + 4); - items [i] = gdl_dock_item_new_with_stock (name, name, GTK_STOCK_NEW, - GDL_DOCK_ITEM_BEH_NORMAL); - gtk_container_add (GTK_CONTAINER (items [i]), create_text_item ()); - gtk_widget_show (items [i]); - - gdl_dock_object_dock (GDL_DOCK_OBJECT (items [0]), - GDL_DOCK_OBJECT (items [i]), - GDL_DOCK_CENTER, NULL); - }; - - /* tests: manually dock and move around some of the items */ - gdl_dock_item_dock_to (GDL_DOCK_ITEM (item3), GDL_DOCK_ITEM (item1), - GDL_DOCK_TOP, -1); - - gdl_dock_item_dock_to (GDL_DOCK_ITEM (item2), GDL_DOCK_ITEM (item3), - GDL_DOCK_RIGHT, -1); - - gdl_dock_item_dock_to (GDL_DOCK_ITEM (item2), GDL_DOCK_ITEM (item3), - GDL_DOCK_LEFT, -1); - - gdl_dock_item_dock_to (GDL_DOCK_ITEM (item2), NULL, - GDL_DOCK_FLOATING, -1); - - box = gtk_hbox_new (TRUE, 5); - gtk_box_pack_end (GTK_BOX (table), box, FALSE, FALSE, 0); - - button = gtk_button_new_from_stock (GTK_STOCK_SAVE); - g_signal_connect (button, "clicked", - G_CALLBACK (save_layout_cb), layout); - gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0); - - button = gtk_button_new_with_label ("Layout Manager"); - g_signal_connect (button, "clicked", - G_CALLBACK (run_layout_manager_cb), layout); - gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0); - - button = gtk_button_new_with_label ("Dump XML"); - g_signal_connect (button, "clicked", - G_CALLBACK (button_dump_cb), layout); - gtk_box_pack_end (GTK_BOX (box), button, FALSE, TRUE, 0); - - gtk_widget_show_all (win); - - gdl_dock_placeholder_new ("ph1", GDL_DOCK_OBJECT (dock), GDL_DOCK_TOP, FALSE); - gdl_dock_placeholder_new ("ph2", GDL_DOCK_OBJECT (dock), GDL_DOCK_BOTTOM, FALSE); - gdl_dock_placeholder_new ("ph3", GDL_DOCK_OBJECT (dock), GDL_DOCK_LEFT, FALSE); - gdl_dock_placeholder_new ("ph4", GDL_DOCK_OBJECT (dock), GDL_DOCK_RIGHT, FALSE); - - gtk_main (); - - g_object_unref (layout); - - return 0; -} -- cgit v1.2.3 From 2b83f175e30021735625712d580adf0e3dd7077f Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Mon, 11 Jul 2011 07:49:37 -0700 Subject: Clean up more whiteboard stuff and fix header name in file (bzr r10441) --- src/color-profile-test.h | 2 +- src/ui/dialog/session-player.cpp | 231 --------------------------------------- src/ui/dialog/session-player.h | 134 ----------------------- 3 files changed, 1 insertion(+), 366 deletions(-) delete mode 100644 src/ui/dialog/session-player.cpp delete mode 100644 src/ui/dialog/session-player.h (limited to 'src') diff --git a/src/color-profile-test.h b/src/color-profile-test.h index 4b679e5b7..b3ead5d55 100644 --- a/src/color-profile-test.h +++ b/src/color-profile-test.h @@ -9,7 +9,7 @@ #include "color-profile.h" -#include "color-profile-fns.h" +#include "cms-system.h" class ColorProfileTest : public CxxTest::TestSuite { diff --git a/src/ui/dialog/session-player.cpp b/src/ui/dialog/session-player.cpp deleted file mode 100644 index 040c1419b..000000000 --- a/src/ui/dialog/session-player.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/** @file - * @brief Whiteboard session playback control dialog - implementation - */ -/* Authors: - * David Yip - * Abhishek Sharma - * - * Copyright (c) 2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -#include "inkscape.h" -#include "path-prefix.h" - -#include "desktop.h" -#include "desktop-handles.h" -#include "document.h" - -#include "jabber_whiteboard/node-tracker.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/session-file-player.h" - -#include "ui/dialog/session-player.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace UI { - -namespace Dialog { - -SessionPlaybackDialog* -SessionPlaybackDialog::create() -{ - return new SessionPlaybackDialogImpl(); -} - -SessionPlaybackDialogImpl::SessionPlaybackDialogImpl() - : _delay(100, 1, 5000, 10, 100), _delayentry(_delay) -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); - this->_sfp = this->_sm->session_player(); - this->_openfile.set_text(this->_sfp->filename()); - - this->_construct(); - this->get_vbox()->show_all_children(); -} - -SessionPlaybackDialogImpl::~SessionPlaybackDialogImpl() -{ - -} - -void -SessionPlaybackDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Dialog organization - this->_filemanager.set_label(_("Session file")); - this->_playback.set_label(_("Playback controls")); - this->_currentmsgbox.set_label(_("Message information")); - - this->_filemanager.set_border_width(4); - this->_playback.set_border_width(4); - this->_fm.set_border_width(4); - this->_toolbarbox.set_border_width(4); - - // Active session file display - // fixme: Does this mean the active file for the session, or the file for the active session? - // Please indicate which with a TRANSLATORS comment. - this->_labels[0].set_text(_("Active session file:")); - this->_labels[1].set_text(_("Delay (milliseconds):")); - - this->_openfile.set_editable(false); - - this->_filebox.pack_start(this->_labels[0], true, false, 8); - this->_filebox.pack_end(this->_openfile, true, true, 0); - - // Unload/load buttons - this->_close.set_label(_("Close file")); - this->_open.set_label(_("Open new file")); - this->_setdelay.set_label(_("Set delay")); - - // Attach callbacks - this->_close.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), CLOSE_FILE)); - this->_open.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), OPEN_FILE)); - this->_setdelay.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), RESET_DELAY)); - - // Button box - this->_filebuttons.pack_start(this->_close, true, false, 0); - this->_filebuttons.pack_start(this->_open, true, false, 0); - - // Message information box - this->_currentmsgbuffer = Gtk::TextBuffer::create(); - this->_currentmsgview.set_buffer(this->_currentmsgbuffer); - this->_currentmsgview.set_editable(false); - this->_currentmsgview.set_cursor_visible(false); - this->_currentmsgview.set_wrap_mode(Gtk::WRAP_WORD); - this->_currentmsgscroller.add(this->_currentmsgview); - this->_currentmsgbox.add(this->_currentmsgscroller); - this->_sfp->setMessageOutputWidget(this->_currentmsgbuffer); - - // Delay setting - // parameters: initial lower upper single-incr page-incr - this->_delayentry.set_numeric(true); - - // Playback controls - this->_playbackcontrols.set_show_arrow(false); - - this->_controls[0].set_label("Rewind"); - this->_controls[1].set_label("Go back one"); - this->_controls[2].set_label("Pause"); - this->_controls[3].set_label("Go forward one"); - this->_controls[4].set_label("Play"); - - this->_controls[0].set_tooltip(this->_tooltips, _("Rewind")); - this->_controls[1].set_tooltip(this->_tooltips, _("Go back one change")); - this->_controls[2].set_tooltip(this->_tooltips, _("Pause")); - this->_controls[3].set_tooltip(this->_tooltips, _("Go forward one change")); - this->_controls[4].set_tooltip(this->_tooltips, _("Play")); - - for(int i = 0; i < 5; i++) { - this->_playbackcontrols.append(this->_controls[i], sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), TOOLBAR_BASE + i)); - } - - this->_delaybox.pack_start(this->_labels[1]); - this->_delaybox.pack_start(this->_delayentry); - this->_delaybox.pack_end(this->_setdelay); - - this->_toolbarbox.pack_start(this->_delaybox); - this->_toolbarbox.pack_end(this->_playbackcontrols); - - // Pack widgets into frames - this->_fm.pack_start(this->_filebox); - this->_fm.pack_end(this->_filebuttons); - - this->_filemanager.add(this->_fm); - this->_playback.add(this->_toolbarbox); - - // Pack widgets into main vbox - main->pack_start(this->_filemanager); - main->pack_start(this->_playback); - main->pack_end(this->_currentmsgbox); -} - -void -SessionPlaybackDialogImpl::_respCallback(int resp) -{ - g_log(NULL, G_LOG_LEVEL_DEBUG, "_respCallback: %u", resp); - switch(resp) { - case CLOSE_FILE: - this->_sfp->unload(); - break; - case OPEN_FILE: { - Gtk::FileChooserDialog sessionfiledlg(_("Open session file"), Gtk::FILE_CHOOSER_ACTION_OPEN); - sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - sessionfiledlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - int result = sessionfiledlg.run(); - switch (result) { - case Gtk::RESPONSE_OK: - this->_sm->clearDocument(); - SPDocumentUndo::done(sp_desktop_document(this->_desktop), SP_VERB_NONE, - /* TODO: annotate */ "session-player.cpp:186"); - this->_sm->loadSessionFile(sessionfiledlg.get_filename()); - this->_openfile.set_text(this->_sfp->filename()); - break; - default: - break; - } - break; - } - case RESET_DELAY: - this->_sfp->setDelay(this->_delayentry.get_value_as_int()); - break; - case REWIND: - if (this->_sfp->_playing) { - this->_sfp->stop(); - } - this->_sfp->_curdir = Whiteboard::SessionFilePlayer::BACKWARD; - this->_sfp->start(); - break; - case STEP_REWIND: - this->_sfp->step(Whiteboard::SessionFilePlayer::BACKWARD); - break; - case PAUSE: - this->_sfp->stop(); - break; - case STEP_PLAY: - this->_sfp->step(Whiteboard::SessionFilePlayer::FORWARD); - break; - case PLAY: - if (this->_sfp->_playing) { - this->_sfp->stop(); - } - this->_sfp->_curdir = Whiteboard::SessionFilePlayer::FORWARD; - this->_sfp->start(); - break; - default: - break; - } -} - -} - -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/session-player.h b/src/ui/dialog/session-player.h deleted file mode 100644 index 2d235cd25..000000000 --- a/src/ui/dialog/session-player.h +++ /dev/null @@ -1,134 +0,0 @@ -/** @file - * @brief Whiteboard session playback control dialog - */ -/* Authors: - * David Yip - * - * Copyright (c) 2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __SESSION_PLAYBACK_DIALOG_H__ -#define __SESSION_PLAYBACK_DIALOG_H__ - -#include "verbs.h" -#include "dialog.h" - -#include "gtkmm/toolbutton.h" -#include "gtkmm/toolbar.h" -#include "gtkmm/expander.h" - -#include "ui/widget/icon-widget.h" - -struct SPDesktop; - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; -class SessionFilePlayer; - -} - -namespace UI { - -namespace Dialog { - -class SessionPlaybackDialog : public Dialog { -public: - SessionPlaybackDialog() : Dialog("/dialogs/session_playback", SP_VERB_DIALOG_WHITEBOARD_SESSIONPLAYBACK) - { - - } - - static SessionPlaybackDialog* create(); - - virtual ~SessionPlaybackDialog() - { - - } -private: - SessionPlaybackDialog(SessionPlaybackDialog const& dlg); // no copy - void operator=(SessionPlaybackDialog const& dlg); // no assign -}; - -class SessionPlaybackDialogImpl : public SessionPlaybackDialog { -public: - SessionPlaybackDialogImpl(); - ~SessionPlaybackDialogImpl(); - -private: - // GTK+ widgets - Gtk::HBox _filebox; - Gtk::HBox _filebuttons; - Gtk::HBox _toolbarbox; - Gtk::HBox _delaybox; - - Gtk::Entry _openfile; - - Gtk::Label _labels[2]; - Gtk::ToolButton _controls[5]; - - Gtk::Button _close, _open, _setdelay; - - Gtk::Tooltips _tooltips; - Gtk::Toolbar _playbackcontrols; - Gtk::Adjustment _delay; - Widget::SpinButton _delayentry; - - Gtk::Frame _filemanager; - Gtk::VBox _fm; - - Gtk::Frame _playback; - - Gtk::Expander _currentmsgbox; - Glib::RefPtr _currentmsgbuffer; - Gtk::TextView _currentmsgview; - Gtk::ScrolledWindow _currentmsgscroller; - - // Construction and callback - void _construct(); - void _respCallback(int resp); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; - Whiteboard::SessionFilePlayer* _sfp; - - // button values - static unsigned short const CLOSE_FILE = 0; - static unsigned short const OPEN_FILE = 1; - static unsigned short const RESET_DELAY = 2; - - static unsigned short const TOOLBAR_BASE = 10; - static unsigned short const REWIND = TOOLBAR_BASE + 0; - static unsigned short const STEP_REWIND = TOOLBAR_BASE + 1; - static unsigned short const PAUSE = TOOLBAR_BASE + 2; - static unsigned short const STEP_PLAY = TOOLBAR_BASE + 3; - static unsigned short const PLAY = TOOLBAR_BASE + 4; - - - // noncopyable - SessionPlaybackDialogImpl(SessionPlaybackDialogImpl const& dlg); // no copy - void operator=(SessionPlaybackDialogImpl const& dlg); // no assign -}; - -} - -} - -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 6ffe6f384a2d322451cb21e720effdae7aa904f0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 11 Jul 2011 20:44:59 +0200 Subject: Fix crash caused by my previous commit; as reported by ~suv in bug lp:212768 Fixed bugs: - https://launchpad.net/bugs/212768 (bzr r10443) --- src/sp-item-transform.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 45d965e44..eb4b81a61 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -183,11 +183,11 @@ get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble scale *= direct; } } else { // The stroke should not be scaled, or is zero - if (!transform_stroke) { // Nonscaling strokewidth + if (r0 == 0 || r0 == Geom::infinity() ) { // Strokewidth is zero or infinite + scale *= direct; + } else { // Nonscaling strokewidth scale *= direct_constant_r; unbudge *= Geom::Translate (flip_x * 0.5 * r0 * (1 - ratio_x), flip_y * 0.5 * r0 * (1 - ratio_y)); - } else { // Strokewidth is zero or infinite - scale *= direct; } } @@ -336,11 +336,11 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re scale *= direct; } } else { // The stroke should not be scaled, or is zero (or infinite) - if (!transform_stroke) { + if (r0w == 0 || r0w == Geom::infinity() || r0h == 0 || r0h == Geom::infinity()) { // can't calculate, because apparently strokewidth is zero or infinite + scale *= direct; + } else { scale *= direct_constant_r; unbudge *= Geom::Translate (flip_x * stroke_ratio_w * r0w * (1 - ratio_x), flip_y * stroke_ratio_h * r0h * (1 - ratio_y)); - } else { // can't calculate, because apparently strokewidth is zero or infinite - scale *= direct; } } @@ -350,7 +350,6 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke) { - g_assert(initial_geom_bbox); // Find the new geometric bounding box; Do this by transforming each corner of -- cgit v1.2.3 From d776f783e99f70029d1ec8d6c938468d7e220de0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 12 Jul 2011 03:18:44 +0200 Subject: Compute different bounding boxes in outline mode to fix partial rendering of objects where the clipping path is much larger than the base object or vice versa. Fixes LP #177687. Fixed bugs: - https://launchpad.net/bugs/177687 (bzr r10347.1.11) --- src/display/nr-arena-group.cpp | 7 +-- src/display/nr-arena-item.cpp | 115 ++++++++++++++++++++++------------------- 2 files changed, 65 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 1a67a8404..1d552fbc2 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -13,9 +13,11 @@ */ #include "display/canvas-bpath.h" +#include "display/nr-arena.h" #include "display/nr-arena-group.h" #include "display/nr-filter.h" #include "display/nr-filter-types.h" +#include "display/rendermode.h" #include "style.h" #include "sp-filter.h" #include "sp-filter-reference.h" @@ -164,10 +166,9 @@ static unsigned int nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset) { unsigned int newstate; - NRArenaGroup *group = NR_ARENA_GROUP (item); - unsigned int beststate = NR_ARENA_ITEM_STATE_ALL; + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); for (NRArenaItem *child = group->children; child != NULL; child = child->next) { NRGC cgc(gc); @@ -180,7 +181,7 @@ nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int item->bbox = NR_RECT_L_EMPTY; for (NRArenaItem *child = group->children; child != NULL; child = child->next) { if (child->visible) - nr_rect_l_union (&item->bbox, &item->bbox, &child->drawbox); + nr_rect_l_union (&item->bbox, &item->bbox, outline ? &child->bbox : &child->drawbox); } } diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index f3de7a66a..7e19b9f52 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -215,6 +215,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, { NRGC childgc (gc); bool filter = (item->arena->rendermode == Inkscape::RENDERMODE_NORMAL); + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), @@ -243,7 +244,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, return item->state; /* Test whether to return immediately */ if (area && (item->state & NR_ARENA_ITEM_STATE_BBOX)) { - if (!nr_rect_l_test_intersect_ptr(area, &item->drawbox)) + if (!nr_rect_l_test_intersect_ptr(area, outline ? &item->bbox : &item->drawbox)) return item->state; } @@ -276,8 +277,6 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, } else { memcpy(&item->drawbox, &item->bbox, sizeof(item->bbox)); } - // fixme: to fix the display glitches, in outline mode bbox must be a combination of - // full item bbox and its clip and mask (after we have the API to get these) /* Clipping */ if (item->clip) { @@ -289,8 +288,12 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } - // for clipping, we need geometric bbox - nr_rect_l_intersect (&item->drawbox, &item->drawbox, &item->clip->bbox); + if (outline) { + nr_rect_l_union(&item->bbox, &item->bbox, &item->clip->bbox); + } else { + // for clipping, we need geometric bbox + nr_rect_l_intersect (&item->drawbox, &item->drawbox, &item->clip->bbox); + } } /* Masking */ if (item->mask) { @@ -299,8 +302,12 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; } - // for masking, we need full drawbox of mask - nr_rect_l_intersect (&item->drawbox, &item->drawbox, &item->mask->drawbox); + if (outline) { + nr_rect_l_union(&item->bbox, &item->bbox, &item->mask->bbox); + } else { + // for masking, we need full drawbox of mask + nr_rect_l_intersect (&item->drawbox, &item->drawbox, &item->mask->drawbox); + } } // now that we know drawbox, dirty the corresponding rect on canvas: @@ -350,18 +357,14 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area if (!item->visible) return item->state | NR_ARENA_ITEM_STATE_RENDER; - // carea is the bounding box for intermediate rendering. - // NOTE: carea might be larger than area, because of filter effects. - NRRectL carea; - nr_rect_l_intersect (&carea, area, &item->drawbox); - if (nr_rect_l_test_empty(carea)) - return item->state | NR_ARENA_ITEM_STATE_RENDER; - if (item->filter && filter) { - item->filter->area_enlarge (carea, item); - nr_rect_l_intersect (&carea, &carea, &item->drawbox); - } - if (outline) { + // intersect with bbox rather than drawbox, as we want to render things outside + // of the clipping path as well + NRRectL carea; + nr_rect_l_intersect (&carea, area, &item->bbox); + if (nr_rect_l_test_empty(carea)) + return item->state | NR_ARENA_ITEM_STATE_RENDER; + // No caching in outline mode for now; investigate if it really gives any advantage with cairo. // Also no attempts to clip anything; just render everything: item, clip, mask // First, render the object itself @@ -389,6 +392,17 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area return item->state | NR_ARENA_ITEM_STATE_RENDER; } + + // carea is the bounding box for intermediate rendering. + // NOTE: carea might be larger than area, because of filter effects. + NRRectL carea; + nr_rect_l_intersect (&carea, area, &item->drawbox); + if (nr_rect_l_test_empty(carea)) + return item->state | NR_ARENA_ITEM_STATE_RENDER; + if (item->filter && filter) { + item->filter->area_enlarge (carea, item); + nr_rect_l_intersect (&carea, &carea, &item->drawbox); + } using namespace Inkscape; @@ -515,16 +529,6 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), NR_ARENA_ITEM_STATE_INVALID); - /* we originally short-circuited if the object state included - * NR_ARENA_ITEM_STATE_CLIP (and showed a warning on the console); - * anyone know why we stopped doing so? - */ - /*nr_return_val_if_fail ((pb->area.x1 - pb->area.x0) >= - (area->x1 - area->x0), - NR_ARENA_ITEM_STATE_INVALID); - nr_return_val_if_fail ((pb->area.y1 - pb->area.y0) >= - (area->y1 - area->y0), - NR_ARENA_ITEM_STATE_INVALID);*/ #ifdef NR_ARENA_ITEM_VERBOSE printf ("Invoke clip by %p: %d %d - %d %d, item bbox %d %d - %d %d\n", @@ -533,34 +537,36 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) #endif unsigned retstate = 0; - - // The item used as the clipping path itself has a clipping path. - // Render this item's clipping path onto a temporary surface, then composite it with the item - // using the IN operator - if (item->clip) { - cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); - cairo_save(ct); - cairo_set_source_rgba(ct, 0,0,0,1); - nr_arena_item_invoke_clip(ct, item->clip, area); - cairo_restore(ct); - cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); - } + + // don't bother if the object does not implement clipping (e.g. NRArenaImage) + if (!((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) + return retstate; if (item->visible && nr_rect_l_test_intersect_ptr(area, &item->bbox)) { - /* Need render that item */ - if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) { - retstate = ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> - clip (ct, item, area); + // The item used as the clipping path itself has a clipping path. + // Render this item's clipping path onto a temporary surface, then composite it with the item + // using the IN operator + if (item->clip) { + cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); + cairo_save(ct); + cairo_set_source_rgba(ct, 0,0,0,1); + nr_arena_item_invoke_clip(ct, item->clip, area); + cairo_restore(ct); + cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); + } + + // rasterize the clipping path + retstate = ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> + clip (ct, item, area); + + if (item->clip) { + cairo_pop_group_to_source(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_IN); + cairo_paint(ct); + cairo_pop_group_to_source(ct); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); } - } - - if (item->clip) { - cairo_pop_group_to_source(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_IN); - cairo_paint(ct); - cairo_pop_group_to_source(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); } return retstate; @@ -624,7 +630,8 @@ nr_arena_item_request_render (NRArenaItem *item) nr_return_if_fail (item != NULL); nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_arena_request_render_rect (item->arena, &item->drawbox); + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); + nr_arena_request_render_rect (item->arena, outline ? &item->bbox : &item->drawbox); } /* Public */ -- cgit v1.2.3 From bcab15a0a88931f0cf2374ab0b76877e90f7f76c Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 12 Jul 2011 22:26:46 +0200 Subject: GUI uniformisation (bzr r10446) --- src/ui/dialog/filter-effects-dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index c6d81b070..68cf3b505 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -965,10 +965,10 @@ public: _settings.add_spinslider(0, SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the YZ plane, in degrees")); _settings.type(LIGHT_POINT); - _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); + _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location:"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); _settings.type(LIGHT_SPOT); - _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); + _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location:"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_POINTSATX, SP_ATTR_POINTSATY, SP_ATTR_POINTSATZ, _("Points At"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); -- cgit v1.2.3 From f2c03a756afd46b6ff2b35720442a853649b65c3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jul 2011 22:00:48 +1000 Subject: update cmake for new files (bzr r10447) --- src/libgdl/CMakeLists.txt | 10 +++++----- src/ui/CMakeLists.txt | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt index befb6edb7..3457337e9 100644 --- a/src/libgdl/CMakeLists.txt +++ b/src/libgdl/CMakeLists.txt @@ -1,17 +1,17 @@ set(libgdl_SRC - gdl-dock.c gdl-dock-bar.c - gdl-dock-item.c + gdl-dock-item-button-image.c gdl-dock-item-grip.c + gdl-dock-item.c gdl-dock-master.c gdl-dock-notebook.c gdl-dock-object.c gdl-dock-paned.c gdl-dock-placeholder.c gdl-dock-tablabel.c + gdl-dock.c gdl-i18n.c - gdl-stock.c gdl-switcher.c gdl-tools.h libgdlmarshal.c @@ -21,6 +21,7 @@ set(libgdl_SRC # ------- # Headers gdl-dock-bar.h + gdl-dock-item-button-image.h gdl-dock-item-grip.h gdl-dock-item.h gdl-dock-master.h @@ -32,9 +33,8 @@ set(libgdl_SRC gdl-dock.h gdl-i18n.h gdl-stock-icons.h - gdl-stock.h gdl-switcher.h - libgdl.h + gdl.h libgdlmarshal.h libgdltypebuiltins.h ) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 9bbdd861e..1a662f3be 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -159,7 +159,6 @@ set(ui_SRC dialog/print-colors-preview-dialog.h dialog/print.h dialog/scriptdialog.h - dialog/session-player.h dialog/svg-fonts-dialog.h dialog/swatches.h dialog/tile.h -- cgit v1.2.3 From 9323663d8412d926c6a868b5fc89f2b354cf77bc Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 13 Jul 2011 13:04:36 +0200 Subject: Properly handle CSS font shorthand property. Work done with Abhishek Sharma for GSOC. (bzr r10448) --- src/style.cpp | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 143 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/style.cpp b/src/style.cpp index 699b087dd..303b347c4 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -6,6 +6,7 @@ * Peter Moulder * bulia byak * Abhishek Sharma + * Tavmjong Bah * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@ -911,8 +912,137 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) style->text->font.value = g_strdup(val); style->text->font.set = TRUE; style->text->font.inherit = (val && !strcmp(val, "inherit")); + + // Break string into white space separated tokens + std::stringstream os( val ); + Glib::ustring param; + + while (os >> param) { + + // CSS is case insensitive but we're comparing against lowercase strings + Glib::ustring lparam = param.lowercase(); + + if (lparam == "/") { + + os >> param; + // Eat the line-height for the moment as it is not an SVG property. + // lparam = param.lowercase(); + // sp_style_read_ilengthornormal(&style->line_height, lparam); + + } else { + + // Skip if "normal" as that is the default (and we don't know which attribute it applies to). + if (lparam == "normal") continue; + + // Check each property in turn + + // font-style + SPIEnum test_style; + test_style.set = FALSE; + + // Read once to see if param is valid style. If valid, .set will be TRUE. + sp_style_read_ienum(&test_style, lparam.c_str(), enum_font_style, true); + + // If valid style parameter + if (test_style.set) { + + // If not previously set + if (!style->font_style.set) { + style->font_style.set = TRUE; + style->font_style.inherit = test_style.inherit; + style->font_style.value = test_style.value; + style->font_style.computed = test_style.computed; + } + continue; // Next parameter. + } + + // font-variant (small-caps) + SPIEnum test_variant; + test_variant.set = FALSE; + sp_style_read_ienum(&test_variant, lparam.c_str(), enum_font_variant, true); + + // If valid variant parameter + if (test_variant.set) { + + // If not previously set + if (!style->font_variant.set) { + style->font_variant.set = TRUE; + style->font_variant.inherit = test_variant.inherit; + style->font_variant.value = test_variant.value; + style->font_variant.computed = test_variant.computed; + } + continue; // Next parameter. + } + + // font-weight + SPIEnum test_weight; + test_weight.set = FALSE; + sp_style_read_ienum(&test_weight, lparam.c_str(), enum_font_weight, true); + + // If valid weight parameter + if (test_weight.set) { + + // If not previously set + if (!style->font_weight.set) { + style->font_weight.set = TRUE; + style->font_weight.inherit = test_weight.inherit; + style->font_weight.value = test_weight.value; + style->font_weight.computed = test_weight.computed; + } + continue; // Next parameter + } + + // Font-size + SPIFontSize test_size; + test_size.set = FALSE; + + // Read once to see if param is valid size. + sp_style_read_ifontsize( &test_size, lparam.c_str() ); + + // If valid size parameter + if (test_size.set) { + + // If not previously set + if (!style->font_size.set) { + style->font_size.set = TRUE; + style->font_size.inherit = test_size.inherit; + style->font_size.unit = test_size.unit; + style->font_size.value = test_size.value; + style->font_size.computed = test_size.computed; + style->font_size.type = test_size.type; + style->font_size.literal = test_size.literal; + } + continue; + } + + // No valid property value found. + break; + } + } // params + + // The rest must be font-family... + std::string val_s = val; + std::string family = val_s.substr( val_s.find( param ) ); + + if (!style->text_private) sp_style_privatize_text(style); + if (!style->text->font_family.set) { + gchar *val_unquoted = attribute_unquote( family.c_str() ); + sp_style_read_istring(&style->text->font_family, val_unquoted); + if (val_unquoted) g_free (val_unquoted); + } + + // Set all properties to their default values per CSS 2.1 spec if not already set + SPS_READ_IFONTSIZE_IF_UNSET(&style->font_size, "medium" ); + SPS_READ_IENUM_IF_UNSET(&style->font_style, "normal", enum_font_style, true); + SPS_READ_IENUM_IF_UNSET(&style->font_variant, "normal", enum_font_variant, true); + SPS_READ_IENUM_IF_UNSET(&style->font_weight, "normal", enum_font_weight, true); + // Line height is not an SVG property but Inkscape uses it for multi-line text. + // sp_style_read_ilengthornormal(&style->line_height, "normal"); + } + break; + /* Text */ case SP_PROP_TEXT_INDENT: SPS_READ_ILENGTH_IF_UNSET(&style->text_indent, val); @@ -3109,9 +3239,8 @@ sp_style_read_ilength(SPILength *val, gchar const *str) val->unit = SP_CSS_UNIT_PT; val->computed = value * PX_PER_PT; } else if (!strcmp(e, "pc")) { - /* 1 pica = 12pt; FIXME: add it to SPUnit */ val->unit = SP_CSS_UNIT_PC; - val->computed = value * PX_PER_PT * 12; + val->computed = value * PX_PER_PC; } else if (!strcmp(e, "mm")) { val->unit = SP_CSS_UNIT_MM; val->computed = value * PX_PER_MM; @@ -3335,16 +3464,19 @@ sp_style_read_ifontsize(SPIFontSize *val, gchar const *str) return; } else { SPILength length; + length.set = FALSE; sp_style_read_ilength(&length, str); - val->set = length.set; - val->inherit = length.inherit; - val->unit = length.unit; - val->value = length.value; - val->computed = length.computed; - if( val->unit == SP_CSS_UNIT_PERCENT ) { - val->type = SP_FONT_SIZE_PERCENTAGE; - } else { - val->type = SP_FONT_SIZE_LENGTH; + if( length.set ) { + val->set = TRUE; + val->inherit = length.inherit; + val->unit = length.unit; + val->value = length.value; + val->computed = length.computed; + if( val->unit == SP_CSS_UNIT_PERCENT ) { + val->type = SP_FONT_SIZE_PERCENTAGE; + } else { + val->type = SP_FONT_SIZE_LENGTH; + } } return; } -- cgit v1.2.3 From 7a6b02a54a5516ff17662352903a928f5f5f7afb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Jul 2011 23:09:35 +0200 Subject: Fix crashes during offscreen rendering, part 1 (bzr r10347.1.12) --- src/display/nr-arena-item.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 7e19b9f52..9ca5a7463 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -496,7 +496,15 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // 4. Apply filter. if (item->filter && filter) { - NRRectL bgarea(item->arena->canvasarena->cache_area); + // HACK: SPCanvasArena doesn't exist when this is called for offscreen rendering + // Proper fix: call this function with a drawing context class + // that contains information about the surface's bounds + NRRectL bgarea; + if (flags & NR_ARENA_ITEM_RENDER_NO_CACHE || !item->arena->canvasarena) { + bgarea = carea; + } else { + bgarea = NRRectL(item->arena->canvasarena->cache_area); + } item->filter->render(item, ct, &bgarea, ict, &carea); // Note that because the object was rendered to a group, // the internals of the filter need to use cairo_get_group_target() -- cgit v1.2.3 From 6973283a77d7becd6a5a1bd7396206c6840ca785 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Jul 2011 23:43:55 +0200 Subject: Fix crashes in print preview Fixed bugs: - https://launchpad.net/bugs/806105 (bzr r10450) --- src/display/cairo-utils.cpp | 12 ++++++++++++ src/display/cairo-utils.h | 1 + src/extension/internal/cairo-renderer.cpp | 8 +++++--- src/helper/pixbuf-ops.cpp | 5 +++-- src/ui/cache/svg_preview_cache.cpp | 3 +-- src/ui/dialog/color-item.cpp | 4 ++-- 6 files changed, 24 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 90f65c33e..8b75f09a6 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -345,6 +345,18 @@ ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb) return pbs; } +/** @brief Cleanup function for GdkPixbuf. + * This function should be passed as the GdkPixbufDestroyNotify parameter + * to gdk_pixbuf_new_from_data when creating a GdkPixbuf backed by + * a Cairo surface. + */ +void +ink_cairo_pixbuf_cleanup(guchar *pixels, void *data) +{ + cairo_surface_t *surface = reinterpret_cast(data); + cairo_surface_destroy(surface); +} + /** @brief Create an exact copy of a surface. * Creates a surface that has the same type, content type, dimensions and contents * as the specified surface. */ diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 0c2ac2dd6..1de88785d 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -106,6 +106,7 @@ void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); void convert_pixbuf_normal_to_argb32(GdkPixbuf *); void convert_pixbuf_argb32_to_normal(GdkPixbuf *); cairo_surface_t *ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb); +void ink_cairo_pixbuf_cleanup(guchar *pixels, void *surface); G_GNUC_CONST guint32 argb32_from_pixbuf(guint32 in); G_GNUC_CONST guint32 pixbuf_from_argb32(guint32 in); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 6118a7ae9..1e550f7d1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -475,9 +475,11 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } // The width and height of the bitmap in pixels - unsigned width = (unsigned) floor ((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN)); - unsigned height =(unsigned) floor ((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN)); - + unsigned width = ceil((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN)); + unsigned height = ceil((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN)); + + if (width == 0 || height == 0) return; + // Scale to exactly fit integer bitmap inside bounding box double scale_x = (bbox->max()[Geom::X] - bbox->min()[Geom::X]) / width; double scale_y = (bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) / height; diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index f6796f2ad..9ebbe13c7 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -107,6 +107,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, GSList *items_only) { + if (width == 0 || height == 0) return NULL; GdkPixbuf* pixbuf = NULL; /* Create new arena for offscreen rendering*/ @@ -167,8 +168,8 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(surface), GDK_COLORSPACE_RGB, TRUE, 8, width, height, cairo_image_surface_get_stride(surface), - (GdkPixbufDestroyNotify) cairo_surface_destroy, - NULL); + ink_cairo_pixbuf_cleanup, + surface); convert_pixbuf_argb32_to_normal(pixbuf); } else diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index fd7070bab..edd7c9431 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -79,8 +79,7 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rec GDK_COLORSPACE_RGB, TRUE, 8, psize, psize, cairo_image_surface_get_stride(s), - (GdkPixbufDestroyNotify)cairo_surface_destroy, - NULL); + ink_cairo_pixbuf_cleanup, s); convert_pixbuf_argb32_to_normal(pixbuf); return pixbuf; diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 3463aa496..598827da9 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -225,7 +225,7 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, TRUE, 8, width, height, cairo_image_surface_get_stride(s), - (GdkPixbufDestroyNotify) cairo_surface_destroy, NULL); + ink_cairo_pixbuf_cleanup, s); convert_pixbuf_argb32_to_normal(pixbuf); } else { Glib::RefPtr thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height ); @@ -533,7 +533,7 @@ void ColorItem::_regenPreview(EekPreview * preview) GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, TRUE, 8, w, h, cairo_image_surface_get_stride(s), - (GdkPixbufDestroyNotify) cairo_surface_destroy, NULL); + ink_cairo_pixbuf_cleanup, s); convert_pixbuf_argb32_to_normal(pixbuf); eek_preview_set_pixbuf( preview, pixbuf ); } -- cgit v1.2.3 From 019aaf9cd028184da90bc8d7dd558ce14b4e7862 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 14 Jul 2011 20:55:37 +0200 Subject: Remove useless pixmap_gc variable (bzr r10347.1.14) --- src/display/sp-canvas.cpp | 27 ++++++--------------------- src/display/sp-canvas.h | 5 +---- 2 files changed, 7 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index f6446bdd7..d7f34969f 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1061,7 +1061,7 @@ sp_canvas_init (SPCanvas *canvas) #if ENABLE_LCMS canvas->enable_cms_display_adj = false; - canvas->cms_key = new Glib::ustring(""); + new (&canvas->cms_key) Glib::ustring(""); #endif // ENABLE_LCMS canvas->is_scrolling = false; @@ -1121,6 +1121,8 @@ sp_canvas_destroy (GtkObject *object) shutdown_transients (canvas); + canvas->cms_key.~ustring(); + if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); } @@ -1150,8 +1152,6 @@ sp_canvas_new_aa (void) static void sp_canvas_realize (GtkWidget *widget) { - SPCanvas *canvas = SP_CANVAS (widget); - GdkWindowAttr attributes; attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; @@ -1187,8 +1187,6 @@ sp_canvas_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_widget_set_realized (widget, TRUE); - - canvas->pixmap_gc = gdk_gc_new (SP_CANVAS_WINDOW (canvas)); } /** @@ -1205,9 +1203,6 @@ sp_canvas_unrealize (GtkWidget *widget) shutdown_transients (canvas); - gdk_gc_destroy (canvas->pixmap_gc); - canvas->pixmap_gc = NULL; - if (GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (* GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (widget); } @@ -1626,7 +1621,7 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) if (event->window != SP_CANVAS_WINDOW (canvas)) return FALSE; - if (canvas->pixmap_gc == NULL) // canvas being deleted + if (canvas->root == NULL) // canvas being deleted return FALSE; canvas->state = event->state; @@ -1694,7 +1689,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); if ( fromDisplay ) { - transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ? *(canvas->cms_key) : "" ); + transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ); } else { transf = Inkscape::CMSSystem::getDisplayTransform(); } @@ -1881,16 +1876,6 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) rect.x1 = MIN (rect.x1, canvas->x0/*draw_x1*/ + GTK_WIDGET (canvas)->allocation.width); rect.y1 = MIN (rect.y1, canvas->y0/*draw_y1*/ + GTK_WIDGET (canvas)->allocation.height); -#ifdef DEBUG_REDRAW - // paint the area to redraw yellow - gdk_rgb_gc_set_foreground (canvas->pixmap_gc, 0xFFFF00); - gdk_draw_rectangle (SP_CANVAS_WINDOW (canvas), - canvas->pixmap_gc, - TRUE, - rect.x0 - canvas->x0, rect.y0 - canvas->y0, - rect.x1 - rect.x0, rect.y1 - rect.y0); -#endif - PaintRectSetup setup; setup.canvas = canvas; @@ -2088,7 +2073,7 @@ paint (SPCanvas *canvas) static int do_update (SPCanvas *canvas) { - if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop during interrupted display! + if (!canvas->root) // canvas may have already be destroyed by closing desktop during interrupted display! return TRUE; if (canvas->drawing_disabled) diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 32747e7c5..f284afdf2 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -112,9 +112,6 @@ struct SPCanvas { int close_enough; - /* GC for temporary draw pixmap */ - GdkGC *pixmap_gc; - unsigned int need_update : 1; unsigned int need_redraw : 1; unsigned int need_repick : 1; @@ -143,7 +140,7 @@ struct SPCanvas { #if ENABLE_LCMS bool enable_cms_display_adj; - Glib::ustring* cms_key; + Glib::ustring cms_key; #endif // ENABLE_LCMS bool is_scrolling; -- cgit v1.2.3 From 34551466a0ddaac96965b730f75cabb1e92ec4d3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 14 Jul 2011 20:56:10 +0200 Subject: Make cms_key in SPDesktopWidget a regular ustring rather than a pointer (bzr r10347.1.15) --- src/widgets/desktop-widget.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 075a24f82..970a094a9 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -544,10 +544,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) Glib::ustring id = Inkscape::CMSSystem::getDisplayId( 0, 0 ); bool enabled = false; - if ( dtw->canvas->cms_key ) { - *(dtw->canvas->cms_key) = id; - enabled = !dtw->canvas->cms_key->empty(); - } + dtw->canvas->cms_key = id; + enabled = !dtw->canvas->cms_key.empty(); cms_adjust_set_sensitive( dtw, enabled ); } #endif // ENABLE_LCMS @@ -808,11 +806,9 @@ void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidge gint monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_toplevel(GTK_WIDGET(dtw))->window); Glib::ustring id = Inkscape::CMSSystem::getDisplayId( screenNum, monitor ); bool enabled = false; - if ( dtw->canvas->cms_key ) { - *(dtw->canvas->cms_key) = id; - dtw->requestCanvasUpdate(); - enabled = !dtw->canvas->cms_key->empty(); - } + dtw->canvas->cms_key = id; + dtw->requestCanvasUpdate(); + enabled = !dtw->canvas->cms_key.empty(); cms_adjust_set_sensitive( dtw, enabled ); #endif // ENABLE_LCMS } -- cgit v1.2.3 From 896fc3e9669eb94159e5471f41f95be9f8f90611 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 15 Jul 2011 02:21:05 +0200 Subject: Remove the icon-names.h thing, which was a mistake. The file now contains a no-op macro which is used to mark icon names. This way we can still generate a list of icon names we use using a simple grep, but don't trigger unnecessary rebuilds when a new icon names is added. (bzr r10452) --- src/dialogs/clonetiler.cpp | 14 +- src/dialogs/text-edit.cpp | 16 +- src/dialogs/xml-tree.cpp | 40 +-- src/ui/CMakeLists.txt | 2 +- src/ui/dialog/align-and-distribute.cpp | 72 ++-- src/ui/dialog/fill-and-stroke.cpp | 6 +- src/ui/dialog/layers.cpp | 4 +- src/ui/dialog/livepatheffect-editor.cpp | 6 +- src/ui/icon-names.h | 578 +------------------------------- src/ui/widget/layer-selector.cpp | 4 +- src/verbs.cpp | 238 ++++++------- src/widgets/desktop-widget.cpp | 12 +- src/widgets/gradient-toolbar.cpp | 8 +- src/widgets/paint-selector.cpp | 18 +- src/widgets/select-toolbar.cpp | 16 +- src/widgets/stroke-style.cpp | 36 +- src/widgets/toolbox.cpp | 172 +++++----- 17 files changed, 337 insertions(+), 905 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index f8553f2aa..d84038db8 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1183,7 +1183,7 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0); } else { bool prefs_bbox = prefs->getBool("/tools/bounding_box", false); - SPItem::BBoxType bbox_type = ( prefs_bbox ? + SPItem::BBoxType bbox_type = ( prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX ); Geom::OptRect r = SP_ITEM(obj)->getBounds(SP_ITEM(obj)->i2doc_affine(), bbox_type); @@ -1641,7 +1641,7 @@ static GtkWidget * clonetiler_table_x_y_rand(int values) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_OBJECT_ROWS); + GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); GtkWidget *l = gtk_label_new (""); @@ -1654,7 +1654,7 @@ static GtkWidget * clonetiler_table_x_y_rand(int values) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_OBJECT_COLUMNS); + GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); GtkWidget *l = gtk_label_new (""); @@ -1812,7 +1812,7 @@ void clonetiler_dialog(void) // Symmetry { GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); - + /* TRANSLATORS: For the following 17 symmetry groups, see * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or @@ -1850,14 +1850,14 @@ void clonetiler_dialog(void) // the symmetry group combo box. GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); GtkTreeIter iter; - + for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { SymGroups const &sg = sym_groups[j]; // Add the description of the symgroup to a new row gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, sg.label, + gtk_list_store_set (store, &iter, + 0, sg.label, -1); } diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 16166d97e..ce3165632 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -299,7 +299,7 @@ sp_text_edit_dialog (void) // horizontal { GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL ); + INKSCAPE_ICON("format-text-direction-horizontal") ); GtkWidget *b = group = gtk_radio_button_new (NULL); gtk_widget_set_tooltip_text (b, _("Horizontal text")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); @@ -307,13 +307,13 @@ sp_text_edit_dialog (void) gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); gtk_container_add (GTK_CONTAINER (b), px); gtk_box_pack_start (GTK_BOX (row), b, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT (dlg), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL, b); + g_object_set_data (G_OBJECT (dlg), INKSCAPE_ICON("format-text-direction-horizontal"), b); } // vertical { GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL ); + INKSCAPE_ICON("format-text-direction-vertical") ); GtkWidget *b = gtk_radio_button_new (gtk_radio_button_get_group (GTK_RADIO_BUTTON (group))); gtk_widget_set_tooltip_text (b, _("Vertical text")); gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); @@ -321,12 +321,12 @@ sp_text_edit_dialog (void) gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); gtk_container_add (GTK_CONTAINER (b), px); gtk_box_pack_start (GTK_BOX (row), b, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT (dlg), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL, b); + g_object_set_data (G_OBJECT (dlg), INKSCAPE_ICON("format-text-direction-vertical"), b); } gtk_box_pack_start (GTK_BOX (l_vb), row, FALSE, FALSE, 0); } - + { GtkWidget *row = gtk_hbox_new (FALSE, VB_MARGIN); @@ -604,7 +604,7 @@ sp_get_text_dialog_style () } } - b = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL ); + b = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), INKSCAPE_ICON("format-text-direction-horizontal") ); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) { sp_repr_css_set_property (css, "writing-mode", "lr"); @@ -818,9 +818,9 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b), TRUE); if (query->writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) { - b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL ); + b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), INKSCAPE_ICON("format-text-direction-horizontal") ); } else { - b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL ); + b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), INKSCAPE_ICON("format-text-direction-vertical") ); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b), TRUE); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 1a003c9c7..2f489c4b5 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -284,7 +284,7 @@ void sp_xml_tree_dialog() _("New element node"), NULL, sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_XML_ELEMENT_NEW ), + INKSCAPE_ICON("xml-element-new") ), G_CALLBACK(cmd_new_element_node), NULL); @@ -305,7 +305,7 @@ void sp_xml_tree_dialog() button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), NULL, _("New text node"), NULL, sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_XML_TEXT_NEW ), + INKSCAPE_ICON("xml-text-new") ), G_CALLBACK(cmd_new_text_node), NULL); @@ -326,7 +326,7 @@ void sp_xml_tree_dialog() button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), NULL, _("Duplicate node"), NULL, sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_XML_NODE_DUPLICATE ), + INKSCAPE_ICON("xml-node-duplicate") ), G_CALLBACK(cmd_duplicate_node), NULL); @@ -338,7 +338,7 @@ void sp_xml_tree_dialog() g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + button, (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -348,16 +348,16 @@ void sp_xml_tree_dialog() button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), NULL, Q_("nodeAsInXMLdialogTooltip|Delete node"), NULL, sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_XML_NODE_DELETE ), + INKSCAPE_ICON("xml-node-delete") ), G_CALLBACK(cmd_delete_node), NULL ); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_mutable), - button, + button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + button, (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -370,12 +370,12 @@ void sp_xml_tree_dialog() g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_has_grandparent), - button, + button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + button, (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -386,11 +386,11 @@ void sp_xml_tree_dialog() G_CALLBACK(cmd_indent_node), NULL); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_indentable), - button, + button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_disable, - button, + button, (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -400,11 +400,11 @@ void sp_xml_tree_dialog() G_CALLBACK(cmd_raise_node), NULL); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_not_first_child), - button, + button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + button, (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -414,11 +414,11 @@ void sp_xml_tree_dialog() G_CALLBACK(cmd_lower_node), NULL); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_not_last_child), - button, + button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + button, (GConnectFlags)0); gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); @@ -458,7 +458,7 @@ void sp_xml_tree_dialog() button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), NULL, _("Delete attribute"), NULL, sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON_XML_ATTRIBUTE_DELETE ), + INKSCAPE_ICON("xml-attribute-delete") ), (GCallback) cmd_delete_attr, NULL); g_signal_connect_object(G_OBJECT(attributes), "select_row", @@ -583,24 +583,24 @@ void sp_xml_tree_dialog() g_signal_connect_object(G_OBJECT(tree), "tree_select_row", (GCallback) on_tree_select_row_show_if_element, - attr_container, + attr_container, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_hide, - attr_container, + attr_container, (GConnectFlags)0); gtk_widget_hide(attr_container); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", (GCallback) on_tree_select_row_show_if_text, - text_container, + text_container, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_hide, - text_container, + text_container, (GConnectFlags)0); gtk_widget_hide(text_container); diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 1a662f3be..e697fba99 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -120,7 +120,7 @@ set(ui_SRC previewfillable.h previewholder.h uxmanager.h - + cache/svg_preview_cache.h dialog/aboutbox.h diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index f7cb06263..904432d65 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -271,7 +271,7 @@ BBoxSort::BBoxSort(const BBoxSort &rhs) : //NOTE : this copy ctor is called O(sort) when sorting the vector //this is bad. The vector should be a vector of pointers. //But I'll wait the bohem GC before doing that - item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) + item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) { } @@ -550,7 +550,7 @@ public: None, ZOrder, Clockwise - }; + }; ActionExchangePositions(Glib::ustring const &id, Glib::ustring const &tiptext, @@ -904,107 +904,107 @@ AlignAndDistribute::AlignAndDistribute() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); //Instanciate the align buttons - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-horizontal-right-to-anchor"), _("Align right edges of objects to the left edge of the anchor"), 0, 0); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT, + addAlignButton(INKSCAPE_ICON("align-horizontal-left"), _("Align left edges"), 0, 1); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_CENTER, + addAlignButton(INKSCAPE_ICON("align-horizontal-center"), _("Center on vertical axis"), 0, 2); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT, + addAlignButton(INKSCAPE_ICON("align-horizontal-right"), _("Align right sides"), 0, 3); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-horizontal-left-to-anchor"), _("Align left edges of objects to the right edge of the anchor"), 0, 4); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-vertical-bottom-to-anchor"), _("Align bottom edges of objects to the top edge of the anchor"), 1, 0); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_TOP, + addAlignButton(INKSCAPE_ICON("align-vertical-top"), _("Align top edges"), 1, 1); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_CENTER, + addAlignButton(INKSCAPE_ICON("align-vertical-center"), _("Center on horizontal axis"), 1, 2); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM, + addAlignButton(INKSCAPE_ICON("align-vertical-bottom"), _("Align bottom edges"), 1, 3); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_TOP_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-vertical-top-to-anchor"), _("Align top edges of objects to the bottom edge of the anchor"), 1, 4); //Baseline aligns - addBaselineButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("align-horizontal-baseline"), _("Align baseline anchors of texts horizontally"), 0, 5, this->align_table(), Geom::X, false); - addBaselineButton(INKSCAPE_ICON_ALIGN_VERTICAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("align-vertical-baseline"), _("Align baselines of texts"), 1, 5, this->align_table(), Geom::Y, false); //The distribute buttons - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_GAPS, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-gaps"), _("Make horizontal gaps between objects equal"), 0, 4, true, Geom::X, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_LEFT, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-left"), _("Distribute left edges equidistantly"), 0, 1, false, Geom::X, 1., 0.); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_CENTER, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-center"), _("Distribute centers equidistantly horizontally"), 0, 2, false, Geom::X, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_RIGHT, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-right"), _("Distribute right edges equidistantly"), 0, 3, false, Geom::X, 0., 1.); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_GAPS, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-gaps"), _("Make vertical gaps between objects equal"), 1, 4, true, Geom::Y, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_TOP, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-top"), _("Distribute top edges equidistantly"), 1, 1, false, Geom::Y, 0, 1); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_CENTER, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-center"), _("Distribute centers equidistantly vertically"), 1, 2, false, Geom::Y, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BOTTOM, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-bottom"), _("Distribute bottom edges equidistantly"), 1, 3, false, Geom::Y, 1., 0.); //Baseline distribs - addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("distribute-horizontal-baseline"), _("Distribute baseline anchors of texts horizontally"), 0, 5, this->distribute_table(), Geom::X, true); - addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("distribute-vertical-baseline"), _("Distribute baselines of texts vertically"), 1, 5, this->distribute_table(), Geom::Y, true); // Rearrange //Graph Layout - addGraphLayoutButton(INKSCAPE_ICON_DISTRIBUTE_GRAPH, + addGraphLayoutButton(INKSCAPE_ICON("distribute-graph"), _("Nicely arrange selected connector network"), 0, 0); - addExchangePositionsButton(INKSCAPE_ICON_EXCHANGE_POSITIONS, + addExchangePositionsButton(INKSCAPE_ICON("exchange-positions"), _("Exchange positions of selected objects - selection order"), 0, 1); - addExchangePositionsByZOrderButton(INKSCAPE_ICON_EXCHANGE_POSITIONS_ZORDER, + addExchangePositionsByZOrderButton(INKSCAPE_ICON("exchange-positions-zorder"), _("Exchange positions of selected objects - stacking order"), 0, 2); - addExchangePositionsClockwiseButton(INKSCAPE_ICON_EXCHANGE_POSITIONS_CLOCKWISE, + addExchangePositionsClockwiseButton(INKSCAPE_ICON("exchange-positions-clockwise"), _("Exchange positions of selected objects - clockwise rotate"), 0, 3); - + //Randomize & Unclump - addRandomizeButton(INKSCAPE_ICON_DISTRIBUTE_RANDOMIZE, + addRandomizeButton(INKSCAPE_ICON("distribute-randomize"), _("Randomize centers in both dimensions"), 0, 4); - addUnclumpButton(INKSCAPE_ICON_DISTRIBUTE_UNCLUMP, + addUnclumpButton(INKSCAPE_ICON("distribute-unclump"), _("Unclump objects: try to equalize edge-to-edge distances"), 0, 5); //Remove overlaps - addRemoveOverlapsButton(INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS, + addRemoveOverlapsButton(INKSCAPE_ICON("distribute-remove-overlaps"), _("Move objects as little as possible so that their bounding boxes do not overlap"), 0, 0); @@ -1012,16 +1012,16 @@ AlignAndDistribute::AlignAndDistribute() // NOTE: "align nodes vertically" means "move nodes vertically until they align on a common // _horizontal_ line". This is analogous to what the "align-vertical-center" icon means. // There is no doubt some ambiguity. For this reason the descriptions are different. - addNodeButton(INKSCAPE_ICON_ALIGN_VERTICAL_NODES, + addNodeButton(INKSCAPE_ICON("align-vertical-node"), _("Align selected nodes to a common horizontal line"), 0, Geom::X, false); - addNodeButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES, + addNodeButton(INKSCAPE_ICON("align-horizontal-node"), _("Align selected nodes to a common vertical line"), 1, Geom::Y, false); - addNodeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_NODE, + addNodeButton(INKSCAPE_ICON("distribute-horizontal-node"), _("Distribute selected nodes horizontally"), 2, Geom::X, true); - addNodeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_NODE, + addNodeButton(INKSCAPE_ICON("distribute-vertical-node"), _("Distribute selected nodes vertically"), 3, Geom::Y, true); diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 19bcadc00..5d85b2397 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -54,9 +54,9 @@ FillAndStroke::FillAndStroke() contents->pack_start(_notebook, true, true); - _notebook.append_page(_page_fill, _createPageTabLabel(_("_Fill"), INKSCAPE_ICON_OBJECT_FILL)); - _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON_OBJECT_STROKE)); - _notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON_OBJECT_STROKE_STYLE)); + _notebook.append_page(_page_fill, _createPageTabLabel(_("_Fill"), INKSCAPE_ICON("object-fill"))); + _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON("object-stroke"))); + _notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON("object-stroke-style"))); _layoutPageFill(); _layoutPageStrokePaint(); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 8d2d25162..3863dafc5 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -582,7 +582,7 @@ LayersPanel::LayersPanel() : _tree.set_headers_visible(false); Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN) ); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-visible")) ); int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1; eyeRenderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) ); @@ -593,7 +593,7 @@ LayersPanel::LayersPanel() : } Inkscape::UI::Widget::ImageToggler * renderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON_OBJECT_LOCKED, INKSCAPE_ICON_OBJECT_UNLOCKED) ); + INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-locked")) ); int lockedColNum = _tree.append_column("lock", *renderer) - 1; renderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) ); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index bf60fe059..40b7f26ac 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -138,7 +138,7 @@ LivePathEffectEditor::LivePathEffectEditor() //Add the visibility icon column: Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN) ); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-visible")) ); int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1; eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) ); eyeRenderer->property_activatable() = true; @@ -245,7 +245,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) // this was triggered by selecting a row in the list, so skip reloading lpe_list_locked = false; return; - } + } effectlist_store->clear(); current_lpeitem = NULL; @@ -265,7 +265,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); if (lpe) { showParams(*lpe); - lpe_list_locked = true; + lpe_list_locked = true; selectInList(lpe); } else { showText(_("Unknown effect is applied")); diff --git a/src/ui/icon-names.h b/src/ui/icon-names.h index 8935b1def..f83d42174 100644 --- a/src/ui/icon-names.h +++ b/src/ui/icon-names.h @@ -1,10 +1,5 @@ /** @file * @brief Macro for icon names used in Inkscape - * - * This file exists for several reasons: firstly, it contains all the icon names - * in Inkscape, so it can serve as a reference to themers. Secondly, using - * macros instead of strings avoids typos. Thirdly, we can change names - * to conform to external icon sets / specifications without changing any code. */ /* Authors: * Krzysztof KosiÅ„ski @@ -16,574 +11,11 @@ #ifndef SEEN_INKSCAPE_ICON_NAMES_H #define SEEN_INKSCAPE_ICON_NAMES_H -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_BASELINE \ - "align-horizontal-baseline" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_CENTER \ - "align-horizontal-center" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT \ - "align-horizontal-left" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT_TO_ANCHOR \ - "align-horizontal-left-to-anchor" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES \ - "align-horizontal-node" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT \ - "align-horizontal-right" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR \ - "align-horizontal-right-to-anchor" -#define INKSCAPE_ICON_ALIGN_VERTICAL_BASELINE \ - "align-vertical-baseline" -#define INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM \ - "align-vertical-bottom" -#define INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM_TO_ANCHOR \ - "align-vertical-bottom-to-anchor" -#define INKSCAPE_ICON_ALIGN_VERTICAL_CENTER \ - "align-vertical-center" -#define INKSCAPE_ICON_ALIGN_VERTICAL_NODES \ - "align-vertical-node" -#define INKSCAPE_ICON_ALIGN_VERTICAL_TOP \ - "align-vertical-top" -#define INKSCAPE_ICON_ALIGN_VERTICAL_TOP_TO_ANCHOR \ - "align-vertical-top-to-anchor" -#define INKSCAPE_ICON_BITMAP_TRACE \ - "bitmap-trace" -#define INKSCAPE_ICON_COLOR_FILL \ - "color-fill" -#define INKSCAPE_ICON_COLOR_GRADIENT \ - "color-gradient" -#define INKSCAPE_ICON_COLOR_MANAGEMENT \ - "color-management" -#define INKSCAPE_ICON_COLOR_PICKER \ - "color-picker" -#define INKSCAPE_ICON_COLOR_REMOVE \ - "color-remove" -#define INKSCAPE_ICON_CONNECTOR_EDIT \ - "connector-edit" -#define INKSCAPE_ICON_CONNECTOR_AVOID \ - "connector-avoid" -#define INKSCAPE_ICON_CONNECTOR_IGNORE \ - "connector-ignore" -#define INKSCAPE_ICON_CONNECTOR_ORTHOGONAL \ - "connector-orthogonal" -#define INKSCAPE_ICON_CONNECTOR_NEW_CONNPOINT \ - "connector-new-connpoint" -#define INKSCAPE_ICON_CONNECTOR_REMOVE_CONNPOINT \ - "connector-remove-connpoint" -#define INKSCAPE_ICON_DIALOG_ALIGN_AND_DISTRIBUTE \ - "dialog-align-and-distribute" -#define INKSCAPE_ICON_DIALOG_FILL_AND_STROKE \ - "dialog-fill-and-stroke" -#define INKSCAPE_ICON_DIALOG_ICON_PREVIEW \ - "dialog-icon-preview" -#define INKSCAPE_ICON_DIALOG_INPUT_DEVICES \ - "dialog-input-devices" -#define INKSCAPE_ICON_DIALOG_LAYERS \ - "dialog-layers" -#define INKSCAPE_ICON_DIALOG_MEMORY \ - "dialog-memory" -#define INKSCAPE_ICON_DIALOG_MESSAGES \ - "dialog-messages" -#define INKSCAPE_ICON_DIALOG_OBJECT_PROPERTIES \ - "dialog-object-properties" -#define INKSCAPE_ICON_DIALOG_ROWS_AND_COLUMNS \ - "dialog-rows-and-columns" -#define INKSCAPE_ICON_DIALOG_SCRIPTS \ - "dialog-scripts" -#define INKSCAPE_ICON_DIALOG_TEXT_AND_FONT \ - "dialog-text-and-font" -#define INKSCAPE_ICON_DIALOG_TILE_CLONES \ - "dialog-tile-clones" -#define INKSCAPE_ICON_DIALOG_TRANSFORM \ - "dialog-transform" -#define INKSCAPE_ICON_DIALOG_XML_EDITOR \ - "dialog-xml-editor" -#define INKSCAPE_ICON_DISTRIBUTE_GRAPH \ - "distribute-graph" -#define INKSCAPE_ICON_DISTRIBUTE_GRAPH_DIRECTED \ - "distribute-graph-directed" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_BASELINE \ - "distribute-horizontal-baseline" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_CENTER \ - "distribute-horizontal-center" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_GAPS \ - "distribute-horizontal-gaps" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_LEFT \ - "distribute-horizontal-left" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_NODE \ - "distribute-horizontal-node" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_RIGHT \ - "distribute-horizontal-right" -#define INKSCAPE_ICON_DISTRIBUTE_RANDOMIZE \ - "distribute-randomize" -#define INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS \ - "distribute-remove-overlaps" -#define INKSCAPE_ICON_DISTRIBUTE_UNCLUMP \ - "distribute-unclump" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BASELINE \ - "distribute-vertical-baseline" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BOTTOM \ - "distribute-vertical-bottom" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_CENTER \ - "distribute-vertical-center" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_GAPS \ - "distribute-vertical-gaps" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_NODE \ - "distribute-vertical-node" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_TOP \ - "distribute-vertical-top" -#define INKSCAPE_ICON_DOCUMENT_CLEANUP \ - "document-cleanup" -#define INKSCAPE_ICON_DOCUMENT_EXPORT \ - "document-export" -#define INKSCAPE_ICON_DOCUMENT_EXPORT_OCAL \ - "document-export-ocal" -#define INKSCAPE_ICON_DOCUMENT_IMPORT \ - "document-import" -#define INKSCAPE_ICON_DOCUMENT_IMPORT_OCAL \ - "document-import-ocal" -#define INKSCAPE_ICON_DOCUMENT_METADATA \ - "document-metadata" -#define INKSCAPE_ICON_DOCUMENT_OPEN_RECENT \ - "document-open-recent" -#define INKSCAPE_ICON_DRAW_CALLIGRAPHIC \ - "draw-calligraphic" -#define INKSCAPE_ICON_DRAW_CONNECTOR \ - "draw-connector" -#define INKSCAPE_ICON_DRAW_CUBOID \ - "draw-cuboid" -#define INKSCAPE_ICON_DRAW_ELLIPSE \ - "draw-ellipse" -#define INKSCAPE_ICON_DRAW_ELLIPSE_ARC \ - "draw-ellipse-arc" -#define INKSCAPE_ICON_DRAW_ELLIPSE_SEGMENT \ - "draw-ellipse-segment" -#define INKSCAPE_ICON_DRAW_ELLIPSE_WHOLE \ - "draw-ellipse-whole" -#define INKSCAPE_ICON_DRAW_ERASER \ - "draw-eraser" -#define INKSCAPE_ICON_DRAW_ERASER_DELETE_OBJECTS \ - "draw-eraser-delete-objects" -#define INKSCAPE_ICON_DRAW_FREEHAND \ - "draw-freehand" -#define INKSCAPE_ICON_DRAW_PATH \ - "draw-path" -#define INKSCAPE_ICON_DRAW_POLYGON \ - "draw-polygon" -#define INKSCAPE_ICON_DRAW_POLYGON_STAR \ - "draw-polygon-star" -#define INKSCAPE_ICON_DRAW_RECTANGLE \ - "draw-rectangle" -#define INKSCAPE_ICON_DRAW_SPIRAL \ - "draw-spiral" -#define INKSCAPE_ICON_DRAW_STAR \ - "draw-star" -#define INKSCAPE_ICON_DRAW_TEXT \ - "draw-text" -#define INKSCAPE_ICON_DRAW_TRACE_BACKGROUND \ - "draw-trace-background" -#define INKSCAPE_ICON_DRAW_USE_PRESSURE \ - "draw-use-pressure" -#define INKSCAPE_ICON_DRAW_USE_TILT \ - "draw-use-tilt" -#define INKSCAPE_ICON_EDIT_CLONE \ - "edit-clone" -#define INKSCAPE_ICON_EDIT_CLONE_UNLINK \ - "edit-clone-unlink" -#define INKSCAPE_ICON_EDIT_DUPLICATE \ - "edit-duplicate" -#define INKSCAPE_ICON_EDIT_PASTE_IN_PLACE \ - "edit-paste-in-place" -#define INKSCAPE_ICON_EDIT_PASTE_STYLE \ - "edit-paste-style" -#define INKSCAPE_ICON_EDIT_SELECT_ALL \ - "edit-select-all" -#define INKSCAPE_ICON_EDIT_SELECT_ALL_LAYERS \ - "edit-select-all-layers" -#define INKSCAPE_ICON_EDIT_SELECT_INVERT \ - "edit-select-invert" -#define INKSCAPE_ICON_EDIT_SELECT_NONE \ - "edit-select-none" -#define INKSCAPE_ICON_EDIT_SELECT_ORIGINAL \ - "edit-select-original" -#define INKSCAPE_ICON_EDIT_UNDO_HISTORY \ - "edit-undo-history" -#define INKSCAPE_ICON_EXCHANGE_POSITIONS \ - "exchange-positions" -#define INKSCAPE_ICON_EXCHANGE_POSITIONS_ZORDER \ - "exchange-positions-zorder" -#define INKSCAPE_ICON_EXCHANGE_POSITIONS_CLOCKWISE \ - "exchange-positions-clockwise" -#define INKSCAPE_ICON_FILL_RULE_EVEN_ODD \ - "fill-rule-even-odd" -#define INKSCAPE_ICON_FILL_RULE_NONZERO \ - "fill-rule-nonzero" -#define INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL \ - "format-text-direction-horizontal" -#define INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL \ - "format-text-direction-vertical" -#define INKSCAPE_ICON_GRID_AXONOMETRIC \ - "grid-axonometric" -#define INKSCAPE_ICON_GRID_RECTANGULAR \ - "grid-rectangular" -#define INKSCAPE_ICON_GUIDES \ - "guides" -#define INKSCAPE_ICON_HELP_CONTENTS \ - "help-contents" -#define INKSCAPE_ICON_HELP_KEYBOARD_SHORTCUTS \ - "help-keyboard-shortcuts" -#define INKSCAPE_ICON_IMAGE_FILTER_BLEND \ - "image-filter-blend" -#define INKSCAPE_ICON_IMAGE_FILTER_COLOR_MATRIX \ - "image-filter-color-matrix" -#define INKSCAPE_ICON_IMAGE_FILTER_DIFFUSE_LIGHTING \ - "image-filter-diffuse-lighting" -#define INKSCAPE_ICON_IMAGE_FILTER_DISPLACEMENT_MAP \ - "image-filter-displacement-map" -#define INKSCAPE_ICON_IMAGE_FILTER_FLOOD \ - "image-filter-flood" -#define INKSCAPE_ICON_IMAGE_FILTER_GAUSSIAN_BLUR \ - "image-filter-gaussian-blur" -#define INKSCAPE_ICON_IMAGE_FILTER_MORPHOLOGY \ - "image-filter-morphology" -#define INKSCAPE_ICON_IMAGE_FILTER_OFFSET \ - "image-filter-offset" -#define INKSCAPE_ICON_IMAGE_FILTER_TURBULENCE \ - "image-filter-turbulence" -#define INKSCAPE_ICON_INKSCAPE \ - "inkscape-logo" -#define INKSCAPE_ICON_LAYER_BOTTOM \ - "layer-bottom" -#define INKSCAPE_ICON_LAYER_DELETE \ - "layer-delete" -#define INKSCAPE_ICON_LAYER_LOWER \ - "layer-lower" -#define INKSCAPE_ICON_LAYER_NEW \ - "layer-new" -#define INKSCAPE_ICON_LAYER_NEXT \ - "layer-next" -#define INKSCAPE_ICON_LAYER_PREVIOUS \ - "layer-previous" -#define INKSCAPE_ICON_LAYER_RAISE \ - "layer-raise" -#define INKSCAPE_ICON_LAYER_RENAME \ - "layer-rename" -#define INKSCAPE_ICON_LAYER_TOP \ - "layer-top" -#define INKSCAPE_ICON_NODE_ADD \ - "node-add" -#define INKSCAPE_ICON_NODE_BREAK \ - "node-break" -#define INKSCAPE_ICON_NODE_DELETE \ - "node-delete" -#define INKSCAPE_ICON_NODE_DELETE_SEGMENT \ - "node-delete-segment" -#define INKSCAPE_ICON_NODE_DISTRIBUTE_HORIZONTAL \ - "distribute-horizontal-node" -#define INKSCAPE_ICON_NODE_DISTRIBUTE_VERTICAL \ - "distribute-vertical-node" -#define INKSCAPE_ICON_NODE_JOIN \ - "node-join" -#define INKSCAPE_ICON_NODE_JOIN_SEGMENT \ - "node-join-segment" -#define INKSCAPE_ICON_NODE_SEGMENT_CURVE \ - "node-segment-curve" -#define INKSCAPE_ICON_NODE_SEGMENT_LINE \ - "node-segment-line" -#define INKSCAPE_ICON_NODE_TYPE_AUTO_SMOOTH \ - "node-type-auto-smooth" -#define INKSCAPE_ICON_NODE_TYPE_CUSP \ - "node-type-cusp" -#define INKSCAPE_ICON_NODE_TYPE_SMOOTH \ - "node-type-smooth" -#define INKSCAPE_ICON_NODE_TYPE_SYMMETRIC \ - "node-type-symmetric" -#define INKSCAPE_ICON_OBJECT_COLUMNS \ - "object-columns" -#define INKSCAPE_ICON_OBJECT_FILL \ - "object-fill" -#define INKSCAPE_ICON_OBJECT_FLIP_HORIZONTAL \ - "object-flip-horizontal" -#define INKSCAPE_ICON_OBJECT_FLIP_VERTICAL \ - "object-flip-vertical" -#define INKSCAPE_ICON_OBJECT_GROUP \ - "object-group" -#define INKSCAPE_ICON_OBJECT_HIDDEN \ - "object-hidden" -#define INKSCAPE_ICON_OBJECT_LOCKED \ - "object-locked" -#define INKSCAPE_ICON_OBJECT_ROTATE_LEFT \ - "object-rotate-left" -#define INKSCAPE_ICON_OBJECT_ROTATE_RIGHT \ - "object-rotate-right" -#define INKSCAPE_ICON_OBJECT_ROWS \ - "object-rows" -#define INKSCAPE_ICON_OBJECT_STROKE \ - "object-stroke" -#define INKSCAPE_ICON_OBJECT_STROKE_STYLE \ - "object-stroke-style" -#define INKSCAPE_ICON_OBJECT_TO_PATH \ - "object-to-path" -#define INKSCAPE_ICON_OBJECT_TWEAK_ATTRACT \ - "object-tweak-attract" -#define INKSCAPE_ICON_OBJECT_TWEAK_BLUR \ - "object-tweak-blur" -#define INKSCAPE_ICON_OBJECT_TWEAK_DUPLICATE \ - "object-tweak-duplicate" -#define INKSCAPE_ICON_OBJECT_TWEAK_JITTER_COLOR \ - "object-tweak-jitter-color" -#define INKSCAPE_ICON_OBJECT_TWEAK_PAINT \ - "object-tweak-paint" -#define INKSCAPE_ICON_OBJECT_TWEAK_PUSH \ - "object-tweak-push" -#define INKSCAPE_ICON_OBJECT_TWEAK_RANDOMIZE \ - "object-tweak-randomize" -#define INKSCAPE_ICON_OBJECT_TWEAK_ROTATE \ - "object-tweak-rotate" -#define INKSCAPE_ICON_OBJECT_TWEAK_SHRINK \ - "object-tweak-shrink" -#define INKSCAPE_ICON_OBJECT_UNGROUP \ - "object-ungroup" -#define INKSCAPE_ICON_OBJECT_UNLOCKED \ - "object-unlocked" -#define INKSCAPE_ICON_OBJECT_VISIBLE \ - "object-visible" -#define INKSCAPE_ICON_PAINT_GRADIENT_LINEAR \ - "paint-gradient-linear" -#define INKSCAPE_ICON_PAINT_GRADIENT_RADIAL \ - "paint-gradient-radial" -#define INKSCAPE_ICON_PAINT_NONE \ - "paint-none" -#define INKSCAPE_ICON_PAINT_PATTERN \ - "paint-pattern" -#define INKSCAPE_ICON_PAINT_SOLID \ - "paint-solid" -#define INKSCAPE_ICON_PAINT_SWATCH \ - "paint-swatch" -#define INKSCAPE_ICON_PAINT_UNKNOWN \ - "paint-unknown" -#define INKSCAPE_ICON_PATH_BREAK_APART \ - "path-break-apart" -#define INKSCAPE_ICON_PATH_CLIP_EDIT \ - "path-clip-edit" -#define INKSCAPE_ICON_PATH_COMBINE \ - "path-combine" -#define INKSCAPE_ICON_PATH_CUT \ - "path-cut" -#define INKSCAPE_ICON_PATH_DIFFERENCE \ - "path-difference" -#define INKSCAPE_ICON_PATH_DIVISION \ - "path-division" -#define INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT \ - "path-effect-parameter-next" -#define INKSCAPE_ICON_PATH_EXCLUSION \ - "path-exclusion" -#define INKSCAPE_ICON_PATH_INSET \ - "path-inset" -#define INKSCAPE_ICON_PATH_INTERSECTION \ - "path-intersection" -#define INKSCAPE_ICON_PATH_MASK_EDIT \ - "path-mask-edit" -#define INKSCAPE_ICON_PATH_MODE_BEZIER \ - "path-mode-bezier" -#define INKSCAPE_ICON_PATH_MODE_POLYLINE \ - "path-mode-polyline" -#define INKSCAPE_ICON_PATH_MODE_POLYLINE_PARAXIAL \ - "path-mode-polyline-paraxial" -#define INKSCAPE_ICON_PATH_MODE_SPIRO \ - "path-mode-spiro" -#define INKSCAPE_ICON_PATH_OFFSET_DYNAMIC \ - "path-offset-dynamic" -#define INKSCAPE_ICON_PATH_OFFSET_LINKED \ - "path-offset-linked" -#define INKSCAPE_ICON_PATH_OUTSET \ - "path-outset" -#define INKSCAPE_ICON_PATH_REVERSE \ - "path-reverse" -#define INKSCAPE_ICON_PATH_SIMPLIFY \ - "path-simplify" -#define INKSCAPE_ICON_PATH_TWEAK_ATTRACT \ - "path-tweak-attract" -#define INKSCAPE_ICON_PATH_TWEAK_GROW \ - "path-tweak-grow" -#define INKSCAPE_ICON_PATH_TWEAK_PUSH \ - "path-tweak-push" -#define INKSCAPE_ICON_PATH_TWEAK_ROUGHEN \ - "path-tweak-roughen" -#define INKSCAPE_ICON_PATH_TWEAK_SHRINK \ - "path-tweak-shrink" -#define INKSCAPE_ICON_PATH_UNION \ - "path-union" -#define INKSCAPE_ICON_PERSPECTIVE_PARALLEL \ - "perspective-parallel" -#define INKSCAPE_ICON_RECTANGLE_MAKE_CORNERS_SHARP \ - "rectangle-make-corners-sharp" -#define INKSCAPE_ICON_SELECTION_BOTTOM \ - "selection-bottom" -#define INKSCAPE_ICON_SELECTION_LOWER \ - "selection-lower" -#define INKSCAPE_ICON_SELECTION_MAKE_BITMAP_COPY \ - "selection-make-bitmap-copy" -#define INKSCAPE_ICON_SELECTION_MOVE_TO_LAYER_ABOVE \ - "selection-move-to-layer-above" -#define INKSCAPE_ICON_SELECTION_MOVE_TO_LAYER_BELOW \ - "selection-move-to-layer-below" -#define INKSCAPE_ICON_SELECTION_RAISE \ - "selection-raise" -#define INKSCAPE_ICON_SELECTION_TOP \ - "selection-top" -#define INKSCAPE_ICON_SHOW_DIALOGS \ - "show-dialogs" -#define INKSCAPE_ICON_SHOW_GRID \ - "show-grid" -#define INKSCAPE_ICON_SHOW_GUIDES \ - "show-guides" -#define INKSCAPE_ICON_SHOW_NODE_HANDLES \ - "show-node-handles" -#define INKSCAPE_ICON_SHOW_PATH_OUTLINE \ - "show-path-outline" -#define INKSCAPE_ICON_SNAP \ - "snap" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX \ - "snap-bounding-box" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_CENTER \ - "snap-bounding-box-center" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_CORNERS \ - "snap-bounding-box-corners" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_EDGES \ - "snap-bounding-box-edges" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_MIDPOINTS \ - "snap-bounding-box-midpoints" -#define INKSCAPE_ICON_SNAP_GRID_GUIDE_INTERSECTIONS \ - "snap-grid-guide-intersections" -#define INKSCAPE_ICON_SNAP_NODES \ - "snap-nodes" -#define INKSCAPE_ICON_SNAP_NODES_CENTER \ - "snap-nodes-center" -#define INKSCAPE_ICON_SNAP_OTHERS \ - "snap-nodes-others" -#define INKSCAPE_ICON_SNAP_NODES_CUSP \ - "snap-nodes-cusp" -#define INKSCAPE_ICON_SNAP_NODES_INTERSECTION \ - "snap-nodes-intersection" -#define INKSCAPE_ICON_SNAP_NODES_MIDPOINT \ - "snap-nodes-midpoint" -#define INKSCAPE_ICON_SNAP_NODES_PATH \ - "snap-nodes-path" -#define INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER \ - "snap-nodes-rotation-center" -#define INKSCAPE_ICON_SNAP_TEXT_BASELINE \ - "snap-text-baseline" -#define INKSCAPE_ICON_SNAP_NODES_SMOOTH \ - "snap-nodes-smooth" -#define INKSCAPE_ICON_SNAP_PAGE \ - "snap-page" -#define INKSCAPE_ICON_SPRAY_COPY_MODE \ - "spray-copy-mode" -#define INKSCAPE_ICON_SPRAY_CLONE_MODE \ - "spray-clone-mode" -#define INKSCAPE_ICON_SPRAY_UNION_MODE \ - "spray-union-mode" -#define INKSCAPE_ICON_DIALOG_SPRAY_OPTIONS \ - "dialog-spray-options" -#define INKSCAPE_ICON_STROKE_CAP_BUTT \ - "stroke-cap-butt" -#define INKSCAPE_ICON_STROKE_CAP_ROUND \ - "stroke-cap-round" -#define INKSCAPE_ICON_STROKE_CAP_SQUARE \ - "stroke-cap-square" -#define INKSCAPE_ICON_STROKE_JOIN_BEVEL \ - "stroke-join-bevel" -#define INKSCAPE_ICON_STROKE_JOIN_MITER \ - "stroke-join-miter" -#define INKSCAPE_ICON_STROKE_JOIN_ROUND \ - "stroke-join-round" -#define INKSCAPE_ICON_STROKE_TO_PATH \ - "stroke-to-path" -#define INKSCAPE_ICON_TEXT_CONVERT_TO_REGULAR \ - "text-convert-to-regular" -#define INKSCAPE_ICON_TEXT_FLOW_INTO_FRAME \ - "text-flow-into-frame" -#define INKSCAPE_ICON_TEXT_PUT_ON_PATH \ - "text-put-on-path" -#define INKSCAPE_ICON_TEXT_REMOVE_FROM_PATH \ - "text-remove-from-path" -#define INKSCAPE_ICON_TEXT_UNFLOW \ - "text-unflow" -#define INKSCAPE_ICON_TEXT_UNKERN \ - "text-unkern" -#define INKSCAPE_ICON_TOOL_NODE_EDITOR \ - "tool-node-editor" -#define INKSCAPE_ICON_TOOL_POINTER \ - "tool-pointer" -#define INKSCAPE_ICON_TOOL_TWEAK \ - "tool-tweak" -#define INKSCAPE_ICON_TOOL_SPRAY \ - "tool-spray" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_GRADIENT \ - "transform-affect-gradient" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_PATTERN \ - "transform-affect-pattern" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_ROUNDED_CORNERS \ - "transform-affect-rounded-corners" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_STROKE \ - "transform-affect-stroke" -#define INKSCAPE_ICON_TRANSFORM_MOVE_HORIZONTAL \ - "transform-move-horizontal" -#define INKSCAPE_ICON_TRANSFORM_MOVE_VERTICAL \ - "transform-move-vertical" -#define INKSCAPE_ICON_TRANSFORM_ROTATE \ - "transform-rotate" -#define INKSCAPE_ICON_TRANSFORM_SCALE_HORIZONTAL \ - "transform-scale-horizontal" -#define INKSCAPE_ICON_TRANSFORM_SCALE_VERTICAL \ - "transform-scale-vertical" -#define INKSCAPE_ICON_TRANSFORM_SKEW_HORIZONTAL \ - "transform-skew-horizontal" -#define INKSCAPE_ICON_TRANSFORM_SKEW_VERTICAL \ - "transform-skew-vertical" -#define INKSCAPE_ICON_VIEW_FULLSCREEN \ - "view-fullscreen" -#define INKSCAPE_ICON_WINDOW_NEW \ - "window-new" -#define INKSCAPE_ICON_WINDOW_NEXT \ - "window-next" -#define INKSCAPE_ICON_WINDOW_PREVIOUS \ - "window-previous" -#define INKSCAPE_ICON_XML_ATTRIBUTE_DELETE \ - "xml-attribute-delete" -#define INKSCAPE_ICON_XML_ELEMENT_NEW \ - "xml-element-new" -#define INKSCAPE_ICON_XML_NODE_DELETE \ - "xml-node-delete" -#define INKSCAPE_ICON_XML_NODE_DUPLICATE \ - "xml-node-duplicate" -#define INKSCAPE_ICON_XML_TEXT_NEW \ - "xml-text-new" -#define INKSCAPE_ICON_ZOOM \ - "zoom" -#define INKSCAPE_ICON_MEASURE \ - "measure" -#define INKSCAPE_ICON_ZOOM_DOUBLE_SIZE \ - "zoom-double-size" -#define INKSCAPE_ICON_ZOOM_FIT_DRAWING \ - "zoom-fit-drawing" -#define INKSCAPE_ICON_ZOOM_FIT_PAGE \ - "zoom-fit-page" -#define INKSCAPE_ICON_ZOOM_FIT_SELECTION \ - "zoom-fit-selection" -#define INKSCAPE_ICON_ZOOM_FIT_WIDTH \ - "zoom-fit-width" -#define INKSCAPE_ICON_ZOOM_HALF_SIZE \ - "zoom-half-size" -#define INKSCAPE_ICON_ZOOM_IN \ - "zoom-in" -#define INKSCAPE_ICON_ZOOM_NEXT \ - "zoom-next" -#define INKSCAPE_ICON_ZOOM_ORIGINAL \ - "zoom-original" -#define INKSCAPE_ICON_ZOOM_OUT \ - "zoom-out" -#define INKSCAPE_ICON_ZOOM_PREVIOUS \ - "zoom-previous" +/** @brief Icon name annotation. + * Use this macro to mark strings which are used as icon names. + * This greatly simplifies tasks such as obtaining a full list of icons + * used by Inkscape. */ +#define INKSCAPE_ICON(icon) icon #endif /* ifdef SEEN_INKSCAPE_ICON_NAMES_H */ diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index ba4629c82..e254b8599 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -95,7 +95,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) AlternateIcons *label; label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, - INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN)); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-visible"))); _visibility_toggle.add(*label); _visibility_toggle.signal_toggled().connect( sigc::compose( @@ -116,7 +116,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING); label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, - INKSCAPE_ICON_OBJECT_UNLOCKED, INKSCAPE_ICON_OBJECT_LOCKED)); + INKSCAPE_ICON("object-unlocked"), INKSCAPE_ICON("object-unlocked"))); _lock_toggle.add(*label); _lock_toggle.signal_toggled().connect( sigc::compose( diff --git a/src/verbs.cpp b/src/verbs.cpp index bb22711e8..e443e9917 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2257,17 +2257,17 @@ Verb *Verb::_base_verbs[] = { GTK_STOCK_PRINT ), // TRANSLATORS: "Vacuum Defs" means "Clean up defs" (so as to remove unused definitions) new FileVerb(SP_VERB_FILE_VACUUM, "FileVacuum", N_("Vac_uum Defs"), N_("Remove unused definitions (such as gradients or clipping paths) from the <defs> of the document"), - INKSCAPE_ICON_DOCUMENT_CLEANUP ), + INKSCAPE_ICON("document-cleanup") ), new FileVerb(SP_VERB_FILE_IMPORT, "FileImport", N_("_Import..."), - N_("Import a bitmap or SVG image into this document"), INKSCAPE_ICON_DOCUMENT_IMPORT), + N_("Import a bitmap or SVG image into this document"), INKSCAPE_ICON("document-import")), new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."), - N_("Export this document or a selection as a bitmap image"), INKSCAPE_ICON_DOCUMENT_EXPORT), - new FileVerb(SP_VERB_FILE_IMPORT_FROM_OCAL, "FileImportFromOCAL", N_("Import From Open Clip Art Library"), N_("Import a document from Open Clip Art Library"), INKSCAPE_ICON_DOCUMENT_IMPORT_OCAL), -// new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To Open Clip Art Library"), N_("Export this document to Open Clip Art Library"), INKSCAPE_ICON_DOCUMENT_EXPORT_OCAL), + N_("Export this document or a selection as a bitmap image"), INKSCAPE_ICON("document-export")), + new FileVerb(SP_VERB_FILE_IMPORT_FROM_OCAL, "FileImportFromOCAL", N_("Import From Open Clip Art Library"), N_("Import a document from Open Clip Art Library"), INKSCAPE_ICON("document-import-ocal")), +// new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To Open Clip Art Library"), N_("Export this document to Open Clip Art Library"), INKSCAPE_ICON("document-export-ocal")), new FileVerb(SP_VERB_FILE_NEXT_DESKTOP, "NextWindow", N_("N_ext Window"), - N_("Switch to the next document window"), INKSCAPE_ICON_WINDOW_NEXT), + N_("Switch to the next document window"), INKSCAPE_ICON("window-next")), new FileVerb(SP_VERB_FILE_PREV_DESKTOP, "PrevWindow", N_("P_revious Window"), - N_("Switch to the previous document window"), INKSCAPE_ICON_WINDOW_PREVIOUS), + N_("Switch to the previous document window"), INKSCAPE_ICON("window-previous")), new FileVerb(SP_VERB_FILE_CLOSE_VIEW, "FileClose", N_("_Close"), N_("Close this document window"), GTK_STOCK_CLOSE), new FileVerb(SP_VERB_FILE_QUIT, "FileQuit", N_("_Quit"), N_("Quit Inkscape"), GTK_STOCK_QUIT), @@ -2284,7 +2284,7 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_PASTE, "EditPaste", N_("_Paste"), N_("Paste objects from clipboard to mouse point, or paste text"), GTK_STOCK_PASTE), new EditVerb(SP_VERB_EDIT_PASTE_STYLE, "EditPasteStyle", N_("Paste _Style"), - N_("Apply the style of the copied object to selection"), INKSCAPE_ICON_EDIT_PASTE_STYLE), + N_("Apply the style of the copied object to selection"), INKSCAPE_ICON("edit-paste-style")), new EditVerb(SP_VERB_EDIT_PASTE_SIZE, "EditPasteSize", N_("Paste Si_ze"), N_("Scale selection to match the size of the copied object"), NULL), new EditVerb(SP_VERB_EDIT_PASTE_SIZE_X, "EditPasteWidth", N_("Paste _Width"), @@ -2298,7 +2298,7 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y, "EditPasteHeightSeparately", N_("Paste Height Separately"), N_("Scale each selected object vertically to match the height of the copied object"), NULL), new EditVerb(SP_VERB_EDIT_PASTE_IN_PLACE, "EditPasteInPlace", N_("Paste _In Place"), - N_("Paste objects from clipboard to the original location"), INKSCAPE_ICON_EDIT_PASTE_IN_PLACE), + N_("Paste objects from clipboard to the original location"), INKSCAPE_ICON("edit-paste-in-place")), new EditVerb(SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, "PasteLivePathEffect", N_("Paste Path _Effect"), N_("Apply the path effect of the copied object to selection"), NULL), new EditVerb(SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, "RemoveLivePathEffect", N_("Remove Path _Effect"), @@ -2308,15 +2308,15 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_DELETE, "EditDelete", N_("_Delete"), N_("Delete selection"), GTK_STOCK_DELETE), new EditVerb(SP_VERB_EDIT_DUPLICATE, "EditDuplicate", N_("Duplic_ate"), - N_("Duplicate selected objects"), INKSCAPE_ICON_EDIT_DUPLICATE), + N_("Duplicate selected objects"), INKSCAPE_ICON("edit-duplicate")), new EditVerb(SP_VERB_EDIT_CLONE, "EditClone", N_("Create Clo_ne"), - N_("Create a clone (a copy linked to the original) of selected object"), INKSCAPE_ICON_EDIT_CLONE), + N_("Create a clone (a copy linked to the original) of selected object"), INKSCAPE_ICON("edit-clone")), new EditVerb(SP_VERB_EDIT_UNLINK_CLONE, "EditUnlinkClone", N_("Unlin_k Clone"), - N_("Cut the selected clones' links to the originals, turning them into standalone objects"), INKSCAPE_ICON_EDIT_CLONE_UNLINK), + N_("Cut the selected clones' links to the originals, turning them into standalone objects"), INKSCAPE_ICON("edit-clone-unlink")), new EditVerb(SP_VERB_EDIT_RELINK_CLONE, "EditRelinkClone", N_("Relink to Copied"), N_("Relink the selected clones to the object currently on the clipboard"), NULL), new EditVerb(SP_VERB_EDIT_CLONE_SELECT_ORIGINAL, "EditCloneSelectOriginal", N_("Select _Original"), - N_("Select the object to which the selected clone is linked"), INKSCAPE_ICON_EDIT_SELECT_ORIGINAL), + N_("Select the object to which the selected clone is linked"), INKSCAPE_ICON("edit-select-original")), new EditVerb(SP_VERB_EDIT_SELECTION_2_MARKER, "ObjectsToMarker", N_("Objects to _Marker"), N_("Convert selection to a line marker"), NULL), new EditVerb(SP_VERB_EDIT_SELECTION_2_GUIDES, "ObjectsToGuides", N_("Objects to Gu_ides"), @@ -2330,9 +2330,9 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_SELECT_ALL, "EditSelectAll", N_("Select Al_l"), N_("Select all objects or all nodes"), GTK_STOCK_SELECT_ALL), new EditVerb(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, "EditSelectAllInAllLayers", N_("Select All in All La_yers"), - N_("Select all objects in all visible and unlocked layers"), INKSCAPE_ICON_EDIT_SELECT_ALL_LAYERS), + N_("Select all objects in all visible and unlocked layers"), INKSCAPE_ICON("edit-select-all-layers")), new EditVerb(SP_VERB_EDIT_INVERT, "EditInvert", N_("In_vert Selection"), - N_("Invert selection (unselect what is selected and select everything else)"), INKSCAPE_ICON_EDIT_SELECT_INVERT), + N_("Invert selection (unselect what is selected and select everything else)"), INKSCAPE_ICON("edit-select-invert")), new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"), N_("Invert selection in all visible and unlocked layers"), NULL), new EditVerb(SP_VERB_EDIT_SELECT_NEXT, "EditSelectNext", N_("Select Next"), @@ -2340,56 +2340,56 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_SELECT_PREV, "EditSelectPrev", N_("Select Previous"), N_("Select previous object or node"), NULL), new EditVerb(SP_VERB_EDIT_DESELECT, "EditDeselect", N_("D_eselect"), - N_("Deselect any selected objects or nodes"), INKSCAPE_ICON_EDIT_SELECT_NONE), + N_("Deselect any selected objects or nodes"), INKSCAPE_ICON("edit-select-none")), new EditVerb(SP_VERB_EDIT_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("Create _Guides Around the Page"), N_("Create four guides aligned with the page borders"), NULL), new EditVerb(SP_VERB_EDIT_DELETE_ALL_GUIDES, "EditRemoveAllGuides", N_("Delete All Guides"), N_("Create four guides aligned with the page borders"), NULL), new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"), - N_("Show next editable path effect parameter"), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT), + N_("Show next editable path effect parameter"), INKSCAPE_ICON("path-effect-parameter-next")), /* Selection */ new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"), - N_("Raise selection to top"), INKSCAPE_ICON_SELECTION_TOP), + N_("Raise selection to top"), INKSCAPE_ICON("selection-top")), new SelectionVerb(SP_VERB_SELECTION_TO_BACK, "SelectionToBack", N_("Lower to _Bottom"), - N_("Lower selection to bottom"), INKSCAPE_ICON_SELECTION_BOTTOM), + N_("Lower selection to bottom"), INKSCAPE_ICON("selection-bottom")), new SelectionVerb(SP_VERB_SELECTION_RAISE, "SelectionRaise", N_("_Raise"), - N_("Raise selection one step"), INKSCAPE_ICON_SELECTION_RAISE), + N_("Raise selection one step"), INKSCAPE_ICON("selection-raise")), new SelectionVerb(SP_VERB_SELECTION_LOWER, "SelectionLower", N_("_Lower"), - N_("Lower selection one step"), INKSCAPE_ICON_SELECTION_LOWER), + N_("Lower selection one step"), INKSCAPE_ICON("selection-lower")), new SelectionVerb(SP_VERB_SELECTION_GROUP, "SelectionGroup", N_("_Group"), - N_("Group selected objects"), INKSCAPE_ICON_OBJECT_GROUP), + N_("Group selected objects"), INKSCAPE_ICON("object-group")), new SelectionVerb(SP_VERB_SELECTION_UNGROUP, "SelectionUnGroup", N_("_Ungroup"), - N_("Ungroup selected groups"), INKSCAPE_ICON_OBJECT_UNGROUP), + N_("Ungroup selected groups"), INKSCAPE_ICON("object-ungroup")), new SelectionVerb(SP_VERB_SELECTION_TEXTTOPATH, "SelectionTextToPath", N_("_Put on Path"), - N_("Put text on path"), INKSCAPE_ICON_TEXT_PUT_ON_PATH), + N_("Put text on path"), INKSCAPE_ICON("text-put-on-path")), new SelectionVerb(SP_VERB_SELECTION_TEXTFROMPATH, "SelectionTextFromPath", N_("_Remove from Path"), - N_("Remove text from path"), INKSCAPE_ICON_TEXT_REMOVE_FROM_PATH), + N_("Remove text from path"), INKSCAPE_ICON("text-remove-from-path")), new SelectionVerb(SP_VERB_SELECTION_REMOVE_KERNS, "SelectionTextRemoveKerns", N_("Remove Manual _Kerns"), // TRANSLATORS: "glyph": An image used in the visual representation of characters; // roughly speaking, how a character looks. A font is a set of glyphs. - N_("Remove all manual kerns and glyph rotations from a text object"), INKSCAPE_ICON_TEXT_UNKERN), + N_("Remove all manual kerns and glyph rotations from a text object"), INKSCAPE_ICON("text-unkern")), new SelectionVerb(SP_VERB_SELECTION_UNION, "SelectionUnion", N_("_Union"), - N_("Create union of selected paths"), INKSCAPE_ICON_PATH_UNION), + N_("Create union of selected paths"), INKSCAPE_ICON("path-union")), new SelectionVerb(SP_VERB_SELECTION_INTERSECT, "SelectionIntersect", N_("_Intersection"), - N_("Create intersection of selected paths"), INKSCAPE_ICON_PATH_INTERSECTION), + N_("Create intersection of selected paths"), INKSCAPE_ICON("path-intersection")), new SelectionVerb(SP_VERB_SELECTION_DIFF, "SelectionDiff", N_("_Difference"), - N_("Create difference of selected paths (bottom minus top)"), INKSCAPE_ICON_PATH_DIFFERENCE), + N_("Create difference of selected paths (bottom minus top)"), INKSCAPE_ICON("path-difference")), new SelectionVerb(SP_VERB_SELECTION_SYMDIFF, "SelectionSymDiff", N_("E_xclusion"), - N_("Create exclusive OR of selected paths (those parts that belong to only one path)"), INKSCAPE_ICON_PATH_EXCLUSION), + N_("Create exclusive OR of selected paths (those parts that belong to only one path)"), INKSCAPE_ICON("path-exclusion")), new SelectionVerb(SP_VERB_SELECTION_CUT, "SelectionDivide", N_("Di_vision"), - N_("Cut the bottom path into pieces"), INKSCAPE_ICON_PATH_DIVISION), + N_("Cut the bottom path into pieces"), INKSCAPE_ICON("path-division")), // TRANSLATORS: "to cut a path" is not the same as "to break a path apart" - see the // Advanced tutorial for more info new SelectionVerb(SP_VERB_SELECTION_SLICE, "SelectionCutPath", N_("Cut _Path"), - N_("Cut the bottom path's stroke into pieces, removing fill"), INKSCAPE_ICON_PATH_CUT), + N_("Cut the bottom path's stroke into pieces, removing fill"), INKSCAPE_ICON("path-cut")), // TRANSLATORS: "outset": expand a shape by offsetting the object's path, // i.e. by displacing it perpendicular to the path in each point. // See also the Advanced Tutorial for explanation. new SelectionVerb(SP_VERB_SELECTION_OFFSET, "SelectionOffset", N_("Outs_et"), - N_("Outset selected paths"), INKSCAPE_ICON_PATH_OUTSET), + N_("Outset selected paths"), INKSCAPE_ICON("path-outset")), new SelectionVerb(SP_VERB_SELECTION_OFFSET_SCREEN, "SelectionOffsetScreen", N_("O_utset Path by 1 px"), N_("Outset selected paths by 1 px"), NULL), @@ -2400,7 +2400,7 @@ Verb *Verb::_base_verbs[] = { // i.e. by displacing it perpendicular to the path in each point. // See also the Advanced Tutorial for explanation. new SelectionVerb(SP_VERB_SELECTION_INSET, "SelectionInset", N_("I_nset"), - N_("Inset selected paths"), INKSCAPE_ICON_PATH_INSET), + N_("Inset selected paths"), INKSCAPE_ICON("path-inset")), new SelectionVerb(SP_VERB_SELECTION_INSET_SCREEN, "SelectionInsetScreen", N_("I_nset Path by 1 px"), N_("Inset selected paths by 1 px"), NULL), @@ -2408,55 +2408,55 @@ Verb *Verb::_base_verbs[] = { N_("I_nset Path by 10 px"), N_("Inset selected paths by 10 px"), NULL), new SelectionVerb(SP_VERB_SELECTION_DYNAMIC_OFFSET, "SelectionDynOffset", - N_("D_ynamic Offset"), N_("Create a dynamic offset object"), INKSCAPE_ICON_PATH_OFFSET_DYNAMIC), + N_("D_ynamic Offset"), N_("Create a dynamic offset object"), INKSCAPE_ICON("path-offset-dynamic")), new SelectionVerb(SP_VERB_SELECTION_LINKED_OFFSET, "SelectionLinkedOffset", N_("_Linked Offset"), N_("Create a dynamic offset object linked to the original path"), - INKSCAPE_ICON_PATH_OFFSET_LINKED), + INKSCAPE_ICON("path-offset-linked")), new SelectionVerb(SP_VERB_SELECTION_OUTLINE, "StrokeToPath", N_("_Stroke to Path"), - N_("Convert selected object's stroke to paths"), INKSCAPE_ICON_STROKE_TO_PATH), + N_("Convert selected object's stroke to paths"), INKSCAPE_ICON("stroke-to-path")), new SelectionVerb(SP_VERB_SELECTION_SIMPLIFY, "SelectionSimplify", N_("Si_mplify"), - N_("Simplify selected paths (remove extra nodes)"), INKSCAPE_ICON_PATH_SIMPLIFY), + N_("Simplify selected paths (remove extra nodes)"), INKSCAPE_ICON("path-simplify")), new SelectionVerb(SP_VERB_SELECTION_REVERSE, "SelectionReverse", N_("_Reverse"), - N_("Reverse the direction of selected paths (useful for flipping markers)"), INKSCAPE_ICON_PATH_REVERSE), + N_("Reverse the direction of selected paths (useful for flipping markers)"), INKSCAPE_ICON("path-reverse")), // TRANSLATORS: "to trace" means "to convert a bitmap to vector graphics" (to vectorize) new SelectionVerb(SP_VERB_SELECTION_TRACE, "SelectionTrace", N_("_Trace Bitmap..."), - N_("Create one or more paths from a bitmap by tracing it"), INKSCAPE_ICON_BITMAP_TRACE), + N_("Create one or more paths from a bitmap by tracing it"), INKSCAPE_ICON("bitmap-trace")), new SelectionVerb(SP_VERB_SELECTION_CREATE_BITMAP, "SelectionCreateBitmap", N_("_Make a Bitmap Copy"), - N_("Export selection to a bitmap and insert it into document"), INKSCAPE_ICON_SELECTION_MAKE_BITMAP_COPY ), + N_("Export selection to a bitmap and insert it into document"), INKSCAPE_ICON("selection-make-bitmap-copy") ), new SelectionVerb(SP_VERB_SELECTION_COMBINE, "SelectionCombine", N_("_Combine"), - N_("Combine several paths into one"), INKSCAPE_ICON_PATH_COMBINE), + N_("Combine several paths into one"), INKSCAPE_ICON("path-combine")), // TRANSLATORS: "to cut a path" is not the same as "to break a path apart" - see the // Advanced tutorial for more info new SelectionVerb(SP_VERB_SELECTION_BREAK_APART, "SelectionBreakApart", N_("Break _Apart"), - N_("Break selected paths into subpaths"), INKSCAPE_ICON_PATH_BREAK_APART), + N_("Break selected paths into subpaths"), INKSCAPE_ICON("path-break-apart")), new SelectionVerb(SP_VERB_SELECTION_GRIDTILE, "DialogGridArrange", N_("Ro_ws and Columns..."), - N_("Arrange selected objects in a table"), INKSCAPE_ICON_DIALOG_ROWS_AND_COLUMNS), + N_("Arrange selected objects in a table"), INKSCAPE_ICON("dialog-rows-and-columns")), /* Layer */ new LayerVerb(SP_VERB_LAYER_NEW, "LayerNew", N_("_Add Layer..."), - N_("Create a new layer"), INKSCAPE_ICON_LAYER_NEW), + N_("Create a new layer"), INKSCAPE_ICON("layer-new")), new LayerVerb(SP_VERB_LAYER_RENAME, "LayerRename", N_("Re_name Layer..."), - N_("Rename the current layer"), INKSCAPE_ICON_LAYER_RENAME), + N_("Rename the current layer"), INKSCAPE_ICON("layer-rename")), new LayerVerb(SP_VERB_LAYER_NEXT, "LayerNext", N_("Switch to Layer Abov_e"), - N_("Switch to the layer above the current"), INKSCAPE_ICON_LAYER_PREVIOUS), + N_("Switch to the layer above the current"), INKSCAPE_ICON("layer-previous")), new LayerVerb(SP_VERB_LAYER_PREV, "LayerPrev", N_("Switch to Layer Belo_w"), - N_("Switch to the layer below the current"), INKSCAPE_ICON_LAYER_NEXT), + N_("Switch to the layer below the current"), INKSCAPE_ICON("layer-next")), new LayerVerb(SP_VERB_LAYER_MOVE_TO_NEXT, "LayerMoveToNext", N_("Move Selection to Layer Abo_ve"), - N_("Move selection to the layer above the current"), INKSCAPE_ICON_SELECTION_MOVE_TO_LAYER_ABOVE), + N_("Move selection to the layer above the current"), INKSCAPE_ICON("selection-move-to-layer-above")), new LayerVerb(SP_VERB_LAYER_MOVE_TO_PREV, "LayerMoveToPrev", N_("Move Selection to Layer Bel_ow"), - N_("Move selection to the layer below the current"), INKSCAPE_ICON_SELECTION_MOVE_TO_LAYER_BELOW), + N_("Move selection to the layer below the current"), INKSCAPE_ICON("selection-move-to-layer-below")), new LayerVerb(SP_VERB_LAYER_TO_TOP, "LayerToTop", N_("Layer to _Top"), - N_("Raise the current layer to the top"), INKSCAPE_ICON_LAYER_TOP), + N_("Raise the current layer to the top"), INKSCAPE_ICON("layer-top")), new LayerVerb(SP_VERB_LAYER_TO_BOTTOM, "LayerToBottom", N_("Layer to _Bottom"), - N_("Lower the current layer to the bottom"), INKSCAPE_ICON_LAYER_BOTTOM), + N_("Lower the current layer to the bottom"), INKSCAPE_ICON("layer-bottom")), new LayerVerb(SP_VERB_LAYER_RAISE, "LayerRaise", N_("_Raise Layer"), - N_("Raise the current layer"), INKSCAPE_ICON_LAYER_RAISE), + N_("Raise the current layer"), INKSCAPE_ICON("layer-raise")), new LayerVerb(SP_VERB_LAYER_LOWER, "LayerLower", N_("_Lower Layer"), - N_("Lower the current layer"), INKSCAPE_ICON_LAYER_LOWER), + N_("Lower the current layer"), INKSCAPE_ICON("layer-lower")), new LayerVerb(SP_VERB_LAYER_DUPLICATE, "LayerDuplicate", N_("D_uplicate Current Layer"), N_("Duplicate an existing layer"), NULL), new LayerVerb(SP_VERB_LAYER_DELETE, "LayerDelete", N_("_Delete Current Layer"), - N_("Delete the current layer"), INKSCAPE_ICON_LAYER_DELETE), + N_("Delete the current layer"), INKSCAPE_ICON("layer-delete")), new LayerVerb(SP_VERB_LAYER_SOLO, "LayerSolo", N_("_Show/hide other layers"), N_("Solo the current layer"), NULL), @@ -2464,83 +2464,83 @@ Verb *Verb::_base_verbs[] = { new ObjectVerb(SP_VERB_OBJECT_ROTATE_90_CW, "ObjectRotate90", N_("Rotate _90° CW"), // This is shared between tooltips and statusbar, so they // must use UTF-8, not HTML entities for special characters. - N_("Rotate selection 90\xc2\xb0 clockwise"), INKSCAPE_ICON_OBJECT_ROTATE_RIGHT), + N_("Rotate selection 90\xc2\xb0 clockwise"), INKSCAPE_ICON("object-rotate-right")), new ObjectVerb(SP_VERB_OBJECT_ROTATE_90_CCW, "ObjectRotate90CCW", N_("Rotate 9_0° CCW"), // This is shared between tooltips and statusbar, so they // must use UTF-8, not HTML entities for special characters. - N_("Rotate selection 90\xc2\xb0 counter-clockwise"), INKSCAPE_ICON_OBJECT_ROTATE_LEFT), + N_("Rotate selection 90\xc2\xb0 counter-clockwise"), INKSCAPE_ICON("object-rotate-left")), new ObjectVerb(SP_VERB_OBJECT_FLATTEN, "ObjectRemoveTransform", N_("Remove _Transformations"), N_("Remove transformations from object"), NULL), new ObjectVerb(SP_VERB_OBJECT_TO_CURVE, "ObjectToPath", N_("_Object to Path"), - N_("Convert selected object to path"), INKSCAPE_ICON_OBJECT_TO_PATH), + N_("Convert selected object to path"), INKSCAPE_ICON("object-to-path")), new ObjectVerb(SP_VERB_OBJECT_FLOW_TEXT, "ObjectFlowText", N_("_Flow into Frame"), N_("Put text into a frame (path or shape), creating a flowed text linked to the frame object"), "text-flow-into-frame"), new ObjectVerb(SP_VERB_OBJECT_UNFLOW_TEXT, "ObjectUnFlowText", N_("_Unflow"), - N_("Remove text from frame (creates a single-line text object)"), INKSCAPE_ICON_TEXT_UNFLOW), + N_("Remove text from frame (creates a single-line text object)"), INKSCAPE_ICON("text-unflow")), new ObjectVerb(SP_VERB_OBJECT_FLOWTEXT_TO_TEXT, "ObjectFlowtextToText", N_("_Convert to Text"), - N_("Convert flowed text to regular text object (preserves appearance)"), INKSCAPE_ICON_TEXT_CONVERT_TO_REGULAR), + N_("Convert flowed text to regular text object (preserves appearance)"), INKSCAPE_ICON("text-convert-to-regular")), new ObjectVerb(SP_VERB_OBJECT_FLIP_HORIZONTAL, "ObjectFlipHorizontally", N_("Flip _Horizontal"), N_("Flip selected objects horizontally"), - INKSCAPE_ICON_OBJECT_FLIP_HORIZONTAL), + INKSCAPE_ICON("object-flip-horizontal")), new ObjectVerb(SP_VERB_OBJECT_FLIP_VERTICAL, "ObjectFlipVertically", N_("Flip _Vertical"), N_("Flip selected objects vertically"), - INKSCAPE_ICON_OBJECT_FLIP_VERTICAL), + INKSCAPE_ICON("object-flip-vertical")), new ObjectVerb(SP_VERB_OBJECT_SET_MASK, "ObjectSetMask", N_("_Set"), N_("Apply mask to selection (using the topmost object as mask)"), NULL), new ObjectVerb(SP_VERB_OBJECT_EDIT_MASK, "ObjectEditMask", N_("_Edit"), - N_("Edit mask"), INKSCAPE_ICON_PATH_MASK_EDIT), + N_("Edit mask"), INKSCAPE_ICON("path-mask-edit")), new ObjectVerb(SP_VERB_OBJECT_UNSET_MASK, "ObjectUnSetMask", N_("_Release"), N_("Remove mask from selection"), NULL), new ObjectVerb(SP_VERB_OBJECT_SET_CLIPPATH, "ObjectSetClipPath", N_("_Set"), N_("Apply clipping path to selection (using the topmost object as clipping path)"), NULL), new ObjectVerb(SP_VERB_OBJECT_EDIT_CLIPPATH, "ObjectEditClipPath", N_("_Edit"), - N_("Edit clipping path"), INKSCAPE_ICON_PATH_CLIP_EDIT), + N_("Edit clipping path"), INKSCAPE_ICON("path-clip-edit")), new ObjectVerb(SP_VERB_OBJECT_UNSET_CLIPPATH, "ObjectUnSetClipPath", N_("_Release"), N_("Remove clipping path from selection"), NULL), /* Tools */ new ContextVerb(SP_VERB_CONTEXT_SELECT, "ToolSelector", N_("Select"), - N_("Select and transform objects"), INKSCAPE_ICON_TOOL_POINTER), + N_("Select and transform objects"), INKSCAPE_ICON("tool-pointer")), new ContextVerb(SP_VERB_CONTEXT_NODE, "ToolNode", N_("Node Edit"), - N_("Edit paths by nodes"), INKSCAPE_ICON_TOOL_NODE_EDITOR), + N_("Edit paths by nodes"), INKSCAPE_ICON("tool-node-editor")), new ContextVerb(SP_VERB_CONTEXT_TWEAK, "ToolTweak", N_("Tweak"), - N_("Tweak objects by sculpting or painting"), INKSCAPE_ICON_TOOL_TWEAK), + N_("Tweak objects by sculpting or painting"), INKSCAPE_ICON("tool-tweak")), new ContextVerb(SP_VERB_CONTEXT_SPRAY, "ToolSpray", N_("Spray"), - N_("Spray objects by sculpting or painting"), INKSCAPE_ICON_TOOL_SPRAY), + N_("Spray objects by sculpting or painting"), INKSCAPE_ICON("tool-spray")), new ContextVerb(SP_VERB_CONTEXT_RECT, "ToolRect", N_("Rectangle"), - N_("Create rectangles and squares"), INKSCAPE_ICON_DRAW_RECTANGLE), + N_("Create rectangles and squares"), INKSCAPE_ICON("draw-rectangle")), new ContextVerb(SP_VERB_CONTEXT_3DBOX, "Tool3DBox", N_("3D Box"), - N_("Create 3D boxes"), INKSCAPE_ICON_DRAW_CUBOID), + N_("Create 3D boxes"), INKSCAPE_ICON("draw-cuboid")), new ContextVerb(SP_VERB_CONTEXT_ARC, "ToolArc", N_("Ellipse"), - N_("Create circles, ellipses, and arcs"), INKSCAPE_ICON_DRAW_ELLIPSE), + N_("Create circles, ellipses, and arcs"), INKSCAPE_ICON("draw-ellipse")), new ContextVerb(SP_VERB_CONTEXT_STAR, "ToolStar", N_("Star"), - N_("Create stars and polygons"), INKSCAPE_ICON_DRAW_POLYGON_STAR), + N_("Create stars and polygons"), INKSCAPE_ICON("draw-polygon-star")), new ContextVerb(SP_VERB_CONTEXT_SPIRAL, "ToolSpiral", N_("Spiral"), - N_("Create spirals"), INKSCAPE_ICON_DRAW_SPIRAL), + N_("Create spirals"), INKSCAPE_ICON("draw-spiral")), new ContextVerb(SP_VERB_CONTEXT_PENCIL, "ToolPencil", N_("Pencil"), - N_("Draw freehand lines"), INKSCAPE_ICON_DRAW_FREEHAND), + N_("Draw freehand lines"), INKSCAPE_ICON("draw-freehand")), new ContextVerb(SP_VERB_CONTEXT_PEN, "ToolPen", N_("Pen"), - N_("Draw Bezier curves and straight lines"), INKSCAPE_ICON_DRAW_PATH), + N_("Draw Bezier curves and straight lines"), INKSCAPE_ICON("draw-path")), new ContextVerb(SP_VERB_CONTEXT_CALLIGRAPHIC, "ToolCalligraphic", N_("Calligraphy"), - N_("Draw calligraphic or brush strokes"), INKSCAPE_ICON_DRAW_CALLIGRAPHIC), + N_("Draw calligraphic or brush strokes"), INKSCAPE_ICON("draw-calligraphic")), new ContextVerb(SP_VERB_CONTEXT_TEXT, "ToolText", N_("Text"), - N_("Create and edit text objects"), INKSCAPE_ICON_DRAW_TEXT), + N_("Create and edit text objects"), INKSCAPE_ICON("draw-text")), new ContextVerb(SP_VERB_CONTEXT_GRADIENT, "ToolGradient", N_("Gradient"), - N_("Create and edit gradients"), INKSCAPE_ICON_COLOR_GRADIENT), + N_("Create and edit gradients"), INKSCAPE_ICON("color-gradient")), new ContextVerb(SP_VERB_CONTEXT_ZOOM, "ToolZoom", N_("Zoom"), - N_("Zoom in or out"), INKSCAPE_ICON_ZOOM), + N_("Zoom in or out"), INKSCAPE_ICON("zoom")), new ContextVerb(SP_VERB_CONTEXT_MEASURE, "ToolMeasure", N_("Measure"), - N_("Measurement tool"), INKSCAPE_ICON_MEASURE), + N_("Measurement tool"), INKSCAPE_ICON("tool-measure")), new ContextVerb(SP_VERB_CONTEXT_DROPPER, "ToolDropper", N_("Dropper"), - N_("Pick colors from image"), INKSCAPE_ICON_COLOR_PICKER), + N_("Pick colors from image"), INKSCAPE_ICON("color-picker")), new ContextVerb(SP_VERB_CONTEXT_CONNECTOR, "ToolConnector", N_("Connector"), - N_("Create diagram connectors"), INKSCAPE_ICON_DRAW_CONNECTOR), + N_("Create diagram connectors"), INKSCAPE_ICON("draw-connector")), new ContextVerb(SP_VERB_CONTEXT_PAINTBUCKET, "ToolPaintBucket", N_("Paint Bucket"), - N_("Fill bounded areas"), INKSCAPE_ICON_COLOR_FILL), + N_("Fill bounded areas"), INKSCAPE_ICON("color-fill")), new ContextVerb(SP_VERB_CONTEXT_LPE, "ToolLPE", N_("LPE Edit"), N_("Edit Path Effect parameters"), NULL), new ContextVerb(SP_VERB_CONTEXT_ERASER, "ToolEraser", N_("Eraser"), - N_("Erase existing paths"), INKSCAPE_ICON_DRAW_ERASER), + N_("Erase existing paths"), INKSCAPE_ICON("draw-eraser")), new ContextVerb(SP_VERB_CONTEXT_LPETOOL, "ToolLPETool", N_("LPE Tool"), N_("Do geometric constructions"), "draw-geometry"), /* Tool prefs */ @@ -2588,31 +2588,31 @@ Verb *Verb::_base_verbs[] = { N_("Open Preferences for the LPETool tool"), NULL), /* Zoom/View */ - new ZoomVerb(SP_VERB_ZOOM_IN, "ZoomIn", N_("Zoom In"), N_("Zoom in"), INKSCAPE_ICON_ZOOM_IN), - new ZoomVerb(SP_VERB_ZOOM_OUT, "ZoomOut", N_("Zoom Out"), N_("Zoom out"), INKSCAPE_ICON_ZOOM_OUT), + new ZoomVerb(SP_VERB_ZOOM_IN, "ZoomIn", N_("Zoom In"), N_("Zoom in"), INKSCAPE_ICON("zoom-in")), + new ZoomVerb(SP_VERB_ZOOM_OUT, "ZoomOut", N_("Zoom Out"), N_("Zoom out"), INKSCAPE_ICON("zoom-out")), new ZoomVerb(SP_VERB_TOGGLE_RULERS, "ToggleRulers", N_("_Rulers"), N_("Show or hide the canvas rulers"), NULL), new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), NULL), - new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), INKSCAPE_ICON_SHOW_GRID), - new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), INKSCAPE_ICON_SHOW_GUIDES), - new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Enable snapping"), INKSCAPE_ICON_SNAP), + new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), INKSCAPE_ICON("show-grid")), + new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), INKSCAPE_ICON("show-guides")), + new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Enable snapping"), INKSCAPE_ICON("snap")), new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"), - INKSCAPE_ICON_ZOOM_NEXT), + INKSCAPE_ICON("zoom-next")), new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"), - INKSCAPE_ICON_ZOOM_PREVIOUS), + INKSCAPE_ICON("zoom-previous")), new ZoomVerb(SP_VERB_ZOOM_1_1, "Zoom1:0", N_("Zoom 1:_1"), N_("Zoom to 1:1"), - INKSCAPE_ICON_ZOOM_ORIGINAL), + INKSCAPE_ICON("zoom-original")), new ZoomVerb(SP_VERB_ZOOM_1_2, "Zoom1:2", N_("Zoom 1:_2"), N_("Zoom to 1:2"), - INKSCAPE_ICON_ZOOM_HALF_SIZE), + INKSCAPE_ICON("zoom-half-size")), new ZoomVerb(SP_VERB_ZOOM_2_1, "Zoom2:1", N_("_Zoom 2:1"), N_("Zoom to 2:1"), - INKSCAPE_ICON_ZOOM_DOUBLE_SIZE), + INKSCAPE_ICON("zoom-double-size")), #ifdef HAVE_GTK_WINDOW_FULLSCREEN new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"), - INKSCAPE_ICON_VIEW_FULLSCREEN), + INKSCAPE_ICON("view-fullscreen")), #endif /* HAVE_GTK_WINDOW_FULLSCREEN */ new ZoomVerb(SP_VERB_FOCUSTOGGLE, "FocusToggle", N_("Toggle _Focus Mode"), N_("Remove excess toolbars to focus on drawing"), NULL), new ZoomVerb(SP_VERB_VIEW_NEW, "ViewNew", N_("Duplic_ate Window"), N_("Open a new window with the same document"), - INKSCAPE_ICON_WINDOW_NEW), + INKSCAPE_ICON("window-new")), new ZoomVerb(SP_VERB_VIEW_NEW_PREVIEW, "ViewNewPreview", N_("_New View Preview"), N_("New View Preview"), NULL/*"view_new_preview"*/), @@ -2634,18 +2634,18 @@ Verb *Verb::_base_verbs[] = { N_("Toggle between normal and grayscale color display modes"), NULL), new ZoomVerb(SP_VERB_VIEW_CMS_TOGGLE, "ViewCmsToggle", N_("Color-managed view"), - N_("Toggle color-managed display for this document window"), INKSCAPE_ICON_COLOR_MANAGEMENT), + N_("Toggle color-managed display for this document window"), INKSCAPE_ICON("color-management")), new ZoomVerb(SP_VERB_VIEW_ICON_PREVIEW, "ViewIconPreview", N_("Ico_n Preview..."), - N_("Open a window to preview objects at different icon resolutions"), INKSCAPE_ICON_DIALOG_ICON_PREVIEW), + N_("Open a window to preview objects at different icon resolutions"), INKSCAPE_ICON("dialog-icon-preview")), new ZoomVerb(SP_VERB_ZOOM_PAGE, "ZoomPage", N_("_Page"), - N_("Zoom to fit page in window"), INKSCAPE_ICON_ZOOM_FIT_PAGE), + N_("Zoom to fit page in window"), INKSCAPE_ICON("zoom-fit-page")), new ZoomVerb(SP_VERB_ZOOM_PAGE_WIDTH, "ZoomPageWidth", N_("Page _Width"), - N_("Zoom to fit page width in window"), INKSCAPE_ICON_ZOOM_FIT_WIDTH), + N_("Zoom to fit page width in window"), INKSCAPE_ICON("zoom-fit-width")), new ZoomVerb(SP_VERB_ZOOM_DRAWING, "ZoomDrawing", N_("_Drawing"), - N_("Zoom to fit drawing in window"), INKSCAPE_ICON_ZOOM_FIT_DRAWING), + N_("Zoom to fit drawing in window"), INKSCAPE_ICON("zoom-fit-drawing")), new ZoomVerb(SP_VERB_ZOOM_SELECTION, "ZoomSelection", N_("_Selection"), - N_("Zoom to fit selection in window"), INKSCAPE_ICON_ZOOM_FIT_SELECTION), + N_("Zoom to fit selection in window"), INKSCAPE_ICON("zoom-fit-selection")), /* Dialogs */ new DialogVerb(SP_VERB_DIALOG_DISPLAY, "DialogPreferences", N_("In_kscape Preferences..."), @@ -2653,26 +2653,26 @@ Verb *Verb::_base_verbs[] = { new DialogVerb(SP_VERB_DIALOG_NAMEDVIEW, "DialogDocumentProperties", N_("_Document Properties..."), N_("Edit properties of this document (to be saved with the document)"), GTK_STOCK_PROPERTIES ), new DialogVerb(SP_VERB_DIALOG_METADATA, "DialogMetadata", N_("Document _Metadata..."), - N_("Edit document metadata (to be saved with the document)"), INKSCAPE_ICON_DOCUMENT_METADATA ), + N_("Edit document metadata (to be saved with the document)"), INKSCAPE_ICON("document-metadata") ), new DialogVerb(SP_VERB_DIALOG_FILL_STROKE, "DialogFillStroke", N_("_Fill and Stroke..."), - N_("Edit objects' colors, gradients, arrowheads, and other fill and stroke properties..."), INKSCAPE_ICON_DIALOG_FILL_AND_STROKE), + N_("Edit objects' colors, gradients, arrowheads, and other fill and stroke properties..."), INKSCAPE_ICON("dialog-fill-and-stroke")), new DialogVerb(SP_VERB_DIALOG_GLYPHS, "DialogGlyphs", N_("Gl_yphs..."), N_("Select characters from a glyphs palette"), GTK_STOCK_SELECT_FONT), // TRANSLATORS: "Swatches" means: color samples new DialogVerb(SP_VERB_DIALOG_SWATCHES, "DialogSwatches", N_("S_watches..."), N_("Select colors from a swatches palette"), GTK_STOCK_SELECT_COLOR), new DialogVerb(SP_VERB_DIALOG_TRANSFORM, "DialogTransform", N_("Transfor_m..."), - N_("Precisely control objects' transformations"), INKSCAPE_ICON_DIALOG_TRANSFORM), + N_("Precisely control objects' transformations"), INKSCAPE_ICON("dialog-transform")), new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."), - N_("Align and distribute objects"), INKSCAPE_ICON_DIALOG_ALIGN_AND_DISTRIBUTE), + N_("Align and distribute objects"), INKSCAPE_ICON("dialog-align-and-distribute")), new DialogVerb(SP_VERB_DIALOG_SPRAY_OPTION, "DialogSprayOption", N_("_Spray options..."), - N_("Some options for the spray"), INKSCAPE_ICON_DIALOG_SPRAY_OPTIONS), + N_("Some options for the spray"), INKSCAPE_ICON("dialog-spray-options")), new DialogVerb(SP_VERB_DIALOG_UNDO_HISTORY, "DialogUndoHistory", N_("Undo _History..."), - N_("Undo History"), INKSCAPE_ICON_EDIT_UNDO_HISTORY), + N_("Undo History"), INKSCAPE_ICON("edit-undo-history")), new DialogVerb(SP_VERB_DIALOG_TEXT, "DialogText", N_("_Text and Font..."), - N_("View and select font family, font size and other text properties"), INKSCAPE_ICON_DIALOG_TEXT_AND_FONT), + N_("View and select font family, font size and other text properties"), INKSCAPE_ICON("dialog-text-and-font")), new DialogVerb(SP_VERB_DIALOG_XML_EDITOR, "DialogXMLEditor", N_("_XML Editor..."), - N_("View and edit the XML tree of the document"), INKSCAPE_ICON_DIALOG_XML_EDITOR), + N_("View and edit the XML tree of the document"), INKSCAPE_ICON("dialog-xml-editor")), new DialogVerb(SP_VERB_DIALOG_FIND, "DialogFind", N_("_Find..."), N_("Find objects in document"), GTK_STOCK_FIND ), new DialogVerb(SP_VERB_DIALOG_FINDREPLACE, "DialogFindReplace", N_("Find and _Replace Text..."), @@ -2680,25 +2680,25 @@ Verb *Verb::_base_verbs[] = { new DialogVerb(SP_VERB_DIALOG_SPELLCHECK, "DialogSpellcheck", N_("Check Spellin_g..."), N_("Check spelling of text in document"), GTK_STOCK_SPELL_CHECK ), new DialogVerb(SP_VERB_DIALOG_DEBUG, "DialogDebug", N_("_Messages..."), - N_("View debug messages"), INKSCAPE_ICON_DIALOG_MESSAGES), + N_("View debug messages"), INKSCAPE_ICON("dialog-messages")), new DialogVerb(SP_VERB_DIALOG_SCRIPT, "DialogScript", N_("S_cripts..."), - N_("Run scripts"), INKSCAPE_ICON_DIALOG_SCRIPTS), + N_("Run scripts"), INKSCAPE_ICON("dialog-scripts")), new DialogVerb(SP_VERB_DIALOG_TOGGLE, "DialogsToggle", N_("Show/Hide D_ialogs"), - N_("Show or hide all open dialogs"), INKSCAPE_ICON_SHOW_DIALOGS), + N_("Show or hide all open dialogs"), INKSCAPE_ICON("show-dialogs")), new DialogVerb(SP_VERB_DIALOG_CLONETILER, "DialogClonetiler", N_("Create Tiled Clones..."), - N_("Create multiple clones of selected object, arranging them into a pattern or scattering"), INKSCAPE_ICON_DIALOG_TILE_CLONES), + N_("Create multiple clones of selected object, arranging them into a pattern or scattering"), INKSCAPE_ICON("dialog-tile-clones")), new DialogVerb(SP_VERB_DIALOG_ITEM, "DialogObjectProperties", N_("_Object Properties..."), - N_("Edit the ID, locked and visible status, and other object properties"), INKSCAPE_ICON_DIALOG_OBJECT_PROPERTIES), + N_("Edit the ID, locked and visible status, and other object properties"), INKSCAPE_ICON("dialog-object-properties")), /*#ifdef WITH_INKBOARD new DialogVerb(SP_VERB_XMPP_CLIENT, "DialogXmppClient", N_("_Instant Messaging..."), N_("Jabber Instant Messaging Client"), NULL), #endif*/ new DialogVerb(SP_VERB_DIALOG_INPUT, "DialogInput", N_("_Input Devices..."), - N_("Configure extended input devices, such as a graphics tablet"), INKSCAPE_ICON_DIALOG_INPUT_DEVICES), + N_("Configure extended input devices, such as a graphics tablet"), INKSCAPE_ICON("dialog-input-devices")), new DialogVerb(SP_VERB_DIALOG_EXTENSIONEDITOR, "org.inkscape.dialogs.extensioneditor", N_("_Extensions..."), N_("Query information about extensions"), NULL), new DialogVerb(SP_VERB_DIALOG_LAYERS, "DialogLayers", N_("Layer_s..."), - N_("View Layers"), INKSCAPE_ICON_DIALOG_LAYERS), + N_("View Layers"), INKSCAPE_ICON("dialog-layers")), new DialogVerb(SP_VERB_DIALOG_LIVE_PATH_EFFECT, "DialogLivePathEffect", N_("Path E_ffect Editor..."), N_("Manage, edit, and apply path effects"), NULL), new DialogVerb(SP_VERB_DIALOG_FILTER_EFFECTS, "DialogFilterEffects", N_("Filter _Editor..."), @@ -2712,9 +2712,9 @@ Verb *Verb::_base_verbs[] = { new HelpVerb(SP_VERB_HELP_ABOUT_EXTENSIONS, "HelpAboutExtensions", N_("About E_xtensions"), N_("Information on Inkscape extensions"), NULL), new HelpVerb(SP_VERB_HELP_MEMORY, "HelpAboutMemory", N_("About _Memory"), - N_("Memory usage information"), INKSCAPE_ICON_DIALOG_MEMORY), + N_("Memory usage information"), INKSCAPE_ICON("dialog-memory")), new HelpVerb(SP_VERB_HELP_ABOUT, "HelpAbout", N_("_About Inkscape"), - N_("Inkscape version, authors, license"), INKSCAPE_ICON_INKSCAPE), + N_("Inkscape version, authors, license"), INKSCAPE_ICON("inkscape")), //new HelpVerb(SP_VERB_SHOW_LICENSE, "ShowLicense", N_("_License"), // N_("Distribution terms"), /*"show_license"*/"inkscape_options"), diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 970a094a9..c51b88251 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -334,7 +334,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 ); gtk_widget_show(dtw->hbox); - + dtw->aux_toolbox = ToolboxFactory::createAuxToolbox(); gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0); @@ -388,7 +388,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, - INKSCAPE_ICON_ZOOM_ORIGINAL, + INKSCAPE_ICON("zoom-original"), _("Zoom drawing if window size changes")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("/options/stickyzoom/value")); gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0); @@ -410,7 +410,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->cms_adjust = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, - INKSCAPE_ICON_COLOR_MANAGEMENT, + INKSCAPE_ICON("color-management"), tip ); #if ENABLE_LCMS { @@ -1558,12 +1558,12 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) /* This loops through all the grandchildren of aux toolbox, * and for each that it finds, it performs an sp_search_by_data_recursive(), * looking for widgets that hold some "tracker" data (this is used by - * all toolboxes to refer to the unit selector). The default document units + * all toolboxes to refer to the unit selector). The default document units * is then selected within these unit selectors. * * Of course it would be nice to be able to refer to the toolbox and the * unit selector directly by name, but I don't yet see a way to do that. - * + * * This should solve: https://bugs.launchpad.net/inkscape/+bug/362995 */ if (GTK_IS_CONTAINER(aux_toolbox)) { @@ -1571,7 +1571,7 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) for (GList *i = ch; i != NULL; i = i->next) { if (GTK_IS_CONTAINER(i->data)) { GList *grch = gtk_container_get_children (GTK_CONTAINER(i->data)); - for (GList *j = grch; j != NULL; j = j->next) { + for (GList *j = grch; j != NULL; j = j->next) { if (!GTK_IS_WIDGET(j->data)) // wasn't a widget continue; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 6d4f6fae0..9fe875d28 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -552,7 +552,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, - INKSCAPE_ICON_PAINT_GRADIENT_LINEAR, + INKSCAPE_ICON("paint-gradient-linear"), _("Create linear gradient") ); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_type), tbl); g_object_set_data(G_OBJECT(tbl), "linear", button); @@ -565,7 +565,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, - INKSCAPE_ICON_PAINT_GRADIENT_RADIAL, + INKSCAPE_ICON("paint-gradient-radial"), _("Create radial (elliptic or circular) gradient")); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_type), tbl); g_object_set_data(G_OBJECT(tbl), "radial", button); @@ -592,7 +592,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, - INKSCAPE_ICON_OBJECT_FILL, + INKSCAPE_ICON("object-fill"), _("Create gradient in the fill")); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_fillstroke), tbl); g_object_set_data(G_OBJECT(tbl), "fill", button); @@ -605,7 +605,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop) GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION, SP_BUTTON_TYPE_TOGGLE, NULL, - INKSCAPE_ICON_OBJECT_STROKE, + INKSCAPE_ICON("object-stroke"), _("Create gradient in the stroke")); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_fillstroke), tbl); g_object_set_data(G_OBJECT(tbl), "stroke", button); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 9f2a30e32..259aa5f25 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -221,19 +221,19 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_box_pack_start(GTK_BOX(psel), psel->style, FALSE, FALSE, 0); /* Buttons */ - psel->none = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_NONE, + psel->none = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-none"), SPPaintSelector::MODE_NONE, _("No paint")); - psel->solid = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_SOLID, + psel->solid = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-solid"), SPPaintSelector::MODE_COLOR_RGB, _("Flat color")); - psel->gradient = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_GRADIENT_LINEAR, + psel->gradient = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-gradient-linear"), SPPaintSelector::MODE_GRADIENT_LINEAR, _("Linear gradient")); - psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_GRADIENT_RADIAL, + psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-gradient-radial"), SPPaintSelector::MODE_GRADIENT_RADIAL, _("Radial gradient")); - psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_PATTERN, + psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-pattern"), SPPaintSelector::MODE_PATTERN, _("Pattern")); - psel->swatch = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_SWATCH, + psel->swatch = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-swatch"), SPPaintSelector::MODE_SWATCH, _("Swatch")); - psel->unset = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_UNKNOWN, + psel->unset = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-unknown"), SPPaintSelector::MODE_UNSET, _("Unset paint (make it undefined so it can be inherited)")); /* Fillrule */ @@ -248,7 +248,7 @@ sp_paint_selector_init(SPPaintSelector *psel) // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty gtk_widget_set_tooltip_text(psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)")); g_object_set_data(G_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_EVENODD)); - w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_EVEN_ODD); + w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("fill-rule-even-odd")); gtk_container_add(GTK_CONTAINER(psel->evenodd), w); gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->evenodd, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(psel->evenodd), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel); @@ -259,7 +259,7 @@ sp_paint_selector_init(SPPaintSelector *psel) // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty gtk_widget_set_tooltip_text(psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)")); g_object_set_data(G_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_NONZERO)); - w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_NONZERO); + w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("fill-rule-nonzero")); gtk_container_add(GTK_CONTAINER(psel->nonzero), w); gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->nonzero, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(psel->nonzero), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index ba32dc321..260c09c69 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -378,9 +378,9 @@ static void toggle_pattern( GtkToggleAction* act, gpointer data ) static void toggle_lock( GtkToggleAction *act, gpointer /*data*/ ) { gboolean active = gtk_toggle_action_get_active( act ); if ( active ) { - g_object_set( G_OBJECT(act), "iconId", INKSCAPE_ICON_OBJECT_LOCKED, NULL ); + g_object_set( G_OBJECT(act), "iconId", INKSCAPE_ICON("object-locked"), NULL ); } else { - g_object_set( G_OBJECT(act), "iconId", INKSCAPE_ICON_OBJECT_UNLOCKED, NULL ); + g_object_set( G_OBJECT(act), "iconId", INKSCAPE_ICON("object-unlocked"), NULL ); } } @@ -507,7 +507,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkToggleAction* itact = ink_toggle_action_new( "LockAction", _("Lock width and height"), _("When locked, change both width and height by the same proportion"), - INKSCAPE_ICON_OBJECT_UNLOCKED, + INKSCAPE_ICON("object-unlocked"), Inkscape::ICON_SIZE_DECORATION ); g_object_set( itact, "short_label", "Lock", NULL ); g_object_set_data( G_OBJECT(spw), "lock", itact ); @@ -554,7 +554,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // "Transform with object" buttons { - EgeOutputAction* act = ege_output_action_new( "transform_affect_label", _("Affect:"), _("Control whether or not to scale stroke widths, scale rectangle corners, transform gradient fills, and transform pattern fills with the object"), 0 ); + EgeOutputAction* act = ege_output_action_new( "transform_affect_label", _("Affect:"), _("Control whether or not to scale stroke widths, scale rectangle corners, transform gradient fills, and transform pattern fills with the object"), 0 ); ege_output_action_set_use_markup( act, TRUE ); g_object_set( act, "visible-overflown", FALSE, NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -564,7 +564,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkToggleAction* itact = ink_toggle_action_new( "transform_stroke", _("Scale stroke width"), _("When scaling objects, scale the stroke width by the same proportion"), - INKSCAPE_ICON_TRANSFORM_AFFECT_STROKE, + INKSCAPE_ICON("transform-affect-stroke"), Inkscape::ICON_SIZE_DECORATION ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/stroke", true) ); g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_stroke), desktop) ; @@ -575,7 +575,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkToggleAction* itact = ink_toggle_action_new( "transform_corners", _("Scale rounded corners"), _("When scaling rectangles, scale the radii of rounded corners"), - INKSCAPE_ICON_TRANSFORM_AFFECT_ROUNDED_CORNERS, + INKSCAPE_ICON("transform-affect-rounded-corners"), Inkscape::ICON_SIZE_DECORATION ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/rectcorners", true) ); g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_corners), desktop) ; @@ -586,7 +586,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkToggleAction* itact = ink_toggle_action_new( "transform_gradient", _("Move gradients"), _("Move gradients (in fill or stroke) along with the objects"), - INKSCAPE_ICON_TRANSFORM_AFFECT_GRADIENT, + INKSCAPE_ICON("transform-affect-gradient"), Inkscape::ICON_SIZE_DECORATION ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/gradient", true) ); g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_gradient), desktop) ; @@ -597,7 +597,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb InkToggleAction* itact = ink_toggle_action_new( "transform_pattern", _("Move patterns"), _("Move patterns (in fill or stroke) along with the objects"), - INKSCAPE_ICON_TRANSFORM_AFFECT_PATTERN, + INKSCAPE_ICON("transform-affect-pattern"), Inkscape::ICON_SIZE_DECORATION ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/pattern", true) ); g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_pattern), desktop) ; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 9da39bac4..8544c8cad 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -721,7 +721,7 @@ sp_stroke_style_line_widget_new(void) tb = NULL; - tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_JOIN_MITER, + tb = sp_stroke_radio_button(tb, INKSCAPE_ICON("stroke-join-miter"), hb, spw, "join", "miter"); // TRANSLATORS: Miter join: joining lines with a sharp (pointed) corner. @@ -730,7 +730,7 @@ sp_stroke_style_line_widget_new(void) tt->set_tip(*tb, _("Miter join")); spw->set_data("miter join", tb); - tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_JOIN_ROUND, + tb = sp_stroke_radio_button(tb, INKSCAPE_ICON("stroke-join-round"), hb, spw, "join", "round"); @@ -740,7 +740,7 @@ sp_stroke_style_line_widget_new(void) tt->set_tip(*tb, _("Round join")); spw->set_data("round join", tb); - tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_JOIN_BEVEL, + tb = sp_stroke_radio_button(tb, INKSCAPE_ICON("stroke-join-bevel"), hb, spw, "join", "bevel"); @@ -787,7 +787,7 @@ sp_stroke_style_line_widget_new(void) tb = NULL; - tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_CAP_BUTT, + tb = sp_stroke_radio_button(tb, INKSCAPE_ICON("stroke-cap-butt"), hb, spw, "cap", "butt"); spw->set_data("cap butt", tb); @@ -795,7 +795,7 @@ sp_stroke_style_line_widget_new(void) // of the line; the ends of the line are square tt->set_tip(*tb, _("Butt cap")); - tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_CAP_ROUND, + tb = sp_stroke_radio_button(tb, INKSCAPE_ICON("stroke-cap-round"), hb, spw, "cap", "round"); spw->set_data("cap round", tb); @@ -803,7 +803,7 @@ sp_stroke_style_line_widget_new(void) // line; the ends of the line are rounded tt->set_tip(*tb, _("Round cap")); - tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_CAP_SQUARE, + tb = sp_stroke_radio_button(tb, INKSCAPE_ICON("stroke-cap-square"), hb, spw, "cap", "square"); spw->set_data("cap square", tb); @@ -949,13 +949,13 @@ sp_jointype_set (Gtk::Container *spw, unsigned const jointype) Gtk::RadioButton *tb = NULL; switch (jointype) { case SP_STROKE_LINEJOIN_MITER: - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_MITER)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-join-miter"))); break; case SP_STROKE_LINEJOIN_ROUND: - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_ROUND)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-join-round"))); break; case SP_STROKE_LINEJOIN_BEVEL: - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_BEVEL)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-join-bevel"))); break; default: break; @@ -972,13 +972,13 @@ sp_captype_set (Gtk::Container *spw, unsigned const captype) Gtk::RadioButton *tb = NULL; switch (captype) { case SP_STROKE_LINECAP_BUTT: - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_CAP_BUTT)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-cap-butt"))); break; case SP_STROKE_LINECAP_ROUND: - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_CAP_ROUND)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-cap-round"))); break; case SP_STROKE_LINECAP_SQUARE: - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_CAP_SQUARE)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-cap-square"))); break; default: break; @@ -1325,16 +1325,16 @@ sp_stroke_style_set_join_buttons(Gtk::Container *spw, Gtk::ToggleButton *active) { Gtk::RadioButton *tb; - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_MITER)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-join-miter"))); tb->set_active(active == tb); Gtk::SpinButton *ml = static_cast(spw->get_data("miterlimit_sb")); ml->set_sensitive(active == tb); - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_ROUND)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-join-round"))); tb->set_active(active == tb); - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_BEVEL)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-join-bevel"))); tb->set_active(active == tb); } @@ -1346,11 +1346,11 @@ sp_stroke_style_set_cap_buttons(Gtk::Container *spw, Gtk::ToggleButton *active) { Gtk::RadioButton *tb; - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_CAP_BUTT)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-cap-butt"))); tb->set_active(active == tb); - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_CAP_ROUND)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-cap-round"))); tb->set_active(active == tb); - tb = static_cast(spw->get_data(INKSCAPE_ICON_STROKE_CAP_SQUARE)); + tb = static_cast(spw->get_data(INKSCAPE_ICON("stroke-cap-square"))); tb->set_active(active == tb); } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 3c1196e96..9e28e4bee 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1369,7 +1369,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeInsertAction", _("Insert node"), _("Insert new nodes into selected segments"), - INKSCAPE_ICON_NODE_ADD, + INKSCAPE_ICON("node-add"), secondarySize ); g_object_set( inky, "short_label", _("Insert"), NULL ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add), 0 ); @@ -1380,7 +1380,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeDeleteAction", _("Delete node"), _("Delete selected nodes"), - INKSCAPE_ICON_NODE_DELETE, + INKSCAPE_ICON("node-delete"), secondarySize ); g_object_set( inky, "short_label", _("Delete"), NULL ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete), 0 ); @@ -1391,7 +1391,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeJoinAction", _("Join nodes"), _("Join selected nodes"), - INKSCAPE_ICON_NODE_JOIN, + INKSCAPE_ICON("node-join"), secondarySize ); g_object_set( inky, "short_label", _("Join"), NULL ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join), 0 ); @@ -1402,7 +1402,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeBreakAction", _("Break nodes"), _("Break path at selected nodes"), - INKSCAPE_ICON_NODE_BREAK, + INKSCAPE_ICON("node-break"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_break), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1413,7 +1413,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeJoinSegmentAction", _("Join with segment"), _("Join selected endnodes with a new segment"), - INKSCAPE_ICON_NODE_JOIN_SEGMENT, + INKSCAPE_ICON("node-join-segment"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join_segment), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1423,7 +1423,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeDeleteSegmentAction", _("Delete segment"), _("Delete segment between two non-endpoint nodes"), - INKSCAPE_ICON_NODE_DELETE_SEGMENT, + INKSCAPE_ICON("node-delete-segment"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete_segment), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1433,7 +1433,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeCuspAction", _("Node Cusp"), _("Make selected nodes corner"), - INKSCAPE_ICON_NODE_TYPE_CUSP, + INKSCAPE_ICON("node-type-cusp"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_cusp), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1443,7 +1443,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeSmoothAction", _("Node Smooth"), _("Make selected nodes smooth"), - INKSCAPE_ICON_NODE_TYPE_SMOOTH, + INKSCAPE_ICON("node-type-smooth"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_smooth), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1453,7 +1453,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeSymmetricAction", _("Node Symmetric"), _("Make selected nodes symmetric"), - INKSCAPE_ICON_NODE_TYPE_SYMMETRIC, + INKSCAPE_ICON("node-type-symmetric"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_symmetrical), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1463,7 +1463,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeAutoAction", _("Node Auto"), _("Make selected nodes auto-smooth"), - INKSCAPE_ICON_NODE_TYPE_AUTO_SMOOTH, + INKSCAPE_ICON("node-type-auto-smooth"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_auto), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1473,7 +1473,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeLineAction", _("Node Line"), _("Make selected segments lines"), - INKSCAPE_ICON_NODE_SEGMENT_LINE, + INKSCAPE_ICON("node-segment-line"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_toline), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1483,7 +1483,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "NodeCurveAction", _("Node Curve"), _("Make selected segments curves"), - INKSCAPE_ICON_NODE_SEGMENT_CURVE, + INKSCAPE_ICON("node-segment-curve"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_tocurve), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1504,7 +1504,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkToggleAction* act = ink_toggle_action_new( "NodesShowHandlesAction", _("Show Handles"), _("Show Bezier handles of selected nodes"), - INKSCAPE_ICON_SHOW_NODE_HANDLES, + INKSCAPE_ICON("show-node-handles"), secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_handles"); @@ -1515,7 +1515,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath", _("Show Outline"), _("Show path outline (without path effects)"), - INKSCAPE_ICON_SHOW_PATH_OUTLINE, + INKSCAPE_ICON("show-path-outline"), secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_outline"); @@ -1527,7 +1527,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), - INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT, + INKSCAPE_ICON("path-effect-parameter-next"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1538,7 +1538,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkToggleAction* inky = ink_toggle_action_new( "ObjectEditClipPathAction", _("Edit clipping paths"), _("Show clipping path(s) of selected object(s)"), - INKSCAPE_ICON_PATH_CLIP_EDIT, + INKSCAPE_ICON("path-clip-edit"), secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_clipping_paths"); @@ -1549,7 +1549,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkToggleAction* inky = ink_toggle_action_new( "ObjectEditMaskPathAction", _("Edit masks"), _("Show mask(s) of selected object(s)"), - INKSCAPE_ICON_PATH_MASK_EDIT, + INKSCAPE_ICON("path-mask-edit"), secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_masks"); @@ -1677,7 +1677,7 @@ static void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainAct // units label { - EgeOutputAction* act = ege_output_action_new( "measure_units_label", _("Units:"), _("The units to be used for the measurements"), 0 ); + EgeOutputAction* act = ege_output_action_new( "measure_units_label", _("Units:"), _("The units to be used for the measurements"), 0 ); ege_output_action_set_use_markup( act, TRUE ); g_object_set( act, "visible-overflown", FALSE, NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -2274,7 +2274,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) // For example, this action could be based on the verb(+action) + PrefsPusher. Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_TOGGLE_SNAPPING); InkToggleAction* act = ink_toggle_action_new(verb->get_id(), - verb->get_name(), verb->get_tip(), INKSCAPE_ICON_SNAP, secondarySize, + verb->get_name(), verb->get_tip(), INKSCAPE_ICON("snap"), secondarySize, SP_ATTR_INKSCAPE_SNAP_GLOBAL); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2283,7 +2283,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromBBoxCorner", - _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON_SNAP_BOUNDING_BOX, + _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON("snap-bounding-box"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2293,7 +2293,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxPath", _("Bounding box edges"), _("Snap to edges of a bounding box"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_EDGES, secondarySize, SP_ATTR_INKSCAPE_BBOX_PATHS); + INKSCAPE_ICON("snap-bounding-box-edges"), secondarySize, SP_ATTR_INKSCAPE_BBOX_PATHS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2302,7 +2302,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxNode", _("Bounding box corners"), _("Snap to bounding box corners"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_CORNERS, secondarySize, SP_ATTR_INKSCAPE_BBOX_NODES); + INKSCAPE_ICON("snap-bounding-box-corners"), secondarySize, SP_ATTR_INKSCAPE_BBOX_NODES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2311,7 +2311,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxEdgeMidpoints", _("BBox Edge Midpoints"), _("Snap from and to midpoints of bounding box edges"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_MIDPOINTS, secondarySize, + INKSCAPE_ICON("snap-bounding-box-midpoints"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2321,7 +2321,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxCenters", _("BBox Centers"), _("Snapping from and to centers of bounding boxes"), - INKSCAPE_ICON_SNAP_BOUNDING_BOX_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS); + INKSCAPE_ICON("snap-bounding-box-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2329,7 +2329,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode", - _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON_SNAP_NODES, secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); + _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2337,7 +2337,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemPath", - _("Paths"), _("Snap to paths"), INKSCAPE_ICON_SNAP_NODES_PATH, secondarySize, + _("Paths"), _("Snap to paths"), INKSCAPE_ICON("snap-nodes-path"), secondarySize, SP_ATTR_INKSCAPE_OBJECT_PATHS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2347,7 +2347,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPathIntersections", _("Path intersections"), _("Snap to path intersections"), - INKSCAPE_ICON_SNAP_NODES_INTERSECTION, secondarySize, SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS); + INKSCAPE_ICON("snap-nodes-intersection"), secondarySize, SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2355,7 +2355,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemNode", - _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON_SNAP_NODES_CUSP, secondarySize, + _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON("snap-nodes-cusp"), secondarySize, SP_ATTR_INKSCAPE_OBJECT_NODES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2364,7 +2364,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToSmoothNodes", - _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON_SNAP_NODES_SMOOTH, + _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON("snap-nodes-smooth"), secondarySize, SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2374,7 +2374,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromLineMidpoints", _("Line Midpoints"), _("Snap from and to midpoints of line segments"), - INKSCAPE_ICON_SNAP_NODES_MIDPOINT, secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS); + INKSCAPE_ICON("snap-nodes-midpoint"), secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2382,7 +2382,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromOthers", - _("Others"), _("Snap other points (centers, guide origins, gradient handles, etc.)"), INKSCAPE_ICON_SNAP_OTHERS, secondarySize, SP_ATTR_INKSCAPE_SNAP_OTHERS); + _("Others"), _("Snap other points (centers, guide origins, gradient handles, etc.)"), INKSCAPE_ICON("snap-others"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OTHERS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2391,7 +2391,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromObjectCenters", _("Object Centers"), _("Snap from and to centers of objects"), - INKSCAPE_ICON_SNAP_NODES_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS); + INKSCAPE_ICON("snap-nodes-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2400,7 +2400,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromRotationCenter", _("Rotation Centers"), _("Snap from and to an item's rotation center"), - INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_CENTER); + INKSCAPE_ICON("snap-nodes-rotation-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_CENTER); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2409,7 +2409,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromTextBaseline", _("Text baseline"), _("Snap from and to text anchors and baselines"), - INKSCAPE_ICON_SNAP_TEXT_BASELINE, secondarySize, SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE); + INKSCAPE_ICON("snap-text-baseline"), secondarySize, SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2418,7 +2418,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPageBorder", - _("Page border"), _("Snap to the page border"), INKSCAPE_ICON_SNAP_PAGE, + _("Page border"), _("Snap to the page border"), INKSCAPE_ICON("snap-page"), secondarySize, SP_ATTR_INKSCAPE_SNAP_PAGE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2427,7 +2427,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGrids", - _("Grids"), _("Snap to grids"), INKSCAPE_ICON_GRID_RECTANGULAR, secondarySize, + _("Grids"), _("Snap to grids"), INKSCAPE_ICON("grid-rectangular"), secondarySize, SP_ATTR_INKSCAPE_SNAP_GRIDS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2436,7 +2436,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGuides", - _("Guides"), _("Snap to guides"), INKSCAPE_ICON_GUIDES, secondarySize, + _("Guides"), _("Snap to guides"), INKSCAPE_ICON("guides"), secondarySize, SP_ATTR_INKSCAPE_SNAP_TO_GUIDES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2446,7 +2446,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) /*{ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGridGuideIntersections", _("Grid/guide intersections"), _("Snap to intersections of a grid with a guide"), - INKSCAPE_ICON_SNAP_GRID_GUIDE_INTERSECTIONS, secondarySize, + INKSCAPE_ICON("snap-grid-guide-intersections"), secondarySize, SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -3014,14 +3014,14 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions gtk_list_store_set( model, &iter, 0, _("Polygon"), 1, _("Regular polygon (with one handle) instead of a star"), - 2, INKSCAPE_ICON_DRAW_POLYGON, + 2, INKSCAPE_ICON("draw-polygon"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Star"), 1, _("Star instead of a regular polygon (with one handle)"), - 2, INKSCAPE_ICON_DRAW_STAR, + 2, INKSCAPE_ICON("draw-star"), -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "FlatAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); @@ -3444,7 +3444,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions InkAction* inky = ink_action_new( "RectResetAction", _("Not rounded"), _("Make corners sharp"), - INKSCAPE_ICON_RECTANGLE_MAKE_CORNERS_SHARP, + INKSCAPE_ICON("rectangle-make-corners-sharp"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_rtb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -3731,7 +3731,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, // Translators: VP is short for 'vanishing point' _("State of VP in X direction"), _("Toggle VP in X direction between 'finite' and 'infinite' (=parallel)"), - INKSCAPE_ICON_PERSPECTIVE_PARALLEL, + INKSCAPE_ICON("perspective-parallel"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_object_set_data( holder, "box3d_vp_x_state_action", act ); @@ -3770,7 +3770,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, // Translators: VP is short for 'vanishing point' _("State of VP in Y direction"), _("Toggle VP in Y direction between 'finite' and 'infinite' (=parallel)"), - INKSCAPE_ICON_PERSPECTIVE_PARALLEL, + INKSCAPE_ICON("perspective-parallel"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_object_set_data( holder, "box3d_vp_y_state_action", act ); @@ -3809,7 +3809,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, // Translators: VP is short for 'vanishing point' _("State of VP in Z direction"), _("Toggle VP in Z direction between 'finite' and 'infinite' (=parallel)"), - INKSCAPE_ICON_PERSPECTIVE_PARALLEL, + INKSCAPE_ICON("perspective-parallel"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_object_set_data( holder, "box3d_vp_z_state_action", act ); @@ -4111,14 +4111,14 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho gtk_list_store_set( model, &iter, 0, _("Bezier"), 1, _("Create regular Bezier path"), - 2, INKSCAPE_ICON_PATH_MODE_BEZIER, + 2, INKSCAPE_ICON("path-mode-bezier"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Spiro"), 1, _("Create Spiro path"), - 2, INKSCAPE_ICON_PATH_MODE_SPIRO, + 2, INKSCAPE_ICON("path-mode-spiro"), -1 ); if (!tool_is_pencil) { @@ -4126,14 +4126,14 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho gtk_list_store_set( model, &iter, 0, _("Zigzag"), 1, _("Create a sequence of straight line segments"), - 2, INKSCAPE_ICON_PATH_MODE_POLYLINE, + 2, INKSCAPE_ICON("path-mode-polyline"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Paraxial"), 1, _("Create a sequence of paraxial line segments"), - 2, INKSCAPE_ICON_PATH_MODE_POLYLINE_PARAXIAL, + 2, INKSCAPE_ICON("path-mode-polyline-paraxial"), -1 ); } @@ -4429,91 +4429,91 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction gtk_list_store_set( model, &iter, 0, _("Move mode"), 1, _("Move objects in any direction"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_PUSH, + 2, INKSCAPE_ICON("object-tweak-push"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Move in/out mode"), 1, _("Move objects towards cursor; with Shift from cursor"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_ATTRACT, + 2, INKSCAPE_ICON("object-tweak-attract"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Move jitter mode"), 1, _("Move objects in random directions"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_RANDOMIZE, + 2, INKSCAPE_ICON("object-tweak-randomize"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Scale mode"), 1, _("Shrink objects, with Shift enlarge"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_SHRINK, + 2, INKSCAPE_ICON("object-tweak-shrink"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Rotate mode"), 1, _("Rotate objects, with Shift counterclockwise"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_ROTATE, + 2, INKSCAPE_ICON("object-tweak-rotate"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Duplicate/delete mode"), 1, _("Duplicate objects, with Shift delete"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_DUPLICATE, + 2, INKSCAPE_ICON("object-tweak-duplicate"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Push mode"), 1, _("Push parts of paths in any direction"), - 2, INKSCAPE_ICON_PATH_TWEAK_PUSH, + 2, INKSCAPE_ICON("path-tweak-push"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Shrink/grow mode"), 1, _("Shrink (inset) parts of paths; with Shift grow (outset)"), - 2, INKSCAPE_ICON_PATH_TWEAK_SHRINK, + 2, INKSCAPE_ICON("path-tweak-shrink"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Attract/repel mode"), 1, _("Attract parts of paths towards cursor; with Shift from cursor"), - 2, INKSCAPE_ICON_PATH_TWEAK_ATTRACT, + 2, INKSCAPE_ICON("path-tweak-attract"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Roughen mode"), 1, _("Roughen parts of paths"), - 2, INKSCAPE_ICON_PATH_TWEAK_ROUGHEN, + 2, INKSCAPE_ICON("path-tweak-roughen"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Color paint mode"), 1, _("Paint the tool's color upon selected objects"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_PAINT, + 2, INKSCAPE_ICON("object-tweak-paint"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Color jitter mode"), 1, _("Jitter the colors of selected objects"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_JITTER_COLOR, + 2, INKSCAPE_ICON("object-tweak-jitter-color"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Blur mode"), 1, _("Blur selected objects more; with Shift, blur less"), - 2, INKSCAPE_ICON_OBJECT_TWEAK_BLUR, + 2, INKSCAPE_ICON("object-tweak-blur"), -1 ); @@ -4638,7 +4638,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction InkToggleAction* act = ink_toggle_action_new( "TweakPressureAction", _("Pressure"), _("Use the pressure of the input device to alter the force of tweak action"), - INKSCAPE_ICON_DRAW_USE_PRESSURE, + INKSCAPE_ICON("draw-use-pressure"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_tweak_pressure_state_changed), NULL); @@ -4758,21 +4758,21 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction gtk_list_store_set( model, &iter, 0, _("Spray with copies"), 1, _("Spray copies of the initial selection"), - 2, INKSCAPE_ICON_SPRAY_COPY_MODE, + 2, INKSCAPE_ICON("spray-mode-copy"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Spray with clones"), 1, _("Spray clones of the initial selection"), - 2, INKSCAPE_ICON_SPRAY_CLONE_MODE, + 2, INKSCAPE_ICON("spray-mode-clone"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Spray single path"), 1, _("Spray objects in a single path"), - 2, INKSCAPE_ICON_SPRAY_UNION_MODE, + 2, INKSCAPE_ICON("spray-mode-union"), -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "SprayModeAction", _("Mode"), (""), NULL, GTK_TREE_MODEL(model) ); @@ -4821,7 +4821,7 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure"); g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); - + } { /* Rotation */ @@ -5338,7 +5338,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main InkToggleAction* act = ink_toggle_action_new( "TraceAction", _("Trace Background"), _("Trace the lightness of the background by the width of the pen (white - minimum width, black - maximum width)"), - INKSCAPE_ICON_DRAW_TRACE_BACKGROUND, + INKSCAPE_ICON("draw-trace-background"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/tracebackground", update_presets_list, holder); @@ -5351,7 +5351,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main InkToggleAction* act = ink_toggle_action_new( "PressureAction", _("Pressure"), _("Use the pressure of the input device to alter the width of the pen"), - INKSCAPE_ICON_DRAW_USE_PRESSURE, + INKSCAPE_ICON("draw-use-pressure"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/usepressure", update_presets_list, holder); @@ -5364,7 +5364,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main InkToggleAction* act = ink_toggle_action_new( "TiltAction", _("Tilt"), _("Use the tilt of the input device to alter the angle of the pen's nib"), - INKSCAPE_ICON_DRAW_USE_TILT, + INKSCAPE_ICON("draw-use-tilt"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/usetilt", update_presets_list, holder); @@ -5692,14 +5692,14 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, gtk_list_store_set( model, &iter, 0, _("Closed arc"), 1, _("Switch to segment (closed shape with two radii)"), - 2, INKSCAPE_ICON_DRAW_ELLIPSE_SEGMENT, + 2, INKSCAPE_ICON("draw-ellipse-segment"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Open Arc"), 1, _("Switch to arc (unclosed shape)"), - 2, INKSCAPE_ICON_DRAW_ELLIPSE_ARC, + 2, INKSCAPE_ICON("draw-ellipse-arc"), -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "ArcOpenAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); @@ -5723,7 +5723,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, InkAction* inky = ink_action_new( "ArcResetAction", _("Make whole"), _("Make the shape a whole ellipse, not arc or segment"), - INKSCAPE_ICON_DRAW_ELLIPSE_WHOLE, + INKSCAPE_ICON("draw-ellipse-whole"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_arctb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -6230,21 +6230,21 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio gtk_list_store_set( model, &iter, 0, _("Delete"), 1, _("Delete objects touched by the eraser"), - 2, INKSCAPE_ICON_DRAW_ERASER_DELETE_OBJECTS, + 2, INKSCAPE_ICON("draw-eraser-delete-objects"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Cut"), 1, _("Cut out from objects"), - 2, INKSCAPE_ICON_PATH_DIFFERENCE, + 2, INKSCAPE_ICON("path-difference"), -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); g_object_set( act, "short_label", _("Mode:"), NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); g_object_set_data( holder, "eraser_mode_action", act ); - + ege_select_one_action_set_appearance( act, "full" ); ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); @@ -7753,14 +7753,14 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions gtk_list_store_set( model, &iter, 0, _("Horizontal"), 1, _("Horizontal text"), - 2, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL, + 2, INKSCAPE_ICON("format-text-direction-horizontal"), -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Vertical"), 1, _("Vertical text"), - 2, INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL, + 2, INKSCAPE_ICON("format-text-direction-vertical"), -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "TextOrientationAction", // Name @@ -8281,7 +8281,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkToggleAction* act = ink_toggle_action_new( "ConnectorEditModeAction", _("EditMode"), _("Switch between connection point editing and connector drawing mode"), - INKSCAPE_ICON_CONNECTOR_EDIT, + INKSCAPE_ICON("connector-edit"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -8296,7 +8296,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkAction* inky = ink_action_new( "ConnectorAvoidAction", _("Avoid"), _("Make connectors avoid selected objects"), - INKSCAPE_ICON_CONNECTOR_AVOID, + INKSCAPE_ICON("connector-avoid"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_path_set_avoid), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -8306,7 +8306,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkAction* inky = ink_action_new( "ConnectorIgnoreAction", _("Ignore"), _("Make connectors ignore selected objects"), - INKSCAPE_ICON_CONNECTOR_IGNORE, + INKSCAPE_ICON("connector-ignore"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_path_set_ignore), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -8317,7 +8317,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkToggleAction* act = ink_toggle_action_new( "ConnectorOrthogonalAction", _("Orthogonal"), _("Make connector orthogonal or polyline"), - INKSCAPE_ICON_CONNECTOR_ORTHOGONAL, + INKSCAPE_ICON("connector-orthogonal"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -8355,7 +8355,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkAction* inky = ink_action_new( "ConnectorGraphAction", _("Graph"), _("Nicely arrange selected connector network"), - INKSCAPE_ICON_DISTRIBUTE_GRAPH, + INKSCAPE_ICON("distribute-graph"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_graph_layout), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -8378,7 +8378,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkToggleAction* act = ink_toggle_action_new( "ConnectorDirectedAction", _("Downwards"), _("Make connectors with end-markers (arrows) point downwards"), - INKSCAPE_ICON_DISTRIBUTE_GRAPH_DIRECTED, + INKSCAPE_ICON("distribute-graph-directed"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -8394,7 +8394,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkToggleAction* act = ink_toggle_action_new( "ConnectorOverlapAction", _("Remove overlaps"), _("Do not allow overlapping shapes"), - INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS, + INKSCAPE_ICON("distribute-remove-overlaps"), Inkscape::ICON_SIZE_DECORATION ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -8410,7 +8410,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkAction* inky = ink_action_new( "ConnectorNewConnPointAction", _("New connection point"), _("Add a new connection point to the currently selected item"), - INKSCAPE_ICON_CONNECTOR_NEW_CONNPOINT, + INKSCAPE_ICON("connector-new-connpoint"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_new_connection_point), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -8422,7 +8422,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA InkAction* inky = ink_action_new( "ConnectorRemoveConnPointAction", _("Remove connection point"), _("Remove the currently selected connection point"), - INKSCAPE_ICON_CONNECTOR_REMOVE_CONNPOINT, + INKSCAPE_ICON("connector-remove-connpoint"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_remove_connection_point), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); -- cgit v1.2.3 From ba9bc8cfbe07a68a5e5aff7ed708f25c72ccca83 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 14 Jul 2011 21:21:46 -0700 Subject: Fixed issue with copy ctor in 2geom's BezierCurve. (bzr r10453) --- src/2geom/bezier-curve.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/2geom/bezier-curve.h b/src/2geom/bezier-curve.h index d13ff8321..ff80b739b 100644 --- a/src/2geom/bezier-curve.h +++ b/src/2geom/bezier-curve.h @@ -46,8 +46,8 @@ namespace Geom class BezierCurve : public Curve { protected: D2 inner; - BezierCurve() {} - BezierCurve(BezierCurve const &b) : inner(b.inner) {} + BezierCurve() : Curve() {} + BezierCurve(BezierCurve const &b) : Curve(b), inner(b.inner) {} BezierCurve(D2 const &b) : inner(b) {} BezierCurve(Bezier const &x, Bezier const &y) : inner(x, y) {} BezierCurve(std::vector const &pts); -- cgit v1.2.3 From 8411c3272ce2cf9230841c86d6545502216ec0b8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 14 Jul 2011 21:35:42 -0700 Subject: Address issues with GtkRuleMetric const warnings. (bzr r10454) --- src/widgets/ruler.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index 60e460cda..7baa0a172 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -1,5 +1,3 @@ -#define __SP_RULER_C__ - /* * Customized ruler class for inkscape * @@ -8,8 +6,9 @@ * Frank Felfe * bulia byak * Diederik van Lierop + * Jon A. Cruz * - * Copyright (C) 1999-2008 authors + * Copyright (C) 1999-2011 authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -377,26 +376,19 @@ sp_ruler_common_draw_ticks (GtkRuler *ruler) } } -//TODO: warning: deprecated conversion from string constant to ‘gchar*’ -// -//Turn out to be warnings that we should probably leave in place. The -// pointers/types used need to be read-only. So until we correct the using -// code, those warnings are actually desired. They say "Hey! Fix this". We -// definitely don't want to hide/ignore them. --JonCruz - -// TODO address const/non-const gchar* issue: +// Note: const casts are due to GtkRuler being const-broken and not scheduled for any more fixes. /// Ruler metrics. static GtkRulerMetric const sp_ruler_metrics[] = { // NOTE: the order of records in this struct must correspond to the SPMetric enum. - {"NONE", "", 1, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"millimeters", "mm", PX_PER_MM, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"centimeters", "cm", PX_PER_CM, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"inches", "in", PX_PER_IN, { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 }, { 1, 2, 4, 8, 16 }}, - {"feet", "ft", PX_PER_FT, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"points", "pt", PX_PER_PT, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"picas", "pc", PX_PER_PC, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"pixels", "px", PX_PER_PX, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, - {"meters", "m", PX_PER_M, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("NONE"), const_cast(""), 1, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("millimeters"), const_cast("mm"), PX_PER_MM, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("centimeters"), const_cast("cm"), PX_PER_CM, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("inches"), const_cast("in"), PX_PER_IN, { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 }, { 1, 2, 4, 8, 16 }}, + {const_cast("feet"), const_cast("ft"), PX_PER_FT, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("points"), const_cast("pt"), PX_PER_PT, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("picas"), const_cast("pc"), PX_PER_PC, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("pixels"), const_cast("px"), PX_PER_PX, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, + {const_cast("meters"), const_cast("m"), PX_PER_M, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, }; void -- cgit v1.2.3 From 35bbccbb48ee920cd53a6fa11344958140069e4d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 15 Jul 2011 07:34:06 +0200 Subject: Remove BezierCurve copy constructor - it's equivalent the default one (bzr r10455) --- src/2geom/bezier-curve.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/2geom/bezier-curve.h b/src/2geom/bezier-curve.h index ff80b739b..c0224e850 100644 --- a/src/2geom/bezier-curve.h +++ b/src/2geom/bezier-curve.h @@ -46,8 +46,7 @@ namespace Geom class BezierCurve : public Curve { protected: D2 inner; - BezierCurve() : Curve() {} - BezierCurve(BezierCurve const &b) : Curve(b), inner(b.inner) {} + BezierCurve() {} BezierCurve(D2 const &b) : inner(b) {} BezierCurve(Bezier const &x, Bezier const &y) : inner(x, y) {} BezierCurve(std::vector const &pts); -- cgit v1.2.3 From ea8b6e71c525667e16f9449d1e90d9e414122f80 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 15 Jul 2011 19:41:49 +0200 Subject: Fix icon toggler breakage after the icon-names.h change. Patch from ~suv. (bzr r10456) --- src/ui/dialog/layers.cpp | 4 ++-- src/ui/widget/layer-selector.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 3863dafc5..340a1921c 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -582,7 +582,7 @@ LayersPanel::LayersPanel() : _tree.set_headers_visible(false); Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-visible")) ); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1; eyeRenderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) ); @@ -593,7 +593,7 @@ LayersPanel::LayersPanel() : } Inkscape::UI::Widget::ImageToggler * renderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-locked")) ); + INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-unlocked")) ); int lockedColNum = _tree.append_column("lock", *renderer) - 1; renderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) ); diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index e254b8599..de482fb74 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -95,7 +95,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) AlternateIcons *label; label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, - INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-visible"))); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden"))); _visibility_toggle.add(*label); _visibility_toggle.signal_toggled().connect( sigc::compose( @@ -116,7 +116,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING); label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, - INKSCAPE_ICON("object-unlocked"), INKSCAPE_ICON("object-unlocked"))); + INKSCAPE_ICON("object-unlocked"), INKSCAPE_ICON("object-locked"))); _lock_toggle.add(*label); _lock_toggle.signal_toggled().connect( sigc::compose( -- cgit v1.2.3 From f412e210814555e34cd2a6d1bb86cd2c153d60a0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 16 Jul 2011 00:51:02 +0200 Subject: Fix scaling error when snapping, caused by rev. #10326 Fixed bugs: - https://launchpad.net/bugs/808558 (bzr r10458) --- src/snap.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/snap.cpp b/src/snap.cpp index 3e79a221e..d556a751a 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -746,6 +746,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // std::cout << std::endl; bool first_free_snap = true; + for (std::vector::const_iterator i = points.begin(); i != points.end(); i++) { /* Snap it */ @@ -850,6 +851,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( result[0] = result[1]; } } + // Compare the resulting scaling with the desired scaling Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE if (scale_metric[0] == NR_HUGE || scale_metric[1] == NR_HUGE) { @@ -930,10 +932,10 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( Geom::Coord best_metric; if (transformation_type == SCALE) { - // When scaling, don't ever exit with one of scaling components set to Geom::infinity() + // When scaling, don't ever exit with one of scaling components uninitialized for (int index = 0; index < 2; index++) { - if (best_transformation[index] == Geom::infinity()) { - if (uniform && best_transformation[1-index] < Geom::infinity()) { + if (fabs(best_transformation[index]) >= 1e12) { + if (uniform && fabs(best_transformation[1-index]) < 1e12) { best_transformation[index] = best_transformation[1-index]; } else { best_transformation[index] = transformation[index]; -- cgit v1.2.3 From 662d4502604f027a0d0fd2b1f8613de8e0d04668 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jul 2011 23:53:24 +1000 Subject: fix for building with cmake and building without lcms works again. (bzr r10459) --- src/2geom/CMakeLists.txt | 11 ++++++++--- src/display/sp-canvas.cpp | 4 ++-- src/libnr/CMakeLists.txt | 10 ---------- 3 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index bc3f64bdc..dc261b5bd 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -27,6 +27,7 @@ set(2geom_SRC point.cpp poly.cpp quadtree.cpp + rect.cpp # recursive-bezier-intersection.cpp region.cpp sbasis-2d.cpp @@ -43,6 +44,7 @@ set(2geom_SRC svg-path-parser.cpp svg-path.cpp sweep.cpp + toposweep.cpp transforms.cpp utils.cpp @@ -76,10 +78,14 @@ set(2geom_SRC elliptical-arc.h exception.h forward.h + generic-interval.h + generic-rect.h geom.h hvlinesegment.h + int-interval.h + int-point.h + int-rect.h interval.h - isnan.h line.h linear.h math-utils.h @@ -89,7 +95,6 @@ set(2geom_SRC path.h pathvector.h piecewise.h - point-l.h point-ops.h point.h poly.h @@ -106,11 +111,11 @@ set(2geom_SRC sbasis.h shape.h solver.h - sturm.h svg-elliptical-arc.h svg-path-parser.h svg-path.h sweep.h + toposweep.h transforms.h utils.h diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index d7f34969f..71f608118 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1120,9 +1120,9 @@ sp_canvas_destroy (GtkObject *object) } shutdown_transients (canvas); - +#if ENABLE_LCMS canvas->cms_key.~ustring(); - +#endif if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); } diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index b83358ae0..8a31e20db 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -8,7 +8,6 @@ set(nr_SRC nr-rect-l.cpp # nr-rotate-fns-test.cpp #nr-translate-test.cpp - nr-types.cpp # nr-types-test.cpp nr-values.cpp # testnr.cpp @@ -19,24 +18,15 @@ set(nr_SRC # in-svg-plane-test.h in-svg-plane.h nr-convert2geom.h - nr-coord.h - nr-dim2.h nr-forward.h - nr-i-coord.h nr-macros.h nr-object.h # nr-point-fns-test.h nr-point-fns.h - nr-point-l.h - nr-point-ops.h - nr-point.h nr-rect-l.h - nr-rect-ops.h nr-rect.h - nr-render.h # nr-translate-test.h # nr-types-test.h - nr-types.h nr-values.h ) -- cgit v1.2.3 From 2be2cf32db0668dc64512a98f6c2394152bd10cc Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 16 Jul 2011 00:42:39 -0700 Subject: Cleanup of oudated/redundant SP_ITEM() macro use. (bzr r10461) --- src/arc-context.cpp | 2 - src/box3d.cpp | 6 +- src/desktop.cpp | 15 +-- src/desktop.h | 3 + src/dialogs/clonetiler.cpp | 13 +- src/extension/internal/cairo-png-out.cpp | 4 +- src/extension/internal/cairo-ps-out.cpp | 2 +- src/extension/internal/cairo-renderer-pdf-out.cpp | 2 +- src/extension/internal/cairo-renderer.cpp | 2 +- src/extension/internal/latex-pstricks-out.cpp | 28 ++--- src/extension/internal/latex-text-renderer.cpp | 4 +- src/flood-context.cpp | 7 +- src/helper/pixbuf-ops.cpp | 4 +- src/helper/png-write.cpp | 6 +- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/lpe-lattice.cpp | 3 +- src/live_effects/lpe-mirror_symmetry.cpp | 5 +- src/live_effects/lpegroupbbox.cpp | 6 +- src/marker.cpp | 36 ++---- src/object-snapper.cpp | 10 +- src/path-chemistry.cpp | 10 +- src/print.cpp | 5 +- src/sp-conn-end-pair.cpp | 10 +- src/sp-conn-end.cpp | 7 +- src/sp-flowregion.cpp | 20 ++-- src/sp-flowtext.cpp | 11 +- src/sp-image.cpp | 5 +- src/sp-item-group.cpp | 16 ++- src/sp-item.cpp | 23 ++-- src/sp-lpe-item.cpp | 2 +- src/sp-offset.cpp | 15 +-- src/sp-path.cpp | 2 +- src/sp-rect.cpp | 26 ++-- src/sp-root.cpp | 8 +- src/sp-shape.cpp | 9 +- src/sp-switch.cpp | 9 +- src/sp-symbol.cpp | 139 +++++++--------------- src/spray-context.cpp | 2 +- src/svg-view.cpp | 8 +- src/text-chemistry.cpp | 9 +- src/text-context.cpp | 4 +- src/text-editing.cpp | 2 +- src/tweak-context.cpp | 2 +- src/ui/dialog/icon-preview.cpp | 9 +- src/ui/tool/path-manipulator.cpp | 4 +- src/widgets/icon.cpp | 10 +- src/widgets/stroke-style.cpp | 18 +-- 47 files changed, 238 insertions(+), 307 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 6e5b935f1..32a0bab40 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -14,8 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#define __SP_ARC_CONTEXT_C__ - #ifdef HAVE_CONFIG_H # include #endif diff --git a/src/box3d.cpp b/src/box3d.cpp index 1a9c26b26..efd4054e1 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -388,7 +388,7 @@ box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) { if (!box3d_get_perspective(box)) { return Geom::Point (Geom::infinity(), Geom::infinity()); } - Geom::Affine const i2d (SP_ITEM(box)->i2d_affine ()); + Geom::Affine const i2d(box->i2d_affine ()); if (item_coords) { return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_corner).affine() * i2d.inverse(); } else { @@ -412,7 +412,7 @@ box3d_get_center_screen (SPBox3D *box) { if (!box3d_get_perspective(box)) { return Geom::Point (Geom::infinity(), Geom::infinity()); } - Geom::Affine const i2d (SP_ITEM(box)->i2d_affine ()); + Geom::Affine const i2d(box->i2d_affine ()); return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_center).affine() * i2d.inverse(); } @@ -1180,7 +1180,7 @@ box3d_set_z_orders (SPBox3D *box) { for (unsigned int i = 0; i < 6; ++i) { side = sides.find(box->z_orders[i]); if (side != sides.end()) { - SP_ITEM((*side).second)->lowerToBottom(); + ((*side).second)->lowerToBottom(); } } } diff --git a/src/desktop.cpp b/src/desktop.cpp index 4ff2716ca..7034e85b6 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -285,7 +285,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); - NRArenaItem *ai = SP_ITEM(document->getRoot())->invoke_show( + NRArenaItem *ai = document->getRoot()->invoke_show( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); @@ -402,7 +402,7 @@ void SPDesktop::destroy() } if (drawing) { - SP_ITEM(doc()->getRoot())->invoke_hide(dkey); + doc()->getRoot()->invoke_hide(dkey); drawing = NULL; } @@ -541,8 +541,9 @@ void SPDesktop::toggleLayerSolo(SPObject *object) { } - if ( SP_ITEM(object)->isHidden() ) { - SP_ITEM(object)->setHidden(false); + SPItem *item = SP_ITEM(object); + if ( item->isHidden() ) { + item->setHidden(false); } for ( std::vector::iterator it = layers.begin(); it != layers.end(); ++it ) { @@ -1131,7 +1132,7 @@ void SPDesktop::zoom_drawing() { g_return_if_fail (doc() != NULL); - SPItem *docitem = SP_ITEM(doc()->getRoot()); + SPItem *docitem = doc()->getRoot(); g_return_if_fail (docitem != NULL); Geom::OptRect d = docitem->getBboxDesktop(); @@ -1536,7 +1537,7 @@ SPDesktop::setDocument (SPDocument *doc) { if (this->doc() && doc) { namedview->hide(this); - SP_ITEM(this->doc()->getRoot())->invoke_hide(dkey); + this->doc()->getRoot()->invoke_hide(dkey); } if (_layer_hierarchy) { @@ -1567,7 +1568,7 @@ SPDesktop::setDocument (SPDocument *doc) _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); number = namedview->getViewCount(); - ai = SP_ITEM(doc->getRoot())->invoke_show( + ai = doc->getRoot()->invoke_show( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/desktop.h b/src/desktop.h index ed0a99dea..a7264e4aa 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -228,8 +228,11 @@ public: Inkscape::UI::Widget::Dock* getDock() { return _widget->getDock(); } void set_active (bool new_active); + + // TODO look into making these return a more specific subclass: SPObject *currentRoot() const; SPObject *currentLayer() const; + void setCurrentLayer(SPObject *object); void toggleLayerSolo(SPObject *object); SPObject *layerForObject(SPObject *object); diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index d84038db8..194f341e1 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -853,7 +853,7 @@ static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *origin /* Create ArenaItem and set transform */ trace_visionkey = SPItem::display_key_new(1); trace_doc = doc; - trace_root = SP_ITEM(trace_doc->getRoot())->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); + trace_root = trace_doc->getRoot()->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); // hide the (current) original and any tiled clones, we only want to pick the background original->invoke_hide(trace_visionkey); @@ -907,7 +907,7 @@ static guint32 clonetiler_trace_pick(Geom::Rect box) static void clonetiler_trace_finish() { if (trace_doc) { - SP_ITEM(trace_doc->getRoot())->invoke_hide(trace_visionkey); + trace_doc->getRoot()->invoke_hide(trace_visionkey); } if (trace_arena) { ((NRObject *) trace_arena)->unreference(); @@ -1067,6 +1067,7 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) gdk_window_process_all_updates(); SPObject *obj = selection->singleItem(); + SPItem *item = SP_IS_ITEM(obj) ? SP_ITEM(obj) : 0; Inkscape::XML::Node *obj_repr = obj->getRepr(); const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id")); SPObject *parent = obj->parent; @@ -1156,7 +1157,7 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) double gamma_picked = prefs->getDoubleLimited(prefs_path + "gamma_picked", 0, -10, 10); if (dotrace) { - clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj)); + clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, item); } Geom::Point center; @@ -1185,14 +1186,14 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) bool prefs_bbox = prefs->getBool("/tools/bounding_box", false); SPItem::BBoxType bbox_type = ( prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX ); - Geom::OptRect r = SP_ITEM(obj)->getBounds(SP_ITEM(obj)->i2doc_affine(), + Geom::OptRect r = item->getBounds(item->i2doc_affine(), bbox_type); if (r) { w = r->dimensions()[Geom::X]; h = r->dimensions()[Geom::Y]; x0 = r->min()[Geom::X]; y0 = r->min()[Geom::Y]; - center = desktop->dt2doc(SP_ITEM(obj)->getCenter()); + center = desktop->dt2doc(item->getCenter()); sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[Geom::X]); sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[Geom::Y]); @@ -1408,7 +1409,7 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) Geom::Point new_center; bool center_set = false; if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) { - new_center = desktop->dt2doc(SP_ITEM(obj)->getCenter()) * t; + new_center = desktop->dt2doc(item->getCenter()) * t; center_set = true; } diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index b30e22e7e..f741c9f39 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -57,8 +57,8 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) doc->ensureUpToDate(); /* Start */ - /* Create new arena */ - SPItem *base = SP_ITEM(doc->getRoot()); + // Create new arena + SPItem *base = doc->getRoot(); NRArena *arena = NRArena::create(); unsigned dkey = SPItem::display_key_new(1); NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index a5b7b3237..7fdfaf8df 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -79,7 +79,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l } else { // we want to export the entire document from root - base = SP_ITEM(doc->getRoot()); + base = doc->getRoot(); pageBoundingBox = !exportDrawing; } diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index cdd9647e2..5d7c82bff 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -73,7 +73,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int } else { // we want to export the entire document from root - base = SP_ITEM(doc->getRoot()); + base = doc->getRoot(); pageBoundingBox = !exportDrawing; } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 1e550f7d1..3b16df96c 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -624,7 +624,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page g_assert( ctx != NULL ); if (!base) { - base = SP_ITEM(doc->getRoot()); + base = doc->getRoot(); } NRRect d; diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 1477d5daf..376db7ee3 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -20,7 +20,7 @@ #include "extension/db.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" - +#include "sp-root.h" @@ -39,36 +39,30 @@ LatexOutput::~LatexOutput (void) //The destructor return; } -bool -LatexOutput::check (Inkscape::Extension::Extension * module) +bool LatexOutput::check(Inkscape::Extension::Extension * /*module*/) { - if (NULL == Inkscape::Extension::db.get("org.inkscape.print.latex")) - return FALSE; - return TRUE; + bool result = Inkscape::Extension::db.get("org.inkscape.print.latex") != NULL; + return result; } -void -LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar const *filename) +void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename) { - Inkscape::Extension::Print *mod; SPPrintContext context; - const gchar * oldconst; - gchar * oldoutput; - unsigned int ret; + unsigned int ret = 0; doc->ensureUpToDate(); - mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); - oldconst = mod->get_param_string("destination"); - oldoutput = g_strdup(oldconst); + Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); + const gchar * oldconst = mod->get_param_string("destination"); + gchar * oldoutput = g_strdup(oldconst); mod->set_param_string("destination", filename); /* Start */ context.module = mod; /* fixme: This has to go into module constructor somehow */ - /* Create new arena */ - mod->base = SP_ITEM(doc->getRoot()); + // Create new arena + mod->base = doc->getRoot(); mod->arena = NRArena::create(); mod->dkey = SPItem::display_key_new (1); mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 5d9fec905..818f39f68 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -70,7 +70,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename, } else { // we want to export the entire document from root - base = SP_ITEM(doc->getRoot()); + base = doc->getRoot(); pageBoundingBox = !exportDrawing; } @@ -585,7 +585,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * // The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument ! if (!base) { - base = SP_ITEM(doc->getRoot()); + base = doc->getRoot(); } Geom::OptRect d; diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 90278ac95..16a2e6ea7 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -783,8 +783,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even document->ensureUpToDate(); - SPItem *document_root = SP_ITEM(document->getRoot()); - Geom::OptRect bbox = document_root->getBounds(Geom::identity()); + Geom::OptRect bbox = document->getRoot()->getBounds(Geom::identity()); if (!bbox) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Area is not bounded, cannot fill.")); @@ -812,7 +811,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even Geom::Affine affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = SP_ITEM(document->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = document->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -851,7 +850,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even cairo_surface_destroy(s); // Hide items - SP_ITEM(document->getRoot())->invoke_hide(dkey); + document->getRoot()->invoke_hide(dkey); nr_object_unref((NRObject *) arena); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index e1ced31b4..2e513afb2 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -132,7 +132,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, Geom::Affine affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = SP_ITEM(doc->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = doc->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -179,7 +179,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %lld.", size); cairo_surface_destroy(surface); } - SP_ITEM(doc->getRoot())->invoke_hide(dkey); + doc->getRoot()->invoke_hide(dkey); nr_object_unref((NRObject *) arena); // gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 5a20ac363..a23c8fd43 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -466,8 +466,8 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, nr_arena_set_renderoffscreen(arena); unsigned const dkey = SPItem::display_key_new(1); - /* Create ArenaItems and set transform */ - ebp.root = SP_ITEM(doc->getRoot())->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); + // Create ArenaItems and set transform + ebp.root = doc->getRoot()->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine); // We show all and then hide all items we don't want, instead of showing only requested items, @@ -490,7 +490,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, } // Hide items, this releases arenaitem - SP_ITEM(doc->getRoot())->invoke_hide(dkey); + doc->getRoot()->invoke_hide(dkey); /* Free arena */ nr_object_unref((NRObject *) arena); diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 522b3cdc6..b025debb3 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -517,7 +517,7 @@ void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &p for (unsigned i=0; istyle->stroke_width.computed); + stroke_widths.push_back(lpeitem->style->stroke_width.computed); } } } diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 50ecdf04b..473469c8a 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_LATTICE_CPP /** \file * LPE implementation @@ -283,7 +282,7 @@ LPELattice::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop) c->lineto(grid_point3); // TODO: factor this out (and remove the #include of desktop.h above) - SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, c, SP_ITEM(lpeitem), 0x009000ff); + SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, c, lpeitem, 0x009000ff); Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0); lpeitem->lpe_helperpaths.push_back(tmpitem); diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index dec8c9216..e64cd0905 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -45,9 +45,8 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) { using namespace Geom; - SPItem *item = SP_ITEM(lpeitem); - Geom::Affine t = item->i2d_affine(); - Geom::Rect bbox = *item->getBounds(t); // fixme: what happens if getBounds does not return a valid rect? + Geom::Affine t = lpeitem->i2d_affine(); + Geom::Rect bbox = *lpeitem->getBounds(t); // fixme: what happens if getBounds does not return a valid rect? Point A(bbox.left(), bbox.bottom()); Point B(bbox.left(), bbox.top()); diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 2678509a4..382231378 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -26,17 +26,15 @@ void GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) { // Get item bounding box - SPItem* item = SP_ITEM(lpeitem); - Geom::Affine transform; if (absolute) { - transform = item->i2doc_affine(); + transform = lpeitem->i2doc_affine(); } else { transform = Geom::identity(); } - Geom::OptRect bbox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = lpeitem->getBounds(transform, SPItem::GEOMETRIC_BBOX); if (bbox) { boundingbox_X = (*bbox)[Geom::X]; boundingbox_Y = (*bbox)[Geom::Y]; diff --git a/src/marker.cpp b/src/marker.cpp index 2354d686c..d3fa83ed6 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -191,14 +191,9 @@ sp_marker_release (SPObject *object) * SP_ATTR_VIEWBOX * SP_ATTR_PRESERVEASPECTRATIO */ -static void -sp_marker_set (SPObject *object, unsigned int key, const gchar *value) +static void sp_marker_set(SPObject *object, unsigned int key, const gchar *value) { - SPItem *item; - SPMarker *marker; - - item = SP_ITEM (object); - marker = SP_MARKER (object); + SPMarker *marker = SP_MARKER(object); switch (key) { case SP_ATTR_MARKERUNITS: @@ -339,18 +334,12 @@ sp_marker_set (SPObject *object, unsigned int key, const gchar *value) * Updates when its attributes have changed. Takes care of setting up * transformations and viewBoxes. */ -static void -sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) +static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) { - SPItem *item; - SPMarker *marker; + SPMarker *marker = SP_MARKER(object); SPItemCtx rctx; - Geom::Rect vb; + Geom::Rect vb; double x, y, width, height; - SPMarkerView *v; - - item = SP_ITEM (object); - marker = SP_MARKER (object); /* fixme: We have to set up clip here too */ @@ -450,19 +439,20 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) rctx.i2vp = Geom::identity(); } - /* And invoke parent method */ - if (((SPObjectClass *) (parent_class))->update) + // And invoke parent method + if (((SPObjectClass *) (parent_class))->update) { ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + } - /* As last step set additional transform of arena group */ - for (v = marker->views; v != NULL; v = v->next) { - for (unsigned i = 0 ; i < v->items.size() ; i++) { + // As last step set additional transform of arena group + for (SPMarkerView *v = marker->views; v != NULL; v = v->next) { + for (unsigned i = 0 ; i < v->items.size() ; i++) { if (v->items[i]) { Geom::Affine tmp = marker->c2p; nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &tmp); } - } - } + } + } } /** diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 1944f7ffa..cb0935891 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -483,9 +483,15 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, * manually when applicable. * */ if (node_tool_active) { - SPCurve *curve = curve_for_item(SP_ITEM(selected_path)); + // TODO fix the function to be const correct: + SPCurve *curve = curve_for_item(const_cast(selected_path)); if (curve) { - Geom::PathVector *pathv = pathvector_for_curve(SP_ITEM(selected_path), curve, true, true, Geom::identity(), Geom::identity()); // We will get our own copy of the path, which must be freed at some point + Geom::PathVector *pathv = pathvector_for_curve(const_cast(selected_path), + curve, + true, + true, + Geom::identity(), + Geom::identity()); // We will get our own copy of the path, which must be freed at some point _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pathv, SNAPTARGET_PATH, Geom::OptRect(), true)); curve->unref(); } diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 607d0ab6a..bd72632b2 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -205,14 +205,16 @@ sp_selected_path_break_apart(SPDesktop *desktop) SPItem *item = (SPItem *) items->data; - if (!SP_IS_PATH(item)) + if (!SP_IS_PATH(item)) { continue; + } SPPath *path = SP_PATH(item); - SPCurve *curve = sp_path_get_curve_for_edit(SP_PATH(path)); - if (curve == NULL) + SPCurve *curve = sp_path_get_curve_for_edit(path); + if (curve == NULL) { continue; + } did = true; @@ -225,7 +227,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) // XML Tree being used directly here while it shouldn't be... gchar *path_effect = g_strdup(item->getRepr()->attribute("inkscape:path-effect")); - Geom::PathVector apv = curve->get_pathvector() * SP_ITEM(path)->transform; + Geom::PathVector apv = curve->get_pathvector() * path->transform; curve->unref(); diff --git a/src/print.cpp b/src/print.cpp index 0774f5751..1ee58a3e6 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -21,6 +21,7 @@ #include "extension/print.h" #include "extension/system.h" #include "print.h" +#include "sp-root.h" #include "ui/dialog/print.h" @@ -90,7 +91,7 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) doc->ensureUpToDate(); // Build arena - SPItem *base = SP_ITEM(doc->getRoot()); + SPItem *base = doc->getRoot(); NRArena *arena = NRArena::create(); unsigned int dkey = SPItem::display_key_new(1); // TODO investigate why we are grabbing root and then ignoring it. @@ -126,7 +127,7 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename) context.module = mod; /* fixme: This has to go into module constructor somehow */ /* Create new arena */ - mod->base = SP_ITEM(doc->getRoot()); + mod->base = doc->getRoot(); mod->arena = NRArena::create(); mod->dkey = SPItem::display_key_new(1); mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index e22145425..00b9ab0e9 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -212,12 +212,12 @@ SPConnEndPair::getAttachedItems(SPItem *h2attItem[2]) const { } } -void -SPConnEndPair::getEndpoints(Geom::Point endPts[]) const { +void SPConnEndPair::getEndpoints(Geom::Point endPts[]) const +{ SPCurve *curve = _path->original_curve ? _path->original_curve : _path->curve; - SPItem *h2attItem[2]; + SPItem *h2attItem[2] = {0}; getAttachedItems(h2attItem); - Geom::Affine i2d = SP_ITEM(_path)->i2doc_affine(); + Geom::Affine i2d = _path->i2doc_affine(); for (unsigned h = 0; h < 2; ++h) { if ( h2attItem[h] ) { @@ -407,7 +407,7 @@ SPConnEndPair::reroutePathFromLibavoid(void) recreateCurve( curve, _connRef, _connCurvature ); - Geom::Affine doc2item = SP_ITEM(_path)->i2doc_affine().inverse(); + Geom::Affine doc2item = _path->i2doc_affine().inverse(); curve->transform(doc2item); return true; diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 538638d7a..71b4f45a7 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -141,12 +141,11 @@ sp_conn_get_route_and_redraw(SPPath *const path, return; } - SPItem *h2attItem[2]; + SPItem *h2attItem[2] = {0}; path->connEndPair.getAttachedItems(h2attItem); - SPItem const *const path_item = SP_ITEM(path); - SPObject const *const ancestor = get_nearest_common_ancestor(path_item, h2attItem); - Geom::Affine const path2anc(i2anc_affine(path_item, ancestor)); + SPObject const *const ancestor = get_nearest_common_ancestor(path, h2attItem); + Geom::Affine const path2anc(i2anc_affine(path, ancestor)); // Set sensible values incase there the connector ends are not // attached to any shapes. diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 46690167f..ebcfcdc2f 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -116,15 +116,13 @@ sp_flowregion_dispose(GObject *object) group->computed.~vector(); } -static void -sp_flowregion_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void sp_flowregion_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPItem *item; - - item = SP_ITEM (object); + SP_ITEM(object); - if (((SPObjectClass *) (flowregion_parent_class))->child_added) + if (((SPObjectClass *) (flowregion_parent_class))->child_added) { (* ((SPObjectClass *) (flowregion_parent_class))->child_added) (object, child, ref); + } object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -332,15 +330,13 @@ sp_flowregionexclude_dispose(GObject *object) } } -static void -sp_flowregionexclude_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void sp_flowregionexclude_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPItem *item; - - item = SP_ITEM (object); + SP_ITEM(object); - if (((SPObjectClass *) (flowregionexclude_parent_class))->child_added) + if (((SPObjectClass *) (flowregionexclude_parent_class))->child_added) { (* ((SPObjectClass *) (flowregionexclude_parent_class))->child_added) (object, child, ref); + } object->requestModified(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index ab545919f..694e21dbd 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -554,12 +554,11 @@ void SPFlowtext::_clearFlow(NRArenaGroup *in_arena) } } -Inkscape::XML::Node * -SPFlowtext::getAsText() +Inkscape::XML::Node *SPFlowtext::getAsText() { - if (!this->layout.outputExists()) return NULL; - - SPItem *item = SP_ITEM(this); + if (!this->layout.outputExists()) { + return NULL; + } Inkscape::XML::Document *xml_doc = this->document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:text"); @@ -588,7 +587,7 @@ SPFlowtext::getAsText() // set x,y attributes only when we need to bool set_x = false; bool set_y = false; - if (!item->transform.isIdentity()) { + if (!this->transform.isIdentity()) { set_x = set_y = true; } else { Inkscape::Text::Layout::iterator it_chunk_start = it; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 791e88b39..c82c6fed4 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1017,7 +1017,7 @@ static void sp_image_modified( SPObject *object, unsigned int flags ) } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM (image)->display; v != NULL; v = v->next) { + for (SPItemView *v = image->display; v != NULL; v = v->next) { nr_arena_image_set_style (NR_ARENA_IMAGE (v->arenaitem), object->style); } } @@ -1273,8 +1273,7 @@ sp_image_update_arenaitem (SPImage *image, NRArenaImage *ai) nr_arena_image_set_clipbox(ai, image->clipbox); } -static void -sp_image_update_canvas_image (SPImage *image) +static void sp_image_update_canvas_image(SPImage *image) { SPItem *item = SP_ITEM(image); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 8d38fee07..491b2a62a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -169,17 +169,15 @@ sp_group_dispose(GObject *object) delete SP_GROUP(object)->group; } -static void -sp_group_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void sp_group_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPItem *item; - - item = SP_ITEM (object); + SPGroup *group = SP_GROUP(object); - if (((SPObjectClass *) (parent_class))->child_added) + if (((SPObjectClass *) (parent_class))->child_added) { (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref); + } - SP_GROUP(object)->group->onChildAdded(child); + group->group->onChildAdded(child); } /* fixme: hide (Lauris) */ @@ -347,7 +345,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) SPRoot *root = doc->getRoot(); SPObject *defs = root->defs; - SPItem *gitem = SP_ITEM (group); + SPItem *gitem = group; Inkscape::XML::Node *grepr = gitem->getRepr(); g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch")); @@ -360,7 +358,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) if (SP_IS_BOX3D(gitem)) { group = box3d_convert_to_group(SP_BOX3D(gitem)); - gitem = SP_ITEM(group); + gitem = group; } sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(group), false); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 8e1a4d92c..43fe2c227 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -638,19 +638,19 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPObject *child; SPItem *item = SP_ITEM(object); // in the case of SP_OBJECT_WRITE_BUILD, the item should always be newly created, // so we need to add any children from the underlying object to the new repr if (flags & SP_OBJECT_WRITE_BUILD) { - Inkscape::XML::Node *crepr; - GSList *l; - l = NULL; - for (child = object->firstChild(); child != NULL; child = child->next ) { - if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; - crepr = child->updateRepr(xml_doc, NULL, flags); - if (crepr) l = g_slist_prepend (l, crepr); + GSList *l = NULL; + for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + if (crepr) { + l = g_slist_prepend (l, crepr); + } + } } while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@ -658,9 +658,10 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML l = g_slist_remove (l, l->data); } } else { - for (child = object->firstChild() ; child != NULL; child = child->next ) { - if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; - child->updateRepr(flags); + for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + child->updateRepr(flags); + } } } diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 7d42400fa..d67afce8e 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -669,7 +669,7 @@ void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt) { Inkscape::LivePathEffect::LPEObjectReference *lperef = sp_lpe_item_get_current_lpereference(lpeitem); if (lperef && lperef->lpeobject && lperef->lpeobject->get_lpe()) { - lperef->lpeobject->get_lpe()->editNextParamOncanvas(SP_ITEM(lpeitem), dt); + lperef->lpeobject->get_lpe()->editNextParamOncanvas(lpeitem, dt); } } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 0dd65c7b9..5187ff027 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -1026,23 +1026,20 @@ sp_offset_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPOffset *offse } } -static void -sp_offset_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPOffset *self) +static void sp_offset_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPOffset *self) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL); - SPItem *item = SP_ITEM(self); - Geom::Affine m(*mp); if (!(m.isTranslation()) || mode == SP_CLONE_COMPENSATION_NONE) { self->sourceDirty=true; - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + self->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); return; } // calculate the compensation matrix and the advertized movement matrix - item->readAttr("transform"); + self->readAttr("transform"); Geom::Affine t = self->transform; Geom::Affine offset_move = t.inverse() * m * t; @@ -1061,9 +1058,9 @@ sp_offset_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPOffset self->sourceDirty=true; // commit the compensation - item->transform *= offset_move; - item->doWriteTransform(item->getRepr(), item->transform, &advertized_move); - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + self->transform *= offset_move; + self->doWriteTransform(self->getRepr(), self->transform, &advertized_move); + self->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } static void diff --git a/src/sp-path.cpp b/src/sp-path.cpp index c8022d351..6191d114f 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -169,7 +169,7 @@ sp_path_convert_to_guides(SPItem *item) std::list > pts; - Geom::Affine const i2d (SP_ITEM(path)->i2d_affine()); + Geom::Affine const i2d(path->i2d_affine()); Geom::PathVector const & pv = curve->get_pathvector(); for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index db5a62f8f..7cc9c7f29 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -417,7 +417,7 @@ sp_rect_set_visible_rx(SPRect *rect, gdouble rx) rect->rx.computed = rx / vector_stretch( Geom::Point(rect->x.computed + 1, rect->y.computed), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); rect->rx._set = true; } SP_OBJECT(rect)->updateRepr(); @@ -433,7 +433,7 @@ sp_rect_set_visible_ry(SPRect *rect, gdouble ry) rect->ry.computed = ry / vector_stretch( Geom::Point(rect->x.computed, rect->y.computed + 1), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); rect->ry._set = true; } SP_OBJECT(rect)->updateRepr(); @@ -447,7 +447,7 @@ sp_rect_get_visible_rx(SPRect *rect) return rect->rx.computed * vector_stretch( Geom::Point(rect->x.computed + 1, rect->y.computed), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); } gdouble @@ -458,7 +458,7 @@ sp_rect_get_visible_ry(SPRect *rect) return rect->ry.computed * vector_stretch( Geom::Point(rect->x.computed, rect->y.computed + 1), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); } Geom::Rect @@ -481,9 +481,9 @@ sp_rect_compensate_rxry(SPRect *rect, Geom::Affine xform) Geom::Point cy = c + Geom::Point(0, 1); // apply previous transform if any - c *= SP_ITEM(rect)->transform; - cx *= SP_ITEM(rect)->transform; - cy *= SP_ITEM(rect)->transform; + c *= rect->transform; + cx *= rect->transform; + cy *= rect->transform; // find out stretches that we need to compensate gdouble eX = vector_stretch(cx, c, xform); @@ -513,7 +513,7 @@ sp_rect_set_visible_width(SPRect *rect, gdouble width) rect->width.computed = width / vector_stretch( Geom::Point(rect->x.computed + 1, rect->y.computed), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); rect->width._set = true; SP_OBJECT(rect)->updateRepr(); } @@ -524,7 +524,7 @@ sp_rect_set_visible_height(SPRect *rect, gdouble height) rect->height.computed = height / vector_stretch( Geom::Point(rect->x.computed, rect->y.computed + 1), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); rect->height._set = true; SP_OBJECT(rect)->updateRepr(); } @@ -537,7 +537,7 @@ sp_rect_get_visible_width(SPRect *rect) return rect->width.computed * vector_stretch( Geom::Point(rect->x.computed + 1, rect->y.computed), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); } gdouble @@ -548,7 +548,7 @@ sp_rect_get_visible_height(SPRect *rect) return rect->height.computed * vector_stretch( Geom::Point(rect->x.computed, rect->y.computed + 1), Geom::Point(rect->x.computed, rect->y.computed), - SP_ITEM(rect)->transform); + rect->transform); } /** @@ -606,13 +606,13 @@ sp_rect_convert_to_guides(SPItem *item) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/rect/convertguides", true)) { - SP_ITEM(rect)->convert_to_guides(); + rect->convert_to_guides(); return; } std::list > pts; - Geom::Affine const i2d (SP_ITEM(rect)->i2d_affine()); + Geom::Affine const i2d(rect->i2d_affine()); Geom::Point A1(Geom::Point(rect->x.computed, rect->y.computed) * i2d); Geom::Point A2(Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d); diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 7d72b7695..918bd3295 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -395,12 +395,8 @@ static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child) /** * This callback routine updates the SPRoot object when its attributes have been changed. */ -static void -sp_root_update(SPObject *object, SPCtx *ctx, guint flags) +static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) { - SPItemView *v; - - SPItem *item = SP_ITEM(object); SPRoot *root = SP_ROOT(object); SPItemCtx *ictx = (SPItemCtx *) ctx; @@ -543,7 +539,7 @@ sp_root_update(SPObject *object, SPCtx *ctx, guint flags) ((SPObjectClass *) (parent_class))->update(object, (SPCtx *) &rctx, flags); /* As last step set additional transform of arena group */ - for (v = item->display; v != NULL; v = v->next) { + for (SPItemView *v = root->display; v != NULL; v = v->next) { nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), root->c2p); } } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 24b6b8025..bbfa98598 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -225,7 +225,6 @@ Inkscape::XML::Node * SPShape::sp_shape_write(SPObject *object, Inkscape::XML::D */ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) { - SPItem *item = (SPItem *) object; SPShape *shape = (SPShape *) object; if (((SPObjectClass *) (SPShapeClass::parent_class))->update) { @@ -257,7 +256,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) /* This is suboptimal, because changing parent style schedules recalculation */ /* But on the other hand - how can we know that parent does not tie style and transform */ Geom::OptRect paintbox = SP_ITEM(object)->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); - for (SPItemView *v = SP_ITEM (shape)->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { NRArenaShape * const s = NR_ARENA_SHAPE(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { nr_arena_shape_set_path(s, shape->curve, (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)); @@ -270,7 +269,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) if (shape->hasMarkers ()) { /* Dimension marker views */ - for (SPItemView *v = item->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { if (!v->arenaitem->key) { NR_ARENA_ITEM_SET_KEY (v->arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); } @@ -284,7 +283,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) } /* Update marker views */ - for (SPItemView *v = item->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { sp_shape_update_marker_view (shape, v->arenaitem); } } @@ -495,7 +494,7 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM (shape)->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { nr_arena_shape_set_style (NR_ARENA_SHAPE (v->arenaitem), object->style); } } diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 19c014b9b..eb30f2644 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -125,7 +125,6 @@ void CSwitch::_reevaluate(bool /*add_to_arena*/) { _releaseLastItem(_cached_item); - SPItem * child; for ( GSList *l = _childList(false, SPObject::ActionShow); NULL != l ; l = g_slist_remove (l, l->data)) { @@ -134,7 +133,7 @@ void CSwitch::_reevaluate(bool /*add_to_arena*/) { continue; } - child = SP_ITEM (o); + SPItem * child = SP_ITEM(o); child->setEvaluated(o == evaluated_child); } @@ -161,16 +160,14 @@ void CSwitch::_releaseLastItem(SPObject *obj) void CSwitch::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = _evaluateFirst(); - NRArenaItem *ac = NULL; NRArenaItem *ar = NULL; - SPItem * child; GSList *l = _childList(false, SPObject::ActionShow); while (l) { SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM (o)) { - child = SP_ITEM (o); + SPItem * child = SP_ITEM(o); child->setEvaluated(o == evaluated_child); - ac = child->invoke_show (arena, key, flags); + NRArenaItem *ac = child->invoke_show (arena, key, flags); if (ac) { nr_arena_item_add_child (ai, ac, ar); ar = ac; diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 1d4bdec0f..91218c986 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -4,6 +4,7 @@ * Authors: * Lauris Kaplinski * Abhishek Sharma + * Jon A. Cruz * * Copyright (C) 1999-2003 Lauris Kaplinski * @@ -63,16 +64,10 @@ sp_symbol_get_type (void) return type; } -static void -sp_symbol_class_init (SPSymbolClass *klass) +static void sp_symbol_class_init(SPSymbolClass *klass) { - GObjectClass *object_class; - SPObjectClass *sp_object_class; - SPItemClass *sp_item_class; - - object_class = G_OBJECT_CLASS (klass); - sp_object_class = (SPObjectClass *) klass; - sp_item_class = (SPItemClass *) klass; + SPObjectClass *sp_object_class = (SPObjectClass *) klass; + SPItemClass *sp_item_class = (SPItemClass *) klass; parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); @@ -90,49 +85,33 @@ sp_symbol_class_init (SPSymbolClass *klass) sp_item_class->print = sp_symbol_print; } -static void -sp_symbol_init (SPSymbol *symbol) +static void sp_symbol_init(SPSymbol *symbol) { symbol->viewBox_set = FALSE; symbol->c2p = Geom::identity(); } -static void -sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - SPGroup *group; - SPSymbol *symbol; - - group = (SPGroup *) object; - symbol = (SPSymbol *) object; - object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (((SPObjectClass *) parent_class)->build) + if (((SPObjectClass *) parent_class)->build) { ((SPObjectClass *) parent_class)->build (object, document, repr); + } } -static void -sp_symbol_release (SPObject *object) +static void sp_symbol_release(SPObject *object) { - SPSymbol * symbol; - - symbol = (SPSymbol *) object; - - if (((SPObjectClass *) parent_class)->release) + if (((SPObjectClass *) parent_class)->release) { ((SPObjectClass *) parent_class)->release (object); + } } -static void -sp_symbol_set (SPObject *object, unsigned int key, const gchar *value) +static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value) { - SPItem *item; - SPSymbol *symbol; - - item = SP_ITEM (object); - symbol = SP_SYMBOL (object); + SPSymbol *symbol = SP_SYMBOL(object); switch (key) { case SP_ATTR_VIEWBOX: @@ -232,30 +211,18 @@ sp_symbol_set (SPObject *object, unsigned int key, const gchar *value) } } -static void -sp_symbol_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPSymbol *symbol; - SPGroup *group; - - symbol = (SPSymbol *) object; - group = (SPGroup *) object; - - if (((SPObjectClass *) (parent_class))->child_added) + if (((SPObjectClass *) (parent_class))->child_added) { ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + } } -static void -sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) +static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) { - SPItem *item; - SPSymbol *symbol; - SPItemCtx *ictx, rctx; - SPItemView *v; - - item = SP_ITEM (object); - symbol = SP_SYMBOL (object); - ictx = (SPItemCtx *) ctx; + SPSymbol *symbol = SP_SYMBOL(object); + SPItemCtx *ictx = (SPItemCtx *) ctx; + SPItemCtx rctx; if (object->cloned) { /* Cloned is actually renderable */ @@ -353,38 +320,35 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) rctx.i2vp = Geom::identity(); } - /* And invoke parent method */ - if (((SPObjectClass *) (parent_class))->update) + // And invoke parent method + if (((SPObjectClass *) (parent_class))->update) { ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + } - /* As last step set additional transform of arena group */ - for (v = item->display; v != NULL; v = v->next) { + // As last step set additional transform of arena group + for (SPItemView *v = symbol->display; v != NULL; v = v->next) { nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), symbol->c2p); } } else { - /* No-op */ - if (((SPObjectClass *) (parent_class))->update) + // No-op + if (((SPObjectClass *) (parent_class))->update) { ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + } } } -static void -sp_symbol_modified (SPObject *object, guint flags) +static void sp_symbol_modified(SPObject *object, guint flags) { - SPSymbol *symbol; + SP_SYMBOL(object); - symbol = SP_SYMBOL (object); - - if (((SPObjectClass *) (parent_class))->modified) + if (((SPObjectClass *) (parent_class))->modified) { (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + } } -static Inkscape::XML::Node * -sp_symbol_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPSymbol *symbol; - - symbol = SP_SYMBOL (object); + SP_SYMBOL(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); @@ -403,52 +367,42 @@ sp_symbol_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -static NRArenaItem * -sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) +static NRArenaItem *sp_symbol_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) { - SPSymbol *symbol; - NRArenaItem *ai; - - symbol = SP_SYMBOL (item); + SPSymbol *symbol = SP_SYMBOL(item); + NRArenaItem *ai = 0; if (symbol->cloned) { - /* Cloned is actually renderable */ + // Cloned is actually renderable if (((SPItemClass *) (parent_class))->show) { ai = ((SPItemClass *) (parent_class))->show (item, arena, key, flags); if (ai) { nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), symbol->c2p); } - } else { - ai = NULL; } - } else { - ai = NULL; } return ai; } -static void -sp_symbol_hide (SPItem *item, unsigned int key) +static void sp_symbol_hide(SPItem *item, unsigned int key) { - SPSymbol *symbol; - - symbol = SP_SYMBOL (item); + SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { /* Cloned is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) + if (((SPItemClass *) (parent_class))->hide) { ((SPItemClass *) (parent_class))->hide (item, key); + } } } -static void -sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) +static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) { SPSymbol const *symbol = SP_SYMBOL(item); if (symbol->cloned) { - /* Cloned is actually renderable */ + // Cloned is actually renderable if (((SPItemClass *) (parent_class))->bbox) { Geom::Affine const a( symbol->c2p * transform ); @@ -457,12 +411,11 @@ sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, } } -static void -sp_symbol_print (SPItem *item, SPPrintContext *ctx) +static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) { SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { - /* Cloned is actually renderable */ + // Cloned is actually renderable sp_print_bind(ctx, &symbol->c2p, 1.0); diff --git a/src/spray-context.cpp b/src/spray-context.cpp index b2d99a696..8b0454893 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -432,7 +432,7 @@ bool sp_spray_recursive(SPDesktop *desktop, if (SP_IS_BOX3D(item) ) { // convert 3D boxes to ordinary groups before spraying their shapes - item = SP_ITEM(box3d_convert_to_group(SP_BOX3D(item))); + item = box3d_convert_to_group(SP_BOX3D(item)); selection->add(item); } diff --git a/src/svg-view.cpp b/src/svg-view.cpp index 03056de2e..2f1a20b82 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -18,7 +18,7 @@ #include "document.h" #include "sp-item.h" #include "svg-view.h" - +#include "sp-root.h" /** * Constructs new SPSVGView object and returns pointer to it. @@ -41,7 +41,7 @@ SPSVGView::~SPSVGView() { if (doc() && _drawing) { - SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey); + doc()->getRoot()->invoke_hide(_dkey); _drawing = NULL; } } @@ -191,7 +191,7 @@ void SPSVGView::setDocument (SPDocument *document) { if (doc()) { - SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey); + doc()->getRoot()->invoke_hide(_dkey); } if (!_drawing) { @@ -202,7 +202,7 @@ SPSVGView::setDocument (SPDocument *document) View::setDocument (document); if (document) { - NRArenaItem *ai = SP_ITEM( document->getRoot() )->invoke_show( + NRArenaItem *ai = document->getRoot()->invoke_show( SP_CANVAS_ARENA (_drawing)->arena, _dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 873c214a7..d64fa749a 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -150,7 +150,7 @@ text_put_on_path() Inkscape::Text::Layout::Alignment text_alignment = layout->paragraphAlignment(layout->begin()); // remove transform from text, but recursively scale text's fontsize by the expansion - SP_TEXT(text)->_adjustFontsizeRecursive (text, SP_ITEM(text)->transform.descrim()); + SP_TEXT(text)->_adjustFontsizeRecursive (text, text->transform.descrim()); text->getRepr()->setAttribute("transform", NULL); // make a list of text children @@ -316,7 +316,7 @@ text_flow_into_shape() if (SP_IS_TEXT(text)) { // remove transform from text, but recursively scale text's fontsize by the expansion - SP_TEXT(text)->_adjustFontsizeRecursive(text, SP_ITEM(text)->transform.descrim()); + SP_TEXT(text)->_adjustFontsizeRecursive(text, text->transform.descrim()); text->getRepr()->setAttribute("transform", NULL); } @@ -433,7 +433,7 @@ text_unflow () rtext->setAttribute("style", flowtext->getRepr()->attribute("style")); // fixme: transfer style attrs too; and from descendants Geom::OptRect bbox; - SP_ITEM(flowtext)->invoke_bbox(bbox, SP_ITEM(flowtext)->i2doc_affine(), TRUE); + flowtext->invoke_bbox(bbox, flowtext->i2doc_affine(), TRUE); if (bbox) { Geom::Point xy = bbox->min(); sp_repr_set_svg_double(rtext, "x", xy[Geom::X]); @@ -454,7 +454,8 @@ text_unflow () SPObject *text_object = doc->getObjectByRepr(rtext); // restore the font size multiplier from the flowtext's transform - SP_TEXT(text_object)->_adjustFontsizeRecursive(SP_ITEM(text_object), ex); + SPText *text = SP_TEXT(text_object); + text->_adjustFontsizeRecursive(text, ex); new_objs = g_slist_prepend (new_objs, text_object); old_objs = g_slist_prepend (old_objs, flowtext); diff --git a/src/text-context.cpp b/src/text-context.cpp index a27ad3ee4..9edf96b26 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -1593,8 +1593,8 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) if (tc->text) { Geom::Point p0, p1; sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1); - Geom::Point const d0 = p0 * SP_ITEM(tc->text)->i2d_affine(); - Geom::Point const d1 = p1 * SP_ITEM(tc->text)->i2d_affine(); + Geom::Point const d0 = p0 * tc->text->i2d_affine(); + Geom::Point const d1 = p1 * tc->text->i2d_affine(); // scroll to show cursor if (scroll_to_see) { diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 18264fa56..b3f76817c 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1232,7 +1232,7 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count)); // divide increment by matrix expansion - Geom::Affine t (SP_ITEM(text)->i2doc_affine ()); + Geom::Affine t(text->i2doc_affine()); zby = zby / t.descrim(); switch (style->line_height.unit) { diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 974197786..eb4e28bd4 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -406,7 +406,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (SP_IS_BOX3D(item) && !is_transform_mode(mode) && !is_color_mode(mode)) { // convert 3D boxes to ordinary groups before tweaking their shapes - item = SP_ITEM(box3d_convert_to_group(SP_BOX3D(item))); + item = box3d_convert_to_group(SP_BOX3D(item)); selection->add(item); } diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 4d98793bb..38ec6d1be 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -356,11 +356,10 @@ void IconPreviewPanel::refreshPreview() GSList const *items = sel->itemList(); while ( items && !target ) { SPItem* item = SP_ITEM( items->data ); - SPObject * obj = item; - gchar const *id = obj->getId(); + gchar const *id = item->getId(); if ( id ) { targetId = id; - target = obj; + target = item; } items = g_slist_next(items); @@ -447,7 +446,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) /* Create ArenaItem and set transform */ unsigned int visionkey = SPItem::display_key_new(1); - root = SP_ITEM( doc->getRoot() )->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); for ( int i = 0; i < numEntries; i++ ) { unsigned unused; @@ -465,7 +464,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) } updateMagnify(); - SP_ITEM(doc->getRoot())->invoke_hide(visionkey); + doc->getRoot()->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); renderTimer->stop(); minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 ); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 52286c6cc..9afcf6323 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -120,7 +120,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _lpe_key(lpe_key) { if (_lpe_key.empty()) { - _i2d_transform = SP_ITEM(path)->i2d_affine(); + _i2d_transform = path->i2d_affine(); } else { _i2d_transform = Geom::identity(); } @@ -976,7 +976,7 @@ void PathManipulator::_externalChange(unsigned type) } break; case PATH_CHANGE_TRANSFORM: { Geom::Affine i2d_change = _d2i_transform; - _i2d_transform = SP_ITEM(_path)->i2d_affine(); + _i2d_transform = _path->i2d_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 95cb23a22..6110e6011 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -34,6 +34,7 @@ #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "io/sys.h" +#include "sp-root.h" #include "icon.h" @@ -1085,9 +1086,10 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, if (doc) { SPObject *object = doc->getObjectById(name); if (object && SP_IS_ITEM(object)) { - /* Find bbox in document */ - Geom::Affine const i2doc(SP_ITEM(object)->i2doc_affine()); - Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc); + SPItem *item = SP_ITEM(object); + // Find bbox in document + Geom::Affine const i2doc(item->i2doc_affine()); + Geom::OptRect dbox = item->getBounds(i2doc); if ( object->parent == NULL ) { @@ -1294,7 +1296,7 @@ guchar *IconImpl::load_svg_pixels(std::list const &names, // fixme: Memory manage root if needed (Lauris) // This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days // because shapes are being rendered which are not being freed - NRArenaItem *root = SP_ITEM(doc->getRoot())->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + NRArenaItem *root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); // store into the cache info = new SVGDocCache(doc, root); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 8544c8cad..8b5582163 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -157,8 +157,9 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, { // Retrieve the marker named 'mname' from the source SVG document SPObject const *marker = source->getObjectById(mname); - if (marker == NULL) + if (marker == NULL) { return NULL; + } // Create a copy repr of the marker with id="sample" Inkscape::XML::Document *xml_doc = sandbox->getReprDoc(); @@ -168,8 +169,9 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, // Replace the old sample in the sandbox by the new one Inkscape::XML::Node *defsrepr = sandbox->getObjectById("defs")->getRepr(); SPObject *oldmarker = sandbox->getObjectById("sample"); - if (oldmarker) + if (oldmarker) { oldmarker->deleteObject(false); + } defsrepr->appendChild(mrepr); Inkscape::GC::release(mrepr); @@ -183,12 +185,14 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, sandbox->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); sandbox->ensureUpToDate(); - if (object == NULL || !SP_IS_ITEM(object)) + if (object == NULL || !SP_IS_ITEM(object)) { return NULL; // sandbox broken? + } + SPItem *item = SP_ITEM(object); // Find object's bbox in document - Geom::Affine const i2doc(SP_ITEM(object)->i2doc_affine()); - Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc); + Geom::Affine const i2doc(item->i2doc_affine()); + Geom::OptRect dbox = item->getBounds(i2doc); if (!dbox) { return NULL; @@ -246,7 +250,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD // Do this here, outside of loop, to speed up preview generation: NRArena const *arena = NRArena::create(); unsigned const visionkey = SPItem::display_key_new(1); - NRArenaItem *root = SP_ITEM(sandbox->getRoot())->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = sandbox->getRoot()->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); for (; marker_list != NULL; marker_list = marker_list->next) { Inkscape::XML::Node *repr = reinterpret_cast(marker_list->data)->getRepr(); @@ -284,7 +288,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD m->append(*i); } - SP_ITEM(sandbox->getRoot())->invoke_hide(visionkey); + sandbox->getRoot()->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); } -- cgit v1.2.3 From 38c66b7ac5397f2a6cbf6b2a5f713a5e5d743783 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 16 Jul 2011 22:10:13 +0200 Subject: Fix drawing of controls at (0,0) (e.g. scaling handles, snap-indicator, etc.). See lp:360158 Fixed bugs: - https://launchpad.net/bugs/360158 (bzr r10463) --- src/display/sodipodi-ctrl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 0ff7ca9f5..b4d2633bb 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -105,7 +105,12 @@ sp_ctrl_init (SPCtrl *ctrl) ctrl->stroked = 0; ctrl->fill_color = 0x000000ff; ctrl->stroke_color = 0x000000ff; - ctrl->_moved = false; + + // This way we make sure that the first sp_ctrl_update() call finishes properly; + // in subsequent calls it will not update anything it the control hasn't moved + // Consider for example the case in which a snap indicator is drawn at (0, 0); + // If moveto() is called then it will not set _moved to true because we're initially already at (0, 0) + ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen ctrl->box.x0 = ctrl->box.y0 = ctrl->box.x1 = ctrl->box.y1 = 0; ctrl->cache = NULL; -- cgit v1.2.3 From 2b6e0b43dbcb38e1098a5308d36ba5e75c08d5a1 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 17 Jul 2011 14:05:05 +0200 Subject: Fix crash that occurred when scaling a clipped object, as reported in lp:811819 Fixed bugs: - https://launchpad.net/bugs/811819 (bzr r10464) --- src/sp-item-transform.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index eb4b81a61..0fbce27f9 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -248,10 +248,6 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re gdouble r0w = w0 - bbox_geom.width(); // r0w is the average strokewidth of the left and right edges, i.e. 0.5*(r0l + r0r) gdouble r0h = h0 - bbox_geom.height(); // r0h is the average strokewidth of the top and bottom edges, i.e. 0.5*(r0t + r0b) - // Check whether the stroke is not negative; should not be possible, but just in case: - g_assert(r0w >= 0); - g_assert(r0h >= 0); - if (bbox_visual.hasZeroArea()) { // Obviously we cannot scale from empty visual bounding boxes at all, so we will only translate in such a case Geom::Affine move = Geom::Translate(x0 - bbox_visual.min()[Geom::X], y0 - bbox_visual.min()[Geom::Y]); return (move); @@ -266,6 +262,14 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re return (p2o * direct * o2n); } + // Check whether the stroke is negative; i.e. the geometric bounding box is larger than the visual bounding box, which + // occurs for example for clipped objects (see launchpad bug #811819) + if (r0w < 0 || r0w < 0) { + // How should we handle the stroke width scaling of clipped object? I don't know if we can/should handle this, + // so for now we simply return the direct scaling + return (p2o * direct * o2n); + } + // Here starts the calculation you've been waiting for; first do some preparation int flip_x = (w1 > 0) ? 1 : -1; int flip_y = (h1 > 0) ? 1 : -1; -- cgit v1.2.3 From 37c2baa5e61e755f0199bdd6926e68a7c2e90483 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 17 Jul 2011 21:41:49 +0200 Subject: Fix build failures on make check (bzr r10465) --- src/libnr/Makefile_insert | 4 +--- src/libnr/in-svg-plane-test.h | 21 +++++++++++---------- src/mod360-test.h | 4 +--- 3 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 57d82c8ef..cdb0b482c 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -20,6 +20,4 @@ ink_common_sources += \ # ### CxxTest stuff #### # ###################### CXXTEST_TESTSUITES += \ - $(srcdir)/libnr/in-svg-plane-test.h \ - $(srcdir)/libnr/nr-point-fns-test.h \ - $(srcdir)/libnr/nr-types-test.h + $(srcdir)/libnr/in-svg-plane-test.h diff --git a/src/libnr/in-svg-plane-test.h b/src/libnr/in-svg-plane-test.h index e64f76251..696f82421 100644 --- a/src/libnr/in-svg-plane-test.h +++ b/src/libnr/in-svg-plane-test.h @@ -4,7 +4,8 @@ #include #include "libnr/in-svg-plane.h" -#include "2geom/isnan.h" +#include <2geom/math-utils.h> +#include <2geom/point.h> class InSvgPlaneTest : public CxxTest::TestSuite { @@ -38,14 +39,14 @@ public: } bool setupValid; - NR::Point const p3n4; - NR::Point const p0; + Geom::Point const p3n4; + Geom::Point const p0; double const small; double const inf; double const nan; - NR::Point const small_left; - NR::Point const small_n3_4; - NR::Point const part_nan; + Geom::Point const small_left; + Geom::Point const small_n3_4; + Geom::Point const part_nan; void testInSvgPlane(void) @@ -55,13 +56,13 @@ public: TS_ASSERT( in_svg_plane(small_left) ); TS_ASSERT( in_svg_plane(small_n3_4) ); TS_ASSERT_DIFFERS( nan, nan ); - TS_ASSERT( !in_svg_plane(NR::Point(nan, 3.)) ); - TS_ASSERT( !in_svg_plane(NR::Point(inf, nan)) ); - TS_ASSERT( !in_svg_plane(NR::Point(0., -inf)) ); + TS_ASSERT( !in_svg_plane(Geom::Point(nan, 3.)) ); + TS_ASSERT( !in_svg_plane(Geom::Point(inf, nan)) ); + TS_ASSERT( !in_svg_plane(Geom::Point(0., -inf)) ); double const xs[] = {inf, -inf, nan, 1., -2., small, -small}; for (unsigned i = 0; i < G_N_ELEMENTS(xs); ++i) { for (unsigned j = 0; j < G_N_ELEMENTS(xs); ++j) { - TS_ASSERT_EQUALS( in_svg_plane(NR::Point(xs[i], xs[j])), + TS_ASSERT_EQUALS( in_svg_plane(Geom::Point(xs[i], xs[j])), (fabs(xs[i]) < inf && fabs(xs[j]) < inf ) ); } diff --git a/src/mod360-test.h b/src/mod360-test.h index 508553970..932361eb3 100644 --- a/src/mod360-test.h +++ b/src/mod360-test.h @@ -3,9 +3,7 @@ #define SEEN_MOD_360_TEST_H #include - -#include "2geom/isnan.h" - +#include <2geom/math-utils.h> #include "mod360.h" -- cgit v1.2.3 From eed6e9c2c229b10911a23976c47da79fc70a5b87 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Jul 2011 21:47:09 +0200 Subject: - rename SPItem::i2d_affine to i2dt_affine, to clarify that it is item-to-desktop, not item-to-document. This should make it easier to spot bugs. - tag some instances where the document-to-desktop transform has been hardcoded (bzr r10466) --- src/arc-context.cpp | 2 +- src/box3d.cpp | 4 +-- src/connector-context.cpp | 14 +++++----- src/desktop-style.cpp | 10 +++---- src/desktop.cpp | 3 +- src/dialogs/export.cpp | 2 +- src/dialogs/spellcheck.cpp | 6 ++-- src/draw-context.cpp | 4 +-- src/extension/internal/cairo-renderer.cpp | 6 ++-- src/extension/internal/emf-win32-print.cpp | 4 +-- src/extension/internal/javafx-out.cpp | 8 +++--- src/extension/internal/latex-pstricks.cpp | 2 +- src/extension/internal/latex-text-renderer.cpp | 4 +-- src/extension/internal/odf.cpp | 6 ++-- src/extension/internal/pov-out.cpp | 2 +- src/filter-chemistry.cpp | 6 ++-- src/gradient-chemistry.cpp | 4 +-- src/interface.cpp | 4 +-- src/knot-holder-entity.cpp | 12 ++++---- src/knotholder.cpp | 6 ++-- src/live_effects/lpe-mirror_symmetry.cpp | 2 +- src/live_effects/parameter/path.cpp | 2 +- src/main.cpp | 2 +- src/object-edit.cpp | 8 +++--- src/object-snapper.cpp | 6 ++-- src/selcue.cpp | 2 +- src/selection-chemistry.cpp | 14 +++++----- src/seltrans.cpp | 4 +-- src/sp-ellipse.cpp | 10 +++---- src/sp-flowtext.cpp | 4 +-- src/sp-image.cpp | 2 +- src/sp-item-notify-moveto.cpp | 2 +- src/sp-item-transform.cpp | 8 +++--- src/sp-item.cpp | 38 ++++++++++++++------------ src/sp-item.h | 2 +- src/sp-line.cpp | 6 ++-- src/sp-path.cpp | 4 +-- src/sp-rect.cpp | 20 +++++++------- src/sp-shape.cpp | 20 +++++++------- src/sp-spiral.cpp | 4 +-- src/sp-star.cpp | 4 +-- src/sp-text.cpp | 4 +-- src/splivarot.cpp | 2 +- src/spray-context.cpp | 4 +-- src/text-context.cpp | 6 ++-- src/text-editing.cpp | 2 +- src/tweak-context.cpp | 4 +-- src/ui/dialog/align-and-distribute.cpp | 4 +-- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- src/ui/dialog/tile.cpp | 2 +- src/ui/tool/node-tool.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 4 +-- src/unclump.cpp | 8 +++--- 53 files changed, 158 insertions(+), 159 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 32a0bab40..96f5e1cff 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -445,7 +445,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state) Geom::Point c = r.midpoint(); if (!ctrl_save) { if (fabs(dir[Geom::X]) > 1E-6 && fabs(dir[Geom::Y]) > 1E-6) { - Geom::Affine const i2d ((ac->item)->i2d_affine ()); + Geom::Affine const i2d ( (ac->item)->i2dt_affine() ); Geom::Point new_dir = pt * i2d - c; new_dir[Geom::X] *= dir[Geom::Y] / dir[Geom::X]; double lambda = new_dir.length() / dir[Geom::Y]; diff --git a/src/box3d.cpp b/src/box3d.cpp index efd4054e1..ea1e35982 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -388,7 +388,7 @@ box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) { if (!box3d_get_perspective(box)) { return Geom::Point (Geom::infinity(), Geom::infinity()); } - Geom::Affine const i2d(box->i2d_affine ()); + Geom::Affine const i2d(box->i2dt_affine ()); if (item_coords) { return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_corner).affine() * i2d.inverse(); } else { @@ -412,7 +412,7 @@ box3d_get_center_screen (SPBox3D *box) { if (!box3d_get_perspective(box)) { return Geom::Point (Geom::infinity(), Geom::infinity()); } - Geom::Affine const i2d(box->i2d_affine ()); + Geom::Affine const i2d( box->i2dt_affine() ); return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_center).affine() * i2d.inverse(); } diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 2aa9c41ee..ecc8cdaad 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -977,7 +977,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons m.unSetup(); // Update the hidden path - Geom::Affine i2d = (cc->clickeditem)->i2d_affine(); + Geom::Affine i2d ( (cc->clickeditem)->i2dt_affine() ); Geom::Affine d2i = i2d.inverse(); SPPath *path = SP_PATH(cc->clickeditem); SPCurve *curve = path->original_curve ? path->original_curve : path->curve; @@ -1607,7 +1607,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) // Show the red path for dragging. cc->red_curve = SP_PATH(cc->clickeditem)->original_curve ? SP_PATH(cc->clickeditem)->original_curve->copy() : SP_PATH(cc->clickeditem)->curve->copy(); - Geom::Affine i2d = (cc->clickeditem)->i2d_affine(); + Geom::Affine i2d = (cc->clickeditem)->i2dt_affine(); cc->red_curve->transform(i2d); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); @@ -1766,7 +1766,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) g_assert( SP_IS_PATH(item) ); SPCurve *curve = SP_PATH(item)->original_curve ? SP_PATH(item)->original_curve : SP_PATH(item)->curve; - Geom::Affine i2d = item->i2d_affine(); + Geom::Affine i2dt = item->i2dt_affine(); if (cc->active_conn == item) { @@ -1780,10 +1780,10 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) else { // Just adjust handle positions. - Geom::Point startpt = *(curve->first_point()) * i2d; + Geom::Point startpt = *(curve->first_point()) * i2dt; sp_knot_set_position(cc->endpt_handle[0], startpt, 0); - Geom::Point endpt = *(curve->last_point()) * i2d; + Geom::Point endpt = *(curve->last_point()) * i2dt; sp_knot_set_position(cc->endpt_handle[1], endpt, 0); } @@ -1855,10 +1855,10 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) return; } - Geom::Point startpt = *(curve->first_point()) * i2d; + Geom::Point startpt = *(curve->first_point()) * i2dt; sp_knot_set_position(cc->endpt_handle[0], startpt, 0); - Geom::Point endpt = *(curve->last_point()) * i2d; + Geom::Point endpt = *(curve->last_point()) * i2dt; sp_knot_set_position(cc->endpt_handle[1], endpt, 0); sp_knot_show(cc->endpt_handle[0]); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 88ad9ca57..1cad282b3 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -420,7 +420,7 @@ stroke_average_width (GSList const *objects) if (!SP_IS_ITEM (l->data)) continue; - Geom::Affine i2d = SP_ITEM(l->data)->i2d_affine(); + Geom::Affine i2dt = SP_ITEM(l->data)->i2dt_affine(); SPObject *object = SP_OBJECT(l->data); @@ -431,7 +431,7 @@ stroke_average_width (GSList const *objects) notstroked = false; } - avgwidth += object->style->stroke_width.computed * i2d.descrim(); + avgwidth += object->style->stroke_width.computed * i2dt.descrim(); } if (notstroked) @@ -725,7 +725,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) noneSet &= style->stroke.isNone(); - Geom::Affine i2d = SP_ITEM(obj)->i2d_affine(); + Geom::Affine i2d = SP_ITEM(obj)->i2dt_affine(); double sw = style->stroke_width.computed * i2d.descrim(); if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) @@ -961,7 +961,7 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) } texts ++; - size += style->font_size.computed * Geom::Affine(SP_ITEM(obj)->i2d_affine()).descrim(); /// \todo FIXME: we assume non-% units here + size += style->font_size.computed * Geom::Affine(SP_ITEM(obj)->i2dt_affine()).descrim(); /// \todo FIXME: we assume non-% units here if (style->letter_spacing.normal) { if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing)) { @@ -1428,7 +1428,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) continue; } - Geom::Affine i2d = SP_ITEM(obj)->i2d_affine(); + Geom::Affine i2d = SP_ITEM(obj)->i2dt_affine(); items ++; diff --git a/src/desktop.cpp b/src/desktop.cpp index 7034e85b6..5e968b08b 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1816,8 +1816,7 @@ Geom::Affine SPDesktop::doc2dt() const Geom::Affine SPDesktop::dt2doc() const { - // doc2dt is its own inverse - return _doc2dt; + return _doc2dt.inverse(); } Geom::Point SPDesktop::doc2dt(Geom::Point const &p) const diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 77447b658..c839c376b 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1130,7 +1130,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } Geom::OptRect area; - item->invoke_bbox( area, item->i2d_affine(), TRUE ); + item->invoke_bbox( area, item->i2dt_affine(), TRUE ); if (area) { gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 5de0bc6fe..d0de6ad20 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -243,8 +243,8 @@ gint compare_text_bboxes (gconstpointer a, gconstpointer b) SPItem *i1 = SP_ITEM(a); SPItem *i2 = SP_ITEM(b); - Geom::OptRect bbox1 = i1->getBounds(i1->i2d_affine()); - Geom::OptRect bbox2 = i2->getBounds(i2->i2d_affine()); + Geom::OptRect bbox1 = i1->getBounds(i1->i2dt_affine()); + Geom::OptRect bbox2 = i2->getBounds(i2->i2dt_affine()); if (!bbox1 || !bbox2) { return 0; } @@ -577,7 +577,7 @@ spellcheck_next_word() // draw rect std::vector points = - _layout->createSelectionShape(_begin_w, _end_w, _text->i2d_affine()); + _layout->createSelectionShape(_begin_w, _end_w, _text->i2dt_affine()); Geom::Point tl, br; tl = br = points.front(); for (unsigned i = 0 ; i < points.size() ; i ++) { diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 4dd58afa7..5d324754f 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -439,7 +439,7 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) /* Curve list */ /* We keep it in desktop coordinates to eliminate calculation errors */ SPCurve *norm = sp_path_get_curve_for_edit (SP_PATH(item)); - norm->transform((dc->white_item)->i2d_affine()); + norm->transform((dc->white_item)->i2dt_affine()); g_return_if_fail( norm != NULL ); dc->white_curves = g_slist_reverse(norm->split()); norm->unref(); @@ -821,7 +821,7 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons current stroke width, multiplied by the amount specified in the preferences */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Geom::Affine const i2d (item->i2d_affine ()); + Geom::Affine const i2d (item->i2dt_affine ()); Geom::Point pp = pt; double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0); if (event_state & GDK_MOD1_MASK) { diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 3b16df96c..7eb7881dc 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -454,7 +454,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) // Get the bounding box of the selection in document coordinates. Geom::OptRect bbox = - item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX); + item->getBounds(item->i2dt_affine(), SPItem::RENDERING_BBOX); // no bbox, e.g. empty group if (!bbox) { @@ -502,7 +502,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) (Geom::Affine)(Geom::Translate (shift_x, shift_y)); // ctx matrix already includes item transformation. We must substract. - Geom::Affine t_item = item->i2d_affine (); + Geom::Affine t_item = item->i2dt_affine (); Geom::Affine t = t_on_document * t_item.inverse(); // Do the export @@ -633,7 +633,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page d.x1 = doc->getWidth(); d.y1 = doc->getHeight(); } else { - base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX); + base->invoke_bbox( &d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX); } if (ctx->_vector_based_target) { diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index e5d1b0681..7ed0f6fcf 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -144,7 +144,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) d.y1 = _height; } else { SPItem* doc_item = doc->getRoot(); - doc_item->invoke_bbox(&d, doc_item->i2d_affine(), TRUE); + doc_item->invoke_bbox(&d, doc_item->i2dt_affine(), TRUE); } d.x0 *= IN_PER_PX; @@ -226,7 +226,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) g_free(local_fn); g_free(unicode_fn); - m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); + m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform return 0; } diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 8399d602f..74b6a69ee 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -492,8 +492,8 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) } // convert the path to only lineto's and cubic curveto's: - Geom::Scale yflip(1.0, -1.0); - Geom::Affine tf = item->i2d_affine() * yflip; + Geom::Scale yflip(1.0, -1.0); /// @fixme hardcoded desktop transform! + Geom::Affine tf = item->i2dt_affine() * yflip; Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); //Count the NR_CURVETOs/LINETOs (including closing line segment) @@ -634,8 +634,8 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) } // convert the path to only lineto's and cubic curveto's: - Geom::Scale yflip(1.0, -1.0); - Geom::Affine tf = item->i2d_affine() * yflip; + Geom::Scale yflip(1.0, -1.0); /// @fixme hardcoded desktop transform + Geom::Affine tf = item->i2dt_affine() * yflip; Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); //Count the NR_CURVETOs/LINETOs (including closing line segment) diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index e09e7c024..18950295c 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -141,7 +141,7 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc) os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\n"; } - m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); + m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform return fprintf(_stream, "%s", os.str().c_str()); } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 818f39f68..02f0823d9 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -593,7 +593,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * d = Geom::Rect( Geom::Point(0,0), Geom::Point(doc->getWidth(), doc->getHeight()) ); } else { - base->invoke_bbox( d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX); + base->invoke_bbox( d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX); } if (!d) { g_message("LaTeXTextRenderer: could not retrieve boundingbox."); @@ -612,7 +612,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * } // flip y-axis - push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) ); + push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) ); /// @fixme hardcoded desktop transform! // write the info to LaTeX Inkscape::SVGOStringStream os; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 6a350ab48..568c804a0 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -946,10 +946,10 @@ static Glib::ustring formatTransform(Geom::Affine &tf) static Geom::Affine getODFTransform(const SPItem *item) { //### Get SVG-to-ODF transform - Geom::Affine tf (item->i2d_affine()); + Geom::Affine tf (item->i2dt_affine()); //Flip Y into document coordinates double doc_height = SP_ACTIVE_DOCUMENT->getHeight(); - Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); + Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); /// @fixme hardcoded desktop transform doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height)); tf = tf * doc2dt_tf; tf = tf * Geom::Affine(Geom::Scale(pxToCm)); @@ -986,7 +986,7 @@ static Geom::OptRect getODFBoundingBox(const SPItem *item) */ static Geom::Affine getODFItemTransform(const SPItem *item) { - Geom::Affine itemTransform (Geom::Scale(1, -1)); + Geom::Affine itemTransform (Geom::Scale(1, -1)); /// @fixme hardcoded doc2dt transform? itemTransform = itemTransform * (Geom::Affine)item->transform; itemTransform = itemTransform * Geom::Scale(1, -1); return itemTransform; diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 382f8cbfb..a29aade35 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -301,7 +301,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id) povShapes.push_back(shapeInfo); //passed all tests. save the info // convert the path to only lineto's and cubic curveto's: - Geom::Affine tf = item->i2d_affine(); + Geom::Affine tf = item->i2dt_affine(); Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); /* diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index b78b96c02..e98905439 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -328,9 +328,9 @@ new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mod width = height = 0; } - Geom::Affine i2d (item->i2d_affine () ); + Geom::Affine i2dt (item->i2dt_affine () ); - return (new_filter_blend_gaussian_blur (document, mode, radius, i2d.descrim(), i2d.expansionX(), i2d.expansionY(), width, height)); + return (new_filter_blend_gaussian_blur (document, mode, radius, i2dt.descrim(), i2dt.expansionX(), i2dt.expansionY(), width, height)); } /** @@ -363,7 +363,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it } // Determine the required standard deviation value - Geom::Affine i2d (item->i2d_affine ()); + Geom::Affine i2d (item->i2dt_affine ()); double expansion = i2d.descrim(); double stdDeviation = radius; if (expansion != 0) diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 642ddba5b..f803d7bf8 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -789,7 +789,7 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i, gradient = sp_gradient_convert_to_userspace (gradient, item, fill_or_stroke? "fill" : "stroke"); - Geom::Affine i2d (item->i2d_affine ()); + Geom::Affine i2d (item->i2dt_affine ()); Geom::Point p = p_w * i2d.inverse(); p *= (gradient->gradientTransform).inverse(); // now p is in gradient's original coordinates @@ -1070,7 +1070,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po bbox->min()[Geom::X], bbox->min()[Geom::Y]); } } - p *= Geom::Affine(gradient->gradientTransform) * (Geom::Affine)item->i2d_affine(); + p *= Geom::Affine(gradient->gradientTransform) * (Geom::Affine)item->i2dt_affine(); return p; } diff --git a/src/interface.cpp b/src/interface.cpp index 9aa5cad31..25153097d 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1261,7 +1261,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !item->style->stroke.isNone() ? desktop->current_zoom() * item->style->stroke_width.computed * - item->i2d_affine().descrim() * 0.5 + item->i2dt_affine().descrim() * 0.5 : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); @@ -1364,7 +1364,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !item->style->stroke.isNone() ? desktop->current_zoom() * item->style->stroke_width.computed * - item->i2d_affine().descrim() * 0.5 + item->i2dt_affine().descrim() * 0.5 : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 128ca281e..835ce7550 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -75,9 +75,9 @@ KnotHolderEntity::~KnotHolderEntity() void KnotHolderEntity::update_knot() { - Geom::Affine const i2d(item->i2d_affine()); + Geom::Affine const i2dt(item->i2dt_affine()); - Geom::Point dp(knot_get() * i2d); + Geom::Point dp(knot_get() * i2dt); _moved_connection.block(); sp_knot_set_position(knot, dp, SP_KNOT_STATE_NORMAL); @@ -87,21 +87,21 @@ KnotHolderEntity::update_knot() Geom::Point KnotHolderEntity::snap_knot_position(Geom::Point const &p) { - Geom::Affine const i2d (item->i2d_affine()); - Geom::Point s = p * i2d; + Geom::Affine const i2dt (item->i2dt_affine()); + Geom::Point s = p * i2dt; SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, item); m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE); m.unSetup(); - return s * i2d.inverse(); + return s * i2dt.inverse(); } Geom::Point KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint) { - Geom::Affine const i2d (item->i2d_affine()); + Geom::Affine const i2d (item->i2dt_affine()); Geom::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 59059c2a8..c26082baa 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -85,8 +85,6 @@ KnotHolder::~KnotHolder() { void KnotHolder::update_knots() { - Geom::Affine const i2d(item->i2d_affine()); - for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity *e = *i; e->update_knot(); @@ -165,8 +163,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; if (e->knot == knot) { - Geom::Point const q = p * item->i2d_affine().inverse(); - e->knot_set(q, e->knot->drag_origin * item->i2d_affine().inverse(), state); + Geom::Point const q = p * item->i2dt_affine().inverse(); + e->knot_set(q, e->knot->drag_origin * item->i2dt_affine().inverse(), state); break; } } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index e64cd0905..02d24752b 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -45,7 +45,7 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) { using namespace Geom; - Geom::Affine t = lpeitem->i2d_affine(); + Geom::Affine t = lpeitem->i2dt_affine(); Geom::Rect bbox = *lpeitem->getBounds(t); // fixme: what happens if getBounds does not return a valid rect? Point A(bbox.left(), bbox.bottom()); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index bd9748fd6..32da0a426 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -208,7 +208,7 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt) ShapeRecord r; r.role = SHAPE_ROLE_LPE_PARAM; - r.edit_transform = item->i2d_affine(); // TODO is it right? + r.edit_transform = item->i2dt_affine(); // TODO is it right? if (!href) { r.item = reinterpret_cast(param_effect->getLPEObj()); r.lpe_key = param_key; diff --git a/src/main.cpp b/src/main.cpp index 1614e97f7..ace99f519 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1321,7 +1321,7 @@ sp_do_export_png(SPDocument *doc) // write object bbox to area doc->ensureUpToDate(); Geom::OptRect areaMaybe; - static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2d_affine(), TRUE); + static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2dt_affine(), TRUE); if (areaMaybe) { area = *areaMaybe; } else { diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 28c8d44db..f042d2cf2 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -474,7 +474,7 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom g_assert(item != NULL); SPBox3D *box = SP_BOX3D(item); - Geom::Affine const i2d (item->i2d_affine ()); + Geom::Affine const i2dt (item->i2dt_affine ()); Box3D::Axis movement; if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) { @@ -483,7 +483,7 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom movement = Box3D::Z; } - box3d_set_corner (box, knot_id, s * i2d, movement, (state & GDK_CONTROL_MASK)); + box3d_set_corner (box, knot_id, s * i2dt, movement, (state & GDK_CONTROL_MASK)); box3d_set_z_orders(box); box3d_position_set(box); } @@ -650,9 +650,9 @@ Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point co Geom::Point const s = snap_knot_position(new_pos); SPBox3D *box = SP_BOX3D(item); - Geom::Affine const i2d (item->i2d_affine ()); + Geom::Affine const i2dt (item->i2dt_affine ()); - box3d_set_center (SP_BOX3D(item), s * i2d, origin * i2d, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, + box3d_set_center (SP_BOX3D(item), s * i2dt, origin * i2dt, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, state & GDK_CONTROL_MASK); box3d_set_z_orders(box); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index cb0935891..1267eda37 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -147,7 +147,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt(), true); } else { - item->invoke_bbox( bbox_of_item, item->i2d_affine(), true); + item->invoke_bbox( bbox_of_item, item->i2dt_affine(), true); } if (bbox_of_item) { // See if the item is within range @@ -406,7 +406,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) root_item); if (layout != NULL && layout->outputExists()) { Geom::PathVector *pv = new Geom::PathVector(); - pv->push_back(layout->baseline() * root_item->i2d_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt()); + pv->push_back(layout->baseline() * root_item->i2dt_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt()); _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_TEXT_BASELINE, Geom::OptRect())); } } @@ -432,7 +432,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, // Geom::PathVector *pv = pathvector_for_curve(root_item, curve, true, true, Geom::identity(), (*i).additional_affine); Geom::PathVector *pv = new Geom::PathVector(curve->get_pathvector()); - (*pv) *= root_item->i2d_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); + (*pv) *= root_item->i2dt_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. curve->unref(); diff --git a/src/selcue.cpp b/src/selcue.cpp index 171178c41..c647c1f96 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -191,7 +191,7 @@ void Inkscape::SelCue::_newTextBaselines() NULL); sp_canvas_item_show(baseline_point); - SP_CTRL(baseline_point)->moveto((*pt) * item->i2d_affine()); + SP_CTRL(baseline_point)->moveto((*pt) * item->i2dt_affine()); sp_canvas_item_move_to_z(baseline_point, 0); } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 9b88077e7..df3eaa388 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1399,7 +1399,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons item->readAttr( "transform" ); // calculate the matrix we need to apply to the clone to cancel its induced transform from its original - Geom::Affine parent2dt = SP_ITEM(item->parent)->i2d_affine(); + Geom::Affine parent2dt = SP_ITEM(item->parent)->i2dt_affine(); Geom::Affine t = parent2dt * affine * parent2dt.inverse(); Geom::Affine t_inv = t.inverse(); Geom::Affine result = t_inv * item->transform * t; @@ -1442,7 +1442,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } else { if (set_i2d) { - item->set_i2d_affine(item->i2d_affine() * (Geom::Affine)affine); + item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine); } item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate); } @@ -2248,8 +2248,8 @@ sp_select_clone_original(SPDesktop *desktop) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool highlight = prefs->getBool("/options/highlightoriginal/value"); if (highlight) { - Geom::OptRect a = item->getBounds(item->i2d_affine()); - Geom::OptRect b = original->getBounds(original->i2d_affine()); + Geom::OptRect a = item->getBounds(item->i2dt_affine()); + Geom::OptRect b = original->getBounds(original->i2dt_affine()); if ( a && b ) { // draw a flashing line between the objects SPCurve *curve = new SPCurve(); @@ -2766,7 +2766,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects - Geom::Affine eek(SP_ITEM(parent_object)->i2d_affine()); + Geom::Affine eek(SP_ITEM(parent_object)->i2dt_affine()); Geom::Affine t; double shift_x = bbox->min()[Geom::X]; @@ -2775,7 +2775,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) shift_x = round(shift_x); shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone } - t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse(); + t = Geom::Scale(1, -1) * Geom::Translate(shift_x, shift_y) * eek.inverse(); /// @fixme hardcoded doc2dt transform? // Do the export sp_export_png_file(document, filepath, @@ -3231,7 +3231,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) doc->ensureUpToDate(); SPItem const *const root = doc->getRoot(); - Geom::OptRect const bbox(root->getBounds(root->i2d_affine(), SPItem::RENDERING_BBOX)); + Geom::OptRect const bbox(root->getBounds(root->i2dt_affine(), SPItem::RENDERING_BBOX)); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index f6a702ed9..bc8194d48 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -267,7 +267,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(l->data), NULL)); _items.push_back(it); _items_const.push_back(it); - _items_affines.push_back(it->i2d_affine()); + _items_affines.push_back(it->i2dt_affine()); _items_centers.push_back(it->getCenter()); // for content-dragging, we need to remember original centers } @@ -586,7 +586,7 @@ void Inkscape::SelTrans::stamp() Geom::Affine const *new_affine; if (_show == SHOW_OUTLINE) { - Geom::Affine const i2d(original_item->i2d_affine()); + Geom::Affine const i2d(original_item->i2dt_affine()); Geom::Affine const i2dnew( i2d * _current_relative_affine ); copy_item->set_i2d_affine(i2dnew); new_affine = ©_item->transform; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 7ebedb816..d2ca2c445 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -282,7 +282,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectori2d_affine(); + Geom::Affine const i2dt = item->i2dt_affine(); // figure out if we have a slice, while guarding against rounding errors bool slice = false; @@ -308,7 +308,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vector= ellipse->start && angle <= ellipse->end) { - pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2d; + pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT, Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)); } } @@ -316,7 +316,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && slice && ellipse->closed) || snapprefs->getSnapObjectMidpoints()) { - pt = Geom::Point(cx, cy) * i2d; + pt = Geom::Point(cx, cy) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } @@ -324,12 +324,12 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && slice) { // Add the start point, if it's not coincident with a quadrant point if (fmod(ellipse->start, M_PI_2) != 0.0 ) { - pt = Geom::Point(cx + cos(ellipse->start)*rx, cy + sin(ellipse->start)*ry) * i2d; + pt = Geom::Point(cx + cos(ellipse->start)*rx, cy + sin(ellipse->start)*ry) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } // Add the end point, if it's not coincident with a quadrant point if (fmod(ellipse->end, M_PI_2) != 0.0 ) { - pt = Geom::Point(cx + cos(ellipse->end)*rx, cy + sin(ellipse->end)*ry) * i2d; + pt = Geom::Point(cx + cos(ellipse->end)*rx, cy + sin(ellipse->end)*ry) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 694e21dbd..87266464c 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -371,7 +371,7 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) dbox.y0 = 0.0; dbox.x1 = item->document->getWidth(); dbox.y1 = item->document->getHeight(); - Geom::Affine const ctm (item->i2d_affine()); + Geom::Affine const ctm (item->i2dt_affine()); group->layout.print(ctx, &pbox, &dbox, &bbox, ctm); } @@ -400,7 +400,7 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2dt_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); } } } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index c82c6fed4..c9647c939 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1303,7 +1303,7 @@ static void sp_image_snappoints( SPItem const *item, std::vectori2d_affine ()); + Geom::Affine const i2d (item->i2dt_affine ()); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index 2005356bd..fd27c896a 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -41,7 +41,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin s = (position - pos0) / dot(dir, dir). */ Geom::Translate const tr( ( position - pos0 ) * ( dir / dir_lensq ) ); - item.set_i2d_affine(item.i2d_affine() * tr); + item.set_i2d_affine(item.i2dt_affine() * tr); /// \todo Reget snappoints, check satisfied. if (commit) { diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 0fbce27f9..9f166e718 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -25,7 +25,7 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); // Rotate item. - item->set_i2d_affine(item->i2d_affine() * (Geom::Affine)affine); + item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine); // Use each item's own transform writer, consistent with sp_selection_apply_affine() item->doWriteTransform(item->getRepr(), item->transform); @@ -42,7 +42,7 @@ sp_item_scale_rel (SPItem *item, Geom::Scale const &scale) Geom::OptRect bbox = item->getBboxDesktop(); if (bbox) { Geom::Translate const s(bbox->midpoint()); // use getCenter? - item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s); + item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); item->doWriteTransform(item->getRepr(), item->transform); } } @@ -56,7 +56,7 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) Geom::Affine const skew(1, skewY, skewX, 1, 0, 0); Geom::Affine affine = Geom::Affine(s).inverse() * skew * Geom::Affine(s); - item->set_i2d_affine(item->i2d_affine() * affine); + item->set_i2d_affine(item->i2dt_affine() * affine); item->doWriteTransform(item->getRepr(), item->transform); // Restore the center position (it's changed because the bbox center changed) @@ -68,7 +68,7 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) { - item->set_i2d_affine(item->i2d_affine() * tr); + item->set_i2d_affine(item->i2dt_affine() * tr); item->doWriteTransform(item->getRepr(), item->transform); } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 43fe2c227..905a8f2db 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -272,7 +272,7 @@ void SPItem::setCenter(Geom::Point object_centre) { // for getBounds() to work document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(i2d_affine()); + Geom::OptRect bbox = getBounds(i2dt_affine()); if (bbox) { transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; if (fabs(transform_center_x) < 1e-5) // rounding error @@ -297,7 +297,7 @@ Geom::Point SPItem::getCenter() const { // for getBounds() to work document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(i2d_affine()); + Geom::OptRect bbox = getBounds(i2dt_affine()); if (bbox) { return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y); } else { @@ -790,11 +790,11 @@ void SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transfor } // transform the expansions by the item's transform: - Geom::Affine i2d(i2d_affine ()); - dx0 *= i2d.expansionX(); - dx1 *= i2d.expansionX(); - dy0 *= i2d.expansionY(); - dy1 *= i2d.expansionY(); + Geom::Affine i2dt(i2dt_affine ()); + dx0 *= i2dt.expansionX(); + dx1 *= i2dt.expansionX(); + dy0 *= i2dt.expansionY(); + dy1 *= i2dt.expansionY(); // expand the bbox temp_bbox.x0 += dx0; @@ -890,13 +890,13 @@ void SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) { g_assert(bbox != NULL); - invoke_bbox( bbox, i2d_affine(), TRUE, type); + invoke_bbox( bbox, i2dt_affine(), TRUE, type); } Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) { Geom::OptRect rect = Geom::OptRect(); - invoke_bbox( rect, i2d_affine(), TRUE, type); + invoke_bbox( rect, i2dt_affine(), TRUE, type); return rect; } @@ -907,7 +907,7 @@ void SPItem::sp_item_private_snappoints(SPItem const *item, std::vectorgetBounds(item->i2d_affine()); + Geom::OptRect bbox = item->getBounds(item->i2dt_affine()); if (bbox) { Geom::Point p1, p2; @@ -953,7 +953,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap for (std::vector::const_iterator p_orig = p_clip_or_mask.begin(); p_orig != p_clip_or_mask.end(); p_orig++) { // All snappoints are in desktop coordinates, but the item's transformation is // in document coordinates. Hence the awkward construction below - Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * i2d_affine(); + Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * i2dt_affine(); p.push_back(Inkscape::SnapCandidatePoint(pt, (*p_orig).getSourceType(), (*p_orig).getTargetType())); } } @@ -1465,11 +1465,13 @@ Geom::Affine SPItem::i2doc_affine() const /** * Returns the transformation from item to desktop coords */ -Geom::Affine SPItem::i2d_affine() const +Geom::Affine SPItem::i2dt_affine() const { - Geom::Affine const ret( i2doc_affine() - * Geom::Scale(1, -1) - * Geom::Translate(0, document->getHeight()) ); +// Geom::Affine const ret( i2doc_affine() +// * Geom::Scale(1, -1) +// * Geom::Translate(0, document->getHeight()) ); + SPDesktop const *desktop = inkscape_active_desktop(); + Geom::Affine const ret( i2doc_affine() * desktop->doc2dt() ); return ret; } @@ -1477,10 +1479,10 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) { Geom::Affine dt2p; /* desktop to item parent transform */ if (parent) { - dt2p = static_cast(parent)->i2d_affine().inverse(); + dt2p = static_cast(parent)->i2dt_affine().inverse(); } else { dt2p = ( Geom::Translate(0, -document->getHeight()) - * Geom::Scale(1, -1) ); + * Geom::Scale(1, -1) ); /// @fixme hardcoded doc2dt transform? } Geom::Affine const i2p( i2dt * dt2p ); @@ -1494,7 +1496,7 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) Geom::Affine SPItem::dt2i_affine() const { /* fixme: Implement the right way (Lauris) */ - return i2d_affine().inverse(); + return i2dt_affine().inverse(); } /* Item views */ diff --git a/src/sp-item.h b/src/sp-item.h index 7c3eb87d9..0065a9c0e 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -201,7 +201,7 @@ public: void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); Geom::Affine i2doc_affine() const; - Geom::Affine i2d_affine() const; + Geom::Affine i2dt_affine() const; void set_i2d_affine(Geom::Affine const &transform); Geom::Affine dt2i_affine() const; void convert_to_guides(); diff --git a/src/sp-line.cpp b/src/sp-line.cpp index b21122566..0f467b68e 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -179,10 +179,10 @@ void SPLine::convertToGuides(SPItem *item) SPLine *line = SP_LINE(item); Geom::Point points[2]; - Geom::Affine const i2d(item->i2d_affine()); + Geom::Affine const i2dt(item->i2dt_affine()); - points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2d; - points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2d; + points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2dt; + points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2dt; SPGuide::createSPGuide(inkscape_active_desktop(), points[0], points[1]); } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 6191d114f..d9fb006f2 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -169,7 +169,7 @@ sp_path_convert_to_guides(SPItem *item) std::list > pts; - Geom::Affine const i2d(path->i2d_affine()); + Geom::Affine const i2dt(path->i2dt_affine()); Geom::PathVector const & pv = curve->get_pathvector(); for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { @@ -177,7 +177,7 @@ sp_path_convert_to_guides(SPItem *item) // only add curves for straight line segments if( is_straight_curve(*cit) ) { - pts.push_back(std::make_pair(cit->initialPoint() * i2d, cit->finalPoint() * i2d)); + pts.push_back(std::make_pair(cit->initialPoint() * i2dt, cit->finalPoint() * i2dt)); } } } diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 7cc9c7f29..ec83a47e9 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -573,12 +573,12 @@ static void sp_rect_snappoints(SPItem const *item, std::vectori2d_affine ()); + Geom::Affine const i2dt (item->i2dt_affine ()); - Geom::Point p0 = Geom::Point(rect->x.computed, rect->y.computed) * i2d; - Geom::Point p1 = Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d; - Geom::Point p2 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d; - Geom::Point p3 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d; + Geom::Point p0 = Geom::Point(rect->x.computed, rect->y.computed) * i2dt; + Geom::Point p1 = Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2dt; + Geom::Point p2 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2dt; + Geom::Point p3 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2dt; if (snapprefs->getSnapToItemNode()) { p.push_back(Inkscape::SnapCandidatePoint(p0, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); @@ -612,12 +612,12 @@ sp_rect_convert_to_guides(SPItem *item) { std::list > pts; - Geom::Affine const i2d(rect->i2d_affine()); + Geom::Affine const i2dt(rect->i2dt_affine()); - Geom::Point A1(Geom::Point(rect->x.computed, rect->y.computed) * i2d); - Geom::Point A2(Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d); - Geom::Point A3(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d); - Geom::Point A4(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d); + Geom::Point A1(Geom::Point(rect->x.computed, rect->y.computed) * i2dt); + Geom::Point A2(Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2dt); + Geom::Point A3(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2dt); + Geom::Point A4(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2dt); pts.push_back(std::make_pair(A1, A2)); pts.push_back(std::make_pair(A2, A3)); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index bbfa98598..beec860be 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -763,16 +763,16 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) dbox.x1 = item->document->getWidth(); dbox.y1 = item->document->getHeight(); item->getBboxDesktop (&bbox); - Geom::Affine const i2d(item->i2d_affine()); + Geom::Affine const i2dt(item->i2dt_affine()); SPStyle* style = item->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox); + sp_print_fill (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox); + sp_print_stroke (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); } /** \todo make code prettier */ @@ -1197,10 +1197,10 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectori2d_affine ()); + Geom::Affine const i2dt (item->i2dt_affine ()); if (snapprefs->getSnapObjectMidpoints()) { - Geom::OptRect bbox = item->getBounds(item->i2d_affine()); + Geom::OptRect bbox = item->getBounds(i2dt); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } @@ -1209,7 +1209,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode()) { // Add the first point of the path - p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); + p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve @@ -1219,7 +1219,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping) if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { - p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2d, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2dt, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } } @@ -1227,7 +1227,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && !path_it->closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) - p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); + p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } } else { /* Test whether to add the node between curve_it1 and curve_it2. @@ -1256,7 +1256,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorfinalPoint() * i2d, sst, stt)); + p.push_back(Inkscape::SnapCandidatePoint(curve_it1->finalPoint() * i2dt, sst, stt)); } } @@ -1273,7 +1273,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector 0) { // There might be multiple intersections... for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { Geom::Point p_ix = (*path_it).pointAt((*i).ta); - p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2d, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION)); + p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2dt, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION)); } } } catch (Geom::RangeError &e) { diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index a772e057d..3ba05adc6 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -534,9 +534,9 @@ static void sp_spiral_snappoints(SPItem const *item, std::vectorgetSnapObjectMidpoints()) { - Geom::Affine const i2d (item->i2d_affine ()); + Geom::Affine const i2dt (item->i2dt_affine ()); SPSpiral *spiral = SP_SPIRAL(item); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(spiral->cx, spiral->cy) * i2d, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(spiral->cx, spiral->cy) * i2dt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); // This point is the start-point of the spiral, which is also returned when _snap_to_itemnode has been set // in the object snapper. In that case we will get a duplicate! } diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 17ddf7279..c7c2c54ad 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -562,8 +562,8 @@ static void sp_star_snappoints(SPItem const *item, std::vectorgetSnapObjectMidpoints()) { - Geom::Affine const i2d (item->i2d_affine ()); - p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2d,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); + Geom::Affine const i2dt (item->i2dt_affine ()); + p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2dt,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index f7ba7592b..89ca4ace4 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -450,7 +450,7 @@ static void sp_text_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2dt_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR)); } } } @@ -517,7 +517,7 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) dbox.y0 = 0.0; dbox.x1 = item->document->getWidth(); dbox.y1 = item->document->getHeight(); - Geom::Affine const ctm (item->i2d_affine()); + Geom::Affine const ctm (item->i2dt_affine()); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 3d3027639..d3d6c3db7 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1963,7 +1963,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - Geom::OptRect itemBbox = item->getBounds(item->i2d_affine()); + Geom::OptRect itemBbox = item->getBounds(item->i2dt_affine()); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8b0454893..33fffb01f 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -137,7 +137,7 @@ void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Ge Geom::Translate const s(c); Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); // Rotate item. - item->set_i2d_affine(item->i2d_affine() * (Geom::Affine)affine); + item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine); // Use each item's own transform writer, consistent with sp_selection_apply_affine() item->doWriteTransform(item->getRepr(), item->transform); // Restore the center position (it's changed because the bbox center changed) @@ -151,7 +151,7 @@ void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Ge void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) { Geom::Translate const s(c); - item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s); + item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); item->doWriteTransform(item->getRepr(), item->transform); } diff --git a/src/text-context.cpp b/src/text-context.cpp index 9edf96b26..1468984a1 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -1593,8 +1593,8 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) if (tc->text) { Geom::Point p0, p1; sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1); - Geom::Point const d0 = p0 * tc->text->i2d_affine(); - Geom::Point const d1 = p1 * tc->text->i2d_affine(); + Geom::Point const d0 = p0 * tc->text->i2dt_affine(); + Geom::Point const d1 = p1 * tc->text->i2dt_affine(); // scroll to show cursor if (scroll_to_see) { @@ -1675,7 +1675,7 @@ static void sp_text_context_update_text_selection(SPTextContext *tc) std::vector quads; if (tc->text != NULL) - quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, (tc->text)->i2d_affine()); + quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, (tc->text)->i2dt_affine()); for (unsigned i = 0 ; i < quads.size() ; i += 4) { SPCanvasItem *quad_canvasitem; quad_canvasitem = sp_canvas_item_new(sp_desktop_controls(tc->desktop), SP_TYPE_CTRLQUADR, NULL); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index b3f76817c..7b032065b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -87,7 +87,7 @@ bool sp_te_input_is_empty(SPObject const *item) Inkscape::Text::Layout::iterator sp_te_get_position_by_coords (SPItem const *item, Geom::Point const &i_p) { - Geom::Affine im (item->i2d_affine ()); + Geom::Affine im (item->i2dt_affine ()); im = im.inverse(); Geom::Point p = i_p * im; diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index eb4e28bd4..83598d8da 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -983,7 +983,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, } double blur_now = 0; - Geom::Affine i2d = item->i2d_affine (); + Geom::Affine i2dt = item->i2dt_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives SPObject *primitive_obj = style->getFilter()->children; @@ -994,7 +994,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, if(SP_IS_GAUSSIANBLUR(primitive)) { SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive); float num = spblur->stdDeviation.getNumber(); - blur_now += num * i2d.descrim(); // sum all blurs in the filter + blur_now += num * i2dt.descrim(); // sum all blurs in the filter } } primitive_obj = primitive_obj->next; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 904432d65..8728e2ef4 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -806,7 +806,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * (*it)->i2d_affine(); + Geom::Point base = *pt * (*it)->i2dt_affine(); if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X]; if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y]; if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X]; @@ -849,7 +849,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * (*it)->i2d_affine(); + Geom::Point base = *pt * (*it)->i2dt_affine(); Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; sp_item_move_rel(*it, Geom::Translate(t)); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index e83aeccad..bb800f9ca 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -995,7 +995,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() Geom::OptRect maybeArea(area); svgDoc->ensureUpToDate(); svgDoc->getRoot()->invoke_bbox( maybeArea, - svgDoc->getRoot()->i2d_affine(), TRUE); + svgDoc->getRoot()->i2dt_affine(), TRUE); NRArena *const arena = NRArena::create(); diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 7c7413ce5..68ad9393c 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -337,7 +337,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h // signs are inverted between x and y due to y inversion Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); - item->set_i2d_affine(item->i2d_affine() * affine); + item->set_i2d_affine(item->i2dt_affine() * affine); item->doWriteTransform(repr, item->transform, NULL); SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index f83f8c473..6385fce0a 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -485,7 +485,7 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) nt->flashed_item = over_item; SPCurve *c = SP_SHAPE(over_item)->getCurveBeforeLPE(); if (!c) break; // break out when curve doesn't exist - c->transform(over_item->i2d_affine()); + c->transform(over_item->i2dt_affine()); SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0, diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 9afcf6323..1310219a1 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -120,7 +120,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _lpe_key(lpe_key) { if (_lpe_key.empty()) { - _i2d_transform = path->i2d_affine(); + _i2d_transform = path->i2dt_affine(); } else { _i2d_transform = Geom::identity(); } @@ -976,7 +976,7 @@ void PathManipulator::_externalChange(unsigned type) } break; case PATH_CHANGE_TRANSFORM: { Geom::Affine i2d_change = _d2i_transform; - _i2d_transform = _path->i2d_affine(); + _i2d_transform = _path->i2dt_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { diff --git a/src/unclump.cpp b/src/unclump.cpp index baeeaff76..e570e8fa7 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -34,7 +34,7 @@ unclump_center (SPItem *item) return i->second; } - Geom::OptRect r = item->getBounds(item->i2d_affine()); + Geom::OptRect r = item->getBounds(item->i2dt_affine()); if (r) { Geom::Point const c = r->midpoint(); c_cache[item->getId()] = c; @@ -53,7 +53,7 @@ unclump_wh (SPItem *item) if ( i != wh_cache.end() ) { wh = i->second; } else { - Geom::OptRect r = item->getBounds(item->i2d_affine()); + Geom::OptRect r = item->getBounds(item->i2dt_affine()); if (r) { wh = r->dimensions(); wh_cache[item->getId()] = wh; @@ -297,7 +297,7 @@ unclump_push (SPItem *from, SPItem *what, double dist) //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", what->getId(), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); - what->set_i2d_affine(what->i2d_affine() * move); + what->set_i2d_affine(what->i2dt_affine() * move); what->doWriteTransform(what->getRepr(), what->transform, NULL); } @@ -320,7 +320,7 @@ unclump_pull (SPItem *to, SPItem *what, double dist) //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", what->getId(), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); - what->set_i2d_affine(what->i2d_affine() * move); + what->set_i2d_affine(what->i2dt_affine() * move); what->doWriteTransform(what->getRepr(), what->transform, NULL); } -- cgit v1.2.3 From ecfc5c910d6e4d43907f129ed4ffcaebe6d0de20 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 18 Jul 2011 19:22:32 +0200 Subject: consistency fix (potential bug) Fixed bugs: - https://launchpad.net/bugs/812413 (bzr r10468) --- src/libnrtype/FontInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 1b65dd88c..4288acd79 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -385,7 +385,7 @@ unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int } } if (free_res) { - free(res); + g_free(res); } return len; } -- cgit v1.2.3 From 0621c6d7ff695fca923ff3aa3003f25fccf94b32 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 18 Jul 2011 22:07:56 +0200 Subject: Replace NR_HUGE by Geom:infinity() in some snapping code (bzr r10469) --- src/object-snapper.cpp | 2 +- src/snap.cpp | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 1267eda37..389930b57 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -287,7 +287,7 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, for (std::vector::const_iterator k = _points_to_snap_to->begin(); k != _points_to_snap_to->end(); k++) { if (_allowSourceToSnapToTarget(p.getSourceType(), (*k).getTargetType(), strict_snapping)) { Geom::Point target_pt = (*k).getPoint(); - Geom::Coord dist = NR_HUGE; + Geom::Coord dist = Geom::infinity(); if (!c.isUndefined()) { // We're snapping to nodes along a constraint only, so find out if this node // is at the constraint, while allowing for a small margin diff --git a/src/snap.cpp b/src/snap.cpp index d556a751a..a3015e576 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -375,7 +375,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint // First project the mouse pointer onto the constraint Geom::Point pp = constraint.projection(p.getPoint()); - Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, NR_HUGE, 0, false, true, false); + Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::infinity(), 0, false, true, false); if (!someSnapperMightSnap()) { // Always return point on constraint @@ -437,7 +437,7 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi Geom::OptRect const &bbox_to_snap) const { - Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(p.getPoint(), p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, NR_HUGE, 0, false, true, false); + Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(p.getPoint(), p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::infinity(), 0, false, true, false); if (constraints.size() == 0) { return no_snap; } @@ -829,7 +829,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( break; case SCALE: { - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); // If this point *i is horizontally or vertically aligned with // the origin of the scaling, then it will scale purely in X or Y // We can therefore only calculate the scaling in this direction @@ -840,7 +840,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (fabs(fabs(a[index]/b[index]) - fabs(transformation[index])) > 1e-12) { // if SNAPPING DID occur in this direction result[index] = a[index] / b[index]; // then calculate it! } - // we might have left result[1-index] = NR_HUGE + // we might have left result[1-index] = Geom::infinity() // if scaling didn't occur in the other direction } } @@ -853,17 +853,17 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Compare the resulting scaling with the desired scaling - Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be NR_HUGE - if (scale_metric[0] == NR_HUGE || scale_metric[1] == NR_HUGE) { + Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be Geom::infinity() + if (scale_metric[0] == Geom::infinity() || scale_metric[1] == Geom::infinity()) { snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1])); } else { snapped_point.setSnapDistance(Geom::L2(scale_metric)); } - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; } case STRETCH: - result = Geom::Point(NR_HUGE, NR_HUGE); + result = Geom::Point(Geom::infinity(), Geom::infinity()); if (fabs(b[dim]) > 1e-6) { // if STRETCHING will occur for this point result[dim] = a[dim] / b[dim]; result[1-dim] = uniform ? result[dim] : 1; @@ -875,14 +875,14 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[dim] - transformation[dim])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; case SKEW: result[0] = (snapped_point.getPoint()[dim] - ((*i).getPoint())[dim]) / b[1 - dim]; // skew factor result[1] = transformation[1]; // scale factor // Store the metric for this transformation as a virtual distance snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; case ROTATE: // a is vector to snapped point; b is vector to original point; now lets calculate angle between a and b @@ -891,7 +891,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (Geom::L2(b) < 1e-9) { // points too close to the rotation center will not move. Don't try to snap these // as they will always yield a perfect snap result if they're already snapped beforehand (e.g. // when the transformation center has been snapped to a grid intersection in the selector tool) - snapped_point.setSnapDistance(NR_HUGE); + snapped_point.setSnapDistance(Geom::infinity()); // PS1: Apparently we don't have to do this for skewing, but why? // PS2: We cannot easily filter these points upstream, e.g. in the grab() method (seltrans.cpp) // because the rotation center will change when pressing shift, and grab() won't be recalled. @@ -900,7 +900,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } else { snapped_point.setSnapDistance(std::abs(result[0] - transformation[0])); } - snapped_point.setSecondSnapDistance(NR_HUGE); + snapped_point.setSecondSnapDistance(Geom::infinity()); break; default: g_assert_not_reached(); @@ -934,8 +934,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( if (transformation_type == SCALE) { // When scaling, don't ever exit with one of scaling components uninitialized for (int index = 0; index < 2; index++) { - if (fabs(best_transformation[index]) >= 1e12) { - if (uniform && fabs(best_transformation[1-index]) < 1e12) { + if (fabs(best_transformation[index]) == Geom::infinity()) { + if (uniform && fabs(best_transformation[1-index]) < Geom::infinity()) { best_transformation[index] = best_transformation[1-index]; } else { best_transformation[index] = transformation[index]; @@ -1458,8 +1458,8 @@ void SnapManager::keepClosestPointOnly(std::vector { if (points.size() < 2) return; - Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(NR_HUGE, NR_HUGE), Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED); - Geom::Coord closest_dist = NR_HUGE; + Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(Geom::infinity(), Geom::infinity()), Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED); + Geom::Coord closest_dist = Geom::infinity(); for(std::vector::const_iterator i = points.begin(); i != points.end(); i++) { Geom::Coord dist = Geom::L2((*i).getPoint() - reference); -- cgit v1.2.3 From e64932d2b80a507b0c8b3c2b575621005605be5c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 18 Jul 2011 22:20:21 +0200 Subject: fix hardcoded desktop2doc transform (bzr r10470) --- src/sp-item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 905a8f2db..072d6d57b 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1481,8 +1481,8 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) if (parent) { dt2p = static_cast(parent)->i2dt_affine().inverse(); } else { - dt2p = ( Geom::Translate(0, -document->getHeight()) - * Geom::Scale(1, -1) ); /// @fixme hardcoded doc2dt transform? + SPDesktop *dt = inkscape_active_desktop(); + dt2p = dt->dt2doc(); } Geom::Affine const i2p( i2dt * dt2p ); -- cgit v1.2.3 From 61ec015d8734244ecd6223e941ecc09eccdfcdaa Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 18 Jul 2011 22:44:25 +0200 Subject: refactor the guideline drawing. now it obeys desktop transforms a lot better. (bzr r10471) --- src/display/guideline.cpp | 56 ++++++++++++++++++++++++++--------------------- src/display/guideline.h | 2 ++ src/sp-guide.cpp | 26 +++++++++++++++++++--- 3 files changed, 56 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index c1c3e7740..0d2905d23 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -13,12 +13,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/coord.h> #include <2geom/transforms.h> #include "sp-canvas-util.h" #include "sp-ctrlpoint.h" #include "guideline.h" #include "display/cairo-utils.h" +#include "inkscape.h" // for inkscape_active_desktop() +#include "desktop.h" +#include "sp-namedview.h" + static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); static void sp_guideline_destroy(GtkObject *object); @@ -112,45 +117,46 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); cairo_set_font_size(buf->ct, 10); - int px = round(gl->point_on_line[Geom::X]); - int py = round(gl->point_on_line[Geom::Y]); + Geom::Point normal_dt = /*unit_vector*/(gl->normal_to_line * gl->affine.withoutTranslation()); // note that normal_dt does not have unit length + Geom::Point point_on_line_dt = gl->point_on_line * gl->affine; if (gl->label) { + int px = round(point_on_line_dt[Geom::X]); + int py = round(point_on_line_dt[Geom::Y]); cairo_save(buf->ct); cairo_translate(buf->ct, px, py); - cairo_rotate(buf->ct, atan2(gl->normal_to_line[Geom::X], gl->normal_to_line[Geom::Y])); + cairo_rotate(buf->ct, atan2(normal_dt.cw())); cairo_translate(buf->ct, 0, -5); cairo_move_to(buf->ct, 0, 0); cairo_show_text(buf->ct, gl->label); cairo_restore(buf->ct); } - if (gl->is_vertical()) { - int position = round(gl->point_on_line[Geom::X]); + if ( Geom::are_near(normal_dt[Geom::Y], 0.) ) { // is vertical? + int position = round(point_on_line_dt[Geom::X]); cairo_move_to(buf->ct, position + 0.5, buf->rect.y0 + 0.5); cairo_line_to(buf->ct, position + 0.5, buf->rect.y1 - 0.5); cairo_stroke(buf->ct); - } else if (gl->is_horizontal()) { - int position = round(gl->point_on_line[Geom::Y]); + } else if ( Geom::are_near(normal_dt[Geom::X], 0.) ) { // is horizontal? + int position = round(point_on_line_dt[Geom::Y]); cairo_move_to(buf->ct, buf->rect.x0 + 0.5, position + 0.5); cairo_line_to(buf->ct, buf->rect.x1 - 0.5, position + 0.5); cairo_stroke(buf->ct); } else { - // render angled line, once intersection has been detected, draw from there. - Geom::Point parallel_to_line( gl->normal_to_line[Geom::Y], - /*should be minus, but inverted y axis*/ gl->normal_to_line[Geom::X]); + // render angled line. Once intersection has been detected, draw from there. + Geom::Point parallel_to_line( normal_dt.ccw() ); //try to intersect with left vertical of rect - double y_intersect_left = (buf->rect.x0 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; + double y_intersect_left = (buf->rect.x0 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; if ( (y_intersect_left >= buf->rect.y0) && (y_intersect_left <= buf->rect.y1) ) { // intersects with left vertical! - double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; + double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; sp_guideline_drawline (buf, buf->rect.x0, static_cast(round(y_intersect_left)), buf->rect.x1, static_cast(round(y_intersect_right)), gl->rgba); goto end; } //try to intersect with right vertical of rect - double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; + double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; if ( (y_intersect_right >= buf->rect.y0) && (y_intersect_right <= buf->rect.y1) ) { // intersects with right vertical! sp_guideline_drawline (buf, buf->rect.x1, static_cast(round(y_intersect_right)), buf->rect.x0, static_cast(round(y_intersect_left)), gl->rgba); @@ -158,16 +164,16 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) } //try to intersect with top horizontal of rect - double x_intersect_top = (buf->rect.y0 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; + double x_intersect_top = (buf->rect.y0 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { // intersects with top horizontal! - double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; + double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; sp_guideline_drawline (buf, static_cast(round(x_intersect_top)), buf->rect.y0, static_cast(round(x_intersect_bottom)), buf->rect.y1, gl->rgba); goto end; } //try to intersect with bottom horizontal of rect - double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; + double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { // intersects with bottom horizontal! sp_guideline_drawline (buf, static_cast(round(x_intersect_bottom)), buf->rect.y1, static_cast(round(x_intersect_top)), buf->rect.y0, gl->rgba); @@ -186,16 +192,16 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, ((SPCanvasItemClass *) parent_class)->update(item, affine, flags); } - gl->point_on_line[Geom::X] = affine[4]; - gl->point_on_line[Geom::Y] = affine[5]; + gl->affine = affine; - sp_ctrlpoint_set_coords(gl->origin, gl->point_on_line * affine.inverse()); + sp_ctrlpoint_set_coords(gl->origin, gl->point_on_line); sp_canvas_item_request_update(SP_CANVAS_ITEM (gl->origin)); + Geom::Point pol_transformed = gl->point_on_line*affine; if (gl->is_horizontal()) { - sp_canvas_update_bbox (item, -1000000, round(gl->point_on_line[Geom::Y] - 16), 1000000, round(gl->point_on_line[Geom::Y] + 1)); + sp_canvas_update_bbox (item, -1000000, round(pol_transformed[Geom::Y] - 16), 1000000, round(pol_transformed[Geom::Y] + 1)); } else if (gl->is_vertical()) { - sp_canvas_update_bbox (item, round(gl->point_on_line[Geom::X]), -1000000, round(gl->point_on_line[Geom::X] + 16), 1000000); + sp_canvas_update_bbox (item, round(pol_transformed[Geom::X]), -1000000, round(pol_transformed[Geom::X] + 16), 1000000); } else { //TODO: labels in angled guidelines are not showing up for some reason. sp_canvas_update_bbox (item, -1000000, -1000000, 1000000, 1000000); @@ -213,8 +219,8 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem *actual_item = item; - Geom::Point vec(gl->normal_to_line[Geom::X], - gl->normal_to_line[Geom::Y]); - double distance = Geom::dot((p - gl->point_on_line), vec); + Geom::Point vec = gl->normal_to_line * gl->affine.withoutTranslation(); + double distance = Geom::dot((p - gl->point_on_line * gl->affine), unit_vector(vec)); return MAX(fabs(distance)-1, 0); } @@ -250,8 +256,8 @@ void sp_guideline_set_label(SPGuideLine *gl, const char* label) void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line) { - sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl), Geom::Affine(Geom::Translate(point_on_line))); - sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl->origin), Geom::Affine(Geom::Translate(point_on_line))); + gl->point_on_line = point_on_line; + sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); } void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line) diff --git a/src/display/guideline.h b/src/display/guideline.h index a3966f76f..164244c46 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -25,6 +25,8 @@ class SPCtrlPoint; struct SPGuideLine { SPCanvasItem item; + Geom::Affine affine; + SPCtrlPoint *origin; // unlike 'item', this is only held locally guint32 rgba; diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index f71bc1762..71312b698 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -40,6 +40,7 @@ #include "desktop.h" #include "sp-namedview.h" #include <2geom/angle.h> +#include <2geom/transforms.h> #include "document.h" using Inkscape::DocumentUndo; @@ -321,7 +322,14 @@ sp_guide_delete_all_guides(SPDesktop *dt) { void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { - SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line); + // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation) + // therefore, we have to correct for this first... + SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way... + Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1); + Geom::Point normal_dt = normal_to_line * correction.withoutTranslation() * desktop->doc2dt().withoutTranslation(); + Geom::Point point_on_line_dt = point_on_line * correction * desktop->doc2dt(); + + SPCanvasItem *item = sp_guideline_new(group, label, point_on_line_dt, normal_dt); sp_guideline_set_color(SP_GUIDELINE(item), color); g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); @@ -379,8 +387,14 @@ void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const { g_assert(SP_IS_GUIDE(&guide)); + // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation) + // therefore, we have to correct for this first... + SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way... + Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1); + Geom::Point point_on_line_dt = point_on_line * correction * desktop->doc2dt(); + for (GSList *l = guide.views; l != NULL; l = l->next) { - sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line); + sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line_dt); } /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit @@ -410,8 +424,14 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool { g_assert(SP_IS_GUIDE(&guide)); + // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation) + // therefore, we have to correct for this first... + SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way... + Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1); + Geom::Point normal_dt = normal_to_line * correction.withoutTranslation() * desktop->doc2dt().withoutTranslation(); + for (GSList *l = guide.views; l != NULL; l = l->next) { - sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line); + sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_dt); } /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit -- cgit v1.2.3 From 8c1d98b10004841b97520b6be6eaca72764cdd08 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 18 Jul 2011 22:55:55 +0200 Subject: revert unnecessary complicated change (bzr r10472) --- src/sp-guide.cpp | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 71312b698..f71bc1762 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -40,7 +40,6 @@ #include "desktop.h" #include "sp-namedview.h" #include <2geom/angle.h> -#include <2geom/transforms.h> #include "document.h" using Inkscape::DocumentUndo; @@ -322,14 +321,7 @@ sp_guide_delete_all_guides(SPDesktop *dt) { void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { - // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation) - // therefore, we have to correct for this first... - SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way... - Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1); - Geom::Point normal_dt = normal_to_line * correction.withoutTranslation() * desktop->doc2dt().withoutTranslation(); - Geom::Point point_on_line_dt = point_on_line * correction * desktop->doc2dt(); - - SPCanvasItem *item = sp_guideline_new(group, label, point_on_line_dt, normal_dt); + SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line); sp_guideline_set_color(SP_GUIDELINE(item), color); g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); @@ -387,14 +379,8 @@ void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const { g_assert(SP_IS_GUIDE(&guide)); - // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation) - // therefore, we have to correct for this first... - SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way... - Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1); - Geom::Point point_on_line_dt = point_on_line * correction * desktop->doc2dt(); - for (GSList *l = guide.views; l != NULL; l = l->next) { - sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line_dt); + sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line); } /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit @@ -424,14 +410,8 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool { g_assert(SP_IS_GUIDE(&guide)); - // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation) - // therefore, we have to correct for this first... - SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way... - Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1); - Geom::Point normal_dt = normal_to_line * correction.withoutTranslation() * desktop->doc2dt().withoutTranslation(); - for (GSList *l = guide.views; l != NULL; l = l->next) { - sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_dt); + sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line); } /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit -- cgit v1.2.3 From 70598b9113a9356674a842ca3786c6ee02de1cb9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 19 Jul 2011 00:07:10 +0200 Subject: Clean up some commented-out code (bzr r10347.1.16) --- src/display/canvas-arena.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index dd4a4ed5c..4c105cd09 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -199,12 +199,8 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) { + // todo: handle NR_ARENA_ITEM_RENDER_NO_CACHE SPCanvasArena *arena = SP_CANVAS_ARENA (item); - //SPCanvas *canvas = item->canvas; - - //nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, - // NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, - // NR_ARENA_ITEM_STATE_NONE); Geom::OptIntRect r = buf->rect; if (!r || r->hasZeroArea()) return; @@ -221,11 +217,8 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_save(buf->ct); cairo_translate(buf->ct, -r->left(), -r->top()); - //cairo_rectangle(buf->ct, r->left(), r->top(), r->width(), r->height()); - //cairo_clip(buf->ct); cairo_set_source_surface(buf->ct, arena->cache, arena->cache_area.left(), arena->cache_area.top()); cairo_paint(buf->ct); - //nr_arena_item_invoke_render (buf->ct, arena->root, &area, NULL, 0); cairo_restore(buf->ct); } -- cgit v1.2.3 From 0bf4c13f8cb4a90073210f2ace480701b854d370 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 19 Jul 2011 00:19:23 -0700 Subject: Minor code safety tweak to null out stale pointer. (bzr r10474) --- src/libnrtype/FontInstance.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 4288acd79..641adc3ac 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -386,6 +386,7 @@ unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int } if (free_res) { g_free(res); + res = 0; } return len; } -- cgit v1.2.3 From 153f8e791c8200fa4ed98f485466255c885e0995 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 19 Jul 2011 00:38:15 -0700 Subject: Fix index out of bounds problems. Corrects bug #812003. Fixed bugs: - https://launchpad.net/bugs/812003 (bzr r10475) --- src/2geom/bezier-curve.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/2geom/bezier-curve.cpp b/src/2geom/bezier-curve.cpp index 46aff8b49..6dfb0f0b3 100644 --- a/src/2geom/bezier-curve.cpp +++ b/src/2geom/bezier-curve.cpp @@ -106,10 +106,11 @@ namespace Geom BezierCurve::BezierCurve(std::vector const &pts) { - inner = D2(Bezier::Order(pts.size()-1), Bezier::Order(pts.size()-1)); + inner = D2(Bezier::Order(pts.size() - 1), Bezier::Order(pts.size() - 1)); for (unsigned d = 0; d < 2; ++d) { - for(unsigned i = 0; i <= pts.size(); i++) + for (unsigned i = 0; i < pts.size(); i++) { inner[d][i] = pts[i][d]; + } } } -- cgit v1.2.3 From 97b1c4d688a979eb8e327c13c6bcc6fad20902f2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 19 Jul 2011 20:24:59 +0200 Subject: remove some unnecessary inkscape_active_desktop() calls (bzr r10477) --- src/box3d.cpp | 2 +- src/sp-guide.cpp | 14 ++++++++------ src/sp-guide.h | 4 ++-- src/sp-item.cpp | 5 +---- src/sp-line.cpp | 2 +- src/sp-path.cpp | 2 +- src/sp-rect.cpp | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index ea1e35982..23f934b64 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -1422,7 +1422,7 @@ box3d_convert_to_guides(SPItem *item) { box3d_push_back_corner_pair(box, pts, 2, 6); box3d_push_back_corner_pair(box, pts, 3, 7); - sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts); + sp_guide_pt_pairs_to_guides(item->document, pts); } /* diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index f71bc1762..45491e5e5 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -261,9 +261,8 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) } } -SPGuide *SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) +SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2) { - SPDocument *doc = sp_desktop_document(desktop); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); @@ -273,7 +272,10 @@ SPGuide *SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom sp_repr_set_point(repr, "position", pt1); sp_repr_set_point(repr, "orientation", n); - desktop->namedview->appendChild(repr); + SPNamedView *namedview = sp_document_namedview(doc, NULL); + if (namedview) { + namedview->appendChild(repr); + } Inkscape::GC::release(repr); SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr)); @@ -281,9 +283,9 @@ SPGuide *SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom } void -sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > &pts) { +sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts) { for (std::list >::iterator i = pts.begin(); i != pts.end(); ++i) { - SPGuide::createSPGuide(dt, (*i).first, (*i).second); + SPGuide::createSPGuide(doc, (*i).first, (*i).second); } } @@ -302,7 +304,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { pts.push_back(std::make_pair(C, D)); pts.push_back(std::make_pair(D, A)); - sp_guide_pt_pairs_to_guides(dt, pts); + sp_guide_pt_pairs_to_guides(doc, pts); DocumentUndo::done(doc, SP_VERB_NONE, _("Create Guides Around the Page")); } diff --git a/src/sp-guide.h b/src/sp-guide.h index 4fbfbed3d..5d2a05791 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -43,7 +43,7 @@ public: inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); }; inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); }; inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); }; - static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); + static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2); void showSPGuide(SPCanvasGroup *group, GCallback handler); void hideSPGuide(SPCanvas *canvas); void sensitize(SPCanvas *canvas, gboolean sensitive); @@ -58,7 +58,7 @@ public: GType sp_guide_get_type(); -void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > &pts); +void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_delete_all_guides(SPDesktop *dt); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 072d6d57b..946c94353 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1574,9 +1574,6 @@ SPItem *sp_item_first_item_child(SPObject *obj) } void SPItem::convert_to_guides() { - SPDesktop *dt = inkscape_active_desktop(); - sp_desktop_namedview(dt); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); SPItem::BBoxType bbox_type = (prefs_bbox ==0)? @@ -1600,7 +1597,7 @@ void SPItem::convert_to_guides() { pts.push_back(std::make_pair(C, D)); pts.push_back(std::make_pair(D, A)); - sp_guide_pt_pairs_to_guides(dt, pts); + sp_guide_pt_pairs_to_guides(document, pts); } /* diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 0f467b68e..d3faf2299 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -184,7 +184,7 @@ void SPLine::convertToGuides(SPItem *item) points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2dt; points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2dt; - SPGuide::createSPGuide(inkscape_active_desktop(), points[0], points[1]); + SPGuide::createSPGuide(item->document, points[0], points[1]); } Geom::Affine SPLine::setTransform(SPItem *item, Geom::Affine const &xform) diff --git a/src/sp-path.cpp b/src/sp-path.cpp index d9fb006f2..49cadc116 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -182,7 +182,7 @@ sp_path_convert_to_guides(SPItem *item) } } - sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts); + sp_guide_pt_pairs_to_guides(item->document, pts); } /** diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index ec83a47e9..467b37d17 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -624,7 +624,7 @@ sp_rect_convert_to_guides(SPItem *item) { pts.push_back(std::make_pair(A3, A4)); pts.push_back(std::make_pair(A4, A1)); - sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts); + sp_guide_pt_pairs_to_guides(item->document, pts); } /* -- cgit v1.2.3 From afa84f849bf79bce9ef7c2179982e62df8ca520b Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 19 Jul 2011 20:49:49 +0200 Subject: another case of SP_ACTIVE_DESKTOP removed (bzr r10478) --- src/sp-guide.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 45491e5e5..8d9d7b87d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -474,11 +474,12 @@ char *sp_guide_description(SPGuide const *guide, const bool verbose) { using Geom::X; using Geom::Y; - + + SPNamedView *namedview = sp_document_namedview(guide->document, NULL); GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], - SP_ACTIVE_DESKTOP->namedview->getDefaultMetric()); + namedview->getDefaultMetric()); GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], - SP_ACTIVE_DESKTOP->namedview->getDefaultMetric()); + namedview->getDefaultMetric()); gchar *shortcuts = g_strdup_printf("; %s", _("Shift+drag to rotate, Ctrl+drag to move origin, Del to delete")); gchar *descr; -- cgit v1.2.3 From 7066baff7da784e3570ea5dcced1435fd5689847 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 19 Jul 2011 22:23:41 +0200 Subject: Add two new snap icons, and fix toggling bug for a single button (bzr r10479) --- src/widgets/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 9e28e4bee..1d1fe65bb 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2564,7 +2564,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter()); gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11b->gobj()), nv->snap_manager.snapprefs.getSnapTextBaseline()); - gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); + gtk_action_set_sensitive(GTK_ACTION(act11b->gobj()), c1 && c5); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.getSnapToPageBorder()); gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1); -- cgit v1.2.3 From e24a1e86c4d4cdf272e3ec0cd33b31bf2d59244c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 20 Jul 2011 01:01:23 +0200 Subject: Remove deprecated Glib symbols Fixed bugs: - https://launchpad.net/bugs/367606 (bzr r10480) --- src/dialogs/export.cpp | 14 +++++++++----- src/helper/units.cpp | 4 ++-- src/prefix.cpp | 4 ++-- src/selection-chemistry.cpp | 5 +++-- src/sp-namedview.cpp | 6 +++--- src/widgets/desktop-widget.cpp | 4 +--- src/xml/repr-util.cpp | 6 +++--- 7 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index c839c376b..0c2bc5adc 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -358,18 +358,18 @@ gchar* create_filepath_from_id (const gchar *id, const gchar *file_entry_text) { if (id == NULL) /* This should never happen */ id = "bitmap"; - gchar * directory = NULL; + gchar *directory = NULL; if (directory == NULL && file_entry_text != NULL && file_entry_text[0] != '\0') { // std::cout << "Directory from dialog" << std::endl; - directory = g_dirname(file_entry_text); + directory = g_path_get_dirname(file_entry_text); } if (directory == NULL) { /* Grab document directory */ if ( SP_ACTIVE_DOCUMENT->getURI() ) { // std::cout << "Directory from document" << std::endl; - directory = g_dirname( SP_ACTIVE_DOCUMENT->getURI() ); + directory = g_path_get_dirname( SP_ACTIVE_DOCUMENT->getURI() ); } } @@ -1053,7 +1053,7 @@ filename_add_extension (const gchar *filename, const gchar *extension) return g_strconcat (filename, extension, NULL); else { - if (g_strcasecmp (dot + 1, extension) == 0) + if (g_ascii_strcasecmp (dot + 1, extension) == 0) return g_strdup (filename); else { @@ -1282,11 +1282,13 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) for(; reprlst != NULL; reprlst = reprlst->next) { Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; const gchar * temp_string; + gchar *dir = g_path_get_dirname(filename); + gchar *docdir = g_path_get_dirname(SP_ACTIVE_DOCUMENT->getURI()); if (repr->attribute("id") == NULL || !(g_strrstr(filename_ext, repr->attribute("id")) != NULL && ( !SP_ACTIVE_DOCUMENT->getURI() || - strcmp(g_dirname(filename), g_dirname(SP_ACTIVE_DOCUMENT->getURI())) == 0))) { + strcmp(dir, docdir) == 0))) { temp_string = repr->attribute("inkscape:export-filename"); if (temp_string == NULL || strcmp(temp_string, filename_ext)) { repr->setAttribute("inkscape:export-filename", filename_ext); @@ -1303,6 +1305,8 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); modified = true; } + g_free(dir); + g_free(docdir); } DocumentUndo::setUndoSensitive(doc, saved); diff --git a/src/helper/units.cpp b/src/helper/units.cpp index 7914feeb3..4f5443e72 100644 --- a/src/helper/units.cpp +++ b/src/helper/units.cpp @@ -60,8 +60,8 @@ sp_unit_get_by_abbreviation(gchar const *abbreviation) g_return_val_if_fail(abbreviation != NULL, NULL); for (unsigned i = 0 ; i < sp_num_units ; i++) { - if (!g_strcasecmp(abbreviation, sp_units[i].abbr)) return &sp_units[i]; - if (!g_strcasecmp(abbreviation, sp_units[i].abbr_plural)) return &sp_units[i]; + if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr)) return &sp_units[i]; + if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr_plural)) return &sp_units[i]; } return NULL; diff --git a/src/prefix.cpp b/src/prefix.cpp index 92409a7d2..99e20171f 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -340,8 +340,8 @@ br_strndup (char *str, size_t size) * path: A path. * Returns: A directory name. This string should be freed when no longer needed. * - * Extracts the directory component of path. Similar to g_dirname() or the dirname - * commandline application. + * Extracts the directory component of path. Similar to g_path_get_dirname() + * or the dirname commandline application. * * Example: * br_extract_dir ("/usr/local/foobar"); --> Returns: "/usr/local" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index df3eaa388..23991bfb6 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2691,14 +2691,15 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) g_strcanon(basename, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.=+~$#@^&!?", '_'); // Build the complete path by adding document base dir, if set, otherwise home dir - gchar * directory = NULL; + gchar *directory = NULL; if ( document->getURI() ) { - directory = g_dirname( document->getURI() ); + directory = g_path_get_dirname( document->getURI() ); } if (directory == NULL) { directory = homedir_path(NULL); } gchar *filepath = g_build_filename(directory, basename, NULL); + g_free(directory); //g_print("%s\n", filepath); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index ac2d7dc1b..55947dacb 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -990,9 +990,9 @@ GSList const *SPNamedView::getViewList() const static gboolean sp_str_to_bool(const gchar *str) { if (str) { - if (!g_strcasecmp(str, "true") || - !g_strcasecmp(str, "yes") || - !g_strcasecmp(str, "y") || + if (!g_ascii_strcasecmp(str, "true") || + !g_ascii_strcasecmp(str, "yes") || + !g_ascii_strcasecmp(str, "y") || (atoi(str) != 0)) { return TRUE; } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index c51b88251..7958a9d07 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -631,9 +631,7 @@ SPDesktopWidget::updateTitle(gchar const* uri) Gtk::Window *window = (Gtk::Window*)g_object_get_data(G_OBJECT(this), "window"); if (window) { - gchar const *fname = ( TRUE - ? uri - : g_basename(uri) ); + gchar const *fname = uri; GString *name = g_string_new (""); gchar const *grayscalename = "(grayscale) "; diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 9405cde01..db1d5591e 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -494,9 +494,9 @@ sp_repr_get_boolean(Inkscape::XML::Node *repr, gchar const *key, unsigned int *v v = repr->attribute(key); if (v != NULL) { - if (!g_strcasecmp(v, "true") || - !g_strcasecmp(v, "yes" ) || - !g_strcasecmp(v, "y" ) || + if (!g_ascii_strcasecmp(v, "true") || + !g_ascii_strcasecmp(v, "yes" ) || + !g_ascii_strcasecmp(v, "y" ) || (atoi(v) != 0)) { *val = TRUE; } else { -- cgit v1.2.3 From 02d104385bc03c0019a145d65241a22f2f23d253 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 20 Jul 2011 07:27:55 +0200 Subject: memory leak fix (bzr r10481) --- src/io/ftos.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/io/ftos.cpp b/src/io/ftos.cpp index 47f0dc232..b8d161ca4 100644 --- a/src/io/ftos.cpp +++ b/src/io/ftos.cpp @@ -320,6 +320,7 @@ string ftos(double val, char mode, int sigfig, int precision, int options) break; default: + g_free(p); return "**bad mode**"; } @@ -413,6 +414,7 @@ string ftos(double val, char mode, int sigfig, int precision, int options) fprintf(stderr, "*** End of ftos with ascii = ", ascii.c_str()); #endif /* finally, we can return */ + g_free(p); return ascii; } -- cgit v1.2.3 From 6ff4ed36cd6ff0aff0b8fff0040794e9a0fdcc96 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 20 Jul 2011 18:06:49 +0200 Subject: Filters. Custom predefined filters update. Translations. inkscape.pot and fr.po update. (bzr r10482) --- src/extension/internal/filter/color.h | 60 +++++++++++++++++----------- src/extension/internal/filter/experimental.h | 24 +++++++---- src/extension/internal/filter/image.h | 6 +-- src/extension/internal/filter/shadows.h | 38 +++++++++++++----- 4 files changed, 84 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 27b1fdda9..53734bee5 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -39,9 +39,10 @@ namespace Filter { Brightness filter. Filter's parameters: - * Strength (-10.->10., default 1) -> colorMatrix (RVB entries) - * Vibration (-10.->10., default 0.) -> colorMatrix (6 other entries) + * Brightness (1.->10., default 2.) -> colorMatrix (RVB entries) + * Over-saturation (0.->10., default 0.5) -> colorMatrix (6 other entries) * Lightness (-10.->10., default 0.) -> colorMatrix (last column) + * Inverted (boolean, default false) -> colorMatrix Matrix: St Vi Vi 0 Li @@ -62,9 +63,10 @@ public: "\n" "" N_("Brightness, custom (Color)") "\n" "org.inkscape.effect.filter.Brightness\n" - "1\n" - "0\n" + "2\n" + "0.5\n" "0\n" + "false\n" "\n" "all\n" "\n" @@ -83,21 +85,29 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream strength; - std::ostringstream vibration; + std::ostringstream brightness; + std::ostringstream sat; std::ostringstream lightness; - strength << ext->get_param_float("strength"); - vibration << ext->get_param_float("vibration"); - lightness << ext->get_param_float("lightness"); + if (ext->get_param_bool("invert")) { + brightness << -ext->get_param_float("brightness"); + sat << 1 + ext->get_param_float("sat"); + lightness << -ext->get_param_float("lightness"); + } else { + brightness << ext->get_param_float("brightness"); + sat << -ext->get_param_float("sat"); + lightness << ext->get_param_float("lightness"); + } + + _filter = g_strdup_printf( "\n" "\n" - "\n", strength.str().c_str(), vibration.str().c_str(), vibration.str().c_str(), - lightness.str().c_str(), vibration.str().c_str(), strength.str().c_str(), - vibration.str().c_str(), lightness.str().c_str(), vibration.str().c_str(), - vibration.str().c_str(), strength.str().c_str(), lightness.str().c_str()); + "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), + lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), + sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), + sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str()); return _filter; }; /* Brightness filter */ @@ -192,11 +202,12 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) nlight << ext->get_param_float("nlight"); blend1 << ext->get_param_enum("blend1"); blend2 << ext->get_param_enum("blend2"); - if (ext->get_param_bool("duotone")) + if (ext->get_param_bool("duotone")) { duotone << "0"; - else + } else { duotone << "1"; - + } + _filter = g_strdup_printf( "\n" "\n" @@ -297,17 +308,17 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) b2 << ((color2 >> 8) & 0xff); fluo << fluorescence; - if((g_ascii_strcasecmp("full", swaptype) == 0)) { + if ((g_ascii_strcasecmp("full", swaptype) == 0)) { swap1 << "in"; swap2 << "out"; a1 << (color1 & 0xff) / 255.0F; a2 << (color2 & 0xff) / 255.0F; - } else if((g_ascii_strcasecmp("color", swaptype) == 0)) { + } else if ((g_ascii_strcasecmp("color", swaptype) == 0)) { swap1 << "in"; swap2 << "out"; a1 << (color2 & 0xff) / 255.0F; a2 << (color1 & 0xff) / 255.0F; - } else if((g_ascii_strcasecmp("alpha", swaptype) == 0)) { + } else if ((g_ascii_strcasecmp("alpha", swaptype) == 0)) { swap1 << "out"; swap2 << "in"; a1 << (color2 & 0xff) / 255.0F; @@ -395,8 +406,9 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) // TransfertComponent table values are calculated based on the effect level and inverted parameters. int val = 0; int levels = ext->get_param_int("levels") + 1; - if (ext->get_param_bool("invert")) + if (ext->get_param_bool("invert")) { val = 1; + } values << val; for ( int step = 1 ; step <= levels ; step++ ) { if (val == 1) { @@ -721,7 +733,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) rotate << ext->get_param_int("rotate"); const gchar *type = ext->get_param_enum("type"); - if((g_ascii_strcasecmp("solarize", type) == 0)) { + if ((g_ascii_strcasecmp("solarize", type) == 0)) { // Solarize blend1 << "darken"; blend2 << "screen"; @@ -854,21 +866,21 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) glight << ext->get_param_float("glight"); const gchar *type = ext->get_param_enum("type"); - if((g_ascii_strcasecmp("enhue", type) == 0)) { + if ((g_ascii_strcasecmp("enhue", type) == 0)) { // Enhance hue c1in << "qminp"; c1in2 << "flood"; c2in << "SourceGraphic"; c2in2 << "blend6"; b6in2 << "qminpc"; - } else if((g_ascii_strcasecmp("rad", type) == 0)) { + } else if ((g_ascii_strcasecmp("rad", type) == 0)) { // Radiation c1in << "qminp"; c1in2 << "flood"; c2in << "blend6"; c2in2 << "qminpc"; b6in2 << "SourceGraphic"; - } else if((g_ascii_strcasecmp("htb", type) == 0)) { + } else if ((g_ascii_strcasecmp("htb", type) == 0)) { // Hue to background c1in << "qminp"; c1in2 << "BackgroundImage"; diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 96485ad97..84b0eea3d 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -580,7 +580,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) Normal = feComponentTransfer Dented = Normal + intermediate values * Transfer type (enum, default "descrete") -> component (type) - * Levels (1->15, default 5) -> component (tableValues) + * Levels (0->15, default 5) -> component (tableValues) * Blend mode (enum, default "Lighten") -> blend (mode) * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) @@ -609,11 +609,13 @@ public: "<_item value=\"discrete\">Poster\n" "<_item value=\"table\">Painting\n" "\n" - "5\n" + "5\n" "\n" "<_item value=\"lighten\">Lighten\n" "<_item value=\"normal\">Normal\n" "<_item value=\"darken\">Darken\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" "\n" "4.0\n" "0.5\n" @@ -659,11 +661,19 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) int levels = ext->get_param_int("levels") + 1; const gchar *effecttype = ext->get_param_enum("type"); float val = 0.0; - for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; - transf << " " << val; - if((g_ascii_strcasecmp("dented", effecttype) == 0)) { - transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); + if (levels == 1) { + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " 1 0 1"; + } else { + transf << " 1"; + } + } else { + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); + } } } transf << " 1"; diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 926c56a4d..f459466d5 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -53,7 +53,7 @@ public: "<_item value=\"vertical\">" N_("Vertical lines") "\n" "<_item value=\"horizontal\">" N_("Horizontal lines") "\n" "\n" - "1.0\n" + "1.0\n" "false\n" "\n" "all\n" @@ -80,14 +80,14 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) const gchar *type = ext->get_param_enum("type"); - level << ext->get_param_float("level"); + level << 1 / ext->get_param_float("level"); if ((g_ascii_strcasecmp("vertical", type) == 0)) { matrix << "0 0 0 1 -2 1 0 0 0"; } else if ((g_ascii_strcasecmp("horizontal", type) == 0)) { matrix << "0 1 0 0 -2 0 0 1 0"; } else { - matrix << "1 1 1 1 -8 1 1 1 1"; + matrix << "0 1 0 1 -4 1 0 1 0"; } if (ext->get_param_bool("inverted")) { diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index bfc6cace6..3c964da34 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -37,7 +37,8 @@ namespace Filter { * Blur type (enum, default outer) -> outer = composite1 (operator="in"), composite2 (operator="over", in1="SourceGraphic", in2="offset") inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic") - cutout = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") + innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") + outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset") * Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color) * Use object's color (boolean, default false) -> composite1 (in1, in2) */ @@ -62,7 +63,8 @@ public: "\n" "<_item value=\"outer\">" N_("Outer") "\n" "<_item value=\"inner\">" N_("Inner") "\n" - "<_item value=\"cutout\">" N_("Cutout") "\n" + "<_item value=\"innercut\">" N_("Inner cutout") "\n" + "<_item value=\"outercut\">" N_("Outer cutout") "\n" "\n" "\n" "\n" @@ -113,14 +115,26 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); - if (ext->get_param_bool("objcolor")) { - comp1in1 << "SourceGraphic"; - comp1in2 << "flood"; + // Select object or user-defined color + if ((g_ascii_strcasecmp("outercut", type) == 0)) { + if (ext->get_param_bool("objcolor")) { + comp2in1 << "SourceGraphic"; + comp2in2 << "offset"; + } else { + comp2in1 << "offset"; + comp2in2 << "SourceGraphic"; + } } else { - comp1in1 << "flood"; - comp1in2 << "SourceGraphic"; + if (ext->get_param_bool("objcolor")) { + comp1in1 << "SourceGraphic"; + comp1in2 << "flood"; + } else { + comp1in1 << "flood"; + comp1in2 << "SourceGraphic"; + } } + // Shadow mode if ((g_ascii_strcasecmp("outer", type) == 0)) { comp1op << "in"; comp2op << "over"; @@ -131,14 +145,18 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2op << "atop"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; - } else { + } else if ((g_ascii_strcasecmp("innercut", type) == 0)) { comp1op << "in"; comp2op << "out"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; + } else { //outercut + comp1op << "out"; + comp1in1 << "flood"; + comp1in2 << "SourceGraphic"; + comp2op << "in"; } - - + _filter = g_strdup_printf( "\n" "\n" -- cgit v1.2.3 From 527379af505ab25b77033407d0ab8f6dff6a59e4 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 20 Jul 2011 20:31:22 +0200 Subject: Memory leak fixes (Bug #812497) (bzr r10483) --- src/io/inkjar.cpp | 19 +++++++++++-------- src/io/streamtest.cpp | 8 +++++--- src/trace/imagemap.cpp | 8 +++++++- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp index c238aba36..20b164b99 100644 --- a/src/io/inkjar.cpp +++ b/src/io/inkjar.cpp @@ -139,16 +139,18 @@ bool JarFile::read_signature() #endif if (signature == 0x08074b50) { - //skip data descriptor - bytes = (guint8 *)malloc(sizeof(guint8) * 12); - if (!read(bytes, 12)) { - g_free(bytes); - return false; - } + //skip data descriptor + bytes = (guint8 *)g_malloc(sizeof(guint8) * 12); + if (!read(bytes, 12)) { + g_free(bytes); + return false; + } else { + g_free(bytes); + } } else if (signature == 0x02014b50 || signature == 0x04034b50) { - return true; + return true; } else { - return false; + return false; } return false; } @@ -214,6 +216,7 @@ GByteArray *JarFile::get_next_file_contents() if (_last_filename != NULL) g_free(_last_filename); _last_filename = NULL; + g_free(bytes); return NULL; } diff --git a/src/io/streamtest.cpp b/src/io/streamtest.cpp index b25ef43f0..2030e6a85 100644 --- a/src/io/streamtest.cpp +++ b/src/io/streamtest.cpp @@ -219,13 +219,15 @@ int main(int argc, char **argv) // create temp files somewhere else instead of current dir // TODO: clean them up too char * testpath = strdup("/tmp/streamtest-XXXXXX"); - testpath = mkdtemp(testpath); - if (!testpath) + char * testpath2; + testpath2 = mkdtemp(testpath); + free(testpath); + if (!testpath2) { perror("mkdtemp"); return 1; } - if (chdir(testpath)) + if (chdir(testpath2)) { perror("chdir"); return 1; diff --git a/src/trace/imagemap.cpp b/src/trace/imagemap.cpp index a9ad9b9c8..c5a6bc2b5 100644 --- a/src/trace/imagemap.cpp +++ b/src/trace/imagemap.cpp @@ -78,10 +78,16 @@ GrayMap *GrayMapCreate(int width, int height) me->height = height; me->pixels = (unsigned long *) malloc(sizeof(unsigned long) * width * height); + if (!me->pixels) + { + free(me); + return NULL; + } me->rows = (unsigned long **) malloc(sizeof(unsigned long *) * height); - if (!me->pixels || !me->rows) + if (!me->rows) { + free(me->pixels); free(me); return NULL; } -- cgit v1.2.3 From 8a2d2f26584bb8e13d5af226773925dcee9dce17 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 20 Jul 2011 22:47:24 +0200 Subject: Minor UI fix (bzr r10484) --- src/extension/internal/gdkpixbuf-input.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index c3a30a2f0..8b4c8805b 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -150,8 +150,8 @@ GdkpixbufInput::init(void) "%s\n" "org.inkscape.input.gdkpixbuf.%s\n" "\n" - "<_option value='embed'>" N_("embed") "\n" - "<_option value='link'>" N_("link") "\n" + "<_option value='embed'>" N_("Embed") "\n" + "<_option value='link'>" N_("Link") "\n" "\n" "<_param name='help' type='description'>" N_("Embed results in stand-alone, larger SVG files. Link references a file outside this SVG document and all files must be moved together.") "\n" "\n" -- cgit v1.2.3 From 328fad57dbfb65e3bd31062021d5cc3081e68515 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 22 Jul 2011 04:09:27 +0200 Subject: Replace direct use of Cairo contexts and surfaces in the rendering tree with wrappers which keep some extra information about the surface, amd NRRect and NRRectL use with Geom::Rect and Geom::IntRect. Should simplify implementing filter primitive subregions. (bzr r10347.1.17) --- src/2geom/affine.h | 4 +- src/2geom/bezier-curve.cpp | 5 +- src/2geom/coord.h | 6 -- src/2geom/forward.h | 1 + src/2geom/generic-interval.h | 4 +- src/2geom/generic-rect.h | 26 ++++-- src/2geom/int-point.h | 5 + src/2geom/interval.h | 15 ++- src/2geom/path-intersection.cpp | 2 + src/2geom/point.h | 15 +-- src/2geom/rect.h | 30 +----- src/2geom/transforms.h | 85 +++++++++++++---- src/dialogs/clonetiler.cpp | 24 ++--- src/display/Makefile_insert | 4 + src/display/cairo-templates.h | 4 + src/display/canvas-arena.cpp | 61 +++++++------ src/display/display-forward.h | 3 + src/display/drawing-context.cpp | 135 +++++++++++++++++++++++++++ src/display/drawing-context.h | 123 +++++++++++++++++++++++++ src/display/drawing-surface.cpp | 149 ++++++++++++++++++++++++++++++ src/display/drawing-surface.h | 78 ++++++++++++++++ src/display/nr-arena-glyphs.cpp | 147 +++++++++++------------------ src/display/nr-arena-glyphs.h | 2 +- src/display/nr-arena-group.cpp | 23 ++--- src/display/nr-arena-image.cpp | 108 +++++++++------------- src/display/nr-arena-item.cpp | 183 +++++++++++++++---------------------- src/display/nr-arena-item.h | 23 ++--- src/display/nr-arena-shape.cpp | 137 ++++++++++----------------- src/display/nr-arena-shape.h | 11 +-- src/display/nr-arena.cpp | 9 +- src/display/nr-arena.h | 3 +- src/display/nr-filter-image.cpp | 24 ++--- src/display/nr-filter-slot.cpp | 33 +++---- src/display/nr-filter-slot.h | 12 ++- src/display/nr-filter.cpp | 55 +++++------ src/display/nr-filter.h | 8 +- src/display/nr-style.cpp | 40 ++++---- src/display/nr-style.h | 13 ++- src/flood-context.cpp | 69 +++++++------- src/helper/pixbuf-ops.cpp | 19 +--- src/helper/png-write.cpp | 26 ++---- src/sp-pattern.cpp | 43 ++++----- src/trace/trace.cpp | 12 +-- src/ui/cache/svg_preview_cache.cpp | 50 +++++----- src/widgets/icon.cpp | 66 +++++++------ 45 files changed, 1139 insertions(+), 756 deletions(-) create mode 100644 src/display/drawing-context.cpp create mode 100644 src/display/drawing-context.h create mode 100644 src/display/drawing-surface.cpp create mode 100644 src/display/drawing-surface.h (limited to 'src') diff --git a/src/2geom/affine.h b/src/2geom/affine.h index b07fba0f7..d7a7a0692 100644 --- a/src/2geom/affine.h +++ b/src/2geom/affine.h @@ -65,7 +65,8 @@ class Affine , MultipliableNoncommutative< Affine, Rotate , MultipliableNoncommutative< Affine, HShear , MultipliableNoncommutative< Affine, VShear - > > > > > > > + , MultipliableNoncommutative< Affine, Zoom + > > > > > > > > { Coord _c[6]; public: @@ -113,6 +114,7 @@ public: Affine &operator*=(Rotate const &r); Affine &operator*=(HShear const &h); Affine &operator*=(VShear const &v); + Affine &operator*=(Zoom const &); /// @} bool operator==(Affine const &o) const { diff --git a/src/2geom/bezier-curve.cpp b/src/2geom/bezier-curve.cpp index 46aff8b49..8c40e5e42 100644 --- a/src/2geom/bezier-curve.cpp +++ b/src/2geom/bezier-curve.cpp @@ -106,10 +106,11 @@ namespace Geom BezierCurve::BezierCurve(std::vector const &pts) { - inner = D2(Bezier::Order(pts.size()-1), Bezier::Order(pts.size()-1)); + inner = D2(Bezier::Order(pts.size() - 1), Bezier::Order(pts.size() - 1)); for (unsigned d = 0; d < 2; ++d) { - for(unsigned i = 0; i <= pts.size(); i++) + for(unsigned i = 0; i < pts.size(); i++) { inner[d][i] = pts[i][d]; + } } } diff --git a/src/2geom/coord.h b/src/2geom/coord.h index c7bbcdcd4..f7bf2c5d0 100644 --- a/src/2geom/coord.h +++ b/src/2geom/coord.h @@ -69,9 +69,6 @@ struct CoordTraits { typedef OptIntInterval OptIntervalType; typedef IntRect RectType; typedef OptIntRect OptRectType; - inline static bool contains(IntCoord low, IntCoord high, IntCoord testlow, IntCoord testhigh) { - return low <= testlow && testhigh < high; - } }; template<> @@ -81,9 +78,6 @@ struct CoordTraits { typedef OptInterval OptIntervalType; typedef Rect RectType; typedef OptRect OptRectType; - inline static bool contains(Coord low, Coord high, Coord testlow, Coord testhigh) { - return low <= testlow && testhigh <= high; - } }; } // end namespace Geom diff --git a/src/2geom/forward.h b/src/2geom/forward.h index b1cad6f1f..0dbd9fa94 100644 --- a/src/2geom/forward.h +++ b/src/2geom/forward.h @@ -97,6 +97,7 @@ class Rotate; class Scale; class HShear; class VShear; +class Zoom; // templates template class D2; diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h index d719c16c8..a32e97d4b 100644 --- a/src/2geom/generic-interval.h +++ b/src/2geom/generic-interval.h @@ -106,11 +106,11 @@ public: /// @{ /** @brief Check whether the interval includes this number. */ bool contains(C val) const { - return CoordTraits::contains(min(), max(), val, val); + return min() <= val && val <= max(); } /** @brief Check whether the interval includes the given interval. */ bool contains(Self const &val) const { - return CoordTraits::contains(min(), max(), val.min(), val.max()); + return min() <= val.min() && val.max() <= max(); } /** @brief Check whether the intervals have any common elements. */ bool intersects(Self const &val) const { diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index d60c4bb0f..6dc57b169 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -40,6 +40,7 @@ #ifndef LIB2GEOM_SEEN_GENERIC_RECT_H #define LIB2GEOM_SEEN_GENERIC_RECT_H +#include #include namespace Geom { @@ -93,30 +94,37 @@ public: * @param end End of the range * @return Rectangle that contains all points from [start, end). */ template - static GenericRect from_range(InputIterator start, InputIterator end) { + static CRect from_range(InputIterator start, InputIterator end) { assert(start != end); CPoint p1 = *start++; - GenericRect result(p1, p1); + CRect result(p1, p1); for (; start != end; ++start) { result.expandTo(*start); } return result; } /** @brief Create a rectangle from a C-style array of points it should contain. */ - static GenericRect from_array(CPoint const *c, unsigned n) { - GenericRect result = GenericRect::from_range(c, c+n); + static CRect from_array(CPoint const *c, unsigned n) { + CRect result = GenericRect::from_range(c, c+n); return result; } /** @brief Create rectangle from origin and dimensions. */ - static GenericRect from_xywh(C x, C y, C w, C h) { + static CRect from_xywh(C x, C y, C w, C h) { CPoint xy(x, y); CPoint wh(w, h); - GenericRect result(xy, xy + wh); + CRect result(xy, xy + wh); return result; } /** @brief Create rectangle from origin and dimensions. */ - static GenericRect from_xywh(CPoint const &xy, CPoint const &wh) { - GenericRect result(xy, xy + wh); + static CRect from_xywh(CPoint const &xy, CPoint const &wh) { + CRect result(xy, xy + wh); + return result; + } + /// Create infinite rectangle. + static CRect infinite() { + CPoint p0(std::numeric_limits::min(), std::numeric_limits::min()); + CPoint p1(std::numeric_limits::max(), std::numeric_limits::max()); + CRect result(p0, p1); return result; } /// @} @@ -155,6 +163,8 @@ public: C width() const { return f[X].extent(); } /** @brief Get the vertical extent of the rectangle. */ C height() const { return f[Y].extent(); } + /** @brief Get the ratio of width to height of the rectangle. */ + Coord aspectRatio() const { return Coord(width()) / Coord(height()); } /** @brief Get rectangle's width and height as a point. * @return Point with X coordinate corresponding to the width and the Y coordinate diff --git a/src/2geom/int-point.h b/src/2geom/int-point.h index cf2fe720f..1a16ecb7a 100644 --- a/src/2geom/int-point.h +++ b/src/2geom/int-point.h @@ -83,6 +83,11 @@ public: } IntCoord operator[](Dim2 d) const { return _pt[d]; } IntCoord &operator[](Dim2 d) { return _pt[d]; } + + IntCoord x() const throw() { return _pt[X]; } + IntCoord &x() throw() { return _pt[X]; } + IntCoord y() const throw() { return _pt[Y]; } + IntCoord &y() throw() { return _pt[Y]; } /// @} /// @name Vector-like arithmetic operations diff --git a/src/2geom/interval.h b/src/2geom/interval.h index ee6d674d2..e95da4811 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -64,7 +64,7 @@ typedef GenericOptInterval OptInterval; class Interval : public GenericInterval , boost::multipliable< Interval - , boost::multipliable< Interval, Coord + , boost::multiplicative< Interval, Coord > > { typedef GenericInterval Base; @@ -180,7 +180,20 @@ public: /// @} }; +// functions required for Python bindings +inline Interval unify(Interval const &a, Interval const &b) +{ + Interval r = a | b; + return r; +} +inline OptInterval intersect(Interval const &a, Interval const &b) +{ + OptInterval r = a & b; + return r; } + +} // end namespace Geom + #endif //SEEN_INTERVAL_H /* diff --git a/src/2geom/path-intersection.cpp b/src/2geom/path-intersection.cpp index 7aa662abb..be3e3b7cc 100644 --- a/src/2geom/path-intersection.cpp +++ b/src/2geom/path-intersection.cpp @@ -271,6 +271,8 @@ intersect_polish_root (Curve const &A, double &s, } #ifdef HAVE_GSL + int status; + size_t iter = 0; if(0) { // the GSL version is more accurate, but taints this with GPL const size_t n = 2; struct rparams p = {A, B}; diff --git a/src/2geom/point.h b/src/2geom/point.h index 69da8a4ae..0eb771874 100644 --- a/src/2geom/point.h +++ b/src/2geom/point.h @@ -58,7 +58,8 @@ class Point , MultipliableNoncommutative< Point, Scale , MultipliableNoncommutative< Point, HShear , MultipliableNoncommutative< Point, VShear - > > > > > > > > > // this uses chaining so it looks weird, but works + , MultipliableNoncommutative< Point, Zoom + > > > > > > > > > > // this uses chaining so it looks weird, but works { Coord _pt[2]; public: @@ -111,6 +112,11 @@ public: Coord operator[](Dim2 d) const throw() { return _pt[d]; } Coord &operator[](Dim2 d) throw() { return _pt[d]; } + + Coord x() const throw() { return _pt[X]; } + Coord &x() throw() { return _pt[X]; } + Coord y() const throw() { return _pt[Y]; } + Coord &y() throw() { return _pt[Y]; } /// @} /// @name Vector operations @@ -172,12 +178,7 @@ public: Point &operator*=(Rotate const &r); Point &operator*=(HShear const &s); Point &operator*=(VShear const &s); - /** @brief Transform the point by the inverse of the specified matrix. */ - template - Point &operator/=(T const &m) { - *this *= m.inverse(); - return *this; - } + Point &operator*=(Zoom const &z); /// @} /// @name Conversion to integer points diff --git a/src/2geom/rect.h b/src/2geom/rect.h index e9f6cbeb7..f7d331523 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -73,31 +73,7 @@ public: Rect(Point const &a, Point const &b) : Base(a,b) {} Rect(Coord x0, Coord y0, Coord x1, Coord y1) : Base(x0, y0, x1, y1) {} Rect(Base const &b) : Base(b) {} - /** @brief Create a rectangle from a range of points. - * The resulting rectangle will contain all ponts from the range. - * The return type of iterators must be convertible to Point. - * The range must not be empty. For possibly empty ranges, see OptRect. - * @param start Beginning of the range - * @param end End of the range - * @return Rectangle that contains all points from [start, end). */ - template - static Rect from_range(InputIterator start, InputIterator end) { - Rect result = Base::from_range(start, end); - return result; - } - /** @brief Create a rectangle from a C-style array of points it should contain. */ - static Rect from_array(Point const *c, unsigned n) { - Rect result = Rect::from_range(c, c+n); - return result; - } - static Rect from_xywh(Coord x, Coord y, Coord w, Coord h) { - Rect result = Base::from_xywh(x, y, w, h); - return result; - } - static Rect from_xywh(Point const &o, Point const &dim) { - Rect result = Base::from_xywh(o, dim); - return result; - } + Rect(IntRect const &ir) : Base(ir.min(), ir.max()) {} /// @} /// @name Inspect dimensions. @@ -114,6 +90,10 @@ public: bool interiorIntersects(Rect const &r) const { return f[X].interiorIntersects(r[X]) && f[Y].interiorIntersects(r[Y]); } + /** @brief Check whether the interior includes the given point. */ + bool interiorContains(Point const &p) const { + return f[X].interiorContains(p[X]) && f[Y].interiorContains(p[Y]); + } /** @brief Check whether the interior includes all points in the given rectangle. * Interior of the rectangle is the entire rectangle without its borders. */ bool interiorContains(Rect const &r) const { diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 9623bed26..5627e8b6f 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -106,13 +106,14 @@ T pow(T const &t, int n) { class Translate : public TransformOperations< Translate > { - Translate() : vec(0, 0) {} Point vec; public: - /** @brief Construct a translation from its vector. */ - explicit Translate(Point const &p) : vec(p) {} - /** @brief Construct a translation from its coordinates. */ - explicit Translate(Coord x, Coord y) : vec(x, y) {} + /// Create a translation that doesn't do anything. + Translate() : vec(0, 0) {} + /// Construct a translation from its vector. + Translate(Point const &p) : vec(p) {} + /// Construct a translation from its coordinates. + Translate(Coord x, Coord y) : vec(x, y) {} operator Affine() const { Affine ret(1, 0, 0, 1, vec[X], vec[Y]); return ret; } Coord operator[](Dim2 dim) const { return vec[dim]; } @@ -120,9 +121,10 @@ public: Translate &operator*=(Translate const &o) { vec += o.vec; return *this; } bool operator==(Translate const &o) const { return vec == o.vec; } - /** @brief Get the inverse translation. */ + Point vector() const { return vec; } + /// Get the inverse translation. Translate inverse() const { return Translate(-vec); } - /** @brief Get a translation that doesn't do anything. */ + /// Get a translation that doesn't do anything. static Translate identity() { Translate ret; return ret; } friend class Point; @@ -136,10 +138,14 @@ class Scale : public TransformOperations< Scale > { Point vec; - Scale() : vec(1, 1) {} public: + /// Create a scaling that doesn't do anything. + Scale() : vec(1, 1) {} + /// Create a scaling from two scaling factors given as coordinates of a point. explicit Scale(Point const &p) : vec(p) {} + /// Create a scaling from two scaling factors. Scale(Coord x, Coord y) : vec(x, y) {} + /// Create an uniform scaling from a single scaling factor. explicit Scale(Coord s) : vec(s, s) {} inline operator Affine() const { Affine ret(vec[X], 0, 0, vec[Y], 0, 0); return ret; } @@ -150,6 +156,8 @@ public: Coord &operator[](unsigned d) { return vec[d]; } Scale &operator*=(Scale const &b) { vec[X] *= b[X]; vec[Y] *= b[Y]; return *this; } bool operator==(Scale const &o) const { return vec == o.vec; } + + Point vector() const { return vec; } Scale inverse() const { return Scale(1./vec[0], 1./vec[1]); } static Scale identity() { Scale ret; return ret; } @@ -162,15 +170,16 @@ public: class Rotate : public TransformOperations< Rotate > { - Rotate() : vec(1, 0) {} - Point vec; + Point vec; ///< @todo Convert to storing the angle, as it's more space-efficient. public: + /// Construct a zero-degree rotation. + Rotate() : vec(1, 0) {} /** @brief Construct a rotation from its angle in radians. * Positive arguments correspond to counter-clockwise rotations (if Y grows upwards). */ explicit Rotate(Coord theta) : vec(Point::polar(theta)) {} - /** @brief Construct a rotation from its characteristic vector. */ + /// Construct a rotation from its characteristic vector. explicit Rotate(Point const &p) : vec(unit_vector(p)) {} - /** @brief Construct a rotation from the coordinates of its characteristic vector. */ + /// Construct a rotation from the coordinates of its characteristic vector. explicit Rotate(Coord x, Coord y) { Rotate(Point(x, y)); } operator Affine() const { Affine ret(vec[X], vec[Y], -vec[Y], vec[X], 0, 0); return ret; } @@ -186,10 +195,10 @@ public: r.vec = Point(vec[X], -vec[Y]); return r; } - /** @brief Get a 0-degree rotation. */ + /// @brief Get a zero-degree rotation. static Rotate identity() { Rotate ret; return ret; } /** @brief Construct a rotation from its angle in degrees. - * Positive arguments correspond to counter-clockwise rotations (if Y grows upwards). */ + * Positive arguments correspond to clockwise rotations if Y grows downwards. */ static Rotate from_degrees(Coord deg) { Coord rad = (deg / 180.0) * M_PI; return Rotate(rad); @@ -213,8 +222,8 @@ public: void setFactor(Coord nf) { f = nf; } S &operator*=(S const &s) { f += s.f; return static_cast(*this); } bool operator==(S const &s) const { return f == s.f; } - S inverse() const { return S(-f); } - static S identity() { return S(0); } + S inverse() const { S ret(-f); return ret; } + static S identity() { S ret(0); return ret; } friend class Point; friend class Affine; @@ -244,6 +253,48 @@ public: operator Affine() const { Affine ret(1, f, 0, 1, 0, 0); return ret; } }; +/** @brief Combination of a translation and uniform scale. + * The translation part is applied first, then the result is scaled from the new origin. + * This way when the class is used to accumulate a zoom transform, trans always points + * to the new origin in original coordinates. + * @ingroup Transform */ +class Zoom + : public TransformOperations< Zoom > +{ + Coord _scale; + Point _trans; + Zoom() : _scale(1), _trans() {} +public: + /// Construct a zoom from a scaling factor. + explicit Zoom(Coord s) : _scale(s), _trans() {} + /// Construct a zoom from a translation. + explicit Zoom(Translate const &t) : _scale(1), _trans(t.vector()) {} + /// Construct a zoom from a scaling factor and a translation. + Zoom(Coord s, Translate const &t) : _scale(s), _trans(t.vector()) {} + + operator Affine() const { + Affine ret(_scale, 0, 0, _scale, _trans[X] * _scale, _trans[Y] * _scale); + return ret; + } + Zoom &operator*=(Zoom const &z) { + _trans += z._trans / _scale; + _scale *= z._scale; + return *this; + } + bool operator==(Zoom const &z) const { return _scale == z._scale && _trans == z._trans; } + + Coord scale() const { return _scale; } + void setScale(Coord s) { _scale = s; } + Point translation() const { return _trans; } + void setTranslation(Point const &p) { _trans = p; } + Zoom inverse() const { Zoom ret(1/_scale, Translate(-_trans*_scale)); return ret; } + static Zoom identity() { Zoom ret(1.0); return ret; } + static Zoom map_rect(Rect const &old_r, Rect const &new_r); + + friend class Point; + friend class Affine; +}; + /** @brief Specialization of exponentiation for Scale. * @relates Scale */ template<> @@ -259,7 +310,7 @@ inline Translate pow(Translate const &t, int n) { return ret; } -//TODO: matrix to trans/scale/rotate +//TODO: decomposition of Affine into some finite combination of the above classes } // end namespace Geom diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index f8553f2aa..1738754b4 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -14,6 +14,8 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif + +#include #include #include #include @@ -23,6 +25,7 @@ #include "desktop-handles.h" #include "dialog-events.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "document.h" @@ -875,29 +878,20 @@ static guint32 clonetiler_trace_pick(Geom::Rect box) nr_arena_item_set_transform(trace_root, &t); NRGC gc(NULL); gc.transform.setIdentity(); - nr_arena_item_invoke_update( trace_root, NULL, &gc, + nr_arena_item_invoke_update( trace_root, Geom::IntRect::infinite(), &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); /* Item integer bbox in points */ - NRRectL ibox; - ibox.x0 = floor(trace_zoom * box[Geom::X].min()); - ibox.y0 = floor(trace_zoom * box[Geom::Y].min()); - ibox.x1 = ceil(trace_zoom * box[Geom::X].max()); - ibox.y1 = ceil(trace_zoom * box[Geom::Y].max()); + Geom::IntRect ibox = (box * Geom::Scale(trace_zoom)).roundOutwards(); /* Find visible area */ - int width = ibox.x1 - ibox.x0; - int height = ibox.y1 - ibox.y0; - double R = 0, G = 0, B = 0, A = 0; - - cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - cairo_t *ct = cairo_create(s); - cairo_translate(ct, -ibox.x0, -ibox.y0); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ibox.width(), ibox.height()); + Inkscape::DrawingContext ct(s, ibox.min()); /* Render */ - nr_arena_item_invoke_render(ct, trace_root, &ibox, NULL, + nr_arena_item_invoke_render(ct, trace_root, ibox, NR_ARENA_ITEM_RENDER_NO_CACHE ); - cairo_destroy(ct); + double R = 0, G = 0, B = 0, A = 0; ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index fc7c8e9ab..53f87efb1 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -23,6 +23,10 @@ ink_common_sources += \ display/canvas-text.h \ display/curve.cpp \ display/curve.h \ + display/drawing-context.cpp \ + display/drawing-context.h \ + display/drawing-surface.cpp \ + display/drawing-surface.h \ display/gnome-canvas-acetate.cpp \ display/gnome-canvas-acetate.h \ display/grayscale.cpp \ diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index a79f58548..d4c8e1493 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -12,6 +12,10 @@ #ifndef SEEN_INKSCAPE_DISPLAY_CAIRO_TEMPLATES_H #define SEEN_INKSCAPE_DISPLAY_CAIRO_TEMPLATES_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef HAVE_OPENMP #include #include "preferences.h" diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 4c105cd09..1d5cfe826 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -19,6 +19,8 @@ #include "display/nr-arena-group.h" #include "display/canvas-arena.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" +#include "display/drawing-surface.h" enum { ARENA_EVENT, @@ -161,12 +163,15 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned guint reset; reset = (flags & SP_CANVAS_UPDATE_AFFINE)? NR_ARENA_ITEM_STATE_ALL : NR_ARENA_ITEM_STATE_NONE; - nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_ALL, reset); + nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_ALL, reset); - item->x1 = arena->root->bbox.x0 - 1; - item->y1 = arena->root->bbox.y0 - 1; - item->x2 = arena->root->bbox.x1 + 1; - item->y2 = arena->root->bbox.y1 + 1; + Geom::OptIntRect b = arena->root->bbox; + if (b) { + item->x1 = b->left() - 1; + item->y1 = b->top() - 1; + item->x2 = b->right() + 1; + item->y2 = b->bottom() + 1; + } if (arena->cursor) { /* Mess with enter/leave notifiers */ @@ -228,27 +233,23 @@ static void sp_canvas_arena_render_cache (SPCanvasItem *item, Geom::IntRect cons Geom::OptIntRect r = Geom::intersect(arena->cache_area, area); if (!r || r->hasZeroArea()) return; // nothing to do - - cairo_t *ct = cairo_create(arena->cache); - cairo_translate(ct, -arena->cache_area.left(), -arena->cache_area.top()); - - // clear area to paint - cairo_rectangle(ct, area.left(), area.top(), area.width(), area.height()); - cairo_clip(ct); - cairo_save(ct); - cairo_set_source_rgba(ct, 0,0,0,0); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_restore(ct); - - NRRectL nr_area(r); - nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, + Inkscape::DrawingSurface cache(arena->cache, arena->cache_area.min()); + Inkscape::DrawingContext ct(cache); + + ct.rectangle(area); + ct.clip(); + + { Inkscape::DrawingContext::Save save(ct); + ct.setSource(0,0,0,0); + ct.setOperator(CAIRO_OPERATOR_SOURCE); + ct.paint(); + } + + nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, NR_ARENA_ITEM_STATE_NONE); - nr_arena_item_invoke_render (ct, arena->root, &nr_area, NULL, 0); - - cairo_destroy(ct); + nr_arena_item_invoke_render (ct, arena->root, *r, 0); } static void @@ -267,7 +268,7 @@ sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ { SPCanvasArena *arena = SP_CANVAS_ARENA (item); - nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, + nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); @@ -367,7 +368,7 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->crossing.x, event->crossing.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); + nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); arena->active = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky); if (arena->active) nr_object_ref ((NRObject *) arena->active); ret = sp_canvas_arena_send_event (arena, event); @@ -388,7 +389,7 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->motion.x, event->motion.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); + nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; @@ -474,10 +475,10 @@ sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRR g_return_if_fail (ca != NULL); g_return_if_fail (SP_IS_CANVAS_ARENA (ca)); - cairo_t *ct = cairo_create(surface); - cairo_translate(ct, -r.x0, -r.y0); - nr_arena_item_invoke_render (ct, ca->root, &r, NULL, 0); - cairo_destroy(ct); + Geom::OptIntRect area = r.upgrade_2geom(); + if (!area) return; + Inkscape::DrawingContext ct(surface, area->min()); + nr_arena_item_invoke_render (ct, ca->root, *area, 0); } diff --git a/src/display/display-forward.h b/src/display/display-forward.h index bc7013214..288da829a 100644 --- a/src/display/display-forward.h +++ b/src/display/display-forward.h @@ -12,6 +12,9 @@ struct SPCanvasGroupClass; class SPCurve; namespace Inkscape { +class DrawingContext; +class DrawingSurface; + namespace Display { class TemporaryItem; class TemporaryItemList; diff --git a/src/display/drawing-context.cpp b/src/display/drawing-context.cpp new file mode 100644 index 000000000..8f37bb693 --- /dev/null +++ b/src/display/drawing-context.cpp @@ -0,0 +1,135 @@ +/** + * @file + * @brief Cairo drawing context with Inkscape extensions + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/drawing-context.h" +#include "display/drawing-surface.h" +#include "display/cairo-utils.h" +#include "helper/geom.h" + +namespace Inkscape { + +using Geom::X; +using Geom::Y; + +/** @class DrawingContext::Save + * @brief RAII idiom for saving the state of DrawingContext. */ + +DrawingContext::Save::Save() + : _ct(NULL) +{} +DrawingContext::Save::Save(DrawingContext &ct) + : _ct(&ct) +{ + _ct->save(); +} +DrawingContext::Save::~Save() +{ + if (_ct) { + _ct->restore(); + } +} +void DrawingContext::Save::save(DrawingContext &ct) +{ + if (_ct) { + // TODO: it might be better to treat this occurence as a bug + _ct->restore(); + } + _ct = &ct; + _ct->save(); +} + +/** @class DrawingContext + * @brief Minimal wrapper over Cairo. + * + * This is a wrapper over cairo_t, extended with operations that work + * with 2Geom geometrical primitives. Some of this is probably duplicated + * in cairo-render-context.cpp, which provides higher level operations + * for drawing entire SPObjects when exporting. + */ + +DrawingContext::DrawingContext(cairo_surface_t *surface, Geom::Point const &origin) + : _ct(NULL) + , _surface(new DrawingSurface(surface, origin)) + , _delete_surface(true) +{ + _surface->_has_context = true; + _ct = _surface->createRawContext(); +} + +DrawingContext::DrawingContext(DrawingSurface &s) + : _ct(s.createRawContext()) + , _surface(&s) + , _delete_surface(false) +{} + +DrawingContext::~DrawingContext() +{ + cairo_destroy(_ct); + _surface->_has_context = false; + if (_delete_surface) { + delete _surface; + } +} + +void DrawingContext::arc(Geom::Point const ¢er, double radius, Geom::AngleInterval const &angle) +{ + double from = angle.initialAngle(); + double to = angle.finalAngle(); + if (to > from) { + cairo_arc(_ct, center[X], center[Y], radius, from, to); + } else { + cairo_arc_negative(_ct, center[X], center[Y], radius, to, from); + } +} + +void DrawingContext::transform(Geom::Affine const &trans) { + ink_cairo_transform(_ct, trans); +} + +void DrawingContext::path(Geom::PathVector const &pv) { + feed_pathvector_to_cairo(_ct, pv); +} + +void DrawingContext::paint(double alpha) { + if (alpha == 1.0) cairo_paint(_ct); + else cairo_paint_with_alpha(_ct, alpha); +} +void DrawingContext::setSource(guint32 rgba) { + ink_cairo_set_source_rgba32(_ct, rgba); +} +void DrawingContext::setSource(DrawingSurface *s) { + Geom::Point origin = s->origin(); + cairo_set_source_surface(_ct, s->raw(), origin[X], origin[Y]); +} +void DrawingContext::setSourceCheckerboard() { + cairo_pattern_t *check = ink_cairo_pattern_create_checkerboard(); + cairo_set_source(_ct, check); + cairo_pattern_destroy(check); +} + +Geom::Rect DrawingContext::targetLogicalBounds() const +{ + Geom::Rect ret(_surface->area()); + return ret; +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h new file mode 100644 index 000000000..c0ea81874 --- /dev/null +++ b/src/display/drawing-context.h @@ -0,0 +1,123 @@ +/** + * @file + * @brief Cairo drawing context with Inkscape extensions + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_CONTEXT_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_CONTEXT_H + +#include +#include +#include +#include <2geom/affine.h> +#include <2geom/angle.h> +#include <2geom/rect.h> +#include <2geom/transforms.h> + +namespace Inkscape { + +class DrawingSurface; + +class DrawingContext + : boost::noncopyable +{ +public: + class Save { + public: + Save(); + Save(DrawingContext &ct); + ~Save(); + void save(DrawingContext &ct); + private: + DrawingContext *_ct; + }; + + DrawingContext(cairo_surface_t *surface, Geom::Point const &origin); + DrawingContext(DrawingSurface &s); + ~DrawingContext(); + + void save() { cairo_save(_ct); } + void restore() { cairo_restore(_ct); } + void pushGroup() { cairo_push_group(_ct); } + void pushAlphaGroup() { cairo_push_group_with_content(_ct, CAIRO_CONTENT_ALPHA); } + void popGroupToSource() { cairo_pop_group_to_source(_ct); } + + void transform(Geom::Affine const &trans); + void translate(Geom::Point const &t) { cairo_translate(_ct, t[Geom::X], t[Geom::Y]); } // todo: take Translate + void translate(double dx, double dy) { cairo_translate(_ct, dx, dy); } + void scale(Geom::Scale const &s) { cairo_scale(_ct, s[Geom::X], s[Geom::Y]); } + void scale(double sx, double sy) { cairo_scale(_ct, sx, sy); } + + void moveTo(Geom::Point const &p) { cairo_move_to(_ct, p[Geom::X], p[Geom::Y]); } + void lineTo(Geom::Point const &p) { cairo_line_to(_ct, p[Geom::X], p[Geom::Y]); } + void curveTo(Geom::Point const &p1, Geom::Point const &p2, Geom::Point const &p3) { + cairo_curve_to(_ct, p1[Geom::X], p1[Geom::Y], p2[Geom::X], p2[Geom::Y], p3[Geom::X], p3[Geom::Y]); + } + void arc(Geom::Point const ¢er, double radius, Geom::AngleInterval const &angle); + void rectangle(Geom::Rect const &r) { + cairo_rectangle(_ct, r.left(), r.top(), r.width(), r.height()); + } + void newPath() { cairo_new_path(_ct); } + void newSubpath() { cairo_new_sub_path(_ct); } + void path(Geom::PathVector const &pv); + + void paint(double alpha = 1.0); + void fill() { cairo_fill(_ct); } + void fillPreserve() { cairo_fill_preserve(_ct); } + void stroke() { cairo_stroke(_ct); } + void strokePreserve() { cairo_stroke_preserve(_ct); } + void clip() { cairo_clip(_ct); } + + void setLineWidth(double w) { cairo_set_line_width(_ct, w); } + void setLineCap(cairo_line_cap_t cap) { cairo_set_line_cap(_ct, cap); } + void setLineJoin(cairo_line_join_t join) { cairo_set_line_join(_ct, join); } + void setMiterLimit(double miter) { cairo_set_miter_limit(_ct, miter); } + void setFillRule(cairo_fill_rule_t rule) { cairo_set_fill_rule(_ct, rule); } + void setOperator(cairo_operator_t op) { cairo_set_operator(_ct, op); } + void setTolerance(double tol) { cairo_set_tolerance(_ct, tol); } + void setSource(cairo_pattern_t *source) { cairo_set_source(_ct, source); } + void setSource(cairo_surface_t *surface, double x, double y) { + cairo_set_source_surface(_ct, surface, x, y); + } + void setSource(double r, double g, double b, double a = 1.0) { + cairo_set_source_rgba(_ct, r, g, b, a); + } + void setSource(guint32 rgba); + void setSource(DrawingSurface *s); + void setSourceCheckerboard(); + + Geom::Rect targetLogicalBounds() const; + + cairo_t *raw() { return _ct; } + cairo_surface_t *rawTarget() { return cairo_get_group_target(_ct); } + +private: + DrawingContext(cairo_t *ct, DrawingSurface *surface, bool destroy); + + cairo_t *_ct; + DrawingSurface *_surface; + bool _delete_surface; + + friend class DrawingSurface; +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp new file mode 100644 index 000000000..e50a732c6 --- /dev/null +++ b/src/display/drawing-surface.cpp @@ -0,0 +1,149 @@ +/** + * @file + * @brief Cairo surface that remembers its origin + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/drawing-surface.h" +#include "display/cairo-utils.h" + +namespace Inkscape { + +using Geom::X; +using Geom::Y; + + +/** @class DrawingSurface + * @brief Drawing surface that remembers its origin. + * + * This is a very minimalistic wrapper over cairo_surface_t. The main + * extra functionality provided by this class is that it automates + * the mapping from "logical space" (coordinates in the rendering) + * and the "physical space" (surface pixels). For example, patterns + * have to be rendered on surfaces which have possibly non-integer + * widths and heights. + */ + +/** @brief Creates a surface with the given physical extents. + * When a drawing context is created for this surface, its pixels + * will cover the area under the given rectangle. */ +DrawingSurface::DrawingSurface(Geom::IntRect const &area) + : _surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height())) + , _origin(area.min()) + , _scale(1, 1) +{} + +/** @brief Creates a surface with the given logical extents. + * When a drawing context is created for this surface, its pixels + * will cover the area under the given rectangle. If the rectangle + * has non-integer width, there will be slightly more than 1 pixel + * per logical unit. */ +DrawingSurface::DrawingSurface(Geom::Rect const &area) + : _surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ceil(area.width()), ceil(area.height()))) + , _origin(area.min()) + , _scale(ceil(area.width()) / area.width(), ceil(area.height()) / area.height()) +{} + +/** @brief Creates a surface with the given logical and physical extents. + * When a drawing context is created for this surface, its pixels + * will cover the area under the given rectangle. IT will contain + * the number of pixels specified by the second argument. + * @param logbox Logical extents of the surface + * @param pixdims Pixel dimensions of the surface. */ +DrawingSurface::DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims) + : _surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pixdims[X], pixdims[Y])) + , _origin(logbox.min()) + , _scale(pixdims[X] / logbox.width(), pixdims[Y] / logbox.height()) +{} + +/** @brief Wrap a cairo_surface_t. + * This constructor will take an extra reference on @a surface, which will + * be released on destruction. */ +DrawingSurface::DrawingSurface(cairo_surface_t *surface, Geom::Point const &origin) + : _surface(surface) + , _origin(origin) + , _scale(1, 1) +{ + cairo_surface_reference(surface); +} + +DrawingSurface::~DrawingSurface() +{ + cairo_surface_destroy(_surface); +} + +/// Get the logical extents of the surface. +Geom::Rect +DrawingSurface::area() const +{ + Geom::Rect r = Geom::Rect::from_xywh(_origin, dimensions()); + return r; +} + +/// Get the logical width and weight of the surface as a point. +Geom::Point +DrawingSurface::dimensions() const +{ + double w = cairo_image_surface_get_width(_surface); + double h = cairo_image_surface_get_height(_surface); + Geom::Point logical_dims(w / _scale[X], h / _scale[Y]); + return logical_dims; +} + +Geom::Point +DrawingSurface::origin() const +{ + return _origin; +} + +Geom::Scale +DrawingSurface::scale() const +{ + return _scale; +} + +/// Get the transformation applied to the drawing context on construction. +Geom::Affine +DrawingSurface::drawingTransform() const +{ + Geom::Affine ret = _scale * Geom::Translate(-_origin); + return ret; +} + +cairo_surface_type_t +DrawingSurface::type() const +{ + // currently hardcoded + return CAIRO_SURFACE_TYPE_IMAGE; +} + +/** @brief Create a drawing context for this surface. + * It's better to use the surface constructor of DrawingContext. */ +cairo_t * +DrawingSurface::createRawContext() +{ + cairo_t *ct = cairo_create(_surface); + if (_scale != Geom::Scale::identity()) { + cairo_scale(ct, _scale[X], _scale[Y]); + } + cairo_translate(ct, -_origin[X], -_origin[Y]); + return ct; +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h new file mode 100644 index 000000000..2d0e147e2 --- /dev/null +++ b/src/display/drawing-surface.h @@ -0,0 +1,78 @@ +/** + * @file + * @brief Cairo surface that remembers its origin + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_SURFACE_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_SURFACE_H + +#include +#include +#include +#include <2geom/affine.h> +#include <2geom/rect.h> +#include <2geom/transforms.h> + +namespace Inkscape { +class DrawingContext; + +class DrawingSurface +{ +public: + explicit DrawingSurface(Geom::IntRect const &area); + explicit DrawingSurface(Geom::Rect const &area); + DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims); + DrawingSurface(cairo_surface_t *surface, Geom::Point const &origin); + virtual ~DrawingSurface(); + + Geom::Rect area() const; + Geom::Point dimensions() const; + Geom::Point origin() const; + Geom::Scale scale() const; + Geom::Affine drawingTransform() const; + cairo_surface_type_t type() const; + + cairo_surface_t *raw() { return _surface; } + cairo_t *createRawContext(); + +protected: + cairo_surface_t *_surface; + Geom::Point _origin; + Geom::Scale _scale; + bool _has_context; + + friend class DrawingContext; +}; + +class PixbufSurface + : public DrawingSurface +{ +public: + explicit PixbufSurface(GdkPixbuf *pb, Geom::Point const &origin = Geom::Point(0,0)); + ~PixbufSurface(); +protected: + GdkPixbuf *pb; + + friend class DrawingContext; +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index d09f66a2f..99b0a004e 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -14,13 +14,15 @@ #ifdef HAVE_CONFIG_H # include #endif -#include "libnr/nr-convert2geom.h" +#include #include <2geom/affine.h> +#include <2geom/rect.h> +#include "libnr/nr-convert2geom.h" #include "style.h" #include "display/nr-arena.h" #include "display/nr-arena-glyphs.h" -#include #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "helper/geom.h" #ifdef test_glyph_liv @@ -39,9 +41,8 @@ static void nr_arena_glyphs_class_init(NRArenaGlyphsClass *klass); static void nr_arena_glyphs_init(NRArenaGlyphs *glyphs); static void nr_arena_glyphs_finalize(NRObject *object); -static guint nr_arena_glyphs_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); -static guint nr_arena_glyphs_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area); -static NRArenaItem *nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); +static guint nr_arena_glyphs_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset); +static NRArenaItem *nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); static NRArenaItemClass *glyphs_parent_class; @@ -75,7 +76,6 @@ nr_arena_glyphs_class_init(NRArenaGlyphsClass *klass) object_class->cpp_ctor = NRObject::invoke_ctor; item_class->update = nr_arena_glyphs_update; - item_class->clip = nr_arena_glyphs_clip; item_class->pick = nr_arena_glyphs_pick; } @@ -102,7 +102,7 @@ nr_arena_glyphs_finalize(NRObject *object) } static guint -nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*state*/, guint /*reset*/) +nr_arena_glyphs_update(NRArenaItem *item, Geom::IntRect const &/*area*/, NRGC *gc, guint /*state*/, guint /*reset*/) { NRArenaGlyphs *glyphs = NR_ARENA_GLYPHS(item); NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item->parent); @@ -132,50 +132,32 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s // (one for each point on the curve) b->expandBy(miterMax); } - } + } if (b) { - item->bbox.x0 = floor(b->left()); - item->bbox.y0 = floor(b->top()); - item->bbox.x1 = ceil (b->right()); - item->bbox.y1 = ceil (b->bottom()); + item->bbox = b->roundOutwards(); } else { - item->bbox.x0 = 0; - item->bbox.y0 = 0; - item->bbox.x1 = -1; - item->bbox.y1 = -1; + item->bbox = Geom::OptIntRect(); } return NR_ARENA_ITEM_STATE_ALL; } -static guint nr_arena_glyphs_clip(cairo_t * /*ct*/, NRArenaItem *item, NRRectL * /*area*/) -{ - NRArenaGlyphs *glyphs; - - glyphs = NR_ARENA_GLYPHS(item); - - if (!glyphs->font) return item->state; - - // TODO : render to greyscale pixblock provided for clipping - - return item->state; -} - static NRArenaItem * -nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int /*sticky*/) +nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point const &p, gdouble delta, unsigned int /*sticky*/) { NRArenaGlyphs *glyphs; glyphs = NR_ARENA_GLYPHS(item); if (!glyphs->font ) return NULL; + if (!item->bbox) return NULL; - double const x = p[Geom::X]; - double const y = p[Geom::Y]; - /* With text we take a simple approach: pick if the point is in a characher bbox */ - if ((x + delta >= item->bbox.x0) && (y + delta >= item->bbox.y0) && (x - delta <= item->bbox.x1) && (y - delta <= item->bbox.y1)) return item; - + // With text we take a simple approach: pick if the point is in a characher bbox + Geom::Rect expanded(*item->bbox); + expanded.expandBy(delta); + if (expanded.contains(p)) + return item; return NULL; } @@ -205,10 +187,10 @@ static void nr_arena_glyphs_group_class_init(NRArenaGlyphsGroupClass *klass); static void nr_arena_glyphs_group_init(NRArenaGlyphsGroup *group); static void nr_arena_glyphs_group_finalize(NRObject *object); -static guint nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); -static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area); -static NRArenaItem *nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int sticky); +static guint nr_arena_glyphs_group_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset); +static unsigned int nr_arena_glyphs_group_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); +static unsigned int nr_arena_glyphs_group_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); +static NRArenaItem *nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point const &p, gdouble delta, unsigned int sticky); static NRArenaGroupClass *group_parent_class; @@ -251,14 +233,12 @@ static void nr_arena_glyphs_group_init(NRArenaGlyphsGroup *group) { group->style = NULL; - group->paintbox.x0 = group->paintbox.y0 = 0.0F; - group->paintbox.x1 = group->paintbox.y1 = -1.0F; } static void nr_arena_glyphs_group_finalize(NRObject *object) { - NRArenaGlyphsGroup *group=static_cast(object); + NRArenaGlyphsGroup *group = static_cast(object); if (group->style) { sp_style_unref(group->style); @@ -269,7 +249,7 @@ nr_arena_glyphs_group_finalize(NRObject *object) } static guint -nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset) +nr_arena_glyphs_group_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset) { NRArenaGlyphsGroup *group = NR_ARENA_GLYPHS_GROUP(item); @@ -283,24 +263,20 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s static unsigned int -nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock * /*pb*/, unsigned int /*flags*/) +nr_arena_glyphs_group_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int /*flags*/) { NRArenaItem *child = 0; NRArenaGroup *group = NR_ARENA_GROUP(item); NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); - if (!ct) { - return item->state; - } - if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - cairo_save(ct); + Inkscape::DrawingContext::Save save(ct); guint32 rgba = item->arena->outlinecolor; - ink_cairo_set_source_rgba32(ct, rgba); - cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode - cairo_new_path(ct); - ink_cairo_transform(ct, ggroup->ctm); + ct.setSource(rgba); + ct.setTolerance(1.25); // low quality, but good enough for outline mode + ct.newPath(); + ct.transform(ggroup->ctm); for (child = group->children; child != NULL; child = child->next) { NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); @@ -308,83 +284,78 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi Geom::PathVector const * pathv = g->font->PathVector(g->glyph); Geom::Affine transform = g->g_transform; - cairo_save(ct); - ink_cairo_transform(ct, transform); - feed_pathvector_to_cairo (ct, *pathv); - cairo_fill(ct); - cairo_restore(ct); + Inkscape::DrawingContext::Save save(ct); + ct.transform(transform); + ct.path(*pathv); + ct.fill(); } - cairo_restore(ct); return item->state; } // NOTE: this is very similar to nr-arena-shape.cpp; the only difference is path feeding bool has_stroke, has_fill; - cairo_save(ct); - ink_cairo_transform(ct, ggroup->ctm); + Inkscape::DrawingContext::Save save(ct); + ct.transform(ggroup->ctm); - has_fill = ggroup->nrstyle.prepareFill(ct, &ggroup->paintbox); - has_stroke = ggroup->nrstyle.prepareStroke(ct, &ggroup->paintbox); + has_fill = ggroup->nrstyle.prepareFill(ct, ggroup->paintbox); + has_stroke = ggroup->nrstyle.prepareStroke(ct, ggroup->paintbox); if (has_fill || has_stroke) { for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); - cairo_save(ct); - ink_cairo_transform(ct, g->g_transform); - feed_pathvector_to_cairo(ct, pathv); - cairo_restore(ct); + Inkscape::DrawingContext::Save save(ct); + ct.transform(g->g_transform); + ct.path(pathv); } if (has_fill) { ggroup->nrstyle.applyFill(ct); - cairo_fill_preserve(ct); + ct.fillPreserve(); } if (has_stroke) { ggroup->nrstyle.applyStroke(ct); - cairo_stroke_preserve(ct); + ct.strokePreserve(); } - cairo_new_path(ct); // clear path + ct.newPath(); // clear path } // has fill or stroke pattern - cairo_restore(ct); return item->state; } -static unsigned int nr_arena_glyphs_group_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/) +static unsigned int nr_arena_glyphs_group_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/) { NRArenaGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); - cairo_save(ct); + Inkscape::DrawingContext::Save save(ct); + // handle clip-rule if (ggroup->style) { if (ggroup->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); } else { - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + ct.setFillRule(CAIRO_FILL_RULE_WINDING); } } - ink_cairo_transform(ct, ggroup->ctm); + ct.transform(ggroup->ctm); for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); - cairo_save(ct); - ink_cairo_transform(ct, g->g_transform); - feed_pathvector_to_cairo(ct, pathv); - cairo_restore(ct); + Inkscape::DrawingContext::Save save(ct); + ct.transform(g->g_transform); + ct.path(pathv); } - cairo_fill(ct); - cairo_restore(ct); + ct.fill(); return item->state; } static NRArenaItem * -nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int sticky) +nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point const &p, gdouble delta, unsigned int sticky) { NRArenaItem *picked = NULL; @@ -450,15 +421,7 @@ nr_arena_glyphs_group_set_paintbox(NRArenaGlyphsGroup *gg, NRRect const *pbox) nr_return_if_fail(NR_IS_ARENA_GLYPHS_GROUP(gg)); nr_return_if_fail(pbox != NULL); - if ((pbox->x0 < pbox->x1) && (pbox->y0 < pbox->y1)) { - gg->paintbox.x0 = pbox->x0; - gg->paintbox.y0 = pbox->y0; - gg->paintbox.x1 = pbox->x1; - gg->paintbox.y1 = pbox->y1; - } else { - gg->paintbox.x0 = gg->paintbox.y0 = 0.0F; - gg->paintbox.x1 = gg->paintbox.y1 = -1.0F; - } + gg->paintbox = pbox->upgrade_2geom(); nr_arena_item_request_update(NR_ARENA_ITEM(gg), NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-arena-glyphs.h b/src/display/nr-arena-glyphs.h index c43095cb2..4b2aed7b9 100644 --- a/src/display/nr-arena-glyphs.h +++ b/src/display/nr-arena-glyphs.h @@ -70,7 +70,7 @@ typedef struct NRArenaGlyphsGroupClass NRArenaGlyphsGroupClass; NRType nr_arena_glyphs_group_get_type (void); struct NRArenaGlyphsGroup : public NRArenaGroup { - NRRect paintbox; + Geom::OptRect paintbox; NRStyle nrstyle; static NRArenaGlyphsGroup *create(NRArena *arena) { diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 1d552fbc2..1f7c421d0 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -24,6 +24,7 @@ #include "filters/blend.h" #include "display/nr-filter-blend.h" #include "helper/geom.h" +#include "display/drawing-context.h" static void nr_arena_group_class_init (NRArenaGroupClass *klass); static void nr_arena_group_init (NRArenaGroup *group); @@ -34,10 +35,10 @@ static void nr_arena_group_add_child (NRArenaItem *item, NRArenaItem *child, NRA static void nr_arena_group_remove_child (NRArenaItem *item, NRArenaItem *child); static void nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); -static unsigned int nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); -static unsigned int nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static unsigned int nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area); -static NRArenaItem *nr_arena_group_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); +static unsigned int nr_arena_group_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); +static unsigned int nr_arena_group_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); +static unsigned int nr_arena_group_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); +static NRArenaItem *nr_arena_group_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); static NRArenaItemClass *parent_class; @@ -163,7 +164,7 @@ nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *child, NRAren } static unsigned int -nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset) +nr_arena_group_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset) { unsigned int newstate; NRArenaGroup *group = NR_ARENA_GROUP (item); @@ -178,10 +179,10 @@ nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int } if (beststate & NR_ARENA_ITEM_STATE_BBOX) { - item->bbox = NR_RECT_L_EMPTY; + item->bbox = Geom::OptIntRect(); for (NRArenaItem *child = group->children; child != NULL; child = child->next) { if (child->visible) - nr_rect_l_union (&item->bbox, &item->bbox, outline ? &child->bbox : &child->drawbox); + item->bbox.unionWith(outline ? child->bbox : child->drawbox); } } @@ -217,7 +218,7 @@ void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) } static unsigned int -nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags) +nr_arena_group_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags) { NRArenaGroup *group = NR_ARENA_GROUP (item); @@ -225,7 +226,7 @@ nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock /* Just compose children into parent buffer */ for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - ret = nr_arena_item_invoke_render (ct, child, area, pb, flags); + ret = nr_arena_item_invoke_render (ct, child, area, flags); if (ret & NR_ARENA_ITEM_STATE_INVALID) break; } @@ -233,7 +234,7 @@ nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } static unsigned int -nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) +nr_arena_group_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area) { NRArenaGroup *group = NR_ARENA_GROUP (item); unsigned int ret = item->state; @@ -247,7 +248,7 @@ nr_arena_group_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) } static NRArenaItem * -nr_arena_group_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky) +nr_arena_group_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky) { NRArenaGroup *group = NR_ARENA_GROUP (item); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index a943a6214..5336fcda9 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -17,6 +17,7 @@ #include "nr-arena-image.h" #include "style.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena.h" #include "display/nr-filter.h" #include "sp-filter.h" @@ -34,9 +35,9 @@ static void nr_arena_image_class_init (NRArenaImageClass *klass); static void nr_arena_image_init (NRArenaImage *image); static void nr_arena_image_finalize (NRObject *object); -static unsigned int nr_arena_image_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); -static unsigned int nr_arena_image_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static NRArenaItem *nr_arena_image_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); +static unsigned int nr_arena_image_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); +static unsigned int nr_arena_image_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); +static NRArenaItem *nr_arena_image_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); static Geom::Rect nr_arena_image_rect (NRArenaImage *image); static NRArenaItemClass *parent_class; @@ -104,7 +105,7 @@ nr_arena_image_finalize (NRObject *object) } static unsigned int -nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned int /*state*/, unsigned int /*reset*/ ) +nr_arena_image_update( NRArenaItem *item, Geom::IntRect const &/*area*/, NRGC *gc, unsigned int /*state*/, unsigned int /*reset*/ ) { // clear old bbox nr_arena_item_request_render(item); @@ -116,30 +117,17 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned /* Calculate bbox */ if (image->pixbuf) { - NRRect bbox; - Geom::Rect r = nr_arena_image_rect(image) * gc->transform; - - item->bbox.x0 = floor(r.left()); // Floor gives the coordinate in which the point resides - item->bbox.y0 = floor(r.top()); - item->bbox.x1 = ceil(r.right()); // Ceil gives the first coordinate beyond the point - item->bbox.y1 = ceil(r.bottom()); + item->bbox = r.roundOutwards(); } else { - item->bbox.x0 = (int) gc->transform[4]; - item->bbox.y0 = (int) gc->transform[5]; - item->bbox.x1 = item->bbox.x0 - 1; - item->bbox.y1 = item->bbox.y0 - 1; + item->bbox = Geom::OptIntRect(); } return NR_ARENA_ITEM_STATE_ALL; } -static unsigned int nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/, NRPixBlock * /*pb*/, unsigned int /*flags*/ ) +static unsigned int nr_arena_image_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/, unsigned int /*flags*/ ) { - if (!ct) { - return item->state; - } - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); NRArenaImage *image = NR_ARENA_IMAGE (item); @@ -151,69 +139,63 @@ static unsigned int nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRec // FIXME: at the moment gdk_cairo_set_source_pixbuf creates an ARGB copy // of the pixbuf. Fix this in Cairo and/or GDK. - cairo_save(ct); - ink_cairo_transform(ct, image->ctm); + Inkscape::DrawingContext::Save save(ct); + ct.transform(image->ctm); + ct.newPath(); + ct.rectangle(image->clipbox); + ct.clip(); - cairo_new_path(ct); - cairo_rectangle(ct, image->clipbox.left(), image->clipbox.top(), - image->clipbox.width(), image->clipbox.height()); - cairo_clip(ct); - - cairo_translate(ct, image->ox, image->oy); - cairo_scale(ct, image->sx, image->sy); - - cairo_set_source_surface(ct, image->surface, 0, 0); + ct.translate(image->ox, image->oy); + ct.scale(image->sx, image->sy); + ct.setSource(image->surface, 0, 0); cairo_matrix_t tt; Geom::Affine total; - cairo_get_matrix(ct, &tt); + cairo_get_matrix(ct.raw(), &tt); ink_matrix_to_2geom(total, tt); if (total.expansionX() > 1.0 || total.expansionY() > 1.0) { - cairo_pattern_t *p = cairo_get_source(ct); + cairo_pattern_t *p = cairo_get_source(ct.raw()); cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST); } - - cairo_paint_with_alpha(ct, ((double) item->opacity) / 255.0); - cairo_restore(ct); + ct.paint(((double) item->opacity) / 255.0); } else { // outline; draw a rect instead Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); - cairo_save(ct); - ink_cairo_transform(ct, image->ctm); - - cairo_new_path(ct); - - Geom::Rect r = nr_arena_image_rect (image); - Geom::Point c00 = r.corner(0); - Geom::Point c01 = r.corner(3); - Geom::Point c11 = r.corner(2); - Geom::Point c10 = r.corner(1); + { Inkscape::DrawingContext::Save save(ct); + ct.transform(image->ctm); + ct.newPath(); + + Geom::Rect r = nr_arena_image_rect (image); + Geom::Point c00 = r.corner(0); + Geom::Point c01 = r.corner(3); + Geom::Point c11 = r.corner(2); + Geom::Point c10 = r.corner(1); + + ct.moveTo(c00); + // the box + ct.lineTo(c10); + ct.lineTo(c11); + ct.lineTo(c01); + ct.lineTo(c00); + // the diagonals + ct.lineTo(c11); + ct.moveTo(c10); + ct.lineTo(c01); + } - cairo_move_to (ct, c00[Geom::X], c00[Geom::Y]); - // the box - cairo_line_to (ct, c10[Geom::X], c10[Geom::Y]); - cairo_line_to (ct, c11[Geom::X], c11[Geom::Y]); - cairo_line_to (ct, c01[Geom::X], c01[Geom::Y]); - cairo_line_to (ct, c00[Geom::X], c00[Geom::Y]); - // the diagonals - cairo_line_to (ct, c11[Geom::X], c11[Geom::Y]); - cairo_move_to (ct, c10[Geom::X], c10[Geom::Y]); - cairo_line_to (ct, c01[Geom::X], c01[Geom::Y]); - cairo_restore(ct); - - cairo_set_line_width(ct, 0.5); - ink_cairo_set_source_rgba32(ct, rgba); - cairo_stroke(ct); + ct.setLineWidth(0.5); + ct.setSource(rgba); + ct.stroke(); } return item->state; } /** Calculates the closest distance from p to the segment a1-a2*/ double -distance_to_segment (Geom::Point p, Geom::Point a1, Geom::Point a2) +distance_to_segment (Geom::Point const &p, Geom::Point const &a1, Geom::Point const &a2) { // calculate sides of the triangle and their squares double d1 = Geom::L2(p - a1); @@ -233,7 +215,7 @@ distance_to_segment (Geom::Point p, Geom::Point a1, Geom::Point a2) } static NRArenaItem * -nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned int /*sticky*/ ) +nr_arena_image_pick( NRArenaItem *item, Geom::Point const &p, double delta, unsigned int /*sticky*/ ) { NRArenaImage *image = NR_ARENA_IMAGE (item); diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 9ca5a7463..c1ffefa1d 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -21,6 +21,8 @@ #include "display/cairo-utils.h" #include "display/cairo-templates.h" +#include "display/drawing-context.h" +#include "display/drawing-surface.h" #include "display/canvas-arena.h" #include "nr-arena.h" #include "nr-arena-item.h" @@ -210,7 +212,7 @@ nr_arena_item_unref (NRArenaItem *item) } unsigned int -nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, +nr_arena_item_invoke_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset) { NRGC childgc (gc); @@ -243,8 +245,8 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, if (!(~item->state & state)) return item->state; /* Test whether to return immediately */ - if (area && (item->state & NR_ARENA_ITEM_STATE_BBOX)) { - if (!nr_rect_l_test_intersect_ptr(area, outline ? &item->bbox : &item->drawbox)) + if (item->state & NR_ARENA_ITEM_STATE_BBOX) { + if (!area.intersects(outline ? item->bbox : item->drawbox)) return item->state; } @@ -269,13 +271,9 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, /* Enlarge the drawbox to contain filter effects */ if (item->filter && filter && item->item_bbox) { - item->drawbox.x0 = item->item_bbox->min()[Geom::X]; - item->drawbox.y0 = item->item_bbox->min()[Geom::Y]; - item->drawbox.x1 = item->item_bbox->max()[Geom::X]; - item->drawbox.y1 = item->item_bbox->max()[Geom::Y]; - item->filter->compute_drawbox (item, item->drawbox); + item->drawbox = item->filter->compute_drawbox(item, *item->item_bbox); } else { - memcpy(&item->drawbox, &item->bbox, sizeof(item->bbox)); + item->drawbox = item->bbox; } /* Clipping */ @@ -289,10 +287,9 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, return item->state; } if (outline) { - nr_rect_l_union(&item->bbox, &item->bbox, &item->clip->bbox); + item->bbox.unionWith(item->clip->bbox); } else { - // for clipping, we need geometric bbox - nr_rect_l_intersect (&item->drawbox, &item->drawbox, &item->clip->bbox); + item->drawbox.intersectWith(item->clip->bbox); } } /* Masking */ @@ -303,10 +300,10 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, return item->state; } if (outline) { - nr_rect_l_union(&item->bbox, &item->bbox, &item->mask->bbox); + item->bbox.unionWith(item->mask->bbox); } else { // for masking, we need full drawbox of mask - nr_rect_l_intersect (&item->drawbox, &item->drawbox, &item->mask->drawbox); + item->drawbox.intersectWith(item->mask->drawbox); } } @@ -331,8 +328,8 @@ struct MaskLuminanceToAlpha { }; unsigned int -nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area, - NRPixBlock *pb, unsigned int flags) +nr_arena_item_invoke_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, + unsigned int flags) { bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); bool filter = (item->arena->rendermode != Inkscape::RENDERMODE_OUTLINE && @@ -343,15 +340,6 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (item->state & NR_ARENA_ITEM_STATE_BBOX, item->state); - if (!ct) return item->state; - -#ifdef NR_ARENA_ITEM_VERBOSE - g_message ("Invoke render %p on %p: %d %d - %d %d, %d %d - %d %d", item, pb, - area->x0, area->y0, - area->x1, area->y1, - item->drawbox.x0, item->drawbox.y0, - item->drawbox.x1, item->drawbox.y1); -#endif /* If we are invisible, just return successfully */ if (!item->visible) @@ -360,15 +348,14 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area if (outline) { // intersect with bbox rather than drawbox, as we want to render things outside // of the clipping path as well - NRRectL carea; - nr_rect_l_intersect (&carea, area, &item->bbox); - if (nr_rect_l_test_empty(carea)) + Geom::OptIntRect carea = Geom::intersect(area, item->bbox); + if (!carea) return item->state | NR_ARENA_ITEM_STATE_RENDER; // No caching in outline mode for now; investigate if it really gives any advantage with cairo. // Also no attempts to clip anything; just render everything: item, clip, mask // First, render the object itself - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, pb, flags); + unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, *carea, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { /* Clean up and return error */ item->state |= NR_ARENA_ITEM_STATE_INVALID; @@ -381,12 +368,12 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (item->clip) { item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips - NR_ARENA_ITEM_VIRTUAL (item->clip, render) (ct, item->clip, &carea, pb, flags); - } + NR_ARENA_ITEM_VIRTUAL (item->clip, render) (ct, item->clip, *carea, flags); + } // render mask as an object, using a different color if (item->mask) { item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks - NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, &carea, pb, flags); + NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, *carea, flags); } item->arena->outlinecolor = saved_rgba; // restore outline color @@ -395,13 +382,12 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // carea is the bounding box for intermediate rendering. // NOTE: carea might be larger than area, because of filter effects. - NRRectL carea; - nr_rect_l_intersect (&carea, area, &item->drawbox); - if (nr_rect_l_test_empty(carea)) + Geom::OptIntRect carea = Geom::intersect(area, item->drawbox); + if (!carea) return item->state | NR_ARENA_ITEM_STATE_RENDER; if (item->filter && filter) { - item->filter->area_enlarge (carea, item); - nr_rect_l_intersect (&carea, &carea, &item->drawbox); + item->filter->area_enlarge(*carea, item); + carea.intersectWith(item->drawbox); } using namespace Inkscape; @@ -436,7 +422,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // short-circuit the simple case. if (!needs_intermediate_rendering) { - state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, pb, flags); + state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, *carea, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { item->state |= NR_ARENA_ITEM_STATE_INVALID; return item->state; @@ -444,51 +430,48 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area return item->state | NR_ARENA_ITEM_STATE_RENDER; } - cairo_surface_t *intermediate = cairo_surface_create_similar( - cairo_get_group_target(ct), CAIRO_CONTENT_COLOR_ALPHA, - carea.x1 - carea.x0, carea.y1 - carea.y0); - cairo_t *ict = cairo_create(intermediate); - cairo_translate(ict, -carea.x0, -carea.y0); + DrawingSurface intermediate(*carea); + DrawingContext ict(intermediate); // 1. Render clipping path with alpha = opacity. - cairo_set_source_rgba(ict, 0,0,0,opacity); + ict.setSource(0,0,0,opacity); // Since clip can be combined with opacity, the result could be incorrect // for overlapping clip children. To fix this we use the SOURCE operator // instead of the default OVER. - cairo_set_operator(ict, CAIRO_OPERATOR_SOURCE); + ict.setOperator(CAIRO_OPERATOR_SOURCE); if (item->clip) { - state = nr_arena_item_invoke_clip(ict, item->clip, const_cast(area)); + state = nr_arena_item_invoke_clip(ict, item->clip, *carea); // fixme: carea or area? if (state & NR_ARENA_ITEM_STATE_INVALID) { retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); goto cleanup; } } else { // if there is no clipping path, fill the entire surface with alpha = opacity. - cairo_paint(ict); + ict.paint(); } // reset back to default - cairo_set_operator(ict, CAIRO_OPERATOR_OVER); + ict.setOperator(CAIRO_OPERATOR_OVER); // 2. Render the mask if present and compose it with the clipping path + opacity. if (item->mask) { - cairo_push_group(ict); - state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ict, item->mask, &carea, NULL, flags); + ict.pushGroup(); + state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ict, item->mask, *carea, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); goto cleanup; } - cairo_surface_t *mask_s = cairo_get_group_target(ict); + cairo_surface_t *mask_s = ict.rawTarget(); // Convert mask's luminance to alpha ink_cairo_surface_filter(mask_s, mask_s, MaskLuminanceToAlpha()); - cairo_pop_group_to_source(ict); - cairo_set_operator(ict, CAIRO_OPERATOR_IN); - cairo_paint(ict); - cairo_set_operator(ict, CAIRO_OPERATOR_OVER); + ict.popGroupToSource(); + ict.setOperator(CAIRO_OPERATOR_IN); + ict.paint(); + ict.setOperator(CAIRO_OPERATOR_OVER); } // 3. Render object itself. - cairo_push_group(ict); - state = NR_ARENA_ITEM_VIRTUAL (item, render) (ict, item, &carea, pb, flags); + ict.pushGroup(); + state = NR_ARENA_ITEM_VIRTUAL (item, render) (ict, item, *carea, flags); if (state & NR_ARENA_ITEM_STATE_INVALID) { retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); goto cleanup; @@ -496,71 +479,53 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area // 4. Apply filter. if (item->filter && filter) { - // HACK: SPCanvasArena doesn't exist when this is called for offscreen rendering - // Proper fix: call this function with a drawing context class - // that contains information about the surface's bounds - NRRectL bgarea; - if (flags & NR_ARENA_ITEM_RENDER_NO_CACHE || !item->arena->canvasarena) { - bgarea = carea; - } else { - bgarea = NRRectL(item->arena->canvasarena->cache_area); - } - item->filter->render(item, ct, &bgarea, ict, &carea); + item->filter->render(item, ct, ict); // Note that because the object was rendered to a group, // the internals of the filter need to use cairo_get_group_target() // instead of cairo_get_target(). } // 5. Render object inside the composited mask + clip - cairo_pop_group_to_source(ict); - cairo_set_operator(ict, CAIRO_OPERATOR_IN); - cairo_paint(ict); + ict.popGroupToSource(); + ict.setOperator(CAIRO_OPERATOR_IN); + ict.paint(); // 6. Paint the completed rendering onto the base context - cairo_set_source_surface(ct, intermediate, carea.x0, carea.y0); - cairo_paint(ct); - cairo_set_source_rgba(ct, 0,0,0,0); + ct.setSource(&intermediate); + ct.paint(); + ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct retstate = item->state | NR_ARENA_ITEM_STATE_RENDER; cleanup: - cairo_destroy(ict); - cairo_surface_destroy(intermediate); - return retstate; } unsigned int -nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) +nr_arena_item_invoke_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area) { nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), NR_ARENA_ITEM_STATE_INVALID); -#ifdef NR_ARENA_ITEM_VERBOSE - printf ("Invoke clip by %p: %d %d - %d %d, item bbox %d %d - %d %d\n", - item, area->x0, area->y0, area->x1, area->y1, (&item->bbox)->x0, - (&item->bbox)->y0, (&item->bbox)->x1, (&item->bbox)->y1); -#endif - unsigned retstate = 0; - + // don't bother if the object does not implement clipping (e.g. NRArenaImage) if (!((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) return retstate; - if (item->visible && nr_rect_l_test_intersect_ptr(area, &item->bbox)) { + if (item->visible && area.intersects(item->bbox)) { // The item used as the clipping path itself has a clipping path. - // Render this item's clipping path onto a temporary surface, then composite it with the item - // using the IN operator + // Render this item's clipping path onto a temporary surface, then composite it + // with the item using the IN operator if (item->clip) { - cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); - cairo_save(ct); - cairo_set_source_rgba(ct, 0,0,0,1); - nr_arena_item_invoke_clip(ct, item->clip, area); - cairo_restore(ct); - cairo_push_group_with_content(ct, CAIRO_CONTENT_ALPHA); + ct.pushAlphaGroup(); + { Inkscape::DrawingContext::Save save(ct); + ct.setSource(0,0,0,1); + nr_arena_item_invoke_clip(ct, item->clip, area); + } + ct.pushAlphaGroup(); } // rasterize the clipping path @@ -568,12 +533,12 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) clip (ct, item, area); if (item->clip) { - cairo_pop_group_to_source(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_IN); - cairo_paint(ct); - cairo_pop_group_to_source(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); + ct.popGroupToSource(); + ct.setOperator(CAIRO_OPERATOR_IN); + ct.paint(); + ct.popGroupToSource(); + ct.setOperator(CAIRO_OPERATOR_SOURCE); + ct.paint(); } } @@ -581,7 +546,7 @@ nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area) } NRArenaItem * -nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, +nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky) { nr_return_val_if_fail (item != NULL, NULL); @@ -595,14 +560,11 @@ nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, if (!sticky && !(item->visible && item->sensitive)) return NULL; - // TODO: rewrite using Geom::Rect - const double x = p[Geom::X]; - const double y = p[Geom::Y]; + if (!item->bbox) return NULL; + Geom::Rect expanded(*item->bbox); + expanded.expandBy(delta); - if (((x + delta) >= item->bbox.x0) && - ((x - delta) < item->bbox.x1) && - ((y + delta) >= item->bbox.y0) && ((y - delta) < item->bbox.y1)) - { + if (expanded.contains(p)) { if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->pick) return ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> pick (item, p, delta, sticky); @@ -639,7 +601,7 @@ nr_arena_item_request_render (NRArenaItem *item) nr_return_if_fail (NR_IS_ARENA_ITEM (item)); bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - nr_arena_request_render_rect (item->arena, outline ? &item->bbox : &item->drawbox); + nr_arena_request_render_rect (item->arena, outline ? item->bbox : item->drawbox); } /* Public */ @@ -694,6 +656,7 @@ nr_arena_item_set_transform (NRArenaItem *item, Geom::Affine const *transform) const Geom::Affine *ms = (transform) ? transform : &GEOM_MATRIX_IDENTITY; if (!Geom::matrix_equalp(*md, *ms, NR_EPSILON)) { + // mark the area where the object was for redraw. nr_arena_item_request_render (item); if (!transform || transform->isIdentity()) { /* Set to identity affine */ @@ -703,6 +666,8 @@ nr_arena_item_set_transform (NRArenaItem *item, Geom::Affine const *transform) item->transform = new (GC::ATOMIC) Geom::Affine (); *item->transform = *transform; } + // when update is called, the area where the object was moved + // will be redrawn as well nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, TRUE); } } @@ -800,7 +765,7 @@ nr_arena_item_set_order (NRArenaItem *item, int order) } void -nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect &bbox) +nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect const &bbox) { nr_return_if_fail(item != NULL); nr_return_if_fail(NR_IS_ARENA_ITEM(item)); diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index d65a75ed8..4b43e4da8 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -23,6 +23,7 @@ #include "nr-arena-forward.h" namespace Inkscape { +class DrawingContext; namespace Filters { class Filter; } } @@ -92,8 +93,8 @@ struct NRArenaItem : public NRObject { unsigned int key; ///< Some SPItems can have more than one NRArenaItem, ///this value is a hack used to distinguish between them - NRRectL bbox; ///< Bounding box in pixel grid coordinates; (0,0) is at page origin - NRRectL drawbox; ///< Bounding box enlarged by filters, shrinked by clips and masks + Geom::OptIntRect bbox; ///< Bounding box in pixel grid coordinates; (0,0) is at page origin + Geom::OptIntRect drawbox; ///< Bounding box enlarged by filters, shrinked by clips and masks Geom::OptRect item_bbox; ///< Bounding box in item coordinates, required by filters Geom::Affine *transform; ///< Incremental transform of this item, as given by the transform= attribute Geom::Affine ctm; ///< Total transform from pixel grid to item coords @@ -119,10 +120,10 @@ struct NRArenaItemClass : public NRObjectClass { void (* remove_child) (NRArenaItem *item, NRArenaItem *child); void (* set_child_position) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); - unsigned int (* update) (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); - unsigned int (* render) (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); - unsigned int (* clip) (cairo_t *ct, NRArenaItem *item, NRRectL *area); - NRArenaItem * (* pick) (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); + unsigned int (* update) (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); + unsigned int (* render) (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); + unsigned int (* clip) (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); + NRArenaItem * (* pick) (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); }; #define NR_ARENA_ITEM_ARENA(ai) (((NRArenaItem *) (ai))->arena) @@ -147,12 +148,12 @@ void nr_arena_item_set_child_position (NRArenaItem *item, NRArenaItem *child, NR * reset - reset to state (bitwise or of flags to reset) */ -unsigned int nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); +unsigned int nr_arena_item_invoke_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); -unsigned int nr_arena_item_invoke_render(cairo_t *ct, NRArenaItem *item, NRRectL const *area, NRPixBlock *pb, unsigned int flags); +unsigned int nr_arena_item_invoke_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); -unsigned int nr_arena_item_invoke_clip (cairo_t *ct, NRArenaItem *item, NRRectL *area); -NRArenaItem *nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); +unsigned int nr_arena_item_invoke_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); +NRArenaItem *nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); void nr_arena_item_request_update (NRArenaItem *item, unsigned int reset, unsigned int propagate); void nr_arena_item_request_render (NRArenaItem *item); @@ -171,7 +172,7 @@ void nr_arena_item_set_visible (NRArenaItem *item, unsigned int visible); void nr_arena_item_set_clip (NRArenaItem *item, NRArenaItem *clip); void nr_arena_item_set_mask (NRArenaItem *item, NRArenaItem *mask); void nr_arena_item_set_order (NRArenaItem *item, int order); -void nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect &bbox); +void nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect const &bbox); NRPixBlock *nr_arena_item_get_background (NRArenaItem const *item); diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 6d65611bf..ff985550c 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -23,6 +23,7 @@ #include "display/canvas-arena.h" #include "display/canvas-bpath.h" #include "display/curve.h" +#include "display/drawing-context.h" #include "display/nr-arena.h" #include "display/nr-arena-shape.h" #include "display/nr-filter.h" @@ -44,10 +45,10 @@ static void nr_arena_shape_add_child(NRArenaItem *item, NRArenaItem *child, NRAr static void nr_arena_shape_remove_child(NRArenaItem *item, NRArenaItem *child); static void nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); -static guint nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); -static unsigned int nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL *area); -static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); +static guint nr_arena_shape_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset); +static unsigned int nr_arena_shape_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); +static guint nr_arena_shape_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); +static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); static NRArenaItemClass *shape_parent_class; @@ -99,14 +100,6 @@ nr_arena_shape_init(NRArenaShape *shape) { shape->curve = NULL; shape->style = NULL; - shape->paintbox.x0 = shape->paintbox.y0 = 0.0F; - shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; - shape->delayed_shp = false; - shape->path = NULL; - - shape->approx_bbox.x0 = shape->approx_bbox.y0 = 0; - shape->approx_bbox.x1 = shape->approx_bbox.y1 = 0; - shape->markers = NULL; shape->last_pick = NULL; shape->repick_after = 0; @@ -117,7 +110,6 @@ nr_arena_shape_finalize(NRObject *object) { NRArenaShape *shape = (NRArenaShape *) object; - if (shape->path) cairo_path_destroy(shape->path); if (shape->style) sp_style_unref(shape->style); if (shape->curve) shape->curve->unref(); shape->last_pick = NULL; @@ -203,7 +195,7 @@ nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArena * Updates the arena shape 'item' and all of its children, including the markers. */ static guint -nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset) +nr_arena_shape_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset) { Geom::OptRect boundingbox; @@ -224,34 +216,26 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); if (boundingbox) { - item->bbox.x0 = floor((*boundingbox)[0][0]); // Floor gives the coordinate in which the point resides - item->bbox.y0 = floor((*boundingbox)[1][0]); - item->bbox.x1 = ceil ((*boundingbox)[0][1]); // Ceil gives the first coordinate beyond the point - item->bbox.y1 = ceil ((*boundingbox)[1][1]); + item->bbox = boundingbox->roundOutwards(); } else { - item->bbox = NR_RECT_L_EMPTY; + item->bbox = Geom::OptIntRect(); } } if (beststate & NR_ARENA_ITEM_STATE_BBOX) { for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - nr_rect_l_union(&item->bbox, &item->bbox, &child->bbox); + item->bbox.unionWith(child->bbox); } } } return (state | item->state); } - shape->delayed_shp=true; boundingbox = Geom::OptRect(); bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); // clear Cairo data to force update shape->nrstyle.update(); - if (shape->path) { - cairo_path_destroy(shape->path); - shape->path = NULL; - } if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); @@ -273,19 +257,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g } } - /// \todo just write item->bbox = boundingbox - if (boundingbox) { - shape->approx_bbox.x0 = floor(boundingbox->left()); - shape->approx_bbox.y0 = floor(boundingbox->top()); - shape->approx_bbox.x1 = ceil (boundingbox->right()); - shape->approx_bbox.y1 = ceil (boundingbox->bottom()); - } else { - shape->approx_bbox = NR_RECT_L_EMPTY; - } - if ( area && nr_rect_l_test_intersect_ptr(area, &shape->approx_bbox) ) shape->delayed_shp=false; - - // TODO: compute a better bounding box that respects miters - item->bbox = shape->approx_bbox; + item->bbox = boundingbox ? boundingbox->roundOutwards() : Geom::OptIntRect(); if (!shape->curve || !shape->style || @@ -299,7 +271,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (beststate & NR_ARENA_ITEM_STATE_BBOX) { for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - nr_rect_l_union(&item->bbox, &item->bbox, &child->bbox); + item->bbox.unionWith(child->bbox); } } @@ -308,25 +280,22 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g // cairo outline rendering: static unsigned int -cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect /*area*/) +cairo_arena_shape_render_outline(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/) { NRArenaShape *shape = NR_ARENA_SHAPE(item); - if (!ct) - return item->state; - guint32 rgba = NR_ARENA_ITEM(shape)->arena->outlinecolor; - cairo_save(ct); - ink_cairo_transform(ct, shape->ctm); - feed_pathvector_to_cairo (ct, shape->curve->get_pathvector()); - cairo_restore(ct); - cairo_save(ct); - ink_cairo_set_source_rgba32(ct, rgba); - cairo_set_line_width(ct, 0.5); - cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode - cairo_stroke(ct); - cairo_restore(ct); + { Inkscape::DrawingContext::Save save(ct); + ct.transform(shape->ctm); + ct.path(shape->curve->get_pathvector()); + } + { Inkscape::DrawingContext::Save save(ct); + ct.setSource(rgba); + ct.setLineWidth(0.5); + ct.setTolerance(1.25); + ct.stroke(); + } return item->state; } @@ -335,59 +304,55 @@ cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect / * Renders the item. Markers are just composed into the parent buffer. */ static unsigned int -nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags) +nr_arena_shape_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags) { NRArenaShape *shape = NR_ARENA_SHAPE(item); if (!shape->curve) return item->state; if (!shape->style) return item->state; - if (!ct) return item->state; // skip if not within bounding box - if (!nr_rect_l_test_intersect_ptr(area, &item->bbox)) { + if (!area.intersects(item->bbox)) { return item->state; } bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - if (outline) { // cairo outline rendering - - NRRect temp(area->x0, area->y0, area->x1, area->y1); - unsigned int ret = cairo_arena_shape_render_outline (ct, item, temp.upgrade_2geom()); + if (outline) { + // cairo outline rendering + unsigned int ret = cairo_arena_shape_render_outline (ct, item, area); if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; - } else { bool has_stroke, has_fill; // we assume the context has no path - cairo_save(ct); - ink_cairo_transform(ct, shape->ctm); + Inkscape::DrawingContext::Save save(ct); + ct.transform(shape->ctm); // update fill and stroke paints. // this cannot be done during nr_arena_shape_update, because we need a Cairo context // to render svg:pattern - has_fill = shape->nrstyle.prepareFill(ct, &shape->paintbox); - has_stroke = shape->nrstyle.prepareStroke(ct, &shape->paintbox); + has_fill = shape->nrstyle.prepareFill(ct, shape->paintbox); + has_stroke = shape->nrstyle.prepareStroke(ct, shape->paintbox); has_stroke &= (shape->nrstyle.stroke_width != 0); if (has_fill || has_stroke) { // TODO: remove segments outside of bbox when no dashes present - feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); + ct.path(shape->curve->get_pathvector()); if (has_fill) { shape->nrstyle.applyFill(ct); - cairo_fill_preserve(ct); + ct.fillPreserve(); } if (has_stroke) { shape->nrstyle.applyStroke(ct); - cairo_stroke_preserve(ct); + ct.strokePreserve(); } - cairo_new_path(ct); // clear path + ct.newPath(); // clear path } // has fill or stroke pattern - cairo_restore(ct); } // marker rendering for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - unsigned int ret = nr_arena_item_invoke_render(ct, child, area, pb, flags); + unsigned int ret = nr_arena_item_invoke_render(ct, child, area, flags); if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; } @@ -395,32 +360,31 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock } -static guint nr_arena_shape_clip(cairo_t *ct, NRArenaItem *item, NRRectL * /*area*/) +static guint nr_arena_shape_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/) { NRArenaShape *shape = NR_ARENA_SHAPE(item); if (!shape->curve) { return item->state; } - cairo_save(ct); + Inkscape::DrawingContext::Save save(ct); // handle clip-rule if (shape->style) { if (shape->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_EVEN_ODD); + ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); } else { - cairo_set_fill_rule(ct, CAIRO_FILL_RULE_WINDING); + ct.setFillRule(CAIRO_FILL_RULE_WINDING); } } - ink_cairo_transform(ct, shape->ctm); - feed_pathvector_to_cairo(ct, shape->curve->get_pathvector()); - cairo_fill(ct); - cairo_restore(ct); + ct.transform(shape->ctm); + ct.path(shape->curve->get_pathvector()); + ct.fill(); return item->state; } static NRArenaItem * -nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int /*sticky*/) +nr_arena_shape_pick(NRArenaItem *item, Geom::Point const &p, double delta, unsigned int /*sticky*/) { NRArenaShape *shape = NR_ARENA_SHAPE(item); @@ -577,23 +541,14 @@ nr_arena_shape_set_paintbox(NRArenaShape *shape, NRRect const *pbox) g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); g_return_if_fail(pbox != NULL); - if ((pbox->x0 < pbox->x1) && (pbox->y0 < pbox->y1)) { - shape->paintbox = *pbox; - } else { - /* fixme: We kill warning, although not sure what to do here (Lauris) */ - shape->paintbox.x0 = shape->paintbox.y0 = 0.0F; - shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; - } + shape->paintbox = pbox->upgrade_2geom(); nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE); } void NRArenaShape::setPaintBox(Geom::Rect const &pbox) { - paintbox.x0 = pbox.min()[Geom::X]; - paintbox.y0 = pbox.min()[Geom::Y]; - paintbox.x1 = pbox.max()[Geom::X]; - paintbox.y1 = pbox.max()[Geom::Y]; + paintbox = pbox; nr_arena_item_request_update(this, NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index 7b86f7f59..317cff7fb 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -31,16 +31,7 @@ struct NRArenaShape : public NRArenaItem { SPCurve *curve; SPStyle *style; NRStyle nrstyle; - NRRect paintbox; - - cairo_path_t *path; - - // delayed_shp=true means the *_shp polygons are not computed yet - // they'll be computed on demand in *_render(), *_pick() or *_clip() - // the goal is to not uncross polygons that are outside the viewing region - bool delayed_shp; - // approximate bounding box, for the case when the polygons have been delayed - NRRectL approx_bbox; + Geom::OptRect paintbox; /* Markers */ NRArenaItem *markers; diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index ce62a81dc..5747de26c 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -104,13 +104,13 @@ nr_arena_request_update (NRArena *arena, NRArenaItem *item) } void -nr_arena_request_render_rect (NRArena *arena, NRRectL *area) +nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area) { NRActiveObject *aobject = (NRActiveObject *) arena; nr_return_if_fail (arena != NULL); nr_return_if_fail (NR_IS_ARENA (arena)); - nr_return_if_fail (area != NULL); + if (!area) return; // setup render parameter if (arena->renderoffscreen == false) { @@ -123,12 +123,13 @@ nr_arena_request_render_rect (NRArena *arena, NRRectL *area) arena->rendermode = Inkscape::RENDERMODE_NORMAL; arena->colorrendermode = Inkscape::COLORRENDERMODE_NORMAL; } - if (aobject->callbacks && area && !nr_rect_l_test_empty_ptr(area)) { + NRRectL nr_area(*area); + if (aobject->callbacks) { for (unsigned int i = 0; i < aobject->callbacks->length; i++) { NRObjectListener *listener = aobject->callbacks->listeners + i; NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector; if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_render) { - avector->request_render (arena, area, listener->data); + avector->request_render (arena, &nr_area, listener->data); } } } diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index 1c8216434..49d133f9f 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -27,6 +27,7 @@ G_END_DECLS #define NR_ARENA(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA, NRArena)) #define NR_IS_ARENA(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA)) +#include <2geom/rect.h> #include #include #include "nr-arena-forward.h" @@ -61,7 +62,7 @@ struct NRArenaClass : public NRActiveObjectClass { }; void nr_arena_request_update (NRArena *arena, NRArenaItem *item); -void nr_arena_request_render_rect (NRArena *arena, NRRectL *area); +void nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area); void nr_arena_set_renderoffscreen (NRArena *arena); void nr_arena_separate_color_plates(guint32* rgba); diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 0cb7901b3..01d2eca64 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -13,6 +13,7 @@ #include "document.h" #include "sp-item.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "display/nr-filter.h" @@ -94,28 +95,23 @@ void FilterImage::render_cairo(FilterSlot &slot) Geom::Rect sa = slot.get_slot_area(); cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, sa.width(), sa.height()); - cairo_t *ct = cairo_create(out); - cairo_translate(ct, -sa.min()[Geom::X], -sa.min()[Geom::Y]); - ink_cairo_transform(ct, pu2pb); // we are now in primitive units - cairo_translate(ct, feImageX, feImageY); - cairo_scale(ct, scaleX, scaleY); - - NRRectL render_rect; - render_rect.x0 = floor(area.left()); - render_rect.y0 = floor(area.top()); - render_rect.x1 = ceil(area.right()); - render_rect.y1 = ceil(area.bottom()); - cairo_translate(ct, render_rect.x0, render_rect.y0); + Inkscape::DrawingContext ct(out, sa.min()); + ct.transform(pu2pb); // we are now in primitive units + ct.translate(feImageX, feImageY); + ct.scale(scaleX, scaleY); + + Geom::IntRect render_rect = area.roundOutwards(); + ct.translate(render_rect.min()); // Update to renderable state NRGC gc(NULL); Geom::Affine t = Geom::identity(); nr_arena_item_set_transform(ai, &t); gc.transform.setIdentity(); - nr_arena_item_invoke_update(ai, NULL, &gc, + nr_arena_item_invoke_update(ai, render_rect, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); - nr_arena_item_invoke_render(ct, ai, &render_rect, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE); + nr_arena_item_invoke_render(ct, ai, render_rect, NR_ARENA_ITEM_RENDER_NO_CACHE); SVGElem->invoke_hide(key); nr_object_unref((NRObject*) arena); diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 3464fda66..494d77749 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -16,6 +16,7 @@ #include <2geom/transforms.h> #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena-item.h" #include "display/nr-filter-types.h" #include "display/nr-filter-gaussian.h" @@ -25,13 +26,13 @@ namespace Inkscape { namespace Filters { -FilterSlot::FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, - cairo_surface_t *graphic, NRRectL const *graphicarea, FilterUnits const &u) +FilterSlot::FilterSlot(NRArenaItem *item, DrawingContext &bgct, + DrawingContext &graphic, FilterUnits const &u) : _item(item) - , _source_graphic(graphic) - , _background_ct(bgct) - , _source_graphic_area(graphicarea) - , _background_area(bgarea) + , _source_graphic(graphic.rawTarget()) + , _background_ct(bgct.raw()) + , _source_graphic_area(graphic.targetLogicalBounds().roundOutwards()) // fixme + , _background_area(bgct.targetLogicalBounds().roundOutwards()) // fixme , _units(u) , _last_out(NR_FILTER_SOURCEGRAPHIC) , filterquality(FILTER_QUALITY_BEST) @@ -41,19 +42,15 @@ FilterSlot::FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, using Geom::Y; // compute slot bbox - Geom::Rect bbox( - Geom::Point(_source_graphic_area->x0, _source_graphic_area->y0), - Geom::Point(_source_graphic_area->x1, _source_graphic_area->y1)); - Geom::Affine trans = _units.get_matrix_display2pb(); - Geom::Rect bbox_trans = bbox * trans; + Geom::Rect bbox_trans = graphic.targetLogicalBounds() * trans; Geom::Point min = bbox_trans.min(); _slot_x = min[X]; _slot_y = min[Y]; if (trans.isTranslation()) { - _slot_w = _source_graphic_area->x1 - _source_graphic_area->x0; - _slot_h = _source_graphic_area->y1 - _source_graphic_area->y0; + _slot_w = _source_graphic_area.width(); + _slot_h = _source_graphic_area.height(); } else { _slot_w = ceil(bbox_trans.width()); _slot_h = ceil(bbox_trans.height()); @@ -143,7 +140,7 @@ cairo_surface_t *FilterSlot::_get_transformed_source_graphic() cairo_translate(tsg_ct, -_slot_x, -_slot_y); ink_cairo_transform(tsg_ct, trans); - cairo_translate(tsg_ct, _source_graphic_area->x0, _source_graphic_area->y0); + cairo_translate(tsg_ct, _source_graphic_area.left(), _source_graphic_area.top()); cairo_set_source_surface(tsg_ct, _source_graphic, 0, 0); cairo_set_operator(tsg_ct, CAIRO_OPERATOR_SOURCE); cairo_paint(tsg_ct); @@ -164,7 +161,7 @@ cairo_surface_t *FilterSlot::_get_transformed_background() cairo_translate(tbg_ct, -_slot_x, -_slot_y); ink_cairo_transform(tbg_ct, trans); - cairo_translate(tbg_ct, _background_area->x0, _background_area->y0); + cairo_translate(tbg_ct, _background_area.left(), _background_area.top()); cairo_set_source_surface(tbg_ct, bg, 0, 0); cairo_set_operator(tbg_ct, CAIRO_OPERATOR_SOURCE); cairo_paint(tbg_ct); @@ -184,11 +181,11 @@ cairo_surface_t *FilterSlot::get_result(int res) cairo_surface_t *r = cairo_surface_create_similar(_source_graphic, cairo_surface_get_content(_source_graphic), - _source_graphic_area->x1 - _source_graphic_area->x0, - _source_graphic_area->y1 - _source_graphic_area->y0); + _source_graphic_area.width(), + _source_graphic_area.height()); cairo_t *r_ct = cairo_create(r); - cairo_translate(r_ct, -_source_graphic_area->x0, -_source_graphic_area->y0); + cairo_translate(r_ct, -_source_graphic_area.left(), -_source_graphic_area.top()); ink_cairo_transform(r_ct, trans); cairo_translate(r_ct, _slot_x, _slot_y); cairo_set_source_surface(r_ct, getcairo(res), 0, 0); diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 3b08743ed..6a86ded8c 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -22,13 +22,15 @@ struct NRArenaItem; namespace Inkscape { +class DrawingContext; + namespace Filters { class FilterSlot { public: /** Creates a new FilterSlot object. */ - FilterSlot(NRArenaItem *item, cairo_t *bgct, NRRectL const *bgarea, - cairo_surface_t *graphic, NRRectL const *graphicarea, FilterUnits const &u); + FilterSlot(NRArenaItem *item, DrawingContext &bgct, + DrawingContext &graphic, FilterUnits const &u); /** Destroys the FilterSlot object and all its contents */ virtual ~FilterSlot(); @@ -66,7 +68,7 @@ public: FilterUnits const &get_units() const { return _units; } Geom::Rect get_slot_area() const; - NRRectL const &get_sg_area() const { return *_source_graphic_area; } + NRRectL get_sg_area() const { NRRectL ret(_source_graphic_area); return ret; } private: typedef std::map SlotMap; @@ -81,8 +83,8 @@ private: double _slot_x, _slot_y; cairo_surface_t *_source_graphic; cairo_t *_background_ct; - NRRectL const *_source_graphic_area; - NRRectL const *_background_area; ///< needed to extract background + Geom::IntRect _source_graphic_area; + Geom::IntRect _background_area; ///< needed to extract background FilterUnits const &_units; int _last_out; FilterQuality filterquality; diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 963d98654..25ef80c17 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -40,6 +40,7 @@ #include "display/nr-arena.h" #include "display/nr-arena-item.h" +#include "display/drawing-context.h" #include <2geom/affine.h> #include <2geom/rect.h> #include "svg/svg-length.h" @@ -96,14 +97,14 @@ Filter::~Filter() } -int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea, cairo_t *graphic, NRRectL const *area) +int Filter::render(NRArenaItem const *item, DrawingContext &bgct, DrawingContext &graphic) { if (_primitive.empty()) { // when no primitives are defined, clear source graphic - cairo_set_source_rgba(graphic, 0,0,0,0); - cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); - cairo_paint(graphic); - cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); + graphic.setSource(0,0,0,0); + graphic.setOperator(CAIRO_OPERATOR_SOURCE); + graphic.paint(); + graphic.setOperator(CAIRO_OPERATOR_OVER); return 1; } @@ -136,10 +137,10 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea = _filter_resolution(filter_area, trans, filterquality); if (!(resolution.first > 0 && resolution.second > 0)) { // zero resolution - clear source graphic and return - cairo_set_source_rgba(graphic, 0,0,0,0); - cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); - cairo_paint(graphic); - cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); + graphic.setSource(0,0,0,0); + graphic.setOperator(CAIRO_OPERATOR_SOURCE); + graphic.paint(); + graphic.setOperator(CAIRO_OPERATOR_OVER); return 1; } @@ -160,7 +161,7 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea } } - FilterSlot slot(const_cast(item), bgct, bgarea, cairo_get_group_target(graphic), area, units); + FilterSlot slot(const_cast(item), bgct, graphic, units); slot.set_quality(filterquality); slot.set_blurquality(blurquality); @@ -168,11 +169,12 @@ int Filter::render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea _primitive[i]->render_cairo(slot); } + Geom::Point origin = graphic.targetLogicalBounds().min(); cairo_surface_t *result = slot.get_result(_output_slot); - cairo_set_source_surface(graphic, result, area->x0, area->y0); - cairo_set_operator(graphic, CAIRO_OPERATOR_SOURCE); - cairo_paint(graphic); - cairo_set_operator(graphic, CAIRO_OPERATOR_OVER); + graphic.setSource(result, origin[Geom::X], origin[Geom::Y]); + graphic.setOperator(CAIRO_OPERATOR_SOURCE); + graphic.paint(); + graphic.setOperator(CAIRO_OPERATOR_OVER); cairo_surface_destroy(result); return 0; @@ -186,10 +188,12 @@ void Filter::set_primitive_units(SPFilterUnits unit) { _primitive_units = unit; } -void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { +void Filter::area_enlarge(Geom::IntRect &bbox, NRArenaItem const *item) const { + NRRectL b(bbox); for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm); + if (_primitive[i]) _primitive[i]->area_enlarge(b, item->ctm); } + bbox = *b.upgrade_2geom(); /* TODO: something. See images at the bottom of filters.svg with medium-low @@ -224,22 +228,13 @@ void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { */ } -void Filter::compute_drawbox(NRArenaItem const *item, NRRectL &item_bbox) { - // Modifying empty bounding boxes confuses rest of the renderer, so - // let's not do that. - if (item_bbox.x0 > item_bbox.x1 || item_bbox.y0 > item_bbox.y1) return; +Geom::IntRect Filter::compute_drawbox(NRArenaItem const *item, Geom::Rect const &item_bbox) { - Geom::Point min(item_bbox.x0, item_bbox.y0); - Geom::Point max(item_bbox.x1, item_bbox.y1); - Geom::Rect tmp_bbox(min, max); + Geom::Rect enlarged = filter_effect_area(item_bbox); + enlarged *= item->ctm; - Geom::Rect enlarged = filter_effect_area(tmp_bbox); - enlarged = enlarged * item->ctm; - - item_bbox.x0 = floor(enlarged.min()[X]); - item_bbox.y0 = floor(enlarged.min()[Y]); - item_bbox.x1 = ceil(enlarged.max()[X]); - item_bbox.y1 = ceil(enlarged.max()[Y]); + Geom::IntRect ret(enlarged.roundOutwards()); + return ret; } Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index e1d4c10e5..5cebf3ad3 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -24,6 +24,8 @@ struct NRArenaItem; namespace Inkscape { +class DrawingContext; + namespace Filters { class Filter : public Inkscape::GC::Managed<> { @@ -33,7 +35,7 @@ public: * the results of filter rendering. @a bgarea and @a area specify bounding boxes * of both surfaces in world coordinates; Cairo contexts are assumed to be in default state * (0,0 = surface origin, no path, OVER operator) */ - int render(NRArenaItem const *item, cairo_t *bgct, NRRectL const *bgarea, cairo_t *graphic, NRRectL const *area); + int render(NRArenaItem const *item, DrawingContext &bgct, DrawingContext &graphic); /** * Creates a new filter primitive under this filter object. @@ -149,13 +151,13 @@ public: * to be rendered so that after filtering, the original area is * drawn correctly. */ - void area_enlarge(NRRectL &area, NRArenaItem const *item) const; + void area_enlarge(Geom::IntRect &area, NRArenaItem const *item) const; /** * Given an item bounding box (in user coords), this function enlarges it * to contain the filter effects region and transforms it to screen * coordinates */ - void compute_drawbox(NRArenaItem const *item, NRRectL &item_bbox); + Geom::IntRect compute_drawbox(NRArenaItem const *item, Geom::Rect const &item_bbox); /** * Returns the filter effects area in user coordinate system. * The given bounding box should be a bounding box as specified in diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 72fa0c444..fa5dd0d98 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -13,6 +13,8 @@ #include "style.h" #include "sp-paint-server.h" #include "display/canvas-bpath.h" // contains SPStrokeJoinType, SPStrokeCapType etc. (WTF!) +#include "display/drawing-context.h" +#include "libnr/nr-rect.h" void NRStyle::Paint::clear() { @@ -142,14 +144,15 @@ void NRStyle::set(SPStyle *style) update(); } -bool NRStyle::prepareFill(cairo_t *ct, NRRect *paintbox) +bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox) { // update fill pattern if (!fill_pattern) { switch (fill.type) { - case PAINT_SERVER: - fill_pattern = sp_paint_server_create_pattern(fill.server, ct, paintbox, fill.opacity); - break; + case PAINT_SERVER: { + NRRect pb(paintbox); + fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), &pb, fill.opacity); + } break; case PAINT_COLOR: { SPColor const &c = fill.color; fill_pattern = cairo_pattern_create_rgba( @@ -162,19 +165,20 @@ bool NRStyle::prepareFill(cairo_t *ct, NRRect *paintbox) return true; } -void NRStyle::applyFill(cairo_t *ct) +void NRStyle::applyFill(Inkscape::DrawingContext &ct) { - cairo_set_source(ct, fill_pattern); - cairo_set_fill_rule(ct, fill_rule); + ct.setSource(fill_pattern); + ct.setFillRule(fill_rule); } -bool NRStyle::prepareStroke(cairo_t *ct, NRRect *paintbox) +bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox) { if (!stroke_pattern) { switch (stroke.type) { - case PAINT_SERVER: - stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct, paintbox, stroke.opacity); - break; + case PAINT_SERVER: { + NRRect pb(paintbox); + stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), &pb, stroke.opacity); + } break; case PAINT_COLOR: { SPColor const &c = stroke.color; stroke_pattern = cairo_pattern_create_rgba( @@ -187,14 +191,14 @@ bool NRStyle::prepareStroke(cairo_t *ct, NRRect *paintbox) return true; } -void NRStyle::applyStroke(cairo_t *ct) +void NRStyle::applyStroke(Inkscape::DrawingContext &ct) { - cairo_set_source(ct, stroke_pattern); - cairo_set_line_width(ct, stroke_width); - cairo_set_line_cap(ct, line_cap); - cairo_set_line_join(ct, line_join); - cairo_set_miter_limit(ct, miter_limit); - cairo_set_dash(ct, dash, n_dash, dash_offset); + ct.setSource(stroke_pattern); + ct.setLineWidth(stroke_width); + ct.setLineCap(line_cap); + ct.setLineJoin(line_join); + ct.setMiterLimit(miter_limit); + cairo_set_dash(ct.raw(), dash, n_dash, dash_offset); // fixme } void NRStyle::update() diff --git a/src/display/nr-style.h b/src/display/nr-style.h index e741e46b4..0ba6ce2c6 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -13,22 +13,25 @@ #define SEEN_INKSCAPE_DISPLAY_NR_ARENA_STYLE_H #include +#include <2geom/rect.h> #include "color.h" class SPColor; class SPPaintServer; class SPStyle; -struct NRRect; +namespace Inkscape { +class DrawingContext; +} struct NRStyle { NRStyle(); ~NRStyle(); void set(SPStyle *); - bool prepareFill(cairo_t *ct, NRRect *paintbox); - bool prepareStroke(cairo_t *ct, NRRect *paintbox); - void applyFill(cairo_t *ct); - void applyStroke(cairo_t *ct); + bool prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox); + bool prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox); + void applyFill(Inkscape::DrawingContext &ct); + void applyStroke(Inkscape::DrawingContext &ct); void update(); enum PaintType { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 90278ac95..d93e0284d 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -53,6 +53,7 @@ #include "display/nr-arena-image.h" #include "display/canvas-arena.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include <2geom/pathvector.h> #include "sp-item.h" #include "sp-root.h" @@ -805,8 +806,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even Geom::Point origin(screen.min()[Geom::X], document->getHeight() - screen.height() - screen.min()[Geom::Y]); - origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2)); - origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2)); + origin[Geom::X] += (screen.width() * ((1 - padding) / 2)); + origin[Geom::Y] += (screen.height() * ((1 - padding) / 2)); Geom::Scale scale(zoom_scale, zoom_scale); Geom::Affine affine = scale * Geom::Translate(-origin * scale); @@ -817,44 +818,42 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even NRGC gc(NULL); gc.transform.setIdentity(); + + Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); - NRRectL final_bbox; - final_bbox.x0 = 0; - final_bbox.y0 = 0; //row; - final_bbox.x1 = width; - final_bbox.y1 = height; //row + num_rows; - - nr_arena_item_invoke_update(root, &final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + nr_arena_item_invoke_update(root, final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); guchar *px = g_new(guchar, stride * height); - - cairo_surface_t *s = cairo_image_surface_create_for_data( - px, CAIRO_FORMAT_ARGB32, width, height, stride); - cairo_t *ct = cairo_create(s); - // cairo_translate not necessary here - surface origin is at 0,0 - - SPNamedView *nv = sp_desktop_namedview(desktop); - guint32 bgcolor = nv->pagecolor; - // bgcolor is 0xrrggbbaa, we need 0xaarrggbb - guint32 dtc = (bgcolor >> 8) | (bgcolor << 24); - - ink_cairo_set_source_rgba32(ct, bgcolor); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_OVER); - - nr_arena_item_invoke_render(ct, root, &final_bbox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); - - cairo_surface_flush(s); - cairo_destroy(ct); - cairo_surface_destroy(s); - - // Hide items - SP_ITEM(document->getRoot())->invoke_hide(dkey); + guint32 bgcolor, dtc; + + { // this block limits the lifetime of DrawingContext + cairo_surface_t *s = cairo_image_surface_create_for_data( + px, CAIRO_FORMAT_ARGB32, width, height, stride); + Inkscape::DrawingContext ct(s, Geom::Point(0,0)); + // cairo_translate not necessary here - surface origin is at 0,0 + + SPNamedView *nv = sp_desktop_namedview(desktop); + bgcolor = nv->pagecolor; + // bgcolor is 0xrrggbbaa, we need 0xaarrggbb + dtc = (bgcolor >> 8) | (bgcolor << 24); + + ct.setSource(bgcolor); + ct.setOperator(CAIRO_OPERATOR_SOURCE); + ct.paint(); + ct.setOperator(CAIRO_OPERATOR_OVER); + + nr_arena_item_invoke_render(ct, root, final_bbox, NR_ARENA_ITEM_RENDER_NO_CACHE ); + + cairo_surface_flush(s); + cairo_surface_destroy(s); + + // Hide items + SP_ITEM(document->getRoot())->invoke_hide(dkey); + + nr_object_unref((NRObject *) arena); + } - nr_object_unref((NRObject *) arena); - guchar *trace_px = g_new(guchar, width * height); memset(trace_px, 0x00, width * height); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index e1ced31b4..df0a40858 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -23,6 +23,7 @@ #include "interface.h" #include "helper/png-write.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena-item.h" #include "display/nr-arena.h" #include "document.h" @@ -144,27 +145,17 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, hide_other_items_recursively(doc->getRoot(), items_only, dkey); } - NRRectL final_bbox; - final_bbox.x0 = 0; - final_bbox.y0 = 0;//row; - final_bbox.x1 = width; - final_bbox.y1 = height;//row + num_rows; + Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); - nr_arena_item_invoke_update(root, &final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + nr_arena_item_invoke_update(root, final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) { - cairo_t *ct = cairo_create(surface); - - // clear to background - ink_cairo_set_source_rgba32(ct, bgcolor); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_OVER); + Inkscape::DrawingContext ct(surface, Geom::Point(0,0)); // render items - nr_arena_item_invoke_render(ct, root, &final_bbox, NULL, NR_ARENA_ITEM_RENDER_NO_CACHE ); + nr_arena_item_invoke_render(ct, root, final_bbox, NR_ARENA_ITEM_RENDER_NO_CACHE ); pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(surface), GDK_COLORSPACE_RGB, TRUE, diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 5a20ac363..f75f96afb 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -23,6 +23,7 @@ #include #include "png-write.h" #include "io/sys.h" +#include "display/drawing-context.h" #include "display/nr-arena-item.h" #include "display/nr-arena.h" #include "document.h" @@ -322,16 +323,13 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v // bbox is now set to the entire image to prevent discontinuities // in the image when blur is used (the borders may still be a bit // off, but that's less noticeable). - NRRectL bbox; - bbox.x0 = 0; - bbox.y0 = row; - bbox.x1 = ebp->width; - bbox.y1 = row + num_rows; + Geom::IntRect bbox = Geom::IntRect::from_xywh(0, row, ebp->width, num_rows); + /* Update to renderable state */ NRGC gc(NULL); gc.transform.setIdentity(); - nr_arena_item_invoke_update(ebp->root, &bbox, &gc, + nr_arena_item_invoke_update(ebp->root, bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ebp->width); @@ -339,18 +337,14 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, ebp->width, num_rows, stride); - cairo_t *ct = cairo_create(s); - cairo_translate(ct, -bbox.x0, -bbox.y0); - - ink_cairo_set_source_rgba32(ct, ebp->background); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_set_operator(ct, CAIRO_OPERATOR_OVER); + Inkscape::DrawingContext ct(s, bbox.min()); + ct.setSource(ebp->background); + ct.setOperator(CAIRO_OPERATOR_SOURCE); + ct.paint(); + ct.setOperator(CAIRO_OPERATOR_OVER); /* Render */ - nr_arena_item_invoke_render(ct, ebp->root, &bbox, NULL, 0); - - cairo_destroy(ct); + nr_arena_item_invoke_render(ct, ebp->root, bbox, 0); cairo_surface_destroy(s); *to_free = px; diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index d1e7671ed..3a3d01ebd 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -22,6 +22,8 @@ #include "macros.h" #include "svg/svg.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" +#include "display/drawing-surface.h" #include "display/nr-arena.h" #include "display/nr-arena-group.h" #include "attributes.h" @@ -658,9 +660,8 @@ sp_pattern_create_pattern(SPPaintServer *ps, } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; - Geom::Point p(pattern_x(pat), pattern_y(pat)); - Geom::Point pd(pattern_width(pat), pattern_height(pat)); - Geom::Rect pattern_tile(p, p + pd); + Geom::Rect pattern_tile = Geom::Rect::from_xywh(pattern_x(pat), pattern_y(pat), + pattern_width(pat), pattern_height(pat)); if (pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { // interpret x, y, width, height in relation to bbox @@ -674,34 +675,24 @@ sp_pattern_create_pattern(SPPaintServer *ps, // oversample the pattern slightly // TODO: find optimum value - Geom::Point c(pattern_tile.dimensions()*ps2user.descrim()*full.descrim()*1.2); + Geom::Point c(pattern_tile.dimensions()*ps2user.descrim()*full.descrim()*1.1); c[Geom::X] = ceil(c[Geom::X]); c[Geom::Y] = ceil(c[Geom::Y]); - Geom::Affine t = Geom::Scale(c) * Geom::Scale(pattern_tile.dimensions()).inverse(); - - NRRectL one_tile; - one_tile.x0 = (int) floor(pattern_tile[Geom::X].min()); - one_tile.y0 = (int) floor(pattern_tile[Geom::Y].min()); - one_tile.x1 = (int) ceil(pattern_tile[Geom::X].max()); - one_tile.y1 = (int) ceil(pattern_tile[Geom::Y].max()); - - cairo_surface_t *target = cairo_get_target(base_ct); - cairo_surface_t *temp = cairo_surface_create_similar(target, CAIRO_CONTENT_COLOR_ALPHA, - c[Geom::X], c[Geom::Y]); - cairo_t *ct = cairo_create(temp); - // scale into a coord system where the surface w,h are equal to tile w,h - ink_cairo_transform(ct, t); + + Geom::IntRect one_tile = pattern_tile.roundOutwards(); + Inkscape::DrawingSurface temp(pattern_tile, c.ceil()); + Inkscape::DrawingContext ct(temp); // render pattern. if (needs_opacity) { - cairo_push_group(ct); // this group is for pattern + opacity + ct.pushGroup(); // this group is for pattern + opacity } // TODO: make sure there are no leaks. NRGC gc(NULL); gc.transform = vb2ps; - nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); - nr_arena_item_invoke_render (ct, root, &one_tile, NULL, 0); + nr_arena_item_invoke_update (root, Geom::IntRect::infinite(), &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); + nr_arena_item_invoke_render (ct, root, one_tile, 0); for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { SP_ITEM(child)->invoke_hide(dkey); @@ -711,16 +702,14 @@ sp_pattern_create_pattern(SPPaintServer *ps, nr_object_unref(arena); if (needs_opacity) { - cairo_pop_group_to_source(ct); // pop raw pattern - cairo_paint_with_alpha(ct, opacity); // apply opacity + ct.popGroupToSource(); // pop raw pattern + ct.paint(opacity); // apply opacity } - cairo_pattern_t *cp = cairo_pattern_create_for_surface(temp); - cairo_destroy(ct); - cairo_surface_destroy(temp); + cairo_pattern_t *cp = cairo_pattern_create_for_surface(temp.raw()); // Apply transformation to user space. Also compensate for oversampling. - ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * t); + ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * temp.drawingTransform()); cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); return cp; diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 813f532a4..ef75d8b23 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -251,11 +251,11 @@ Tracer::sioxProcessImage(SPImage *img, //g_message("img: %d %d %d %d\n", aImg->bbox.x0, aImg->bbox.y0, // aImg->bbox.x1, aImg->bbox.y1); - double width = (double)(aImg->bbox.x1 - aImg->bbox.x0); - double height = (double)(aImg->bbox.y1 - aImg->bbox.y0); + double width = aImg->bbox->width(); + double height = aImg->bbox->height(); - double iwidth = (double)simage.getWidth(); - double iheight = (double)simage.getHeight(); + double iwidth = simage.getWidth(); + double iheight = simage.getHeight(); double iwscale = width / iwidth; double ihscale = height / iheight; @@ -278,11 +278,11 @@ Tracer::sioxProcessImage(SPImage *img, for (int row=0 ; rowbbox.y0) + ihscale * (double) row; + double ypos = aImg->bbox->top() + ihscale * (double) row; for (int col=0 ; colbbox.x0) + iwscale * (double)col; + double xpos = aImg->bbox->left() + iwscale * (double)col; Geom::Point point(xpos, ypos); if (aImg->transform) point *= *aImg->transform; diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index cd1d65ba7..67ec701cb 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -27,9 +27,10 @@ #include "inkscape.h" #include "sp-rect.h" #include "document-private.h" +#include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" -#include "display/cairo-utils.h" #include "ui/cache/svg_preview_cache.h" @@ -38,43 +39,33 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rec Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); nr_arena_item_set_transform(root, t); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, NULL, &gc, + + Geom::IntRect ibox = (dbox * Geom::Scale(scale_factor)).roundOutwards(); + + nr_arena_item_invoke_update( root, ibox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); - /* Item integer bbox in points */ - NRRectL ibox; - ibox.x0 = floor(scale_factor * dbox.min()[Geom::X]); - ibox.y0 = floor(scale_factor * dbox.min()[Geom::Y]); - ibox.x1 = ceil(scale_factor * dbox.max()[Geom::X]); - ibox.y1 = ceil(scale_factor * dbox.max()[Geom::Y]); - /* Find visible area */ - int width = ibox.x1 - ibox.x0; - int height = ibox.y1 - ibox.y0; + int width = ibox.width(); + int height = ibox.height(); int dx = psize; int dy = psize; dx = (dx - width)/2; // watch out for size, since 'unsigned'-'signed' can cause problems if the result is negative dy = (dy - height)/2; - NRRectL area; - area.x0 = ibox.x0 - dx; - area.y0 = ibox.y0 - dy; - area.x1 = area.x0 + psize; - area.y1 = area.y0 + psize; + Geom::IntRect area = Geom::IntRect::from_xywh( + ibox.min() - Geom::IntPoint(dx, dy), Geom::IntPoint(psize, psize)); /* Render */ cairo_surface_t *s = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, psize, psize); - cairo_t *ct = cairo_create(s); - cairo_translate(ct, -area.x0, -area.y0); + Inkscape::DrawingContext ct(s, area.min()); - nr_arena_item_invoke_render(ct, root, &area, NULL, + nr_arena_item_invoke_render(ct, root, area, NR_ARENA_ITEM_RENDER_NO_CACHE ); cairo_surface_flush(s); - cairo_destroy(ct); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, @@ -135,6 +126,17 @@ GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, NRArenaIte return px; } -}; -}; -}; +} +} +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 95cb23a22..bb2029bcf 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -31,6 +31,7 @@ #include "document.h" #include "sp-item.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" #include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "io/sys.h" @@ -1073,6 +1074,19 @@ GdkPixbuf *IconImpl::loadPixmap(gchar const *name, unsigned /*lsize*/, unsigned return pb; } +static Geom::IntRect round_rect(Geom::Rect const &r) +{ + using Geom::X; + using Geom::Y; + Geom::IntPoint a, b; + a[X] = round(r.left()); + a[Y] = round(r.top()); + b[X] = round(r.right()); + b[Y] = round(r.bottom()); + Geom::IntRect ret(a, b); + return ret; +} + // takes doc, root, icon, and icon name to produce pixels extern "C" guchar * sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, @@ -1102,23 +1116,20 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, double sf = 1.0; nr_arena_item_set_transform(root, (Geom::Affine)Geom::Scale(sf, sf)); gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, NULL, &gc, + nr_arena_item_invoke_update( root, Geom::IntRect::infinite(), &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); /* Item integer bbox in points */ - NRRectL ibox; - ibox.x0 = (int) floor(sf * dbox->min()[Geom::X] + 0.5); - ibox.y0 = (int) floor(sf * dbox->min()[Geom::Y] + 0.5); - ibox.x1 = (int) floor(sf * dbox->max()[Geom::X] + 0.5); - ibox.y1 = (int) floor(sf * dbox->max()[Geom::Y] + 0.5); + // NOTE: previously, each rect coordinate was rounded using floor(c + 0.5) + Geom::IntRect ibox = round_rect(*dbox); if ( dump ) { - g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 ); + g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() ); } /* Find button visible area */ - int width = ibox.x1 - ibox.x0; - int height = ibox.y1 - ibox.y0; + int width = ibox.width(); + int height = ibox.height(); if ( dump ) { g_message( " vis --'%s' (%d,%d)", name, width, height ); @@ -1134,49 +1145,38 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, nr_arena_item_set_transform(root, (Geom::Affine)Geom::Scale(sf, sf)); gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, NULL, &gc, + nr_arena_item_invoke_update( root, Geom::IntRect::infinite(), &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); - /* Item integer bbox in points */ - ibox.x0 = (int) floor(sf * dbox->min()[Geom::X] + 0.5); - ibox.y0 = (int) floor(sf * dbox->min()[Geom::Y] + 0.5); - ibox.x1 = (int) floor(sf * dbox->max()[Geom::X] + 0.5); - ibox.y1 = (int) floor(sf * dbox->max()[Geom::Y] + 0.5); + ibox = round_rect(*dbox * Geom::Scale(sf)); if ( dump ) { - g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 ); + g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.left(), (double)ibox.top(), (double)ibox.right(), (double)ibox.bottom() ); } /* Find button visible area */ - width = ibox.x1 - ibox.x0; - height = ibox.y1 - ibox.y0; + width = ibox.width(); + height = ibox.height(); if ( dump ) { g_message( " vis2 --'%s' (%d,%d)", name, width, height ); } } } + Geom::IntPoint pdim(psize, psize); int dx, dy; //dx = (psize - width) / 2; //dy = (psize - height) / 2; dx=dy=psize; dx=(dx-width)/2; // watch out for psize, since 'unsigned'-'signed' can cause problems if the result is negative dy=(dy-height)/2; - NRRectL area; - area.x0 = ibox.x0 - dx; - area.y0 = ibox.y0 - dy; - area.x1 = area.x0 + psize; - area.y1 = area.y0 + psize; + Geom::IntRect area = Geom::IntRect::from_xywh(ibox.min() - Geom::IntPoint(dx,dy), pdim); /* Actual renderable area */ - NRRectL ua; - ua.x0 = MAX(ibox.x0, area.x0); - ua.y0 = MAX(ibox.y0, area.y0); - ua.x1 = MIN(ibox.x1, area.x1); - ua.y1 = MIN(ibox.y1, area.y1); + Geom::IntRect ua = *Geom::intersect(ibox, area); if ( dump ) { - g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.x0, (double)area.y0, (double)area.x1, (double)area.y1 ); - g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.x0, (double)ua.y0, (double)ua.x1, (double)ua.y1 ); + g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.left(), (double)area.top(), (double)area.right(), (double)area.bottom() ); + g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.left(), (double)ua.top(), (double)ua.right(), (double)ua.bottom() ); } stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, psize); @@ -1188,12 +1188,10 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, /* Render */ cairo_surface_t *s = cairo_image_surface_create_for_data(px, CAIRO_FORMAT_ARGB32, psize, psize, stride); - cairo_t *ct = cairo_create(s); - cairo_translate(ct, -ua.x0, -ua.y0); + Inkscape::DrawingContext ct(s, ua.min()); - nr_arena_item_invoke_render(ct, root, &ua, NULL, + nr_arena_item_invoke_render(ct, root, ua, NR_ARENA_ITEM_RENDER_NO_CACHE ); - cairo_destroy(ct); cairo_surface_destroy(s); // convert to GdkPixbuf format -- cgit v1.2.3 From 8dfecde0bdff41381e65b077420692645887c440 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 22 Jul 2011 11:22:07 +0200 Subject: Patch from Andreas Becker to fix bug 805238 (Crash when setting empty font family) (bzr r10487) --- src/libnrtype/FontFactory.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 7fc0a9715..e6d22e070 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -404,7 +404,10 @@ Glib::ustring font_factory::GetUIFamilyString(PangoFontDescription const *fontDe if (fontDescr) { // For now, keep it as family name taken from pango - family = pango_font_description_get_family(fontDescr); + const char *pangoFamily = pango_font_description_get_family(fontDescr); + if( pangoFamily ) { + family = pangoFamily; + } } return family; -- cgit v1.2.3 From 9c0b8ae87db4fc8f471924a14b9420709a607b7d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 22 Jul 2011 12:02:36 +0200 Subject: fix crash when guideline is deleted by dragging it off-canvas (bzr r10488) --- src/sp-guide.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 8d9d7b87d..033e1db1f 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -476,6 +476,10 @@ char *sp_guide_description(SPGuide const *guide, const bool verbose) using Geom::Y; SPNamedView *namedview = sp_document_namedview(guide->document, NULL); + if (!namedview) { + // Guide has probably been deleted and no longer has an attached namedview. + return g_strdup_printf(_("Deleted")); + } GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], namedview->getDefaultMetric()); GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], -- cgit v1.2.3 From 31a7730f576e48628f7e909b2a22fb4952d5d1fd Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 22 Jul 2011 20:56:19 +0200 Subject: Fixed bug where having a font-family with an uninstalled font (or with a list of fonts) prevented changing the font family, style, or weight. (bzr r10491) --- src/widgets/toolbox.cpp | 191 ++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 95 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 1d1fe65bb..ea1811b92 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -6361,6 +6361,20 @@ static void cell_data_func(GtkCellLayout * /*cell_layout*/, } // Font family +// +// In most cases we should just be able to set the new family name +// but there may be cases where a font family doesn't follow the +// standard naming pattern. To handle those cases, we do a song and +// dance to use Pango to find the best match. To do that we start +// with the old "fontSpec" (which is the returned string from +// pango_font_description_to_string() with the size unset). This +// has the form "[family-list] [style-options]" where the +// family-list is a comma separated list of font-family names +// (optionally terminated by a comma). An example would be +// "DejaVu Sans, Sans Bold". Only a "fontSpec" containing a +// single font-family will work with Pango's best match routine. +// If we can't obtain a good "fontSpec", we then resort to blindly +// changing the font-family. static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GObject *tbl ) { #ifdef DEBUG_TEXT @@ -6385,6 +6399,9 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : ""; +#ifdef DEBUG_TEXT + std::cout << " fontSpec from query :" << fontSpec << ":" << std::endl; +#endif // If that didn't work, try to get font spec from style if (fontSpec.empty()) { @@ -6400,90 +6417,90 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle); fontFromStyle->Unref(); } + #ifdef DEBUG_TEXT - std::cout << " Fontspec not defined, reconstructed from style :" << fontSpec << ":" << std::endl; + std::cout << " fontSpec empty, try from style" << std::endl; + std::cout << " from style :" << fontSpec << ":" << std::endl; sp_print_font( query ); #endif + } - // And if that didn't work use default - if( fontSpec.empty() ) { + // And if that didn't work use default. DO WE REALLY WANT TO DO THIS? + if ( fontSpec.empty() ) { + sp_style_read_from_prefs(query, "/tools/text"); -#ifdef DEBUG_TEXT - std::cout << " read style from prefs:" << std::endl; - sp_print_font( query ); -#endif + // Construct a new font specification if it does not yet exist font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query); - if( fontFromStyle ) { + if ( fontFromStyle ) { fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle); fontFromStyle->Unref(); } + #ifdef DEBUG_TEXT - std::cout << " Fontspec not defined, reconstructed from style :" << fontSpec << ":" << std::endl; + std::cout << " fontSpec empty, trying from prefs" << std::endl; + std::cout << " from prefs :" << fontSpec << ":" << std::endl; sp_print_font( query ); #endif } + // Now we have a font specification, replace family. + Glib::ustring newFontSpec = ""; SPCSSAttr *css = sp_repr_css_attr_new (); - if (!fontSpec.empty()) { - // Now we have a font specification, replace family. - Glib::ustring newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family); + if (!fontSpec.empty()) newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family); #ifdef DEBUG_TEXT - std::cout << " New FontSpec from ReplaceFontSpecificationFamily :" << newFontSpec << ":" << std::endl; + std::cout << " New FontSpec from ReplaceFontSpecificationFamily :" << newFontSpec << ":" << std::endl; #endif - if (!newFontSpec.empty()) { + if (!fontSpec.empty() && !newFontSpec.empty() ) { - if (fontSpec != newFontSpec) { + if (fontSpec != newFontSpec) { - font_instance *font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str()); + font_instance *font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str()); - if (font) { - sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str()); + if (font) { + sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str()); - // Set all the these just in case they were altered when finding the best - // match for the new family and old style... + // Set all the these just in case they were altered when finding the best + // match for the new family and old style... Unnecessary? - gchar c[256]; + gchar c[256]; - font->Family(c, 256); + font->Family(c, 256); - sp_repr_css_set_property (css, "font-family", c); + sp_repr_css_set_property (css, "font-family", c); - font->Attribute( "weight", c, 256); - sp_repr_css_set_property (css, "font-weight", c); + font->Attribute( "weight", c, 256); + sp_repr_css_set_property (css, "font-weight", c); - font->Attribute("style", c, 256); - sp_repr_css_set_property (css, "font-style", c); + font->Attribute("style", c, 256); + sp_repr_css_set_property (css, "font-style", c); - font->Attribute("stretch", c, 256); - sp_repr_css_set_property (css, "font-stretch", c); + font->Attribute("stretch", c, 256); + sp_repr_css_set_property (css, "font-stretch", c); - font->Attribute("variant", c, 256); - sp_repr_css_set_property (css, "font-variant", c); + font->Attribute("variant", c, 256); + sp_repr_css_set_property (css, "font-variant", c); - font->Unref(); - } + font->Unref(); + } else { + g_warning(_("Failed to find font matching: %s\n"), newFontSpec.c_str()); } + } + } else { - } else { - - // newFontSpec empty - // If the old font on selection (or default) does not exist on the system, - // or the new font family does not exist, - // ReplaceFontSpecificationFamily does not work. In that case we fall back to blindly - // setting the family reported by the family chooser. - - // g_print ("fallback setting family: %s\n", family); - sp_repr_css_set_property (css, "-inkscape-font-specification", family); - sp_repr_css_set_property (css, "font-family", family); - // Shoud we set other css font attributes? - } + // Either old font does not exist on system or ReplaceFontSpecificationFamily() failed. + // Blindly fall back to setting the family to text in the font-family chooser. - } // fontSpec not empty or not +#ifdef DEBUG_TEXT + std::cout << " Failed to find new font, blindly setting family: " << family << std::endl; +#endif + sp_repr_css_set_property (css, "-inkscape-font-specification", family); + sp_repr_css_set_property (css, "font-family", family); + } // If querying returned nothing, update default style. if (result_fontspec == QUERY_STYLE_NOTHING) @@ -6600,7 +6617,7 @@ static void sp_text_style_changed( InkToggleAction* act, GObject *tbl ) sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query); - if( fontFromStyle ) { + if ( fontFromStyle ) { fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle); fontFromStyle->Unref(); } @@ -6617,67 +6634,51 @@ static void sp_text_style_changed( InkToggleAction* act, GObject *tbl ) case 0: { // Bold - if (!fontSpec.empty()) { - - newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active); - - if (!newFontSpec.empty()) { + if (!fontSpec.empty()) newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active); + if ( !fontSpec.empty() && !newFontSpec.empty() ) { - // Set weight if we found font. - font_instance * font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str()); - if (font) { - gchar c[256]; - font->Attribute( "weight", c, 256); - sp_repr_css_set_property (css, "font-weight", c); - font->Unref(); - font = NULL; - } - nochange = false; + // Set weight using new font if found. + font_instance * font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str()); + if (font) { + gchar c[256]; + font->Attribute( "weight", c, 256); + sp_repr_css_set_property (css, "font-weight", c); + font->Unref(); + font = NULL; } + nochange = false; + } else { + + // Blindly set weight. + sp_repr_css_set_property (css, "font-weight", (active == 0 ? "normal" : "bold") ); } - // Reset button if no change. - // The reset code didn't work in 0.47 and doesn't here... one must prevent an infinite loop - /* - if(nochange) { - gtk_action_block_activate( GTK_ACTION(act) ); - gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), !active ); - gtk_action_unblock_activate( GTK_ACTION(act) ); - } - */ break; } case 1: { // Italic/Oblique - if (!fontSpec.empty()) { + if (!fontSpec.empty()) newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active); - newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active); + if ( !fontSpec.empty() && !newFontSpec.empty() ) { - if (!newFontSpec.empty()) { - - // Don't even set the italic/oblique if the font didn't exist on the system - if( active ) { - if( newFontSpec.find( "Italic" ) != Glib::ustring::npos ) { - sp_repr_css_set_property (css, "font-style", "italic"); - } else { - sp_repr_css_set_property (css, "font-style", "oblique"); - } + // Don't even set the italic/oblique if the font didn't exist on the system + if ( active ) { + if ( newFontSpec.find( "Italic" ) != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-style", "italic"); } else { - sp_repr_css_set_property (css, "font-style", "normal"); + sp_repr_css_set_property (css, "font-style", "oblique"); } - nochange = false; + } else { + sp_repr_css_set_property (css, "font-style", "normal"); } + nochange = false; + + } else { + + // Blindly set style. + sp_repr_css_set_property (css, "font-style", (active == 0 ? "normal" : "italic") ); } - // Reset button if no change. - // The reset code didn't work in 0.47... one must prevent an infinite loop - /* - if(nochange) { - gtk_action_block_activate( GTK_ACTION(act) ); - gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), !active ); - gtk_action_unblock_activate( GTK_ACTION(act) ); - } - */ break; } } @@ -7228,7 +7229,7 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject * * This function sets up the text-tool tool-controls, setting the entry boxes * etc. to the values from the current selection or the default if no selection. * It is called whenever a text selection is changed, including stepping cursor - * through text. + * through text, or setting focus to text. */ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/, GObject *tbl) { -- cgit v1.2.3 From 4812c9be2179558c274be11608a667d14268e6af Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 23 Jul 2011 08:45:54 +0200 Subject: Don't flag a comma separted list of fonts in the font-family entry box as missing on the system if each font in the list is present. (bzr r10493) --- src/ink-comboboxentry-action.cpp | 48 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 5147b04a8..b0fd299bb 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -3,7 +3,8 @@ * Features: * Setting GtkEntryBox width in characters. * Passing a function for formatting cells. - * Displaying a warning if text isn't in list. + * Displaying a warning if entry text isn't in list. + * Check comma separated values in text against list. (Useful for font-family fallbacks.) * Setting names for GtkComboBoxEntry and GtkEntry (actionName_combobox, actionName_entry) * to allow setting resources. * @@ -35,6 +36,7 @@ static GtkWidget* create_menu_item( GtkAction* action ); // Internal static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ); +static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ); // Callbacks static void combo_box_changed_cb( GtkComboBoxEntry* widget, gpointer data ); @@ -463,7 +465,9 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink gtk_entry_set_text( ink_comboboxentry_action->entry, text ); // Show or hide warning - if( ink_comboboxentry_action->active == -1 && ink_comboboxentry_action->warning != NULL ) { + if( ink_comboboxentry_action->active == -1 && + ink_comboboxentry_action->warning != NULL && + check_comma_separated_text( ink_comboboxentry_action ) ) { { GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); @@ -607,6 +611,46 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta } +// Checks if all comma separated text fragments are in the list. +// This is useful for checking if all fonts in a font-family fallback +// list are available on the system. +// The return value is set to the number of missing text fragments. +// This routine could also create a Pango Markup string to show which +// fragments are invalid. +// It is envisioned that one can construct a Pango Markup String here +// so that individual text fragments can be flagged as not being in the +// list. +static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { + + gint ret_val = 0; + + // Parse fallback_list using a comma as deliminator + gchar** tokens = g_strsplit( action->text, ",", 0 ); + + gint i = 0; + gboolean first = TRUE; + while( tokens[i] != NULL ) { + + // Remove any surrounding white space. + g_strstrip( tokens[i] ); + + if( get_active_row_from_text( action, tokens[i] ) == -1 ) { + ret_val += 1; + } + ++i; + } + g_strfreev( tokens ); + + // Pango Markup notes: + // GString* Pango_Markup = g_string_new(""); + // if not present: + // g_string_sprintfa( Pango_Markup, "%s", tokens[i] ); + // PangoLayout * pl = gtk_entry_get_layout( entry ); + // pango_layout_set_markup( pl, Pango_Markup->str, -1 ); + // g_string_free( Pango_Markup, TRUE ); + + return ret_val; +} // Callbacks --------------------------------------------------- -- cgit v1.2.3 From 61752bf47e94af5a5290fd48a8587dfa6ecca5cc Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 23 Jul 2011 14:20:33 +0200 Subject: remove obsolete code because changed to cairo (bzr r10494) --- src/display/sodipodi-ctrlrect.cpp | 93 --------------------------------------- 1 file changed, 93 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index b516456e9..2379fcefd 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -83,77 +83,7 @@ static void sp_ctrlrect_destroy(GtkObject *object) (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); } } -#if 0 -/* FIXME: use definitions from somewhere else */ -#define RGBA_R(v) ((v) >> 24) -#define RGBA_G(v) (((v) >> 16) & 0xff) -#define RGBA_B(v) (((v) >> 8) & 0xff) -#define RGBA_A(v) ((v) & 0xff) - -static void sp_ctrlrect_hline(SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba, guint dashed) -{ - if (y >= buf->rect.y0 && y < buf->rect.y1) { - guint const r = RGBA_R(rgba); - guint const g = RGBA_G(rgba); - guint const b = RGBA_B(rgba); - guint const a = RGBA_A(rgba); - gint const x0 = MAX(buf->rect.x0, xs); - gint const x1 = MIN(buf->rect.x1, xe + 1); - guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (gint x = x0; x < x1; x++) { - if (!dashed || ((x / DASH_LENGTH) % 2)) { - p[0] = INK_COMPOSE(r, a, p[0]); - p[1] = INK_COMPOSE(g, a, p[1]); - p[2] = INK_COMPOSE(b, a, p[2]); - } - p += 4; - } - } -} -static void sp_ctrlrect_vline(SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba, guint dashed) -{ - if (x >= buf->rect.x0 && x < buf->rect.x1) { - guint const r = RGBA_R(rgba); - guint const g = RGBA_G(rgba); - guint const b = RGBA_B(rgba); - guint const a = RGBA_A(rgba); - gint const y0 = MAX(buf->rect.y0, ys); - gint const y1 = MIN(buf->rect.y1, ye + 1); - guchar *p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - for (gint y = y0; y < y1; y++) { - if (!dashed || ((y / DASH_LENGTH) % 2)) { - p[0] = INK_COMPOSE(r, a, p[0]); - p[1] = INK_COMPOSE(g, a, p[1]); - p[2] = INK_COMPOSE(b, a, p[2]); - } - p += buf->buf_rowstride; - } - } -} - -/** Fills the pixels in [xs, xe)*[ys,ye) clipped to the tile with rgb * a. */ -static void sp_ctrlrect_area(SPCanvasBuf *buf, gint xs, gint ys, gint xe, gint ye, guint32 rgba) -{ - guint const r = RGBA_R(rgba); - guint const g = RGBA_G(rgba); - guint const b = RGBA_B(rgba); - guint const a = RGBA_A(rgba); - gint const x0 = MAX(buf->rect.x0, xs); - gint const x1 = MIN(buf->rect.x1, xe + 1); - gint const y0 = MAX(buf->rect.y0, ys); - gint const y1 = MIN(buf->rect.y1, ye + 1); - for (gint y = y0; y < y1; y++) { - guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (gint x = x0; x < x1; x++) { - p[0] = INK_COMPOSE(r, a, p[0]); - p[1] = INK_COMPOSE(g, a, p[1]); - p[2] = INK_COMPOSE(b, a, p[2]); - p += 4; - } - } -} -#endif static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf) { @@ -220,29 +150,6 @@ void CtrlRect::render(SPCanvasBuf *buf) cairo_fill(buf->ct); } cairo_restore(buf->ct); -#if 0 - /* Top */ - sp_ctrlrect_hline(buf, _area.y0, _area.x0, _area.x1, _border_color, _dashed); - /* Bottom */ - sp_ctrlrect_hline(buf, _area.y1, _area.x0, _area.x1, _border_color, _dashed); - /* Left */ - sp_ctrlrect_vline(buf, _area.x0, _area.y0 + 1, _area.y1 - 1, _border_color, _dashed); - /* Right */ - sp_ctrlrect_vline(buf, _area.x1, _area.y0 + 1, _area.y1 - 1, _border_color, _dashed); - if (_shadow_size > 0) { - /* Right shadow */ - sp_ctrlrect_area(buf, _area.x1 + 1, _area.y0 + _shadow_size, - _area.x1 + _shadow_size, _area.y1 + _shadow_size, _shadow_color); - /* Bottom shadow */ - sp_ctrlrect_area(buf, _area.x0 + _shadow_size, _area.y1 + 1, - _area.x1, _area.y1 + _shadow_size, _shadow_color); - } - if (_has_fill) { - /* Fill */ - sp_ctrlrect_area(buf, _area.x0 + 1, _area.y0 + 1, - _area.x1 - 1, _area.y1 - 1, _fill_color); - } -#endif } } -- cgit v1.2.3 From 31ae7c8ea53c651ddcaf9c4b73ecc3fd9e8c8eef Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 23 Jul 2011 15:40:39 +0200 Subject: NRRectL -> 2geom (bzr r10495) --- src/display/sodipodi-ctrlrect.cpp | 181 ++++++++++++++++++++------------------ src/display/sodipodi-ctrlrect.h | 5 +- 2 files changed, 97 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index 2379fcefd..b4539841b 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -15,8 +15,8 @@ * */ -#include "sp-canvas-util.h" #include "sodipodi-ctrlrect.h" +#include "sp-canvas-util.h" #include "display/cairo-utils.h" /* @@ -104,8 +104,7 @@ void CtrlRect::init() _dashed = false; _shadow = 0; - _area.x0 = _area.y0 = 0; - _area.x1 = _area.y1 = 0; + _area = Geom::OptIntRect(); _rect = Geom::Rect(Geom::Point(0,0),Geom::Point(0,0)); @@ -119,20 +118,25 @@ void CtrlRect::init() void CtrlRect::render(SPCanvasBuf *buf) { + using Geom::X; + using Geom::Y; + static double const dashes[2] = {4.0, 4.0}; - if ((_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) && - (_area.x0 < buf->rect.x1) && - (_area.y0 < buf->rect.y1) && - ((_area.x1 + _shadow_size) >= buf->rect.x0) && - ((_area.y1 + _shadow_size) >= buf->rect.y0)) + if (!_area) { + return; + } + Geom::IntRect area = *_area; + Geom::IntRect area_w_shadow (area[X].min(), area[Y].min(), + area[X].max() + _shadow_size, area[Y].max() + _shadow_size); + if ( area_w_shadow.intersects(buf->rect) ) { cairo_save(buf->ct); cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); cairo_set_line_width(buf->ct, 1); if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0); - cairo_rectangle(buf->ct, 0.5 + _area.x0, 0.5 + _area.y0, - _area.x1 - _area.x0, _area.y1 - _area.y0); + cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); if (_has_fill) { ink_cairo_set_source_rgba32(buf->ct, _fill_color); @@ -143,10 +147,10 @@ void CtrlRect::render(SPCanvasBuf *buf) if (_shadow_size > 0) { ink_cairo_set_source_rgba32(buf->ct, _shadow_color); - cairo_rectangle(buf->ct, 1 + _area.x1, _area.y0 + _shadow_size, - _shadow_size, _area.y1 - _area.y0 + 1); // right shadow - cairo_rectangle(buf->ct, _area.x0 + _shadow_size, 1 + _area.y1, - _area.x1 - _area.x0 - _shadow_size + 1, _shadow_size); + cairo_rectangle(buf->ct, 1 + area[X].max(), area[Y].min() + _shadow_size, + _shadow_size, area[Y].max() - area[Y].min() + 1); // right shadow + cairo_rectangle(buf->ct, area[X].min() + _shadow_size, 1 + area[Y].max(), + area[X].max() - area[X].min() - _shadow_size + 1, _shadow_size); cairo_fill(buf->ct); } cairo_restore(buf->ct); @@ -156,145 +160,148 @@ void CtrlRect::render(SPCanvasBuf *buf) 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); } sp_canvas_item_reset_bounds(this); - NRRectL _area_old; - _area_old.x0 = _area.x0; - _area_old.x1 = _area.x1; - _area_old.y0 = _area.y0; - _area_old.y1 = _area.y1; - Geom::Rect bbox(_rect.min() * affine, _rect.max() * affine); - _area.x0 = (int) floor(bbox.min()[Geom::X] + 0.5); - _area.y0 = (int) floor(bbox.min()[Geom::Y] + 0.5); - _area.x1 = (int) floor(bbox.max()[Geom::X] + 0.5); - _area.y1 = (int) floor(bbox.max()[Geom::Y] + 0.5); + Geom::OptIntRect _area_old = _area; + Geom::IntRect area ( (int) floor(bbox.min()[Geom::X] + 0.5), + (int) floor(bbox.min()[Geom::Y] + 0.5), + (int) floor(bbox.max()[Geom::X] + 0.5), + (int) floor(bbox.max()[Geom::Y] + 0.5) ); + _area = area; + Geom::IntRect area_old(0,0,0,0); + if (_area_old) { // this weird construction is because the code below assumes _area_old to be 'valid' + area_old = *_area_old; + } gint _shadow_size_old = _shadow_size; _shadow_size = _shadow; // FIXME: we don't process a possible change in _has_fill if (_has_fill) { - if (_area_old.x0 != 0 || _area_old.x1 != 0 || _area_old.y0 != 0 || _area_old.y1 != 0) { + if (_area_old) { sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y0 - 1, - _area_old.x1 + _shadow_size + 1, _area_old.y1 + _shadow_size + 1); + area_old[X].min() - 1, area_old[Y].min() - 1, + area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); } - if (_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) { + if (_area) { sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y0 - 1, - _area.x1 + _shadow_size + 1, _area.y1 + _shadow_size + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } } else { // clear box, be smart about what part of the frame to redraw /* Top */ - if (_area.y0 != _area_old.y0) { // different level, redraw fully old and new - if (_area_old.x0 != _area_old.x1) + if (area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new + if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y0 - 1, - _area_old.x1 + 1, _area_old.y0 + 1); + area_old[X].min() - 1, area_old[Y].min() - 1, + area_old[X].max() + 1, area_old[Y].min() + 1); - if (_area.x0 != _area.x1) + if (area[X].min() != area[X].max()) sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y0 - 1, - _area.x1 + 1, _area.y0 + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].max() + 1, area[Y].min() + 1); } else { // same level, redraw only the ends - if (_area.x0 != _area_old.x0) { + if (area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x0,_area.x0) - 1, _area.y0 - 1, - MAX(_area_old.x0,_area.x0) + 1, _area.y0 + 1); + MIN(area_old[X].min(),area[X].min()) - 1, area[Y].min() - 1, + MAX(area_old[X].min(),area[X].min()) + 1, area[Y].min() + 1); } - if (_area.x1 != _area_old.x1) { + if (area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x1,_area.x1) - 1, _area.y0 - 1, - MAX(_area_old.x1,_area.x1) + 1, _area.y0 + 1); + MIN(area_old[X].max(),area[X].max()) - 1, area[Y].min() - 1, + MAX(area_old[X].max(),area[X].max()) + 1, area[Y].min() + 1); } } /* Left */ - if (_area.x0 != _area_old.x0) { // different level, redraw fully old and new - if (_area_old.y0 != _area_old.y1) + if (area[X].min() != area_old[X].min()) { // different level, redraw fully old and new + if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y0 - 1, - _area_old.x0 + 1, _area_old.y1 + 1); + area_old[X].min() - 1, area_old[Y].min() - 1, + area_old[X].min() + 1, area_old[Y].max() + 1); - if (_area.y0 != _area.y1) + if (area[Y].min() != area[Y].max()) sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y0 - 1, - _area.x0 + 1, _area.y1 + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].min() + 1, area[Y].max() + 1); } else { // same level, redraw only the ends - if (_area.y0 != _area_old.y0) { + if (area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - _area.x0 - 1, MIN(_area_old.y0,_area.y0) - 1, - _area.x0 + 1, MAX(_area_old.y0,_area.y0) + 1); + area[X].min() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, + area[X].min() + 1, MAX(area_old[Y].min(),area[Y].min()) + 1); } - if (_area.y1 != _area_old.y1) { + if (area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - _area.x0 - 1, MIN(_area_old.y1,_area.y1) - 1, - _area.x0 + 1, MAX(_area_old.y1,_area.y1) + 1); + area[X].min() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, + area[X].min() + 1, MAX(area_old[Y].max(),area[Y].max()) + 1); } } /* Right */ - if (_area.x1 != _area_old.x1 || _shadow_size_old != _shadow_size) { - if (_area_old.y0 != _area_old.y1) + if (area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) { + if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, - _area_old.x1 - 1, _area_old.y0 - 1, - _area_old.x1 + _shadow_size + 1, _area_old.y1 + _shadow_size + 1); + area_old[X].max() - 1, area_old[Y].min() - 1, + area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (_area.y0 != _area.y1) + if (area[Y].min() != area[Y].max()) sp_canvas_request_redraw(canvas, - _area.x1 - 1, _area.y0 - 1, - _area.x1 + _shadow_size + 1, _area.y1 + _shadow_size + 1); + area[X].max() - 1, area[Y].min() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (_area.y0 != _area_old.y0) { + if (area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - _area.x1 - 1, MIN(_area_old.y0,_area.y0) - 1, - _area.x1 + _shadow_size + 1, MAX(_area_old.y0,_area.y0) + _shadow_size + 1); + area[X].max() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, + area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),area[Y].min()) + _shadow_size + 1); } - if (_area.y1 != _area_old.y1) { + if (area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - _area.x1 - 1, MIN(_area_old.y1,_area.y1) - 1, - _area.x1 + _shadow_size + 1, MAX(_area_old.y1,_area.y1) + _shadow_size + 1); + area[X].max() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, + area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),area[Y].max()) + _shadow_size + 1); } } /* Bottom */ - if (_area.y1 != _area_old.y1 || _shadow_size_old != _shadow_size) { - if (_area_old.x0 != _area_old.x1) + if (area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) { + if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y1 - 1, - _area_old.x1 + _shadow_size + 1, _area_old.y1 + _shadow_size + 1); + area_old[X].min() - 1, area_old[Y].max() - 1, + area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (_area.x0 != _area.x1) + if (area[X].min() != area[X].max()) sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y1 - 1, - _area.x1 + _shadow_size + 1, _area.y1 + _shadow_size + 1); + area[X].min() - 1, area[Y].max() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (_area.x0 != _area_old.x0) { + if (area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x0,_area.x0) - 1, _area.y1 - 1, - MAX(_area_old.x0,_area.x0) + _shadow_size + 1, _area.y1 + _shadow_size + 1); + MIN(area_old[X].min(),area[X].min()) - 1, area[Y].max() - 1, + MAX(area_old[X].min(),area[X].min()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } - if (_area.x1 != _area_old.x1) { + if (area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x1,_area.x1) - 1, _area.y1 - 1, - MAX(_area_old.x1,_area.x1) + _shadow_size + 1, _area.y1 + _shadow_size + 1); + MIN(area_old[X].max(),area[X].max()) - 1, area[Y].max() - 1, + MAX(area_old[X].max(),area[X].max()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } } } // update SPCanvasItem box - if (_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) { - x1 = _area.x0 - 1; - y1 = _area.y0 - 1; - x2 = _area.x1 + _shadow_size + 1; - y2 = _area.y1 + _shadow_size + 1; + if (_area) { + x1 = area[X].min() - 1; + y1 = area[Y].min() - 1; + x2 = area[X].max() + _shadow_size + 1; + y2 = area[Y].max() + _shadow_size + 1; } } diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index e69b6ba68..45f8523ed 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -18,7 +18,8 @@ #include #include "sp-canvas-item.h" -#include "libnr/nr-rect-l.h" +#include <2geom/rect.h> +#include <2geom/int-rect.h> struct SPCanvasBuf; @@ -47,7 +48,7 @@ private: Geom::Rect _rect; bool _has_fill; bool _dashed; - NRRectL _area; + Geom::OptIntRect _area; gint _shadow_size; guint32 _border_color; guint32 _fill_color; -- cgit v1.2.3 From 07fed71027585bb07a0952ca2c5e6ab2f90f8e68 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 23 Jul 2011 14:58:50 -0700 Subject: Fix issue with deleted guides and gtk warnings. (bzr r10496) --- src/sp-guide.cpp | 61 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 033e1db1f..0b1888340 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -475,40 +475,43 @@ char *sp_guide_description(SPGuide const *guide, const bool verbose) using Geom::X; using Geom::Y; - SPNamedView *namedview = sp_document_namedview(guide->document, NULL); - if (!namedview) { + char *descr = 0; + if ( !guide->document ) { // Guide has probably been deleted and no longer has an attached namedview. - return g_strdup_printf(_("Deleted")); - } - GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], - namedview->getDefaultMetric()); - GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], - namedview->getDefaultMetric()); - - gchar *shortcuts = g_strdup_printf("; %s", _("Shift+drag to rotate, Ctrl+drag to move origin, Del to delete")); - gchar *descr; - - if ( are_near(guide->normal_to_line, component_vectors[X]) || - are_near(guide->normal_to_line, -component_vectors[X]) ) { - descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str); - } else if ( are_near(guide->normal_to_line, component_vectors[Y]) || - are_near(guide->normal_to_line, -component_vectors[Y]) ) { - descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str); + descr = g_strdup_printf(_("Deleted")); } else { - double const radians = guide->angle(); - double const degrees = Geom::rad_to_deg(radians); - int const degrees_int = (int) round(degrees); - descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"), - degrees_int, position_string_x->str, position_string_y->str); - } + SPNamedView *namedview = sp_document_namedview(guide->document, NULL); + + GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], + namedview->getDefaultMetric()); + GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], + namedview->getDefaultMetric()); - g_string_free(position_string_x, TRUE); - g_string_free(position_string_y, TRUE); + gchar *shortcuts = g_strdup_printf("; %s", _("Shift+drag to rotate, Ctrl+drag to move origin, Del to delete")); - if (verbose) { - descr = g_strconcat(descr, shortcuts, NULL); + if ( are_near(guide->normal_to_line, component_vectors[X]) || + are_near(guide->normal_to_line, -component_vectors[X]) ) { + descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str); + } else if ( are_near(guide->normal_to_line, component_vectors[Y]) || + are_near(guide->normal_to_line, -component_vectors[Y]) ) { + descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str); + } else { + double const radians = guide->angle(); + double const degrees = Geom::rad_to_deg(radians); + int const degrees_int = (int) round(degrees); + descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"), + degrees_int, position_string_x->str, position_string_y->str); + } + + g_string_free(position_string_x, TRUE); + g_string_free(position_string_y, TRUE); + + if (verbose) { + descr = g_strconcat(descr, shortcuts, NULL); + } + g_free(shortcuts); } - g_free(shortcuts); + return descr; } -- cgit v1.2.3 From 894102c82e86480a4701ef92464d4f895bcd0d91 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 23 Jul 2011 15:33:32 -0700 Subject: Fix memory leak. (bzr r10497) --- src/sp-guide.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 0b1888340..b55084609 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -507,7 +507,9 @@ char *sp_guide_description(SPGuide const *guide, const bool verbose) g_string_free(position_string_y, TRUE); if (verbose) { - descr = g_strconcat(descr, shortcuts, NULL); + gchar *oldDescr = descr; + descr = g_strconcat(oldDescr, shortcuts, NULL); + g_free(oldDescr); } g_free(shortcuts); } -- cgit v1.2.3 From 03e215c74bb6ff87bbabae12d82ad58d5a278bdd Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 24 Jul 2011 13:04:11 +0200 Subject: Fixed path update (Bug #812517) (bzr r10499) --- src/extension/patheffect.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index 6da310d30..e093d20d7 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -65,11 +65,9 @@ PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path) Inkscape::Extension::PathEffect * peffect; peffect = dynamic_cast(Inkscape::Extension::db.get(ext_id)); if (peffect != NULL) { - + peffect->processPath(doc, path, prefs); continue; } - - peffect->processPath(doc, path, prefs); } g_strfreev(patheffects); -- cgit v1.2.3 From 2eb1f16b8a4ae20fe6360d8c99ade7e3721d891d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 24 Jul 2011 21:11:02 +0200 Subject: fix page shadow rendering bug introduced in r10495 (bzr r10501) --- src/display/sodipodi-ctrlrect.cpp | 139 ++++++++++++++++++-------------------- src/display/sodipodi-ctrlrect.h | 2 +- 2 files changed, 67 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index b4539841b..b696e5e6c 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -104,7 +104,7 @@ void CtrlRect::init() _dashed = false; _shadow = 0; - _area = Geom::OptIntRect(); + _area = Geom::IntRect(0,0,0,0); _rect = Geom::Rect(Geom::Point(0,0),Geom::Point(0,0)); @@ -123,20 +123,18 @@ void CtrlRect::render(SPCanvasBuf *buf) static double const dashes[2] = {4.0, 4.0}; - if (!_area) { - return; - } - Geom::IntRect area = *_area; - Geom::IntRect area_w_shadow (area[X].min(), area[Y].min(), - area[X].max() + _shadow_size, area[Y].max() + _shadow_size); - if ( area_w_shadow.intersects(buf->rect) ) + if ((_area[X].min() != 0 || _area[X].max() != 0 || _area[Y].min() != 0 || _area[Y].max() != 0) && + (_area[X].min() < buf->rect.x1) && + (_area[Y].min() < buf->rect.y1) && + ((_area[X].max() + _shadow_size) >= buf->rect.x0) && + ((_area[Y].max() + _shadow_size) >= buf->rect.y0) ) { cairo_save(buf->ct); cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); cairo_set_line_width(buf->ct, 1); if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0); - cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), - area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); + cairo_rectangle(buf->ct, 0.5 + _area[X].min(), 0.5 + _area[Y].min(), + _area[X].max() - _area[X].min(), _area[Y].max() - _area[Y].min()); if (_has_fill) { ink_cairo_set_source_rgba32(buf->ct, _fill_color); @@ -147,10 +145,10 @@ void CtrlRect::render(SPCanvasBuf *buf) if (_shadow_size > 0) { ink_cairo_set_source_rgba32(buf->ct, _shadow_color); - cairo_rectangle(buf->ct, 1 + area[X].max(), area[Y].min() + _shadow_size, - _shadow_size, area[Y].max() - area[Y].min() + 1); // right shadow - cairo_rectangle(buf->ct, area[X].min() + _shadow_size, 1 + area[Y].max(), - area[X].max() - area[X].min() - _shadow_size + 1, _shadow_size); + cairo_rectangle(buf->ct, 1 + _area[X].max(), _area[Y].min() + _shadow_size, + _shadow_size, _area[Y].max() - _area[Y].min() + 1); // right shadow + cairo_rectangle(buf->ct, _area[X].min() + _shadow_size, 1 + _area[Y].max(), + _area[X].max() - _area[X].min() - _shadow_size + 1, _shadow_size); cairo_fill(buf->ct); } cairo_restore(buf->ct); @@ -171,137 +169,132 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags) Geom::Rect bbox(_rect.min() * affine, _rect.max() * affine); - Geom::OptIntRect _area_old = _area; - Geom::IntRect area ( (int) floor(bbox.min()[Geom::X] + 0.5), - (int) floor(bbox.min()[Geom::Y] + 0.5), - (int) floor(bbox.max()[Geom::X] + 0.5), - (int) floor(bbox.max()[Geom::Y] + 0.5) ); - _area = area; - Geom::IntRect area_old(0,0,0,0); - if (_area_old) { // this weird construction is because the code below assumes _area_old to be 'valid' - area_old = *_area_old; - } + Geom::IntRect area_old = _area; + _area = Geom::IntRect( (int) floor(bbox.min()[Geom::X] + 0.5), + (int) floor(bbox.min()[Geom::Y] + 0.5), + (int) floor(bbox.max()[Geom::X] + 0.5), + (int) floor(bbox.max()[Geom::Y] + 0.5) ); gint _shadow_size_old = _shadow_size; _shadow_size = _shadow; // FIXME: we don't process a possible change in _has_fill if (_has_fill) { - if (_area_old) { + if (area_old[X].min() != 0 || area_old[X].max() != 0 || area_old[Y].min() != 0 || area_old[Y].max() != 0) { sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].min() - 1, area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); } - if (_area) { + if (_area[X].min() != 0 || _area[X].max() != 0 || _area[Y].min() != 0 || _area[Y].max() != 0) { sp_canvas_request_redraw(canvas, - area[X].min() - 1, area[Y].min() - 1, - area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); + _area[X].min() - 1, _area[Y].min() - 1, + _area[X].max() + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); } } else { // clear box, be smart about what part of the frame to redraw /* Top */ - if (area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new + if (_area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].min() - 1, area_old[X].max() + 1, area_old[Y].min() + 1); - if (area[X].min() != area[X].max()) + if (_area[X].min() != _area[X].max()) sp_canvas_request_redraw(canvas, - area[X].min() - 1, area[Y].min() - 1, - area[X].max() + 1, area[Y].min() + 1); + _area[X].min() - 1, _area[Y].min() - 1, + _area[X].max() + 1, _area[Y].min() + 1); } else { // same level, redraw only the ends - if (area[X].min() != area_old[X].min()) { + if (_area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].min(),area[X].min()) - 1, area[Y].min() - 1, - MAX(area_old[X].min(),area[X].min()) + 1, area[Y].min() + 1); + MIN(area_old[X].min(),_area[X].min()) - 1, _area[Y].min() - 1, + MAX(area_old[X].min(),_area[X].min()) + 1, _area[Y].min() + 1); } - if (area[X].max() != area_old[X].max()) { + if (_area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].max(),area[X].max()) - 1, area[Y].min() - 1, - MAX(area_old[X].max(),area[X].max()) + 1, area[Y].min() + 1); + MIN(area_old[X].max(),_area[X].max()) - 1, _area[Y].min() - 1, + MAX(area_old[X].max(),_area[X].max()) + 1, _area[Y].min() + 1); } } /* Left */ - if (area[X].min() != area_old[X].min()) { // different level, redraw fully old and new + if (_area[X].min() != area_old[X].min()) { // different level, redraw fully old and new if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].min() - 1, area_old[X].min() + 1, area_old[Y].max() + 1); - if (area[Y].min() != area[Y].max()) + if (_area[Y].min() != _area[Y].max()) sp_canvas_request_redraw(canvas, - area[X].min() - 1, area[Y].min() - 1, - area[X].min() + 1, area[Y].max() + 1); + _area[X].min() - 1, _area[Y].min() - 1, + _area[X].min() + 1, _area[Y].max() + 1); } else { // same level, redraw only the ends - if (area[Y].min() != area_old[Y].min()) { + if (_area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - area[X].min() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, - area[X].min() + 1, MAX(area_old[Y].min(),area[Y].min()) + 1); + _area[X].min() - 1, MIN(area_old[Y].min(),_area[Y].min()) - 1, + _area[X].min() + 1, MAX(area_old[Y].min(),_area[Y].min()) + 1); } - if (area[Y].max() != area_old[Y].max()) { + if (_area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - area[X].min() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, - area[X].min() + 1, MAX(area_old[Y].max(),area[Y].max()) + 1); + _area[X].min() - 1, MIN(area_old[Y].max(),_area[Y].max()) - 1, + _area[X].min() + 1, MAX(area_old[Y].max(),_area[Y].max()) + 1); } } /* Right */ - if (area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) { + if (_area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) { if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, area_old[X].max() - 1, area_old[Y].min() - 1, area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (area[Y].min() != area[Y].max()) + if (_area[Y].min() != _area[Y].max()) sp_canvas_request_redraw(canvas, - area[X].max() - 1, area[Y].min() - 1, - area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); + _area[X].max() - 1, _area[Y].min() - 1, + _area[X].max() + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (area[Y].min() != area_old[Y].min()) { + if (_area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - area[X].max() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, - area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),area[Y].min()) + _shadow_size + 1); + _area[X].max() - 1, MIN(area_old[Y].min(),_area[Y].min()) - 1, + _area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),_area[Y].min()) + _shadow_size + 1); } - if (area[Y].max() != area_old[Y].max()) { + if (_area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - area[X].max() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, - area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),area[Y].max()) + _shadow_size + 1); + _area[X].max() - 1, MIN(area_old[Y].max(),_area[Y].max()) - 1, + _area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),_area[Y].max()) + _shadow_size + 1); } } /* Bottom */ - if (area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) { + if (_area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) { if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].max() - 1, area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (area[X].min() != area[X].max()) + if (_area[X].min() != _area[X].max()) sp_canvas_request_redraw(canvas, - area[X].min() - 1, area[Y].max() - 1, - area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); + _area[X].min() - 1, _area[Y].max() - 1, + _area[X].max() + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (area[X].min() != area_old[X].min()) { + if (_area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].min(),area[X].min()) - 1, area[Y].max() - 1, - MAX(area_old[X].min(),area[X].min()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); + MIN(area_old[X].min(),_area[X].min()) - 1, _area[Y].max() - 1, + MAX(area_old[X].min(),_area[X].min()) + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); } - if (area[X].max() != area_old[X].max()) { + if (_area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].max(),area[X].max()) - 1, area[Y].max() - 1, - MAX(area_old[X].max(),area[X].max()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); + MIN(area_old[X].max(),_area[X].max()) - 1, _area[Y].max() - 1, + MAX(area_old[X].max(),_area[X].max()) + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); } } } // update SPCanvasItem box - if (_area) { - x1 = area[X].min() - 1; - y1 = area[Y].min() - 1; - x2 = area[X].max() + _shadow_size + 1; - y2 = area[Y].max() + _shadow_size + 1; + if (_area[X].min() != 0 || _area[X].max() != 0 || _area[Y].min() != 0 || _area[Y].max() != 0) { + x1 = _area[X].min() - 1; + y1 = _area[Y].min() - 1; + x2 = _area[X].max() + _shadow_size + 1; + y2 = _area[Y].max() + _shadow_size + 1; } } diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 45f8523ed..4093fafd6 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -48,7 +48,7 @@ private: Geom::Rect _rect; bool _has_fill; bool _dashed; - Geom::OptIntRect _area; + Geom::IntRect _area; gint _shadow_size; guint32 _border_color; guint32 _fill_color; -- cgit v1.2.3 From 3e2e4bb6dc7b919c0fc2a56b3e9eed9e30cfabed Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 25 Jul 2011 01:24:28 +0200 Subject: Update 2Geom to fix serious IntRect bug I've found in my GSoC branch (bzr r10502) --- src/2geom/2geom.h | 75 +++++++++++++++++++++++++++++++ src/2geom/affine.h | 4 +- src/2geom/coord.h | 6 --- src/2geom/forward.h | 1 + src/2geom/generic-interval.h | 4 +- src/2geom/generic-rect.h | 44 +++++++++++------- src/2geom/int-point.h | 5 +++ src/2geom/int-rect.h | 1 - src/2geom/interval.h | 15 ++++++- src/2geom/path-intersection.cpp | 6 ++- src/2geom/point.cpp | 4 +- src/2geom/point.h | 15 ++++--- src/2geom/rect.h | 30 +++---------- src/2geom/solve-bezier-parametric.cpp | 12 ++--- src/2geom/solver.h | 4 +- src/2geom/transforms.cpp | 41 ++++++++++++++--- src/2geom/transforms.h | 85 ++++++++++++++++++++++++++++------- 17 files changed, 258 insertions(+), 94 deletions(-) create mode 100644 src/2geom/2geom.h (limited to 'src') diff --git a/src/2geom/2geom.h b/src/2geom/2geom.h new file mode 100644 index 000000000..000f3423d --- /dev/null +++ b/src/2geom/2geom.h @@ -0,0 +1,75 @@ +/** + * \file + * \brief Include everything + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright 2011 Authors + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + */ + +#ifndef SEEN_LIB2GEOM_2GEOM_H +#define SEEN_LIB2GEOM_2GEOM_H + +#include <2geom/forward.h> + +// primitives +#include <2geom/coord.h> +#include <2geom/point.h> +#include <2geom/interval.h> +#include <2geom/rect.h> +#include <2geom/angle.h> +#include <2geom/ray.h> +#include <2geom/line.h> +#include <2geom/affine.h> +#include <2geom/transforms.h> + +// curves and paths +#include <2geom/curves.h> +#include <2geom/path.h> +#include <2geom/pathvector.h> + +// fragments +#include <2geom/d2.h> +#include <2geom/linear.h> +#include <2geom/bezier.h> +#include <2geom/sbasis.h> + +// others +#include <2geom/math-utils.h> +#include <2geom/utils.h> + +#endif // SEEN_LIB2GEOM_HEADER_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/2geom/affine.h b/src/2geom/affine.h index b07fba0f7..d7a7a0692 100644 --- a/src/2geom/affine.h +++ b/src/2geom/affine.h @@ -65,7 +65,8 @@ class Affine , MultipliableNoncommutative< Affine, Rotate , MultipliableNoncommutative< Affine, HShear , MultipliableNoncommutative< Affine, VShear - > > > > > > > + , MultipliableNoncommutative< Affine, Zoom + > > > > > > > > { Coord _c[6]; public: @@ -113,6 +114,7 @@ public: Affine &operator*=(Rotate const &r); Affine &operator*=(HShear const &h); Affine &operator*=(VShear const &v); + Affine &operator*=(Zoom const &); /// @} bool operator==(Affine const &o) const { diff --git a/src/2geom/coord.h b/src/2geom/coord.h index c7bbcdcd4..f7bf2c5d0 100644 --- a/src/2geom/coord.h +++ b/src/2geom/coord.h @@ -69,9 +69,6 @@ struct CoordTraits { typedef OptIntInterval OptIntervalType; typedef IntRect RectType; typedef OptIntRect OptRectType; - inline static bool contains(IntCoord low, IntCoord high, IntCoord testlow, IntCoord testhigh) { - return low <= testlow && testhigh < high; - } }; template<> @@ -81,9 +78,6 @@ struct CoordTraits { typedef OptInterval OptIntervalType; typedef Rect RectType; typedef OptRect OptRectType; - inline static bool contains(Coord low, Coord high, Coord testlow, Coord testhigh) { - return low <= testlow && testhigh <= high; - } }; } // end namespace Geom diff --git a/src/2geom/forward.h b/src/2geom/forward.h index b1cad6f1f..0dbd9fa94 100644 --- a/src/2geom/forward.h +++ b/src/2geom/forward.h @@ -97,6 +97,7 @@ class Rotate; class Scale; class HShear; class VShear; +class Zoom; // templates template class D2; diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h index d719c16c8..a32e97d4b 100644 --- a/src/2geom/generic-interval.h +++ b/src/2geom/generic-interval.h @@ -106,11 +106,11 @@ public: /// @{ /** @brief Check whether the interval includes this number. */ bool contains(C val) const { - return CoordTraits::contains(min(), max(), val, val); + return min() <= val && val <= max(); } /** @brief Check whether the interval includes the given interval. */ bool contains(Self const &val) const { - return CoordTraits::contains(min(), max(), val.min(), val.max()); + return min() <= val.min() && val.max() <= max(); } /** @brief Check whether the intervals have any common elements. */ bool intersects(Self const &val) const { diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index d60c4bb0f..2db30dfa9 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -40,6 +40,7 @@ #ifndef LIB2GEOM_SEEN_GENERIC_RECT_H #define LIB2GEOM_SEEN_GENERIC_RECT_H +#include #include namespace Geom { @@ -53,10 +54,10 @@ class GenericOptRect; */ template class GenericRect - : boost::additive< GenericRect, typename CoordTraits::PointType - , boost::equality_comparable< GenericRect - , boost::orable< GenericRect - , boost::orable< GenericRect, typename CoordTraits::OptRectType + : boost::additive< typename CoordTraits::RectType, typename CoordTraits::PointType + , boost::equality_comparable< typename CoordTraits::RectType + , boost::orable< typename CoordTraits::RectType + , boost::orable< typename CoordTraits::RectType, typename CoordTraits::OptRectType > > > > { typedef typename CoordTraits::IntervalType CInterval; @@ -93,30 +94,37 @@ public: * @param end End of the range * @return Rectangle that contains all points from [start, end). */ template - static GenericRect from_range(InputIterator start, InputIterator end) { + static CRect from_range(InputIterator start, InputIterator end) { assert(start != end); CPoint p1 = *start++; - GenericRect result(p1, p1); + CRect result(p1, p1); for (; start != end; ++start) { result.expandTo(*start); } return result; } /** @brief Create a rectangle from a C-style array of points it should contain. */ - static GenericRect from_array(CPoint const *c, unsigned n) { - GenericRect result = GenericRect::from_range(c, c+n); + static CRect from_array(CPoint const *c, unsigned n) { + CRect result = GenericRect::from_range(c, c+n); return result; } /** @brief Create rectangle from origin and dimensions. */ - static GenericRect from_xywh(C x, C y, C w, C h) { + static CRect from_xywh(C x, C y, C w, C h) { CPoint xy(x, y); CPoint wh(w, h); - GenericRect result(xy, xy + wh); + CRect result(xy, xy + wh); return result; } /** @brief Create rectangle from origin and dimensions. */ - static GenericRect from_xywh(CPoint const &xy, CPoint const &wh) { - GenericRect result(xy, xy + wh); + static CRect from_xywh(CPoint const &xy, CPoint const &wh) { + CRect result(xy, xy + wh); + return result; + } + /// Create infinite rectangle. + static CRect infinite() { + CPoint p0(std::numeric_limits::min(), std::numeric_limits::min()); + CPoint p1(std::numeric_limits::max(), std::numeric_limits::max()); + CRect result(p0, p1); return result; } /// @} @@ -155,6 +163,8 @@ public: C width() const { return f[X].extent(); } /** @brief Get the vertical extent of the rectangle. */ C height() const { return f[Y].extent(); } + /** @brief Get the ratio of width to height of the rectangle. */ + Coord aspectRatio() const { return Coord(width()) / Coord(height()); } /** @brief Get rectangle's width and height as a point. * @return Point with X coordinate corresponding to the width and the Y coordinate @@ -215,7 +225,7 @@ public: f[X].expandTo(p[X]); f[Y].expandTo(p[Y]); } /** @brief Enlarge the rectangle to contain the given rectangle. */ - void unionWith(GenericRect const &b) { + void unionWith(CRect const &b) { f[X].unionWith(b[X]); f[Y].unionWith(b[Y]); } /** @brief Enlarge the rectangle to contain the given rectangle. @@ -255,7 +265,7 @@ public: return *this; } /** @brief Union two rectangles. */ - GenericRect &operator|=(GenericRect const &o) { + GenericRect &operator|=(CRect const &o) { unionWith(o); return *this; } @@ -275,9 +285,9 @@ public: template class GenericOptRect : public boost::optional::RectType> - , boost::orable< GenericOptRect - , boost::andable< GenericOptRect - , boost::andable< GenericOptRect, typename CoordTraits::RectType + , boost::orable< typename CoordTraits::OptRectType + , boost::andable< typename CoordTraits::OptRectType + , boost::andable< typename CoordTraits::OptRectType, typename CoordTraits::RectType > > > { typedef typename CoordTraits::IntervalType CInterval; diff --git a/src/2geom/int-point.h b/src/2geom/int-point.h index cf2fe720f..1a16ecb7a 100644 --- a/src/2geom/int-point.h +++ b/src/2geom/int-point.h @@ -83,6 +83,11 @@ public: } IntCoord operator[](Dim2 d) const { return _pt[d]; } IntCoord &operator[](Dim2 d) { return _pt[d]; } + + IntCoord x() const throw() { return _pt[X]; } + IntCoord &x() throw() { return _pt[X]; } + IntCoord y() const throw() { return _pt[Y]; } + IntCoord &y() throw() { return _pt[Y]; } /// @} /// @name Vector-like arithmetic operations diff --git a/src/2geom/int-rect.h b/src/2geom/int-rect.h index a143b3ac5..567d42da5 100644 --- a/src/2geom/int-rect.h +++ b/src/2geom/int-rect.h @@ -32,7 +32,6 @@ #define LIB2GEOM_SEEN_INT_RECT_H #include <2geom/coord.h> -#include <2geom/int-point.h> #include <2geom/int-interval.h> #include <2geom/generic-rect.h> diff --git a/src/2geom/interval.h b/src/2geom/interval.h index ee6d674d2..e95da4811 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -64,7 +64,7 @@ typedef GenericOptInterval OptInterval; class Interval : public GenericInterval , boost::multipliable< Interval - , boost::multipliable< Interval, Coord + , boost::multiplicative< Interval, Coord > > { typedef GenericInterval Base; @@ -180,7 +180,20 @@ public: /// @} }; +// functions required for Python bindings +inline Interval unify(Interval const &a, Interval const &b) +{ + Interval r = a | b; + return r; +} +inline OptInterval intersect(Interval const &a, Interval const &b) +{ + OptInterval r = a & b; + return r; } + +} // end namespace Geom + #endif //SEEN_INTERVAL_H /* diff --git a/src/2geom/path-intersection.cpp b/src/2geom/path-intersection.cpp index 7aa662abb..c38776304 100644 --- a/src/2geom/path-intersection.cpp +++ b/src/2geom/path-intersection.cpp @@ -226,8 +226,8 @@ intersect_polish_f (const gsl_vector * x, void *params, #endif static void -intersect_polish_root (Curve const &A, double &s, - Curve const &B, double &t) { +intersect_polish_root (Curve const &A, double &s, Curve const &B, double &t) +{ std::vector as, bs; as = A.pointAndDerivatives(s, 2); bs = B.pointAndDerivatives(t, 2); @@ -271,6 +271,8 @@ intersect_polish_root (Curve const &A, double &s, } #ifdef HAVE_GSL + int status; + size_t iter = 0; if(0) { // the GSL version is more accurate, but taints this with GPL const size_t n = 2; struct rparams p = {A, B}; diff --git a/src/2geom/point.cpp b/src/2geom/point.cpp index cafc0fdba..3ad9dd1fd 100644 --- a/src/2geom/point.cpp +++ b/src/2geom/point.cpp @@ -49,8 +49,8 @@ namespace Geom { * from the origin (point at 0,0) to the stored coordinates, * and has methods implementing several vector operations (like length()). * - * @par Operator note - * @par + * @section OpNotePoint Operator note + * * Most operators are provided by Boost operator helpers, so they are not visible in this class. * If @a p, @a q, @a r denote points, @a s a floating-point scalar, and @a m a transformation matrix, * then the following operations are available: diff --git a/src/2geom/point.h b/src/2geom/point.h index 69da8a4ae..0eb771874 100644 --- a/src/2geom/point.h +++ b/src/2geom/point.h @@ -58,7 +58,8 @@ class Point , MultipliableNoncommutative< Point, Scale , MultipliableNoncommutative< Point, HShear , MultipliableNoncommutative< Point, VShear - > > > > > > > > > // this uses chaining so it looks weird, but works + , MultipliableNoncommutative< Point, Zoom + > > > > > > > > > > // this uses chaining so it looks weird, but works { Coord _pt[2]; public: @@ -111,6 +112,11 @@ public: Coord operator[](Dim2 d) const throw() { return _pt[d]; } Coord &operator[](Dim2 d) throw() { return _pt[d]; } + + Coord x() const throw() { return _pt[X]; } + Coord &x() throw() { return _pt[X]; } + Coord y() const throw() { return _pt[Y]; } + Coord &y() throw() { return _pt[Y]; } /// @} /// @name Vector operations @@ -172,12 +178,7 @@ public: Point &operator*=(Rotate const &r); Point &operator*=(HShear const &s); Point &operator*=(VShear const &s); - /** @brief Transform the point by the inverse of the specified matrix. */ - template - Point &operator/=(T const &m) { - *this *= m.inverse(); - return *this; - } + Point &operator*=(Zoom const &z); /// @} /// @name Conversion to integer points diff --git a/src/2geom/rect.h b/src/2geom/rect.h index e9f6cbeb7..f7d331523 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -73,31 +73,7 @@ public: Rect(Point const &a, Point const &b) : Base(a,b) {} Rect(Coord x0, Coord y0, Coord x1, Coord y1) : Base(x0, y0, x1, y1) {} Rect(Base const &b) : Base(b) {} - /** @brief Create a rectangle from a range of points. - * The resulting rectangle will contain all ponts from the range. - * The return type of iterators must be convertible to Point. - * The range must not be empty. For possibly empty ranges, see OptRect. - * @param start Beginning of the range - * @param end End of the range - * @return Rectangle that contains all points from [start, end). */ - template - static Rect from_range(InputIterator start, InputIterator end) { - Rect result = Base::from_range(start, end); - return result; - } - /** @brief Create a rectangle from a C-style array of points it should contain. */ - static Rect from_array(Point const *c, unsigned n) { - Rect result = Rect::from_range(c, c+n); - return result; - } - static Rect from_xywh(Coord x, Coord y, Coord w, Coord h) { - Rect result = Base::from_xywh(x, y, w, h); - return result; - } - static Rect from_xywh(Point const &o, Point const &dim) { - Rect result = Base::from_xywh(o, dim); - return result; - } + Rect(IntRect const &ir) : Base(ir.min(), ir.max()) {} /// @} /// @name Inspect dimensions. @@ -114,6 +90,10 @@ public: bool interiorIntersects(Rect const &r) const { return f[X].interiorIntersects(r[X]) && f[Y].interiorIntersects(r[Y]); } + /** @brief Check whether the interior includes the given point. */ + bool interiorContains(Point const &p) const { + return f[X].interiorContains(p[X]) && f[Y].interiorContains(p[Y]); + } /** @brief Check whether the interior includes all points in the given rectangle. * Interior of the rectangle is the entire rectangle without its borders. */ bool interiorContains(Rect const &r) const { diff --git a/src/2geom/solve-bezier-parametric.cpp b/src/2geom/solve-bezier-parametric.cpp index 437f073a3..76cf65e17 100644 --- a/src/2geom/solve-bezier-parametric.cpp +++ b/src/2geom/solve-bezier-parametric.cpp @@ -68,13 +68,13 @@ find_parametric_bezier_roots(Geom::Point const *w, /* The control points */ break; } - // Otherwise, solve recursively after subdividing control polygon - std::vector Left(degree + 1); // New left and right - std::vector Right(degree + 1); // control polygons - Bezier(w, degree, 0.5, &Left[0], &Right[0]); + /* Otherwise, solve recursively after subdividing control polygon */ + Geom::Point Left[degree+1], /* New left and right */ + Right[degree+1]; /* control polygons */ + Bezier(w, degree, 0.5, Left, Right); total_subs ++; - find_parametric_bezier_roots(&Left[0], degree, solutions, depth + 1); - find_parametric_bezier_roots(&Right[0], degree, solutions, depth + 1); + find_parametric_bezier_roots(Left, degree, solutions, depth+1); + find_parametric_bezier_roots(Right, degree, solutions, depth+1); } diff --git a/src/2geom/solver.h b/src/2geom/solver.h index 5e77f13dc..793939b2a 100644 --- a/src/2geom/solver.h +++ b/src/2geom/solver.h @@ -1,7 +1,7 @@ /** * \file - * \brief \todo brief description - * + * \brief Finding roots of Bernstein-Bezier polynomials + *//* * Authors: * ? * diff --git a/src/2geom/transforms.cpp b/src/2geom/transforms.cpp index 2658719c4..b8355cadc 100644 --- a/src/2geom/transforms.cpp +++ b/src/2geom/transforms.cpp @@ -35,9 +35,21 @@ #include #include <2geom/point.h> #include <2geom/transforms.h> +#include <2geom/rect.h> namespace Geom { +/** @brief Zoom between rectangles. + * Given two rectangles, compute a zoom that maps one to the other. + * Rectangles are assumed to have the same aspect ratio. */ +Zoom Zoom::map_rect(Rect const &old_r, Rect const &new_r) +{ + Zoom ret; + ret._scale = new_r.width() / old_r.width(); + ret._trans = new_r.min() - old_r.min(); + return ret; +} + // Point transformation methods. Point &Point::operator*=(Translate const &t) { @@ -68,6 +80,14 @@ Point &Point::operator*=(VShear const &v) _pt[Y] += v.f * _pt[Y]; return *this; } +Point &Point::operator*=(Zoom const &z) +{ + _pt[X] += z._trans[X]; + _pt[Y] += z._trans[Y]; + _pt[X] *= z._scale; + _pt[Y] *= z._scale; + return *this; +} // Affine multiplication methods. @@ -110,6 +130,14 @@ Affine &Affine::operator*=(VShear const &v) { return *this; } +Affine &Affine::operator*=(Zoom const &z) { + _c[0] *= z._scale; _c[1] *= z._scale; + _c[2] *= z._scale; _c[3] *= z._scale; + _c[4] += z._trans[X]; _c[5] += z._trans[Y]; + _c[4] *= z._scale; _c[5] *= z._scale; + return *this; +} + // this checks whether the requirements of TransformConcept are satisfied for all transforms. // if you add a new transform type, include it here! void check_transforms() @@ -120,6 +148,7 @@ void check_transforms() BOOST_CONCEPT_ASSERT((TransformConcept)); BOOST_CONCEPT_ASSERT((TransformConcept)); BOOST_CONCEPT_ASSERT((TransformConcept)); + BOOST_CONCEPT_ASSERT((TransformConcept)); BOOST_CONCEPT_ASSERT((TransformConcept)); // Affine is also a transform #endif @@ -130,14 +159,16 @@ void check_transforms() Rotate r(Rotate::identity()); HShear h(HShear::identity()); VShear v(VShear::identity()); + Zoom z(Zoom::identity()); // notice that the first column is always the same and enumerates all transform types, // while the second one changes to each transform type in turn. - m = t * t; m = t * s; m = t * r; m = t * h; m = t * v; - m = s * t; m = s * s; m = s * r; m = s * h; m = s * v; - m = r * t; m = r * s; m = r * r; m = r * h; m = r * v; - m = h * t; m = h * s; m = h * r; m = h * h; m = h * v; - m = v * t; m = v * s; m = v * r; m = v * h; m = v * v; + m = t * t; m = t * s; m = t * r; m = t * h; m = t * v; m = t * z; + m = s * t; m = s * s; m = s * r; m = s * h; m = s * v; m = s * z; + m = r * t; m = r * s; m = r * r; m = r * h; m = r * v; m = r * z; + m = h * t; m = h * s; m = h * r; m = h * h; m = h * v; m = h * z; + m = v * t; m = v * s; m = v * r; m = v * h; m = v * v; m = v * z; + m = z * t; m = z * s; m = z * r; m = z * h; m = z * v; m = z * z; } } diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 9623bed26..5627e8b6f 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -106,13 +106,14 @@ T pow(T const &t, int n) { class Translate : public TransformOperations< Translate > { - Translate() : vec(0, 0) {} Point vec; public: - /** @brief Construct a translation from its vector. */ - explicit Translate(Point const &p) : vec(p) {} - /** @brief Construct a translation from its coordinates. */ - explicit Translate(Coord x, Coord y) : vec(x, y) {} + /// Create a translation that doesn't do anything. + Translate() : vec(0, 0) {} + /// Construct a translation from its vector. + Translate(Point const &p) : vec(p) {} + /// Construct a translation from its coordinates. + Translate(Coord x, Coord y) : vec(x, y) {} operator Affine() const { Affine ret(1, 0, 0, 1, vec[X], vec[Y]); return ret; } Coord operator[](Dim2 dim) const { return vec[dim]; } @@ -120,9 +121,10 @@ public: Translate &operator*=(Translate const &o) { vec += o.vec; return *this; } bool operator==(Translate const &o) const { return vec == o.vec; } - /** @brief Get the inverse translation. */ + Point vector() const { return vec; } + /// Get the inverse translation. Translate inverse() const { return Translate(-vec); } - /** @brief Get a translation that doesn't do anything. */ + /// Get a translation that doesn't do anything. static Translate identity() { Translate ret; return ret; } friend class Point; @@ -136,10 +138,14 @@ class Scale : public TransformOperations< Scale > { Point vec; - Scale() : vec(1, 1) {} public: + /// Create a scaling that doesn't do anything. + Scale() : vec(1, 1) {} + /// Create a scaling from two scaling factors given as coordinates of a point. explicit Scale(Point const &p) : vec(p) {} + /// Create a scaling from two scaling factors. Scale(Coord x, Coord y) : vec(x, y) {} + /// Create an uniform scaling from a single scaling factor. explicit Scale(Coord s) : vec(s, s) {} inline operator Affine() const { Affine ret(vec[X], 0, 0, vec[Y], 0, 0); return ret; } @@ -150,6 +156,8 @@ public: Coord &operator[](unsigned d) { return vec[d]; } Scale &operator*=(Scale const &b) { vec[X] *= b[X]; vec[Y] *= b[Y]; return *this; } bool operator==(Scale const &o) const { return vec == o.vec; } + + Point vector() const { return vec; } Scale inverse() const { return Scale(1./vec[0], 1./vec[1]); } static Scale identity() { Scale ret; return ret; } @@ -162,15 +170,16 @@ public: class Rotate : public TransformOperations< Rotate > { - Rotate() : vec(1, 0) {} - Point vec; + Point vec; ///< @todo Convert to storing the angle, as it's more space-efficient. public: + /// Construct a zero-degree rotation. + Rotate() : vec(1, 0) {} /** @brief Construct a rotation from its angle in radians. * Positive arguments correspond to counter-clockwise rotations (if Y grows upwards). */ explicit Rotate(Coord theta) : vec(Point::polar(theta)) {} - /** @brief Construct a rotation from its characteristic vector. */ + /// Construct a rotation from its characteristic vector. explicit Rotate(Point const &p) : vec(unit_vector(p)) {} - /** @brief Construct a rotation from the coordinates of its characteristic vector. */ + /// Construct a rotation from the coordinates of its characteristic vector. explicit Rotate(Coord x, Coord y) { Rotate(Point(x, y)); } operator Affine() const { Affine ret(vec[X], vec[Y], -vec[Y], vec[X], 0, 0); return ret; } @@ -186,10 +195,10 @@ public: r.vec = Point(vec[X], -vec[Y]); return r; } - /** @brief Get a 0-degree rotation. */ + /// @brief Get a zero-degree rotation. static Rotate identity() { Rotate ret; return ret; } /** @brief Construct a rotation from its angle in degrees. - * Positive arguments correspond to counter-clockwise rotations (if Y grows upwards). */ + * Positive arguments correspond to clockwise rotations if Y grows downwards. */ static Rotate from_degrees(Coord deg) { Coord rad = (deg / 180.0) * M_PI; return Rotate(rad); @@ -213,8 +222,8 @@ public: void setFactor(Coord nf) { f = nf; } S &operator*=(S const &s) { f += s.f; return static_cast(*this); } bool operator==(S const &s) const { return f == s.f; } - S inverse() const { return S(-f); } - static S identity() { return S(0); } + S inverse() const { S ret(-f); return ret; } + static S identity() { S ret(0); return ret; } friend class Point; friend class Affine; @@ -244,6 +253,48 @@ public: operator Affine() const { Affine ret(1, f, 0, 1, 0, 0); return ret; } }; +/** @brief Combination of a translation and uniform scale. + * The translation part is applied first, then the result is scaled from the new origin. + * This way when the class is used to accumulate a zoom transform, trans always points + * to the new origin in original coordinates. + * @ingroup Transform */ +class Zoom + : public TransformOperations< Zoom > +{ + Coord _scale; + Point _trans; + Zoom() : _scale(1), _trans() {} +public: + /// Construct a zoom from a scaling factor. + explicit Zoom(Coord s) : _scale(s), _trans() {} + /// Construct a zoom from a translation. + explicit Zoom(Translate const &t) : _scale(1), _trans(t.vector()) {} + /// Construct a zoom from a scaling factor and a translation. + Zoom(Coord s, Translate const &t) : _scale(s), _trans(t.vector()) {} + + operator Affine() const { + Affine ret(_scale, 0, 0, _scale, _trans[X] * _scale, _trans[Y] * _scale); + return ret; + } + Zoom &operator*=(Zoom const &z) { + _trans += z._trans / _scale; + _scale *= z._scale; + return *this; + } + bool operator==(Zoom const &z) const { return _scale == z._scale && _trans == z._trans; } + + Coord scale() const { return _scale; } + void setScale(Coord s) { _scale = s; } + Point translation() const { return _trans; } + void setTranslation(Point const &p) { _trans = p; } + Zoom inverse() const { Zoom ret(1/_scale, Translate(-_trans*_scale)); return ret; } + static Zoom identity() { Zoom ret(1.0); return ret; } + static Zoom map_rect(Rect const &old_r, Rect const &new_r); + + friend class Point; + friend class Affine; +}; + /** @brief Specialization of exponentiation for Scale. * @relates Scale */ template<> @@ -259,7 +310,7 @@ inline Translate pow(Translate const &t, int n) { return ret; } -//TODO: matrix to trans/scale/rotate +//TODO: decomposition of Affine into some finite combination of the above classes } // end namespace Geom -- cgit v1.2.3 From 8b4525894a9dddb99556fb17a698b8131641aad0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 25 Jul 2011 02:02:24 +0200 Subject: Revert workarounds from 10501 - no longer necessary (bzr r10503) --- src/display/sodipodi-ctrlrect.cpp | 139 ++++++++++++++++++++------------------ src/display/sodipodi-ctrlrect.h | 2 +- 2 files changed, 74 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index b696e5e6c..b4539841b 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -104,7 +104,7 @@ void CtrlRect::init() _dashed = false; _shadow = 0; - _area = Geom::IntRect(0,0,0,0); + _area = Geom::OptIntRect(); _rect = Geom::Rect(Geom::Point(0,0),Geom::Point(0,0)); @@ -123,18 +123,20 @@ void CtrlRect::render(SPCanvasBuf *buf) static double const dashes[2] = {4.0, 4.0}; - if ((_area[X].min() != 0 || _area[X].max() != 0 || _area[Y].min() != 0 || _area[Y].max() != 0) && - (_area[X].min() < buf->rect.x1) && - (_area[Y].min() < buf->rect.y1) && - ((_area[X].max() + _shadow_size) >= buf->rect.x0) && - ((_area[Y].max() + _shadow_size) >= buf->rect.y0) ) + if (!_area) { + return; + } + Geom::IntRect area = *_area; + Geom::IntRect area_w_shadow (area[X].min(), area[Y].min(), + area[X].max() + _shadow_size, area[Y].max() + _shadow_size); + if ( area_w_shadow.intersects(buf->rect) ) { cairo_save(buf->ct); cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); cairo_set_line_width(buf->ct, 1); if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0); - cairo_rectangle(buf->ct, 0.5 + _area[X].min(), 0.5 + _area[Y].min(), - _area[X].max() - _area[X].min(), _area[Y].max() - _area[Y].min()); + cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); if (_has_fill) { ink_cairo_set_source_rgba32(buf->ct, _fill_color); @@ -145,10 +147,10 @@ void CtrlRect::render(SPCanvasBuf *buf) if (_shadow_size > 0) { ink_cairo_set_source_rgba32(buf->ct, _shadow_color); - cairo_rectangle(buf->ct, 1 + _area[X].max(), _area[Y].min() + _shadow_size, - _shadow_size, _area[Y].max() - _area[Y].min() + 1); // right shadow - cairo_rectangle(buf->ct, _area[X].min() + _shadow_size, 1 + _area[Y].max(), - _area[X].max() - _area[X].min() - _shadow_size + 1, _shadow_size); + cairo_rectangle(buf->ct, 1 + area[X].max(), area[Y].min() + _shadow_size, + _shadow_size, area[Y].max() - area[Y].min() + 1); // right shadow + cairo_rectangle(buf->ct, area[X].min() + _shadow_size, 1 + area[Y].max(), + area[X].max() - area[X].min() - _shadow_size + 1, _shadow_size); cairo_fill(buf->ct); } cairo_restore(buf->ct); @@ -169,132 +171,137 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags) Geom::Rect bbox(_rect.min() * affine, _rect.max() * affine); - Geom::IntRect area_old = _area; - _area = Geom::IntRect( (int) floor(bbox.min()[Geom::X] + 0.5), - (int) floor(bbox.min()[Geom::Y] + 0.5), - (int) floor(bbox.max()[Geom::X] + 0.5), - (int) floor(bbox.max()[Geom::Y] + 0.5) ); + Geom::OptIntRect _area_old = _area; + Geom::IntRect area ( (int) floor(bbox.min()[Geom::X] + 0.5), + (int) floor(bbox.min()[Geom::Y] + 0.5), + (int) floor(bbox.max()[Geom::X] + 0.5), + (int) floor(bbox.max()[Geom::Y] + 0.5) ); + _area = area; + Geom::IntRect area_old(0,0,0,0); + if (_area_old) { // this weird construction is because the code below assumes _area_old to be 'valid' + area_old = *_area_old; + } gint _shadow_size_old = _shadow_size; _shadow_size = _shadow; // FIXME: we don't process a possible change in _has_fill if (_has_fill) { - if (area_old[X].min() != 0 || area_old[X].max() != 0 || area_old[Y].min() != 0 || area_old[Y].max() != 0) { + if (_area_old) { sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].min() - 1, area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); } - if (_area[X].min() != 0 || _area[X].max() != 0 || _area[Y].min() != 0 || _area[Y].max() != 0) { + if (_area) { sp_canvas_request_redraw(canvas, - _area[X].min() - 1, _area[Y].min() - 1, - _area[X].max() + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } } else { // clear box, be smart about what part of the frame to redraw /* Top */ - if (_area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new + if (area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].min() - 1, area_old[X].max() + 1, area_old[Y].min() + 1); - if (_area[X].min() != _area[X].max()) + if (area[X].min() != area[X].max()) sp_canvas_request_redraw(canvas, - _area[X].min() - 1, _area[Y].min() - 1, - _area[X].max() + 1, _area[Y].min() + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].max() + 1, area[Y].min() + 1); } else { // same level, redraw only the ends - if (_area[X].min() != area_old[X].min()) { + if (area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].min(),_area[X].min()) - 1, _area[Y].min() - 1, - MAX(area_old[X].min(),_area[X].min()) + 1, _area[Y].min() + 1); + MIN(area_old[X].min(),area[X].min()) - 1, area[Y].min() - 1, + MAX(area_old[X].min(),area[X].min()) + 1, area[Y].min() + 1); } - if (_area[X].max() != area_old[X].max()) { + if (area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].max(),_area[X].max()) - 1, _area[Y].min() - 1, - MAX(area_old[X].max(),_area[X].max()) + 1, _area[Y].min() + 1); + MIN(area_old[X].max(),area[X].max()) - 1, area[Y].min() - 1, + MAX(area_old[X].max(),area[X].max()) + 1, area[Y].min() + 1); } } /* Left */ - if (_area[X].min() != area_old[X].min()) { // different level, redraw fully old and new + if (area[X].min() != area_old[X].min()) { // different level, redraw fully old and new if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].min() - 1, area_old[X].min() + 1, area_old[Y].max() + 1); - if (_area[Y].min() != _area[Y].max()) + if (area[Y].min() != area[Y].max()) sp_canvas_request_redraw(canvas, - _area[X].min() - 1, _area[Y].min() - 1, - _area[X].min() + 1, _area[Y].max() + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].min() + 1, area[Y].max() + 1); } else { // same level, redraw only the ends - if (_area[Y].min() != area_old[Y].min()) { + if (area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - _area[X].min() - 1, MIN(area_old[Y].min(),_area[Y].min()) - 1, - _area[X].min() + 1, MAX(area_old[Y].min(),_area[Y].min()) + 1); + area[X].min() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, + area[X].min() + 1, MAX(area_old[Y].min(),area[Y].min()) + 1); } - if (_area[Y].max() != area_old[Y].max()) { + if (area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - _area[X].min() - 1, MIN(area_old[Y].max(),_area[Y].max()) - 1, - _area[X].min() + 1, MAX(area_old[Y].max(),_area[Y].max()) + 1); + area[X].min() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, + area[X].min() + 1, MAX(area_old[Y].max(),area[Y].max()) + 1); } } /* Right */ - if (_area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) { + if (area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) { if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, area_old[X].max() - 1, area_old[Y].min() - 1, area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (_area[Y].min() != _area[Y].max()) + if (area[Y].min() != area[Y].max()) sp_canvas_request_redraw(canvas, - _area[X].max() - 1, _area[Y].min() - 1, - _area[X].max() + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); + area[X].max() - 1, area[Y].min() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (_area[Y].min() != area_old[Y].min()) { + if (area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - _area[X].max() - 1, MIN(area_old[Y].min(),_area[Y].min()) - 1, - _area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),_area[Y].min()) + _shadow_size + 1); + area[X].max() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, + area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),area[Y].min()) + _shadow_size + 1); } - if (_area[Y].max() != area_old[Y].max()) { + if (area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - _area[X].max() - 1, MIN(area_old[Y].max(),_area[Y].max()) - 1, - _area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),_area[Y].max()) + _shadow_size + 1); + area[X].max() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, + area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),area[Y].max()) + _shadow_size + 1); } } /* Bottom */ - if (_area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) { + if (area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) { if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, area_old[X].min() - 1, area_old[Y].max() - 1, area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (_area[X].min() != _area[X].max()) + if (area[X].min() != area[X].max()) sp_canvas_request_redraw(canvas, - _area[X].min() - 1, _area[Y].max() - 1, - _area[X].max() + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); + area[X].min() - 1, area[Y].max() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (_area[X].min() != area_old[X].min()) { + if (area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].min(),_area[X].min()) - 1, _area[Y].max() - 1, - MAX(area_old[X].min(),_area[X].min()) + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); + MIN(area_old[X].min(),area[X].min()) - 1, area[Y].max() - 1, + MAX(area_old[X].min(),area[X].min()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } - if (_area[X].max() != area_old[X].max()) { + if (area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(area_old[X].max(),_area[X].max()) - 1, _area[Y].max() - 1, - MAX(area_old[X].max(),_area[X].max()) + _shadow_size + 1, _area[Y].max() + _shadow_size + 1); + MIN(area_old[X].max(),area[X].max()) - 1, area[Y].max() - 1, + MAX(area_old[X].max(),area[X].max()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } } } // update SPCanvasItem box - if (_area[X].min() != 0 || _area[X].max() != 0 || _area[Y].min() != 0 || _area[Y].max() != 0) { - x1 = _area[X].min() - 1; - y1 = _area[Y].min() - 1; - x2 = _area[X].max() + _shadow_size + 1; - y2 = _area[Y].max() + _shadow_size + 1; + if (_area) { + x1 = area[X].min() - 1; + y1 = area[Y].min() - 1; + x2 = area[X].max() + _shadow_size + 1; + y2 = area[Y].max() + _shadow_size + 1; } } diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 4093fafd6..45f8523ed 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -48,7 +48,7 @@ private: Geom::Rect _rect; bool _has_fill; bool _dashed; - Geom::IntRect _area; + Geom::OptIntRect _area; gint _shadow_size; guint32 _border_color; guint32 _fill_color; -- cgit v1.2.3 From ce9e05100362f2748202b0a7160fb8ff4be8927e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 25 Jul 2011 21:29:40 +0200 Subject: Filters. New Channel painting custom predefined filter. Documentation. New Greek translation of the keys reference by Dimitris Spingos. Documentation. Adding forgotten CSS file for the keys reference. (bzr r10504) --- src/extension/internal/filter/color.h | 117 ++++++++++++++++++++++++++- src/extension/internal/filter/filter-all.cpp | 1 + 2 files changed, 116 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 53734bee5..4f9954b2c 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -9,6 +9,7 @@ * * Color filters * Brightness + * Channel painting * Colorize * Duochrome * Electrize @@ -98,8 +99,6 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) sat << -ext->get_param_float("sat"); lightness << ext->get_param_float("lightness"); } - - _filter = g_strdup_printf( "\n" @@ -112,6 +111,120 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Brightness filter */ + +/** + \brief Custom predefined Channel Painting filter. + + Channel Painting filter. + + Filter's parameters: + * Saturation (0.->1., default 1.) -> colormatrix1 (values) + * Red (-10.->10., default -1.) -> colormatrix2 (values) + * Green (-10.->10., default 0.5) -> colormatrix2 (values) + * Blue (-10.->10., default 0.5) -> colormatrix2 (values) + * Alpha (-10.->10., default 1.) -> colormatrix2 (values) + * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) + * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') + + Matrix: + 1 0 0 0 0 + 0 1 0 0 0 + 0 0 1 0 0 + R G B A 0 +*/ +class ChannelPaint : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ChannelPaint ( ) : Filter() { }; + virtual ~ChannelPaint ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Channel painting, custom (Color)") "\n" + "org.inkscape.effect.filter.ChannelPaint\n" + "\n" + "\n" + "1\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" + "false\n" + "\n" + "\n" + "16777215\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Replace RGB by any color") "\n" + "\n" + "\n", new ChannelPaint()); + }; +}; + +gchar const * +ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream saturation; + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream alpha; + std::ostringstream invert; + std::ostringstream floodRed; + std::ostringstream floodGreen; + std::ostringstream floodBlue; + std::ostringstream floodAlpha; + + saturation << ext->get_param_float("saturation"); + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + alpha << ext->get_param_float("alpha"); + + guint32 color = ext->get_param_color("color"); + floodRed << ((color >> 24) & 0xff); + floodGreen << ((color >> 16) & 0xff); + floodBlue << ((color >> 8) & 0xff); + floodAlpha << (color & 0xff) / 255.0F; + + if (ext->get_param_bool("invert")) { + invert << "in"; + } else { + invert << "out"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", saturation.str().c_str(), red.str().c_str(), green.str().c_str(), + blue.str().c_str(), alpha.str().c_str(), floodRed.str().c_str(), + floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(), + invert.str().c_str()); + + return _filter; +}; /* Channel Painting filter */ + + /** \brief Custom predefined Colorize filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 6ee849925..8a8dd57a6 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -49,6 +49,7 @@ Filter::filters_all (void ) // Color Brightness::init(); + ChannelPaint::init(); Colorize::init(); Duochrome::init(); Electrize::init(); -- cgit v1.2.3 From c38ea35d79b2990cfb8f56c029962a0f4e952547 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 25 Jul 2011 12:33:56 -0700 Subject: Temporary fix for crash when launching via command-line. (bzr r10505) --- src/sp-item.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 946c94353..9e3bc02ae 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1467,11 +1467,18 @@ Geom::Affine SPItem::i2doc_affine() const */ Geom::Affine SPItem::i2dt_affine() const { -// Geom::Affine const ret( i2doc_affine() -// * Geom::Scale(1, -1) -// * Geom::Translate(0, document->getHeight()) ); + Geom::Affine ret; SPDesktop const *desktop = inkscape_active_desktop(); - Geom::Affine const ret( i2doc_affine() * desktop->doc2dt() ); + if ( desktop ) { + ret = i2doc_affine() * desktop->doc2dt(); + } else { + // TODO temp code to prevent crashing on command-line launch: + ret = i2doc_affine() + * Geom::Scale(1, -1) + * Geom::Translate(0, document->getHeight()); + + g_return_val_if_fail(desktop != NULL, ret); + } return ret; } -- cgit v1.2.3 From c1ad04d91b5cac237f184c3c6943ab520dd21cf7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 26 Jul 2011 00:03:48 +0200 Subject: Add deferred allocation functionality to DrawingSurface (bzr r10347.1.19) --- src/display/drawing-surface.cpp | 45 +++++++++++++++++++++++++++++++++-------- src/display/drawing-surface.h | 3 +++ 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index e50a732c6..41ff14167 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -25,17 +25,22 @@ using Geom::Y; * extra functionality provided by this class is that it automates * the mapping from "logical space" (coordinates in the rendering) * and the "physical space" (surface pixels). For example, patterns - * have to be rendered on surfaces which have possibly non-integer + * have to be rendered on tiles which have possibly non-integer * widths and heights. + * + * This class has delayed allocation functionality - it creates + * the Cairo surface it wraps on the first call to createRawContext() + * of when a DrawingContext is constructed. */ /** @brief Creates a surface with the given physical extents. * When a drawing context is created for this surface, its pixels * will cover the area under the given rectangle. */ DrawingSurface::DrawingSurface(Geom::IntRect const &area) - : _surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height())) + : _surface(NULL) , _origin(area.min()) , _scale(1, 1) + , _pixels(area.dimensions()) {} /** @brief Creates a surface with the given logical extents. @@ -44,9 +49,10 @@ DrawingSurface::DrawingSurface(Geom::IntRect const &area) * has non-integer width, there will be slightly more than 1 pixel * per logical unit. */ DrawingSurface::DrawingSurface(Geom::Rect const &area) - : _surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ceil(area.width()), ceil(area.height()))) + : _surface(NULL) , _origin(area.min()) , _scale(ceil(area.width()) / area.width(), ceil(area.height()) / area.height()) + , _pixels(area.dimensions().ceil()) {} /** @brief Creates a surface with the given logical and physical extents. @@ -56,9 +62,10 @@ DrawingSurface::DrawingSurface(Geom::Rect const &area) * @param logbox Logical extents of the surface * @param pixdims Pixel dimensions of the surface. */ DrawingSurface::DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims) - : _surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pixdims[X], pixdims[Y])) + : _surface(NULL) , _origin(logbox.min()) , _scale(pixdims[X] / logbox.width(), pixdims[Y] / logbox.height()) + , _pixels(pixdims) {} /** @brief Wrap a cairo_surface_t. @@ -70,11 +77,14 @@ DrawingSurface::DrawingSurface(cairo_surface_t *surface, Geom::Point const &orig , _scale(1, 1) { cairo_surface_reference(surface); + _pixels[X] = cairo_image_surface_get_width(surface); + _pixels[Y] = cairo_image_surface_get_height(surface); } DrawingSurface::~DrawingSurface() { - cairo_surface_destroy(_surface); + if (_surface) + cairo_surface_destroy(_surface); } /// Get the logical extents of the surface. @@ -85,13 +95,18 @@ DrawingSurface::area() const return r; } +/// Get the pixel dimensions of the surface +Geom::IntPoint +DrawingSurface::pixels() const +{ + return _pixels; +} + /// Get the logical width and weight of the surface as a point. Geom::Point DrawingSurface::dimensions() const { - double w = cairo_image_surface_get_width(_surface); - double h = cairo_image_surface_get_height(_surface); - Geom::Point logical_dims(w / _scale[X], h / _scale[Y]); + Geom::Point logical_dims(_pixels[X] / _scale[X], _pixels[Y] / _scale[Y]); return logical_dims; } @@ -122,11 +137,25 @@ DrawingSurface::type() const return CAIRO_SURFACE_TYPE_IMAGE; } +/// Drop contents of the surface and release the underlying Cairo object. +void +DrawingSurface::dropContents() +{ + if (_surface) { + cairo_surface_destroy(_surface); + _surface = NULL; + } +} + /** @brief Create a drawing context for this surface. * It's better to use the surface constructor of DrawingContext. */ cairo_t * DrawingSurface::createRawContext() { + // deferred allocation + if (!_surface) { + _surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, _pixels[X], _pixels[Y]); + } cairo_t *ct = cairo_create(_surface); if (_scale != Geom::Scale::identity()) { cairo_scale(ct, _scale[X], _scale[Y]); diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index 2d0e147e2..e26bc28fa 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -32,11 +32,13 @@ public: virtual ~DrawingSurface(); Geom::Rect area() const; + Geom::IntPoint pixels() const; Geom::Point dimensions() const; Geom::Point origin() const; Geom::Scale scale() const; Geom::Affine drawingTransform() const; cairo_surface_type_t type() const; + void dropContents(); cairo_surface_t *raw() { return _surface; } cairo_t *createRawContext(); @@ -45,6 +47,7 @@ protected: cairo_surface_t *_surface; Geom::Point _origin; Geom::Scale _scale; + Geom::IntPoint _pixels; bool _has_context; friend class DrawingContext; -- cgit v1.2.3 From 0cc08b5e0fc4cdb7023831523e1221a5fdb88685 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 27 Jul 2011 01:52:15 +1000 Subject: update to cmake checker and add missing header. (bzr r10506) --- src/2geom/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index dc261b5bd..4aeb7ffac 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -50,6 +50,7 @@ set(2geom_SRC # ------- + 2geom.h # Headers affine.h angle.h -- cgit v1.2.3 From adbc8efa025ad921775e3c171c3ce3bd7763d1ca Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 26 Jul 2011 21:55:07 -0700 Subject: Cleaning up trace methods to aid fixing color inversion. (bzr r10507) --- src/message-stack.cpp | 6 + src/message-stack.h | 29 +++-- src/trace/potrace/inkscape-potrace.cpp | 203 ++++++++++++++++----------------- src/trace/potrace/inkscape-potrace.h | 10 ++ 4 files changed, 136 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/src/message-stack.cpp b/src/message-stack.cpp index d2101009e..c1669e3db 100644 --- a/src/message-stack.cpp +++ b/src/message-stack.cpp @@ -62,6 +62,12 @@ void MessageStack::cancel(MessageId id) { } } +MessageId MessageStack::flash(MessageType type, Glib::ustring const &message) +{ + MessageId id = flash( type, message.c_str() ); + return id; +} + MessageId MessageStack::flash(MessageType type, gchar const *message) { switch (type) { case INFORMATION_MESSAGE: // stay rather long so as to seem permanent, but eventually disappear diff --git a/src/message-stack.h b/src/message-stack.h index ae8860965..3b8307761 100644 --- a/src/message-stack.h +++ b/src/message-stack.h @@ -5,8 +5,10 @@ /* * Authors: * MenTaLguY + * Jon A. Cruz * * Copyright (C) 2004 MenTaLguY + * Copyright (C) 2011 Jon A. Cruz * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,6 +20,7 @@ #include #include #include +#include #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" @@ -108,15 +111,27 @@ public: */ void cancel(MessageId id); - /** @brief temporarily pushes a message onto the stack - * - * @param type the message type - * @param message the message text - * - * @return the id of the pushed message - */ + /** + * Temporarily pushes a message onto the stack. + * + * @param type the message type + * @param message the message text + * + * @return the id of the pushed message + */ MessageId flash(MessageType type, gchar const *message); + /** + * Temporarily pushes a message onto the stack. + * + * @param type the message type + * @param message the message text + * + * @return the id of the pushed message + */ + MessageId flash(MessageType type, Glib::ustring const &message); + + /** @brief temporarily pushes a message onto the stack using * printf-like formatting * diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp index 2f4dc7a6f..6583fb735 100644 --- a/src/trace/potrace/inkscape-potrace.cpp +++ b/src/trace/potrace/inkscape-potrace.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "trace/filterset.h" #include "trace/quantize.h" @@ -31,7 +32,7 @@ #include "curve.h" #include "bitmap.h" - +using Glib::ustring; static void updateGui() { @@ -57,6 +58,12 @@ static void potraceStatusCallback(double /*progress*/, void *userData) /* callba } +namespace { +ustring twohex( int value ) +{ + return ustring::format(std::hex, std::setfill(L'0'), std::setw(2), value); +} +} // namespace //required by potrace @@ -471,67 +478,56 @@ PotraceTracingEngine::traceGrayMap(GrayMap *grayMap) /** * Called for multiple-scanning algorithms */ -std::vector -PotraceTracingEngine::traceBrightnessMulti(GdkPixbuf * thePixbuf) +std::vector PotraceTracingEngine::traceBrightnessMulti(GdkPixbuf * thePixbuf) { - std::vector results; - if (!thePixbuf) - return results; - - double low = 0.2; //bottom of range - double high = 0.9; //top of range - double delta = (high - low ) / ((double)multiScanNrColors); - - brightnessFloor = 0.0; //Set bottom to black - - int traceCount = 0; + if ( thePixbuf ) { + double low = 0.2; //bottom of range + double high = 0.9; //top of range + double delta = (high - low ) / ((double)multiScanNrColors); - for ( brightnessThreshold = low ; - brightnessThreshold <= high ; - brightnessThreshold += delta) + brightnessFloor = 0.0; //Set bottom to black - { - - GrayMap *grayMap = filter(*this, thePixbuf); - if (!grayMap) - return results; - - long nodeCount; - std::string d = grayMapToPath(grayMap, &nodeCount); + int traceCount = 0; - grayMap->destroy(grayMap); + for ( brightnessThreshold = low ; + brightnessThreshold <= high ; + brightnessThreshold += delta) { + GrayMap *grayMap = filter(*this, thePixbuf); + if ( grayMap ) { + long nodeCount; + std::string d = grayMapToPath(grayMap, &nodeCount); - if (d.size() == 0) - return results; + grayMap->destroy(grayMap); - int grayVal = (int)(256.0 * brightnessThreshold); - char style[31]; - sprintf(style, "fill-opacity:1.0;fill:#%02x%02x%02x", - grayVal, grayVal, grayVal); + if ( !d.empty() ) { + //### get style info + int grayVal = (int)(256.0 * brightnessThreshold); + ustring style = ustring::compose("fill-opacity:1.0;fill:%1%2%3", twohex(grayVal), twohex(grayVal), twohex(grayVal) ); - //g_message("### GOT '%s' \n", d); - TracingEngineResult result(style, d, nodeCount); - results.push_back(result); + //g_message("### GOT '%s' \n", style.c_str()); + TracingEngineResult result(style, d, nodeCount); + results.push_back(result); - if (!multiScanStack) - brightnessFloor = brightnessThreshold; + if (!multiScanStack) { + brightnessFloor = brightnessThreshold; + } - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) - { - gchar *msg = g_strdup_printf(_("Trace: %d. %ld nodes"), traceCount++, nodeCount); - sp_desktop_message_stack(desktop)->flash(Inkscape::NORMAL_MESSAGE, msg); - g_free(msg); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + ustring msg = ustring::compose(_("Trace: %1. %2 nodes"), traceCount++, nodeCount); + sp_desktop_message_stack(desktop)->flash(Inkscape::NORMAL_MESSAGE, msg); + } + } } } - //# Remove the bottom-most scan, if requested - if (results.size() > 1 && multiScanRemoveBackground) - { - results.erase(results.end() - 1); + //# Remove the bottom-most scan, if requested + if (results.size() > 1 && multiScanRemoveBackground) { + results.erase(results.end() - 1); } + } return results; } @@ -540,77 +536,64 @@ PotraceTracingEngine::traceBrightnessMulti(GdkPixbuf * thePixbuf) /** * Quantization */ -std::vector -PotraceTracingEngine::traceQuant(GdkPixbuf * thePixbuf) +std::vector PotraceTracingEngine::traceQuant(GdkPixbuf * thePixbuf) { - std::vector results; - if (!thePixbuf) - return results; - - IndexedMap *iMap = filterIndexed(*this, thePixbuf); - if (!iMap) - return results; - - //Create and clear a gray map - GrayMap *gm = GrayMapCreate(iMap->width, iMap->height); - for (int row=0 ; rowheight ; row++) - for (int col=0 ; colwidth ; col++) - gm->setPixel(gm, col, row, GRAYMAP_WHITE); - - - for (int colorIndex=0 ; colorIndexnrColors ; colorIndex++) - { - - /*Make a gray map for each color index */ - for (int row=0 ; rowheight ; row++) - { - for (int col=0 ; colwidth ; col++) - { - int indx = (int) iMap->getPixel(iMap, col, row); - if (indx == colorIndex) - gm->setPixel(gm, col, row, GRAYMAP_BLACK); //black - else if (!multiScanStack) - gm->setPixel(gm, col, row, GRAYMAP_WHITE); //white + if (thePixbuf) { + IndexedMap *iMap = filterIndexed(*this, thePixbuf); + if ( iMap ) { + //Create and clear a gray map + GrayMap *gm = GrayMapCreate(iMap->width, iMap->height); + for (int row=0 ; rowheight ; row++) { + for (int col=0 ; colwidth ; col++) { + gm->setPixel(gm, col, row, GRAYMAP_WHITE); } } - //## Now we have a traceable graymap - long nodeCount; - std::string d = grayMapToPath(gm, &nodeCount); - - if (d.size() == 0) - return results; + for (int colorIndex=0 ; colorIndexnrColors ; colorIndex++) { + // Make a gray map for each color index + for (int row=0 ; rowheight ; row++) { + for (int col=0 ; colwidth ; col++) { + int indx = (int) iMap->getPixel(iMap, col, row); + if (indx == colorIndex) { + gm->setPixel(gm, col, row, GRAYMAP_BLACK); //black + } else if (!multiScanStack) { + gm->setPixel(gm, col, row, GRAYMAP_WHITE); //white + } + } + } - //### get style info - char style[13]; - RGB rgb = iMap->clut[colorIndex]; - sprintf(style, "fill:#%02x%02x%02x", rgb.r, rgb.g, rgb.b); + //## Now we have a traceable graymap + long nodeCount; + std::string d = grayMapToPath(gm, &nodeCount); - //g_message("### GOT '%s' \n", d); - TracingEngineResult result(style, d, nodeCount); - results.push_back(result); + if ( !d.empty() ) { + //### get style info + RGB rgb = iMap->clut[colorIndex]; + ustring style = ustring::compose("fill:#%1%2%3", twohex(rgb.r), twohex(rgb.g), twohex(rgb.b) ); - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) - { - gchar *msg = g_strdup_printf(_("Trace: %d. %ld nodes"), colorIndex, nodeCount); - sp_desktop_message_stack(desktop)->flash(Inkscape::NORMAL_MESSAGE, msg); - g_free(msg); - } + //g_message("### GOT '%s' \n", style.c_str()); + TracingEngineResult result(style, d, nodeCount); + results.push_back(result); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + ustring msg = ustring::compose(_("Trace: %1. %2 nodes"), colorIndex, nodeCount); + sp_desktop_message_stack(desktop)->flash(Inkscape::NORMAL_MESSAGE, msg); + } + } + }// for colorIndex - }// for colorIndex - - gm->destroy(gm); - iMap->destroy(iMap); + gm->destroy(gm); + iMap->destroy(iMap); + } - //# Remove the bottom-most scan, if requested - if (results.size() > 1 && multiScanRemoveBackground) - { - results.erase(results.end() - 1); + //# Remove the bottom-most scan, if requested + if (results.size() > 1 && multiScanRemoveBackground) { + results.erase(results.end() - 1); } + } return results; } @@ -667,3 +650,13 @@ PotraceTracingEngine::abort() } // namespace Trace } // namespace Inkscape +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/trace/potrace/inkscape-potrace.h b/src/trace/potrace/inkscape-potrace.h index b32ab6461..5ed0c0e5a 100644 --- a/src/trace/potrace/inkscape-potrace.h +++ b/src/trace/potrace/inkscape-potrace.h @@ -286,3 +286,13 @@ class PotraceTracingEngine : public TracingEngine #endif //__INKSCAPE_POTRACE_H__ +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 3b780cbf81e0dd6f27f58888a518e33d39265a6b Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 26 Jul 2011 22:54:50 -0700 Subject: Reverse color order in tracing support function to match reversal of colors in GdkPixmaps used. Fixes bug #815596. Fixed bugs: - https://launchpad.net/bugs/815596 (bzr r10508) --- src/trace/imagemap-gdk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/trace/imagemap-gdk.cpp b/src/trace/imagemap-gdk.cpp index e217dd619..e5ff23ad0 100644 --- a/src/trace/imagemap-gdk.cpp +++ b/src/trace/imagemap-gdk.cpp @@ -190,9 +190,9 @@ RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf) { int alpha = (int)p[3]; int white = 255 - alpha; - int r = (int)p[0]; r = r * alpha / 256 + white; + int r = (int)p[2]; r = r * alpha / 256 + white; int g = (int)p[1]; g = g * alpha / 256 + white; - int b = (int)p[2]; b = b * alpha / 256 + white; + int b = (int)p[0]; b = b * alpha / 256 + white; rgbMap->setPixel(rgbMap, x, y, r, g, b); p += n_channels; -- cgit v1.2.3 From 3d4c30d84221a63cde583267004f79ff74430f4c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 27 Jul 2011 20:52:17 +0200 Subject: Filters. New Channel transparency and Cross blur custom predefined filters. Extensions. Barcode extensions reorganization. Translations. inkscape.pot and French translation update. (bzr r10509) --- src/extension/internal/filter/blurs.h | 114 +++++++++++++++++++++++++++ src/extension/internal/filter/color.h | 85 ++++++++++++++++++++ src/extension/internal/filter/filter-all.cpp | 9 +++ 3 files changed, 208 insertions(+) create mode 100644 src/extension/internal/filter/blurs.h (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h new file mode 100644 index 000000000..957484cbb --- /dev/null +++ b/src/extension/internal/filter/blurs.h @@ -0,0 +1,114 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ +/* Change the 'BLURS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Blur filters + * Cross blur + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Cross blur filter. + + Combine vertical and horizontal blur + + Filter's parameters: + * Brighness (0.->10., default 0) -> composite (k3) + * Fading (0.->1., default 0) -> composite (k4) + * Horizontal blur (0.01->20., default 5) -> blur (stdDeviation) + * Vertical blur (0.01->20., default 5) -> blur (stdDeviation) + * Blend mode (enum, default Darken) -> blend (mode) +*/ + +class CrossBlur : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CrossBlur ( ) : Filter() { }; + virtual ~CrossBlur ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Cross blur, custom (Blurs)") "\n" + "org.inkscape.effect.filter.CrossBlur\n" + "0\n" + "0\n" + "5\n" + "5\n" + "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Combine vertical and horizontal blur") "\n" + "\n" + "\n", new CrossBlur()); + }; + +}; + +gchar const * +CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream bright; + std::ostringstream fade; + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream blend; + + bright << ext->get_param_float("bright"); + fade << ext->get_param_float("fade"); + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + blend << ext->get_param_enum("blend"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", bright.str().c_str(), fade.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), blend.str().c_str()); + + return _filter; +}; /* Cross blur filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'BLURS' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 4f9954b2c..2df92df29 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -10,6 +10,7 @@ * Color filters * Brightness * Channel painting + * Channel transparency * Colorize * Duochrome * Electrize @@ -225,6 +226,90 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Channel Painting filter */ +/** + \brief Custom predefined Channel transparency filter. + + Channel transparency filter. + + Filter's parameters: + * Saturation (0.->1., default 1.) -> colormatrix1 (values) + * Red (-10.->10., default -1.) -> colormatrix2 (values) + * Green (-10.->10., default 0.5) -> colormatrix2 (values) + * Blue (-10.->10., default 0.5) -> colormatrix2 (values) + * Alpha (-10.->10., default 1.) -> colormatrix2 (values) + * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) + * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') + + Matrix: + 1 0 0 0 0 + 0 1 0 0 0 + 0 0 1 0 0 + R G B A 0 +*/ +class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ChannelTransparency ( ) : Filter() { }; + virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Channel transparency, custom (Color)") "\n" + "org.inkscape.effect.filter.ChannelTransparency\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Replace RGB by transparency") "\n" + "\n" + "\n", new ChannelTransparency()); + }; +}; + +gchar const * +ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream alpha; + std::ostringstream invert; + + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + alpha << ext->get_param_float("alpha"); + + if (!ext->get_param_bool("invert")) { + invert << "in"; + } else { + invert << "xor"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), + invert.str().c_str()); + + return _filter; +}; /* Channel Transparency filter */ + + /** \brief Custom predefined Colorize filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 8a8dd57a6..ed8b4e180 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -9,6 +9,8 @@ /* Put your filter here */ #include "abc.h" +#include "blurs.h" +//#include "bumps.h" #include "color.h" #include "drop-shadow.h" #include "image.h" @@ -47,9 +49,16 @@ Filter::filters_all (void ) Silhouette::init(); SpecularLight::init(); + // Blurs + CrossBlur::init(); + + // Bumps +// SpecularBump::init(); + // Color Brightness::init(); ChannelPaint::init(); + ChannelTransparency::init(); Colorize::init(); Duochrome::init(); Electrize::init(); -- cgit v1.2.3 From 905b8a96963f78358abfd109c0c49758c6fe4e9d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 28 Jul 2011 07:04:08 +0200 Subject: Per-item render cache. Cache some offscreen data to facilitate smoother navigation. (bzr r10347.1.20) --- src/display/canvas-arena.cpp | 125 +++--------------------------------- src/display/canvas-arena.h | 4 -- src/display/drawing-context.cpp | 17 +++++ src/display/drawing-context.h | 2 + src/display/drawing-surface.cpp | 137 ++++++++++++++++++++++++++++++++++++---- src/display/drawing-surface.h | 22 +++++-- src/display/nr-arena-item.cpp | 121 +++++++++++++++++++++++++++++------ src/display/nr-arena-item.h | 24 ++++--- src/display/nr-arena.cpp | 11 ++++ src/display/nr-arena.h | 4 ++ src/display/sp-canvas-item.h | 2 +- src/display/sp-canvas.cpp | 27 +++++--- 12 files changed, 320 insertions(+), 176 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 1d5cfe826..0f653a258 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -33,10 +33,8 @@ static void sp_canvas_arena_destroy(GtkObject *object); static void sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf); -static void sp_canvas_arena_render_cache (SPCanvasItem *item, Geom::IntRect const &area); -static void sp_canvas_arena_dirty_cache (SPCanvasArena *arena, NRRectL *area); static double sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); -static void sp_canvas_arena_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); +static void sp_canvas_arena_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area); static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event); static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event); @@ -98,7 +96,7 @@ sp_canvas_arena_class_init (SPCanvasArenaClass *klass) item_class->render = sp_canvas_arena_render; item_class->point = sp_canvas_arena_point; item_class->event = sp_canvas_arena_event; - item_class->visible_area_changed = sp_canvas_arena_visible_area_changed; + item_class->viewbox_changed = sp_canvas_arena_viewbox_changed; } static void @@ -110,11 +108,9 @@ sp_canvas_arena_init (SPCanvasArena *arena) arena->arena->canvasarena = arena; arena->root = NRArenaGroup::create(arena->arena); nr_arena_group_set_transparent (NR_ARENA_GROUP (arena->root), TRUE); + nr_arena_item_set_cache(arena->root, true); arena->active = NULL; - arena->cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); - arena->cache_area = Geom::IntRect::from_xywh(0,0,1,1); - arena->dirty = cairo_region_create(); nr_active_object_add_listener ((NRActiveObject *) arena->arena, (NRObjectEventVector *) &carenaev, sizeof (carenaev), arena); } @@ -140,11 +136,6 @@ sp_canvas_arena_destroy (GtkObject *object) nr_object_unref ((NRObject *) arena->arena); arena->arena = NULL; } - if (arena->cache) { - cairo_surface_destroy(arena->cache); - arena->cache = NULL; - } - cairo_region_destroy(arena->dirty); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -209,42 +200,8 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) Geom::OptIntRect r = buf->rect; if (!r || r->hasZeroArea()) return; - - cairo_rectangle_int_t crect; - crect.x = r->left(); - crect.y = r->top(); - crect.width = r->width(); - crect.height = r->height(); - if (cairo_region_contains_rectangle(arena->dirty, &crect) != CAIRO_REGION_OVERLAP_OUT) { - sp_canvas_arena_render_cache(item, *r); - cairo_region_subtract_rectangle(arena->dirty, &crect); - } - - cairo_save(buf->ct); - cairo_translate(buf->ct, -r->left(), -r->top()); - cairo_set_source_surface(buf->ct, arena->cache, arena->cache_area.left(), arena->cache_area.top()); - cairo_paint(buf->ct); - cairo_restore(buf->ct); -} - -static void sp_canvas_arena_render_cache (SPCanvasItem *item, Geom::IntRect const &area) -{ - SPCanvasArena *arena = SP_CANVAS_ARENA (item); - - Geom::OptIntRect r = Geom::intersect(arena->cache_area, area); - if (!r || r->hasZeroArea()) return; // nothing to do - - Inkscape::DrawingSurface cache(arena->cache, arena->cache_area.min()); - Inkscape::DrawingContext ct(cache); - ct.rectangle(area); - ct.clip(); - - { Inkscape::DrawingContext::Save save(ct); - ct.setSource(0,0,0,0); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); - } + Inkscape::DrawingContext ct(buf->ct, r->min()); nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, @@ -252,17 +209,6 @@ static void sp_canvas_arena_render_cache (SPCanvasItem *item, Geom::IntRect cons nr_arena_item_invoke_render (ct, arena->root, *r, 0); } -static void -sp_canvas_arena_dirty_cache (SPCanvasArena *arena, NRRectL *area) -{ - cairo_rectangle_int_t rect; - rect.x = area->x0; - rect.y = area->y0; - rect.width = area->x1 - area->x0; - rect.height = area->y1 - area->y0; - cairo_region_union_rectangle(arena->dirty, &rect); -} - static double sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) { @@ -285,64 +231,14 @@ sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ } static void -sp_canvas_arena_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area) +sp_canvas_arena_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area) { SPCanvasArena *arena = SP_CANVAS_ARENA(item); - - cairo_surface_t *new_cache = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - new_area.width(), new_area.height()); - cairo_t *ct = cairo_create(new_cache); - cairo_set_source_surface(ct, arena->cache, old_area.left() - new_area.left(), old_area.top() - new_area.top()); - cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(ct); - cairo_destroy(ct); - cairo_surface_destroy(arena->cache); - arena->cache = new_cache; - arena->cache_area = new_area; - - cairo_rectangle_int_t crect; - crect.x = new_area.left(); - crect.y = new_area.top(); - crect.width = new_area.width(); - crect.height = new_area.height(); - cairo_region_intersect_rectangle(arena->dirty, &crect); - - // invalidate newly exposed areas - /* - * +----------------------+ - * | top strip | - * +-------+------+-------+ - * | | | | - * | left | old | right | - * | strip | area | strip | - * | | | | - * +-------+------+-------+ - * | bottom strip | - * +----------------------+ - */ - - // top strip - if (new_area.top() < old_area.top()) { - NRRectL top_strip(new_area.left(), new_area.top(), new_area.right(), old_area.top()); - sp_canvas_arena_dirty_cache(arena, &top_strip); - } - // left strip - if (new_area.left() < old_area.left()) { - NRRectL left_strip(new_area.left(), std::max(new_area.top(), old_area.top()), - old_area.left(), std::min(new_area.bottom(), old_area.bottom())); - sp_canvas_arena_dirty_cache(arena, &left_strip); - } - // right strip - if (new_area.right() > old_area.right()) { - NRRectL right_strip(old_area.right(), std::max(new_area.top(), old_area.top()), - new_area.right(), std::min(new_area.bottom(), old_area.bottom())); - sp_canvas_arena_dirty_cache(arena, &right_strip); - } - // bottom strip - if (new_area.bottom() > old_area.bottom()) { - NRRectL bottom_strip(new_area.left(), old_area.bottom(), new_area.right(), new_area.bottom()); - sp_canvas_arena_dirty_cache(arena, &bottom_strip); - } + // make the cache limit larger than screen to facilitate smooth scrolling + Geom::IntRect expanded = new_area; + Geom::IntPoint expansion(new_area.width()/2, new_area.height()/2); + expanded.expandBy(expansion); + nr_arena_set_cache_limit(arena->arena, expanded); } static gint @@ -445,7 +341,6 @@ static void sp_canvas_arena_request_render (NRArena */*arena*/, NRRectL *area, void *data) { if (!area) return; - sp_canvas_arena_dirty_cache (SP_CANVAS_ARENA(data), area); sp_canvas_request_redraw (SP_CANVAS_ITEM (data)->canvas, area->x0, area->y0, area->x1, area->y1); } diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 220976da0..4cfeccb5a 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -45,10 +45,6 @@ struct _SPCanvasArena { /* fixme: */ NRArenaItem *picked; gdouble delta; - - Geom::IntRect cache_area; - cairo_surface_t *cache; - cairo_region_t *dirty; }; struct _SPCanvasArenaClass { diff --git a/src/display/drawing-context.cpp b/src/display/drawing-context.cpp index 8f37bb693..3c0c2163b 100644 --- a/src/display/drawing-context.cpp +++ b/src/display/drawing-context.cpp @@ -55,10 +55,23 @@ void DrawingContext::Save::save(DrawingContext &ct) * for drawing entire SPObjects when exporting. */ +DrawingContext::DrawingContext(cairo_t *ct, Geom::Point const &origin) + : _ct(ct) + , _surface(new DrawingSurface(cairo_get_group_target(ct), origin)) + , _delete_surface(true) + , _restore_context(true) +{ + _surface->_has_context = true; + cairo_reference(_ct); + cairo_save(_ct); + cairo_translate(_ct, -origin[Geom::X], -origin[Geom::Y]); +} + DrawingContext::DrawingContext(cairo_surface_t *surface, Geom::Point const &origin) : _ct(NULL) , _surface(new DrawingSurface(surface, origin)) , _delete_surface(true) + , _restore_context(false) { _surface->_has_context = true; _ct = _surface->createRawContext(); @@ -68,10 +81,14 @@ DrawingContext::DrawingContext(DrawingSurface &s) : _ct(s.createRawContext()) , _surface(&s) , _delete_surface(false) + , _restore_context(false) {} DrawingContext::~DrawingContext() { + if (_restore_context) { + cairo_restore(_ct); + } cairo_destroy(_ct); _surface->_has_context = false; if (_delete_surface) { diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index c0ea81874..8d2e7d68a 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -38,6 +38,7 @@ public: DrawingContext *_ct; }; + DrawingContext(cairo_t *ct, Geom::Point const &origin); DrawingContext(cairo_surface_t *surface, Geom::Point const &origin); DrawingContext(DrawingSurface &s); ~DrawingContext(); @@ -103,6 +104,7 @@ private: cairo_t *_ct; DrawingSurface *_surface; bool _delete_surface; + bool _restore_context; friend class DrawingSurface; }; diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 41ff14167..28bdc1f3c 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -10,6 +10,7 @@ */ #include "display/drawing-surface.h" +#include "display/drawing-context.h" #include "display/cairo-utils.h" namespace Inkscape { @@ -43,18 +44,6 @@ DrawingSurface::DrawingSurface(Geom::IntRect const &area) , _pixels(area.dimensions()) {} -/** @brief Creates a surface with the given logical extents. - * When a drawing context is created for this surface, its pixels - * will cover the area under the given rectangle. If the rectangle - * has non-integer width, there will be slightly more than 1 pixel - * per logical unit. */ -DrawingSurface::DrawingSurface(Geom::Rect const &area) - : _surface(NULL) - , _origin(area.min()) - , _scale(ceil(area.width()) / area.width(), ceil(area.height()) / area.height()) - , _pixels(area.dimensions().ceil()) -{} - /** @brief Creates a surface with the given logical and physical extents. * When a drawing context is created for this surface, its pixels * will cover the area under the given rectangle. IT will contain @@ -164,6 +153,130 @@ DrawingSurface::createRawContext() return ct; } +Geom::IntRect +DrawingSurface::pixelArea() const +{ + Geom::IntRect ret = Geom::IntRect::from_xywh(_origin.round(), _pixels); + return ret; +} + +////////////////////////////////////////////////////////////////////////////// + +DrawingCache::DrawingCache(Geom::IntRect const &area) + : DrawingSurface(area) + , _clean_region(cairo_region_create()) +{} + +DrawingCache::~DrawingCache() +{ + cairo_region_destroy(_clean_region); +} + +void +DrawingCache::markDirty(Geom::IntRect const &area) +{ + cairo_rectangle_int_t dirty = _convertRect(area); + cairo_region_subtract_rectangle(_clean_region, &dirty); +} +void +DrawingCache::markClean(Geom::IntRect const &area) +{ + Geom::OptIntRect r = Geom::intersect(area, pixelArea()); + if (!r) return; + cairo_rectangle_int_t clean = _convertRect(*r); + cairo_region_union_rectangle(_clean_region, &clean); +} +bool +DrawingCache::isClean(Geom::IntRect const &area) const +{ + cairo_rectangle_int_t test = _convertRect(area); + if (cairo_region_contains_rectangle(_clean_region, &test) == CAIRO_REGION_OVERLAP_IN) { + return true; + } else { + return false; + } +} +void +DrawingCache::resizeAndTransform(Geom::IntRect const &new_area, Geom::Affine const &trans) +{ + Geom::IntRect old_area = pixelArea(); + bool is_identity = false; + bool is_integer_translation = false; + if (trans.isIdentity()) { + is_identity = true; + if (new_area == old_area) return; + } + if (!is_identity && trans.isTranslation()) { + Geom::IntPoint t = trans.translation().round(); + if (Geom::are_near(Geom::Point(t), trans.translation())) { + // integer translation or identity with change of area + is_integer_translation = true; + cairo_region_translate(_clean_region, t[X], t[Y]); + if (old_area + t == new_area) { + // if the areas match, the only thing to do + // is to ensure that the clean area is not too large + cairo_rectangle_int_t limit = _convertRect(new_area); + cairo_region_intersect_rectangle(_clean_region, &limit); + _origin += t; + return; + } + } + } + // otherwise, we need to transform the cache + Geom::IntPoint old_origin = old_area.min(); + cairo_surface_t *old_surface = _surface; + _surface = NULL; + _pixels = new_area.dimensions(); + _origin = new_area.min(); + + cairo_t *ct = createRawContext(); + if (!is_identity) { + ink_cairo_transform(ct, trans); + } + cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]); + cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(ct); + + cairo_surface_destroy(old_surface); + cairo_destroy(ct); + + if (!is_identity && !is_integer_translation) { + // dirty everything + cairo_region_destroy(_clean_region); + _clean_region = cairo_region_create(); + } else { + cairo_rectangle_int_t limit = _convertRect(new_area); + cairo_region_intersect_rectangle(_clean_region, &limit); + } +} + +/** @brief Paints the clean area from cache and returns the remaining part */ +bool +DrawingCache::paintFromCache(DrawingContext &ct, Geom::IntRect const &area) +{ + if (!isClean(area)) + return false; + + Inkscape::DrawingContext::Save save(ct); + ct.rectangle(area); + ct.clip(); + ct.setSource(this); + ct.paint(); + + return true; +} + +cairo_rectangle_int_t +DrawingCache::_convertRect(Geom::IntRect const &area) +{ + cairo_rectangle_int_t ret; + ret.x = area.left(); + ret.y = area.top(); + ret.width = area.width(); + ret.height = area.height(); + return ret; +} + } // end namespace Inkscape /* diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index e26bc28fa..f279d771b 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -26,7 +26,6 @@ class DrawingSurface { public: explicit DrawingSurface(Geom::IntRect const &area); - explicit DrawingSurface(Geom::Rect const &area); DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims); DrawingSurface(cairo_surface_t *surface, Geom::Point const &origin); virtual ~DrawingSurface(); @@ -44,6 +43,8 @@ public: cairo_t *createRawContext(); protected: + Geom::IntRect pixelArea() const; + cairo_surface_t *_surface; Geom::Point _origin; Geom::Scale _scale; @@ -53,16 +54,23 @@ protected: friend class DrawingContext; }; -class PixbufSurface +class DrawingCache : public DrawingSurface { public: - explicit PixbufSurface(GdkPixbuf *pb, Geom::Point const &origin = Geom::Point(0,0)); - ~PixbufSurface(); -protected: - GdkPixbuf *pb; + explicit DrawingCache(Geom::IntRect const &area); + ~DrawingCache(); - friend class DrawingContext; + void markDirty(Geom::IntRect const &area = Geom::IntRect::infinite()); + void markClean(Geom::IntRect const &area = Geom::IntRect::infinite()); + bool isClean(Geom::IntRect const &area) const; + void resizeAndTransform(Geom::IntRect const &new_area, Geom::Affine const &trans); + bool paintFromCache(DrawingContext &ct, Geom::IntRect const &area); + +protected: + cairo_region_t *_clean_region; +private: + static cairo_rectangle_int_t _convertRect(Geom::IntRect const &r); }; } // end namespace Inkscape diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index c1ffefa1d..264b8ab10 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -90,14 +90,14 @@ nr_arena_item_init (NRArenaItem *item) item->ctm.setIdentity(); item->opacity = 255; item->render_opacity = FALSE; + item->render_cache = FALSE; item->transform = NULL; item->clip = NULL; item->mask = NULL; - item->px = NULL; + item->cache = NULL; item->data = NULL; item->filter = NULL; - item->background_pb = NULL; item->background_new = false; } @@ -106,13 +106,13 @@ nr_arena_item_private_finalize (NRObject *object) { NRArenaItem *item = static_cast < NRArenaItem * >(object); - item->px = NULL; item->transform = NULL; if (item->clip) nr_arena_item_detach(item, item->clip); if (item->mask) nr_arena_item_detach(item, item->mask); + delete item->cache; ((NRObjectClass *) (parent_class))->finalize (object); } @@ -246,21 +246,18 @@ nr_arena_item_invoke_update (NRArenaItem *item, Geom::IntRect const &area, NRGC return item->state; /* Test whether to return immediately */ if (item->state & NR_ARENA_ITEM_STATE_BBOX) { + // we have up-to-date bbox if (!area.intersects(outline ? item->bbox : item->drawbox)) return item->state; } - /* Reset image cache, if not to be kept */ - if (!(item->state & NR_ARENA_ITEM_STATE_IMAGE) && (item->px)) { - item->px = NULL; - } - /* Set up local gc */ childgc = *gc; if (item->transform) { childgc.transform = (*item->transform) * childgc.transform; } /* Remember the transformation matrix */ + Geom::Affine ctm_change = item->ctm.inverse() * childgc.transform; item->ctm = childgc.transform; /* Invoke the real method */ @@ -307,10 +304,31 @@ nr_arena_item_invoke_update (NRArenaItem *item, Geom::IntRect const &area, NRGC } } + // update cache if enabled + if (item->render_cache) { + Geom::OptIntRect cl = item->arena->cache_limit; + cl.intersectWith(item->drawbox); + if (cl) { + if (item->cache) { + // this takes care of invalidation on transform + item->cache->resizeAndTransform(*cl, ctm_change); + } else { + item->cache = new Inkscape::DrawingCache(*cl); + // the cache is initially dirty + } + } else { + // disable cache for this item - not visible + delete item->cache; + item->cache = NULL; + } + } + // now that we know drawbox, dirty the corresponding rect on canvas: if (!NR_IS_ARENA_GROUP(item) || (item->filter && filter)) { // unless filtered, groups do not need to render by themselves, only their members - nr_arena_item_request_render (item); + if (state & ~NR_ARENA_ITEM_STATE_CACHE) { + nr_arena_item_request_render (item); + } } return item->state; @@ -379,12 +397,19 @@ nr_arena_item_invoke_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Ge return item->state | NR_ARENA_ITEM_STATE_RENDER; } - + // carea is the bounding box for intermediate rendering. - // NOTE: carea might be larger than area, because of filter effects. Geom::OptIntRect carea = Geom::intersect(area, item->drawbox); if (!carea) return item->state | NR_ARENA_ITEM_STATE_RENDER; + + // render from cache + if (item->render_cache && item->cache) { + if(item->cache->paintFromCache(ct, *carea)) + return item->state | NR_ARENA_ITEM_STATE_RENDER; + } + + // expand carea to contain the dependent area of filters. if (item->filter && filter) { item->filter->area_enlarge(*carea, item); carea.intersectWith(item->drawbox); @@ -422,12 +447,40 @@ nr_arena_item_invoke_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Ge // short-circuit the simple case. if (!needs_intermediate_rendering) { - state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, *carea, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; + if (item->render_cache && item->cache) { + Inkscape::DrawingContext cachect(*item->cache); + cachect.rectangle(area); + cachect.clip(); + + { // 1. clear the corresponding part of cache + Inkscape::DrawingContext::Save save(cachect); + cachect.setSource(0,0,0,0); + cachect.setOperator(CAIRO_OPERATOR_SOURCE); + cachect.paint(); + } + // 2. render to cache + state = NR_ARENA_ITEM_VIRTUAL (item, render) (cachect, item, *carea, flags); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + item->state |= NR_ARENA_ITEM_STATE_INVALID; + return item->state; + } + // 3. copy from cache to output + Inkscape::DrawingContext::Save save(ct); + ct.rectangle(*carea); + ct.clip(); + ct.setSource(item->cache); + ct.paint(); + // 4. mark as clean + item->cache->markClean(area); + return item->state | NR_ARENA_ITEM_STATE_RENDER; + } else { + state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, *carea, flags); + if (state & NR_ARENA_ITEM_STATE_INVALID) { + item->state |= NR_ARENA_ITEM_STATE_INVALID; + return item->state; + } + return item->state | NR_ARENA_ITEM_STATE_RENDER; } - return item->state | NR_ARENA_ITEM_STATE_RENDER; } DrawingSurface intermediate(*carea); @@ -490,7 +543,16 @@ nr_arena_item_invoke_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Ge ict.setOperator(CAIRO_OPERATOR_IN); ict.paint(); - // 6. Paint the completed rendering onto the base context + // 6. Paint the completed rendering onto the base context (or into cache) + if (item->render_cache && item->cache) { + DrawingContext cachect(*item->cache); + cachect.rectangle(area); + cachect.clip(); + cachect.setOperator(CAIRO_OPERATOR_SOURCE); + cachect.setSource(&intermediate); + cachect.paint(); + item->cache->markClean(area); + } ct.setSource(&intermediate); ct.paint(); ct.setSource(0,0,0,0); @@ -601,7 +663,17 @@ nr_arena_item_request_render (NRArenaItem *item) nr_return_if_fail (NR_IS_ARENA_ITEM (item)); bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - nr_arena_request_render_rect (item->arena, outline ? item->bbox : item->drawbox); + Geom::OptIntRect dirty = outline ? item->bbox : item->drawbox; + if (!dirty) return; + + // dirty the caches of all parents + for (NRArenaItem *i = item; i; i = i->parent) { + if (i->render_cache && i->cache) { + i->cache->markDirty(*dirty); + } + } + + nr_arena_request_render_rect (item->arena, dirty); } /* Public */ @@ -773,6 +845,19 @@ nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect const &bbox) item->item_bbox = bbox; } +void +nr_arena_item_set_cache (NRArenaItem *item, bool cache) +{ + if (cache) { + item->render_cache = TRUE; + item->arena->cached_items.insert(item); + } else { + item->render_cache = FALSE; + item->arena->cached_items.erase(item); + } + nr_arena_item_request_update(item, NR_ARENA_ITEM_STATE_ALL, FALSE); +} + /** Returns a background image for use with filter effects. */ NRPixBlock *nr_arena_item_get_background(NRArenaItem const * /*item*/) { diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 4b43e4da8..2c00c0bf3 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -24,6 +24,7 @@ namespace Inkscape { class DrawingContext; +class DrawingCache; namespace Filters { class Filter; } } @@ -57,15 +58,17 @@ class Filter; #define NR_ARENA_ITEM_STATE_MASK (1 << 6) #define NR_ARENA_ITEM_STATE_PICK (1 << 7) #define NR_ARENA_ITEM_STATE_IMAGE (1 << 8) +#define NR_ARENA_ITEM_STATE_CACHE (1 << 9) #define NR_ARENA_ITEM_STATE_NONE 0x0000 -#define NR_ARENA_ITEM_STATE_ALL 0x01fe +#define NR_ARENA_ITEM_STATE_ALL 0x03fe #define NR_ARENA_ITEM_STATE(i,s) (NR_ARENA_ITEM (i)->state & (s)) #define NR_ARENA_ITEM_SET_STATE(i,s) (NR_ARENA_ITEM (i)->state |= (s)) #define NR_ARENA_ITEM_UNSET_STATE(i,s) (NR_ARENA_ITEM (i)->state &= ~(s)) #define NR_ARENA_ITEM_RENDER_NO_CACHE (1 << 0) +#define NR_ARENA_ITEM_RENDER_CACHE (1 << 1) struct NRGC { NRGC(NRGC const *p) : parent(p) {} @@ -81,14 +84,15 @@ struct NRArenaItem : public NRObject { Inkscape::GC::soft_ptr prev; /* Item state */ - unsigned int state : 16; - unsigned int propagate : 1; - unsigned int sensitive : 1; - unsigned int visible : 1; - /* Whether items renders opacity itself */ - unsigned int render_opacity : 1; + unsigned state : 16; /* Opacity itself */ - unsigned int opacity : 8; + unsigned opacity : 8; + unsigned propagate : 1; + unsigned sensitive : 1; + unsigned visible : 1; + /* Whether items renders opacity itself */ + unsigned render_opacity : 1; + unsigned render_cache : 1; unsigned int key; ///< Some SPItems can have more than one NRArenaItem, ///this value is a hack used to distinguish between them @@ -101,11 +105,10 @@ struct NRArenaItem : public NRObject { NRArenaItem *clip; ///< Clipping path NRArenaItem *mask; ///< Mask Inkscape::Filters::Filter *filter; ///< Filter - unsigned char *px; ///< Render cache; unused + Inkscape::DrawingCache *cache; ///< Render cache void *data; ///< Anonymous data member - this is used to associate SPItems with arena items - NRPixBlock *background_pb; ///< Background for filters; unused bool background_new; void init(NRArena *arena) { @@ -173,6 +176,7 @@ void nr_arena_item_set_clip (NRArenaItem *item, NRArenaItem *clip); void nr_arena_item_set_mask (NRArenaItem *item, NRArenaItem *mask); void nr_arena_item_set_order (NRArenaItem *item, int order); void nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect const &bbox); +void nr_arena_item_set_cache (NRArenaItem *item, bool cache); NRPixBlock *nr_arena_item_get_background (NRArenaItem const *item); diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index 5747de26c..735d44e9e 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -151,6 +151,17 @@ nr_arena_set_renderoffscreen (NRArena *arena) } +void +nr_arena_set_cache_limit (NRArena *arena, Geom::OptIntRect const &cache_limit) +{ + arena->cache_limit = cache_limit; + for (std::set::iterator i = arena->cached_items.begin(); + i != arena->cached_items.end(); ++i) + { + nr_arena_item_request_update(*i, NR_ARENA_ITEM_STATE_CACHE, FALSE); + } +} + #define FLOAT_TO_UINT8(f) (int(f*255)) #define RGBA_R(v) ((v) >> 24) #define RGBA_G(v) (((v) >> 16) & 0xff) diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index 49d133f9f..5d078e19d 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -27,6 +27,7 @@ G_END_DECLS #define NR_ARENA(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA, NRArena)) #define NR_IS_ARENA(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA)) +#include #include <2geom/rect.h> #include #include @@ -53,6 +54,8 @@ struct NRArena : public NRActiveObject { Inkscape::ColorRenderMode colorrendermode; int blurquality; // will be updated during update from preferences int filterquality; // will be updated during update from preferences + Geom::OptIntRect cache_limit; + std::set cached_items; guint32 outlinecolor; SPCanvasArena *canvasarena; // may be NULL is this arena is not the screen but used for export etc. @@ -64,6 +67,7 @@ struct NRArenaClass : public NRActiveObjectClass { void nr_arena_request_update (NRArena *arena, NRArenaItem *item); void nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area); void nr_arena_set_renderoffscreen (NRArena *arena); +void nr_arena_set_cache_limit (NRArena *arena, Geom::OptIntRect const &cache_limit); void nr_arena_separate_color_plates(guint32* rgba); diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 4c731e56b..415c36566 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -64,7 +64,7 @@ struct _SPCanvasItemClass : public GtkObjectClass { double (* point) (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); int (* event) (SPCanvasItem *item, GdkEvent *event); - void (* visible_area_changed) (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); + void (* viewbox_changed) (SPCanvasItem *item, Geom::IntRect const &new_area); }; SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, const gchar *first_arg_name, ...); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 71f608118..7d6727ff3 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -689,7 +689,7 @@ static void sp_canvas_group_destroy (GtkObject *object); static void sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf); -static void sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); +static void sp_canvas_group_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area); static SPCanvasItemClass *group_parent_class; @@ -733,7 +733,7 @@ sp_canvas_group_class_init (SPCanvasGroupClass *klass) item_class->update = sp_canvas_group_update; item_class->render = sp_canvas_group_render; item_class->point = sp_canvas_group_point; - item_class->visible_area_changed = sp_canvas_group_visible_area_changed; + item_class->viewbox_changed = sp_canvas_group_viewbox_changed; } /** @@ -878,15 +878,15 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf) } static void -sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area) +sp_canvas_group_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area) { SPCanvasGroup *group = SP_CANVAS_GROUP (item); for (GList *list = group->items; list; list = list->next) { SPCanvasItem *child = (SPCanvasItem *)list->data; if (child->flags & SP_CANVAS_ITEM_VISIBLE) { - if (SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed) - SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed (child, old_area, new_area); + if (SP_CANVAS_ITEM_GET_CLASS (child)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (child)->viewbox_changed (child, new_area); } } } @@ -1234,8 +1234,8 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) /* Schedule redraw of new region */ sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height); - if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) - SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area); if (allocation->width > widget->allocation.width) { sp_canvas_request_redraw (canvas, @@ -1655,6 +1655,15 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int buf.is_empty = true; //buf.ct = gdk_cairo_create(widget->window); + /* + cairo_t *xctt = gdk_cairo_create(widget->window); + cairo_translate(xctt, x0 - canvas->x0, y0 - canvas->y0); + cairo_set_source_rgb(xctt, 1,0,0); + cairo_rectangle(xctt, 0, 0, x1-x0, y1-y0); + cairo_fill(xctt); + cairo_destroy(xctt); + //*/ + // create temporary surface int w = x1 - x0; int h = y1 - y0; @@ -2168,8 +2177,8 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, canvas->y0 = iy; sp_canvas_resize_tiles (canvas, canvas->x0, canvas->y0, canvas->x0+canvas->widget.allocation.width, canvas->y0+canvas->widget.allocation.height); - if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) - SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area); if (!clear) { // scrolling without zoom; redraw only the newly exposed areas -- cgit v1.2.3 From 1d926d1c2010fea85264f26c21e7c3be0c7fb5ab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Jul 2011 07:29:35 +1000 Subject: fix for build error when not returning a value in libgdl & minor style edit. (bzr r10510) --- src/ege-select-one-action.cpp | 2 +- src/libgdl/gdl-dock-item-button-image.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index e0130a68d..047a65868 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -758,7 +758,7 @@ GtkWidget* create_tool_item( GtkAction* action ) GtkWidget *normal = (act->private_data->selectionMode == SELECTION_OPEN) ? gtk_combo_box_entry_new_with_model( act->private_data->model, act->private_data->labelColumn ) : gtk_combo_box_new_with_model( act->private_data->model ); - if ((act->private_data->selectionMode == SELECTION_OPEN)) { + if (act->private_data->selectionMode == SELECTION_OPEN) { GtkWidget *child = gtk_bin_get_child( GTK_BIN(normal) ); if (GTK_IS_ENTRY(child)) { int maxUsed = scan_max_width( act->private_data->model, act->private_data->labelColumn ); diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c index f115c652c..ce5c33ea6 100644 --- a/src/libgdl/gdl-dock-item-button-image.c +++ b/src/libgdl/gdl-dock-item-button-image.c @@ -49,7 +49,7 @@ gdl_dock_item_button_image_expose (GtkWidget *widget, cairo_set_line_width(cr, 1.0); style = gtk_widget_get_style (widget); - g_return_if_fail (style != NULL); + g_return_val_if_fail (style != NULL, 0); color = &style->fg[GTK_STATE_NORMAL]; cairo_set_source_rgba(cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0, 0.55); -- cgit v1.2.3 From 11d64122c5299b9d7b2ef9459d40cdbe012c0ab8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Jul 2011 07:36:35 +1000 Subject: another g_return_if_fail -> g_return_val_if_fail & add include to cmake. (bzr r10511) --- src/extension/CMakeLists.txt | 1 + src/libgdl/gdl-dock-item.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index c9c466bb0..7cbbc886f 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -114,6 +114,7 @@ set(extension_SRC internal/emf-win32-inout.h internal/emf-win32-print.h internal/filter/abc.h + internal/filter/blurs.h internal/filter/color.h internal/filter/drop-shadow.h internal/filter/experimental.h diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 0c0d765df..22f261b32 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -1952,7 +1952,7 @@ gdl_dock_item_set_tablabel (GdlDockItem *item, GtkWidget * gdl_dock_item_get_grip(GdlDockItem *item) { - g_return_if_fail (item != NULL); + g_return_val_if_fail (item != NULL, NULL); g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL); return item->_priv->grip; -- cgit v1.2.3 From ee4956cfe78fc822d0cadcc24f3e49d199bd0fe6 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 28 Jul 2011 20:09:35 +0200 Subject: Filters. New Bump custom predefined filter. Translations. inkscape.pot and French translation update. (bzr r10512) --- src/extension/internal/filter/bumps.h | 272 +++++++++++++++++++++++++++ src/extension/internal/filter/filter-all.cpp | 6 +- 2 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 src/extension/internal/filter/bumps.h (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h new file mode 100644 index 000000000..5b0be2b7e --- /dev/null +++ b/src/extension/internal/filter/bumps.h @@ -0,0 +1,272 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ +/* Change the 'BUMPS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Bump filters + * Bump + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Bump filter. + + All purpose bump filter + + Filter's parameters: + Options + * Image simplification (0.01->10., default 0.01) -> blur1 (stdDeviation) + * Bump simplification (0.01->10., default 0.01) -> blur2 (stdDeviation) + * Crop (-1.->1., default 0) -> composite1 (k3) + * Red (-50.->50., default 0.) -> colormatrix1 (values) + * Green (-50.->50., default 0.) -> colormatrix1 (values) + * Blue (-50.->50., default 0.) -> colormatrix1 (values) + * Bump from background (boolean, default false) -> colormatrix1 (false: in="SourceGraphic", true: in="BackgroundImage") + Lighting + * Lighting type (enum, default specular) -> lighting block + * Height (0.->50., default 5.) -> lighting (surfaceScale) + * Lightness (0.->5., default 1.) -> lighting [diffuselighting (diffuseConstant)|specularlighting (specularConstant)] + * Precision (1->128, default 15) -> lighting (specularExponent) + * Color (guint, default -1 (RGB:255,255,255))-> lighting (lighting-color) + Light source + * Azimuth (0->360, default 225) -> lightsOptions (distantAzimuth) + * Elevation (0->180, default 45) -> lightsOptions (distantElevation) + * X location [point] (-5000->5000, default 526) -> lightsOptions (x) + * Y location [point] (-5000->5000, default 372) -> lightsOptions (y) + * Z location [point] (0->5000, default 150) -> lightsOptions (z) + * X location [spot] (-5000->5000, default 526) -> lightsOptions (x) + * Y location [spot] (-5000->5000, default 372) -> lightsOptions (y) + * Z location [spot] (-5000->5000, default 150) -> lightsOptions (z) + * X target (-5000->5000, default 0) -> lightsOptions (pointsAtX) + * Y target (-5000->5000, default 0) -> lightsOptions (pointsAtX) + * Z target (-5000->0, default -1000) -> lightsOptions (pointsAtX) + * Specular exponent (1->100, default 1) -> lightsOptions (specularExponent) + * Cone angle (0->100, default 50) -> lightsOptions (limitingConeAngle) + Color bump + * Blend type (enum, default normal) -> blend (mode) + * Image color (guint, default -987158017 (RGB:197,41,41)) -> flood (flood-color) + * Color bump (boolean, default false) -> composite2 (false: in="diffuselighting", true in="flood") +*/ + +class Bump : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Bump ( ) : Filter() { }; + virtual ~Bump ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Bump, custom (Bumps)") "\n" + "org.inkscape.effect.filter.Bump\n" + "\n" + "\n" + "0.01\n" + "0.01\n" + "0\n" + "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">Bump source\n" + "0\n" + "0\n" + "0\n" + "false\n" + "\n" + "\n" + "\n" + "<_item value=\"specular\">" N_("Specular") "\n" + "<_item value=\"diffuse\">" N_("Diffuse") "\n" + "\n" + "5\n" + "1\n" + "15\n" + "-1\n" + "\n" + "\n" + "\n" + "<_item value=\"distant\">" N_("Distant") "\n" + "<_item value=\"point\">" N_("Point") "\n" + "<_item value=\"spot\">" N_("Spot") "\n" + "\n" + "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">Distant light options\n" + "225\n" + "45\n" + "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">Point light options\n" + "526\n" + "372\n" + "150\n" + "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">Spot light options\n" + "526\n" + "372\n" + "150\n" + "0\n" + "0\n" + "-1000\n" + "1\n" + "50\n" + "\n" + "\n" + "-987158017\n" + "false\n" + "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("All purposes bump filter") "\n" + "\n" + "\n", new Bump()); + }; + +}; + +gchar const * +Bump::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream simplifyImage; + std::ostringstream simplifyBump; + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream crop; + std::ostringstream bumpSource; + std::ostringstream blend; + + std::ostringstream lightStart; + std::ostringstream lightOptions; + std::ostringstream lightEnd; + + std::ostringstream lightRed; + std::ostringstream lightGreen; + std::ostringstream lightBlue; + std::ostringstream floodRed; + std::ostringstream floodGreen; + std::ostringstream floodBlue; + std::ostringstream colorize; + + + simplifyImage << ext->get_param_float("simplifyImage"); + simplifyBump << ext->get_param_float("simplifyBump"); + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + crop << ext->get_param_float("crop"); + blend << ext->get_param_enum("blend"); + + guint32 lightingColor = ext->get_param_color("lightingColor"); + guint32 imageColor = ext->get_param_color("imageColor"); + + if (ext->get_param_bool("background")) { + bumpSource << "BackgroundImage" ; + } else { + bumpSource << "blur1" ; + } + + const gchar *lightType = ext->get_param_enum("lightType"); + if ((g_ascii_strcasecmp("specular", lightType) == 0)) { + // Specular + lightStart << "> 24) & 0xff) << "," + << ((lightingColor >> 16) & 0xff) << "," << ((lightingColor >> 8) & 0xff) << ")\" surfaceScale=\"" + << ext->get_param_float("height") << "\" specularConstant=\"" << ext->get_param_float("lightness") + << "\" specularExponent=\"" << ext->get_param_int("precision") << "\" result=\"lighting\">"; + lightEnd << ""; + } else { + // Diffuse + lightStart << "> 24) & 0xff) << "," + << ((lightingColor >> 16) & 0xff) << "," << ((lightingColor >> 8) & 0xff) << ")\" surfaceScale=\"" + << ext->get_param_float("height") << "\" diffuseConstant=\"" << ext->get_param_float("lightness") + << "\" result=\"lighting\">"; + lightEnd << ""; + } + + const gchar *lightSource = ext->get_param_enum("lightSource"); + if ((g_ascii_strcasecmp("distant", lightSource) == 0)) { + // Distant + lightOptions << "get_param_int("distantAzimuth") << "\" elevation=\"" + << ext->get_param_int("distantElevation") << "\" />"; + } else if ((g_ascii_strcasecmp("point", lightSource) == 0)) { + // Point + lightOptions << "get_param_int("pointX") << "\" y=\"" << ext->get_param_int("pointY") + << "\" x=\"" << ext->get_param_int("pointZ") << "\" />"; + } else { + // Spot + lightOptions << "get_param_int("pointX") << "\" y=\"" << ext->get_param_int("pointY") + << "\" z=\"" << ext->get_param_int("pointZ") << "\" pointsAtX=\"" << ext->get_param_int("spotAtX") + << "\" pointsAtY=\"" << ext->get_param_int("spotAtY") << "\" pointsAtZ=\"" << ext->get_param_int("spotAtZ") + << "\" specularExponent=\"" << ext->get_param_int("spotExponent") + << "\" limitingConeAngle=\"" << ext->get_param_int("spotConeAngle") + << "\" />"; + } + + floodRed << ((imageColor >> 24) & 0xff); + floodGreen << ((imageColor >> 16) & 0xff); + floodBlue << ((imageColor >> 8) & 0xff); + + if (ext->get_param_bool("colorize")) { + colorize << "flood" ; + } else { + colorize << "blur1" ; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "%s\n" + "%s\n" + "%s\n" + "\n" + "\n" + "\n" + "\n" + "\n", simplifyImage.str().c_str(), bumpSource.str().c_str(), red.str().c_str(), green.str().c_str(), blue.str().c_str(), + crop.str().c_str(), simplifyBump.str().c_str(), + lightStart.str().c_str(), lightOptions.str().c_str(), lightEnd.str().c_str(), + floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), + colorize.str().c_str(), blend.str().c_str()); + + return _filter; + +}; /* Cross blur filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'BUMPS' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index ed8b4e180..210d1d87a 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -10,7 +10,7 @@ /* Put your filter here */ #include "abc.h" #include "blurs.h" -//#include "bumps.h" +#include "bumps.h" #include "color.h" #include "drop-shadow.h" #include "image.h" @@ -36,7 +36,7 @@ Filter::filters_all (void ) /* Experimental custom predefined filters */ - // ABCs + // ABC Blur::init(); CleanEdges::init(); ColorShift::init(); @@ -53,7 +53,7 @@ Filter::filters_all (void ) CrossBlur::init(); // Bumps -// SpecularBump::init(); + Bump::init(); // Color Brightness::init(); -- cgit v1.2.3 From 471d20119544155b62e3d90492443b3ddc14b289 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 28 Jul 2011 22:34:55 +0200 Subject: UI uniformisation / addition of mnemonics (Bug #170765) Removed unnecessary command in path effects (bzr r10515) --- src/extension/patheffect.cpp | 1 - src/ui/dialog/tracedialog.cpp | 77 +++++++++++++++++++++++++++++-------------- 2 files changed, 53 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index e093d20d7..a3094d536 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -66,7 +66,6 @@ PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path) peffect = dynamic_cast(Inkscape::Extension::db.get(ext_id)); if (peffect != NULL) { peffect->processPath(doc, path, prefs); - continue; } } diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index 7fb172531..3f2cc451b 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -403,8 +403,9 @@ TraceDialogImpl::TraceDialogImpl() : // brightness - modeBrightnessRadioButton.set_label(_("Brightness cutoff")); + modeBrightnessRadioButton.set_label(_("_Brightness cutoff")); modeGroup = modeBrightnessRadioButton.get_group(); + modeBrightnessRadioButton.set_use_underline(true); modeBrightnessBox.pack_start(modeBrightnessRadioButton, false, false, MARGIN); tips.set_tip(modeBrightnessRadioButton, _("Trace by a given brightness level")); @@ -417,7 +418,9 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(modeBrightnessSpinner, _("Brightness cutoff for black/white")); - modeBrightnessSpinnerLabel.set_label(_("Threshold:")); + modeBrightnessSpinnerLabel.set_label(_("_Threshold:")); + modeBrightnessSpinnerLabel.set_use_underline(true); + modeBrightnessSpinnerLabel.set_mnemonic_widget(modeBrightnessSpinner); modeBrightnessBox.pack_end(modeBrightnessSpinnerLabel, false, false, MARGIN); modeBrightnessVBox.pack_start(modeBrightnessBox, false, false, MARGIN); @@ -427,8 +430,9 @@ TraceDialogImpl::TraceDialogImpl() : // canny edge detection // TRANSLATORS: "Canny" is the name of the inventor of this edge detection method - modeCannyRadioButton.set_label(_("Edge detection")); + modeCannyRadioButton.set_label(_("_Edge detection")); modeCannyRadioButton.set_group(modeGroup); + modeCannyRadioButton.set_use_underline(true); modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN); tips.set_tip(modeCannyRadioButton, _("Trace with optimal edge detection by J. Canny's algorithm")); @@ -450,7 +454,9 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(modeCannyHiSpinner, _("Brightness cutoff for adjacent pixels (determines edge thickness)")); - modeCannyHiSpinnerLabel.set_label(_("Threshold:")); + modeCannyHiSpinnerLabel.set_label(_("T_hreshold:")); + modeCannyHiSpinnerLabel.set_use_underline(true); + modeCannyHiSpinnerLabel.set_mnemonic_widget(modeCannyHiSpinner); modeCannyBox.pack_end(modeCannyHiSpinnerLabel, false, false, MARGIN); modeBrightnessVBox.pack_start(modeCannyBox, false, false, MARGIN); @@ -460,8 +466,9 @@ TraceDialogImpl::TraceDialogImpl() : // of colors in an image by selecting an optimized set of representative // colors and then re-applying this reduced set to the original image. - modeQuantRadioButton.set_label(_("Color quantization")); + modeQuantRadioButton.set_label(_("Color _quantization")); modeQuantRadioButton.set_group(modeGroup); + modeQuantRadioButton.set_use_underline(true); modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN); tips.set_tip(modeQuantRadioButton, _("Trace along the boundaries of reduced colors")); @@ -474,14 +481,17 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(modeQuantNrColorSpinner, _("The number of reduced colors")); - modeQuantNrColorLabel.set_label(_("Colors:")); + modeQuantNrColorLabel.set_label(_("_Colors:")); + modeQuantNrColorLabel.set_mnemonic_widget(modeQuantNrColorSpinner); + modeQuantNrColorLabel.set_use_underline(true); modeQuantBox.pack_end(modeQuantNrColorLabel, false, false, MARGIN); modeBrightnessVBox.pack_start(modeQuantBox, false, false, MARGIN); // swap black and white - modeInvertButton.set_label(_("Invert image")); + modeInvertButton.set_label(_("_Invert image")); modeInvertButton.set_active(false); + modeInvertButton.set_use_underline(true); modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN); modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN); tips.set_tip(modeInvertButton, @@ -494,8 +504,9 @@ TraceDialogImpl::TraceDialogImpl() : //# begin multiple scan - modeMultiScanBrightnessRadioButton.set_label(_("Brightness steps")); + modeMultiScanBrightnessRadioButton.set_label(_("B_rightness steps")); modeMultiScanBrightnessRadioButton.set_group(modeGroup); + modeMultiScanBrightnessRadioButton.set_use_underline(true); modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN); tips.set_tip(modeMultiScanBrightnessRadioButton, _("Trace the given number of brightness levels")); @@ -505,23 +516,27 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanNrColorSpinner.set_range(2.0, 256.0); modeMultiScanNrColorSpinner.set_value(8.0); modeMultiScanHBox1.pack_end(modeMultiScanNrColorSpinner, false, false, MARGIN); - modeMultiScanNrColorLabel.set_label(_("Scans:")); + modeMultiScanNrColorLabel.set_label(_("Sc_ans:")); + modeMultiScanNrColorLabel.set_use_underline(true); + modeMultiScanNrColorLabel.set_mnemonic_widget(modeMultiScanNrColorSpinner); modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN); tips.set_tip(modeMultiScanNrColorSpinner, _("The desired number of scans")); modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN); - modeMultiScanColorRadioButton.set_label(_("Colors")); + modeMultiScanColorRadioButton.set_label(_("Co_lors")); modeMultiScanColorRadioButton.set_group(modeGroup); + modeMultiScanColorRadioButton.set_use_underline(true); modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN); tips.set_tip(modeMultiScanColorRadioButton, _("Trace the given number of reduced colors")); modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN); - modeMultiScanMonoRadioButton.set_label(_("Grays")); + modeMultiScanMonoRadioButton.set_label(_("_Grays")); modeMultiScanMonoRadioButton.set_group(modeGroup); + modeMultiScanMonoRadioButton.set_use_underline(true); modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN); tips.set_tip(modeMultiScanMonoRadioButton, _("Same as Colors, but the result is converted to grayscale")); @@ -529,20 +544,23 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN); // TRANSLATORS: "Smooth" is a verb here - modeMultiScanSmoothButton.set_label(_("Smooth")); + modeMultiScanSmoothButton.set_label(_("S_mooth")); + modeMultiScanSmoothButton.set_use_underline(true); modeMultiScanSmoothButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN); tips.set_tip(modeMultiScanSmoothButton, _("Apply Gaussian blur to the bitmap before tracing")); // TRANSLATORS: "Stack" is a verb here - modeMultiScanStackButton.set_label(_("Stack scans")); + modeMultiScanStackButton.set_label(_("Stac_k scans")); + modeMultiScanStackButton.set_use_underline(true); modeMultiScanStackButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN); tips.set_tip(modeMultiScanStackButton, _("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)")); - modeMultiScanBackgroundButton.set_label(_("Remove background")); + modeMultiScanBackgroundButton.set_label(_("Remo_ve background")); + modeMultiScanBackgroundButton.set_use_underline(true); modeMultiScanBackgroundButton.set_active(false); modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN); // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan @@ -560,13 +578,14 @@ TraceDialogImpl::TraceDialogImpl() : //## end mode page - notebook.append_page(modePageBox, _("Mode")); + notebook.append_page(modePageBox, _("_Mode"), true); //## begin option page //# potrace parameters - optionsSpecklesButton.set_label(_("Suppress speckles")); + optionsSpecklesButton.set_label(_("Suppress _speckles")); + optionsSpecklesButton.set_use_underline(true); tips.set_tip(optionsSpecklesButton, _("Ignore small spots (speckles) in the bitmap")); optionsSpecklesButton.set_active(true); @@ -578,10 +597,13 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(optionsSpecklesSizeSpinner, _("Speckles of up to this many pixels will be suppressed")); optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN); - optionsSpecklesSizeLabel.set_label(_("Size:")); + optionsSpecklesSizeLabel.set_label(_("S_ize:")); + optionsSpecklesSizeLabel.set_use_underline(true); + optionsSpecklesSizeLabel.set_mnemonic_widget(optionsSpecklesSizeSpinner); optionsSpecklesBox.pack_end(optionsSpecklesSizeLabel, false, false, MARGIN); - optionsCornersButton.set_label(_("Smooth corners")); + optionsCornersButton.set_label(_("Smooth _corners")); + optionsCornersButton.set_use_underline(true); tips.set_tip(optionsCornersButton, _("Smooth out sharp corners of the trace")); optionsCornersButton.set_active(true); @@ -593,10 +615,13 @@ TraceDialogImpl::TraceDialogImpl() : optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN); tips.set_tip(optionsCornersThresholdSpinner, _("Increase this to smooth corners more")); - optionsCornersThresholdLabel.set_label(_("Threshold:")); + optionsCornersThresholdLabel.set_label(_("_Threshold:")); + optionsCornersThresholdLabel.set_use_underline(true); + optionsCornersThresholdLabel.set_mnemonic_widget(optionsCornersThresholdSpinner); optionsCornersBox.pack_end(optionsCornersThresholdLabel, false, false, MARGIN); - optionsOptimButton.set_label(_("Optimize paths")); + optionsOptimButton.set_label(_("Optimize p_aths")); + optionsOptimButton.set_use_underline(true); optionsOptimButton.set_active(true); tips.set_tip(optionsOptimButton, _("Try to optimize paths by joining adjacent Bezier curve segments")); @@ -608,7 +633,9 @@ TraceDialogImpl::TraceDialogImpl() : optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN); tips.set_tip(optionsOptimToleranceSpinner, _("Increase this to reduce the number of nodes in the trace by more aggressive optimization")); - optionsOptimToleranceLabel.set_label(_("Tolerance:")); + optionsOptimToleranceLabel.set_label(_("To_lerance:")); + optionsOptimToleranceLabel.set_use_underline(true); + optionsOptimToleranceLabel.set_mnemonic_widget(optionsOptimToleranceSpinner); optionsOptimBox.pack_end(optionsOptimToleranceLabel, false, false, MARGIN); optionsVBox.pack_start(optionsSpecklesBox, false, false, MARGIN); @@ -620,7 +647,7 @@ TraceDialogImpl::TraceDialogImpl() : //## end option page - notebook.append_page(optionsPageBox, _("Options")); + notebook.append_page(optionsPageBox, _("O_ptions"), true); //### credits @@ -641,7 +668,8 @@ TraceDialogImpl::TraceDialogImpl() : //## SIOX - sioxButton.set_label(_("SIOX foreground selection")); + sioxButton.set_label(_("SIOX _foreground selection")); + sioxButton.set_use_underline(true); sioxBox.pack_start(sioxButton, false, false, MARGIN); tips.set_tip(sioxButton, _("Cover the area you want to select as the foreground")); @@ -649,7 +677,8 @@ TraceDialogImpl::TraceDialogImpl() : //## preview - previewButton.set_label(_("Update")); + previewButton.set_label(_("_Update")); + previewButton.set_use_underline(true); previewButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) ); previewVBox.pack_end(previewButton, false, false, 0); -- cgit v1.2.3 From b4585b0c847affe383fca32a318a627588ce4722 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Jul 2011 19:57:01 +1000 Subject: add header to cmake files (bzr r10516) --- src/extension/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 7cbbc886f..1fd0ce220 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -115,6 +115,7 @@ set(extension_SRC internal/emf-win32-print.h internal/filter/abc.h internal/filter/blurs.h + internal/filter/bumps.h internal/filter/color.h internal/filter/drop-shadow.h internal/filter/experimental.h -- cgit v1.2.3 From 7c08a0a0c893ca60e6844871e671ead34bf09edb Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 30 Jul 2011 20:50:46 +0200 Subject: Memory leaks fix / code cleanup (bzr r10519) --- src/desktop.cpp | 3 +++ src/dialogs/text-edit.cpp | 1 + src/display/nr-filter-gaussian.cpp | 2 -- src/document.cpp | 11 ++++++++++- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index 5e968b08b..bef4ad8cd 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1698,6 +1698,9 @@ static void _reconstruction_start (SPDesktop * desktop) { // printf("Desktop, starting reconstruction\n"); + if (desktop->_reconstruction_old_layer_id){ + g_free(desktop->_reconstruction_old_layer_id); + } desktop->_reconstruction_old_layer_id = g_strdup(desktop->currentLayer()->getId()); desktop->_layer_hierarchy->setBottom(desktop->currentRoot()); diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index ce3165632..382b1d630 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -752,6 +752,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, gtk_text_buffer_set_text (tb, str, strlen (str)); gtk_text_buffer_set_modified (tb, FALSE); } + g_free(phrase); phrase = str; } else { diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 3a6b425e1..d240c1a43 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -226,7 +226,6 @@ static void calcFilter(double const sigma, double b[N]) { double qbeg = 1; // Don't go lower than sigma==2 (we'd probably want a normal convolution in that case anyway) double qend = 2*sigma; double const sigmasqr = sqr(sigma); - double s; do { // Binary search for right q (a linear interpolation scheme is suggested, but this should work fine as well) double const q = (qbeg+qend)/2; // Compute scaled filter coefficients @@ -239,7 +238,6 @@ static void calcFilter(double const sigma, double b[N]) { } else { qend = q; } - s = sqrt(ssqr); } while(qend-qbeg>(sigma/(1<<30))); // Compute filter coefficients double const q = (qbeg+qend)/2; diff --git a/src/document.cpp b/src/document.cpp index 5bcf1bf40..441a5876f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -312,6 +312,15 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->rdoc = rdoc; document->rroot = rroot; + if (document->uri){ + g_free(document->uri); + } + if (document->base){ + g_free(document->base); + } + if (document->name){ + g_free(document->name); + } #ifndef WIN32 document->uri = prepend_current_dir_if_relative(uri); #else @@ -503,7 +512,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un name = g_strdup_printf(_("Memory document %d"), ++doc_count); doc = createDoc(rdoc, NULL, NULL, name, keepalive); - + g_free(name); return doc; } -- cgit v1.2.3 From d7cc3ab4cde91c261e13a2a208ed125227e6b30f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 30 Jul 2011 21:48:59 -0700 Subject: Added overload for getObjectById(). Added safety by zeroing out invalid points (prevents accidental use of stale pointers). (bzr r10521) --- src/document.cpp | 8 ++++++++ src/document.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 441a5876f..4d1d8780a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -314,12 +314,15 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, if (document->uri){ g_free(document->uri); + document->uri = 0; } if (document->base){ g_free(document->base); + document->base = 0; } if (document->name){ g_free(document->name); + document->name = 0; } #ifndef WIN32 document->uri = prepend_current_dir_if_relative(uri); @@ -852,6 +855,11 @@ SPDocument::removeUndoObserver(Inkscape::UndoStackObserver& observer) this->priv->undoStackObservers.remove(observer); } +SPObject *SPDocument::getObjectById(Glib::ustring const &id) const +{ + return getObjectById( id.c_str() ); +} + SPObject *SPDocument::getObjectById(gchar const *id) const { g_return_val_if_fail(id != NULL, NULL); diff --git a/src/document.h b/src/document.h index 82a9a5158..c94b66c4d 100644 --- a/src/document.h +++ b/src/document.h @@ -174,6 +174,7 @@ public: sigc::connection connectCommit(CommitSignal::slot_type slot); void bindObjectToId(gchar const *id, SPObject *object); + SPObject *getObjectById(Glib::ustring const &id) const; SPObject *getObjectById(gchar const *id) const; sigc::connection connectIdChanged(const gchar *id, IDChangedSignal::slot_type slot); -- cgit v1.2.3 From 08835accb19b022319d08f9f92705d294f5fe8fb Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 30 Jul 2011 21:50:14 -0700 Subject: Better memory-leak fix by just changing member to Glib::ustring. Eliminates potential for missing g_free() calls. (bzr r10522) --- src/desktop.cpp | 33 +++++++++++++-------------------- src/desktop.h | 2 +- 2 files changed, 14 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index bef4ad8cd..19504fa81 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -156,7 +156,7 @@ SPDesktop::SPDesktop() : gr_point_i( 0 ), gr_fill_or_stroke( true ), _layer_hierarchy( 0 ), - _reconstruction_old_layer_id( 0 ), + _reconstruction_old_layer_id(), // an id attribute is not allowed to be the empty string _display_mode(Inkscape::RENDERMODE_NORMAL), _display_color_mode(Inkscape::COLORRENDERMODE_NORMAL), _widget( 0 ), @@ -305,7 +305,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid document->connectReconstructionStart(sigc::bind(sigc::ptr_fun(_reconstruction_start), this)); _reconstruction_finish_connection = document->connectReconstructionFinish(sigc::bind(sigc::ptr_fun(_reconstruction_finish), this)); - _reconstruction_old_layer_id = NULL; + _reconstruction_old_layer_id.clear(); // ? // sp_active_desktop_set (desktop); @@ -1694,14 +1694,10 @@ _layer_hierarchy_changed(SPObject */*top*/, SPObject *bottom, } /// Called when document is starting to be rebuilt. -static void -_reconstruction_start (SPDesktop * desktop) +static void _reconstruction_start(SPDesktop * desktop) { // printf("Desktop, starting reconstruction\n"); - if (desktop->_reconstruction_old_layer_id){ - g_free(desktop->_reconstruction_old_layer_id); - } - desktop->_reconstruction_old_layer_id = g_strdup(desktop->currentLayer()->getId()); + desktop->_reconstruction_old_layer_id = desktop->currentLayer()->getId() ? desktop->currentLayer()->getId() : ""; desktop->_layer_hierarchy->setBottom(desktop->currentRoot()); /* @@ -1716,21 +1712,18 @@ _reconstruction_start (SPDesktop * desktop) } /// Called when document rebuild is finished. -static void -_reconstruction_finish (SPDesktop * desktop) +static void _reconstruction_finish(SPDesktop * desktop) { // printf("Desktop, finishing reconstruction\n"); - if (desktop->_reconstruction_old_layer_id == NULL) - return; - - SPObject * newLayer = desktop->namedview->document->getObjectById(desktop->_reconstruction_old_layer_id); - if (newLayer != NULL) - desktop->setCurrentLayer(newLayer); + if ( !desktop->_reconstruction_old_layer_id.empty() ) { + SPObject * newLayer = desktop->namedview->document->getObjectById(desktop->_reconstruction_old_layer_id); + if (newLayer != NULL) { + desktop->setCurrentLayer(newLayer); + } - g_free(desktop->_reconstruction_old_layer_id); - desktop->_reconstruction_old_layer_id = NULL; - // printf("Desktop, finishing reconstruction end\n"); - return; + desktop->_reconstruction_old_layer_id.clear(); + // printf("Desktop, finishing reconstruction end\n"); + } } /** diff --git a/src/desktop.h b/src/desktop.h index a7264e4aa..e4b71ca59 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -138,7 +138,7 @@ public: Inkscape::ObjectHierarchy *_layer_hierarchy; - gchar * _reconstruction_old_layer_id; + Glib::ustring _reconstruction_old_layer_id; sigc::signal _tool_changed; sigc::signal _layer_changed_signal; -- cgit v1.2.3 From ef9e5dcdd29b794de438155f43a0a3374b4d33a3 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 30 Jul 2011 22:21:21 -0700 Subject: Refactored createnewDocFromMem() to be C++ instead of C, removing potential for memory leaks. (bzr r10523) --- src/document.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 4d1d8780a..b699f8afa 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -497,25 +497,21 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) { - SPDocument *doc; - Inkscape::XML::Document *rdoc; - Inkscape::XML::Node *rroot; - gchar *name; - - rdoc = sp_repr_read_mem(buffer, length, SP_SVG_NS_URI); - - /* If it cannot be loaded, return NULL without warning */ - if (rdoc == NULL) return NULL; - - rroot = rdoc->root(); - /* If xml file is not svg, return NULL without warning */ - /* fixme: destroy document */ - if (strcmp(rroot->name(), "svg:svg") != 0) return NULL; - - name = g_strdup_printf(_("Memory document %d"), ++doc_count); + SPDocument *doc = 0; + + Inkscape::XML::Document *rdoc = sp_repr_read_mem(buffer, length, SP_SVG_NS_URI); + if ( rdoc ) { + // Only continue to create a non-null doc if it could be loaded + Inkscape::XML::Node *rroot = rdoc->root(); + if ( strcmp(rroot->name(), "svg:svg") != 0 ) { + // If xml file is not svg, return NULL without warning + // TODO fixme: destroy document + } else { + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); + doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); + } + } - doc = createDoc(rdoc, NULL, NULL, name, keepalive); - g_free(name); return doc; } -- cgit v1.2.3 From 3594386bb9587e461d086e9854b27a337c0d8ff9 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 1 Aug 2011 09:26:10 +0200 Subject: Filters. Removing starting underscores in identifiers. (bzr r10524) --- src/extension/internal/filter/abc.h | 6 +++--- src/extension/internal/filter/blurs.h | 6 +++--- src/extension/internal/filter/bumps.h | 6 +++--- src/extension/internal/filter/color.h | 6 +++--- src/extension/internal/filter/drop-shadow.h | 6 +++--- src/extension/internal/filter/experimental.h | 6 +++--- src/extension/internal/filter/image.h | 6 +++--- src/extension/internal/filter/morphology.h | 6 +++--- src/extension/internal/filter/shadows.h | 6 +++--- src/extension/internal/filter/snow.h | 6 +++--- 10 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h index cf2bc8927..530fd105a 100755 --- a/src/extension/internal/filter/abc.h +++ b/src/extension/internal/filter/abc.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ /* Change the 'ABC' above to be your file name */ /* @@ -875,4 +875,4 @@ SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'ABC' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */ diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 957484cbb..5cad23ba3 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ /* Change the 'BLURS' above to be your file name */ /* @@ -111,4 +111,4 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'BLURS' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 5b0be2b7e..3105dbca1 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ /* Change the 'BUMPS' above to be your file name */ /* @@ -269,4 +269,4 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'BUMPS' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 2df92df29..7be675bec 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ /* Change the 'COLOR' above to be your file name */ /* @@ -1126,4 +1126,4 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'COLOR' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ */ diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h index c80571d67..c2338d194 100644 --- a/src/extension/internal/filter/drop-shadow.h +++ b/src/extension/internal/filter/drop-shadow.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ /* Change the 'DROP_SHADOW' above to be your file name */ /* @@ -147,4 +147,4 @@ DropGlow::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'DROP_SHADOW' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 84b0eea3d..3dbb6a76d 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ /* Change the 'EXPERIMENTAL' above to be your file name */ /* @@ -779,4 +779,4 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'EXPERIMENTAL' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ */ diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index f459466d5..bc052bfc0 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ /* Change the 'IMAGE' above to be your file name */ /* @@ -110,4 +110,4 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'IMAGE' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ */ diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index f52920158..25cef0fca 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ /* Change the 'MORPHOLOGY' above to be your file name */ /* @@ -104,4 +104,4 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'MORPHOLOGY' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */ diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 3c964da34..2339373c1 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ /* Change the 'SHADOWS' above to be your file name */ /* @@ -178,4 +178,4 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'SHADOWS' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ */ diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h index 9a88ab9d2..7a15f9efa 100644 --- a/src/extension/internal/filter/snow.h +++ b/src/extension/internal/filter/snow.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ /* Change the 'SNOW' above to be your file name */ /* @@ -79,4 +79,4 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Inkscape */ /* Change the 'SNOW' below to be your file name */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */ -- cgit v1.2.3 From 066cb3b40bbadba241fddf7b0c585522121e2dc7 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 3 Aug 2011 17:43:05 -0400 Subject: emf import. re-evaluate scaling formulas (Bug 341847, comment 7) (bzr r10526) --- src/extension/internal/emf-win32-inout.cpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 646b33507..e4997fce1 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -327,7 +327,7 @@ pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py) double ppy = _pix_y_to_point(d, py); double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx; - x *= d->dc[d->level].ScaleOutX ? d->dc[d->level].ScaleOutX : device_scale; + x *= device_scale; return x; } @@ -339,7 +339,7 @@ pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py) double ppy = _pix_y_to_point(d, py); double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy; - y *= d->dc[d->level].ScaleOutY ? d->dc[d->level].ScaleOutY : device_scale; + y *= device_scale; return y; } @@ -351,9 +351,9 @@ pix_to_size_point(PEMF_CALLBACK_DATA d, double px) double ppy = 0; double dx = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21; - dx *= d->dc[d->level].ScaleOutX ? d->dc[d->level].ScaleOutX : device_scale; + dx *= device_scale; double dy = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22; - dy *= d->dc[d->level].ScaleOutY ? d->dc[d->level].ScaleOutY : device_scale; + dy *= device_scale; double tmp = sqrt(dx * dx + dy * dy); return tmp; @@ -1056,15 +1056,6 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * d->dc[d->level].ScaleInY = 1; } - if (d->dc[d->level].sizeView.cx && d->dc[d->level].sizeView.cy) { - d->dc[d->level].ScaleOutX = (double) d->dc[d->level].PixelsOutX / (double) d->dc[d->level].sizeView.cx; - d->dc[d->level].ScaleOutY = (double) d->dc[d->level].PixelsOutY / (double) d->dc[d->level].sizeView.cy; - } - else { - d->dc[d->level].ScaleOutX = device_scale; - d->dc[d->level].ScaleOutY = device_scale; - } - break; } case EMR_SETWINDOWORGEX: @@ -1107,15 +1098,6 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * d->dc[d->level].ScaleInY = 1; } - if (d->dc[d->level].sizeView.cx && d->dc[d->level].sizeView.cy) { - d->dc[d->level].ScaleOutX = (double) d->dc[d->level].PixelsOutX / (double) d->dc[d->level].sizeView.cx; - d->dc[d->level].ScaleOutY = (double) d->dc[d->level].PixelsOutY / (double) d->dc[d->level].sizeView.cy; - } - else { - d->dc[d->level].ScaleOutX = device_scale; - d->dc[d->level].ScaleOutY = device_scale; - } - break; } case EMR_SETVIEWPORTORGEX: -- cgit v1.2.3 From e13a15e651a5fe1216cfab3eaa647b47fc1edc71 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 5 Aug 2011 15:57:22 +0200 Subject: Filters. Adding opacity support in Bump filter. Filters. New Image blur CPF. Filters. Blurs and ABC groups reorganization. (bzr r10527) --- src/extension/internal/filter/abc.h | 59 --------- src/extension/internal/filter/blurs.h | 179 +++++++++++++++++++++++++++ src/extension/internal/filter/bumps.h | 6 +- src/extension/internal/filter/filter-all.cpp | 3 +- 4 files changed, 185 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h index 530fd105a..832fb90c2 100755 --- a/src/extension/internal/filter/abc.h +++ b/src/extension/internal/filter/abc.h @@ -8,7 +8,6 @@ * Nicolas Dufour (UI) * * Basic filters - * Blur * Clean edges * Color shift * Diffuse light @@ -35,64 +34,6 @@ namespace Extension { namespace Internal { namespace Filter { -/** - \brief Custom predefined Blur filter. - - Simple horizontal and vertical blur - - Filter's parameters: - * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation) - * Vertical blur (0.01->100., default 2) -> blur (stdDeviation) -*/ - -class Blur : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Blur ( ) : Filter() { }; - virtual ~Blur ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Blur, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Blur\n" - "2\n" - "2\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Simple vertical and horizontal blur effect") "\n" - "\n" - "\n", new Blur()); - }; - -}; - -gchar const * -Blur::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream hblur; - std::ostringstream vblur; - - hblur << ext->get_param_float("hblur"); - vblur << ext->get_param_float("vblur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n", hblur.str().c_str(), vblur.str().c_str()); - - return _filter; -}; /* Blur filter */ - /** \brief Custom predefined Clean edges filter. diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 5cad23ba3..0fa15dfe6 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -8,7 +8,9 @@ * Nicolas Dufour (UI) * * Blur filters + * Blur * Cross blur + * Image blur * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -25,6 +27,65 @@ namespace Extension { namespace Internal { namespace Filter { +/** + \brief Custom predefined Blur filter. + + Simple horizontal and vertical blur + + Filter's parameters: + * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation) + * Vertical blur (0.01->100., default 2) -> blur (stdDeviation) +*/ + +class Blur : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Blur ( ) : Filter() { }; + virtual ~Blur ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Blur, custom (Blurs)") "\n" + "org.inkscape.effect.filter.Blur\n" + "2\n" + "2\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Simple vertical and horizontal blur effect") "\n" + "\n" + "\n", new Blur()); + }; + +}; + +gchar const * +Blur::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream hblur; + std::ostringstream vblur; + + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", hblur.str().c_str(), vblur.str().c_str()); + + return _filter; +}; /* Blur filter */ + + /** \brief Custom predefined Cross blur filter. @@ -105,6 +166,124 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Cross blur filter */ +/** + \brief Custom predefined Image blur filter. + + Blur eroded by white or transparency + + Filter's parameters: + * Horizontal blur (0.01->10., default 3) -> blur (stdDeviation) + * Vertical blur (0.01->10., default 3) -> blur (stdDeviation) + * Dilatation (n-1th value, 0.->100., default 6) -> colormatrix2 (matrix) + * Erosion (nth value, 0.->100., default 2) -> colormatrix2 (matrix) + * Opacity (0.->1., default 1.) -> composite1 (k2) + * Background color (guint, default -1) -> flood (flood-opacity, flood-color) + * Blend type (enum, default normal) -> blend (mode) + * Blend to background (boolean, default false) -> blend (false: in2="flood", true: in2="BackgroundImage") + +*/ + +class ImageBlur : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ImageBlur ( ) : Filter() { }; + virtual ~ImageBlur ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Image blur, custom (Blurs)") "\n" + "org.inkscape.effect.filter.ImageBlur\n" + "\n" + "\n" + "3\n" + "3\n" + "6\n" + "2\n" + "1\n" + "\n" + "\n" + "-1\n" + "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "false\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Blur eroded by white or transparency") "\n" + "\n" + "\n", new ImageBlur()); + }; + +}; + +gchar const * +ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream opacity; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream blend; + std::ostringstream background; + + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + dilat << ext->get_param_float("dilat"); + erosion << -ext->get_param_float("erosion"); + opacity << ext->get_param_float("opacity"); + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + blend << ext->get_param_enum("blend"); + + if (ext->get_param_bool("background")) { + background << "BackgroundImage" ; + } else { + background << "flood" ; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + hblur.str().c_str(), vblur.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), + background.str().c_str(), blend.str().c_str(), opacity.str().c_str()); + + return _filter; +}; /* Image blur filter */ + + + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 3105dbca1..3591377be 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -172,6 +172,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream floodRed; std::ostringstream floodGreen; std::ostringstream floodBlue; + std::ostringstream floodAlpha; std::ostringstream colorize; @@ -231,6 +232,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) floodRed << ((imageColor >> 24) & 0xff); floodGreen << ((imageColor >> 16) & 0xff); floodBlue << ((imageColor >> 8) & 0xff); + floodAlpha << (imageColor & 0xff) / 255.0F; if (ext->get_param_bool("colorize")) { colorize << "flood" ; @@ -248,14 +250,14 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) "%s\n" "%s\n" "%s\n" - "\n" + "\n" "\n" "\n" "\n" "\n", simplifyImage.str().c_str(), bumpSource.str().c_str(), red.str().c_str(), green.str().c_str(), blue.str().c_str(), crop.str().c_str(), simplifyBump.str().c_str(), lightStart.str().c_str(), lightOptions.str().c_str(), lightEnd.str().c_str(), - floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), + floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(), colorize.str().c_str(), blend.str().c_str()); return _filter; diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 210d1d87a..b451ac619 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -37,7 +37,6 @@ Filter::filters_all (void ) /* Experimental custom predefined filters */ // ABC - Blur::init(); CleanEdges::init(); ColorShift::init(); DiffuseLight::init(); @@ -50,7 +49,9 @@ Filter::filters_all (void ) SpecularLight::init(); // Blurs + Blur::init(); CrossBlur::init(); + ImageBlur::init(); // Bumps Bump::init(); -- cgit v1.2.3 From 4dd33aa4d5c57706c7f64f63391174954160a308 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 6 Aug 2011 14:18:32 +0200 Subject: Rewrite NRArenaItem hierarchy into C++ (bzr r10347.1.21) --- src/2geom/affine.cpp | 12 + src/2geom/affine.h | 10 +- src/2geom/coord.h | 38 + src/2geom/generic-interval.h | 8 +- src/2geom/generic-rect.h | 105 ++- src/2geom/interval.h | 3 - src/2geom/linear.h | 2 +- src/2geom/rect.h | 1 - src/2geom/transforms.h | 30 +- src/context-fns.h | 1 + src/desktop.cpp | 89 ++- src/desktop.h | 12 +- src/dialogs/clonetiler.cpp | 18 +- src/display/Makefile_insert | 22 +- src/display/canvas-arena.cpp | 95 +-- src/display/canvas-arena.h | 15 +- src/display/display-forward.h | 8 + src/display/drawing-group.cpp | 141 ++++ src/display/drawing-group.h | 61 ++ src/display/drawing-image.cpp | 263 ++++++ src/display/drawing-image.h | 66 ++ src/display/drawing-item.cpp | 620 ++++++++++++++ src/display/drawing-item.h | 168 ++++ src/display/drawing-shape.cpp | 340 ++++++++ src/display/drawing-shape.h | 64 ++ src/display/drawing-text.cpp | 275 +++++++ src/display/drawing-text.h | 84 ++ src/display/grayscale.cpp | 2 +- src/display/nr-arena-forward.h | 51 -- src/display/nr-arena-glyphs.cpp | 439 ---------- src/display/nr-arena-glyphs.h | 108 --- src/display/nr-arena-group.cpp | 300 ------- src/display/nr-arena-group.h | 61 -- src/display/nr-arena-image.cpp | 390 --------- src/display/nr-arena-image.h | 66 -- src/display/nr-arena-item.cpp | 932 ---------------------- src/display/nr-arena-item.h | 205 ----- src/display/nr-arena-shape.cpp | 565 ------------- src/display/nr-arena-shape.h | 72 -- src/display/nr-arena.cpp | 23 +- src/display/nr-arena.h | 23 +- src/display/nr-filter-diffuselighting.cpp | 1 - src/display/nr-filter-image.cpp | 19 +- src/display/nr-filter-slot.cpp | 3 +- src/display/nr-filter-slot.h | 7 +- src/display/nr-filter.cpp | 28 +- src/display/nr-filter.h | 11 +- src/display/rendermode.h | 8 +- src/document.cpp | 14 +- src/extension/internal/cairo-png-out.cpp | 3 +- src/extension/internal/cairo-ps-out.cpp | 1 - src/extension/internal/cairo-render-context.cpp | 7 +- src/extension/internal/cairo-renderer-pdf-out.cpp | 1 - src/extension/internal/cairo-renderer.cpp | 7 +- src/extension/internal/latex-pstricks-out.cpp | 4 +- src/extension/print.h | 10 +- src/flood-context.cpp | 76 +- src/helper/Makefile_insert | 1 - src/helper/pixbuf-ops.cpp | 55 +- src/helper/png-write.cpp | 15 +- src/interface.cpp | 8 +- src/libnrtype/Layout-TNG-Output.cpp | 17 +- src/libnrtype/Layout-TNG.h | 5 +- src/marker.cpp | 34 +- src/marker.h | 2 +- src/print.cpp | 15 +- src/print.h | 1 + src/select-context.cpp | 18 +- src/sp-clippath.cpp | 34 +- src/sp-clippath.h | 4 +- src/sp-flowtext.cpp | 39 +- src/sp-flowtext.h | 4 +- src/sp-image.cpp | 29 +- src/sp-item-group.cpp | 69 +- src/sp-item-group.h | 4 +- src/sp-item.cpp | 158 ++-- src/sp-item.h | 15 +- src/sp-mask.cpp | 32 +- src/sp-mask.h | 4 +- src/sp-pattern.cpp | 19 +- src/sp-root.cpp | 14 +- src/sp-shape.cpp | 63 +- src/sp-shape.h | 4 +- src/sp-switch.cpp | 10 +- src/sp-switch.h | 2 +- src/sp-symbol.cpp | 16 +- src/sp-text.cpp | 43 +- src/sp-text.h | 2 +- src/sp-tref.cpp | 1 - src/sp-use.cpp | 33 +- src/svg-view.cpp | 9 +- src/trace/trace.cpp | 53 +- src/ui/cache/svg_preview_cache.cpp | 19 +- src/ui/cache/svg_preview_cache.h | 23 +- src/ui/dialog/icon-preview.cpp | 4 +- src/widgets/desktop-widget.cpp | 4 +- src/widgets/icon.cpp | 28 +- src/widgets/stroke-style.cpp | 7 +- 98 files changed, 2919 insertions(+), 3986 deletions(-) create mode 100644 src/display/drawing-group.cpp create mode 100644 src/display/drawing-group.h create mode 100644 src/display/drawing-image.cpp create mode 100644 src/display/drawing-image.h create mode 100644 src/display/drawing-item.cpp create mode 100644 src/display/drawing-item.h create mode 100644 src/display/drawing-shape.cpp create mode 100644 src/display/drawing-shape.h create mode 100644 src/display/drawing-text.cpp create mode 100644 src/display/drawing-text.h delete mode 100644 src/display/nr-arena-forward.h delete mode 100644 src/display/nr-arena-glyphs.cpp delete mode 100644 src/display/nr-arena-glyphs.h delete mode 100644 src/display/nr-arena-group.cpp delete mode 100644 src/display/nr-arena-group.h delete mode 100644 src/display/nr-arena-image.cpp delete mode 100644 src/display/nr-arena-image.h delete mode 100644 src/display/nr-arena-item.cpp delete mode 100644 src/display/nr-arena-item.h delete mode 100644 src/display/nr-arena-shape.cpp delete mode 100644 src/display/nr-arena-shape.h (limited to 'src') diff --git a/src/2geom/affine.cpp b/src/2geom/affine.cpp index 2a1f18d77..c31b9ba90 100644 --- a/src/2geom/affine.cpp +++ b/src/2geom/affine.cpp @@ -410,6 +410,9 @@ Affine &Affine::operator*=(Affine const &o) { } //TODO: What's this!?! +/** Given a matrix m such that unit_circle = m*x, this returns the + * quadratic form x*A*x = 1. + * @relates Affine */ Affine elliptic_quadratic_form(Affine const &m) { double od = m[0] * m[1] + m[2] * m[3]; Affine ret (m[0]*m[0] + m[1]*m[1], od, @@ -469,6 +472,15 @@ Eigen::Eigen(double m[2][2]) { vectors[i] = Point(0,0); } +/** @brief Nearness predicate for affine transforms + * @returns True if all entries of matrices are within eps of each other */ +bool are_near(Affine const &a, Affine const &b, Coord eps) +{ + return are_near(a[0], b[0], eps) && are_near(a[1], b[1], eps) && + are_near(a[2], b[2], eps) && are_near(a[3], b[3], eps) && + are_near(a[4], b[4], eps) && are_near(a[5], b[5], eps); +} + } //namespace Geom /* diff --git a/src/2geom/affine.h b/src/2geom/affine.h index d7a7a0692..22f8bd9f5 100644 --- a/src/2geom/affine.h +++ b/src/2geom/affine.h @@ -200,9 +200,8 @@ inline std::ostream &operator<< (std::ostream &out_file, const Geom::Affine &m) return out_file; } -/** Given a matrix m such that unit_circle = m*x, this returns the - * quadratic form x*A*x = 1. - * @relates Affine */ +// Affine factories +Affine from_basis(const Point x_basis, const Point y_basis, const Point offset=Point(0,0)); Affine elliptic_quadratic_form(Affine const &m); /** Given a matrix (ignoring the translation) this returns the eigen @@ -215,9 +214,6 @@ public: Eigen(double M[2][2]); }; -// Affine factories -Affine from_basis(const Point x_basis, const Point y_basis, const Point offset=Point(0,0)); - /** @brief Create an identity matrix. * This is a convenience function identical to Affine::identity(). */ inline Affine identity() { @@ -239,6 +235,8 @@ inline Affine Affine::identity() { return ret; // allow NRVO } +bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON); + } // end namespace Geom #endif // LIB2GEOM_SEEN_AFFINE_H diff --git a/src/2geom/coord.h b/src/2geom/coord.h index f7bf2c5d0..90e776665 100644 --- a/src/2geom/coord.h +++ b/src/2geom/coord.h @@ -34,6 +34,7 @@ #include #include +#include #include <2geom/forward.h> namespace Geom { @@ -62,6 +63,9 @@ inline bool rel_error_bound(Coord a, Coord b, double eps=EPSILON) { return a <= template struct CoordTraits {}; +// NOTE: operator helpers for Rect and Interval are defined here. +// This is to avoid increasing their size through multiple inheritance. + template<> struct CoordTraits { typedef IntPoint PointType; @@ -69,6 +73,22 @@ struct CoordTraits { typedef OptIntInterval OptIntervalType; typedef IntRect RectType; typedef OptIntRect OptRectType; + + typedef + boost::equality_comparable< IntervalType + , boost::additive< IntervalType + , boost::additive< IntervalType, IntCoord + , boost::orable< IntervalType + > > > > + IntervalOps; + + typedef + boost::equality_comparable< RectType + , boost::orable< RectType + , boost::orable< RectType, OptRectType + , boost::additive< RectType, PointType + > > > > + RectOps; }; template<> @@ -78,6 +98,24 @@ struct CoordTraits { typedef OptInterval OptIntervalType; typedef Rect RectType; typedef OptRect OptRectType; + + typedef + boost::equality_comparable< IntervalType + , boost::additive< IntervalType + , boost::multipliable< IntervalType + , boost::orable< IntervalType + , boost::arithmetic< IntervalType, Coord + > > > > > + IntervalOps; + + typedef + boost::equality_comparable< RectType + , boost::orable< RectType + , boost::orable< RectType, OptRectType + , boost::additive< RectType, PointType + , boost::multipliable< RectType, Affine + > > > > > + RectOps; }; } // end namespace Geom diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h index a32e97d4b..0212da676 100644 --- a/src/2geom/generic-interval.h +++ b/src/2geom/generic-interval.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include <2geom/coord.h> namespace Geom { @@ -47,11 +47,7 @@ class GenericOptInterval; */ template class GenericInterval - : boost::equality_comparable< GenericInterval - , boost::additive< GenericInterval - , boost::additive< GenericInterval, C - , boost::orable< GenericInterval - > > > > + : CoordTraits::IntervalOps { typedef GenericInterval Self; protected: diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index 2db30dfa9..efe499809 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -42,6 +42,7 @@ #include #include +#include <2geom/coord.h> namespace Geom { @@ -54,11 +55,7 @@ class GenericOptRect; */ template class GenericRect - : boost::additive< typename CoordTraits::RectType, typename CoordTraits::PointType - , boost::equality_comparable< typename CoordTraits::RectType - , boost::orable< typename CoordTraits::RectType - , boost::orable< typename CoordTraits::RectType, typename CoordTraits::OptRectType - > > > > + : CoordTraits::RectOps { typedef typename CoordTraits::IntervalType CInterval; typedef typename CoordTraits::PointType CPoint; @@ -131,15 +128,22 @@ public: /// @name Inspect dimensions. /// @{ - CInterval &operator[](unsigned i) { return f[i]; } + CInterval &operator[](unsigned i) { return f[i]; } CInterval const &operator[](unsigned i) const { return f[i]; } + CInterval &operator[](Dim2 d) { return f[d]; } + CInterval const &operator[](Dim2 d) const { return f[d]; } + /** @brief Get the corner of the rectangle with smallest coordinate values. + * In 2Geom standard coordinate system, this means upper left. */ CPoint min() const { return CPoint(f[X].min(), f[Y].min()); } + /** @brief Get the corner of the rectangle with largest coordinate values. + * In 2Geom standard coordinate system, this means lower right. */ CPoint max() const { return CPoint(f[X].max(), f[Y].max()); } /** @brief Return the n-th corner of the rectangle. - * If the Y axis grows upwards, this returns corners in clockwise order - * starting from the lower left. If Y grows downwards, it returns the corners - * in counter-clockwise order starting from the upper left. */ + * Returns corners in the direction of growing angles, starting from + * the one given by min(). For the standard coordinate system used + * in 2Geom (+Y downwards), this means clockwise starting from + * the upper left. */ CPoint corner(unsigned i) const { switch(i % 4) { case 0: return CPoint(f[X].min(), f[Y].min()); @@ -196,10 +200,10 @@ public: } /** @brief Check whether the rectangles have any common points. - * A non-empty rectangle will not intersect empty rectangles. */ + * Empty rectangles will not intersect with any other rectangle. */ inline bool intersects(OptCRect const &r) const; /** @brief Check whether the rectangle includes all points in the given rectangle. - * A non-empty rectangle will contain any empty rectangle. */ + * Empty rectangles will be contained in any non-empty rectangle. */ inline bool contains(OptCRect const &r) const; /** @brief Check whether the given point is within the rectangle. */ @@ -224,11 +228,11 @@ public: void expandTo(CPoint const &p) { f[X].expandTo(p[X]); f[Y].expandTo(p[Y]); } - /** @brief Enlarge the rectangle to contain the given rectangle. */ + /** @brief Enlarge the rectangle to contain the argument. */ void unionWith(CRect const &b) { f[X].unionWith(b[X]); f[Y].unionWith(b[Y]); } - /** @brief Enlarge the rectangle to contain the given rectangle. + /** @brief Enlarge the rectangle to contain the argument. * Unioning with an empty rectangle results in no changes. */ void unionWith(OptCRect const &b); @@ -244,7 +248,8 @@ public: * This will expand the width by the X coordinate of the point in both directions * and the height by Y coordinate of the point. Negative coordinate values will * shrink the rectangle. If -p[X] is larger than half of the width, - * the X interval will contain only the X coordinate of the midpoint; same for height. */ + * the X interval will contain only the X coordinate of the midpoint; + * same for height. */ void expandBy(CPoint const &p) { f[X].expandBy(p[X]); f[Y].expandBy(p[Y]); } @@ -297,30 +302,66 @@ class GenericOptRect typedef typename CoordTraits::OptRectType OptCRect; typedef boost::optional Base; public: + /// @name Create potentially empty rectangles. + /// @{ GenericOptRect() : Base() {} GenericOptRect(GenericRect const &a) : Base(CRect(a)) {} GenericOptRect(CPoint const &a, CPoint const &b) : Base(CRect(a, b)) {} - /** - * Creates an empty OptRect when one of the argument intervals is empty. - */ + /// Creates an empty OptRect when one of the argument intervals is empty. GenericOptRect(OptCInterval const &x_int, OptCInterval const &y_int) { if (x_int && y_int) { *this = CRect(*x_int, *y_int); } // else, stay empty. } + /** @brief Create a rectangle from a range of points. + * The resulting rectangle will contain all ponts from the range. + * If the range contains no points, the result will be an empty rectangle. + * The return type of iterators must be convertible to the corresponding + * point type (Point or IntPoint). + * @param start Beginning of the range + * @param end End of the range + * @return Rectangle that contains all points from [start, end). */ + template + static OptCRect from_range(InputIterator start, InputIterator end) { + OptCRect result; + for (; start != end; ++start) { + result.expandTo(*start); + } + return result; + } + /// @} + /// @name Check other rectangles and points for inclusion. + /// @{ /** @brief Check for emptiness. */ inline bool isEmpty() const { return !*this; }; - + /** @brief Check whether the rectangles have any common points. + * Empty rectangles will not intersect with any other rectangle. */ bool intersects(CRect const &r) const { return r.intersects(*this); } + /** @brief Check whether the rectangle includes all points in the given rectangle. + * Empty rectangles will be contained in any non-empty rectangle. */ bool contains(CRect const &r) const { return *this && (*this)->contains(r); } + /** @brief Check whether the rectangles have any common points. + * Empty rectangles will not intersect with any other rectangle. + * Two empty rectangles will not intersect each other. */ bool intersects(OptCRect const &r) const { return *this && (*this)->intersects(r); } + /** @brief Check whether the rectangle includes all points in the given rectangle. + * Empty rectangles will be contained in any non-empty rectangle. + * An empty rectangle will not contain other empty rectangles. */ bool contains(OptCRect const &r) const { return *this && (*this)->contains(r); } + /** @brief Check whether the given point is within the rectangle. + * An empty rectangle will not contain any points. */ bool contains(CPoint const &p) const { return *this && (*this)->contains(p); } + /// @} + /// @name Modify the potentially empty rectangle. + /// @{ + /** @brief Enlarge the rectangle to contain the argument. + * If this rectangle is empty, after callng this method it will + * be equal to the argument. */ void unionWith(CRect const &b) { if (*this) { (*this)->unionWith(b); @@ -328,9 +369,16 @@ public: *this = b; } } + /** @brief Enlarge the rectangle to contain the argument. + * Unioning with an empty rectangle results in no changes. + * If this rectangle is empty, after calling this method it will + * be equal to the argument. */ void unionWith(OptCRect const &b) { if (b) unionWith(*b); } + /** @brief Leave only the area overlapping with the argument. + * If the rectangles do not have any points in common, after calling + * this method the rectangle will be empty. */ void intersectWith(CRect const &b) { if (!*this) return; OptCInterval x = (**this)[X] & b[X], y = (**this)[Y] & b[Y]; @@ -340,6 +388,9 @@ public: *(static_cast(this)) = boost::none; } } + /** @brief Leave only the area overlapping with the argument. + * If the argument is empty or the rectangles do not have any points + * in common, after calling this method the rectangle will be empty. */ void intersectWith(OptCRect const &b) { if (b) { intersectWith(*b); @@ -347,18 +398,36 @@ public: *(static_cast(this)) = boost::none; } } + /** @brief Create or enlarge the rectangle to contain the given point. + * If the rectangle is empty, after calling this method it will be non-empty + * and it will contain only the given point. */ + void expandTo(CPoint const &p) { + if (*this) { + (*this).expandTo(p); + } else { + *this = CRect(p, p); + } + } + /// @} + + /// @name Operators + /// @{ + /** @brief Union with @a b */ GenericOptRect &operator|=(OptCRect const &b) { unionWith(b); return *this; } + /** @brief Intersect with @a b */ GenericOptRect &operator&=(CRect const &b) { intersectWith(b); return *this; } + /** @brief Intersect with @a b */ GenericOptRect &operator&=(OptCRect const &b) { intersectWith(b); return *this; } + /// @} }; template diff --git a/src/2geom/interval.h b/src/2geom/interval.h index e95da4811..711eaa5e2 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -63,9 +63,6 @@ typedef GenericOptInterval OptInterval; */ class Interval : public GenericInterval - , boost::multipliable< Interval - , boost::multiplicative< Interval, Coord - > > { typedef GenericInterval Base; public: diff --git a/src/2geom/linear.h b/src/2geom/linear.h index df6dd9904..448ab3bb7 100644 --- a/src/2geom/linear.h +++ b/src/2geom/linear.h @@ -55,7 +55,7 @@ class SBasis; class Linear{ public: double a[2]; - Linear() {} + Linear() { a[0] = 0; a[1] = 0; } Linear(double aa, double b) {a[0] = aa; a[1] = b;} Linear(double aa) {a[0] = aa; a[1] = aa;} diff --git a/src/2geom/rect.h b/src/2geom/rect.h index f7d331523..b79a0a04f 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -59,7 +59,6 @@ typedef GenericOptRect OptRect; */ class Rect : public GenericRect - , boost::multipliable< Rect, Affine > { typedef GenericRect Base; public: diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 5627e8b6f..eaf869056 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -45,10 +45,11 @@ namespace Geom { * @ingroup Concepts */ template struct TransformConcept { - T t; + T t, t2; Affine m; Point p; bool bool_; + Coord epsilon; void constraints() { m = t; //implicit conversion m *= t; @@ -63,6 +64,8 @@ struct TransformConcept { bool_ = (t != t); t = T::identity(); t = t.inverse(); + bool_ = are_near(t, t2); + bool_ = are_near(t, t2, epsilon); } }; @@ -130,6 +133,10 @@ public: friend class Point; }; +inline bool are_near(Translate const &a, Translate const &b, Coord eps=EPSILON) { + return are_near(a[X], b[X], eps) && are_near(a[Y], b[Y], eps); +} + /** @brief Scaling from the origin. * During scaling, the point (0,0) will not move. To obtain a scale with a different * invariant point, combine with translation to the origin and back. @@ -164,6 +171,10 @@ public: friend class Point; }; +inline bool are_near(Scale const &a, Scale const &b, Coord eps=EPSILON) { + return are_near(a[X], b[X], eps) && are_near(a[Y], b[Y], eps); +} + /** @brief Rotation around the origin. * Combine with translations to the origin and back to get a rotation around a different point. * @ingroup Transforms */ @@ -207,6 +218,10 @@ public: friend class Point; }; +inline bool are_near(Rotate const &a, Rotate const &b, Coord eps=EPSILON) { + return are_near(a[X], b[X], eps) && are_near(a[Y], b[Y], eps); +} + /** @brief Common base for shearing transforms. * This class is an implementation detail and should not be used directly. * @ingroup Transforms */ @@ -241,6 +256,10 @@ public: operator Affine() const { Affine ret(1, 0, f, 1, 0, 0); return ret; } }; +inline bool are_near(HShear const &a, HShear const &b, Coord eps=EPSILON) { + return are_near(a.factor(), b.factor(), eps); +} + /** @brief Vertical shearing. * Points on the Y axis will not move. Combine with translations to get a shear * with a different invariant line. @@ -253,6 +272,10 @@ public: operator Affine() const { Affine ret(1, f, 0, 1, 0, 0); return ret; } }; +inline bool are_near(VShear const &a, VShear const &b, Coord eps=EPSILON) { + return are_near(a.factor(), b.factor(), eps); +} + /** @brief Combination of a translation and uniform scale. * The translation part is applied first, then the result is scaled from the new origin. * This way when the class is used to accumulate a zoom transform, trans always points @@ -295,6 +318,11 @@ public: friend class Affine; }; +inline bool are_near(Zoom const &a, Zoom const &b, Coord eps=EPSILON) { + return are_near(a.scale(), b.scale(), eps) && + are_near(a.translation(), b.translation(), eps); +} + /** @brief Specialization of exponentiation for Scale. * @relates Scale */ template<> diff --git a/src/context-fns.h b/src/context-fns.h index c86640aba..c56c67a27 100644 --- a/src/context-fns.h +++ b/src/context-fns.h @@ -16,6 +16,7 @@ struct SPDesktop; struct SPItem; +struct SPEventContext; const double goldenratio = 1.61803398874989484820; // golden ratio diff --git a/src/desktop.cpp b/src/desktop.cpp index 5e968b08b..cceee9499 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -59,55 +59,56 @@ #include <2geom/transforms.h> #include <2geom/rect.h> -#include "macros.h" -#include "inkscape-private.h" -#include "desktop.h" + +#include "box3d-context.h" +#include "color.h" #include "desktop-events.h" +#include "desktop.h" #include "desktop-handles.h" -#include "document.h" -#include "message-stack.h" -#include "selection.h" -#include "select-context.h" -#include "sp-namedview.h" -#include "color.h" -#include "sp-item-group.h" -#include "preferences.h" -#include "object-hierarchy.h" -#include "helper/units.h" +#include "desktop-style.h" +#include "device-manager.h" #include "display/canvas-arena.h" -#include "display/nr-arena.h" -#include "display/gnome-canvas-acetate.h" -#include "display/sodipodi-ctrlrect.h" -#include "display/sp-canvas-util.h" +#include "display/canvas-grid.h" #include "display/canvas-temporary-item-list.h" +#include "display/drawing-group.h" +#include "display/gnome-canvas-acetate.h" +#include "display/nr-arena.h" #include "display/snap-indicator.h" +#include "display/sodipodi-ctrlrect.h" #include "display/sp-canvas-group.h" -#include "ui/dialog/dialog-manager.h" -#include "xml/repr.h" -#include "message-context.h" -#include "device-manager.h" +#include "display/sp-canvas.h" +#include "display/sp-canvas-util.h" +#include "document.h" +#include "event-log.h" +#include "helper/units.h" +#include "inkscape-private.h" #include "layer-fns.h" #include "layer-manager.h" +#include "macros.h" +#include "message-context.h" +#include "message-stack.h" +#include "object-hierarchy.h" +#include "preferences.h" #include "resource-manager.h" -#include "event-log.h" -#include "display/canvas-grid.h" -#include "widgets/desktop-widget.h" -#include "box3d-context.h" -#include "desktop-style.h" +#include "select-context.h" +#include "selection.h" #include "sp-item-group.h" +#include "sp-item-group.h" +#include "sp-namedview.h" #include "sp-root.h" +#include "ui/dialog/dialog-manager.h" +#include "widgets/desktop-widget.h" +#include "xml/repr.h" // TODO those includes are only for node tool quick zoom. Remove them after fixing it. #include "ui/tool/node-tool.h" #include "ui/tool/control-point-selection.h" -#include "display/sp-canvas.h" - namespace Inkscape { namespace XML { class Node; }} // Callback declarations static void _onSelectionChanged (Inkscape::Selection *selection, SPDesktop *desktop); -static gint _arena_handler (SPCanvasArena *arena, NRArenaItem *ai, GdkEvent *event, SPDesktop *desktop); +static gint _arena_handler (SPCanvasArena *arena, Inkscape::DrawingItem *ai, GdkEvent *event, SPDesktop *desktop); static void _layer_activated(SPObject *layer, SPDesktop *desktop); static void _layer_deactivated(SPObject *layer, SPDesktop *desktop); static void _layer_hierarchy_changed(SPObject *top, SPObject *bottom, SPDesktop *desktop); @@ -158,7 +159,7 @@ SPDesktop::SPDesktop() : _layer_hierarchy( 0 ), _reconstruction_old_layer_id( 0 ), _display_mode(Inkscape::RENDERMODE_NORMAL), - _display_color_mode(Inkscape::COLORRENDERMODE_NORMAL), + _display_color_mode(Inkscape::COLORMODE_NORMAL), _widget( 0 ), _inkscape( 0 ), _guides_message_context( 0 ), @@ -285,12 +286,12 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); - NRArenaItem *ai = document->getRoot()->invoke_show( + Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - nr_arena_item_add_child (SP_CANVAS_ARENA (drawing)->root, ai, NULL); + SP_CANVAS_ARENA (drawing)->root->prependChild(ai); } namedview->show(this); @@ -460,8 +461,8 @@ void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) { sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw _widget->setTitle( sp_desktop_document(this)->getName() ); } -void SPDesktop::_setDisplayColorMode(Inkscape::ColorRenderMode mode) { - SP_CANVAS_ARENA (drawing)->arena->colorrendermode = mode; +void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) { + SP_CANVAS_ARENA (drawing)->arena->colormode = mode; canvas->colorrendermode = mode; _display_color_mode = mode; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw @@ -485,15 +486,15 @@ void SPDesktop::displayModeToggle() { } void SPDesktop::displayColorModeToggle() { switch (_display_color_mode) { - case Inkscape::COLORRENDERMODE_NORMAL: - _setDisplayColorMode(Inkscape::COLORRENDERMODE_GRAYSCALE); + case Inkscape::COLORMODE_NORMAL: + _setDisplayColorMode(Inkscape::COLORMODE_GRAYSCALE); break; - case Inkscape::COLORRENDERMODE_GRAYSCALE: - _setDisplayColorMode(Inkscape::COLORRENDERMODE_NORMAL); + case Inkscape::COLORMODE_GRAYSCALE: + _setDisplayColorMode(Inkscape::COLORMODE_NORMAL); break; -// case Inkscape::COLORRENDERMODE_PRINT_COLORS_PREVIEW: +// case Inkscape::COLORMODE_PRINT_COLORS_PREVIEW: default: - _setDisplayColorMode(Inkscape::COLORRENDERMODE_NORMAL); + _setDisplayColorMode(Inkscape::COLORMODE_NORMAL); } } @@ -1562,7 +1563,7 @@ SPDesktop::setDocument (SPDocument *doc) /// are surely more safe methods to accomplish this. // TODO since the comment had reversed logic, check the intent of this block of code: if (drawing) { - NRArenaItem *ai = 0; + Inkscape::DrawingItem *ai = 0; namedview = sp_document_namedview (doc, NULL); _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); @@ -1573,7 +1574,7 @@ SPDesktop::setDocument (SPDocument *doc) dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - nr_arena_item_add_child (SP_CANVAS_ARENA (drawing)->root, ai, NULL); + SP_CANVAS_ARENA (drawing)->root->prependChild(ai); } namedview->show(this); /* Ugly hack */ @@ -1662,10 +1663,10 @@ _onSelectionChanged * \todo fixme */ static gint -_arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPDesktop *desktop) +_arena_handler (SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPDesktop *desktop) { if (ai) { - SPItem *spi = (SPItem*)NR_ARENA_ITEM_GET_DATA (ai); + SPItem *spi = (SPItem*) ai->data(); return sp_event_context_item_handler (desktop->event_context, spi, event); } else { return sp_event_context_root_handler (desktop->event_context, event); diff --git a/src/desktop.h b/src/desktop.h index a7264e4aa..26c308f5d 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -211,19 +211,19 @@ public: Inkscape::RenderMode _display_mode; Inkscape::RenderMode getMode() const { return _display_mode; } - void _setDisplayColorMode(Inkscape::ColorRenderMode mode); + void _setDisplayColorMode(Inkscape::ColorMode mode); void setDisplayColorModeNormal() { - _setDisplayColorMode(Inkscape::COLORRENDERMODE_NORMAL); + _setDisplayColorMode(Inkscape::COLORMODE_NORMAL); } void setDisplayColorModeGrayscale() { - _setDisplayColorMode(Inkscape::COLORRENDERMODE_GRAYSCALE); + _setDisplayColorMode(Inkscape::COLORMODE_GRAYSCALE); } // void setDisplayColorModePrintColorsPreview() { -// _setDisplayColorMode(Inkscape::COLORRENDERMODE_PRINT_COLORS_PREVIEW); +// _setDisplayColorMode(Inkscape::COLORMODE_PRINT_COLORS_PREVIEW); // } void displayColorModeToggle(); - Inkscape::ColorRenderMode _display_color_mode; - Inkscape::ColorRenderMode getColorMode() const { return _display_color_mode; } + Inkscape::ColorMode _display_color_mode; + Inkscape::ColorMode getColorMode() const { return _display_color_mode; } Inkscape::UI::Widget::Dock* getDock() { return _widget->getDock(); } diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 55b405523..2b08a307a 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -27,7 +27,7 @@ #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "document.h" #include "filter-chemistry.h" #include "helper/unit-menu.h" @@ -834,7 +834,7 @@ static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) static NRArena const *trace_arena = NULL; static unsigned trace_visionkey; -static NRArenaItem *trace_root; +static Inkscape::DrawingItem *trace_root; static gdouble trace_zoom; static SPDocument *trace_doc; @@ -852,6 +852,8 @@ static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { + // FIXME MEMORY LEAK: the stuff here is never freed + trace_arena = NRArena::create(); /* Create ArenaItem and set transform */ trace_visionkey = SPItem::display_key_new(1); @@ -874,13 +876,8 @@ static guint32 clonetiler_trace_pick(Geom::Rect box) return 0; } - Geom::Affine t(Geom::Scale(trace_zoom, trace_zoom)); - nr_arena_item_set_transform(trace_root, &t); - NRGC gc(NULL); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( trace_root, Geom::IntRect::infinite(), &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); + trace_root->setTransform(Geom::Scale(trace_zoom)); + trace_root->update(); /* Item integer bbox in points */ Geom::IntRect ibox = (box * Geom::Scale(trace_zoom)).roundOutwards(); @@ -889,8 +886,7 @@ static guint32 clonetiler_trace_pick(Geom::Rect box) cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ibox.width(), ibox.height()); Inkscape::DrawingContext ct(s, ibox.min()); /* Render */ - nr_arena_item_invoke_render(ct, trace_root, ibox, - NR_ARENA_ITEM_RENDER_NO_CACHE ); + trace_root->render(ct, ibox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); double R = 0, G = 0, B = 0, A = 0; ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 53f87efb1..1c51f19a0 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -25,8 +25,18 @@ ink_common_sources += \ display/curve.h \ display/drawing-context.cpp \ display/drawing-context.h \ + display/drawing-group.cpp \ + display/drawing-group.h \ + display/drawing-image.cpp \ + display/drawing-image.h \ + display/drawing-item.cpp \ + display/drawing-item.h \ + display/drawing-shape.cpp \ + display/drawing-shape.h \ display/drawing-surface.cpp \ display/drawing-surface.h \ + display/drawing-text.cpp \ + display/drawing-text.h \ display/gnome-canvas-acetate.cpp \ display/gnome-canvas-acetate.h \ display/grayscale.cpp \ @@ -35,19 +45,9 @@ ink_common_sources += \ display/guideline.h \ display/nr-3dutils.cpp \ display/nr-3dutils.h \ + display/nr-arena.h \ display/nr-arena.cpp \ display/nr-arena-forward.h \ - display/nr-arena-glyphs.cpp \ - display/nr-arena-glyphs.h \ - display/nr-arena-group.cpp \ - display/nr-arena-group.h \ - display/nr-arena.h \ - display/nr-arena-image.cpp \ - display/nr-arena-image.h \ - display/nr-arena-item.cpp \ - display/nr-arena-item.h \ - display/nr-arena-shape.cpp \ - display/nr-arena-shape.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ display/nr-filter-colormatrix.cpp \ diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 0f653a258..81416fefb 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -16,12 +16,15 @@ #include "display/sp-canvas-util.h" #include "helper/sp-marshal.h" #include "display/nr-arena.h" -#include "display/nr-arena-group.h" #include "display/canvas-arena.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" +#include "display/drawing-item.h" +#include "display/drawing-group.h" #include "display/drawing-surface.h" +using namespace Inkscape; + enum { ARENA_EVENT, LAST_SIGNAL @@ -31,6 +34,7 @@ static void sp_canvas_arena_class_init(SPCanvasArenaClass *klass); static void sp_canvas_arena_init(SPCanvasArena *group); static void sp_canvas_arena_destroy(GtkObject *object); +static void sp_canvas_arena_item_deleted(SPCanvasArena *arena, Inkscape::DrawingItem *item); static void sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf); static double sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); @@ -39,7 +43,7 @@ static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event); static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event); -static void sp_canvas_arena_request_update (NRArena *arena, NRArenaItem *item, void *data); +static void sp_canvas_arena_request_update (NRArena *arena, DrawingItem *item, void *data); static void sp_canvas_arena_request_render (NRArena *arena, NRRectL *area, void *data); NRArenaEventVector carenaev = { @@ -105,10 +109,16 @@ sp_canvas_arena_init (SPCanvasArena *arena) arena->sticky = FALSE; arena->arena = NRArena::create(); + nr_object_ref(arena->arena); arena->arena->canvasarena = arena; - arena->root = NRArenaGroup::create(arena->arena); - nr_arena_group_set_transparent (NR_ARENA_GROUP (arena->root), TRUE); - nr_arena_item_set_cache(arena->root, true); + arena->arena->item_deleted.connect( + sigc::bind<0>( + sigc::ptr_fun(&sp_canvas_arena_item_deleted), + arena)); + + arena->root = new DrawingGroup(arena->arena); + arena->root->setPickChildren(true); + arena->root->setCached(true); arena->active = NULL; @@ -120,22 +130,11 @@ sp_canvas_arena_destroy (GtkObject *object) { SPCanvasArena *arena = SP_CANVAS_ARENA (object); - if (arena->active) { - nr_object_unref ((NRObject *) arena->active); - arena->active = NULL; - } - - if (arena->root) { - nr_arena_item_unref (arena->root); - arena->root = NULL; - } - - if (arena->arena) { - nr_active_object_remove_listener_by_data ((NRActiveObject *) arena->arena, arena); + delete arena->root; - nr_object_unref ((NRObject *) arena->arena); - arena->arena = NULL; - } + nr_active_object_remove_listener_by_data ((NRActiveObject *) arena->arena, arena); + nr_object_unref ((NRObject *) arena->arena); + arena->arena = NULL; if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -149,14 +148,12 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned if (((SPCanvasItemClass *) parent_class)->update) (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags); - arena->gc.transform = affine; + arena->ctx.ctm = affine; - guint reset; - reset = (flags & SP_CANVAS_UPDATE_AFFINE)? NR_ARENA_ITEM_STATE_ALL : NR_ARENA_ITEM_STATE_NONE; + unsigned reset = flags & SP_CANVAS_UPDATE_AFFINE ? DrawingItem::STATE_ALL : 0; + arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_ALL, reset); - nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_ALL, reset); - - Geom::OptIntRect b = arena->root->bbox; + Geom::OptIntRect b = arena->root->visualBounds(); if (b) { item->x1 = b->left() - 1; item->y1 = b->top() - 1; @@ -166,7 +163,7 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned if (arena->cursor) { /* Mess with enter/leave notifiers */ - NRArenaItem *new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky); + DrawingItem *new_arena = arena->root->pick(arena->c, arena->arena->delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; ec.window = GTK_WIDGET (item->canvas)->window; @@ -180,10 +177,7 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned ec.type = GDK_LEAVE_NOTIFY; sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); } - /* fixme: This is not optimal - better track ::destroy (Lauris) */ - if (arena->active) nr_object_unref ((NRObject *) arena->active); arena->active = new_arena; - if (arena->active) nr_object_ref ((NRObject *) arena->active); if (arena->active) { ec.type = GDK_ENTER_NOTIFY; sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); @@ -192,6 +186,14 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned } } +static void +sp_canvas_arena_item_deleted(SPCanvasArena *arena, Inkscape::DrawingItem *item) +{ + if (arena->active == item) { + arena->active = NULL; + } +} + static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) { @@ -203,10 +205,8 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) Inkscape::DrawingContext ct(buf->ct, r->min()); - nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, - NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_RENDER, - NR_ARENA_ITEM_STATE_NONE); - nr_arena_item_invoke_render (ct, arena->root, *r, 0); + arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_ALL, 0); + arena->root->render(ct, *r, 0); } static double @@ -214,11 +214,8 @@ sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ { SPCanvasArena *arena = SP_CANVAS_ARENA (item); - nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, - NR_ARENA_ITEM_STATE_BBOX | NR_ARENA_ITEM_STATE_PICK, - NR_ARENA_ITEM_STATE_NONE); - - NRArenaItem *picked = nr_arena_item_invoke_pick (arena->root, p, arena->arena->delta, arena->sticky); + arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); + DrawingItem *picked = arena->root->pick(p, arena->arena->delta, arena->sticky); arena->picked = picked; @@ -244,7 +241,7 @@ sp_canvas_arena_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_ar static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) { - NRArenaItem *new_arena; + Inkscape::DrawingItem *new_arena; /* fixme: This sucks, we have to handle enter/leave notifiers */ SPCanvasArena *arena = SP_CANVAS_ARENA (item); @@ -256,7 +253,6 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) if (!arena->cursor) { if (arena->active) { //g_warning ("Cursor entered to arena with already active item"); - nr_object_unref ((NRObject *) arena->active); } arena->cursor = TRUE; @@ -264,9 +260,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->crossing.x, event->crossing.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); - arena->active = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky); - if (arena->active) nr_object_ref ((NRObject *) arena->active); + arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); + arena->active = arena->root->pick(arena->c, arena->arena->delta, arena->sticky); ret = sp_canvas_arena_send_event (arena, event); } break; @@ -274,7 +269,6 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) case GDK_LEAVE_NOTIFY: if (arena->cursor) { ret = sp_canvas_arena_send_event (arena, event); - if (arena->active) nr_object_unref ((NRObject *) arena->active); arena->active = NULL; arena->cursor = FALSE; } @@ -285,8 +279,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->motion.x, event->motion.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - nr_arena_item_invoke_update (arena->root, Geom::IntRect::infinite(), &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); - new_arena = nr_arena_item_invoke_pick (arena->root, arena->c, arena->arena->delta, arena->sticky); + arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); + new_arena = arena->root->pick(arena->c, arena->arena->delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; ec.window = event->motion.window; @@ -300,9 +294,7 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) ec.type = GDK_LEAVE_NOTIFY; ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); } - if (arena->active) nr_object_unref ((NRObject *) arena->active); arena->active = new_arena; - if (arena->active) nr_object_ref ((NRObject *) arena->active); if (arena->active) { ec.type = GDK_ENTER_NOTIFY; ret = sp_canvas_arena_send_event (arena, (GdkEvent *) &ec); @@ -332,7 +324,7 @@ sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event) } static void -sp_canvas_arena_request_update (NRArena */*arena*/, NRArenaItem */*item*/, void *data) +sp_canvas_arena_request_update (NRArena */*arena*/, DrawingItem */*item*/, void *data) { sp_canvas_item_request_update (SP_CANVAS_ITEM (data)); } @@ -373,7 +365,8 @@ sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRR Geom::OptIntRect area = r.upgrade_2geom(); if (!area) return; Inkscape::DrawingContext ct(surface, area->min()); - nr_arena_item_invoke_render (ct, ca->root, *area, 0); + ca->root->update(Geom::IntRect::infinite(), ca->ctx, DrawingItem::STATE_ALL, 0); + ca->root->render(ct, *area, 0); } diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 4cfeccb5a..e63a524f2 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -15,9 +15,10 @@ #include #include <2geom/rect.h> +#include "display/display-forward.h" +#include "display/drawing-item.h" #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" -#include "display/nr-arena-item.h" G_BEGIN_DECLS @@ -38,19 +39,19 @@ struct _SPCanvasArena { Geom::Point c; // what is this? NRArena *arena; - NRArenaItem *root; - NRGC gc; + Inkscape::DrawingGroup *root; + Inkscape::UpdateContext ctx; - NRArenaItem *active; + Inkscape::DrawingItem *active; /* fixme: */ - NRArenaItem *picked; - gdouble delta; + Inkscape::DrawingItem *picked; + double delta; }; struct _SPCanvasArenaClass { SPCanvasItemClass parent_class; - gint (* arena_event) (SPCanvasArena *carena, NRArenaItem *item, GdkEvent *event); + gint (* arena_event) (SPCanvasArena *carena, Inkscape::DrawingItem *item, GdkEvent *event); }; GType sp_canvas_arena_get_type (void); diff --git a/src/display/display-forward.h b/src/display/display-forward.h index 288da829a..d7e7d72ab 100644 --- a/src/display/display-forward.h +++ b/src/display/display-forward.h @@ -11,9 +11,17 @@ struct SPCanvasGroup; struct SPCanvasGroupClass; class SPCurve; +class NRArena; + namespace Inkscape { class DrawingContext; class DrawingSurface; +class DrawingItem; +class DrawingGroup; +class DrawingImage; +class DrawingShape; +class DrawingGlyphs; +class DrawingText; namespace Display { class TemporaryItem; diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp new file mode 100644 index 000000000..2d40f0a83 --- /dev/null +++ b/src/display/drawing-group.cpp @@ -0,0 +1,141 @@ +/** + * @file + * @brief Group belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/cairo-utils.h" +#include "display/drawing-context.h" +#include "display/drawing-item.h" +#include "display/drawing-group.h" +#include "libnr/nr-values.h" +#include "nr-arena.h" +#include "style.h" + +namespace Inkscape { + +DrawingGroup::DrawingGroup(Drawing *drawing) + : DrawingItem(drawing) + , _style(NULL) + , _child_transform(NULL) +{} + +DrawingGroup::~DrawingGroup() +{ + if (_style) + sp_style_unref(_style); +} + +void +DrawingGroup::setPickChildren(bool p) +{ + _pick_children = p; +} + +void +DrawingGroup::setStyle(SPStyle *style) +{ + _setStyleCommon(_style, style); +} + +void +DrawingGroup::setChildTransform(Geom::Affine const &new_trans) +{ + Geom::Affine current; + if (_child_transform) { + current = *_child_transform; + } + + if (!Geom::are_near(current, new_trans, NR_EPSILON)) { + // mark the area where the object was for redraw. + _markForRendering(); + if (new_trans.isIdentity()) { + delete _child_transform; // delete NULL; is safe + _child_transform = NULL; + } else { + _child_transform = new Geom::Affine(new_trans); + } + _markForUpdate(STATE_ALL, true); + } +} + +unsigned +DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +{ + unsigned beststate = STATE_ALL; + bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + UpdateContext child_ctx(ctx); + if (_child_transform) { + child_ctx.ctm = *_child_transform * ctx.ctm; + } + i->update(area, child_ctx, flags, reset); + } + if (beststate & STATE_BBOX) { + _bbox = Geom::OptIntRect(); + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + if (i->visible()) { + _bbox.unionWith(outline ? i->geometricBounds() : i->visualBounds()); + } + } + } + return beststate; +} + +void +DrawingGroup::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->render(ct, area, flags); + } +} + +void +DrawingGroup::_clipItem(DrawingContext &ct, Geom::IntRect const &area) +{ + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->clip(ct, area); + } +} + +DrawingItem * +DrawingGroup::_pickItem(Geom::Point const &p, double delta) +{ + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + DrawingItem *picked = i->pick(p, delta, false); + if (picked) { + return _pick_children ? picked : this; + } + } + return NULL; +} + +bool +DrawingGroup::_canClip() +{ + return true; +} + +bool is_drawing_group(DrawingItem *item) +{ + return dynamic_cast(item) != NULL; +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h new file mode 100644 index 000000000..f7d6a2be3 --- /dev/null +++ b/src/display/drawing-group.h @@ -0,0 +1,61 @@ +/** + * @file + * @brief Group belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_GROUP_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_GROUP_H + +#include "display/drawing-item.h" + +class SPStyle; + +namespace Inkscape { + +class DrawingGroup + : public DrawingItem +{ +public: + DrawingGroup(Drawing *drawing); + ~DrawingGroup(); + + bool pickChildren() { return _pick_children; } + void setPickChildren(bool p); + + void setStyle(SPStyle *style); + void setChildTransform(Geom::Affine const &new_trans); + +protected: + unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + unsigned flags, unsigned reset); + virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual bool _canClip(); + + SPStyle *_style; + Geom::Affine *_child_transform; +}; + +bool is_drawing_group(DrawingItem *item); + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp new file mode 100644 index 000000000..ea6f6ce3c --- /dev/null +++ b/src/display/drawing-image.cpp @@ -0,0 +1,263 @@ +/** + * @file + * @brief Bitmap image belonging to an SVG drawing + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/cairo-utils.h" +#include "display/drawing-context.h" +#include "display/drawing-image.h" +#include "nr-arena.h" +#include "preferences.h" +#include "style.h" + +namespace Inkscape { + +DrawingImage::DrawingImage(Drawing *drawing) + : DrawingItem(drawing) + , _pixbuf(NULL) + , _surface(NULL) + , _style(NULL) +{} + +DrawingImage::~DrawingImage() +{ + if (_style) + sp_style_unref(_style); + if (_pixbuf) { + cairo_surface_destroy(_surface); + g_object_unref(_pixbuf); + } +} + +void +DrawingImage::setARGB32Pixbuf(GdkPixbuf *pb) +{ + // when done in this order, it won't break if pb == image->pixbuf and the refcount is 1 + if (pb != NULL) { + g_object_ref (pb); + } + if (_pixbuf != NULL) { + g_object_unref(_pixbuf); + cairo_surface_destroy(_surface); + } + _pixbuf = pb; + _surface = pb ? ink_cairo_surface_create_for_argb32_pixbuf(pb) : NULL; + + _markForUpdate(STATE_ALL, false); +} + +void +DrawingImage::setStyle(SPStyle *style) +{ + _setStyleCommon(_style, style); +} + +void +DrawingImage::setScale(double sx, double sy) +{ + _scale = Geom::Scale(sx, sy); + _markForUpdate(STATE_ALL, false); +} + +void +DrawingImage::setOrigin(Geom::Point const &o) +{ + _origin = o; + _markForUpdate(STATE_ALL, false); +} + +void +DrawingImage::setClipbox(Geom::Rect const &box) +{ + _clipbox = box; + _markForUpdate(STATE_ALL, false); +} + +Geom::Rect +DrawingImage::bounds() const +{ + if (!_pixbuf) return _clipbox; + + double pw = gdk_pixbuf_get_width(_pixbuf); + double ph = gdk_pixbuf_get_height(_pixbuf); + double vw = pw * _scale[Geom::X]; + double vh = ph * _scale[Geom::Y]; + Geom::Point wh(vw, vh); + Geom::Rect view(_origin, _origin+wh); + Geom::OptRect res = _clipbox & view; + Geom::Rect ret = res ? *res : _clipbox; + + return ret; +} + +unsigned +DrawingImage::_updateItem(Geom::IntRect const &, UpdateContext const &, unsigned, unsigned) +{ + _markForRendering(); + + // Calculate bbox + if (_pixbuf) { + Geom::Rect r = bounds() * _ctm; + _bbox = r.roundOutwards(); + } else { + _bbox = Geom::OptIntRect(); + } + + return STATE_ALL; +} + +void +DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + + if (!outline) { + if (!_pixbuf) return; + + Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); + ct.newPath(); + ct.rectangle(_clipbox); + ct.clip(); + + ct.translate(_origin); + ct.scale(_scale); + ct.setSource(_surface, 0, 0); + + cairo_matrix_t tt; + Geom::Affine total; + cairo_get_matrix(ct.raw(), &tt); + ink_matrix_to_2geom(total, tt); + + if (total.expansionX() > 1.0 || total.expansionY() > 1.0) { + cairo_pattern_t *p = cairo_get_source(ct.raw()); + cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST); + } + //ct.paint(_opacity); + ct.paint(); + + } else { // outline; draw a rect instead + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); + + { Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); + ct.newPath(); + + Geom::Rect r = bounds(); + Geom::Point c00 = r.corner(0); + Geom::Point c01 = r.corner(3); + Geom::Point c11 = r.corner(2); + Geom::Point c10 = r.corner(1); + + ct.moveTo(c00); + // the box + ct.lineTo(c10); + ct.lineTo(c11); + ct.lineTo(c01); + ct.lineTo(c00); + // the diagonals + ct.lineTo(c11); + ct.moveTo(c10); + ct.lineTo(c01); + } + + ct.setLineWidth(0.5); + ct.setSource(rgba); + ct.stroke(); + } +} + +/** Calculates the closest distance from p to the segment a1-a2*/ +static double +distance_to_segment (Geom::Point const &p, Geom::Point const &a1, Geom::Point const &a2) +{ + // calculate sides of the triangle and their squares + double d1 = Geom::L2(p - a1); + double d1_2 = d1 * d1; + double d2 = Geom::L2(p - a2); + double d2_2 = d2 * d2; + double a = Geom::L2(a1 - a2); + double a_2 = a * a; + + // if one of the angles at the base is > 90, return the corresponding side + if (d1_2 + a_2 <= d2_2) return d1; + if (d2_2 + a_2 <= d1_2) return d2; + + // otherwise calculate the height to the base + double peri = (a + d1 + d2)/2; + return (2*sqrt(peri * (peri - a) * (peri - d1) * (peri - d2))/a); +} + +DrawingItem * +DrawingImage::_pickItem(Geom::Point const &p, double delta) +{ + if (!_pixbuf) return NULL; + + bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + + if (outline) { + Geom::Rect r = bounds(); + + Geom::Point c00 = r.corner(0); + Geom::Point c01 = r.corner(3); + Geom::Point c11 = r.corner(2); + Geom::Point c10 = r.corner(1); + + // frame + if (distance_to_segment (p, c00, c10) < delta) return this; + if (distance_to_segment (p, c10, c11) < delta) return this; + if (distance_to_segment (p, c11, c01) < delta) return this; + if (distance_to_segment (p, c01, c00) < delta) return this; + + // diagonals + if (distance_to_segment (p, c00, c11) < delta) return this; + if (distance_to_segment (p, c10, c01) < delta) return this; + + return NULL; + + } else { + unsigned char *const pixels = gdk_pixbuf_get_pixels(_pixbuf); + int width = gdk_pixbuf_get_width(_pixbuf); + int height = gdk_pixbuf_get_height(_pixbuf); + int rowstride = gdk_pixbuf_get_rowstride(_pixbuf); + + Geom::Point tp = p * _ctm.inverse(); + Geom::Rect r = bounds(); + + if (!r.contains(tp)) + return NULL; + + double vw = width * _scale[Geom::X]; + double vh = height * _scale[Geom::Y]; + int ix = floor((tp[Geom::X] - _origin[Geom::X]) / vw * width); + int iy = floor((tp[Geom::Y] - _origin[Geom::Y]) / vh * height); + + if ((ix < 0) || (iy < 0) || (ix >= width) || (iy >= height)) + return NULL; + + unsigned char *pix_ptr = pixels + iy * rowstride + ix * 4; + // pick if the image is less than 99% transparent + float alpha = (pix_ptr[3] / 255.0f) * _opacity; + return alpha > 0.01 ? this : NULL; + } +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h new file mode 100644 index 000000000..570c10360 --- /dev/null +++ b/src/display/drawing-image.h @@ -0,0 +1,66 @@ +/** + * @file + * @brief Bitmap image belonging to an SVG drawing + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_IMAGE_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_IMAGE_H + +#include +#include +#include <2geom/transforms.h> + +#include "display/drawing-item.h" + +namespace Inkscape { + +class DrawingImage + : public DrawingItem +{ +public: + DrawingImage(Drawing *drawing); + ~DrawingImage(); + + void setARGB32Pixbuf(GdkPixbuf *pb); + void setStyle(SPStyle *style); + void setScale(double sx, double sy); + void setOrigin(Geom::Point const &o); + void setClipbox(Geom::Rect const &box); + Geom::Rect bounds() const; + +protected: + virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + unsigned flags, unsigned reset); + virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + + GdkPixbuf *_pixbuf; + cairo_surface_t *_surface; + SPStyle *_style; + + // TODO: the following three should probably be merged into a new Geom::Viewbox object + Geom::Rect _clipbox; ///< for preserveAspectRatio + Geom::Point _origin; + Geom::Scale _scale; +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp new file mode 100644 index 000000000..318ff28e7 --- /dev/null +++ b/src/display/drawing-item.cpp @@ -0,0 +1,620 @@ +/** + * @file + * @brief Canvas item belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/cairo-utils.h" +#include "display/cairo-templates.h" +#include "display/drawing-context.h" +#include "display/drawing-item.h" +#include "display/drawing-group.h" +#include "display/drawing-surface.h" +#include "nr-arena.h" +#include "nr-filter.h" +#include "preferences.h" +#include "style.h" + +namespace Inkscape { + +DrawingItem::DrawingItem(Drawing *drawing) + : _drawing(drawing) + , _parent(NULL) + , _key(0) + , _opacity(1.0) + , _transform(NULL) + , _clip(NULL) + , _mask(NULL) + , _filter(NULL) + , _user_data(NULL) + , _cache(NULL) + , _state(0) + , _visible(true) + , _sensitive(true) + , _cached(0) + , _propagate(0) +// , _renders_opacity(0) + , _clip_child(0) + , _mask_child(0) + , _pick_children(0) +{ + nr_object_ref(_drawing); +} + +DrawingItem::~DrawingItem() +{ + _drawing->item_deleted.emit(this); + //if (!_children.empty()) { + // g_warning("Removing item with children"); + //} + + // remove from the set of cached items + if (_cached) { + _drawing->cached_items.erase(this); + } + // remove this item from parent's children list + // due to the effect of clearChildren(), this only happens for the top-level deleted item + if (_parent) { + _markForRendering(); + // we cannot call setClip(NULL) or setMask(NULL), + // because that would be an endless loop + if (_clip_child) { + _parent->_clip = NULL; + } else if (_mask_child) { + _parent->_mask = NULL; + } else { + ChildrenList::iterator ithis = _parent->_children.iterator_to(*this); + _parent->_children.erase(ithis); + } + _parent->_markForUpdate(STATE_ALL, false); + } + clearChildren(); + delete _transform; + delete _clip; + delete _mask; + delete _filter; + nr_object_unref(_drawing); +} + +DrawingItem * +DrawingItem::parent() const +{ + //if (_clip_child || _mask_child) + // return NULL; + + return _parent; +} + +void +DrawingItem::appendChild(DrawingItem *item) +{ + item->_parent = this; + _children.push_back(*item); + _markForUpdate(STATE_ALL, false); +} + +void +DrawingItem::prependChild(DrawingItem *item) +{ + item->_parent = this; + _children.push_front(*item); + _markForUpdate(STATE_ALL, false); +} + +void +DrawingItem::clearChildren() +{ + // prevent children from referencing the parent during deletion + // this way, children won't try to remove themselves from a list + // from which they have already been removed by clear_and_dispose + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->_parent = NULL; + } + _children.clear_and_dispose(DeleteDisposer()); +} + +void +DrawingItem::setTransform(Geom::Affine const &new_trans) +{ + Geom::Affine current; + if (_transform) { + current = *_transform; + } + + if (!Geom::are_near(current, new_trans, NR_EPSILON)) { + // mark the area where the object was for redraw. + _markForRendering(); + if (new_trans.isIdentity()) { + delete _transform; // delete NULL; is safe + _transform = NULL; + } else { + _transform = new Geom::Affine(new_trans); + } + _markForUpdate(STATE_ALL, true); + } +} + +void +DrawingItem::setOpacity(float opacity) +{ + _opacity = opacity; + _markForRendering(); +} + +void +DrawingItem::setVisible(bool v) +{ + _visible = v; + _markForRendering(); +} + +void +DrawingItem::setSensitive(bool s) +{ + _sensitive = s; +} + +void +DrawingItem::setCached(bool c) +{ + _cached = c; + if (c) { + _drawing->cached_items.insert(this); + } else { + _drawing->cached_items.erase(this); + } + _markForUpdate(STATE_CACHE, false); +} + +void +DrawingItem::setClip(DrawingItem *item) +{ + _markForRendering(); + delete _clip; + _clip = item; + if (item) { + item->_parent = this; + item->_clip_child = true; + } + _markForUpdate(STATE_ALL, true); +} + +void +DrawingItem::setMask(DrawingItem *item) +{ + _markForRendering(); + delete _mask; + _mask = item; + if (item) { + item->_parent = this; + item->_mask_child = true; + } + _markForUpdate(STATE_ALL, true); +} + +void +DrawingItem::setZOrder(unsigned z) +{ + if (!_parent) return; + + ChildrenList::iterator it = _parent->_children.iterator_to(*this); + _parent->_children.erase(it); + + ChildrenList::iterator i = _parent->_children.begin(); + std::advance(i, std::min(z, unsigned(_parent->_children.size()))); + _parent->_children.insert(i, *this); + _markForRendering(); +} + +void +DrawingItem::setItemBounds(Geom::OptRect const &bounds) +{ + _item_bbox = bounds; +} + +void +DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +{ + bool render_filters = (_drawing->rendermode == Inkscape::RENDERMODE_NORMAL); + bool outline = (_drawing->rendermode == Inkscape::RENDERMODE_OUTLINE); + + // Set reset flags according to propagation status + if (_propagate) { + reset |= ~_state; + _propagate = FALSE; + } + _state &= ~reset; // reset state of this item + + if ((~_state & flags) == 0) return; // nothing to do + + // TODO this might be wrong + if (_state & STATE_BBOX) { + // we have up-to-date bbox + if (!area.intersects(outline ? _bbox : _drawbox)) return; + } + + UpdateContext child_ctx(ctx); + if (_transform) { + child_ctx.ctm = *_transform * ctx.ctm; + } + /* Remember the transformation matrix */ + Geom::Affine ctm_change = _ctm.inverse() * child_ctx.ctm; + _ctm = child_ctx.ctm; + + // update _bbox + _state = _updateItem(area, child_ctx, flags, reset); + + // compute drawbox + if (_filter && render_filters && _item_bbox) { + _drawbox = _filter->compute_drawbox(this, *_item_bbox); + } else { + _drawbox = _bbox; + } + + // Clipping + if (_clip) { + _clip->update(area, child_ctx, flags, reset); + if (outline) { + _bbox.unionWith(_clip->_bbox); + } else { + _drawbox.intersectWith(_clip->_bbox); + } + } + // masking + if (_mask) { + _mask->update(area, child_ctx, flags, reset); + if (outline) { + _bbox.unionWith(_mask->_bbox); + } else { + // for masking, we need full drawbox of mask + _drawbox.intersectWith(_mask->_drawbox); + } + } + + // update cache if enabled + if (_cached) { + Geom::OptIntRect cl = _drawing->cache_limit; + cl.intersectWith(_drawbox); + if (cl) { + if (_cache) { + // this takes care of invalidation on transform + _cache->resizeAndTransform(*cl, ctm_change); + } else { + _cache = new Inkscape::DrawingCache(*cl); + // the cache is initially dirty + } + } else { + // disable cache for this item - not visible + delete _cache; + _cache = NULL; + } + } + + // now that we know drawbox, dirty the corresponding rect on canvas + // unless filtered, groups do not need to render by themselves, only their members + if (!is_drawing_group(this) || (_filter && render_filters)) { + if (flags & ~STATE_CACHE) { + _markForRendering(); + } + } +} + +struct MaskLuminanceToAlpha { + guint32 operator()(guint32 in) { + EXTRACT_ARGB32(in, a, r, g, b) + // the operation of unpremul -> luminance-to-alpha -> multiply by alpha + // is equivalent to luminance-to-alpha on premultiplied color values + // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 + guint32 ao = r*109 + g*366 + b*37; // coeffs add up to 512 + return ((ao + 256) << 15) & 0xff000000; // equivalent to ((ao + 256) / 512) << 24 + } +}; + +void +DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + bool outline = (_drawing->rendermode == Inkscape::RENDERMODE_OUTLINE); + bool render_filters = (_drawing->rendermode == Inkscape::RENDERMODE_NORMAL); + + /* If we are invisible, just return successfully */ + if (!_visible) return; + + if (outline) { + _renderOutline(ct, area, flags); + return; + } + + // carea is the bounding box for intermediate rendering. + Geom::OptIntRect carea = Geom::intersect(area, _drawbox); + if (!carea) return; + + // render from cache + if (_cached && _cache) { + if (_cache->paintFromCache(ct, *carea)) + return; + } + + // expand carea to contain the dependent area of filters. + if (_filter && render_filters) { + _filter->area_enlarge(*carea, this); + carea.intersectWith(_drawbox); + } + + // determine whether this shape needs intermediate rendering. + bool needs_intermediate_rendering = false; + bool &nir = needs_intermediate_rendering; + bool needs_opacity = (_opacity < 0.995); + + // this item needs an intermediate rendering if: + nir |= (_clip != NULL); // 1. it has a clipping path + nir |= (_mask != NULL); // 2. it has a mask + nir |= (_filter != NULL && render_filters); // 3. it has a filter + nir |= needs_opacity; // 4. it is non-opaque + + /* How the rendering is done. + * + * Clipping, masking and opacity are done by rendering them to a surface + * and then compositing the object's rendering onto it with the IN operator. + * The object itself is rendered to a group. + * + * Opacity is done by rendering the clipping path with an alpha + * value corresponding to the opacity. If there is no clipping path, + * the entire intermediate surface is painted with alpha corresponding + * to the opacity value. + */ + + // short-circuit the simple case. + if (!needs_intermediate_rendering) { + if (_cached && _cache) { + Inkscape::DrawingContext cachect(*_cache); + cachect.rectangle(area); + cachect.clip(); + + { // 1. clear the corresponding part of cache + Inkscape::DrawingContext::Save save(cachect); + cachect.setSource(0,0,0,0); + cachect.setOperator(CAIRO_OPERATOR_SOURCE); + cachect.paint(); + } + // 2. render to cache + _renderItem(cachect, *carea, flags); + // 3. copy from cache to output + Inkscape::DrawingContext::Save save(ct); + ct.rectangle(*carea); + ct.clip(); + ct.setSource(_cache); + ct.paint(); + // 4. mark as clean + _cache->markClean(area); + return; + } else { + _renderItem(ct, *carea, flags); + return; + } + } + + DrawingSurface intermediate(*carea); + DrawingContext ict(intermediate); + + // 1. Render clipping path with alpha = opacity. + ict.setSource(0,0,0,_opacity); + // Since clip can be combined with opacity, the result could be incorrect + // for overlapping clip children. To fix this we use the SOURCE operator + // instead of the default OVER. + ict.setOperator(CAIRO_OPERATOR_SOURCE); + if (_clip) { + _clip->clip(ict, *carea); // fixme: carea or area? + } else { + // if there is no clipping path, fill the entire surface with alpha = opacity. + ict.paint(); + } + ict.setOperator(CAIRO_OPERATOR_OVER); // reset back to default + + // 2. Render the mask if present and compose it with the clipping path + opacity. + if (_mask) { + ict.pushGroup(); + _mask->render(ict, *carea, flags); + + cairo_surface_t *mask_s = ict.rawTarget(); + // Convert mask's luminance to alpha + ink_cairo_surface_filter(mask_s, mask_s, MaskLuminanceToAlpha()); + ict.popGroupToSource(); + ict.setOperator(CAIRO_OPERATOR_IN); + ict.paint(); + ict.setOperator(CAIRO_OPERATOR_OVER); + } + + // 3. Render object itself. + ict.pushGroup(); + _renderItem(ict, *carea, flags); + + // 4. Apply filter. + if (_filter && render_filters) { + _filter->render(this, ct, ict); + // Note that because the object was rendered to a group, + // the internals of the filter need to use cairo_get_group_target() + // instead of cairo_get_target(). + } + + // 5. Render object inside the composited mask + clip + ict.popGroupToSource(); + ict.setOperator(CAIRO_OPERATOR_IN); + ict.paint(); + + // 6. Paint the completed rendering onto the base context (or into cache) + if (_cached && _cache) { + DrawingContext cachect(*_cache); + cachect.rectangle(area); + cachect.clip(); + cachect.setOperator(CAIRO_OPERATOR_SOURCE); + cachect.setSource(&intermediate); + cachect.paint(); + _cache->markClean(area); + } + ct.setSource(&intermediate); + ct.paint(); + ct.setSource(0,0,0,0); + // the call above is to clear a ref on the intermediate surface held by ct +} + +void +DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + // intersect with bbox rather than drawbox, as we want to render things outside + // of the clipping path as well + Geom::OptIntRect carea = Geom::intersect(area, _bbox); + if (!carea) return; + + // just render everything: item, clip, mask + // First, render the object itself + _renderItem(ct, *carea, flags); + + // render clip and mask, if any + guint32 saved_rgba = _drawing->outlinecolor; // save current outline color + // render clippath as an object, using a different color + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (_clip) { + _drawing->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips + _clip->render(ct, *carea, flags); + } + // render mask as an object, using a different color + if (_mask) { + _drawing->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks + _mask->render(ct, *carea, flags); + } + _drawing->outlinecolor = saved_rgba; // restore outline color +} + +void +DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) +{ + // don't bother if the object does not implement clipping (e.g. DrawingImage) + if (!_canClip()) return; + if (!_visible) return; + if (!area.intersects(_bbox)) return; + + // The item used as the clipping path itself has a clipping path. + // Render this item's clipping path onto a temporary surface, then composite it + // with the item using the IN operator + if (_clip) { + ct.pushAlphaGroup(); + { Inkscape::DrawingContext::Save save(ct); + ct.setSource(0,0,0,1); + _clip->clip(ct, area); + } + ct.pushAlphaGroup(); + } + + // rasterize the clipping path + _clipItem(ct, area); + + if (_clip) { + ct.popGroupToSource(); + ct.setOperator(CAIRO_OPERATOR_IN); + ct.paint(); + ct.popGroupToSource(); + ct.setOperator(CAIRO_OPERATOR_SOURCE); + ct.paint(); + } +} + +DrawingItem * +DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) +{ + // Sometimes there's no BBOX in state, reason unknown (bug 992817) + // I made this not an assert to remove the warning + if (!(_state & STATE_BBOX) || !(_state & STATE_PICK)) + return NULL; + + if (!sticky && !(_visible && _sensitive)) + return NULL; + + if (!_bbox) return NULL; + Geom::Rect expanded(*_bbox); + expanded.expandBy(delta); + + if (expanded.contains(p)) { + return _pickItem(p, delta); + } + return NULL; +} + +void +DrawingItem::_markForRendering() +{ + bool outline = (_drawing->rendermode == Inkscape::RENDERMODE_OUTLINE); + Geom::OptIntRect dirty = outline ? _bbox : _drawbox; + if (!dirty) return; + + // dirty the caches of all parents + for (DrawingItem *i = this; i; i = i->_parent) { + if (i->_cached && i->_cache) { + i->_cache->markDirty(*dirty); + } + } + + nr_arena_request_render_rect (_drawing, dirty); +} + +void +DrawingItem::_markForUpdate(unsigned flags, bool propagate) +{ + // here we can't simply assign because a previous markForUpdate call + // could have had propagate=true even if this one has propagate=false + if (propagate) + _propagate = true; + + if (_state & flags) { + _state &= ~flags; + if (_parent) { + _parent->_markForUpdate(flags, false); + } else { + nr_arena_request_update (_drawing, this); + } + } +} + +void +DrawingItem::_setStyleCommon(SPStyle *&_style, SPStyle *style) +{ + if (style) sp_style_ref(style); + if (_style) sp_style_unref(_style); + _style = style; + + // if group has a filter + if (style->filter.set && style->getFilter()) { + if (!_filter) { + int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); + _filter = new Inkscape::Filters::Filter(primitives); + } + sp_filter_build_renderer(SP_FILTER(style->getFilter()), _filter); + } else { + // no filter set for this group + delete _filter; + _filter = NULL; + } + + /* + if (style && style->enable_background.set + && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { + _background_new = true; + }*/ +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h new file mode 100644 index 000000000..b34ddf0e4 --- /dev/null +++ b/src/display/drawing-item.h @@ -0,0 +1,168 @@ +/** + * @file + * @brief Canvas item belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +#include +#include +#include <2geom/rect.h> +#include <2geom/affine.h> + +class NRArena; +class SPStyle; +void nr_arena_set_cache_limit(NRArena *, Geom::OptIntRect const &); + +namespace Inkscape { + +typedef ::NRArena Drawing; +class DrawingContext; +class DrawingCache; +class DrawingItem; +namespace Filters { class Filter; } + +struct UpdateContext { + Geom::Affine ctm; +}; + +class InvalidItemException : public std::exception { + virtual const char *what() const throw() { + return "Invalid item in drawing"; + } +}; + +typedef boost::intrusive::list_base_hook<> ChildrenListHook; + +class DrawingItem + : public ChildrenListHook +{ +public: + enum RenderFlags { + RENDER_DEFAULT = 0, + RENDER_CACHE_ONLY = 1, + RENDER_BYPASS_CACHE = 2 + }; + enum StateFlags { + STATE_NONE = 0, + STATE_BBOX = (1<<0), // geometric bounding box is up-to-date + STATE_DRAWBOX = (1<<1), // visual bounding box is up-to-date + STATE_CACHE = (1<<2), // cache extents and clean area are up-to-date + STATE_PICK = (1<<3), // can process pick requests + STATE_RENDER = (1<<4), // can be rendered + STATE_ALL = (1<<5)-1 + }; + typedef boost::intrusive::list ChildrenList; + + DrawingItem(Drawing *drawing); + virtual ~DrawingItem(); + + Geom::OptIntRect geometricBounds() const { return _bbox; } + Geom::OptIntRect visualBounds() const { return _drawbox; } + Geom::OptRect itemBounds() const { return _item_bbox; } + Geom::Affine ctm() const { return _ctm; } + Geom::Affine transform() const { return _transform ? *_transform : Geom::identity(); } + Drawing *drawing() const { return _drawing; } + DrawingItem *parent() const; + + void appendChild(DrawingItem *item); + void prependChild(DrawingItem *item); + void clearChildren(); + + bool visible() const { return _visible; } + void setVisible(bool v); + bool sensitive() const { return _sensitive; } + void setSensitive(bool v); + bool cached() const { return _cached; } + void setCached(bool c); + + void setOpacity(float opacity); + void setTransform(Geom::Affine const &trans); + void setClip(DrawingItem *item); + void setMask(DrawingItem *item); + void setZOrder(unsigned z); + void setItemBounds(Geom::OptRect const &bounds); + + void setKey(unsigned key) { _key = key; } + unsigned key() const { return _key; } + void setData(void *data) { _user_data = data; } + void *data() const { return _user_data; } + + void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = STATE_ALL, unsigned reset = 0); + void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); + void clip(DrawingContext &ct, Geom::IntRect const &area); + DrawingItem *pick(Geom::Point const &p, double delta, bool sticky); + +protected: + void _renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + void _markForUpdate(unsigned state, bool propagate); + void _markForRendering(); + void _setStyleCommon(SPStyle *&_style, SPStyle *style); + virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + unsigned flags, unsigned reset) { return 0; } + virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) {} + virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area) {} + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta) { return NULL; } + virtual bool _canClip() { return false; } + + Drawing *_drawing; + DrawingItem *_parent; + ChildrenList _children; + + unsigned _key; ///< Some SPItems can have more than one NRArenaItem; + /// this value is a hack used to distinguish between them + float _opacity; + + Geom::Affine *_transform; ///< Incremental transform from parent to this item's coords + Geom::Affine _ctm; ///< Total transform from item coords to display coords + Geom::OptIntRect _bbox; ///< Bounding box in display (pixel) coords + Geom::OptIntRect _drawbox; ///< Bounding box enlarged by filters, shrinked by clips and masks + Geom::OptRect _item_bbox; ///< Bounding box in item coordinates + + DrawingItem *_clip; + DrawingItem *_mask; + Inkscape::Filters::Filter *_filter; + void *_user_data; ///< Used to associate DrawingItems with SPItems that created them + DrawingCache *_cache; + + unsigned _state : 8; + unsigned _visible : 1; + unsigned _sensitive : 1; ///< Whether this item responds to events + unsigned _cached : 1; ///< Whether the rendering is stored for reuse + unsigned _propagate : 1; ///< Whether to call update for all children on next update + //unsigned _renders_opacity : 1; ///< Whether object needs temporary surface for opacity + unsigned _clip_child : 1; ///< If set, this is not a child of _parent, but a clipping path + unsigned _mask_child : 1; ///< If set, this is not a child of _parent, but a mask + unsigned _pick_children : 1; ///< For groups: if true, children are returned from pick(), + /// otherwise the group is returned + + // temporary hacks until I rewrite NRArena to Inkscape::Drawing + friend class NRArena; + friend void ::nr_arena_set_cache_limit(NRArena *, Geom::OptIntRect const &); +}; + +struct DeleteDisposer { + void operator()(DrawingItem *item) { delete item; } +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp new file mode 100644 index 000000000..1a56eea9b --- /dev/null +++ b/src/display/drawing-shape.cpp @@ -0,0 +1,340 @@ +/** + * @file + * @brief Shape (styled path) belonging to an SVG drawing + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include <2geom/curves.h> +#include <2geom/pathvector.h> +#include <2geom/svg-path.h> +#include <2geom/svg-path-parser.h> + +#include "display/cairo-utils.h" +#include "display/canvas-arena.h" +#include "display/canvas-bpath.h" +#include "display/curve.h" +#include "display/drawing-context.h" +#include "display/drawing-group.h" +#include "display/drawing-shape.h" +#include "display/nr-arena.h" +#include "helper/geom-curves.h" +#include "helper/geom.h" +#include "libnr/nr-convert2geom.h" +#include "preferences.h" +#include "style.h" +#include "svg/svg.h" + +namespace Inkscape { + +DrawingShape::DrawingShape(Drawing *drawing) + : DrawingItem(drawing) + , _curve(NULL) + , _style(NULL) + , _last_pick(NULL) + , _repick_after(0) +{} + +DrawingShape::~DrawingShape() +{ + if (_style) + sp_style_unref(_style); + if (_curve) + _curve->unref(); +} + +void +DrawingShape::setPath(SPCurve *curve) +{ + _markForRendering(); + + if (_curve) { + _curve->unref(); + _curve = NULL; + } + if (curve) { + _curve = curve; + curve->ref(); + } + + _markForUpdate(STATE_ALL, false); +} + +void +DrawingShape::setStyle(SPStyle *style) +{ + _setStyleCommon(_style, style); + _nrstyle.set(style); +} + +void +DrawingShape::setPaintBox(Geom::Rect const &box) +{ + _paintbox = box; + _markForUpdate(STATE_ALL, false); +} + +unsigned +DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +{ + Geom::OptRect boundingbox; + + unsigned beststate = STATE_ALL; + + // update markers + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->update(area, ctx, flags, reset); + } + + if (!(flags & STATE_RENDER)) { + /* We do not have to create rendering structures */ + if (flags & STATE_BBOX) { + if (_curve) { + boundingbox = bounds_exact_transformed(_curve->get_pathvector(), ctx.ctm); + if (boundingbox) { + _bbox = boundingbox->roundOutwards(); + } else { + _bbox = Geom::OptIntRect(); + } + } + if (beststate & STATE_BBOX) { + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + _bbox.unionWith(i->geometricBounds()); + } + } + } + return (flags | _state); + } + + boundingbox = Geom::OptRect(); + bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + + // clear Cairo data to force update + _nrstyle.update(); + + if (_curve) { + boundingbox = bounds_exact_transformed(_curve->get_pathvector(), ctx.ctm); + + if (boundingbox && (_nrstyle.stroke.type != NRStyle::PAINT_NONE || outline)) { + float width, scale; + scale = ctx.ctm.descrim(); + width = std::max(0.125f, _nrstyle.stroke_width * scale); + if ( fabs(_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true + boundingbox->expandBy(width); + } + // those pesky miters, now + float miterMax = width * _nrstyle.miter_limit; + if ( miterMax > 0.01 ) { + // grunt mode. we should compute the various miters instead + // (one for each point on the curve) + boundingbox->expandBy(miterMax); + } + } + } + + _bbox = boundingbox ? boundingbox->roundOutwards() : Geom::OptIntRect(); + + if (!_curve || + !_style || + _curve->is_empty() || + (( _nrstyle.fill.type != NRStyle::PAINT_NONE ) && + ( _nrstyle.stroke.type != NRStyle::PAINT_NONE && !outline) )) + { + return STATE_ALL; + } + + if (beststate & STATE_BBOX) { + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + _bbox.unionWith(i->geometricBounds()); + } + } + + return STATE_ALL; +} + +void +DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + if (!_curve || !_style) return; + if (!area.intersects(_bbox)) return; // skip if not within bounding box + + bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + + if (outline) { + guint32 rgba = _drawing->outlinecolor; + + { Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); + ct.path(_curve->get_pathvector()); + } + { Inkscape::DrawingContext::Save save(ct); + ct.setSource(rgba); + ct.setLineWidth(0.5); + ct.setTolerance(1.25); + ct.stroke(); + } + } else { + bool has_stroke, has_fill; + // we assume the context has no path + Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); + + // update fill and stroke paints. + // this cannot be done during nr_arena_shape_update, because we need a Cairo context + // to render svg:pattern + has_fill = _nrstyle.prepareFill(ct, _paintbox); + has_stroke = _nrstyle.prepareStroke(ct, _paintbox); + has_stroke &= (_nrstyle.stroke_width != 0); + + if (has_fill || has_stroke) { + // TODO: remove segments outside of bbox when no dashes present + ct.path(_curve->get_pathvector()); + if (has_fill) { + _nrstyle.applyFill(ct); + ct.fillPreserve(); + } + if (has_stroke) { + _nrstyle.applyStroke(ct); + ct.strokePreserve(); + } + ct.newPath(); // clear path + } // has fill or stroke pattern + } + + // marker rendering + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->render(ct, area, flags); + } +} + +void +DrawingShape::_clipItem(DrawingContext &ct, Geom::IntRect const &area) +{ + if (!_curve) return; + + Inkscape::DrawingContext::Save save(ct); + // handle clip-rule + if (_style) { + if (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); + } else { + ct.setFillRule(CAIRO_FILL_RULE_WINDING); + } + } + ct.transform(_ctm); + ct.path(_curve->get_pathvector()); + ct.fill(); +} + +DrawingItem * +DrawingShape::_pickItem(Geom::Point const &p, double delta) +{ + if (_repick_after > 0) + --_repick_after; + + if (_repick_after > 0) // we are a slow, huge path. skip this pick, returning what was returned last time + return _last_pick; + + if (!_curve) return NULL; + if (!_style) return NULL; + + bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + + if (SP_SCALE24_TO_FLOAT(_style->opacity.value) == 0 && !outline) + // fully transparent, no pick unless outline mode + return NULL; + + GTimeVal tstart, tfinish; + g_get_current_time (&tstart); + + double width; + if (outline) { + width = 0.5; + } else if (_nrstyle.stroke.type != NRStyle::PAINT_NONE && _nrstyle.stroke.opacity > 1e-3) { + float const scale = _ctm.descrim(); + width = std::max(0.125f, _nrstyle.stroke_width * scale) / 2; + } else { + width = 0; + } + + double dist = Geom::infinity(); + int wind = 0; + bool needfill = (_nrstyle.fill.type != NRStyle::PAINT_NONE + && _nrstyle.fill.opacity > 1e-3 && !outline); + + if (_drawing->canvasarena) { + Geom::Rect viewbox = _drawing->canvasarena->item.canvas->getViewbox(); + viewbox.expandBy (width); + pathv_matrix_point_bbox_wind_distance(_curve->get_pathvector(), _ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, &viewbox); + } else { + pathv_matrix_point_bbox_wind_distance(_curve->get_pathvector(), _ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, NULL); + } + + g_get_current_time (&tfinish); + glong this_pick = (tfinish.tv_sec - tstart.tv_sec) * 1000000 + (tfinish.tv_usec - tstart.tv_usec); + //g_print ("pick time %lu\n", this_pick); + + if (this_pick > 10000) { // slow picking, remember to skip several new picks + _repick_after = this_pick / 5000; + } + + // covered by fill? + if (needfill) { + if (!_style->fill_rule.computed) { + if (wind != 0) { + _last_pick = this; + return this; + } + } else { + if (wind & 0x1) { + _last_pick = this; + return this; + } + } + } + + // close to the edge, as defined by strokewidth and delta? + // this ignores dashing (as if the stroke is solid) and always works as if caps are round + if (needfill || width > 0) { // if either fill or stroke visible, + if ((dist - width) < delta) { + _last_pick = this; + return this; + } + } + + // if not picked on the shape itself, try its markers + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + DrawingItem *ret = i->pick(p, delta, false); + if (ret) { + _last_pick = this; + return this; + } + } + + _last_pick = NULL; + return NULL; +} + +bool +DrawingShape::_canClip() +{ + return true; +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h new file mode 100644 index 000000000..7fd16374e --- /dev/null +++ b/src/display/drawing-shape.h @@ -0,0 +1,64 @@ +/** + * @file + * @brief Group belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_SHAPE_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_SHAPE_H + +#include "display/drawing-item.h" +#include "display/nr-style.h" + +class SPStyle; +class SPCurve; + +namespace Inkscape { + +class DrawingShape + : public DrawingItem +{ +public: + DrawingShape(Drawing *drawing); + ~DrawingShape(); + + void setPath(SPCurve *curve); + void setStyle(SPStyle *style); + void setPaintBox(Geom::Rect const &box); + +protected: + unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + unsigned flags, unsigned reset); + virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual bool _canClip(); + + SPCurve *_curve; + SPStyle *_style; + NRStyle _nrstyle; + + Geom::OptRect _paintbox; + DrawingItem *_last_pick; + unsigned _repick_after; +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp new file mode 100644 index 000000000..784888bd7 --- /dev/null +++ b/src/display/drawing-text.cpp @@ -0,0 +1,275 @@ +/** + * @file + * @brief Group belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/cairo-utils.h" +#include "display/canvas-bpath.h" // for SPWindRule (WTF!) +#include "display/drawing-context.h" +#include "display/drawing-surface.h" +#include "display/drawing-text.h" +#include "display/nr-arena.h" +#include "helper/geom.h" +#include "libnrtype/font-instance.h" +#include "style.h" + +namespace Inkscape { + +DrawingGlyphs::DrawingGlyphs(Drawing *drawing) + : DrawingItem(drawing) + , _glyph_transform(NULL) + , _font(NULL) + , _glyph(0) +{} + +DrawingGlyphs::~DrawingGlyphs() +{ + if (_font) { + _font->Unref(); + _font = NULL; + } + delete _glyph_transform; +} + +void +DrawingGlyphs::setGlyph(font_instance *font, int glyph, Geom::Affine const &trans) +{ + _markForRendering(); + + if (trans.isIdentity()) { + delete _glyph_transform; // delete NULL; is safe + _glyph_transform = NULL; + } else { + _glyph_transform = new Geom::Affine(trans); + } + + if (font) font->Ref(); + if (_font) _font->Unref(); + _font = font; + _glyph = glyph; + + _markForUpdate(STATE_ALL, false); +} + +unsigned +DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +{ + DrawingText *ggroup = dynamic_cast(_parent); + if (!ggroup) throw InvalidItemException(); + + if (!_font || !ggroup->_style) return STATE_ALL; + if (ggroup->_nrstyle.fill.type == NRStyle::PAINT_NONE && + ggroup->_nrstyle.stroke.type == NRStyle::PAINT_NONE) + { + return STATE_ALL; + } + + Geom::OptRect b; + Geom::Affine t = _glyph_transform ? *_glyph_transform * ctx.ctm : ctx.ctm; + _x = t[4]; + _y = t[5]; + + b = bounds_exact_transformed(*_font->PathVector(_glyph), t); + if (b && ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) { + float width, scale; + scale = ctx.ctm.descrim(); + width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); + if ( fabs(ggroup->_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true + b->expandBy(width); + } + // those pesky miters, now + float miterMax = width * ggroup->_nrstyle.miter_limit; + if ( miterMax > 0.01 ) { + // grunt mode. we should compute the various miters instead + // (one for each point on the curve) + b->expandBy(miterMax); + } + } + + if (b) { + _bbox = b->roundOutwards(); + } else { + _bbox = Geom::OptIntRect(); + } + + return STATE_ALL; +} + +DrawingItem * +DrawingGlyphs::_pickItem(Geom::Point const &p, double delta) +{ + if (!_font || !_bbox) return NULL; + + // With text we take a simple approach: pick if the point is in a characher bbox + Geom::Rect expanded(*_bbox); + expanded.expandBy(delta); + if (expanded.contains(p)) return this; + return NULL; +} + + + +DrawingText::DrawingText(Drawing *drawing) + : DrawingGroup(drawing) +{} + +DrawingText::~DrawingText() +{} + +void +DrawingText::clear() +{ + _markForRendering(); + _children.clear_and_dispose(DeleteDisposer()); +} + +void +DrawingText::addComponent(font_instance *font, int glyph, Geom::Affine const &trans) +{ + if (!font || !font->PathVector(glyph)) return; + + _markForRendering(); + DrawingGlyphs *ng = new DrawingGlyphs(_drawing); + ng->setGlyph(font, glyph, trans); + appendChild(ng); +} + +void +DrawingText::setStyle(SPStyle *style) +{ + _nrstyle.set(style); + DrawingGroup::setStyle(style); +} + +void +DrawingText::setPaintBox(Geom::OptRect const &box) +{ + _paintbox = box; + _markForUpdate(STATE_ALL, false); +} + +unsigned +DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +{ + _nrstyle.update(); + return DrawingGroup::_updateItem(area, ctx, flags, reset); +} + +void +DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + if (_drawing->rendermode == RENDERMODE_OUTLINE) { + DrawingContext::Save save(ct); + guint32 rgba = _drawing->outlinecolor; + ct.setSource(rgba); + ct.setTolerance(1.25); // low quality, but good enough for outline mode + ct.newPath(); + ct.transform(_ctm); + + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + DrawingGlyphs *g = dynamic_cast(&*i); + if (!g) throw InvalidItemException(); + + Inkscape::DrawingContext::Save save(ct); + if (g->_glyph_transform) { + ct.transform(*g->_glyph_transform); + } + ct.path(*g->_font->PathVector(g->_glyph)); + ct.fill(); + } + return; + } + + // NOTE: this is very similar to drawing-shape.cpp; the only difference is in path feeding + bool has_stroke, has_fill; + + Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); + + has_fill = _nrstyle.prepareFill(ct, _paintbox); + has_stroke = _nrstyle.prepareStroke(ct, _paintbox); + + if (has_fill || has_stroke) { + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + DrawingGlyphs *g = dynamic_cast(&*i); + if (!g) throw InvalidItemException(); + + Inkscape::DrawingContext::Save save(ct); + if (g->_glyph_transform) { + ct.transform(*g->_glyph_transform); + } + ct.path(*g->_font->PathVector(g->_glyph)); + } + + if (has_fill) { + _nrstyle.applyFill(ct); + ct.fillPreserve(); + } + if (has_stroke) { + _nrstyle.applyStroke(ct); + ct.strokePreserve(); + } + ct.newPath(); // clear path + } +} + +void +DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &area) +{ + Inkscape::DrawingContext::Save save(ct); + + // handle clip-rule + if (_style) { + if (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) { + ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); + } else { + ct.setFillRule(CAIRO_FILL_RULE_WINDING); + } + } + ct.transform(_ctm); + + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + DrawingGlyphs *g = dynamic_cast(&*i); + if (!g) throw InvalidItemException(); + + Inkscape::DrawingContext::Save save(ct); + if (g->_glyph_transform) { + ct.transform(*g->_glyph_transform); + } + ct.path(*g->_font->PathVector(g->_glyph)); + } + ct.fill(); +} + +DrawingItem * +DrawingText::_pickItem(Geom::Point const &p, double delta) +{ + DrawingItem *picked = DrawingGroup::_pickItem(p, delta); + if (picked) return this; + return NULL; +} + +bool +DrawingText::_canClip() +{ + return true; +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h new file mode 100644 index 000000000..58fecc067 --- /dev/null +++ b/src/display/drawing-text.h @@ -0,0 +1,84 @@ +/** + * @file + * @brief Group belonging to an SVG drawing element + *//* + * Authors: + * Krzysztof KosiÅ„ski + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_TEXT_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_TEXT_H + +#include "display/drawing-group.h" +#include "display/nr-style.h" + +class SPStyle; +class font_instance; + +namespace Inkscape { + +class DrawingGlyphs + : public DrawingItem +{ +public: + DrawingGlyphs(Drawing *drawing); + ~DrawingGlyphs(); + + void setGlyph(font_instance *font, int glyph, Geom::Affine const &trans); + +protected: + unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + unsigned flags, unsigned reset); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + + Geom::Affine *_glyph_transform; + font_instance *_font; + int _glyph; + float _x, _y; + + friend class DrawingText; +}; + +class DrawingText + : public DrawingGroup +{ +public: + DrawingText(Drawing *drawing); + ~DrawingText(); + + void clear(); + void addComponent(font_instance *font, int glyph, Geom::Affine const &trans); + void setStyle(SPStyle *style); + void setPaintBox(Geom::OptRect const &box); + +protected: + unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + unsigned flags, unsigned reset); + virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual bool _canClip(); + + Geom::OptRect _paintbox; + NRStyle _nrstyle; + + friend class DrawingGlyphs; +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/grayscale.cpp b/src/display/grayscale.cpp index 745a08c1e..e468044d3 100644 --- a/src/display/grayscale.cpp +++ b/src/display/grayscale.cpp @@ -82,7 +82,7 @@ guchar luminance(guchar r, guchar g, guchar b) { */ bool activeDesktopIsGrayscale() { if (SP_ACTIVE_DESKTOP) { - return (SP_ACTIVE_DESKTOP->getColorMode() == Inkscape::COLORRENDERMODE_GRAYSCALE); + return (SP_ACTIVE_DESKTOP->getColorMode() == Inkscape::COLORMODE_GRAYSCALE); } else { return false; } diff --git a/src/display/nr-arena-forward.h b/src/display/nr-arena-forward.h deleted file mode 100644 index 5a5cf228a..000000000 --- a/src/display/nr-arena-forward.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef __NR_ARENA_FORWARD_H__ -#define __NR_ARENA_FORWARD_H__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -struct NRArena; -struct NRArenaClass; - -struct NRArenaItem; -struct NRArenaItemClass; - -struct NRArenaGroup; -struct NRArenaGroupClass; - -struct NRArenaShape; -struct NRArenaShapeClass; - -struct NRArenaShapeGroup; -struct NRArenaShapeGroupClass; - -struct NRArenaImage; -struct NRArenaImageClass; - -struct NRArenaGlyphs; -struct NRArenaGlyphsClass; - -struct NRArenaGlyphsGroup; -struct NRArenaGlyphsGroupClass; - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp deleted file mode 100644 index 99b0a004e..000000000 --- a/src/display/nr-arena-glyphs.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2002 Lauris Kaplinski - * - * Released under GNU GPL - * - */ - - -#ifdef HAVE_CONFIG_H -# include -#endif -#include -#include <2geom/affine.h> -#include <2geom/rect.h> -#include "libnr/nr-convert2geom.h" -#include "style.h" -#include "display/nr-arena.h" -#include "display/nr-arena-glyphs.h" -#include "display/cairo-utils.h" -#include "display/drawing-context.h" -#include "helper/geom.h" - -#ifdef test_glyph_liv -#include "../display/canvas-bpath.h" -#include "libnrtype/font-instance.h" - -// defined in nr-arena-shape.cpp -void nr_pixblock_render_shape_mask_or(NRPixBlock &m, Shape *theS); -#endif - -#ifdef ENABLE_SVG_FONTS -#include "nr-svgfonts.h" -#endif //#ifdef ENABLE_SVG_FONTS - -static void nr_arena_glyphs_class_init(NRArenaGlyphsClass *klass); -static void nr_arena_glyphs_init(NRArenaGlyphs *glyphs); -static void nr_arena_glyphs_finalize(NRObject *object); - -static guint nr_arena_glyphs_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset); -static NRArenaItem *nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); - -static NRArenaItemClass *glyphs_parent_class; - -NRType -nr_arena_glyphs_get_type(void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type(NR_TYPE_ARENA_ITEM, - "NRArenaGlyphs", - sizeof(NRArenaGlyphsClass), - sizeof(NRArenaGlyphs), - (void (*)(NRObjectClass *)) nr_arena_glyphs_class_init, - (void (*)(NRObject *)) nr_arena_glyphs_init); - } - return type; -} - -static void -nr_arena_glyphs_class_init(NRArenaGlyphsClass *klass) -{ - NRObjectClass *object_class; - NRArenaItemClass *item_class; - - object_class = (NRObjectClass *) klass; - item_class = (NRArenaItemClass *) klass; - - glyphs_parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent; - - object_class->finalize = nr_arena_glyphs_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; - - item_class->update = nr_arena_glyphs_update; - item_class->pick = nr_arena_glyphs_pick; -} - -static void -nr_arena_glyphs_init(NRArenaGlyphs *glyphs) -{ - glyphs->g_transform.setIdentity(); - glyphs->font = NULL; - glyphs->glyph = 0; - glyphs->x = glyphs->y = 0.0; -} - -static void -nr_arena_glyphs_finalize(NRObject *object) -{ - NRArenaGlyphs *glyphs = static_cast(object); - - if (glyphs->font) { - glyphs->font->Unref(); - glyphs->font=NULL; - } - - ((NRObjectClass *) glyphs_parent_class)->finalize(object); -} - -static guint -nr_arena_glyphs_update(NRArenaItem *item, Geom::IntRect const &/*area*/, NRGC *gc, guint /*state*/, guint /*reset*/) -{ - NRArenaGlyphs *glyphs = NR_ARENA_GLYPHS(item); - NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item->parent); - - if (!glyphs->font || !ggroup->style) - return NR_ARENA_ITEM_STATE_ALL; - if (ggroup->nrstyle.fill.type == NRStyle::PAINT_NONE && ggroup->nrstyle.stroke.type == NRStyle::PAINT_NONE) - return NR_ARENA_ITEM_STATE_ALL; - - Geom::OptRect b; - Geom::Affine t = glyphs->g_transform * gc->transform; - glyphs->x = t[4]; - glyphs->y = t[5]; - - b = bounds_exact_transformed(*glyphs->font->PathVector(glyphs->glyph), t); - if (b && ggroup->nrstyle.stroke.type != NRStyle::PAINT_NONE) { - float width, scale; - scale = gc->transform.descrim(); - width = MAX(0.125, ggroup->nrstyle.stroke_width * scale); - if ( fabs(ggroup->nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true - b->expandBy(width); - } - // those pesky miters, now - float miterMax = width * ggroup->nrstyle.miter_limit; - if ( miterMax > 0.01 ) { - // grunt mode. we should compute the various miters instead - // (one for each point on the curve) - b->expandBy(miterMax); - } - } - - if (b) { - item->bbox = b->roundOutwards(); - } else { - item->bbox = Geom::OptIntRect(); - } - - return NR_ARENA_ITEM_STATE_ALL; -} - -static NRArenaItem * -nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point const &p, gdouble delta, unsigned int /*sticky*/) -{ - NRArenaGlyphs *glyphs; - - glyphs = NR_ARENA_GLYPHS(item); - - if (!glyphs->font ) return NULL; - if (!item->bbox) return NULL; - - // With text we take a simple approach: pick if the point is in a characher bbox - Geom::Rect expanded(*item->bbox); - expanded.expandBy(delta); - if (expanded.contains(p)) - return item; - return NULL; -} - -void -nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int /*lieutenant*/, font_instance *font, gint glyph, Geom::Affine const *transform) -{ - nr_return_if_fail(glyphs != NULL); - nr_return_if_fail(NR_IS_ARENA_GLYPHS(glyphs)); - - nr_arena_item_request_render(NR_ARENA_ITEM(glyphs)); - - if (transform) { - glyphs->g_transform = *transform; - } else { - glyphs->g_transform.setIdentity(); - } - - if (font) font->Ref(); - if (glyphs->font) glyphs->font->Unref(); - glyphs->font=font; - glyphs->glyph = glyph; - - nr_arena_item_request_update(NR_ARENA_ITEM(glyphs), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -static void nr_arena_glyphs_group_class_init(NRArenaGlyphsGroupClass *klass); -static void nr_arena_glyphs_group_init(NRArenaGlyphsGroup *group); -static void nr_arena_glyphs_group_finalize(NRObject *object); - -static guint nr_arena_glyphs_group_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset); -static unsigned int nr_arena_glyphs_group_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); -static unsigned int nr_arena_glyphs_group_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); -static NRArenaItem *nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point const &p, gdouble delta, unsigned int sticky); - -static NRArenaGroupClass *group_parent_class; - -NRType -nr_arena_glyphs_group_get_type(void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type(NR_TYPE_ARENA_GROUP, - "NRArenaGlyphsGroup", - sizeof(NRArenaGlyphsGroupClass), - sizeof(NRArenaGlyphsGroup), - (void (*)(NRObjectClass *)) nr_arena_glyphs_group_class_init, - (void (*)(NRObject *)) nr_arena_glyphs_group_init); - } - return type; -} - -static void -nr_arena_glyphs_group_class_init(NRArenaGlyphsGroupClass *klass) -{ - NRObjectClass *object_class; - NRArenaItemClass *item_class; - - object_class = (NRObjectClass *) klass; - item_class = (NRArenaItemClass *) klass; - - group_parent_class = (NRArenaGroupClass *) ((NRObjectClass *) klass)->parent; - - object_class->finalize = nr_arena_glyphs_group_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; - - item_class->update = nr_arena_glyphs_group_update; - item_class->render = nr_arena_glyphs_group_render; - item_class->clip = nr_arena_glyphs_group_clip; - item_class->pick = nr_arena_glyphs_group_pick; -} - -static void -nr_arena_glyphs_group_init(NRArenaGlyphsGroup *group) -{ - group->style = NULL; -} - -static void -nr_arena_glyphs_group_finalize(NRObject *object) -{ - NRArenaGlyphsGroup *group = static_cast(object); - - if (group->style) { - sp_style_unref(group->style); - group->style = NULL; - } - - ((NRObjectClass *) group_parent_class)->finalize(object); -} - -static guint -nr_arena_glyphs_group_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset) -{ - NRArenaGlyphsGroup *group = NR_ARENA_GLYPHS_GROUP(item); - - group->nrstyle.update(); - - if (((NRArenaItemClass *) group_parent_class)->update) - return ((NRArenaItemClass *) group_parent_class)->update(item, area, gc, state, reset); - - return NR_ARENA_ITEM_STATE_ALL; -} - - -static unsigned int -nr_arena_glyphs_group_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int /*flags*/) -{ - NRArenaItem *child = 0; - - NRArenaGroup *group = NR_ARENA_GROUP(item); - NRArenaGlyphsGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); - - if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { - Inkscape::DrawingContext::Save save(ct); - guint32 rgba = item->arena->outlinecolor; - ct.setSource(rgba); - ct.setTolerance(1.25); // low quality, but good enough for outline mode - ct.newPath(); - ct.transform(ggroup->ctm); - - for (child = group->children; child != NULL; child = child->next) { - NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); - - Geom::PathVector const * pathv = g->font->PathVector(g->glyph); - Geom::Affine transform = g->g_transform; - - Inkscape::DrawingContext::Save save(ct); - ct.transform(transform); - ct.path(*pathv); - ct.fill(); - } - return item->state; - } - - // NOTE: this is very similar to nr-arena-shape.cpp; the only difference is path feeding - bool has_stroke, has_fill; - - Inkscape::DrawingContext::Save save(ct); - ct.transform(ggroup->ctm); - - has_fill = ggroup->nrstyle.prepareFill(ct, ggroup->paintbox); - has_stroke = ggroup->nrstyle.prepareStroke(ct, ggroup->paintbox); - - if (has_fill || has_stroke) { - for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { - NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); - Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); - - Inkscape::DrawingContext::Save save(ct); - ct.transform(g->g_transform); - ct.path(pathv); - } - - if (has_fill) { - ggroup->nrstyle.applyFill(ct); - ct.fillPreserve(); - } - if (has_stroke) { - ggroup->nrstyle.applyStroke(ct); - ct.strokePreserve(); - } - ct.newPath(); // clear path - } // has fill or stroke pattern - - return item->state; -} - -static unsigned int nr_arena_glyphs_group_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/) -{ - NRArenaGroup *ggroup = NR_ARENA_GLYPHS_GROUP(item); - - Inkscape::DrawingContext::Save save(ct); - - // handle clip-rule - if (ggroup->style) { - if (ggroup->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); - } else { - ct.setFillRule(CAIRO_FILL_RULE_WINDING); - } - } - ct.transform(ggroup->ctm); - - for (NRArenaItem *child = ggroup->children; child != NULL; child = child->next) { - NRArenaGlyphs *g = NR_ARENA_GLYPHS(child); - Geom::PathVector const &pathv = *g->font->PathVector(g->glyph); - - Inkscape::DrawingContext::Save save(ct); - ct.transform(g->g_transform); - ct.path(pathv); - } - ct.fill(); - - return item->state; -} - -static NRArenaItem * -nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point const &p, gdouble delta, unsigned int sticky) -{ - NRArenaItem *picked = NULL; - - if (((NRArenaItemClass *) group_parent_class)->pick) - picked = ((NRArenaItemClass *) group_parent_class)->pick(item, p, delta, sticky); - - if (picked) picked = item; - - return picked; -} - -void -nr_arena_glyphs_group_clear(NRArenaGlyphsGroup *sg) -{ - NRArenaGroup *group = NR_ARENA_GROUP(sg); - - nr_arena_item_request_render(NR_ARENA_ITEM(group)); - - while (group->children) { - nr_arena_item_remove_child(NR_ARENA_ITEM(group), group->children); - } -} - -void -nr_arena_glyphs_group_add_component(NRArenaGlyphsGroup *sg, font_instance *font, int glyph, Geom::Affine const &transform) -{ - NRArenaGroup *group; - - group = NR_ARENA_GROUP(sg); - - Geom::PathVector const * pathv = ( font - ? font->PathVector(glyph) - : NULL ); - if ( pathv ) { - nr_arena_item_request_render(NR_ARENA_ITEM(group)); - - NRArenaItem *new_arena = NRArenaGlyphs::create(group->arena); - nr_arena_item_append_child(NR_ARENA_ITEM(group), new_arena); - nr_arena_item_unref(new_arena); - nr_arena_glyphs_set_path(NR_ARENA_GLYPHS(new_arena), NULL, FALSE, font, glyph, &transform); - } -} - -void -nr_arena_glyphs_group_set_style(NRArenaGlyphsGroup *sg, SPStyle *style) -{ - nr_return_if_fail(sg != NULL); - nr_return_if_fail(NR_IS_ARENA_GLYPHS_GROUP(sg)); - - if (style) sp_style_ref(style); - if (sg->style) sp_style_unref(sg->style); - sg->style = style; - - sg->nrstyle.set(style); - - nr_arena_item_request_update(NR_ARENA_ITEM(sg), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void -nr_arena_glyphs_group_set_paintbox(NRArenaGlyphsGroup *gg, NRRect const *pbox) -{ - nr_return_if_fail(gg != NULL); - nr_return_if_fail(NR_IS_ARENA_GLYPHS_GROUP(gg)); - nr_return_if_fail(pbox != NULL); - - gg->paintbox = pbox->upgrade_2geom(); - - nr_arena_item_request_update(NR_ARENA_ITEM(gg), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-glyphs.h b/src/display/nr-arena-glyphs.h deleted file mode 100644 index 4b2aed7b9..000000000 --- a/src/display/nr-arena-glyphs.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef SEEN_NR_ARENA_GLYPHS_H -#define SEEN_NR_ARENA_GLYPHS_H - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2002 Lauris Kaplinski - * - * Released under GNU GPL - * - */ - -#define NR_TYPE_ARENA_GLYPHS (nr_arena_glyphs_get_type ()) -#define NR_ARENA_GLYPHS(obj) (NR_CHECK_INSTANCE_CAST ((obj), NR_TYPE_ARENA_GLYPHS, NRArenaGlyphs)) -#define NR_IS_ARENA_GLYPHS(obj) (NR_CHECK_INSTANCE_TYPE ((obj), NR_TYPE_ARENA_GLYPHS)) - -#include "libnrtype/nrtype-forward.h" -#include "display/display-forward.h" -#include "forward.h" -#include "display/nr-arena-item.h" -#include "display/nr-style.h" - -#define test_glyph_liv - -struct SPCurve; -class Shape; -class SPPainter; - -NRType nr_arena_glyphs_get_type (void); - -struct NRArenaGlyphs : public NRArenaItem { - /* Glyphs data */ - Geom::Affine g_transform; - - font_instance *font; - gint glyph; - float x, y; - - static NRArenaGlyphs *create(NRArena *arena) { - NRArenaGlyphs *obj=reinterpret_cast(nr_object_new(NR_TYPE_ARENA_GLYPHS)); - obj->init(arena); - return obj; - } -}; - -struct NRArenaGlyphsClass { - NRArenaItemClass parent_class; -}; - -void nr_arena_glyphs_set_path ( NRArenaGlyphs *glyphs, - SPCurve *curve, unsigned int lieutenant, - font_instance *font, int glyph, - Geom::Affine const *transform ); -void nr_arena_glyphs_set_style (NRArenaGlyphs *glyphs, SPStyle *style); - -/* Integrated group of component glyphss */ - -typedef struct NRArenaGlyphsGroup NRArenaGlyphsGroup; -typedef struct NRArenaGlyphsGroupClass NRArenaGlyphsGroupClass; - -#include "nr-arena-group.h" - -#define NR_TYPE_ARENA_GLYPHS_GROUP (nr_arena_glyphs_group_get_type ()) -#define NR_ARENA_GLYPHS_GROUP(obj) (NR_CHECK_INSTANCE_CAST ((obj), NR_TYPE_ARENA_GLYPHS_GROUP, NRArenaGlyphsGroup)) -#define NR_IS_ARENA_GLYPHS_GROUP(obj) (NR_CHECK_INSTANCE_TYPE ((obj), NR_TYPE_ARENA_GLYPHS_GROUP)) - -NRType nr_arena_glyphs_group_get_type (void); - -struct NRArenaGlyphsGroup : public NRArenaGroup { - Geom::OptRect paintbox; - NRStyle nrstyle; - - static NRArenaGlyphsGroup *create(NRArena *arena) { - NRArenaGlyphsGroup *obj=reinterpret_cast(nr_object_new(NR_TYPE_ARENA_GLYPHS_GROUP)); - obj->init(arena); - return obj; - } -}; - -struct NRArenaGlyphsGroupClass { - NRArenaGroupClass parent_class; -}; - -/* Utility functions */ - -void nr_arena_glyphs_group_clear (NRArenaGlyphsGroup *group); - -void nr_arena_glyphs_group_add_component (NRArenaGlyphsGroup *group, font_instance *font, int glyph, Geom::Affine const &transform); - -void nr_arena_glyphs_group_set_style (NRArenaGlyphsGroup *group, SPStyle *style); - -void nr_arena_glyphs_group_set_paintbox (NRArenaGlyphsGroup *group, const NRRect *pbox); - -#endif // SEEN_NR_ARENA_GLYPHS_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp deleted file mode 100644 index 1f7c421d0..000000000 --- a/src/display/nr-arena-group.cpp +++ /dev/null @@ -1,300 +0,0 @@ -#define __NR_ARENA_GROUP_C__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/canvas-bpath.h" -#include "display/nr-arena.h" -#include "display/nr-arena-group.h" -#include "display/nr-filter.h" -#include "display/nr-filter-types.h" -#include "display/rendermode.h" -#include "style.h" -#include "sp-filter.h" -#include "sp-filter-reference.h" -#include "filters/blend.h" -#include "display/nr-filter-blend.h" -#include "helper/geom.h" -#include "display/drawing-context.h" - -static void nr_arena_group_class_init (NRArenaGroupClass *klass); -static void nr_arena_group_init (NRArenaGroup *group); - -static NRArenaItem *nr_arena_group_children (NRArenaItem *item); -static NRArenaItem *nr_arena_group_last_child (NRArenaItem *item); -static void nr_arena_group_add_child (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); -static void nr_arena_group_remove_child (NRArenaItem *item, NRArenaItem *child); -static void nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); - -static unsigned int nr_arena_group_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); -static unsigned int nr_arena_group_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); -static unsigned int nr_arena_group_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); -static NRArenaItem *nr_arena_group_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); - -static NRArenaItemClass *parent_class; - -NRType -nr_arena_group_get_type (void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type (NR_TYPE_ARENA_ITEM, - "NRArenaGroup", - sizeof (NRArenaGroupClass), - sizeof (NRArenaGroup), - (void (*) (NRObjectClass *)) nr_arena_group_class_init, - (void (*) (NRObject *)) nr_arena_group_init); - } - return type; -} - -static void -nr_arena_group_class_init (NRArenaGroupClass *klass) -{ - NRObjectClass *object_class; - NRArenaItemClass *item_class; - - object_class = (NRObjectClass *) klass; - item_class = (NRArenaItemClass *) klass; - - parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent; - - object_class->cpp_ctor = NRObject::invoke_ctor; - - item_class->children = nr_arena_group_children; - item_class->last_child = nr_arena_group_last_child; - item_class->add_child = nr_arena_group_add_child; - item_class->set_child_position = nr_arena_group_set_child_position; - item_class->remove_child = nr_arena_group_remove_child; - item_class->update = nr_arena_group_update; - item_class->render = nr_arena_group_render; - item_class->clip = nr_arena_group_clip; - item_class->pick = nr_arena_group_pick; -} - -static void -nr_arena_group_init (NRArenaGroup *group) -{ - group->transparent = FALSE; - group->children = NULL; - group->last = NULL; - group->style = NULL; - group->child_transform.setIdentity(); -} - -static NRArenaItem * -nr_arena_group_children (NRArenaItem *item) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - return group->children; -} - -static NRArenaItem * -nr_arena_group_last_child (NRArenaItem *item) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - return group->last; -} - -static void -nr_arena_group_add_child (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - if (!ref) { - group->children = nr_arena_item_attach (item, child, NULL, group->children); - } else { - ref->next = nr_arena_item_attach (item, child, ref, ref->next); - } - - if (ref == group->last) group->last = child; - - nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -static void -nr_arena_group_remove_child (NRArenaItem *item, NRArenaItem *child) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - if (child == group->last) group->last = child->prev; - - if (child->prev) { - nr_arena_item_detach (item, child); - } else { - group->children = nr_arena_item_detach (item, child); - } - - nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -static void -nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - if (child == group->last) group->last = child->prev; - - if (child->prev) { - nr_arena_item_detach (item, child); - } else { - group->children = nr_arena_item_detach (item, child); - } - - if (!ref) { - group->children = nr_arena_item_attach (item, child, NULL, group->children); - } else { - ref->next = nr_arena_item_attach (item, child, ref, ref->next); - } - - if (ref == group->last) group->last = child; - - nr_arena_item_request_render (child); -} - -static unsigned int -nr_arena_group_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset) -{ - unsigned int newstate; - NRArenaGroup *group = NR_ARENA_GROUP (item); - unsigned int beststate = NR_ARENA_ITEM_STATE_ALL; - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - NRGC cgc(gc); - cgc.transform = group->child_transform * gc->transform; - newstate = nr_arena_item_invoke_update (child, area, &cgc, state, reset); - beststate = beststate & newstate; - } - - if (beststate & NR_ARENA_ITEM_STATE_BBOX) { - item->bbox = Geom::OptIntRect(); - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - if (child->visible) - item->bbox.unionWith(outline ? child->bbox : child->drawbox); - } - } - - return beststate; -} - -void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) -{ - g_return_if_fail(group != NULL); - g_return_if_fail(NR_IS_ARENA_GROUP(group)); - - if (style) sp_style_ref(style); - if (group->style) sp_style_unref(group->style); - group->style = style; - - //if group has a filter - if (style->filter.set && style->getFilter()) { - if (!group->filter) { - int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); - group->filter = new Inkscape::Filters::Filter(primitives); - } - sp_filter_build_renderer(SP_FILTER(style->getFilter()), group->filter); - } else { - //no filter set for this group - delete group->filter; - group->filter = NULL; - } - - if (style && style->enable_background.set - && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { - group->background_new = true; - } -} - -static unsigned int -nr_arena_group_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - unsigned int ret = item->state; - - /* Just compose children into parent buffer */ - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - ret = nr_arena_item_invoke_render (ct, child, area, flags); - if (ret & NR_ARENA_ITEM_STATE_INVALID) break; - } - - return ret; -} - -static unsigned int -nr_arena_group_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - unsigned int ret = item->state; - - for (NRArenaItem *child = group->children; child != NULL; child = child->next) { - ret = nr_arena_item_invoke_clip (ct, child, area); - if (ret & NR_ARENA_ITEM_STATE_INVALID) break; - } - - return ret; -} - -static NRArenaItem * -nr_arena_group_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky) -{ - NRArenaGroup *group = NR_ARENA_GROUP (item); - - for (NRArenaItem *child = group->last; child != NULL; child = child->prev) { - NRArenaItem *picked = nr_arena_item_invoke_pick (child, p, delta, sticky); - if (picked) - return (group->transparent) ? picked : item; - } - - return NULL; -} - -void -nr_arena_group_set_transparent (NRArenaGroup *group, unsigned int transparent) -{ - nr_return_if_fail (group != NULL); - nr_return_if_fail (NR_IS_ARENA_GROUP (group)); - - group->transparent = transparent; -} - -void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Affine const &t) -{ - Geom::Affine nt(t); - nr_arena_group_set_child_transform(group, &nt); -} - -void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Affine const *t) -{ - if (!t) t = &GEOM_MATRIX_IDENTITY; - - if (!Geom::matrix_equalp(*t, group->child_transform, NR_EPSILON)) { - nr_arena_item_request_render (NR_ARENA_ITEM (group)); - group->child_transform = *t; - nr_arena_item_request_update (NR_ARENA_ITEM (group), NR_ARENA_ITEM_STATE_ALL, TRUE); - } -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-group.h b/src/display/nr-arena-group.h deleted file mode 100644 index 58394643c..000000000 --- a/src/display/nr-arena-group.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __NR_ARENA_GROUP_H__ -#define __NR_ARENA_GROUP_H__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001 Lauris Kaplinski and Ximian, Inc. - * - * Released under GNU GPL - * - */ - -#define NR_TYPE_ARENA_GROUP (nr_arena_group_get_type ()) -#define NR_ARENA_GROUP(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA_GROUP, NRArenaGroup)) -#define NR_IS_ARENA_GROUP(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA_GROUP)) - -#include "nr-arena-item.h" -#include "style.h" - -NRType nr_arena_group_get_type (void); - -struct NRArenaGroup : public NRArenaItem{ - unsigned int transparent : 1; - NRArenaItem *children; - NRArenaItem *last; - Geom::Affine child_transform; - SPStyle *style; - - static NRArenaGroup *create(NRArena *arena) { - NRArenaGroup *obj = reinterpret_cast(nr_object_new(NR_TYPE_ARENA_GROUP)); - obj->init(arena); - return obj; - } -}; - -struct NRArenaGroupClass { - NRArenaItemClass parent_class; -}; - -void nr_arena_group_set_transparent(NRArenaGroup *group, unsigned int transparent); - -void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Affine const &t); -void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Affine const *t); -void nr_arena_group_set_style(NRArenaGroup *group, SPStyle *style); - -#endif - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp deleted file mode 100644 index 5336fcda9..000000000 --- a/src/display/nr-arena-image.cpp +++ /dev/null @@ -1,390 +0,0 @@ -#define __NR_ARENA_IMAGE_C__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <2geom/transforms.h> -#include "../preferences.h" -#include "nr-arena-image.h" -#include "style.h" -#include "display/cairo-utils.h" -#include "display/drawing-context.h" -#include "display/nr-arena.h" -#include "display/nr-filter.h" -#include "sp-filter.h" -#include "sp-filter-reference.h" - -int nr_arena_image_x_sample = 1; -int nr_arena_image_y_sample = 1; - -/* - * NRArenaCanvasImage - * - */ - -static void nr_arena_image_class_init (NRArenaImageClass *klass); -static void nr_arena_image_init (NRArenaImage *image); -static void nr_arena_image_finalize (NRObject *object); - -static unsigned int nr_arena_image_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); -static unsigned int nr_arena_image_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); -static NRArenaItem *nr_arena_image_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); -static Geom::Rect nr_arena_image_rect (NRArenaImage *image); - -static NRArenaItemClass *parent_class; - -NRType -nr_arena_image_get_type (void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type (NR_TYPE_ARENA_ITEM, - "NRArenaImage", - sizeof (NRArenaImageClass), - sizeof (NRArenaImage), - (void (*) (NRObjectClass *)) nr_arena_image_class_init, - (void (*) (NRObject *)) nr_arena_image_init); - } - return type; -} - -static void -nr_arena_image_class_init (NRArenaImageClass *klass) -{ - NRObjectClass *object_class; - NRArenaItemClass *item_class; - - object_class = (NRObjectClass *) klass; - item_class = (NRArenaItemClass *) klass; - - parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent; - - object_class->finalize = nr_arena_image_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; - - item_class->update = nr_arena_image_update; - item_class->render = nr_arena_image_render; - item_class->pick = nr_arena_image_pick; -} - -static void -nr_arena_image_init (NRArenaImage *image) -{ - image->pixbuf = NULL; - image->ctm.setIdentity(); - image->clipbox = Geom::Rect(); - image->ox = image->oy = 0.0; - image->sx = image->sy = 1.0; - - image->style = 0; - image->render_opacity = TRUE; -} - -static void -nr_arena_image_finalize (NRObject *object) -{ - NRArenaImage *image = NR_ARENA_IMAGE (object); - - if (image->pixbuf != NULL) { - g_object_unref(image->pixbuf); - cairo_surface_destroy(image->surface); - } - if (image->style) - sp_style_unref(image->style); - - ((NRObjectClass *) parent_class)->finalize (object); -} - -static unsigned int -nr_arena_image_update( NRArenaItem *item, Geom::IntRect const &/*area*/, NRGC *gc, unsigned int /*state*/, unsigned int /*reset*/ ) -{ - // clear old bbox - nr_arena_item_request_render(item); - - NRArenaImage *image = NR_ARENA_IMAGE (item); - - /* Copy affine */ - image->ctm = gc->transform; - - /* Calculate bbox */ - if (image->pixbuf) { - Geom::Rect r = nr_arena_image_rect(image) * gc->transform; - item->bbox = r.roundOutwards(); - } else { - item->bbox = Geom::OptIntRect(); - } - - return NR_ARENA_ITEM_STATE_ALL; -} - -static unsigned int nr_arena_image_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/, unsigned int /*flags*/ ) -{ - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - NRArenaImage *image = NR_ARENA_IMAGE (item); - - if (!outline) { - if (!image->pixbuf) { - return item->state; - } - - // FIXME: at the moment gdk_cairo_set_source_pixbuf creates an ARGB copy - // of the pixbuf. Fix this in Cairo and/or GDK. - Inkscape::DrawingContext::Save save(ct); - ct.transform(image->ctm); - ct.newPath(); - ct.rectangle(image->clipbox); - ct.clip(); - - ct.translate(image->ox, image->oy); - ct.scale(image->sx, image->sy); - ct.setSource(image->surface, 0, 0); - - cairo_matrix_t tt; - Geom::Affine total; - cairo_get_matrix(ct.raw(), &tt); - ink_matrix_to_2geom(total, tt); - - if (total.expansionX() > 1.0 || total.expansionY() > 1.0) { - cairo_pattern_t *p = cairo_get_source(ct.raw()); - cairo_pattern_set_filter(p, CAIRO_FILTER_NEAREST); - } - ct.paint(((double) item->opacity) / 255.0); - - } else { // outline; draw a rect instead - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); - - { Inkscape::DrawingContext::Save save(ct); - ct.transform(image->ctm); - ct.newPath(); - - Geom::Rect r = nr_arena_image_rect (image); - Geom::Point c00 = r.corner(0); - Geom::Point c01 = r.corner(3); - Geom::Point c11 = r.corner(2); - Geom::Point c10 = r.corner(1); - - ct.moveTo(c00); - // the box - ct.lineTo(c10); - ct.lineTo(c11); - ct.lineTo(c01); - ct.lineTo(c00); - // the diagonals - ct.lineTo(c11); - ct.moveTo(c10); - ct.lineTo(c01); - } - - ct.setLineWidth(0.5); - ct.setSource(rgba); - ct.stroke(); - } - return item->state; -} - -/** Calculates the closest distance from p to the segment a1-a2*/ -double -distance_to_segment (Geom::Point const &p, Geom::Point const &a1, Geom::Point const &a2) -{ - // calculate sides of the triangle and their squares - double d1 = Geom::L2(p - a1); - double d1_2 = d1 * d1; - double d2 = Geom::L2(p - a2); - double d2_2 = d2 * d2; - double a = Geom::L2(a1 - a2); - double a_2 = a * a; - - // if one of the angles at the base is > 90, return the corresponding side - if (d1_2 + a_2 <= d2_2) return d1; - if (d2_2 + a_2 <= d1_2) return d2; - - // otherwise calculate the height to the base - double peri = (a + d1 + d2)/2; - return (2*sqrt(peri * (peri - a) * (peri - d1) * (peri - d2))/a); -} - -static NRArenaItem * -nr_arena_image_pick( NRArenaItem *item, Geom::Point const &p, double delta, unsigned int /*sticky*/ ) -{ - NRArenaImage *image = NR_ARENA_IMAGE (item); - - if (!image->pixbuf) return NULL; - - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - if (outline) { - Geom::Rect r = nr_arena_image_rect (image); - - Geom::Point c00 = r.corner(0); - Geom::Point c01 = r.corner(3); - Geom::Point c11 = r.corner(2); - Geom::Point c10 = r.corner(1); - - // frame - if (distance_to_segment (p, c00, c10) < delta) return item; - if (distance_to_segment (p, c10, c11) < delta) return item; - if (distance_to_segment (p, c11, c01) < delta) return item; - if (distance_to_segment (p, c01, c00) < delta) return item; - - // diagonals - if (distance_to_segment (p, c00, c11) < delta) return item; - if (distance_to_segment (p, c10, c01) < delta) return item; - - return NULL; - - } else { - - unsigned char *const pixels = gdk_pixbuf_get_pixels(image->pixbuf); - int const width = gdk_pixbuf_get_width(image->pixbuf); - int const height = gdk_pixbuf_get_height(image->pixbuf); - int const rowstride = gdk_pixbuf_get_rowstride(image->pixbuf); - - Geom::Point tp = p * image->ctm.inverse(); - Geom::Rect r = nr_arena_image_rect(image); - - if (!r.contains(tp)) - return NULL; - - double vw = width * image->sx; - double vh = height * image->sy; - int ix = floor((tp[Geom::X] - image->ox) / vw * width); - int iy = floor((tp[Geom::Y] - image->oy) / vh * height); - - if ((ix < 0) || (iy < 0) || (ix >= width) || (iy >= height)) - return NULL; - - unsigned char *pix_ptr = pixels + iy * rowstride + ix * 4; - // is the alpha not transparent? - return (pix_ptr[3] > 0) ? item : NULL; - } -} - -Geom::Rect -nr_arena_image_rect (NRArenaImage *image) -{ - Geom::Rect r = image->clipbox; - - if (image->pixbuf) { - double pw = gdk_pixbuf_get_width(image->pixbuf); - double ph = gdk_pixbuf_get_height(image->pixbuf); - double vw = pw * image->sx; - double vh = ph * image->sy; - Geom::Point p(image->ox, image->oy); - Geom::Point wh(vw, vh); - Geom::Rect view(p, p+wh); - Geom::OptRect res = r & view; - r = res ? *res : r; - } - - return r; -} - -/* Utility */ - -void -nr_arena_image_set_argb32_pixbuf (NRArenaImage *image, GdkPixbuf *pb) -{ - nr_return_if_fail (image != NULL); - nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); - - // when done in this order, it won't break if pb == image->pixbuf and the refcount is 1 - if (pb != NULL) { - g_object_ref (pb); - } - if (image->pixbuf != NULL) { - g_object_unref(image->pixbuf); - cairo_surface_destroy(image->surface); - } - image->pixbuf = pb; - image->surface = pb ? ink_cairo_surface_create_for_argb32_pixbuf(pb) : NULL; - - nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void -nr_arena_image_set_clipbox (NRArenaImage *image, Geom::Rect const &clip) -{ - nr_return_if_fail (image != NULL); - nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); - - image->clipbox = clip; - - nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void -nr_arena_image_set_origin (NRArenaImage *image, Geom::Point const &origin) -{ - nr_return_if_fail (image != NULL); - nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); - - image->ox = origin[Geom::X]; - image->oy = origin[Geom::Y]; - - nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void -nr_arena_image_set_scale (NRArenaImage *image, double sx, double sy) -{ - nr_return_if_fail (image != NULL); - nr_return_if_fail (NR_IS_ARENA_IMAGE (image)); - - image->sx = sx; - image->sy = sy; - - nr_arena_item_request_update (NR_ARENA_ITEM (image), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style) -{ - g_return_if_fail(image != NULL); - g_return_if_fail(NR_IS_ARENA_IMAGE(image)); - - if (style) sp_style_ref(style); - if (image->style) sp_style_unref(image->style); - image->style = style; - - //if image has a filter - if (style->filter.set && style->getFilter()) { - if (!image->filter) { - int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); - image->filter = new Inkscape::Filters::Filter(primitives); - } - sp_filter_build_renderer(SP_FILTER(style->getFilter()), image->filter); - } else { - //no filter set for this image - delete image->filter; - image->filter = NULL; - } - - if (style && style->enable_background.set - && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { - image->background_new = true; - } - - nr_arena_item_request_update(image, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-image.h b/src/display/nr-arena-image.h deleted file mode 100644 index 6fa9223dd..000000000 --- a/src/display/nr-arena-image.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef __NR_ARENA_IMAGE_H__ -#define __NR_ARENA_IMAGE_H__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include <2geom/rect.h> -#include "nr-arena-item.h" -#include "style.h" - -#define NR_TYPE_ARENA_IMAGE (nr_arena_image_get_type ()) -#define NR_ARENA_IMAGE(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA_IMAGE, NRArenaImage)) -#define NR_IS_ARENA_IMAGE(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA_IMAGE)) - -NRType nr_arena_image_get_type (void); - -struct NRArenaImage : public NRArenaItem { - GdkPixbuf *pixbuf; - cairo_surface_t *surface; - - Geom::Affine ctm; - Geom::Rect clipbox; - double ox, oy; - double sx, sy; - - SPStyle *style; - - static NRArenaImage *create(NRArena *arena) { - NRArenaImage *obj=reinterpret_cast(nr_object_new(NR_TYPE_ARENA_IMAGE)); - obj->init(arena); - return obj; - } -}; - -struct NRArenaImageClass { - NRArenaItemClass parent_class; -}; - -void nr_arena_image_set_argb32_pixbuf (NRArenaImage *image, GdkPixbuf *pb); -void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style); -void nr_arena_image_set_clipbox (NRArenaImage *image, Geom::Rect const &clip); -void nr_arena_image_set_origin (NRArenaImage *image, Geom::Point const &origin); -void nr_arena_image_set_scale (NRArenaImage *image, double sx, double sy); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp deleted file mode 100644 index 264b8ab10..000000000 --- a/src/display/nr-arena-item.cpp +++ /dev/null @@ -1,932 +0,0 @@ -#define __NR_ARENA_ITEM_C__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#define noNR_ARENA_ITEM_VERBOSE -#define noNR_ARENA_ITEM_DEBUG_CASCADE - -#include -#include -#include - -#include "display/cairo-utils.h" -#include "display/cairo-templates.h" -#include "display/drawing-context.h" -#include "display/drawing-surface.h" -#include "display/canvas-arena.h" -#include "nr-arena.h" -#include "nr-arena-item.h" -#include "gc-core.h" -#include "helper/geom.h" - -#include "nr-filter.h" -#include "nr-arena-group.h" -#include "preferences.h" - -namespace GC = Inkscape::GC; - -static void nr_arena_item_class_init (NRArenaItemClass *klass); -static void nr_arena_item_init (NRArenaItem *item); -static void nr_arena_item_private_finalize (NRObject *object); - -static NRObjectClass *parent_class; - -NRType -nr_arena_item_get_type (void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type (NR_TYPE_OBJECT, - "NRArenaItem", - sizeof (NRArenaItemClass), - sizeof (NRArenaItem), - (void (*)(NRObjectClass *)) - nr_arena_item_class_init, - (void (*)(NRObject *)) - nr_arena_item_init); - } - return type; -} - -static void -nr_arena_item_class_init (NRArenaItemClass *klass) -{ - NRObjectClass *object_class; - - object_class = (NRObjectClass *) klass; - - parent_class = ((NRObjectClass *) klass)->parent; - - object_class->finalize = nr_arena_item_private_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor < NRArenaItem >; -} - -static void -nr_arena_item_init (NRArenaItem *item) -{ - item->arena = NULL; - item->parent = NULL; - item->next = item->prev = NULL; - - item->key = 0; - - item->state = 0; - item->sensitive = TRUE; - item->visible = TRUE; - - memset (&item->bbox, 0, sizeof (item->bbox)); - memset (&item->drawbox, 0, sizeof (item->drawbox)); - item->transform = NULL; - item->ctm.setIdentity(); - item->opacity = 255; - item->render_opacity = FALSE; - item->render_cache = FALSE; - - item->transform = NULL; - item->clip = NULL; - item->mask = NULL; - item->cache = NULL; - item->data = NULL; - item->filter = NULL; - item->background_new = false; -} - -static void -nr_arena_item_private_finalize (NRObject *object) -{ - NRArenaItem *item = static_cast < NRArenaItem * >(object); - - item->transform = NULL; - - if (item->clip) - nr_arena_item_detach(item, item->clip); - if (item->mask) - nr_arena_item_detach(item, item->mask); - delete item->cache; - - ((NRObjectClass *) (parent_class))->finalize (object); -} - -NRArenaItem * -nr_arena_item_children (NRArenaItem *item) -{ - nr_return_val_if_fail (item != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), NULL); - - if (NR_ARENA_ITEM_VIRTUAL (item, children)) - return NR_ARENA_ITEM_VIRTUAL (item, children) (item); - - return NULL; -} - -NRArenaItem * -nr_arena_item_last_child (NRArenaItem *item) -{ - nr_return_val_if_fail (item != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), NULL); - - if (NR_ARENA_ITEM_VIRTUAL (item, last_child)) { - return NR_ARENA_ITEM_VIRTUAL (item, last_child) (item); - } else { - NRArenaItem *ref = nr_arena_item_children (item); - if (ref) - while (ref->next) - ref = ref->next; - return ref; - } -} - -void -nr_arena_item_add_child (NRArenaItem *item, NRArenaItem *child, - NRArenaItem *ref) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_return_if_fail (child != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (child)); - nr_return_if_fail (child->parent == NULL); - nr_return_if_fail (child->prev == NULL); - nr_return_if_fail (child->next == NULL); - nr_return_if_fail (child->arena == item->arena); - nr_return_if_fail (child != ref); - nr_return_if_fail (!ref || NR_IS_ARENA_ITEM (ref)); - nr_return_if_fail (!ref || (ref->parent == item)); - - if (NR_ARENA_ITEM_VIRTUAL (item, add_child)) - NR_ARENA_ITEM_VIRTUAL (item, add_child) (item, child, ref); -} - -void -nr_arena_item_remove_child (NRArenaItem *item, NRArenaItem *child) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_return_if_fail (child != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (child)); - nr_return_if_fail (child->parent == item); - - if (NR_ARENA_ITEM_VIRTUAL (item, remove_child)) - NR_ARENA_ITEM_VIRTUAL (item, remove_child) (item, child); -} - -void -nr_arena_item_set_child_position (NRArenaItem *item, NRArenaItem *child, - NRArenaItem *ref) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_return_if_fail (child != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (child)); - nr_return_if_fail (child->parent == item); - nr_return_if_fail (!ref || NR_IS_ARENA_ITEM (ref)); - nr_return_if_fail (!ref || (ref->parent == item)); - - if (NR_ARENA_ITEM_VIRTUAL (item, set_child_position)) - NR_ARENA_ITEM_VIRTUAL (item, set_child_position) (item, child, ref); -} - -NRArenaItem * -nr_arena_item_ref (NRArenaItem *item) -{ - nr_object_ref ((NRObject *) item); - - return item; -} - -NRArenaItem * -nr_arena_item_unref (NRArenaItem *item) -{ - nr_object_unref ((NRObject *) item); - - return NULL; -} - -unsigned int -nr_arena_item_invoke_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, - unsigned int state, unsigned int reset) -{ - NRGC childgc (gc); - bool filter = (item->arena->rendermode == Inkscape::RENDERMODE_NORMAL); - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), - NR_ARENA_ITEM_STATE_INVALID); - nr_return_val_if_fail (!(state & NR_ARENA_ITEM_STATE_INVALID), - NR_ARENA_ITEM_STATE_INVALID); - -#ifdef NR_ARENA_ITEM_DEBUG_CASCADE - printf ("Update %s:%p %x %x %x\n", - nr_type_name_from_instance ((GTypeInstance *) item), item, state, - item->state, reset); -#endif - - /* return if in error */ - if (item->state & NR_ARENA_ITEM_STATE_INVALID) - return item->state; - /* Set reset flags according to propagation status */ - if (item->propagate) { - reset |= ~item->state; - item->propagate = FALSE; - } - /* Reset our state */ - item->state &= ~reset; - /* Return if NOP */ - if (!(~item->state & state)) - return item->state; - /* Test whether to return immediately */ - if (item->state & NR_ARENA_ITEM_STATE_BBOX) { - // we have up-to-date bbox - if (!area.intersects(outline ? item->bbox : item->drawbox)) - return item->state; - } - - /* Set up local gc */ - childgc = *gc; - if (item->transform) { - childgc.transform = (*item->transform) * childgc.transform; - } - /* Remember the transformation matrix */ - Geom::Affine ctm_change = item->ctm.inverse() * childgc.transform; - item->ctm = childgc.transform; - - /* Invoke the real method */ - // that will update bbox - item->state = NR_ARENA_ITEM_VIRTUAL (item, update) (item, area, &childgc, state, reset); - if (item->state & NR_ARENA_ITEM_STATE_INVALID) - return item->state; - - /* Enlarge the drawbox to contain filter effects */ - if (item->filter && filter && item->item_bbox) { - item->drawbox = item->filter->compute_drawbox(item, *item->item_bbox); - } else { - item->drawbox = item->bbox; - } - - /* Clipping */ - if (item->clip) { - // FIXME: since here we only need bbox, consider passing - // ((state & !(NR_ARENA_ITEM_STATE_RENDER)) | NR_ARENA_ITEM_STATE_BBOX) - // instead of state, so it does not have to create rendering structures in nr_arena_shape_update - unsigned int newstate = nr_arena_item_invoke_update (item->clip, area, &childgc, state, reset); - if (newstate & NR_ARENA_ITEM_STATE_INVALID) { - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - if (outline) { - item->bbox.unionWith(item->clip->bbox); - } else { - item->drawbox.intersectWith(item->clip->bbox); - } - } - /* Masking */ - if (item->mask) { - unsigned int newstate = nr_arena_item_invoke_update (item->mask, area, &childgc, state, reset); - if (newstate & NR_ARENA_ITEM_STATE_INVALID) { - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - if (outline) { - item->bbox.unionWith(item->mask->bbox); - } else { - // for masking, we need full drawbox of mask - item->drawbox.intersectWith(item->mask->drawbox); - } - } - - // update cache if enabled - if (item->render_cache) { - Geom::OptIntRect cl = item->arena->cache_limit; - cl.intersectWith(item->drawbox); - if (cl) { - if (item->cache) { - // this takes care of invalidation on transform - item->cache->resizeAndTransform(*cl, ctm_change); - } else { - item->cache = new Inkscape::DrawingCache(*cl); - // the cache is initially dirty - } - } else { - // disable cache for this item - not visible - delete item->cache; - item->cache = NULL; - } - } - - // now that we know drawbox, dirty the corresponding rect on canvas: - if (!NR_IS_ARENA_GROUP(item) || (item->filter && filter)) { - // unless filtered, groups do not need to render by themselves, only their members - if (state & ~NR_ARENA_ITEM_STATE_CACHE) { - nr_arena_item_request_render (item); - } - } - - return item->state; -} - -struct MaskLuminanceToAlpha { - guint32 operator()(guint32 in) { - EXTRACT_ARGB32(in, a, r, g, b) - // the operation of unpremul -> luminance-to-alpha -> multiply by alpha - // is equivalent to luminance-to-alpha on premultiplied color values - // original computation in double: r*0.2125 + g*0.7154 + b*0.0721 - guint32 ao = r*109 + g*366 + b*37; // coeffs add up to 512 - return ((ao + 256) << 15) & 0xff000000; // equivalent to ((ao + 256) / 512) << 24 - } -}; - -unsigned int -nr_arena_item_invoke_render (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, - unsigned int flags) -{ - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - bool filter = (item->arena->rendermode != Inkscape::RENDERMODE_OUTLINE && - item->arena->rendermode != Inkscape::RENDERMODE_NO_FILTERS); - - nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), - NR_ARENA_ITEM_STATE_INVALID); - nr_return_val_if_fail (item->state & NR_ARENA_ITEM_STATE_BBOX, - item->state); - - /* If we are invisible, just return successfully */ - if (!item->visible) - return item->state | NR_ARENA_ITEM_STATE_RENDER; - - if (outline) { - // intersect with bbox rather than drawbox, as we want to render things outside - // of the clipping path as well - Geom::OptIntRect carea = Geom::intersect(area, item->bbox); - if (!carea) - return item->state | NR_ARENA_ITEM_STATE_RENDER; - - // No caching in outline mode for now; investigate if it really gives any advantage with cairo. - // Also no attempts to clip anything; just render everything: item, clip, mask - // First, render the object itself - unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, *carea, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - /* Clean up and return error */ - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - - // render clip and mask, if any - guint32 saved_rgba = item->arena->outlinecolor; // save current outline color - // render clippath as an object, using a different color - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (item->clip) { - item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips - NR_ARENA_ITEM_VIRTUAL (item->clip, render) (ct, item->clip, *carea, flags); - } - // render mask as an object, using a different color - if (item->mask) { - item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks - NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, *carea, flags); - } - item->arena->outlinecolor = saved_rgba; // restore outline color - - return item->state | NR_ARENA_ITEM_STATE_RENDER; - } - - // carea is the bounding box for intermediate rendering. - Geom::OptIntRect carea = Geom::intersect(area, item->drawbox); - if (!carea) - return item->state | NR_ARENA_ITEM_STATE_RENDER; - - // render from cache - if (item->render_cache && item->cache) { - if(item->cache->paintFromCache(ct, *carea)) - return item->state | NR_ARENA_ITEM_STATE_RENDER; - } - - // expand carea to contain the dependent area of filters. - if (item->filter && filter) { - item->filter->area_enlarge(*carea, item); - carea.intersectWith(item->drawbox); - } - - using namespace Inkscape; - - unsigned state; - unsigned retstate; - - // determine whether this shape needs intermediate rendering. - bool needs_intermediate_rendering = false; - bool &nir = needs_intermediate_rendering; - bool needs_opacity = (item->opacity != 255 && !item->render_opacity); - - // this item needs an intermediate rendering if: - nir |= (item->clip != NULL); // 1. it has a clipping path - nir |= (item->mask != NULL); // 2. it has a mask - nir |= (item->filter != NULL && filter); // 3. it has a filter - nir |= needs_opacity; // 4. it is non-opaque - - double opacity = static_cast(item->opacity) / 255.0; - - /* How the rendering is done. - * - * Clipping, masking and opacity are done by rendering them to a surface - * and then compositing the object's rendering onto it with the IN operator. - * The object itself is rendered to a group. - * - * Opacity is done by rendering the clipping path with an alpha - * value corresponding to the opacity. If there is no clipping path, - * the entire intermediate surface is painted with alpha corresponding - * to the opacity value. - */ - - // short-circuit the simple case. - if (!needs_intermediate_rendering) { - if (item->render_cache && item->cache) { - Inkscape::DrawingContext cachect(*item->cache); - cachect.rectangle(area); - cachect.clip(); - - { // 1. clear the corresponding part of cache - Inkscape::DrawingContext::Save save(cachect); - cachect.setSource(0,0,0,0); - cachect.setOperator(CAIRO_OPERATOR_SOURCE); - cachect.paint(); - } - // 2. render to cache - state = NR_ARENA_ITEM_VIRTUAL (item, render) (cachect, item, *carea, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - // 3. copy from cache to output - Inkscape::DrawingContext::Save save(ct); - ct.rectangle(*carea); - ct.clip(); - ct.setSource(item->cache); - ct.paint(); - // 4. mark as clean - item->cache->markClean(area); - return item->state | NR_ARENA_ITEM_STATE_RENDER; - } else { - state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, *carea, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - item->state |= NR_ARENA_ITEM_STATE_INVALID; - return item->state; - } - return item->state | NR_ARENA_ITEM_STATE_RENDER; - } - } - - DrawingSurface intermediate(*carea); - DrawingContext ict(intermediate); - - // 1. Render clipping path with alpha = opacity. - ict.setSource(0,0,0,opacity); - // Since clip can be combined with opacity, the result could be incorrect - // for overlapping clip children. To fix this we use the SOURCE operator - // instead of the default OVER. - ict.setOperator(CAIRO_OPERATOR_SOURCE); - if (item->clip) { - state = nr_arena_item_invoke_clip(ict, item->clip, *carea); // fixme: carea or area? - if (state & NR_ARENA_ITEM_STATE_INVALID) { - retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); - goto cleanup; - } - } else { - // if there is no clipping path, fill the entire surface with alpha = opacity. - ict.paint(); - } - // reset back to default - ict.setOperator(CAIRO_OPERATOR_OVER); - - // 2. Render the mask if present and compose it with the clipping path + opacity. - if (item->mask) { - ict.pushGroup(); - state = NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ict, item->mask, *carea, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); - goto cleanup; - } - cairo_surface_t *mask_s = ict.rawTarget(); - // Convert mask's luminance to alpha - ink_cairo_surface_filter(mask_s, mask_s, MaskLuminanceToAlpha()); - ict.popGroupToSource(); - ict.setOperator(CAIRO_OPERATOR_IN); - ict.paint(); - ict.setOperator(CAIRO_OPERATOR_OVER); - } - - // 3. Render object itself. - ict.pushGroup(); - state = NR_ARENA_ITEM_VIRTUAL (item, render) (ict, item, *carea, flags); - if (state & NR_ARENA_ITEM_STATE_INVALID) { - retstate = (item->state |= NR_ARENA_ITEM_STATE_INVALID); - goto cleanup; - } - - // 4. Apply filter. - if (item->filter && filter) { - item->filter->render(item, ct, ict); - // Note that because the object was rendered to a group, - // the internals of the filter need to use cairo_get_group_target() - // instead of cairo_get_target(). - } - - // 5. Render object inside the composited mask + clip - ict.popGroupToSource(); - ict.setOperator(CAIRO_OPERATOR_IN); - ict.paint(); - - // 6. Paint the completed rendering onto the base context (or into cache) - if (item->render_cache && item->cache) { - DrawingContext cachect(*item->cache); - cachect.rectangle(area); - cachect.clip(); - cachect.setOperator(CAIRO_OPERATOR_SOURCE); - cachect.setSource(&intermediate); - cachect.paint(); - item->cache->markClean(area); - } - ct.setSource(&intermediate); - ct.paint(); - ct.setSource(0,0,0,0); - // the call above is to clear a ref on the intermediate surface held by ct - - retstate = item->state | NR_ARENA_ITEM_STATE_RENDER; - - cleanup: - return retstate; -} - -unsigned int -nr_arena_item_invoke_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area) -{ - nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), - NR_ARENA_ITEM_STATE_INVALID); - - unsigned retstate = 0; - - // don't bother if the object does not implement clipping (e.g. NRArenaImage) - if (!((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->clip) - return retstate; - - if (item->visible && area.intersects(item->bbox)) { - // The item used as the clipping path itself has a clipping path. - // Render this item's clipping path onto a temporary surface, then composite it - // with the item using the IN operator - if (item->clip) { - ct.pushAlphaGroup(); - { Inkscape::DrawingContext::Save save(ct); - ct.setSource(0,0,0,1); - nr_arena_item_invoke_clip(ct, item->clip, area); - } - ct.pushAlphaGroup(); - } - - // rasterize the clipping path - retstate = ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> - clip (ct, item, area); - - if (item->clip) { - ct.popGroupToSource(); - ct.setOperator(CAIRO_OPERATOR_IN); - ct.paint(); - ct.popGroupToSource(); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); - } - } - - return retstate; -} - -NRArenaItem * -nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point const &p, double delta, - unsigned int sticky) -{ - nr_return_val_if_fail (item != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), NULL); - - // Sometimes there's no BBOX in item->state, reason unknown (bug 992817); I made this not an assert to remove the warning - if (!(item->state & NR_ARENA_ITEM_STATE_BBOX) - || !(item->state & NR_ARENA_ITEM_STATE_PICK)) - return NULL; - - if (!sticky && !(item->visible && item->sensitive)) - return NULL; - - if (!item->bbox) return NULL; - Geom::Rect expanded(*item->bbox); - expanded.expandBy(delta); - - if (expanded.contains(p)) { - if (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))->pick) - return ((NRArenaItemClass *) NR_OBJECT_GET_CLASS (item))-> - pick (item, p, delta, sticky); - } - - return NULL; -} - -void -nr_arena_item_request_update (NRArenaItem *item, unsigned int reset, - unsigned int propagate) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_return_if_fail (!(reset & NR_ARENA_ITEM_STATE_INVALID)); - - if (propagate && !item->propagate) - item->propagate = TRUE; - - if (item->state & reset) { - item->state &= ~reset; - if (item->parent) { - nr_arena_item_request_update (item->parent, reset, FALSE); - } else { - nr_arena_request_update (item->arena, item); - } - } -} - -void -nr_arena_item_request_render (NRArenaItem *item) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - - bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - Geom::OptIntRect dirty = outline ? item->bbox : item->drawbox; - if (!dirty) return; - - // dirty the caches of all parents - for (NRArenaItem *i = item; i; i = i->parent) { - if (i->render_cache && i->cache) { - i->cache->markDirty(*dirty); - } - } - - nr_arena_request_render_rect (item->arena, dirty); -} - -/* Public */ - -NRArenaItem * -nr_arena_item_unparent (NRArenaItem *item) -{ - nr_return_val_if_fail (item != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), NULL); - - nr_arena_item_request_render (item); - - if (item->parent) { - nr_arena_item_remove_child (item->parent, item); - } - - return NULL; -} - -void -nr_arena_item_append_child (NRArenaItem *parent, NRArenaItem *child) -{ - nr_return_if_fail (parent != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (parent)); - nr_return_if_fail (child != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (child)); - nr_return_if_fail (parent->arena == child->arena); - nr_return_if_fail (child->parent == NULL); - nr_return_if_fail (child->prev == NULL); - nr_return_if_fail (child->next == NULL); - - nr_arena_item_add_child (parent, child, nr_arena_item_last_child (parent)); -} - -void -nr_arena_item_set_transform (NRArenaItem *item, Geom::Affine const &transform) -{ - Geom::Affine const t (transform); - nr_arena_item_set_transform (item, &t); -} - -void -nr_arena_item_set_transform (NRArenaItem *item, Geom::Affine const *transform) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - - if (!transform && !item->transform) - return; - - const Geom::Affine *md = (item->transform) ? item->transform : &GEOM_MATRIX_IDENTITY; - const Geom::Affine *ms = (transform) ? transform : &GEOM_MATRIX_IDENTITY; - - if (!Geom::matrix_equalp(*md, *ms, NR_EPSILON)) { - // mark the area where the object was for redraw. - nr_arena_item_request_render (item); - if (!transform || transform->isIdentity()) { - /* Set to identity affine */ - item->transform = NULL; - } else { - if (!item->transform) - item->transform = new (GC::ATOMIC) Geom::Affine (); - *item->transform = *transform; - } - // when update is called, the area where the object was moved - // will be redrawn as well - nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, TRUE); - } -} - -void -nr_arena_item_set_opacity (NRArenaItem *item, double opacity) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - - nr_arena_item_request_render (item); - - item->opacity = (unsigned int) (opacity * 255.9999); -} - -void -nr_arena_item_set_sensitive (NRArenaItem *item, unsigned int sensitive) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - - /* fixme: mess with pick/repick... */ - - item->sensitive = sensitive; -} - -void -nr_arena_item_set_visible (NRArenaItem *item, unsigned int visible) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - - item->visible = visible; - - nr_arena_item_request_render (item); -} - -void -nr_arena_item_set_clip (NRArenaItem *item, NRArenaItem *clip) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_return_if_fail (!clip || NR_IS_ARENA_ITEM (clip)); - - if (clip != item->clip) { - nr_arena_item_request_render (item); - if (item->clip) - item->clip = nr_arena_item_detach (item, item->clip); - if (clip) - item->clip = nr_arena_item_attach (item, clip, NULL, NULL); - nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, TRUE); - } -} - -void -nr_arena_item_set_mask (NRArenaItem *item, NRArenaItem *mask) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - nr_return_if_fail (!mask || NR_IS_ARENA_ITEM (mask)); - - if (mask != item->mask) { - nr_arena_item_request_render (item); - if (item->mask) - item->mask = nr_arena_item_detach (item, item->mask); - if (mask) - item->mask = nr_arena_item_attach (item, mask, NULL, NULL); - nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, TRUE); - } -} - -void -nr_arena_item_set_order (NRArenaItem *item, int order) -{ - nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); - - if (!item->parent) - return; - - NRArenaItem *children = nr_arena_item_children (item->parent); - - NRArenaItem *ref = NULL; - int pos = 0; - for (NRArenaItem *child = children; child != NULL; child = child->next) { - if (pos >= order) - break; - if (child != item) { - ref = child; - pos += 1; - } - } - - nr_arena_item_set_child_position (item->parent, item, ref); -} - -void -nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect const &bbox) -{ - nr_return_if_fail(item != NULL); - nr_return_if_fail(NR_IS_ARENA_ITEM(item)); - - item->item_bbox = bbox; -} - -void -nr_arena_item_set_cache (NRArenaItem *item, bool cache) -{ - if (cache) { - item->render_cache = TRUE; - item->arena->cached_items.insert(item); - } else { - item->render_cache = FALSE; - item->arena->cached_items.erase(item); - } - nr_arena_item_request_update(item, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -/** Returns a background image for use with filter effects. */ -NRPixBlock *nr_arena_item_get_background(NRArenaItem const * /*item*/) -{ - return NULL; -} - -/* Helpers */ - -NRArenaItem * -nr_arena_item_attach (NRArenaItem *parent, NRArenaItem *child, - NRArenaItem *prev, NRArenaItem *next) -{ - nr_return_val_if_fail (parent != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (parent), NULL); - nr_return_val_if_fail (child != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (child), NULL); - nr_return_val_if_fail (child->parent == NULL, NULL); - nr_return_val_if_fail (child->prev == NULL, NULL); - nr_return_val_if_fail (child->next == NULL, NULL); - nr_return_val_if_fail (!prev || NR_IS_ARENA_ITEM (prev), NULL); - nr_return_val_if_fail (!prev || (prev->parent == parent), NULL); - nr_return_val_if_fail (!prev || (prev->next == next), NULL); - nr_return_val_if_fail (!next || NR_IS_ARENA_ITEM (next), NULL); - nr_return_val_if_fail (!next || (next->parent == parent), NULL); - nr_return_val_if_fail (!next || (next->prev == prev), NULL); - - child->parent = parent; - child->prev = prev; - child->next = next; - - if (prev) - prev->next = child; - if (next) - next->prev = child; - - return child; -} - -NRArenaItem * -nr_arena_item_detach (NRArenaItem *parent, NRArenaItem *child) -{ - nr_return_val_if_fail (parent != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (parent), NULL); - nr_return_val_if_fail (child != NULL, NULL); - nr_return_val_if_fail (NR_IS_ARENA_ITEM (child), NULL); - nr_return_val_if_fail (child->parent == parent, NULL); - - NRArenaItem *prev = child->prev; - NRArenaItem *next = child->next; - - child->parent = NULL; - child->prev = NULL; - child->next = NULL; - - if (prev) - prev->next = next; - if (next) - next->prev = prev; - - return next; -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h deleted file mode 100644 index 2c00c0bf3..000000000 --- a/src/display/nr-arena-item.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_DISPLAY_NR_ARENA_ITEM_H -#define SEEN_DISPLAY_NR_ARENA_ITEM_H - -#include -#include <2geom/affine.h> -#include <2geom/rect.h> -#include "libnr/nr-forward.h" -#include "libnr/nr-rect-l.h" -#include "libnr/nr-object.h" -#include "gc-soft-ptr.h" -#include "nr-arena-forward.h" - -namespace Inkscape { -class DrawingContext; -class DrawingCache; -namespace Filters { -class Filter; -} } - -#define NR_TYPE_ARENA_ITEM (nr_arena_item_get_type ()) -#define NR_ARENA_ITEM(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA_ITEM, NRArenaItem)) -#define NR_IS_ARENA_ITEM(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA_ITEM)) - -#define NR_ARENA_ITEM_VIRTUAL(i,m) (((NRArenaItemClass *) NR_OBJECT_GET_CLASS (i))->m) - -/* - * NRArenaItem state flags - */ - -/* - * NR_ARENA_ITEM_STATE_INVALID - * - * If set or retuned indicates, that given object is in error. - * Calling method has to return immediately, with appropriate - * error flag. - */ - -#define NR_ARENA_ITEM_STATE_INVALID (1 << 0) - - -#define NR_ARENA_ITEM_STATE_BBOX (1 << 1) -#define NR_ARENA_ITEM_STATE_COVERAGE (1 << 2) -#define NR_ARENA_ITEM_STATE_DRAFT (1 << 3) -#define NR_ARENA_ITEM_STATE_RENDER (1 << 4) -#define NR_ARENA_ITEM_STATE_CLIP (1 << 5) -#define NR_ARENA_ITEM_STATE_MASK (1 << 6) -#define NR_ARENA_ITEM_STATE_PICK (1 << 7) -#define NR_ARENA_ITEM_STATE_IMAGE (1 << 8) -#define NR_ARENA_ITEM_STATE_CACHE (1 << 9) - -#define NR_ARENA_ITEM_STATE_NONE 0x0000 -#define NR_ARENA_ITEM_STATE_ALL 0x03fe - -#define NR_ARENA_ITEM_STATE(i,s) (NR_ARENA_ITEM (i)->state & (s)) -#define NR_ARENA_ITEM_SET_STATE(i,s) (NR_ARENA_ITEM (i)->state |= (s)) -#define NR_ARENA_ITEM_UNSET_STATE(i,s) (NR_ARENA_ITEM (i)->state &= ~(s)) - -#define NR_ARENA_ITEM_RENDER_NO_CACHE (1 << 0) -#define NR_ARENA_ITEM_RENDER_CACHE (1 << 1) - -struct NRGC { - NRGC(NRGC const *p) : parent(p) {} - NRGC const *parent; - Geom::Affine transform; -}; - -struct NRArenaItem : public NRObject { - - NRArena *arena; - Inkscape::GC::soft_ptr parent; - NRArenaItem *next; - Inkscape::GC::soft_ptr prev; - - /* Item state */ - unsigned state : 16; - /* Opacity itself */ - unsigned opacity : 8; - unsigned propagate : 1; - unsigned sensitive : 1; - unsigned visible : 1; - /* Whether items renders opacity itself */ - unsigned render_opacity : 1; - unsigned render_cache : 1; - - unsigned int key; ///< Some SPItems can have more than one NRArenaItem, - ///this value is a hack used to distinguish between them - - Geom::OptIntRect bbox; ///< Bounding box in pixel grid coordinates; (0,0) is at page origin - Geom::OptIntRect drawbox; ///< Bounding box enlarged by filters, shrinked by clips and masks - Geom::OptRect item_bbox; ///< Bounding box in item coordinates, required by filters - Geom::Affine *transform; ///< Incremental transform of this item, as given by the transform= attribute - Geom::Affine ctm; ///< Total transform from pixel grid to item coords - NRArenaItem *clip; ///< Clipping path - NRArenaItem *mask; ///< Mask - Inkscape::Filters::Filter *filter; ///< Filter - Inkscape::DrawingCache *cache; ///< Render cache - - void *data; ///< Anonymous data member - this is used to associate SPItems with arena items - - bool background_new; - - void init(NRArena *arena) { - this->arena = arena; - } -}; - -struct NRArenaItemClass : public NRObjectClass { - NRArenaItem * (* children) (NRArenaItem *item); - NRArenaItem * (* last_child) (NRArenaItem *item); - void (* add_child) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); - void (* remove_child) (NRArenaItem *item, NRArenaItem *child); - void (* set_child_position) (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); - - unsigned int (* update) (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); - unsigned int (* render) (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); - unsigned int (* clip) (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); - NRArenaItem * (* pick) (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); -}; - -#define NR_ARENA_ITEM_ARENA(ai) (((NRArenaItem *) (ai))->arena) - -NRType nr_arena_item_get_type (void); - -NRArenaItem *nr_arena_item_ref (NRArenaItem *item); -NRArenaItem *nr_arena_item_unref (NRArenaItem *item); - -NRArenaItem *nr_arena_item_children (NRArenaItem *item); -NRArenaItem *nr_arena_item_last_child (NRArenaItem *item); -void nr_arena_item_add_child (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); -void nr_arena_item_remove_child (NRArenaItem *item, NRArenaItem *child); -void nr_arena_item_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); - -/* - * Invoke update to given state, if item is inside area - * - * area == NULL is infinite - * gc is PARENT gc for invoke, CHILD gc in corresponding virtual method - * state - requested to state (bitwise or of requested flags) - * reset - reset to state (bitwise or of flags to reset) - */ - -unsigned int nr_arena_item_invoke_update (NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, unsigned int state, unsigned int reset); - -unsigned int nr_arena_item_invoke_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); - -unsigned int nr_arena_item_invoke_clip (Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); -NRArenaItem *nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); - -void nr_arena_item_request_update (NRArenaItem *item, unsigned int reset, unsigned int propagate); -void nr_arena_item_request_render (NRArenaItem *item); - -/* Public */ - -NRArenaItem *nr_arena_item_unparent (NRArenaItem *item); - -void nr_arena_item_append_child (NRArenaItem *parent, NRArenaItem *child); - -void nr_arena_item_set_transform(NRArenaItem *item, Geom::Affine const &transform); -void nr_arena_item_set_transform(NRArenaItem *item, Geom::Affine const *transform); -void nr_arena_item_set_opacity (NRArenaItem *item, double opacity); -void nr_arena_item_set_sensitive (NRArenaItem *item, unsigned int sensitive); -void nr_arena_item_set_visible (NRArenaItem *item, unsigned int visible); -void nr_arena_item_set_clip (NRArenaItem *item, NRArenaItem *clip); -void nr_arena_item_set_mask (NRArenaItem *item, NRArenaItem *mask); -void nr_arena_item_set_order (NRArenaItem *item, int order); -void nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect const &bbox); -void nr_arena_item_set_cache (NRArenaItem *item, bool cache); - -NRPixBlock *nr_arena_item_get_background (NRArenaItem const *item); - -/* Helpers */ - -NRArenaItem *nr_arena_item_attach (NRArenaItem *parent, NRArenaItem *child, NRArenaItem *prev, NRArenaItem *next); -NRArenaItem *nr_arena_item_detach (NRArenaItem *parent, NRArenaItem *child); - -#define NR_ARENA_ITEM_SET_DATA(i,v) (((NRArenaItem *) (i))->data = (v)) -#define NR_ARENA_ITEM_GET_DATA(i) (((NRArenaItem *) (i))->data) - -#define NR_ARENA_ITEM_SET_KEY(i,k) (((NRArenaItem *) (i))->key = (k)) -#define NR_ARENA_ITEM_GET_KEY(i) (((NRArenaItem *) (i))->key) - -#endif /* !SEEN_DISPLAY_NR_ARENA_ITEM_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp deleted file mode 100644 index ff985550c..000000000 --- a/src/display/nr-arena-shape.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include -#include -#include - -#include <2geom/curves.h> -#include <2geom/pathvector.h> -#include <2geom/svg-path.h> -#include <2geom/svg-path-parser.h> -#include "display/cairo-utils.h" -#include "display/canvas-arena.h" -#include "display/canvas-bpath.h" -#include "display/curve.h" -#include "display/drawing-context.h" -#include "display/nr-arena.h" -#include "display/nr-arena-shape.h" -#include "display/nr-filter.h" -#include "helper/geom-curves.h" -#include "helper/geom.h" -#include "libnr/nr-convert2geom.h" -#include "preferences.h" -#include "sp-filter.h" -#include "sp-filter-reference.h" -#include "style.h" -#include "svg/svg.h" - -static void nr_arena_shape_class_init(NRArenaShapeClass *klass); -static void nr_arena_shape_init(NRArenaShape *shape); -static void nr_arena_shape_finalize(NRObject *object); - -static NRArenaItem *nr_arena_shape_children(NRArenaItem *item); -static void nr_arena_shape_add_child(NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); -static void nr_arena_shape_remove_child(NRArenaItem *item, NRArenaItem *child); -static void nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref); - -static guint nr_arena_shape_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset); -static unsigned int nr_arena_shape_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags); -static guint nr_arena_shape_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area); -static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, Geom::Point const &p, double delta, unsigned int sticky); - -static NRArenaItemClass *shape_parent_class; - -NRType -nr_arena_shape_get_type(void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type(NR_TYPE_ARENA_ITEM, - "NRArenaShape", - sizeof(NRArenaShapeClass), - sizeof(NRArenaShape), - (void (*)(NRObjectClass *)) nr_arena_shape_class_init, - (void (*)(NRObject *)) nr_arena_shape_init); - } - return type; -} - -static void -nr_arena_shape_class_init(NRArenaShapeClass *klass) -{ - NRObjectClass *object_class; - NRArenaItemClass *item_class; - - object_class = (NRObjectClass *) klass; - item_class = (NRArenaItemClass *) klass; - - shape_parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent; - - object_class->finalize = nr_arena_shape_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; - - item_class->children = nr_arena_shape_children; - item_class->add_child = nr_arena_shape_add_child; - item_class->set_child_position = nr_arena_shape_set_child_position; - item_class->remove_child = nr_arena_shape_remove_child; - item_class->update = nr_arena_shape_update; - item_class->render = nr_arena_shape_render; - item_class->clip = nr_arena_shape_clip; - item_class->pick = nr_arena_shape_pick; -} - -/** - * Initializes the arena shape, setting all parameters to null, 0, false, - * or other defaults - */ -static void -nr_arena_shape_init(NRArenaShape *shape) -{ - shape->curve = NULL; - shape->style = NULL; - shape->markers = NULL; - shape->last_pick = NULL; - shape->repick_after = 0; -} - -static void -nr_arena_shape_finalize(NRObject *object) -{ - NRArenaShape *shape = (NRArenaShape *) object; - - if (shape->style) sp_style_unref(shape->style); - if (shape->curve) shape->curve->unref(); - shape->last_pick = NULL; - - ((NRObjectClass *) shape_parent_class)->finalize(object); -} - -/** - * Retrieves the markers from the item - */ -static NRArenaItem * -nr_arena_shape_children(NRArenaItem *item) -{ - NRArenaShape *shape = (NRArenaShape *) item; - - return shape->markers; -} - -/** - * Attaches child to item, and if ref is not NULL, sets it and ref->next as - * the prev and next items. If ref is NULL, then it sets the item's markers - * as the next items. - */ -static void -nr_arena_shape_add_child(NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref) -{ - NRArenaShape *shape = (NRArenaShape *) item; - - if (!ref) { - shape->markers = nr_arena_item_attach(item, child, NULL, shape->markers); - } else { - ref->next = nr_arena_item_attach(item, child, ref, ref->next); - } - - nr_arena_item_request_update(item, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -/** - * Removes child from the shape. If there are no prev items in - * the child, it sets items' markers to the next item in the child. - */ -static void -nr_arena_shape_remove_child(NRArenaItem *item, NRArenaItem *child) -{ - NRArenaShape *shape = (NRArenaShape *) item; - - if (child->prev) { - nr_arena_item_detach(item, child); - } else { - shape->markers = nr_arena_item_detach(item, child); - } - - nr_arena_item_request_update(item, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -/** - * Detaches child from item, and if there are no previous items in child, it - * sets item's markers to the child. It then attaches the child back onto the item. - * If ref is null, it sets the markers to be the next item, otherwise it uses - * the next/prev items in ref. - */ -static void -nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref) -{ - NRArenaShape *shape = (NRArenaShape *) item; - - if (child->prev) { - nr_arena_item_detach(item, child); - } else { - shape->markers = nr_arena_item_detach(item, child); - } - - if (!ref) { - shape->markers = nr_arena_item_attach(item, child, NULL, shape->markers); - } else { - ref->next = nr_arena_item_attach(item, child, ref, ref->next); - } - - nr_arena_item_request_render(child); -} - -/** - * Updates the arena shape 'item' and all of its children, including the markers. - */ -static guint -nr_arena_shape_update(NRArenaItem *item, Geom::IntRect const &area, NRGC *gc, guint state, guint reset) -{ - Geom::OptRect boundingbox; - - NRArenaShape *shape = NR_ARENA_SHAPE(item); - - unsigned int beststate = NR_ARENA_ITEM_STATE_ALL; - - // update markers - unsigned int newstate; - for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - newstate = nr_arena_item_invoke_update(child, area, gc, state, reset); - beststate = beststate & newstate; - } - - if (!(state & NR_ARENA_ITEM_STATE_RENDER)) { - /* We do not have to create rendering structures */ - if (state & NR_ARENA_ITEM_STATE_BBOX) { - if (shape->curve) { - boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); - if (boundingbox) { - item->bbox = boundingbox->roundOutwards(); - } else { - item->bbox = Geom::OptIntRect(); - } - } - if (beststate & NR_ARENA_ITEM_STATE_BBOX) { - for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - item->bbox.unionWith(child->bbox); - } - } - } - return (state | item->state); - } - - boundingbox = Geom::OptRect(); - - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - // clear Cairo data to force update - shape->nrstyle.update(); - - if (shape->curve) { - boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); - - if (boundingbox && (shape->nrstyle.stroke.type != NRStyle::PAINT_NONE || outline)) { - float width, scale; - scale = gc->transform.descrim(); - width = MAX(0.125, shape->nrstyle.stroke_width * scale); - if ( fabs(shape->nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true - boundingbox->expandBy(width); - } - // those pesky miters, now - float miterMax = width * shape->nrstyle.miter_limit; - if ( miterMax > 0.01 ) { - // grunt mode. we should compute the various miters instead - // (one for each point on the curve) - boundingbox->expandBy(miterMax); - } - } - } - - item->bbox = boundingbox ? boundingbox->roundOutwards() : Geom::OptIntRect(); - - if (!shape->curve || - !shape->style || - shape->curve->is_empty() || - (( shape->nrstyle.fill.type != NRStyle::PAINT_NONE ) && - ( shape->nrstyle.stroke.type != NRStyle::PAINT_NONE && !outline) )) - { - //item->bbox = shape->approx_bbox; - return NR_ARENA_ITEM_STATE_ALL; - } - - if (beststate & NR_ARENA_ITEM_STATE_BBOX) { - for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - item->bbox.unionWith(child->bbox); - } - } - - return NR_ARENA_ITEM_STATE_ALL; -} - -// cairo outline rendering: -static unsigned int -cairo_arena_shape_render_outline(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/) -{ - NRArenaShape *shape = NR_ARENA_SHAPE(item); - - guint32 rgba = NR_ARENA_ITEM(shape)->arena->outlinecolor; - - { Inkscape::DrawingContext::Save save(ct); - ct.transform(shape->ctm); - ct.path(shape->curve->get_pathvector()); - } - { Inkscape::DrawingContext::Save save(ct); - ct.setSource(rgba); - ct.setLineWidth(0.5); - ct.setTolerance(1.25); - ct.stroke(); - } - - return item->state; -} - -/** - * Renders the item. Markers are just composed into the parent buffer. - */ -static unsigned int -nr_arena_shape_render(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &area, unsigned int flags) -{ - NRArenaShape *shape = NR_ARENA_SHAPE(item); - - if (!shape->curve) return item->state; - if (!shape->style) return item->state; - - // skip if not within bounding box - if (!area.intersects(item->bbox)) { - return item->state; - } - - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - if (outline) { - // cairo outline rendering - unsigned int ret = cairo_arena_shape_render_outline (ct, item, area); - if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; - } else { - bool has_stroke, has_fill; - // we assume the context has no path - Inkscape::DrawingContext::Save save(ct); - ct.transform(shape->ctm); - - // update fill and stroke paints. - // this cannot be done during nr_arena_shape_update, because we need a Cairo context - // to render svg:pattern - has_fill = shape->nrstyle.prepareFill(ct, shape->paintbox); - has_stroke = shape->nrstyle.prepareStroke(ct, shape->paintbox); - has_stroke &= (shape->nrstyle.stroke_width != 0); - - if (has_fill || has_stroke) { - // TODO: remove segments outside of bbox when no dashes present - ct.path(shape->curve->get_pathvector()); - if (has_fill) { - shape->nrstyle.applyFill(ct); - ct.fillPreserve(); - } - if (has_stroke) { - shape->nrstyle.applyStroke(ct); - ct.strokePreserve(); - } - ct.newPath(); // clear path - } // has fill or stroke pattern - } - - // marker rendering - for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - unsigned int ret = nr_arena_item_invoke_render(ct, child, area, flags); - if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; - } - - return item->state; -} - - -static guint nr_arena_shape_clip(Inkscape::DrawingContext &ct, NRArenaItem *item, Geom::IntRect const &/*area*/) -{ - NRArenaShape *shape = NR_ARENA_SHAPE(item); - if (!shape->curve) { - return item->state; - } - - Inkscape::DrawingContext::Save save(ct); - // handle clip-rule - if (shape->style) { - if (shape->style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); - } else { - ct.setFillRule(CAIRO_FILL_RULE_WINDING); - } - } - ct.transform(shape->ctm); - ct.path(shape->curve->get_pathvector()); - ct.fill(); - - return item->state; -} - -static NRArenaItem * -nr_arena_shape_pick(NRArenaItem *item, Geom::Point const &p, double delta, unsigned int /*sticky*/) -{ - NRArenaShape *shape = NR_ARENA_SHAPE(item); - - if (shape->repick_after > 0) - shape->repick_after--; - - if (shape->repick_after > 0) // we are a slow, huge path. skip this pick, returning what was returned last time - return shape->last_pick; - - if (!shape->curve) return NULL; - if (!shape->style) return NULL; - - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); - - if (SP_SCALE24_TO_FLOAT(shape->style->opacity.value) == 0 && !outline) - // fully transparent, no pick unless outline mode - return NULL; - - GTimeVal tstart, tfinish; - g_get_current_time (&tstart); - - double width; - if (outline) { - width = 0.5; - } else if (shape->nrstyle.stroke.type != NRStyle::PAINT_NONE && shape->nrstyle.stroke.opacity > 1e-3) { - float const scale = shape->ctm.descrim(); - width = MAX(0.125, shape->nrstyle.stroke_width * scale) / 2; - } else { - width = 0; - } - - double dist = Geom::infinity(); - int wind = 0; - bool needfill = (shape->nrstyle.fill.type != NRStyle::PAINT_NONE - && shape->nrstyle.fill.opacity > 1e-3 && !outline); - - if (item->arena->canvasarena) { - Geom::Rect viewbox = item->arena->canvasarena->item.canvas->getViewbox(); - viewbox.expandBy (width); - pathv_matrix_point_bbox_wind_distance(shape->curve->get_pathvector(), shape->ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, &viewbox); - } else { - pathv_matrix_point_bbox_wind_distance(shape->curve->get_pathvector(), shape->ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, NULL); - } - - g_get_current_time (&tfinish); - glong this_pick = (tfinish.tv_sec - tstart.tv_sec) * 1000000 + (tfinish.tv_usec - tstart.tv_usec); - //g_print ("pick time %lu\n", this_pick); - - if (this_pick > 10000) { // slow picking, remember to skip several new picks - shape->repick_after = this_pick / 5000; - } - - // covered by fill? - if (needfill) { - if (!shape->style->fill_rule.computed) { - if (wind != 0) { - shape->last_pick = item; - return item; - } - } else { - if (wind & 0x1) { - shape->last_pick = item; - return item; - } - } - } - - // close to the edge, as defined by strokewidth and delta? - // this ignores dashing (as if the stroke is solid) and always works as if caps are round - if (needfill || width > 0) { // if either fill or stroke visible, - if ((dist - width) < delta) { - shape->last_pick = item; - return item; - } - } - - // if not picked on the shape itself, try its markers - for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { - NRArenaItem *ret = nr_arena_item_invoke_pick(child, p, delta, 0); - if (ret) { - shape->last_pick = item; - return item; - } - } - - shape->last_pick = NULL; - return NULL; -} - -/** - * - * Requests a render of the shape, then if the shape is already a curve it - * unrefs the old curve; if the new curve is valid it creates a copy of the - * curve and adds it to the shape. Finally, it requests an update of the - * arena for the shape. - */ -void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve, bool /*justTrans*/) -{ - g_return_if_fail(shape != NULL); - g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); - - nr_arena_item_request_render(NR_ARENA_ITEM(shape)); - - if (shape->curve) { - shape->curve->unref(); - shape->curve = NULL; - } - - if (curve) { - shape->curve = curve; - curve->ref(); - } - - nr_arena_item_request_update(NR_ARENA_ITEM(shape), NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -/** nr_arena_shape_set_style - * - * Unrefs any existing style and ref's to the given one, then requests an update of the arena - */ -void -nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) -{ - g_return_if_fail(shape != NULL); - g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); - g_return_if_fail(style != NULL); - - sp_style_ref(style); - if (shape->style) sp_style_unref(shape->style); - shape->style = style; - - shape->nrstyle.set(style); - - //if shape has a filter - if (style->filter.set && style->getFilter()) { - if (!shape->filter) { - int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); - shape->filter = new Inkscape::Filters::Filter(primitives); - } - sp_filter_build_renderer(SP_FILTER(style->getFilter()), shape->filter); - } else { - //no filter set for this shape - delete shape->filter; - shape->filter = NULL; - } - - nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void -nr_arena_shape_set_paintbox(NRArenaShape *shape, NRRect const *pbox) -{ - g_return_if_fail(shape != NULL); - g_return_if_fail(NR_IS_ARENA_SHAPE(shape)); - g_return_if_fail(pbox != NULL); - - shape->paintbox = pbox->upgrade_2geom(); - - nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -void NRArenaShape::setPaintBox(Geom::Rect const &pbox) -{ - paintbox = pbox; - - nr_arena_item_request_update(this, NR_ARENA_ITEM_STATE_ALL, FALSE); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h deleted file mode 100644 index 317cff7fb..000000000 --- a/src/display/nr-arena-shape.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __NR_ARENA_SHAPE_H__ -#define __NR_ARENA_SHAPE_H__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#define NR_TYPE_ARENA_SHAPE (nr_arena_shape_get_type ()) -#define NR_ARENA_SHAPE(obj) (NR_CHECK_INSTANCE_CAST ((obj), NR_TYPE_ARENA_SHAPE, NRArenaShape)) -#define NR_IS_ARENA_SHAPE(obj) (NR_CHECK_INSTANCE_TYPE ((obj), NR_TYPE_ARENA_SHAPE)) - -#include -#include "display/display-forward.h" -#include "forward.h" -#include "nr-arena-item.h" -#include "nr-style.h" -#include "libnr/nr-rect.h" - -NRType nr_arena_shape_get_type (void); - -struct NRArenaShape : public NRArenaItem { - /* Shape data */ - SPCurve *curve; - SPStyle *style; - NRStyle nrstyle; - Geom::OptRect paintbox; - - /* Markers */ - NRArenaItem *markers; - - NRArenaItem *last_pick; - guint repick_after; - - static NRArenaShape *create(NRArena *arena) { - NRArenaShape *obj=reinterpret_cast(nr_object_new(NR_TYPE_ARENA_SHAPE)); - obj->init(arena); - obj->key = 0; - return obj; - } - - void setPaintBox(Geom::Rect const &pbox); -}; - -struct NRArenaShapeClass { - NRArenaItemClass parent_class; -}; - -void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve, bool justTrans); -void nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style); -void nr_arena_shape_set_paintbox(NRArenaShape *shape, NRRect const *pbox); - - -#endif /* !__NR_ARENA_SHAPE_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index 735d44e9e..b3e962201 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -12,13 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "nr-arena-item.h" -#include "nr-arena.h" -#include "nr-filter-gaussian.h" -#include "nr-filter-types.h" +#include "display/drawing-item.h" +#include "display/nr-arena.h" +#include "display/nr-filter-gaussian.h" +#include "display/nr-filter-types.h" #include "preferences.h" #include "color.h" #include "libnr/nr-rect.h" +#include "libnr/nr-rect-l.h" static void nr_arena_class_init (NRArenaClass *klass); static void nr_arena_init (NRArena *arena); @@ -58,7 +59,7 @@ nr_arena_init (NRArena *arena) arena->delta = 0; // to be set by desktop from prefs arena->renderoffscreen = false; // use render values from preferences otherwise render exact arena->rendermode = Inkscape::RENDERMODE_NORMAL; // default is normal render - arena->colorrendermode = Inkscape::COLORRENDERMODE_NORMAL; // default is normal color + arena->colormode = Inkscape::COLORMODE_NORMAL; // default is normal color arena->blurquality = BLUR_QUALITY_NORMAL; arena->filterquality = Inkscape::Filters::FILTER_QUALITY_NORMAL; arena->outlinecolor = 0xff; // black; to be set by desktop from bg color @@ -72,14 +73,14 @@ nr_arena_finalize (NRObject *object) } void -nr_arena_request_update (NRArena *arena, NRArenaItem *item) +nr_arena_request_update (NRArena *arena, Inkscape::DrawingItem *item) { NRActiveObject *aobject = (NRActiveObject *) arena; nr_return_if_fail (arena != NULL); nr_return_if_fail (NR_IS_ARENA (arena)); nr_return_if_fail (item != NULL); - nr_return_if_fail (NR_IS_ARENA_ITEM (item)); + // setup render parameter if (arena->renderoffscreen == false) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -89,7 +90,7 @@ nr_arena_request_update (NRArena *arena, NRArenaItem *item) arena->blurquality = BLUR_QUALITY_BEST; arena->filterquality = Inkscape::Filters::FILTER_QUALITY_BEST; arena->rendermode = Inkscape::RENDERMODE_NORMAL; - arena->colorrendermode = Inkscape::COLORRENDERMODE_NORMAL; + arena->colormode = Inkscape::COLORMODE_NORMAL; } if (aobject->callbacks) { @@ -121,7 +122,7 @@ nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area) arena->blurquality = BLUR_QUALITY_BEST; arena->filterquality = Inkscape::Filters::FILTER_QUALITY_BEST; arena->rendermode = Inkscape::RENDERMODE_NORMAL; - arena->colorrendermode = Inkscape::COLORRENDERMODE_NORMAL; + arena->colormode = Inkscape::COLORMODE_NORMAL; } NRRectL nr_area(*area); if (aobject->callbacks) { @@ -155,10 +156,10 @@ void nr_arena_set_cache_limit (NRArena *arena, Geom::OptIntRect const &cache_limit) { arena->cache_limit = cache_limit; - for (std::set::iterator i = arena->cached_items.begin(); + for (std::set::iterator i = arena->cached_items.begin(); i != arena->cached_items.end(); ++i) { - nr_arena_item_request_update(*i, NR_ARENA_ITEM_STATE_CACHE, FALSE); + (*i)->_markForUpdate(Inkscape::DrawingItem::STATE_CACHE, false); } } diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index 5d078e19d..a444ed505 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -13,9 +13,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include - +#include +#include <2geom/rect.h> #include "display/rendermode.h" +#include "libnr/nr-forward.h" +#include "libnr/nr-object.h" +#include "display/display-forward.h" G_BEGIN_DECLS @@ -27,19 +32,13 @@ G_END_DECLS #define NR_ARENA(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA, NRArena)) #define NR_IS_ARENA(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA)) -#include -#include <2geom/rect.h> -#include -#include -#include "nr-arena-forward.h" - class SPPainter; NRType nr_arena_get_type (void); struct NRArenaEventVector { NRObjectEventVector parent; - void (* request_update) (NRArena *arena, NRArenaItem *item, void *data); + void (* request_update) (NRArena *arena, Inkscape::DrawingItem *item, void *data); void (* request_render) (NRArena *arena, NRRectL *area, void *data); }; @@ -51,20 +50,22 @@ struct NRArena : public NRActiveObject { double delta; bool renderoffscreen; // if true then rendering must be exact Inkscape::RenderMode rendermode; - Inkscape::ColorRenderMode colorrendermode; + Inkscape::ColorMode colormode; int blurquality; // will be updated during update from preferences int filterquality; // will be updated during update from preferences Geom::OptIntRect cache_limit; - std::set cached_items; + std::set cached_items; guint32 outlinecolor; SPCanvasArena *canvasarena; // may be NULL is this arena is not the screen but used for export etc. + + sigc::signal item_deleted; }; struct NRArenaClass : public NRActiveObjectClass { }; -void nr_arena_request_update (NRArena *arena, NRArenaItem *item); +void nr_arena_request_update (NRArena *arena, Inkscape::DrawingItem *item); void nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area); void nr_arena_set_renderoffscreen (NRArena *arena); void nr_arena_set_cache_limit (NRArena *arena, Geom::OptIntRect const &cache_limit); diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index eaed2a8bd..039e56bb0 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -16,7 +16,6 @@ #include "display/cairo-templates.h" #include "display/cairo-utils.h" #include "display/nr-3dutils.h" -#include "display/nr-arena-item.h" #include "display/nr-filter-diffuselighting.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 01d2eca64..55cd02697 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -15,7 +15,7 @@ #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "display/nr-filter.h" #include "display/nr-filter-image.h" #include "display/nr-filter-units.h" @@ -70,7 +70,7 @@ void FilterImage::render_cairo(FilterSlot &slot) // TODO: do not recreate the rendering tree every time // TODO: the entire thing is a hack, we should give filter primitives an "update" method - // like the one for NRArenaItems + // like the one for DrawingItems document->ensureUpToDate(); NRArena* arena = NRArena::create(); @@ -78,7 +78,7 @@ void FilterImage::render_cairo(FilterSlot &slot) if (!optarea) return; unsigned const key = SPItem::display_key_new(1); - NRArenaItem* ai = SVGElem->invoke_show(arena, key, SP_ITEM_SHOW_DISPLAY); + DrawingItem *ai = SVGElem->invoke_show(arena, key, SP_ITEM_SHOW_DISPLAY); if (!ai) { g_warning("feImage renderer: error creating NRArenaItem for SVG Element"); @@ -104,15 +104,12 @@ void FilterImage::render_cairo(FilterSlot &slot) ct.translate(render_rect.min()); // Update to renderable state - NRGC gc(NULL); - Geom::Affine t = Geom::identity(); - nr_arena_item_set_transform(ai, &t); - gc.transform.setIdentity(); - nr_arena_item_invoke_update(ai, render_rect, &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE); - nr_arena_item_invoke_render(ct, ai, render_rect, NR_ARENA_ITEM_RENDER_NO_CACHE); + UpdateContext ctx; + ai->setTransform(Geom::identity()); + ai->update(render_rect, ctx, DrawingItem::STATE_ALL, 0); + ai->render(ct, render_rect, DrawingItem::RENDER_BYPASS_CACHE); SVGElem->invoke_hide(key); + //delete ai; // should be deleted by hide() above nr_object_unref((NRObject*) arena); slot.set(_output, out); diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 494d77749..d2f992859 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -17,7 +17,6 @@ #include <2geom/transforms.h> #include "display/cairo-utils.h" #include "display/drawing-context.h" -#include "display/nr-arena-item.h" #include "display/nr-filter-types.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-slot.h" @@ -26,7 +25,7 @@ namespace Inkscape { namespace Filters { -FilterSlot::FilterSlot(NRArenaItem *item, DrawingContext &bgct, +FilterSlot::FilterSlot(DrawingItem *item, DrawingContext &bgct, DrawingContext &graphic, FilterUnits const &u) : _item(item) , _source_graphic(graphic.rawTarget()) diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 6a86ded8c..1e7c3a5a6 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -19,17 +19,16 @@ #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" -struct NRArenaItem; - namespace Inkscape { class DrawingContext; +class DrawingItem; namespace Filters { class FilterSlot { public: /** Creates a new FilterSlot object. */ - FilterSlot(NRArenaItem *item, DrawingContext &bgct, + FilterSlot(DrawingItem *item, DrawingContext &bgct, DrawingContext &graphic, FilterUnits const &u); /** Destroys the FilterSlot object and all its contents */ virtual ~FilterSlot(); @@ -73,7 +72,7 @@ public: private: typedef std::map SlotMap; SlotMap _slots; - NRArenaItem *_item; + DrawingItem *_item; //Geom::Rect _source_bbox; ///< bounding box of source graphic surface //Geom::Rect _intermediate_bbox; ///< bounding box of intermediate surfaces diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 25ef80c17..abd102452 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -39,7 +39,7 @@ #include "display/nr-filter-turbulence.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "display/drawing-context.h" #include <2geom/affine.h> #include <2geom/rect.h> @@ -97,7 +97,7 @@ Filter::~Filter() } -int Filter::render(NRArenaItem const *item, DrawingContext &bgct, DrawingContext &graphic) +int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &bgct, DrawingContext &graphic) { if (_primitive.empty()) { // when no primitives are defined, clear source graphic @@ -108,14 +108,14 @@ int Filter::render(NRArenaItem const *item, DrawingContext &bgct, DrawingContext return 1; } - FilterQuality const filterquality = (FilterQuality)item->arena->filterquality; - int const blurquality = item->arena->blurquality; + FilterQuality const filterquality = (FilterQuality)item->drawing()->filterquality; + int const blurquality = item->drawing()->blurquality; - Geom::Affine trans = item->ctm; + Geom::Affine trans = item->ctm(); Geom::Rect item_bbox; { - Geom::OptRect maybe_bbox = item->item_bbox; + Geom::OptRect maybe_bbox = item->itemBounds(); if (maybe_bbox.isEmpty()) { // Code below needs a bounding box return 1; @@ -161,7 +161,7 @@ int Filter::render(NRArenaItem const *item, DrawingContext &bgct, DrawingContext } } - FilterSlot slot(const_cast(item), bgct, graphic, units); + FilterSlot slot(const_cast(item), bgct, graphic, units); slot.set_quality(filterquality); slot.set_blurquality(blurquality); @@ -188,10 +188,10 @@ void Filter::set_primitive_units(SPFilterUnits unit) { _primitive_units = unit; } -void Filter::area_enlarge(Geom::IntRect &bbox, NRArenaItem const *item) const { +void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item) const { NRRectL b(bbox); for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) _primitive[i]->area_enlarge(b, item->ctm); + if (_primitive[i]) _primitive[i]->area_enlarge(b, item->ctm()); } bbox = *b.upgrade_2geom(); @@ -208,7 +208,7 @@ void Filter::area_enlarge(Geom::IntRect &bbox, NRArenaItem const *item) const { } Geom::Rect item_bbox; - Geom::OptRect maybe_bbox = item->item_bbox; + Geom::OptRect maybe_bbox = item->itemBounds(); if (maybe_bbox.isEmpty()) { // Code below needs a bounding box return; @@ -216,9 +216,9 @@ void Filter::area_enlarge(Geom::IntRect &bbox, NRArenaItem const *item) const { item_bbox = *maybe_bbox; std::pair res_low - = _filter_resolution(item_bbox, item->ctm, filterquality); + = _filter_resolution(item_bbox, item->ctm(), filterquality); //std::pair res_full - // = _filter_resolution(item_bbox, item->ctm, FILTER_QUALITY_BEST); + // = _filter_resolution(item_bbox, item->ctm(), FILTER_QUALITY_BEST); double pixels_per_block = fmax(item_bbox.width() / res_low.first, item_bbox.height() / res_low.second); bbox.x0 -= (int)pixels_per_block; @@ -228,10 +228,10 @@ void Filter::area_enlarge(Geom::IntRect &bbox, NRArenaItem const *item) const { */ } -Geom::IntRect Filter::compute_drawbox(NRArenaItem const *item, Geom::Rect const &item_bbox) { +Geom::IntRect Filter::compute_drawbox(Inkscape::DrawingItem const *item, Geom::Rect const &item_bbox) { Geom::Rect enlarged = filter_effect_area(item_bbox); - enlarged *= item->ctm; + enlarged *= item->ctm(); Geom::IntRect ret(enlarged.roundOutwards()); return ret; diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 5cebf3ad3..31705f53b 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -21,21 +21,20 @@ #include "sp-filter-units.h" #include "gc-managed.h" -struct NRArenaItem; - namespace Inkscape { class DrawingContext; +class DrawingItem; namespace Filters { -class Filter : public Inkscape::GC::Managed<> { +class Filter { public: /** Given background state from @a bgct and an intermediate rendering from the surface * backing @a graphic, modify the contents of the surface backing @a graphic to represent * the results of filter rendering. @a bgarea and @a area specify bounding boxes * of both surfaces in world coordinates; Cairo contexts are assumed to be in default state * (0,0 = surface origin, no path, OVER operator) */ - int render(NRArenaItem const *item, DrawingContext &bgct, DrawingContext &graphic); + int render(Inkscape::DrawingItem const *item, DrawingContext &bgct, DrawingContext &graphic); /** * Creates a new filter primitive under this filter object. @@ -151,13 +150,13 @@ public: * to be rendered so that after filtering, the original area is * drawn correctly. */ - void area_enlarge(Geom::IntRect &area, NRArenaItem const *item) const; + void area_enlarge(Geom::IntRect &area, Inkscape::DrawingItem const *item) const; /** * Given an item bounding box (in user coords), this function enlarges it * to contain the filter effects region and transforms it to screen * coordinates */ - Geom::IntRect compute_drawbox(NRArenaItem const *item, Geom::Rect const &item_bbox); + Geom::IntRect compute_drawbox(Inkscape::DrawingItem const *item, Geom::Rect const &item_bbox); /** * Returns the filter effects area in user coordinate system. * The given bounding box should be a bounding box as specified in diff --git a/src/display/rendermode.h b/src/display/rendermode.h index 8fc022bfb..cbd35de73 100644 --- a/src/display/rendermode.h +++ b/src/display/rendermode.h @@ -15,10 +15,10 @@ enum RenderMode { RENDERMODE_OUTLINE }; -enum ColorRenderMode { - COLORRENDERMODE_NORMAL, - COLORRENDERMODE_GRAYSCALE, - COLORRENDERMODE_PRINT_COLORS_PREVIEW +enum ColorMode { + COLORMODE_NORMAL, + COLORMODE_GRAYSCALE, + COLORMODE_PRINT_COLORS_PREVIEW }; } diff --git a/src/document.cpp b/src/document.cpp index 5bcf1bf40..64f4ea92a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -44,7 +44,7 @@ #include "desktop.h" #include "dir-util.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "document-private.h" #include "helper/units.h" #include "inkscape-private.h" @@ -1113,8 +1113,8 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro for ( SPObject *o = group->firstChild() ; o && !bottomMost; o = o->getNext() ) { if ( SP_IS_ITEM(o) ) { SPItem *item = SP_ITEM(o); - NRArenaItem *arenaitem = item->get_arenaitem(dkey); - if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL + Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); + if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { if (g_slist_find((GSList *) list, item) != NULL) { bottomMost = item; @@ -1167,10 +1167,10 @@ SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const } } else { SPItem *child = SP_ITEM(o); - NRArenaItem *arenaitem = child->get_arenaitem(dkey); + Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); // seen remembers the last (topmost) of items pickable at this point - if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL + if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { seen = child; } @@ -1201,10 +1201,10 @@ SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const } if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { SPItem *child = SP_ITEM(o); - NRArenaItem *arenaitem = child->get_arenaitem(dkey); + Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); // seen remembers the last (topmost) of groups pickable at this point - if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL) { + if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) { seen = child; } } diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index f741c9f39..4b551e730 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -28,7 +28,6 @@ #include "extension/db.h" #include "extension/output.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "display/curve.h" #include "display/canvas-bpath.h" @@ -61,7 +60,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) SPItem *base = doc->getRoot(); NRArena *arena = NRArena::create(); unsigned dkey = SPItem::display_key_new(1); - NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); + base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ renderer = new CairoRenderer(); diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 7fdfaf8df..7e5324e57 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -30,7 +30,6 @@ #include "extension/db.h" #include "extension/output.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "display/curve.h" #include "display/canvas-bpath.h" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 22b68b0ca..c7cba09bb 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -33,8 +33,7 @@ #include #include "display/nr-arena.h" -#include "display/nr-arena-item.h" -#include "display/nr-arena-group.h" +#include "display/display-forward.h" #include "display/curve.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" @@ -91,14 +90,14 @@ struct SPClipPathView { SPClipPathView *next; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; NRRect bbox; }; struct SPMaskView { SPMaskView *next; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; NRRect bbox; }; diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 5d7c82bff..5be9e15c3 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -30,7 +30,6 @@ #include "extension/db.h" #include "extension/output.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "display/curve.h" #include "display/canvas-bpath.h" diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 7eb7881dc..76fc5073f 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -37,8 +37,7 @@ #include #include "display/nr-arena.h" -#include "display/nr-arena-item.h" -#include "display/nr-arena-group.h" +#include "display/display-forward.h" #include "display/curve.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" @@ -88,14 +87,14 @@ struct SPClipPathView { SPClipPathView *next; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; NRRect bbox; }; struct SPMaskView { SPMaskView *next; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; NRRect bbox; }; diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 376db7ee3..000280158 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -19,7 +19,7 @@ #include "extension/print.h" #include "extension/db.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/display-forward.h" #include "sp-root.h" @@ -73,7 +73,7 @@ void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, /* Release arena */ (mod->base)->invoke_hide (mod->dkey); mod->base = NULL; - mod->root = NULL; + mod->root = NULL; // should have been deleted by invoke_hide nr_object_unref ((NRObject *) mod->arena); mod->arena = NULL; /* end */ diff --git a/src/extension/print.h b/src/extension/print.h index d5218aed8..b3c686d26 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -13,7 +13,7 @@ #include "extension.h" -#include "display/nr-arena-forward.h" +#include "display/display-forward.h" #include "forward.h" #include "sp-item.h" namespace Inkscape { @@ -22,10 +22,10 @@ namespace Extension { class Print : public Extension { public: /* TODO: These are public for the short term, but this should be fixed */ - SPItem *base; /**< TODO: Document these */ - NRArena *arena; /**< TODO: Document these */ - NRArenaItem *root; /**< TODO: Document these */ - unsigned int dkey; /**< TODO: Document these */ + SPItem *base; + NRArena *arena; + Inkscape::DrawingItem *root; + unsigned int dkey; public: Print (Inkscape::XML::Node * in_repr, diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 84c97b096..a71333a4f 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -20,54 +20,53 @@ #include "config.h" #endif +#include <2geom/pathvector.h> #include #include #include +#include -#include "macros.h" -#include "display/sp-canvas.h" -#include "document.h" -#include "sp-namedview.h" -#include "sp-object.h" -#include "sp-rect.h" -#include "selection.h" -#include "desktop-handles.h" +#include "color.h" +#include "context-fns.h" #include "desktop.h" +#include "desktop-handles.h" #include "desktop-style.h" -#include "message-stack.h" -#include "message-context.h" -#include "pixmaps/cursor-paintbucket.xpm" +#include "display/cairo-utils.h" +#include "display/canvas-arena.h" +#include "display/drawing-context.h" +#include "display/drawing-image.h" +#include "display/drawing-item.h" +#include "display/nr-arena.h" +#include "display/sp-canvas.h" +#include "document.h" #include "flood-context.h" -#include "sp-metrics.h" -#include +#include "livarot/Path.h" +#include "livarot/Shape.h" +#include "macros.h" +#include "message-context.h" +#include "message-stack.h" #include "object-edit.h" -#include "xml/repr.h" -#include "xml/node-event-vector.h" #include "preferences.h" -#include "context-fns.h" #include "rubberband.h" +#include "selection.h" #include "shape-editor.h" - -#include "display/nr-arena-item.h" -#include "display/nr-arena.h" -#include "display/nr-arena-image.h" -#include "display/canvas-arena.h" -#include "display/cairo-utils.h" -#include "display/drawing-context.h" -#include <2geom/pathvector.h> -#include "sp-item.h" -#include "sp-root.h" #include "sp-defs.h" -#include "sp-path.h" +#include "sp-item.h" #include "splivarot.h" -#include "livarot/Path.h" -#include "livarot/Shape.h" +#include "sp-metrics.h" +#include "sp-namedview.h" +#include "sp-object.h" +#include "sp-path.h" +#include "sp-rect.h" +#include "sp-root.h" #include "svg/svg.h" -#include "color.h" - -#include "trace/trace.h" #include "trace/imagemap.h" #include "trace/potrace/inkscape-potrace.h" +#include "trace/trace.h" +#include "xml/node-event-vector.h" +#include "xml/repr.h" + +#include "pixmaps/cursor-paintbucket.xpm" using Inkscape::DocumentUndo; @@ -812,15 +811,12 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even Geom::Affine affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = document->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); - nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); - - NRGC gc(NULL); - gc.transform.setIdentity(); + Inkscape::DrawingItem *root = document->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); + root->setTransform(affine); + Inkscape::UpdateContext ctx; Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); - - nr_arena_item_invoke_update(root, final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + root->update(final_bbox, ctx, Inkscape::DrawingItem::STATE_ALL, 0); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); guchar *px = g_new(guchar, stride * height); @@ -842,7 +838,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even ct.paint(); ct.setOperator(CAIRO_OPERATOR_OVER); - nr_arena_item_invoke_render(ct, root, final_bbox, NR_ARENA_ITEM_RENDER_NO_CACHE ); + root->render(ct, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); cairo_surface_destroy(s); diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert index 2ccec8d16..7110c2025 100644 --- a/src/helper/Makefile_insert +++ b/src/helper/Makefile_insert @@ -18,7 +18,6 @@ ink_common_sources += \ helper/recthull.h \ helper/sp-marshal.cpp \ helper/sp-marshal.h \ - helper/stlport.h \ helper/unit-menu.cpp \ helper/unit-menu.h \ helper/unit-tracker.cpp \ diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index c845da011..959007450 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -24,7 +24,7 @@ #include "helper/png-write.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "display/nr-arena.h" #include "document.h" #include "sp-item.h" @@ -111,43 +111,40 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, { if (width == 0 || height == 0) return NULL; - GdkPixbuf* pixbuf = NULL; - /* Create new arena for offscreen rendering*/ - NRArena *arena = NRArena::create(); - nr_arena_set_renderoffscreen(arena); - unsigned dkey = SPItem::display_key_new(1); + GdkPixbuf* pixbuf = NULL; + /* Create new arena for offscreen rendering*/ + NRArena *arena = NRArena::create(); + nr_arena_set_renderoffscreen(arena); + unsigned dkey = SPItem::display_key_new(1); - doc->ensureUpToDate(); + doc->ensureUpToDate(); - Geom::Rect screen=Geom::Rect(Geom::Point(x0,y0), Geom::Point(x1, y1)); + Geom::Rect screen=Geom::Rect(Geom::Point(x0,y0), Geom::Point(x1, y1)); - double padding = 1.0; + double padding = 1.0; - Geom::Point origin(screen.min()[Geom::X], - doc->getHeight() - screen[Geom::Y].extent() - screen.min()[Geom::Y]); + Geom::Point origin(screen.min()[Geom::X], + doc->getHeight() - screen[Geom::Y].extent() - screen.min()[Geom::Y]); - origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); - origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); + origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); + origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); - Geom::Scale scale( (xdpi / PX_PER_IN), (ydpi / PX_PER_IN)); - Geom::Affine affine = scale * Geom::Translate(-origin * scale); + Geom::Scale scale( (xdpi / PX_PER_IN), (ydpi / PX_PER_IN)); + Geom::Affine affine = scale * Geom::Translate(-origin * scale); - /* Create ArenaItems and set transform */ - NRArenaItem *root = doc->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); - nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); + /* Create ArenaItems and set transform */ + Inkscape::DrawingItem *root = doc->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); + root->setTransform(affine); + Inkscape::UpdateContext ctx; - NRGC gc(NULL); - gc.transform.setIdentity(); - - // We show all and then hide all items we don't want, instead of showing only requested items, - // because that would not work if the shown item references something in defs - if (items_only) { - hide_other_items_recursively(doc->getRoot(), items_only, dkey); - } + // We show all and then hide all items we don't want, instead of showing only requested items, + // because that would not work if the shown item references something in defs + if (items_only) { + hide_other_items_recursively(doc->getRoot(), items_only, dkey); + } Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); - - nr_arena_item_invoke_update(root, final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + root->update(final_bbox, ctx, Inkscape::DrawingItem::STATE_ALL, 0); cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); @@ -155,7 +152,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, Inkscape::DrawingContext ct(surface, Geom::Point(0,0)); // render items - nr_arena_item_invoke_render(ct, root, final_bbox, NR_ARENA_ITEM_RENDER_NO_CACHE ); + root->render(ct, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(surface), GDK_COLORSPACE_RGB, TRUE, diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index d2983806a..7812969a0 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -24,7 +24,7 @@ #include "png-write.h" #include "io/sys.h" #include "display/drawing-context.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "display/nr-arena.h" #include "document.h" #include "sp-item.h" @@ -51,7 +51,7 @@ static unsigned int const MAX_STRIPE_SIZE = 1024*1024; struct SPEBP { unsigned long int width, height, sheight; guint32 background; - NRArenaItem *root; // the root arena item to show; it is assumed that all unneeded items are hidden + Inkscape::DrawingItem *root; // the root arena item to show; it is assumed that all unneeded items are hidden guchar *px; unsigned (*status)(float, void *); void *data; @@ -326,11 +326,8 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v Geom::IntRect bbox = Geom::IntRect::from_xywh(0, row, ebp->width, num_rows); /* Update to renderable state */ - NRGC gc(NULL); - gc.transform.setIdentity(); - - nr_arena_item_invoke_update(ebp->root, bbox, &gc, - NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); + Inkscape::UpdateContext ctx; + ebp->root->update(bbox, ctx, Inkscape::DrawingItem::STATE_ALL, 0); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ebp->width); unsigned char *px = g_new(guchar, num_rows * stride); @@ -344,7 +341,7 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v ct.setOperator(CAIRO_OPERATOR_OVER); /* Render */ - nr_arena_item_invoke_render(ct, ebp->root, bbox, 0); + ebp->root->render(ct, bbox, 0); cairo_surface_destroy(s); *to_free = px; @@ -462,7 +459,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, // Create ArenaItems and set transform ebp.root = doc->getRoot()->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); - nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine); + ebp.root->setTransform(affine); // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs diff --git a/src/interface.cpp b/src/interface.cpp index 25153097d..a981424fa 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -646,7 +646,7 @@ update_view_menu(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_dat Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(widget), "view"); SPDesktop *dt = static_cast(view); Inkscape::RenderMode mode = dt->getMode(); - Inkscape::ColorRenderMode colormode = dt->getColorMode(); + Inkscape::ColorMode colormode = dt->getColorMode(); bool new_state = false; if (!strcmp(action->id, "ViewModeNormal")) { @@ -656,11 +656,11 @@ update_view_menu(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_dat } else if (!strcmp(action->id, "ViewModeOutline")) { new_state = mode == Inkscape::RENDERMODE_OUTLINE; } else if (!strcmp(action->id, "ViewColorModeNormal")) { - new_state = colormode == Inkscape::COLORRENDERMODE_NORMAL; + new_state = colormode == Inkscape::COLORMODE_NORMAL; } else if (!strcmp(action->id, "ViewColorModeGrayscale")) { - new_state = colormode == Inkscape::COLORRENDERMODE_GRAYSCALE; + new_state = colormode == Inkscape::COLORMODE_GRAYSCALE; } else if (!strcmp(action->id, "ViewColorModePrintColorsPreview")) { - new_state = colormode == Inkscape::COLORRENDERMODE_PRINT_COLORS_PREVIEW; + new_state = colormode == Inkscape::COLORMODE_PRINT_COLORS_PREVIEW; } else { g_warning("update_view_menu does not handle this verb"); } diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 610f92582..a72fa0180 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -10,7 +10,7 @@ */ #include #include "Layout-TNG.h" -#include "display/nr-arena-glyphs.h" +#include "display/drawing-text.h" #include "style.h" #include "print.h" #include "extension/print.h" @@ -81,28 +81,27 @@ void Layout::_getGlyphTransformMatrix(int glyph_index, Geom::Affine *matrix) con } } -void Layout::show(NRArenaGroup *in_arena, NRRect const *paintbox) const +void Layout::show(DrawingGroup *in_arena, NRRect const *paintbox) const { int glyph_index = 0; for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) { if (_input_stream[_spans[span_index].in_input_stream_item]->Type() != TEXT_SOURCE) continue; InputStreamTextSource const *text_source = static_cast(_input_stream[_spans[span_index].in_input_stream_item]); - NRArenaGlyphsGroup *nr_group = NRArenaGlyphsGroup::create(in_arena->arena); - nr_arena_item_add_child(in_arena, nr_group, NULL); - nr_arena_item_unref(nr_group); - nr_arena_glyphs_group_set_style(nr_group, text_source->style); + DrawingText *nr_text = new DrawingText(in_arena->drawing()); + nr_text->setStyle(text_source->style); + while (glyph_index < (int)_glyphs.size() && _characters[_glyphs[glyph_index].in_character].in_span == span_index) { if (_characters[_glyphs[glyph_index].in_character].in_glyph != -1) { Geom::Affine glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); - nr_arena_glyphs_group_add_component(nr_group, _spans[span_index].font, _glyphs[glyph_index].glyph, glyph_matrix); + nr_text->addComponent(_spans[span_index].font, _glyphs[glyph_index].glyph, glyph_matrix); } glyph_index++; } - nr_arena_glyphs_group_set_paintbox(NR_ARENA_GLYPHS_GROUP(nr_group), paintbox); + nr_text->setPaintBox(paintbox ? paintbox->upgrade_2geom() : Geom::OptRect()); + in_arena->prependChild(nr_text); } - nr_arena_item_request_update(NR_ARENA_ITEM(in_arena), NR_ARENA_ITEM_STATE_ALL, FALSE); } void Layout::getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start, int length) const diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 6ab02c0e3..25f80e9e9 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -37,7 +37,6 @@ using Inkscape::Extension::Internal::CairoRenderContext; class SPStyle; class Shape; -class NRArenaGroup; class SPPrintContext; class SVGLength; class Path; @@ -46,6 +45,8 @@ class font_instance; typedef struct _PangoFontDescription PangoFontDescription; namespace Inkscape { +class DrawingGroup; + namespace Text { /** \brief Generates the layout for either wrapped or non-wrapped text and stores the result @@ -327,7 +328,7 @@ public: \param in_arena The arena to add the glyphs group to \param paintbox The current rendering tile */ - void show(NRArenaGroup *in_arena, NRRect const *paintbox) const; + void show(DrawingGroup *in_arena, NRRect const *paintbox) const; /** Calculates the smallest rectangle completely enclosing all the glyphs. diff --git a/src/marker.cpp b/src/marker.cpp index d3fa83ed6..11a270e73 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -21,7 +21,7 @@ #include <2geom/affine.h> #include <2geom/transforms.h> #include "svg/svg.h" -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "xml/repr.h" #include "attributes.h" #include "marker.h" @@ -31,7 +31,7 @@ struct SPMarkerView { SPMarkerView *next; unsigned int key; - std::vector items; + std::vector items; }; static void sp_marker_class_init (SPMarkerClass *klass); @@ -43,7 +43,7 @@ static void sp_marker_set (SPObject *object, unsigned int key, const gchar *valu static void sp_marker_update (SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_marker_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static NRArenaItem *sp_marker_private_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_marker_private_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_marker_private_hide (SPItem *item, unsigned int key); static void sp_marker_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_marker_print (SPItem *item, SPPrintContext *ctx); @@ -448,8 +448,8 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) for (SPMarkerView *v = marker->views; v != NULL; v = v->next) { for (unsigned i = 0 ; i < v->items.size() ; i++) { if (v->items[i]) { - Geom::Affine tmp = marker->c2p; - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &tmp); + Inkscape::DrawingGroup *g = dynamic_cast(v->items[i]); + g->setChildTransform(marker->c2p); } } } @@ -522,7 +522,7 @@ sp_marker_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X /** * This routine is disabled to break propagation. */ -static NRArenaItem * +static Inkscape::DrawingItem * sp_marker_private_show (SPItem */*item*/, NRArena */*arena*/, unsigned int /*key*/, unsigned int /*flags*/) { /* Break propagation */ @@ -560,14 +560,14 @@ sp_marker_print (SPItem */*item*/, SPPrintContext */*ctx*/) /** * Removes any SPMarkerViews that a marker has with a specific key. - * Set up the NRArenaItem array's size in the specified SPMarker's SPMarkerView. + * Set up the DrawingItem array's size in the specified SPMarker's SPMarkerView. * This is called from sp_shape_update() for shapes that have markers. It * removes the old view of the marker and establishes a new one, registering * it with the marker's list of views for future updates. * * \param marker Marker to create views in. * \param key Key to give each SPMarkerView. - * \param size Number of NRArenaItems to put in the SPMarkerView. + * \param size Number of DrawingItems to put in the SPMarkerView. */ void sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) @@ -601,8 +601,8 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) * Shows an instance of a marker. This is called during sp_shape_update_marker_view() * show and transform a child item in the arena for all views with the given key. */ -NRArenaItem * -sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, +Inkscape::DrawingItem * +sp_marker_show_instance ( SPMarker *marker, Inkscape::DrawingItem *parent, unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth) { @@ -621,14 +621,13 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, if (!v->items[pos]) { /* Parent class ::show method */ v->items[pos] = ((SPItemClass *) parent_class)->show ((SPItem *) marker, - parent->arena, key, + parent->drawing(), key, SP_ITEM_REFERENCE_FLAGS); if (v->items[pos]) { /* fixme: Position (Lauris) */ - nr_arena_item_add_child (parent, v->items[pos], NULL); - /* nr_arena_item_unref (v->items[pos]); */ - Geom::Affine tmp = marker->c2p; - nr_arena_group_set_child_transform((NRArenaGroup *) v->items[pos], &tmp); + parent->prependChild(v->items[pos]); + Inkscape::DrawingGroup *g = dynamic_cast(v->items[pos]); + if (g) g->setChildTransform(marker->c2p); } } if (v->items[pos]) { @@ -643,8 +642,7 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { m = Geom::Scale(linewidth) * m; } - - nr_arena_item_set_transform(v->items[pos], m); + v->items[pos]->setTransform(m); } return v->items[pos]; } @@ -695,7 +693,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro if (destroyitems) { for (i = 0; i < view->items.size(); i++) { /* We have to walk through the whole array because there may be hidden items */ - if (view->items[i]) nr_arena_item_unref (view->items[i]); + delete view->items[i]; } } view->items.clear(); diff --git a/src/marker.h b/src/marker.h index 09461b3a1..eb907e2fb 100644 --- a/src/marker.h +++ b/src/marker.h @@ -85,7 +85,7 @@ protected: }; void sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size); -NRArenaItem *sp_marker_show_instance (SPMarker *marker, NRArenaItem *parent, +Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::DrawingItem *parent, unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); diff --git a/src/print.cpp b/src/print.cpp index 1ee58a3e6..29c5b0ed2 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -15,6 +15,8 @@ # include "config.h" #endif +#include "display/nr-arena.h" +#include "display/drawing-item.h" #include "inkscape.h" #include "desktop.h" #include "sp-item.h" @@ -80,9 +82,6 @@ unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, return ctx->module->text(text, p, style); } -#include "display/nr-arena.h" -#include "display/nr-arena-item.h" - /* UI */ void @@ -92,19 +91,11 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) // Build arena SPItem *base = doc->getRoot(); - NRArena *arena = NRArena::create(); - unsigned int dkey = SPItem::display_key_new(1); - // TODO investigate why we are grabbing root and then ignoring it. - NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); // Run print dialog Inkscape::UI::Dialog::Print printop(doc,base); Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow); (void)res; // TODO handle this - - // Release arena - base->invoke_hide(dkey); - nr_object_unref((NRObject *) arena); } void @@ -138,8 +129,8 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename) /* Release arena */ (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; - mod->root = NULL; nr_object_unref((NRObject *) mod->arena); + mod->root = NULL; // should be deleted by invoke_hide mod->arena = NULL; /* end */ diff --git a/src/print.h b/src/print.h index caea6ae3a..6bdbe4b82 100644 --- a/src/print.h +++ b/src/print.h @@ -17,6 +17,7 @@ #include "forward.h" #include "extension/extension-forward.h" +struct NRRect; struct SPPrintContext { Inkscape::Extension::Print *module; }; diff --git a/src/select-context.cpp b/src/select-context.cpp index 143fb1ae2..b3e38bf7b 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -43,7 +43,7 @@ #include "seltrans.h" #include "box3d.h" #include "display/sp-canvas.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" using Inkscape::DocumentUndo; @@ -414,7 +414,7 @@ sp_select_context_cycle_through_items(SPSelectContext *sc, Inkscape::Selection * if (!sc->cycling_cur_item) return; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop; SPItem *item = SP_ITEM(sc->cycling_cur_item->data); @@ -422,7 +422,7 @@ sp_select_context_cycle_through_items(SPSelectContext *sc, Inkscape::Selection * if (!g_list_find(sc->cycling_items_selected_before, item) && selection->includes(item)) selection->remove(item); arenaitem = item->get_arenaitem(desktop->dkey); - nr_arena_item_set_opacity (arenaitem, 0.3); + arenaitem->setOpacity(0.3); // Find next item and activate it GList *next; @@ -438,7 +438,7 @@ sp_select_context_cycle_through_items(SPSelectContext *sc, Inkscape::Selection * sc->cycling_cur_item = next; item = SP_ITEM(sc->cycling_cur_item->data); arenaitem = item->get_arenaitem(desktop->dkey); - nr_arena_item_set_opacity (arenaitem, 1.0); + arenaitem->setOpacity(1.0); if (shift_pressed) selection->add(item); @@ -788,10 +788,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) g_assert(sc->cycling_cur_item != NULL || sc->cycling_items == NULL); } else { // ... otherwise reset opacities for outdated items ... - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; for(GList *l = sc->cycling_items_cmp; l != NULL; l = l->next) { arenaitem = SP_ITEM(l->data)->get_arenaitem(desktop->dkey); - nr_arena_item_set_opacity (arenaitem, 1.0); + arenaitem->setOpacity(1.0); //if (!shift_pressed && !g_list_find(sc->cycling_items_selected_before, SP_ITEM(l->data)) && selection->includes(SP_ITEM(l->data))) if (!g_list_find(sc->cycling_items_selected_before, SP_ITEM(l->data)) && selection->includes(SP_ITEM(l->data))) selection->remove(SP_ITEM(l->data)); @@ -810,7 +810,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) for(GList *l = sc->cycling_items; l != NULL; l = l->next) { item = SP_ITEM(l->data); arenaitem = item->get_arenaitem(desktop->dkey); - nr_arena_item_set_opacity (arenaitem, 0.3); + arenaitem->setOpacity(0.3); if (selection->includes(item)) { // already selected items are stored separately, too sc->cycling_items_selected_before = g_list_append(sc->cycling_items_selected_before, item); @@ -1085,10 +1085,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (alt) { // TODO: Should we have a variable like is_cycling or is it harmless to run this piece of code each time? // quit cycle-selection and reset opacities SPSelectContext *sc = SP_SELECT_CONTEXT(event_context); - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; for (GList *l = sc->cycling_items; l != NULL; l = g_list_next(l)) { arenaitem = SP_ITEM(l->data)->get_arenaitem(desktop->dkey); - nr_arena_item_set_opacity (arenaitem, 1.0); + arenaitem->setOpacity(1.0); } g_list_free(sc->cycling_items); g_list_free(sc->cycling_items_selected_before); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 48e466628..14c206828 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -16,7 +16,7 @@ #include #include "display/nr-arena.h" -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "xml/repr.h" #include "enums.h" @@ -24,6 +24,7 @@ #include "document.h" #include "document-private.h" #include "sp-item.h" +#include "style.h" #include <2geom/transforms.h> @@ -32,11 +33,11 @@ struct SPClipPathView { SPClipPathView *next; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; NRRect bbox; }; -SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, NRArenaItem *arenaitem); +SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); SPClipPathView *sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); SPObjectGroupClass * SPClipPathClass::static_parent_class = 0; @@ -155,11 +156,11 @@ void SPClipPath::childAdded(SPObject *object, Inkscape::XML::Node *child, Inksca if (SP_IS_ITEM(ochild)) { SPClipPath *cp = SP_CLIPPATH(object); for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { - NRArenaItem *ac = SP_ITEM(ochild)->invoke_show( NR_ARENA_ITEM_ARENA(v->arenaitem), + Inkscape::DrawingItem *ac = SP_ITEM(ochild)->invoke_show( v->arenaitem->drawing(), v->key, SP_ITEM_REFERENCE_FLAGS); if (ac) { - nr_arena_item_add_child(v->arenaitem, ac, NULL); + v->arenaitem->prependChild(ac); } } } @@ -191,13 +192,14 @@ void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags) SPClipPath *cp = SP_CLIPPATH(object); for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { Geom::Affine t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); t[4] = v->bbox.x0; t[5] = v->bbox.y0; - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), &t); + g->setChildTransform(t); } else { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), NULL); + g->setChildTransform(Geom::identity()); } } } @@ -240,20 +242,20 @@ Inkscape::XML::Node *SPClipPath::write(SPObject *object, Inkscape::XML::Document return repr; } -NRArenaItem *SPClipPath::show(NRArena *arena, unsigned int key) +Inkscape::DrawingItem *SPClipPath::show(NRArena *arena, unsigned int key) { g_return_val_if_fail(arena != NULL, NULL); g_return_val_if_fail(NR_IS_ARENA(arena), NULL); - NRArenaItem *ai = NRArenaGroup::create(arena); + Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(arena); display = sp_clippath_view_new_prepend(display, key, ai); for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { if (SP_IS_ITEM(child)) { - NRArenaItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); + Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in clippath */ - nr_arena_item_add_child(ai, ac, NULL); + ai->appendChild(ac); } } } @@ -262,9 +264,9 @@ NRArenaItem *SPClipPath::show(NRArena *arena, unsigned int key) Geom::Affine t(Geom::Scale(display->bbox.x1 - display->bbox.x0, display->bbox.y1 - display->bbox.y0)); t[4] = display->bbox.x0; t[5] = display->bbox.y0; - nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), &t); + ai->setChildTransform(t); } - nr_arena_group_set_style(NR_ARENA_GROUP(ai), this->style); + ai->setStyle(this->style); return ai; } @@ -329,13 +331,13 @@ void SPClipPath::getBBox(NRRect *bbox, Geom::Affine const &transform, unsigned c /* ClipPath views */ SPClipPathView * -sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, NRArenaItem *arenaitem) +sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem) { SPClipPathView *new_path_view = g_new(SPClipPathView, 1); new_path_view->next = list; new_path_view->key = key; - new_path_view->arenaitem = nr_arena_item_ref(arenaitem); + new_path_view->arenaitem = arenaitem; new_path_view->bbox.x0 = new_path_view->bbox.x1 = 0.0; new_path_view->bbox.y0 = new_path_view->bbox.y1 = 0.0; @@ -354,7 +356,7 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view) prev->next = view->next; } - nr_arena_item_unref(view->arenaitem); + delete view->arenaitem; g_free(view); return list; diff --git a/src/sp-clippath.h b/src/sp-clippath.h index d3c650ca6..d163e0709 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -23,7 +23,7 @@ class SPClipPathView; -#include "display/nr-arena-forward.h" +#include "display/display-forward.h" #include "libnr/nr-forward.h" #include "sp-object-group.h" #include "uri-references.h" @@ -40,7 +40,7 @@ public: static const gchar *create(GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); static GType sp_clippath_get_type(void); - NRArenaItem *show(NRArena *arena, unsigned int key); + Inkscape::DrawingItem *show(NRArena *arena, unsigned int key); void hide(unsigned int key); void setBBox(unsigned int key, NRRect *bbox); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 87266464c..cbdc8684b 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -31,7 +31,7 @@ #include "livarot/Shape.h" -#include "display/nr-arena-glyphs.h" +#include "display/drawing-text.h" static void sp_flowtext_class_init(SPFlowtextClass *klass); @@ -50,7 +50,7 @@ static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine cons static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_flowtext_description(SPItem *item); static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -static NRArenaItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); +static Inkscape::DrawingItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); static void sp_flowtext_hide(SPItem *item, unsigned key); static SPItemClass *parent_class; @@ -179,10 +179,11 @@ static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) NRRect paintbox; group->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView *v = group->display; v != NULL; v = v->next) { - group->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + group->_clearFlow(g); + g->setStyle(object->style); // pass the bbox of the flowtext object as paintbox (used for paintserver fills) - group->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox); + group->layout.show(g, &paintbox); } } @@ -200,9 +201,10 @@ static void sp_flowtext_modified(SPObject *object, guint flags) NRRect paintbox; text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { - text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); - text->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + text->_clearFlow(g); + g->setStyle(object->style); + text->layout.show(g, &paintbox); } } @@ -406,14 +408,13 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vectorstyle); + Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(arena); + flowed->setPickChildren(false); + flowed->setStyle(group->style); // pass the bbox of the flowtext object as paintbox (used for paintserver fills) NRRect paintbox; @@ -541,17 +542,9 @@ void SPFlowtext::rebuildLayout() //g_print(layout.dumpAsText().c_str()); } -void SPFlowtext::_clearFlow(NRArenaGroup *in_arena) +void SPFlowtext::_clearFlow(Inkscape::DrawingGroup *in_arena) { - nr_arena_item_request_render(NR_ARENA_ITEM(in_arena)); - for (NRArenaItem *child = in_arena->children; child != NULL; ) { - NRArenaItem *nchild = child->next; - - nr_arena_glyphs_group_clear(NR_ARENA_GLYPHS_GROUP(child)); - nr_arena_item_remove_child(NR_ARENA_ITEM(in_arena), child); - - child = nchild; - } + in_arena->clearChildren(); } Inkscape::XML::Node *SPFlowtext::getAsText() diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index 3b0ce178a..d06105c30 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -6,7 +6,7 @@ #include "sp-item.h" -#include "display/nr-arena-forward.h" +#include "display/display-forward.h" #include <2geom/forward.h> #include "libnrtype/Layout-TNG.h" @@ -32,7 +32,7 @@ struct SPFlowtext : public SPItem { Inkscape::Text::Layout layout; /** discards the NRArena objects representing this text. */ - void _clearFlow(NRArenaGroup* in_arena); + void _clearFlow(Inkscape::DrawingGroup* in_arena); double par_indent; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index c9647c939..3a1280aa0 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -28,7 +28,7 @@ #include <2geom/transforms.h> #include -#include "display/nr-arena-image.h" +#include "display/drawing-image.h" #include "display/cairo-utils.h" #include "display/curve.h" //Added for preserveAspectRatio support -- EAF @@ -84,14 +84,14 @@ static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const & static void sp_image_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_image_description (SPItem * item); static void sp_image_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -static NRArenaItem *sp_image_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_image_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static Geom::Affine sp_image_set_transform (SPItem *item, Geom::Affine const &xform); static void sp_image_set_curve(SPImage *image); static GdkPixbuf *sp_image_repr_read_image( time_t& modTime, gchar*& pixPath, const gchar *href, const gchar *absref, const gchar *base ); static GdkPixbuf *sp_image_pixbuf_force_rgba (GdkPixbuf * pixbuf); -static void sp_image_update_arenaitem (SPImage *img, NRArenaImage *ai); +static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); static void sp_image_update_canvas_image (SPImage *image); static GdkPixbuf * sp_image_repr_read_dataURI (const gchar * uri_data); static GdkPixbuf * sp_image_repr_read_b64 (const gchar * uri_data); @@ -1018,7 +1018,8 @@ static void sp_image_modified( SPObject *object, unsigned int flags ) if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = image->display; v != NULL; v = v->next) { - nr_arena_image_set_style (NR_ARENA_IMAGE (v->arenaitem), object->style); + Inkscape::DrawingImage *img = dynamic_cast(v->arenaitem); + img->setStyle(object->style); } } } @@ -1148,12 +1149,12 @@ static gchar *sp_image_description( SPItem *item ) return ret; } -static NRArenaItem *sp_image_show( SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/ ) +static Inkscape::DrawingItem *sp_image_show( SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/ ) { SPImage * image = SP_IMAGE(item); - NRArenaItem *ai = NRArenaImage::create(arena); + Inkscape::DrawingImage *ai = new Inkscape::DrawingImage(arena); - sp_image_update_arenaitem(image, NR_ARENA_IMAGE(ai)); + sp_image_update_arenaitem(image, ai); return ai; } @@ -1264,13 +1265,13 @@ static GdkPixbuf *sp_image_pixbuf_force_rgba( GdkPixbuf * pixbuf ) /* We assert that realpixbuf is either NULL or identical size to pixbuf */ static void -sp_image_update_arenaitem (SPImage *image, NRArenaImage *ai) +sp_image_update_arenaitem (SPImage *image, Inkscape::DrawingImage *ai) { - nr_arena_image_set_style(ai, SP_OBJECT(image)->style); - nr_arena_image_set_argb32_pixbuf(ai, image->pixbuf); - nr_arena_image_set_origin(ai, Geom::Point(image->ox, image->oy)); - nr_arena_image_set_scale(ai, image->sx, image->sy); - nr_arena_image_set_clipbox(ai, image->clipbox); + ai->setStyle(SP_OBJECT(image)->style); + ai->setARGB32Pixbuf(image->pixbuf); + ai->setOrigin(Geom::Point(image->ox, image->oy)); + ai->setScale(image->sx, image->sy); + ai->setClipbox(image->clipbox); } static void sp_image_update_canvas_image(SPImage *image) @@ -1278,7 +1279,7 @@ static void sp_image_update_canvas_image(SPImage *image) SPItem *item = SP_ITEM(image); for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_image_update_arenaitem(image, NR_ARENA_IMAGE(v->arenaitem)); + sp_image_update_arenaitem(image, dynamic_cast(v->arenaitem)); } } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 491b2a62a..c27319c83 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -22,7 +22,7 @@ #include #include -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "display/curve.h" #include "xml/repr.h" #include "svg/svg.h" @@ -68,7 +68,7 @@ static void sp_group_set(SPObject *object, unsigned key, char const *value); static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_group_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_group_description (SPItem * item); -static NRArenaItem *sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_group_hide (SPItem * item, unsigned int key); static void sp_group_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); @@ -312,7 +312,7 @@ static void sp_group_set(SPObject *object, unsigned key, char const *value) { } } -static NRArenaItem * +static Inkscape::DrawingItem * sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) { return SP_GROUP(item)->group->show(arena, key, flags); @@ -562,9 +562,9 @@ void SPGroup::_updateLayerMode(unsigned int display_key) { SPItemView *view; for ( view = this->display ; view ; view = view->next ) { if ( !display_key || view->key == display_key ) { - NRArenaGroup *arena_group=NR_ARENA_GROUP(view->arenaitem); - if (arena_group) { - nr_arena_group_set_transparent(arena_group, effectiveLayerMode(view->key) == SPGroup::LAYER); + Inkscape::DrawingGroup *g = dynamic_cast(view->arenaitem); + if (g) { + g->setPickChildren(effectiveLayerMode(view->key) == SPGroup::LAYER); } } } @@ -596,13 +596,13 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) { if ( SP_IS_ITEM(ochild) ) { /* TODO: this should be moved into SPItem somehow */ SPItemView *v; - NRArenaItem *ac; + Inkscape::DrawingItem *ac; for (v = _group->display; v != NULL; v = v->next) { - ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); + ac = SP_ITEM (ochild)->invoke_show (v->arenaitem->drawing(), v->key, v->flags); if (ac) { - nr_arena_item_append_child (v->arenaitem, ac); + v->arenaitem->appendChild(ac); } } } @@ -611,16 +611,16 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) { if ( ochild && SP_IS_ITEM(ochild) ) { /* TODO: this should be moved into SPItem somehow */ SPItemView *v; - NRArenaItem *ac; + Inkscape::DrawingItem *ac; unsigned position = SP_ITEM(ochild)->pos_in_parent(); for (v = _group->display; v != NULL; v = v->next) { - ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); + ac = SP_ITEM (ochild)->invoke_show (v->arenaitem->drawing(), v->key, v->flags); if (ac) { - nr_arena_item_add_child (v->arenaitem, ac, NULL); - nr_arena_item_set_order (ac, position); + v->arenaitem->prependChild(ac); + ac->setZOrder(position); } } } @@ -646,10 +646,11 @@ void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - SPObject *object = _group; - for (SPItemView *v = _group->display; v != NULL; v = v->next) { - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); - } + SPObject *object = _group; + for (SPItemView *v = _group->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *group = dynamic_cast(v->arenaitem); + group->setStyle(object->style); + } } GSList *l = g_slist_reverse(_group->childList(true, SPObject::ActionUpdate)); @@ -677,10 +678,11 @@ void CGroup::onModified(guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - SPObject *object = _group; - for (SPItemView *v = _group->display; v != NULL; v = v->next) { - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); - } + SPObject *object = _group; + for (SPItemView *v = _group->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *group = dynamic_cast(v->arenaitem); + group->setStyle(object->style); + } } GSList *l = g_slist_reverse(_group->childList(true)); @@ -742,24 +744,20 @@ gchar *CGroup::getDescription() { len), len); } -NRArenaItem *CGroup::show (NRArena *arena, unsigned int key, unsigned int flags) { - NRArenaItem *ai; +Inkscape::DrawingItem *CGroup::show (NRArena *arena, unsigned int key, unsigned int flags) { + Inkscape::DrawingGroup *ai; SPObject *object = _group; - ai = NRArenaGroup::create(arena); - - nr_arena_group_set_transparent(NR_ARENA_GROUP (ai), - _group->effectiveLayerMode(key) == - SPGroup::LAYER); - nr_arena_group_set_style(NR_ARENA_GROUP(ai), object->style); + ai = new Inkscape::DrawingGroup(arena); + ai->setPickChildren(_group->effectiveLayerMode(key) == SPGroup::LAYER); + ai->setStyle(object->style); _showChildren(arena, ai, key, flags); return ai; } -void CGroup::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags) { - NRArenaItem *ac = NULL; - NRArenaItem *ar = NULL; +void CGroup::_showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { + Inkscape::DrawingItem *ac = NULL; SPItem * child = NULL; GSList *l = g_slist_reverse(_group->childList(false, SPObject::ActionShow)); while (l) { @@ -767,10 +765,7 @@ void CGroup::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, u if (SP_IS_ITEM (o)) { child = SP_ITEM (o); ac = child->invoke_show (arena, key, flags); - if (ac) { - nr_arena_item_add_child (ai, ac, ar); - ar = ac; - } + ai->appendChild(ac); } l = g_slist_remove (l, o); } @@ -801,7 +796,7 @@ void CGroup::onOrderChanged (Inkscape::XML::Node *child, Inkscape::XML::Node *, SPItemView *v; unsigned position = SP_ITEM(ochild)->pos_in_parent(); for ( v = SP_ITEM (ochild)->display ; v != NULL ; v = v->next ) { - nr_arena_item_set_order (v->arenaitem, position); + v->arenaitem->setZOrder(position); } } diff --git a/src/sp-item-group.h b/src/sp-item-group.h index e2aeb8bc5..88586a6b0 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -73,13 +73,13 @@ public: virtual void onPrint(SPPrintContext *ctx); virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); virtual gchar *getDescription(); - virtual NRArenaItem *show (NRArena *arena, unsigned int key, unsigned int flags); + virtual Inkscape::DrawingItem *show (NRArena *arena, unsigned int key, unsigned int flags); virtual void hide (unsigned int key); gint getItemCount(); protected: - virtual void _showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags); + virtual void _showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); SPGroup *_group; }; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 946c94353..9ab924423 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -30,7 +30,7 @@ #include "svg/svg.h" #include "print.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/drawing-item.h" #include "attributes.h" #include "document.h" #include "uri.h" @@ -145,14 +145,10 @@ void SPItem::init() { display = NULL; clip_ref = new SPClipPathReference(this); - sigc::signal cs1 = clip_ref->changedSignal(); - sigc::slot2 sl1 = sigc::bind(sigc::ptr_fun(clip_ref_changed), this); - _clip_ref_connection = cs1.connect(sl1); + clip_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(clip_ref_changed), this)); mask_ref = new SPMaskReference(this); - sigc::signal cs2 = mask_ref->changedSignal(); - sigc::slot2 sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), this); - _mask_ref_connection = cs2.connect(sl2); + mask_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(mask_ref_changed), this)); avoidRef = new SPAvoidRef(this); @@ -204,10 +200,10 @@ bool SPItem::isHidden(unsigned display_key) const { for ( SPItemView *view(display) ; view ; view = view->next ) { if ( view->key == display_key ) { g_assert(view->arenaitem != NULL); - for ( NRArenaItem *arenaitem = view->arenaitem ; - arenaitem ; arenaitem = arenaitem->parent ) + for ( Inkscape::DrawingItem *arenaitem = view->arenaitem ; + arenaitem ; arenaitem = arenaitem->parent() ) { - if (!arenaitem->visible) { + if (!arenaitem->visible()) { return true; } } @@ -394,35 +390,22 @@ void SPItem::sp_item_release(SPObject *object) { SPItem *item = (SPItem *) object; - item->_clip_ref_connection.disconnect(); - item->_mask_ref_connection.disconnect(); - // Note: do this here before the clip_ref is deleted, since calling // ensureUpToDate() for triggered routing may reference // the deleted clip_ref. - if (item->avoidRef) { - delete item->avoidRef; - item->avoidRef = NULL; - } - - if (item->clip_ref) { - item->clip_ref->detach(); - delete item->clip_ref; - item->clip_ref = NULL; - } + delete item->avoidRef; - if (item->mask_ref) { - item->mask_ref->detach(); - delete item->mask_ref; - item->mask_ref = NULL; - } + // we do NOT disconnect from the changed signal of those before deletion. + // The destructor will call *_ref_changed with NULL as the new value, + // which will cause the hide() function to be called. + delete item->clip_ref; + delete item->mask_ref; if (((SPObjectClass *) (SPItemClass::static_parent_class))->release) { ((SPObjectClass *) SPItemClass::static_parent_class)->release(object); } while (item->display) { - nr_arena_item_unparent(item->display->arenaitem); item->display = sp_item_view_list_remove(item->display, item->display); } @@ -478,7 +461,7 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) case SP_ATTR_SODIPODI_INSENSITIVE: item->sensitive = !value; for (SPItemView *v = item->display; v != NULL; v = v->next) { - nr_arena_item_set_sensitive(v->arenaitem, item->sensitive); + v->arenaitem->setSensitive(item->sensitive); } break; case SP_ATTR_CONNECTOR_AVOID: @@ -529,23 +512,22 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) SPItemView *v; /* Hide clippath */ for (v = item->display; v != NULL; v = v->next) { - SP_CLIPPATH(old_clip)->hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - nr_arena_item_set_clip(v->arenaitem, NULL); + SP_CLIPPATH(old_clip)->hide(v->arenaitem->key()); + v->arenaitem->setClip(NULL); } } if (SP_IS_CLIPPATH(clip)) { NRRect bbox; item->invoke_bbox( &bbox, Geom::identity(), TRUE); for (SPItemView *v = item->display; v != NULL; v = v->next) { - if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(v->arenaitem, SPItem::display_key_new(3)); + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); } - NRArenaItem *ai = SP_CLIPPATH(clip)->show( - NR_ARENA_ITEM_ARENA(v->arenaitem), - NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - nr_arena_item_set_clip(v->arenaitem, ai); - nr_arena_item_unref(ai); - SP_CLIPPATH(clip)->setBBox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + Inkscape::DrawingItem *ai = SP_CLIPPATH(clip)->show( + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setClip(ai); + SP_CLIPPATH(clip)->setBBox(v->arenaitem->key(), &bbox); clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -556,23 +538,22 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) if (old_mask) { /* Hide mask */ for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_hide(SP_MASK(old_mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - nr_arena_item_set_mask(v->arenaitem, NULL); + sp_mask_hide(SP_MASK(old_mask), v->arenaitem->key()); + v->arenaitem->setMask(NULL); } } if (SP_IS_MASK(mask)) { NRRect bbox; item->invoke_bbox( &bbox, Geom::identity(), TRUE); for (SPItemView *v = item->display; v != NULL; v = v->next) { - if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(v->arenaitem, SPItem::display_key_new(3)); + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); } - NRArenaItem *ai = sp_mask_show(SP_MASK(mask), - NR_ARENA_ITEM_ARENA(v->arenaitem), - NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - nr_arena_item_set_mask(v->arenaitem, ai); - nr_arena_item_unref(ai); - sp_mask_set_bbox(SP_MASK(mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + Inkscape::DrawingItem *ai = sp_mask_show(SP_MASK(mask), + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setMask(ai); + sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), &bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -589,7 +570,7 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) { if (flags & SP_OBJECT_MODIFIED_FLAG) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - nr_arena_item_set_transform(v->arenaitem, item->transform); + v->arenaitem->setTransform(item->transform); } } @@ -601,20 +582,20 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) item->invoke_bbox( &bbox, Geom::identity(), TRUE); if (clip_path) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - clip_path->setBBox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + clip_path->setBBox(v->arenaitem->key(), &bbox); } } if (mask) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_set_bbox(mask, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + sp_mask_set_bbox(mask, v->arenaitem->key(), &bbox); } } } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - nr_arena_item_set_opacity(v->arenaitem, SP_SCALE24_TO_FLOAT(object->style->opacity.value)); - nr_arena_item_set_visible(v->arenaitem, !item->isHidden()); + v->arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(object->style->opacity.value)); + v->arenaitem->setVisible(!item->isHidden()); } } } @@ -627,7 +608,7 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) SPItemView *itemview = item->display; do { if (itemview->arenaitem) - nr_arena_item_set_item_bbox(itemview->arenaitem, item_bbox); + itemview->arenaitem->setItemBounds(item_bbox); } while ( (itemview = itemview->next) ); } @@ -1036,34 +1017,33 @@ unsigned SPItem::display_key_new(unsigned numkeys) return dkey - numkeys; } -NRArenaItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) +Inkscape::DrawingItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) { g_assert(arena != NULL); g_assert(NR_IS_ARENA(arena)); - NRArenaItem *ai = NULL; + Inkscape::DrawingItem *ai = NULL; if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) { ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, arena, key, flags); } if (ai != NULL) { display = sp_item_view_new_prepend(display, this, flags, key, ai); - nr_arena_item_set_transform(ai, transform); - nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(style->opacity.value)); - nr_arena_item_set_visible(ai, !isHidden()); - nr_arena_item_set_sensitive(ai, sensitive); + ai->setTransform(transform); + ai->setOpacity(SP_SCALE24_TO_FLOAT(style->opacity.value)); + ai->setVisible(!isHidden()); + ai->setSensitive(sensitive); if (clip_ref->getObject()) { SPClipPath *cp = clip_ref->getObject(); - if (!display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3)); + if (!display->arenaitem->key()) { + display->arenaitem->setKey(display_key_new(3)); } - int clip_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); + int clip_key = display->arenaitem->key(); // Show and set clip - NRArenaItem *ac = cp->show(arena, clip_key); - nr_arena_item_set_clip(ai, ac); - nr_arena_item_unref(ac); + Inkscape::DrawingItem *ac = cp->show(arena, clip_key); + ai->setClip(ac); // Update bbox, in case the clip uses bbox units NRRect bbox; @@ -1074,15 +1054,14 @@ NRArenaItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) if (mask_ref->getObject()) { SPMask *mask = mask_ref->getObject(); - if (!display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3)); + if (!display->arenaitem->key()) { + display->arenaitem->setKey(display_key_new(3)); } - int mask_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); + int mask_key = display->arenaitem->key(); // Show and set mask - NRArenaItem *ac = sp_mask_show(mask, arena, mask_key); - nr_arena_item_set_mask(ai, ac); - nr_arena_item_unref(ac); + Inkscape::DrawingItem *ac = sp_mask_show(mask, arena, mask_key); + ai->setMask(ac); // Update bbox, in case the mask uses bbox units NRRect bbox; @@ -1090,10 +1069,10 @@ NRArenaItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - NR_ARENA_ITEM_SET_DATA(ai, this); + ai->setData(this); Geom::OptRect item_bbox; invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); - nr_arena_item_set_item_bbox(ai, item_bbox); + ai->setItemBounds(item_bbox); } return ai; @@ -1111,20 +1090,19 @@ void SPItem::invoke_hide(unsigned key) SPItemView *next = v->next; if (v->key == key) { if (clip_ref->getObject()) { - (clip_ref->getObject())->hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - nr_arena_item_set_clip(v->arenaitem, NULL); + (clip_ref->getObject())->hide(v->arenaitem->key()); + v->arenaitem->setClip(NULL); } if (mask_ref->getObject()) { - sp_mask_hide(mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - nr_arena_item_set_mask(v->arenaitem, NULL); + sp_mask_hide(mask_ref->getObject(), v->arenaitem->key()); + v->arenaitem->setMask(NULL); } if (!ref) { display = v->next; } else { ref->next = v->next; } - nr_arena_item_unparent(v->arenaitem); - nr_arena_item_unref(v->arenaitem); + delete v->arenaitem; g_free(v); } else { ref = v; @@ -1501,27 +1479,27 @@ Geom::Affine SPItem::dt2i_affine() const /* Item views */ -SPItemView *SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem) +SPItemView *SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, Inkscape::DrawingItem *drawing_item) { g_assert(item != NULL); g_assert(SP_IS_ITEM(item)); - g_assert(arenaitem != NULL); - g_assert(NR_IS_ARENA_ITEM(arenaitem)); + g_assert(drawing_item != NULL); SPItemView *new_view = g_new(SPItemView, 1); new_view->next = list; new_view->flags = flags; new_view->key = key; - new_view->arenaitem = arenaitem; + new_view->arenaitem = drawing_item; return new_view; } SPItemView *SPItem::sp_item_view_list_remove(SPItemView *list, SPItemView *view) { + SPItemView *ret = list; if (view == list) { - list = list->next; + ret = list->next; } else { SPItemView *prev; prev = list; @@ -1529,17 +1507,17 @@ SPItemView *SPItem::sp_item_view_list_remove(SPItemView *list, SPItemView *view) prev->next = view->next; } - nr_arena_item_unref(view->arenaitem); + delete view->arenaitem; g_free(view); - return list; + return ret; } /** * Return the arenaitem corresponding to the given item in the display * with the given key */ -NRArenaItem *SPItem::get_arenaitem(unsigned key) +Inkscape::DrawingItem *SPItem::get_arenaitem(unsigned key) { for ( SPItemView *iv = display ; iv ; iv = iv->next ) { if ( iv->key == key ) { diff --git a/src/sp-item.h b/src/sp-item.h index 0065a9c0e..f8cc948bb 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -20,7 +20,7 @@ */ #include -#include "display/nr-arena-forward.h" +#include "display/display-forward.h" #include "sp-object.h" #include <2geom/affine.h> #include @@ -66,7 +66,7 @@ public: SPItemView *next; unsigned int flags; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; }; /* flags */ @@ -169,9 +169,6 @@ public: Geom::OptRect getBounds(Geom::Affine const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; - sigc::connection _clip_ref_connection; - sigc::connection _mask_ref_connection; - sigc::connection connectTransformed(sigc::slot slot) { return _transformed_signal.connect(slot); } @@ -184,7 +181,7 @@ public: gchar *description(); void invoke_print(SPPrintContext *ctx); static unsigned int display_key_new(unsigned int numkeys); - NRArenaItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); + Inkscape::DrawingItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); void invoke_hide(unsigned int key); void getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs=0) const; void adjust_pattern(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false); @@ -197,7 +194,7 @@ public: void set_item_transform(Geom::Affine const &transform_matrix); void convert_item_to_guides(); gint emitEvent (SPEvent &event); - NRArenaItem *get_arenaitem(unsigned int key); + Inkscape::DrawingItem *get_arenaitem(unsigned int key); void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); Geom::Affine i2doc_affine() const; @@ -226,7 +223,7 @@ private: static gchar *sp_item_private_description(SPItem *item); static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); - static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); + static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, Inkscape::DrawingItem *arenaitem); static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); @@ -249,7 +246,7 @@ public: /** Give short description of item (for status display) */ gchar * (* description) (SPItem * item); - NRArenaItem * (* show) (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); + Inkscape::DrawingItem * (* show) (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); void (* hide) (SPItem *item, unsigned int key); /** Write to an iterator the points that should be considered for snapping diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 38599188f..f23be6fc5 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -16,7 +16,7 @@ #include <2geom/transforms.h> #include "display/nr-arena.h" -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "xml/repr.h" #include "enums.h" @@ -30,7 +30,7 @@ struct SPMaskView { SPMaskView *next; unsigned int key; - NRArenaItem *arenaitem; + Inkscape::DrawingItem *arenaitem; NRRect bbox; }; @@ -45,7 +45,7 @@ static void sp_mask_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_mask_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_mask_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, NRArenaItem *arenaitem); +SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); SPMaskView *sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view); static SPObjectGroupClass *parent_class; @@ -179,11 +179,11 @@ sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML if (SP_IS_ITEM (ochild)) { SPMask *cp = SP_MASK (object); for (SPMaskView *v = cp->display; v != NULL; v = v->next) { - NRArenaItem *ac = SP_ITEM (ochild)->invoke_show ( NR_ARENA_ITEM_ARENA (v->arenaitem), + Inkscape::DrawingItem *ac = SP_ITEM (ochild)->invoke_show ( v->arenaitem->drawing(), v->key, SP_ITEM_REFERENCE_FLAGS); if (ac) { - nr_arena_item_add_child (v->arenaitem, ac, NULL); + v->arenaitem->prependChild(ac); } } } @@ -215,13 +215,14 @@ static void sp_mask_update(SPObject *object, SPCtx *ctx, guint flags) SPMask *mask = SP_MASK(object); for (SPMaskView *v = mask->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { Geom::Affine t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); t[4] = v->bbox.x0; t[5] = v->bbox.y0; - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), &t); + g->setChildTransform(t); } else { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), NULL); + g->setChildTransform(Geom::identity()); } } } @@ -296,22 +297,21 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTr return mask_id; } -NRArenaItem *sp_mask_show(SPMask *mask, NRArena *arena, unsigned int key) +Inkscape::DrawingItem *sp_mask_show(SPMask *mask, NRArena *arena, unsigned int key) { g_return_val_if_fail (mask != NULL, NULL); g_return_val_if_fail (SP_IS_MASK (mask), NULL); g_return_val_if_fail (arena != NULL, NULL); g_return_val_if_fail (NR_IS_ARENA (arena), NULL); - NRArenaItem *ai = NRArenaGroup::create(arena); + Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(arena); mask->display = sp_mask_view_new_prepend (mask->display, key, ai); for ( SPObject *child = mask->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - NRArenaItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS); + Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { - /* The order is not important in mask */ - nr_arena_item_add_child (ai, ac, NULL); + ai->prependChild(ac); } } } @@ -320,7 +320,7 @@ NRArenaItem *sp_mask_show(SPMask *mask, NRArena *arena, unsigned int key) Geom::Affine t(Geom::Scale(mask->display->bbox.x1 - mask->display->bbox.x0, mask->display->bbox.y1 - mask->display->bbox.y0)); t[4] = mask->display->bbox.x0; t[5] = mask->display->bbox.y0; - nr_arena_group_set_child_transform (NR_ARENA_GROUP (ai), &t); + ai->setChildTransform(t); } return ai; @@ -367,13 +367,13 @@ sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox) /* Mask views */ SPMaskView * -sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, NRArenaItem *arenaitem) +sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem) { SPMaskView *new_mask_view = g_new (SPMaskView, 1); new_mask_view->next = list; new_mask_view->key = key; - new_mask_view->arenaitem = nr_arena_item_ref(arenaitem); + new_mask_view->arenaitem = arenaitem; new_mask_view->bbox.x0 = new_mask_view->bbox.x1 = 0.0; new_mask_view->bbox.y0 = new_mask_view->bbox.y1 = 0.0; @@ -392,7 +392,7 @@ sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view) prev->next = view->next; } - nr_arena_item_unref (view->arenaitem); + delete view->arenaitem; g_free (view); return list; diff --git a/src/sp-mask.h b/src/sp-mask.h index 5a98ac8c5..e7a4723cf 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -23,7 +23,7 @@ class SPMask; class SPMaskClass; class SPMaskView; -#include "display/nr-arena-forward.h" +#include "display/display-forward.h" #include "libnr/nr-forward.h" #include "sp-object-group.h" #include "uri-references.h" @@ -90,7 +90,7 @@ protected: } }; -NRArenaItem *sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key); +Inkscape::DrawingItem *sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key); void sp_mask_hide (SPMask *mask, unsigned int key); void sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 3a3d01ebd..805a93267 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -25,10 +25,11 @@ #include "display/drawing-context.h" #include "display/drawing-surface.h" #include "display/nr-arena.h" -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" #include "uri.h" +#include "style.h" #include "sp-pattern.h" #include "xml/repr.h" #include "display/grayscale.h" @@ -632,15 +633,15 @@ sp_pattern_create_pattern(SPPaintServer *ps, /* Create arena */ NRArena *arena = NRArena::create(); unsigned int dkey = SPItem::display_key_new (1); - NRArenaGroup *root = NRArenaGroup::create(arena); + Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(arena); for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { // for each item in pattern, show it on our arena, add to the group, // and connect to the release signal in case the item gets deleted - NRArenaItem *cai; + Inkscape::DrawingItem *cai; cai = SP_ITEM(child)->invoke_show (arena, dkey, SP_ITEM_SHOW_DISPLAY); - nr_arena_item_append_child (root, cai); + root->appendChild(cai); } } @@ -689,17 +690,17 @@ sp_pattern_create_pattern(SPPaintServer *ps, } // TODO: make sure there are no leaks. - NRGC gc(NULL); - gc.transform = vb2ps; - nr_arena_item_invoke_update (root, Geom::IntRect::infinite(), &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_ALL); - nr_arena_item_invoke_render (ct, root, one_tile, 0); + Inkscape::UpdateContext ctx; + ctx.ctm = vb2ps; + root->update(Geom::IntRect::infinite(), ctx, Inkscape::DrawingItem::STATE_ALL, 0); + root->render(ct, one_tile, 0); for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { SP_ITEM(child)->invoke_hide(dkey); } } - nr_object_unref(root); nr_object_unref(arena); + delete root; if (needs_opacity) { ct.popGroupToSource(); // pop raw pattern diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 918bd3295..bbb12f5d3 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -22,7 +22,7 @@ #include <2geom/transforms.h> #include "svg/svg.h" -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "attributes.h" #include "print.h" #include "document.h" @@ -46,7 +46,7 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_root_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_root_print(SPItem *item, SPPrintContext *ctx); static SPGroupClass *parent_class; @@ -540,7 +540,8 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) /* As last step set additional transform of arena group */ for (SPItemView *v = root->display; v != NULL; v = v->next) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), root->c2p); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + g->setChildTransform(root->c2p); } } @@ -609,16 +610,17 @@ sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: /** * Displays the SPRoot item on the NRArena. */ -static NRArenaItem * +static Inkscape::DrawingItem * sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) { SPRoot *root = SP_ROOT(item); - NRArenaItem *ai; + Inkscape::DrawingItem *ai; if (((SPItemClass *) (parent_class))->show) { ai = ((SPItemClass *) (parent_class))->show(item, arena, key, flags); if (ai) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), root->c2p); + Inkscape::DrawingGroup *g = dynamic_cast(ai); + g->setChildTransform(root->c2p); } } else { ai = NULL; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index beec860be..1512898f5 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -30,7 +30,7 @@ #include #include "macros.h" -#include "display/nr-arena-shape.h" +#include "display/drawing-shape.h" #include "display/curve.h" #include "print.h" #include "document.h" @@ -182,7 +182,7 @@ void SPShape::sp_shape_release(SPObject *object) for (i = 0; i < SP_MARKER_LOC_QTY; i++) { if (shape->marker[i]) { for (v = item->display; v != NULL; v = v->next) { - sp_marker_hide ((SPMarker *) shape->marker[i], NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i); + sp_marker_hide ((SPMarker *) shape->marker[i], v->arenaitem->key() + i); } shape->release_connect[i].disconnect(); shape->modified_connect[i].disconnect(); @@ -247,7 +247,8 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) double const aw = 1.0 / ictx->i2vp.descrim(); style->stroke_width.computed = style->stroke_width.value * aw; for (SPItemView *v = ((SPItem *) (shape))->display; v != NULL; v = v->next) { - nr_arena_shape_set_style ((NRArenaShape *) v->arenaitem, style); + Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); + sh->setStyle(style); } } } @@ -257,12 +258,12 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) /* But on the other hand - how can we know that parent does not tie style and transform */ Geom::OptRect paintbox = SP_ITEM(object)->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); for (SPItemView *v = shape->display; v != NULL; v = v->next) { - NRArenaShape * const s = NR_ARENA_SHAPE(v->arenaitem); + Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { - nr_arena_shape_set_path(s, shape->curve, (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)); + sh->setPath(shape->curve); } if (paintbox) { - s->setPaintBox(*paintbox); + sh->setPaintBox(*paintbox); } } } @@ -270,13 +271,13 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) if (shape->hasMarkers ()) { /* Dimension marker views */ for (SPItemView *v = shape->display; v != NULL; v = v->next) { - if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY (v->arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { if (shape->marker[i]) { sp_marker_show_dimension ((SPMarker *) shape->marker[i], - NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i, + v->arenaitem->key() + i, shape->numberOfMarkers (i)); } } @@ -375,7 +376,7 @@ Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const & c) * * @todo figure out what to do when both 'marker' and for instance 'marker-end' are set. */ -void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) +void SPShape::sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) { SPStyle *style = ((SPObject *) shape)->style; @@ -395,7 +396,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( shape->marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -413,7 +414,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if ( shape->marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -433,7 +434,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if (shape->marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -450,7 +451,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if (shape->marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -474,7 +475,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END if (shape->marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -495,7 +496,8 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = shape->display; v != NULL; v = v->next) { - nr_arena_shape_set_style (NR_ARENA_SHAPE (v->arenaitem), object->style); + Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); + sh->setStyle(object->style); } } } @@ -850,15 +852,14 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) /** * Sets style, path, and paintbox. Updates marker views, including dimensions. */ -NRArenaItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) +Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) { SPObject *object = item; SPShape *shape = SP_SHAPE(item); - NRArenaItem *arenaitem = NRArenaShape::create(arena); - NRArenaShape * const s = NR_ARENA_SHAPE(arenaitem); - nr_arena_shape_set_style(s, object->style); - nr_arena_shape_set_path(s, shape->curve, false); + Inkscape::DrawingShape *s = new Inkscape::DrawingShape(arena); + s->setStyle(object->style); + s->setPath(shape->curve); Geom::OptRect paintbox = item->getBounds(Geom::identity()); if (paintbox) { s->setPaintBox(*paintbox); @@ -876,23 +877,23 @@ NRArenaItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int if (shape->hasMarkers ()) { /* provide key and dimension the marker views */ - if (!arenaitem->key) { - NR_ARENA_ITEM_SET_KEY (arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); + if (!s->key()) { + s->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0; i < SP_MARKER_LOC_QTY; i++) { if (shape->marker[i]) { sp_marker_show_dimension ((SPMarker *) shape->marker[i], - NR_ARENA_ITEM_GET_KEY (arenaitem) + i, + s->key() + i, shape->numberOfMarkers (i)); } } /* Update marker views */ - sp_shape_update_marker_view (shape, arenaitem); + sp_shape_update_marker_view (shape, s); } - return arenaitem; + return s; } /** @@ -911,7 +912,7 @@ void SPShape::sp_shape_hide(SPItem *item, unsigned int key) for (v = item->display; v != NULL; v = v->next) { if (key == v->key) { sp_marker_hide ((SPMarker *) shape->marker[i], - NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i); + v->arenaitem->key() + i); } } } @@ -1013,9 +1014,9 @@ sp_shape_marker_release (SPObject *marker, SPShape *shape) SPItemView *v; /* Hide marker */ for (v = item->display; v != NULL; v = v->next) { - sp_marker_hide ((SPMarker *) (shape->marker[i]), NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i); + sp_marker_hide ((SPMarker *) (shape->marker[i]), v->arenaitem->key() + i); /* fixme: Do we need explicit remove here? (Lauris) */ - /* nr_arena_item_set_mask (v->arenaitem, NULL); */ + /* v->arenaitem->setMask(NULL); */ } /* Detach marker */ shape->release_connect[i].disconnect(); @@ -1064,9 +1065,9 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value) /* Hide marker */ for (v = item->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) (shape->marker[key]), - NR_ARENA_ITEM_GET_KEY (v->arenaitem) + key); + v->arenaitem->key() + key); /* fixme: Do we need explicit remove here? (Lauris) */ - /* nr_arena_item_set_mask (v->arenaitem, NULL); */ + /* v->arenaitem->setMask(NULL); */ } /* Unref marker */ diff --git a/src/sp-shape.h b/src/sp-shape.h index b91850d1f..4da2d5a2d 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -67,11 +67,11 @@ private: static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); - static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); + static Inkscape::DrawingItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_shape_hide (SPItem *item, unsigned int key); static void sp_shape_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); - static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai); + static void sp_shape_update_marker_view (SPShape *shape, Inkscape::DrawingItem *ai); diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index eb30f2644..bb1495387 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -19,7 +19,7 @@ #include #include "sp-switch.h" -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "conditions.h" #include @@ -157,20 +157,18 @@ void CSwitch::_releaseLastItem(SPObject *obj) _cached_item = NULL; } -void CSwitch::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags) { +void CSwitch::_showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = _evaluateFirst(); - NRArenaItem *ar = NULL; GSList *l = _childList(false, SPObject::ActionShow); while (l) { SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); child->setEvaluated(o == evaluated_child); - NRArenaItem *ac = child->invoke_show (arena, key, flags); + Inkscape::DrawingItem *ac = child->invoke_show (arena, key, flags); if (ac) { - nr_arena_item_add_child (ai, ac, ar); - ar = ac; + ai->appendChild(ac); } } l = g_slist_remove (l, o); diff --git a/src/sp-switch.h b/src/sp-switch.h index 310655a23..7b108947d 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -42,7 +42,7 @@ public: protected: virtual GSList *_childList(bool add_ref, SPObject::Action action); - virtual void _showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags); + virtual void _showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); SPObject *_evaluateFirst(); void _reevaluate(bool add_to_arena = false); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 91218c986..1f35a0ee1 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -19,7 +19,7 @@ #include #include <2geom/transforms.h> -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "xml/repr.h" #include "attributes.h" #include "print.h" @@ -37,7 +37,7 @@ static void sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_symbol_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_symbol_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static NRArenaItem *sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_symbol_hide (SPItem *item, unsigned int key); static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); @@ -327,7 +327,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) // As last step set additional transform of arena group for (SPItemView *v = symbol->display; v != NULL; v = v->next) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), symbol->c2p); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + g->setChildTransform(symbol->c2p); } } else { // No-op @@ -367,17 +368,18 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc return repr; } -static NRArenaItem *sp_symbol_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) +static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) { SPSymbol *symbol = SP_SYMBOL(item); - NRArenaItem *ai = 0; + Inkscape::DrawingItem *ai = 0; if (symbol->cloned) { // Cloned is actually renderable if (((SPItemClass *) (parent_class))->show) { ai = ((SPItemClass *) (parent_class))->show (item, arena, key, flags); - if (ai) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), symbol->c2p); + Inkscape::DrawingGroup *g = dynamic_cast(ai); + if (g) { + g->setChildTransform(symbol->c2p); } } } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 89ca4ace4..ed848c646 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -35,7 +35,7 @@ #include #include "svg/svg.h" #include "svg/stringstream.h" -#include "display/nr-arena-glyphs.h" +#include "display/drawing-text.h" #include "attributes.h" #include "document.h" #include "desktop-handles.h" @@ -72,7 +72,7 @@ static void sp_text_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); -static NRArenaItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags); +static Inkscape::DrawingItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags); static void sp_text_hide (SPItem *item, unsigned key); static char *sp_text_description (SPItem *item); static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); @@ -251,10 +251,11 @@ static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) NRRect paintbox; text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { - text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + text->_clearFlow(g); + g->setStyle(object->style); // pass the bbox of the text object as paintbox (used for paintserver fills) - text->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox); + text->layout.show(g, &paintbox); } } } @@ -270,8 +271,8 @@ static void sp_text_modified(SPObject *object, guint flags) cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } - // FIXME: all that we need to do here is nr_arena_glyphs_[group_]set_style, to set the changed - // style, but there's no easy way to access the arena glyphs or glyph groups corresponding to a + // FIXME: all that we need to do here is to call setStyle, to set the changed + // style, but there's no easy way to access the drawing glyphs or texts corresponding to a // text object. Therefore we do here the same as in _update, that is, destroy all arena items // and create new ones. This is probably quite wasteful. if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { @@ -279,9 +280,10 @@ static void sp_text_modified(SPObject *object, guint flags) NRRect paintbox; text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { - text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); - text->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + text->_clearFlow(g); + g->setStyle(object->style); + text->layout.show(g, &paintbox); } } @@ -383,15 +385,14 @@ sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, un } -static NRArenaItem * +static Inkscape::DrawingItem * sp_text_show(SPItem *item, NRArena *arena, unsigned /* key*/, unsigned /*flags*/) { SPText *group = (SPText *) item; - NRArenaGroup *flowed = NRArenaGroup::create(arena); - nr_arena_group_set_transparent (flowed, FALSE); - - nr_arena_group_set_style(flowed, group->style); + Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(arena); + flowed->setPickChildren(false); + flowed->setStyle(group->style); // pass the bbox of the text object as paintbox (used for paintserver fills) NRRect paintbox; @@ -662,17 +663,9 @@ void SPText::_adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double } -void SPText::_clearFlow(NRArenaGroup *in_arena) +void SPText::_clearFlow(Inkscape::DrawingGroup *in_arena) { - nr_arena_item_request_render (in_arena); - for (NRArenaItem *child = in_arena->children; child != NULL; ) { - NRArenaItem *nchild = child->next; - - nr_arena_glyphs_group_clear(NR_ARENA_GLYPHS_GROUP(child)); - nr_arena_item_remove_child (in_arena, child); - - child=nchild; - } + in_arena->clearChildren(); } diff --git a/src/sp-text.h b/src/sp-text.h index cd103aa2a..f865713c7 100644 --- a/src/sp-text.h +++ b/src/sp-text.h @@ -57,7 +57,7 @@ struct SPText : public SPItem { static void _adjustFontsizeRecursive(SPItem *item, double ex, bool is_root = true); /** discards the NRArena objects representing this text. */ - void _clearFlow(NRArenaGroup *in_arena); + void _clearFlow(Inkscape::DrawingGroup *in_arena); private: /** Recursively walks the xml tree adding tags and their contents. The diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index b301add7f..dcf46f6ac 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -32,7 +32,6 @@ #include "text-editing.h" #include "uri.h" -#include "display/nr-arena-group.h" #include "xml/node.h" #include "xml/repr.h" diff --git a/src/sp-use.cpp b/src/sp-use.cpp index a05b28a5f..2f83679de 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -22,7 +22,7 @@ #include <2geom/transforms.h> #include -#include "display/nr-arena-group.h" +#include "display/drawing-group.h" #include "attributes.h" #include "document.h" #include "sp-object-repr.h" @@ -53,7 +53,7 @@ static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &tr static void sp_use_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); static void sp_use_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_use_description(SPItem *item); -static NRArenaItem *sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); +static Inkscape::DrawingItem *sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); static void sp_use_hide(SPItem *item, unsigned key); static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use); @@ -346,23 +346,23 @@ sp_use_description(SPItem *item) } } -static NRArenaItem * +static Inkscape::DrawingItem * sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) { SPUse *use = SP_USE(item); - NRArenaItem *ai = NRArenaGroup::create(arena); - nr_arena_group_set_transparent(NR_ARENA_GROUP(ai), FALSE); - nr_arena_group_set_style(NR_ARENA_GROUP(ai), item->style); + Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(arena); + ai->setPickChildren(false); + ai->setStyle(item->style); if (use->child) { - NRArenaItem *ac = SP_ITEM(use->child)->invoke_show(arena, key, flags); + Inkscape::DrawingItem *ac = SP_ITEM(use->child)->invoke_show(arena, key, flags); if (ac) { - nr_arena_item_add_child(ai, ac, NULL); + ai->prependChild(ac); } Geom::Translate t(use->x.computed, use->y.computed); - nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), Geom::Affine(t)); + ai->setChildTransform(t); } return ai; @@ -540,10 +540,10 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) (use->child)->invoke_build(use->document, childrepr, TRUE); for (SPItemView *v = item->display; v != NULL; v = v->next) { - NRArenaItem *ai; - ai = SP_ITEM(use->child)->invoke_show(NR_ARENA_ITEM_ARENA(v->arenaitem), v->key, v->flags); + Inkscape::DrawingItem *ai; + ai = SP_ITEM(use->child)->invoke_show(v->arenaitem->drawing(), v->key, v->flags); if (ai) { - nr_arena_item_add_child(v->arenaitem, ai, NULL); + v->arenaitem->prependChild(ai); } } @@ -592,7 +592,8 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = SP_ITEM(object)->display; v != NULL; v = v->next) { - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + g->setStyle(object->style); } } @@ -633,8 +634,9 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) /* As last step set additional transform of arena group */ for (SPItemView *v = item->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); Geom::Affine t(Geom::Translate(use->x.computed, use->y.computed)); - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), t); + g->setChildTransform(t); } } @@ -650,7 +652,8 @@ sp_use_modified(SPObject *object, guint flags) if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = SP_ITEM(object)->display; v != NULL; v = v->next) { - nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style); + Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); + g->setStyle(object->style); } } diff --git a/src/svg-view.cpp b/src/svg-view.cpp index 2f1a20b82..3221ce146 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -15,6 +15,7 @@ #include <2geom/transforms.h> #include "display/canvas-arena.h" +#include "display/drawing-group.h" #include "document.h" #include "sp-item.h" #include "svg-view.h" @@ -129,13 +130,13 @@ SPSVGView::mouseout() */ /// \todo fixme. static gint -arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVGView *svgview) +arena_handler (SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPSVGView *svgview) { static gdouble x, y; static gboolean active = FALSE; SPEvent spev; - SPItem *spitem = (ai) ? (SPItem*)NR_ARENA_ITEM_GET_DATA (ai) : 0; + SPItem *spitem = (ai) ? (SPItem*) ai->data() : 0; switch (event->type) { case GDK_BUTTON_PRESS: @@ -202,13 +203,13 @@ SPSVGView::setDocument (SPDocument *document) View::setDocument (document); if (document) { - NRArenaItem *ai = document->getRoot()->invoke_show( + Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( SP_CANVAS_ARENA (_drawing)->arena, _dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - nr_arena_item_add_child (SP_CANVAS_ARENA (_drawing)->root, ai, NULL); + SP_CANVAS_ARENA (_drawing)->root->prependChild(ai); } doRescale (!_rescale); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index ef75d8b23..7093ff683 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -12,8 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - - #include "trace/potrace/inkscape-potrace.h" #include "inkscape.h" @@ -32,22 +30,13 @@ #include <2geom/transforms.h> #include "display/nr-arena.h" -#include "display/nr-arena-shape.h" +#include "display/drawing-shape.h" #include "siox.h" #include "imagemap-gdk.h" - - -namespace Inkscape -{ - -namespace Trace -{ - - - - +namespace Inkscape { +namespace Trace { /** * Get the selected image. Also check for any SPItems over it, in @@ -247,12 +236,12 @@ Tracer::sioxProcessImage(SPImage *img, return Glib::RefPtr(NULL); } - NRArenaItem *aImg = img->get_arenaitem(desktop->dkey); + Inkscape::DrawingItem *aImg = img->get_arenaitem(desktop->dkey); //g_message("img: %d %d %d %d\n", aImg->bbox.x0, aImg->bbox.y0, // aImg->bbox.x1, aImg->bbox.y1); - double width = aImg->bbox->width(); - double height = aImg->bbox->height(); + double width = aImg->geometricBounds()->width(); + double height = aImg->geometricBounds()->height(); double iwidth = simage.getWidth(); double iheight = simage.getHeight(); @@ -260,12 +249,12 @@ Tracer::sioxProcessImage(SPImage *img, double iwscale = width / iwidth; double ihscale = height / iheight; - std::vector arenaItems; + std::vector arenaItems; std::vector::iterator iter; for (iter = sioxShapes.begin() ; iter!=sioxShapes.end() ; iter++) { SPItem *item = *iter; - NRArenaItem *aItem = item->get_arenaitem(desktop->dkey); + Inkscape::DrawingItem *aItem = item->get_arenaitem(desktop->dkey); arenaItems.push_back(aItem); } @@ -278,25 +267,22 @@ Tracer::sioxProcessImage(SPImage *img, for (int row=0 ; rowbbox->top() + ihscale * (double) row; + double ypos = aImg->geometricBounds()->top() + ihscale * (double) row; for (int col=0 ; colbbox->left() + iwscale * (double)col; + double xpos = aImg->geometricBounds()->left() + iwscale * (double)col; Geom::Point point(xpos, ypos); - if (aImg->transform) - point *= *aImg->transform; + point *= aImg->transform(); //point *= imgMat; //point = desktop->doc2dt(point); //g_message("x:%f y:%f\n", point[0], point[1]); bool weHaveAHit = false; - std::vector::iterator aIter; + std::vector::iterator aIter; for (aIter = arenaItems.begin() ; aIter!=arenaItems.end() ; aIter++) { - NRArenaItem *arenaItem = *aIter; - NRArenaItemClass *arenaClass = - (NRArenaItemClass *) NR_OBJECT_GET_CLASS (arenaItem); - if (arenaClass->pick(arenaItem, point, 1.0f, 1)) + Inkscape::DrawingItem *arenaItem = *aIter; + if (arenaItem->pick(point, 1.0f, 1)) { weHaveAHit = true; break; @@ -338,17 +324,6 @@ Tracer::sioxProcessImage(SPImage *img, //result.writePPM("siox2.ppm"); - /* Free Arena and ArenaItem */ - /* - std::vector::iterator aIter; - for (aIter = arenaItems.begin() ; aIter!=arenaItems.end() ; aIter++) - { - NRArenaItem *arenaItem = *aIter; - nr_arena_item_unref(arenaItem); - } - nr_object_unref((NRObject *) arena); - */ - Glib::RefPtr newPixbuf = Glib::wrap(result.getGdkPixbuf()); //g_message("siox: done"); diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 67ec701cb..ae5355c58 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -29,23 +29,19 @@ #include "document-private.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" +#include "display/drawing-item.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) { - NRGC gc(NULL); - +GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) +{ Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); - nr_arena_item_set_transform(root, t); - gc.transform.setIdentity(); + root->setTransform(Geom::Scale(scale_factor)); Geom::IntRect ibox = (dbox * Geom::Scale(scale_factor)).roundOutwards(); - nr_arena_item_invoke_update( root, ibox, &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); + root->update(ibox); /* Find visible area */ int width = ibox.width(); @@ -63,8 +59,7 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rec CAIRO_FORMAT_ARGB32, psize, psize); Inkscape::DrawingContext ct(s, area.min()); - nr_arena_item_invoke_render(ct, root, area, - NR_ARENA_ITEM_RENDER_NO_CACHE ); + root->render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), @@ -111,7 +106,7 @@ void SvgPreview::set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px) { _pixmap_cache[key] = px; } -GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, NRArenaItem */*root*/, +GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem */*root*/, double /*scale_factor*/, unsigned int psize) { // First try looking up the cached preview in the cache map Glib::ustring key = cache_key(uri, id, psize); diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index 0fac94782..b9fa6f627 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -1,17 +1,22 @@ -#ifndef __SVG_PREVIEW_CACHE_H__ -#define __SVG_PREVIEW_CACHE_H__ - -/** \file - * SPIcon: Generic icon widget +/** @file + * @brief Preview cache */ /* * Copyright (C) 2007 Bryce W. Harrington - * * Released under GNU GPL, read the file 'COPYING' for more information - * */ -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); +#ifndef SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H +#define SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H + +#include +#include +#include +#include <2geom/rect.h> + +#include "display/display-forward.h" + +GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); namespace Inkscape { namespace UI { @@ -28,7 +33,7 @@ class SvgPreview { Glib::ustring cache_key(gchar const *uri, gchar const *name, unsigned psize) const; GdkPixbuf* get_preview_from_cache(const Glib::ustring& key); void set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px); - GdkPixbuf* get_preview(const gchar* uri, const gchar* id, NRArenaItem *root, double scale_factor, unsigned int psize); + GdkPixbuf* get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem *root, double scale_factor, unsigned int psize); }; }; // namespace Cache diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 38ec6d1be..a6d76eb13 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -38,7 +38,7 @@ extern "C" { // takes doc, root, icon, and icon name to produce pixels guchar * -sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, +sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, const gchar *name, unsigned int psize, unsigned &stride); } @@ -438,7 +438,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) g_message("%s setting up to render '%s' as the icon", getTimestr().c_str(), id ); #endif // ICON_VERBOSE - NRArenaItem *root = NULL; + Inkscape::DrawingItem *root = NULL; /* Create new arena */ NRArena *arena = NRArena::create(); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 7958a9d07..af329f3fc 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -641,10 +641,10 @@ SPDesktopWidget::updateTitle(gchar const* uri) gchar const *colormodename = ""; gchar const *colormodenamecomma = ""; - if (this->desktop->getColorMode() == Inkscape::COLORRENDERMODE_GRAYSCALE) { + if (this->desktop->getColorMode() == Inkscape::COLORMODE_GRAYSCALE) { colormodename = grayscalename; colormodenamecomma = grayscalenamecomma; - } else if (this->desktop->getColorMode() == Inkscape::COLORRENDERMODE_PRINT_COLORS_PREVIEW) { + } else if (this->desktop->getColorMode() == Inkscape::COLORMODE_PRINT_COLORS_PREVIEW) { colormodename = printcolorsname; colormodenamecomma = printcolorsnamecomma; } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index c6823e2d8..fea825444 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -32,8 +32,8 @@ #include "sp-item.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" +#include "display/drawing-item.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "io/sys.h" #include "sp-root.h" @@ -1090,7 +1090,7 @@ static Geom::IntRect round_rect(Geom::Rect const &r) // takes doc, root, icon, and icon name to produce pixels extern "C" guchar * -sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, +sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, gchar const *name, unsigned psize, unsigned &stride) { @@ -1113,14 +1113,10 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, /* This is in document coordinates, i.e. pixels */ if ( dbox ) { - NRGC gc(NULL); /* Update to renderable state */ double sf = 1.0; - nr_arena_item_set_transform(root, (Geom::Affine)Geom::Scale(sf, sf)); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, Geom::IntRect::infinite(), &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); + root->setTransform(Geom::Scale(sf)); + root->update(); /* Item integer bbox in points */ // NOTE: previously, each rect coordinate was rounded using floor(c + 0.5) Geom::IntRect ibox = round_rect(*dbox); @@ -1145,11 +1141,8 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, } sf = (double)psize / (double)block; - nr_arena_item_set_transform(root, (Geom::Affine)Geom::Scale(sf, sf)); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, Geom::IntRect::infinite(), &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); + root->setTransform(Geom::Scale(sf)); + root->update(); ibox = round_rect(*dbox * Geom::Scale(sf)); if ( dump ) { @@ -1192,8 +1185,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, CAIRO_FORMAT_ARGB32, psize, psize, stride); Inkscape::DrawingContext ct(s, ua.min()); - nr_arena_item_invoke_render(ct, root, ua, - NR_ARENA_ITEM_RENDER_NO_CACHE ); + root->render(ct, ua, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_destroy(s); // convert to GdkPixbuf format @@ -1214,9 +1206,9 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, class SVGDocCache { public: - SVGDocCache( SPDocument *doc, NRArenaItem *root ) : doc(doc), root(root) {} + SVGDocCache( SPDocument *doc, Inkscape::DrawingItem *root ) : doc(doc), root(root) {} SPDocument *doc; - NRArenaItem *root; + Inkscape::DrawingItem *root; }; static std::map doc_cache; @@ -1294,7 +1286,7 @@ guchar *IconImpl::load_svg_pixels(std::list const &names, // fixme: Memory manage root if needed (Lauris) // This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days // because shapes are being rendered which are not being freed - NRArenaItem *root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + Inkscape::DrawingItem *root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); // store into the cache info = new SVGDocCache(doc, root); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 8b5582163..4f6466ce8 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -28,8 +28,8 @@ #include "desktop-style.h" #include "dialogs/dialog-events.h" #include "display/canvas-bpath.h" // for SP_STROKE_LINEJOIN_* +#include "display/display-forward.h" #include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "document-private.h" #include "gradient-chemistry.h" #include "helper/stock-items.h" @@ -153,7 +153,8 @@ sp_stroke_radio_button(Gtk::RadioButton *tb, char const *icon, static Gtk::Image * sp_marker_prev_new(unsigned psize, gchar const *mname, SPDocument *source, SPDocument *sandbox, - gchar const *menu_id, NRArena const * /*arena*/, unsigned /*visionkey*/, NRArenaItem *root) + gchar const *menu_id, NRArena const * /*arena*/, unsigned /*visionkey*/, + Inkscape::DrawingItem *root) { // Retrieve the marker named 'mname' from the source SVG document SPObject const *marker = source->getObjectById(mname); @@ -250,7 +251,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD // Do this here, outside of loop, to speed up preview generation: NRArena const *arena = NRArena::create(); unsigned const visionkey = SPItem::display_key_new(1); - NRArenaItem *root = sandbox->getRoot()->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); + Inkscape::DrawingItem *root = sandbox->getRoot()->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); for (; marker_list != NULL; marker_list = marker_list->next) { Inkscape::XML::Node *repr = reinterpret_cast(marker_list->data)->getRepr(); -- cgit v1.2.3 From 42c8636a2c5814746c41f1452ffa7df99cf21367 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 6 Aug 2011 15:38:28 +0200 Subject: Document things figured out during the rewriting (bzr r10347.1.22) --- src/display/drawing-group.cpp | 11 ++++- src/display/drawing-image.cpp | 2 +- src/display/drawing-image.h | 2 +- src/display/drawing-item.cpp | 99 +++++++++++++++++++++++++++++++++++++++++-- src/display/drawing-item.h | 2 +- src/display/drawing-shape.cpp | 6 +-- src/display/drawing-shape.h | 2 +- src/display/drawing-text.cpp | 4 +- src/display/drawing-text.h | 4 +- 9 files changed, 115 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 2d40f0a83..feaa7622a 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -31,6 +31,9 @@ DrawingGroup::~DrawingGroup() sp_style_unref(_style); } +/** @brief Set whether the group returns children from pick calls. + * Previously this feature was called "transparent groups". + */ void DrawingGroup::setPickChildren(bool p) { @@ -43,6 +46,10 @@ DrawingGroup::setStyle(SPStyle *style) _setStyleCommon(_style, style); } +/** @brief Set additional transform for the group. + * This is applied after the normal transform and mainly useful for + * markers, clipping paths, etc. + */ void DrawingGroup::setChildTransform(Geom::Affine const &new_trans) { @@ -105,10 +112,10 @@ DrawingGroup::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingGroup::_pickItem(Geom::Point const &p, double delta) +DrawingGroup::_pickItem(Geom::Point const &p, double delta, bool sticky) { for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *picked = i->pick(p, delta, false); + DrawingItem *picked = i->pick(p, delta, sticky); if (picked) { return _pick_children ? picked : this; } diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index ea6f6ce3c..879809cfa 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -196,7 +196,7 @@ distance_to_segment (Geom::Point const &p, Geom::Point const &a1, Geom::Point co } DrawingItem * -DrawingImage::_pickItem(Geom::Point const &p, double delta) +DrawingImage::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) { if (!_pixbuf) return NULL; diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h index 570c10360..d66395aab 100644 --- a/src/display/drawing-image.h +++ b/src/display/drawing-image.h @@ -38,7 +38,7 @@ protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); GdkPixbuf *_pixbuf; cairo_surface_t *_surface; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 318ff28e7..caed08e6f 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -22,6 +22,26 @@ namespace Inkscape { +/** @class DrawingItem + * @brief SVG drawing item for display. + * + * This was previously known as NRArenaItem. It represents the renderable + * portion of the SVG document. Typically this is created by the SP tree, + * in particular the show() virtual function. + * + * @section ObjectLifetime Object Lifetime + * Deleting a DrawingItem will cause all of its children to be deleted as well. + * This can lead to nasty surprises if you hold references to things + * which are children of what is being deleted. Therefore, in the SP tree, + * you always need to delete the item views of children before deleting + * the view of the parent. Do not call delete on things returned from show() + * - this will cause dangling pointers inside the SPItem and lead to a crash. + * Use the corresponing hide() method. + * + * Outside of the SP tree you should not use any references after the root node + * has been deleted. + */ + DrawingItem::DrawingItem(Drawing *drawing) : _drawing(drawing) , _parent(NULL) @@ -84,9 +104,8 @@ DrawingItem::~DrawingItem() DrawingItem * DrawingItem::parent() const { - //if (_clip_child || _mask_child) - // return NULL; - + // initially I wanted to return NULL if we are a clip or mask child, + // but the previous behavior was just to return the parent return _parent; } @@ -106,6 +125,7 @@ DrawingItem::prependChild(DrawingItem *item) _markForUpdate(STATE_ALL, false); } +/// Delete all regular children of this item (not mask or clip). void DrawingItem::clearChildren() { @@ -118,6 +138,7 @@ DrawingItem::clearChildren() _children.clear_and_dispose(DeleteDisposer()); } +/// Set the incremental transform for this item void DrawingItem::setTransform(Geom::Affine const &new_trans) { @@ -153,12 +174,14 @@ DrawingItem::setVisible(bool v) _markForRendering(); } +/// This is currently unused void DrawingItem::setSensitive(bool s) { _sensitive = s; } +/// Enable / disable storing the rendering in memory. void DrawingItem::setCached(bool c) { @@ -197,6 +220,8 @@ DrawingItem::setMask(DrawingItem *item) _markForUpdate(STATE_ALL, true); } +/// Move this item to the given place in the Z order of siblings. +/// Does nothing if the item has no parent. void DrawingItem::setZOrder(unsigned z) { @@ -217,6 +242,27 @@ DrawingItem::setItemBounds(Geom::OptRect const &bounds) _item_bbox = bounds; } +/** @brief Update derived data before operations. + * The purpose of this call is to recompute internal data which depends + * on the attributes of the object, but is not directly settable by the user. + * Precomputing this data speeds up later rendering, because some items + * can be omitted. + * + * Currently this method handles updating the visual and geometric bounding boxes + * in pixels, storing the total transformation from item space to the screen + * and cache invalidation. + * + * @param area Area to which the update should be restricted. Only takes effect + * if the bounding box is known. + * @param ctx A structure to store cascading state. + * @param flags Which internal data should be recomputed. This can be any combination + * of StateFlags. + * @param reset State fields that should be reset before processing them. This is + * a means to force a recomputation of internal data even if the item + * considers it up to date. Mainly for internal use, such as + * propagating bunding box recomputation to children when the item's + * transform changes. + */ void DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { @@ -315,6 +361,15 @@ struct MaskLuminanceToAlpha { } }; +/** @brief Rasterize items. + * This method submits the drawing opeartions required to draw this item + * to the supplied DrawingContext, restricting drawing the the specified area. + * + * This method does some common tasks and calls the item-specific rendering + * function, _renderItem(), to render e.g. paths or bitmaps. + * + * @param flags Rendering options. This deals mainly with cache control. + */ void DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { @@ -490,6 +545,13 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig _drawing->outlinecolor = saved_rgba; // restore outline color } +/** @brief Rasterize the clipping path. + * This method submits drawing operations required to draw a basic filled shape + * of the item to the supplied drawing context. Rendering is limited to the + * given area. The rendering of the clipped object is composited into + * the result of this call using the IN operator. See the implementation + * of render() for details. + */ void DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) { @@ -523,6 +585,16 @@ DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) } } +/** @brief Get the item under the specified point. + * Searches the tree for the first item in the Z-order which is closer than + * @a delta to the given point. The pick should be visual - for example + * an object with a thick stroke should pick on the entire area of the stroke. + * @param p Search point + * @param delta Maximum allowed distance from the point + * @param sticky Whether the pick should ignore visibility and sensitivity. + * When false, only visible and sensitive objects are considered. + * When true, invisible and insensitive objects can also be picked. + */ DrawingItem * DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) { @@ -544,6 +616,11 @@ DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) return NULL; } +/** Marks the current visual bounding box of the item for redrawing. + * This is called whenever the object changes its visible appearance. + * For some cases (such as setting opacity) this is enough, but for others + * _markForUpdate() also needs to be called. + */ void DrawingItem::_markForRendering() { @@ -561,10 +638,24 @@ DrawingItem::_markForRendering() nr_arena_request_render_rect (_drawing, dirty); } +/** @brief Marks the item as needing a recomputation of internal data. + * + * This mechanism avoids traversing the entire rendering tree (which could be vast) + * on every trivial state changed in any item. Only items marked as needing + * an update (having some bits in their _state unset) will be traversed + * during the update call. + * + * The _propagate variable is another optimization. We use it to specify that + * all children should also have the corresponding flags unset before checking + * whether they need to be traversed. This way there is one less traversal + * of the tree. Without this we would need to unset state bits in all children. + * With _propagate we do this during the update call, when we have to traverse + * the tree anyway. + */ void DrawingItem::_markForUpdate(unsigned flags, bool propagate) { - // here we can't simply assign because a previous markForUpdate call + // we can't simply assign because a previous markForUpdate call // could have had propagate=true even if this one has propagate=false if (propagate) _propagate = true; diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index b34ddf0e4..87b9ba048 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -109,7 +109,7 @@ protected: unsigned flags, unsigned reset) { return 0; } virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) {} virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area) {} - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta) { return NULL; } + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky) { return NULL; } virtual bool _canClip() { return false; } Drawing *_drawing; diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 1a56eea9b..602aa2515 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -232,13 +232,13 @@ DrawingShape::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingShape::_pickItem(Geom::Point const &p, double delta) +DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) { if (_repick_after > 0) --_repick_after; - if (_repick_after > 0) // we are a slow, huge path. skip this pick, returning what was returned last time - return _last_pick; + if (_repick_after > 0) // we are a slow, huge path + return _last_pick; // skip this pick, returning what was returned last time if (!_curve) return NULL; if (!_style) return NULL; diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 7fd16374e..4b7b75e2a 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -36,7 +36,7 @@ protected: unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); virtual bool _canClip(); SPCurve *_curve; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 784888bd7..e03a91b39 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -102,7 +102,7 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, } DrawingItem * -DrawingGlyphs::_pickItem(Geom::Point const &p, double delta) +DrawingGlyphs::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) { if (!_font || !_bbox) return NULL; @@ -248,7 +248,7 @@ DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingText::_pickItem(Geom::Point const &p, double delta) +DrawingText::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) { DrawingItem *picked = DrawingGroup::_pickItem(p, delta); if (picked) return this; diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index 58fecc067..f95a5073c 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -32,7 +32,7 @@ public: protected: unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); Geom::Affine *_glyph_transform; font_instance *_font; @@ -59,7 +59,7 @@ protected: unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); virtual bool _canClip(); Geom::OptRect _paintbox; -- cgit v1.2.3 From d44b95520c721d25c79287788bcc51865810051d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 6 Aug 2011 15:40:27 +0200 Subject: Plug a giant gaping memory leak in Gaussian blur filter (bzr r10347.1.23) --- src/display/nr-filter-gaussian.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 3a6b425e1..a777d76a4 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -643,6 +643,13 @@ void FilterGaussian::render_cairo(FilterSlot &slot) } } + // free the temporary data + if ( use_IIR_x || use_IIR_y ) { + for(int i = 0; i < threads; ++i) { + delete[] tmpdata[i]; + } + } + cairo_surface_mark_dirty(downsampled); if (resampling) { cairo_surface_t *upsampled = cairo_surface_create_similar(downsampled, cairo_surface_get_content(downsampled), -- cgit v1.2.3 From 456dddb2670686427c60497702e86648635ce42e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 6 Aug 2011 15:45:04 +0200 Subject: Fix compilation (oops). (bzr r10347.1.24) --- src/display/drawing-group.h | 2 +- src/display/drawing-item.cpp | 2 +- src/display/drawing-item.h | 2 +- src/display/drawing-text.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index f7d6a2be3..072944b6c 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -36,7 +36,7 @@ protected: unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); virtual bool _canClip(); SPStyle *_style; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index caed08e6f..53639f765 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -611,7 +611,7 @@ DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) expanded.expandBy(delta); if (expanded.contains(p)) { - return _pickItem(p, delta); + return _pickItem(p, delta, sticky); } return NULL; } diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 87b9ba048..f26c65df5 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -109,7 +109,7 @@ protected: unsigned flags, unsigned reset) { return 0; } virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) {} virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area) {} - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky) { return NULL; } + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky = false) { return NULL; } virtual bool _canClip() { return false; } Drawing *_drawing; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index e03a91b39..5fc732779 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -248,9 +248,9 @@ DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingText::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) +DrawingText::_pickItem(Geom::Point const &p, double delta, bool sticky) { - DrawingItem *picked = DrawingGroup::_pickItem(p, delta); + DrawingItem *picked = DrawingGroup::_pickItem(p, delta, sticky); if (picked) return this; return NULL; } -- cgit v1.2.3 From ec8d0b742153e4715efd13fb19607c3167cc2092 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 6 Aug 2011 20:48:21 +0200 Subject: Extensions. New "indent" attribute to add an indent level to extension elements. Filters. Adding the new "indent" attribute to parameters groups. (bzr r10529) --- src/extension/internal/filter/bumps.h | 34 +++++++++++----------- src/extension/internal/filter/experimental.h | 20 ++++++------- src/extension/param/bool.cpp | 18 +++++++++--- src/extension/param/bool.h | 1 + src/extension/param/description.cpp | 26 +++++++++++------ src/extension/param/description.h | 1 + src/extension/param/enum.cpp | 43 ++++++++++++++++++++-------- src/extension/param/enum.h | 2 +- src/extension/param/float.cpp | 41 +++++++++++++++++++------- src/extension/param/float.h | 1 + src/extension/param/int.cpp | 39 ++++++++++++++++++------- src/extension/param/int.h | 1 + src/extension/param/radiobutton.cpp | 41 +++++++++++++++++--------- src/extension/param/radiobutton.h | 2 +- src/extension/param/string.cpp | 40 ++++++++++++++++++-------- src/extension/param/string.h | 1 + 16 files changed, 210 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 3591377be..b52581844 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -84,10 +84,10 @@ public: "0.01\n" "0\n" "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">Bump source\n" - "0\n" - "0\n" - "0\n" - "false\n" + "0\n" + "0\n" + "0\n" + "false\n" "\n" "\n" "\n" @@ -106,21 +106,21 @@ public: "<_item value=\"spot\">" N_("Spot") "\n" "\n" "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">Distant light options\n" - "225\n" - "45\n" + "225\n" + "45\n" "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">Point light options\n" - "526\n" - "372\n" - "150\n" + "526\n" + "372\n" + "150\n" "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">Spot light options\n" - "526\n" - "372\n" - "150\n" - "0\n" - "0\n" - "-1000\n" - "1\n" - "50\n" + "526\n" + "372\n" + "150\n" + "0\n" + "0\n" + "-1000\n" + "1\n" + "50\n" "\n" "\n" "-987158017\n" diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 3dbb6a76d..2032cb513 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -332,18 +332,18 @@ public: "\n" "\n" "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" - "0.6\n" - "10\n" - "0\n" - "false\n" + "0.6\n" + "10\n" + "0\n" + "false\n" "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" - "0.6\n" - "6\n" - "2\n" + "0.6\n" + "6\n" + "2\n" "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" - "1\n" - "6\n" - "2\n" + "1\n" + "6\n" + "2\n" "\n" "\n" "-1515870721\n" diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index a8a410382..36ea9c556 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -23,11 +23,13 @@ namespace Extension { /** \brief Use the superclass' allocator and set the \c _value */ ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(false) + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(false), _indent(0) { const char * defaultval = NULL; - if (sp_repr_children(xml) != NULL) + if (sp_repr_children(xml) != NULL) { defaultval = sp_repr_children(xml)->content(); + } if (defaultval != NULL && (!strcmp(defaultval, "true") || !strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) { _value = true; @@ -35,6 +37,11 @@ ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * d _value = false; } + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } + gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _value = prefs->getBool(extension_pref_root + pref_name, _value); @@ -134,7 +141,10 @@ ParamBool::string (std::string &string) Gtk::Widget * ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT)); @@ -143,7 +153,7 @@ ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signa ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, doc, node, changeSignal)); checkbox->show(); - hbox->pack_start(*checkbox, false, false); + hbox->pack_start(*checkbox, false, false, _indent); hbox->show(); diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h index a1cd4ce4a..964778f8f 100644 --- a/src/extension/param/bool.h +++ b/src/extension/param/bool.h @@ -20,6 +20,7 @@ class ParamBool : public Parameter { private: /** \brief Internal value. */ bool _value; + int _indent; public: ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); bool get (const SPDocument * doc, const Inkscape::XML::Node * node); diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index 049b7d5a3..7a68aff62 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -39,18 +39,26 @@ ParamDescription::ParamDescription (const gchar * name, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml, AppearanceMode mode) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL), _mode(mode) + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(NULL), _mode(mode), _indent(0) { // printf("Building Description\n"); const char * defaultval = NULL; - if (sp_repr_children(xml) != NULL) + if (sp_repr_children(xml) != NULL) { defaultval = sp_repr_children(xml)->content(); + } - if (defaultval != NULL) + if (defaultval != NULL) { _value = g_strdup(defaultval); - + } + _context = xml->attribute("msgctxt"); - + + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } + return; } @@ -58,7 +66,9 @@ ParamDescription::ParamDescription (const gchar * name, Gtk::Widget * ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal * /*changeSignal*/) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Glib::ustring newguitext; @@ -69,12 +79,12 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node } Gtk::Label * label; - int padding = 12; + int padding = 12 + _indent; if (_mode == HEADER) { label = Gtk::manage(new Gtk::Label(Glib::ustring("") +newguitext + Glib::ustring(""), Gtk::ALIGN_LEFT)); label->set_padding(0,5); label->set_use_markup(true); - padding = 0; + padding = _indent; } else { label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT)); } diff --git a/src/extension/param/description.h b/src/extension/param/description.h index c34e4ee38..a33ff719a 100644 --- a/src/extension/param/description.h +++ b/src/extension/param/description.h @@ -36,6 +36,7 @@ private: /** \brief Internal value. */ gchar * _value; AppearanceMode _mode; + int _indent; const gchar* _context; }; diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 9ed5aac16..e25559eeb 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -49,7 +49,7 @@ public: ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext) + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _indent(0) { choices = NULL; _value = NULL; @@ -62,7 +62,9 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { Glib::ustring newguitext, newvalue; const char * contents = NULL; - if (node->firstChild()) contents = node->firstChild()->content(); + if (node->firstChild()) { + contents = node->firstChild()->content(); + } if (contents != NULL) { // don't translate when 'item' but do translate when '_item' // NOTE: internal extensions use build_from_mem and don't need _item but @@ -80,10 +82,11 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g continue; const char * val = node->attribute("value"); - if (val != NULL) + if (val != NULL) { newvalue = val; - else + } else { newvalue = contents; + } if ( (!newguitext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here choices = g_slist_append( choices, new enumentry(newvalue, newguitext) ); @@ -95,18 +98,26 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g // Initialize _value with the default value from xml // for simplicity : default to the contents of the first xml-child const char * defaultval = NULL; - if (xml->firstChild() && xml->firstChild()->firstChild()) + if (xml->firstChild() && xml->firstChild()->firstChild()) { defaultval = xml->firstChild()->attribute("value"); + } + + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); g_free(pref_name); - if (!paramval.empty()) + if (!paramval.empty()) { defaultval = paramval.data(); - if (defaultval != NULL) + } + if (defaultval != NULL) { _value = g_strdup(defaultval); + } return; } @@ -139,7 +150,9 @@ ParamComboBox::~ParamComboBox (void) const gchar * ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { - if (in == NULL) return NULL; /* Can't have NULL string */ + if (in == NULL) { + return NULL; /* Can't have NULL string */ + } Glib::ustring settext; for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { @@ -150,7 +163,9 @@ ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node } } if (!settext.empty()) { - if (_value != NULL) g_free(_value); + if (_value != NULL) { + g_free(_value); + } _value = g_strdup(settext.data()); gchar * prefname = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -221,13 +236,15 @@ ParamComboBoxEntry::changed (void) Gtk::Widget * ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT)); label->show(); - hbox->pack_start(*label, false, false); + hbox->pack_start(*label, false, false, _indent); ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal)); // add choice strings: @@ -240,7 +257,9 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s settext = entr->guitext; } } - if (!settext.empty()) combo->set_active_text(settext); + if (!settext.empty()) { + combo->set_active_text(settext); + } combo->show(); hbox->pack_start(*combo, true, true); diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h index 3f9707c34..6fc22e8aa 100644 --- a/src/extension/param/enum.h +++ b/src/extension/param/enum.h @@ -33,7 +33,7 @@ private: been allocated in memory. And should be free'd. It is the value of the current selected string */ gchar * _value; - + int _indent; GSList * choices; /**< A table to store the choice strings */ public: diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 4ef816d61..ea6a70855 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -34,27 +34,31 @@ ParamFloat::ParamFloat (const gchar * name, Inkscape::XML::Node * xml, AppearanceMode mode) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), - _value(0.0), _mode(mode), _min(0.0), _max(10.0) + _value(0.0), _mode(mode), _indent(0), _min(0.0), _max(10.0) { const gchar * defaultval = NULL; - if (sp_repr_children(xml) != NULL) + if (sp_repr_children(xml) != NULL) { defaultval = sp_repr_children(xml)->content(); + } if (defaultval != NULL) { _value = g_ascii_strtod (defaultval,NULL); } const char * maxval = xml->attribute("max"); - if (maxval != NULL) + if (maxval != NULL) { _max = g_ascii_strtod (maxval,NULL); + } const char * minval = xml->attribute("min"); - if (minval != NULL) + if (minval != NULL) { _min = g_ascii_strtod (minval,NULL); + } _precision = 1; const char * precision = xml->attribute("precision"); - if (precision != NULL) + if (precision != NULL) { _precision = atoi(precision); + } /* We're handling this by just killing both values */ if (_max < _min) { @@ -62,6 +66,11 @@ ParamFloat::ParamFloat (const gchar * name, _min = 0.0; } + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } + gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _value = prefs->getDouble(extension_pref_root + pref_name, _value); @@ -69,8 +78,12 @@ ParamFloat::ParamFloat (const gchar * name, // std::cout << "New Float:: value: " << _value << " max: " << _max << " min: " << _min << std::endl; - if (_value > _max) _value = _max; - if (_value < _min) _value = _min; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } return; } @@ -88,8 +101,12 @@ float ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { _value = in; - if (_value > _max) _value = _max; - if (_value < _min) _value = _min; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } gchar * prefname = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -154,13 +171,15 @@ ParamFloatAdjustment::val_changed (void) Gtk::Widget * ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT)); label->show(); - hbox->pack_start(*label, true, true); + hbox->pack_start(*label, true, true, _indent); ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); diff --git a/src/extension/param/float.h b/src/extension/param/float.h index 2e816d4dc..a2c19441d 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -42,6 +42,7 @@ private: /** \brief Internal value. */ float _value; AppearanceMode _mode; + int _indent; float _min; float _max; int _precision; diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index 3ed8addd9..090441c17 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -34,29 +34,36 @@ ParamInt::ParamInt (const gchar * name, Inkscape::XML::Node * xml, AppearanceMode mode) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), - _value(0), _mode(mode), _min(0), _max(10) + _value(0), _mode(mode), _indent(0), _min(0), _max(10) { const char * defaultval = NULL; - if (sp_repr_children(xml) != NULL) + if (sp_repr_children(xml) != NULL) { defaultval = sp_repr_children(xml)->content(); + } if (defaultval != NULL) { _value = atoi(defaultval); } const char * maxval = xml->attribute("max"); - if (maxval != NULL) + if (maxval != NULL) { _max = atoi(maxval); + } const char * minval = xml->attribute("min"); - if (minval != NULL) + if (minval != NULL) { _min = atoi(minval); - + } /* We're handling this by just killing both values */ if (_max < _min) { _max = 10; _min = 0; } + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } + gchar *pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _value = prefs->getInt(extension_pref_root + pref_name, _value); @@ -64,8 +71,12 @@ ParamInt::ParamInt (const gchar * name, // std::cout << "New Int:: value: " << _value << " max: " << _max << " min: " << _min << std::endl; - if (_value > _max) _value = _max; - if (_value < _min) _value = _min; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } return; } @@ -83,8 +94,12 @@ int ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { _value = in; - if (_value > _max) _value = _max; - if (_value < _min) _value = _min; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } gchar * prefname = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -139,13 +154,15 @@ ParamIntAdjustment::val_changed (void) Gtk::Widget * ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT)); label->show(); - hbox->pack_start(*label, true, true); + hbox->pack_start(*label, true, true, _indent); ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); diff --git a/src/extension/param/int.h b/src/extension/param/int.h index fce085378..138368ff3 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -41,6 +41,7 @@ private: /** \brief Internal value. */ int _value; AppearanceMode _mode; + int _indent; int _min; int _max; }; diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 23655baea..a805efc7e 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -69,9 +69,7 @@ ParamRadioButton::ParamRadioButton (const gchar * name, Inkscape::XML::Node * xml, AppearanceMode mode) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), - _value(0), - _mode(mode), - choices(0) + _value(0), _mode(mode), _indent(0), choices(0) { // Read XML tree to add enumeration items: // printf("Extension Constructor: "); @@ -95,16 +93,17 @@ ParamRadioButton::ParamRadioButton (const gchar * name, } else { newguitext = new Glib::ustring(contents); } - } else + } else { continue; - + } const char * val = child_repr->attribute("value"); - if (val != NULL) + if (val != NULL) { newvalue = new Glib::ustring(val); - else + } else { newvalue = new Glib::ustring(contents); + } if ( (newguitext) && (newvalue) ) { // logical error if this is not true here choices = g_slist_append( choices, new optionentry(newvalue, newguitext) ); @@ -117,18 +116,26 @@ ParamRadioButton::ParamRadioButton (const gchar * name, // Initialize _value with the default value from xml // for simplicity : default to the contents of the first xml-child const char * defaultval = NULL; - if (choices) + if (choices) { defaultval = ((optionentry*) choices->data)->value->c_str(); + } + + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); g_free(pref_name); - if (!paramval.empty()) + if (!paramval.empty()) { defaultval = paramval.data(); - if (defaultval != NULL) + } + if (defaultval != NULL) { _value = g_strdup(defaultval); // allocate space for _value + } return; } @@ -161,7 +168,9 @@ ParamRadioButton::~ParamRadioButton (void) const gchar * ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { - if (in == NULL) return NULL; /* Can't have NULL string */ + if (in == NULL) { + return NULL; /* Can't have NULL string */ + } Glib::ustring * settext = NULL; for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { @@ -172,7 +181,9 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No } } if (settext) { - if (_value != NULL) g_free(_value); + if (_value != NULL) { + g_free(_value); + } _value = g_strdup(settext->c_str()); gchar * prefname = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -269,14 +280,16 @@ protected: Gtk::Widget * ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP)); label->show(); - hbox->pack_start(*label, false, false); + hbox->pack_start(*label, false, false, _indent); Gtk::ComboBoxText* cbt = 0; bool comboSet = false; diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h index ea8440de2..e15afdbc7 100644 --- a/src/extension/param/radiobutton.h +++ b/src/extension/param/radiobutton.h @@ -55,7 +55,7 @@ private: It is the value of the current selected string */ gchar * _value; AppearanceMode _mode; - + int _indent; GSList * choices; /**< A table to store the choice strings */ }; /* class ParamRadioButton */ diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index e32224332..18cc754a6 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -44,10 +44,14 @@ ParamString::~ParamString(void) const gchar * ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { - if (in == NULL) return NULL; /* Can't have NULL string */ + if (in == NULL) { + return NULL; /* Can't have NULL string */ + } - if (_value != NULL) + if (_value != NULL) { g_free(_value); + } + _value = g_strdup(in); gchar * prefname = this->pref_name(); @@ -62,31 +66,40 @@ ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * void ParamString::string (std::string &string) { - if (_value == NULL) + if (_value == NULL) { return; - + } string += _value; return; } /** \brief Initialize the object, to do that, copy the data. */ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL) + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(NULL), _indent(0) { const char * defaultval = NULL; - if (sp_repr_children(xml) != NULL) + if (sp_repr_children(xml) != NULL) { defaultval = sp_repr_children(xml)->content(); + } + + const char * indent = xml->attribute("indent"); + if (indent != NULL) { + _indent = atoi(indent) * 12; + } gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); g_free(pref_name); - if (!paramval.empty()) + if (!paramval.empty()) { defaultval = paramval.data(); - if (defaultval != NULL) + } + if (defaultval != NULL) { _value = g_strdup(defaultval); - + } + _max_length = 0; return; @@ -106,8 +119,9 @@ public: */ ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) : Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { - if (_pref->get(NULL, NULL) != NULL) + if (_pref->get(NULL, NULL) != NULL) { this->set_text(Glib::ustring(_pref->get(NULL, NULL))); + } this->set_max_length(_pref->getMaxLength()); //Set the max lenght - default zero means no maximum this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text)); }; @@ -139,13 +153,15 @@ ParamStringEntry::changed_text (void) Gtk::Widget * ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT)); label->show(); - hbox->pack_start(*label, false, false); + hbox->pack_start(*label, false, false, _indent); ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal); textbox->show(); diff --git a/src/extension/param/string.h b/src/extension/param/string.h index 10f45e5ac..a1892fe9c 100644 --- a/src/extension/param/string.h +++ b/src/extension/param/string.h @@ -23,6 +23,7 @@ private: gchar * _value; /** \brief Internal value. This indicates the maximum leght of the string. Zero meaning unlimited. */ + int _indent; gint _max_length; public: ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); -- cgit v1.2.3 From 929f61c316838dd4a8823399df845aa699b9d4e9 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 6 Aug 2011 22:11:25 +0200 Subject: Filters. Global custom predefined filters reorganization. (bzr r10530) --- src/extension/internal/filter/abc.h | 819 --------------------------- src/extension/internal/filter/blurs.h | 133 ++++- src/extension/internal/filter/bumps.h | 256 ++++++++- src/extension/internal/filter/color.h | 126 ++--- src/extension/internal/filter/distort.h | 112 ++++ src/extension/internal/filter/drop-shadow.h | 150 ----- src/extension/internal/filter/experimental.h | 782 ------------------------- src/extension/internal/filter/filter-all.cpp | 64 ++- src/extension/internal/filter/image.h | 6 +- src/extension/internal/filter/morphology.h | 98 +++- src/extension/internal/filter/overlays.h | 147 +++++ src/extension/internal/filter/paint.h | 782 +++++++++++++++++++++++++ src/extension/internal/filter/protrusions.h | 99 ++++ src/extension/internal/filter/shadows.h | 8 +- src/extension/internal/filter/snow.h | 82 --- src/extension/internal/filter/transparency.h | 192 +++++++ 16 files changed, 1890 insertions(+), 1966 deletions(-) delete mode 100755 src/extension/internal/filter/abc.h mode change 100755 => 100644 src/extension/internal/filter/color.h create mode 100644 src/extension/internal/filter/distort.h delete mode 100644 src/extension/internal/filter/drop-shadow.h delete mode 100755 src/extension/internal/filter/experimental.h create mode 100644 src/extension/internal/filter/overlays.h create mode 100644 src/extension/internal/filter/paint.h create mode 100644 src/extension/internal/filter/protrusions.h delete mode 100644 src/extension/internal/filter/snow.h create mode 100644 src/extension/internal/filter/transparency.h (limited to 'src') diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h deleted file mode 100755 index 832fb90c2..000000000 --- a/src/extension/internal/filter/abc.h +++ /dev/null @@ -1,819 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -/* Change the 'ABC' above to be your file name */ - -/* - * Copyright (C) 2011 Authors: - * Ivan Louette (filters) - * Nicolas Dufour (UI) - * - * Basic filters - * Clean edges - * Color shift - * Diffuse light - * Feather - * Matte jelly - * Noise fill - * Outline - * Roughen - * Silhouette - * Specular light - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -/** - \brief Custom predefined Clean edges filter. - - Removes or decreases glows and jaggeries around objects edges after applying some filters - - Filter's parameters: - * Strength (0.01->2., default 0.4) -> blur (stdDeviation) -*/ - -class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - CleanEdges ( ) : Filter() { }; - virtual ~CleanEdges ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Clean edges, custom (ABCs)") "\n" - "org.inkscape.effect.filter.CleanEdges\n" - "0.4\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "\n" - "\n" - "\n", new CleanEdges()); - }; - -}; - -gchar const * -CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str()); - - return _filter; -}; /* CleanEdges filter */ - - -/** - \brief Custom predefined Color shift filter. - - Rotate and desaturate hue - - Filter's parameters: - * Shift (0->360, default 330) -> color1 (values) - * Saturation (0.->1., default 0.6) -> color2 (values) -*/ - -class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - ColorShift ( ) : Filter() { }; - virtual ~ColorShift ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Color shift, custom (ABCs)") "\n" - "org.inkscape.effect.filter.ColorShift\n" - "330\n" - "0.6\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Rotate and desaturate hue") "\n" - "\n" - "\n", new ColorShift()); - }; - -}; - -gchar const * -ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream shift; - std::ostringstream sat; - - shift << ext->get_param_int("shift"); - sat << ext->get_param_float("sat"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n", shift.str().c_str(), sat.str().c_str()); - - return _filter; -}; /* ColorShift filter */ - -/** - \brief Custom predefined Diffuse light filter. - - Basic diffuse bevel to use for building textures - - Filter's parameters: - * Smoothness (0.->10., default 6.) -> blur (stdDeviation) - * Elevation (0->360, default 25) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) -*/ - -class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DiffuseLight ( ) : Filter() { }; - virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Diffuse light, custom (ABCs)") "\n" - "org.inkscape.effect.filter.DiffuseLight\n" - "6\n" - "25\n" - "235\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic diffuse bevel to use for building textures") "\n" - "\n" - "\n", new DiffuseLight()); - }; - -}; - -gchar const * -DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* DiffuseLight filter */ - -/** - \brief Custom predefined Feather filter. - - Blurred mask on the edge without altering the contents - - Filter's parameters: - * Strength (0.01->100., default 5) -> blur (stdDeviation) -*/ - -class Feather : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Feather ( ) : Filter() { }; - virtual ~Feather ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Feather, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Feather\n" - "5\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Blurred mask on the edge without altering the contents") "\n" - "\n" - "\n", new Feather()); - }; - -}; - -gchar const * -Feather::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str()); - - return _filter; -}; /* Feather filter */ - -/** - \brief Custom predefined Matte jelly filter. - - Bulging, matte jelly covering - - Filter's parameters: - * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) - * Brightness (0.0->5., default .9) -> specular (specularConstant) - * Elevation (0->360, default 60) -> feDistantLight (elevation) - * Azimuth (0->360, default 225) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - MatteJelly ( ) : Filter() { }; - virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Matte jelly, custom (ABCs)") "\n" - "org.inkscape.effect.filter.MatteJelly\n" - "7\n" - "0.9\n" - "60\n" - "225\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Bulging, matte jelly covering") "\n" - "\n" - "\n", new MatteJelly()); - }; - -}; - -gchar const * -MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* MatteJelly filter */ - -/** - \brief Custom predefined Noise fill filter. - - Basic noise fill and transparency texture - - Filter's parameters: - * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) - * Complexity (1->5, default 5) -> turbulence (numOctaves) - * Variation (1->360, default 1) -> turbulence (seed) - * Dilatation (1.->50., default 3) -> color (n-1th value) - * Erosion (0.->50., default 1) -> color (nth value 0->-50) - * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity) - * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out") -*/ - -class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - NoiseFill ( ) : Filter() { }; - virtual ~NoiseFill ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Noise fill, custom (ABCs)") "\n" - "org.inkscape.effect.filter.NoiseFill\n" - "\n" - "\n" - "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" - "\n" - "20\n" - "40\n" - "5\n" - "0\n" - "3\n" - "1\n" - "false\n" - "\n" - "\n" - "354957823\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic noise fill and transparency texture") "\n" - "\n" - "\n", new NoiseFill()); - }; - -}; - -gchar const * -NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream type; - std::ostringstream hfreq; - std::ostringstream vfreq; - std::ostringstream complexity; - std::ostringstream variation; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - std::ostringstream inverted; - - type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); - complexity << ext->get_param_int("complexity"); - variation << ext->get_param_int("variation"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - if (ext->get_param_bool("inverted")) - inverted << "out"; - else - inverted << "in"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); - - return _filter; -}; /* NoiseFill filter */ - -/** - \brief Custom predefined Outline filter. - - Adds a colorizable outline - - Filter's parameters: - * Width (0.01->50., default 5) -> blur1 (stdDeviation) - * Melt (0.01->50., default 2) -> blur2 (stdDeviation) - * Dilatation (1.->50., default 8) -> color2 (n-1th value) - * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) - * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) - * Blend (enum, default Normal) -> blend (mode) -*/ - -class Outline : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Outline ( ) : Filter() { }; - virtual ~Outline ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Outline, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Outline\n" - "\n" - "\n" - "5\n" - "2\n" - "8\n" - "5\n" - "\n" - "\n" - "1029214207\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Adds a colorizable outline") "\n" - "\n" - "\n", new Outline()); - }; - -}; - -gchar const * -Outline::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream width; - std::ostringstream melt; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - std::ostringstream blend; - - width << ext->get_param_float("width"); - melt << ext->get_param_float("melt"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); - - return _filter; -}; /* Outline filter */ - -/** - \brief Custom predefined Roughen filter. - - Small-scale roughening to edges and content - - Filter's parameters: - * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) - * Complexity (1->5, default 5) -> turbulence (numOctaves) - * Variation (1->360, default 1) -> turbulence (seed) - * Intensity (0.0->50., default 6.6) -> displacement (scale) -*/ - -class Roughen : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Roughen ( ) : Filter() { }; - virtual ~Roughen ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Roughen, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Roughen\n" - "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" - "\n" - "13\n" - "13\n" - "5\n" - "0\n" - "6.6\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Small-scale roughening to edges and content") "\n" - "\n" - "\n", new Roughen()); - }; - -}; - -gchar const * -Roughen::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream type; - std::ostringstream hfreq; - std::ostringstream vfreq; - std::ostringstream complexity; - std::ostringstream variation; - std::ostringstream intensity; - - type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); - complexity << ext->get_param_int("complexity"); - variation << ext->get_param_int("variation"); - intensity << ext->get_param_float("intensity"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); - - return _filter; -}; /* Roughen filter */ - -/** - \brief Custom predefined Silhouette filter. - - Repaint anything visible monochrome - - Filter's parameters: - * Blur (0.01->50., default 0.01) -> blur (stdDeviation) - * Cutout (boolean, default False) -> composite (false=in, true=out) - * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) -*/ - -class Silhouette : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Silhouette ( ) : Filter() { }; - virtual ~Silhouette ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Silhouette, custom (ABCs)") "\n" - "org.inkscape.effect.filter.Silhouette\n" - "0.01\n" - "false\n" - "255\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Repaint anything visible monochrome") "\n" - "\n" - "\n", new Silhouette()); - }; - -}; - -gchar const * -Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream a; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream cutout; - std::ostringstream blur; - - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - if (ext->get_param_bool("cutout")) - cutout << "out"; - else - cutout << "in"; - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); - - return _filter; -}; /* Silhouette filter */ - -/** - \brief Custom predefined Specular light filter. - - Basic specular bevel to use for building textures - - Filter's parameters: - * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) - * Brightness (0.0->5., default 1.) -> specular (specularConstant) - * Elevation (0->360, default 45) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - SpecularLight ( ) : Filter() { }; - virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Specular light, custom (ABCs)") "\n" - "org.inkscape.effect.filter.SpecularLight\n" - "6\n" - "1\n" - "45\n" - "235\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic specular bevel to use for building textures") "\n" - "\n" - "\n", new SpecularLight()); - }; - -}; - -gchar const * -SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* SpecularLight filter */ - - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'ABC' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */ diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 0fa15dfe6..d6f9a79e6 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -9,7 +9,9 @@ * * Blur filters * Blur + * Clean edges * Cross blur + * Feather * Image blur * * Released under GNU GPL, read the file 'COPYING' for more information @@ -48,7 +50,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Blur, custom (Blurs)") "\n" + "" N_("Blur") "\n" "org.inkscape.effect.filter.Blur\n" "2\n" "2\n" @@ -56,7 +58,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Simple vertical and horizontal blur effect") "\n" @@ -78,13 +80,68 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) vblur << ext->get_param_float("vblur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", hblur.str().c_str(), vblur.str().c_str()); return _filter; }; /* Blur filter */ +/** + \brief Custom predefined Clean edges filter. + + Removes or decreases glows and jaggeries around objects edges after applying some filters + + Filter's parameters: + * Strength (0.01->2., default 0.4) -> blur (stdDeviation) +*/ + +class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CleanEdges ( ) : Filter() { }; + virtual ~CleanEdges ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Clean edges") "\n" + "org.inkscape.effect.filter.CleanEdges\n" + "0.4\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "\n" + "\n" + "\n", new CleanEdges()); + }; + +}; + +gchar const * +CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str()); + + return _filter; +}; /* CleanEdges filter */ /** \brief Custom predefined Cross blur filter. @@ -110,7 +167,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross blur, custom (Blurs)") "\n" + "" N_("Cross blur") "\n" "org.inkscape.effect.filter.CrossBlur\n" "0\n" "0\n" @@ -126,7 +183,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Combine vertical and horizontal blur") "\n" @@ -154,7 +211,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) blend << ext->get_param_enum("blend"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -165,6 +222,62 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Cross blur filter */ +/** + \brief Custom predefined Feather filter. + + Blurred mask on the edge without altering the contents + + Filter's parameters: + * Strength (0.01->100., default 5) -> blur (stdDeviation) +*/ + +class Feather : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Feather ( ) : Filter() { }; + virtual ~Feather ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Feather") "\n" + "org.inkscape.effect.filter.Feather\n" + "5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Blurred mask on the edge without altering the contents") "\n" + "\n" + "\n", new Feather()); + }; + +}; + +gchar const * +Feather::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str()); + + return _filter; +}; /* Feather filter */ /** \brief Custom predefined Image blur filter. @@ -194,7 +307,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Image blur, custom (Blurs)") "\n" + "" N_("Image blur") "\n" "org.inkscape.effect.filter.ImageBlur\n" "\n" "\n" @@ -220,7 +333,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Blur eroded by white or transparency") "\n" @@ -267,7 +380,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -282,8 +395,6 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Image blur filter */ - - }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index b52581844..596d1547f 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -9,6 +9,9 @@ * * Bump filters * Bump + * Diffuse light + * Matte jelly + * Specular light * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -76,7 +79,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Bump, custom (Bumps)") "\n" + "" N_("Bump") "\n" "org.inkscape.effect.filter.Bump\n" "\n" "\n" @@ -138,7 +141,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("All purposes bump filter") "\n" @@ -241,7 +244,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -262,8 +265,253 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; -}; /* Cross blur filter */ +}; /* Bump filter */ +/** + \brief Custom predefined Diffuse light filter. + + Basic diffuse bevel to use for building textures + + Filter's parameters: + * Smoothness (0.->10., default 6.) -> blur (stdDeviation) + * Elevation (0->360, default 25) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) +*/ + +class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + DiffuseLight ( ) : Filter() { }; + virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Diffuse light") "\n" + "org.inkscape.effect.filter.DiffuseLight\n" + "6\n" + "25\n" + "235\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic diffuse bevel to use for building textures") "\n" + "\n" + "\n", new DiffuseLight()); + }; + +}; + +gchar const * +DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* DiffuseLight filter */ + +/** + \brief Custom predefined Matte jelly filter. + + Bulging, matte jelly covering + + Filter's parameters: + * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) + * Brightness (0.0->5., default .9) -> specular (specularConstant) + * Elevation (0->360, default 60) -> feDistantLight (elevation) + * Azimuth (0->360, default 225) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + MatteJelly ( ) : Filter() { }; + virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Matte jelly") "\n" + "org.inkscape.effect.filter.MatteJelly\n" + "7\n" + "0.9\n" + "60\n" + "225\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Bulging, matte jelly covering") "\n" + "\n" + "\n", new MatteJelly()); + }; + +}; + +gchar const * +MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* MatteJelly filter */ + +/** + \brief Custom predefined Specular light filter. + + Basic specular bevel to use for building textures + + Filter's parameters: + * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) + * Brightness (0.0->5., default 1.) -> specular (specularConstant) + * Elevation (0->360, default 45) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + SpecularLight ( ) : Filter() { }; + virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Specular light") "\n" + "org.inkscape.effect.filter.SpecularLight\n" + "6\n" + "1\n" + "45\n" + "235\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic specular bevel to use for building textures") "\n" + "\n" + "\n", new SpecularLight()); + }; + +}; + +gchar const * +SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* SpecularLight filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h old mode 100755 new mode 100644 index 7be675bec..e8de022b9 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -10,7 +10,7 @@ * Color filters * Brightness * Channel painting - * Channel transparency + * Color shift * Colorize * Duochrome * Electrize @@ -63,7 +63,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Brightness, custom (Color)") "\n" + "" N_("Brightness") "\n" "org.inkscape.effect.filter.Brightness\n" "2\n" "0.5\n" @@ -73,7 +73,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Brightness filter") "\n" @@ -112,7 +112,6 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Brightness filter */ - /** \brief Custom predefined Channel Painting filter. @@ -144,7 +143,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Channel painting, custom (Color)") "\n" + "" N_("Channel painting") "\n" "org.inkscape.effect.filter.ChannelPaint\n" "\n" "\n" @@ -163,7 +162,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Replace RGB by any color") "\n" @@ -225,90 +224,64 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Channel Painting filter */ - /** - \brief Custom predefined Channel transparency filter. + \brief Custom predefined Color shift filter. - Channel transparency filter. + Rotate and desaturate hue Filter's parameters: - * Saturation (0.->1., default 1.) -> colormatrix1 (values) - * Red (-10.->10., default -1.) -> colormatrix2 (values) - * Green (-10.->10., default 0.5) -> colormatrix2 (values) - * Blue (-10.->10., default 0.5) -> colormatrix2 (values) - * Alpha (-10.->10., default 1.) -> colormatrix2 (values) - * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) - * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') - - Matrix: - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 1 0 0 - R G B A 0 + * Shift (0->360, default 330) -> color1 (values) + * Saturation (0.->1., default 0.6) -> color2 (values) */ -class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { + +class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - ChannelTransparency ( ) : Filter() { }; - virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - + ColorShift ( ) : Filter() { }; + virtual ~ColorShift ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Channel transparency, custom (Color)") "\n" - "org.inkscape.effect.filter.ChannelTransparency\n" - "-1\n" - "0.5\n" - "0.5\n" - "1\n" - "false\n" + "" N_("Color shift") "\n" + "org.inkscape.effect.filter.ColorShift\n" + "330\n" + "0.6\n" "\n" "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" - "" N_("Replace RGB by transparency") "\n" + "" N_("Rotate and desaturate hue") "\n" "\n" - "\n", new ChannelTransparency()); + "\n", new ColorShift()); }; + }; gchar const * -ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream red; - std::ostringstream green; - std::ostringstream blue; - std::ostringstream alpha; - std::ostringstream invert; + std::ostringstream shift; + std::ostringstream sat; - red << ext->get_param_float("red"); - green << ext->get_param_float("green"); - blue << ext->get_param_float("blue"); - alpha << ext->get_param_float("alpha"); + shift << ext->get_param_int("shift"); + sat << ext->get_param_float("sat"); - if (!ext->get_param_bool("invert")) { - invert << "in"; - } else { - invert << "xor"; - } - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), - invert.str().c_str()); + "\n" + "\n" + "\n" + "\n", shift.str().c_str(), sat.str().c_str()); return _filter; -}; /* Channel Transparency filter */ - +}; /* ColorShift filter */ /** \brief Custom predefined Colorize filter. @@ -335,7 +308,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Colorize, custom (Color)") "\n" + "" N_("Colorize") "\n" "org.inkscape.effect.filter.Colorize\n" "\n" "\n" @@ -365,7 +338,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Blend image or object with a flood color") "\n" @@ -420,7 +393,6 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Colorize filter */ - /** \brief Custom predefined Duochrome filter. @@ -444,7 +416,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Duochrome, custom (Color)") "\n" + "" N_("Duochrome") "\n" "org.inkscape.effect.filter.Duochrome\n" "\n" "\n" @@ -467,7 +439,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Convert luminance values to a duochrome palette") "\n" @@ -567,7 +539,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Electrize, custom (Color)") "\n" + "" N_("Electrize") "\n" "org.inkscape.effect.filter.Electrize\n" "2.0\n" "\n" @@ -580,7 +552,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Electro solarization effects") "\n" @@ -661,7 +633,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Greyscale, custom (Color)") "\n" + "" N_("Greyscale") "\n" "org.inkscape.effect.filter.Greyscale\n" "0.21\n" "0.72\n" @@ -672,7 +644,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Customize greyscale components") "\n" @@ -743,7 +715,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Lightness, custom (Color)") "\n" + "" N_("Lightness") "\n" "org.inkscape.effect.filter.Lightness\n" "1\n" "1\n" @@ -752,7 +724,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Modify lights and shadows separately") "\n" @@ -812,7 +784,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Quadritone fantasy, custom (Color)") "\n" + "" N_("Quadritone fantasy") "\n" "org.inkscape.effect.filter.Quadritone\n" "280\n" "100\n" @@ -833,7 +805,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Replace hue by two colors") "\n" @@ -874,7 +846,6 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Quadritone filter */ - /** \brief Custom predefined Solarize filter. @@ -899,7 +870,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Solarize, custom (Color)") "\n" + "" N_("Solarize") "\n" "org.inkscape.effect.filter.Solarize\n" "0\n" "\n" @@ -910,7 +881,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Classic photographic solarization effect") "\n" @@ -954,7 +925,6 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Solarize filter */ - /** \brief Custom predefined Tritone filter. @@ -986,7 +956,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Tritone, custom (Color)") "\n" + "" N_("Tritone") "\n" "org.inkscape.effect.filter.Tritone\n" "\n" "\n" @@ -1020,7 +990,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Create a custom tritone palette with additional glow, blend modes and hue moving") "\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h new file mode 100644 index 000000000..7157722d7 --- /dev/null +++ b/src/extension/internal/filter/distort.h @@ -0,0 +1,112 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ +/* Change the 'DISTORT' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Distort filters + * Roughen + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Roughen filter. + + Small-scale roughening to edges and content + + Filter's parameters: + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 5) -> turbulence (numOctaves) + * Variation (1->360, default 1) -> turbulence (seed) + * Intensity (0.0->50., default 6.6) -> displacement (scale) +*/ + +class Roughen : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Roughen ( ) : Filter() { }; + virtual ~Roughen ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Roughen") "\n" + "org.inkscape.effect.filter.Roughen\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "13\n" + "13\n" + "5\n" + "0\n" + "6.6\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Small-scale roughening to edges and content") "\n" + "\n" + "\n", new Roughen()); + }; + +}; + +gchar const * +Roughen::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream intensity; + + type << ext->get_param_enum("type"); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + intensity << ext->get_param_float("intensity"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); + + return _filter; +}; /* Roughen filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'DISTORT' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ */ diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h deleted file mode 100644 index c2338d194..000000000 --- a/src/extension/internal/filter/drop-shadow.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -/* Change the 'DROP_SHADOW' above to be your file name */ - -/* - * Copyright (C) 2008 Authors: - * Ted Gould - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -class DropShadow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DropShadow ( ) : Filter() { }; - virtual ~DropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Drop Shadow") "\n" - "org.inkscape.effect.filter.drop-shadow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Black, blurred drop shadow") "\n" - "\n" - "\n", new DropShadow()); - }; - -}; - -gchar const * -DropShadow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream opacity; - std::ostringstream x; - std::ostringstream y; - - blur << ext->get_param_float("blur"); - opacity << ext->get_param_float("opacity") / 100; - x << ext->get_param_float("xoffset"); - y << ext->get_param_float("yoffset"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); - - return _filter; -}; - -class DropGlow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DropGlow ( ) : Filter() { }; - virtual ~DropGlow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Drop Glow") "\n" - "org.inkscape.effect.filter.drop-glow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("White, blurred drop glow") "\n" - "\n" - "\n", new DropGlow()); - }; - -}; - -gchar const * -DropGlow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream opacity; - std::ostringstream x; - std::ostringstream y; - - blur << ext->get_param_float("blur"); - opacity << ext->get_param_float("opacity") / 100; - x << ext->get_param_float("xoffset"); - y << ext->get_param_float("yoffset"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); - - return _filter; -}; - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'DROP_SHADOW' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h deleted file mode 100755 index 2032cb513..000000000 --- a/src/extension/internal/filter/experimental.h +++ /dev/null @@ -1,782 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -/* Change the 'EXPERIMENTAL' above to be your file name */ - -/* - * Copyright (C) 2011 Authors: - * Ivan Louette (filters) - * Nicolas Dufour (UI) - * - * Experimental filters (no assigned menu) - * Chromolitho - * Cross engraving - * Drawing - * Neon draw - * Posterize - * Posterize basic - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -/** - \brief Custom predefined Chromolitho filter. - - Chromo effect with customizable edge drawing and graininess - - Filter's parameters: - * Drawing (boolean, default checked) -> Checked = blend1 (in="convolve1"), unchecked = blend1 (in="composite1") - * Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1") - * Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0] - * Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s] - * Lightness (0.->10., default 0.) -> composite1 (k1) - * Saturation (0.->1., default 1.) -> colormatrix3 (values) - * Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020) - * Drawing blend (enum, default Normal) -> blend1 (mode) - * Smoothness (0.01->10, default 1) -> blur1 (stdDeviation) - * Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1") - * Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value) - * Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value) - * Grain complexity (1->5, default 1) -> turbulence1 (numOctaves) - * Grain variation (0->1000, default 0) -> turbulence1 (seed) - * Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value) - * Grain erosion (0.->40., default 0.) -> colormatrix1 (nth value) [inverted] - * Grain color (boolean, default true) -> colormatrix2 (values) - * Grain blend (enum, default Normal) -> blend2 (mode) -*/ -class Chromolitho : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Chromolitho ( ) : Filter() { }; - virtual ~Chromolitho ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Chromolitho, custom") "\n" - "org.inkscape.effect.filter.Chromolitho\n" - "\n" - "\n" - "true\n" - "\n" - "<_item value=\"darken\">Darken\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "<_item value=\"lighten\">Lighten\n" - "\n" - "false\n" - "false\n" - "false\n" - "0\n" - "1\n" - "10\n" - "1\n" - "\n" - "\n" - "true\n" - "1000\n" - "1000\n" - "1\n" - "0\n" - "1\n" - "0\n" - "true\n" - "\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "<_item value=\"lighten\">Lighten\n" - "<_item value=\"darken\">Darken\n" - "\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Chromo effect with customizable edge drawing and graininess") "\n" - "\n" - "\n", new Chromolitho()); - }; -}; - -gchar const * -Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream b1in; - std::ostringstream b2in; - std::ostringstream col3in; - std::ostringstream transf; - std::ostringstream light; - std::ostringstream saturation; - std::ostringstream noise; - std::ostringstream dblend; - std::ostringstream smooth; - std::ostringstream grain; - std::ostringstream grainxf; - std::ostringstream grainyf; - std::ostringstream grainc; - std::ostringstream grainv; - std::ostringstream gblend; - std::ostringstream grainexp; - std::ostringstream grainero; - std::ostringstream graincol; - - if (ext->get_param_bool("drawing")) - b1in << "convolve1"; - else - b1in << "composite1"; - - if (ext->get_param_bool("transparent")) - col3in << "colormatrix4"; - else - col3in << "component1"; - light << ext->get_param_float("light"); - saturation << ext->get_param_float("saturation"); - noise << (-1000 - ext->get_param_int("noise")); - dblend << ext->get_param_enum("dblend"); - smooth << ext->get_param_float("smooth"); - - if (ext->get_param_bool("dented")) { - transf << "0 1 0 1"; - } else { - transf << "0 1 1"; - } - if (ext->get_param_bool("inverted")) - transf << " 0"; - - if (ext->get_param_bool("grain")) - b2in << "colormatrix2"; - else - b2in << "blur1"; - grainxf << (ext->get_param_float("grainxf") / 1000); - grainyf << (ext->get_param_float("grainyf") / 1000); - grainc << ext->get_param_int("grainc"); - grainv << ext->get_param_int("grainv"); - gblend << ext->get_param_enum("gblend"); - grainexp << ext->get_param_float("grainexp"); - grainero << (-ext->get_param_float("grainero")); - if (ext->get_param_bool("graincol")) - graincol << "1"; - else - graincol << "0"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", light.str().c_str(), noise.str().c_str(), b1in.str().c_str(), dblend.str().c_str(), smooth.str().c_str(), grainxf.str().c_str(), grainyf.str().c_str(), grainc.str().c_str(), grainv.str().c_str(), grainexp.str().c_str(), grainero.str().c_str(), graincol.str().c_str(), b2in.str().c_str(), gblend.str().c_str(), saturation.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str(), col3in.str().c_str()); - - return _filter; -}; /* Chromolitho filter */ - -/** - \brief Custom predefined Cross engraving filter. - - Convert image to an engraving made of vertical and horizontal lines - - Filter's parameters: - * Clean-up (1->500, default 30) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1030) - * Dilatation (1.->50., default 1) -> color2 (n-1th value) - * Erosion (0.->50., default 0) -> color2 (nth value 0->-50) - * Strength (0.->10., default 0.5) -> composite2 (k2) - * Length (0.5->20, default 4) -> blur1 (stdDeviation x), blur2 (stdDeviation y) - * Transparent (boolean, default false) -> composite 4 (in, true->composite3, false->blend) -*/ -class CrossEngraving : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - CrossEngraving ( ) : Filter() { }; - virtual ~CrossEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Cross engraving, custom") "\n" - "org.inkscape.effect.filter.CrossEngraving\n" - "30\n" - "1\n" - "0\n" - "0.5\n" - "4\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Convert image to an engraving made of vertical and horizontal lines") "\n" - "\n" - "\n", new CrossEngraving()); - }; -}; - -gchar const * -CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream clean; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream strength; - std::ostringstream length; - std::ostringstream trans; - - clean << (-1000 - ext->get_param_int("clean")); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - strength << ext->get_param_float("strength"); - length << ext->get_param_float("length"); - if (ext->get_param_bool("trans")) - trans << "composite3"; - else - trans << "blend"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str()); - - return _filter; -}; /* CrossEngraving filter */ - -/** - \brief Custom predefined Drawing filter. - - Convert images to duochrome drawings. - - Filter's parameters: - * Simplification strength (0.01->20, default 0.6) -> blur1 (stdDeviation) - * Clean-up (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010) - * Erase (0.->6., default 0) -> composite1 (k4) - * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) - * Dilatation (1.->50., default 6) -> color2 (n-1th value) - * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) - * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) - - * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) - * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) - * Blur erosion (0.->50., default 2) -> color4 (nth value 0->-50) - - * Stroke color (guint, default 64,64,64,255) -> flood2 (flood-color), composite3 (k2) - * Image on stroke (boolean, default false) -> composite2 (in="flood2" true-> in="SourceGraphic") - * Offset (-100->100, default 0) -> offset (val) - - * Fill color (guint, default 200,200,200,255) -> flood3 (flood-opacity), composite5 (k2) - * Image on fill (boolean, default false) -> composite4 (in="flood3" true-> in="SourceGraphic") - -*/ - -class Drawing : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Drawing ( ) : Filter() { }; - virtual ~Drawing ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Drawing, custom") "\n" - "org.inkscape.effect.filter.Drawing\n" - "\n" - "\n" - "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" - "0.6\n" - "10\n" - "0\n" - "false\n" - "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" - "0.6\n" - "6\n" - "2\n" - "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" - "1\n" - "6\n" - "2\n" - "\n" - "\n" - "-1515870721\n" - "false\n" - "\n" - "\n" - "589505535\n" - "false\n" - "0\n" - "\n" - "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Convert images to duochrome drawings") "\n" - "\n" - "\n", new Drawing()); - }; -}; - -gchar const * -Drawing::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream simply; - std::ostringstream clean; - std::ostringstream erase; - std::ostringstream smooth; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream translucent; - std::ostringstream offset; - std::ostringstream blur; - std::ostringstream bdilat; - std::ostringstream berosion; - std::ostringstream strokea; - std::ostringstream stroker; - std::ostringstream strokeg; - std::ostringstream strokeb; - std::ostringstream ios; - std::ostringstream filla; - std::ostringstream fillr; - std::ostringstream fillg; - std::ostringstream fillb; - std::ostringstream iof; - - simply << ext->get_param_float("simply"); - clean << (-1000 - ext->get_param_int("clean")); - erase << (ext->get_param_float("erase") / 10); - smooth << ext->get_param_float("smooth"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - if (ext->get_param_bool("translucent")) - translucent << "merge1"; - else - translucent << "color5"; - offset << ext->get_param_int("offset"); - - blur << ext->get_param_float("blur"); - bdilat << ext->get_param_float("bdilat"); - berosion << (- ext->get_param_float("berosion")); - - guint32 fcolor = ext->get_param_color("fcolor"); - fillr << ((fcolor >> 24) & 0xff); - fillg << ((fcolor >> 16) & 0xff); - fillb << ((fcolor >> 8) & 0xff); - filla << (fcolor & 0xff) / 255.0F; - if (ext->get_param_bool("iof")) - iof << "SourceGraphic"; - else - iof << "flood3"; - - guint32 scolor = ext->get_param_color("scolor"); - stroker << ((scolor >> 24) & 0xff); - strokeg << ((scolor >> 16) & 0xff); - strokeb << ((scolor >> 8) & 0xff); - strokea << (scolor & 0xff) / 255.0F; - if (ext->get_param_bool("ios")) - ios << "SourceGraphic"; - else - ios << "flood2"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str()); - - return _filter; -}; /* Drawing filter */ - - -/** - \brief Custom predefined Neon draw filter. - - Posterize and draw smooth lines around color shapes - - Filter's parameters: - * Lines type (enum, default smooth) -> - smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2") - hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1") - * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation) - * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation) - * Lightness (0.->10., default 0.5) -> composite1 (k3) - * Blend (enum [normal, multiply, screen], default normal) -> blend (mode) - * Dark mode (boolean, default false) -> composite1 (true: in2="component2") -*/ -class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - NeonDraw ( ) : Filter() { }; - virtual ~NeonDraw ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Neon draw, custom") "\n" - "org.inkscape.effect.filter.NeonDraw\n" - "\n" - "<_item value=\"table\">Smoothed\n" - "<_item value=\"discrete\">Contrasted\n" - "\n" - "1.5\n" - "1.5\n" - "0.5\n" - "\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Posterize and draw smooth lines around color shapes") "\n" - "\n" - "\n", new NeonDraw()); - }; -}; - -gchar const * -NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blend; - std::ostringstream simply; - std::ostringstream width; - std::ostringstream lightness; - std::ostringstream type; - std::ostringstream dark; - - type << ext->get_param_enum("type"); - blend << ext->get_param_enum("blend"); - simply << ext->get_param_float("simply"); - width << ext->get_param_float("width"); - lightness << ext->get_param_float("lightness"); - - const gchar *typestr = ext->get_param_enum("type"); - if (ext->get_param_bool("dark")) - dark << "component2"; - else if ((g_ascii_strcasecmp("table", typestr) == 0)) - dark << "blur2"; - else - dark << "component1"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str()); - - return _filter; -}; /* NeonDraw filter */ - -/** - \brief Custom predefined Poster paint filter. - - Poster and painting effects. - - Filter's parameters: - * Effect type (enum, default "Normal") -> - Normal = feComponentTransfer - Dented = Normal + intermediate values - * Transfer type (enum, default "descrete") -> component (type) - * Levels (0->15, default 5) -> component (tableValues) - * Blend mode (enum, default "Lighten") -> blend (mode) - * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) - * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) - * Pre-saturation (0.->1., default 1.) -> color1 (values) - * Post-saturation (0.->1., default 1.) -> color2 (values) - * Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01) -*/ -class Posterize : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Posterize ( ) : Filter() { }; - virtual ~Posterize ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Poster paint, custom") "\n" - "org.inkscape.effect.filter.Posterize\n" - "\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"dented\">Dented\n" - "\n" - "\n" - "<_item value=\"discrete\">Poster\n" - "<_item value=\"table\">Painting\n" - "\n" - "5\n" - "\n" - "<_item value=\"lighten\">Lighten\n" - "<_item value=\"normal\">Normal\n" - "<_item value=\"darken\">Darken\n" - "<_item value=\"multiply\">Multiply\n" - "<_item value=\"screen\">Screen\n" - "\n" - "4.0\n" - "0.5\n" - "1.00\n" - "1.00\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Poster and painting effects") "\n" - "\n" - "\n", new Posterize()); - }; -}; - -gchar const * -Posterize::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream table; - std::ostringstream blendmode; - std::ostringstream blur1; - std::ostringstream blur2; - std::ostringstream presat; - std::ostringstream postsat; - std::ostringstream transf; - std::ostringstream antialias; - - table << ext->get_param_enum("table"); - blendmode << ext->get_param_enum("blend"); - blur1 << ext->get_param_float("blur1"); - blur2 << ext->get_param_float("blur2"); - presat << ext->get_param_float("presaturation"); - postsat << ext->get_param_float("postsaturation"); - - // TransfertComponent table values are calculated based on the poster type. - transf << "0"; - int levels = ext->get_param_int("levels") + 1; - const gchar *effecttype = ext->get_param_enum("type"); - float val = 0.0; - if (levels == 1) { - if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { - transf << " 1 0 1"; - } else { - transf << " 1"; - } - } else { - for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; - transf << " " << val; - if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { - transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); - } - } - } - transf << " 1"; - - if (ext->get_param_bool("antialiasing")) - antialias << "0.5"; - else - antialias << "0.01"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str()); - - return _filter; -}; /* Posterize filter */ - -/** - \brief Custom predefined Posterize basic filter. - - Simple posterizing effect - - Filter's parameters: - * Levels (0->20, default 5) -> component1 (tableValues) - * Blur (0.01->20., default 4.) -> blur1 (stdDeviation) -*/ -class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - PosterizeBasic ( ) : Filter() { }; - virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Posterize basic, custom") "\n" - "org.inkscape.effect.filter.PosterizeBasic\n" - "5\n" - "4.0\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Simple posterizing effect") "\n" - "\n" - "\n", new PosterizeBasic()); - }; -}; - -gchar const * -PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream transf; - - blur << ext->get_param_float("blur"); - - transf << "0"; - int levels = ext->get_param_int("levels") + 1; - float val = 0.0; - for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; - transf << " " << val; - } - transf << " 1"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str()); - - return _filter; -}; /* PosterizeBasic filter */ - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'EXPERIMENTAL' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index b451ac619..ffac97e0c 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,17 +8,17 @@ #include "filter.h" /* Put your filter here */ -#include "abc.h" #include "blurs.h" #include "bumps.h" #include "color.h" -#include "drop-shadow.h" +#include "distort.h" #include "image.h" #include "morphology.h" +#include "overlays.h" +#include "paint.h" +#include "protrusions.h" #include "shadows.h" -#include "snow.h" - -#include "experimental.h" +#include "transparency.h" namespace Inkscape { namespace Extension { @@ -30,36 +30,26 @@ void Filter::filters_all (void ) { // Here come the filters which are coded in C++ in order to present a parameters dialog - DropShadow::init(); - DropGlow::init(); - Snow::init(); /* Experimental custom predefined filters */ - // ABC - CleanEdges::init(); - ColorShift::init(); - DiffuseLight::init(); - Feather::init(); - MatteJelly::init(); - NoiseFill::init(); - Outline::init(); - Roughen::init(); - Silhouette::init(); - SpecularLight::init(); - // Blurs Blur::init(); + CleanEdges::init(); CrossBlur::init(); + Feather::init(); ImageBlur::init(); // Bumps Bump::init(); - + DiffuseLight::init(); + MatteJelly::init(); + SpecularLight::init(); + // Color Brightness::init(); ChannelPaint::init(); - ChannelTransparency::init(); + ColorShift::init(); Colorize::init(); Duochrome::init(); Electrize::init(); @@ -69,16 +59,13 @@ Filter::filters_all (void ) Solarize::init(); Tritone::init(); - // Image - EdgeDetect::init(); - - // Morphology - Crosssmooth::init(); + // Distort + Roughen::init(); - // Shadows and glows - ColorizableDropShadow::init(); + // Image effect + EdgeDetect::init(); - // TDB + // Image paint and draw Chromolitho::init(); CrossEngraving::init(); Drawing::init(); @@ -86,6 +73,23 @@ Filter::filters_all (void ) Posterize::init(); PosterizeBasic::init(); + // Morphology + Crosssmooth::init(); + Outline::init(); + + // Overlays + NoiseFill::init(); + + // Protrusions + Snow::init(); + + // Shadows and glows + ColorizableDropShadow::init(); + + // Fill and transparency + ChannelTransparency::init(); + Silhouette::init(); + // Here come the rest of the filters that are read from SVG files in share/filters and // .config/Inkscape/filters /* This should always be last, don't put stuff below this diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index bc052bfc0..3f1a33055 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -46,7 +46,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Edge detect, custom (Image)") "\n" + "" N_("Edge detect") "\n" "org.inkscape.effect.filter.EdgeDetect\n" "\n" "<_item value=\"all\">" N_("All") "\n" @@ -59,7 +59,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Detect color edges in object") "\n" @@ -97,7 +97,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 25cef0fca..59c33f586 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -9,6 +9,7 @@ * * Morphology filters * Cross-smooth + * Outline * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -48,7 +49,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross-smooth, custom (Morphology)") "\n" + "" N_("Cross-smooth") "\n" "org.inkscape.effect.filter.crosssmooth\n" "\n" "<_item value=\"edges\">Smooth edges\n" @@ -59,7 +60,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Smooth edges and angles of shapes") "\n" @@ -87,7 +88,7 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -98,6 +99,97 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Crosssmooth filter */ +/** + \brief Custom predefined Outline filter. + + Adds a colorizable outline + + Filter's parameters: + * Width (0.01->50., default 5) -> blur1 (stdDeviation) + * Melt (0.01->50., default 2) -> blur2 (stdDeviation) + * Dilatation (1.->50., default 8) -> color2 (n-1th value) + * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) + * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) + * Blend (enum, default Normal) -> blend (mode) +*/ + +class Outline : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Outline ( ) : Filter() { }; + virtual ~Outline ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Outline") "\n" + "org.inkscape.effect.filter.Outline\n" + "\n" + "\n" + "5\n" + "2\n" + "8\n" + "5\n" + "\n" + "\n" + "1029214207\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Adds a colorizable outline") "\n" + "\n" + "\n", new Outline()); + }; + +}; + +gchar const * +Outline::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream width; + std::ostringstream melt; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream blend; + + width << ext->get_param_float("width"); + melt << ext->get_param_float("melt"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + + return _filter; +}; /* Outline filter */ + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h new file mode 100644 index 000000000..4c59b553b --- /dev/null +++ b/src/extension/internal/filter/overlays.h @@ -0,0 +1,147 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ +/* Change the 'OVERLAYS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Overlays filters + * Noise fill + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Noise fill filter. + + Basic noise fill and transparency texture + + Filter's parameters: + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 5) -> turbulence (numOctaves) + * Variation (1->360, default 1) -> turbulence (seed) + * Dilatation (1.->50., default 3) -> color (n-1th value) + * Erosion (0.->50., default 1) -> color (nth value 0->-50) + * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity) + * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out") +*/ + +class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + NoiseFill ( ) : Filter() { }; + virtual ~NoiseFill ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Noise fill") "\n" + "org.inkscape.effect.filter.NoiseFill\n" + "\n" + "\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "20\n" + "40\n" + "5\n" + "0\n" + "3\n" + "1\n" + "false\n" + "\n" + "\n" + "354957823\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic noise fill and transparency texture") "\n" + "\n" + "\n", new NoiseFill()); + }; + +}; + +gchar const * +NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream inverted; + + type << ext->get_param_enum("type"); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + if (ext->get_param_bool("inverted")) + inverted << "out"; + else + inverted << "in"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + + return _filter; +}; /* NoiseFill filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'OVERLAYS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ */ diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h new file mode 100644 index 000000000..7a1cc6046 --- /dev/null +++ b/src/extension/internal/filter/paint.h @@ -0,0 +1,782 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ +/* Change the 'PAINT' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Image paint and draw filters + * Chromolitho + * Cross engraving + * Drawing + * Neon draw + * Posterize + * Posterize basic + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Chromolitho filter. + + Chromo effect with customizable edge drawing and graininess + + Filter's parameters: + * Drawing (boolean, default checked) -> Checked = blend1 (in="convolve1"), unchecked = blend1 (in="composite1") + * Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1") + * Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0] + * Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s] + * Lightness (0.->10., default 0.) -> composite1 (k1) + * Saturation (0.->1., default 1.) -> colormatrix3 (values) + * Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020) + * Drawing blend (enum, default Normal) -> blend1 (mode) + * Smoothness (0.01->10, default 1) -> blur1 (stdDeviation) + * Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1") + * Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value) + * Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value) + * Grain complexity (1->5, default 1) -> turbulence1 (numOctaves) + * Grain variation (0->1000, default 0) -> turbulence1 (seed) + * Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value) + * Grain erosion (0.->40., default 0.) -> colormatrix1 (nth value) [inverted] + * Grain color (boolean, default true) -> colormatrix2 (values) + * Grain blend (enum, default Normal) -> blend2 (mode) +*/ +class Chromolitho : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Chromolitho ( ) : Filter() { }; + virtual ~Chromolitho ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Chromolitho") "\n" + "org.inkscape.effect.filter.Chromolitho\n" + "\n" + "\n" + "true\n" + "\n" + "<_item value=\"darken\">Darken\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "<_item value=\"lighten\">Lighten\n" + "\n" + "false\n" + "false\n" + "false\n" + "0\n" + "1\n" + "10\n" + "1\n" + "\n" + "\n" + "true\n" + "1000\n" + "1000\n" + "1\n" + "0\n" + "1\n" + "0\n" + "true\n" + "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "<_item value=\"lighten\">Lighten\n" + "<_item value=\"darken\">Darken\n" + "\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Chromo effect with customizable edge drawing and graininess") "\n" + "\n" + "\n", new Chromolitho()); + }; +}; + +gchar const * +Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream b1in; + std::ostringstream b2in; + std::ostringstream col3in; + std::ostringstream transf; + std::ostringstream light; + std::ostringstream saturation; + std::ostringstream noise; + std::ostringstream dblend; + std::ostringstream smooth; + std::ostringstream grain; + std::ostringstream grainxf; + std::ostringstream grainyf; + std::ostringstream grainc; + std::ostringstream grainv; + std::ostringstream gblend; + std::ostringstream grainexp; + std::ostringstream grainero; + std::ostringstream graincol; + + if (ext->get_param_bool("drawing")) + b1in << "convolve1"; + else + b1in << "composite1"; + + if (ext->get_param_bool("transparent")) + col3in << "colormatrix4"; + else + col3in << "component1"; + light << ext->get_param_float("light"); + saturation << ext->get_param_float("saturation"); + noise << (-1000 - ext->get_param_int("noise")); + dblend << ext->get_param_enum("dblend"); + smooth << ext->get_param_float("smooth"); + + if (ext->get_param_bool("dented")) { + transf << "0 1 0 1"; + } else { + transf << "0 1 1"; + } + if (ext->get_param_bool("inverted")) + transf << " 0"; + + if (ext->get_param_bool("grain")) + b2in << "colormatrix2"; + else + b2in << "blur1"; + grainxf << (ext->get_param_float("grainxf") / 1000); + grainyf << (ext->get_param_float("grainyf") / 1000); + grainc << ext->get_param_int("grainc"); + grainv << ext->get_param_int("grainv"); + gblend << ext->get_param_enum("gblend"); + grainexp << ext->get_param_float("grainexp"); + grainero << (-ext->get_param_float("grainero")); + if (ext->get_param_bool("graincol")) + graincol << "1"; + else + graincol << "0"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", light.str().c_str(), noise.str().c_str(), b1in.str().c_str(), dblend.str().c_str(), smooth.str().c_str(), grainxf.str().c_str(), grainyf.str().c_str(), grainc.str().c_str(), grainv.str().c_str(), grainexp.str().c_str(), grainero.str().c_str(), graincol.str().c_str(), b2in.str().c_str(), gblend.str().c_str(), saturation.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str(), col3in.str().c_str()); + + return _filter; +}; /* Chromolitho filter */ + +/** + \brief Custom predefined Cross engraving filter. + + Convert image to an engraving made of vertical and horizontal lines + + Filter's parameters: + * Clean-up (1->500, default 30) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1030) + * Dilatation (1.->50., default 1) -> color2 (n-1th value) + * Erosion (0.->50., default 0) -> color2 (nth value 0->-50) + * Strength (0.->10., default 0.5) -> composite2 (k2) + * Length (0.5->20, default 4) -> blur1 (stdDeviation x), blur2 (stdDeviation y) + * Transparent (boolean, default false) -> composite 4 (in, true->composite3, false->blend) +*/ +class CrossEngraving : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CrossEngraving ( ) : Filter() { }; + virtual ~CrossEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Cross engraving") "\n" + "org.inkscape.effect.filter.CrossEngraving\n" + "30\n" + "1\n" + "0\n" + "0.5\n" + "4\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Convert image to an engraving made of vertical and horizontal lines") "\n" + "\n" + "\n", new CrossEngraving()); + }; +}; + +gchar const * +CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream clean; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream strength; + std::ostringstream length; + std::ostringstream trans; + + clean << (-1000 - ext->get_param_int("clean")); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + strength << ext->get_param_float("strength"); + length << ext->get_param_float("length"); + if (ext->get_param_bool("trans")) + trans << "composite3"; + else + trans << "blend"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str()); + + return _filter; +}; /* CrossEngraving filter */ + +/** + \brief Custom predefined Drawing filter. + + Convert images to duochrome drawings. + + Filter's parameters: + * Simplification strength (0.01->20, default 0.6) -> blur1 (stdDeviation) + * Clean-up (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010) + * Erase (0.->6., default 0) -> composite1 (k4) + * Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation) + * Dilatation (1.->50., default 6) -> color2 (n-1th value) + * Erosion (0.->50., default 2) -> color2 (nth value 0->-50) + * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5) + + * Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation) + * Blur dilatation (1.->50., default 6) -> color4 (n-1th value) + * Blur erosion (0.->50., default 2) -> color4 (nth value 0->-50) + + * Stroke color (guint, default 64,64,64,255) -> flood2 (flood-color), composite3 (k2) + * Image on stroke (boolean, default false) -> composite2 (in="flood2" true-> in="SourceGraphic") + * Offset (-100->100, default 0) -> offset (val) + + * Fill color (guint, default 200,200,200,255) -> flood3 (flood-opacity), composite5 (k2) + * Image on fill (boolean, default false) -> composite4 (in="flood3" true-> in="SourceGraphic") + +*/ + +class Drawing : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Drawing ( ) : Filter() { }; + virtual ~Drawing ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Drawing") "\n" + "org.inkscape.effect.filter.Drawing\n" + "\n" + "\n" + "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" + "0.6\n" + "10\n" + "0\n" + "false\n" + "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" + "0.6\n" + "6\n" + "2\n" + "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" + "1\n" + "6\n" + "2\n" + "\n" + "\n" + "-1515870721\n" + "false\n" + "\n" + "\n" + "589505535\n" + "false\n" + "0\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Convert images to duochrome drawings") "\n" + "\n" + "\n", new Drawing()); + }; +}; + +gchar const * +Drawing::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream simply; + std::ostringstream clean; + std::ostringstream erase; + std::ostringstream smooth; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream translucent; + std::ostringstream offset; + std::ostringstream blur; + std::ostringstream bdilat; + std::ostringstream berosion; + std::ostringstream strokea; + std::ostringstream stroker; + std::ostringstream strokeg; + std::ostringstream strokeb; + std::ostringstream ios; + std::ostringstream filla; + std::ostringstream fillr; + std::ostringstream fillg; + std::ostringstream fillb; + std::ostringstream iof; + + simply << ext->get_param_float("simply"); + clean << (-1000 - ext->get_param_int("clean")); + erase << (ext->get_param_float("erase") / 10); + smooth << ext->get_param_float("smooth"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + if (ext->get_param_bool("translucent")) + translucent << "merge1"; + else + translucent << "color5"; + offset << ext->get_param_int("offset"); + + blur << ext->get_param_float("blur"); + bdilat << ext->get_param_float("bdilat"); + berosion << (- ext->get_param_float("berosion")); + + guint32 fcolor = ext->get_param_color("fcolor"); + fillr << ((fcolor >> 24) & 0xff); + fillg << ((fcolor >> 16) & 0xff); + fillb << ((fcolor >> 8) & 0xff); + filla << (fcolor & 0xff) / 255.0F; + if (ext->get_param_bool("iof")) + iof << "SourceGraphic"; + else + iof << "flood3"; + + guint32 scolor = ext->get_param_color("scolor"); + stroker << ((scolor >> 24) & 0xff); + strokeg << ((scolor >> 16) & 0xff); + strokeb << ((scolor >> 8) & 0xff); + strokea << (scolor & 0xff) / 255.0F; + if (ext->get_param_bool("ios")) + ios << "SourceGraphic"; + else + ios << "flood2"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str()); + + return _filter; +}; /* Drawing filter */ + + +/** + \brief Custom predefined Neon draw filter. + + Posterize and draw smooth lines around color shapes + + Filter's parameters: + * Lines type (enum, default smooth) -> + smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2") + hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1") + * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation) + * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation) + * Lightness (0.->10., default 0.5) -> composite1 (k3) + * Blend (enum [normal, multiply, screen], default normal) -> blend (mode) + * Dark mode (boolean, default false) -> composite1 (true: in2="component2") +*/ +class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + NeonDraw ( ) : Filter() { }; + virtual ~NeonDraw ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Neon draw") "\n" + "org.inkscape.effect.filter.NeonDraw\n" + "\n" + "<_item value=\"table\">Smoothed\n" + "<_item value=\"discrete\">Contrasted\n" + "\n" + "1.5\n" + "1.5\n" + "0.5\n" + "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Posterize and draw smooth lines around color shapes") "\n" + "\n" + "\n", new NeonDraw()); + }; +}; + +gchar const * +NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blend; + std::ostringstream simply; + std::ostringstream width; + std::ostringstream lightness; + std::ostringstream type; + std::ostringstream dark; + + type << ext->get_param_enum("type"); + blend << ext->get_param_enum("blend"); + simply << ext->get_param_float("simply"); + width << ext->get_param_float("width"); + lightness << ext->get_param_float("lightness"); + + const gchar *typestr = ext->get_param_enum("type"); + if (ext->get_param_bool("dark")) + dark << "component2"; + else if ((g_ascii_strcasecmp("table", typestr) == 0)) + dark << "blur2"; + else + dark << "component1"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str()); + + return _filter; +}; /* NeonDraw filter */ + +/** + \brief Custom predefined Poster paint filter. + + Poster and painting effects. + + Filter's parameters: + * Effect type (enum, default "Normal") -> + Normal = feComponentTransfer + Dented = Normal + intermediate values + * Transfer type (enum, default "descrete") -> component (type) + * Levels (0->15, default 5) -> component (tableValues) + * Blend mode (enum, default "Lighten") -> blend (mode) + * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation) + * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation) + * Pre-saturation (0.->1., default 1.) -> color1 (values) + * Post-saturation (0.->1., default 1.) -> color2 (values) + * Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01) +*/ +class Posterize : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Posterize ( ) : Filter() { }; + virtual ~Posterize ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Poster paint") "\n" + "org.inkscape.effect.filter.Posterize\n" + "\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"dented\">Dented\n" + "\n" + "\n" + "<_item value=\"discrete\">Poster\n" + "<_item value=\"table\">Painting\n" + "\n" + "5\n" + "\n" + "<_item value=\"lighten\">Lighten\n" + "<_item value=\"normal\">Normal\n" + "<_item value=\"darken\">Darken\n" + "<_item value=\"multiply\">Multiply\n" + "<_item value=\"screen\">Screen\n" + "\n" + "4.0\n" + "0.5\n" + "1.00\n" + "1.00\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Poster and painting effects") "\n" + "\n" + "\n", new Posterize()); + }; +}; + +gchar const * +Posterize::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream table; + std::ostringstream blendmode; + std::ostringstream blur1; + std::ostringstream blur2; + std::ostringstream presat; + std::ostringstream postsat; + std::ostringstream transf; + std::ostringstream antialias; + + table << ext->get_param_enum("table"); + blendmode << ext->get_param_enum("blend"); + blur1 << ext->get_param_float("blur1"); + blur2 << ext->get_param_float("blur2"); + presat << ext->get_param_float("presaturation"); + postsat << ext->get_param_float("postsaturation"); + + // TransfertComponent table values are calculated based on the poster type. + transf << "0"; + int levels = ext->get_param_int("levels") + 1; + const gchar *effecttype = ext->get_param_enum("type"); + float val = 0.0; + if (levels == 1) { + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " 1 0 1"; + } else { + transf << " 1"; + } + } else { + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { + transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); + } + } + } + transf << " 1"; + + if (ext->get_param_bool("antialiasing")) + antialias << "0.5"; + else + antialias << "0.01"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str()); + + return _filter; +}; /* Posterize filter */ + +/** + \brief Custom predefined Posterize basic filter. + + Simple posterizing effect + + Filter's parameters: + * Levels (0->20, default 5) -> component1 (tableValues) + * Blur (0.01->20., default 4.) -> blur1 (stdDeviation) +*/ +class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + PosterizeBasic ( ) : Filter() { }; + virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Posterize basic") "\n" + "org.inkscape.effect.filter.PosterizeBasic\n" + "5\n" + "4.0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Simple posterizing effect") "\n" + "\n" + "\n", new PosterizeBasic()); + }; +}; + +gchar const * +PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + std::ostringstream transf; + + blur << ext->get_param_float("blur"); + + transf << "0"; + int levels = ext->get_param_int("levels") + 1; + float val = 0.0; + for ( int step = 1 ; step <= levels ; step++ ) { + val = (float) step / levels; + transf << " " << val; + } + transf << " 1"; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str()); + + return _filter; +}; /* PosterizeBasic filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'PAINT' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ */ diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h new file mode 100644 index 000000000..9103bdc11 --- /dev/null +++ b/src/extension/internal/filter/protrusions.h @@ -0,0 +1,99 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ +/* Change the 'PROTRUSIONS' above to be your file name */ + +/* + * Copyright (C) 2008 Authors: + * Ted Gould + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Protrusion filters + * Snow + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + + +/** + \brief Custom predefined Snow filter. + + Snow has fallen on object. +*/ +class Snow : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Snow ( ) : Filter() { }; + virtual ~Snow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + +public: + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Snow crest") "\n" + "org.inkscape.effect.filter.snow\n" + "3.5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Snow has fallen on object") "\n" + "\n" + "\n", new Snow()); + }; + +}; + +gchar const * +Snow::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream drift; + drift << ext->get_param_float("drift"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", drift.str().c_str()); + + return _filter; +}; /* Snow filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'PROTRUSIONS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ */ diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 2339373c1..49f1003cc 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -53,7 +53,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drop shadow, custom (Shadows and Glows)") "\n" + "" N_("Drop shadow") "\n" "org.inkscape.effect.filter.ColorDropShadow\n" "\n" "\n" @@ -76,7 +76,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Colorizable Drop shadow") "\n" @@ -158,7 +158,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -170,7 +170,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2in1.str().c_str(), comp2in2.str().c_str(), comp2op.str().c_str()); return _filter; -}; +}; /* Drop shadow filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/snow.h deleted file mode 100644 index 7a15f9efa..000000000 --- a/src/extension/internal/filter/snow.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -/* Change the 'SNOW' above to be your file name */ - -/* - * Copyright (C) 2008 Authors: - * Ted Gould - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -class Snow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Snow ( ) : Filter() { }; - virtual ~Snow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - -public: - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Snow crest") "\n" - "org.inkscape.effect.filter.snow\n" - "3.5\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Snow has fallen on object") "\n" - "\n" - "\n", new Snow()); - }; - -}; - -gchar const * -Snow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream drift; - drift << ext->get_param_float("drift"); - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", drift.str().c_str()); - - return _filter; -}; - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'SNOW' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */ diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h new file mode 100644 index 000000000..c47df89df --- /dev/null +++ b/src/extension/internal/filter/transparency.h @@ -0,0 +1,192 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ +/* Change the 'TRANSPARENCY' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Fill and transparency filters + * Channel transparency + * Silhouette + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Channel transparency filter. + + Channel transparency filter. + + Filter's parameters: + * Saturation (0.->1., default 1.) -> colormatrix1 (values) + * Red (-10.->10., default -1.) -> colormatrix2 (values) + * Green (-10.->10., default 0.5) -> colormatrix2 (values) + * Blue (-10.->10., default 0.5) -> colormatrix2 (values) + * Alpha (-10.->10., default 1.) -> colormatrix2 (values) + * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) + * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') + + Matrix: + 1 0 0 0 0 + 0 1 0 0 0 + 0 0 1 0 0 + R G B A 0 +*/ +class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ChannelTransparency ( ) : Filter() { }; + virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Channel transparency") "\n" + "org.inkscape.effect.filter.ChannelTransparency\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Replace RGB with transparency") "\n" + "\n" + "\n", new ChannelTransparency()); + }; +}; + +gchar const * +ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream alpha; + std::ostringstream invert; + + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + alpha << ext->get_param_float("alpha"); + + if (!ext->get_param_bool("invert")) { + invert << "in"; + } else { + invert << "xor"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), + invert.str().c_str()); + + return _filter; +}; /* Channel transparency filter */ + +/** + \brief Custom predefined Silhouette filter. + + Repaint anything visible monochrome + + Filter's parameters: + * Blur (0.01->50., default 0.01) -> blur (stdDeviation) + * Cutout (boolean, default False) -> composite (false=in, true=out) + * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) +*/ + +class Silhouette : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Silhouette ( ) : Filter() { }; + virtual ~Silhouette ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Silhouette") "\n" + "org.inkscape.effect.filter.Silhouette\n" + "0.01\n" + "false\n" + "255\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Repaint anything visible monochrome") "\n" + "\n" + "\n", new Silhouette()); + }; + +}; + +gchar const * +Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream a; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream cutout; + std::ostringstream blur; + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + if (ext->get_param_bool("cutout")) + cutout << "out"; + else + cutout << "in"; + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); + + return _filter; +}; /* Silhouette filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'TRANSPARENCY' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ */ -- cgit v1.2.3 From 75976ea07dba9b97186667524d0a76603de416af Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 7 Aug 2011 12:53:12 +0200 Subject: Rewrite NRArena -> Inkscape::Drawing. Call render and update methods on the Drawing rather than on the root DrawingItem. (bzr r10347.1.25) --- src/desktop.cpp | 21 +-- src/dialogs/clonetiler.cpp | 30 ++-- src/display/Makefile_insert | 4 +- src/display/canvas-arena.cpp | 82 +++++---- src/display/canvas-arena.h | 4 +- src/display/display-forward.h | 15 +- src/display/drawing-group.cpp | 6 +- src/display/drawing-group.h | 2 +- src/display/drawing-image.cpp | 8 +- src/display/drawing-image.h | 2 +- src/display/drawing-item.cpp | 42 ++--- src/display/drawing-item.h | 41 ++--- src/display/drawing-shape.cpp | 16 +- src/display/drawing-shape.h | 2 +- src/display/drawing-text.cpp | 10 +- src/display/drawing-text.h | 4 +- src/display/drawing.cpp | 159 +++++++++++++++++ src/display/drawing.h | 103 +++++++++++ src/display/nr-arena.cpp | 198 ---------------------- src/display/nr-arena.h | 75 -------- src/display/nr-filter-image.cpp | 19 +-- src/display/nr-filter.cpp | 6 +- src/extension/internal/cairo-png-out.cpp | 10 +- src/extension/internal/cairo-ps-out.cpp | 9 +- src/extension/internal/cairo-render-context.cpp | 8 +- src/extension/internal/cairo-renderer-pdf-out.cpp | 10 +- src/extension/internal/cairo-renderer.cpp | 1 - src/extension/internal/emf-win32-inout.cpp | 13 +- src/extension/internal/latex-pstricks-out.cpp | 12 +- src/extension/print.cpp | 23 ++- src/extension/print.h | 2 +- src/flood-context.cpp | 31 ++-- src/helper/pixbuf-ops.cpp | 19 +-- src/helper/png-write.cpp | 24 ++- src/marker.cpp | 10 +- src/print.cpp | 13 +- src/sp-clippath.cpp | 11 +- src/sp-clippath.h | 2 +- src/sp-flowtext.cpp | 6 +- src/sp-flowtext.h | 2 +- src/sp-image.cpp | 6 +- src/sp-item-group.cpp | 16 +- src/sp-item-group.h | 4 +- src/sp-item.cpp | 14 +- src/sp-item.h | 4 +- src/sp-mask.cpp | 10 +- src/sp-mask.h | 2 +- src/sp-pattern.cpp | 24 +-- src/sp-root.cpp | 10 +- src/sp-shape.cpp | 8 +- src/sp-shape.h | 2 +- src/sp-switch.cpp | 6 +- src/sp-switch.h | 2 +- src/sp-symbol.cpp | 8 +- src/sp-text.cpp | 8 +- src/sp-text.h | 2 +- src/sp-use.cpp | 8 +- src/svg-view.cpp | 4 +- src/text-context.h | 1 - src/trace/trace.cpp | 2 +- src/ui/cache/svg_preview_cache.cpp | 10 +- src/ui/cache/svg_preview_cache.h | 2 +- src/ui/dialog/filedialogimpl-win32.cpp | 4 +- src/ui/dialog/icon-preview.cpp | 21 +-- src/ui/view/view.h | 2 +- src/widgets/desktop-widget.cpp | 1 - src/widgets/icon.cpp | 49 +++--- src/widgets/stroke-style.cpp | 14 +- 68 files changed, 619 insertions(+), 680 deletions(-) create mode 100644 src/display/drawing.cpp create mode 100644 src/display/drawing.h delete mode 100644 src/display/nr-arena.cpp delete mode 100644 src/display/nr-arena.h (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index cceee9499..7a71862d3 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -72,7 +72,7 @@ #include "display/canvas-temporary-item-list.h" #include "display/drawing-group.h" #include "display/gnome-canvas-acetate.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/snap-indicator.h" #include "display/sodipodi-ctrlrect.h" #include "display/sp-canvas-group.h" @@ -230,7 +230,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid drawing = sp_canvas_item_new (main, SP_TYPE_CANVAS_ARENA, NULL); g_signal_connect (G_OBJECT (drawing), "arena_event", G_CALLBACK (_arena_handler), this); - SP_CANVAS_ARENA (drawing)->arena->delta = prefs->getDouble("/options/cursortolerance/value", 1.0); // default is 1 px + SP_CANVAS_ARENA (drawing)->drawing.delta = prefs->getDouble("/options/cursortolerance/value", 1.0); // default is 1 px if (prefs->getBool("/options/startmode/outline")) { // Start in outline mode @@ -287,11 +287,11 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( - SP_CANVAS_ARENA (drawing)->arena, + SP_CANVAS_ARENA (drawing)->drawing, dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - SP_CANVAS_ARENA (drawing)->root->prependChild(ai); + SP_CANVAS_ARENA (drawing)->drawing.root()->prependChild(ai); } namedview->show(this); @@ -404,6 +404,7 @@ void SPDesktop::destroy() if (drawing) { doc()->getRoot()->invoke_hide(dkey); + g_object_unref(drawing); drawing = NULL; } @@ -455,14 +456,14 @@ SPDesktop::remove_temporary_canvasitem (Inkscape::Display::TemporaryItem * tempi } void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) { - SP_CANVAS_ARENA (drawing)->arena->rendermode = mode; + SP_CANVAS_ARENA (drawing)->drawing.setRenderMode(mode); canvas->rendermode = mode; _display_mode = mode; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw _widget->setTitle( sp_desktop_document(this)->getName() ); } void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) { - SP_CANVAS_ARENA (drawing)->arena->colormode = mode; + SP_CANVAS_ARENA (drawing)->drawing.setColorMode(mode); canvas->colorrendermode = mode; _display_color_mode = mode; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw @@ -1570,11 +1571,11 @@ SPDesktop::setDocument (SPDocument *doc) number = namedview->getViewCount(); ai = doc->getRoot()->invoke_show( - SP_CANVAS_ARENA (drawing)->arena, + SP_CANVAS_ARENA (drawing)->drawing, dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - SP_CANVAS_ARENA (drawing)->root->prependChild(ai); + SP_CANVAS_ARENA (drawing)->drawing.root()->prependChild(ai); } namedview->show(this); /* Ugly hack */ @@ -1788,9 +1789,9 @@ _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) SP_RGBA32_G_U(nv->pagecolor) + SP_RGBA32_B_U(nv->pagecolor)) >= 384) { // the background color is light or transparent, use black outline - SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs->getInt("/options/wireframecolors/onlight", 0xff); + SP_CANVAS_ARENA (desktop->drawing)->drawing.outlinecolor = prefs->getInt("/options/wireframecolors/onlight", 0xff); } else { // use white outline - SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs->getInt("/options/wireframecolors/ondark", 0xffffffff); + SP_CANVAS_ARENA (desktop->drawing)->drawing.outlinecolor = prefs->getInt("/options/wireframecolors/ondark", 0xffffffff); } } } diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 2b08a307a..109b235d0 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -25,8 +25,8 @@ #include "desktop-handles.h" #include "dialog-events.h" #include "display/cairo-utils.h" +#include "display/drawing.h" #include "display/drawing-context.h" -#include "display/nr-arena.h" #include "display/drawing-item.h" #include "document.h" #include "filter-chemistry.h" @@ -832,15 +832,14 @@ static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) return result; } -static NRArena const *trace_arena = NULL; +static Inkscape::Drawing *trace_drawing = NULL; static unsigned trace_visionkey; -static Inkscape::DrawingItem *trace_root; static gdouble trace_zoom; -static SPDocument *trace_doc; +static SPDocument *trace_doc = NULL; static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) { - if (!trace_arena) + if (!trace_drawing) return; for (SPObject *o = from->firstChild(); o != NULL; o = o->next) { @@ -852,13 +851,11 @@ static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { - // FIXME MEMORY LEAK: the stuff here is never freed - - trace_arena = NRArena::create(); + trace_drawing = new Inkscape::Drawing(); /* Create ArenaItem and set transform */ trace_visionkey = SPItem::display_key_new(1); trace_doc = doc; - trace_root = trace_doc->getRoot()->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); + trace_drawing->setRoot(trace_doc->getRoot()->invoke_show(*trace_drawing, trace_visionkey, SP_ITEM_SHOW_DISPLAY)); // hide the (current) original and any tiled clones, we only want to pick the background original->invoke_hide(trace_visionkey); @@ -872,12 +869,12 @@ static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *origin static guint32 clonetiler_trace_pick(Geom::Rect box) { - if (!trace_arena) { + if (!trace_drawing) { return 0; } - trace_root->setTransform(Geom::Scale(trace_zoom)); - trace_root->update(); + trace_drawing->root()->setTransform(Geom::Scale(trace_zoom)); + trace_drawing->update(); /* Item integer bbox in points */ Geom::IntRect ibox = (box * Geom::Scale(trace_zoom)).roundOutwards(); @@ -886,7 +883,7 @@ static guint32 clonetiler_trace_pick(Geom::Rect box) cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ibox.width(), ibox.height()); Inkscape::DrawingContext ct(s, ibox.min()); /* Render */ - trace_root->render(ct, ibox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + trace_drawing->render(ct, ibox); double R = 0, G = 0, B = 0, A = 0; ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); @@ -898,10 +895,9 @@ static void clonetiler_trace_finish() { if (trace_doc) { trace_doc->getRoot()->invoke_hide(trace_visionkey); - } - if (trace_arena) { - ((NRObject *) trace_arena)->unreference(); - trace_arena = NULL; + delete trace_drawing; + trace_doc = NULL; + trace_drawing = NULL; } } diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index 1c51f19a0..1c7a21dae 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -23,6 +23,8 @@ ink_common_sources += \ display/canvas-text.h \ display/curve.cpp \ display/curve.h \ + display/drawing.cpp \ + display/drawing.h \ display/drawing-context.cpp \ display/drawing-context.h \ display/drawing-group.cpp \ @@ -45,8 +47,6 @@ ink_common_sources += \ display/guideline.h \ display/nr-3dutils.cpp \ display/nr-3dutils.h \ - display/nr-arena.h \ - display/nr-arena.cpp \ display/nr-arena-forward.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 81416fefb..6026ebd3f 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -15,7 +15,6 @@ #include "display/display-forward.h" #include "display/sp-canvas-util.h" #include "helper/sp-marshal.h" -#include "display/nr-arena.h" #include "display/canvas-arena.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" @@ -43,14 +42,8 @@ static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event); static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event); -static void sp_canvas_arena_request_update (NRArena *arena, DrawingItem *item, void *data); -static void sp_canvas_arena_request_render (NRArena *arena, NRRectL *area, void *data); - -NRArenaEventVector carenaev = { - {NULL}, - sp_canvas_arena_request_update, - sp_canvas_arena_request_render -}; +static void sp_canvas_arena_request_update (SPCanvasArena *ca, DrawingItem *item); +static void sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect const &area); static SPCanvasItemClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; @@ -108,21 +101,27 @@ sp_canvas_arena_init (SPCanvasArena *arena) { arena->sticky = FALSE; - arena->arena = NRArena::create(); - nr_object_ref(arena->arena); - arena->arena->canvasarena = arena; - arena->arena->item_deleted.connect( + new (&arena->drawing) Inkscape::Drawing(arena); + + Inkscape::DrawingGroup *root = new DrawingGroup(arena->drawing); + root->setPickChildren(true); + root->setCached(true); + arena->drawing.setRoot(root); + + arena->drawing.signal_request_update.connect( + sigc::bind<0>( + sigc::ptr_fun(&sp_canvas_arena_request_update), + arena)); + arena->drawing.signal_request_render.connect( + sigc::bind<0>( + sigc::ptr_fun(&sp_canvas_arena_request_render), + arena)); + arena->drawing.signal_item_deleted.connect( sigc::bind<0>( sigc::ptr_fun(&sp_canvas_arena_item_deleted), arena)); - arena->root = new DrawingGroup(arena->arena); - arena->root->setPickChildren(true); - arena->root->setCached(true); - arena->active = NULL; - - nr_active_object_add_listener ((NRActiveObject *) arena->arena, (NRObjectEventVector *) &carenaev, sizeof (carenaev), arena); } static void @@ -130,11 +129,7 @@ sp_canvas_arena_destroy (GtkObject *object) { SPCanvasArena *arena = SP_CANVAS_ARENA (object); - delete arena->root; - - nr_active_object_remove_listener_by_data ((NRActiveObject *) arena->arena, arena); - nr_object_unref ((NRObject *) arena->arena); - arena->arena = NULL; + arena->drawing.~Drawing(); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -151,9 +146,9 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned arena->ctx.ctm = affine; unsigned reset = flags & SP_CANVAS_UPDATE_AFFINE ? DrawingItem::STATE_ALL : 0; - arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_ALL, reset); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_ALL, reset); - Geom::OptIntRect b = arena->root->visualBounds(); + Geom::OptIntRect b = arena->drawing.root()->visualBounds(); if (b) { item->x1 = b->left() - 1; item->y1 = b->top() - 1; @@ -163,7 +158,7 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned if (arena->cursor) { /* Mess with enter/leave notifiers */ - DrawingItem *new_arena = arena->root->pick(arena->c, arena->arena->delta, arena->sticky); + DrawingItem *new_arena = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; ec.window = GTK_WIDGET (item->canvas)->window; @@ -205,8 +200,8 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) Inkscape::DrawingContext ct(buf->ct, r->min()); - arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_ALL, 0); - arena->root->render(ct, *r, 0); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx); + arena->drawing.render(ct, *r); } static double @@ -214,8 +209,8 @@ sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ { SPCanvasArena *arena = SP_CANVAS_ARENA (item); - arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); - DrawingItem *picked = arena->root->pick(p, arena->arena->delta, arena->sticky); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK); + DrawingItem *picked = arena->drawing.pick(p, arena->drawing.delta, arena->sticky); arena->picked = picked; @@ -235,7 +230,7 @@ sp_canvas_arena_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_ar Geom::IntRect expanded = new_area; Geom::IntPoint expansion(new_area.width()/2, new_area.height()/2); expanded.expandBy(expansion); - nr_arena_set_cache_limit(arena->arena, expanded); + arena->drawing.setCacheLimit(expanded); } static gint @@ -260,8 +255,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->crossing.x, event->crossing.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); - arena->active = arena->root->pick(arena->c, arena->arena->delta, arena->sticky); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); + arena->active = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky); ret = sp_canvas_arena_send_event (arena, event); } break; @@ -279,8 +274,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->motion.x, event->motion.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - arena->root->update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); - new_arena = arena->root->pick(arena->c, arena->arena->delta, arena->sticky); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK); + new_arena = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; ec.window = event->motion.window; @@ -324,16 +319,16 @@ sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event) } static void -sp_canvas_arena_request_update (NRArena */*arena*/, DrawingItem */*item*/, void *data) +sp_canvas_arena_request_update (SPCanvasArena *ca, DrawingItem */*item*/) { - sp_canvas_item_request_update (SP_CANVAS_ITEM (data)); + sp_canvas_item_request_update (SP_CANVAS_ITEM (ca)); } static void -sp_canvas_arena_request_render (NRArena */*arena*/, NRRectL *area, void *data) +sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect const &area) { - if (!area) return; - sp_canvas_request_redraw (SP_CANVAS_ITEM (data)->canvas, area->x0, area->y0, area->x1, area->y1); + SPCanvas *canvas = SP_CANVAS_ITEM (ca)->canvas; + sp_canvas_request_redraw (canvas, area.left(), area.top(), area.right(), area.bottom()); } void @@ -365,11 +360,10 @@ sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRR Geom::OptIntRect area = r.upgrade_2geom(); if (!area) return; Inkscape::DrawingContext ct(surface, area->min()); - ca->root->update(Geom::IntRect::infinite(), ca->ctx, DrawingItem::STATE_ALL, 0); - ca->root->render(ct, *area, 0); + ca->drawing.update(Geom::IntRect::infinite(), ca->ctx); + ca->drawing.render(ct, *area); } - /* Local Variables: mode:c++ diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index e63a524f2..6c65bb0e5 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -16,6 +16,7 @@ #include #include <2geom/rect.h> #include "display/display-forward.h" +#include "display/drawing.h" #include "display/drawing-item.h" #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" @@ -38,8 +39,7 @@ struct _SPCanvasArena { guint sticky : 1; Geom::Point c; // what is this? - NRArena *arena; - Inkscape::DrawingGroup *root; + Inkscape::Drawing drawing; Inkscape::UpdateContext ctx; Inkscape::DrawingItem *active; diff --git a/src/display/display-forward.h b/src/display/display-forward.h index d7e7d72ab..7dccb76ef 100644 --- a/src/display/display-forward.h +++ b/src/display/display-forward.h @@ -10,23 +10,30 @@ typedef struct _SPCanvasItemClass SPCanvasItemClass; struct SPCanvasGroup; struct SPCanvasGroupClass; class SPCurve; - -class NRArena; +typedef struct _SPCanvasArena SPCanvasArena; namespace Inkscape { -class DrawingContext; -class DrawingSurface; +class Drawing; class DrawingItem; class DrawingGroup; class DrawingImage; class DrawingShape; class DrawingGlyphs; class DrawingText; +class UpdateContext; + +class DrawingContext; +class DrawingSurface; +class DrawingCache; namespace Display { class TemporaryItem; class TemporaryItemList; } + +namespace Filters { + class Filter; +} } #endif /* !SEEN_DISPLAY_DISPLAY_FORWARD_H */ diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index feaa7622a..38ab73ca2 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -10,16 +10,16 @@ */ #include "display/cairo-utils.h" +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-item.h" #include "display/drawing-group.h" #include "libnr/nr-values.h" -#include "nr-arena.h" #include "style.h" namespace Inkscape { -DrawingGroup::DrawingGroup(Drawing *drawing) +DrawingGroup::DrawingGroup(Drawing &drawing) : DrawingItem(drawing) , _style(NULL) , _child_transform(NULL) @@ -75,7 +75,7 @@ unsigned DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { unsigned beststate = STATE_ALL; - bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { UpdateContext child_ctx(ctx); diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 072944b6c..7b0645bf4 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -22,7 +22,7 @@ class DrawingGroup : public DrawingItem { public: - DrawingGroup(Drawing *drawing); + DrawingGroup(Drawing &drawing); ~DrawingGroup(); bool pickChildren() { return _pick_children; } diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 879809cfa..64601354d 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -10,15 +10,15 @@ */ #include "display/cairo-utils.h" +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-image.h" -#include "nr-arena.h" #include "preferences.h" #include "style.h" namespace Inkscape { -DrawingImage::DrawingImage(Drawing *drawing) +DrawingImage::DrawingImage(Drawing &drawing) : DrawingItem(drawing) , _pixbuf(NULL) , _surface(NULL) @@ -115,7 +115,7 @@ DrawingImage::_updateItem(Geom::IntRect const &, UpdateContext const &, unsigned void DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { - bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); if (!outline) { if (!_pixbuf) return; @@ -200,7 +200,7 @@ DrawingImage::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) { if (!_pixbuf) return NULL; - bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); if (outline) { Geom::Rect r = bounds(); diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h index d66395aab..de8591221 100644 --- a/src/display/drawing-image.h +++ b/src/display/drawing-image.h @@ -24,7 +24,7 @@ class DrawingImage : public DrawingItem { public: - DrawingImage(Drawing *drawing); + DrawingImage(Drawing &drawing); ~DrawingImage(); void setARGB32Pixbuf(GdkPixbuf *pb); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 53639f765..47f6c55a1 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -11,11 +11,11 @@ #include "display/cairo-utils.h" #include "display/cairo-templates.h" +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-item.h" #include "display/drawing-group.h" #include "display/drawing-surface.h" -#include "nr-arena.h" #include "nr-filter.h" #include "preferences.h" #include "style.h" @@ -42,7 +42,7 @@ namespace Inkscape { * has been deleted. */ -DrawingItem::DrawingItem(Drawing *drawing) +DrawingItem::DrawingItem(Drawing &drawing) : _drawing(drawing) , _parent(NULL) , _key(0) @@ -61,21 +61,21 @@ DrawingItem::DrawingItem(Drawing *drawing) // , _renders_opacity(0) , _clip_child(0) , _mask_child(0) + , _drawing_root(0) , _pick_children(0) { - nr_object_ref(_drawing); } DrawingItem::~DrawingItem() { - _drawing->item_deleted.emit(this); + _drawing.signal_item_deleted.emit(this); //if (!_children.empty()) { // g_warning("Removing item with children"); //} // remove from the set of cached items if (_cached) { - _drawing->cached_items.erase(this); + _drawing._cached_items.erase(this); } // remove this item from parent's children list // due to the effect of clearChildren(), this only happens for the top-level deleted item @@ -92,13 +92,14 @@ DrawingItem::~DrawingItem() _parent->_children.erase(ithis); } _parent->_markForUpdate(STATE_ALL, false); + } else if (_drawing_root) { + _drawing._root = NULL; } clearChildren(); delete _transform; delete _clip; delete _mask; delete _filter; - nr_object_unref(_drawing); } DrawingItem * @@ -187,9 +188,9 @@ DrawingItem::setCached(bool c) { _cached = c; if (c) { - _drawing->cached_items.insert(this); + _drawing._cached_items.insert(this); } else { - _drawing->cached_items.erase(this); + _drawing._cached_items.erase(this); } _markForUpdate(STATE_CACHE, false); } @@ -266,8 +267,8 @@ DrawingItem::setItemBounds(Geom::OptRect const &bounds) void DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { - bool render_filters = (_drawing->rendermode == Inkscape::RENDERMODE_NORMAL); - bool outline = (_drawing->rendermode == Inkscape::RENDERMODE_OUTLINE); + bool render_filters = _drawing.renderFilters(); + bool outline = _drawing.outline(); // Set reset flags according to propagation status if (_propagate) { @@ -324,7 +325,7 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne // update cache if enabled if (_cached) { - Geom::OptIntRect cl = _drawing->cache_limit; + Geom::OptIntRect cl = _drawing.cacheLimit(); cl.intersectWith(_drawbox); if (cl) { if (_cache) { @@ -373,8 +374,8 @@ struct MaskLuminanceToAlpha { void DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { - bool outline = (_drawing->rendermode == Inkscape::RENDERMODE_OUTLINE); - bool render_filters = (_drawing->rendermode == Inkscape::RENDERMODE_NORMAL); + bool outline = _drawing.outline(); + bool render_filters = _drawing.renderFilters(); /* If we are invisible, just return successfully */ if (!_visible) return; @@ -530,19 +531,19 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig _renderItem(ct, *carea, flags); // render clip and mask, if any - guint32 saved_rgba = _drawing->outlinecolor; // save current outline color + guint32 saved_rgba = _drawing.outlinecolor; // save current outline color // render clippath as an object, using a different color Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (_clip) { - _drawing->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips + _drawing.outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips _clip->render(ct, *carea, flags); } // render mask as an object, using a different color if (_mask) { - _drawing->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks + _drawing.outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks _mask->render(ct, *carea, flags); } - _drawing->outlinecolor = saved_rgba; // restore outline color + _drawing.outlinecolor = saved_rgba; // restore outline color } /** @brief Rasterize the clipping path. @@ -624,7 +625,7 @@ DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) void DrawingItem::_markForRendering() { - bool outline = (_drawing->rendermode == Inkscape::RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); Geom::OptIntRect dirty = outline ? _bbox : _drawbox; if (!dirty) return; @@ -634,8 +635,7 @@ DrawingItem::_markForRendering() i->_cache->markDirty(*dirty); } } - - nr_arena_request_render_rect (_drawing, dirty); + _drawing.signal_request_render.emit(*dirty); } /** @brief Marks the item as needing a recomputation of internal data. @@ -665,7 +665,7 @@ DrawingItem::_markForUpdate(unsigned flags, bool propagate) if (_parent) { _parent->_markForUpdate(flags, false); } else { - nr_arena_request_update (_drawing, this); + _drawing.signal_request_update.emit(this); } } } diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index f26c65df5..ba0c42695 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -13,22 +13,16 @@ #define SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H #include +#include #include #include <2geom/rect.h> #include <2geom/affine.h> +#include "display/display-forward.h" -class NRArena; class SPStyle; -void nr_arena_set_cache_limit(NRArena *, Geom::OptIntRect const &); namespace Inkscape { -typedef ::NRArena Drawing; -class DrawingContext; -class DrawingCache; -class DrawingItem; -namespace Filters { class Filter; } - struct UpdateContext { Geom::Affine ctm; }; @@ -39,10 +33,8 @@ class InvalidItemException : public std::exception { } }; -typedef boost::intrusive::list_base_hook<> ChildrenListHook; - class DrawingItem - : public ChildrenListHook + : boost::noncopyable { public: enum RenderFlags { @@ -59,9 +51,8 @@ public: STATE_RENDER = (1<<4), // can be rendered STATE_ALL = (1<<5)-1 }; - typedef boost::intrusive::list ChildrenList; - DrawingItem(Drawing *drawing); + DrawingItem(Drawing &drawing); virtual ~DrawingItem(); Geom::OptIntRect geometricBounds() const { return _bbox; } @@ -69,7 +60,7 @@ public: Geom::OptRect itemBounds() const { return _item_bbox; } Geom::Affine ctm() const { return _ctm; } Geom::Affine transform() const { return _transform ? *_transform : Geom::identity(); } - Drawing *drawing() const { return _drawing; } + Drawing &drawing() const { return _drawing; } DrawingItem *parent() const; void appendChild(DrawingItem *item); @@ -112,11 +103,21 @@ protected: virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky = false) { return NULL; } virtual bool _canClip() { return false; } - Drawing *_drawing; + // member variables start here + + Drawing &_drawing; DrawingItem *_parent; + + typedef boost::intrusive::list_member_hook<> ListHook; + ListHook _child_hook; + + typedef boost::intrusive::list< + DrawingItem, + boost::intrusive::member_hook + > ChildrenList; ChildrenList _children; - unsigned _key; ///< Some SPItems can have more than one NRArenaItem; + unsigned _key; ///< Some SPItems can have more than one DrawingItem; /// this value is a hack used to distinguish between them float _opacity; @@ -140,12 +141,14 @@ protected: //unsigned _renders_opacity : 1; ///< Whether object needs temporary surface for opacity unsigned _clip_child : 1; ///< If set, this is not a child of _parent, but a clipping path unsigned _mask_child : 1; ///< If set, this is not a child of _parent, but a mask + unsigned _drawing_root : 1; ///< If set, this is the root item of Drawing unsigned _pick_children : 1; ///< For groups: if true, children are returned from pick(), /// otherwise the group is returned - // temporary hacks until I rewrite NRArena to Inkscape::Drawing - friend class NRArena; - friend void ::nr_arena_set_cache_limit(NRArena *, Geom::OptIntRect const &); + friend class Drawing; + +private: + DrawingItem(DrawingItem const &); }; struct DeleteDisposer { diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 602aa2515..1e41bf5dd 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -19,10 +19,10 @@ #include "display/canvas-arena.h" #include "display/canvas-bpath.h" #include "display/curve.h" +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-group.h" #include "display/drawing-shape.h" -#include "display/nr-arena.h" #include "helper/geom-curves.h" #include "helper/geom.h" #include "libnr/nr-convert2geom.h" @@ -32,7 +32,7 @@ namespace Inkscape { -DrawingShape::DrawingShape(Drawing *drawing) +DrawingShape::DrawingShape(Drawing &drawing) : DrawingItem(drawing) , _curve(NULL) , _style(NULL) @@ -112,7 +112,7 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } boundingbox = Geom::OptRect(); - bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); // clear Cairo data to force update _nrstyle.update(); @@ -163,10 +163,10 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne if (!_curve || !_style) return; if (!area.intersects(_bbox)) return; // skip if not within bounding box - bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); if (outline) { - guint32 rgba = _drawing->outlinecolor; + guint32 rgba = _drawing.outlinecolor; { Inkscape::DrawingContext::Save save(ct); ct.transform(_ctm); @@ -243,7 +243,7 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) if (!_curve) return NULL; if (!_style) return NULL; - bool outline = (_drawing->rendermode == RENDERMODE_OUTLINE); + bool outline = _drawing.outline(); if (SP_SCALE24_TO_FLOAT(_style->opacity.value) == 0 && !outline) // fully transparent, no pick unless outline mode @@ -267,8 +267,8 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) bool needfill = (_nrstyle.fill.type != NRStyle::PAINT_NONE && _nrstyle.fill.opacity > 1e-3 && !outline); - if (_drawing->canvasarena) { - Geom::Rect viewbox = _drawing->canvasarena->item.canvas->getViewbox(); + if (_drawing.arena()) { + Geom::Rect viewbox = _drawing.arena()->item.canvas->getViewbox(); viewbox.expandBy (width); pathv_matrix_point_bbox_wind_distance(_curve->get_pathvector(), _ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, &viewbox); } else { diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 4b7b75e2a..153dcd54e 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -24,7 +24,7 @@ class DrawingShape : public DrawingItem { public: - DrawingShape(Drawing *drawing); + DrawingShape(Drawing &drawing); ~DrawingShape(); void setPath(SPCurve *curve); diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 5fc732779..2f0881c49 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -11,17 +11,17 @@ #include "display/cairo-utils.h" #include "display/canvas-bpath.h" // for SPWindRule (WTF!) +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-surface.h" #include "display/drawing-text.h" -#include "display/nr-arena.h" #include "helper/geom.h" #include "libnrtype/font-instance.h" #include "style.h" namespace Inkscape { -DrawingGlyphs::DrawingGlyphs(Drawing *drawing) +DrawingGlyphs::DrawingGlyphs(Drawing &drawing) : DrawingItem(drawing) , _glyph_transform(NULL) , _font(NULL) @@ -115,7 +115,7 @@ DrawingGlyphs::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) -DrawingText::DrawingText(Drawing *drawing) +DrawingText::DrawingText(Drawing &drawing) : DrawingGroup(drawing) {} @@ -164,9 +164,9 @@ DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, un void DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { - if (_drawing->rendermode == RENDERMODE_OUTLINE) { + if (_drawing.outline()) { DrawingContext::Save save(ct); - guint32 rgba = _drawing->outlinecolor; + guint32 rgba = _drawing.outlinecolor; ct.setSource(rgba); ct.setTolerance(1.25); // low quality, but good enough for outline mode ct.newPath(); diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index f95a5073c..671f8f64e 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -24,7 +24,7 @@ class DrawingGlyphs : public DrawingItem { public: - DrawingGlyphs(Drawing *drawing); + DrawingGlyphs(Drawing &drawing); ~DrawingGlyphs(); void setGlyph(font_instance *font, int glyph, Geom::Affine const &trans); @@ -46,7 +46,7 @@ class DrawingText : public DrawingGroup { public: - DrawingText(Drawing *drawing); + DrawingText(Drawing &drawing); ~DrawingText(); void clear(); diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp new file mode 100644 index 000000000..22bd84587 --- /dev/null +++ b/src/display/drawing.cpp @@ -0,0 +1,159 @@ +/** + * @file + * @brief SVG drawing for display + *//* + * Authors: + * Krzysztof Kosiński + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/drawing.h" +#include "nr-filter-gaussian.h" +#include "nr-filter-types.h" + +namespace Inkscape { + +Drawing::Drawing(SPCanvasArena *arena) + : _root(NULL) + , outlinecolor(0x000000ff) + , delta(0) + , _exact(false) + , _rendermode(RENDERMODE_NORMAL) + , _colormode(COLORMODE_NORMAL) + , _blur_quality(BLUR_QUALITY_BEST) + , _filter_quality(Filters::FILTER_QUALITY_BEST) + , _canvasarena(arena) +{ + +} + +Drawing::~Drawing() +{ + delete _root; +} + +void +Drawing::setRoot(DrawingItem *item) +{ + delete _root; + _root = item; + _root->_drawing_root = true; +} + +RenderMode +Drawing::renderMode() const +{ + return _exact ? RENDERMODE_NORMAL : _rendermode; +} +ColorMode +Drawing::colorMode() const +{ + return (outline() || _exact) ? COLORMODE_NORMAL : _colormode; +} +bool +Drawing::outline() const +{ + return renderMode() == RENDERMODE_OUTLINE; +} +bool +Drawing::renderFilters() const +{ + return renderMode() == RENDERMODE_NORMAL; +} +int +Drawing::blurQuality() const +{ + if (renderMode() == RENDERMODE_NORMAL) { + return _exact ? BLUR_QUALITY_BEST : _blur_quality; + } else { + return BLUR_QUALITY_WORST; + } +} +int +Drawing::filterQuality() const +{ + if (renderMode() == RENDERMODE_NORMAL) { + return _exact ? Filters::FILTER_QUALITY_BEST : _filter_quality; + } else { + return Filters::FILTER_QUALITY_WORST; + } +} + +void +Drawing::setRenderMode(RenderMode mode) +{ + _rendermode = mode; +} +void +Drawing::setColorMode(ColorMode mode) +{ + _colormode = mode; +} +void +Drawing::setBlurQuality(int q) +{ + _blur_quality = q; +} +void +Drawing::setFilterQuality(int q) +{ + _filter_quality = q; +} +void +Drawing::setExact(bool e) +{ + _exact = e; +} + +Geom::OptIntRect const & +Drawing::cacheLimit() const +{ + return _cache_limit; +} +void +Drawing::setCacheLimit(Geom::OptIntRect const &r) +{ + _cache_limit = r; + for (std::set::iterator i = _cached_items.begin(); + i != _cached_items.end(); ++i) + { + (*i)->_markForUpdate(DrawingItem::STATE_CACHE, false); + } +} + +void +Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +{ + // TODO add autocache + if (!_root) return; + _root->update(area, ctx, flags, reset); +} + +void +Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + if (!_root) return; + _root->render(ct, area, flags); +} + +DrawingItem * +Drawing::pick(Geom::Point const &p, double delta, bool sticky) +{ + if (!_root) return NULL; + return _root->pick(p, delta, sticky); +} + +} // end namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/drawing.h b/src/display/drawing.h new file mode 100644 index 000000000..4560d277d --- /dev/null +++ b/src/display/drawing.h @@ -0,0 +1,103 @@ +/** + * @file + * @brief SVG drawing for display + *//* + * Authors: + * Krzysztof Kosiński + * + * Copyright (C) 2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_H +#define SEEN_INKSCAPE_DISPLAY_DRAWING_H + +#include +#include +#include +#include <2geom/rect.h> +#include "display/display-forward.h" +#include "display/drawing-item.h" +#include "display/rendermode.h" + +namespace Inkscape { + +struct OutlineColors { + guint32 paths; + guint32 clippaths; + guint32 masks; + guint32 images; +}; + +class Drawing + : boost::noncopyable +{ +public: + Drawing(SPCanvasArena *arena = NULL); + ~Drawing(); + + DrawingItem *root() { return _root; } + SPCanvasArena *arena() { return _canvasarena; } + void setRoot(DrawingItem *item); + + RenderMode renderMode() const; + ColorMode colorMode() const; + bool outline() const; + bool renderFilters() const; + int blurQuality() const; + int filterQuality() const; + void setRenderMode(RenderMode mode); + void setColorMode(ColorMode mode); + void setBlurQuality(int q); + void setFilterQuality(int q); + void setExact(bool e); + + Geom::OptIntRect const &cacheLimit() const; + void setCacheLimit(Geom::OptIntRect const &r); + + OutlineColors const &colors() const { return _colors; } + + void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = DrawingItem::STATE_ALL, unsigned reset = 0); + void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); + DrawingItem *pick(Geom::Point const &p, double delta, bool sticky); + + sigc::signal signal_request_update; + sigc::signal signal_request_render; + sigc::signal signal_item_deleted; + +private: + DrawingItem *_root; + std::set _cached_items; +public: + // TODO: remove these temporarily public members + guint32 outlinecolor; + double delta; +private: + bool _exact; // if true then rendering must be exact + RenderMode _rendermode; + ColorMode _colormode; + int _blur_quality; + int _filter_quality; + Geom::OptIntRect _cache_limit; + + OutlineColors _colors; + + SPCanvasArena *_canvasarena; // may be NULL is this arena is not the screen but used for export etc. + + friend class DrawingItem; +}; + +} // end namespace Inkscape + +#endif // !SEEN_INKSCAPE_DRAWING_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp deleted file mode 100644 index b3e962201..000000000 --- a/src/display/nr-arena.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#define __NR_ARENA_C__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/drawing-item.h" -#include "display/nr-arena.h" -#include "display/nr-filter-gaussian.h" -#include "display/nr-filter-types.h" -#include "preferences.h" -#include "color.h" -#include "libnr/nr-rect.h" -#include "libnr/nr-rect-l.h" - -static void nr_arena_class_init (NRArenaClass *klass); -static void nr_arena_init (NRArena *arena); -static void nr_arena_finalize (NRObject *object); - -static NRActiveObjectClass *parent_class; - -NRType -nr_arena_get_type (void) -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type (NR_TYPE_ACTIVE_OBJECT, - "NRArena", - sizeof (NRArenaClass), - sizeof (NRArena), - (void (*) (NRObjectClass *)) nr_arena_class_init, - (void (*) (NRObject *)) nr_arena_init); - } - return type; -} - -static void -nr_arena_class_init (NRArenaClass *klass) -{ - NRObjectClass *object_class = (NRObjectClass *) klass; - - parent_class = (NRActiveObjectClass *) (((NRObjectClass *) klass)->parent); - - object_class->finalize = nr_arena_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; -} - -static void -nr_arena_init (NRArena *arena) -{ - arena->delta = 0; // to be set by desktop from prefs - arena->renderoffscreen = false; // use render values from preferences otherwise render exact - arena->rendermode = Inkscape::RENDERMODE_NORMAL; // default is normal render - arena->colormode = Inkscape::COLORMODE_NORMAL; // default is normal color - arena->blurquality = BLUR_QUALITY_NORMAL; - arena->filterquality = Inkscape::Filters::FILTER_QUALITY_NORMAL; - arena->outlinecolor = 0xff; // black; to be set by desktop from bg color - arena->canvasarena = NULL; -} - -static void -nr_arena_finalize (NRObject *object) -{ - ((NRObjectClass *) (parent_class))->finalize (object); -} - -void -nr_arena_request_update (NRArena *arena, Inkscape::DrawingItem *item) -{ - NRActiveObject *aobject = (NRActiveObject *) arena; - - nr_return_if_fail (arena != NULL); - nr_return_if_fail (NR_IS_ARENA (arena)); - nr_return_if_fail (item != NULL); - - // setup render parameter - if (arena->renderoffscreen == false) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - arena->blurquality = prefs->getInt("/options/blurquality/value", 0); - arena->filterquality = prefs->getInt("/options/filterquality/value", 0); - } else { - arena->blurquality = BLUR_QUALITY_BEST; - arena->filterquality = Inkscape::Filters::FILTER_QUALITY_BEST; - arena->rendermode = Inkscape::RENDERMODE_NORMAL; - arena->colormode = Inkscape::COLORMODE_NORMAL; - } - - if (aobject->callbacks) { - for (unsigned int i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener = aobject->callbacks->listeners + i; - NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector; - if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_update) { - avector->request_update (arena, item, listener->data); - } - } - } -} - -void -nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area) -{ - NRActiveObject *aobject = (NRActiveObject *) arena; - - nr_return_if_fail (arena != NULL); - nr_return_if_fail (NR_IS_ARENA (arena)); - if (!area) return; - - // setup render parameter - if (arena->renderoffscreen == false) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - arena->blurquality = prefs->getInt("/options/blurquality/value", 0); - arena->filterquality = prefs->getInt("/options/filterquality/value", 0); - } else { - arena->blurquality = BLUR_QUALITY_BEST; - arena->filterquality = Inkscape::Filters::FILTER_QUALITY_BEST; - arena->rendermode = Inkscape::RENDERMODE_NORMAL; - arena->colormode = Inkscape::COLORMODE_NORMAL; - } - NRRectL nr_area(*area); - if (aobject->callbacks) { - for (unsigned int i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener = aobject->callbacks->listeners + i; - NRArenaEventVector *avector = (NRArenaEventVector *) listener->vector; - if ((listener->size >= sizeof (NRArenaEventVector)) && avector->request_render) { - avector->request_render (arena, &nr_area, listener->data); - } - } - } -} - -/** - set arena to offscreen mode - rendering will be exact - @param arena NRArena object -*/ -void -nr_arena_set_renderoffscreen (NRArena *arena) -{ - nr_return_if_fail (arena != NULL); - nr_return_if_fail (NR_IS_ARENA (arena)); - - // the real assignment to the quality indicators is in the update function - arena->renderoffscreen = true; - -} - -void -nr_arena_set_cache_limit (NRArena *arena, Geom::OptIntRect const &cache_limit) -{ - arena->cache_limit = cache_limit; - for (std::set::iterator i = arena->cached_items.begin(); - i != arena->cached_items.end(); ++i) - { - (*i)->_markForUpdate(Inkscape::DrawingItem::STATE_CACHE, false); - } -} - -#define FLOAT_TO_UINT8(f) (int(f*255)) -#define RGBA_R(v) ((v) >> 24) -#define RGBA_G(v) (((v) >> 16) & 0xff) -#define RGBA_B(v) (((v) >> 8) & 0xff) -#define RGBA_A(v) ((v) & 0xff) - -void nr_arena_separate_color_plates(guint32* rgba){ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool render_cyan = prefs->getBool("/options/printcolorspreview/cyan", true); - bool render_magenta = prefs->getBool("/options/printcolorspreview/magenta", true); - bool render_yellow = prefs->getBool("/options/printcolorspreview/yellow", true); - bool render_black = prefs->getBool("/options/printcolorspreview/black", true); - - float rgb_v[3]; - float cmyk_v[4]; - sp_color_rgb_to_cmyk_floatv (cmyk_v, RGBA_R(*rgba)/256.0, RGBA_G(*rgba)/256.0, RGBA_B(*rgba)/256.0); - sp_color_cmyk_to_rgb_floatv (rgb_v, render_cyan ? cmyk_v[0] : 0, - render_magenta ? cmyk_v[1] : 0, - render_yellow ? cmyk_v[2] : 0, - render_black ? cmyk_v[3] : 0); - *rgba = (FLOAT_TO_UINT8(rgb_v[0])<<24) + (FLOAT_TO_UINT8(rgb_v[1])<<16) + (FLOAT_TO_UINT8(rgb_v[2])<<8) + 0xff; -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h deleted file mode 100644 index a444ed505..000000000 --- a/src/display/nr-arena.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __NR_ARENA_H__ -#define __NR_ARENA_H__ - -/* - * RGBA display list system for inkscape - * - * Author: - * Lauris Kaplinski - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include -#include -#include <2geom/rect.h> -#include "display/rendermode.h" -#include "libnr/nr-forward.h" -#include "libnr/nr-object.h" -#include "display/display-forward.h" - -G_BEGIN_DECLS - -typedef struct _SPCanvasArena SPCanvasArena; - -G_END_DECLS - -#define NR_TYPE_ARENA (nr_arena_get_type ()) -#define NR_ARENA(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ARENA, NRArena)) -#define NR_IS_ARENA(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ARENA)) - -class SPPainter; - -NRType nr_arena_get_type (void); - -struct NRArenaEventVector { - NRObjectEventVector parent; - void (* request_update) (NRArena *arena, Inkscape::DrawingItem *item, void *data); - void (* request_render) (NRArena *arena, NRRectL *area, void *data); -}; - -struct NRArena : public NRActiveObject { - static NRArena *create() { - return reinterpret_cast(nr_object_new(NR_TYPE_ARENA)); - } - - double delta; - bool renderoffscreen; // if true then rendering must be exact - Inkscape::RenderMode rendermode; - Inkscape::ColorMode colormode; - int blurquality; // will be updated during update from preferences - int filterquality; // will be updated during update from preferences - Geom::OptIntRect cache_limit; - std::set cached_items; - - guint32 outlinecolor; - SPCanvasArena *canvasarena; // may be NULL is this arena is not the screen but used for export etc. - - sigc::signal item_deleted; -}; - -struct NRArenaClass : public NRActiveObjectClass { -}; - -void nr_arena_request_update (NRArena *arena, Inkscape::DrawingItem *item); -void nr_arena_request_render_rect (NRArena *arena, Geom::OptIntRect const &area); -void nr_arena_set_renderoffscreen (NRArena *arena); -void nr_arena_set_cache_limit (NRArena *arena, Geom::OptIntRect const &cache_limit); - -void nr_arena_separate_color_plates(guint32* rgba); - -#endif diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 55cd02697..b176cdcef 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -14,7 +14,7 @@ #include "sp-item.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-item.h" #include "display/nr-filter.h" #include "display/nr-filter-image.h" @@ -73,18 +73,17 @@ void FilterImage::render_cairo(FilterSlot &slot) // like the one for DrawingItems document->ensureUpToDate(); - NRArena* arena = NRArena::create(); + Drawing drawing; Geom::OptRect optarea = SVGElem->getBounds(Geom::identity()); if (!optarea) return; unsigned const key = SPItem::display_key_new(1); - DrawingItem *ai = SVGElem->invoke_show(arena, key, SP_ITEM_SHOW_DISPLAY); - + DrawingItem *ai = SVGElem->invoke_show(drawing, key, SP_ITEM_SHOW_DISPLAY); if (!ai) { - g_warning("feImage renderer: error creating NRArenaItem for SVG Element"); - nr_object_unref((NRObject *) arena); + g_warning("feImage renderer: error creating DrawingItem for SVG Element"); return; } + drawing.setRoot(ai); Geom::Rect area = *optarea; Geom::Affine pu2pb = slot.get_units().get_matrix_primitiveunits2pb(); @@ -104,13 +103,9 @@ void FilterImage::render_cairo(FilterSlot &slot) ct.translate(render_rect.min()); // Update to renderable state - UpdateContext ctx; - ai->setTransform(Geom::identity()); - ai->update(render_rect, ctx, DrawingItem::STATE_ALL, 0); - ai->render(ct, render_rect, DrawingItem::RENDER_BYPASS_CACHE); + drawing.update(render_rect); + drawing.render(ct, render_rect); SVGElem->invoke_hide(key); - //delete ai; // should be deleted by hide() above - nr_object_unref((NRObject*) arena); slot.set(_output, out); cairo_surface_destroy(out); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index abd102452..e84e6f0c2 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -38,7 +38,7 @@ #include "display/nr-filter-tile.h" #include "display/nr-filter-turbulence.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-item.h" #include "display/drawing-context.h" #include <2geom/affine.h> @@ -108,8 +108,8 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &bgct, Draw return 1; } - FilterQuality const filterquality = (FilterQuality)item->drawing()->filterquality; - int const blurquality = item->drawing()->blurquality; + FilterQuality const filterquality = (FilterQuality)item->drawing().filterQuality(); + int const blurquality = item->drawing().blurQuality(); Geom::Affine trans = item->ctm(); diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index 4b551e730..678a46095 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -27,7 +27,7 @@ #include "extension/print.h" #include "extension/db.h" #include "extension/output.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/curve.h" #include "display/canvas-bpath.h" @@ -56,11 +56,11 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) doc->ensureUpToDate(); /* Start */ - // Create new arena + SPItem *base = doc->getRoot(); - NRArena *arena = NRArena::create(); + Inkscape::Drawing drawing; unsigned dkey = SPItem::display_key_new(1); - base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); + base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ renderer = new CairoRenderer(); @@ -75,9 +75,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) } renderer->destroyContext(ctx); - /* Release arena */ base->invoke_hide(dkey); - nr_object_unref((NRObject *) arena); /* end */ delete renderer; diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 7e5324e57..9cc3a4ce3 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -29,7 +29,7 @@ #include "extension/print.h" #include "extension/db.h" #include "extension/output.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/curve.h" #include "display/canvas-bpath.h" @@ -85,10 +85,9 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l if (!base) return false; - /* Create new arena */ - NRArena *arena = NRArena::create(); + Inkscape::Drawing drawing; unsigned dkey = SPItem::display_key_new(1); - base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); + base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ CairoRenderer *renderer = new CairoRenderer(); @@ -110,9 +109,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l } } - /* Release arena */ base->invoke_hide(dkey); - nr_object_unref((NRObject *) arena); renderer->destroyContext(ctx); delete renderer; diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index c7cba09bb..c3a8a790b 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -32,7 +32,7 @@ #include #include -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/display-forward.h" #include "display/curve.h" #include "display/canvas-bpath.h" @@ -1092,8 +1092,8 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver pattern_ctx->setTransform(&pcs2dev); pattern_ctx->pushState(); - // create arena and group - NRArena *arena = NRArena::create(); + // create drawing and group + Inkscape::Drawing drawing; unsigned dkey = SPItem::display_key_new(1); // show items and render them @@ -1101,7 +1101,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS); + SP_ITEM (child)->invoke_show (drawing, dkey, SP_ITEM_REFERENCE_FLAGS); _renderer->renderItem(pattern_ctx, SP_ITEM (child)); } } diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 5be9e15c3..7ea5718f7 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -29,7 +29,7 @@ #include "extension/print.h" #include "extension/db.h" #include "extension/output.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/curve.h" #include "display/canvas-bpath.h" @@ -81,10 +81,10 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int } /* Create new arena */ - NRArena *arena = NRArena::create(); - nr_arena_set_renderoffscreen (arena); + Inkscape::Drawing drawing; + drawing.setExact(true); unsigned dkey = SPItem::display_key_new(1); - base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); + base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ CairoRenderer *renderer = new CairoRenderer(); @@ -105,9 +105,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int } } - /* Release arena */ base->invoke_hide(dkey); - nr_object_unref((NRObject *) arena); renderer->destroyContext(ctx); delete renderer; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 76fc5073f..5e7fb991a 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -36,7 +36,6 @@ #include #include -#include "display/nr-arena.h" #include "display/display-forward.h" #include "display/curve.h" #include "display/canvas-bpath.h" diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 646b33507..aadfce86f 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -36,8 +36,8 @@ #include "extension/print.h" #include "extension/db.h" #include "extension/output.h" -#include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/drawing.h" +#include "display/drawing-item.h" #include "unit-constants.h" #include "clear-n_.h" @@ -106,9 +106,10 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename) /* fixme: This has to go into module constructor somehow */ /* Create new arena */ mod->base = doc->getRoot(); - mod->arena = NRArena::create(); + Inkscape::Drawing drawing; mod->dkey = SPItem::display_key_new(1); - mod->root = mod->base->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->root = mod->base->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY); + drawing.setRoot(mod->root); /* Print document */ ret = mod->begin(doc); if (ret) { @@ -120,9 +121,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename) /* Release arena */ mod->base->invoke_hide(mod->dkey); mod->base = NULL; - mod->root = NULL; - nr_object_unref((NRObject *) mod->arena); - mod->arena = NULL; + mod->root = NULL; // deleted by invoke_hide /* end */ mod->set_param_string("destination", oldoutput); diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 000280158..3a16268e6 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -18,8 +18,8 @@ #include "extension/system.h" #include "extension/print.h" #include "extension/db.h" -#include "display/nr-arena.h" #include "display/display-forward.h" +#include "display/drawing.h" #include "sp-root.h" @@ -61,21 +61,19 @@ void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, /* Start */ context.module = mod; /* fixme: This has to go into module constructor somehow */ - // Create new arena mod->base = doc->getRoot(); - mod->arena = NRArena::create(); + Inkscape::Drawing drawing; mod->dkey = SPItem::display_key_new (1); - mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->root = (mod->base)->invoke_show (drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY); + drawing.setRoot(mod->root); /* Print document */ ret = mod->begin (doc); (mod->base)->invoke_print (&context); ret = mod->finish (); - /* Release arena */ + /* Release things */ (mod->base)->invoke_hide (mod->dkey); mod->base = NULL; mod->root = NULL; // should have been deleted by invoke_hide - nr_object_unref ((NRObject *) mod->arena); - mod->arena = NULL; /* end */ mod->set_param_string("destination", oldoutput); diff --git a/src/extension/print.cpp b/src/extension/print.cpp index ad8c4c38d..f2dbb0b9b 100644 --- a/src/extension/print.cpp +++ b/src/extension/print.cpp @@ -15,25 +15,22 @@ namespace Inkscape { namespace Extension { -Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : Extension(in_repr, in_imp) +Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) + : Extension(in_repr, in_imp) + , base(NULL) + , drawing(NULL) + , root(NULL) + , dkey(0) { - base = NULL; - arena = NULL; - root = NULL; - dkey = 0; - - return; } Print::~Print (void) -{ - return; -} +{} bool Print::check (void) { - return Extension::check(); + return Extension::check(); } unsigned int @@ -108,14 +105,14 @@ Print::text (const char* text, Geom::Point p, const SPStyle* style) bool Print::textToPath (void) { - return imp->textToPath(this); + return imp->textToPath(this); } //whether embed font in print output (EPS especially) bool Print::fontEmbedded (void) { - return imp->fontEmbedded(this); + return imp->fontEmbedded(this); } } } /* namespace Inkscape, Extension */ diff --git a/src/extension/print.h b/src/extension/print.h index b3c686d26..c2276126b 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -23,7 +23,7 @@ class Print : public Extension { public: /* TODO: These are public for the short term, but this should be fixed */ SPItem *base; - NRArena *arena; + Inkscape::Drawing *drawing; Inkscape::DrawingItem *root; unsigned int dkey; diff --git a/src/flood-context.cpp b/src/flood-context.cpp index a71333a4f..8603f8b66 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -32,11 +32,10 @@ #include "desktop-handles.h" #include "desktop-style.h" #include "display/cairo-utils.h" -#include "display/canvas-arena.h" #include "display/drawing-context.h" #include "display/drawing-image.h" #include "display/drawing-item.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/sp-canvas.h" #include "document.h" #include "flood-context.h" @@ -777,10 +776,6 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even SPDesktop *desktop = event_context->desktop; SPDocument *document = sp_desktop_document(desktop); - /* Create new arena */ - NRArena *arena = NRArena::create(); - unsigned dkey = SPItem::display_key_new(1); - document->ensureUpToDate(); Geom::OptRect bbox = document->getRoot()->getBounds(Geom::identity()); @@ -809,20 +804,22 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even Geom::Scale scale(zoom_scale, zoom_scale); Geom::Affine affine = scale * Geom::Translate(-origin * scale); - - /* Create ArenaItems and set transform */ - Inkscape::DrawingItem *root = document->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); - root->setTransform(affine); - - Inkscape::UpdateContext ctx; - Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); - root->update(final_bbox, ctx, Inkscape::DrawingItem::STATE_ALL, 0); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); guchar *px = g_new(guchar, stride * height); guint32 bgcolor, dtc; - { // this block limits the lifetime of DrawingContext + { // this block limits the lifetime of Drawing and DrawingContext + /* Create DrawingItems and set transform */ + unsigned dkey = SPItem::display_key_new(1); + Inkscape::Drawing drawing; + Inkscape::DrawingItem *root = document->getRoot()->invoke_show( drawing, dkey, SP_ITEM_SHOW_DISPLAY); + root->setTransform(affine); + drawing.setRoot(root); + + Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); + drawing.update(final_bbox); + cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, width, height, stride); Inkscape::DrawingContext ct(s, Geom::Point(0,0)); @@ -838,15 +835,13 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even ct.paint(); ct.setOperator(CAIRO_OPERATOR_OVER); - root->render(ct, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(ct, final_bbox); cairo_surface_flush(s); cairo_surface_destroy(s); // Hide items document->getRoot()->invoke_hide(dkey); - - nr_object_unref((NRObject *) arena); } guchar *trace_px = g_new(guchar, width * height); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 959007450..3f987dc01 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -23,9 +23,9 @@ #include "interface.h" #include "helper/png-write.h" #include "display/cairo-utils.h" +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-item.h" -#include "display/nr-arena.h" #include "document.h" #include "sp-item.h" #include "sp-root.h" @@ -112,9 +112,9 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, if (width == 0 || height == 0) return NULL; GdkPixbuf* pixbuf = NULL; - /* Create new arena for offscreen rendering*/ - NRArena *arena = NRArena::create(); - nr_arena_set_renderoffscreen(arena); + /* Create new drawing for offscreen rendering*/ + Inkscape::Drawing drawing; + drawing.setExact(true); unsigned dkey = SPItem::display_key_new(1); doc->ensureUpToDate(); @@ -133,9 +133,9 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, Geom::Affine affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - Inkscape::DrawingItem *root = doc->getRoot()->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); + Inkscape::DrawingItem *root = doc->getRoot()->invoke_show( drawing, dkey, SP_ITEM_SHOW_DISPLAY); root->setTransform(affine); - Inkscape::UpdateContext ctx; + drawing.setRoot(root); // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs @@ -144,7 +144,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, } Geom::IntRect final_bbox = Geom::IntRect::from_xywh(0, 0, width, height); - root->update(final_bbox, ctx, Inkscape::DrawingItem::STATE_ALL, 0); + drawing.update(final_bbox); cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); @@ -152,7 +152,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, Inkscape::DrawingContext ct(surface, Geom::Point(0,0)); // render items - root->render(ct, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(ct, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(surface), GDK_COLORSPACE_RGB, TRUE, @@ -167,8 +167,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %lld.", size); cairo_surface_destroy(surface); } - doc->getRoot()->invoke_hide(dkey); - nr_object_unref((NRObject *) arena); + doc->getRoot()->invoke_hide(dkey); // gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 7812969a0..24da697c1 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -23,9 +23,9 @@ #include #include "png-write.h" #include "io/sys.h" +#include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-item.h" -#include "display/nr-arena.h" #include "document.h" #include "sp-item.h" #include "sp-root.h" @@ -51,7 +51,7 @@ static unsigned int const MAX_STRIPE_SIZE = 1024*1024; struct SPEBP { unsigned long int width, height, sheight; guint32 background; - Inkscape::DrawingItem *root; // the root arena item to show; it is assumed that all unneeded items are hidden + Inkscape::Drawing *drawing; // it is assumed that all unneeded items are hidden guchar *px; unsigned (*status)(float, void *); void *data; @@ -326,8 +326,7 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v Geom::IntRect bbox = Geom::IntRect::from_xywh(0, row, ebp->width, num_rows); /* Update to renderable state */ - Inkscape::UpdateContext ctx; - ebp->root->update(bbox, ctx, Inkscape::DrawingItem::STATE_ALL, 0); + ebp->drawing->update(bbox); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ebp->width); unsigned char *px = g_new(guchar, num_rows * stride); @@ -341,7 +340,7 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v ct.setOperator(CAIRO_OPERATOR_OVER); /* Render */ - ebp->root->render(ct, bbox, 0); + ebp->drawing->render(ct, bbox); cairo_surface_destroy(s); *to_free = px; @@ -451,15 +450,15 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, ebp.height = height; ebp.background = bgcolor; - /* Create new arena */ - NRArena *const arena = NRArena::create(); - // export with maximum blur rendering quality - nr_arena_set_renderoffscreen(arena); + /* Create new drawing */ + Inkscape::Drawing drawing; + drawing.setExact(true); // export with maximum blur rendering quality unsigned const dkey = SPItem::display_key_new(1); // Create ArenaItems and set transform - ebp.root = doc->getRoot()->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); - ebp.root->setTransform(affine); + drawing.setRoot(doc->getRoot()->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY)); + drawing.root()->setTransform(affine); + ebp.drawing = &drawing; // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs @@ -483,9 +482,6 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, // Hide items, this releases arenaitem doc->getRoot()->invoke_hide(dkey); - /* Free arena */ - nr_object_unref((NRObject *) arena); - return write_status; } diff --git a/src/marker.cpp b/src/marker.cpp index 11a270e73..c8fa9218d 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -43,7 +43,7 @@ static void sp_marker_set (SPObject *object, unsigned int key, const gchar *valu static void sp_marker_update (SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_marker_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static Inkscape::DrawingItem *sp_marker_private_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_marker_private_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_marker_private_hide (SPItem *item, unsigned int key); static void sp_marker_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_marker_print (SPItem *item, SPPrintContext *ctx); @@ -168,7 +168,7 @@ sp_marker_release (SPObject *object) marker = (SPMarker *) object; while (marker->views) { - /* Destroy all NRArenaitems etc. */ + /* Destroy all DrawingItems etc. */ /* Parent class ::hide method */ ((SPItemClass *) parent_class)->hide ((SPItem *) marker, marker->views->key); sp_marker_view_remove (marker, marker->views, TRUE); @@ -444,7 +444,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); } - // As last step set additional transform of arena group + // As last step set additional transform of drawing group for (SPMarkerView *v = marker->views; v != NULL; v = v->next) { for (unsigned i = 0 ; i < v->items.size() ; i++) { if (v->items[i]) { @@ -523,7 +523,7 @@ sp_marker_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X * This routine is disabled to break propagation. */ static Inkscape::DrawingItem * -sp_marker_private_show (SPItem */*item*/, NRArena */*arena*/, unsigned int /*key*/, unsigned int /*flags*/) +sp_marker_private_show (SPItem */*item*/, Inkscape::Drawing &/*drawing*/, unsigned int /*key*/, unsigned int /*flags*/) { /* Break propagation */ return NULL; @@ -599,7 +599,7 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) /** * Shows an instance of a marker. This is called during sp_shape_update_marker_view() - * show and transform a child item in the arena for all views with the given key. + * show and transform a child item in the drawing for all views with the given key. */ Inkscape::DrawingItem * sp_marker_show_instance ( SPMarker *marker, Inkscape::DrawingItem *parent, diff --git a/src/print.cpp b/src/print.cpp index 29c5b0ed2..2eadf0fa9 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -15,7 +15,7 @@ # include "config.h" #endif -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-item.h" #include "inkscape.h" #include "desktop.h" @@ -117,21 +117,20 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename) /* Start */ context.module = mod; /* fixme: This has to go into module constructor somehow */ - /* Create new arena */ + /* Create new drawing */ mod->base = doc->getRoot(); - mod->arena = NRArena::create(); + Inkscape::Drawing drawing; mod->dkey = SPItem::display_key_new(1); - mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->root = (mod->base)->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY); + drawing.setRoot(mod->root); /* Print document */ ret = mod->begin(doc); (mod->base)->invoke_print(&context); ret = mod->finish(); - /* Release arena */ + /* Release drawing items */ (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; - nr_object_unref((NRObject *) mod->arena); mod->root = NULL; // should be deleted by invoke_hide - mod->arena = NULL; /* end */ mod->set_param_string("destination", oldoutput); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 14c206828..0b3320e59 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -15,7 +15,7 @@ #include #include -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-group.h" #include "xml/repr.h" @@ -242,17 +242,14 @@ Inkscape::XML::Node *SPClipPath::write(SPObject *object, Inkscape::XML::Document return repr; } -Inkscape::DrawingItem *SPClipPath::show(NRArena *arena, unsigned int key) +Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int key) { - g_return_val_if_fail(arena != NULL, NULL); - g_return_val_if_fail(NR_IS_ARENA(arena), NULL); - - Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(arena); + Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); display = sp_clippath_view_new_prepend(display, key, ai); for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { if (SP_IS_ITEM(child)) { - Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); + Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in clippath */ ai->appendChild(ac); diff --git a/src/sp-clippath.h b/src/sp-clippath.h index d163e0709..11817eb77 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -40,7 +40,7 @@ public: static const gchar *create(GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); static GType sp_clippath_get_type(void); - Inkscape::DrawingItem *show(NRArena *arena, unsigned int key); + Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned int key); void hide(unsigned int key); void setBBox(unsigned int key, NRRect *bbox); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index cbdc8684b..710f799a5 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -50,7 +50,7 @@ static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine cons static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_flowtext_description(SPItem *item); static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -static Inkscape::DrawingItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); +static Inkscape::DrawingItem *sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); static void sp_flowtext_hide(SPItem *item, unsigned key); static SPItemClass *parent_class; @@ -409,10 +409,10 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vectorsetPickChildren(false); flowed->setStyle(group->style); diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index d06105c30..de41ba47f 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -31,7 +31,7 @@ struct SPFlowtext : public SPItem { //semiprivate: (need to be accessed by the C-style functions still) Inkscape::Text::Layout layout; - /** discards the NRArena objects representing this text. */ + /** discards the drawing objects representing this text. */ void _clearFlow(Inkscape::DrawingGroup* in_arena); double par_indent; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 3a1280aa0..225cccfca 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -84,7 +84,7 @@ static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const & static void sp_image_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_image_description (SPItem * item); static void sp_image_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -static Inkscape::DrawingItem *sp_image_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_image_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static Geom::Affine sp_image_set_transform (SPItem *item, Geom::Affine const &xform); static void sp_image_set_curve(SPImage *image); @@ -1149,10 +1149,10 @@ static gchar *sp_image_description( SPItem *item ) return ret; } -static Inkscape::DrawingItem *sp_image_show( SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/ ) +static Inkscape::DrawingItem *sp_image_show( SPItem *item, Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/ ) { SPImage * image = SP_IMAGE(item); - Inkscape::DrawingImage *ai = new Inkscape::DrawingImage(arena); + Inkscape::DrawingImage *ai = new Inkscape::DrawingImage(drawing); sp_image_update_arenaitem(image, ai); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index c27319c83..f8ab0460a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -68,7 +68,7 @@ static void sp_group_set(SPObject *object, unsigned key, char const *value); static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_group_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_group_description (SPItem * item); -static Inkscape::DrawingItem *sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_group_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_group_hide (SPItem * item, unsigned int key); static void sp_group_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); @@ -313,9 +313,9 @@ static void sp_group_set(SPObject *object, unsigned key, char const *value) { } static Inkscape::DrawingItem * -sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) +sp_group_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { - return SP_GROUP(item)->group->show(arena, key, flags); + return SP_GROUP(item)->group->show(drawing, key, flags); } static void @@ -744,19 +744,19 @@ gchar *CGroup::getDescription() { len), len); } -Inkscape::DrawingItem *CGroup::show (NRArena *arena, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem *CGroup::show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { Inkscape::DrawingGroup *ai; SPObject *object = _group; - ai = new Inkscape::DrawingGroup(arena); + ai = new Inkscape::DrawingGroup(drawing); ai->setPickChildren(_group->effectiveLayerMode(key) == SPGroup::LAYER); ai->setStyle(object->style); - _showChildren(arena, ai, key, flags); + _showChildren(drawing, ai, key, flags); return ai; } -void CGroup::_showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { +void CGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { Inkscape::DrawingItem *ac = NULL; SPItem * child = NULL; GSList *l = g_slist_reverse(_group->childList(false, SPObject::ActionShow)); @@ -764,7 +764,7 @@ void CGroup::_showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM (o)) { child = SP_ITEM (o); - ac = child->invoke_show (arena, key, flags); + ac = child->invoke_show (drawing, key, flags); ai->appendChild(ac); } l = g_slist_remove (l, o); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 88586a6b0..99f375e44 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -73,13 +73,13 @@ public: virtual void onPrint(SPPrintContext *ctx); virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); virtual gchar *getDescription(); - virtual Inkscape::DrawingItem *show (NRArena *arena, unsigned int key, unsigned int flags); + virtual Inkscape::DrawingItem *show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide (unsigned int key); gint getItemCount(); protected: - virtual void _showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); + virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); SPGroup *_group; }; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9ab924423..bd3802dd3 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -29,7 +29,6 @@ #include "sp-item.h" #include "svg/svg.h" #include "print.h" -#include "display/nr-arena.h" #include "display/drawing-item.h" #include "attributes.h" #include "document.h" @@ -513,7 +512,6 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) /* Hide clippath */ for (v = item->display; v != NULL; v = v->next) { SP_CLIPPATH(old_clip)->hide(v->arenaitem->key()); - v->arenaitem->setClip(NULL); } } if (SP_IS_CLIPPATH(clip)) { @@ -539,7 +537,6 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) /* Hide mask */ for (SPItemView *v = item->display; v != NULL; v = v->next) { sp_mask_hide(SP_MASK(old_mask), v->arenaitem->key()); - v->arenaitem->setMask(NULL); } } if (SP_IS_MASK(mask)) { @@ -1017,14 +1014,11 @@ unsigned SPItem::display_key_new(unsigned numkeys) return dkey - numkeys; } -Inkscape::DrawingItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) +Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { - g_assert(arena != NULL); - g_assert(NR_IS_ARENA(arena)); - Inkscape::DrawingItem *ai = NULL; if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) { - ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, arena, key, flags); + ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, drawing, key, flags); } if (ai != NULL) { @@ -1042,7 +1036,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigne int clip_key = display->arenaitem->key(); // Show and set clip - Inkscape::DrawingItem *ac = cp->show(arena, clip_key); + Inkscape::DrawingItem *ac = cp->show(drawing, clip_key); ai->setClip(ac); // Update bbox, in case the clip uses bbox units @@ -1060,7 +1054,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigne int mask_key = display->arenaitem->key(); // Show and set mask - Inkscape::DrawingItem *ac = sp_mask_show(mask, arena, mask_key); + Inkscape::DrawingItem *ac = sp_mask_show(mask, drawing, mask_key); ai->setMask(ac); // Update bbox, in case the mask uses bbox units diff --git a/src/sp-item.h b/src/sp-item.h index f8cc948bb..633deb508 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -181,7 +181,7 @@ public: gchar *description(); void invoke_print(SPPrintContext *ctx); static unsigned int display_key_new(unsigned int numkeys); - Inkscape::DrawingItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); + Inkscape::DrawingItem *invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); void invoke_hide(unsigned int key); void getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs=0) const; void adjust_pattern(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false); @@ -246,7 +246,7 @@ public: /** Give short description of item (for status display) */ gchar * (* description) (SPItem * item); - Inkscape::DrawingItem * (* show) (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); + Inkscape::DrawingItem * (* show) (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); void (* hide) (SPItem *item, unsigned int key); /** Write to an iterator the points that should be considered for snapping diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index f23be6fc5..f23172a17 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -15,7 +15,7 @@ #include #include <2geom/transforms.h> -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-group.h" #include "xml/repr.h" @@ -297,19 +297,17 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTr return mask_id; } -Inkscape::DrawingItem *sp_mask_show(SPMask *mask, NRArena *arena, unsigned int key) +Inkscape::DrawingItem *sp_mask_show(SPMask *mask, Inkscape::Drawing &drawing, unsigned int key) { g_return_val_if_fail (mask != NULL, NULL); g_return_val_if_fail (SP_IS_MASK (mask), NULL); - g_return_val_if_fail (arena != NULL, NULL); - g_return_val_if_fail (NR_IS_ARENA (arena), NULL); - Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(arena); + Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); mask->display = sp_mask_view_new_prepend (mask->display, key, ai); for ( SPObject *child = mask->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS); + Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { ai->prependChild(ac); } diff --git a/src/sp-mask.h b/src/sp-mask.h index e7a4723cf..b1048e6be 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -90,7 +90,7 @@ protected: } }; -Inkscape::DrawingItem *sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key); +Inkscape::DrawingItem *sp_mask_show (SPMask *mask, Inkscape::Drawing &drawing, unsigned int key); void sp_mask_hide (SPMask *mask, unsigned int key); void sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 805a93267..9aefdf6ff 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -24,7 +24,7 @@ #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/drawing-surface.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" @@ -630,17 +630,18 @@ sp_pattern_create_pattern(SPPaintServer *ps, return cairo_pattern_create_rgba(0,0,0,0); } - /* Create arena */ - NRArena *arena = NRArena::create(); + /* Create drawing for rendering */ + Inkscape::Drawing drawing; unsigned int dkey = SPItem::display_key_new (1); - Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(arena); + Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); + drawing.setRoot(root); for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - // for each item in pattern, show it on our arena, add to the group, + // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted Inkscape::DrawingItem *cai; - cai = SP_ITEM(child)->invoke_show (arena, dkey, SP_ITEM_SHOW_DISPLAY); + cai = SP_ITEM(child)->invoke_show (drawing, dkey, SP_ITEM_SHOW_DISPLAY); root->appendChild(cai); } } @@ -676,7 +677,10 @@ sp_pattern_create_pattern(SPPaintServer *ps, // oversample the pattern slightly // TODO: find optimum value - Geom::Point c(pattern_tile.dimensions()*ps2user.descrim()*full.descrim()*1.1); + // TODO: this is lame. instead of using descrim(), we should extract + // the scaling component from the complete matrix and use it + // to find the optimum tile size for rendering + Geom::Point c(pattern_tile.dimensions()*vb2ps.descrim()*ps2user.descrim()*full.descrim()*1.1); c[Geom::X] = ceil(c[Geom::X]); c[Geom::Y] = ceil(c[Geom::Y]); @@ -692,15 +696,13 @@ sp_pattern_create_pattern(SPPaintServer *ps, // TODO: make sure there are no leaks. Inkscape::UpdateContext ctx; ctx.ctm = vb2ps; - root->update(Geom::IntRect::infinite(), ctx, Inkscape::DrawingItem::STATE_ALL, 0); - root->render(ct, one_tile, 0); + drawing.update(Geom::IntRect::infinite(), ctx); + drawing.render(ct, one_tile); for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { SP_ITEM(child)->invoke_hide(dkey); } } - nr_object_unref(arena); - delete root; if (needs_opacity) { ct.popGroupToSource(); // pop raw pattern diff --git a/src/sp-root.cpp b/src/sp-root.cpp index bbb12f5d3..a6df580d3 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -46,7 +46,7 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_root_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static Inkscape::DrawingItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_root_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_root_print(SPItem *item, SPPrintContext *ctx); static SPGroupClass *parent_class; @@ -538,7 +538,7 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) if (((SPObjectClass *) (parent_class))->update) ((SPObjectClass *) (parent_class))->update(object, (SPCtx *) &rctx, flags); - /* As last step set additional transform of arena group */ + /* As last step set additional transform of drawing group */ for (SPItemView *v = root->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); g->setChildTransform(root->c2p); @@ -608,16 +608,16 @@ sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: } /** - * Displays the SPRoot item on the NRArena. + * Displays the SPRoot item on the drawing. */ static Inkscape::DrawingItem * -sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) +sp_root_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { SPRoot *root = SP_ROOT(item); Inkscape::DrawingItem *ai; if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show(item, arena, key, flags); + ai = ((SPItemClass *) (parent_class))->show(item, drawing, key, flags); if (ai) { Inkscape::DrawingGroup *g = dynamic_cast(ai); g->setChildTransform(root->c2p); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 1512898f5..eff0665af 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -852,12 +852,12 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) /** * Sets style, path, and paintbox. Updates marker views, including dimensions. */ -Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) +Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { SPObject *object = item; SPShape *shape = SP_SHAPE(item); - Inkscape::DrawingShape *s = new Inkscape::DrawingShape(arena); + Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); s->setStyle(object->style); s->setPath(shape->curve); Geom::OptRect paintbox = item->getBounds(Geom::identity()); @@ -1015,8 +1015,6 @@ sp_shape_marker_release (SPObject *marker, SPShape *shape) /* Hide marker */ for (v = item->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) (shape->marker[i]), v->arenaitem->key() + i); - /* fixme: Do we need explicit remove here? (Lauris) */ - /* v->arenaitem->setMask(NULL); */ } /* Detach marker */ shape->release_connect[i].disconnect(); @@ -1066,8 +1064,6 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value) for (v = item->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) (shape->marker[key]), v->arenaitem->key() + key); - /* fixme: Do we need explicit remove here? (Lauris) */ - /* v->arenaitem->setMask(NULL); */ } /* Unref marker */ diff --git a/src/sp-shape.h b/src/sp-shape.h index 4da2d5a2d..355d8e7cc 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -67,7 +67,7 @@ private: static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); - static Inkscape::DrawingItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); + static Inkscape::DrawingItem *sp_shape_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_shape_hide (SPItem *item, unsigned int key); static void sp_shape_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index bb1495387..500e43c9c 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -117,7 +117,7 @@ void CSwitch::onOrderChanged (Inkscape::XML::Node *, Inkscape::XML::Node *, Inks _reevaluate(); } -void CSwitch::_reevaluate(bool /*add_to_arena*/) { +void CSwitch::_reevaluate(bool /*add_to_drawing*/) { SPObject *evaluated_child = _evaluateFirst(); if (!evaluated_child || _cached_item == evaluated_child) { return; @@ -157,7 +157,7 @@ void CSwitch::_releaseLastItem(SPObject *obj) _cached_item = NULL; } -void CSwitch::_showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { +void CSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = _evaluateFirst(); GSList *l = _childList(false, SPObject::ActionShow); @@ -166,7 +166,7 @@ void CSwitch::_showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); child->setEvaluated(o == evaluated_child); - Inkscape::DrawingItem *ac = child->invoke_show (arena, key, flags); + Inkscape::DrawingItem *ac = child->invoke_show (drawing, key, flags); if (ac) { ai->appendChild(ac); } diff --git a/src/sp-switch.h b/src/sp-switch.h index 7b108947d..8eafe6e7b 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -42,7 +42,7 @@ public: protected: virtual GSList *_childList(bool add_ref, SPObject::Action action); - virtual void _showChildren (NRArena *arena, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); + virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); SPObject *_evaluateFirst(); void _reevaluate(bool add_to_arena = false); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 1f35a0ee1..bee28f8e3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -37,7 +37,7 @@ static void sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_symbol_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_symbol_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static Inkscape::DrawingItem *sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +static Inkscape::DrawingItem *sp_symbol_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_symbol_hide (SPItem *item, unsigned int key); static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); @@ -325,7 +325,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); } - // As last step set additional transform of arena group + // As last step set additional transform of drawing group for (SPItemView *v = symbol->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); g->setChildTransform(symbol->c2p); @@ -368,7 +368,7 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc return repr; } -static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) +static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { SPSymbol *symbol = SP_SYMBOL(item); Inkscape::DrawingItem *ai = 0; @@ -376,7 +376,7 @@ static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, NRArena *arena, unsig if (symbol->cloned) { // Cloned is actually renderable if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, arena, key, flags); + ai = ((SPItemClass *) (parent_class))->show (item, drawing, key, flags); Inkscape::DrawingGroup *g = dynamic_cast(ai); if (g) { g->setChildTransform(symbol->c2p); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index ed848c646..34722ce5d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -72,7 +72,7 @@ static void sp_text_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); -static Inkscape::DrawingItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags); +static Inkscape::DrawingItem *sp_text_show (SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); static void sp_text_hide (SPItem *item, unsigned key); static char *sp_text_description (SPItem *item); static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); @@ -273,7 +273,7 @@ static void sp_text_modified(SPObject *object, guint flags) // FIXME: all that we need to do here is to call setStyle, to set the changed // style, but there's no easy way to access the drawing glyphs or texts corresponding to a - // text object. Therefore we do here the same as in _update, that is, destroy all arena items + // text object. Therefore we do here the same as in _update, that is, destroy all items // and create new ones. This is probably quite wasteful. if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPText *text = SP_TEXT (object); @@ -386,11 +386,11 @@ sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, un static Inkscape::DrawingItem * -sp_text_show(SPItem *item, NRArena *arena, unsigned /* key*/, unsigned /*flags*/) +sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned /* key*/, unsigned /*flags*/) { SPText *group = (SPText *) item; - Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(arena); + Inkscape::DrawingGroup *flowed = new Inkscape::DrawingGroup(drawing); flowed->setPickChildren(false); flowed->setStyle(group->style); diff --git a/src/sp-text.h b/src/sp-text.h index f865713c7..e426c425b 100644 --- a/src/sp-text.h +++ b/src/sp-text.h @@ -56,7 +56,7 @@ struct SPText : public SPItem { static void _adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double ex, bool is_root = true); static void _adjustFontsizeRecursive(SPItem *item, double ex, bool is_root = true); - /** discards the NRArena objects representing this text. */ + /** discards the drawing objects representing this text. */ void _clearFlow(Inkscape::DrawingGroup *in_arena); private: diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 2f83679de..89df9130d 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -53,7 +53,7 @@ static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &tr static void sp_use_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); static void sp_use_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_use_description(SPItem *item); -static Inkscape::DrawingItem *sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); +static Inkscape::DrawingItem *sp_use_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); static void sp_use_hide(SPItem *item, unsigned key); static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use); @@ -347,16 +347,16 @@ sp_use_description(SPItem *item) } static Inkscape::DrawingItem * -sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) +sp_use_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags) { SPUse *use = SP_USE(item); - Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(arena); + Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); ai->setPickChildren(false); ai->setStyle(item->style); if (use->child) { - Inkscape::DrawingItem *ac = SP_ITEM(use->child)->invoke_show(arena, key, flags); + Inkscape::DrawingItem *ac = SP_ITEM(use->child)->invoke_show(drawing, key, flags); if (ac) { ai->prependChild(ac); } diff --git a/src/svg-view.cpp b/src/svg-view.cpp index 3221ce146..8773dfab7 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -204,12 +204,12 @@ SPSVGView::setDocument (SPDocument *document) if (document) { Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( - SP_CANVAS_ARENA (_drawing)->arena, + SP_CANVAS_ARENA (_drawing)->drawing, _dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - SP_CANVAS_ARENA (_drawing)->root->prependChild(ai); + SP_CANVAS_ARENA (_drawing)->drawing.root()->prependChild(ai); } doRescale (!_rescale); diff --git a/src/text-context.h b/src/text-context.h index a140c2f08..50a738ca0 100644 --- a/src/text-context.h +++ b/src/text-context.h @@ -31,7 +31,6 @@ class SPTextContext; class SPTextContextClass; -class SPCanvasArena; struct SPTextContext : public SPEventContext { diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 7093ff683..7c47dc442 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -29,7 +29,7 @@ #include "sp-image.h" #include <2geom/transforms.h> -#include "display/nr-arena.h" +#include "display/drawing.h" #include "display/drawing-shape.h" #include "siox.h" diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index ae5355c58..912bc1a40 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -30,18 +30,18 @@ #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/drawing-item.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize) { Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); - root->setTransform(Geom::Scale(scale_factor)); + drawing.root()->setTransform(Geom::Scale(scale_factor)); Geom::IntRect ibox = (dbox * Geom::Scale(scale_factor)).roundOutwards(); - root->update(ibox); + drawing.update(ibox); /* Find visible area */ int width = ibox.width(); @@ -59,7 +59,7 @@ GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const CAIRO_FORMAT_ARGB32, psize, psize); Inkscape::DrawingContext ct(s, area.min()); - root->render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index b9fa6f627..2318307e2 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -16,7 +16,7 @@ #include "display/display-forward.h" -GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize); namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index bb800f9ca..4f4093a99 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -34,8 +34,8 @@ #include "extension/output.h" #include "extension/db.h" -#include "display/nr-arena-item.h" -#include "display/nr-arena.h" +//#include "display/drawing-item.h" +//#include "display/drawing.h" #include "sp-item.h" #include "display/canvas-arena.h" diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index a6d76eb13..9865c0cdb 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -16,6 +16,7 @@ # include #endif +#include #include #include #include @@ -25,7 +26,7 @@ #include "desktop.h" #include "desktop-handles.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "document.h" #include "inkscape.h" #include "preferences.h" @@ -36,9 +37,10 @@ #include "icon-preview.h" extern "C" { -// takes doc, root, icon, and icon name to produce pixels +// takes doc, drawing, icon, and icon name to produce pixels +// this is defined in widgets/icon.cpp guchar * -sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, +sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, const gchar *name, unsigned int psize, unsigned &stride); } @@ -438,20 +440,16 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) g_message("%s setting up to render '%s' as the icon", getTimestr().c_str(), id ); #endif // ICON_VERBOSE - Inkscape::DrawingItem *root = NULL; + Inkscape::Drawing drawing; - /* Create new arena */ - NRArena *arena = NRArena::create(); - - /* Create ArenaItem and set transform */ + /* Create drawing items and set transform */ unsigned int visionkey = SPItem::display_key_new(1); - - root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + drawing.setRoot(doc->getRoot()->invoke_show( drawing, visionkey, SP_ITEM_SHOW_DISPLAY )); for ( int i = 0; i < numEntries; i++ ) { unsigned unused; int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, sizes[i]); - guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i], unused); + guchar * px = sp_icon_doc_icon( doc, drawing, id, sizes[i], unused); // g_message( " size %d %s", sizes[i], (px ? "worked" : "failed") ); if ( px ) { memcpy( pixMem[i], px, sizes[i] * stride ); @@ -465,7 +463,6 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) updateMagnify(); doc->getRoot()->invoke_hide(visionkey); - nr_object_unref((NRObject *) arena); renderTimer->stop(); minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 ); #if ICON_VERBOSE diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 13499a2e4..db6061434 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -65,7 +65,7 @@ namespace Inkscape { /** * View is an abstract base class of all UI document views. This * includes both the editing window and the SVG preview, but does not - * include the non-UI RGBA buffer-based NRArena nor the XML editor or + * include the non-UI RGBA buffer-based Inkscape::Drawing nor the XML editor or * similar views. The View base class has very little functionality of * its own. */ diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index af329f3fc..08f0eadfb 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -36,7 +36,6 @@ #include "desktop-widget.h" #include "display/sp-canvas.h" #include "display/canvas-arena.h" -#include "display/nr-arena.h" #include "document.h" #include "ege-color-prof-tracker.h" #include "ege-select-one-action.h" diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index fea825444..a57b56b5c 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -33,7 +33,7 @@ #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/drawing-item.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "io/sys.h" #include "sp-root.h" @@ -1088,9 +1088,9 @@ static Geom::IntRect round_rect(Geom::Rect const &r) return ret; } -// takes doc, root, icon, and icon name to produce pixels +// takes doc, drawing, icon, and icon name to produce pixels extern "C" guchar * -sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, +sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, gchar const *name, unsigned psize, unsigned &stride) { @@ -1115,8 +1115,8 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, if ( dbox ) { /* Update to renderable state */ double sf = 1.0; - root->setTransform(Geom::Scale(sf)); - root->update(); + drawing.root()->setTransform(Geom::Scale(sf)); + drawing.update(); /* Item integer bbox in points */ // NOTE: previously, each rect coordinate was rounded using floor(c + 0.5) Geom::IntRect ibox = round_rect(*dbox); @@ -1141,8 +1141,8 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, } sf = (double)psize / (double)block; - root->setTransform(Geom::Scale(sf)); - root->update(); + drawing.root()->setTransform(Geom::Scale(sf)); + drawing.update(); ibox = round_rect(*dbox * Geom::Scale(sf)); if ( dump ) { @@ -1185,7 +1185,7 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, CAIRO_FORMAT_ARGB32, psize, psize, stride); Inkscape::DrawingContext ct(s, ua.min()); - root->render(ct, ua, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(ct, ua); cairo_surface_destroy(s); // convert to GdkPixbuf format @@ -1206,9 +1206,21 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, class SVGDocCache { public: - SVGDocCache( SPDocument *doc, Inkscape::DrawingItem *root ) : doc(doc), root(root) {} + SVGDocCache( SPDocument *doc ) + : doc(doc) + , visionkey(SPItem::display_key_new(1)) + { + doc->doRef(); + doc->ensureUpToDate(); + drawing.setRoot(doc->getRoot()->invoke_show(drawing, visionkey, SP_ITEM_SHOW_DISPLAY )); + } + ~SVGDocCache() { + doc->getRoot()->invoke_hide(visionkey); + doc->doUnref(); + } SPDocument *doc; - Inkscape::DrawingItem *root; + Inkscape::Drawing drawing; + unsigned visionkey; }; static std::map doc_cache; @@ -1275,27 +1287,14 @@ guchar *IconImpl::load_svg_pixels(std::list const &names, if ( dump ) { g_message("Loaded icon file %s", doc_filename); } - // prep the document - doc->ensureUpToDate(); - - // Create new arena - NRArena *arena = NRArena::create(); - - // Create ArenaItem and set transform - unsigned visionkey = SPItem::display_key_new(1); - // fixme: Memory manage root if needed (Lauris) - // This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days - // because shapes are being rendered which are not being freed - Inkscape::DrawingItem *root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); - // store into the cache - info = new SVGDocCache(doc, root); + info = new SVGDocCache(doc); doc_cache[key] = info; } } if (info) { for (std::list::const_iterator it = names.begin(); !px && (it != names.end()); ++it ) { - px = sp_icon_doc_icon( info->doc, info->root, it->c_str(), psize, stride ); + px = sp_icon_doc_icon( info->doc, info->drawing, it->c_str(), psize, stride ); } } } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 4f6466ce8..8d9b9b429 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -29,7 +29,7 @@ #include "dialogs/dialog-events.h" #include "display/canvas-bpath.h" // for SP_STROKE_LINEJOIN_* #include "display/display-forward.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "document-private.h" #include "gradient-chemistry.h" #include "helper/stock-items.h" @@ -153,8 +153,7 @@ sp_stroke_radio_button(Gtk::RadioButton *tb, char const *icon, static Gtk::Image * sp_marker_prev_new(unsigned psize, gchar const *mname, SPDocument *source, SPDocument *sandbox, - gchar const *menu_id, NRArena const * /*arena*/, unsigned /*visionkey*/, - Inkscape::DrawingItem *root) + gchar const *menu_id, Inkscape::Drawing &drawing, unsigned /*visionkey*/) { // Retrieve the marker named 'mname' from the source SVG document SPObject const *marker = source->getObjectById(mname); @@ -209,7 +208,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, Glib::RefPtr pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key)); if (!pixbuf) { - pixbuf = Glib::wrap(render_pixbuf(root, sf, *dbox, psize)); + pixbuf = Glib::wrap(render_pixbuf(drawing, sf, *dbox, psize)); svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj()); } @@ -249,9 +248,9 @@ static void sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPDocument *sandbox, gchar const *menu_id) { // Do this here, outside of loop, to speed up preview generation: - NRArena const *arena = NRArena::create(); + Inkscape::Drawing drawing; unsigned const visionkey = SPItem::display_key_new(1); - Inkscape::DrawingItem *root = sandbox->getRoot()->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); + drawing.setRoot(sandbox->getRoot()->invoke_show(drawing, visionkey, SP_ITEM_SHOW_DISPLAY)); for (; marker_list != NULL; marker_list = marker_list->next) { Inkscape::XML::Node *repr = reinterpret_cast(marker_list->data)->getRepr(); @@ -272,7 +271,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD // generate preview - Gtk::Image *prv = sp_marker_prev_new (22, markid, source, sandbox, menu_id, arena, visionkey, root); + Gtk::Image *prv = sp_marker_prev_new (22, markid, source, sandbox, menu_id, drawing, visionkey); prv->show(); hb->pack_start(*prv, false, false, 6); @@ -290,7 +289,6 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD } sandbox->getRoot()->invoke_hide(visionkey); - nr_object_unref((NRObject *) arena); } /** -- cgit v1.2.3 From bd6a4aa2e2e19da2d4d1c82c46ee02a7b828de35 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 7 Aug 2011 15:29:33 +0200 Subject: Filters. More filters reorganisation and consistency work. Translations. PO template, PO file list and French translation update. (bzr r10531) --- src/extension/internal/filter/blurs.h | 12 +-- src/extension/internal/filter/bumps.h | 24 +++--- src/extension/internal/filter/color.h | 111 +++------------------------ src/extension/internal/filter/filter-all.cpp | 2 +- src/extension/internal/filter/image.h | 6 +- src/extension/internal/filter/overlays.h | 4 +- src/extension/internal/filter/paint.h | 109 +++++++++++++++++++++++--- src/extension/internal/filter/shadows.h | 4 +- src/extension/internal/filter/transparency.h | 4 +- 9 files changed, 138 insertions(+), 138 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index d6f9a79e6..b09a4f347 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -107,7 +107,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Clean edges") "\n" + "" N_("Clean Edges") "\n" "org.inkscape.effect.filter.CleanEdges\n" "0.4\n" "\n" @@ -134,7 +134,7 @@ CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -167,7 +167,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross blur") "\n" + "" N_("Cross Blur") "\n" "org.inkscape.effect.filter.CrossBlur\n" "0\n" "0\n" @@ -211,7 +211,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) blend << ext->get_param_enum("blend"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -307,7 +307,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Image blur") "\n" + "" N_("Image Blur") "\n" "org.inkscape.effect.filter.ImageBlur\n" "\n" "\n" @@ -380,7 +380,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 596d1547f..e8c80315a 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -37,7 +37,7 @@ namespace Filter { Options * Image simplification (0.01->10., default 0.01) -> blur1 (stdDeviation) * Bump simplification (0.01->10., default 0.01) -> blur2 (stdDeviation) - * Crop (-1.->1., default 0) -> composite1 (k3) + * Crop (-50.->50., default 1) -> composite1 (k3) * Red (-50.->50., default 0.) -> colormatrix1 (values) * Green (-50.->50., default 0.) -> colormatrix1 (values) * Blue (-50.->50., default 0.) -> colormatrix1 (values) @@ -85,8 +85,8 @@ public: "\n" "0.01\n" "0.01\n" - "0\n" - "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">Bump source\n" + "1\n" + "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "\n" "0\n" "0\n" "0\n" @@ -108,14 +108,14 @@ public: "<_item value=\"point\">" N_("Point") "\n" "<_item value=\"spot\">" N_("Spot") "\n" "\n" - "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">Distant light options\n" + "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">" N_("Distant light options") "\n" "225\n" "45\n" - "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">Point light options\n" + "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">" N_("Point light options") "\n" "526\n" "372\n" "150\n" - "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">Spot light options\n" + "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">" N_("Spot light options") "\n" "526\n" "372\n" "150\n" @@ -290,7 +290,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Diffuse light") "\n" + "" N_("Diffuse Light") "\n" "org.inkscape.effect.filter.DiffuseLight\n" "6\n" "25\n" @@ -334,7 +334,7 @@ DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -370,7 +370,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Matte jelly") "\n" + "" N_("Matte Jelly") "\n" "org.inkscape.effect.filter.MatteJelly\n" "7\n" "0.9\n" @@ -417,7 +417,7 @@ MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -454,7 +454,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Specular light") "\n" + "" N_("Specular Light") "\n" "org.inkscape.effect.filter.SpecularLight\n" "6\n" "1\n" @@ -501,7 +501,7 @@ SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index e8de022b9..e19c2054d 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -13,7 +13,6 @@ * Color shift * Colorize * Duochrome - * Electrize * Greyscale * Lightness * Quadritone @@ -102,7 +101,7 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), @@ -143,7 +142,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Channel painting") "\n" + "" N_("Channel Painting") "\n" "org.inkscape.effect.filter.ChannelPaint\n" "\n" "\n" @@ -206,7 +205,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -245,7 +244,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Color shift") "\n" + "" N_("Color Shift") "\n" "org.inkscape.effect.filter.ColorShift\n" "330\n" "0.6\n" @@ -275,7 +274,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) sat << ext->get_param_float("sat"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", shift.str().c_str(), sat.str().c_str()); @@ -380,7 +379,7 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -501,7 +500,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -517,92 +516,6 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Duochrome filter */ -/** - \brief Custom predefined Electrize filter. - - Electro solarization effects. - - Filter's parameters: - * Simplify (0.01->10., default 2.) -> blur (stdDeviation) - * Effect type (enum: table or discrete, default "table") -> component (type) - * Level (0->10, default 3) -> component (tableValues) - * Inverted (boolean, default false) -> component (tableValues) -*/ -class Electrize : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Electrize ( ) : Filter() { }; - virtual ~Electrize ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Electrize") "\n" - "org.inkscape.effect.filter.Electrize\n" - "2.0\n" - "\n" - "<_item value=\"table\">" N_("Table") "\n" - "<_item value=\"discrete\">" N_("Discrete") "\n" - "\n" - "3\n" - "false\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Electro solarization effects") "\n" - "\n" - "\n", new Electrize()); - }; -}; - -gchar const * -Electrize::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream type; - std::ostringstream values; - - blur << ext->get_param_float("blur"); - type << ext->get_param_enum("type"); - - // TransfertComponent table values are calculated based on the effect level and inverted parameters. - int val = 0; - int levels = ext->get_param_int("levels") + 1; - if (ext->get_param_bool("invert")) { - val = 1; - } - values << val; - for ( int step = 1 ; step <= levels ; step++ ) { - if (val == 1) { - val = 0; - } - else { - val = 1; - } - values << " " << val; - } - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str()); - - return _filter; -}; /* Electrize filter */ - /** \brief Custom predefined Greyscale filter. @@ -688,7 +601,7 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str()); return _filter; @@ -747,7 +660,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) offset << ext->get_param_float("offset"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -833,7 +746,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) blend2 << ext->get_param_enum("blend2"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -913,7 +826,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1065,7 +978,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index ffac97e0c..5b3280656 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -52,7 +52,6 @@ Filter::filters_all (void ) ColorShift::init(); Colorize::init(); Duochrome::init(); - Electrize::init(); Greyscale::init(); Lightness::init(); Quadritone::init(); @@ -69,6 +68,7 @@ Filter::filters_all (void ) Chromolitho::init(); CrossEngraving::init(); Drawing::init(); + Electrize::init(); NeonDraw::init(); Posterize::init(); PosterizeBasic::init(); diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 3f1a33055..47744a2f6 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -46,7 +46,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Edge detect") "\n" + "" N_("Edge Detect") "\n" "org.inkscape.effect.filter.EdgeDetect\n" "\n" "<_item value=\"all\">" N_("All") "\n" @@ -59,7 +59,7 @@ public: "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Detect color edges in object") "\n" @@ -97,7 +97,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h index 4c59b553b..0d02777d1 100644 --- a/src/extension/internal/filter/overlays.h +++ b/src/extension/internal/filter/overlays.h @@ -53,7 +53,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Noise fill") "\n" + "" N_("Noise Fill") "\n" "org.inkscape.effect.filter.NoiseFill\n" "\n" "\n" @@ -123,7 +123,7 @@ NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) inverted << "in"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 7a1cc6046..c2eb0c0ae 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -11,6 +11,7 @@ * Chromolitho * Cross engraving * Drawing + * Electrize * Neon draw * Posterize * Posterize basic @@ -228,7 +229,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Cross engraving") "\n" + "" N_("Cross Engraving") "\n" "org.inkscape.effect.filter.CrossEngraving\n" "30\n" "1\n" @@ -272,7 +273,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) trans << "blend"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -331,16 +332,16 @@ public: "org.inkscape.effect.filter.Drawing\n" "\n" "\n" - "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" + "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">" N_("Simplify") "\n" "0.6\n" "10\n" "0\n" "false\n" - "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" + "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">" N_("Smoothness") "\n" "0.6\n" "6\n" "2\n" - "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" + "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">" N_("Melt") "\n" "1\n" "6\n" "2\n" @@ -468,6 +469,92 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Drawing filter */ +/** + \brief Custom predefined Electrize filter. + + Electro solarization effects. + + Filter's parameters: + * Simplify (0.01->10., default 2.) -> blur (stdDeviation) + * Effect type (enum: table or discrete, default "table") -> component (type) + * Level (0->10, default 3) -> component (tableValues) + * Inverted (boolean, default false) -> component (tableValues) +*/ +class Electrize : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Electrize ( ) : Filter() { }; + virtual ~Electrize ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Electrize") "\n" + "org.inkscape.effect.filter.Electrize\n" + "2.0\n" + "\n" + "<_item value=\"table\">" N_("Table") "\n" + "<_item value=\"discrete\">" N_("Discrete") "\n" + "\n" + "3\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Electro solarization effects") "\n" + "\n" + "\n", new Electrize()); + }; +}; + +gchar const * +Electrize::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + std::ostringstream type; + std::ostringstream values; + + blur << ext->get_param_float("blur"); + type << ext->get_param_enum("type"); + + // TransfertComponent table values are calculated based on the effect level and inverted parameters. + int val = 0; + int levels = ext->get_param_int("levels") + 1; + if (ext->get_param_bool("invert")) { + val = 1; + } + values << val; + for ( int step = 1 ; step <= levels ; step++ ) { + if (val == 1) { + val = 0; + } + else { + val = 1; + } + values << " " << val; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", blur.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str()); + + return _filter; +}; /* Electrize filter */ + /** \brief Custom predefined Neon draw filter. @@ -494,7 +581,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Neon draw") "\n" + "" N_("Neon Draw") "\n" "org.inkscape.effect.filter.NeonDraw\n" "\n" "<_item value=\"table\">Smoothed\n" @@ -549,7 +636,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) dark << "component1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -599,7 +686,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Poster paint") "\n" + "" N_("Poster Paint") "\n" "org.inkscape.effect.filter.Posterize\n" "\n" "<_item value=\"normal\">Normal\n" @@ -684,7 +771,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -723,7 +810,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Posterize basic") "\n" + "" N_("Posterize Basic") "\n" "org.inkscape.effect.filter.PosterizeBasic\n" "5\n" "4.0\n" @@ -760,7 +847,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) transf << " 1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 49f1003cc..2d63ac00f 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -53,7 +53,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Drop shadow") "\n" + "" N_("Drop Shadow") "\n" "org.inkscape.effect.filter.ColorDropShadow\n" "\n" "\n" @@ -158,7 +158,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index c47df89df..f8f02575b 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -57,7 +57,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Channel transparency") "\n" + "" N_("Channel Transparency") "\n" "org.inkscape.effect.filter.ChannelTransparency\n" "-1\n" "0.5\n" @@ -100,7 +100,7 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), -- cgit v1.2.3 From f336c94939e9740501835b2584ad9a3160ac6d51 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 9 Aug 2011 03:14:07 +0200 Subject: Initial autocache work (bzr r10347.1.26) --- src/display/canvas-arena.cpp | 2 +- src/display/drawing-item.cpp | 146 ++++++++++++++++++++++----- src/display/drawing-item.h | 22 +++- src/display/drawing-surface.cpp | 47 ++++++--- src/display/drawing-surface.h | 5 +- src/display/drawing.cpp | 45 +++++++-- src/display/drawing.h | 29 ++++-- src/display/nr-filter-blend.cpp | 5 + src/display/nr-filter-blend.h | 1 + src/display/nr-filter-colormatrix.cpp | 5 + src/display/nr-filter-colormatrix.h | 1 + src/display/nr-filter-component-transfer.cpp | 5 + src/display/nr-filter-component-transfer.h | 1 + src/display/nr-filter-composite.cpp | 5 + src/display/nr-filter-composite.h | 1 + src/display/nr-filter-convolve-matrix.cpp | 5 + src/display/nr-filter-convolve-matrix.h | 1 + src/display/nr-filter-diffuselighting.cpp | 5 + src/display/nr-filter-diffuselighting.h | 1 + src/display/nr-filter-displacement-map.cpp | 5 + src/display/nr-filter-displacement-map.h | 6 +- src/display/nr-filter-flood.cpp | 7 ++ src/display/nr-filter-flood.h | 5 +- src/display/nr-filter-gaussian.cpp | 7 ++ src/display/nr-filter-gaussian.h | 1 + src/display/nr-filter-image.cpp | 6 ++ src/display/nr-filter-image.h | 2 + src/display/nr-filter-merge.cpp | 5 + src/display/nr-filter-merge.h | 1 + src/display/nr-filter-morphology.cpp | 7 ++ src/display/nr-filter-morphology.h | 2 + src/display/nr-filter-offset.cpp | 5 + src/display/nr-filter-offset.h | 1 + src/display/nr-filter-primitive.cpp | 4 - src/display/nr-filter-primitive.h | 32 +----- src/display/nr-filter-specularlighting.cpp | 135 +------------------------ src/display/nr-filter-specularlighting.h | 2 + src/display/nr-filter-tile.cpp | 5 + src/display/nr-filter-tile.h | 1 + src/display/nr-filter-turbulence.cpp | 5 + src/display/nr-filter-turbulence.h | 1 + src/display/nr-filter.cpp | 12 +++ src/display/nr-filter.h | 3 + 43 files changed, 367 insertions(+), 225 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 6026ebd3f..b254a55c8 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -105,7 +105,7 @@ sp_canvas_arena_init (SPCanvasArena *arena) Inkscape::DrawingGroup *root = new DrawingGroup(arena->drawing); root->setPickChildren(true); - root->setCached(true); + root->setCached(true, true); arena->drawing.setRoot(root); arena->drawing.signal_request_update.connect( diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 47f6c55a1..3f409b8ee 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -9,6 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include "display/cairo-utils.h" #include "display/cairo-templates.h" #include "display/drawing.h" @@ -29,7 +30,7 @@ namespace Inkscape { * portion of the SVG document. Typically this is created by the SP tree, * in particular the show() virtual function. * - * @section ObjectLifetime Object Lifetime + * @section ObjectLifetime Object lifetime * Deleting a DrawingItem will cause all of its children to be deleted as well. * This can lead to nasty surprises if you hold references to things * which are children of what is being deleted. Therefore, in the SP tree, @@ -38,7 +39,7 @@ namespace Inkscape { * - this will cause dangling pointers inside the SPItem and lead to a crash. * Use the corresponing hide() method. * - * Outside of the SP tree you should not use any references after the root node + * Outside of the SP tree, you should not use any references after the root node * has been deleted. */ @@ -57,6 +58,8 @@ DrawingItem::DrawingItem(Drawing &drawing) , _visible(true) , _sensitive(true) , _cached(0) + , _cached_persistent(0) + , _has_cache_iterator(0) , _propagate(0) // , _renders_opacity(0) , _clip_child(0) @@ -77,6 +80,9 @@ DrawingItem::~DrawingItem() if (_cached) { _drawing._cached_items.erase(this); } + if (_has_cache_iterator) { + _drawing._candidate_items.erase(_cache_iterator); + } // remove this item from parent's children list // due to the effect of clearChildren(), this only happens for the top-level deleted item if (_parent) { @@ -182,17 +188,27 @@ DrawingItem::setSensitive(bool s) _sensitive = s; } -/// Enable / disable storing the rendering in memory. +/** @brief Enable / disable storing the rendering in memory. + * Calling setCached(false, true) will also remove the persistent status + */ void -DrawingItem::setCached(bool c) +DrawingItem::setCached(bool cached, bool persistent) { - _cached = c; - if (c) { + static const char *cache_env = getenv("_INKSCAPE_DISABLE_CACHE"); + if (cache_env) return; + + if (_cached_persistent && !persistent) + return; + + _cached = cached; + _cached_persistent = persistent ? cached : false; + if (cached) { _drawing._cached_items.insert(this); } else { _drawing._cached_items.erase(this); + delete _cache; + _cache = NULL; } - _markForUpdate(STATE_CACHE, false); } void @@ -277,7 +293,7 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne } _state &= ~reset; // reset state of this item - if ((~_state & flags) == 0) return; // nothing to do + if ((~_state & flags) == 0) return; // nothing to do // TODO this might be wrong if (_state & STATE_BBOX) { @@ -323,20 +339,40 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne } } - // update cache if enabled - if (_cached) { - Geom::OptIntRect cl = _drawing.cacheLimit(); - cl.intersectWith(_drawbox); - if (cl) { - if (_cache) { - // this takes care of invalidation on transform - _cache->resizeAndTransform(*cl, ctm_change); - } else { - _cache = new Inkscape::DrawingCache(*cl); - // the cache is initially dirty - } + // Update cache score for this item + if (_has_cache_iterator) { + // remove old score information + _drawing._candidate_items.erase(_cache_iterator); + _has_cache_iterator = false; + } + double score = _cacheScore(); + if (score >= _drawing._cache_score_threshold) { + CacheRecord cr; + cr.score = score; + // if _cacheRect() is empty, a negative score will be returnedfrom _cacheScore(), + // so this will not execute (cache score threshold must be positive) + cr.cache_size = _cacheRect()->area() * 4; + cr.item = this; + _drawing._candidate_items.push_back(cr); + _cache_iterator = --_drawing._candidate_items.end(); + _has_cache_iterator = true; + } + + /* Update cache if enabled. + * General note: here we only tell the cache how it has to transform + * during the render phase. The transformation is deferred because + * after the update the item can have its caching turned off, + * e.g. because its filter was removed. This way we avoid tempoerarily + * using more memory than the cache budget */ + if (_cache) { + Geom::OptIntRect cl = _cacheRect(); + if (_visible && cl) { // never create cache for invisible items + // this takes care of invalidation on transform + _cache->scheduleTransform(*cl, ctm_change); } else { - // disable cache for this item - not visible + // Destroy cache for this item - outside of canvas or invisible. + // The opposite transition (invisible -> visible or object + // entering the canvas) is handled during the render phase delete _cache; _cache = NULL; } @@ -377,9 +413,10 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag bool outline = _drawing.outline(); bool render_filters = _drawing.renderFilters(); - /* If we are invisible, just return successfully */ + // If we are invisible, return immediately if (!_visible) return; + // TODO convert outline rendering to a separate virtual function if (outline) { _renderOutline(ct, area, flags); return; @@ -389,10 +426,25 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag Geom::OptIntRect carea = Geom::intersect(area, _drawbox); if (!carea) return; - // render from cache - if (_cached && _cache) { - if (_cache->paintFromCache(ct, *carea)) - return; + // render from cache if possible + if (_cached) { + if (_cache) { + _cache->prepare(); + if (_cache->paintFromCache(ct, *carea)) + return; + } else { + // There is no cache. This could be because caching of this item + // was just turned on after the last update phase, or because + // we are outside of the canvas. + Geom::OptIntRect cl = _drawing.cacheLimit(); + cl.intersectWith(_drawbox); + if (cl) { + _cache = new DrawingCache(*cl); + } + } + } else { + // if our caching was turned off after the last update, it was already + // deleted in setCached() } // expand carea to contain the dependent area of filters. @@ -695,6 +747,48 @@ DrawingItem::_setStyleCommon(SPStyle *&_style, SPStyle *style) && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { _background_new = true; }*/ + + // TODO: STATE_ALL unsets too much + _markForUpdate(STATE_ALL, false); +} + +double +DrawingItem::_cacheScore() +{ + Geom::OptIntRect cache_rect = _cacheRect(); + if (!cache_rect) return -1.0; + + // a crude first approximation: + // the basic score is the number of pixels in the drawbox + double score = cache_rect->area(); + // this is multiplied by the filter complexity and its expansion + if (_filter &&_drawing.renderFilters()) { + score *= _filter->complexity(_ctm); + Geom::IntRect ref_area = Geom::IntRect::from_xywh(0, 0, 16, 16); + Geom::IntRect test_area = ref_area; + Geom::IntRect limit_area(0, INT_MIN, 16, INT_MAX); + _filter->area_enlarge(test_area, this); + // area_enlarge never shrinks the rect, so the result of intersection below + // must be non-empty + score *= double((test_area & limit_area)->area()) / ref_area.area(); + } + // if the object is clipped, add 1/2 of its bbox pixels + if (_clip && _clip->_bbox) { + score += _clip->_bbox->area() * 0.5; + } + // if masked, add mask score + if (_mask) { + score += _mask->_cacheScore(); + } + g_message("caching score: %f", score); + return score; +} + +Geom::OptIntRect +DrawingItem::_cacheRect() +{ + Geom::OptIntRect r = _drawbox & _drawing.cacheLimit(); + return r; } } // end namespace Inkscape diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index ba0c42695..b934570f2 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -12,7 +12,9 @@ #ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H #define SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H +#include #include +#include #include #include #include <2geom/rect.h> @@ -27,6 +29,18 @@ struct UpdateContext { Geom::Affine ctm; }; +struct CacheRecord + : boost::totally_ordered +{ + bool operator<(CacheRecord const &other) const { return score < other.score; } + bool operator==(CacheRecord const &other) const { return score == other.score; } + operator DrawingItem *() const { return item; } + double score; + size_t cache_size; + DrawingItem *item; +}; +typedef std::list CacheList; + class InvalidItemException : public std::exception { virtual const char *what() const throw() { return "Invalid item in drawing"; @@ -72,7 +86,7 @@ public: bool sensitive() const { return _sensitive; } void setSensitive(bool v); bool cached() const { return _cached; } - void setCached(bool c); + void setCached(bool c, bool persistent = false); void setOpacity(float opacity); void setTransform(Geom::Affine const &trans); @@ -96,6 +110,8 @@ protected: void _markForUpdate(unsigned state, bool propagate); void _markForRendering(); void _setStyleCommon(SPStyle *&_style, SPStyle *style); + double _cacheScore(); + Geom::OptIntRect _cacheRect(); virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { return 0; } virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) {} @@ -133,10 +149,14 @@ protected: void *_user_data; ///< Used to associate DrawingItems with SPItems that created them DrawingCache *_cache; + CacheList::iterator _cache_iterator; + unsigned _state : 8; unsigned _visible : 1; unsigned _sensitive : 1; ///< Whether this item responds to events unsigned _cached : 1; ///< Whether the rendering is stored for reuse + unsigned _cached_persistent : 1; ///< If set, will always be cached regardless of score + unsigned _has_cache_iterator : 1; ///< If set, _cache_list_pos is valid unsigned _propagate : 1; ///< Whether to call update for all children on next update //unsigned _renders_opacity : 1; ///< Whether object needs temporary surface for opacity unsigned _clip_child : 1; ///< If set, this is not a child of _parent, but a clipping path diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 28bdc1f3c..1faa3151e 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -9,6 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include "display/drawing-surface.h" #include "display/drawing-context.h" #include "display/cairo-utils.h" @@ -165,6 +166,7 @@ DrawingSurface::pixelArea() const DrawingCache::DrawingCache(Geom::IntRect const &area) : DrawingSurface(area) , _clean_region(cairo_region_create()) + , _pending_area(area) {} DrawingCache::~DrawingCache() @@ -196,28 +198,41 @@ DrawingCache::isClean(Geom::IntRect const &area) const return false; } } + +/// Call this during the update phase to schedule a transformation of the cache. +void +DrawingCache::scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans) +{ + if (new_area.hasZeroArea() && trans.isIdentity()) return; + _pending_area = new_area; + _pending_transform *= trans; +} + +/// Transforms the cache according to the transform specified during the update phase. +/// Call this during render phase, before painting. void -DrawingCache::resizeAndTransform(Geom::IntRect const &new_area, Geom::Affine const &trans) +DrawingCache::prepare() { Geom::IntRect old_area = pixelArea(); - bool is_identity = false; - bool is_integer_translation = false; - if (trans.isIdentity()) { - is_identity = true; - if (new_area == old_area) return; + bool is_identity = _pending_transform.isIdentity(); + if (is_identity) { + if (_pending_area == old_area) return; } - if (!is_identity && trans.isTranslation()) { - Geom::IntPoint t = trans.translation().round(); - if (Geom::are_near(Geom::Point(t), trans.translation())) { + + bool is_integer_translation = false; + if (!is_identity && _pending_transform.isTranslation()) { + Geom::IntPoint t = _pending_transform.translation().round(); + if (Geom::are_near(Geom::Point(t), _pending_transform.translation())) { // integer translation or identity with change of area is_integer_translation = true; cairo_region_translate(_clean_region, t[X], t[Y]); - if (old_area + t == new_area) { + if (old_area + t == _pending_area) { // if the areas match, the only thing to do // is to ensure that the clean area is not too large - cairo_rectangle_int_t limit = _convertRect(new_area); + cairo_rectangle_int_t limit = _convertRect(_pending_area); cairo_region_intersect_rectangle(_clean_region, &limit); _origin += t; + _pending_transform.setIdentity(); return; } } @@ -226,12 +241,12 @@ DrawingCache::resizeAndTransform(Geom::IntRect const &new_area, Geom::Affine con Geom::IntPoint old_origin = old_area.min(); cairo_surface_t *old_surface = _surface; _surface = NULL; - _pixels = new_area.dimensions(); - _origin = new_area.min(); + _pixels = _pending_area.dimensions(); + _origin = _pending_area.min(); cairo_t *ct = createRawContext(); if (!is_identity) { - ink_cairo_transform(ct, trans); + ink_cairo_transform(ct, _pending_transform); } cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]); cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE); @@ -245,9 +260,11 @@ DrawingCache::resizeAndTransform(Geom::IntRect const &new_area, Geom::Affine con cairo_region_destroy(_clean_region); _clean_region = cairo_region_create(); } else { - cairo_rectangle_int_t limit = _convertRect(new_area); + cairo_rectangle_int_t limit = _convertRect(_pending_area); cairo_region_intersect_rectangle(_clean_region, &limit); } + std::cout << _pending_transform << old_area << _pending_area << std::endl; + _pending_transform.setIdentity(); } /** @brief Paints the clean area from cache and returns the remaining part */ diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index f279d771b..fd46d66ba 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -64,11 +64,14 @@ public: void markDirty(Geom::IntRect const &area = Geom::IntRect::infinite()); void markClean(Geom::IntRect const &area = Geom::IntRect::infinite()); bool isClean(Geom::IntRect const &area) const; - void resizeAndTransform(Geom::IntRect const &new_area, Geom::Affine const &trans); + void scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans); + void prepare(); bool paintFromCache(DrawingContext &ct, Geom::IntRect const &area); protected: cairo_region_t *_clean_region; + Geom::IntRect _pending_area; + Geom::Affine _pending_transform; private: static cairo_rectangle_int_t _convertRect(Geom::IntRect const &r); }; diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 22bd84587..5881c84ed 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -9,6 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include "display/drawing.h" #include "nr-filter-gaussian.h" #include "nr-filter-types.h" @@ -24,6 +25,8 @@ Drawing::Drawing(SPCanvasArena *arena) , _colormode(COLORMODE_NORMAL) , _blur_quality(BLUR_QUALITY_BEST) , _filter_quality(Filters::FILTER_QUALITY_BEST) + , _cache_score_threshold(50000.0) + , _cache_budget(128 << 20) // 128 MiB , _canvasarena(arena) { @@ -126,23 +129,51 @@ Drawing::setCacheLimit(Geom::OptIntRect const &r) void Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { - // TODO add autocache - if (!_root) return; - _root->update(area, ctx, flags, reset); + if (_root) { + _root->update(area, ctx, flags, reset); + } + // process the updated cache scores + // we cache the objects with the highest score until the budget is exhausted + _candidate_items.sort(std::greater()); + size_t used = 0; + CandidateList::iterator i; + for (i = _candidate_items.begin(); i != _candidate_items.end(); ++i) { + if (used + i->cache_size > _cache_budget) break; + used += i->cache_size; + } + + std::set to_cache; + for (i = _candidate_items.begin(); i != _candidate_items.end(); ++i) { + i->item->setCached(true); + to_cache.insert(i->item); + } + // Everything which is now in _cached_items but not in to_cache must be uncached + // Note that calling setCached on an item modifies _cached_items + // TODO: find a way to avoid the set copy + std::set to_uncache; + std::set_difference(_cached_items.begin(), _cached_items.end(), + to_cache.begin(), to_cache.end(), + std::inserter(to_uncache, to_uncache.end())); + for (std::set::iterator j = to_uncache.begin(); j != to_uncache.end(); ++j) { + (*j)->setCached(false); + } } void Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { - if (!_root) return; - _root->render(ct, area, flags); + if (_root) { + _root->render(ct, area, flags); + } } DrawingItem * Drawing::pick(Geom::Point const &p, double delta, bool sticky) { - if (!_root) return NULL; - return _root->pick(p, delta, sticky); + if (_root) { + return _root->pick(p, delta, sticky); + } + return NULL; } } // end namespace Inkscape diff --git a/src/display/drawing.h b/src/display/drawing.h index 4560d277d..a8e70bbe6 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -13,6 +13,7 @@ #define SEEN_INKSCAPE_DISPLAY_DRAWING_H #include +#include #include #include #include <2geom/rect.h> @@ -22,17 +23,17 @@ namespace Inkscape { -struct OutlineColors { - guint32 paths; - guint32 clippaths; - guint32 masks; - guint32 images; -}; - class Drawing : boost::noncopyable { public: + struct OutlineColors { + guint32 paths; + guint32 clippaths; + guint32 masks; + guint32 images; + }; + Drawing(SPCanvasArena *arena = NULL); ~Drawing(); @@ -66,8 +67,13 @@ public: sigc::signal signal_item_deleted; private: + void _reportCacheScore(CacheRecord const &); + + typedef std::list CandidateList; + DrawingItem *_root; - std::set _cached_items; + std::set _cached_items; // modified by DrawingItem::setCached() + CacheList _candidate_items; public: // TODO: remove these temporarily public members guint32 outlinecolor; @@ -80,9 +86,12 @@ private: int _filter_quality; Geom::OptIntRect _cache_limit; - OutlineColors _colors; + double _cache_score_threshold; ///< do not consider objects for caching below this score + size_t _cache_budget; ///< maximum allowed size of cache - SPCanvasArena *_canvasarena; // may be NULL is this arena is not the screen but used for export etc. + OutlineColors _colors; + SPCanvasArena *_canvasarena; // may be NULL is this arena is not the screen + // but used for export etc. friend class DrawingItem; }; diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 3cec479fa..99a142b44 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -196,6 +196,11 @@ bool FilterBlend::can_handle_affine(Geom::Affine const &) return true; } +double FilterBlend::complexity(Geom::Affine const &) +{ + return 1.1; +} + void FilterBlend::set_input(int slot) { _input = slot; } diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 64b3c9284..5f71d468d 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -39,6 +39,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); + virtual double complexity(Geom::Affine const &ctm); virtual void set_input(int slot); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 7eb2fa2e9..6fa34bf0b 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -192,6 +192,11 @@ void FilterColorMatrix::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*tr { } +double FilterColorMatrix::complexity(Geom::Affine const &) +{ + return 2.0; +} + void FilterColorMatrix::set_type(FilterColorMatrixType t){ type = t; } diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index df851e0aa..5864a010e 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -38,6 +38,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); virtual void set_type(FilterColorMatrixType type); virtual void set_value(gdouble value); diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index 80bc07df8..887352f62 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -308,6 +308,11 @@ void FilterComponentTransfer::area_enlarge(NRRectL &/*area*/, Geom::Affine const { } +double FilterComponentTransfer::complexity(Geom::Affine const &) +{ + return 2.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index 89bc61403..6d65ae6d1 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -38,6 +38,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); FilterComponentTransferType type[4]; std::vector tableValues[4]; diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index 694ccaec5..b25ecdf2c 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -139,6 +139,11 @@ void FilterComposite::set_arithmetic(double k1, double k2, double k3, double k4) this->k4 = k4; } +double FilterComposite::complexity(Geom::Affine const &) +{ + return 1.1; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index 930898830..95579cc0e 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -28,6 +28,7 @@ public: virtual void render_cairo(FilterSlot &); virtual bool can_handle_affine(Geom::Affine const &); + virtual double complexity(Geom::Affine const &ctm); virtual void set_input(int input); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 06e28b074..469baf346 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -212,6 +212,11 @@ void FilterConvolveMatrix::area_enlarge(NRRectL &area, Geom::Affine const &/*tra area.y1 += orderY - targetY - 1; } +double FilterConvolveMatrix::complexity(Geom::Affine const &) +{ + return kernelMatrix.size(); +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index d13738260..8b7fc35d1 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -36,6 +36,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); void set_targetY(int coord); void set_targetX(int coord); diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 039e56bb0..14144ace5 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -171,6 +171,11 @@ void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*t area.y1 += 1; } +double FilterDiffuseLighting::complexity(Geom::Affine const &) +{ + return 9.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 6e39242f6..bb3ceccb3 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -33,6 +33,7 @@ public: virtual ~FilterDiffuseLighting(); virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); union { SPFeDistantLight *distant; diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 15200223b..75e310339 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -140,6 +140,11 @@ void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Affine const &tran area.y1 += (int)(scaley)+2; } +double FilterDisplacementMap::complexity(Geom::Affine const &) +{ + return 3.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index aec4b7eb6..393a904c1 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -27,12 +27,14 @@ public: static FilterPrimitive *create(); virtual ~FilterDisplacementMap(); + virtual void render_cairo(FilterSlot &slot); + virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); + virtual void set_input(int slot); virtual void set_input(int input, int slot); virtual void set_scale(double s); virtual void set_channel_selector(int s, FilterDisplacementMapChannelSelector channel); - virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); private: double scale; diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index a015d3f1f..5716c1bc5 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -86,6 +86,13 @@ void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/) { } +double FilterFlood::complexity(Geom::Affine const &) +{ + // flood is actually less expensive than normal rendering, + // but when flood is processed, the object has already been rendered + return 1.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 6db90d439..c87bf6d8f 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -27,10 +27,13 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); + virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); + virtual void set_opacity(double o); virtual void set_color(guint32 c); virtual void set_icc(SVGICCColor *icc_color); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + private: double opacity; guint32 color; diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index a777d76a4..988a8479e 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -691,6 +691,13 @@ bool FilterGaussian::can_handle_affine(Geom::Affine const &) return false; } +double FilterGaussian::complexity(Geom::Affine const &trans) +{ + int area_x = _effect_area_scr(_deviation_x * trans.expansionX()); + int area_y = _effect_area_scr(_deviation_y * trans.expansionY()); + return 2.0 * area_x * area_y; +} + void FilterGaussian::set_deviation(double deviation) { if(IS_FINITE(deviation) && deviation >= 0) { diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 811502016..f52bea01e 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -37,6 +37,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &m); virtual bool can_handle_affine(Geom::Affine const &m); + virtual double complexity(Geom::Affine const &ctm); /** * Set the standard deviation value for gaussian blur. Deviation along diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index b176cdcef..a22d23548 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -196,6 +196,12 @@ bool FilterImage::can_handle_affine(Geom::Affine const &) return true; } +double FilterImage::complexity(Geom::Affine const &) +{ + // TODO: right now we cannot actually measure this in any meaningful way. + return 1.1; +} + void FilterImage::set_href(const gchar *href){ if (feImageHref) g_free (feImageHref); feImageHref = (href) ? g_strdup (href) : NULL; diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index 0651109ec..5af0b3338 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -29,6 +29,8 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); + virtual double complexity(Geom::Affine const &ctm); + void set_document( SPDocument *document ); void set_href(const gchar *href); void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height); diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 51d3975cb..6042da018 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -67,6 +67,11 @@ bool FilterMerge::can_handle_affine(Geom::Affine const &) return true; } +double FilterMerge::complexity(Geom::Affine const &) +{ + return 1.02; +} + void FilterMerge::set_input(int slot) { _input_image[0] = slot; } diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index 263fc8026..cedab9086 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -26,6 +26,7 @@ public: virtual void render_cairo(FilterSlot &); virtual bool can_handle_affine(Geom::Affine const &); + virtual double complexity(Geom::Affine const &ctm); virtual void set_input(int input); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index c79667d3e..9e43d01f3 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -158,6 +158,13 @@ void FilterMorphology::area_enlarge(NRRectL &area, Geom::Affine const &trans) area.y1 += enlarge_y; } +double FilterMorphology::complexity(Geom::Affine const &trans) +{ + int enlarge_x = ceil(xradius * trans.expansionX()); + int enlarge_y = ceil(yradius * trans.expansionY()); + return enlarge_x * enlarge_y; +} + void FilterMorphology::set_operator(FilterMorphologyOperator &o){ Operator = o; } diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index 5924085d9..512eca83c 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -33,6 +33,8 @@ public: virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); + void set_operator(FilterMorphologyOperator &o); void set_xradius(double x); void set_yradius(double y); diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index 3b0f83841..db8b6d92a 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -85,6 +85,11 @@ void FilterOffset::area_enlarge(NRRectL &area, Geom::Affine const &trans) } } +double FilterOffset::complexity(Geom::Affine const &) +{ + return 1.02; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index 09c57f803..841be6008 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -29,6 +29,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); virtual bool can_handle_affine(Geom::Affine const &); + virtual double complexity(Geom::Affine const &ctm); void set_dx(double amount); void set_dy(double amount); diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index 539e3e952..0a445b9e6 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -161,10 +161,6 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units) return area; } -FilterTraits FilterPrimitive::get_input_traits() { - return TRAIT_ANYTHING; -} - } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index ebecb91ec..259a25e7e 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -22,24 +22,6 @@ namespace Filters { class FilterSlot; class FilterUnits; -/* - * Different filter effects need different types of inputs. This is what - * traits are used for: one can specify, what special restrictions - * there are for inputs. - * - * Example: gaussian blur requires that x- and y-axis of input image - * are paraller to blurred object's x- and y-axis, respectively. - * Otherwise blur wouldn't rotate with the object. - * - * Values here should be powers of two, so these can be used as bitfield. - * That is: any combination ef existing traits can be specified. (excluding - * TRAIT_ANYTHING, which is alias for no traits defined) - */ -enum FilterTraits { - TRAIT_ANYTHING = 0, - TRAIT_PARALLER = 1 -}; - class FilterPrimitive { public: FilterPrimitive(); @@ -81,6 +63,10 @@ public: */ virtual void set_output(int slot); + // returns cache score factor, reflecting the cost of rendering this filter + // this should return how many times slower this primitive is that normal rendering + virtual double complexity(Geom::Affine const &/*ctm*/) { return 1.0; } + /** * Sets the filter primitive subregion. Passing an unset length * (length._set == false) WILL change the parameter as it is @@ -103,14 +89,6 @@ public: */ Geom::Rect filter_primitive_area(FilterUnits const &units); - /** - * Queries the filter, which traits it needs from its input buffers. - * At the time of writing this, only one trait was needed, having - * user coordinate system and input pixelblock coordinates paraller to - * each other. - */ - virtual FilterTraits get_input_traits(); - /** @brief Indicate whether the filter primitive can handle the given affine. * * Results of some filter primitives depend on the coordinate system used when rendering. @@ -121,7 +99,7 @@ public: * When any filter returns false, filter rendering is performed on an intermediate surface * with edges parallel to the axes of the user coordinate system. This means * the matrices from FilterUnits will contain at most a (possibly non-uniform) scale - * and a translation. When all primitives of the filter return false, the rendering is + * and a translation. When all primitives of the filter return true, the rendering is * performed in display coordinate space and no intermediate surface is used. */ virtual bool can_handle_affine(Geom::Affine const &) { return false; } diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 2e5f69d65..c28fd485a 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -174,136 +174,6 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -/* -int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { - NRPixBlock *in = slot.get(_input); - if (!in) { - g_warning("Missing source image for feSpecularLighting (in=%d)", _input); - return 1; - } - - NRPixBlock *out = new NRPixBlock; - - //Fvector *L = NULL; //vector to the light - - int w = in->area.x1 - in->area.x0; - int h = in->area.y1 - in->area.y0; - int x0 = in->area.x0; - int y0 = in->area.y0; - int i, j; - //As long as FilterRes and kernel unit is not supported we hardcode the - //default value - int dx = 1; //TODO setup - int dy = 1; //TODO setup - //surface scale - Geom::Affine trans = units.get_matrix_primitiveunits2pb(); - gdouble ss = surfaceScale * trans[0]; - gdouble ks = specularConstant; //diffuse lighting constant - NR::Fvector L, N, LC, H; - gdouble inter; - - nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, - in->area.x0, in->area.y0, in->area.x1, in->area.y1, - true); - unsigned char *data_i = NR_PIXBLOCK_PX (in); - unsigned char *data_o = NR_PIXBLOCK_PX (out); - //No light, nothing to do - switch (light_type) { - case DISTANT_LIGHT: - //the light vector is constant - { - DistantLight *dl = new DistantLight(light.distant, lighting_color); - dl->light_vector(L); - dl->light_components(LC); - NR::normalized_sum(H, L, NR::EYE_VECTOR); - //finish the work - for (i = 0, j = 0; i < w*h; i++) { - NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); - COMPUTE_INTER(inter, N, H, ks, specularExponent); - - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); // CLAMP includes rounding! - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]); - data_o[j] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]); - ++j; - } - out->empty = FALSE; - delete dl; - } - break; - case POINT_LIGHT: - { - PointLight *pl = new PointLight(light.point, lighting_color, trans); - pl->light_components(LC); - //TODO we need a reference to the filter to determine primitiveUnits - //if objectBoundingBox is used, use a different matrix for light_vector - // UPDATE: trans is now correct matrix from primitiveUnits to - // pixblock coordinates - //finish the work - for (i = 0, j = 0; i < w*h; i++) { - NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); - pl->light_vector(L, - i % w + x0, - i / w + y0, - ss * (double) data_i[4*i+3]/ 255); - NR::normalized_sum(H, L, NR::EYE_VECTOR); - COMPUTE_INTER(inter, N, H, ks, specularExponent); - - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]); - data_o[j] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]); - ++j; - } - out->empty = FALSE; - delete pl; - } - break; - case SPOT_LIGHT: - { - SpotLight *sl = new SpotLight(light.spot, lighting_color, trans); - //TODO we need a reference to the filter to determine primitiveUnits - //if objectBoundingBox is used, use a different matrix for light_vector - // UPDATE: trans is now correct matrix from primitiveUnits to - // pixblock coordinates - //finish the work - for (i = 0, j = 0; i < w*h; i++) { - NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); - sl->light_vector(L, - i % w + x0, - i / w + y0, - ss * (double) data_i[4*i+3]/ 255); - sl->light_components(LC, L); - NR::normalized_sum(H, L, NR::EYE_VECTOR); - COMPUTE_INTER(inter, N, H, ks, specularExponent); - - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]); - data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]); - data_o[j] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]); - ++j; - } - out->empty = FALSE; - delete sl; - } - break; - //else unknown light source, doing nothing - case NO_LIGHT: - default: - { - if (light_type != NO_LIGHT) - g_warning("unknown light source %d", light_type); - out->empty = false; - } - } - - //finishing - slot.set(_output, out); - //nr_pixblock_release(in); - //delete in; - return 0; -}*/ - void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength @@ -314,6 +184,11 @@ void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Affine const & /* area.y1 += 1; } +double FilterSpecularLighting::complexity(Geom::Affine const &) +{ + return 9.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 2fcb02588..8471b70b0 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -31,8 +31,10 @@ public: FilterSpecularLighting(); static FilterPrimitive *create(); virtual ~FilterSpecularLighting(); + virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); union { SPFeDistantLight *distant; diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index b88386638..4aadde2aa 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -45,6 +45,11 @@ void FilterTile::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/) { } +double FilterTile::complexity(Geom::Affine const &) +{ + return 1.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index 5c0a3e553..37e257f79 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -27,6 +27,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual double complexity(Geom::Affine const &ctm); }; } /* namespace Filters */ diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 60d5ce872..f065ded11 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -388,6 +388,11 @@ void FilterTurbulence::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } +double FilterTurbulence::complexity(Geom::Affine const &) +{ + return 5.0; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 8d3639543..9f824ef48 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -45,6 +45,7 @@ public: virtual ~FilterTurbulence(); virtual void render_cairo(FilterSlot &slot); + virtual double complexity(Geom::Affine const &ctm); void set_baseFrequency(int axis, double freq); void set_numOctaves(int num); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index e84e6f0c2..df6b6222b 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -282,6 +282,18 @@ Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) return area; } +double Filter::complexity(Geom::Affine const &ctm) +{ + double factor; + for (unsigned i = 0 ; i < _primitive.size() ; i++) { + if (_primitive[i]) { + double f = _primitive[i]->complexity(ctm); + factor += (f - 1.0); + } + } + return factor; +} + /* Constructor table holds pointers to static methods returning filter * primitives. This table is indexed with FilterPrimitiveType, so that * for example method in _constructor[NR_FILTER_GAUSSIANBLUR] diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 31705f53b..7d31e10ce 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -164,6 +164,9 @@ public: */ Geom::Rect filter_effect_area(Geom::Rect const &bbox); + // returns cache score factor + double complexity(Geom::Affine const &ctm); + /** Creates a new filter with space for one filter element */ Filter(); /** -- cgit v1.2.3 From 16c067ffe728e848bd555b1607d766ccd4162ac5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 9 Aug 2011 06:02:34 +0200 Subject: Turn off debug message spam (bzr r10347.1.27) --- src/display/drawing-item.cpp | 2 +- src/display/drawing-surface.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 3f409b8ee..e86e222e2 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -780,7 +780,7 @@ DrawingItem::_cacheScore() if (_mask) { score += _mask->_cacheScore(); } - g_message("caching score: %f", score); + //g_message("caching score: %f", score); return score; } diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 1faa3151e..39a622fe7 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +//#include #include "display/drawing-surface.h" #include "display/drawing-context.h" #include "display/cairo-utils.h" @@ -263,7 +263,7 @@ DrawingCache::prepare() cairo_rectangle_int_t limit = _convertRect(_pending_area); cairo_region_intersect_rectangle(_clean_region, &limit); } - std::cout << _pending_transform << old_area << _pending_area << std::endl; + //std::cout << _pending_transform << old_area << _pending_area << std::endl; _pending_transform.setIdentity(); } -- cgit v1.2.3 From 74b91362758052e0f03bb819663a4606f08e4c69 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 9 Aug 2011 07:51:45 +0200 Subject: Use cache even if only part of the redraw region is clean (bzr r10347.1.28) --- src/display/drawing-context.h | 3 ++ src/display/drawing-item.cpp | 38 ++++++++++++---------- src/display/drawing-surface.cpp | 71 ++++++++++++++++++++++++++++------------- src/display/drawing-surface.h | 4 +-- 4 files changed, 75 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index 8d2e7d68a..4ada79057 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -64,6 +64,9 @@ public: void rectangle(Geom::Rect const &r) { cairo_rectangle(_ct, r.left(), r.top(), r.width(), r.height()); } + void rectangle(Geom::IntRect const &r) { + cairo_rectangle(_ct, r.left(), r.top(), r.width(), r.height()); + } void newPath() { cairo_new_path(_ct); } void newSubpath() { cairo_new_sub_path(_ct); } void path(Geom::PathVector const &pv); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index e86e222e2..113bf9c33 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -422,7 +422,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag return; } - // carea is the bounding box for intermediate rendering. + // carea is the area to paint Geom::OptIntRect carea = Geom::intersect(area, _drawbox); if (!carea) return; @@ -430,8 +430,8 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag if (_cached) { if (_cache) { _cache->prepare(); - if (_cache->paintFromCache(ct, *carea)) - return; + _cache->paintFromCache(ct, carea); + if (!carea) return; } else { // There is no cache. This could be because caching of this item // was just turned on after the last update phase, or because @@ -447,12 +447,6 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // deleted in setCached() } - // expand carea to contain the dependent area of filters. - if (_filter && render_filters) { - _filter->area_enlarge(*carea, this); - carea.intersectWith(_drawbox); - } - // determine whether this shape needs intermediate rendering. bool needs_intermediate_rendering = false; bool &nir = needs_intermediate_rendering; @@ -480,7 +474,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag if (!needs_intermediate_rendering) { if (_cached && _cache) { Inkscape::DrawingContext cachect(*_cache); - cachect.rectangle(area); + cachect.rectangle(*carea); cachect.clip(); { // 1. clear the corresponding part of cache @@ -498,7 +492,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag ct.setSource(_cache); ct.paint(); // 4. mark as clean - _cache->markClean(area); + _cache->markClean(*carea); return; } else { _renderItem(ct, *carea, flags); @@ -506,7 +500,19 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag } } - DrawingSurface intermediate(*carea); + // iarea is the bounding box for intermediate rendering + // Note 1: pixels inside iarea but outside carea might be invalid + // (incomplete filter dependence region). + // Note 2: We only need to render carea of clip and mask, but + // iarea of the object. + Geom::OptIntRect iarea = carea; + // expand carea to contain the dependent area of filters. + if (_filter && render_filters) { + _filter->area_enlarge(*iarea, this); + iarea.intersectWith(_drawbox); + } + + DrawingSurface intermediate(*iarea); DrawingContext ict(intermediate); // 1. Render clipping path with alpha = opacity. @@ -537,9 +543,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag ict.setOperator(CAIRO_OPERATOR_OVER); } - // 3. Render object itself. + // 3. Render object itself ict.pushGroup(); - _renderItem(ict, *carea, flags); + _renderItem(ict, *iarea, flags); // 4. Apply filter. if (_filter && render_filters) { @@ -557,12 +563,12 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // 6. Paint the completed rendering onto the base context (or into cache) if (_cached && _cache) { DrawingContext cachect(*_cache); - cachect.rectangle(area); + cachect.rectangle(*carea); cachect.clip(); cachect.setOperator(CAIRO_OPERATOR_SOURCE); cachect.setSource(&intermediate); cachect.paint(); - _cache->markClean(area); + _cache->markClean(*carea); } ct.setSource(&intermediate); ct.paint(); diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 39a622fe7..43cf50b88 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -188,16 +188,6 @@ DrawingCache::markClean(Geom::IntRect const &area) cairo_rectangle_int_t clean = _convertRect(*r); cairo_region_union_rectangle(_clean_region, &clean); } -bool -DrawingCache::isClean(Geom::IntRect const &area) const -{ - cairo_rectangle_int_t test = _convertRect(area); - if (cairo_region_contains_rectangle(_clean_region, &test) == CAIRO_REGION_OVERLAP_IN) { - return true; - } else { - return false; - } -} /// Call this during the update phase to schedule a transformation of the cache. void @@ -267,20 +257,46 @@ DrawingCache::prepare() _pending_transform.setIdentity(); } -/** @brief Paints the clean area from cache and returns the remaining part */ -bool -DrawingCache::paintFromCache(DrawingContext &ct, Geom::IntRect const &area) +/** @brief Paints the clean area from cache and modifies the @a area + * parameter to the bounds of the region that must be repainted. */ +void +DrawingCache::paintFromCache(DrawingContext &ct, Geom::OptIntRect &area) { - if (!isClean(area)) - return false; - - Inkscape::DrawingContext::Save save(ct); - ct.rectangle(area); - ct.clip(); - ct.setSource(this); - ct.paint(); - - return true; + if (!area) return; + + // We subtract the clean region from the area, then get the bounds + // of the resulting region. This is the area that needs to be repainted + // by the item. + // Then we subtract the area that needs to be repainted from the + // original area and paint the resulting region from cache. + cairo_rectangle_int_t area_c = _convertRect(*area); + cairo_region_t *dirty_region = cairo_region_create_rectangle(&area_c); + cairo_region_t *cache_region = cairo_region_copy(dirty_region); + cairo_region_subtract(dirty_region, _clean_region); + + if (cairo_region_is_empty(dirty_region)) { + area = Geom::OptIntRect(); + } else { + cairo_rectangle_int_t to_repaint; + cairo_region_get_extents(dirty_region, &to_repaint); + *area = _convertRect(to_repaint); + cairo_region_subtract_rectangle(cache_region, &to_repaint); + } + cairo_region_destroy(dirty_region); + + if (!cairo_region_is_empty(cache_region)) { + Inkscape::DrawingContext::Save save(ct); + int nr = cairo_region_num_rectangles(cache_region); + cairo_rectangle_int_t tmp; + for (int i = 0; i < nr; ++i) { + cairo_region_get_rectangle(cache_region, i, &tmp); + ct.rectangle(_convertRect(tmp)); + } + ct.clip(); + ct.setSource(this); + ct.paint(); + } + cairo_region_destroy(cache_region); } cairo_rectangle_int_t @@ -294,6 +310,15 @@ DrawingCache::_convertRect(Geom::IntRect const &area) return ret; } +Geom::IntRect +DrawingCache::_convertRect(cairo_rectangle_int_t const &r) +{ + Geom::IntRect ret = Geom::IntRect::from_xywh( + r.x, r.y, + r.width, r.height); + return ret; +} + } // end namespace Inkscape /* diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index fd46d66ba..f3af33002 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -63,10 +63,9 @@ public: void markDirty(Geom::IntRect const &area = Geom::IntRect::infinite()); void markClean(Geom::IntRect const &area = Geom::IntRect::infinite()); - bool isClean(Geom::IntRect const &area) const; void scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans); void prepare(); - bool paintFromCache(DrawingContext &ct, Geom::IntRect const &area); + void paintFromCache(DrawingContext &ct, Geom::OptIntRect &area); protected: cairo_region_t *_clean_region; @@ -74,6 +73,7 @@ protected: Geom::Affine _pending_transform; private: static cairo_rectangle_int_t _convertRect(Geom::IntRect const &r); + static Geom::IntRect _convertRect(cairo_rectangle_int_t const &r); }; } // end namespace Inkscape -- cgit v1.2.3 From 604cdd14c76d5da4d52c29bacf5a741d20402aeb Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Tue, 9 Aug 2011 00:17:43 -0700 Subject: Remove unused variable. (bzr r10532) --- src/ink-comboboxentry-action.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index b0fd299bb..cd3b3636e 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -628,7 +628,6 @@ static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { gchar** tokens = g_strsplit( action->text, ",", 0 ); gint i = 0; - gboolean first = TRUE; while( tokens[i] != NULL ) { // Remove any surrounding white space. -- cgit v1.2.3 From 52d06f53a4efef7c6880e34cad9de0c770fc13ad Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 9 Aug 2011 10:01:41 +0200 Subject: Fix invalidation on scrolling (bzr r10347.1.29) --- src/display/drawing-item.cpp | 21 +++++++++++++-------- src/display/drawing-surface.cpp | 6 +----- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 113bf9c33..8da59bbe2 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -296,7 +296,7 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne if ((~_state & flags) == 0) return; // nothing to do // TODO this might be wrong - if (_state & STATE_BBOX) { + if (_state & (outline ? STATE_BBOX : STATE_DRAWBOX)) { // we have up-to-date bbox if (!area.intersects(outline ? _bbox : _drawbox)) return; } @@ -310,6 +310,7 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne _ctm = child_ctx.ctm; // update _bbox + unsigned old_state = _state; _state = _updateItem(area, child_ctx, flags, reset); // compute drawbox @@ -349,7 +350,7 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne if (score >= _drawing._cache_score_threshold) { CacheRecord cr; cr.score = score; - // if _cacheRect() is empty, a negative score will be returnedfrom _cacheScore(), + // if _cacheRect() is empty, a negative score will be returned from _cacheScore(), // so this will not execute (cache score threshold must be positive) cr.cache_size = _cacheRect()->area() * 4; cr.item = this; @@ -381,7 +382,8 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne // now that we know drawbox, dirty the corresponding rect on canvas // unless filtered, groups do not need to render by themselves, only their members if (!is_drawing_group(this) || (_filter && render_filters)) { - if (flags & ~STATE_CACHE) { + // mark for rendering if the item becomes renderable + if ((old_state ^ _state) & STATE_RENDER) { _markForRendering(); } } @@ -501,7 +503,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag } // iarea is the bounding box for intermediate rendering - // Note 1: pixels inside iarea but outside carea might be invalid + // Note 1: Pixels inside iarea but outside carea are invalid // (incomplete filter dependence region). // Note 2: We only need to render carea of clip and mask, but // iarea of the object. @@ -665,11 +667,14 @@ DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) if (!sticky && !(_visible && _sensitive)) return NULL; - if (!_bbox) return NULL; - Geom::Rect expanded(*_bbox); - expanded.expandBy(delta); + // some part of the shape might be hidden by clipping + // TODO add Geom::OptRect(Geom::OptIntRect const &) constructor + Geom::OptIntRect expanded_i = _bbox & _drawbox; + Geom::OptRect expanded = expanded_i ? Geom::Rect(*expanded_i) : Geom::OptRect(); + if (!expanded) return NULL; + expanded->expandBy(delta); - if (expanded.contains(p)) { + if (expanded->contains(p)) { return _pickItem(p, delta, sticky); } return NULL; diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 43cf50b88..e5564f2b3 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -193,7 +193,6 @@ DrawingCache::markClean(Geom::IntRect const &area) void DrawingCache::scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans) { - if (new_area.hasZeroArea() && trans.isIdentity()) return; _pending_area = new_area; _pending_transform *= trans; } @@ -205,15 +204,12 @@ DrawingCache::prepare() { Geom::IntRect old_area = pixelArea(); bool is_identity = _pending_transform.isIdentity(); - if (is_identity) { - if (_pending_area == old_area) return; - } + if (is_identity && _pending_area == old_area) return; // no change bool is_integer_translation = false; if (!is_identity && _pending_transform.isTranslation()) { Geom::IntPoint t = _pending_transform.translation().round(); if (Geom::are_near(Geom::Point(t), _pending_transform.translation())) { - // integer translation or identity with change of area is_integer_translation = true; cairo_region_translate(_clean_region, t[X], t[Y]); if (old_area + t == _pending_area) { -- cgit v1.2.3 From df08cc238f064ebdac402a4c9abd7e1737e0d274 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 9 Aug 2011 22:29:53 +0200 Subject: Filters. New Invert, Wax bump and Felt feather custom predefined filters. Filters. More reorganization and consistency fixes. (bzr r10533) --- src/extension/internal/filter/blurs.h | 10 +- src/extension/internal/filter/bumps.h | 220 ++++++++++++++++++++++++++- src/extension/internal/filter/color.h | 164 ++++++++++++++++++-- src/extension/internal/filter/distort.h | 146 +++++++++++++++++- src/extension/internal/filter/filter-all.cpp | 9 +- src/extension/internal/filter/paint.h | 7 +- 6 files changed, 527 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index b09a4f347..b8a6d7c4c 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -12,7 +12,7 @@ * Clean edges * Cross blur * Feather - * Image blur + * Out of focus * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -280,7 +280,7 @@ Feather::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Feather filter */ /** - \brief Custom predefined Image blur filter. + \brief Custom predefined Out of Focus filter. Blur eroded by white or transparency @@ -307,7 +307,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Image Blur") "\n" + "" N_("Out of Focus") "\n" "org.inkscape.effect.filter.ImageBlur\n" "\n" "\n" @@ -380,7 +380,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -393,7 +393,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) background.str().c_str(), blend.str().c_str(), opacity.str().c_str()); return _filter; -}; /* Image blur filter */ +}; /* Out of Focus filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index e8c80315a..9d46a25b2 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -12,6 +12,7 @@ * Diffuse light * Matte jelly * Specular light + * Wax bump * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -37,7 +38,7 @@ namespace Filter { Options * Image simplification (0.01->10., default 0.01) -> blur1 (stdDeviation) * Bump simplification (0.01->10., default 0.01) -> blur2 (stdDeviation) - * Crop (-50.->50., default 1) -> composite1 (k3) + * Crop (-50.->50., default 0.) -> composite1 (k3) * Red (-50.->50., default 0.) -> colormatrix1 (values) * Green (-50.->50., default 0.) -> colormatrix1 (values) * Blue (-50.->50., default 0.) -> colormatrix1 (values) @@ -85,7 +86,7 @@ public: "\n" "0.01\n" "0.01\n" - "1\n" + "0\n" "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "\n" "0\n" "0\n" @@ -513,6 +514,221 @@ SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* SpecularLight filter */ +/** + \brief Custom predefined Wax Bump filter. + + Turns an image to jelly + + Filter's parameters: + Options + * Image simplification (0.01->10., default 1.5) -> blur1 (stdDeviation) + * Bump simplification (0.01->10., default 1) -> blur2 (stdDeviation) + * Crop (-10.->10., default 1.) -> colormatrix2 (4th value of the last line) + * Red (-10.->10., default 0.) -> colormatrix2 (values, substract 0.21) + * Green (-10.->10., default 0.) -> colormatrix2 (values, substract 0.72) + * Blue (-10.->10., default 0.) -> colormatrix2 (values, substract 0.07) + * Background (enum, default color) -> + * color: colormatrix1 (in="flood1") + * image: colormatrix1 (in="SourceGraphic") + * blurred image: colormatrix1 (in="blur1") + * Background opacity (0.->1., default 0) -> colormatrix1 (last value) + Lighting (specular, distant light) + * Color (guint, default -1 (RGB:255,255,255))-> lighting (lighting-color) + * Height (-50.->50., default 5.) -> lighting (surfaceScale) + * Lightness (0.->10., default 1.4) -> lighting [diffuselighting (diffuseConstant)|specularlighting (specularConstant)] + * Precision (0->50, default 35) -> lighting (specularExponent) + * Azimuth (0->360, default 225) -> lightsOptions (distantAzimuth) + * Elevation (0->180, default 60) -> lightsOptions (distantElevation) + * Lighting blend (enum, default screen) -> blend1 (mode) + * Highlight blend (enum, default screen) -> blend2 (mode) + Bump + * Trasparency type (enum [in,atop], default atop) -> composite2 (operator) + * Color (guint, default -520083713 (RGB:225,0,38)) -> flood2 (flood-color) + * Revert bump (boolean, default false) -> composite1 (false: operator="out", true operator="in") +*/ + +class WaxBump : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + WaxBump ( ) : Filter() { }; + virtual ~WaxBump ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Wax Bump") "\n" + "org.inkscape.effect.filter.WaxBump\n" + "\n" + "\n" + "1.5\n" + "1\n" + "1\n" + "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "\n" + "0\n" + "0\n" + "0\n" + "\n" + "<_item value=\"flood1\">" N_("Color") "\n" + "<_item value=\"SourceGraphic\">" N_("Image") "\n" + "<_item value=\"blur1\">" N_("Blurred image") "\n" + "\n" + "0\n" + "\n" + "\n" + "-1\n" + "5\n" + "1.4\n" + "35\n" + "225\n" + "60\n" + "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "\n" + "\n" + "-520083713\n" + "false\n" + "\n" + "<_item value=\"atop\">" N_("Atop") "\n" + "<_item value=\"in\">" N_("In") "\n" + "\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Turns an image to jelly") "\n" + "\n" + "\n", new WaxBump()); + }; + +}; + +gchar const * +WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream simplifyImage; + std::ostringstream simplifyBump; + std::ostringstream crop; + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + + std::ostringstream background; + std::ostringstream bgopacity; + + std::ostringstream height; + std::ostringstream lightness; + std::ostringstream precision; + std::ostringstream distantAzimuth; + std::ostringstream distantElevation; + + std::ostringstream lightRed; + std::ostringstream lightGreen; + std::ostringstream lightBlue; + + std::ostringstream floodRed; + std::ostringstream floodGreen; + std::ostringstream floodBlue; + std::ostringstream floodAlpha; + + std::ostringstream revert; + std::ostringstream lightingblend; + std::ostringstream highlightblend; + std::ostringstream transparency; + + simplifyImage << ext->get_param_float("simplifyImage"); + simplifyBump << ext->get_param_float("simplifyBump"); + crop << ext->get_param_float("crop"); + + red << ext->get_param_float("red") - 0.21; + green << ext->get_param_float("green") - 0.72; + blue << ext->get_param_float("blue") - 0.07; + + background << ext->get_param_enum("background"); + bgopacity << ext->get_param_float("bgopacity"); + + height << ext->get_param_float("height"); + lightness << ext->get_param_float("lightness"); + precision << ext->get_param_int("precision"); + distantAzimuth << ext->get_param_int("distantAzimuth"); + distantElevation << ext->get_param_int("distantElevation"); + + guint32 lightingColor = ext->get_param_color("lightingColor"); + lightRed << ((lightingColor >> 24) & 0xff); + lightGreen << ((lightingColor >> 16) & 0xff); + lightBlue << ((lightingColor >> 8) & 0xff); + + guint32 imageColor = ext->get_param_color("imageColor"); + floodRed << ((imageColor >> 24) & 0xff); + floodGreen << ((imageColor >> 16) & 0xff); + floodBlue << ((imageColor >> 8) & 0xff); + floodAlpha << (imageColor & 0xff) / 255.0F; + + if (ext->get_param_bool("revert")) { + revert << "in" ; + } else { + revert << "out" ; + } + + lightingblend << ext->get_param_enum("lightingblend"); + highlightblend << ext->get_param_enum("highlightblend"); + transparency << ext->get_param_enum("transparency"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", simplifyImage.str().c_str(), background.str().c_str(), bgopacity.str().c_str(), + red.str().c_str(), green.str().c_str(), blue.str().c_str(), crop.str().c_str(), + floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(), + revert.str().c_str(), simplifyBump.str().c_str(), + lightRed.str().c_str(), lightGreen.str().c_str(), lightBlue.str().c_str(), + lightness.str().c_str(), height.str().c_str(), precision.str().c_str(), + distantElevation.str().c_str(), distantAzimuth.str().c_str(), + lightingblend.str().c_str(), transparency.str().c_str(), highlightblend.str().c_str() ); + + return _filter; + +}; /* Wax bump filter */ + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index e19c2054d..b34c2c61f 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -8,12 +8,13 @@ * Nicolas Dufour (UI) * * Color filters - * Brightness + * Brilliance * Channel painting * Color shift * Colorize * Duochrome * Greyscale + * Invert * Lightness * Quadritone * Solarize @@ -35,12 +36,12 @@ namespace Internal { namespace Filter { /** - \brief Custom predefined Brightness filter. + \brief Custom predefined Brilliance filter. - Brightness filter. + Brilliance filter. Filter's parameters: - * Brightness (1.->10., default 2.) -> colorMatrix (RVB entries) + * Brilliance (1.->10., default 2.) -> colorMatrix (RVB entries) * Over-saturation (0.->10., default 0.5) -> colorMatrix (6 other entries) * Lightness (-10.->10., default 0.) -> colorMatrix (last column) * Inverted (boolean, default false) -> colorMatrix @@ -51,18 +52,18 @@ namespace Filter { Vi Vi St 0 Li 0 0 0 1 0 */ -class Brightness : public Inkscape::Extension::Internal::Filter::Filter { +class Brilliance : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - Brightness ( ) : Filter() { }; - virtual ~Brightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + Brilliance ( ) : Filter() { }; + virtual ~Brilliance ( ) { if (_filter != NULL) g_free((void *)_filter); return; } static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Brightness") "\n" + "" N_("Brilliance") "\n" "org.inkscape.effect.filter.Brightness\n" "2\n" "0.5\n" @@ -77,12 +78,12 @@ public: "\n" "" N_("Brightness filter") "\n" "\n" - "\n", new Brightness()); + "\n", new Brilliance()); }; }; gchar const * -Brightness::get_filter_text (Inkscape::Extension::Extension * ext) +Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); @@ -101,7 +102,7 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), @@ -109,7 +110,7 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str()); return _filter; -}; /* Brightness filter */ +}; /* Brilliance filter */ /** \brief Custom predefined Channel Painting filter. @@ -607,6 +608,145 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Greyscale filter */ +/** + \brief Custom predefined Invert filter. + + Manage hue, lightness and transparency inversions + + Filter's parameters: + * Invert hue (boolean, default false) -> color1 (values, true: 180, false: 0) + * Invert lightness (boolean, default false) -> color1 (values, true: 180, false: 0; XOR with Invert hue), + color2 (values: from a00 to a22, if 1, set -1 and set 1 in ax4, if -1, set 1 and set 0 in ax4) + * Invert transparency (boolean, default false) -> color2 (values: negate a30, a31 and a32, substract 1 from a33) + * Invert channels (enum, default Red and blue) -> color2 (values -for R&B: swap ax0 and ax2 in the first 3 lines) + * Light transparency (0.->1., default 0.) -> color2 (values: a33=a33-x) +*/ + +class Invert : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Invert ( ) : Filter() { }; + virtual ~Invert ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Invert") "\n" + "org.inkscape.effect.filter.Invert\n" + "\n" + "<_item value=\"0\">" N_("No invertion") "\n" + "<_item value=\"1\">" N_("Red and blue") "\n" + "<_item value=\"2\">" N_("Red and green") "\n" + "<_item value=\"3\">" N_("Green and blue") "\n" + "\n" + "0\n" + "false\n" + "false\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Manage hue, lightness and transparency inversions") "\n" + "\n" + "\n", new Invert()); + }; + +}; + +gchar const * +Invert::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream line1; + std::ostringstream line2; + std::ostringstream line3; + + std::ostringstream col5; + std::ostringstream transparency; + std::ostringstream hue; + + if (ext->get_param_bool("hue") xor ext->get_param_bool("lightness")) { + hue << "\n"; + } else { + hue << ""; + } + + if (ext->get_param_bool("transparency")) { + transparency << "0.21 0.72 0.07 " << 1 - ext->get_param_float("opacify"); + } else { + transparency << "-0.21 -0.72 -0.07 " << 2 - ext->get_param_float("opacify"); + } + + if (ext->get_param_bool("lightness")) { + switch (atoi(ext->get_param_enum("channels"))) { + case 1: + line1 << "0 0 -1"; + line2 << "0 -1 0"; + line3 << "-1 0 0"; + break; + case 2: + line1 << "0 -1 0"; + line2 << "-1 0 0"; + line3 << "0 0 -1"; + break; + case 3: + line1 << "-1 0 0"; + line2 << "0 0 -1"; + line3 << "0 -1 0"; + break; + default: + line1 << "-1 0 0"; + line2 << "0 -1 0"; + line3 << "0 0 -1"; + break; + } + col5 << "1"; + } else { + switch (atoi(ext->get_param_enum("channels"))) { + case 1: + line1 << "0 0 1"; + line2 << "0 1 0"; + line3 << "1 0 0"; + break; + case 2: + line1 << "0 1 0"; + line2 << "1 0 0"; + line3 << "0 0 1"; + break; + case 3: + line1 << "1 0 0"; + line2 << "0 0 1"; + line3 << "0 1 0"; + break; + default: + line1 << "1 0 0"; + line2 << "0 1 0"; + line3 << "0 0 1"; + break; + } + col5 << "0"; + } + + _filter = g_strdup_printf( + "\n" + "%s" + "\n" + "\n", hue.str().c_str(), + line1.str().c_str(), col5.str().c_str(), + line2.str().c_str(), col5.str().c_str(), + line3.str().c_str(), col5.str().c_str(), + transparency.str().c_str() ); + + return _filter; +}; /* Invert filter */ + /** \brief Custom predefined Lightness filter. diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index 7157722d7..3972029ae 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -8,6 +8,7 @@ * Nicolas Dufour (UI) * * Distort filters + * Felt Feather * Roughen * * Released under GNU GPL, read the file 'COPYING' for more information @@ -25,6 +26,139 @@ namespace Extension { namespace Internal { namespace Filter { +/** + \brief Custom predefined FeltFeather filter. + + Blur and displace edges of shapes and pictures + + Filter's parameters: + * Type (enum, default "In") -> + in = map (in="composite3") + out = map (in="blur") + * Horizontal blur (0.01->30., default 15) -> blur (stdDeviation) + * Vertical blur (0.01->30., default 15) -> blur (stdDeviation) + * Dilatation (n-1th value, 0.->100., default 1) -> colormatrix (matrix) + * Erosion (nth value, 0.->100., default 0) -> colormatrix (matrix) + * Stroke (enum, default "Normal") -> + Normal = composite4 (operator="atop") + Wide = composite4 (operator="over") + Narrow = composite4 (operator="in") + No fill = composite4 (operator="xor") + + * Roughness (group) + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 3) -> turbulence (numOctaves) + * Variation (0->100, default 0) -> turbulence (seed) +*/ + +class FeltFeather : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + FeltFeather ( ) : Filter() { }; + virtual ~FeltFeather ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Felt Feather") "\n" + "org.inkscape.effect.filter.FeltFeather\n" + "\n" + "<_item value=\"in\">" N_("In") "\n" + "<_item value=\"out\">" N_("Out") "\n" + "\n" + "15\n" + "15\n" + "1\n" + "0\n" + "\n" + "<_item value=\"atop\">" N_("Normal") "\n" + "<_item value=\"over\">" N_("Wide") "\n" + "<_item value=\"in\">" N_("Narrow") "\n" + "<_item value=\"xor\">" N_("No fill") "\n" + "\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "0.05\n" + "0.05\n" + "3\n" + "0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Blur and displace edges of shapes and pictures") "\n" + "\n" + "\n", new FeltFeather()); + }; + +}; + +gchar const * +FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream dilat; + std::ostringstream erosion; + + std::ostringstream turbulence; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + + std::ostringstream map; + std::ostringstream stroke; + + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + dilat << ext->get_param_float("dilat"); + erosion << -ext->get_param_float("erosion"); + + turbulence << ext->get_param_enum("turbulence"); + hfreq << ext->get_param_float("hfreq"); + vfreq << ext->get_param_float("vfreq"); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + + stroke << ext->get_param_enum("stroke"); + + const gchar *maptype = ext->get_param_enum("type"); + if (g_ascii_strcasecmp("in", maptype) == 0) { + map << "composite3"; + } else { + map << "blur"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", hblur.str().c_str(), vblur.str().c_str(), + turbulence.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), + map.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), stroke.str().c_str() ); + + return _filter; +}; /* Felt feather filter */ + /** \brief Custom predefined Roughen filter. @@ -32,8 +166,8 @@ namespace Filter { Filter's parameters: * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Horizontal frequency (0.01->10., default 0.013) -> turbulence (baseFrequency) + * Vertical frequency (0.01->10., default 0.013) -> turbulence (baseFrequency) * Complexity (1->5, default 5) -> turbulence (numOctaves) * Variation (1->360, default 1) -> turbulence (seed) * Intensity (0.0->50., default 6.6) -> displacement (scale) @@ -56,8 +190,8 @@ public: "<_item value=\"fractalNoise\">Fractal noise\n" "<_item value=\"turbulence\">Turbulence\n" "\n" - "13\n" - "13\n" + "0.013\n" + "0.013\n" "5\n" "0\n" "6.6\n" @@ -88,8 +222,8 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream intensity; type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); + hfreq << ext->get_param_float("hfreq"); + vfreq << ext->get_param_float("vfreq"); complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); intensity << ext->get_param_float("intensity"); diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 5b3280656..dcd68b75a 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -45,20 +45,23 @@ Filter::filters_all (void ) DiffuseLight::init(); MatteJelly::init(); SpecularLight::init(); + WaxBump::init(); // Color - Brightness::init(); + Brilliance::init(); ChannelPaint::init(); ColorShift::init(); Colorize::init(); Duochrome::init(); Greyscale::init(); + Invert::init(); Lightness::init(); Quadritone::init(); Solarize::init(); Tritone::init(); // Distort + FeltFeather::init(); Roughen::init(); // Image effect @@ -70,6 +73,7 @@ Filter::filters_all (void ) Drawing::init(); Electrize::init(); NeonDraw::init(); + //PointEngraving::init(); Posterize::init(); PosterizeBasic::init(); @@ -86,6 +90,9 @@ Filter::filters_all (void ) // Shadows and glows ColorizableDropShadow::init(); + // Textures + // InkBlot::init(); + // Fill and transparency ChannelTransparency::init(); Silhouette::init(); diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index c2eb0c0ae..a3077d1c4 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -628,12 +628,13 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) lightness << ext->get_param_float("lightness"); const gchar *typestr = ext->get_param_enum("type"); - if (ext->get_param_bool("dark")) + if (ext->get_param_bool("dark")) { dark << "component2"; - else if ((g_ascii_strcasecmp("table", typestr) == 0)) + } else if ((g_ascii_strcasecmp("table", typestr) == 0)) { dark << "blur2"; - else + } else { dark << "component1"; + } _filter = g_strdup_printf( "\n" -- cgit v1.2.3 From f0d6cbd77ecb7d022539e5019d2a8532f346084c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 9 Aug 2011 22:30:14 +0200 Subject: Do not leak cache objects in DrawingItem destructor (bzr r10347.1.30) --- src/display/drawing-item.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 8da59bbe2..ae3dd49ab 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -76,10 +76,8 @@ DrawingItem::~DrawingItem() // g_warning("Removing item with children"); //} - // remove from the set of cached items - if (_cached) { - _drawing._cached_items.erase(this); - } + // remove from the set of cached items and delete cache + setCached(false, true); if (_has_cache_iterator) { _drawing._candidate_items.erase(_cache_iterator); } -- cgit v1.2.3 From c1e8d3c29bde66b87e8f19bb859d074e77a9e982 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 10 Aug 2011 21:39:47 +0200 Subject: Filters. New Blend, Extract Channel and Ink Blot custom predefined filters. (bzr r10534) --- src/extension/internal/filter/bumps.h | 3 +- src/extension/internal/filter/color.h | 103 +++++++++++++++++++++++++++ src/extension/internal/filter/filter-all.cpp | 5 +- src/extension/internal/filter/transparency.h | 68 ++++++++++++++++++ 4 files changed, 176 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 9d46a25b2..b8617eafc 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -698,13 +698,12 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index b34c2c61f..fb6ea0ab9 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -13,6 +13,7 @@ * Color shift * Colorize * Duochrome + * Extract channel * Greyscale * Invert * Lightness @@ -517,6 +518,108 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Duochrome filter */ +/** + \brief Custom predefined Extract Channel filter. + + Extract color channel as a transparent image. + + Filter's parameters: + * Channel (enum, all colors, default Red) -> colormatrix (values) + * Background blend (enum, all blend modes, default Multiply) -> blend (mode) + * Channel to alpha (boolean, default false) -> colormatrix (values) + * Invert (boolean, default false) -> colormatrix (values) + +*/ +class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ExtractChannel ( ) : Filter() { }; + virtual ~ExtractChannel ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Extract Channel") "\n" + "org.inkscape.effect.filter.ExtractChannel\n" + "\n" + "<_item value=\"r\">" N_("Red") "\n" + "<_item value=\"g\">" N_("Green") "\n" + "<_item value=\"b\">" N_("Blue") "\n" + "\n" + "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "false\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Extract color channel as a transparent image") "\n" + "\n" + "\n", new ExtractChannel()); + }; +}; + +gchar const * +ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blend; + std::ostringstream colors; + std::ostringstream alpha; + std::ostringstream invert; + + blend << ext->get_param_enum("blend"); + + const gchar *channel = ext->get_param_enum("source"); + if (ext->get_param_bool("alpha")) { + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; + } else if ((g_ascii_strcasecmp("r", channel) == 0)) { + colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0"; + } else if ((g_ascii_strcasecmp("g", channel) == 0)) { + colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0"; + } else { + colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1"; + } + + if (ext->get_param_bool("invert")) { + if ((g_ascii_strcasecmp("r", channel) == 0)) { + alpha << "-1 0 0 1"; + } else if ((g_ascii_strcasecmp("g", channel) == 0)) { + alpha << "0 -1 0 1"; + } else { + alpha << "0 0 -1 1"; + } + } else { + if ((g_ascii_strcasecmp("r", channel) == 0)) { + alpha << "1 0 0 0"; + } else if ((g_ascii_strcasecmp("g", channel) == 0)) { + alpha << "0 1 0 0"; + } else { + alpha << "0 0 1 0"; + } + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() ); + + return _filter; +}; /* ExtractChannel filter */ + /** \brief Custom predefined Greyscale filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index dcd68b75a..30376d231 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -18,6 +18,7 @@ #include "paint.h" #include "protrusions.h" #include "shadows.h" +#include "textures.h" #include "transparency.h" namespace Inkscape { @@ -53,6 +54,7 @@ Filter::filters_all (void ) ColorShift::init(); Colorize::init(); Duochrome::init(); + ExtractChannel::init(); Greyscale::init(); Invert::init(); Lightness::init(); @@ -91,9 +93,10 @@ Filter::filters_all (void ) ColorizableDropShadow::init(); // Textures - // InkBlot::init(); + InkBlot::init(); // Fill and transparency + Blend::init(); ChannelTransparency::init(); Silhouette::init(); diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index f8f02575b..9fd6cac22 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -8,6 +8,7 @@ * Nicolas Dufour (UI) * * Fill and transparency filters + * Blend * Channel transparency * Silhouette * @@ -26,6 +27,73 @@ namespace Extension { namespace Internal { namespace Filter { +/** + \brief Custom predefined Blend filter. + + Blend objecs with background images or with themselves + + Filter's parameters: + * Source (enum [SourceGraphic,BackgroundImage], default BackgroundImage) -> blend (in2) + * Mode (enum, all blend modes, default Multiply) -> blend (mode) +*/ + +class Blend : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Blend ( ) : Filter() { }; + virtual ~Blend ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Blend") "\n" + "org.inkscape.effect.filter.Blend\n" + "\n" + "<_item value=\"BackgroundImage\">" N_("Background") "\n" + "<_item value=\"SourceGraphic\">" N_("Image") "\n" + "\n" + "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Blend objecs with background images or with themselves") "\n" + "\n" + "\n", new Blend()); + }; + +}; + +gchar const * +Blend::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream source; + std::ostringstream mode; + + source << ext->get_param_enum("source"); + mode << ext->get_param_enum("mode"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", source.str().c_str(), mode.str().c_str() ); + + return _filter; +}; /* Blend filter */ + /** \brief Custom predefined Channel transparency filter. -- cgit v1.2.3 From 74989927846c114eda06120fcc13ff3bd55fde6e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 10 Aug 2011 21:45:15 +0200 Subject: Filters. Forgotten textures file... (bzr r10535) --- src/extension/internal/filter/textures.h | 158 +++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 src/extension/internal/filter/textures.h (limited to 'src') diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h new file mode 100644 index 000000000..17fccfcbc --- /dev/null +++ b/src/extension/internal/filter/textures.h @@ -0,0 +1,158 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ +/* Change the 'TEXTURES' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Protrusion filters + * Ink blot + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + + +/** + \brief Custom predefined Ink Blot filter. + + Inkblot on tissue or rough paper. + + Filter's parameters: + + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Frequency (0.001->1., default 0.04) -> turbulence (baseFrequency) + * Complexity (1->5, default 3) -> turbulence (numOctaves) + * Variation (0->100, default 0) -> turbulence (seed) + * Horizontal inlay (0.01->30., default 10) -> blur1 (stdDeviation x) + * Vertical inlay (0.01->30., default 10) -> blur1 (stdDeviation y) + * Displacement (0.->100., default 50) -> map (scale) + * Blend (0.01->30., default 5) -> blur2 (stdDeviation) + * Stroke (enum, default over) -> composite (operator) + * Arithmetic stroke options + * k1 (-10.->10., default 1.5) + * k2 (-10.->10., default -0.25) + * k3 (-10.->10., default 0.5) +*/ +class InkBlot : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + InkBlot ( ) : Filter() { }; + virtual ~InkBlot ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + +public: + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Ink Blot") "\n" + "org.inkscape.effect.filter.InkBlot\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "0.04\n" + "3\n" + "0\n" + "10\n" + "10\n" + "50\n" + "5\n" + "\n" + "<_item value=\"over\">Wide\n" + "<_item value=\"atop\">Normal\n" + "<_item value=\"in\">Narrow\n" + "<_item value=\"xor\">Overlapping\n" + "<_item value=\"out\">External\n" + "<_item value=\"arithmetic\">Custom\n" + "\n" + "<_param name=\"customHeader\" type=\"description\" appearance=\"header\">" N_("Custom stroke options") "\n" + "1.5\n" + "-0.25\n" + "0.5\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Inkblot on tissue or rough paper") "\n" + "\n" + "\n", new InkBlot()); + }; + +}; + +gchar const * +InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream freq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream displacement; + std::ostringstream blend; + std::ostringstream stroke; + std::ostringstream custom; + + type << ext->get_param_enum("type"); + freq << ext->get_param_float("freq"); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + displacement << ext->get_param_float("displacement"); + blend << ext->get_param_float("blend"); + + const gchar *ope = ext->get_param_enum("stroke"); + if (g_ascii_strcasecmp("arithmetic", ope) == 0) { + custom << "k1=\"" << ext->get_param_float("k1") << "\" k2=\"" << ext->get_param_float("k2") << "\" k3=\"" << ext->get_param_float("k3") << "\""; + } else { + custom << ""; + } + + stroke << ext->get_param_enum("stroke"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", hblur.str().c_str(), vblur.str().c_str(), type.str().c_str(), + freq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), + displacement.str().c_str(), blend.str().c_str(), + custom.str().c_str(), stroke.str().c_str() ); + + return _filter; + +}; /* Ink Blot filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'TEXTURES' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ */ -- cgit v1.2.3 From f8ec6beee66399feae2bd94d6f212aaeb86d1a50 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 11 Aug 2011 18:47:03 +0200 Subject: Filters. New Point engraving and Nudge custom predefined filters. Translations. Translation list and template files update. (bzr r10536) --- src/extension/internal/filter/color.h | 146 ++++++++++++++++++++++++- src/extension/internal/filter/distort.h | 37 ++++--- src/extension/internal/filter/filter-all.cpp | 3 +- src/extension/internal/filter/paint.h | 155 +++++++++++++++++++++++++++ src/extension/internal/filter/textures.h | 6 +- 5 files changed, 325 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index fb6ea0ab9..e9aea4ed2 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -17,6 +17,7 @@ * Greyscale * Invert * Lightness + * Nudge * Quadritone * Solarize * Tritone @@ -65,7 +66,7 @@ public: Inkscape::Extension::build_from_mem( "\n" "" N_("Brilliance") "\n" - "org.inkscape.effect.filter.Brightness\n" + "org.inkscape.effect.filter.Brilliance\n" "2\n" "0.5\n" "0\n" @@ -916,6 +917,149 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Lightness filter */ +/** + \brief Custom predefined Nudge filter. + + Nudge separately RGB channels and blend them to different types of backgrounds + + Filter's parameters: + Offsets + * Red + * x (-100.->100., default -7) -> offset1 (dx) + * y (-100.->100., default 5) -> offset1 (dy) + * Green + * x (-100.->100., default 0) -> offset2 (dx) + * y (-100.->100., default 10) -> offset2 (dy) + * Blue + * x (-100.->100., default 3) -> offset3 (dx) + * y (-100.->100., default -9) -> offset3 (dy) + Color + * Background color (guint, default -1)-> flood (flood-color, flood-opacity) + * Blend type (enum [normal,multiply and screen], default screen) -> blend1,2,3 (mode) + * Blend source (enum, default color) -> + * color: blend1 (in="flood") + * image: blend1 (in="SourceGraphic") + * background: blend1 (in="BackgroundImage") + * Composite (enum [in,over], default over) -> composite (operator) + +*/ +class Nudge : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Nudge ( ) : Filter() { }; + virtual ~Nudge ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Nudge") "\n" + "org.inkscape.effect.filter.Nudge\n" + "\n" + "\n" + "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "\n" + "-7\n" + "5\n" + "<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "\n" + "0\n" + "10\n" + "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "\n" + "3\n" + "-9\n" + "\n" + "\n" + "255\n" + "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "\n" + "\n" + "<_item value=\"flood\">" N_("Color") "\n" + "<_item value=\"SourceGraphic\">" N_("Image") "\n" + "<_item value=\"BackgroundImage\">" N_("Background") "\n" + "\n" + "\n" + "<_item value=\"over\">" N_("Over") "\n" + "<_item value=\"in\">" N_("In") "\n" + "\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Nudge separately RGB channels and blend them to different types of backgrounds") "\n" + "\n" + "\n", new Nudge()); + }; +}; + +gchar const * +Nudge::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream rx; + std::ostringstream ry; + std::ostringstream gx; + std::ostringstream gy; + std::ostringstream bx; + std::ostringstream by; + + std::ostringstream blend; + std::ostringstream source; + std::ostringstream composite; + + std::ostringstream a; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + + rx << ext->get_param_float("rx"); + ry << ext->get_param_float("ry"); + gx << ext->get_param_float("gx"); + gy << ext->get_param_float("gy"); + bx << ext->get_param_float("bx"); + by << ext->get_param_float("by"); + + blend << ext->get_param_enum("blend"); + source << ext->get_param_enum("source"); + composite << ext->get_param_enum("composite"); + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(), + gx.str().c_str(), gy.str().c_str(), blend.str().c_str(), + bx.str().c_str(), by.str().c_str(), blend.str().c_str(), + composite.str().c_str()); + + return _filter; + +}; /* Nudge filter */ + /** \brief Custom predefined Quadritone filter. diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index 3972029ae..56855abea 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -44,13 +44,13 @@ namespace Filter { Wide = composite4 (operator="over") Narrow = composite4 (operator="in") No fill = composite4 (operator="xor") - * Roughness (group) * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/1000]) + * Horizontal frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/100]) + * Vertical frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/100]) * Complexity (1->5, default 3) -> turbulence (numOctaves) * Variation (0->100, default 0) -> turbulence (seed) + * Intensity (0.0->100., default 30) -> displacement (scale) */ class FeltFeather : public Inkscape::Extension::Internal::Filter::Filter { @@ -84,10 +84,11 @@ public: "<_item value=\"fractalNoise\">Fractal noise\n" "<_item value=\"turbulence\">Turbulence\n" "\n" - "0.05\n" - "0.05\n" + "5\n" + "5\n" "3\n" "0\n" + "30\n" "\n" "all\n" "\n" @@ -118,7 +119,8 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream vfreq; std::ostringstream complexity; std::ostringstream variation; - + std::ostringstream intensity; + std::ostringstream map; std::ostringstream stroke; @@ -128,11 +130,12 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) erosion << -ext->get_param_float("erosion"); turbulence << ext->get_param_enum("turbulence"); - hfreq << ext->get_param_float("hfreq"); - vfreq << ext->get_param_float("vfreq"); + hfreq << ext->get_param_float("hfreq") / 100; + vfreq << ext->get_param_float("vfreq") / 100; complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); - + intensity << ext->get_param_float("intensity"); + stroke << ext->get_param_enum("stroke"); const gchar *maptype = ext->get_param_enum("type"); @@ -149,12 +152,12 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n", hblur.str().c_str(), vblur.str().c_str(), turbulence.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), - map.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), stroke.str().c_str() ); + map.str().c_str(), intensity.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), stroke.str().c_str() ); return _filter; }; /* Felt feather filter */ @@ -166,8 +169,8 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (0.01->10., default 0.013) -> turbulence (baseFrequency) - * Vertical frequency (0.01->10., default 0.013) -> turbulence (baseFrequency) + * Horizontal frequency (0.001->10., default 0.013) -> turbulence (baseFrequency [/100]) + * Vertical frequency (0.001->10., default 0.013) -> turbulence (baseFrequency [/100]) * Complexity (1->5, default 5) -> turbulence (numOctaves) * Variation (1->360, default 1) -> turbulence (seed) * Intensity (0.0->50., default 6.6) -> displacement (scale) @@ -190,8 +193,8 @@ public: "<_item value=\"fractalNoise\">Fractal noise\n" "<_item value=\"turbulence\">Turbulence\n" "\n" - "0.013\n" - "0.013\n" + "1.3\n" + "1.3\n" "5\n" "0\n" "6.6\n" @@ -222,8 +225,8 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream intensity; type << ext->get_param_enum("type"); - hfreq << ext->get_param_float("hfreq"); - vfreq << ext->get_param_float("vfreq"); + hfreq << ext->get_param_float("hfreq") / 100; + vfreq << ext->get_param_float("vfreq") / 100; complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); intensity << ext->get_param_float("intensity"); diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 30376d231..f288c27b8 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -58,6 +58,7 @@ Filter::filters_all (void ) Greyscale::init(); Invert::init(); Lightness::init(); + Nudge::init(); Quadritone::init(); Solarize::init(); Tritone::init(); @@ -75,7 +76,7 @@ Filter::filters_all (void ) Drawing::init(); Electrize::init(); NeonDraw::init(); - //PointEngraving::init(); + PointEngraving::init(); Posterize::init(); PosterizeBasic::init(); diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index a3077d1c4..7c3bbfcd3 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -13,6 +13,7 @@ * Drawing * Electrize * Neon draw + * Point engraving * Posterize * Posterize basic * @@ -658,6 +659,160 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* NeonDraw filter */ +/** + \brief Custom predefined Point engraving filter. + + Convert image to a transparent point engraving + + Filter's parameters: + + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (0.001->1., default 1) -> turbulence (baseFrequency [/100]) + * Vertical frequency (0.001->1., default 1) -> turbulence (baseFrequency [/100]) + * Complexity (1->5, default 3) -> turbulence (numOctaves) + * Variation (0->1000, default 0) -> turbulence (seed) + * Noise reduction (-1000->-1500, default -1045) -> convolve (kernelMatrix, central value) + * Noise blend (enum, all blend options, default normal) -> blend (mode) + * Lightness (0.->10., default 2.5) -> composite1 (k1) + * Grain lightness (0.->10., default 1.3) -> composite1 (k2) + * Erase (0.00->1., default 0) -> composite1 (k4) + * Blur (0.01->2., default 0.5) -> blur (stdDeviation) + + * Drawing color (guint32, default rgb(73,69,40)) -> flood1 (flood-color, flood-opacity) + + * Background color (guint32, default rgb(255,255,255)) -> flood2 (flood-color, flood-opacity) +*/ + +class PointEngraving : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + PointEngraving ( ) : Filter() { }; + virtual ~PointEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Point Engraving") "\n" + "org.inkscape.effect.filter.PointEngraving\n" + "\n" + "\n" + "\n" + "<_item value=\"fractalNoise\">Fractal noise\n" + "<_item value=\"turbulence\">Turbulence\n" + "\n" + "100\n" + "100\n" + "3\n" + "0\n" + "45\n" + "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "\n" + "2.5\n" + "1.3\n" + "0\n" + "0.5\n" + "\n" + "\n" + "1229269247\n" + "\n" + "\n" + "255\n" + "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Convert image to a transparent point engraving") "\n" + "\n" + "\n", new PointEngraving()); + }; + +}; + +gchar const * +PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream reduction; + std::ostringstream blend; + std::ostringstream lightness; + std::ostringstream grain; + std::ostringstream erase; + std::ostringstream blur; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream br; + std::ostringstream bg; + std::ostringstream bb; + std::ostringstream ba; + + type << ext->get_param_enum("type"); + hfreq << ext->get_param_float("hfreq") / 100; + vfreq << ext->get_param_float("vfreq") / 100; + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + reduction << (-1000 - ext->get_param_int("reduction")); + blend << ext->get_param_enum("blend"); + lightness << ext->get_param_float("lightness"); + grain << ext->get_param_float("grain"); + erase << ext->get_param_float("erase"); + blur << ext->get_param_float("blur"); + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + guint32 bgcolor = ext->get_param_color("bgcolor"); + br << ((bgcolor >> 24) & 0xff); + bg << ((bgcolor >> 16) & 0xff); + bb << ((bgcolor >> 8) & 0xff); + ba << (bgcolor & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", reduction.str().c_str(), blend.str().c_str(), + type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), + lightness.str().c_str(), grain.str().c_str(), erase.str().c_str(), blur.str().c_str(), + r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), + br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str() ); + + return _filter; +}; /* Point engraving filter */ + /** \brief Custom predefined Poster paint filter. diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h index 17fccfcbc..f0086eccf 100644 --- a/src/extension/internal/filter/textures.h +++ b/src/extension/internal/filter/textures.h @@ -34,7 +34,7 @@ namespace Filter { Filter's parameters: * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Frequency (0.001->1., default 0.04) -> turbulence (baseFrequency) + * Frequency (0.001->1., default 0.04) -> turbulence (baseFrequency [/100]) * Complexity (1->5, default 3) -> turbulence (numOctaves) * Variation (0->100, default 0) -> turbulence (seed) * Horizontal inlay (0.01->30., default 10) -> blur1 (stdDeviation x) @@ -65,7 +65,7 @@ public: "<_item value=\"fractalNoise\">Fractal noise\n" "<_item value=\"turbulence\">Turbulence\n" "\n" - "0.04\n" + "4\n" "3\n" "0\n" "10\n" @@ -115,7 +115,7 @@ InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream custom; type << ext->get_param_enum("type"); - freq << ext->get_param_float("freq"); + freq << ext->get_param_float("freq") / 100; complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); hblur << ext->get_param_float("hblur"); -- cgit v1.2.3 From caa510445fc091c63e1ca0ff8f44f2e81ae0638d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 13 Aug 2011 20:30:30 +0200 Subject: More generic handling of child type in DrawingItem. Fix clip object selection bug (LP #365458). Fixed bugs: - https://launchpad.net/bugs/365458 (bzr r10347.1.31) --- src/display/drawing-group.cpp | 4 +-- src/display/drawing-group.h | 2 +- src/display/drawing-image.cpp | 2 +- src/display/drawing-image.h | 2 +- src/display/drawing-item.cpp | 83 +++++++++++++++++++++++++++++-------------- src/display/drawing-item.h | 39 ++++++++++++-------- src/display/drawing-shape.cpp | 13 +++---- src/display/drawing-shape.h | 2 +- src/display/drawing-text.cpp | 6 ++-- src/display/drawing-text.h | 4 +-- src/display/drawing.cpp | 9 +++-- src/display/drawing.h | 2 +- src/display/nr-filter.cpp | 2 +- 13 files changed, 106 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 38ab73ca2..002a5a2d4 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -112,10 +112,10 @@ DrawingGroup::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingGroup::_pickItem(Geom::Point const &p, double delta, bool sticky) +DrawingGroup::_pickItem(Geom::Point const &p, double delta, unsigned flags) { for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *picked = i->pick(p, delta, sticky); + DrawingItem *picked = i->pick(p, delta, flags); if (picked) { return _pick_children ? picked : this; } diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 7b0645bf4..377c0be39 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -36,7 +36,7 @@ protected: unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); SPStyle *_style; diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 64601354d..074393ab5 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -196,7 +196,7 @@ distance_to_segment (Geom::Point const &p, Geom::Point const &a1, Geom::Point co } DrawingItem * -DrawingImage::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) +DrawingImage::_pickItem(Geom::Point const &p, double delta, unsigned /*sticky*/) { if (!_pixbuf) return NULL; diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h index de8591221..9f758398b 100644 --- a/src/display/drawing-image.h +++ b/src/display/drawing-image.h @@ -38,7 +38,7 @@ protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); GdkPixbuf *_pixbuf; cairo_surface_t *_surface; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index ae3dd49ab..ac0d1be1e 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -55,6 +55,7 @@ DrawingItem::DrawingItem(Drawing &drawing) , _user_data(NULL) , _cache(NULL) , _state(0) + , _child_type(CHILD_ORPHAN) , _visible(true) , _sensitive(true) , _cached(0) @@ -62,9 +63,6 @@ DrawingItem::DrawingItem(Drawing &drawing) , _has_cache_iterator(0) , _propagate(0) // , _renders_opacity(0) - , _clip_child(0) - , _mask_child(0) - , _drawing_root(0) , _pick_children(0) { } @@ -85,19 +83,29 @@ DrawingItem::~DrawingItem() // due to the effect of clearChildren(), this only happens for the top-level deleted item if (_parent) { _markForRendering(); + } + + switch (_child_type) { + case CHILD_NORMAL: { + ChildrenList::iterator ithis = _parent->_children.iterator_to(*this); + _parent->_children.erase(ithis); + } break; + case CHILD_CLIP: // we cannot call setClip(NULL) or setMask(NULL), // because that would be an endless loop - if (_clip_child) { - _parent->_clip = NULL; - } else if (_mask_child) { - _parent->_mask = NULL; - } else { - ChildrenList::iterator ithis = _parent->_children.iterator_to(*this); - _parent->_children.erase(ithis); - } - _parent->_markForUpdate(STATE_ALL, false); - } else if (_drawing_root) { + _parent->_clip = NULL; + break; + case CHILD_MASK: + _parent->_mask = NULL; + break; + case CHILD_ROOT: _drawing._root = NULL; + break; + default: ; + } + + if (_parent) { + _parent->_markForUpdate(STATE_ALL, false); } clearChildren(); delete _transform; @@ -118,6 +126,8 @@ void DrawingItem::appendChild(DrawingItem *item) { item->_parent = this; + assert(item->_child_type == CHILD_ORPHAN); + item->_child_type = CHILD_NORMAL; _children.push_back(*item); _markForUpdate(STATE_ALL, false); } @@ -126,6 +136,8 @@ void DrawingItem::prependChild(DrawingItem *item) { item->_parent = this; + assert(item->_child_type == CHILD_ORPHAN); + item->_child_type = CHILD_NORMAL; _children.push_front(*item); _markForUpdate(STATE_ALL, false); } @@ -139,6 +151,7 @@ DrawingItem::clearChildren() // from which they have already been removed by clear_and_dispose for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { i->_parent = NULL; + i->_child_type = CHILD_ORPHAN; } _children.clear_and_dispose(DeleteDisposer()); } @@ -217,7 +230,8 @@ DrawingItem::setClip(DrawingItem *item) _clip = item; if (item) { item->_parent = this; - item->_clip_child = true; + assert(item->_child_type == CHILD_ORPHAN); + item->_child_type = CHILD_CLIP; } _markForUpdate(STATE_ALL, true); } @@ -230,7 +244,8 @@ DrawingItem::setMask(DrawingItem *item) _mask = item; if (item) { item->_parent = this; - item->_mask_child = true; + assert(item->_child_type == CHILD_ORPHAN); + item->_child_type = CHILD_MASK; } _markForUpdate(STATE_ALL, true); } @@ -294,7 +309,7 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne if ((~_state & flags) == 0) return; // nothing to do // TODO this might be wrong - if (_state & (outline ? STATE_BBOX : STATE_DRAWBOX)) { + if (_state & STATE_BBOX) { // we have up-to-date bbox if (!area.intersects(outline ? _bbox : _drawbox)) return; } @@ -655,25 +670,39 @@ DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) * When true, invisible and insensitive objects can also be picked. */ DrawingItem * -DrawingItem::pick(Geom::Point const &p, double delta, bool sticky) +DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags) { // Sometimes there's no BBOX in state, reason unknown (bug 992817) // I made this not an assert to remove the warning if (!(_state & STATE_BBOX) || !(_state & STATE_PICK)) return NULL; - - if (!sticky && !(_visible && _sensitive)) + // ignore invisible and insensitive items unless sticky + if (!(flags & PICK_STICKY) && !(_visible && _sensitive)) return NULL; - // some part of the shape might be hidden by clipping - // TODO add Geom::OptRect(Geom::OptIntRect const &) constructor - Geom::OptIntRect expanded_i = _bbox & _drawbox; - Geom::OptRect expanded = expanded_i ? Geom::Rect(*expanded_i) : Geom::OptRect(); - if (!expanded) return NULL; - expanded->expandBy(delta); + bool outline = _drawing.outline(); + + if (!_drawing.outline()) { + // pick inside clipping path; if NULL, it means the object is clipped away there + if (_clip) { + DrawingItem *cpick = _clip->pick(p, delta, flags | PICK_AS_CLIP); + if (!cpick) return NULL; + } + // same for mask + if (_mask) { + DrawingItem *mpick = _mask->pick(p, delta, flags); + if (!mpick) return NULL; + } + } + + Geom::OptIntRect box = (outline || (flags & PICK_AS_CLIP)) ? _bbox : _drawbox; + if (!box) return NULL; + + Geom::Rect expanded = *box; + expanded.expandBy(delta); - if (expanded->contains(p)) { - return _pickItem(p, delta, sticky); + if (expanded.contains(p)) { + return _pickItem(p, delta, flags); } return NULL; } diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index b934570f2..a50e3ef03 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -58,12 +58,16 @@ public: }; enum StateFlags { STATE_NONE = 0, - STATE_BBOX = (1<<0), // geometric bounding box is up-to-date - STATE_DRAWBOX = (1<<1), // visual bounding box is up-to-date - STATE_CACHE = (1<<2), // cache extents and clean area are up-to-date - STATE_PICK = (1<<3), // can process pick requests - STATE_RENDER = (1<<4), // can be rendered - STATE_ALL = (1<<5)-1 + STATE_BBOX = (1<<0), // bounding boxes are up-to-date + STATE_CACHE = (1<<1), // cache extents and clean area are up-to-date + STATE_PICK = (1<<2), // can process pick requests + STATE_RENDER = (1<<3), // can be rendered + STATE_ALL = (1<<4)-1 + }; + enum PickFlags { + PICK_NORMAL = 0, // normal pick + PICK_STICKY = (1<<0), // sticky pick - ignore visibility and sensitivity + PICK_AS_CLIP = (1<<2) // pick with no stroke and opaque fill regardless of item style }; DrawingItem(Drawing &drawing); @@ -103,9 +107,19 @@ public: void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = STATE_ALL, unsigned reset = 0); void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); void clip(DrawingContext &ct, Geom::IntRect const &area); - DrawingItem *pick(Geom::Point const &p, double delta, bool sticky); + DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags = 0); protected: + enum ChildType { + CHILD_ORPHAN = 0, // no parent + CHILD_NORMAL = 1, // contained in _children of parent + CHILD_CLIP = 2, // referenced by _clip member of parent + CHILD_MASK = 3, // referenced by _mask member of parent + CHILD_ROOT = 4, // root item of _drawing + CHILD_FILL_PATTERN = 5, // not yet implemented: referenced by fill pattern of parent + CHILD_STROKE_PATTERN = 6 // not yet implemented: referenced by stroke pattern of parent + }; + void _renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); void _markForUpdate(unsigned state, bool propagate); void _markForRendering(); @@ -116,7 +130,7 @@ protected: unsigned flags, unsigned reset) { return 0; } virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) {} virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area) {} - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky = false) { return NULL; } + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags) { return NULL; } virtual bool _canClip() { return false; } // member variables start here @@ -152,23 +166,18 @@ protected: CacheList::iterator _cache_iterator; unsigned _state : 8; + unsigned _child_type : 3; // see ChildType enum unsigned _visible : 1; unsigned _sensitive : 1; ///< Whether this item responds to events unsigned _cached : 1; ///< Whether the rendering is stored for reuse unsigned _cached_persistent : 1; ///< If set, will always be cached regardless of score - unsigned _has_cache_iterator : 1; ///< If set, _cache_list_pos is valid + unsigned _has_cache_iterator : 1; ///< If set, _cache_iterator is valid unsigned _propagate : 1; ///< Whether to call update for all children on next update //unsigned _renders_opacity : 1; ///< Whether object needs temporary surface for opacity - unsigned _clip_child : 1; ///< If set, this is not a child of _parent, but a clipping path - unsigned _mask_child : 1; ///< If set, this is not a child of _parent, but a mask - unsigned _drawing_root : 1; ///< If set, this is the root item of Drawing unsigned _pick_children : 1; ///< For groups: if true, children are returned from pick(), /// otherwise the group is returned friend class Drawing; - -private: - DrawingItem(DrawingItem const &); }; struct DeleteDisposer { diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 1e41bf5dd..b333b50f8 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -232,7 +232,7 @@ DrawingShape::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) +DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) { if (_repick_after > 0) --_repick_after; @@ -264,8 +264,9 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) double dist = Geom::infinity(); int wind = 0; - bool needfill = (_nrstyle.fill.type != NRStyle::PAINT_NONE + bool needfill = (flags & PICK_AS_CLIP) || (_nrstyle.fill.type != NRStyle::PAINT_NONE && _nrstyle.fill.opacity > 1e-3 && !outline); + bool wind_evenodd = (flags & PICK_AS_CLIP) ? (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) : (_style->fill_rule.computed == SP_WIND_RULE_EVENODD); if (_drawing.arena()) { Geom::Rect viewbox = _drawing.arena()->item.canvas->getViewbox(); @@ -285,13 +286,13 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) // covered by fill? if (needfill) { - if (!_style->fill_rule.computed) { - if (wind != 0) { + if (wind_evenodd) { + if (wind & 0x1) { _last_pick = this; return this; } } else { - if (wind & 0x1) { + if (wind != 0) { _last_pick = this; return this; } @@ -309,7 +310,7 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) // if not picked on the shape itself, try its markers for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - DrawingItem *ret = i->pick(p, delta, false); + DrawingItem *ret = i->pick(p, delta, flags & ~PICK_STICKY); if (ret) { _last_pick = this; return this; diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 153dcd54e..2938d6397 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -36,7 +36,7 @@ protected: unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); SPCurve *_curve; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 2f0881c49..21588cc4f 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -102,7 +102,7 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, } DrawingItem * -DrawingGlyphs::_pickItem(Geom::Point const &p, double delta, bool /*sticky*/) +DrawingGlyphs::_pickItem(Geom::Point const &p, double delta, unsigned /*flags*/) { if (!_font || !_bbox) return NULL; @@ -248,9 +248,9 @@ DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &area) } DrawingItem * -DrawingText::_pickItem(Geom::Point const &p, double delta, bool sticky) +DrawingText::_pickItem(Geom::Point const &p, double delta, unsigned flags) { - DrawingItem *picked = DrawingGroup::_pickItem(p, delta, sticky); + DrawingItem *picked = DrawingGroup::_pickItem(p, delta, flags); if (picked) return this; return NULL; } diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index 671f8f64e..faa33057c 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -32,7 +32,7 @@ public: protected: unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); Geom::Affine *_glyph_transform; font_instance *_font; @@ -59,7 +59,7 @@ protected: unsigned flags, unsigned reset); virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, bool sticky); + virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); Geom::OptRect _paintbox; diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 5881c84ed..e1a17edf1 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -42,7 +42,10 @@ Drawing::setRoot(DrawingItem *item) { delete _root; _root = item; - _root->_drawing_root = true; + if (item) { + assert(item->_child_type == DrawingItem::CHILD_ORPHAN); + item->_child_type = DrawingItem::CHILD_ROOT; + } } RenderMode @@ -168,10 +171,10 @@ Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) } DrawingItem * -Drawing::pick(Geom::Point const &p, double delta, bool sticky) +Drawing::pick(Geom::Point const &p, double delta, unsigned flags) { if (_root) { - return _root->pick(p, delta, sticky); + return _root->pick(p, delta, flags); } return NULL; } diff --git a/src/display/drawing.h b/src/display/drawing.h index a8e70bbe6..011bf35a6 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -60,7 +60,7 @@ public: void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = DrawingItem::STATE_ALL, unsigned reset = 0); void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); - DrawingItem *pick(Geom::Point const &p, double delta, bool sticky); + DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags); sigc::signal signal_request_update; sigc::signal signal_request_render; diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index df6b6222b..ef9ac5be6 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -284,7 +284,7 @@ Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) double Filter::complexity(Geom::Affine const &ctm) { - double factor; + double factor = 1.0; for (unsigned i = 0 ; i < _primitive.size() ; i++) { if (_primitive[i]) { double f = _primitive[i]->complexity(ctm); -- cgit v1.2.3 From 01913a7cb9e1f9190fd3f9d2d047cbb88b9aa4ff Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 14 Aug 2011 09:08:30 +0200 Subject: Correctly invalidate cache of objects with background-accessing filters (bzr r10347.1.32) --- src/display/drawing-item.cpp | 197 ++++++++++++++++++++++--------------- src/display/drawing-item.h | 8 +- src/display/drawing-shape.cpp | 20 ++-- src/display/nr-filter-blend.cpp | 11 +++ src/display/nr-filter-blend.h | 1 + src/display/nr-filter-flood.h | 1 + src/display/nr-filter-merge.cpp | 11 +++ src/display/nr-filter-merge.h | 1 + src/display/nr-filter-primitive.h | 9 ++ src/display/nr-filter-turbulence.h | 1 + src/display/nr-filter.cpp | 10 ++ src/display/nr-filter.h | 3 + 12 files changed, 188 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index ac0d1be1e..f28894c14 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -56,6 +56,8 @@ DrawingItem::DrawingItem(Drawing &drawing) , _cache(NULL) , _state(0) , _child_type(CHILD_ORPHAN) + , _background_new(0) + , _background_accumulate(0) , _visible(true) , _sensitive(true) , _cached(0) @@ -300,10 +302,9 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne bool outline = _drawing.outline(); // Set reset flags according to propagation status - if (_propagate) { - reset |= ~_state; - _propagate = FALSE; - } + reset |= _propagate_state; + _propagate_state = 0; + _state &= ~reset; // reset state of this item if ((~_state & flags) == 0) return; // nothing to do @@ -323,80 +324,91 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne _ctm = child_ctx.ctm; // update _bbox - unsigned old_state = _state; + unsigned to_update = _state ^ flags; _state = _updateItem(area, child_ctx, flags, reset); - // compute drawbox - if (_filter && render_filters && _item_bbox) { - _drawbox = _filter->compute_drawbox(this, *_item_bbox); - } else { - _drawbox = _bbox; - } - - // Clipping - if (_clip) { - _clip->update(area, child_ctx, flags, reset); - if (outline) { - _bbox.unionWith(_clip->_bbox); + if (to_update & STATE_BBOX) { + // compute drawbox + if (_filter && render_filters && _item_bbox) { + _drawbox = _filter->compute_drawbox(this, *_item_bbox); } else { - _drawbox.intersectWith(_clip->_bbox); + _drawbox = _bbox; } - } - // masking - if (_mask) { - _mask->update(area, child_ctx, flags, reset); - if (outline) { - _bbox.unionWith(_mask->_bbox); - } else { - // for masking, we need full drawbox of mask - _drawbox.intersectWith(_mask->_drawbox); + + // Clipping + if (_clip) { + _clip->update(area, child_ctx, flags, reset); + if (outline) { + _bbox.unionWith(_clip->_bbox); + } else { + _drawbox.intersectWith(_clip->_bbox); + } + } + // Masking + if (_mask) { + _mask->update(area, child_ctx, flags, reset); + if (outline) { + _bbox.unionWith(_mask->_bbox); + } else { + // for masking, we need full drawbox of mask + _drawbox.intersectWith(_mask->_drawbox); + } } } - // Update cache score for this item - if (_has_cache_iterator) { - // remove old score information - _drawing._candidate_items.erase(_cache_iterator); - _has_cache_iterator = false; - } - double score = _cacheScore(); - if (score >= _drawing._cache_score_threshold) { - CacheRecord cr; - cr.score = score; - // if _cacheRect() is empty, a negative score will be returned from _cacheScore(), - // so this will not execute (cache score threshold must be positive) - cr.cache_size = _cacheRect()->area() * 4; - cr.item = this; - _drawing._candidate_items.push_back(cr); - _cache_iterator = --_drawing._candidate_items.end(); - _has_cache_iterator = true; - } - - /* Update cache if enabled. - * General note: here we only tell the cache how it has to transform - * during the render phase. The transformation is deferred because - * after the update the item can have its caching turned off, - * e.g. because its filter was removed. This way we avoid tempoerarily - * using more memory than the cache budget */ - if (_cache) { - Geom::OptIntRect cl = _cacheRect(); - if (_visible && cl) { // never create cache for invisible items - // this takes care of invalidation on transform - _cache->scheduleTransform(*cl, ctm_change); - } else { - // Destroy cache for this item - outside of canvas or invisible. - // The opposite transition (invisible -> visible or object - // entering the canvas) is handled during the render phase - delete _cache; - _cache = NULL; + if (to_update & STATE_CACHE) { + // Update cache score for this item + if (_has_cache_iterator) { + // remove old score information + _drawing._candidate_items.erase(_cache_iterator); + _has_cache_iterator = false; + } + double score = _cacheScore(); + if (score >= _drawing._cache_score_threshold) { + CacheRecord cr; + cr.score = score; + // if _cacheRect() is empty, a negative score will be returned from _cacheScore(), + // so this will not execute (cache score threshold must be positive) + cr.cache_size = _cacheRect()->area() * 4; + cr.item = this; + _drawing._candidate_items.push_back(cr); + _cache_iterator = --_drawing._candidate_items.end(); + _has_cache_iterator = true; + } + + /* Update cache if enabled. + * General note: here we only tell the cache how it has to transform + * during the render phase. The transformation is deferred because + * after the update the item can have its caching turned off, + * e.g. because its filter was removed. This way we avoid tempoerarily + * using more memory than the cache budget */ + if (_cache) { + Geom::OptIntRect cl = _cacheRect(); + if (_visible && cl) { // never create cache for invisible items + // this takes care of invalidation on transform + _cache->scheduleTransform(*cl, ctm_change); + } else { + // Destroy cache for this item - outside of canvas or invisible. + // The opposite transition (invisible -> visible or object + // entering the canvas) is handled during the render phase + delete _cache; + _cache = NULL; + } } } - // now that we know drawbox, dirty the corresponding rect on canvas - // unless filtered, groups do not need to render by themselves, only their members - if (!is_drawing_group(this) || (_filter && render_filters)) { - // mark for rendering if the item becomes renderable - if ((old_state ^ _state) & STATE_RENDER) { + if (to_update & STATE_BACKGROUND) { + // Update _background_accumulate flag + // The code below correctly passes information from _background_new down the tree + _background_accumulate = _background_new; + if (_child_type == CHILD_NORMAL && _parent->_background_accumulate) + _background_accumulate = true; + } + + if (to_update & STATE_RENDER) { + // now that we know drawbox, dirty the corresponding rect on canvas + // unless filtered, groups do not need to render by themselves, only their members + if (!is_drawing_group(this) || (_filter && render_filters)) { _markForRendering(); } } @@ -720,14 +732,37 @@ DrawingItem::_markForRendering() if (!dirty) return; // dirty the caches of all parents + DrawingItem *bkg_root = NULL; + for (DrawingItem *i = this; i; i = i->_parent) { if (i->_cached && i->_cache) { i->_cache->markDirty(*dirty); } + if (i->_background_accumulate) { + bkg_root = i; + } + } + + if (bkg_root) { + bkg_root->_invalidateFilterBackground(*dirty); } _drawing.signal_request_render.emit(*dirty); } +void +DrawingItem::_invalidateFilterBackground(Geom::IntRect const &area) +{ + if (!_drawbox.intersects(area)) return; + + if (_cache && _filter && _filter->uses_background()) { + _cache->markDirty(area); + } + + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->_invalidateFilterBackground(area); + } +} + /** @brief Marks the item as needing a recomputation of internal data. * * This mechanism avoids traversing the entire rendering tree (which could be vast) @@ -745,10 +780,9 @@ DrawingItem::_markForRendering() void DrawingItem::_markForUpdate(unsigned flags, bool propagate) { - // we can't simply assign because a previous markForUpdate call - // could have had propagate=true even if this one has propagate=false - if (propagate) - _propagate = true; + if (propagate) { + _propagate_state |= flags; + } if (_state & flags) { _state &= ~flags; @@ -780,16 +814,23 @@ DrawingItem::_setStyleCommon(SPStyle *&_style, SPStyle *style) _filter = NULL; } - /* - if (style && style->enable_background.set - && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { - _background_new = true; - }*/ + if (style && style->enable_background.set) { + if (style->enable_background.value == SP_CSS_BACKGROUND_NEW && !_background_new) { + _background_new = true; + _markForUpdate(STATE_BACKGROUND, true); + } else if (style->enable_background.value == SP_CSS_BACKGROUND_ACCUMULATE && _background_new) { + _background_new = false; + _markForUpdate(STATE_BACKGROUND, true); + } + } - // TODO: STATE_ALL unsets too much _markForUpdate(STATE_ALL, false); } +/** @brief Compute the caching score. + * + * Higher scores mean the item is more aggresively prioritized for automatic + * caching by Inkscape::Drawing. */ double DrawingItem::_cacheScore() { diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index a50e3ef03..6d142c061 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -62,7 +62,8 @@ public: STATE_CACHE = (1<<1), // cache extents and clean area are up-to-date STATE_PICK = (1<<2), // can process pick requests STATE_RENDER = (1<<3), // can be rendered - STATE_ALL = (1<<4)-1 + STATE_BACKGROUND = (1<<4), // filter background data is up to date + STATE_ALL = (1<<5)-1 }; enum PickFlags { PICK_NORMAL = 0, // normal pick @@ -123,6 +124,7 @@ protected: void _renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); void _markForUpdate(unsigned state, bool propagate); void _markForRendering(); + void _invalidateFilterBackground(Geom::IntRect const &area); void _setStyleCommon(SPStyle *&_style, SPStyle *style); double _cacheScore(); Geom::OptIntRect _cacheRect(); @@ -166,7 +168,11 @@ protected: CacheList::iterator _cache_iterator; unsigned _state : 8; + unsigned _propagate_state : 8; unsigned _child_type : 3; // see ChildType enum + unsigned _background_new : 1; ///< Whether enable-background: new is set for this element + unsigned _background_accumulate : 1; ///< Whether this element accumulates background + /// (has any ancestor with enable-background: new) unsigned _visible : 1; unsigned _sensitive : 1; ///< Whether this item responds to events unsigned _cached : 1; ///< Whether the rendering is stored for reuse diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index b333b50f8..1b201927f 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -244,8 +244,9 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) if (!_style) return NULL; bool outline = _drawing.outline(); + bool pick_as_clip = flags & PICK_AS_CLIP; - if (SP_SCALE24_TO_FLOAT(_style->opacity.value) == 0 && !outline) + if (SP_SCALE24_TO_FLOAT(_style->opacity.value) == 0 && !outline && !pick_as_clip) // fully transparent, no pick unless outline mode return NULL; @@ -253,9 +254,14 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) g_get_current_time (&tstart); double width; - if (outline) { - width = 0.5; + if (pick_as_clip) { + width = 0; // no width should be applied to clip picking + // this overrides display mode and stroke style considerations + } else if (outline) { + width = 0.5; // in outline mode, everything is stroked with the same 0.5px line width } else if (_nrstyle.stroke.type != NRStyle::PAINT_NONE && _nrstyle.stroke.opacity > 1e-3) { + // for normal picking calculate the distance corresponding top the stroke width + // FIXME BUG: this is incorrect for transformed strokes float const scale = _ctm.descrim(); width = std::max(0.125f, _nrstyle.stroke_width * scale) / 2; } else { @@ -264,10 +270,12 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) double dist = Geom::infinity(); int wind = 0; - bool needfill = (flags & PICK_AS_CLIP) || (_nrstyle.fill.type != NRStyle::PAINT_NONE - && _nrstyle.fill.opacity > 1e-3 && !outline); - bool wind_evenodd = (flags & PICK_AS_CLIP) ? (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) : (_style->fill_rule.computed == SP_WIND_RULE_EVENODD); + bool needfill = pick_as_clip || (_nrstyle.fill.type != NRStyle::PAINT_NONE && + _nrstyle.fill.opacity > 1e-3 && !outline); + bool wind_evenodd = pick_as_clip ? (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) : + (_style->fill_rule.computed == SP_WIND_RULE_EVENODD); + // actual shape picking if (_drawing.arena()) { Geom::Rect viewbox = _drawing.arena()->item.canvas->getViewbox(); viewbox.expandBy (width); diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 99a142b44..267883b4b 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -201,6 +201,17 @@ double FilterBlend::complexity(Geom::Affine const &) return 1.1; } +bool FilterBlend::uses_background() +{ + if (_input == NR_FILTER_BACKGROUNDIMAGE || _input == NR_FILTER_BACKGROUNDALPHA || + _input2 == NR_FILTER_BACKGROUNDIMAGE || _input2 == NR_FILTER_BACKGROUNDALPHA) + { + return true; + } else { + return false; + } +} + void FilterBlend::set_input(int slot) { _input = slot; } diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 5f71d468d..957d3cfc8 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -40,6 +40,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); virtual double complexity(Geom::Affine const &ctm); + virtual bool uses_background(); virtual void set_input(int slot); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index c87bf6d8f..f744e9f48 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -29,6 +29,7 @@ public: virtual bool can_handle_affine(Geom::Affine const &); virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); + virtual bool uses_background() { return false; } virtual void set_opacity(double o); virtual void set_color(guint32 c); diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 6042da018..28ac19a19 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -72,6 +72,17 @@ double FilterMerge::complexity(Geom::Affine const &) return 1.02; } +bool FilterMerge::uses_background() +{ + for (int i = 0; i < _input_image.size(); ++i) { + int input = _input_image[i]; + if (input == NR_FILTER_BACKGROUNDIMAGE || input == NR_FILTER_BACKGROUNDALPHA) { + return true; + } + } + return false; +} + void FilterMerge::set_input(int slot) { _input_image[0] = slot; } diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index cedab9086..238f9a3e7 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -27,6 +27,7 @@ public: virtual void render_cairo(FilterSlot &); virtual bool can_handle_affine(Geom::Affine const &); virtual double complexity(Geom::Affine const &ctm); + virtual bool uses_background(); virtual void set_input(int input); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 259a25e7e..501d76447 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -12,6 +12,7 @@ #define SEEN_NR_FILTER_PRIMITIVE_H #include <2geom/forward.h> +#include "display/nr-filter-types.h" #include "svg/svg-length.h" struct NRRectL; @@ -66,6 +67,14 @@ public: // returns cache score factor, reflecting the cost of rendering this filter // this should return how many times slower this primitive is that normal rendering virtual double complexity(Geom::Affine const &/*ctm*/) { return 1.0; } + + virtual bool uses_background() { + if (_input == NR_FILTER_BACKGROUNDIMAGE || _input == NR_FILTER_BACKGROUNDALPHA) { + return true; + } else { + return false; + } + } /** * Sets the filter primitive subregion. Passing an unset length diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 9f824ef48..0b451d355 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -46,6 +46,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual double complexity(Geom::Affine const &ctm); + virtual bool uses_background() { return false; } void set_baseFrequency(int axis, double freq); void set_numOctaves(int num); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index ef9ac5be6..ae50e641b 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -294,6 +294,16 @@ double Filter::complexity(Geom::Affine const &ctm) return factor; } +bool Filter::uses_background() +{ + for (unsigned i = 0 ; i < _primitive.size() ; i++) { + if (_primitive[i] && _primitive[i]->uses_background()) { + return true; + } + } + return false; +} + /* Constructor table holds pointers to static methods returning filter * primitives. This table is indexed with FilterPrimitiveType, so that * for example method in _constructor[NR_FILTER_GAUSSIANBLUR] diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 7d31e10ce..87a0fae94 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -167,6 +167,9 @@ public: // returns cache score factor double complexity(Geom::Affine const &ctm); + // says whether the filter accesses any of the background images + bool uses_background(); + /** Creates a new filter with space for one filter element */ Filter(); /** -- cgit v1.2.3 From 34f2be35f436eba541decaf0850edcb3cbd498ba Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 14 Aug 2011 13:29:07 -0700 Subject: Prevent creation of preview images if 'Enable preview' is not enabled. Fixes bug #826027. Fixed bugs: - https://launchpad.net/bugs/826027 (bzr r10541) --- src/ui/dialog/filedialogimpl-gtkmm.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 8e0b9294b..99662f0c2 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -599,8 +599,9 @@ void FileDialogBaseGtk::cleanup( bool showConfirmed ) { if (_dialogType != EXE_TYPES) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if ( showConfirmed ) + if ( showConfirmed ) { prefs->setBool( preferenceBase + "/enable_preview", previewCheckbox.get_active() ); + } } } @@ -611,6 +612,9 @@ void FileDialogBaseGtk::_previewEnabledCB() set_preview_widget_active(enabled); if ( enabled ) { _updatePreviewCallback(); + } else { + // Clears out any current preview image. + svgPreview.showNoPreview(); } } @@ -622,6 +626,7 @@ void FileDialogBaseGtk::_previewEnabledCB() void FileDialogBaseGtk::_updatePreviewCallback() { Glib::ustring fileName = get_preview_filename(); + bool enabled = previewCheckbox.get_active(); #ifdef WITH_GNOME_VFS if ( fileName.empty() && gnome_vfs_initialized() ) { @@ -629,11 +634,11 @@ void FileDialogBaseGtk::_updatePreviewCallback() } #endif - if (fileName.empty()) { - return; + if ( enabled && !fileName.empty() ) { + svgPreview.set(fileName, _dialogType); + } else { + svgPreview.showNoPreview(); } - - svgPreview.set(fileName, _dialogType); } -- cgit v1.2.3 From 4fb1ad44a9b51a119dc0c3b73145106e4f5d0ec5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 15 Aug 2011 10:41:50 +0200 Subject: Filters. New global filters file, and some SVG fixes. (bzr r10542) --- src/extension/internal/filter/bumps.h | 2 +- src/extension/internal/filter/color.h | 8 ++++---- src/extension/internal/filter/morphology.h | 2 +- src/extension/internal/filter/overlays.h | 2 +- src/extension/internal/filter/paint.h | 8 ++++---- src/extension/internal/filter/transparency.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index b8617eafc..c80ca004a 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -701,7 +701,7 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index e9aea4ed2..9ffb74e04 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -1234,7 +1234,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) * Option (enum, default Normal) -> Normal = composite1 (in="qminp", in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="qminpc") Enhance hue = Normal + composite2 (in="SourceGraphic") - Radiation = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc") + Phosphorescence = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc") Hue to background = Normal + composite1 (in2="BackgroundImage") [a template with an activated background is needed, or colors become black] * Hue distribution (0->360, default 0) -> colormatrix1 (values) * Colors (guint, default -73203457) -> flood (flood-opacity, flood-color) @@ -1263,7 +1263,7 @@ public: "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"enhue\">" N_("Enhance hue") "\n" - "<_item value=\"rad\">" N_("Radiation") "\n" + "<_item value=\"rad\">" N_("Phosphorescence") "\n" "<_item value=\"htb\">" N_("Hue to background") "\n" "\n" "\n" @@ -1342,7 +1342,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) c2in2 << "blend6"; b6in2 << "qminpc"; } else if ((g_ascii_strcasecmp("rad", type) == 0)) { - // Radiation + // Phosphorescence c1in << "qminp"; c1in2 << "flood"; c2in << "blend6"; @@ -1379,7 +1379,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 59c33f586..d893ae635 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -182,7 +182,7 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h index 0d02777d1..12e7b5985 100644 --- a/src/extension/internal/filter/overlays.h +++ b/src/extension/internal/filter/overlays.h @@ -127,7 +127,7 @@ NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 7c3bbfcd3..7fc241623 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -704,13 +704,13 @@ public: "\n" "100\n" "100\n" - "3\n" + "1\n" "0\n" "45\n" "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"screen\">" N_("Screen") "\n" - "<_item value=\"multiply\">" N_("Multiply") "\n" "<_item value=\"lighten\">" N_("Lighten") "\n" "<_item value=\"darken\">" N_("Darken") "\n" "\n" @@ -723,7 +723,7 @@ public: "1229269247\n" "\n" "\n" - "255\n" + "-16843009\n" "\n" "\n" "\n" @@ -798,7 +798,7 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 9fd6cac22..a73191bcc 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -243,7 +243,7 @@ Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" - "\n" + "\n" "\n" "\n" "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); -- cgit v1.2.3 From 8645e4456441be2d171a09b285ad49b09efd0325 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 15 Aug 2011 16:57:04 +0200 Subject: Filters. New basic component transfer CPF. (bzr r10543) --- src/extension/internal/filter/color.h | 83 ++++++++++++++++++++++++++++ src/extension/internal/filter/filter-all.cpp | 1 + 2 files changed, 84 insertions(+) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 9ffb74e04..7a055b240 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -12,6 +12,7 @@ * Channel painting * Color shift * Colorize + * Component transfer * Duochrome * Extract channel * Greyscale @@ -395,6 +396,88 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Colorize filter */ +/** + \brief Custom predefined ComponentTransfer filter. + + Basic component transfer structure. + + Filter's parameters: + * Type (enum, default identity) -> component function + +*/ +class ComponentTransfer : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ComponentTransfer ( ) : Filter() { }; + virtual ~ComponentTransfer ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Component Transfer") "\n" + "org.inkscape.effect.filter.ComponentTransfer\n" + "\n" + "<_item value=\"identity\">" N_("Identity") "\n" + "<_item value=\"table\">" N_("Table") "\n" + "<_item value=\"discrete\">" N_("Discrete") "\n" + "<_item value=\"linear\">" N_("Linear") "\n" + "<_item value=\"gamma\">" N_("Gamma") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic component transfer structure") "\n" + "\n" + "\n", new ComponentTransfer()); + }; +}; + +gchar const * +ComponentTransfer::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream CTfunction; + const gchar *type = ext->get_param_enum("type"); + + if ((g_ascii_strcasecmp("identity", type) == 0)) { + CTfunction << "\n" + << "\n" + << "\n" + << "\n"; + } else if ((g_ascii_strcasecmp("table", type) == 0)) { + CTfunction << "\n" + << "\n" + << "\n"; + } else if ((g_ascii_strcasecmp("discrete", type) == 0)) { + CTfunction << "\n" + << "\n" + << "\n"; + } else if ((g_ascii_strcasecmp("linear", type) == 0)) { + CTfunction << "\n" + << "\n" + << "\n"; + } else { //Gamma + CTfunction << "\n" + << "\n" + << "\n"; + } + _filter = g_strdup_printf( + "\n" + "\n" + "%s\n" + "\n" + "\n", CTfunction.str().c_str()); + + return _filter; +}; /* ComponentTransfer filter */ + /** \brief Custom predefined Duochrome filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index f288c27b8..251402762 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -53,6 +53,7 @@ Filter::filters_all (void ) ChannelPaint::init(); ColorShift::init(); Colorize::init(); + ComponentTransfer::init(); Duochrome::init(); ExtractChannel::init(); Greyscale::init(); -- cgit v1.2.3 From e13bcd147d5c9b5712254ba74718d29b7f13d32a Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 15 Aug 2011 21:48:07 +0200 Subject: Filters. Global filters file cleanup and Point Engraving CPF improvements. (bzr r10544) --- src/extension/internal/filter/paint.h | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 7fc241623..5d79b6c3b 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -719,11 +719,13 @@ public: "0\n" "0.5\n" "\n" - "\n" + "\n" "1229269247\n" + "false\n" "\n" - "\n" + "\n" "-16843009\n" + "false\n" "\n" "\n" "\n" @@ -764,7 +766,9 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream bg; std::ostringstream bb; std::ostringstream ba; - + std::ostringstream iof; + std::ostringstream iop; + type << ext->get_param_enum("type"); hfreq << ext->get_param_float("hfreq") / 100; vfreq << ext->get_param_float("vfreq") / 100; @@ -789,6 +793,16 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) bb << ((bgcolor >> 8) & 0xff); ba << (bgcolor & 0xff) / 255.0F; + if (ext->get_param_bool("iof")) + iof << "SourceGraphic"; + else + iof << "flood1"; + + if (ext->get_param_bool("iop")) + iop << "SourceGraphic"; + else + iop << "flood2"; + _filter = g_strdup_printf( "\n" "\n" @@ -799,16 +813,17 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" "\n", reduction.str().c_str(), blend.str().c_str(), type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), lightness.str().c_str(), grain.str().c_str(), erase.str().c_str(), blur.str().c_str(), - r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), - br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str() ); + r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(), + br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str(), iop.str().c_str(), + ba.str().c_str(), a.str().c_str() ); return _filter; }; /* Point engraving filter */ -- cgit v1.2.3 From 66bab1f2b80ff441643fd5fdeb5bade70fb5aa8c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 16 Aug 2011 03:40:10 +0200 Subject: Add sanity checks against singular transforms in the drawing tree. Fixes LP #825767. Fixed bugs: - https://launchpad.net/bugs/825767 (bzr r10347.1.33) --- src/display/drawing-item.cpp | 6 +++--- src/display/drawing-item.h | 2 +- src/display/drawing-text.cpp | 39 +++++++++----------------------------- src/display/drawing-text.h | 2 -- src/display/nr-filter-gaussian.cpp | 4 ++-- 5 files changed, 15 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index f28894c14..1195bc56c 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -66,8 +66,7 @@ DrawingItem::DrawingItem(Drawing &drawing) , _propagate(0) // , _renders_opacity(0) , _pick_children(0) -{ -} +{} DrawingItem::~DrawingItem() { @@ -120,7 +119,7 @@ DrawingItem * DrawingItem::parent() const { // initially I wanted to return NULL if we are a clip or mask child, - // but the previous behavior was just to return the parent + // but the previous behavior was just to return the parent regardless of child type return _parent; } @@ -442,6 +441,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // If we are invisible, return immediately if (!_visible) return; + if (_ctm.isSingular(NR_EPSILON)) return; // TODO convert outline rendering to a separate virtual function if (outline) { diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 6d142c061..abc69be02 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -112,7 +112,7 @@ public: protected: enum ChildType { - CHILD_ORPHAN = 0, // no parent + CHILD_ORPHAN = 0, // no parent - implies _parent == NULL CHILD_NORMAL = 1, // contained in _children of parent CHILD_CLIP = 2, // referenced by _clip member of parent CHILD_MASK = 3, // referenced by _mask member of parent diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 21588cc4f..5e6396df1 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -23,7 +23,6 @@ namespace Inkscape { DrawingGlyphs::DrawingGlyphs(Drawing &drawing) : DrawingItem(drawing) - , _glyph_transform(NULL) , _font(NULL) , _glyph(0) {} @@ -34,7 +33,6 @@ DrawingGlyphs::~DrawingGlyphs() _font->Unref(); _font = NULL; } - delete _glyph_transform; } void @@ -42,12 +40,7 @@ DrawingGlyphs::setGlyph(font_instance *font, int glyph, Geom::Affine const &tran { _markForRendering(); - if (trans.isIdentity()) { - delete _glyph_transform; // delete NULL; is safe - _glyph_transform = NULL; - } else { - _glyph_transform = new Geom::Affine(trans); - } + setTransform(trans); if (font) font->Ref(); if (_font) _font->Unref(); @@ -70,12 +63,7 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, return STATE_ALL; } - Geom::OptRect b; - Geom::Affine t = _glyph_transform ? *_glyph_transform * ctx.ctm : ctx.ctm; - _x = t[4]; - _y = t[5]; - - b = bounds_exact_transformed(*_font->PathVector(_glyph), t); + Geom::OptRect b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); if (b && ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) { float width, scale; scale = ctx.ctm.descrim(); @@ -165,21 +153,19 @@ void DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) { if (_drawing.outline()) { - DrawingContext::Save save(ct); 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.newPath(); - ct.transform(_ctm); for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { DrawingGlyphs *g = dynamic_cast(&*i); if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(ct); - if (g->_glyph_transform) { - ct.transform(*g->_glyph_transform); - } + // skip glpyhs with singular transforms + if (g->_ctm.isSingular()) continue; + ct.transform(g->_ctm); ct.path(*g->_font->PathVector(g->_glyph)); ct.fill(); } @@ -189,9 +175,6 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned // NOTE: this is very similar to drawing-shape.cpp; the only difference is in path feeding bool has_stroke, has_fill; - Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); - has_fill = _nrstyle.prepareFill(ct, _paintbox); has_stroke = _nrstyle.prepareStroke(ct, _paintbox); @@ -201,9 +184,8 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(ct); - if (g->_glyph_transform) { - ct.transform(*g->_glyph_transform); - } + if (g->_ctm.isSingular()) continue; + ct.transform(g->_ctm); ct.path(*g->_font->PathVector(g->_glyph)); } @@ -232,16 +214,13 @@ DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &area) ct.setFillRule(CAIRO_FILL_RULE_WINDING); } } - ct.transform(_ctm); for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { DrawingGlyphs *g = dynamic_cast(&*i); if (!g) throw InvalidItemException(); Inkscape::DrawingContext::Save save(ct); - if (g->_glyph_transform) { - ct.transform(*g->_glyph_transform); - } + ct.transform(g->_ctm); ct.path(*g->_font->PathVector(g->_glyph)); } ct.fill(); diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index faa33057c..07962365c 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -34,10 +34,8 @@ protected: unsigned flags, unsigned reset); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); - Geom::Affine *_glyph_transform; font_instance *_font; int _glyph; - float _x, _y; friend class DrawingText; }; diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 988a8479e..19cf51772 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -511,7 +511,7 @@ gaussian_pass_IIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_su w, h, b, M, tmpdata, num_threads); break; default: - assert(false); + g_warning("gaussian_pass_IIR: unsupported image format"); }; } @@ -544,7 +544,7 @@ gaussian_pass_FIR(Geom::Dim2 d, double deviation, cairo_surface_t *src, cairo_su w, h, &kernel[0], scr_len, num_threads); break; default: - assert(false); + g_warning("gaussian_pass_FIR: unsupported image format"); }; } -- cgit v1.2.3 From dc713ea50efc5fd3f041db05ff92d31a3a54dc5b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 16 Aug 2011 06:04:53 +0200 Subject: Add user preference for rendering cache size (bzr r10347.1.34) --- src/display/canvas-arena.cpp | 19 ++++++++++++ src/display/canvas-arena.h | 2 ++ src/display/drawing.cpp | 48 ++++++++++++++++++------------ src/display/drawing.h | 3 +- src/preferences-skeleton.h | 1 + src/ui/dialog/inkscape-preferences.cpp | 54 ++++++++++++++++++---------------- src/ui/dialog/inkscape-preferences.h | 9 +++--- 7 files changed, 88 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index b254a55c8..ac2704895 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -21,6 +21,7 @@ #include "display/drawing-item.h" #include "display/drawing-group.h" #include "display/drawing-surface.h" +#include "preferences.h" using namespace Inkscape; @@ -48,6 +49,22 @@ static void sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect con static SPCanvasItemClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; +struct CacheBudgetObserver : public Inkscape::Preferences::Observer { + CacheBudgetObserver(SPCanvasArena *arena) + : Inkscape::Preferences::Observer("/options/renderingcache/size") + , _arena(arena) + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Inkscape::Preferences::Entry v = prefs->getEntry(observed_path); + notify(v); + prefs->addObserver(*this); + } + void notify(Preferences::Entry const &v) { + _arena->drawing.setCacheBudget((1 << 20) * v.getIntLimited(128, 0, 4096)); + } + SPCanvasArena *_arena; +}; + GType sp_canvas_arena_get_type (void) { @@ -102,6 +119,7 @@ sp_canvas_arena_init (SPCanvasArena *arena) arena->sticky = FALSE; new (&arena->drawing) Inkscape::Drawing(arena); + arena->observer = new CacheBudgetObserver(arena); Inkscape::DrawingGroup *root = new DrawingGroup(arena->drawing); root->setPickChildren(true); @@ -129,6 +147,7 @@ sp_canvas_arena_destroy (GtkObject *object) { SPCanvasArena *arena = SP_CANVAS_ARENA (object); + delete arena->observer; arena->drawing.~Drawing(); if (GTK_OBJECT_CLASS (parent_class)->destroy) diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 6c65bb0e5..463dc1bc3 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS typedef struct _SPCanvasArena SPCanvasArena; typedef struct _SPCanvasArenaClass SPCanvasArenaClass; +struct CacheBudgetObserver; struct _SPCanvasArena { SPCanvasItem item; @@ -45,6 +46,7 @@ struct _SPCanvasArena { Inkscape::DrawingItem *active; /* fixme: */ Inkscape::DrawingItem *picked; + CacheBudgetObserver *observer; double delta; }; diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index e1a17edf1..06183fed2 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -26,7 +26,7 @@ Drawing::Drawing(SPCanvasArena *arena) , _blur_quality(BLUR_QUALITY_BEST) , _filter_quality(Filters::FILTER_QUALITY_BEST) , _cache_score_threshold(50000.0) - , _cache_budget(128 << 20) // 128 MiB + , _cache_budget(0) , _canvasarena(arena) { @@ -128,6 +128,12 @@ Drawing::setCacheLimit(Geom::OptIntRect const &r) (*i)->_markForUpdate(DrawingItem::STATE_CACHE, false); } } +void +Drawing::setCacheBudget(size_t bytes) +{ + _cache_budget = bytes; + _pickItemsForCaching(); +} void Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) @@ -136,6 +142,29 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl _root->update(area, ctx, flags, reset); } // process the updated cache scores + _pickItemsForCaching(); +} + +void +Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +{ + if (_root) { + _root->render(ct, area, flags); + } +} + +DrawingItem * +Drawing::pick(Geom::Point const &p, double delta, unsigned flags) +{ + if (_root) { + return _root->pick(p, delta, flags); + } + return NULL; +} + +void +Drawing::_pickItemsForCaching() +{ // we cache the objects with the highest score until the budget is exhausted _candidate_items.sort(std::greater()); size_t used = 0; @@ -162,23 +191,6 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl } } -void -Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) -{ - if (_root) { - _root->render(ct, area, flags); - } -} - -DrawingItem * -Drawing::pick(Geom::Point const &p, double delta, unsigned flags) -{ - if (_root) { - return _root->pick(p, delta, flags); - } - return NULL; -} - } // end namespace Inkscape /* diff --git a/src/display/drawing.h b/src/display/drawing.h index 011bf35a6..cfba4ebe6 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -55,6 +55,7 @@ public: Geom::OptIntRect const &cacheLimit() const; void setCacheLimit(Geom::OptIntRect const &r); + void setCacheBudget(size_t bytes); OutlineColors const &colors() const { return _colors; } @@ -67,7 +68,7 @@ public: sigc::signal signal_item_deleted; private: - void _reportCacheScore(CacheRecord const &); + void _pickItemsForCaching(); typedef std::list CandidateList; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 16723170f..895eb7276 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -231,6 +231,7 @@ static char const preferences_skeleton[] = " \n" "\n" " \n" +" " " " " " " " diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index d11ffd565..0129f196f 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -124,7 +124,7 @@ InkscapePreferences::InkscapePreferences() initPageTransforms(); initPageClones(); initPageMasks(); - initPageFilters(); + initPageRendering(); initPageBitmaps(); initPageCMS(); initPageGrids(); @@ -739,8 +739,22 @@ void InkscapePreferences::initPageTransforms() this->AddPage(_page_transforms, _("Transforms"), PREFS_PAGE_TRANSFORMS); } -void InkscapePreferences::initPageFilters() +void InkscapePreferences::initPageRendering() { + /* show infobox */ + _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); + _page_rendering.add_line(true, "", _show_filters_info_box, "", + _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); + + /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded + _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); + _page_rendering.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), + _("Configure number of processors/threads to use when rendering filters"), false); + + // rendering cache + _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 128.0, true, false); + _page_rendering.add_line( false, _("Rendering cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per drawing which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); + /* blur quality */ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value", BLUR_QUALITY_BEST, false, 0); @@ -753,16 +767,16 @@ void InkscapePreferences::initPageFilters() _blur_quality_worst.init ( _("Lowest quality (fastest)"), "/options/blurquality/value", BLUR_QUALITY_WORST, false, &_blur_quality_best); - _page_filters.add_group_header( _("Gaussian blur quality for display")); - _page_filters.add_line( true, "", _blur_quality_best, "", + _page_rendering.add_group_header( _("Gaussian blur quality for display")); + _page_rendering.add_line( true, "", _blur_quality_best, "", _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)")); - _page_filters.add_line( true, "", _blur_quality_better, "", + _page_rendering.add_line( true, "", _blur_quality_better, "", _("Better quality, but slower display")); - _page_filters.add_line( true, "", _blur_quality_normal, "", + _page_rendering.add_line( true, "", _blur_quality_normal, "", _("Average quality, acceptable display speed")); - _page_filters.add_line( true, "", _blur_quality_worse, "", + _page_rendering.add_line( true, "", _blur_quality_worse, "", _("Lower quality (some artifacts), but display is faster")); - _page_filters.add_line( true, "", _blur_quality_worst, "", + _page_rendering.add_line( true, "", _blur_quality_worst, "", _("Lowest quality (considerable artifacts), but display is fastest")); /* filter quality */ @@ -777,29 +791,19 @@ void InkscapePreferences::initPageFilters() _filter_quality_worst.init ( _("Lowest quality (fastest)"), "/options/filterquality/value", Inkscape::Filters::FILTER_QUALITY_WORST, false, &_filter_quality_best); - _page_filters.add_group_header( _("Filter effects quality for display")); - _page_filters.add_line( true, "", _filter_quality_best, "", + _page_rendering.add_group_header( _("Filter effects quality for display")); + _page_rendering.add_line( true, "", _filter_quality_best, "", _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)")); - _page_filters.add_line( true, "", _filter_quality_better, "", + _page_rendering.add_line( true, "", _filter_quality_better, "", _("Better quality, but slower display")); - _page_filters.add_line( true, "", _filter_quality_normal, "", + _page_rendering.add_line( true, "", _filter_quality_normal, "", _("Average quality, acceptable display speed")); - _page_filters.add_line( true, "", _filter_quality_worse, "", + _page_rendering.add_line( true, "", _filter_quality_worse, "", _("Lower quality (some artifacts), but display is faster")); - _page_filters.add_line( true, "", _filter_quality_worst, "", + _page_rendering.add_line( true, "", _filter_quality_worst, "", _("Lowest quality (considerable artifacts), but display is fastest")); - /* show infobox */ - _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); - _page_filters.add_line(true, "", _show_filters_info_box, "", - _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); - - /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded - _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); - _page_filters.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), - _("Configure number of processors/threads to use with rendering of gaussian blur"), false); - - this->AddPage(_page_filters, _("Filters"), PREFS_PAGE_FILTERS); + this->AddPage(_page_rendering, _("Rendering"), PREFS_PAGE_RENDERING); } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 13851e525..d783a2df1 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -44,7 +44,7 @@ enum { PREFS_PAGE_TOOLS_SELECTOR, PREFS_PAGE_TOOLS_NODE, PREFS_PAGE_TOOLS_TWEAK, - PREFS_PAGE_TOOLS_SPRAY, + PREFS_PAGE_TOOLS_SPRAY, PREFS_PAGE_TOOLS_ZOOM, PREFS_PAGE_TOOLS_MEASURE, PREFS_PAGE_TOOLS_SHAPES, @@ -67,7 +67,7 @@ enum { PREFS_PAGE_TRANSFORMS, PREFS_PAGE_CLONES, PREFS_PAGE_MASKS, - PREFS_PAGE_FILTERS, + PREFS_PAGE_RENDERING, PREFS_PAGE_BITMAPS, PREFS_PAGE_CMS, PREFS_PAGE_GRIDS, @@ -124,7 +124,7 @@ protected: UI::Widget::DialogPage _page_clones; UI::Widget::DialogPage _page_mask; UI::Widget::DialogPage _page_transforms; - UI::Widget::DialogPage _page_filters; + UI::Widget::DialogPage _page_rendering; UI::Widget::DialogPage _page_select; UI::Widget::DialogPage _page_importexport; UI::Widget::DialogPage _page_cms; @@ -254,6 +254,7 @@ protected: UI::Widget::PrefRadioButton _filter_quality_worse; UI::Widget::PrefRadioButton _filter_quality_worst; UI::Widget::PrefCheckButton _show_filters_info_box; + UI::Widget::PrefSpinButton _rendering_cache_size; UI::Widget::PrefSpinButton _filter_multi_threaded; UI::Widget::PrefCheckButton _trans_scale_stroke; @@ -389,7 +390,7 @@ protected: void initPageClones(); void initPageMasks(); void initPageTransforms(); - void initPageFilters(); + void initPageRendering(); void initPageSelecting(); void initPageImportExport(); void initPageCMS(); -- cgit v1.2.3 From dac56109f3f34616ce6fdacf456ec9763d871322 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 16 Aug 2011 07:08:36 +0200 Subject: Fix large memory leaks in the swatches panel (bzr r10347.1.35) --- src/ege-adjustment-action.cpp | 9 +++++---- src/ege-select-one-action.cpp | 15 +++++++++++++++ src/ui/dialog/color-item.cpp | 18 +++++++++--------- src/ui/dialog/color-item.h | 3 ++- src/ui/dialog/swatches.cpp | 24 +++++++++--------------- 5 files changed, 40 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 45a44ae0c..f3009ac04 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -300,10 +300,11 @@ static void ege_adjustment_action_finalize( GObject* object ) action = EGE_ADJUSTMENT_ACTION( object ); - if ( action->private_data->format ) { - g_free( action->private_data->format ); - action->private_data->format = 0; - } + // g_free(NULL) does nothing + g_free( action->private_data->format ); + g_free( action->private_data->selfId ); + g_free( action->private_data->appearance ); + g_free( action->private_data->iconId ); egeAct_free_all_descriptions( action ); diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index e0130a68d..44b3dc465 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -52,6 +52,7 @@ enum { static void ege_select_one_action_class_init( EgeSelectOneActionClass* klass ); static void ege_select_one_action_init( EgeSelectOneAction* action ); +static void ege_select_one_action_finalize( GObject* action ); static void ege_select_one_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_select_one_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -159,6 +160,7 @@ void ege_select_one_action_class_init( EgeSelectOneActionClass* klass ) gDataName = g_quark_from_string("ege-select1-action"); + objClass->finalize = ege_select_one_action_finalize; objClass->get_property = ege_select_one_action_get_property; objClass->set_property = ege_select_one_action_set_property; @@ -282,6 +284,19 @@ void ege_select_one_action_init( EgeSelectOneAction* action ) /* g_signal_connect( action, "notify", G_CALLBACK( fixup_labels ), NULL ); */ } +void ege_select_one_action_finalize( GObject* object ) +{ + EgeSelectOneAction *action = EGE_SELECT_ONE_ACTION( object ); + + g_free( action->private_data->iconProperty ); + g_free( action->private_data->appearance ); + g_free( action->private_data->selection ); + + if ( G_OBJECT_CLASS(gParentClass)->finalize ) { + (*G_OBJECT_CLASS(gParentClass)->finalize)(object); + } +} + EgeSelectOneAction* ege_select_one_action_new( const gchar *name, const gchar *label, const gchar *tooltip, diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 598827da9..b61925855 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -460,8 +460,8 @@ void ColorItem::_updatePreviews() for ( std::vector::iterator it2 = possible.begin(); it2 != possible.end() && !found; ++it2 ) { SwatchPage* curr = *it2; index = 0; - for ( std::vector::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) { - if ( this == *zz ) { + for ( boost::ptr_vector::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) { + if ( this == &*zz ) { found = true; paletteName = curr->_name; break; @@ -734,12 +734,12 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) { if ( colorSet ) { - for ( std::vector::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it ) + for ( boost::ptr_vector::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it ) { - std::string::size_type pos = (*it)->def.descr.find("*{"); + std::string::size_type pos = it->def.descr.find("*{"); if ( pos != std::string::npos ) { - std::string subby = (*it)->def.descr.substr( pos + 2 ); + std::string subby = it->def.descr.substr( pos + 2 ); std::string::size_type endPos = subby.find("}*"); if ( endPos != std::string::npos ) { @@ -749,12 +749,12 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( subby.find('E') != std::string::npos ) { - (*it)->def.setEditable( true ); + it->def.setEditable( true ); } if ( subby.find('L') != std::string::npos ) { - (*it)->_isLive = true; + it->_isLive = true; } std::string part; @@ -764,7 +764,7 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( popVal( colorIndex, part ) ) { guint64 percent = 0; if ( popVal( percent, part ) ) { - (*it)->_linkTint( *(colorSet->_colors[colorIndex]), percent ); + it->_linkTint( colorSet->_colors[colorIndex], percent ); } } } @@ -779,7 +779,7 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( !popVal( grayLevel, part ) ) { grayLevel = 0; } - (*it)->_linkTone( *(colorSet->_colors[colorIndex]), percent, grayLevel ); + it->_linkTone( colorSet->_colors[colorIndex], percent, grayLevel ); } } } diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h index 9080498eb..d06082f2e 100644 --- a/src/ui/dialog/color-item.h +++ b/src/ui/dialog/color-item.h @@ -12,6 +12,7 @@ #ifndef SEEN_DIALOGS_COLOR_ITEM_H #define SEEN_DIALOGS_COLOR_ITEM_H +#include #include #include "widgets/ege-paint-def.h" @@ -33,7 +34,7 @@ public: Glib::ustring _name; int _prefWidth; - std::vector _colors; + boost::ptr_vector _colors; }; diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index ad3b79630..910d63873 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -885,7 +885,7 @@ void SwatchesPanel::_setDocument( SPDocument *document ) } static void recalcSwatchContents(SPDocument* doc, - std::vector &tmpColors, + boost::ptr_vector &tmpColors, std::map &previewMappings, std::map &gradMappings) { @@ -938,7 +938,7 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette) { - std::vector tmpColors; + boost::ptr_vector tmpColors; std::map tmpPrevs; std::map tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); @@ -953,9 +953,6 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) } docPalette->_colors.swap(tmpColors); - for (std::vector::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) { - delete *it; - } // Figure out which SwatchesPanel instances are affected and update them. @@ -976,7 +973,7 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette && !DocTrack::queueUpdateIfNeeded(document) ) { - std::vector tmpColors; + boost::ptr_vector tmpColors; std::map tmpPrevs; std::map tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); @@ -986,8 +983,8 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) } else { int cap = std::min(docPalette->_colors.size(), tmpColors.size()); for (int i = 0; i < cap; i++) { - ColorItem* newColor = tmpColors[i]; - ColorItem* oldColor = docPalette->_colors[i]; + ColorItem *newColor = &tmpColors[i]; + ColorItem *oldColor = &docPalette->_colors[i]; if ( (newColor->def.getType() != oldColor->def.getType()) || (newColor->def.getR() != oldColor->def.getR()) || (newColor->def.getG() != oldColor->def.getG()) || @@ -1006,9 +1003,6 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) for (std::map::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { cairo_pattern_destroy(it->second); } - for (std::vector::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) { - delete *it; - } } } @@ -1098,8 +1092,8 @@ void SwatchesPanel::_updateFromSelection() } sp_style_unref(tmpStyle); - for ( std::vector::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { - ColorItem* item = *it; + for ( boost::ptr_vector::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { + ColorItem* item = &*it; bool isFill = (fillId == item->def.descr); bool isStroke = (strokeId == item->def.descr); item->setState( isFill, isStroke ); @@ -1140,8 +1134,8 @@ void SwatchesPanel::_rebuild() _holder->freezeUpdates(); // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); - for ( std::vector::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { - _holder->addPreview(*it); + for ( boost::ptr_vector::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { + _holder->addPreview(&*it); } _holder->thawUpdates(); } -- cgit v1.2.3 From 0c3f98a8aace4b2b1b83e625f7b45aef0fa40c3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Aug 2011 03:00:28 +1000 Subject: update cmake for added/removed source files. (bzr r10546) --- src/extension/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 1fd0ce220..798c18d84 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -113,17 +113,19 @@ set(extension_SRC internal/clear-n_.h internal/emf-win32-inout.h internal/emf-win32-print.h - internal/filter/abc.h internal/filter/blurs.h internal/filter/bumps.h internal/filter/color.h - internal/filter/drop-shadow.h - internal/filter/experimental.h + internal/filter/distort.h internal/filter/filter.h internal/filter/image.h internal/filter/morphology.h + internal/filter/overlays.h + internal/filter/paint.h + internal/filter/protrusions.h internal/filter/shadows.h - internal/filter/snow.h + internal/filter/textures.h + internal/filter/transparency.h internal/gdkpixbuf-input.h internal/gimpgrad.h internal/grid.h -- cgit v1.2.3 From 29ea1bcd2b784536d5eb24f71d09e08720155397 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 16 Aug 2011 22:10:08 +0200 Subject: Filters. Fixes for SVG validation (now 100% pass). Filters. New Light Eraser CPF. Translations. inkscape.pot and French translation update. (bzr r10547) --- src/extension/internal/filter/bumps.h | 4 +- src/extension/internal/filter/color.h | 4 +- src/extension/internal/filter/filter-all.cpp | 1 + src/extension/internal/filter/paint.h | 32 ++++++------ src/extension/internal/filter/transparency.h | 77 +++++++++++++++++++++++++++- 5 files changed, 97 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index c80ca004a..e9860f4a7 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -698,11 +698,11 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 7a055b240..343a5eb84 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -590,7 +590,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -988,7 +988,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 251402762..092edff18 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -100,6 +100,7 @@ Filter::filters_all (void ) // Fill and transparency Blend::init(); ChannelTransparency::init(); + LightEraser::init(); Silhouette::init(); // Here come the rest of the filters that are read from SVG files in share/filters and diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 5d79b6c3b..0546b672f 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -184,16 +184,16 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -437,19 +437,19 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -546,7 +546,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -796,12 +796,12 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) if (ext->get_param_bool("iof")) iof << "SourceGraphic"; else - iof << "flood1"; + iof << "flood2"; if (ext->get_param_bool("iop")) iop << "SourceGraphic"; else - iop << "flood2"; + iop << "flood1"; _filter = g_strdup_printf( "\n" @@ -814,16 +814,16 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n", reduction.str().c_str(), blend.str().c_str(), type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), lightness.str().c_str(), grain.str().c_str(), erase.str().c_str(), blur.str().c_str(), - r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(), br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str(), iop.str().c_str(), - ba.str().c_str(), a.str().c_str() ); + r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(), + a.str().c_str(), ba.str().c_str() ); return _filter; }; /* Point engraving filter */ @@ -1020,7 +1020,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index a73191bcc..48322ae43 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -10,6 +10,7 @@ * Fill and transparency filters * Blend * Channel transparency + * Light eraser * Silhouette * * Released under GNU GPL, read the file 'COPYING' for more information @@ -168,7 +169,7 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), @@ -177,6 +178,80 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Channel transparency filter */ +/** + \brief Custom predefined LightEraser filter. + + Make the lightest parts of the object progressively transparent. + + Filter's parameters: + * Expand (1->1000, default 250) -> colormatrix (first 3 values, multiplicator) + * Erode (0->1000, default 75) -> colormatrix (4th value, multiplicator) + * Global opacity (0.->1., default 1.) -> composite (k2) + * Inverted (boolean, default false) -> colormatrix (values, true: first 3 values positive, 4th negative) + +*/ +class LightEraser : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + LightEraser ( ) : Filter() { }; + virtual ~LightEraser ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Light Eraser") "\n" + "org.inkscape.effect.filter.LightEraser\n" + "100\n" + "50\n" + "1\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Make the lightest parts of the object progressively transparent") "\n" + "\n" + "\n", new LightEraser()); + }; +}; + +gchar const * +LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream expand; + std::ostringstream erode; + std::ostringstream opacity; + + opacity << ext->get_param_float("opacity"); + + if (ext->get_param_bool("invert")) { + expand << (ext->get_param_int("expand") * 0.2125) << " " + << (ext->get_param_int("expand") * 0.7154) << " " + << (ext->get_param_int("expand") * 0.0721); + erode << (-ext->get_param_int("erode") * 720 / 1000); + } else { + expand << (-ext->get_param_int("expand") * 0.2125) << " " + << (-ext->get_param_int("expand") * 0.7154) << " " + << (-ext->get_param_int("expand") * 0.0721); + erode << (ext->get_param_int("erode") * 720 / 1000); + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str()); + + return _filter; +}; /* Light Eraser filter */ + /** \brief Custom predefined Silhouette filter. -- cgit v1.2.3 From a14d33de8c9e17477a13a7e76c9eb1fbe490f011 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 17 Aug 2011 18:19:16 +0200 Subject: Filters. New Opacity CPF, Blur and Tritone improvements. (bzr r10548) --- src/extension/internal/filter/blurs.h | 19 ++++- src/extension/internal/filter/color.h | 100 +++++++++++++++------------ src/extension/internal/filter/filter-all.cpp | 1 + src/extension/internal/filter/paint.h | 32 ++++----- src/extension/internal/filter/transparency.h | 88 +++++++++++++++++++---- 5 files changed, 165 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index b8a6d7c4c..1854572ff 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -37,6 +37,7 @@ namespace Filter { Filter's parameters: * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation) * Vertical blur (0.01->100., default 2) -> blur (stdDeviation) + * Blur content only (boolean, default false) -> */ class Blur : public Inkscape::Extension::Internal::Filter::Filter { @@ -54,6 +55,7 @@ public: "org.inkscape.effect.filter.Blur\n" "2\n" "2\n" + "False\n" "\n" "all\n" "\n" @@ -73,16 +75,29 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); + std::ostringstream bbox; std::ostringstream hblur; std::ostringstream vblur; + std::ostringstream content; hblur << ext->get_param_float("hblur"); vblur << ext->get_param_float("vblur"); + if (ext->get_param_bool("content")) { + bbox << "height=\"1\" width=\"1\" y=\"0\" x=\"0\""; + content << "\n" + << "\n"; + } else { + bbox << "" ; + content << "" ; + } + + _filter = g_strdup_printf( - "\n" + "\n" "\n" - "\n", hblur.str().c_str(), vblur.str().c_str()); + "%s" + "\n", bbox.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), content.str().c_str() ); return _filter; }; /* Blur filter */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 343a5eb84..9ba03a3d6 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -108,9 +108,9 @@ Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), - lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), - sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), - sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str()); + lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), + sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), + sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str() ); return _filter; }; /* Brilliance filter */ @@ -222,7 +222,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) "\n", saturation.str().c_str(), red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(), - invert.str().c_str()); + invert.str().c_str() ); return _filter; }; /* Channel Painting filter */ @@ -281,7 +281,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", shift.str().c_str(), sat.str().c_str()); + "\n", shift.str().c_str(), sat.str().c_str() ); return _filter; }; /* ColorShift filter */ @@ -391,7 +391,9 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blend1.str().c_str(), blend2.str().c_str()); + "\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), + a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + blend1.str().c_str(), blend2.str().c_str() ); return _filter; }; /* Colorize filter */ @@ -597,7 +599,9 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), fluo.str().c_str()); + "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), + a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), + fluo.str().c_str() ); return _filter; }; /* Duochrome filter */ @@ -791,7 +795,7 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str()); + "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str() ); return _filter; }; /* Greyscale filter */ @@ -994,8 +998,8 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n", amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(), - amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(), - amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str()); + amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(), + amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str() ); return _filter; }; /* Lightness filter */ @@ -1137,7 +1141,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(), gx.str().c_str(), gy.str().c_str(), blend.str().c_str(), bx.str().c_str(), by.str().c_str(), blend.str().c_str(), - composite.str().c_str()); + composite.str().c_str() ); return _filter; @@ -1224,7 +1228,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str()); + "\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str() ); return _filter; }; /* Quadritone filter */ @@ -1303,7 +1307,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str()); + "\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str() ); return _filter; }; /* Solarize filter */ @@ -1315,14 +1319,15 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: * Option (enum, default Normal) -> - Normal = composite1 (in="qminp", in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="qminpc") + Normal = composite1 (in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="composite1") Enhance hue = Normal + composite2 (in="SourceGraphic") - Phosphorescence = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc") + Phosphorescence = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="composite1") + PhosphorescenceB = Normal + blend6 (in2="flood") composite1 (in2="SourceGraphic") Hue to background = Normal + composite1 (in2="BackgroundImage") [a template with an activated background is needed, or colors become black] * Hue distribution (0->360, default 0) -> colormatrix1 (values) * Colors (guint, default -73203457) -> flood (flood-opacity, flood-color) * Global blend (enum, default Lighten) -> blend5 (mode) [Multiply, Screen, Darken, Lighten only!] - * Glow (0.01->10., default 0.01) -> feGaussianBlur (stdDeviation) + * Glow (0.01->10., default 0.01) -> blur (stdDeviation) * Glow & blend (enum, default Normal) -> blend6 (mode) [Normal, Multiply and Darken only!] * Local light (0.->10., default 0) -> composite2 (k1) * Global light (0.->10., default 1) -> composite2 (k3) [k2 must be fixed to 1]. @@ -1346,7 +1351,8 @@ public: "\n" "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"enhue\">" N_("Enhance hue") "\n" - "<_item value=\"rad\">" N_("Phosphorescence") "\n" + "<_item value=\"phospho\">" N_("Phosphorescence") "\n" + "<_item value=\"phosphoB\">" N_("Phosphorescence B") "\n" "<_item value=\"htb\">" N_("Hue to background") "\n" "\n" "\n" @@ -1398,7 +1404,6 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream glowblend; std::ostringstream llight; std::ostringstream glight; - std::ostringstream c1in; std::ostringstream c1in2; std::ostringstream c2in; std::ostringstream c2in2; @@ -1419,56 +1424,61 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) const gchar *type = ext->get_param_enum("type"); if ((g_ascii_strcasecmp("enhue", type) == 0)) { // Enhance hue - c1in << "qminp"; c1in2 << "flood"; c2in << "SourceGraphic"; c2in2 << "blend6"; - b6in2 << "qminpc"; - } else if ((g_ascii_strcasecmp("rad", type) == 0)) { + b6in2 << "composite1"; + } else if ((g_ascii_strcasecmp("phospho", type) == 0)) { // Phosphorescence - c1in << "qminp"; c1in2 << "flood"; c2in << "blend6"; - c2in2 << "qminpc"; + c2in2 << "composite1"; b6in2 << "SourceGraphic"; + } else if ((g_ascii_strcasecmp("phosphoB", type) == 0)) { + // Phosphorescence B + c1in2 << "SourceGraphic"; + c2in << "blend6"; + c2in2 << "composite1"; + b6in2 << "flood"; } else if ((g_ascii_strcasecmp("htb", type) == 0)) { // Hue to background - c1in << "qminp"; c1in2 << "BackgroundImage"; - c2in << "p"; + c2in << "blend2"; c2in2 << "blend6"; - b6in2 << "qminpc"; + b6in2 << "composite1"; } else { // Normal - c1in << "qminp"; c1in2 << "flood"; - c2in << "p"; + c2in << "blend2"; c2in2 << "blend6"; - b6in2 << "qminpc"; + b6in2 << "composite"; } _filter = g_strdup_printf( "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" - "\n" - "\n", dist.str().c_str(), globalblend.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), glow.str().c_str(), b6in2.str().c_str(), glowblend.str().c_str(), c2in.str().c_str(), c2in2.str().c_str(), llight.str().c_str(), glight.str().c_str()); + "\n" + "\n", dist.str().c_str(), globalblend.str().c_str(), + a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + c1in2.str().c_str(), glow.str().c_str(), b6in2.str().c_str(), glowblend.str().c_str(), + c2in.str().c_str(), c2in2.str().c_str(), llight.str().c_str(), glight.str().c_str() ); return _filter; }; /* Tritone filter */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 092edff18..c145dd717 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -101,6 +101,7 @@ Filter::filters_all (void ) Blend::init(); ChannelTransparency::init(); LightEraser::init(); + Opacity::init(); Silhouette::init(); // Here come the rest of the filters that are read from SVG files in share/filters and diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 0546b672f..b22eeb889 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -678,9 +678,9 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) * Erase (0.00->1., default 0) -> composite1 (k4) * Blur (0.01->2., default 0.5) -> blur (stdDeviation) - * Drawing color (guint32, default rgb(73,69,40)) -> flood1 (flood-color, flood-opacity) + * Drawing color (guint32, default rgb(255,255,255)) -> flood1 (flood-color, flood-opacity) - * Background color (guint32, default rgb(255,255,255)) -> flood2 (flood-color, flood-opacity) + * Background color (guint32, default rgb(99,89,46)) -> flood2 (flood-color, flood-opacity) */ class PointEngraving : public Inkscape::Extension::Internal::Filter::Filter { @@ -719,12 +719,12 @@ public: "0\n" "0.5\n" "\n" - "\n" - "1229269247\n" + "\n" + "-1\n" "false\n" "\n" - "\n" - "-16843009\n" + "\n" + "1666789119\n" "false\n" "\n" "\n" @@ -781,17 +781,17 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) erase << ext->get_param_float("erase"); blur << ext->get_param_float("blur"); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; + guint32 fcolor = ext->get_param_color("fcolor"); + r << ((fcolor >> 24) & 0xff); + g << ((fcolor >> 16) & 0xff); + b << ((fcolor >> 8) & 0xff); + a << (fcolor & 0xff) / 255.0F; - guint32 bgcolor = ext->get_param_color("bgcolor"); - br << ((bgcolor >> 24) & 0xff); - bg << ((bgcolor >> 16) & 0xff); - bb << ((bgcolor >> 8) & 0xff); - ba << (bgcolor & 0xff) / 255.0F; + guint32 pcolor = ext->get_param_color("pcolor"); + br << ((pcolor >> 24) & 0xff); + bg << ((pcolor >> 16) & 0xff); + bb << ((pcolor >> 8) & 0xff); + ba << (pcolor & 0xff) / 255.0F; if (ext->get_param_bool("iof")) iof << "SourceGraphic"; diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 48322ae43..696c65b48 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -11,6 +11,7 @@ * Blend * Channel transparency * Light eraser + * Opacity * Silhouette * * Released under GNU GPL, read the file 'COPYING' for more information @@ -184,8 +185,8 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) Make the lightest parts of the object progressively transparent. Filter's parameters: - * Expand (1->1000, default 250) -> colormatrix (first 3 values, multiplicator) - * Erode (0->1000, default 75) -> colormatrix (4th value, multiplicator) + * Expansion (1.->1000., default 100) -> colormatrix (first 3 values, multiplicator) + * Erosion (0.->1000., default 50) -> colormatrix (4th value, multiplicator) * Global opacity (0.->1., default 1.) -> composite (k2) * Inverted (boolean, default false) -> colormatrix (values, true: first 3 values positive, 4th negative) @@ -203,8 +204,8 @@ public: "\n" "" N_("Light Eraser") "\n" "org.inkscape.effect.filter.LightEraser\n" - "100\n" - "50\n" + "100\n" + "50\n" "1\n" "false\n" "\n" @@ -232,15 +233,15 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) opacity << ext->get_param_float("opacity"); if (ext->get_param_bool("invert")) { - expand << (ext->get_param_int("expand") * 0.2125) << " " - << (ext->get_param_int("expand") * 0.7154) << " " - << (ext->get_param_int("expand") * 0.0721); - erode << (-ext->get_param_int("erode") * 720 / 1000); + expand << (ext->get_param_float("expand") * 0.2125) << " " + << (ext->get_param_float("expand") * 0.7154) << " " + << (ext->get_param_float("expand") * 0.0721); + erode << (-ext->get_param_float("erode") * 720 / 1000); } else { - expand << (-ext->get_param_int("expand") * 0.2125) << " " - << (-ext->get_param_int("expand") * 0.7154) << " " - << (-ext->get_param_int("expand") * 0.0721); - erode << (ext->get_param_int("erode") * 720 / 1000); + expand << (-ext->get_param_float("expand") * 0.2125) << " " + << (-ext->get_param_float("expand") * 0.7154) << " " + << (-ext->get_param_float("expand") * 0.0721); + erode << (ext->get_param_float("erode") * 720 / 1000); } _filter = g_strdup_printf( @@ -252,6 +253,69 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Light Eraser filter */ + +/** + \brief Custom predefined Opacity filter. + + Set opacity and strength of opacity boundaries. + + Filter's parameters: + * Expansion (0.->1000., default 5) -> colormatrix (last-1th value) + * Erosion (0.->1000., default 1) -> colormatrix (last value) + * Global opacity (0.->1., default 1.) -> composite (k2) + +*/ +class Opacity : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Opacity ( ) : Filter() { }; + virtual ~Opacity ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Opacity") "\n" + "org.inkscape.effect.filter.Opacity\n" + "5\n" + "1\n" + "1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Set opacity and strength of opacity boundaries") "\n" + "\n" + "\n", new Opacity()); + }; +}; + +gchar const * +Opacity::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream matrix; + std::ostringstream opacity; + + opacity << ext->get_param_float("opacity"); + + matrix << (ext->get_param_float("expand")) << " " + << (-ext->get_param_float("erode")); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", matrix.str().c_str(), opacity.str().c_str()); + + return _filter; +}; /* Opacity filter */ + /** \brief Custom predefined Silhouette filter. -- cgit v1.2.3 From b352ca710fbaef29a6eebdb42adad0b41716bef7 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 18 Aug 2011 21:33:47 +0200 Subject: Filters. Removing unnecessary elements and attributes. (bzr r10551) --- src/extension/internal/filter/blurs.h | 4 ++-- src/extension/internal/filter/bumps.h | 4 ++-- src/extension/internal/filter/color.h | 18 +++++++++--------- src/extension/internal/filter/morphology.h | 2 +- src/extension/internal/filter/paint.h | 12 ++++++------ src/extension/internal/filter/transparency.h | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 1854572ff..39d40ee33 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -231,7 +231,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n", bright.str().c_str(), fade.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), blend.str().c_str()); return _filter; @@ -400,7 +400,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index e9860f4a7..ef7f1dc8b 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -707,13 +707,13 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n", simplifyImage.str().c_str(), background.str().c_str(), bgopacity.str().c_str(), red.str().c_str(), green.str().c_str(), blue.str().c_str(), crop.str().c_str(), diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 9ba03a3d6..77fa06a25 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -597,7 +597,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), @@ -702,7 +702,7 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() ); return _filter; @@ -1129,13 +1129,13 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" - "\n" + "\n" "\n" "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(), @@ -1224,10 +1224,10 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" - "\n" + "\n" "\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str() ); return _filter; @@ -1352,7 +1352,7 @@ public: "<_item value=\"normal\">" N_("Normal") "\n" "<_item value=\"enhue\">" N_("Enhance hue") "\n" "<_item value=\"phospho\">" N_("Phosphorescence") "\n" - "<_item value=\"phosphoB\">" N_("Phosphorescence B") "\n" + "<_item value=\"phosphoB\">" N_("Colored nights") "\n" "<_item value=\"htb\">" N_("Hue to background") "\n" "\n" "\n" @@ -1472,7 +1472,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n", dist.str().c_str(), globalblend.str().c_str(), diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index d893ae635..2f5c3ecc8 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -184,7 +184,7 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); return _filter; diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index b22eeb889..fec2f8356 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -186,12 +186,12 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -284,7 +284,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str()); @@ -442,7 +442,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -639,7 +639,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -806,7 +806,7 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 696c65b48..989df0131 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -90,7 +90,7 @@ Blend::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" - "\n" + "\n" "\n", source.str().c_str(), mode.str().c_str() ); return _filter; @@ -308,7 +308,7 @@ Opacity::get_filter_text (Inkscape::Extension::Extension * ext) << (-ext->get_param_float("erode")); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", matrix.str().c_str(), opacity.str().c_str()); -- cgit v1.2.3 From f9769351b6771aa325333ad4841abf71fb0e6c03 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 18 Aug 2011 22:28:44 +0200 Subject: fix old standing issue of converting 0.45 grids to >0.45 Fixed bugs: - https://launchpad.net/bugs/221040 (bzr r10552) --- src/sp-namedview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 55947dacb..5adc0dc74 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -133,14 +133,14 @@ static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *doc const char* gridoriginy = "0px"; const char* gridoriginx = "0px"; const char* gridempspacing = "5"; - const char* gridcolor = "#0000ff"; - const char* gridempcolor = "#0000ff"; - const char* gridopacity = "0.2"; - const char* gridempopacity = "0.4"; + const char* gridcolor = "#3f3fff"; + const char* gridempcolor = "#3f3fff"; + const char* gridopacity = "0.15"; + const char* gridempopacity = "0.38"; const char* value = NULL; if ((value = repr->attribute("gridoriginx"))) { - gridspacingx = value; + gridoriginx = value; old_grid_settings_present = true; } if ((value = repr->attribute("gridoriginy"))) { -- cgit v1.2.3 From 6e0c3298c3b26f3316e7283466c18597296cd830 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 18 Aug 2011 22:40:25 +0200 Subject: default to slightly friendlier grid color like the one from 0.45 :) (bzr r10553) --- src/preferences-skeleton.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 16723170f..70ec0def4 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -326,8 +326,8 @@ static char const preferences_skeleton[] = " origin_y=\"0.0\"\n" " spacing_x=\"1.0\"\n" " spacing_y=\"1.0\"\n" -" color=\"65312\"\n" // 0x0000FF20 -" empcolor=\"65344\"\n" // 0x0000FF40 +" color=\"1061158688\"\n" // 0x3F3FFF20 +" empcolor=\"1061158720\"\n" // 0x3F3FFF40 " empspacing=\"5\"\n" " dotted=\"0\"/>\n" " \n" " \n" " Date: Thu, 18 Aug 2011 23:29:26 +0200 Subject: Extensions. New Crop bitmap extension (see Bug #517082, Request Crop Image). (bzr r10554) --- src/extension/init.cpp | 2 + src/extension/internal/Makefile_insert | 2 + src/extension/internal/bitmap/crop.cpp | 84 ++++++++ src/extension/internal/bitmap/crop.h | 34 +++ src/extension/internal/bitmap/imagemagick.cpp | 298 +++++++++++++------------- src/extension/internal/bitmap/imagemagick.h | 1 + 6 files changed, 277 insertions(+), 144 deletions(-) create mode 100644 src/extension/internal/bitmap/crop.cpp create mode 100644 src/extension/internal/bitmap/crop.h (limited to 'src') diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 355922bc5..064a59700 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -66,6 +66,7 @@ #include "internal/bitmap/charcoal.h" #include "internal/bitmap/colorize.h" #include "internal/bitmap/contrast.h" +#include "internal/bitmap/crop.h" #include "internal/bitmap/cycleColormap.h" #include "internal/bitmap/despeckle.h" #include "internal/bitmap/edge.h" @@ -200,6 +201,7 @@ init() Internal::Bitmap::Charcoal::init(); Internal::Bitmap::Colorize::init(); Internal::Bitmap::Contrast::init(); + Internal::Bitmap::Crop::init(); Internal::Bitmap::CycleColormap::init(); Internal::Bitmap::Edge::init(); Internal::Bitmap::Despeckle::init(); diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 36a80712d..06fa275cb 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -25,6 +25,8 @@ ink_common_sources += \ extension/internal/bitmap/colorize.h \ extension/internal/bitmap/contrast.cpp \ extension/internal/bitmap/contrast.h \ + extension/internal/bitmap/crop.cpp \ + extension/internal/bitmap/crop.h \ extension/internal/bitmap/cycleColormap.cpp \ extension/internal/bitmap/cycleColormap.h \ extension/internal/bitmap/despeckle.cpp \ diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp new file mode 100644 index 000000000..23e31b510 --- /dev/null +++ b/src/extension/internal/bitmap/crop.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2011 Authors: + * Nicolas Dufour + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "2geom/transforms.h" +#include "extension/effect.h" +#include "extension/system.h" + +#include "crop.h" +#include "selection-chemistry.h" +#include "sp-item-transform.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Bitmap { + +void +Crop::applyEffect(Magick::Image *image) { + int width = image->baseColumns() - (_left + _right); + int height = image->baseRows() - (_top + _bottom); + if (width > 0 and height > 0) { + image->crop(Magick::Geometry(width, height, _left, _top, false, false)); + image->page("+0+0"); + } +} + +void +Crop::postEffect(Magick::Image *image, SPItem *item) { + + // Scale bbox + Geom::Scale scale (0,0); + scale = Geom::Scale(image->columns() / (double) image->baseColumns(), + image->rows() / (double) image->baseRows()); + sp_item_scale_rel (item, scale); + + // Translate proportionaly to the image/bbox ratio + Geom::OptRect bbox(item->getBboxDesktop()); + //g_warning("bbox. W:%f, H:%f, X:%f, Y:%f", bbox->dimensions()[Geom::X], bbox->dimensions()[Geom::Y], bbox->min()[Geom::X], bbox->min()[Geom::Y]); + + Geom::Translate translate (0,0); + translate = Geom::Translate(((_left - _right) / 2.0) * (bbox->dimensions()[Geom::X] / (double) image->columns()), + ((_bottom - _top) / 2.0) * (bbox->dimensions()[Geom::Y] / (double) image->rows())); + sp_item_move_rel(item, translate); +} + +void +Crop::refreshParameters(Inkscape::Extension::Effect *module) { + _top = module->get_param_int("top"); + _bottom = module->get_param_int("bottom"); + _left = module->get_param_int("left"); + _right = module->get_param_int("right"); +} + +#include "../clear-n_.h" + +void +Crop::init(void) +{ + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Crop") "\n" + "org.inkscape.effect.bitmap.crop\n" + "0\n" + "0\n" + "0\n" + "0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "" N_("Crop selected bitmap(s).") "\n" + "\n" + "\n", new Crop()); +} + +}; /* namespace Bitmap */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ diff --git a/src/extension/internal/bitmap/crop.h b/src/extension/internal/bitmap/crop.h new file mode 100644 index 000000000..ce9b92797 --- /dev/null +++ b/src/extension/internal/bitmap/crop.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2010 Authors: + * Christopher Brown + * Ted Gould + * Nicolas Dufour + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "imagemagick.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Bitmap { + +class Crop : public ImageMagick +{ +private: + int _top; + int _bottom; + int _left; + int _right; +public: + void applyEffect(Magick::Image *image); + void postEffect(Magick::Image *image, SPItem *item); + void refreshParameters(Inkscape::Extension::Effect *module); + static void init (void); +}; + +}; /* namespace Bitmap */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 65968bdc4..a5d27726f 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -34,182 +34,192 @@ namespace Internal { namespace Bitmap { class ImageMagickDocCache: public Inkscape::Extension::Implementation::ImplementationDocumentCache { - friend class ImageMagick; + friend class ImageMagick; private: - void readImage(char const *xlink, Magick::Image *image); + void readImage(char const *xlink, Magick::Image *image); protected: - Inkscape::XML::Node** _nodes; - - Magick::Image** _images; - int _imageCount; - char** _caches; - unsigned* _cacheLengths; - - const char** _originals; + Inkscape::XML::Node** _nodes; + + Magick::Image** _images; + int _imageCount; + char** _caches; + unsigned* _cacheLengths; + const char** _originals; + SPItem** _imageItems; public: - ImageMagickDocCache(Inkscape::UI::View::View * view); - ~ImageMagickDocCache ( ); + ImageMagickDocCache(Inkscape::UI::View::View * view); + ~ImageMagickDocCache ( ); }; ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : - Inkscape::Extension::Implementation::ImplementationDocumentCache(view), - _nodes(NULL), - _images(NULL), - _imageCount(0), - _caches(NULL), - _cacheLengths(NULL), - _originals(NULL) + Inkscape::Extension::Implementation::ImplementationDocumentCache(view), + _nodes(NULL), + _images(NULL), + _imageCount(0), + _caches(NULL), + _cacheLengths(NULL), + _originals(NULL), + _imageItems(NULL) { - SPDesktop *desktop = (SPDesktop*)view; - const GSList *selectedReprList = desktop->selection->reprList(); - int selectCount = g_slist_length((GSList *)selectedReprList); - - // Init the data-holders - _nodes = new Inkscape::XML::Node*[selectCount]; - _originals = new const char*[selectCount]; - _caches = new char*[selectCount]; - _cacheLengths = new unsigned int[selectCount]; - _images = new Magick::Image*[selectCount]; - _imageCount = 0; - - // Loop through selected nodes - for (; selectedReprList != NULL; selectedReprList = g_slist_next(selectedReprList)) - { - Inkscape::XML::Node *node = reinterpret_cast(selectedReprList->data); - if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) - { - _nodes[_imageCount] = node; - char const *xlink = node->attribute("xlink:href"); - - _originals[_imageCount] = xlink; - _caches[_imageCount] = ""; - _cacheLengths[_imageCount] = 0; - _images[_imageCount] = new Magick::Image(); - readImage(xlink, _images[_imageCount]); - - _imageCount++; - } - } + SPDesktop *desktop = (SPDesktop*)view; + const GSList *selectedItemList = desktop->selection->itemList(); + int selectCount = g_slist_length((GSList *)selectedItemList); + + // Init the data-holders + _nodes = new Inkscape::XML::Node*[selectCount]; + _originals = new const char*[selectCount]; + _caches = new char*[selectCount]; + _cacheLengths = new unsigned int[selectCount]; + _images = new Magick::Image*[selectCount]; + _imageCount = 0; + _imageItems = new SPItem*[selectCount]; + + // Loop through selected items + for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList)) + { + SPItem *item = SP_ITEM(selectedItemList->data); + Inkscape::XML::Node *node = reinterpret_cast(item->getRepr()); + if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) + { + _nodes[_imageCount] = node; + char const *xlink = node->attribute("xlink:href"); + _originals[_imageCount] = xlink; + _caches[_imageCount] = (char*)""; + _cacheLengths[_imageCount] = 0; + _images[_imageCount] = new Magick::Image(); + readImage(xlink, _images[_imageCount]); + _imageItems[_imageCount] = item; + _imageCount++; + } + } } ImageMagickDocCache::~ImageMagickDocCache ( ) { - if (_nodes) - delete _nodes; - if (_originals) - delete _originals; - if (_caches) - delete _caches; - if (_cacheLengths) - delete _cacheLengths; - if (_images) - delete _images; - - return; + if (_nodes) + delete _nodes; + if (_originals) + delete _originals; + if (_caches) + delete _caches; + if (_cacheLengths) + delete _cacheLengths; + if (_images) + delete _images; + if (_imageItems) + delete _imageItems; + return; } void ImageMagickDocCache::readImage(const char *xlink, Magick::Image *image) { - // Find if the xlink:href is base64 data, i.e. if the image is embedded - char *search = (char *) g_strndup(xlink, 30); - if (strstr(search, "base64") != (char*)NULL) { - // 7 = strlen("base64") + strlen(",") - const char* pureBase64 = strstr(xlink, "base64") + 7; - Magick::Blob blob; - blob.base64(pureBase64); - image->read(blob); - } - else { - const gchar *path = xlink; + // Find if the xlink:href is base64 data, i.e. if the image is embedded + char *search = (char *) g_strndup(xlink, 30); + if (strstr(search, "base64") != (char*)NULL) { + // 7 = strlen("base64") + strlen(",") + const char* pureBase64 = strstr(xlink, "base64") + 7; + Magick::Blob blob; + blob.base64(pureBase64); + image->read(blob); + } + else { + const gchar *path = xlink; if (strncmp (xlink,"file:", 5) == 0) { path = g_filename_from_uri(xlink, NULL, NULL); - } + } - try { - image->read(path); - } catch (...) {} - } - g_free(search); + try { + image->read(path); + } catch (...) {} + } + g_free(search); } bool ImageMagick::load(Inkscape::Extension::Extension */*module*/) { - return true; + return true; } Inkscape::Extension::Implementation::ImplementationDocumentCache * ImageMagick::newDocCache (Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * view) { - return new ImageMagickDocCache(view); + return new ImageMagickDocCache(view); } void ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { - refreshParameters(module); - - if (docCache == NULL) { // should never happen - docCache = newDocCache(module, document); - } - ImageMagickDocCache * dc = dynamic_cast(docCache); - if (dc == NULL) { // should really never happen - printf("AHHHHHHHHH!!!!!"); - exit(1); - } - - for (int i = 0; i < dc->_imageCount; i++) - { - try - { - Magick::Image effectedImage = *dc->_images[i]; // make a copy - applyEffect(&effectedImage); - - Magick::Blob *blob = new Magick::Blob(); - effectedImage.write(blob); - - std::string raw_string = blob->base64(); - const int raw_len = raw_string.length(); - const char *raw_i = raw_string.c_str(); - - unsigned new_len = (int)(raw_len * (77.0 / 76.0) + 100); - if (new_len > dc->_cacheLengths[i]) { - dc->_cacheLengths[i] = (int)(new_len * 1.2); - dc->_caches[i] = new char[dc->_cacheLengths[i]]; - } - char *formatted_i = dc->_caches[i]; - const char *src; - - for (src = "data:image/"; *src; ) - *formatted_i++ = *src++; - for (src = effectedImage.magick().c_str(); *src ; ) - *formatted_i++ = *src++; - for (src = ";base64, \n" ; *src; ) - *formatted_i++ = *src++; - - int col = 0; - while (*raw_i) { - *formatted_i++ = *raw_i++; - if (col++ > 76) { - *formatted_i++ = '\n'; - col = 0; - } - } - if (col) { - *formatted_i++ = '\n'; - } - *formatted_i = '\0'; - - dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true); - dc->_nodes[i]->setAttribute("sodipodi:absref", NULL, true); - } - catch (Magick::Exception &error_) { - printf("Caught exception: %s \n", error_.what()); - } - - //while(Gtk::Main::events_pending()) { - // Gtk::Main::iteration(); - //} - } + refreshParameters(module); + + if (docCache == NULL) { // should never happen + docCache = newDocCache(module, document); + } + ImageMagickDocCache * dc = dynamic_cast(docCache); + if (dc == NULL) { // should really never happen + printf("AHHHHHHHHH!!!!!"); + exit(1); + } + + for (int i = 0; i < dc->_imageCount; i++) + { + try + { + Magick::Image effectedImage = *dc->_images[i]; // make a copy + + applyEffect(&effectedImage); + + // postEffect can be used to change things on the item itself + // e.g. resize the image element, after the effecti is applied + postEffect(&effectedImage, dc->_imageItems[i]); + +// dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true); + + Magick::Blob *blob = new Magick::Blob(); + effectedImage.write(blob); + + std::string raw_string = blob->base64(); + const int raw_len = raw_string.length(); + const char *raw_i = raw_string.c_str(); + + unsigned new_len = (int)(raw_len * (77.0 / 76.0) + 100); + if (new_len > dc->_cacheLengths[i]) { + dc->_cacheLengths[i] = (int)(new_len * 1.2); + dc->_caches[i] = new char[dc->_cacheLengths[i]]; + } + char *formatted_i = dc->_caches[i]; + const char *src; + + for (src = "data:image/"; *src; ) + *formatted_i++ = *src++; + for (src = effectedImage.magick().c_str(); *src ; ) + *formatted_i++ = *src++; + for (src = ";base64, \n" ; *src; ) + *formatted_i++ = *src++; + + int col = 0; + while (*raw_i) { + *formatted_i++ = *raw_i++; + if (col++ > 76) { + *formatted_i++ = '\n'; + col = 0; + } + } + if (col) { + *formatted_i++ = '\n'; + } + *formatted_i = '\0'; + + dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true); + dc->_nodes[i]->setAttribute("sodipodi:absref", NULL, true); + } + catch (Magick::Exception &error_) { + printf("Caught exception: %s \n", error_.what()); + } + + //while(Gtk::Main::events_pending()) { + // Gtk::Main::iteration(); + //} + } } /** \brief A function to get the prefences for the grid diff --git a/src/extension/internal/bitmap/imagemagick.h b/src/extension/internal/bitmap/imagemagick.h index 5b4a1eb21..1b150fc3d 100644 --- a/src/extension/internal/bitmap/imagemagick.h +++ b/src/extension/internal/bitmap/imagemagick.h @@ -23,6 +23,7 @@ public: /* Functions to be implemented by subclasses */ virtual void applyEffect(Magick::Image */*image*/) { }; virtual void refreshParameters(Inkscape::Extension::Effect */*module*/) { }; + virtual void postEffect(Magick::Image */*image*/, SPItem */*item*/) { }; /* Functions implemented from ::Implementation */ bool load(Inkscape::Extension::Extension *module); -- cgit v1.2.3 From a49c525365ff86ea1e22281d3a3b66d7ef0087c1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 19 Aug 2011 09:33:48 +0200 Subject: Fix rendering glitches appearing when filtered, cached groups have filtered, cached children (bzr r10347.1.36) --- src/display/drawing-group.cpp | 10 +++++----- src/display/drawing-item.cpp | 20 +++++++++++--------- src/display/drawing-surface.cpp | 33 +++++++++++++++++++++++++++++---- src/display/drawing-surface.h | 1 + src/display/nr-filter-units.cpp | 4 ++-- 5 files changed, 48 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 002a5a2d4..d9a75925e 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -57,7 +57,7 @@ DrawingGroup::setChildTransform(Geom::Affine const &new_trans) if (_child_transform) { current = *_child_transform; } - + if (!Geom::are_near(current, new_trans, NR_EPSILON)) { // mark the area where the object was for redraw. _markForRendering(); @@ -77,11 +77,11 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u unsigned beststate = STATE_ALL; bool outline = _drawing.outline(); + UpdateContext child_ctx(ctx); + if (_child_transform) { + child_ctx.ctm = *_child_transform * ctx.ctm; + } for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - UpdateContext child_ctx(ctx); - if (_child_transform) { - child_ctx.ctm = *_child_transform * ctx.ctm; - } i->update(area, child_ctx, flags, reset); } if (beststate & STATE_BBOX) { diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 1195bc56c..c517b1bb5 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -370,8 +370,8 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne // so this will not execute (cache score threshold must be positive) cr.cache_size = _cacheRect()->area() * 4; cr.item = this; - _drawing._candidate_items.push_back(cr); - _cache_iterator = --_drawing._candidate_items.end(); + _drawing._candidate_items.push_front(cr); + _cache_iterator = _drawing._candidate_items.begin(); _has_cache_iterator = true; } @@ -462,7 +462,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag } else { // There is no cache. This could be because caching of this item // was just turned on after the last update phase, or because - // we are outside of the canvas. + // we were previously outside of the canvas. Geom::OptIntRect cl = _drawing.cacheLimit(); cl.intersectWith(_drawbox); if (cl) { @@ -515,9 +515,8 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // 3. copy from cache to output Inkscape::DrawingContext::Save save(ct); ct.rectangle(*carea); - ct.clip(); ct.setSource(_cache); - ct.paint(); + ct.fill(); // 4. mark as clean _cache->markClean(*carea); return; @@ -591,14 +590,14 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag if (_cached && _cache) { DrawingContext cachect(*_cache); cachect.rectangle(*carea); - cachect.clip(); cachect.setOperator(CAIRO_OPERATOR_SOURCE); cachect.setSource(&intermediate); - cachect.paint(); + cachect.fill(); _cache->markClean(*carea); } + ct.rectangle(*carea); ct.setSource(&intermediate); - ct.paint(); + ct.fill(); ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct } @@ -735,7 +734,10 @@ DrawingItem::_markForRendering() DrawingItem *bkg_root = NULL; for (DrawingItem *i = this; i; i = i->_parent) { - if (i->_cached && i->_cache) { + if (i != this && i->_filter) { + i->_filter->area_enlarge(*dirty, i); + } + if (i->_cache) { i->_cache->markDirty(*dirty); } if (i->_background_accumulate) { diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index e5564f2b3..5cbfaa3fe 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -275,26 +275,51 @@ DrawingCache::paintFromCache(DrawingContext &ct, Geom::OptIntRect &area) } else { cairo_rectangle_int_t to_repaint; cairo_region_get_extents(dirty_region, &to_repaint); - *area = _convertRect(to_repaint); + area = _convertRect(to_repaint); cairo_region_subtract_rectangle(cache_region, &to_repaint); } cairo_region_destroy(dirty_region); if (!cairo_region_is_empty(cache_region)) { - Inkscape::DrawingContext::Save save(ct); int nr = cairo_region_num_rectangles(cache_region); cairo_rectangle_int_t tmp; for (int i = 0; i < nr; ++i) { cairo_region_get_rectangle(cache_region, i, &tmp); ct.rectangle(_convertRect(tmp)); } - ct.clip(); ct.setSource(this); - ct.paint(); + ct.fill(); } cairo_region_destroy(cache_region); } +// debugging utility +void +DrawingCache::_dumpCache(Geom::OptIntRect const &area) +{ + static int dumpnr = 0; + cairo_surface_t *surface = ink_cairo_surface_copy(_surface); + DrawingContext ct(surface, _origin); + if (!cairo_region_is_empty(_clean_region)) { + Inkscape::DrawingContext::Save save(ct); + int nr = cairo_region_num_rectangles(_clean_region); + cairo_rectangle_int_t tmp; + for (int i = 0; i < nr; ++i) { + cairo_region_get_rectangle(_clean_region, i, &tmp); + ct.rectangle(_convertRect(tmp)); + } + ct.setSource(0,1,0,0.1); + ct.fill(); + } + ct.rectangle(*area); + ct.setSource(1,0,0,0.1); + ct.fill(); + char *fn = g_strdup_printf("dump%d.png", dumpnr++); + cairo_surface_write_to_png(surface, fn); + cairo_surface_destroy(surface); + g_free(fn); +} + cairo_rectangle_int_t DrawingCache::_convertRect(Geom::IntRect const &area) { diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index f3af33002..e3637d402 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -72,6 +72,7 @@ protected: Geom::IntRect _pending_area; Geom::Affine _pending_transform; private: + void _dumpCache(Geom::OptIntRect const &area); static cairo_rectangle_int_t _convertRect(Geom::IntRect const &r); static Geom::IntRect _convertRect(cairo_rectangle_int_t const &r); }; diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp index a8686545a..baf4af45d 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -71,10 +71,10 @@ Geom::Affine FilterUnits::get_matrix_user2pb() const { Geom::Affine u2pb = ctm; if (paraller_axis || !automatic_resolution) { - u2pb[0] = resolution_x / (filter_area->max()[X] - filter_area->min()[X]); + u2pb[0] = resolution_x / filter_area->width(); u2pb[1] = 0; u2pb[2] = 0; - u2pb[3] = resolution_y / (filter_area->max()[Y] - filter_area->min()[Y]); + u2pb[3] = resolution_y / filter_area->height(); u2pb[4] = ctm[4]; u2pb[5] = ctm[5]; } -- cgit v1.2.3 From 429a74fe79316cf29eafbe9842dfd4812eaf18a5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 19 Aug 2011 14:38:26 +0200 Subject: Filters. Some extra clean-up (moving color-interpolation-filters attribute to style). Filters. New Lightness-Contrast and Fade to Black or White CPFs. Translations. POT file and French translation update. (bzr r10556) --- src/extension/internal/filter/blurs.h | 10 +- src/extension/internal/filter/bumps.h | 10 +- src/extension/internal/filter/color.h | 180 ++++++++++++++++++++++++--- src/extension/internal/filter/distort.h | 4 +- src/extension/internal/filter/filter-all.cpp | 2 + src/extension/internal/filter/image.h | 2 +- src/extension/internal/filter/morphology.h | 4 +- src/extension/internal/filter/overlays.h | 2 +- src/extension/internal/filter/paint.h | 16 +-- src/extension/internal/filter/protrusions.h | 2 +- src/extension/internal/filter/shadows.h | 2 +- src/extension/internal/filter/textures.h | 2 +- src/extension/internal/filter/transparency.h | 10 +- 13 files changed, 200 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 39d40ee33..59790b1be 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -94,7 +94,7 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( - "\n" + "\n" "\n" "%s" "\n", bbox.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), content.str().c_str() ); @@ -149,7 +149,7 @@ CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -226,7 +226,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) blend << ext->get_param_enum("blend"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -284,7 +284,7 @@ Feather::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -395,7 +395,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index ef7f1dc8b..bb2bfd8a8 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -245,7 +245,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -335,7 +335,7 @@ DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -418,7 +418,7 @@ MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -502,7 +502,7 @@ SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -696,7 +696,7 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) transparency << ext->get_param_enum("transparency"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 77fa06a25..a026e686a 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -15,9 +15,11 @@ * Component transfer * Duochrome * Extract channel + * Fade to black or white * Greyscale * Invert * Lightness + * Lightness-contrast * Nudge * Quadritone * Solarize @@ -105,7 +107,7 @@ Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), @@ -209,7 +211,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -278,7 +280,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) sat << ext->get_param_float("sat"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", shift.str().c_str(), sat.str().c_str() ); @@ -383,7 +385,7 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -471,7 +473,7 @@ ComponentTransfer::get_filter_text (Inkscape::Extension::Extension * ext) << "\n"; } _filter = g_strdup_printf( - "\n" + "\n" "\n" "%s\n" "\n" @@ -588,7 +590,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -700,7 +702,7 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() ); @@ -708,6 +710,82 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* ExtractChannel filter */ +/** + \brief Custom predefined Fade to Black or White filter. + + Fade to black or white. + + Filter's parameters: + * Level (0.->1., default 1.) -> colorMatrix (RVB entries) + * Fade to (enum [black|white], default black) -> colorMatrix (RVB entries) + + Matrix + black white + Lv 0 0 0 0 Lv 0 0 1-lv 0 + 0 Lv 0 0 0 0 Lv 0 1-lv 0 + 0 0 Lv 0 0 0 0 Lv 1-lv 0 + 0 0 0 1 0 0 0 0 1 0 +*/ +class FadeToBW : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + FadeToBW ( ) : Filter() { }; + virtual ~FadeToBW ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Fade to Black or White") "\n" + "org.inkscape.effect.filter.FadeToBW\n" + "1\n" + "\n" + "<_item value=\"black\">" N_("Black") "\n" + "<_item value=\"white\">" N_("White") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Fade to black or white") "\n" + "\n" + "\n", new FadeToBW()); + }; +}; + +gchar const * +FadeToBW::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream level; + std::ostringstream wlevel; + + level << ext->get_param_float("level"); + + const gchar *fadeto = ext->get_param_enum("fadeto"); + if ((g_ascii_strcasecmp("white", fadeto) == 0)) { + // White + wlevel << (1 - ext->get_param_float("level")); + } else { + // Black + wlevel << "0"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", level.str().c_str(), wlevel.str().c_str(), + level.str().c_str(), wlevel.str().c_str(), + level.str().c_str(), wlevel.str().c_str() ); + + return _filter; +}; /* Fade to black or white filter */ + /** \brief Custom predefined Greyscale filter. @@ -793,7 +871,7 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str() ); return _filter; @@ -926,7 +1004,7 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "%s" "\n" "\n", hue.str().c_str(), @@ -991,7 +1069,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) offset << ext->get_param_float("offset"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1004,6 +1082,80 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Lightness filter */ +/** + \brief Custom predefined Lightness-Contrast filter. + + Modify lightness and contrast separately. + + Filter's parameters: + * Lightness (0.->100., default 0.) -> colorMatrix + * Contrast (0.->100., default 0.) -> colorMatrix + + Matrix: + Co/10 0 0 1+(Co-1)*Li/2000 -(Co-1)/20 + 0 Co/10 0 1+(Co-1)*Li/2000 -(Co-1)/20 + 0 0 Co/10 1+(Co-1)*Li/2000 -(Co-1)/20 + 0 0 0 1 0 +*/ +class LightnessContrast : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + LightnessContrast ( ) : Filter() { }; + virtual ~LightnessContrast ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Lightness-Contrast") "\n" + "org.inkscape.effect.filter.LightnessContrast\n" + "0\n" + "0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Modify lightness and contrast separately") "\n" + "\n" + "\n", new LightnessContrast()); + }; +}; + +gchar const * +LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream lightness; + std::ostringstream contrast; + std::ostringstream contrast5; + + gfloat c5; + if (ext->get_param_float("contrast") > 0) { + contrast << (1 + ext->get_param_float("contrast") / 10); + c5 = (- ext->get_param_float("contrast") / 20); + } else { + contrast << (1 + ext->get_param_float("contrast") / 100); + c5 =(- ext->get_param_float("contrast") / 200); + } + + contrast5 << c5; + lightness << ((1 - c5) * ext->get_param_float("lightness") / 100); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n", contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str(), + contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str(), + contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str() ); + + return _filter; +}; /* Lightness-Contrast filter */ + /** \brief Custom predefined Nudge filter. @@ -1125,7 +1277,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1220,7 +1372,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) blend2 << ext->get_param_enum("blend2"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1300,7 +1452,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1455,7 +1607,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index 56855abea..f4caf3d11 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -146,7 +146,7 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -232,7 +232,7 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) intensity << ext->get_param_float("intensity"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index c145dd717..7dd35b055 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -56,9 +56,11 @@ Filter::filters_all (void ) ComponentTransfer::init(); Duochrome::init(); ExtractChannel::init(); + FadeToBW::init(); Greyscale::init(); Invert::init(); Lightness::init(); + LightnessContrast::init(); Nudge::init(); Quadritone::init(); Solarize::init(); diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 47744a2f6..b0a6367e1 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -97,7 +97,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 2f5c3ecc8..e51eb5a0b 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -88,7 +88,7 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -177,7 +177,7 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) a << (color & 0xff) / 255.0F; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h index 12e7b5985..b98577ce1 100644 --- a/src/extension/internal/filter/overlays.h +++ b/src/extension/internal/filter/overlays.h @@ -123,7 +123,7 @@ NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) inverted << "in"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index fec2f8356..678c0c08f 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -183,7 +183,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) graincol << "0"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -274,7 +274,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) trans << "blend"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -434,7 +434,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) ios << "flood2"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -544,7 +544,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -638,7 +638,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -804,7 +804,7 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) iop << "flood1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -942,7 +942,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1018,7 +1018,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) transf << " 1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h index 9103bdc11..8ba35db62 100644 --- a/src/extension/internal/filter/protrusions.h +++ b/src/extension/internal/filter/protrusions.h @@ -71,7 +71,7 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext) drift << ext->get_param_float("drift"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 2d63ac00f..a1a82111d 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -158,7 +158,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h index f0086eccf..513483e26 100644 --- a/src/extension/internal/filter/textures.h +++ b/src/extension/internal/filter/textures.h @@ -133,7 +133,7 @@ InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) stroke << ext->get_param_enum("stroke"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 989df0131..1397b726d 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -89,7 +89,7 @@ Blend::get_filter_text (Inkscape::Extension::Extension * ext) mode << ext->get_param_enum("mode"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", source.str().c_str(), mode.str().c_str() ); @@ -170,7 +170,7 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), @@ -245,7 +245,7 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str()); @@ -308,7 +308,7 @@ Opacity::get_filter_text (Inkscape::Extension::Extension * ext) << (-ext->get_param_float("erode")); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", matrix.str().c_str(), opacity.str().c_str()); @@ -381,7 +381,7 @@ Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) blur << ext->get_param_float("blur"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" -- cgit v1.2.3 From b705b8c158cb5c0297995711772433594d8dc6c5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 20 Aug 2011 07:53:21 +0200 Subject: Filters. Fix for bug #713064 (Filter Effect Turbulence Base frequency limited to 0.400). (bzr r10557) --- src/ui/dialog/filter-effects-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 68cf3b505..30803715e 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -2270,7 +2270,7 @@ void FilterEffectsDialog::init_settings_widgets() _settings->type(NR_FILTER_TURBULENCE); // _settings->add_checkbutton(false, SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch"); _settings->add_combo(TURBULENCE_TURBULENCE, SP_ATTR_TYPE, _("Type:"), TurbulenceTypeConverter, _("Indicates whether the filter primitive should perform a noise or turbulence function.")); - _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 0.4, 0.001, 0.01, 3); + _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 1, 0.001, 0.01, 3); _settings->add_spinslider(1, SP_ATTR_NUMOCTAVES, _("Octaves:"), 1, 10, 1, 1, 0); _settings->add_spinslider(0, SP_ATTR_SEED, _("Seed:"), 0, 1000, 1, 1, 0, _("The starting number for the pseudo random number generator.")); } -- cgit v1.2.3 From 369d232bba58127f1962415ab437614a61980196 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 20 Aug 2011 21:26:29 +0200 Subject: Filters. More filters clean-up. Filters. New Outline filter (rewrite). Filters. Replace the default blend="normal" attribute with mode="normal" for the feBlend primitive. (bzr r10558) --- src/extension/internal/filter/bevels.h | 282 +++++++++++++++++++++++++++ src/extension/internal/filter/bumps.h | 249 ----------------------- src/extension/internal/filter/filter-all.cpp | 9 +- src/extension/internal/filter/morphology.h | 127 +++++++++--- src/filter-chemistry.cpp | 2 +- 5 files changed, 390 insertions(+), 279 deletions(-) create mode 100644 src/extension/internal/filter/bevels.h (limited to 'src') diff --git a/src/extension/internal/filter/bevels.h b/src/extension/internal/filter/bevels.h new file mode 100644 index 000000000..6fc73e58a --- /dev/null +++ b/src/extension/internal/filter/bevels.h @@ -0,0 +1,282 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ +/* Change the 'BEVELS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Bevel filters + * Diffuse light + * Matte jelly + * Specular light + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Diffuse light filter. + + Basic diffuse bevel to use for building textures + + Filter's parameters: + * Smoothness (0.->10., default 6.) -> blur (stdDeviation) + * Elevation (0->360, default 25) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) +*/ + +class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + DiffuseLight ( ) : Filter() { }; + virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Diffuse Light") "\n" + "org.inkscape.effect.filter.DiffuseLight\n" + "6\n" + "25\n" + "235\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic diffuse bevel to use for building textures") "\n" + "\n" + "\n", new DiffuseLight()); + }; + +}; + +gchar const * +DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* DiffuseLight filter */ + +/** + \brief Custom predefined Matte jelly filter. + + Bulging, matte jelly covering + + Filter's parameters: + * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) + * Brightness (0.0->5., default .9) -> specular (specularConstant) + * Elevation (0->360, default 60) -> feDistantLight (elevation) + * Azimuth (0->360, default 225) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + MatteJelly ( ) : Filter() { }; + virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Matte Jelly") "\n" + "org.inkscape.effect.filter.MatteJelly\n" + "7\n" + "0.9\n" + "60\n" + "225\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Bulging, matte jelly covering") "\n" + "\n" + "\n", new MatteJelly()); + }; + +}; + +gchar const * +MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* MatteJelly filter */ + +/** + \brief Custom predefined Specular light filter. + + Basic specular bevel to use for building textures + + Filter's parameters: + * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) + * Brightness (0.0->5., default 1.) -> specular (specularConstant) + * Elevation (0->360, default 45) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + SpecularLight ( ) : Filter() { }; + virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Specular Light") "\n" + "org.inkscape.effect.filter.SpecularLight\n" + "6\n" + "1\n" + "45\n" + "235\n" + "-1\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Basic specular bevel to use for building textures") "\n" + "\n" + "\n", new SpecularLight()); + }; + +}; + +gchar const * +SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* SpecularLight filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'BEVELS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index bb2bfd8a8..f002c8b37 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -9,9 +9,6 @@ * * Bump filters * Bump - * Diffuse light - * Matte jelly - * Specular light * Wax bump * * Released under GNU GPL, read the file 'COPYING' for more information @@ -268,252 +265,6 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Bump filter */ -/** - \brief Custom predefined Diffuse light filter. - - Basic diffuse bevel to use for building textures - - Filter's parameters: - * Smoothness (0.->10., default 6.) -> blur (stdDeviation) - * Elevation (0->360, default 25) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) -*/ - -class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DiffuseLight ( ) : Filter() { }; - virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Diffuse Light") "\n" - "org.inkscape.effect.filter.DiffuseLight\n" - "6\n" - "25\n" - "235\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic diffuse bevel to use for building textures") "\n" - "\n" - "\n", new DiffuseLight()); - }; - -}; - -gchar const * -DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* DiffuseLight filter */ - -/** - \brief Custom predefined Matte jelly filter. - - Bulging, matte jelly covering - - Filter's parameters: - * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) - * Brightness (0.0->5., default .9) -> specular (specularConstant) - * Elevation (0->360, default 60) -> feDistantLight (elevation) - * Azimuth (0->360, default 225) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - MatteJelly ( ) : Filter() { }; - virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Matte Jelly") "\n" - "org.inkscape.effect.filter.MatteJelly\n" - "7\n" - "0.9\n" - "60\n" - "225\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Bulging, matte jelly covering") "\n" - "\n" - "\n", new MatteJelly()); - }; - -}; - -gchar const * -MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* MatteJelly filter */ - -/** - \brief Custom predefined Specular light filter. - - Basic specular bevel to use for building textures - - Filter's parameters: - * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) - * Brightness (0.0->5., default 1.) -> specular (specularConstant) - * Elevation (0->360, default 45) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - SpecularLight ( ) : Filter() { }; - virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Specular Light") "\n" - "org.inkscape.effect.filter.SpecularLight\n" - "6\n" - "1\n" - "45\n" - "235\n" - "-1\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Basic specular bevel to use for building textures") "\n" - "\n" - "\n", new SpecularLight()); - }; - -}; - -gchar const * -SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* SpecularLight filter */ - /** \brief Custom predefined Wax Bump filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 7dd35b055..17c22c0cb 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,6 +8,7 @@ #include "filter.h" /* Put your filter here */ +#include "bevels.h" #include "blurs.h" #include "bumps.h" #include "color.h" @@ -34,6 +35,11 @@ Filter::filters_all (void ) /* Experimental custom predefined filters */ + // Bevels + DiffuseLight::init(); + MatteJelly::init(); + SpecularLight::init(); + // Blurs Blur::init(); CleanEdges::init(); @@ -43,9 +49,6 @@ Filter::filters_all (void ) // Bumps Bump::init(); - DiffuseLight::init(); - MatteJelly::init(); - SpecularLight::init(); WaxBump::init(); // Color diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index e51eb5a0b..4b69f564b 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -105,12 +105,23 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) Adds a colorizable outline Filter's parameters: - * Width (0.01->50., default 5) -> blur1 (stdDeviation) - * Melt (0.01->50., default 2) -> blur2 (stdDeviation) - * Dilatation (1.->50., default 8) -> color2 (n-1th value) - * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) - * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) - * Blend (enum, default Normal) -> blend (mode) + * Stroke type (enum, default single) + * single -> composite4 (in="composite3"), composite2 (operator="atop") + * double -> composite4 (in="SourceGraphic"), composite2 (operator="xor") + * Stroke position (enum, default inside) + * inside -> composite1 (operator="out", in="SourceGraphic", in2="blur1") + * outside -> composite1 (operator="out", in="blur1", in2="SourceGraphic") + * overlayed -> composite1 (operator="xor", in="blur1", in2="SourceGraphic") + * Width 1(0.01->20., default 4) -> blur1 (stdDeviation) + * Width 2 (0.01->20., default 0.5) -> blur2 (stdDeviation) + * Dilatation 1 (1.->100., default 100) -> colormatrix1 (n-1th value) + * Erosion 1 (0.->100., default 1) -> colormatrix1 (nth value 0->-100) + * Dilatation 2 (1.->100., default 50) -> colormatrix2 (n-1th value) + * Erosion 2 (0.->100., default 5) -> colormatrix2 (nth value 0->-100) + * Color (guint, default 200,55,55,255) -> flood (flood-color, flood-opacity) + * Fill opacity (0.->1., default 1) -> composite5 (k2) + * Stroke opacity (0.->1., default 1) -> composite5 (k3) + */ class Outline : public Inkscape::Extension::Internal::Filter::Filter { @@ -128,13 +139,26 @@ public: "org.inkscape.effect.filter.Outline\n" "\n" "\n" - "5\n" - "2\n" - "8\n" - "5\n" + "\n" + "<_item value=\"single\">" N_("Single") "\n" + "<_item value=\"double\">" N_("Double") "\n" + "\n" + "\n" + "<_item value=\"inside\">" N_("Inside") "\n" + "<_item value=\"outside\">" N_("Outside") "\n" + "<_item value=\"overlayed\">" N_("Overlayed") "\n" + "\n" + "4\n" + "0.5\n" + "100\n" + "1\n" + "50\n" + "5\n" "\n" "\n" "1029214207\n" + "1\n" + "1\n" "\n" "\n" "\n" @@ -156,36 +180,87 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream width; - std::ostringstream melt; - std::ostringstream dilat; - std::ostringstream erosion; + std::ostringstream width1; + std::ostringstream width2; + std::ostringstream dilat1; + std::ostringstream erosion1; + std::ostringstream dilat2; + std::ostringstream erosion2; std::ostringstream r; std::ostringstream g; std::ostringstream b; std::ostringstream a; - std::ostringstream blend; + std::ostringstream fopacity; + std::ostringstream sopacity; + std::ostringstream c4in; + std::ostringstream c4op; + std::ostringstream c1in; + std::ostringstream c1in2; + std::ostringstream c1op; + + width1 << ext->get_param_float("width1"); + width2 << ext->get_param_float("width2"); + dilat1 << ext->get_param_float("dilat1"); + erosion1 << (- ext->get_param_float("erosion1")); + dilat2 << ext->get_param_float("dilat2"); + erosion2 << (- ext->get_param_float("erosion2")); - width << ext->get_param_float("width"); - melt << ext->get_param_float("melt"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); guint32 color = ext->get_param_color("color"); r << ((color >> 24) & 0xff); g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); a << (color & 0xff) / 255.0F; + fopacity << ext->get_param_float("fopacity"); + sopacity << ext->get_param_float("sopacity"); + + const gchar *type = ext->get_param_enum("type"); + if((g_ascii_strcasecmp("single", type) == 0)) { + // Single + c4in << "composite3"; + c4op << "atop"; + } else { + // Double + c4in << "SourceGraphic"; + c4op << "xor"; + } + + const gchar *position = ext->get_param_enum("position"); + if((g_ascii_strcasecmp("inside", position) == 0)) { + // Indide + c1in << "SourceGraphic3"; + c1in2 << "blur1"; + c1op << "out"; + } else if((g_ascii_strcasecmp("outside", position) == 0)) { + // Outside + c1in << "blur1"; + c1in2 << "SourceGraphic"; + c1op << "out"; + } else { + // Overlayed + c1in << "blur1"; + c1in2 << "SourceGraphic"; + c1op << "xor"; + } + _filter = g_strdup_printf( - "\n" + "\n" "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" + "\n" "\n" - "\n" - "\n" - "\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + "\n" + "\n" + "\n" + "\n", width1.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), c1op.str().c_str(), + dilat1.str().c_str(), erosion1.str().c_str(), + width2.str().c_str(), dilat2.str().c_str(), erosion2.str().c_str(), + a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + c4in.str().c_str(), c4op.str().c_str(), + fopacity.str().c_str(), sopacity.str().c_str() ); return _filter; }; /* Outline filter */ diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index e98905439..9ea9407b1 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -123,7 +123,7 @@ filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveT // set default values switch(type) { case Inkscape::Filters::NR_FILTER_BLEND: - repr->setAttribute("blend", "normal"); + repr->setAttribute("mode", "normal"); break; case Inkscape::Filters::NR_FILTER_COLORMATRIX: break; -- cgit v1.2.3 From cf0c689f665675b976215e80ec7c9acf1b2e49e6 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 21 Aug 2011 09:42:08 +0200 Subject: DBUS. Merging lp:~joakim-verona/inkscape/dbus-fixes changes. (bzr r10559) --- src/desktop.h | 3 +- src/extension/dbus/dbus-init.cpp | 2 +- src/extension/dbus/document-interface.cpp | 181 +++++++++++++++++++++++++++++- src/extension/dbus/document-interface.h | 26 +++++ src/extension/dbus/document-interface.xml | 163 ++++++++++++++++++++++++++- src/extension/dbus/proposed-interface.xml | 50 --------- src/file.cpp | 6 +- src/file.h | 2 +- src/select-context.cpp | 8 ++ 9 files changed, 381 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/desktop.h b/src/desktop.h index e4b71ca59..5fd786936 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -50,6 +50,7 @@ struct SPItem; struct SPNamedView; struct SPObject; struct SPStyle; +typedef struct _DocumentInterface DocumentInterface;//struct DocumentInterface; namespace Gtk { @@ -98,7 +99,7 @@ public: SPEventContext *event_context; Inkscape::LayerManager *layer_manager; Inkscape::EventLog *event_log; - + DocumentInterface *dbus_document_interface; Inkscape::Display::TemporaryItemList *temporary_item_list; Inkscape::Display::SnapIndicator *snapindicator; diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index 3e453d048..1b6baa979 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -147,7 +147,7 @@ dbus_init_desktop_interface (SPDesktop * dt) &dbus_glib_document_interface_object_info, name.c_str()); obj->desk = dt; obj->updates = TRUE; - + dt->dbus_document_interface=obj; return strdup(name.c_str()); } diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 4e629a1a9..1e6577173 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -17,7 +17,7 @@ #include "document-interface.h" #include - +#include #include "desktop-handles.h" //sp_desktop_document() #include "desktop-style.h" //sp_desktop_get_style #include "display/canvas-text.h" //text @@ -56,6 +56,25 @@ //#include "2geom/svg-path-parser.h" //get_node_coordinates +#include +#include + +#if 0 +#include +#include +#include +#include +#endif + + enum + { + OBJECT_MOVED_SIGNAL, + LAST_SIGNAL + }; + + static guint signals[LAST_SIGNAL] = { 0 }; + + /**************************************************************************** HELPER / SHORTCUT FUNCTIONS ****************************************************************************/ @@ -280,6 +299,14 @@ document_interface_class_init (DocumentInterfaceClass *klass) GObjectClass *object_class; object_class = G_OBJECT_CLASS (klass); object_class->finalize = document_interface_finalize; + signals[OBJECT_MOVED_SIGNAL] = + g_signal_new ("object_moved", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); } static void @@ -587,6 +614,44 @@ document_interface_document_resize_to_fit_selection (DocumentInterface *object, return TRUE; } +gboolean +document_interface_document_set_display_area (DocumentInterface *object, + double x0, + double y0, + double x1, + double y1, + double border, + GError **error) +{ + object->desk->set_display_area (x0, + y0, + x1, + y1, + border, false); + return TRUE; +} + + +GArray * +document_interface_document_get_display_area (DocumentInterface *object) +{ + Geom::Rect const d = object->desk->get_display_area(); + + GArray * dArr = g_array_new (TRUE, TRUE, sizeof(double)); + + double x0 = d.min()[Geom::X]; + double y0 = d.min()[Geom::Y]; + double x1 = d.max()[Geom::X]; + double y1 = d.max()[Geom::Y]; + g_array_append_val (dArr, x0); // + g_array_append_val (dArr, y0); + g_array_append_val (dArr, x1); + g_array_append_val (dArr, y1); + return dArr; + +} + + /**************************************************************************** OBJECT FUNCTIONS ****************************************************************************/ @@ -835,6 +900,35 @@ document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text } + +gboolean +document_interface_text_apply_style (DocumentInterface *object, gchar *name, + int start_pos, int end_pos, gchar *style, gchar *styleval, + GError **error) +{ + + SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + + //void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPCSSAttr const *css) + //TODO verify object type + if (!text_obj) + return FALSE; + Inkscape::Text::Layout const *layout = te_get_layout(text_obj); + Inkscape::Text::Layout::iterator start = layout->charIndexToIterator (start_pos); + Inkscape::Text::Layout::iterator end = layout->charIndexToIterator (end_pos); + + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, style, styleval); + + sp_te_apply_style(text_obj, + start, + end, + css); + return TRUE; + +} + + /**************************************************************************** FILE I/O FUNCTIONS ****************************************************************************/ @@ -861,8 +955,22 @@ gboolean document_interface_load(DocumentInterface *object, return TRUE; } -gboolean document_interface_save_as(DocumentInterface *object, - const gchar *filename, GError ** /*error*/) +gchar * +document_interface_import (DocumentInterface *object, + gchar *filename, GError **error) +{ + desktop_ensure_active (object->desk); + const Glib::ustring file(filename); + SPDocument * doc = sp_desktop_document(object->desk); + + SPObject *new_obj = NULL; + new_obj = file_import(doc, file, NULL); + return strdup(new_obj->getRepr()->attribute("id")); +} + +gboolean +document_interface_save_as (DocumentInterface *object, + const gchar *filename, GError **error) { SPDocument * doc = sp_desktop_document(object->desk); #ifdef WITH_GNOME_VFS @@ -1329,6 +1437,73 @@ document_interface_layer_previous (DocumentInterface *object, GError **error) return dbus_call_verb (object, SP_VERB_LAYER_PREV, error); } + +//////////////signals + + +DocumentInterface *fugly; +gboolean dbus_send_ping (SPDesktop* desk, SPItem *item) +{ + //DocumentInterface *obj; + g_signal_emit (desk->dbus_document_interface, signals[OBJECT_MOVED_SIGNAL], 0, item->getId()); + g_print("Ping!\n"); + return TRUE; +} + +//////////tree + + +gboolean +document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error) +{ + SPItem* parent=(SPItem* )get_object_by_name(object->desk, name, error); + + GSList const *children = parent->childList(false); + + int size = g_slist_length((GSList *) children); + + *out = g_new0 (char *, size + 1); + + int i = 0; + for (GSList const *iter = children; iter != NULL; iter = iter->next) { + (*out)[i] = g_strdup(SP_OBJECT(iter->data)->getRepr()->attribute("id")); + i++; + } + (*out)[i] = NULL; + + return TRUE; + +} + + +gchar* +document_interface_get_parent (DocumentInterface *object, char *name, GError **error) +{ + SPItem* node=(SPItem* )get_object_by_name(object->desk, name, error); + + SPObject* parent=node->parent; + + return g_strdup(parent->getRepr()->attribute("id")); + +} + +#if 0 +//just pseudo code +gboolean +document_interface_get_xpath (DocumentInterface *object, char *xpath_expression, char ***out, GError **error){ + SPDocument * doc = sp_desktop_document (object->desk); + Inkscape::XML::Document *repr = doc->getReprDoc(); + + xmlXPathObjectPtr xpathObj; + xmlXPathContextPtr xpathCtx; + xpathCtx = xmlXPathNewContext(repr);//XmlDocPtr + xpathObj = xmlXPathEvalExpression(xmlCharStrdup(xpath_expression), xpathCtx); + + //xpathresult result = xpatheval(repr, xpath_selection); + //convert resut to a string array we can return via dbus + return TRUE; +} +#endif /* Local Variables: mode:c++ diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index 0283d987e..e7e55cb7d 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -121,6 +121,10 @@ document_interface_text (DocumentInterface *object, int x, int y, gboolean document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error); +gboolean +document_interface_text_apply_style (DocumentInterface *object, gchar *name, + int start_pos, int end_pos, gchar *style, gchar *styleval, + GError **error); gchar * document_interface_image (DocumentInterface *object, int x, int y, @@ -154,6 +158,16 @@ document_interface_document_set_css (DocumentInterface *object, gboolean document_interface_document_resize_to_fit_selection (DocumentInterface *object, GError **error); +gboolean +document_interface_document_set_display_area (DocumentInterface *object, + double x0, + double y0, + double x1, + double y1, + double border, + GError **error); +GArray * +document_interface_document_get_display_area (DocumentInterface *object); /**************************************************************************** OBJECT FUNCTIONS @@ -404,6 +418,18 @@ document_interface_layer_previous (DocumentInterface *object, GError **error); DocumentInterface *document_interface_new (void); GType document_interface_get_type (void); +extern DocumentInterface *fugly; +gboolean dbus_send_ping (SPDesktop* desk, SPItem *item); + +gboolean +document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error); + +gchar* +document_interface_get_parent (DocumentInterface *object, char *name, GError **error); + +gchar* +document_interface_import (DocumentInterface *object, + gchar *filename, GError **error); G_END_DECLS diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml index 94f39ae7e..aeacfae44 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -352,6 +352,27 @@ + + + + The path to a valid svg file. + + + + + + The name of the new image. + + + + + Imports the file at pathname. Similar to the image + method. + + + + + @@ -453,6 +474,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Set display area. + + + + + + + + Get display area. + + + + + + area + + + + + @@ -499,6 +570,43 @@ + + + + The id of an object. + + + + + + start text pos. + + + + + end text pos. + + + + + + css attribute. + + + + + + css attribute value. + + + + + + + set styling of partial text object. + + + @@ -864,6 +972,9 @@ + + + + + + + The id of the object. + + + + + Emitted when an object has been moved. + + + + + + + + + Any node with an "id" attribute. + + + + + The ids of this nodes children, NULL if bottom level. + + + + + Returns the children of any node. This function along with get_parent() can be used to navigate the XML tree. + + + + + + + Any node with an "id" attribute. + + + + + + The id of this nodes parent, NULL if toplevel. + + + + + Returns the parent of any node. This function along with get_children() can be used to navigate the XML tree. + + + - + diff --git a/src/extension/dbus/proposed-interface.xml b/src/extension/dbus/proposed-interface.xml index c281aff96..ac74b64f9 100644 --- a/src/extension/dbus/proposed-interface.xml +++ b/src/extension/dbus/proposed-interface.xml @@ -40,19 +40,6 @@ - - - - The id of the object. - - - - - Emitted when an object has been moved. - - - - @@ -136,43 +123,6 @@ - - - - Any node with an "id" attribute. - - - - - - The id of this nodes parent, NULL if toplevel. - - - - - Returns the parent of any node. This function along with get_children() can be used to navigate the XML tree. In proposed because I think it might confuse users who don't know about the SVG tree structure. In the main API I have de-emphasized nodes and required no knowledge of internal representation. - - - - - - - - Any node with an "id" attribute. - - - - - - The ids of this nodes children, NULL if bottom level. - - - - - Returns the children of any node. This function along with get_parent() can be used to navigate the XML tree. In proposed because I think it might confuse users who don't know about the SVG tree structure. In the main API I have de-emphasized nodes and required no knowledge of internal representation. - - - diff --git a/src/file.cpp b/src/file.cpp index 43d1ddaaa..c6d43fa51 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -952,7 +952,7 @@ sp_file_save_a_copy(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d /** * Import a resource. Called by sp_file_import() */ -void +SPObject * file_import(SPDocument *in_doc, const Glib::ustring &uri, Inkscape::Extension::Extension *key) { @@ -1067,14 +1067,14 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, doc->doUnref(); DocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); - + return new_obj; } else { gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), uri.c_str()); sp_ui_error_dialog(text); g_free(text); } - return; + return NULL; } diff --git a/src/file.h b/src/file.h index 0041af81f..cf3adec2b 100644 --- a/src/file.h +++ b/src/file.h @@ -129,7 +129,7 @@ void sp_file_import (Gtk::Window &parentWindow); /** * Imports a resource */ -void file_import(SPDocument *in_doc, const Glib::ustring &uri, +SPObject* file_import(SPDocument *in_doc, const Glib::ustring &uri, Inkscape::Extension::Extension *key); /*###################### diff --git a/src/select-context.cpp b/src/select-context.cpp index 143fb1ae2..1ce3ccd25 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -33,6 +33,9 @@ #include "select-context.h" #include "selection-chemistry.h" +#ifdef WITH_DBUS +#include "extension/dbus/document-interface.h" +#endif #include "desktop.h" #include "desktop-handles.h" #include "sp-root.h" @@ -47,6 +50,7 @@ using Inkscape::DocumentUndo; + static void sp_select_context_class_init(SPSelectContextClass *klass); static void sp_select_context_init(SPSelectContext *select_context); static void sp_select_context_dispose(GObject *object); @@ -622,6 +626,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) // item has been moved seltrans->ungrab(); sc->moved = FALSE; +#ifdef WITH_DBUS + g_print("moved!\n");//JAVE + dbus_send_ping(desktop, sc->item); +#endif } else if (sc->item && !drag_escaped) { // item has not been moved -> simply a click, do selecting if (!selection->isEmpty()) { -- cgit v1.2.3 From 3091b61045fd1196591cf3befbff45441dd5a4a8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 21 Aug 2011 12:15:37 +0200 Subject: fix copy edit bug in axislinesegment Fixed bugs: - https://launchpad.net/bugs/813829 (bzr r10560) --- src/2geom/hvlinesegment.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/2geom/hvlinesegment.h b/src/2geom/hvlinesegment.h index 05252468e..d2b9d6310 100644 --- a/src/2geom/hvlinesegment.h +++ b/src/2geom/hvlinesegment.h @@ -1,4 +1,4 @@ -/** +/** * \file * \brief Horizontal and vertical line segment *//* @@ -96,14 +96,13 @@ public: } virtual Point pointAt(Coord t) const { if ( t < 0 || t > 1 ) - THROW_RANGEERROR("HLineSegment: Time value out of range"); - Coord x = initialPoint()[axis] + t * (finalPoint()[axis] - initialPoint()[axis]); - Point ret(x, initialPoint()[other_axis]); + THROW_RANGEERROR("AxisLineSegment: Time value out of range"); + Point ret = initialPoint() + t * (finalPoint() - initialPoint()); return ret; } virtual Coord valueAt(Coord t, Dim2 d) const { if ( t < 0 || t > 1 ) - THROW_RANGEERROR("HLineSegment: Time value out of range"); + THROW_RANGEERROR("AxisLineSegment: Time value out of range"); if (d != axis) return initialPoint()[other_axis]; return initialPoint()[axis] + t * (finalPoint()[axis] - initialPoint()[axis]); } @@ -111,8 +110,8 @@ public: std::vector result; result.push_back(pointAt(t)); if (n > 0) { - Coord x = finalPoint()[axis] - initialPoint()[axis]; - result.push_back( Point(x, 0) ); + Point der = finalPoint() - initialPoint(); + result.push_back( der ); } if (n > 1) { /* higher order derivatives are zero, -- cgit v1.2.3 From 22c8e14b7234a59618d378f91ac99a18d3ccb6d4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Aug 2011 20:21:49 +1000 Subject: update cmake file list. (bzr r10561) --- src/extension/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 798c18d84..89e5a6041 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -113,6 +113,7 @@ set(extension_SRC internal/clear-n_.h internal/emf-win32-inout.h internal/emf-win32-print.h + internal/filter/bevels.h internal/filter/blurs.h internal/filter/bumps.h internal/filter/color.h @@ -173,6 +174,8 @@ if(ImageMagick_FOUND) internal/bitmap/colorize.h internal/bitmap/contrast.cpp internal/bitmap/contrast.h + internal/bitmap/crop.cpp + internal/bitmap/crop.h internal/bitmap/cycleColormap.cpp internal/bitmap/cycleColormap.h internal/bitmap/despeckle.cpp -- cgit v1.2.3 From 9b4b20104eba525bdfff7c40ca1a985cda5d7791 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 21 Aug 2011 12:29:02 +0200 Subject: fix for bad argument crash for guides Fixed bugs: - https://launchpad.net/bugs/829947 (bzr r10562) --- src/sp-guide.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index b55084609..a06d098d0 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -231,23 +231,27 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) break; case SP_ATTR_POSITION: { - gchar ** strarray = g_strsplit(value, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2) { - guide->point_on_line = Geom::Point(newx, newy); - } else if (success == 1) { - // before 0.46 style guideline definition. - const gchar *attr = object->getRepr()->attribute("orientation"); - if (attr && !strcmp(attr, "horizontal")) { - guide->point_on_line = Geom::Point(0, newx); - } else { - guide->point_on_line = Geom::Point(newx, 0); + if (value) { + gchar ** strarray = g_strsplit(value, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + guide->point_on_line = Geom::Point(newx, newy); + } else if (success == 1) { + // before 0.46 style guideline definition. + const gchar *attr = object->getRepr()->attribute("orientation"); + if (attr && !strcmp(attr, "horizontal")) { + guide->point_on_line = Geom::Point(0, newx); + } else { + guide->point_on_line = Geom::Point(newx, 0); + } } + } else { + // default to (0,0) for bad arguments + guide->point_on_line = Geom::Point(0,0); } - // update position in non-committing way // fixme: perhaps we need to add an update method instead, and request_update here sp_guide_moveto(*guide, guide->point_on_line, false); -- cgit v1.2.3 From 0fc028f7050c91bfdb1a50ba8cb6462b2bf03d57 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 21 Aug 2011 17:33:09 +0200 Subject: Filter background rendering now matches the SVG specification. (bzr r10347.1.37) --- src/display/drawing-group.cpp | 25 +++++++-- src/display/drawing-group.h | 5 +- src/display/drawing-image.cpp | 7 +-- src/display/drawing-image.h | 3 +- src/display/drawing-item.cpp | 112 +++++++++++++++++++++++------------------ src/display/drawing-item.h | 14 ++++-- src/display/drawing-shape.cpp | 11 ++-- src/display/drawing-shape.h | 5 +- src/display/drawing-text.cpp | 7 +-- src/display/drawing-text.h | 5 +- src/display/nr-filter-slot.cpp | 38 ++++++++------ src/display/nr-filter-slot.h | 2 +- src/display/nr-filter.cpp | 56 +++++++++------------ src/display/nr-filter.h | 6 +-- 14 files changed, 170 insertions(+), 126 deletions(-) (limited to 'src') diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index d9a75925e..a678c3feb 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -95,12 +95,29 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u return beststate; } -void -DrawingGroup::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +unsigned +DrawingGroup::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(ct, area, flags); + if (stop_at == NULL) { + // normal rendering + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->render(ct, area, flags, stop_at); + } + } else { + // background rendering + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + if (&*i == stop_at) return RENDER_OK; // do not render the stop_at item at all + if (i->isAncestorOf(stop_at)) { + // render its ancestors without masks, opacity or filters + i->render(ct, area, flags | RENDER_FILTER_BACKGROUND, stop_at); + // stop further rendering + return RENDER_OK; + } else { + i->render(ct, area, flags, stop_at); + } + } } + return RENDER_OK; } void diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 377c0be39..961e5b9a3 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -32,9 +32,10 @@ public: void setChildTransform(Geom::Affine const &new_trans); protected: - unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + DrawingItem *stop_at); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 074393ab5..fa0402699 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -112,13 +112,13 @@ DrawingImage::_updateItem(Geom::IntRect const &, UpdateContext const &, unsigned return STATE_ALL; } -void -DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +unsigned +DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { bool outline = _drawing.outline(); if (!outline) { - if (!_pixbuf) return; + if (!_pixbuf) return RENDER_OK; Inkscape::DrawingContext::Save save(ct); ct.transform(_ctm); @@ -172,6 +172,7 @@ DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne ct.setSource(rgba); ct.stroke(); } + return RENDER_OK; } /** Calculates the closest distance from p to the segment a1-a2*/ diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h index 9f758398b..300d6f0b5 100644 --- a/src/display/drawing-image.h +++ b/src/display/drawing-image.h @@ -37,7 +37,8 @@ public: protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + DrawingItem *stop_at); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); GdkPixbuf *_pixbuf; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index c517b1bb5..a5496e999 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -123,6 +123,16 @@ DrawingItem::parent() const return _parent; } +/// Returns true if item is among the descendants. Will return false if item == this. +bool +DrawingItem::isAncestorOf(DrawingItem *item) const +{ + for (DrawingItem *i = item->_parent; i; i = i->_parent) { + if (i == this) return true; + } + return false; +} + void DrawingItem::appendChild(DrawingItem *item) { @@ -314,6 +324,16 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne if (!area.intersects(outline ? _bbox : _drawbox)) return; } + // compute which elements need an update + unsigned to_update = _state ^ flags; + + // this needs to be called before we recurse into children + if (to_update & STATE_BACKGROUND) { + _background_accumulate = _background_new; + if (_child_type == CHILD_NORMAL && _parent->_background_accumulate) + _background_accumulate = true; + } + UpdateContext child_ctx(ctx); if (_transform) { child_ctx.ctm = *_transform * ctx.ctm; @@ -322,14 +342,13 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne Geom::Affine ctm_change = _ctm.inverse() * child_ctx.ctm; _ctm = child_ctx.ctm; - // update _bbox - unsigned to_update = _state ^ flags; + // update _bbox and call this function for children _state = _updateItem(area, child_ctx, flags, reset); if (to_update & STATE_BBOX) { // compute drawbox - if (_filter && render_filters && _item_bbox) { - _drawbox = _filter->compute_drawbox(this, *_item_bbox); + if (_filter && render_filters) { + _drawbox = _filter->compute_drawbox(this, _item_bbox); } else { _drawbox = _bbox; } @@ -396,14 +415,6 @@ DrawingItem::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigne } } - if (to_update & STATE_BACKGROUND) { - // Update _background_accumulate flag - // The code below correctly passes information from _background_new down the tree - _background_accumulate = _background_new; - if (_child_type == CHILD_NORMAL && _parent->_background_accumulate) - _background_accumulate = true; - } - if (to_update & STATE_RENDER) { // now that we know drawbox, dirty the corresponding rect on canvas // unless filtered, groups do not need to render by themselves, only their members @@ -433,32 +444,36 @@ struct MaskLuminanceToAlpha { * * @param flags Rendering options. This deals mainly with cache control. */ -void -DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +unsigned +DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { bool outline = _drawing.outline(); bool render_filters = _drawing.renderFilters(); + // stop_at is handled in DrawingGroup, but this check is required to handle the case + // where a filtered item with background-accessing filter has enable-background: new + if (this == stop_at) return RENDER_STOP; + // If we are invisible, return immediately - if (!_visible) return; - if (_ctm.isSingular(NR_EPSILON)) return; + if (!_visible) return RENDER_OK; + if (_ctm.isSingular(NR_EPSILON)) return RENDER_OK; // TODO convert outline rendering to a separate virtual function if (outline) { _renderOutline(ct, area, flags); - return; + return RENDER_OK; } // carea is the area to paint Geom::OptIntRect carea = Geom::intersect(area, _drawbox); - if (!carea) return; + if (!carea) return RENDER_OK; // render from cache if possible if (_cached) { if (_cache) { _cache->prepare(); _cache->paintFromCache(ct, carea); - if (!carea) return; + if (!carea) return RENDER_OK; } else { // There is no cache. This could be because caching of this item // was just turned on after the last update phase, or because @@ -484,6 +499,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag nir |= (_mask != NULL); // 2. it has a mask nir |= (_filter != NULL && render_filters); // 3. it has a filter nir |= needs_opacity; // 4. it is non-opaque + nir |= (_cache != NULL); // 5. it is cached /* How the rendering is done. * @@ -497,33 +513,12 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag * to the opacity value. */ - // short-circuit the simple case. - if (!needs_intermediate_rendering) { - if (_cached && _cache) { - Inkscape::DrawingContext cachect(*_cache); - cachect.rectangle(*carea); - cachect.clip(); - - { // 1. clear the corresponding part of cache - Inkscape::DrawingContext::Save save(cachect); - cachect.setSource(0,0,0,0); - cachect.setOperator(CAIRO_OPERATOR_SOURCE); - cachect.paint(); - } - // 2. render to cache - _renderItem(cachect, *carea, flags); - // 3. copy from cache to output - Inkscape::DrawingContext::Save save(ct); - ct.rectangle(*carea); - ct.setSource(_cache); - ct.fill(); - // 4. mark as clean - _cache->markClean(*carea); - return; - } else { - _renderItem(ct, *carea, flags); - return; - } + // Short-circuit the simple case. + // We also use this path for filter background rendering, because masking, clipping, + // filters and opacity do not apply when rendering the ancestors of the filtered + // element + if ((flags & RENDER_FILTER_BACKGROUND) || !needs_intermediate_rendering) { + return _renderItem(ct, *carea, flags & ~RENDER_FILTER_BACKGROUND, stop_at); } // iarea is the bounding box for intermediate rendering @@ -540,6 +535,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag DrawingSurface intermediate(*iarea); DrawingContext ict(intermediate); + unsigned render_result = RENDER_OK; // 1. Render clipping path with alpha = opacity. ict.setSource(0,0,0,_opacity); @@ -571,11 +567,27 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // 3. Render object itself ict.pushGroup(); - _renderItem(ict, *iarea, flags); + render_result = _renderItem(ict, *iarea, flags, stop_at); // 4. Apply filter. if (_filter && render_filters) { - _filter->render(this, ct, ict); + bool rendered = false; + if (_filter->uses_background() && _background_accumulate) { + DrawingItem *bg_root = this; + for (; bg_root; bg_root = bg_root->_parent) { + if (bg_root->_background_new) break; + } + if (bg_root) { + DrawingSurface bg(*iarea); + DrawingContext bgct(bg); + bg_root->render(bgct, *iarea, flags | RENDER_FILTER_BACKGROUND, this); + _filter->render(this, ict, &bgct); + rendered = true; + } + } + if (!rendered) { + _filter->render(this, ict, NULL); + } // Note that because the object was rendered to a group, // the internals of the filter need to use cairo_get_group_target() // instead of cairo_get_target(). @@ -600,6 +612,8 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag ct.fill(); ct.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by ct + + return render_result; } void @@ -612,7 +626,7 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig // just render everything: item, clip, mask // First, render the object itself - _renderItem(ct, *carea, flags); + _renderItem(ct, *carea, flags, NULL); // render clip and mask, if any guint32 saved_rgba = _drawing.outlinecolor; // save current outline color diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index abc69be02..7a3b8047b 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -54,7 +54,8 @@ public: enum RenderFlags { RENDER_DEFAULT = 0, RENDER_CACHE_ONLY = 1, - RENDER_BYPASS_CACHE = 2 + RENDER_BYPASS_CACHE = 2, + RENDER_FILTER_BACKGROUND = 4 }; enum StateFlags { STATE_NONE = 0, @@ -81,6 +82,7 @@ public: Geom::Affine transform() const { return _transform ? *_transform : Geom::identity(); } Drawing &drawing() const { return _drawing; } DrawingItem *parent() const; + bool isAncestorOf(DrawingItem *item) const; void appendChild(DrawingItem *item); void prependChild(DrawingItem *item); @@ -106,7 +108,7 @@ public: void *data() const { return _user_data; } void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = STATE_ALL, unsigned reset = 0); - void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); + unsigned render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0, DrawingItem *stop_at = NULL); void clip(DrawingContext &ct, Geom::IntRect const &area); DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags = 0); @@ -120,7 +122,10 @@ protected: CHILD_FILL_PATTERN = 5, // not yet implemented: referenced by fill pattern of parent CHILD_STROKE_PATTERN = 6 // not yet implemented: referenced by stroke pattern of parent }; - + enum RenderResult { + RENDER_OK = 0, + RENDER_STOP = 1 + }; void _renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); void _markForUpdate(unsigned state, bool propagate); void _markForRendering(); @@ -130,7 +135,8 @@ protected: Geom::OptIntRect _cacheRect(); virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { return 0; } - virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) {} + virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + DrawingItem *stop_at) { return RENDER_OK; } virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area) {} virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags) { return NULL; } virtual bool _canClip() { return false; } diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 1b201927f..cd7b9150d 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -157,11 +157,11 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u return STATE_ALL; } -void -DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +unsigned +DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { - if (!_curve || !_style) return; - if (!area.intersects(_bbox)) return; // skip if not within bounding box + if (!_curve || !_style) return RENDER_OK; + if (!area.intersects(_bbox)) return RENDER_OK; // skip if not within bounding box bool outline = _drawing.outline(); @@ -208,8 +208,9 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne // marker rendering for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(ct, area, flags); + i->render(ct, area, flags, stop_at); } + return RENDER_OK; } void diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 2938d6397..122130590 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -32,9 +32,10 @@ public: void setPaintBox(Geom::Rect const &box); protected: - unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + DrawingItem *stop_at); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 5e6396df1..1134771bc 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -149,8 +149,8 @@ DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, un return DrawingGroup::_updateItem(area, ctx, flags, reset); } -void -DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +unsigned +DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { if (_drawing.outline()) { guint32 rgba = _drawing.outlinecolor; @@ -169,7 +169,7 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned ct.path(*g->_font->PathVector(g->_glyph)); ct.fill(); } - return; + return RENDER_OK; } // NOTE: this is very similar to drawing-shape.cpp; the only difference is in path feeding @@ -199,6 +199,7 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned } ct.newPath(); // clear path } + return RENDER_OK; } void diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index 07962365c..4f3940dde 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -53,9 +53,10 @@ public: void setPaintBox(Geom::OptRect const &box); protected: - unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, + virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual void _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + DrawingItem *stop_at); virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index d2f992859..4f7a8849e 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -25,13 +25,13 @@ namespace Inkscape { namespace Filters { -FilterSlot::FilterSlot(DrawingItem *item, DrawingContext &bgct, +FilterSlot::FilterSlot(DrawingItem *item, DrawingContext *bgct, DrawingContext &graphic, FilterUnits const &u) : _item(item) , _source_graphic(graphic.rawTarget()) - , _background_ct(bgct.raw()) + , _background_ct(bgct ? bgct->raw() : NULL) , _source_graphic_area(graphic.targetLogicalBounds().roundOutwards()) // fixme - , _background_area(bgct.targetLogicalBounds().roundOutwards()) // fixme + , _background_area(bgct ? bgct->targetLogicalBounds().roundOutwards() : Geom::IntRect()) // fixme , _units(u) , _last_out(NR_FILTER_SOURCEGRAPHIC) , filterquality(FILTER_QUALITY_BEST) @@ -152,19 +152,25 @@ cairo_surface_t *FilterSlot::_get_transformed_background() { Geom::Affine trans = _units.get_matrix_display2pb(); - cairo_surface_t *bg = cairo_get_group_target(_background_ct); - cairo_surface_t *tbg = cairo_surface_create_similar( - bg, cairo_surface_get_content(bg), - _slot_w, _slot_h); - cairo_t *tbg_ct = cairo_create(tbg); - - cairo_translate(tbg_ct, -_slot_x, -_slot_y); - ink_cairo_transform(tbg_ct, trans); - cairo_translate(tbg_ct, _background_area.left(), _background_area.top()); - cairo_set_source_surface(tbg_ct, bg, 0, 0); - cairo_set_operator(tbg_ct, CAIRO_OPERATOR_SOURCE); - cairo_paint(tbg_ct); - cairo_destroy(tbg_ct); + cairo_surface_t *tbg; + + if (_background_ct) { + cairo_surface_t *bg = cairo_get_group_target(_background_ct); + tbg = cairo_surface_create_similar( + bg, cairo_surface_get_content(bg), + _slot_w, _slot_h); + cairo_t *tbg_ct = cairo_create(tbg); + + cairo_translate(tbg_ct, -_slot_x, -_slot_y); + ink_cairo_transform(tbg_ct, trans); + cairo_translate(tbg_ct, _background_area.left(), _background_area.top()); + cairo_set_source_surface(tbg_ct, bg, 0, 0); + cairo_set_operator(tbg_ct, CAIRO_OPERATOR_SOURCE); + cairo_paint(tbg_ct); + cairo_destroy(tbg_ct); + } else { + tbg = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, _slot_w, _slot_h); + } return tbg; } diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 1e7c3a5a6..d41b5180b 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -28,7 +28,7 @@ namespace Filters { class FilterSlot { public: /** Creates a new FilterSlot object. */ - FilterSlot(DrawingItem *item, DrawingContext &bgct, + FilterSlot(DrawingItem *item, DrawingContext *bgct, DrawingContext &graphic, FilterUnits const &u); /** Destroys the FilterSlot object and all its contents */ virtual ~FilterSlot(); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index ae50e641b..450ce689d 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -97,7 +97,7 @@ Filter::~Filter() } -int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &bgct, DrawingContext &graphic) +int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgct) { if (_primitive.empty()) { // when no primitives are defined, clear source graphic @@ -113,28 +113,16 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &bgct, Draw Geom::Affine trans = item->ctm(); - Geom::Rect item_bbox; - { - Geom::OptRect maybe_bbox = item->itemBounds(); - if (maybe_bbox.isEmpty()) { - // Code below needs a bounding box - return 1; - } - item_bbox = *maybe_bbox; - } - if (item_bbox.hasZeroArea()) { - // It's no use to try and filter an empty object. - return 1; - } - Geom::Rect filter_area = filter_effect_area(item_bbox); + Geom::OptRect filter_area = filter_effect_area(item->itemBounds()); + if (!filter_area) return 1; FilterUnits units(_filter_units, _primitive_units); units.set_ctm(trans); - units.set_item_bbox(item_bbox); - units.set_filter_area(filter_area); + units.set_item_bbox(item->itemBounds()); + units.set_filter_area(*filter_area); std::pair resolution - = _filter_resolution(filter_area, trans, filterquality); + = _filter_resolution(*filter_area, trans, filterquality); if (!(resolution.first > 0 && resolution.second > 0)) { // zero resolution - clear source graphic and return graphic.setSource(0,0,0,0); @@ -228,30 +216,36 @@ void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item */ } -Geom::IntRect Filter::compute_drawbox(Inkscape::DrawingItem const *item, Geom::Rect const &item_bbox) { +Geom::OptIntRect Filter::compute_drawbox(Inkscape::DrawingItem const *item, Geom::OptRect const &item_bbox) { - Geom::Rect enlarged = filter_effect_area(item_bbox); - enlarged *= item->ctm(); + Geom::OptRect enlarged = filter_effect_area(item_bbox); + if (enlarged) { + *enlarged *= item->ctm(); - Geom::IntRect ret(enlarged.roundOutwards()); - return ret; + Geom::OptIntRect ret(enlarged->roundOutwards()); + return ret; + } else { + return Geom::OptIntRect(); + } } -Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) +Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox) { Geom::Point minp, maxp; - double len_x = bbox.width(); - double len_y = bbox.height(); + double len_x = bbox ? bbox->width() : 0; + double len_y = bbox ? bbox->height() : 0; /* TODO: fetch somehow the object ex and em lengths */ _region_x.update(12, 6, len_x); _region_y.update(12, 6, len_y); _region_width.update(12, 6, len_x); _region_height.update(12, 6, len_y); if (_filter_units == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) { + if (!bbox) return Geom::OptRect(); + if (_region_x.unit == SVGLength::PERCENT) { - minp[X] = bbox.min()[X] + _region_x.computed; + minp[X] = bbox->left() + _region_x.computed; } else { - minp[X] = bbox.min()[X] + _region_x.computed * len_x; + minp[X] = bbox->left() + _region_x.computed * len_x; } if (_region_width.unit == SVGLength::PERCENT) { maxp[X] = minp[X] + _region_width.computed; @@ -260,9 +254,9 @@ Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) } if (_region_y.unit == SVGLength::PERCENT) { - minp[Y] = bbox.min()[Y] + _region_y.computed; + minp[Y] = bbox->top() + _region_y.computed; } else { - minp[Y] = bbox.min()[Y] + _region_y.computed * len_y; + minp[Y] = bbox->top() + _region_y.computed * len_y; } if (_region_height.unit == SVGLength::PERCENT) { maxp[Y] = minp[Y] + _region_height.computed; @@ -278,7 +272,7 @@ Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) } else { g_warning("Error in Inkscape::Filters::Filter::filter_effect_area: unrecognized value of _filter_units"); } - Geom::Rect area(minp, maxp); + Geom::OptRect area(minp, maxp); return area; } diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 87a0fae94..32e1df60b 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -34,7 +34,7 @@ public: * the results of filter rendering. @a bgarea and @a area specify bounding boxes * of both surfaces in world coordinates; Cairo contexts are assumed to be in default state * (0,0 = surface origin, no path, OVER operator) */ - int render(Inkscape::DrawingItem const *item, DrawingContext &bgct, DrawingContext &graphic); + int render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgct); /** * Creates a new filter primitive under this filter object. @@ -156,13 +156,13 @@ public: * to contain the filter effects region and transforms it to screen * coordinates */ - Geom::IntRect compute_drawbox(Inkscape::DrawingItem const *item, Geom::Rect const &item_bbox); + Geom::OptIntRect compute_drawbox(Inkscape::DrawingItem const *item, Geom::OptRect const &item_bbox); /** * Returns the filter effects area in user coordinate system. * The given bounding box should be a bounding box as specified in * SVG standard and in user coordinate system. */ - Geom::Rect filter_effect_area(Geom::Rect const &bbox); + Geom::OptRect filter_effect_area(Geom::OptRect const &bbox); // returns cache score factor double complexity(Geom::Affine const &ctm); -- cgit v1.2.3 From babb7a67749cb691674bdd9758f0568d4b094b56 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 20:27:53 +0200 Subject: Refactoring of the snapping preferences; mainly about storing all toggles in a single array, instead of each having its own member variable (bzr r10569) --- src/attributes-test.h | 1 - src/attributes.cpp | 2 +- src/attributes.h | 3 +- src/display/canvas-axonomgrid.cpp | 2 +- src/display/canvas-grid.cpp | 2 +- src/display/snap-indicator.cpp | 12 +- src/guide-snapper.cpp | 2 +- src/object-snapper.cpp | 231 ++++++++++++++-------------------- src/selection.cpp | 12 +- src/seltrans.cpp | 9 +- src/snap-enums.h | 29 +++-- src/snap-preferences.cpp | 199 +++++++++++++++++++++++++---- src/snap-preferences.h | 70 ++--------- src/snap.cpp | 10 +- src/sp-ellipse.cpp | 20 +-- src/sp-flowtext.cpp | 2 +- src/sp-image.cpp | 26 ++-- src/sp-item.cpp | 21 +--- src/sp-namedview.cpp | 38 +++--- src/sp-rect.cpp | 19 ++- src/sp-shape.cpp | 19 ++- src/sp-spiral.cpp | 11 +- src/sp-star.cpp | 11 +- src/sp-text.cpp | 2 +- src/ui/dialog/document-properties.cpp | 6 +- src/ui/dialog/document-properties.h | 1 - src/widgets/toolbox.cpp | 81 +++++------- 27 files changed, 425 insertions(+), 416 deletions(-) (limited to 'src') diff --git a/src/attributes-test.h b/src/attributes-test.h index dee29975e..02b53defc 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -358,7 +358,6 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:snap-text-baseline", true}, {"inkscape:snap-bbox-edge-midpoints", true}, {"inkscape:snap-bbox-midpoints", true}, - //{"inkscape:snap-intersection-grid-guide", true}, {"inkscape:snap-grids", true}, {"inkscape:snap-to-guides", true}, {"inkscape:snap-intersection-paths", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index 47b261038..7e0a5e5d3 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -95,7 +95,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"}, {SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"}, {SP_ATTR_INKSCAPE_SNAP_OTHERS, "inkscape:snap-others"}, - {SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, "inkscape:snap-from-guide"}, + //{SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, "inkscape:snap-from-guide"}, {SP_ATTR_INKSCAPE_SNAP_CENTER, "inkscape:snap-center"}, {SP_ATTR_INKSCAPE_SNAP_GRIDS, "inkscape:snap-grids"}, {SP_ATTR_INKSCAPE_SNAP_TO_GUIDES, "inkscape:snap-to-guides"}, diff --git a/src/attributes.h b/src/attributes.h index 2dec8b351..7d42dd357 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -95,7 +95,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_BBOX, SP_ATTR_INKSCAPE_SNAP_NODES, SP_ATTR_INKSCAPE_SNAP_OTHERS, - SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, + //SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, SP_ATTR_INKSCAPE_SNAP_CENTER, SP_ATTR_INKSCAPE_SNAP_GRIDS, SP_ATTR_INKSCAPE_SNAP_TO_GUIDES, @@ -105,7 +105,6 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, - //SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE, SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, SP_ATTR_INKSCAPE_OBJECT_PATHS, SP_ATTR_INKSCAPE_OBJECT_NODES, diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index ec2d35f69..3ed1fa5a9 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -770,7 +770,7 @@ void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Poi bool CanvasAxonomGridSnapper::ThisSnapperMightSnap() const { - return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeAny(); + return _snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID); } diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index aa38a14c9..b3ec73e78 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1072,7 +1072,7 @@ void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point c */ bool CanvasXYGridSnapper::ThisSnapperMightSnap() const { - return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeAny(); + return _snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID); } } // namespace Inkscape diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index e351a1145..5b2314d51 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -120,9 +120,6 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_ROTATION_CENTER: target_name = _("object rotation center"); break; - case SNAPTARGET_HANDLE: - target_name = _("handle"); - break; case SNAPTARGET_BBOX_EDGE_MIDPOINT: target_name = _("bounding box side midpoint"); break; @@ -132,13 +129,11 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_PAGE_CORNER: target_name = _("page corner"); break; - case SNAPTARGET_CONVEX_HULL_CORNER: - target_name = _("convex hull corner"); - break; case SNAPTARGET_ELLIPSE_QUADRANT_POINT: target_name = _("quadrant point"); break; - case SNAPTARGET_CORNER: + case SNAPTARGET_RECT_CORNER: + case SNAPTARGET_IMG_CORNER: target_name = _("corner"); break; case SNAPTARGET_TEXT_ANCHOR: @@ -206,7 +201,8 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPSOURCE_ELLIPSE_QUADRANT_POINT: source_name = _("Quadrant point"); break; - case SNAPSOURCE_CORNER: + case SNAPSOURCE_RECT_CORNER: + case SNAPSOURCE_IMG_CORNER: source_name = _("Corner"); break; case SNAPSOURCE_TEXT_ANCHOR: diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index 4f70521e0..2527ccb31 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -65,7 +65,7 @@ bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const return false; } - return (_snap_enabled && _snapmanager->snapprefs.getSnapToGuides() && _snapmanager->getNamedView()->showguides); + return (_snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE) && _snapmanager->getNamedView()->showguides); } void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 389930b57..da6eca027 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -8,7 +8,7 @@ * Jon A. Cruz * Abhishek Sharma * - * Copyright (C) 2005 - 2010 Authors + * Copyright (C) 2005 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -42,8 +42,8 @@ Inkscape::ObjectSnapper::ObjectSnapper(SnapManager *sm, Geom::Coord const d) : Snapper(sm, d) { _candidates = new std::vector; - _points_to_snap_to = new std::vector; - _paths_to_snap_to = new std::vector; + _points_to_snap_to = new std::vector; + _paths_to_snap_to = new std::vector; } Inkscape::ObjectSnapper::~ObjectSnapper() @@ -87,13 +87,9 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, bool const clip_or_mask, Geom::Affine const additional_affine) const // transformation of the item being clipped / masked { - if (!ThisSnapperMightSnap()) { - return; - } - if (_snapmanager->getDesktop() == NULL) { g_warning("desktop == NULL, so we cannot snap; please inform the developpers of this bug"); - // Apparently the etup() method from the SnapManager class hasn't been called before trying to snap. + // Apparently the setup() method from the SnapManager class hasn't been called before trying to snap. } if (first_point) { @@ -152,7 +148,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, if (bbox_of_item) { // See if the item is within range if (bbox_to_snap_incl.intersects(*bbox_of_item) - || (_snapmanager->snapprefs.getIncludeItemCenter() && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box + || (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER) && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box // This item is within snapping range, so record it as a candidate _candidates->push_back(SnapCandidateItem(item, clip_or_mask, additional_affine)); // For debugging: print the id of the candidate to the console @@ -167,7 +163,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, } -void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, +void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, bool const &first_point) const { // Now, let's first collect all points to snap to. If we have a whole bunch of points to snap, @@ -179,22 +175,24 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, // Determine the type of bounding box we should snap to SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX; - bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; + bool p_is_a_node = t & SNAPSOURCE_NODE_CATEGORY; + bool p_is_a_bbox = t & SNAPSOURCE_BBOX_CATEGORY; + bool p_is_other = t & SNAPSOURCE_OTHERS_CATEGORY; // A point considered for snapping should be either a node, a bbox corner or a guide/other. Pick only ONE! - g_assert(!((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))); + if (((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))) { + g_warning("Snap warning: node type is ambiguous"); + } - if (_snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER, SNAPTARGET_BBOX_EDGE_MIDPOINT, SNAPTARGET_BBOX_MIDPOINT)) { + Preferences *prefs = Preferences::get(); bool prefs_bbox = prefs->getBool("/tools/bounding_box"); bbox_type = !prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; } // Consider the page border for snapping to - if (_snapmanager->snapprefs.getSnapToPageBorder()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_CORNER)) { _getBorderNodes(_points_to_snap_to); } @@ -207,7 +205,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, g_return_if_fail(root_item); //Collect all nodes so we can snap to them - if (p_is_a_node || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node) || p_is_other) { + if (p_is_a_node || p_is_other || (p_is_a_bbox && !_snapmanager->snapprefs.getStrictSnapping())) { // Note: there are two ways in which intersections are considered: // Method 1: Intersections are calculated for each shape individually, for both the // snap source and snap target (see sp_shape_snappoints) @@ -227,19 +225,19 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, // go hunting for intersections (but only when asked to in the prefs of course). In that case we can just // temporarily block the intersections in sp_item_snappoints, we don't need duplicates. If we're not snapping to // paths though but only to item nodes then we should still look for the intersections in sp_item_snappoints() - bool old_pref = _snapmanager->snapprefs.getSnapIntersectionCS(); - if (_snapmanager->snapprefs.getSnapToItemPath()) { - _snapmanager->snapprefs.setSnapIntersectionCS(false); + bool old_pref = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_INTERSECTION); + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) { + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_PATH_INTERSECTION, false); } // We should not snap a transformation center to any of the centers of the items in the // current selection (see the comment in SelTrans::centerRequest()) - bool old_pref2 = _snapmanager->snapprefs.getIncludeItemCenter(); + bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { if ((*i).item == reinterpret_cast(itemlist->data)) { // don't snap to this item's rotation center - _snapmanager->snapprefs.setIncludeItemCenter(false); + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); break; } } @@ -248,17 +246,20 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, root_item->getSnappoints(*_points_to_snap_to, &_snapmanager->snapprefs); // restore the original snap preferences - _snapmanager->snapprefs.setSnapIntersectionCS(old_pref); - _snapmanager->snapprefs.setIncludeItemCenter(old_pref2); + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_PATH_INTERSECTION, old_pref); + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, old_pref2); } //Collect the bounding box's corners so we can snap to them - if (p_is_a_bbox || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_bbox) || p_is_other) { + if (p_is_a_bbox || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node) || p_is_other) { // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { Geom::OptRect b = root_item->getBboxDesktop(bbox_type); - getBBoxPoints(b, _points_to_snap_to, true, _snapmanager->snapprefs.getSnapToBBoxNode(), _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints(), _snapmanager->snapprefs.getSnapBBoxMidpoints()); + getBBoxPoints(b, _points_to_snap_to, true, + _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER), + _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT), + _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT)); } } } @@ -266,7 +267,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, } void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, std::vector *unselected_nodes, SnapConstraint const &c, Geom::Point const &p_proj_on_constraint) const @@ -321,9 +322,9 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, // Iterate through all nodes, find out which one is the closest to this guide, and snap to it! _collectNodes(SNAPSOURCE_GUIDE, true); - if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) { _collectPaths(p, SNAPSOURCE_GUIDE, true); - _snapPaths(sc, Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); + _snapPaths(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); } SnappedPoint s; @@ -349,7 +350,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, */ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, - Inkscape::SnapSourceType const source_type, + SnapSourceType const source_type, bool const &first_point) const { // Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap, @@ -361,21 +362,22 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, // Determine the type of bounding box we should snap to SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX; - bool p_is_a_node = source_type & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_other = source_type & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; + bool p_is_a_node = source_type & SNAPSOURCE_NODE_CATEGORY; + bool p_is_a_bbox = source_type & SNAPSOURCE_BBOX_CATEGORY; + bool p_is_other = source_type & SNAPSOURCE_OTHERS_CATEGORY; - if (_snapmanager->snapprefs.getSnapToBBoxPath()) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE)) { + Preferences *prefs = Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); bbox_type = !prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; } // Consider the page border for snapping - if (_snapmanager->snapprefs.getSnapToPageBorder() && _snapmanager->snapprefs.getSnapModeAny()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_BORDER) && _snapmanager->snapprefs.getSnapModeAny()) { Geom::PathVector *border_path = _getBorderPathv(); if (border_path != NULL) { - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); + _paths_to_snap_to->push_back(SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); } } @@ -397,17 +399,16 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, //Build a list of all paths considered for snapping to //Add the item's path to snap to - if ((_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode()) || - (_snapmanager->snapprefs.getSnapTextBaseline() && (_snapmanager->snapprefs.getSnapModeNode() || _snapmanager->snapprefs.getSnapToItemPath())) ) { - if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_TEXT_BASELINE)) { + if (p_is_other || p_is_a_node || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_bbox)) { if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { - if (_snapmanager->snapprefs.getSnapTextBaseline()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_TEXT_BASELINE)) { // Snap to the text baseline - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) root_item); + Text::Layout const *layout = te_get_layout((SPItem *) root_item); if (layout != NULL && layout->outputExists()) { Geom::PathVector *pv = new Geom::PathVector(); pv->push_back(layout->baseline() * root_item->i2dt_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt()); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_TEXT_BASELINE, Geom::OptRect())); + _paths_to_snap_to->push_back(SnapCandidatePath(pv, SNAPTARGET_TEXT_BASELINE, Geom::OptRect())); } } } else { @@ -419,7 +420,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; } - if (!very_complex_path && root_item && (_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode())) { + if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) { SPCurve *curve = NULL; if (SP_IS_SHAPE(root_item)) { curve = SP_SHAPE(root_item)->getCurve(); @@ -434,7 +435,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, Geom::PathVector *pv = new Geom::PathVector(curve->get_pathvector()); (*pv) *= root_item->i2dt_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. + _paths_to_snap_to->push_back(SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. curve->unref(); } } @@ -443,8 +444,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } //Add the item's bounding box to snap to - if (_snapmanager->snapprefs.getSnapToBBoxPath() && (_snapmanager->snapprefs.getSnapModeBBox() || _snapmanager->snapprefs.getSnapModeOthers())) { - if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE) && (_snapmanager->snapprefs.getSnapModeBBox() || _snapmanager->snapprefs.getSnapModeOthers())) { + if (p_is_other || p_is_a_bbox || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) { // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { @@ -453,7 +454,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, if (rect) { Geom::PathVector *path = _getPathvFromRect(*rect); rect = root_item->getBboxDesktop(bbox_type); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect)); + _paths_to_snap_to->push_back(SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect)); } } } @@ -463,8 +464,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, - std::vector *unselected_nodes, + SnapCandidatePoint const &p, + std::vector *unselected_nodes, SPPath const *selected_path) const { _collectPaths(p.getPoint(), p.getSourceType(), p.getSourceNum() <= 0); @@ -473,7 +474,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, g_assert(_snapmanager->getDesktop() != NULL); Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p.getPoint()); - bool const node_tool_active = _snapmanager->snapprefs.getSnapToItemPath() && selected_path != NULL; + bool const node_tool_active = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH) && selected_path != NULL; if (p.getSourceNum() <= 0) { /* findCandidates() is used for snapping to both paths and nodes. It ignores the path that is @@ -492,7 +493,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, true, Geom::identity(), Geom::identity()); // We will get our own copy of the path, which must be freed at some point - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pathv, SNAPTARGET_PATH, Geom::OptRect(), true)); + _paths_to_snap_to->push_back(SnapCandidatePath(pathv, SNAPTARGET_PATH, Geom::OptRect(), true)); curve->unref(); } } @@ -503,7 +504,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); - for (std::vector::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { + for (std::vector::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { if (_allowSourceToSnapToTarget(p.getSourceType(), (*it_p).target_type, strict_snapping)) { bool const being_edited = node_tool_active && (*it_p).currently_being_edited; //if true then this pathvector it_pv is currently being edited in the node tool @@ -545,7 +546,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, if (!being_edited || (c1 && c2)) { Geom::Coord const dist = Geom::distance(sp_doc, p_doc); if (dist < getSnapperTolerance()) { - sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + sc.curves.push_back(SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); } } } @@ -557,7 +558,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, } /* Returns true if point is coincident with one of the unselected nodes */ -bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::vector const *unselected_nodes) const +bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::vector const *unselected_nodes) const { if (unselected_nodes == NULL) { return false; @@ -567,7 +568,7 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve return false; } - for (std::vector::const_iterator i = unselected_nodes->begin(); i != unselected_nodes->end(); i++) { + for (std::vector::const_iterator i = unselected_nodes->begin(); i != unselected_nodes->end(); i++) { if (Geom::L2(point - (*i).getPoint()) < 1e-4) { return true; } @@ -577,7 +578,7 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve } void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, SnapConstraint const &c, Geom::Point const &p_proj_on_constraint) const { @@ -618,7 +619,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, // Find all intersections of the constrained path with the snap target candidates std::vector intersections; - for (std::vector::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { + for (std::vector::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { if (k->path_vector && _allowSourceToSnapToTarget(p.getSourceType(), (*k).target_type, strict_snapping)) { // Do the intersection math Geom::CrossingSet cs = Geom::crossings(constraint_path, *(k->path_vector)); @@ -671,12 +672,12 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector const *it, std::vector *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false ) { + if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } @@ -686,29 +687,9 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); } - // TODO: Argh, UGLY! Get rid of this here, move this logic to the snap manager - bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( - _snapmanager->snapprefs.getSnapToItemNode() || - _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( - _snapmanager->snapprefs.getSnapToBBoxNode() || - _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || - _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeAny() && ( - _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapTextBaseline() - )) ; - - if (snap_nodes) { - _snapNodes(sc, p, unselected_nodes); - } + _snapNodes(sc, p, unselected_nodes); - if ((_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath()) || - (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath()) || - _snapmanager->snapprefs.getSnapModeAny()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size(); if (n > 0) { /* While editing a path in the node tool, findCandidates must ignore that path because @@ -731,13 +712,13 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, } void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, SnapConstraint const &c, std::vector const *it, std::vector *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } @@ -754,27 +735,9 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, // This is useful for example when scaling an object while maintaining a fixed aspect ratio. It's // nodes are only allowed to move in one direction (i.e. in one degree of freedom). - // TODO: Argh, UGLY! Get rid of this here, move this logic to the snap manager - bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( - _snapmanager->snapprefs.getSnapToItemNode() || - _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( - _snapmanager->snapprefs.getSnapToBBoxNode() || - _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || - _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeAny() && ( - _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getSnapTextBaseline() - )); - - if (snap_nodes) { - _snapNodes(sc, p, unselected_nodes, c, pp); - } + _snapNodes(sc, p, unselected_nodes, c, pp); - if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { _snapPathsConstrained(sc, p, c, pp); } } @@ -785,12 +748,16 @@ void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc, Geom::Point const &p, Geom::Point const &guide_normal) const { - /* Get a list of all the SPItems that we will try to snap to */ - std::vector cand; - std::vector const it; //just an empty list + if (!_snapmanager->snapprefs.getSnapModeOthers()) { + return; + } + - _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); - _snapTranslatingGuide(sc, p, guide_normal); + //std::vector const it; //just an empty list + + freeSnap(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), Geom::Rect(p, p), NULL, NULL); + //_findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); + //_snapTranslatingGuide(sc, p, guide_normal); } @@ -804,8 +771,12 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc, std::vector cand; std::vector const it; //just an empty list - _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); - _snapTranslatingGuide(sc, p, guide_normal); + std::cout << "guideConstrainedSnap" << std::endl; + + if (_snapmanager->snapprefs.getSnapModeOthers()) { + _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); + _snapTranslatingGuide(sc, p, guide_normal); + } } @@ -814,29 +785,15 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc, */ bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const { - bool snap_to_something = (_snapmanager->snapprefs.getSnapModeNode() && ( - _snapmanager->snapprefs.getSnapToItemPath() || - _snapmanager->snapprefs.getSnapToItemNode() || - _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( - _snapmanager->snapprefs.getSnapToBBoxPath() || - _snapmanager->snapprefs.getSnapToBBoxNode() || - _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || - _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeAny() && ( - _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapTextBaseline() - )); - - return (_snap_enabled && snap_to_something); + return _snapmanager->snapprefs.getSnapModeBBox() + || _snapmanager->snapprefs.getSnapModeNode() + || _snapmanager->snapprefs.getSnapModeOthers() + || _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_CORNER); } void Inkscape::ObjectSnapper::_clear_paths() const { - for (std::vector::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { + for (std::vector::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { delete k->path_vector; } _paths_to_snap_to->clear(); @@ -863,10 +820,10 @@ void Inkscape::ObjectSnapper::_getBorderNodes(std::vector *p { Geom::Coord w = (_snapmanager->getDocument())->getWidth(); Geom::Coord h = (_snapmanager->getDocument())->getHeight(); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(w,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(w,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); } void Inkscape::getBBoxPoints(Geom::OptRect const bbox, @@ -880,15 +837,15 @@ void Inkscape::getBBoxPoints(Geom::OptRect const bbox, // collect the corners of the bounding box for ( unsigned k = 0 ; k < 4 ; k++ ) { if (includeCorners) { - points->push_back(Inkscape::SnapCandidatePoint(bbox->corner(k), Inkscape::SNAPSOURCE_BBOX_CORNER, -1, Inkscape::SNAPTARGET_BBOX_CORNER, *bbox)); + points->push_back(SnapCandidatePoint(bbox->corner(k), SNAPSOURCE_BBOX_CORNER, -1, SNAPTARGET_BBOX_CORNER, *bbox)); } // optionally, collect the midpoints of the bounding box's edges too if (includeLineMidpoints) { - points->push_back(Inkscape::SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, Inkscape::SNAPSOURCE_BBOX_EDGE_MIDPOINT, -1, Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox)); + points->push_back(SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, SNAPSOURCE_BBOX_EDGE_MIDPOINT, -1, SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox)); } } if (includeObjectMidpoints) { - points->push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_BBOX_MIDPOINT, -1, Inkscape::SNAPTARGET_BBOX_MIDPOINT, *bbox)); + points->push_back(SnapCandidatePoint(bbox->midpoint(), SNAPSOURCE_BBOX_MIDPOINT, -1, SNAPTARGET_BBOX_MIDPOINT, *bbox)); } } } diff --git a/src/selection.cpp b/src/selection.cpp index 3007a3d1f..677e57d5f 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -433,9 +433,9 @@ std::vector Selection::getSnapPoints(SnapPreferenc GSList const *items = const_cast(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs - snapprefs_dummy.setIncludeItemCenter(false); // locally disable snapping to the item center - snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source - snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center + //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source + //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { SPItem *this_item = SP_ITEM(iter->data); @@ -443,7 +443,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc //Include the transformation origin for snapping //For a selection or group only the overall origin is considered - if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { + if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { p.push_back(Inkscape::SnapCandidatePoint(this_item->getCenter(), SNAPSOURCE_ROTATION_CENTER)); } } @@ -456,8 +456,8 @@ std::vector Selection::getSnapPointsConvexHull(Sna GSList const *items = const_cast(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs - snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source - snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { diff --git a/src/seltrans.cpp b/src/seltrans.cpp index bc8194d48..7538e15d9 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -324,18 +324,19 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s _bbox_points_for_translating.clear(); // Collect the bounding box's corners and midpoints for each selected item if (m.snapprefs.getSnapModeBBox()) { - bool mp = m.snapprefs.getSnapBBoxMidpoints(); - bool emp = m.snapprefs.getSnapBBoxEdgeMidpoints(); + bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER); + bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT); + bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); // Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations // this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the // stroke width. (see get_scale_transform_with_stroke()). This however is currently only implemented for a single bbox. // That's why we have both _bbox_points_for_translating and _bbox_points. - getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, true, emp, mp); + getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, c, emp, mp); if (((_items.size() > 0) && (_items.size() < 50)) || prefs->getBool("/options/snapclosestonly/value", false)) { // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole for (unsigned i = 0; i < _items.size(); i++) { - getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp); + getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, c, emp, mp); } } else { _bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole diff --git a/src/snap-enums.h b/src/snap-enums.h index 6ef021fc0..fd28910a8 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -20,26 +20,28 @@ enum SnapSourceType { //------------------------------------------------------------------- // Bbox points can be located at the edge of the stroke (for visual bboxes); they will therefore not snap // to nodes because these are always located at the center of the stroke - SNAPSOURCE_BBOX_CATEGORY = 256, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_BBOX_CATEGORY = 32, // will be used as a flag and must therefore be a power of two. Also, + // must be larger than the largest number of targets in a single group SNAPSOURCE_BBOX_CORNER, SNAPSOURCE_BBOX_MIDPOINT, SNAPSOURCE_BBOX_EDGE_MIDPOINT, //------------------------------------------------------------------- // For the same reason, nodes will not snap to bbox points - SNAPSOURCE_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_NODE_CATEGORY = 64, // will be used as a flag and must therefore be a power of two SNAPSOURCE_NODE_SMOOTH, // Symmetrical nodes are also considered to be smooth; there's no dedicated type for symm. nodes SNAPSOURCE_NODE_CUSP, SNAPSOURCE_LINE_MIDPOINT, SNAPSOURCE_PATH_INTERSECTION, - SNAPSOURCE_CORNER, // of image or of rectangle + SNAPSOURCE_RECT_CORNER, // of a rectangle, so at the center of the stroke SNAPSOURCE_CONVEX_HULL_CORNER, SNAPSOURCE_ELLIPSE_QUADRANT_POINT, SNAPSOURCE_NODE_HANDLE, // eg. nodes in the path editor, handles of stars or rectangles, etc. (tied to a stroke) //------------------------------------------------------------------- // Other points (e.g. guides, gradient knots) will snap to both bounding boxes and nodes - SNAPSOURCE_OTHERS_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two SNAPSOURCE_ROTATION_CENTER, SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, ellipses, polygon, etc. + SNAPSOURCE_IMG_CORNER, SNAPSOURCE_GUIDE, SNAPSOURCE_GUIDE_ORIGIN, SNAPSOURCE_TEXT_ANCHOR, @@ -50,22 +52,24 @@ enum SnapSourceType { enum SnapTargetType { SNAPTARGET_UNDEFINED = 0, //------------------------------------------------------------------- - SNAPTARGET_BBOX_CATEGORY = 256, // will be used as a flag and must therefore be a power of two + SNAPTARGET_BBOX_CATEGORY = 32, // will be used as a flag and must therefore be a power of two. Also, + // must be larger than the largest number of targets in a single group + // i.e > 15 because that's the number of targets in the "others" group SNAPTARGET_BBOX_CORNER, SNAPTARGET_BBOX_EDGE, SNAPTARGET_BBOX_EDGE_MIDPOINT, SNAPTARGET_BBOX_MIDPOINT, //------------------------------------------------------------------- - SNAPTARGET_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two + SNAPTARGET_NODE_CATEGORY = 64, // will be used as a flag and must therefore be a power of two SNAPTARGET_NODE_SMOOTH, SNAPTARGET_NODE_CUSP, SNAPTARGET_LINE_MIDPOINT, SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, - SNAPTARGET_ELLIPSE_QUADRANT_POINT, - SNAPTARGET_CORNER, // of image or of rectangle + SNAPTARGET_ELLIPSE_QUADRANT_POINT, // this corner is at the center of the stroke + SNAPTARGET_RECT_CORNER, // of a rectangle, so this corner is at the center of the stroke //------------------------------------------------------------------- - SNAPTARGET_OTHERS_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two + SNAPTARGET_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two SNAPTARGET_GRID, SNAPTARGET_GRID_INTERSECTION, SNAPTARGET_GUIDE, @@ -73,15 +77,16 @@ enum SnapTargetType { SNAPTARGET_GUIDE_ORIGIN, SNAPTARGET_GRID_GUIDE_INTERSECTION, SNAPTARGET_OBJECT_MIDPOINT, + SNAPTARGET_IMG_CORNER, SNAPTARGET_ROTATION_CENTER, - SNAPTARGET_HANDLE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_PAGE_CORNER, - SNAPTARGET_CONVEX_HULL_CORNER, SNAPTARGET_TEXT_ANCHOR, SNAPTARGET_TEXT_BASELINE, SNAPTARGET_CONSTRAINED_ANGLE, - SNAPTARGET_CONSTRAINT + SNAPTARGET_CONSTRAINT, + //------------------------------------------------------------------- + SNAPTARGET_MAX_ENUM_VALUE }; } diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index b98726a86..a02e4baba 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -12,20 +12,24 @@ #include "inkscape.h" #include "snap-preferences.h" +#include // g_assert() Inkscape::SnapPreferences::SnapPreferences() : - _include_item_center(false), - _intersectionGG(true), - _snap_to_grids(true), - _snap_to_guides(true), _snap_enabled_globally(true), _snap_postponed_globally(false), - _snap_to_itemnode(true), _snap_to_itempath(true), - _snap_to_bboxnode(true), _snap_to_bboxpath(true), - _snap_to_page_border(false), _strict_snapping(true) { + // Check for enough space to hold all snap target toggles in the "others" group; see the comments in snap-enums.h + g_assert(SNAPTARGET_MAX_ENUM_VALUE - SNAPTARGET_OTHERS_CATEGORY < SNAPTARGET_BBOX_CATEGORY); + // Check for powers of two; see the comments in snap-enums.h + g_assert((SNAPTARGET_BBOX_CATEGORY != 0) && !(SNAPTARGET_BBOX_CATEGORY & (SNAPTARGET_BBOX_CATEGORY - 1))); + g_assert((SNAPTARGET_NODE_CATEGORY != 0) && !(SNAPTARGET_NODE_CATEGORY & (SNAPTARGET_NODE_CATEGORY - 1))); + g_assert((SNAPTARGET_OTHERS_CATEGORY != 0) && !(SNAPTARGET_OTHERS_CATEGORY & (SNAPTARGET_OTHERS_CATEGORY - 1))); + setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab + for (int n = 0; n < Inkscape::SNAPTARGET_MAX_ENUM_VALUE; n++) { + _active_snap_targets[n] = -1; + } } /* @@ -46,6 +50,7 @@ void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled) } else { _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_BBOX_CATEGORY); } + setTargetSnappable(SNAPTARGET_BBOX_CATEGORY, enabled); } bool Inkscape::SnapPreferences::getSnapModeBBox() const @@ -60,6 +65,7 @@ void Inkscape::SnapPreferences::setSnapModeNode(bool enabled) } else { _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_NODE_CATEGORY); } + setTargetSnappable(SNAPTARGET_NODE_CATEGORY, enabled); } bool Inkscape::SnapPreferences::getSnapModeNode() const @@ -74,6 +80,7 @@ void Inkscape::SnapPreferences::setSnapModeOthers(bool enabled) } else { _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } + setTargetSnappable(SNAPTARGET_OTHERS_CATEGORY, enabled); } bool Inkscape::SnapPreferences::getSnapModeOthers() const @@ -81,31 +88,11 @@ bool Inkscape::SnapPreferences::getSnapModeOthers() const return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } - -//bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const -//{ -// return (_snap_from & (Inkscape::SNAPSOURCE_BBOX_CATEGORY | Inkscape::SNAPSOURCE_NODE_CATEGORY) ); -//} - bool Inkscape::SnapPreferences::getSnapModeAny() const { return (_snap_from != 0); } -void Inkscape::SnapPreferences::setSnapModeGuide(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } -} - -bool Inkscape::SnapPreferences::getSnapModeGuide() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); -} - /** * Turn on/off snapping of specific point types. * \param t Point type. @@ -129,6 +116,164 @@ bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const return (_snap_from & t); } +void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const +{ + if (target & SNAPTARGET_BBOX_CATEGORY) { + group_on = getSnapModeBBox(); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets + } else if (target & SNAPTARGET_NODE_CATEGORY) { + group_on = getSnapModeNode(); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths + if (target == SNAPTARGET_RECT_CORNER || target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { // Don't have their own button; on when the group is on + target = SNAPTARGET_NODE_CATEGORY; + } + } else if (target & SNAPTARGET_OTHERS_CATEGORY) { + // Only if the group with "other" snap sources/targets has been enabled, then we might snap to any of those targets + // ... but this doesn't hold for the page border, grids, and guides + group_on = getSnapModeOthers(); + switch (target) { + // Some snap targets don't have their own toggle. These targets are called "secondary targets". We will re-map + // them to their cousin which does have a toggle, and which is called a "primary target" + case SNAPTARGET_GRID_INTERSECTION: + group_on = true; // cannot be disabled as part of a disabled group; + target = SNAPTARGET_GRID; + break; + case SNAPTARGET_GUIDE_INTERSECTION: + case SNAPTARGET_GUIDE_ORIGIN: + group_on = true; // cannot be disabled as part of a disabled group; + target = SNAPTARGET_GUIDE; + break; + case SNAPTARGET_PAGE_CORNER: + group_on = true; // cannot be disabled as part of a disabled group; + target = SNAPTARGET_PAGE_BORDER; + break; + case SNAPTARGET_TEXT_ANCHOR: + target = SNAPTARGET_TEXT_BASELINE; + break; + + case SNAPTARGET_IMG_CORNER: // Doesn't have its own button, on if the group is on + target = SNAPTARGET_OTHERS_CATEGORY; + break; + // Some snap targets cannot be toggled at all, and are therefore always enabled + case SNAPTARGET_GRID_GUIDE_INTERSECTION: + case SNAPTARGET_CONSTRAINED_ANGLE: + case SNAPTARGET_CONSTRAINT: + always_on = true; // Doesn't have it's own button + break; + case SNAPTARGET_GRID: + case SNAPTARGET_GUIDE: + case SNAPTARGET_PAGE_BORDER: + group_on = true; // cannot be disabled as part of a disabled group; + break; + + // These are only listed for completeness + case SNAPTARGET_OBJECT_MIDPOINT: + case SNAPTARGET_ROTATION_CENTER: + case SNAPTARGET_TEXT_BASELINE: + break; + + case SNAPTARGET_BBOX_CATEGORY: + case SNAPTARGET_NODE_CATEGORY: + case SNAPTARGET_OTHERS_CATEGORY: + break; + default: + g_warning("Snap-preferences warning: Undefined snap target (#%i)", target); + break; + } + } else if (target == SNAPTARGET_UNDEFINED ) { + g_warning("Snap-preferences warning: Undefined snaptarget (#%i)", target); + } +} + +void Inkscape::SnapPreferences::setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled) +{ + bool always_on = false; + bool group_on = false; + Inkscape::SnapTargetType index = target; + + _mapTargetToArrayIndex(index, always_on, group_on); + + if (always_on) { + // Catch coding errors + g_warning("Snap-preferences warning: Trying to enable/disable a snap target (#%i) that's always on by definition", index); + } else { + if (index == target) { // I.e. if it has not been re-mapped, then we have a primary target at hand + _active_snap_targets[index] = enabled; + } else { // If it has been re-mapped though, then this target does not have its own toggle button and should therefore not be set + g_warning("Snap-preferences warning: Trying to enable/disable a secondary snap target (#%i); only primary targets can be set", index); + } + } +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target) const +{ + bool always_on = false; + bool group_on = false; + Inkscape::SnapTargetType index = target; + + _mapTargetToArrayIndex(index, always_on, group_on); + + if (group_on) { + if (always_on) { + return true; + } else { + if (_active_snap_targets[index] == -1) { + // Catch coding errors + g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index); + } + return _active_snap_targets[index]; + } + } else { + return false; + } +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const { + return isTargetSnappable(target1) || isTargetSnappable(target2); +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const { + return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3); +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const { + return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4); +} + + +//bool Inkscape::SnapPreferences::isAnyBBoxSnappable() const { +// return getSnapModeBBox() || getSnapModeOthers() || (getSnapModeNode() && !_strict_snapping); +//} + +//bool Inkscape::SnapPreferences::isAnyNodeOrPathSnappable() const { +// return getSnapModeNode() || getSnapModeOthers() || (getSnapModeBBox() && !_strict_snapping); +//} + +//bool Inkscape::SnapPreferences::isAnyOtherSnappable() const { +// return getSnapModeOthers(); +//} + +bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType const target) const +{ + bool always_on = false; + bool group_on = false; + Inkscape::SnapTargetType index = target; + + _mapTargetToArrayIndex(index, always_on, group_on); + + if (_active_snap_targets[index] == -1) { + // Catch coding errors + g_warning("Snap-preferences warning: Using an uninitialized snap target setting"); + } else { + if (index == target) { // I.e. if it has not been re-mapped, then we have a primary target at hand, which does have its own toggle button + return _active_snap_targets[index]; + } else { // If it has been re-mapped though, then this target does not have its own toggle button and therefore the button status cannot be read + g_warning("Snap-preferences warning: Trying to determine the button status of a secondary snap target; However, only primary targets have a button"); + } + } + + return false; +} + + /* Local Variables: mode:c++ diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 35d05c40e..dac11b3aa 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -23,43 +23,23 @@ class SnapPreferences { public: SnapPreferences(); + void setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled); + bool isTargetSnappable(Inkscape::SnapTargetType const target) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const; + //bool isAnyBBoxSnappable() const; + //bool isAnyNodeOrPathSnappable() const; + //bool isAnyOtherSnappable() const; + bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const; void setSnapModeBBox(bool enabled); void setSnapModeNode(bool enabled); void setSnapModeOthers(bool enabled); - void setSnapModeGuide(bool enabled); bool getSnapModeBBox() const; bool getSnapModeNode() const; bool getSnapModeOthers() const; - //bool getSnapModeBBoxOrNodes() const; bool getSnapModeAny() const; - bool getSnapModeGuide() const; - - void setSnapIntersectionGG(bool enabled) {_intersectionGG = enabled;} - void setSnapIntersectionCS(bool enabled) {_intersectionCS = enabled;} - void setSnapSmoothNodes(bool enabled) {_smoothNodes = enabled;} - void setSnapLineMidpoints(bool enabled) {_line_midpoints = enabled;} - void setSnapObjectMidpoints(bool enabled) {_object_midpoints = enabled;} - void setSnapTextBaseline(bool enabled) {_text_baseline = enabled;} - void setSnapBBoxEdgeMidpoints(bool enabled) {_bbox_edge_midpoints = enabled;} - void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;} - bool getSnapIntersectionGG() const {return _intersectionGG;} - bool getSnapIntersectionCS() const {return _intersectionCS;} - bool getSnapSmoothNodes() const {return _smoothNodes;} - bool getSnapLineMidpoints() const {return _line_midpoints;} - bool getSnapObjectMidpoints() const {return _object_midpoints;} - bool getSnapTextBaseline() const {return _text_baseline;} - bool getSnapBBoxEdgeMidpoints() const {return _bbox_edge_midpoints;} - bool getSnapBBoxMidpoints() const {return _bbox_midpoints;} - - void setSnapToGrids(bool enabled) {_snap_to_grids = enabled;} - bool getSnapToGrids() const {return _snap_to_grids;} - - void setSnapToGuides(bool enabled) {_snap_to_guides = enabled;} - bool getSnapToGuides() const {return _snap_to_guides;} - - void setIncludeItemCenter(bool enabled) {_include_item_center = enabled;} - bool getIncludeItemCenter() const {return _include_item_center;} void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;} bool getSnapEnabledGlobally() const {return _snap_enabled_globally;} @@ -70,17 +50,6 @@ public: void setSnapFrom(Inkscape::SnapSourceType t, bool s); bool getSnapFrom(Inkscape::SnapSourceType t) const; - // These will only be used for the object snapper - void setSnapToItemNode(bool s) {_snap_to_itemnode = s;} - bool getSnapToItemNode() const {return _snap_to_itemnode;} - void setSnapToItemPath(bool s) {_snap_to_itempath = s;} - bool getSnapToItemPath() const {return _snap_to_itempath;} - void setSnapToBBoxNode(bool s) {_snap_to_bboxnode = s;} - bool getSnapToBBoxNode() const {return _snap_to_bboxnode;} - void setSnapToBBoxPath(bool s) {_snap_to_bboxpath = s;} - bool getSnapToBBoxPath() const {return _snap_to_bboxpath;} - void setSnapToPageBorder(bool s) {_snap_to_page_border = s;} - bool getSnapToPageBorder() const {return _snap_to_page_border;} bool getStrictSnapping() const {return _strict_snapping;} gdouble getGridTolerance() const {return _grid_tolerance;} @@ -92,27 +61,14 @@ public: void setObjectTolerance(gdouble val) {_object_tolerance = val;} private: - bool _include_item_center; //If true, snapping nodes will also snap the item's center - bool _intersectionGG; //Consider snapping to intersections of grid and guides - bool _intersectionCS; //Consider snapping to intersections of curves - bool _smoothNodes; - bool _line_midpoints; - bool _object_midpoints; // the midpoint of shapes (e.g. a circle, rect, polygon) or of any other shape (at [h/2, w/2]) - bool _text_baseline; // both anchor point and baseline of the text - bool _bbox_edge_midpoints; - bool _bbox_midpoints; - bool _snap_to_grids; - bool _snap_to_guides; + void _mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const; + int _active_snap_targets[Inkscape::SNAPTARGET_MAX_ENUM_VALUE]; + bool _snap_enabled_globally; // Toggles ALL snapping bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast + SnapSourceType _snap_from; ///< bitmap of point types that we will snap from - // These will only be used for the object snapper - bool _snap_to_itemnode; - bool _snap_to_itempath; - bool _snap_to_bboxnode; - bool _snap_to_bboxpath; - bool _snap_to_page_border; //If enabled, then bbox corners will only snap to bboxes, //and nodes will only snap to nodes and paths. We will not //snap bbox corners to nodes, or nodes to bboxes. diff --git a/src/snap.cpp b/src/snap.cpp index a3015e576..8d3103122 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -97,7 +97,7 @@ SnapManager::getGridSnappers() const { SnapperList s; - if (_desktop && _desktop->gridsEnabled() && snapprefs.getSnapToGrids()) { + if (_desktop && _desktop->gridsEnabled() && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID)) { for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) { Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; s.push_back(grid->snapper); @@ -577,7 +577,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, return; } - if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) { + if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { return; } @@ -624,7 +624,7 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) return; } - if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) { + if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { return; } @@ -1202,7 +1202,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } } - if (snapprefs.getSnapIntersectionCS()) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { // search for the closest snapped intersection of curves Inkscape::SnappedPoint closestCurvesIntersection; if (getClosestIntersectionCS(sc.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { @@ -1247,7 +1247,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } // search for the closest snapped intersection of grid with guide lines - if (snapprefs.getSnapIntersectionGG()) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION)) { Inkscape::SnappedPoint closestGridGuidePoint; if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) { closestGridGuidePoint.setSource(p.getSourceType()); diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index d2ca2c445..99189da45 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -275,11 +275,6 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - SPGenericEllipse *ellipse = SP_GENERICELLIPSE(item); sp_genericellipse_normalize(ellipse); Geom::Affine const i2dt = item->i2dt_affine(); @@ -304,7 +299,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapToItemNode()) { //TODO: Make a separate snap option toggle for this? + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)) { double angle = 0; for (angle = 0; angle < SP_2PI; angle += M_PI_2) { if (angle >= ellipse->start && angle <= ellipse->end) { @@ -315,13 +310,20 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && slice && ellipse->closed) || snapprefs->getSnapObjectMidpoints()) { + bool c1 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice && ellipse->closed; + bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT); + if (c1 || c2) { pt = Geom::Point(cx, cy) * i2dt; - p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); + if (c1) { + p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); + } + if (c2) { + p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); + } } // And if we have a slice, also snap to the endpoints - if (snapprefs->getSnapToItemNode() && slice) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice) { // Add the start point, if it's not coincident with a quadrant point if (fmod(ellipse->start, M_PI_2) != 0.0 ) { pt = Geom::Point(cx + cos(ellipse->start)*rx, cy + sin(ellipse->start)*ry) * i2dt; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 87266464c..bb931a869 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -393,7 +393,7 @@ static gchar *sp_flowtext_description(SPItem *item) static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - if (snapprefs->getSnapTextBaseline()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index c9647c939..ea7d5089e 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1282,7 +1282,7 @@ static void sp_image_update_canvas_image(SPImage *image) } } -static void sp_image_snappoints( SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/ ) +static void sp_image_snappoints( SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs ) { /* An image doesn't have any nodes to snap, but still we want to be able snap one image to another. Therefore we will create some snappoints at the corner, similar to a rect. If @@ -1297,17 +1297,19 @@ static void sp_image_snappoints( SPItem const *item, std::vectori2dt_affine ()); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_IMG_CORNER)) { + // The image has not been clipped: return its corners, which might be rotated for example + SPImage &image = *SP_IMAGE(item); + double const x0 = image.x.computed; + double const y0 = image.y.computed; + double const x1 = x0 + image.width.computed; + double const y1 = y0 + image.height.computed; + Geom::Affine const i2d (item->i2dt_affine ()); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y0) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + } } } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9e3bc02ae..a4f2efa2c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -900,27 +900,16 @@ Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) return rect; } -void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { /* This will only be called if the derived class doesn't override this. * see for example sp_genericellipse_snappoints in sp-ellipse.cpp * We don't know what shape we could be dealing with here, so we'll just - * return the corners of the bounding box */ - - Geom::OptRect bbox = item->getBounds(item->i2dt_affine()); - - if (bbox) { - Geom::Point p1, p2; - p1 = bbox->min(); - p2 = bbox->max(); - p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(p1[Geom::X], p2[Geom::Y]), Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(p2[Geom::X], p1[Geom::Y]), Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - } - + * do nothing + */ } + void SPItem::getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item @@ -930,7 +919,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap } // Get the snappoints at the item's center - if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { + if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { p.push_back(Inkscape::SnapCandidatePoint(getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER)); } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 5adc0dc74..7bafabba2 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -472,67 +472,67 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_CENTER: - nv->snap_manager.snapprefs.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GRIDS: - nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: - nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: - nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapLineMidpoints(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: - nv->snap_manager.snapprefs.setSnapTextBaseline(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: - nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; +// case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: +// nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: - nv->snap_manager.snapprefs.setSnapIntersectionCS(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_OBJECT_PATHS: - nv->snap_manager.snapprefs.setSnapToItemPath(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_OBJECT_NODES: - nv->snap_manager.snapprefs.setSnapToItemNode(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_BBOX_PATHS: - nv->snap_manager.snapprefs.setSnapToBBoxPath(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_BBOX_NODES: - nv->snap_manager.snapprefs.setSnapToBBoxNode(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PAGE: - nv->snap_manager.snapprefs.setSnapToPageBorder(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CURRENT_LAYER: diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 467b37d17..729e2a34c 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -566,11 +566,6 @@ static void sp_rect_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - SPRect *rect = SP_RECT(item); Geom::Affine const i2dt (item->i2dt_affine ()); @@ -580,21 +575,21 @@ static void sp_rect_snappoints(SPItem const *item, std::vectorx.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2dt; Geom::Point p3 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2dt; - if (snapprefs->getSnapToItemNode()) { - p.push_back(Inkscape::SnapCandidatePoint(p0, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p3, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_RECT_CORNER)) { + p.push_back(Inkscape::SnapCandidatePoint(p0, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(p3, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); } - if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforce strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { p.push_back(Inkscape::SnapCandidatePoint((p0 + p1)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); p.push_back(Inkscape::SnapCandidatePoint((p1 + p2)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); p.push_back(Inkscape::SnapCandidatePoint((p2 + p3)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); p.push_back(Inkscape::SnapCandidatePoint((p3 + p0)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } - if (snapprefs->getSnapObjectMidpoints()) { // only do this when we're snapping nodes (enforce strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { p.push_back(Inkscape::SnapCandidatePoint((p0 + p2)/2, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index beec860be..7f24dd089 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1188,18 +1188,13 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - Geom::PathVector const &pathv = shape->curve->get_pathvector(); if (pathv.empty()) return; Geom::Affine const i2dt (item->i2dt_affine ()); - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::OptRect bbox = item->getBounds(i2dt); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); @@ -1207,7 +1202,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP)) { // Add the first point of the path p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } @@ -1217,14 +1212,14 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorend_default()) { // For each path: consider midpoints of line segments for snapping - if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2dt, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } } if (curve_it2 == path_it->end_default()) { // Test will only pass for the last iteration of the while loop - if (snapprefs->getSnapToItemNode() && !path_it->closed()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && !path_it->closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); @@ -1235,8 +1230,8 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); - bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); + bool c1 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); + bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH) && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); if (c1 || c2) { Inkscape::SnapSourceType sst; @@ -1266,7 +1261,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapIntersectionCS()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { Geom::Crossings cs; try { cs = self_crossings(*path_it); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 3ba05adc6..298a4444a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -520,20 +520,15 @@ sp_spiral_position_set (SPSpiral *spiral, static void sp_spiral_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { // We will determine the spiral's midpoint ourselves, instead of trusting on the base class - // Therefore setSnapObjectMidpoints() is set to false temporarily + // Therefore snapping to object midpoints is temporarily disabled Inkscape::SnapPreferences local_snapprefs = *snapprefs; - local_snapprefs.setSnapObjectMidpoints(false); + local_snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, false); if (((SPItemClass *) parent_class)->snappoints) { ((SPItemClass *) parent_class)->snappoints (item, p, &local_snapprefs); } - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::Affine const i2dt (item->i2dt_affine ()); SPSpiral *spiral = SP_SPIRAL(item); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(spiral->cx, spiral->cy) * i2dt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index c7c2c54ad..d224ff1ba 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -548,20 +548,15 @@ sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, static void sp_star_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { // We will determine the star's midpoint ourselves, instead of trusting on the base class - // Therefore setSnapObjectMidpoints() is set to false temporarily + // Therefore snapping to object midpoints is temporarily disabled Inkscape::SnapPreferences local_snapprefs = *snapprefs; - local_snapprefs.setSnapObjectMidpoints(false); + local_snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, false); if (((SPItemClass *) parent_class)->snappoints) { ((SPItemClass *) parent_class)->snappoints (item, p, &local_snapprefs); } - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::Affine const i2dt (item->i2dt_affine ()); p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2dt,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 89ca4ace4..c56f2e91f 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -443,7 +443,7 @@ static char * sp_text_description(SPItem *item) static void sp_text_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - if (snapprefs->getSnapTextBaseline()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 5d32839cb..69d634e59 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -98,8 +98,6 @@ DocumentProperties::DocumentProperties() //--------------------------------------------------------------- //General snap options _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr), - _rcbsng(_("_Snap guides while dragging"), _("While dragging a guide, snap to object nodes or bounding box corners ('Snap to nodes' or 'snap to bounding box corners' must be enabled; only a small part of the guide near the cursor will snap)"), - "inkscape:snap-from-guide", _wr), _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr), _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr), //--------------------------------------------------------------- @@ -255,8 +253,7 @@ DocumentProperties::build_guides() label_gui, 0, 0, &_rcb_sgui, _rcp_gui._label, &_rcp_gui, - _rcp_hgui._label, &_rcp_hgui, - 0, &_rcbsng, + _rcp_hgui._label, &_rcp_hgui }; attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array)); @@ -1018,7 +1015,6 @@ DocumentProperties::update() _rcb_sgui.setActive (nv->showguides); _rcp_gui.setRgba32 (nv->guidecolor); _rcp_hgui.setRgba32 (nv->guidehicolor); - _rcbsng.setActive(nv->snap_manager.snapprefs.getSnapModeGuide()); //-----------------------------------------------------------snap page diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 69729f2da..261287877 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -106,7 +106,6 @@ protected: UI::Widget::PageSizer _page_sizer; //--------------------------------------------------------------- UI::Widget::RegisteredCheckButton _rcb_sgui; - UI::Widget::RegisteredCheckButton _rcbsng; UI::Widget::RegisteredColorPicker _rcp_gui; UI::Widget::RegisteredColorPicker _rcp_hgui; //--------------------------------------------------------------- diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index ea1811b92..90b299075 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2149,11 +2149,11 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v); break; case SP_ATTR_INKSCAPE_BBOX_PATHS: - v = nv->snap_manager.snapprefs.getSnapToBBoxPath(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_EDGE); sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v); break; case SP_ATTR_INKSCAPE_BBOX_NODES: - v = nv->snap_manager.snapprefs.getSnapToBBoxNode(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_CORNER); sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_NODES: @@ -2161,19 +2161,19 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v); break; case SP_ATTR_INKSCAPE_OBJECT_PATHS: - v = nv->snap_manager.snapprefs.getSnapToItemPath(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); sp_repr_set_boolean(repr, "inkscape:object-paths", !v); break; case SP_ATTR_INKSCAPE_OBJECT_NODES: - v = nv->snap_manager.snapprefs.getSnapToItemNode(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP); sp_repr_set_boolean(repr, "inkscape:object-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: - v = nv->snap_manager.snapprefs.getSnapSmoothNodes(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH); sp_repr_set_boolean(repr, "inkscape:snap-smooth-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: - v = nv->snap_manager.snapprefs.getSnapIntersectionCS(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION); sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: @@ -2181,43 +2181,39 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-others", !v); break; case SP_ATTR_INKSCAPE_SNAP_CENTER: - v = nv->snap_manager.snapprefs.getIncludeItemCenter(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_ROTATION_CENTER); sp_repr_set_boolean(repr, "inkscape:snap-center", !v); break; case SP_ATTR_INKSCAPE_SNAP_GRIDS: - v = nv->snap_manager.snapprefs.getSnapToGrids(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GRID); sp_repr_set_boolean(repr, "inkscape:snap-grids", !v); break; case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: - v = nv->snap_manager.snapprefs.getSnapToGuides(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE); sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v); break; case SP_ATTR_INKSCAPE_SNAP_PAGE: - v = nv->snap_manager.snapprefs.getSnapToPageBorder(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PAGE_BORDER); sp_repr_set_boolean(repr, "inkscape:snap-page", !v); break; - /*case SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE: - v = nv->snap_manager.snapprefs.getSnapIntersectionGG(); - sp_repr_set_boolean(repr, "inkscape:snap-intersection-grid-guide", !v); - break;*/ case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapLineMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapObjectMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v); break; case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: - v = nv->snap_manager.snapprefs.getSnapTextBaseline(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_TEXT_BASELINE); sp_repr_set_boolean(repr, "inkscape:snap-text-baseline", !v); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapBBoxMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-bbox-midpoints", !v); break; default: @@ -2283,7 +2279,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromBBoxCorner", - _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON("snap-bounding-box"), + _("Bounding box"), _("Snap bounding boxes"), INKSCAPE_ICON("snap-bounding-box"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2329,7 +2325,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode", - _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); + _("Nodes"), _("Snap nodes, paths, and handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2443,16 +2439,6 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); } - /*{ - InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGridGuideIntersections", - _("Grid/guide intersections"), _("Snap to intersections of a grid with a guide"), - INKSCAPE_ICON("snap-grid-guide-intersections"), secondarySize, - SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE); - - gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); - g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); - }*/ - setupToolboxCommon( toolbox, desktop, descr, "/ui/SnapToolbar", "/toolbox/secondary" ); @@ -2510,7 +2496,6 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev Glib::RefPtr act11 = mainActions->get_action("ToggleSnapToFromRotationCenter"); Glib::RefPtr act11b = mainActions->get_action("ToggleSnapToFromTextBaseline"); Glib::RefPtr act12 = mainActions->get_action("ToggleSnapToPageBorder"); - //Glib::RefPtr act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); Glib::RefPtr act14 = mainActions->get_action("ToggleSnapToGrids"); Glib::RefPtr act15 = mainActions->get_action("ToggleSnapToGuides"); @@ -2531,49 +2516,47 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act2->gobj()), c2); gtk_action_set_sensitive(GTK_ACTION(act2->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act3->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxPath()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act3->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_EDGE)); gtk_action_set_sensitive(GTK_ACTION(act3->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxNode()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_CORNER)); gtk_action_set_sensitive(GTK_ACTION(act4->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_EDGE_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act4b->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.getSnapBBoxMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act4c->gobj()), c1 && c2); bool const c3 = nv->snap_manager.snapprefs.getSnapModeNode(); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3); gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1); - bool const c4 = nv->snap_manager.snapprefs.getSnapToItemPath(); + bool const c4 = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4); gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionCS()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION)); gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.getSnapToItemNode()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP)); gtk_action_set_sensitive(GTK_ACTION(act7->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.getSnapSmoothNodes()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH)); gtk_action_set_sensitive(GTK_ACTION(act8->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.getSnapLineMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); bool const c5 = nv->snap_manager.snapprefs.getSnapModeOthers(); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), c5); gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act10b->gobj()), c1 && c5); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_ROTATION_CENTER)); gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11b->gobj()), nv->snap_manager.snapprefs.getSnapTextBaseline()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_TEXT_BASELINE)); gtk_action_set_sensitive(GTK_ACTION(act11b->gobj()), c1 && c5); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.getSnapToPageBorder()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PAGE_BORDER)); gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1); - //gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act13->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionGG()); - //gtk_action_set_sensitive(GTK_ACTION(act13->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act14->gobj()), nv->snap_manager.snapprefs.getSnapToGrids()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act14->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GRID)); gtk_action_set_sensitive(GTK_ACTION(act14->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.getSnapToGuides()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE)); gtk_action_set_sensitive(GTK_ACTION(act15->gobj()), c1); -- cgit v1.2.3 From 14bdd39732f8682dabf02a670c8343286a063ad0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 21:08:55 +0200 Subject: Some code cosmetics and comments (bzr r10570) --- src/attributes.cpp | 31 ++++++++++++------------- src/attributes.h | 30 ++++++++++++------------ src/snap-preferences.cpp | 46 +++++++++++++++++++------------------ src/sp-namedview.cpp | 34 ++++++++++++--------------- src/widgets/toolbox.cpp | 60 ++++++++++++++++++++++++------------------------ 5 files changed, 99 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/attributes.cpp b/src/attributes.cpp index 7e0a5e5d3..df27a578f 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -93,24 +93,23 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED, "inkscape:window-maximized"}, {SP_ATTR_INKSCAPE_SNAP_GLOBAL, "inkscape:snap-global"}, {SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"}, - {SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"}, + {SP_ATTR_INKSCAPE_SNAP_NODE, "inkscape:snap-nodes"}, {SP_ATTR_INKSCAPE_SNAP_OTHERS, "inkscape:snap-others"}, - //{SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, "inkscape:snap-from-guide"}, - {SP_ATTR_INKSCAPE_SNAP_CENTER, "inkscape:snap-center"}, - {SP_ATTR_INKSCAPE_SNAP_GRIDS, "inkscape:snap-grids"}, - {SP_ATTR_INKSCAPE_SNAP_TO_GUIDES, "inkscape:snap-to-guides"}, - {SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES, "inkscape:snap-smooth-nodes"}, - {SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS, "inkscape:snap-midpoints"}, - {SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS, "inkscape:snap-object-midpoints"}, + {SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER, "inkscape:snap-center"}, + {SP_ATTR_INKSCAPE_SNAP_GRID, "inkscape:snap-grids"}, + {SP_ATTR_INKSCAPE_SNAP_TO_GUIDE, "inkscape:snap-to-guides"}, + {SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH, "inkscape:snap-smooth-nodes"}, + {SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT, "inkscape:snap-midpoints"}, + {SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT, "inkscape:snap-object-midpoints"}, {SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE, "inkscape:snap-text-baseline"}, - {SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, "inkscape:snap-bbox-edge-midpoints"}, - {SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, "inkscape:snap-bbox-midpoints"}, - {SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, "inkscape:snap-intersection-paths"}, - {SP_ATTR_INKSCAPE_OBJECT_PATHS, "inkscape:object-paths"}, - {SP_ATTR_INKSCAPE_OBJECT_NODES, "inkscape:object-nodes"}, - {SP_ATTR_INKSCAPE_BBOX_PATHS, "inkscape:bbox-paths"}, - {SP_ATTR_INKSCAPE_BBOX_NODES, "inkscape:bbox-nodes"}, - {SP_ATTR_INKSCAPE_SNAP_PAGE, "inkscape:snap-page"}, + {SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT, "inkscape:snap-bbox-edge-midpoints"}, + {SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT, "inkscape:snap-bbox-midpoints"}, + {SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION, "inkscape:snap-intersection-paths"}, + {SP_ATTR_INKSCAPE_SNAP_PATH, "inkscape:object-paths"}, + {SP_ATTR_INKSCAPE_SNAP_NODE_CUSP, "inkscape:object-nodes"}, + {SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE, "inkscape:bbox-paths"}, + {SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER, "inkscape:bbox-nodes"}, + {SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER, "inkscape:snap-page"}, {SP_ATTR_INKSCAPE_CURRENT_LAYER, "inkscape:current-layer"}, {SP_ATTR_INKSCAPE_DOCUMENT_UNITS, "inkscape:document-units"}, {SP_ATTR_UNITS, "units"}, diff --git a/src/attributes.h b/src/attributes.h index 7d42dd357..237ad60d1 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -93,24 +93,24 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED, SP_ATTR_INKSCAPE_SNAP_GLOBAL, SP_ATTR_INKSCAPE_SNAP_BBOX, - SP_ATTR_INKSCAPE_SNAP_NODES, + SP_ATTR_INKSCAPE_SNAP_NODE, SP_ATTR_INKSCAPE_SNAP_OTHERS, //SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, - SP_ATTR_INKSCAPE_SNAP_CENTER, - SP_ATTR_INKSCAPE_SNAP_GRIDS, - SP_ATTR_INKSCAPE_SNAP_TO_GUIDES, - SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES, - SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS, - SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS, + SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER, + SP_ATTR_INKSCAPE_SNAP_GRID, + SP_ATTR_INKSCAPE_SNAP_TO_GUIDE, + SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH, + SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT, + SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT, SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE, - SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, - SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, - SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, - SP_ATTR_INKSCAPE_OBJECT_PATHS, - SP_ATTR_INKSCAPE_OBJECT_NODES, - SP_ATTR_INKSCAPE_BBOX_PATHS, - SP_ATTR_INKSCAPE_BBOX_NODES, - SP_ATTR_INKSCAPE_SNAP_PAGE, + SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT, + SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT, + SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION, + SP_ATTR_INKSCAPE_SNAP_PATH, + SP_ATTR_INKSCAPE_SNAP_NODE_CUSP, + SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE, + SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER, + SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER, SP_ATTR_INKSCAPE_CURRENT_LAYER, SP_ATTR_INKSCAPE_DOCUMENT_UNITS, SP_ATTR_UNITS, diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index a02e4baba..b1fadcfff 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -115,7 +115,22 @@ bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const { return (_snap_from & t); } - +/** + * \brief Map snap target to array index. + * + * The status of each snap toggle (in the snap toolbar) is stored as a boolean value in an array. This method returns the position + * of relevant boolean in that array, for any given type of snap target. For most snap targets, the enumerated value of that targets + * matches the position in the array (primary snap targets). This however does not hold for snap targets which don't have their own + * toggle button (secondary snap targets). + * + * PS: + * - For snap sources, just pass the corresponding snap target instead (each snap source should have a twin snap target, but not vice versa) + * - All parameters are passed by reference, and will be overwritten + * + * \param target Stores the enumerated snap target, which can be modified to correspond to the array index of this snap target + * \param always_on If true, then this snap target is always active and cannot be toggled + * \param group_on If true, then this snap target is in a snap group that has been enabled (e.g. bbox group, nodes/paths group, or "others" group + */ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const { if (target & SNAPTARGET_BBOX_CATEGORY) { @@ -186,12 +201,12 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType void Inkscape::SnapPreferences::setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled) { bool always_on = false; - bool group_on = false; + bool group_on = false; // Only needed as a dummy Inkscape::SnapTargetType index = target; _mapTargetToArrayIndex(index, always_on, group_on); - if (always_on) { + if (always_on) { // If true, then this snap target is always active and cannot be toggled // Catch coding errors g_warning("Snap-preferences warning: Trying to enable/disable a snap target (#%i) that's always on by definition", index); } else { @@ -211,8 +226,8 @@ bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const _mapTargetToArrayIndex(index, always_on, group_on); - if (group_on) { - if (always_on) { + if (group_on) { // If true, then this snap target is in a snap group that has been enabled (e.g. bbox group, nodes/paths group, or "others" group + if (always_on) { // If true, then this snap target is always active and cannot be toggled return true; } else { if (_active_snap_targets[index] == -1) { @@ -238,35 +253,22 @@ bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4); } - -//bool Inkscape::SnapPreferences::isAnyBBoxSnappable() const { -// return getSnapModeBBox() || getSnapModeOthers() || (getSnapModeNode() && !_strict_snapping); -//} - -//bool Inkscape::SnapPreferences::isAnyNodeOrPathSnappable() const { -// return getSnapModeNode() || getSnapModeOthers() || (getSnapModeBBox() && !_strict_snapping); -//} - -//bool Inkscape::SnapPreferences::isAnyOtherSnappable() const { -// return getSnapModeOthers(); -//} - bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType const target) const { - bool always_on = false; - bool group_on = false; + bool always_on = false; // Only needed as a dummy + bool group_on = false; // Only needed as a dummy Inkscape::SnapTargetType index = target; _mapTargetToArrayIndex(index, always_on, group_on); if (_active_snap_targets[index] == -1) { // Catch coding errors - g_warning("Snap-preferences warning: Using an uninitialized snap target setting"); + g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index); } else { if (index == target) { // I.e. if it has not been re-mapped, then we have a primary target at hand, which does have its own toggle button return _active_snap_targets[index]; } else { // If it has been re-mapped though, then this target does not have its own toggle button and therefore the button status cannot be read - g_warning("Snap-preferences warning: Trying to determine the button status of a secondary snap target; However, only primary targets have a button"); + g_warning("Snap-preferences warning: Trying to determine the button status of a secondary snap target (#%i); However, only primary targets have a button", index); } } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 7bafabba2..fd0dbdd42 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -463,7 +463,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_NODES: + case SP_ATTR_INKSCAPE_SNAP_NODE: nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@ -471,27 +471,27 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setSnapModeOthers(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_CENTER: + case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_GRIDS: + case SP_ATTR_INKSCAPE_SNAP_GRID: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: + case SP_ATTR_INKSCAPE_SNAP_TO_GUIDE: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: + case SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@ -499,39 +499,35 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; -// case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: -// nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); -// object->requestModified(SP_OBJECT_MODIFIED_FLAG); -// break; - case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: + case SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_OBJECT_PATHS: + case SP_ATTR_INKSCAPE_SNAP_PATH: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_OBJECT_NODES: + case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_BBOX_PATHS: + case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_BBOX_NODES: + case SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_PAGE: + case SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 90b299075..6ff8fcb44 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2148,31 +2148,31 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.getSnapModeBBox(); sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v); break; - case SP_ATTR_INKSCAPE_BBOX_PATHS: + case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_EDGE); sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v); break; - case SP_ATTR_INKSCAPE_BBOX_NODES: + case SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_CORNER); sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v); break; - case SP_ATTR_INKSCAPE_SNAP_NODES: + case SP_ATTR_INKSCAPE_SNAP_NODE: v = nv->snap_manager.snapprefs.getSnapModeNode(); sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v); break; - case SP_ATTR_INKSCAPE_OBJECT_PATHS: + case SP_ATTR_INKSCAPE_SNAP_PATH: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); sp_repr_set_boolean(repr, "inkscape:object-paths", !v); break; - case SP_ATTR_INKSCAPE_OBJECT_NODES: + case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP); sp_repr_set_boolean(repr, "inkscape:object-nodes", !v); break; - case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: + case SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH); sp_repr_set_boolean(repr, "inkscape:snap-smooth-nodes", !v); break; - case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: + case SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION); sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); break; @@ -2180,27 +2180,27 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.getSnapModeOthers(); sp_repr_set_boolean(repr, "inkscape:snap-others", !v); break; - case SP_ATTR_INKSCAPE_SNAP_CENTER: + case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_ROTATION_CENTER); sp_repr_set_boolean(repr, "inkscape:snap-center", !v); break; - case SP_ATTR_INKSCAPE_SNAP_GRIDS: + case SP_ATTR_INKSCAPE_SNAP_GRID: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GRID); sp_repr_set_boolean(repr, "inkscape:snap-grids", !v); break; - case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: + case SP_ATTR_INKSCAPE_SNAP_TO_GUIDE: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE); sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v); break; - case SP_ATTR_INKSCAPE_SNAP_PAGE: + case SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PAGE_BORDER); sp_repr_set_boolean(repr, "inkscape:snap-page", !v); break; - case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v); break; - case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v); break; @@ -2208,11 +2208,11 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_TEXT_BASELINE); sp_repr_set_boolean(repr, "inkscape:snap-text-baseline", !v); break; - case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v); break; - case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: + case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-bbox-midpoints", !v); break; @@ -2289,7 +2289,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxPath", _("Bounding box edges"), _("Snap to edges of a bounding box"), - INKSCAPE_ICON("snap-bounding-box-edges"), secondarySize, SP_ATTR_INKSCAPE_BBOX_PATHS); + INKSCAPE_ICON("snap-bounding-box-edges"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2298,7 +2298,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxNode", _("Bounding box corners"), _("Snap to bounding box corners"), - INKSCAPE_ICON("snap-bounding-box-corners"), secondarySize, SP_ATTR_INKSCAPE_BBOX_NODES); + INKSCAPE_ICON("snap-bounding-box-corners"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2308,7 +2308,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxEdgeMidpoints", _("BBox Edge Midpoints"), _("Snap from and to midpoints of bounding box edges"), INKSCAPE_ICON("snap-bounding-box-midpoints"), secondarySize, - SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS); + SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2317,7 +2317,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxCenters", _("BBox Centers"), _("Snapping from and to centers of bounding boxes"), - INKSCAPE_ICON("snap-bounding-box-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS); + INKSCAPE_ICON("snap-bounding-box-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2325,7 +2325,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode", - _("Nodes"), _("Snap nodes, paths, and handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); + _("Nodes"), _("Snap nodes, paths, and handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2334,7 +2334,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemPath", _("Paths"), _("Snap to paths"), INKSCAPE_ICON("snap-nodes-path"), secondarySize, - SP_ATTR_INKSCAPE_OBJECT_PATHS); + SP_ATTR_INKSCAPE_SNAP_PATH); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2343,7 +2343,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPathIntersections", _("Path intersections"), _("Snap to path intersections"), - INKSCAPE_ICON("snap-nodes-intersection"), secondarySize, SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS); + INKSCAPE_ICON("snap-nodes-intersection"), secondarySize, SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2352,7 +2352,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemNode", _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON("snap-nodes-cusp"), secondarySize, - SP_ATTR_INKSCAPE_OBJECT_NODES); + SP_ATTR_INKSCAPE_SNAP_NODE_CUSP); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2361,7 +2361,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToSmoothNodes", _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON("snap-nodes-smooth"), - secondarySize, SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES); + secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2370,7 +2370,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromLineMidpoints", _("Line Midpoints"), _("Snap from and to midpoints of line segments"), - INKSCAPE_ICON("snap-nodes-midpoint"), secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS); + INKSCAPE_ICON("snap-nodes-midpoint"), secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2387,7 +2387,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromObjectCenters", _("Object Centers"), _("Snap from and to centers of objects"), - INKSCAPE_ICON("snap-nodes-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS); + INKSCAPE_ICON("snap-nodes-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2396,7 +2396,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromRotationCenter", _("Rotation Centers"), _("Snap from and to an item's rotation center"), - INKSCAPE_ICON("snap-nodes-rotation-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_CENTER); + INKSCAPE_ICON("snap-nodes-rotation-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2415,7 +2415,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPageBorder", _("Page border"), _("Snap to the page border"), INKSCAPE_ICON("snap-page"), - secondarySize, SP_ATTR_INKSCAPE_SNAP_PAGE); + secondarySize, SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2424,7 +2424,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGrids", _("Grids"), _("Snap to grids"), INKSCAPE_ICON("grid-rectangular"), secondarySize, - SP_ATTR_INKSCAPE_SNAP_GRIDS); + SP_ATTR_INKSCAPE_SNAP_GRID); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2433,7 +2433,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGuides", _("Guides"), _("Snap to guides"), INKSCAPE_ICON("guides"), secondarySize, - SP_ATTR_INKSCAPE_SNAP_TO_GUIDES); + SP_ATTR_INKSCAPE_SNAP_TO_GUIDE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); -- cgit v1.2.3 From 93a4cc098376804399d2a54edfcaec919a1c07ee Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 21:30:56 +0200 Subject: Use different icons to communicate the change in behavior of the snap buttons, and update the tooltips accordingly (bzr r10571) --- src/widgets/toolbox.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 6ff8fcb44..780495819 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2279,7 +2279,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromBBoxCorner", - _("Bounding box"), _("Snap bounding boxes"), INKSCAPE_ICON("snap-bounding-box"), + _("Bounding box"), _("Snap bounding boxes"), INKSCAPE_ICON("snap"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2297,7 +2297,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxNode", - _("Bounding box corners"), _("Snap to bounding box corners"), + _("Bounding box corners"), _("Snap bounding box corners"), INKSCAPE_ICON("snap-bounding-box-corners"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2306,7 +2306,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxEdgeMidpoints", - _("BBox Edge Midpoints"), _("Snap from and to midpoints of bounding box edges"), + _("BBox Edge Midpoints"), _("Snap midpoints of bounding box edges"), INKSCAPE_ICON("snap-bounding-box-midpoints"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT); @@ -2316,7 +2316,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxCenters", - _("BBox Centers"), _("Snapping from and to centers of bounding boxes"), + _("BBox Centers"), _("Snapping centers of bounding boxes"), INKSCAPE_ICON("snap-bounding-box-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2325,7 +2325,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode", - _("Nodes"), _("Snap nodes, paths, and handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE); + _("Nodes"), _("Snap nodes, paths, and handles"), INKSCAPE_ICON("snap"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2351,7 +2351,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemNode", - _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON("snap-nodes-cusp"), secondarySize, + _("To nodes"), _("Snap cusp nodes"), INKSCAPE_ICON("snap-nodes-cusp"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE_CUSP); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2360,7 +2360,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToSmoothNodes", - _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON("snap-nodes-smooth"), + _("Smooth nodes"), _("Snap smooth nodes"), INKSCAPE_ICON("snap-nodes-smooth"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2369,7 +2369,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromLineMidpoints", - _("Line Midpoints"), _("Snap from and to midpoints of line segments"), + _("Line Midpoints"), _("Snap midpoints of line segments"), INKSCAPE_ICON("snap-nodes-midpoint"), secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2378,7 +2378,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromOthers", - _("Others"), _("Snap other points (centers, guide origins, gradient handles, etc.)"), INKSCAPE_ICON("snap-others"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OTHERS); + _("Others"), _("Snap other points (centers, guide origins, gradient handles, etc.)"), INKSCAPE_ICON("snap"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OTHERS); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2386,7 +2386,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromObjectCenters", - _("Object Centers"), _("Snap from and to centers of objects"), + _("Object Centers"), _("Snap centers of objects"), INKSCAPE_ICON("snap-nodes-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2395,7 +2395,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromRotationCenter", - _("Rotation Centers"), _("Snap from and to an item's rotation center"), + _("Rotation Centers"), _("Snap an item's rotation center"), INKSCAPE_ICON("snap-nodes-rotation-center"), secondarySize, SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2404,7 +2404,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromTextBaseline", - _("Text baseline"), _("Snap from and to text anchors and baselines"), + _("Text baseline"), _("Snap text anchors and baselines"), INKSCAPE_ICON("snap-text-baseline"), secondarySize, SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); -- cgit v1.2.3 From 458c1a2a8f34a342d2728b144592110a65b4c2d1 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 22:27:25 +0200 Subject: Fix snap bug #816044 Fixed bugs: - https://launchpad.net/bugs/816044 (bzr r10572) --- src/snap.cpp | 9 ++++++++- src/snapped-point.cpp | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/snap.cpp b/src/snap.cpp index 8d3103122..30fc5387e 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1456,7 +1456,14 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons void SnapManager::keepClosestPointOnly(std::vector &points, const Geom::Point &reference) const { - if (points.size() < 2) return; + if (points.size() == 0) { + return; + } + + if (points.size() == 1) { + points.front().setSourceNum(-1); // Just in case + return; + } Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(Geom::infinity(), Geom::infinity()), Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED); Geom::Coord closest_dist = Geom::infinity(); diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index 2db3d62e4..a777e4dc0 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -131,6 +131,10 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth return false; } + if (!getSnapped() && other_one.getSnapped()) { + return true; + } + double dist_other = other_one.getSnapDistance(); double dist_this = getSnapDistance(); -- cgit v1.2.3 From 906805aab186df9a92048a28962852921a50d334 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 22:41:46 +0200 Subject: Fix another snapping bug (could occur when scaling an object using the selector tool) (bzr r10573) --- src/snap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/snap.cpp b/src/snap.cpp index 30fc5387e..8c96cdfa1 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -853,7 +853,9 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } // Compare the resulting scaling with the desired scaling - Geom::Point scale_metric = Geom::abs(result - transformation); // One or both of its components might be Geom::infinity() + Geom::Point scale_metric = result - transformation; // One or both of its components might be Geom::infinity() + scale_metric[0] = fabs(scale_metric[0]); + scale_metric[1] = fabs(scale_metric[1]); if (scale_metric[0] == Geom::infinity() || scale_metric[1] == Geom::infinity()) { snapped_point.setSnapDistance(std::min(scale_metric[0], scale_metric[1])); } else { -- cgit v1.2.3 From 073995c772424b27f3e63a38e0cc5f3bc800d1d0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 23 Aug 2011 19:56:40 +0200 Subject: Filters. Filters clean-up again. Filters. Outline CPF improvements. Translations. Translation template and file list, French translation update. (bzr r10575) --- src/extension/internal/filter/color.h | 22 +++---- src/extension/internal/filter/filter-all.cpp | 2 +- src/extension/internal/filter/morphology.h | 94 +++++++++++++++++----------- 3 files changed, 71 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index a026e686a..9cc009b3a 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -18,7 +18,7 @@ * Fade to black or white * Greyscale * Invert - * Lightness + * Lighting * Lightness-contrast * Nudge * Quadritone @@ -1017,7 +1017,7 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Invert filter */ /** - \brief Custom predefined Lightness filter. + \brief Custom predefined Lighting filter. Modify lights and shadows separately. @@ -1026,19 +1026,19 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) * Shadow (0.->20., default 1.) -> component (exponent) * Offset (-1.->1., default 0.) -> component (offset) */ -class Lightness : public Inkscape::Extension::Internal::Filter::Filter { +class Lighting : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - Lightness ( ) : Filter() { }; - virtual ~Lightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + Lighting ( ) : Filter() { }; + virtual ~Lighting ( ) { if (_filter != NULL) g_free((void *)_filter); return; } static void init (void) { Inkscape::Extension::build_from_mem( "\n" - "" N_("Lightness") "\n" - "org.inkscape.effect.filter.Lightness\n" + "" N_("Lighting") "\n" + "org.inkscape.effect.filter.Lighting\n" "1\n" "1\n" "0\n" @@ -1051,12 +1051,12 @@ public: "\n" "" N_("Modify lights and shadows separately") "\n" "\n" - "\n", new Lightness()); + "\n", new Lighting()); }; }; gchar const * -Lightness::get_filter_text (Inkscape::Extension::Extension * ext) +Lighting::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); @@ -1069,7 +1069,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) offset << ext->get_param_float("offset"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1080,7 +1080,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str() ); return _filter; -}; /* Lightness filter */ +}; /* Lighting filter */ /** \brief Custom predefined Lightness-Contrast filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 17c22c0cb..b5d47ae45 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -62,7 +62,7 @@ Filter::filters_all (void ) FadeToBW::init(); Greyscale::init(); Invert::init(); - Lightness::init(); + Lighting::init(); LightnessContrast::init(); Nudge::init(); Quadritone::init(); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 4b69f564b..c57cb3618 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -105,20 +105,21 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) Adds a colorizable outline Filter's parameters: - * Stroke type (enum, default single) - * single -> composite4 (in="composite3"), composite2 (operator="atop") - * double -> composite4 (in="SourceGraphic"), composite2 (operator="xor") + * Fill image (boolean, default false) -> true: composite2 (in="SourceGraphic"), false: composite2 (in="blur2") + * Hide image (boolean, default false) -> true: composite4 (in="composite3"), false: composite4 (in="SourceGraphic") + * Stroke type (enum, default over) -> composite2 (operator) * Stroke position (enum, default inside) * inside -> composite1 (operator="out", in="SourceGraphic", in2="blur1") * outside -> composite1 (operator="out", in="blur1", in2="SourceGraphic") * overlayed -> composite1 (operator="xor", in="blur1", in2="SourceGraphic") - * Width 1(0.01->20., default 4) -> blur1 (stdDeviation) - * Width 2 (0.01->20., default 0.5) -> blur2 (stdDeviation) + * Width 1 (0.01->20., default 4) -> blur1 (stdDeviation) * Dilatation 1 (1.->100., default 100) -> colormatrix1 (n-1th value) * Erosion 1 (0.->100., default 1) -> colormatrix1 (nth value 0->-100) + * Width 2 (0.01->20., default 0.5) -> blur2 (stdDeviation) * Dilatation 2 (1.->100., default 50) -> colormatrix2 (n-1th value) * Erosion 2 (0.->100., default 5) -> colormatrix2 (nth value 0->-100) - * Color (guint, default 200,55,55,255) -> flood (flood-color, flood-opacity) + * Antialiasing (0.01->1., default 1) -> blur3 (stdDeviation) + * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) * Fill opacity (0.->1., default 1) -> composite5 (k2) * Stroke opacity (0.->1., default 1) -> composite5 (k3) @@ -139,9 +140,14 @@ public: "org.inkscape.effect.filter.Outline\n" "\n" "\n" - "\n" - "<_item value=\"single\">" N_("Single") "\n" - "<_item value=\"double\">" N_("Double") "\n" + "false\n" + "false\n" + "\n" + "<_item value=\"over\">" N_("Over") "\n" + "<_item value=\"in\">" N_("In") "\n" + "<_item value=\"out\">" N_("Out") "\n" + "<_item value=\"atop\">" N_("Atop") "\n" + "<_item value=\"xor\">" N_("XOR") "\n" "\n" "\n" "<_item value=\"inside\">" N_("Inside") "\n" @@ -149,14 +155,16 @@ public: "<_item value=\"overlayed\">" N_("Overlayed") "\n" "\n" "4\n" - "0.5\n" "100\n" "1\n" + "0.5\n" "50\n" "5\n" + "1\n" + "false\n" "\n" "\n" - "1029214207\n" + "255\n" "1\n" "1\n" "\n" @@ -181,30 +189,35 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) if (_filter != NULL) g_free((void *)_filter); std::ostringstream width1; - std::ostringstream width2; std::ostringstream dilat1; std::ostringstream erosion1; + std::ostringstream width2; std::ostringstream dilat2; std::ostringstream erosion2; + std::ostringstream antialias; std::ostringstream r; std::ostringstream g; std::ostringstream b; std::ostringstream a; std::ostringstream fopacity; std::ostringstream sopacity; - std::ostringstream c4in; - std::ostringstream c4op; + std::ostringstream smooth; + std::ostringstream c1in; std::ostringstream c1in2; std::ostringstream c1op; + std::ostringstream c2in; + std::ostringstream c2op; + std::ostringstream c4in; + width1 << ext->get_param_float("width1"); - width2 << ext->get_param_float("width2"); dilat1 << ext->get_param_float("dilat1"); erosion1 << (- ext->get_param_float("erosion1")); + width2 << ext->get_param_float("width2"); dilat2 << ext->get_param_float("dilat2"); erosion2 << (- ext->get_param_float("erosion2")); - + antialias << ext->get_param_float("antialias"); guint32 color = ext->get_param_color("color"); r << ((color >> 24) & 0xff); g << ((color >> 16) & 0xff); @@ -214,21 +227,10 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) fopacity << ext->get_param_float("fopacity"); sopacity << ext->get_param_float("sopacity"); - const gchar *type = ext->get_param_enum("type"); - if((g_ascii_strcasecmp("single", type) == 0)) { - // Single - c4in << "composite3"; - c4op << "atop"; - } else { - // Double - c4in << "SourceGraphic"; - c4op << "xor"; - } - const gchar *position = ext->get_param_enum("position"); if((g_ascii_strcasecmp("inside", position) == 0)) { // Indide - c1in << "SourceGraphic3"; + c1in << "SourceGraphic"; c1in2 << "blur1"; c1op << "out"; } else if((g_ascii_strcasecmp("outside", position) == 0)) { @@ -243,24 +245,46 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) c1op << "xor"; } + if (ext->get_param_bool("fill")) { + c2in << "SourceGraphic"; + } else { + c2in << "blur2"; + } + + c2op << ext->get_param_enum("type"); + + if (ext->get_param_bool("outline")) { + c4in << "composite3"; + } else { + c4in << "SourceGraphic"; + } + + if (ext->get_param_bool("smooth")) { + smooth << "1 0"; + } else { + smooth << "5 -1"; + } + _filter = g_strdup_printf( "\n" "\n" "\n" "\n" "\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" "\n", width1.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), c1op.str().c_str(), dilat1.str().c_str(), erosion1.str().c_str(), - width2.str().c_str(), dilat2.str().c_str(), erosion2.str().c_str(), + width2.str().c_str(), c2in.str().c_str(), c2op.str().c_str(), + dilat2.str().c_str(), erosion2.str().c_str(), antialias.str().c_str(), smooth.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), - c4in.str().c_str(), c4op.str().c_str(), - fopacity.str().c_str(), sopacity.str().c_str() ); + c4in.str().c_str(), fopacity.str().c_str(), sopacity.str().c_str() ); return _filter; }; /* Outline filter */ -- cgit v1.2.3 From bc41980c93b8627b286daeb51bc29806a6c2b0f0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 23 Aug 2011 21:17:19 +0200 Subject: 1) Use the "snap guides" button both for guides being snap sources, as well as for guides being snap targets 2) Remove some redundant guide-snapping code from the object snapper, (bzr r10576) --- src/attributes.cpp | 2 +- src/attributes.h | 2 +- src/object-snapper.cpp | 38 -------------------------------------- src/object-snapper.h | 11 +---------- src/snap.cpp | 42 ++++++------------------------------------ src/sp-namedview.cpp | 2 +- src/widgets/toolbox.cpp | 6 +++--- 7 files changed, 13 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/attributes.cpp b/src/attributes.cpp index df27a578f..4552adb63 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -97,7 +97,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_SNAP_OTHERS, "inkscape:snap-others"}, {SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER, "inkscape:snap-center"}, {SP_ATTR_INKSCAPE_SNAP_GRID, "inkscape:snap-grids"}, - {SP_ATTR_INKSCAPE_SNAP_TO_GUIDE, "inkscape:snap-to-guides"}, + {SP_ATTR_INKSCAPE_SNAP_GUIDE, "inkscape:snap-to-guides"}, {SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH, "inkscape:snap-smooth-nodes"}, {SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT, "inkscape:snap-midpoints"}, {SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT, "inkscape:snap-object-midpoints"}, diff --git a/src/attributes.h b/src/attributes.h index 237ad60d1..261871482 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -98,7 +98,7 @@ enum SPAttributeEnum { //SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER, SP_ATTR_INKSCAPE_SNAP_GRID, - SP_ATTR_INKSCAPE_SNAP_TO_GUIDE, + SP_ATTR_INKSCAPE_SNAP_GUIDE, SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT, diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index da6eca027..82114e2c4 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -742,44 +742,6 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, } } - -// This method is used to snap a guide to nodes, while dragging the guide around -void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc, - Geom::Point const &p, - Geom::Point const &guide_normal) const -{ - if (!_snapmanager->snapprefs.getSnapModeOthers()) { - return; - } - - - //std::vector const it; //just an empty list - - freeSnap(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), Geom::Rect(p, p), NULL, NULL); - //_findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); - //_snapTranslatingGuide(sc, p, guide_normal); - -} - -// This method is used to snap the origin of a guide to nodes/paths, while dragging the origin along the guide -void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc, - Geom::Point const &p, - Geom::Point const &guide_normal, - SnapConstraint const &/*c*/) const -{ - /* Get a list of all the SPItems that we will try to snap to */ - std::vector cand; - std::vector const it; //just an empty list - - std::cout << "guideConstrainedSnap" << std::endl; - - if (_snapmanager->snapprefs.getSnapModeOthers()) { - _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); - _snapTranslatingGuide(sc, p, guide_normal); - } - -} - /** * \return true if this Snapper will snap at least one kind of point. */ diff --git a/src/object-snapper.h b/src/object-snapper.h index 00fb18923..b97ab827c 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -9,7 +9,7 @@ * Carl Hetherington * Diederik van Lierop * - * Copyright (C) 2005 - 2008 Authors + * Copyright (C) 2005 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -33,15 +33,6 @@ public: ObjectSnapper(SnapManager *sm, Geom::Coord const d); ~ObjectSnapper(); - void guideFreeSnap(SnappedConstraints &sc, - Geom::Point const &p, - Geom::Point const &guide_normal) const; - - void guideConstrainedSnap(SnappedConstraints &sc, - Geom::Point const &p, - Geom::Point const &guide_normal, - SnapConstraint const &c) const; - bool ThisSnapperMightSnap() const; Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom) diff --git a/src/snap.cpp b/src/snap.cpp index 8c96cdfa1..c4ca32364 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -560,11 +560,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida } /** - * \brief Try to snap a point of a guide to another guide or to a node - * - * Try to snap a point of a guide to another guide or to a node in two degrees- - * of-freedom, i.e. snap in any direction on the two dimensional canvas to the - * nearest snap target. This method is used when dragging or rotating a guide + * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) * * PS: SnapManager::setup() must have been called before calling this method, * @@ -573,11 +569,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const { - if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { - return; - } - - if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { + if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; } @@ -586,15 +578,8 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE); } - // Snap to nodes SnappedConstraints sc; - if (object.ThisSnapperMightSnap()) { - object.guideFreeSnap(sc, p, guide_normal); - } - - // Snap to guides & grid lines - SnapperList snappers = getGridSnappers(); - snappers.push_back(&guide); + SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); } @@ -605,12 +590,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, } /** - * \brief Try to snap a point on a guide to the intersection with another guide or a path - * - * Try to snap a point on a guide to the intersection of that guide with another - * guide or with a path. The snapped point will lie somewhere on the guide-line, - * making this is a constrained snap, i.e. in only one degree-of-freedom. - * This method is used when dragging the origin of the guide along the guide itself. + * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) * * PS: SnapManager::setup() must have been called before calling this method, * @@ -620,26 +600,16 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { - if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { - return; - } - - if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { + if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; } Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED); - // Snap to nodes or paths SnappedConstraints sc; Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line)); - if (object.ThisSnapperMightSnap()) { - object.constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL); - } - // Snap to guides & grid lines - SnapperList snappers = getGridSnappers(); - snappers.push_back(&guide); + SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { (*i)->constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL); } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index fd0dbdd42..71ee8298b 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -479,7 +479,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_INKSCAPE_SNAP_TO_GUIDE: + case SP_ATTR_INKSCAPE_SNAP_GUIDE: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 780495819..26947979d 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2188,7 +2188,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GRID); sp_repr_set_boolean(repr, "inkscape:snap-grids", !v); break; - case SP_ATTR_INKSCAPE_SNAP_TO_GUIDE: + case SP_ATTR_INKSCAPE_SNAP_GUIDE: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE); sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v); break; @@ -2432,8 +2432,8 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGuides", - _("Guides"), _("Snap to guides"), INKSCAPE_ICON("guides"), secondarySize, - SP_ATTR_INKSCAPE_SNAP_TO_GUIDE); + _("Guides"), _("Snap guides"), INKSCAPE_ICON("guides"), secondarySize, + SP_ATTR_INKSCAPE_SNAP_GUIDE); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); -- cgit v1.2.3 From 20f5fdf0157485e4a606449bea6ea07ab4b25b64 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 23 Aug 2011 21:50:21 +0200 Subject: UI. Adding a digit in the blur spinbox (F&S dialog, see Bug #414767, More precision to Blur filter value). Filters. Some CPF improvements (including a new Cross-smooth version). (bzr r10577) --- src/extension/internal/filter/color.h | 8 ++-- src/extension/internal/filter/morphology.h | 67 +++++++++++++++++++--------- src/extension/internal/filter/transparency.h | 8 ++-- src/ui/widget/filter-effect-chooser.cpp | 2 +- 4 files changed, 56 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 9cc009b3a..ecdf25f39 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -153,10 +153,10 @@ public: "\n" "\n" "1\n" - "-1\n" - "0.5\n" - "0.5\n" - "1\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" "false\n" "\n" "\n" diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index c57cb3618..7dde0002d 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -33,9 +33,15 @@ namespace Filter { Filter's parameters: * Type (enum, default "Smooth edges") -> - Smooth edges = composite1 (in="SourceGraphic", in2="blur") - Smooth all = composite1 (in="blur", in2="blur") - * Blur (0.01->10., default 5.) -> blur (stdDeviation) + Inner = composite1 (operator="in") + Outer = composite1 (operator="over") + Open = composite1 (operator="XOR") + * Width (0.01->30., default 10.) -> blur (stdDeviation) + * Level (0.2->2., default 1.) -> composite2 (k2) + * Dilatation (1.->100., default 10.) -> colormatrix1 (last-1 value) + * Erosion (1.->100., default 1.) -> colormatrix1 (last value) + * Antialiasing (0.01->1., default 1) -> blur2 (stdDeviation) + * Blur content (boolean, default false) -> blend (true: in="colormatrix2", false: in="SourceGraphic") */ class Crosssmooth : public Inkscape::Extension::Internal::Filter::Filter { @@ -52,10 +58,17 @@ public: "" N_("Cross-smooth") "\n" "org.inkscape.effect.filter.crosssmooth\n" "\n" - "<_item value=\"edges\">Smooth edges\n" - "<_item value=\"all\">Smooth all\n" + "<_item value=\"in\">Inner\n" + "<_item value=\"over\">Outer\n" + "<_item value=\"xor\">Open\n" "\n" - "5\n" + "10\n" + "1\n" + "10\n" + "1\n" + "1\n" + "false\n" + "\n" "all\n" "\n" @@ -75,29 +88,43 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream blur; - std::ostringstream c1in; + std::ostringstream type; + std::ostringstream width; + std::ostringstream level; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream antialias; + std::ostringstream content; - blur << ext->get_param_float("blur"); + type << ext->get_param_enum("type"); + width << ext->get_param_float("width"); + level << ext->get_param_float("level"); + dilat << ext->get_param_float("dilat"); + erosion << (1 - ext->get_param_float("erosion")); + antialias << ext->get_param_float("antialias"); - const gchar *type = ext->get_param_enum("type"); - if((g_ascii_strcasecmp("all", type) == 0)) { - c1in << "blur"; + if (ext->get_param_bool("content")) { + content << "colormatrix2"; } else { - c1in << "SourceGraphic"; + content << "SourceGraphic"; } _filter = g_strdup_printf( "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", blur.str().c_str(), c1in.str().c_str()); + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", width.str().c_str(), type.str().c_str(), level.str().c_str(), + dilat.str().c_str(), erosion.str().c_str(), antialias.str().c_str(), + content.str().c_str()); return _filter; -}; /* Crosssmooth filter */ +}; /* Cross-smooth filter */ /** \brief Custom predefined Outline filter. diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 1397b726d..add50b169 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -129,10 +129,10 @@ public: "\n" "" N_("Channel Transparency") "\n" "org.inkscape.effect.filter.ChannelTransparency\n" - "-1\n" - "0.5\n" - "0.5\n" - "1\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" "false\n" "\n" "all\n" diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index 37202c8b4..52ce0b5bc 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -25,7 +25,7 @@ SimpleFilterModifier::SimpleFilterModifier(int flags) : _lb_blend(_("Blend mode:")), _lb_blur(_("_Blur:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, true), _blend(BlendModeConverter, SP_ATTR_INVALID, false), - _blur(0, 0, 100, 1, 0.01, 1) + _blur(0, 0, 100, 1, 0.01, 2) { _flags = flags; -- cgit v1.2.3 From abe953dc63948d78532c0541a56e664dc386810a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 25 Aug 2011 19:39:31 +0200 Subject: Remove duplicate bbox data from DrawingShape (bzr r10347.1.38) --- src/display/drawing-item.h | 6 +++--- src/display/drawing-shape.cpp | 11 ++--------- src/display/drawing-shape.h | 2 -- src/sp-shape.cpp | 8 -------- 4 files changed, 5 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 7a3b8047b..424616427 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -161,9 +161,9 @@ protected: Geom::Affine *_transform; ///< Incremental transform from parent to this item's coords Geom::Affine _ctm; ///< Total transform from item coords to display coords - Geom::OptIntRect _bbox; ///< Bounding box in display (pixel) coords - Geom::OptIntRect _drawbox; ///< Bounding box enlarged by filters, shrinked by clips and masks - Geom::OptRect _item_bbox; ///< Bounding box in item coordinates + Geom::OptIntRect _bbox; ///< Bounding box in display (pixel) coords including stroke + Geom::OptIntRect _drawbox; ///< Full visual bounding box - enlarged by filters, shrunk by clips and masks + Geom::OptRect _item_bbox; ///< Geometric bounding box in item coordinates DrawingItem *_clip; DrawingItem *_mask; diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index cd7b9150d..ac0ff2ccb 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -72,13 +72,6 @@ DrawingShape::setStyle(SPStyle *style) _nrstyle.set(style); } -void -DrawingShape::setPaintBox(Geom::Rect const &box) -{ - _paintbox = box; - _markForUpdate(STATE_ALL, false); -} - unsigned DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { @@ -187,8 +180,8 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne // update fill and stroke paints. // this cannot be done during nr_arena_shape_update, because we need a Cairo context // to render svg:pattern - has_fill = _nrstyle.prepareFill(ct, _paintbox); - has_stroke = _nrstyle.prepareStroke(ct, _paintbox); + has_fill = _nrstyle.prepareFill(ct, _item_bbox); + has_stroke = _nrstyle.prepareStroke(ct, _item_bbox); has_stroke &= (_nrstyle.stroke_width != 0); if (has_fill || has_stroke) { diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 122130590..27bd7fbba 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -29,7 +29,6 @@ public: void setPath(SPCurve *curve); void setStyle(SPStyle *style); - void setPaintBox(Geom::Rect const &box); protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, @@ -44,7 +43,6 @@ protected: SPStyle *_style; NRStyle _nrstyle; - Geom::OptRect _paintbox; DrawingItem *_last_pick; unsigned _repick_after; }; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index eff0665af..0d1ac029e 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -256,15 +256,11 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) { /* This is suboptimal, because changing parent style schedules recalculation */ /* But on the other hand - how can we know that parent does not tie style and transform */ - Geom::OptRect paintbox = SP_ITEM(object)->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); for (SPItemView *v = shape->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { sh->setPath(shape->curve); } - if (paintbox) { - sh->setPaintBox(*paintbox); - } } } @@ -860,10 +856,6 @@ Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, Inkscape::Drawing & Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); s->setStyle(object->style); s->setPath(shape->curve); - Geom::OptRect paintbox = item->getBounds(Geom::identity()); - if (paintbox) { - s->setPaintBox(*paintbox); - } /* This stanza checks that an object's marker style agrees with * the marker objects it has allocated. sp_shape_set_marker ensures -- cgit v1.2.3 From 969504cc521a5116e1b1b8ea9e0355f69e6c93eb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 25 Aug 2011 20:33:10 +0200 Subject: Reduce default rendering cache size to 64 MiB (bzr r10347.1.39) --- src/display/canvas-arena.cpp | 21 +++++++++++++-------- src/display/canvas-arena.h | 4 ++-- src/preferences-skeleton.h | 2 +- src/ui/dialog/inkscape-preferences.cpp | 4 ++-- 4 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index ac2704895..4688a58e3 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -49,18 +49,23 @@ static void sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect con static SPCanvasItemClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; -struct CacheBudgetObserver : public Inkscape::Preferences::Observer { - CacheBudgetObserver(SPCanvasArena *arena) - : Inkscape::Preferences::Observer("/options/renderingcache/size") +struct CachePrefObserver : public Inkscape::Preferences::Observer { + CachePrefObserver(SPCanvasArena *arena) + : Inkscape::Preferences::Observer("/options/renderingcache") , _arena(arena) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Inkscape::Preferences::Entry v = prefs->getEntry(observed_path); - notify(v); + std::vector v = prefs->getAllEntries(observed_path); + for (unsigned i=0; iaddObserver(*this); } void notify(Preferences::Entry const &v) { - _arena->drawing.setCacheBudget((1 << 20) * v.getIntLimited(128, 0, 4096)); + Glib::ustring name = v.getEntryName(); + if (name == "size") { + _arena->drawing.setCacheBudget((1 << 20) * v.getIntLimited(64, 0, 4096)); + } } SPCanvasArena *_arena; }; @@ -119,13 +124,13 @@ sp_canvas_arena_init (SPCanvasArena *arena) arena->sticky = FALSE; new (&arena->drawing) Inkscape::Drawing(arena); - arena->observer = new CacheBudgetObserver(arena); Inkscape::DrawingGroup *root = new DrawingGroup(arena->drawing); root->setPickChildren(true); - root->setCached(true, true); arena->drawing.setRoot(root); + arena->observer = new CachePrefObserver(arena); + arena->drawing.signal_request_update.connect( sigc::bind<0>( sigc::ptr_fun(&sp_canvas_arena_request_update), diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 463dc1bc3..f145a9c70 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS typedef struct _SPCanvasArena SPCanvasArena; typedef struct _SPCanvasArenaClass SPCanvasArenaClass; -struct CacheBudgetObserver; +struct CachePrefObserver; struct _SPCanvasArena { SPCanvasItem item; @@ -46,7 +46,7 @@ struct _SPCanvasArena { Inkscape::DrawingItem *active; /* fixme: */ Inkscape::DrawingItem *picked; - CacheBudgetObserver *observer; + CachePrefObserver *observer; double delta; }; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 895eb7276..a71451455 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -231,7 +231,7 @@ static char const preferences_skeleton[] = " \n" "\n" " \n" -" " +" " " " " " " " diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 0129f196f..ae27f0720 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -752,8 +752,8 @@ void InkscapePreferences::initPageRendering() _("Configure number of processors/threads to use when rendering filters"), false); // rendering cache - _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 128.0, true, false); - _page_rendering.add_line( false, _("Rendering cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per drawing which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); + _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 64.0, true, false); + _page_rendering.add_line( false, _("Rendering cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per document which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); /* blur quality */ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value", -- cgit v1.2.3 From de1626183e28848a36fe293cea05f256d7ba4086 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 25 Aug 2011 21:35:19 +0200 Subject: Filters. Removing unecessary height, width, x and y attributes in some filters elements. Extensions. New Text>Extract extension. Translations. Translation template and file list update. (bzr r10580) --- src/extension/internal/filter/bumps.h | 2 +- src/extension/internal/filter/color.h | 24 ++++++++++++------------ src/extension/internal/filter/image.h | 2 +- src/extension/internal/filter/paint.h | 16 ++++++++-------- src/extension/internal/filter/shadows.h | 10 +++++----- src/extension/internal/filter/transparency.h | 8 ++++---- 6 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index f002c8b37..9f971b0de 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -242,7 +242,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index ecdf25f39..0f892365c 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -107,7 +107,7 @@ Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), @@ -211,7 +211,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -280,7 +280,7 @@ ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) sat << ext->get_param_float("sat"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", shift.str().c_str(), sat.str().c_str() ); @@ -385,7 +385,7 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -473,7 +473,7 @@ ComponentTransfer::get_filter_text (Inkscape::Extension::Extension * ext) << "\n"; } _filter = g_strdup_printf( - "\n" + "\n" "\n" "%s\n" "\n" @@ -590,7 +590,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -777,7 +777,7 @@ FadeToBW::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", level.str().c_str(), wlevel.str().c_str(), level.str().c_str(), wlevel.str().c_str(), @@ -871,7 +871,7 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str() ); return _filter; @@ -1069,7 +1069,7 @@ Lighting::get_filter_text (Inkscape::Extension::Extension * ext) offset << ext->get_param_float("offset"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1372,7 +1372,7 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) blend2 << ext->get_param_enum("blend2"); _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1452,7 +1452,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1607,7 +1607,7 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index b0a6367e1..60e1a1665 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -97,7 +97,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 678c0c08f..cf0c869a6 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -183,7 +183,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) graincol << "0"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -274,7 +274,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) trans << "blend"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -434,7 +434,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) ios << "flood2"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -544,7 +544,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -638,7 +638,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -804,7 +804,7 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) iop << "flood1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -942,7 +942,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" @@ -1018,7 +1018,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) transf << " 1"; _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index a1a82111d..b816a3e10 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -63,8 +63,8 @@ public: "\n" "<_item value=\"outer\">" N_("Outer") "\n" "<_item value=\"inner\">" N_("Inner") "\n" - "<_item value=\"innercut\">" N_("Inner cutout") "\n" "<_item value=\"outercut\">" N_("Outer cutout") "\n" + "<_item value=\"innercut\">" N_("Inner cutout") "\n" "\n" "\n" "\n" @@ -116,7 +116,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) b << ((color >> 8) & 0xff); // Select object or user-defined color - if ((g_ascii_strcasecmp("outercut", type) == 0)) { + if ((g_ascii_strcasecmp("innercut", type) == 0)) { if (ext->get_param_bool("objcolor")) { comp2in1 << "SourceGraphic"; comp2in2 << "offset"; @@ -145,12 +145,12 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2op << "atop"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; - } else if ((g_ascii_strcasecmp("innercut", type) == 0)) { + } else if ((g_ascii_strcasecmp("outercut", type) == 0)) { comp1op << "in"; comp2op << "out"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; - } else { //outercut + } else { //innercut comp1op << "out"; comp1in1 << "flood"; comp1in2 << "SourceGraphic"; @@ -158,7 +158,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index add50b169..79657749a 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -170,7 +170,7 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), @@ -236,16 +236,16 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) expand << (ext->get_param_float("expand") * 0.2125) << " " << (ext->get_param_float("expand") * 0.7154) << " " << (ext->get_param_float("expand") * 0.0721); - erode << (-ext->get_param_float("erode") * 720 / 1000); + erode << (-ext->get_param_float("erode")); } else { expand << (-ext->get_param_float("expand") * 0.2125) << " " << (-ext->get_param_float("expand") * 0.7154) << " " << (-ext->get_param_float("expand") * 0.0721); - erode << (ext->get_param_float("erode") * 720 / 1000); + erode << ext->get_param_float("erode"); } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str()); -- cgit v1.2.3 From 3da0fd8b645937bcdd26d2ab3db716982030fc19 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 25 Aug 2011 22:08:16 +0200 Subject: Fix "snap guides" toggle Fixed bugs: - https://launchpad.net/bugs/814457 (bzr r10582) --- src/object-snapper.cpp | 22 +++++++---------- src/seltrans.cpp | 2 +- src/snap-enums.h | 25 +++++++++++-------- src/snap-preferences.cpp | 62 ++++++++++++++++++++++++++++++++---------------- src/snap-preferences.h | 4 +--- src/snap.cpp | 7 +++--- 6 files changed, 70 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 82114e2c4..fd8ef0c7c 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -177,7 +177,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, bool p_is_a_node = t & SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = t & SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & SNAPSOURCE_OTHERS_CATEGORY; + bool p_is_other = t & SNAPSOURCE_OTHERS_CATEGORY || t & SNAPSOURCE_DATUMS_CATEGORY; // A point considered for snapping should be either a node, a bbox corner or a guide/other. Pick only ONE! if (((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))) { @@ -364,7 +364,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, bool p_is_a_node = source_type & SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = source_type & SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = source_type & SNAPSOURCE_OTHERS_CATEGORY; + bool p_is_other = source_type & SNAPSOURCE_OTHERS_CATEGORY || source_type & SNAPSOURCE_DATUMS_CATEGORY; if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE)) { Preferences *prefs = Preferences::get(); @@ -444,7 +444,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } //Add the item's bounding box to snap to - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE) && (_snapmanager->snapprefs.getSnapModeBBox() || _snapmanager->snapprefs.getSnapModeOthers())) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE)) { if (p_is_other || p_is_a_bbox || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) { // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time @@ -747,10 +747,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, */ bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const { - return _snapmanager->snapprefs.getSnapModeBBox() - || _snapmanager->snapprefs.getSnapModeNode() - || _snapmanager->snapprefs.getSnapModeOthers() - || _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_CORNER); + return true; } void Inkscape::ObjectSnapper::_clear_paths() const @@ -814,16 +811,13 @@ void Inkscape::getBBoxPoints(Geom::OptRect const bbox, bool Inkscape::ObjectSnapper::_allowSourceToSnapToTarget(SnapSourceType source, SnapTargetType target, bool strict_snapping) const { - bool allow_this_pair_to_snap = false; + bool allow_this_pair_to_snap = true; if (strict_snapping) { // bounding boxes will not snap to nodes/paths and vice versa - int source_cat = source & (SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY); - int target_cat = target & (SNAPTARGET_BBOX_CATEGORY | SNAPTARGET_NODE_CATEGORY | SNAPTARGET_OTHERS_CATEGORY); - if (source_cat == target_cat || source_cat == SNAPSOURCE_OTHERS_CATEGORY || target_cat == SNAPTARGET_OTHERS_CATEGORY) { - allow_this_pair_to_snap = true; + if (((source & SNAPSOURCE_BBOX_CATEGORY) && (target & SNAPTARGET_NODE_CATEGORY)) || + ((source & SNAPSOURCE_NODE_CATEGORY) && (target & SNAPTARGET_BBOX_CATEGORY))) { + allow_this_pair_to_snap = false; } - } else { // anything will snap to anything - allow_this_pair_to_snap = true; } return allow_this_pair_to_snap; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 7538e15d9..3a204a49e 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -360,7 +360,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // points immediately. if (prefs->getBool("/options/snapclosestonly/value", false)) { - if (m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers()) { + if (m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers() || m.snapprefs.getSnapModeDatums()) { m.keepClosestPointOnly(_snap_points, p); } else { _snap_points.clear(); // don't keep any point diff --git a/src/snap-enums.h b/src/snap-enums.h index fd28910a8..8a95bb2dd 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -20,14 +20,14 @@ enum SnapSourceType { //------------------------------------------------------------------- // Bbox points can be located at the edge of the stroke (for visual bboxes); they will therefore not snap // to nodes because these are always located at the center of the stroke - SNAPSOURCE_BBOX_CATEGORY = 32, // will be used as a flag and must therefore be a power of two. Also, + SNAPSOURCE_BBOX_CATEGORY = 16, // will be used as a flag and must therefore be a power of two. Also, // must be larger than the largest number of targets in a single group SNAPSOURCE_BBOX_CORNER, SNAPSOURCE_BBOX_MIDPOINT, SNAPSOURCE_BBOX_EDGE_MIDPOINT, //------------------------------------------------------------------- // For the same reason, nodes will not snap to bbox points - SNAPSOURCE_NODE_CATEGORY = 64, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_NODE_CATEGORY = 32, // will be used as a flag and must therefore be a power of two SNAPSOURCE_NODE_SMOOTH, // Symmetrical nodes are also considered to be smooth; there's no dedicated type for symm. nodes SNAPSOURCE_NODE_CUSP, SNAPSOURCE_LINE_MIDPOINT, @@ -37,13 +37,16 @@ enum SnapSourceType { SNAPSOURCE_ELLIPSE_QUADRANT_POINT, SNAPSOURCE_NODE_HANDLE, // eg. nodes in the path editor, handles of stars or rectangles, etc. (tied to a stroke) //------------------------------------------------------------------- - // Other points (e.g. guides, gradient knots) will snap to both bounding boxes and nodes + // Other points (e.g. guides) will snap to both bounding boxes and nodes + SNAPSOURCE_DATUMS_CATEGORY = 64, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_GUIDE, + SNAPSOURCE_GUIDE_ORIGIN, + //------------------------------------------------------------------- + // Other points (e.g. gradient knots, image corners) will snap to both bounding boxes and nodes SNAPSOURCE_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two SNAPSOURCE_ROTATION_CENTER, SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, ellipses, polygon, etc. SNAPSOURCE_IMG_CORNER, - SNAPSOURCE_GUIDE, - SNAPSOURCE_GUIDE_ORIGIN, SNAPSOURCE_TEXT_ANCHOR, SNAPSOURCE_OTHER_HANDLE, // eg. the handle of a gradient or of a connector (ie not being tied to a stroke) SNAPSOURCE_GRID_PITCH, // eg. when pasting or alt-dragging in the selector tool; not realy a snap source @@ -52,7 +55,7 @@ enum SnapSourceType { enum SnapTargetType { SNAPTARGET_UNDEFINED = 0, //------------------------------------------------------------------- - SNAPTARGET_BBOX_CATEGORY = 32, // will be used as a flag and must therefore be a power of two. Also, + SNAPTARGET_BBOX_CATEGORY = 16, // will be used as a flag and must therefore be a power of two. Also, // must be larger than the largest number of targets in a single group // i.e > 15 because that's the number of targets in the "others" group SNAPTARGET_BBOX_CORNER, @@ -60,7 +63,7 @@ enum SnapTargetType { SNAPTARGET_BBOX_EDGE_MIDPOINT, SNAPTARGET_BBOX_MIDPOINT, //------------------------------------------------------------------- - SNAPTARGET_NODE_CATEGORY = 64, // will be used as a flag and must therefore be a power of two + SNAPTARGET_NODE_CATEGORY = 32, // will be used as a flag and must therefore be a power of two SNAPTARGET_NODE_SMOOTH, SNAPTARGET_NODE_CUSP, SNAPTARGET_LINE_MIDPOINT, @@ -69,18 +72,20 @@ enum SnapTargetType { SNAPTARGET_ELLIPSE_QUADRANT_POINT, // this corner is at the center of the stroke SNAPTARGET_RECT_CORNER, // of a rectangle, so this corner is at the center of the stroke //------------------------------------------------------------------- - SNAPTARGET_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two + SNAPTARGET_DATUMS_CATEGORY = 64, // will be used as a flag and must therefore be a power of two SNAPTARGET_GRID, SNAPTARGET_GRID_INTERSECTION, SNAPTARGET_GUIDE, SNAPTARGET_GUIDE_INTERSECTION, SNAPTARGET_GUIDE_ORIGIN, SNAPTARGET_GRID_GUIDE_INTERSECTION, + SNAPTARGET_PAGE_BORDER, + SNAPTARGET_PAGE_CORNER, + //------------------------------------------------------------------- + SNAPTARGET_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two SNAPTARGET_OBJECT_MIDPOINT, SNAPTARGET_IMG_CORNER, SNAPTARGET_ROTATION_CENTER, - SNAPTARGET_PAGE_BORDER, - SNAPTARGET_PAGE_CORNER, SNAPTARGET_TEXT_ANCHOR, SNAPTARGET_TEXT_BASELINE, SNAPTARGET_CONSTRAINED_ANGLE, diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index b1fadcfff..d655564f2 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -19,14 +19,13 @@ Inkscape::SnapPreferences::SnapPreferences() : _snap_postponed_globally(false), _strict_snapping(true) { - // Check for enough space to hold all snap target toggles in the "others" group; see the comments in snap-enums.h - g_assert(SNAPTARGET_MAX_ENUM_VALUE - SNAPTARGET_OTHERS_CATEGORY < SNAPTARGET_BBOX_CATEGORY); // Check for powers of two; see the comments in snap-enums.h g_assert((SNAPTARGET_BBOX_CATEGORY != 0) && !(SNAPTARGET_BBOX_CATEGORY & (SNAPTARGET_BBOX_CATEGORY - 1))); g_assert((SNAPTARGET_NODE_CATEGORY != 0) && !(SNAPTARGET_NODE_CATEGORY & (SNAPTARGET_NODE_CATEGORY - 1))); + g_assert((SNAPTARGET_DATUMS_CATEGORY != 0) && !(SNAPTARGET_DATUMS_CATEGORY & (SNAPTARGET_DATUMS_CATEGORY - 1))); g_assert((SNAPTARGET_OTHERS_CATEGORY != 0) && !(SNAPTARGET_OTHERS_CATEGORY & (SNAPTARGET_OTHERS_CATEGORY - 1))); - setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab + setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_DATUMS_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab for (int n = 0; n < Inkscape::SNAPTARGET_MAX_ENUM_VALUE; n++) { _active_snap_targets[n] = -1; } @@ -88,6 +87,11 @@ bool Inkscape::SnapPreferences::getSnapModeOthers() const return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } +bool Inkscape::SnapPreferences::getSnapModeDatums() const +{ + return isTargetSnappable(Inkscape::SNAPTARGET_GUIDE); +} + bool Inkscape::SnapPreferences::getSnapModeAny() const { return (_snap_from != 0); @@ -135,31 +139,55 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType { if (target & SNAPTARGET_BBOX_CATEGORY) { group_on = getSnapModeBBox(); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets + + } else if (target & SNAPTARGET_NODE_CATEGORY) { group_on = getSnapModeNode(); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths if (target == SNAPTARGET_RECT_CORNER || target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { // Don't have their own button; on when the group is on target = SNAPTARGET_NODE_CATEGORY; } - } else if (target & SNAPTARGET_OTHERS_CATEGORY) { - // Only if the group with "other" snap sources/targets has been enabled, then we might snap to any of those targets - // ... but this doesn't hold for the page border, grids, and guides - group_on = getSnapModeOthers(); + + + } else if (target & SNAPTARGET_DATUMS_CATEGORY) { + group_on = true; // These snap targets cannot be disabled as part of a disabled group; switch (target) { // Some snap targets don't have their own toggle. These targets are called "secondary targets". We will re-map - // them to their cousin which does have a toggle, and which is called a "primary target" + // them to their cousin which does have a toggle, and which is called a "primary target"case SNAPTARGET_GRID_INTERSECTION: case SNAPTARGET_GRID_INTERSECTION: - group_on = true; // cannot be disabled as part of a disabled group; target = SNAPTARGET_GRID; break; case SNAPTARGET_GUIDE_INTERSECTION: case SNAPTARGET_GUIDE_ORIGIN: - group_on = true; // cannot be disabled as part of a disabled group; target = SNAPTARGET_GUIDE; break; case SNAPTARGET_PAGE_CORNER: - group_on = true; // cannot be disabled as part of a disabled group; target = SNAPTARGET_PAGE_BORDER; break; + + // Some snap targets cannot be toggled at all, and are therefore always enabled + case SNAPTARGET_GRID_GUIDE_INTERSECTION: + always_on = true; // Doesn't have it's own button + break; + + // These are only listed for completeness + case SNAPTARGET_GRID: + case SNAPTARGET_GUIDE: + case SNAPTARGET_PAGE_BORDER: + case SNAPTARGET_DATUMS_CATEGORY: + break; + default: + g_warning("Snap-preferences warning: Undefined snap target (#%i)", target); + break; + } + + + } else if (target & SNAPTARGET_OTHERS_CATEGORY) { + // Only if the group with "other" snap sources/targets has been enabled, then we might snap to any of those targets + // ... but this doesn't hold for the page border, grids, and guides + group_on = getSnapModeOthers(); + switch (target) { + // Some snap targets don't have their own toggle. These targets are called "secondary targets". We will re-map + // them to their cousin which does have a toggle, and which is called a "primary target" case SNAPTARGET_TEXT_ANCHOR: target = SNAPTARGET_TEXT_BASELINE; break; @@ -168,31 +196,23 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType target = SNAPTARGET_OTHERS_CATEGORY; break; // Some snap targets cannot be toggled at all, and are therefore always enabled - case SNAPTARGET_GRID_GUIDE_INTERSECTION: case SNAPTARGET_CONSTRAINED_ANGLE: case SNAPTARGET_CONSTRAINT: always_on = true; // Doesn't have it's own button break; - case SNAPTARGET_GRID: - case SNAPTARGET_GUIDE: - case SNAPTARGET_PAGE_BORDER: - group_on = true; // cannot be disabled as part of a disabled group; - break; // These are only listed for completeness case SNAPTARGET_OBJECT_MIDPOINT: case SNAPTARGET_ROTATION_CENTER: case SNAPTARGET_TEXT_BASELINE: - break; - - case SNAPTARGET_BBOX_CATEGORY: - case SNAPTARGET_NODE_CATEGORY: case SNAPTARGET_OTHERS_CATEGORY: break; default: g_warning("Snap-preferences warning: Undefined snap target (#%i)", target); break; } + + } else if (target == SNAPTARGET_UNDEFINED ) { g_warning("Snap-preferences warning: Undefined snaptarget (#%i)", target); } diff --git a/src/snap-preferences.h b/src/snap-preferences.h index dac11b3aa..cfcdf6137 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -28,9 +28,6 @@ public: bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const; bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const; bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const; - //bool isAnyBBoxSnappable() const; - //bool isAnyNodeOrPathSnappable() const; - //bool isAnyOtherSnappable() const; bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const; void setSnapModeBBox(bool enabled); @@ -38,6 +35,7 @@ public: void setSnapModeOthers(bool enabled); bool getSnapModeBBox() const; bool getSnapModeNode() const; + bool getSnapModeDatums() const; bool getSnapModeOthers() const; bool getSnapModeAny() const; diff --git a/src/snap.cpp b/src/snap.cpp index c4ca32364..7647341fe 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1413,9 +1413,10 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/snapclosestonly/value")) { - bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_a_bbox = p.getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; + Inkscape::SnapSourceType t = p.getSourceType(); + bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY; + bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; + bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY || t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY; g_assert(_desktop != NULL); if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { -- cgit v1.2.3 From 61817a80c06ccd660385ef3c90f01254ecd6c0ab Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 26 Aug 2011 19:19:12 -0400 Subject: remove double backslash in pathname (Bug 805095) Fixed bugs: - https://launchpad.net/bugs/805095 (bzr r10583) --- src/ui/dialog/filedialogimpl-win32.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 4f4093a99..9fb1d831f 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1593,6 +1593,8 @@ FileSaveDialogImplWin32::FileSaveDialogImplWin32(Gtk::Window &parent, // double-directory bug on win32 if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); myFilename = udir.substr(0, udir.find_last_of( '.' ) ); // this removes the extension, or actually, removes everything past the last dot (hopefully this is what most people want) + if (1 + myFilename.find("\\\\",2)) // remove one slash if double + myFilename.replace(myFilename.find("\\\\",2), 1, ""); } } -- cgit v1.2.3 From 72cc39b9f0b340548f395c7f61ca9662b34aea09 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 11:04:37 +0200 Subject: Refactor SPItem bounding box methods: remove NRRect usage and make code using them more obvious. Fix filter region computation. (bzr r10582.1.1) --- src/conn-avoid-ref.cpp | 2 +- src/desktop.cpp | 14 +- src/dialogs/clonetiler.cpp | 7 +- src/dialogs/export.cpp | 29 +- src/dialogs/spellcheck.cpp | 4 +- src/display/nr-filter-image.cpp | 2 +- src/document.cpp | 2 +- src/eraser-context.cpp | 4 +- src/extension/dbus/document-interface.cpp | 10 +- src/extension/internal/bitmap/crop.cpp | 2 +- src/extension/internal/cairo-render-context.cpp | 101 +++---- src/extension/internal/cairo-render-context.h | 26 +- src/extension/internal/cairo-renderer.cpp | 86 +++--- src/extension/internal/emf-win32-print.cpp | 19 +- src/extension/internal/grid.cpp | 2 +- src/extension/internal/latex-text-renderer.cpp | 26 +- src/extension/internal/odf.cpp | 15 +- src/file.cpp | 2 +- src/filter-chemistry.cpp | 4 +- src/flood-context.cpp | 2 +- src/gradient-chemistry.cpp | 6 +- src/gradient-drag.cpp | 6 +- src/graphlayout.cpp | 6 +- src/interface.cpp | 2 +- src/libnrtype/Layout-TNG-Output.cpp | 32 +-- src/libnrtype/Layout-TNG.h | 6 +- src/live_effects/lpe-extrude.cpp | 6 +- src/live_effects/lpe-mirror_symmetry.cpp | 4 +- src/live_effects/lpe-rough-hatches.cpp | 2 +- src/live_effects/lpegroupbbox.cpp | 2 +- src/main.cpp | 9 +- src/marker.cpp | 9 +- src/object-snapper.cpp | 20 +- src/print.cpp | 10 +- src/print.h | 4 +- src/removeoverlap.cpp | 2 +- src/selcue.cpp | 10 +- src/selection-chemistry.cpp | 44 ++-- src/selection.cpp | 46 ++-- src/selection.h | 23 +- src/seltrans.cpp | 22 +- src/seltrans.h | 2 +- src/sp-clippath.cpp | 53 ++-- src/sp-clippath.h | 4 +- src/sp-flowtext.cpp | 65 ++--- src/sp-image.cpp | 23 +- src/sp-item-group.cpp | 19 +- src/sp-item-group.h | 2 +- src/sp-item-transform.cpp | 2 +- src/sp-item.cpp | 321 +++++++++------------- src/sp-item.h | 25 +- src/sp-mask.cpp | 32 +-- src/sp-mask.h | 15 +- src/sp-offset.cpp | 2 +- src/sp-shape.cpp | 337 ++++++++++-------------- src/sp-shape.h | 2 +- src/sp-symbol.cpp | 8 +- src/sp-text.cpp | 55 ++-- src/sp-tref.cpp | 32 +-- src/sp-tspan.cpp | 31 +-- src/sp-use.cpp | 17 +- src/splivarot.cpp | 4 +- src/spray-context.cpp | 6 +- src/text-chemistry.cpp | 3 +- src/text-context.cpp | 4 +- src/tweak-context.cpp | 20 +- src/ui/clipboard.cpp | 8 +- src/ui/dialog/align-and-distribute.cpp | 22 +- src/ui/dialog/align-and-distribute.h | 2 +- src/ui/dialog/filedialogimpl-win32.cpp | 4 +- src/ui/dialog/tile.cpp | 16 +- src/ui/dialog/transformation.cpp | 26 +- src/ui/widget/style-subject.cpp | 2 +- src/ui/widget/style-subject.h | 6 +- src/unclump.cpp | 4 +- src/verbs.cpp | 2 +- src/widgets/desktop-widget.cpp | 2 +- src/widgets/icon.cpp | 3 +- src/widgets/select-toolbar.cpp | 12 +- src/widgets/stroke-style.cpp | 3 +- src/widgets/toolbox.cpp | 5 +- 81 files changed, 789 insertions(+), 1042 deletions(-) (limited to 'src') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index fad11bb89..331865254 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -394,7 +394,7 @@ Geom::Point SPAvoidRef::getConnectionPointPos(const int type, const int id) if ( type == ConnPointDefault ) { // For now, just default to the centre of the item - Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); + Geom::OptRect bbox = item->documentVisualBounds(); pos = (bbox) ? bbox->midpoint() : Geom::Point(0, 0); } else diff --git a/src/desktop.cpp b/src/desktop.cpp index ca5fdc63b..b622d1080 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -577,16 +577,16 @@ bool SPDesktop::isLayer(SPObject *object) const { } /** - * True if desktop viewport fully contains \a item's bbox. + * True if desktop viewport intersects \a item's bbox. */ bool SPDesktop::isWithinViewport (SPItem *item) const { Geom::Rect const viewport = get_display_area(); - Geom::OptRect const bbox = item->getBboxDesktop(); + Geom::OptRect const bbox = item->desktopVisualBounds(); if (bbox) { - return viewport.contains(*bbox); + return viewport.intersects(*bbox); } else { - return true; + return false; } } @@ -957,7 +957,7 @@ SPDesktop::zoom_quick (bool enable) } if (!zoomed) { - Geom::OptRect const d = selection->bounds(); + Geom::OptRect const d = selection->visualBounds(); if (d && d->area() * 2.0 < _quick_zoom_stored_area.area()) { set_display_area(*d, true); zoomed = true; @@ -1109,7 +1109,7 @@ SPDesktop::zoom_page_width() void SPDesktop::zoom_selection() { - Geom::OptRect const d = selection->bounds(); + Geom::OptRect const d = selection->visualBounds(); if ( !d || d->minExtent() < 0.1 ) { return; @@ -1137,7 +1137,7 @@ SPDesktop::zoom_drawing() SPItem *docitem = doc()->getRoot(); g_return_if_fail (docitem != NULL); - Geom::OptRect d = docitem->getBboxDesktop(); + Geom::OptRect d = docitem->desktopVisualBounds(); /* Note that the second condition here indicates that ** there are no items in the drawing. diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 109b235d0..a92b6392e 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1170,10 +1170,9 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0); } else { bool prefs_bbox = prefs->getBool("/tools/bounding_box", false); - SPItem::BBoxType bbox_type = ( prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX ); - Geom::OptRect r = item->getBounds(item->i2doc_affine(), - bbox_type); + SPItem::BBoxType bbox_type = ( !prefs_bbox ? + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX ); + Geom::OptRect r = item->documentBounds(bbox_type); if (r) { w = r->dimensions()[Geom::X]; h = r->dimensions()[Geom::Y]; diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 0c2bc5adc..a19f9b60f 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -783,20 +783,22 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, if ( SP_ACTIVE_DESKTOP ) { SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds(); if (bbox) { - sp_export_set_area (base, bbox->min()[Geom::X], - bbox->min()[Geom::Y], - bbox->max()[Geom::X], - bbox->max()[Geom::Y]); + sp_export_set_area (base, bbox->left(), + bbox->top(), + bbox->right(), + bbox->bottom()); } } break; case SELECTION_SELECTION: if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { - NRRect bbox; - (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(&bbox, SPItem::RENDERING_BBOX); - sp_export_set_area (base, bbox.x0, bbox.y0, bbox.x1, bbox.y1); + Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->visualBounds(); + sp_export_set_area (base, bbox->left(), + bbox->top(), + bbox->right(), + bbox->bottom()); } break; default: @@ -852,7 +854,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) case SELECTION_SELECTION: if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { - bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->bounds(SPItem::RENDERING_BBOX); + bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->visualBounds(); /* Only if there is a selection that we can set do we break, otherwise we fall through to the drawing */ @@ -864,7 +866,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) /** \todo * This returns wrong values if the document has a viewBox. */ - bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); + bbox = doc->getRoot()->desktopVisualBounds(); /* If the drawing is valid, then we'll use it and break otherwise we drop through to the page settings */ if (bbox) { @@ -1129,8 +1131,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) dpi = DPI_BASE; } - Geom::OptRect area; - item->invoke_bbox( area, item->i2dt_affine(), TRUE ); + Geom::OptRect area = item->desktopVisualBounds(); if (area) { gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); @@ -1493,7 +1494,7 @@ sp_export_detect_size(GtkObject * base) { switch (this_test[i]) { case SELECTION_SELECTION: if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { - Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::VISUAL_BBOX); //std::cout << "Selection " << bbox; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox)) { @@ -1504,7 +1505,7 @@ sp_export_detect_size(GtkObject * base) { case SELECTION_DRAWING: { SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds(); // std::cout << "Drawing " << bbox2; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) { diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index d0de6ad20..bd8381d8c 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -243,8 +243,8 @@ gint compare_text_bboxes (gconstpointer a, gconstpointer b) SPItem *i1 = SP_ITEM(a); SPItem *i2 = SP_ITEM(b); - Geom::OptRect bbox1 = i1->getBounds(i1->i2dt_affine()); - Geom::OptRect bbox2 = i2->getBounds(i2->i2dt_affine()); + Geom::OptRect bbox1 = i1->desktopVisualBounds(); + Geom::OptRect bbox2 = i2->desktopVisualBounds(); if (!bbox1 || !bbox2) { return 0; } diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index a22d23548..5911f5908 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -74,7 +74,7 @@ void FilterImage::render_cairo(FilterSlot &slot) document->ensureUpToDate(); Drawing drawing; - Geom::OptRect optarea = SVGElem->getBounds(Geom::identity()); + Geom::OptRect optarea = SVGElem->visualBounds(); if (!optarea) return; unsigned const key = SPItem::display_key_new(1); diff --git a/src/document.cpp b/src/document.cpp index 72f92bd17..cf2474fe5 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1086,7 +1086,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); } else { SPItem *child = SP_ITEM(o); - Geom::OptRect box = child->getBboxDesktop(); + Geom::OptRect box = child->desktopVisualBounds(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s = g_slist_append(s, child); } diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index de6c7d86f..11b150aa0 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -748,7 +748,7 @@ set_to_accumulated(SPEraserContext *dc) Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr)); - Geom::OptRect eraserBbox = acid->getBounds(Geom::identity()); + Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; GSList* toWorkOn = 0; @@ -770,7 +770,7 @@ set_to_accumulated(SPEraserContext *dc) for (GSList *i = toWorkOn ; i ; i = i->next ) { SPItem *item = SP_ITEM(i->data); if ( eraserMode ) { - Geom::OptRect bbox = item->getBounds(Geom::identity()); + Geom::OptRect bbox = item->visualBounds(); if (bbox && bbox->intersects(*eraserBbox)) { Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc); dc->repr->parent()->appendChild(dup); diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 1e6577173..b4f42a37d 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -157,16 +157,14 @@ desktop_ensure_active (SPDesktop* desk) { gdouble selection_get_center_x (Inkscape::Selection *sel){ - NRRect *box = g_new(NRRect, 1);; - box = sel->boundsInDocument(box); - return box->x0 + ((box->x1 - box->x0)/2); + Geom::OptRect box = sel->documentBounds(SPItem::GEOMETRIC_BBOX); + return box ? box->midpoint()[Geom::X] : 0; } gdouble selection_get_center_y (Inkscape::Selection *sel){ - NRRect *box = g_new(NRRect, 1);; - box = sel->boundsInDocument(box); - return box->y0 + ((box->y1 - box->y0)/2); + Geom::OptRect box = sel->documentBounds(SPItem::GEOMETRIC_BBOX); + return box ? box->midpoint()[Geom::X] : 0; } /* diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp index 23e31b510..2ad75a0dc 100644 --- a/src/extension/internal/bitmap/crop.cpp +++ b/src/extension/internal/bitmap/crop.cpp @@ -38,7 +38,7 @@ Crop::postEffect(Magick::Image *image, SPItem *item) { sp_item_scale_rel (item, scale); // Translate proportionaly to the image/bbox ratio - Geom::OptRect bbox(item->getBboxDesktop()); + Geom::OptRect bbox(item->desktopGeometricBounds()); //g_warning("bbox. W:%f, H:%f, X:%f, Y:%f", bbox->dimensions()[Geom::X], bbox->dimensions()[Geom::Y], bbox->min()[Geom::X], bbox->min()[Geom::Y]); Geom::Translate translate (0,0); diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index c3a8a790b..a0573d9ff 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -682,12 +682,12 @@ CairoRenderContext::popLayer(void) // copy the correct CTM to mask context /* if (_state->parent_has_userspace) - mask_ctx->setTransform(&getParentState()->transform); + mask_ctx->setTransform(getParentState()->transform); else - mask_ctx->setTransform(&_state->transform); + mask_ctx->setTransform(_state->transform); */ // This is probably not correct... but it seems to do the trick. - mask_ctx->setTransform(&_state->item_transform); + mask_ctx->setTransform(_state->item_transform); // render mask contents to mask_ctx _renderer->applyMask(mask_ctx, mask); @@ -915,7 +915,7 @@ CairoRenderContext::finish(void) } void -CairoRenderContext::transform(Geom::Affine const *transform) +CairoRenderContext::transform(Geom::Affine const &transform) { g_assert( _is_valid ); @@ -924,42 +924,44 @@ CairoRenderContext::transform(Geom::Affine const *transform) cairo_transform(_cr, &matrix); // store new CTM - getTransform(&_state->transform); + _state->transform = getTransform(); } void -CairoRenderContext::setTransform(Geom::Affine const *transform) +CairoRenderContext::setTransform(Geom::Affine const &transform) { g_assert( _is_valid ); cairo_matrix_t matrix; _initCairoMatrix(&matrix, transform); cairo_set_matrix(_cr, &matrix); - _state->transform = *transform; + _state->transform = transform; } -void -CairoRenderContext::getTransform(Geom::Affine *copy) const +Geom::Affine +CairoRenderContext::getTransform() const { g_assert( _is_valid ); cairo_matrix_t ctm; cairo_get_matrix(_cr, &ctm); - (*copy)[0] = ctm.xx; - (*copy)[1] = ctm.yx; - (*copy)[2] = ctm.xy; - (*copy)[3] = ctm.yy; - (*copy)[4] = ctm.x0; - (*copy)[5] = ctm.y0; + Geom::Affine ret; + ret[0] = ctm.xx; + ret[1] = ctm.yx; + ret[2] = ctm.xy; + ret[3] = ctm.yy; + ret[4] = ctm.x0; + ret[5] = ctm.y0; + return ret; } -void -CairoRenderContext::getParentTransform(Geom::Affine *copy) const +Geom::Affine +CairoRenderContext::getParentTransform() const { g_assert( _is_valid ); CairoRenderState *parent_state = getParentState(); - memcpy(copy, &parent_state->transform, sizeof(Geom::Affine)); + return parent_state->transform; } void @@ -1002,7 +1004,7 @@ static bool pattern_hasItemChildren(SPPattern *pat) } cairo_pattern_t* -CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox) +CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox) { g_assert( SP_IS_PATTERN(paintserver) ); @@ -1023,10 +1025,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { //Geom::Affine bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); - bbox_width_scaler = pbox->x1 - pbox->x0; - bbox_height_scaler = pbox->y1 - pbox->y0; - ps2user[4] = x * bbox_width_scaler + pbox->x0; - ps2user[5] = y * bbox_height_scaler + pbox->y0; + bbox_width_scaler = pbox->width(); + bbox_height_scaler = pbox->height(); + ps2user[4] = x * bbox_width_scaler + pbox->left(); + ps2user[5] = y * bbox_height_scaler + pbox->top(); } else { bbox_width_scaler = 1.0; bbox_height_scaler = 1.0; @@ -1059,8 +1061,8 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver pcs2dev[4] = x - view_box->x0 * pcs2dev[0]; pcs2dev[5] = y - view_box->y0 * pcs2dev[3]; } else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - pcs2dev[0] = pbox->x1 - pbox->x0; - pcs2dev[3] = pbox->y1 - pbox->y0; + pcs2dev[0] = pbox->width(); + pcs2dev[3] = pbox->height(); } @@ -1089,7 +1091,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver ps2user[4] = ori[Geom::X]; ps2user[5] = ori[Geom::Y]; - pattern_ctx->setTransform(&pcs2dev); + pattern_ctx->setTransform(pcs2dev); pattern_ctx->pushState(); // create drawing and group @@ -1119,7 +1121,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // set pattern transformation cairo_matrix_t pattern_matrix; - _initCairoMatrix(&pattern_matrix, &ps2user); + _initCairoMatrix(&pattern_matrix, ps2user); cairo_matrix_invert(&pattern_matrix); cairo_pattern_set_matrix(result, &pattern_matrix); @@ -1142,7 +1144,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver cairo_pattern_t* CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const paintserver, - NRRect const *pbox, float alpha) + Geom::OptRect const &pbox, float alpha) { cairo_pattern_t *pattern = NULL; bool apply_bbox2user = FALSE; @@ -1157,7 +1159,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain Geom::Point p2 (lg->x2.computed, lg->y2.computed); if (pbox && SP_GRADIENT(lg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { // convert to userspace - Geom::Affine bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + Geom::Affine bbox2user(pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top()); p1 *= bbox2user; p2 *= bbox2user; } @@ -1237,7 +1239,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain if (apply_bbox2user) { // convert to userspace cairo_matrix_t bbox2user; - cairo_matrix_init (&bbox2user, pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + cairo_matrix_init (&bbox2user, pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top()); cairo_matrix_multiply (&pattern_matrix, &bbox2user, &pattern_matrix); } cairo_matrix_invert(&pattern_matrix); // because Cairo expects a userspace->patternspace matrix @@ -1248,7 +1250,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain } void -CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox) +CairoRenderContext::_setFillStyle(SPStyle const *const style, Geom::OptRect const &pbox) { g_return_if_fail( !style->fill.set || style->fill.isColor() @@ -1284,7 +1286,7 @@ CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox } void -CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox) +CairoRenderContext::_setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox) { float alpha = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value); if (_state->merge_opacity) @@ -1351,7 +1353,7 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox) } bool -CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox) +CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox) { g_assert( _is_valid ); @@ -1419,7 +1421,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con } bool CairoRenderContext::renderImage(GdkPixbuf *pb, - Geom::Affine const *image_transform, SPStyle const * /*style*/) + Geom::Affine const &image_transform, SPStyle const * /*style*/) { g_assert( _is_valid ); @@ -1442,8 +1444,7 @@ bool CairoRenderContext::renderImage(GdkPixbuf *pb, cairo_save(_cr); // scaling by width & height is not needed because it will be done by Cairo - if (image_transform) - transform(image_transform); + transform(image_transform); cairo_set_source_surface(_cr, image_surface, 0.0, 0.0); @@ -1507,7 +1508,7 @@ unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/, } bool -CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix, +CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, std::vector const &glyphtext, SPStyle const *style) { // create a cairo_font_face from PangoFont @@ -1575,7 +1576,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma stroke = true; } if (fill) { - _setFillStyle(style, NULL); + _setFillStyle(style, Geom::OptRect()); if (_is_texttopath) { _showGlyphs(_cr, font, glyphtext, true); have_path = true; @@ -1586,7 +1587,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma } } if (stroke) { - _setStrokeStyle(style, NULL); + _setStrokeStyle(style, Geom::OptRect()); if (!have_path) _showGlyphs(_cr, font, glyphtext, true); cairo_stroke(_cr); } @@ -1625,22 +1626,22 @@ CairoRenderContext::_concatTransform(cairo_t *cr, double xx, double yx, double x } void -CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform) +CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform) { - matrix->xx = (*transform)[0]; - matrix->yx = (*transform)[1]; - matrix->xy = (*transform)[2]; - matrix->yy = (*transform)[3]; - matrix->x0 = (*transform)[4]; - matrix->y0 = (*transform)[5]; + matrix->xx = transform[0]; + matrix->yx = transform[1]; + matrix->xy = transform[2]; + matrix->yy = transform[3]; + matrix->x0 = transform[4]; + matrix->y0 = transform[5]; } void -CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const *transform) +CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const &transform) { - _concatTransform(cr, (*transform)[0], (*transform)[1], - (*transform)[2], (*transform)[3], - (*transform)[4], (*transform)[5]); + _concatTransform(cr, transform[0], transform[1], + transform[2], transform[3], + transform[4], transform[5]); } static cairo_status_t diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index d4117ff7e..94c7bb294 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -128,20 +128,20 @@ public: CairoRenderState *getParentState(void) const; void setStateForStyle(SPStyle const *style); - void transform(Geom::Affine const *transform); - void setTransform(Geom::Affine const *transform); - void getTransform(Geom::Affine *copy) const; - void getParentTransform(Geom::Affine *copy) const; + void transform(Geom::Affine const &transform); + void setTransform(Geom::Affine const &transform); + Geom::Affine getTransform() const; + Geom::Affine getParentTransform() const; /* Clipping methods */ void addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule); void addClippingRect(double x, double y, double width, double height); /* Rendering methods */ - bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox); + bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox); bool renderImage(GdkPixbuf *pb, - Geom::Affine const *image_transform, SPStyle const *style); - bool renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix, + Geom::Affine const &image_transform, SPStyle const *style); + bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, std::vector const &glyphtext, SPStyle const *style); /* More general rendering methods will have to be added (like fill, stroke) */ @@ -183,18 +183,18 @@ protected: CairoClipMode _clip_mode; cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver, - NRRect const *pbox, float alpha); - cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox); + Geom::OptRect const &pbox, float alpha); + cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox); unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector const &glyphtext, bool is_stroke); bool _finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm = NULL); - void _setFillStyle(SPStyle const *style, NRRect const *pbox); - void _setStrokeStyle(SPStyle const *style, NRRect const *pbox); + void _setFillStyle(SPStyle const *style, Geom::OptRect const &pbox); + void _setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox); - void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform); + void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform); void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0); - void _concatTransform(cairo_t *cr, Geom::Affine const *transform); + void _concatTransform(cairo_t *cr, Geom::Affine const &transform); GHashTable *font_table; static void font_data_free(gpointer data); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5e7fb991a..adfa0421d 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -181,15 +181,13 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) { - NRRect pbox; - SPShape *shape = SP_SHAPE(item); if (!shape->curve) { return; } - item->invoke_bbox( &pbox, Geom::identity(), TRUE); + Geom::OptRect pbox = item->geometricBounds(); SPStyle* style = item->style; @@ -198,7 +196,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) return; } - ctx->renderPathVector(pathv, style, &pbox); + ctx->renderPathVector(pathv, style, pbox); // START marker for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START @@ -316,7 +314,7 @@ static void sp_use_render(SPItem *item, CairoRenderContext *ctx) if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { Geom::Affine tp(Geom::Translate(use->x.computed, use->y.computed)); ctx->pushState(); - ctx->transform(&tp); + ctx->transform(tp); translated = true; } @@ -372,7 +370,7 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) Geom::Scale s(width / (double)w, height / (double)h); Geom::Affine t(s * tp); - ctx->renderImage (image->pixbuf, &t, item->style); + ctx->renderImage (image->pixbuf, t, item->style); } static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) @@ -384,7 +382,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) /* Cloned is actually renderable */ ctx->pushState(); - ctx->transform(&symbol->c2p); + ctx->transform(symbol->c2p); // apply viewbox if set if (0 /*symbol->viewBox_set*/) { @@ -409,7 +407,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) vb2user[4] = x - symbol->viewBox.x0 * vb2user[0]; vb2user[5] = y - symbol->viewBox.y0 * vb2user[3]; - ctx->transform(&vb2user); + ctx->transform(vb2user); } sp_group_render(item, ctx); @@ -425,8 +423,7 @@ static void sp_root_render(SPRoot *root, CairoRenderContext *ctx) ctx->pushState(); renderer->setStateForItem(ctx, root); - Geom::Affine tempmat (root->c2p); - ctx->transform(&tempmat); + ctx->transform(root->c2p); sp_group_render(root, ctx); ctx->popState(); } @@ -450,9 +447,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } TRACE(("sp_asbitmap_render: resolution: %f\n", res )); - // Get the bounding box of the selection in document coordinates. - Geom::OptRect bbox = - item->getBounds(item->i2dt_affine(), SPItem::RENDERING_BBOX); + // Get the bounding box of the selection in desktop coordinates. + Geom::OptRect bbox = item->desktopVisualBounds(); // no bbox, e.g. empty group if (!bbox) { @@ -460,12 +456,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), item->document->getDimensions())); - Geom::Rect bboxrect(Geom::Rect(Geom::Point(bbox->min()[Geom::X], bbox->min()[Geom::Y]), Geom::Point(bbox->max()[Geom::X], bbox->max()[Geom::Y]))); - - Geom::OptRect _bbox = Geom::intersect(docrect, bboxrect); - - // assign the object dimension clipped on the document, no need to draw on area not on canvas - bbox = _bbox; + bbox &= docrect; // no bbox, e.g. empty group if (!bbox) { @@ -473,14 +464,14 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } // The width and height of the bitmap in pixels - unsigned width = ceil((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN)); - unsigned height = ceil((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN)); + unsigned width = ceil(bbox->width() * (res / PX_PER_IN)); + unsigned height = ceil(bbox->height() * (res / PX_PER_IN)); if (width == 0 || height == 0) return; // Scale to exactly fit integer bitmap inside bounding box - double scale_x = (bbox->max()[Geom::X] - bbox->min()[Geom::X]) / width; - double scale_y = (bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) / height; + double scale_x = bbox->width() / width; + double scale_y = bbox->height() / height; // Location of bounding box in document coordinates. double shift_x = bbox->min()[Geom::X]; @@ -516,7 +507,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL )); // TODO this is stupid - we just converted to pixbuf format when generating the bitmap! convert_pixbuf_normal_to_argb32(pb); - ctx->renderImage(pb, &t, item->style); + ctx->renderImage(pb, t, item->style); gdk_pixbuf_unref(pb); pb = 0; } @@ -604,8 +595,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) state->merge_opacity = FALSE; ctx->pushLayer(); } - Geom::Affine tempmat (item->transform); - ctx->transform(&tempmat); + ctx->transform(item->transform); sp_item_invoke_render(item, ctx); if (state->need_layer) @@ -625,25 +615,25 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page base = doc->getRoot(); } - NRRect d; + Geom::Rect d; if (pageBoundingBox) { - d.x0 = d.y0 = 0; - d.x1 = doc->getWidth(); - d.y1 = doc->getHeight(); + d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions()); } else { - base->invoke_bbox( &d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX); + Geom::OptRect bbox = base->desktopVisualBounds(); + if (!bbox) { + g_message("CairoRenderer: empty bounding box."); + return false; + } + d = *bbox; } if (ctx->_vector_based_target) { // convert from px to pt - d.x0 *= PT_PER_PX; - d.x1 *= PT_PER_PX; - d.y0 *= PT_PER_PX; - d.y1 *= PT_PER_PX; + d *= Geom::Scale(PT_PER_PX); } - ctx->_width = d.x1-d.x0; - ctx->_height = d.y1-d.y0; + ctx->_width = d.width(); + ctx->_height = d.height(); TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height)); @@ -655,11 +645,12 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page if (ctx->_vector_based_target) high *= PT_PER_PX; - Geom::Affine tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0), - (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); - ctx->transform(&tp); + /// @fixme hardcoded dt2doc transform? + Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0), + (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); + ctx->transform(tp); } - + return ret; } @@ -685,8 +676,8 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) t[4] = clip_bbox.x0; t[5] = clip_bbox.y0; t *= ctx->getCurrentState()->transform; - ctx->getTransform(&saved_ctm); - ctx->setTransform(&t); + saved_ctm = ctx->getTransform(); + ctx->setTransform(t); } TRACE(("BEGIN clip\n")); @@ -696,12 +687,11 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) SPItem const *item = SP_ITEM(child); // combine transform of the item in clippath and the item using clippath: - Geom::Affine tempmat (item->transform); - tempmat = tempmat * (ctx->getCurrentState()->item_transform); + Geom::Affine tempmat = item->transform * ctx->getCurrentState()->item_transform; // render this item in clippath ctx->pushState(); - ctx->transform(&tempmat); + ctx->transform(tempmat); setStateForItem(ctx, item); // TODO fix this call to accept const items sp_item_invoke_render(const_cast(item), ctx); @@ -716,7 +706,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) cairo_clip(ctx->_cr); if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) - ctx->setTransform(&saved_ctm); + ctx->setTransform(saved_ctm); ctx->setRenderMode(saved_mode); } @@ -738,7 +728,7 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) t[4] = mask_bbox.x0; t[5] = mask_bbox.y0; t *= ctx->getCurrentState()->transform; - ctx->setTransform(&t); + ctx->setTransform(t); } // Clip mask contents... but... diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 7ed0f6fcf..be5bf96c3 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -135,25 +135,22 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) _width = doc->getWidth(); _height = doc->getHeight(); - NRRect d; bool pageBoundingBox; pageBoundingBox = mod->get_param_bool("pageBoundingBox"); + + Geom::Rect d; if (pageBoundingBox) { - d.x0 = d.y0 = 0; - d.x1 = _width; - d.y1 = _height; + d = Geom::Rect::from_xywh(0, 0, _width, _height); } else { SPItem* doc_item = doc->getRoot(); - doc_item->invoke_bbox(&d, doc_item->i2dt_affine(), TRUE); + Geom::OptRect bbox = doc_item->desktopVisualBounds(); + if (bbox) d = *bbox; } - d.x0 *= IN_PER_PX; - d.y0 *= IN_PER_PX; - d.x1 *= IN_PER_PX; - d.y1 *= IN_PER_PX; + d *= IN_PER_PX; - float dwInchesX = (d.x1 - d.x0); - float dwInchesY = (d.y1 - d.y0); + float dwInchesX = d.width(); + float dwInchesY = d.height(); // dwInchesX x dwInchesY in .01mm units SetRect( &rc, 0, 0, (int) ceil(dwInchesX*2540), (int) ceil(dwInchesY*2540) ); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 6436624fd..da5ea6d9e 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -90,7 +90,7 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc bounding_area = Geom::Rect( Geom::Point(0,0), Geom::Point(doc->getWidth(), doc->getHeight()) ); } else { - Geom::OptRect bounds = selection->bounds(); + Geom::OptRect bounds = selection->visualBounds(); if (bounds) { bounding_area = *bounds; } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 02f0823d9..0da048a17 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -588,27 +588,27 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * base = doc->getRoot(); } - Geom::OptRect d; + Geom::Rect d; if (pageBoundingBox) { - d = Geom::Rect( Geom::Point(0,0), - Geom::Point(doc->getWidth(), doc->getHeight()) ); + d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions()); } else { - base->invoke_bbox( d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX); - } - if (!d) { - g_message("LaTeXTextRenderer: could not retrieve boundingbox."); - return false; + Geom::OptRect bbox = base->desktopVisualBounds(); + if (!bbox) { + g_message("CairoRenderer: empty bounding box."); + return false; + } + d = *bbox; } // scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX - double scale = 1/(d->width()); - double _width = d->width() * scale; - double _height = d->height() * scale; + double scale = 1/(d.width()); + double _width = d.width() * scale; + double _height = d.height() * scale; push_transform( Geom::Scale(scale, scale) ); if (!pageBoundingBox) { - push_transform( Geom::Translate( - d->min() ) ); + push_transform( Geom::Translate( -d.min() ) ); } // flip y-axis @@ -621,7 +621,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * // scaling of the image when including it in LaTeX os << " \\ifx\\svgwidth\\undefined%\n"; - os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 + os << " \\setlength{\\unitlength}{" << d.width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 os << " \\ifx\\svgscale\\undefined%\n"; os << " \\relax%\n"; os << " \\else%\n"; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 568c804a0..735c57798 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -573,7 +573,7 @@ void SingularValueDecomposition::calculate() //double eps = pow(2.0,-52.0); //double tiny = pow(2.0,-966.0); //let's just calculate these now - //a double can be e ± 308.25, so this is safe + //a double can be e ± 308.25, so this is safe double eps = 2.22e-16; double tiny = 1.6e-291; while (p > 0) { @@ -965,15 +965,10 @@ static Geom::Affine getODFTransform(const SPItem *item) */ static Geom::OptRect getODFBoundingBox(const SPItem *item) { - Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop(); - Geom::OptRect bbox; - if (bbox_temp) { - bbox = *bbox_temp; - double doc_height = SP_ACTIVE_DOCUMENT->getHeight(); - Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); - doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height)); - bbox = *bbox * doc2dt_tf; - bbox = *bbox * Geom::Affine(Geom::Scale(pxToCm)); + // TODO: geometric or visual? + Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds(); + if (bbox) { + *bbox *= Geom::Affine(Geom::Scale(pxToCm)); } return bbox; } diff --git a/src/file.cpp b/src/file.cpp index c6d43fa51..350281dee 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1056,7 +1056,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // move to mouse pointer { sp_desktop_document(desktop)->ensureUpToDate(); - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); sp_selection_move_relative(selection, m, false); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 9ea9407b1..1b63bf6f9 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -317,7 +317,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo SPFilter * new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, gdouble radius) { - Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX); + Geom::OptRect const r = item->desktopGeometricBounds(); double width; double height; @@ -370,7 +370,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it stdDeviation /= expansion; // Get the object size - Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX); + Geom::OptRect const r = item->desktopGeometricBounds(); double width; double height; if (r) { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 8603f8b66..9e8705862 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -778,7 +778,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even document->ensureUpToDate(); - Geom::OptRect bbox = document->getRoot()->getBounds(Geom::identity()); + Geom::OptRect bbox = document->getRoot()->visualBounds(); if (!bbox) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Area is not bounded, cannot fill.")); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index f803d7bf8..5a8b20850 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -296,7 +296,7 @@ SPGradient *sp_gradient_reset_to_userspace(SPGradient *gr, SPItem *item) // calculate the bbox of the item item->document->ensureUpToDate(); - Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine + Geom::OptRect bbox = item->visualBounds(); // we need "true" bbox without item_i2d_affine if (!bbox) return gr; @@ -363,7 +363,7 @@ SPGradient *sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar // calculate the bbox of the item item->document->ensureUpToDate(); Geom::Affine bbox2user; - Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine + Geom::OptRect bbox = item->visualBounds(); // we need "true" bbox without item_i2d_affine if ( bbox ) { bbox2user = Geom::Affine(bbox->dimensions()[Geom::X], 0, 0, bbox->dimensions()[Geom::Y], @@ -1063,7 +1063,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po if (SP_GRADIENT(gradient)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { item->document->ensureUpToDate(); - Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine + Geom::OptRect bbox = item->visualBounds(); // we need "true" bbox without item_i2d_affine if (bbox) { p *= Geom::Affine(bbox->dimensions()[Geom::X], 0, 0, bbox->dimensions()[Geom::Y], diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 142ae2a98..1275bf995 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1788,15 +1788,15 @@ GrDrag::updateLevels () for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { SPItem *item = SP_ITEM(i->data); - Geom::OptRect rect = item->getBboxDesktop (); + Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { // Remember the edges of the bbox and the center axis hor_levels.push_back(rect->min()[Geom::Y]); hor_levels.push_back(rect->max()[Geom::Y]); - hor_levels.push_back(0.5 * (rect->min()[Geom::Y] + rect->max()[Geom::Y])); + hor_levels.push_back(rect->midpoint()[Geom::Y]); vert_levels.push_back(rect->min()[Geom::X]); vert_levels.push_back(rect->max()[Geom::X]); - vert_levels.push_back(0.5 * (rect->min()[Geom::X] + rect->max()[Geom::X])); + vert_levels.push_back(rect->midpoint()[Geom::X]); } } } diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 57002bfb6..6197be9f7 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -128,7 +128,7 @@ void graphlayout(GSList const *const items) { ++i) { SPItem *u=*i; - Geom::OptRect const item_box(u->getBboxDesktop()); + Geom::OptRect const item_box = u->desktopVisualBounds(); if(item_box) { Geom::Point ll(item_box->min()); Geom::Point ur(item_box->max()); @@ -231,8 +231,8 @@ void graphlayout(GSList const *const items) { map::iterator i=nodelookup.find(u->getId()); if(i!=nodelookup.end()) { Rectangle* r=rs[i->second]; - Geom::OptRect item_box(u->getBboxDesktop()); - if(item_box) { + Geom::OptRect item_box = u->desktopVisualBounds(); + if (item_box) { Geom::Point const curr(item_box->midpoint()); Geom::Point const dest(r->getCentreX(),r->getCentreY()); sp_item_move_rel(u, Geom::Translate(dest - curr)); diff --git a/src/interface.cpp b/src/interface.cpp index a981424fa..fb0d23e1b 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1425,7 +1425,7 @@ sp_ui_drag_data_received(GtkWidget *widget, // move to mouse pointer { sp_desktop_document(desktop)->ensureUpToDate(); - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); sp_selection_move_relative(selection, m, false); diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index a72fa0180..fa1a07414 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -81,7 +81,7 @@ void Layout::_getGlyphTransformMatrix(int glyph_index, Geom::Affine *matrix) con } } -void Layout::show(DrawingGroup *in_arena, NRRect const *paintbox) const +void Layout::show(DrawingGroup *in_arena, Geom::OptRect const &paintbox) const { int glyph_index = 0; for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) { @@ -99,13 +99,14 @@ void Layout::show(DrawingGroup *in_arena, NRRect const *paintbox) const } glyph_index++; } - nr_text->setPaintBox(paintbox ? paintbox->upgrade_2geom() : Geom::OptRect()); + nr_text->setPaintBox(paintbox); in_arena->prependChild(nr_text); } } -void Layout::getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start, int length) const +Geom::OptRect Layout::bounds(Geom::Affine const &transform, int start, int length) const { + Geom::OptRect bbox; for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; glyph_index++) { if (_characters[_glyphs[glyph_index].in_character].in_glyph == -1) continue; if (start != -1 && (int) _glyphs[glyph_index].in_character < start) continue; @@ -122,26 +123,15 @@ void Layout::getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, if(_glyphs[glyph_index].span(this).font) { Geom::OptRect glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph); if (glyph_rect) { - Geom::Point bmi = glyph_rect->min(), bma = glyph_rect->max(); - Geom::Point tlp(bmi[0],bmi[1]), trp(bma[0],bmi[1]), blp(bmi[0],bma[1]), brp(bma[0],bma[1]); - tlp *= total_transform; - trp *= total_transform; - blp *= total_transform; - brp *= total_transform; - *glyph_rect = Geom::Rect(tlp,trp); - glyph_rect->expandTo(blp); - glyph_rect->expandTo(brp); - if ( (glyph_rect->min())[0] < bounding_box->x0 ) bounding_box->x0=(glyph_rect->min())[0]; - if ( (glyph_rect->max())[0] > bounding_box->x1 ) bounding_box->x1=(glyph_rect->max())[0]; - if ( (glyph_rect->min())[1] < bounding_box->y0 ) bounding_box->y0=(glyph_rect->min())[1]; - if ( (glyph_rect->max())[1] > bounding_box->y1 ) bounding_box->y1=(glyph_rect->max())[1]; + bbox.unionWith(*glyph_rect * total_transform); } } } + return bbox; } void Layout::print(SPPrintContext *ctx, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox, Geom::Affine const &ctm) const { if (_input_stream.empty()) return; @@ -240,7 +230,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const if (pathv) { Geom::PathVector pathv_trans = (*pathv) * glyph_matrix; SPStyle const *style = text_source->style; - ctx->renderPathVector(pathv_trans, style, NULL); + ctx->renderPathVector(pathv_trans, style, Geom::OptRect()); } glyph_index++; continue; @@ -302,7 +292,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const ctx->pushLayer(); } if (glyph_index - first_index > 0) - ctx->renderGlyphtext(span.font->pFont, &font_matrix, glyphtext, style); + ctx->renderGlyphtext(span.font->pFont, font_matrix, glyphtext, style); if (opacity != 1.0) { ctx->popLayer(); ctx->popState(); @@ -388,9 +378,9 @@ Glib::ustring Layout::dumpAsText() const for (unsigned char_index = 0 ; char_index < _characters.size() ; char_index++) { if (_characters[char_index].in_span != span_index) continue; if (_input_stream[_spans[span_index].in_input_stream_item]->Type() != TEXT_SOURCE) { - snprintf(line, sizeof(line), " %d: control x=%f flags=%03x glyph=%d\n", char_index, _characters[char_index].x, *(unsigned*)&_characters[char_index].char_attributes, _characters[char_index].in_glyph); + snprintf(line, sizeof(line), " %d: control x=%f flags=%03x glyph=%d\n", char_index, _characters[char_index].x, *(unsigned*) &_characters[char_index].char_attributes, _characters[char_index].in_glyph); } else { - snprintf(line, sizeof(line), " %d: '%c' x=%f flags=%03x glyph=%d\n", char_index, *iter_char, _characters[char_index].x, *(unsigned*)&_characters[char_index].char_attributes, _characters[char_index].in_glyph); + snprintf(line, sizeof(line), " %d: '%c' x=%f flags=%03x glyph=%d\n", char_index, *iter_char, _characters[char_index].x, *(unsigned*) &_characters[char_index].char_attributes, _characters[char_index].in_glyph); iter_char++; } result += line; diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 25f80e9e9..a8852ed8a 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -328,7 +328,7 @@ public: \param in_arena The arena to add the glyphs group to \param paintbox The current rendering tile */ - void show(DrawingGroup *in_arena, NRRect const *paintbox) const; + void show(DrawingGroup *in_arena, Geom::OptRect const &paintbox) const; /** Calculates the smallest rectangle completely enclosing all the glyphs. @@ -336,7 +336,7 @@ public: \param transform The transform to be applied to the entire object prior to calculating its bounds. */ - void getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start = -1, int length = -1) const; + Geom::OptRect bounds(Geom::Affine const &transform, int start = -1, int length = -1) const; /** Sends all the glyphs to the given print context. \param ctx I have @@ -345,7 +345,7 @@ public: \param bbox parameters \param ctm do yet */ - void print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, Geom::Affine const &ctm) const; + void print(SPPrintContext *ctx, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox, Geom::Affine const &ctm) const; #ifdef HAVE_CAIRO_PDF /** Renders all the glyphs to the given Cairo rendering context. diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index 96d465569..8b5badf5f 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -174,10 +174,10 @@ LPEExtrude::resetDefaults(SPItem * item) using namespace Geom; - Geom::OptRect bbox = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = item->geometricBounds(); if (bbox) { - Interval boundingbox_X = (*bbox)[Geom::X]; - Interval boundingbox_Y = (*bbox)[Geom::Y]; + Interval const &boundingbox_X = (*bbox)[Geom::X]; + Interval const &boundingbox_Y = (*bbox)[Geom::Y]; extrude_vector.set_and_write_new_values( Geom::Point(boundingbox_X.middle(), boundingbox_Y.middle()), (boundingbox_X.extent() + boundingbox_Y.extent())*Geom::Point(-0.05,0.2) ); } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 02d24752b..2d043ca91 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -45,8 +45,10 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) { using namespace Geom; + // fixme: what happens if the bbox is empty? + // fixme: this is probably wrong Geom::Affine t = lpeitem->i2dt_affine(); - Geom::Rect bbox = *lpeitem->getBounds(t); // fixme: what happens if getBounds does not return a valid rect? + Geom::Rect bbox = *lpeitem->desktopVisualBounds(); Point A(bbox.left(), bbox.bottom()); Point B(bbox.left(), bbox.top()); diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 671d88a8b..87e3dbe5c 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -557,7 +557,7 @@ LPERoughHatches::resetDefaults(SPItem * item) { Effect::resetDefaults(item); - Geom::OptRect bbox = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = item->geometricBounds(); Geom::Point origin(0.,0.); Geom::Point vector(50.,0.); if (bbox) { diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 382231378..c241b9a4c 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -34,7 +34,7 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) transform = Geom::identity(); } - Geom::OptRect bbox = lpeitem->getBounds(transform, SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = lpeitem->geometricBounds(transform); if (bbox) { boundingbox_X = (*bbox)[Geom::X]; boundingbox_Y = (*bbox)[Geom::Y]; diff --git a/src/main.cpp b/src/main.cpp index ace99f519..501a3e5d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1195,8 +1195,8 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g doc->ensureUpToDate(); SPItem *item = ((SPItem *) o); - // "true" SVG bbox for scripting - Geom::OptRect area = item->getBounds(item->i2doc_affine()); + // visual bbox in document coords for scripting + Geom::OptRect area = item->documentVisualBounds(); if (area) { Inkscape::SVGOStringStream os; if (extent) { @@ -1226,7 +1226,7 @@ do_query_all_recurse (SPObject *o) { SPItem *item = ((SPItem *) o); if (o->getId() && SP_IS_ITEM(item)) { - Geom::OptRect area = item->getBounds(item->i2doc_affine()); + Geom::OptRect area = item->documentVisualBounds(); if (area) { Inkscape::SVGOStringStream os; os << o->getId(); @@ -1320,8 +1320,7 @@ sp_do_export_png(SPDocument *doc) // write object bbox to area doc->ensureUpToDate(); - Geom::OptRect areaMaybe; - static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2dt_affine(), TRUE); + Geom::OptRect areaMaybe = static_cast(o_area)->desktopVisualBounds(); if (areaMaybe) { area = *areaMaybe; } else { diff --git a/src/marker.cpp b/src/marker.cpp index c8fa9218d..9db5cfdc1 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -45,7 +45,7 @@ static Inkscape::XML::Node *sp_marker_write (SPObject *object, Inkscape::XML::Do static Inkscape::DrawingItem *sp_marker_private_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_marker_private_hide (SPItem *item, unsigned int key); -static void sp_marker_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_marker_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_marker_print (SPItem *item, SPPrintContext *ctx); static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems); @@ -541,10 +541,11 @@ sp_marker_private_hide (SPItem */*item*/, unsigned int /*key*/) /** * This routine is disabled to break propagation. */ -static void -sp_marker_bbox(SPItem const *, NRRect *, Geom::Affine const &, unsigned const) +static Geom::OptRect +sp_marker_bbox(SPItem const *, Geom::Affine const &, SPItem::BBoxType) { - /* Break propagation */ + /* Break propagation */ + return Geom::OptRect(); } /** diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index fd8ef0c7c..07d690ce0 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -135,15 +135,14 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, if (SP_IS_GROUP(o)) { _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine); } else { - Geom::OptRect bbox_of_item = Geom::Rect(); + Geom::OptRect bbox_of_item; if (clip_or_mask) { // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine) - item->invoke_bbox(bbox_of_item, - item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt(), - true); + bbox_of_item = item->visualBounds(item->i2doc_affine() * additional_affine * + _snapmanager->getDesktop()->doc2dt()); } else { - item->invoke_bbox( bbox_of_item, item->i2dt_affine(), true); + bbox_of_item = item->desktopVisualBounds(); } if (bbox_of_item) { // See if the item is within range @@ -188,7 +187,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, Preferences *prefs = Preferences::get(); bool prefs_bbox = prefs->getBool("/tools/bounding_box"); bbox_type = !prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; } // Consider the page border for snapping to @@ -255,7 +254,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { - Geom::OptRect b = root_item->getBboxDesktop(bbox_type); + Geom::OptRect b = root_item->desktopBounds(bbox_type); getBBoxPoints(b, _points_to_snap_to, true, _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER), _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT), @@ -370,7 +369,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, Preferences *prefs = Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); bbox_type = !prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; } // Consider the page border for snapping @@ -449,11 +448,10 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { - Geom::OptRect rect; - root_item->invoke_bbox( rect, i2doc, TRUE, bbox_type); + Geom::OptRect rect = root_item->bounds(bbox_type, i2doc); if (rect) { Geom::PathVector *path = _getPathvFromRect(*rect); - rect = root_item->getBboxDesktop(bbox_type); + rect = root_item->desktopBounds(bbox_type); _paths_to_snap_to->push_back(SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect)); } } diff --git a/src/print.cpp b/src/print.cpp index 2eadf0fa9..3e477c976 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -56,16 +56,18 @@ sp_print_comment(SPPrintContext *ctx, char const *comment) unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox); + NRRect nrpbox(pbox), nrdbox(dbox), nrbbox(bbox); + return ctx->module->fill(pathv, ctm, style, &nrpbox, &nrdbox, &nrbbox); } unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox); + NRRect nrpbox(pbox), nrdbox(dbox), nrbbox(bbox); + return ctx->module->stroke(pathv, ctm, style, &nrpbox, &nrdbox, &nrbbox); } unsigned int diff --git a/src/print.h b/src/print.h index 6bdbe4b82..34c85d901 100644 --- a/src/print.h +++ b/src/print.h @@ -27,9 +27,9 @@ unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const *transform, f unsigned int sp_print_release(SPPrintContext *ctx); unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment); unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index a503fea35..6dd8d6a79 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -50,7 +50,7 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG ++it) { using Geom::X; using Geom::Y; - Geom::OptRect item_box((*it)->getBboxDesktop()); + Geom::OptRect item_box((*it)->desktopVisualBounds()); if (item_box) { Geom::Point min(item_box->min() - .5*gap); Geom::Point max(item_box->max() + .5*gap); diff --git a/src/selcue.cpp b/src/selcue.cpp index c647c1f96..dbcaf4cc3 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -68,8 +68,6 @@ void Inkscape::SelCue::_updateItemBboxes() g_return_if_fail(_selection != NULL); int prefs_bbox = prefs->getBool("/tools/bounding_box"); - SPItem::BBoxType bbox_type = !prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; GSList const *items = _selection->itemList(); if (_item_bboxes.size() != g_slist_length((GSList *) items)) { @@ -83,7 +81,8 @@ void Inkscape::SelCue::_updateItemBboxes() SPCanvasItem* box = _item_bboxes[bcount ++]; if (box) { - Geom::OptRect const b = item->getBboxDesktop(bbox_type); + Geom::OptRect const b = (prefs_bbox == 0) ? + item->desktopVisualBounds() : item->desktopGeometricBounds(); if (b) { sp_canvas_item_show(box); @@ -118,13 +117,12 @@ void Inkscape::SelCue::_newItemBboxes() g_return_if_fail(_selection != NULL); int prefs_bbox = prefs->getBool("/tools/bounding_box"); - SPItem::BBoxType bbox_type = !prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { SPItem *item = (SPItem *) l->data; - Geom::OptRect const b = item->getBboxDesktop(bbox_type); + Geom::OptRect const b = (prefs_bbox == 0) ? + item->desktopVisualBounds() : item->desktopGeometricBounds(); SPCanvasItem* box = NULL; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 23991bfb6..75745f4af 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -777,7 +777,7 @@ enclose_items(GSList const *items) Geom::OptRect r; for (GSList const *i = items; i; i = i->next) { - r.unionWith(((SPItem *) i->data)->getBboxDesktop()); + r.unionWith(((SPItem *) i->data)->desktopVisualBounds()); } return r; } @@ -829,7 +829,7 @@ sp_selection_raise(SPDesktop *desktop) for (SPObject *newref = child->next; newref; newref = newref->next) { // if the sibling is an item AND overlaps our selection, if (SP_IS_ITEM(newref)) { - Geom::OptRect newref_bbox = SP_ITEM(newref)->getBboxDesktop(); + Geom::OptRect newref_bbox = SP_ITEM(newref)->desktopVisualBounds(); if ( newref_bbox && selected->intersects(*newref_bbox) ) { // AND if it's not one of our selected objects, if (!g_slist_find((GSList *) items, newref)) { @@ -924,7 +924,7 @@ sp_selection_lower(SPDesktop *desktop) for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { // if the sibling is an item AND overlaps our selection, if (SP_IS_ITEM(newref)) { - Geom::OptRect ref_bbox = SP_ITEM(newref)->getBboxDesktop(); + Geom::OptRect ref_bbox = SP_ITEM(newref)->desktopVisualBounds(); if ( ref_bbox && selected->intersects(*ref_bbox) ) { // AND if it's not one of our selected objects, if (!g_slist_find((GSList *) items, newref)) { @@ -1481,7 +1481,7 @@ sp_selection_scale_absolute(Inkscape::Selection *selection, if (selection->isEmpty()) return; - Geom::OptRect const bbox(selection->bounds()); + Geom::OptRect bbox = selection->visualBounds(); if ( !bbox ) { return; } @@ -1503,7 +1503,7 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point con if (selection->isEmpty()) return; - Geom::OptRect const bbox(selection->bounds()); + Geom::OptRect bbox = selection->visualBounds(); if ( !bbox ) { return; @@ -1621,7 +1621,7 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle) if (selection->isEmpty()) return; - Geom::OptRect const bbox(selection->bounds()); + Geom::OptRect bbox = selection->visualBounds(); boost::optional center = selection->center(); if ( !bbox || !center ) { @@ -1650,7 +1650,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow) if (selection->isEmpty()) return; - Geom::OptRect const bbox(selection->bounds()); + Geom::OptRect bbox = selection->visualBounds(); if (!bbox) { return; } @@ -1687,7 +1687,7 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times) if (selection->isEmpty()) return; - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (!sel_bbox) { return; @@ -2014,7 +2014,7 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, void scroll_to_show_item(SPDesktop *desktop, SPItem *item) { Geom::Rect dbox = desktop->get_display_area(); - Geom::OptRect sbox = item->getBboxDesktop(); + Geom::OptRect sbox = item->desktopVisualBounds(); if ( sbox && dbox.contains(*sbox) == false ) { Geom::Point const s_dt = sbox->midpoint(); @@ -2248,8 +2248,8 @@ sp_select_clone_original(SPDesktop *desktop) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool highlight = prefs->getBool("/options/highlightoriginal/value"); if (highlight) { - Geom::OptRect a = item->getBounds(item->i2dt_affine()); - Geom::OptRect b = original->getBounds(original->i2dt_affine()); + Geom::OptRect a = item->desktopVisualBounds(); + Geom::OptRect b = original->desktopVisualBounds(); if ( a && b ) { // draw a flashing line between the objects SPCurve *curve = new SPCurve(); @@ -2291,7 +2291,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) } doc->ensureUpToDate(); - Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX); + Geom::OptRect r = selection->visualBounds(); boost::optional c = selection->center(); if ( !r || !c ) { return; @@ -2322,7 +2322,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) repr_copies = g_slist_prepend(repr_copies, dup); } - Geom::Rect bounds(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); + Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); if (apply) { // delete objects so that their clones don't get alerted; this object will be restored shortly @@ -2339,7 +2339,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - gchar const *mark_id = generate_marker(repr_copies, bounds, doc, + gchar const *mark_id = generate_marker(repr_copies, bbox, doc, ( Geom::Affine(Geom::Translate(desktop->dt2doc( Geom::Point(r->min()[Geom::X], r->max()[Geom::Y])))) @@ -2416,7 +2416,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } doc->ensureUpToDate(); - Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX); + Geom::OptRect r = selection->visualBounds(); if ( !r ) { return; } @@ -2447,7 +2447,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) // restore the z-order after prepends repr_copies = g_slist_reverse(repr_copies); - Geom::Rect bounds(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); + Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); if (apply) { // delete objects so that their clones don't get alerted; this object will be restored shortly @@ -2464,7 +2464,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - gchar const *pat_id = pattern_tile(repr_copies, bounds, doc, + gchar const *pat_id = pattern_tile(repr_copies, bbox, doc, ( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], r->max()[Geom::Y])))) * parent_transform.inverse() ), @@ -2477,8 +2477,8 @@ sp_selection_tile(SPDesktop *desktop, bool apply) Inkscape::XML::Node *rect = xml_doc->createElement("svg:rect"); rect->setAttribute("style", g_strdup_printf("stroke:none;fill:url(#%s)", pat_id)); - Geom::Point min = bounds.min() * parent_transform.inverse(); - Geom::Point max = bounds.max() * parent_transform.inverse(); + Geom::Point min = bbox.min() * parent_transform.inverse(); + Geom::Point max = bbox.max() * parent_transform.inverse(); sp_repr_set_svg_double(rect, "width", max[Geom::X] - min[Geom::X]); sp_repr_set_svg_double(rect, "height", max[Geom::Y] - min[Geom::Y]); @@ -2663,7 +2663,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Get the bounding box of the selection document->ensureUpToDate(); - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (!bbox) { desktop->clearWaitingCursor(); return; // exceptional situation, so not bother with a translatable error message, just quit quietly @@ -3200,7 +3200,7 @@ fit_canvas_to_selection(SPDesktop *desktop, bool with_margins) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to fit canvas to.")); return false; } - Geom::OptRect const bbox(desktop->selection->bounds(SPItem::RENDERING_BBOX)); + Geom::OptRect const bbox(desktop->selection->visualBounds()); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; @@ -3232,7 +3232,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) doc->ensureUpToDate(); SPItem const *const root = doc->getRoot(); - Geom::OptRect const bbox(root->getBounds(root->i2dt_affine(), SPItem::RENDERING_BBOX)); + Geom::OptRect bbox = root->desktopVisualBounds(); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; diff --git a/src/selection.cpp b/src/selection.cpp index 677e57d5f..92b35bce7 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -362,50 +362,48 @@ Inkscape::XML::Node *Selection::singleRepr() { return obj ? obj->getRepr() : NULL; } -NRRect *Selection::bounds(NRRect *bbox, SPItem::BBoxType type) const +Geom::OptRect Selection::bounds(SPItem::BBoxType type) const { - g_return_val_if_fail (bbox != NULL, NULL); - *bbox = NRRect(bounds(type)); - return bbox; + return (type == SPItem::GEOMETRIC_BBOX) ? + geometricBounds() : visualBounds(); } -Geom::OptRect Selection::bounds(SPItem::BBoxType type) const +Geom::OptRect Selection::geometricBounds() const { GSList const *items = const_cast(this)->itemList(); Geom::OptRect bbox; for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox.unionWith(SP_ITEM(i->data)->getBboxDesktop(type)); + bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds()); } return bbox; } -NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { - g_return_val_if_fail (bbox != NULL, NULL); +Geom::OptRect Selection::visualBounds() const +{ + GSList const *items = const_cast(this)->itemList(); - GSList const *items=const_cast(this)->itemList(); - if (!items) { - bbox->x0 = bbox->y0 = bbox->x1 = bbox->y1 = 0.0; - return bbox; + Geom::OptRect bbox; + for ( GSList const *i = items ; i != NULL ; i = i->next ) { + bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds()); } + return bbox; +} - bbox->x0 = bbox->y0 = 1e18; - bbox->x1 = bbox->y1 = -1e18; +Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const +{ + Geom::OptRect bbox; + GSList const *items = const_cast(this)->itemList(); + if (!items) return bbox; for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { - SPItem *item=SP_ITEM(iter->data); - Geom::Affine i2doc(item->i2doc_affine()); - item->invoke_bbox( bbox, i2doc, FALSE, type); + SPItem *item = SP_ITEM(iter->data); + bbox |= item->documentBounds(type); } return bbox; } -Geom::OptRect Selection::boundsInDocument(SPItem::BBoxType type) const { - NRRect r; - return to_2geom(boundsInDocument(&r, type)); -} - /** Extract the position of the center from the first selected object */ // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() @@ -418,9 +416,9 @@ boost::optional Selection::center() const { return first->getCenter(); } } - Geom::OptRect bbox = bounds(); + Geom::OptRect bbox = visualBounds(); if (bbox) { - return bounds()->midpoint(); + return bbox->midpoint(); } else { return boost::optional(); } diff --git a/src/selection.h b/src/selection.h index 00572a1c5..af0facc3d 100644 --- a/src/selection.h +++ b/src/selection.h @@ -244,25 +244,12 @@ public: guint numberOfParents(); /** @brief Returns the bounding rectangle of the selection */ - NRRect *bounds(NRRect *dest, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; - /** @brief Returns the bounding rectangle of the selection */ - Geom::OptRect bounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; - - /** - * @brief Returns the bounding rectangle of the selection - * - * Gives the coordinates in internal format, does not match onscreen guides. - * (0,0 is the upper left corner, not the lower left corner) - */ - NRRect *boundsInDocument(NRRect *dest, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; + Geom::OptRect bounds(SPItem::BBoxType type) const; + Geom::OptRect visualBounds() const; + Geom::OptRect geometricBounds() const; - /** - * @brief Returns the bounding rectangle of the selection - * - * Gives the coordinates in internal format, does not match onscreen guides. - * (0,0 is the upper left corner, not the lower left corner) - */ - Geom::OptRect boundsInDocument(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; + /// Returns the bounding rectangle of the selectionin document coordinates. + Geom::OptRect documentBounds(SPItem::BBoxType type) const; /** * @brief Returns the rotation/skew center of the selection diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 3a204a49e..0e5e533fc 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -90,7 +90,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _grabbed(false), _show_handles(true), _bbox(), - _approximate_bbox(), + _visual_bbox(), _absolute_affine(Geom::Scale(1,1)), _opposite(Geom::Point(0,0)), _opposite_for_specpoints(Geom::Point(0,0)), @@ -104,7 +104,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); _snap_bbox_type = !prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; g_return_if_fail(desktop != NULL); @@ -279,8 +279,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // First, determine the bounding box _bbox = selection->bounds(_snap_bbox_type); - _approximate_bbox = selection->bounds(SPItem::APPROXIMATE_BBOX); // Used for correctly scaling the strokewidth - _geometric_bbox = selection->bounds(SPItem::GEOMETRIC_BBOX); + _visual_bbox = selection->visualBounds(); // Used for correctly scaling the strokewidth + _geometric_bbox = selection->geometricBounds(); _point = p; if (_geometric_bbox) { @@ -336,7 +336,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole for (unsigned i = 0; i < _items.size(); i++) { - getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, c, emp, mp); + Geom::OptRect b = _items[i]->desktopBounds(_snap_bbox_type); + getBBoxPoints(b, &_bbox_points_for_translating, false, c, emp, mp); } } else { _bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole @@ -696,7 +697,7 @@ void Inkscape::SelTrans::_updateVolatileState() //Update the bboxes _bbox = selection->bounds(_snap_bbox_type); - _approximate_bbox = selection->bounds(SPItem::APPROXIMATE_BBOX); + _visual_bbox = selection->visualBounds(); if (!_bbox) { _empty = true; @@ -898,8 +899,7 @@ void Inkscape::SelTrans::_selChanged(Inkscape::Selection */*selection*/) // reread in case it changed on the fly: int prefs_bbox = prefs->getBool("/tools/bounding_box"); _snap_bbox_type = !prefs_bbox ? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; - //SPItem::APPROXIMATE_BBOX will be replaced by SPItem::VISUAL_BBOX, as soon as the latter is implemented properly + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; _updateVolatileState(); _current_relative_affine.setIdentity(); @@ -1602,8 +1602,8 @@ Geom::Scale Inkscape::calcScaleFactors(Geom::Point const &initial_point, Geom::P Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_scale) { Geom::Affine abs_affine = Geom::Translate(-_origin) * Geom::Affine(default_scale) * Geom::Translate(_origin); - Geom::Point new_bbox_min = _approximate_bbox->min() * abs_affine; - Geom::Point new_bbox_max = _approximate_bbox->max() * abs_affine; + Geom::Point new_bbox_min = _visual_bbox->min() * abs_affine; + Geom::Point new_bbox_max = _visual_bbox->max() * abs_affine; bool transform_stroke = false; gdouble strokewidth = 0; @@ -1614,7 +1614,7 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_ strokewidth = _strokewidth; } - _absolute_affine = get_scale_transform_with_uniform_stroke (*_approximate_bbox, strokewidth, transform_stroke, + _absolute_affine = get_scale_transform_with_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke, new_bbox_min[Geom::X], new_bbox_min[Geom::Y], new_bbox_max[Geom::X], new_bbox_max[Geom::Y]); // return the new handle position diff --git a/src/seltrans.h b/src/seltrans.h index dd890ee9b..9d14fda26 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -136,7 +136,7 @@ private: SPItem::BBoxType _snap_bbox_type; Geom::OptRect _bbox; - Geom::OptRect _approximate_bbox; + Geom::OptRect _visual_bbox; Geom::OptRect _geometric_bbox; gdouble _strokewidth; diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 0b3320e59..2213443a5 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -34,7 +34,7 @@ struct SPClipPathView { SPClipPathView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); @@ -193,10 +193,9 @@ void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags) SPClipPath *cp = SP_CLIPPATH(object); for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); - t[4] = v->bbox.x0; - t[5] = v->bbox.y0; + if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) { + Geom::Affine t = Geom::Scale(v->bbox->dimensions()); + t.setTranslation(v->bbox->min()); g->setChildTransform(t); } else { g->setChildTransform(Geom::identity()); @@ -257,10 +256,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int } } - if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine t(Geom::Scale(display->bbox.x1 - display->bbox.x0, display->bbox.y1 - display->bbox.y0)); - t[4] = display->bbox.x0; - t[5] = display->bbox.y0; + if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && display->bbox) { + Geom::Affine t = Geom::Scale(display->bbox->dimensions()); + t.setTranslation(display->bbox->min()); ai->setChildTransform(t); } ai->setStyle(this->style); @@ -287,42 +285,26 @@ void SPClipPath::hide(unsigned int key) g_assert_not_reached(); } -void SPClipPath::setBBox(unsigned int key, NRRect *bbox) +void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) { for (SPClipPathView *v = display; v != NULL; v = v->next) { if (v->key == key) { - if (!Geom::are_near(v->bbox.x0, bbox->x0) || - !Geom::are_near(v->bbox.y0, bbox->y0) || - !Geom::are_near(v->bbox.x1, bbox->x1) || - !Geom::are_near(v->bbox.y1, bbox->y1)) { - v->bbox = *bbox; - } + v->bbox = bbox; break; } } } -void SPClipPath::getBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) { SPObject *i = 0; - for (i = firstChild(); i && !SP_IS_ITEM(i); i = i->getNext()) { - } - if (!i) { - return; - } - - SP_ITEM(i)->invoke_bbox_full( bbox, Geom::Affine(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); - SPObject *i_start = i; - - while (i != NULL) { - if (i != i_start) { - NRRect i_box; - SP_ITEM(i)->invoke_bbox_full( &i_box, Geom::Affine(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); - nr_rect_d_union (bbox, bbox, &i_box); - } - i = i->getNext(); - for (; i && !SP_IS_ITEM(i); i = i->getNext()){}; + Geom::OptRect bbox; + for (i = firstChild(); i; i = i->getNext()) { + if (!SP_IS_ITEM(i)) continue; + Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform); + bbox.unionWith(tmp); } + return bbox; } /* ClipPath views */ @@ -335,8 +317,7 @@ sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::D new_path_view->next = list; new_path_view->key = key; new_path_view->arenaitem = arenaitem; - new_path_view->bbox.x0 = new_path_view->bbox.x1 = 0.0; - new_path_view->bbox.y0 = new_path_view->bbox.y1 = 0.0; + new_path_view->bbox = Geom::OptRect(); return new_path_view; } diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 11817eb77..c151851d3 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -43,8 +43,8 @@ public: Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned int key); void hide(unsigned int key); - void setBBox(unsigned int key, NRRect *bbox); - void getBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags); + void setBBox(unsigned int key, Geom::OptRect const &bbox); + Geom::OptRect geometricBounds(Geom::Affine const &transform); private: static void init(SPClipPath *clippath); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index ea8079bba..bd73a65c9 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -46,7 +46,7 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D static void sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_flowtext_set(SPObject *object, unsigned key, gchar const *value); -static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_flowtext_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_flowtext_description(SPItem *item); static void sp_flowtext_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); @@ -176,20 +176,19 @@ static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) group->rebuildLayout(); - NRRect paintbox; - group->invoke_bbox( &paintbox, Geom::identity(), TRUE); + Geom::OptRect pbox = group->geometricBounds(); for (SPItemView *v = group->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); group->_clearFlow(g); g->setStyle(object->style); // pass the bbox of the flowtext object as paintbox (used for paintserver fills) - group->layout.show(g, &paintbox); + group->layout.show(g, pbox); } } static void sp_flowtext_modified(SPObject *object, guint flags) { - SPObject *ft = SP_FLOWTEXT (object); + SPObject *ft = object; SPObject *region = NULL; if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -198,13 +197,12 @@ static void sp_flowtext_modified(SPObject *object, guint flags) // FIXME: the below stanza is copied over from sp_text_modified, consider factoring it out if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPFlowtext *text = SP_FLOWTEXT(object); - NRRect paintbox; - text->invoke_bbox( &paintbox, Geom::identity(), TRUE); + Geom::OptRect pbox = text->geometricBounds(); for (SPItemView* v = text->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); text->_clearFlow(g); g->setStyle(object->style); - text->layout.show(g, &paintbox); + text->layout.show(g, pbox); } } @@ -329,53 +327,33 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D return repr; } -static void -sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static Geom::OptRect +sp_flowtext_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { SPFlowtext *group = SP_FLOWTEXT(item); - group->layout.getBoundingBox(bbox, transform); + Geom::OptRect bbox = group->layout.bounds(transform); // Add stroke width - SPStyle* style = item->style; - if ( !style->stroke.isNone() ) { - double const scale = transform.descrim(); - if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - double const width = MAX(0.125, style->stroke_width.computed * scale); - if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { - bbox->x0-=0.5*width; - bbox->x1+=0.5*width; - bbox->y0-=0.5*width; - bbox->y1+=0.5*width; - } - } + // FIXME this code is incorrect + if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + double scale = transform.descrim(); + bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } + return bbox; } static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx) { SPFlowtext *group = SP_FLOWTEXT(item); + Geom::OptRect pbox, bbox, dbox; - NRRect pbox; - item->invoke_bbox( &pbox, Geom::identity(), TRUE); - NRRect bbox; - Geom::OptRect bbox_maybe = item->getBboxDesktop(); - if (!bbox_maybe) { - return; - } - bbox.x0 = bbox_maybe->min()[Geom::X]; - bbox.y0 = bbox_maybe->min()[Geom::Y]; - bbox.x1 = bbox_maybe->max()[Geom::X]; - bbox.y1 = bbox_maybe->max()[Geom::Y]; - - NRRect dbox; - dbox.x0 = 0.0; - dbox.y0 = 0.0; - dbox.x1 = item->document->getWidth(); - dbox.y1 = item->document->getHeight(); + pbox = item->geometricBounds(); + bbox = item->desktopVisualBounds(); + dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions()); Geom::Affine const ctm (item->i2dt_affine()); - group->layout.print(ctx, &pbox, &dbox, &bbox, ctm); + group->layout.print(ctx, pbox, dbox, bbox, ctm); } @@ -417,9 +395,8 @@ sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned/* key*/, uns flowed->setStyle(group->style); // pass the bbox of the flowtext object as paintbox (used for paintserver fills) - NRRect paintbox; - item->invoke_bbox( &paintbox, Geom::identity(), TRUE); - group->layout.show(flowed, &paintbox); + Geom::OptRect bbox = group->geometricBounds(); + group->layout.show(flowed, bbox); return flowed; } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 5f398b10e..3ae2b6e63 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -80,7 +80,7 @@ static void sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags); static void sp_image_modified (SPObject *object, unsigned int flags); static Inkscape::XML::Node *sp_image_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_image_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_image_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_image_description (SPItem * item); static void sp_image_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); @@ -1062,21 +1062,16 @@ static Inkscape::XML::Node *sp_image_write( SPObject *object, Inkscape::XML::Doc return repr; } -static void sp_image_bbox( SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/ ) +static Geom::OptRect sp_image_bbox( SPItem const *item,Geom::Affine const &transform, SPItem::BBoxType type ) { SPImage const &image = *SP_IMAGE(item); + Geom::OptRect bbox; if ((image.width.computed > 0.0) && (image.height.computed > 0.0)) { - double const x0 = image.x.computed; - double const y0 = image.y.computed; - double const x1 = x0 + image.width.computed; - double const y1 = y0 + image.height.computed; - - nr_rect_union_pt(bbox, Geom::Point(x0, y0) * transform); - nr_rect_union_pt(bbox, Geom::Point(x1, y0) * transform); - nr_rect_union_pt(bbox, Geom::Point(x1, y1) * transform); - nr_rect_union_pt(bbox, Geom::Point(x0, y1) * transform); + bbox = Geom::Rect::from_xywh(image.x.computed, image.y.computed, image.width.computed, image.height.computed); + *bbox *= transform; } + return bbox; } static void sp_image_print( SPItem *item, SPPrintContext *ctx ) @@ -1499,10 +1494,8 @@ static void sp_image_set_curve( SPImage *image ) image->curve = image->curve->unref(); } } else { - NRRect rect; - sp_image_bbox(image, &rect, Geom::identity(), 0); - Geom::Rect rect2 = *to_2geom(&rect); - SPCurve *c = SPCurve::new_from_rect(rect2, true); + Geom::OptRect rect = sp_image_bbox(image, Geom::identity(), SPItem::VISUAL_BBOX); + SPCurve *c = SPCurve::new_from_rect(*rect, true); if (image->curve) { image->curve = image->curve->unref(); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index f8ab0460a..ada980b3e 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -65,7 +65,7 @@ static void sp_group_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_group_set(SPObject *object, unsigned key, char const *value); -static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_group_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_group_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_group_description (SPItem * item); static Inkscape::DrawingItem *sp_group_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); @@ -274,10 +274,10 @@ static Inkscape::XML::Node * sp_group_write(SPObject *object, Inkscape::XML::Doc return repr; } -static void -sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) +static Geom::OptRect +sp_group_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { - SP_GROUP(item)->group->calculateBBox(bbox, transform, flags); + return SP_GROUP(item)->group->bounds(type, transform); } static void @@ -696,9 +696,9 @@ void CGroup::onModified(guint flags) { } } -void CGroup::calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags) { - - Geom::OptRect dummy_bbox; +Geom::OptRect CGroup::bounds(SPItem::BBoxType type, Geom::Affine const &transform) +{ + Geom::OptRect bbox; GSList *l = _group->childList(false, SPObject::ActionBBox); while (l) { @@ -706,12 +706,11 @@ void CGroup::calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { SPItem *child = SP_ITEM(o); Geom::Affine const ct(child->transform * transform); - child->invoke_bbox_full( dummy_bbox, ct, flags, FALSE); + bbox |= child->bounds(type, transform); } l = g_slist_remove (l, o); } - - *bbox = NRRect(dummy_bbox); + return bbox; } void CGroup::onPrint(SPPrintContext *ctx) { diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 99f375e44..f56192925 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -69,7 +69,7 @@ public: virtual void onChildRemoved(Inkscape::XML::Node *child); virtual void onUpdate(SPCtx *ctx, unsigned int flags); virtual void onModified(guint flags); - virtual void calculateBBox(NRRect *bbox, Geom::Affine const &transform, unsigned const flags); + virtual Geom::OptRect bounds(SPItem::BBoxType type, Geom::Affine const &transform); virtual void onPrint(SPPrintContext *ctx); virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); virtual gchar *getDescription(); diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 9f166e718..749a32d52 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -39,7 +39,7 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale) { - Geom::OptRect bbox = item->getBboxDesktop(); + Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { Geom::Translate const s(bbox->midpoint()); // use getCenter? item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 07ce73c4b..a2a603c68 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -253,7 +253,7 @@ bool SPItem::isExplicitlyHidden() const * Sets the display CSS property to `hidden' if \a val is true, * otherwise makes it unset */ -void SPItem::setExplicitlyHidden(bool const val) { +void SPItem::setExplicitlyHidden(bool val) { style->display.set = val; style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE ); style->display.computed = style->display.value; @@ -263,17 +263,17 @@ void SPItem::setExplicitlyHidden(bool const val) { /** * Sets the transform_center_x and transform_center_y properties to retain the rotation centre */ -void SPItem::setCenter(Geom::Point object_centre) { - // for getBounds() to work +void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(i2dt_affine()); + // FIXME this is seriously wrong + Geom::OptRect bbox = desktopGeometricBounds(); if (bbox) { transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; - if (fabs(transform_center_x) < 1e-5) // rounding error + if (Geom::are_near(transform_center_x, 0)) // rounding error transform_center_x = 0; transform_center_y = object_centre[Geom::Y] - bbox->midpoint()[Geom::Y]; - if (fabs(transform_center_y) < 1e-5) // rounding error + if (Geom::are_near(transform_center_y, 0)) // rounding error transform_center_y = 0; } } @@ -289,10 +289,10 @@ bool SPItem::isCenterSet() { } Geom::Point SPItem::getCenter() const { - // for getBounds() to work document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(i2dt_affine()); + // FIXME this is seriously wrong + Geom::OptRect bbox = desktopGeometricBounds(); if (bbox) { return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y); } else { @@ -515,8 +515,7 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) } } if (SP_IS_CLIPPATH(clip)) { - NRRect bbox; - item->invoke_bbox( &bbox, Geom::identity(), TRUE); + Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); @@ -525,7 +524,7 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setClip(ai); - SP_CLIPPATH(clip)->setBBox(v->arenaitem->key(), &bbox); + SP_CLIPPATH(clip)->setBBox(v->arenaitem->key(), bbox); clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -540,8 +539,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } if (SP_IS_MASK(mask)) { - NRRect bbox; - item->invoke_bbox( &bbox, Geom::identity(), TRUE); + Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); @@ -550,7 +548,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setMask(ai); - sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), &bbox); + sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -575,16 +573,15 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) SPMask *mask = item->mask_ref ? item->mask_ref->getObject() : NULL; if ( clip_path || mask ) { - NRRect bbox; - item->invoke_bbox( &bbox, Geom::identity(), TRUE); + Geom::OptRect bbox = item->geometricBounds(); if (clip_path) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - clip_path->setBBox(v->arenaitem->key(), &bbox); + clip_path->setBBox(v->arenaitem->key(), bbox); } } if (mask) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_set_bbox(mask, v->arenaitem->key(), &bbox); + sp_mask_set_bbox(mask, v->arenaitem->key(), bbox); } } } @@ -599,8 +596,7 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) /* Update bounding box data used by filters */ if (item->style->filter.set && item->display) { - Geom::OptRect item_bbox; - item->invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); + Geom::OptRect item_bbox = item->geometricBounds(); SPItemView *itemview = item->display; do { @@ -677,169 +673,132 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML return repr; } -/** - * \return There is no guarantee that the return value will contain a rectangle. - If this item does not have a boundingbox, it might well be empty. - */ -Geom::OptRect SPItem::getBounds(Geom::Affine const &transform, - SPItem::BBoxType type, - unsigned int /*dkey*/) const -{ - Geom::OptRect r; - invoke_bbox_full( r, transform, type, TRUE); - return r; -} - -void SPItem::invoke_bbox( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type) -{ - invoke_bbox_full( bbox, transform, type, clear); -} - -// DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect -void SPItem::invoke_bbox( NRRect *bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type) +/** @brief Get item's geometric bounding box in this item's coordinate system. + * The geometric bounding box includes only the path, disregarding all style attributes. */ +Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const { - invoke_bbox_full( bbox, transform, type, clear); + Geom::OptRect bbox; + // call the subclass method + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { + bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::GEOMETRIC_BBOX); + } + return bbox; } -/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and - * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the - * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups, - * clones), in turn, call this function in their bbox methods. - * \retval bbox Note that there is no guarantee that bbox will contain a rectangle when the - * function returns. If this item does not have a boundingbox, this might well be empty. - */ -void SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) const +/** @brief Get item's visual bounding box in this item's coordinate system. + * The visual bounding box includes the stroke and the filter region. */ +Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const { - if (clear) { - bbox = Geom::OptRect(); - } - - // TODO: replace NRRect by Geom::Rect, for all SPItemClasses, and for SP_CLIPPATH + using Geom::X; + using Geom::Y; - NRRect temp_bbox; - temp_bbox.x0 = temp_bbox.y0 = Geom::infinity(); - temp_bbox.x1 = temp_bbox.y1 = -Geom::infinity(); + Geom::OptRect bbox; - // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &temp_bbox, transform, flags); - } - - // unless this is geometric bbox, extend by filter area and crop the bbox by clip path, if any - if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX) { - if ( style && style->filter.href) { - SPObject *filter = style->getFilter(); - if (filter && SP_IS_FILTER(filter)) { - // default filer area per the SVG spec: - double x = -0.1; - double y = -0.1; - double w = 1.2; - double h = 1.2; - - // if area is explicitly set, override: - if (SP_FILTER(filter)->x._set) - x = SP_FILTER(filter)->x.computed; - if (SP_FILTER(filter)->y._set) - y = SP_FILTER(filter)->y.computed; - if (SP_FILTER(filter)->width._set) - w = SP_FILTER(filter)->width.computed; - if (SP_FILTER(filter)->height._set) - h = SP_FILTER(filter)->height.computed; - - double dx0 = 0; - double dx1 = 0; - double dy0 = 0; - double dy1 = 0; - if (filter_is_single_gaussian_blur(SP_FILTER(filter))) { - // if this is a single blur, use 2.4*radius - // which may be smaller than the default area; - // see set_filter_area for why it's 2.4 - double r = get_single_gaussian_blur_radius (SP_FILTER(filter)); - dx0 = -2.4 * r; - dx1 = 2.4 * r; - dy0 = -2.4 * r; - dy1 = 2.4 * r; - } else { - // otherwise, calculate expansion from relative to absolute units: - dx0 = x * (temp_bbox.x1 - temp_bbox.x0); - dx1 = (w + x - 1) * (temp_bbox.x1 - temp_bbox.x0); - dy0 = y * (temp_bbox.y1 - temp_bbox.y0); - dy1 = (h + y - 1) * (temp_bbox.y1 - temp_bbox.y0); - } + if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) { + // call the subclass method + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { + bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX); + } - // transform the expansions by the item's transform: - Geom::Affine i2dt(i2dt_affine ()); - dx0 *= i2dt.expansionX(); - dx1 *= i2dt.expansionX(); - dy0 *= i2dt.expansionY(); - dy1 *= i2dt.expansionY(); - - // expand the bbox - temp_bbox.x0 += dx0; - temp_bbox.x1 += dx1; - temp_bbox.y0 += dy0; - temp_bbox.y1 += dy1; - } + SPFilter *filter = SP_FILTER(style->getFilter()); + // default filer area per the SVG spec: + SVGLength x, y, w, h; + Geom::Point minp, maxp; + x.set(SVGLength::PERCENT, -0.10, 0); + y.set(SVGLength::PERCENT, -0.10, 0); + w.set(SVGLength::PERCENT, 1.20, 0); + h.set(SVGLength::PERCENT, 1.20, 0); + + // if area is explicitly set, override: + if (filter->x._set) + x = filter->x; + if (filter->y._set) + y = filter->y; + if (filter->width._set) + w = filter->width; + if (filter->height._set) + h = filter->height; + + double len_x = bbox ? bbox->width() : 0; + double len_y = bbox ? bbox->height() : 0; + + x.update(12, 6, len_x); + y.update(12, 6, len_y); + w.update(12, 6, len_x); + h.update(12, 6, len_y); + + if (filter->filterUnits == SP_FILTER_UNITS_OBJECTBOUNDINGBOX && bbox) { + minp[X] = bbox->left() + x.computed * (x.unit == SVGLength::PERCENT ? 1.0 : len_x); + maxp[X] = minp[X] + w.computed * (w.unit == SVGLength::PERCENT ? 1.0 : len_x); + minp[Y] = bbox->top() + y.computed * (y.unit == SVGLength::PERCENT ? 1.0 : len_y); + maxp[Y] = minp[Y] + h.computed * (h.unit == SVGLength::PERCENT ? 1.0 : len_y); + } else if (filter->filterUnits == SP_FILTER_UNITS_USERSPACEONUSE) { + minp[X] = x.computed; + maxp[X] = minp[X] + w.computed; + minp[Y] = y.computed; + maxp[Y] = minp[Y] + h.computed; } - if (clip_ref->getObject()) { - NRRect b; - SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags); - nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b); + bbox = Geom::OptRect(minp, maxp); + *bbox *= transform; + } else { + // call the subclass method + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { + bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::VISUAL_BBOX); } } - - if (temp_bbox.x0 > temp_bbox.x1 || temp_bbox.y0 > temp_bbox.y1) { - // Either the bbox hasn't been touched by the SPItemClass' bbox method - // (it still has its initial values, see above: x0 = y0 = Geom::infinity() and x1 = y1 = -Geom::infinity()) - // or it has explicitely been set to be like this (e.g. in sp_shape_bbox) - - // When x0 > x1 or y0 > y1, the bbox is considered to be "nothing", although it has not been - // explicitely defined this way for NRRects (as opposed to Geom::OptRect) - // So union bbox with nothing = do nothing, just return - return; + if (clip_ref->getObject()) { + bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform)); } - // Do not use temp_bbox.upgrade() here, because it uses a test that returns an empty Geom::OptRect() - // for any rectangle with zero area. The geometrical bbox of for example a vertical line - // would therefore be translated into empty Geom::OptRect() (see bug https://bugs.launchpad.net/inkscape/+bug/168684) - Geom::OptRect temp_bbox_new = Geom::Rect(Geom::Point(temp_bbox.x0, temp_bbox.y0), Geom::Point(temp_bbox.x1, temp_bbox.y1)); - - bbox.unionWith(temp_bbox_new); + return bbox; } - -// DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect -/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and - * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the - * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups, - * clones), in turn, call this function in their bbox methods. */ -void SPItem::invoke_bbox_full( NRRect *bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) +Geom::OptRect SPItem::bounds(BBoxType type, Geom::Affine const &transform) const { - g_assert(bbox != NULL); - - if (clear) { - bbox->x0 = bbox->y0 = 1e18; - bbox->x1 = bbox->y1 = -1e18; - } - - NRRect this_bbox; - this_bbox.x0 = this_bbox.y0 = 1e18; - this_bbox.x1 = this_bbox.y1 = -1e18; - - // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &this_bbox, transform, flags); + if (type == GEOMETRIC_BBOX) { + return geometricBounds(transform); + } else { + return visualBounds(transform); } +} - // unless this is geometric bbox, crop the bbox by clip path, if any - if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && clip_ref->getObject()) { - NRRect b; - SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags); - nr_rect_d_intersect (&this_bbox, &this_bbox, &b); +/** Get item's geometric bbox in document coordinate system. + * Document coordinates are the default coordinates of the root element: + * the origin is at the top left, X grows to the right and Y grows downwards. */ +Geom::OptRect SPItem::documentGeometricBounds() const +{ + return geometricBounds(i2doc_affine()); +} +/// Get item's visual bbox in document coordinate system. +Geom::OptRect SPItem::documentVisualBounds() const +{ + return visualBounds(i2doc_affine()); +} +Geom::OptRect SPItem::documentBounds(BBoxType type) const +{ + if (type == GEOMETRIC_BBOX) { + return documentGeometricBounds(); + } else { + return documentVisualBounds(); } - - // if non-empty (with some tolerance - ?) union this_bbox with the bbox we've got passed - if ( fabs(this_bbox.x1-this_bbox.x0) > -0.00001 && fabs(this_bbox.y1-this_bbox.y0) > -0.00001 ) { - nr_rect_d_union (bbox, bbox, &this_bbox); +} +/** Get item's geometric bbox in desktop coordinate system. + * Desktop coordinates should be user defined. Currently they are hardcoded: + * origin is at bottom left, X grows to the right and Y grows upwards. */ +Geom::OptRect SPItem::desktopGeometricBounds() const +{ + return geometricBounds(i2dt_affine()); +} +/// Get item's visual bbox in desktop coordinate system. +Geom::OptRect SPItem::desktopVisualBounds() const +{ + return visualBounds(i2dt_affine()); +} +Geom::OptRect SPItem::desktopBounds(BBoxType type) const +{ + if (type == GEOMETRIC_BBOX) { + return desktopGeometricBounds(); + } else { + return desktopVisualBounds(); } } @@ -864,20 +823,6 @@ unsigned SPItem::pos_in_parent() return 0; } -void SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) -{ - g_assert(bbox != NULL); - - invoke_bbox( bbox, i2dt_affine(), TRUE, type); -} - -Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) -{ - Geom::OptRect rect = Geom::OptRect(); - invoke_bbox( rect, i2dt_affine(), TRUE, type); - return rect; -} - void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { /* This will only be called if the derived class doesn't override this. @@ -1011,6 +956,8 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned } if (ai != NULL) { + Geom::OptRect item_bbox = geometricBounds(); + display = sp_item_view_new_prepend(display, this, flags, key, ai); ai->setTransform(transform); ai->setOpacity(SP_SCALE24_TO_FLOAT(style->opacity.value)); @@ -1029,9 +976,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned ai->setClip(ac); // Update bbox, in case the clip uses bbox units - NRRect bbox; - invoke_bbox( &bbox, Geom::identity(), TRUE); - SP_CLIPPATH(cp)->setBBox(clip_key, &bbox); + SP_CLIPPATH(cp)->setBBox(clip_key, item_bbox); cp->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } if (mask_ref->getObject()) { @@ -1047,14 +992,10 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned ai->setMask(ac); // Update bbox, in case the mask uses bbox units - NRRect bbox; - invoke_bbox( &bbox, Geom::identity(), TRUE); - sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox); + sp_mask_set_bbox(SP_MASK(mask), mask_key, item_bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } ai->setData(this); - Geom::OptRect item_bbox; - invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); ai->setItemBounds(item_bbox); } @@ -1544,10 +1485,8 @@ SPItem *sp_item_first_item_child(SPObject *obj) void SPItem::convert_to_guides() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); - SPItem::BBoxType bbox_type = (prefs_bbox ==0)? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; - Geom::OptRect bbox = getBboxDesktop(bbox_type); + Geom::OptRect bbox = (prefs_bbox == 0) ? desktopVisualBounds() : desktopGeometricBounds(); if (!bbox) { g_warning ("Cannot determine item's bounding box during conversion to guides.\n"); return; diff --git a/src/sp-item.h b/src/sp-item.h index 633deb508..62336e3c8 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -112,7 +112,7 @@ public: // includes only the bare path bbox, no stroke, no nothing GEOMETRIC_BBOX, // includes everything: correctly done stroke (with proper miters and caps), markers, filter margins (e.g. blur) - RENDERING_BBOX + VISUAL_BBOX }; unsigned int sensitive : 1; @@ -151,7 +151,7 @@ public: void setExplicitlyHidden(bool val); - void setCenter(Geom::Point object_centre); + void setCenter(Geom::Point const &object_centre); void unsetCenter(); bool isCenterSet(); Geom::Point getCenter() const; @@ -167,15 +167,19 @@ public: void raiseToTop(); void lowerToBottom(); - Geom::OptRect getBounds(Geom::Affine const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; - sigc::connection connectTransformed(sigc::slot slot) { return _transformed_signal.connect(slot); } - void invoke_bbox( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); - void invoke_bbox( NRRect *bbox, Geom::Affine const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); - void invoke_bbox_full( Geom::OptRect &bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) const; - void invoke_bbox_full( NRRect *bbox, Geom::Affine const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); + + Geom::OptRect geometricBounds(Geom::Affine const &transform = Geom::identity()) const; + Geom::OptRect visualBounds(Geom::Affine const &transform = Geom::identity()) const; + Geom::OptRect bounds(BBoxType type, Geom::Affine const &transform = Geom::identity()) const; + Geom::OptRect documentGeometricBounds() const; + Geom::OptRect documentVisualBounds() const; + Geom::OptRect documentBounds(BBoxType type) const; + Geom::OptRect desktopGeometricBounds() const; + Geom::OptRect desktopVisualBounds() const; + Geom::OptRect desktopBounds(BBoxType type) const; unsigned pos_in_parent(); gchar *description(); @@ -195,8 +199,7 @@ public: void convert_item_to_guides(); gint emitEvent (SPEvent &event); Inkscape::DrawingItem *get_arenaitem(unsigned int key); - void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); - Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + Geom::Affine i2doc_affine() const; Geom::Affine i2dt_affine() const; void set_i2d_affine(Geom::Affine const &transform); @@ -237,7 +240,7 @@ public: SPObjectClass parent_class; /** BBox union in given coordinate system */ - void (* bbox) (SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); + Geom::OptRect (* bbox) (SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); /** Printing method. Assumes ctm is set to item affine matrix */ /* \todo Think about it, and maybe implement generic export method instead (Lauris) */ diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index f23172a17..f955e5428 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -31,7 +31,7 @@ struct SPMaskView { SPMaskView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; static void sp_mask_class_init (SPMaskClass *klass); @@ -216,10 +216,9 @@ static void sp_mask_update(SPObject *object, SPCtx *ctx, guint flags) SPMask *mask = SP_MASK(object); for (SPMaskView *v = mask->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); - if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); - t[4] = v->bbox.x0; - t[5] = v->bbox.y0; + if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) { + Geom::Affine t = Geom::Scale(v->bbox->dimensions()); + t.setTranslation(v->bbox->min()); g->setChildTransform(t); } else { g->setChildTransform(Geom::identity()); @@ -314,11 +313,10 @@ Inkscape::DrawingItem *sp_mask_show(SPMask *mask, Inkscape::Drawing &drawing, un } } - if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine t(Geom::Scale(mask->display->bbox.x1 - mask->display->bbox.x0, mask->display->bbox.y1 - mask->display->bbox.y0)); - t[4] = mask->display->bbox.x0; - t[5] = mask->display->bbox.y0; - ai->setChildTransform(t); + if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) { + Geom::Affine t = Geom::Scale(mask->display->bbox->dimensions()); + t.setTranslation(mask->display->bbox->min()); + ai->setChildTransform(t); } return ai; @@ -347,17 +345,12 @@ void sp_mask_hide(SPMask *cp, unsigned int key) } void -sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox) +sp_mask_set_bbox (SPMask *mask, unsigned int key, Geom::OptRect const &bbox) { for (SPMaskView *v = mask->display; v != NULL; v = v->next) { if (v->key == key) { - if (!Geom::are_near(v->bbox.x0, bbox->x0) || - !Geom::are_near(v->bbox.y0, bbox->y0) || - !Geom::are_near(v->bbox.x1, bbox->x1) || - !Geom::are_near(v->bbox.y1, bbox->y1)) { - v->bbox = *bbox; - } - break; + v->bbox = bbox; + break; } } } @@ -372,8 +365,7 @@ sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingI new_mask_view->next = list; new_mask_view->key = key; new_mask_view->arenaitem = arenaitem; - new_mask_view->bbox.x0 = new_mask_view->bbox.x1 = 0.0; - new_mask_view->bbox.y0 = new_mask_view->bbox.y1 = 0.0; + new_mask_view->bbox = Geom::OptRect(); return new_mask_view; } diff --git a/src/sp-mask.h b/src/sp-mask.h index b1048e6be..d493c2dc7 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -13,6 +13,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/rect.h> +#include "display/display-forward.h" +#include "libnr/nr-forward.h" +#include "sp-object-group.h" +#include "uri-references.h" +#include "xml/node.h" + #define SP_TYPE_MASK (sp_mask_get_type ()) #define SP_MASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_MASK, SPMask)) #define SP_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_MASK, SPMaskClass)) @@ -23,12 +30,6 @@ class SPMask; class SPMaskClass; class SPMaskView; -#include "display/display-forward.h" -#include "libnr/nr-forward.h" -#include "sp-object-group.h" -#include "uri-references.h" -#include "xml/node.h" - struct SPMask : public SPObjectGroup { unsigned int maskUnits_set : 1; unsigned int maskUnits : 1; @@ -93,7 +94,7 @@ protected: Inkscape::DrawingItem *sp_mask_show (SPMask *mask, Inkscape::Drawing &drawing, unsigned int key); void sp_mask_hide (SPMask *mask, unsigned int key); -void sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox); +void sp_mask_set_bbox (SPMask *mask, unsigned int key, Geom::OptRect const &bbox); const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 5187ff027..8617c096a 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -514,7 +514,7 @@ sp_offset_set_shape(SPShape *shape) theRes->ConvertToForme (orig, 1, originaux); SPItem *item = shape; - Geom::OptRect bbox = item->getBboxDesktop (); + Geom::OptRect bbox = item->desktopVisualBounds(); if ( bbox ) { gdouble size = L2(bbox->dimensions()); gdouble const exp = item->transform.descrim(); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 4fd1deb69..15fa76d65 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -502,212 +502,158 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) * Calculates the bounding box for item, storing it into bbox. * This also includes the bounding boxes of any markers included in the shape. */ -void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) +Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType bboxtype) { SPShape const *shape = SP_SHAPE (item); - SPItem::BBoxType bboxtype = (SPItem::BBoxType) flags; - - if (shape->curve) { - Geom::OptRect geombbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform); - if (geombbox) { - NRRect cbbox; - cbbox.x0 = (*geombbox)[0][0]; - cbbox.y0 = (*geombbox)[1][0]; - cbbox.x1 = (*geombbox)[0][1]; - cbbox.y1 = (*geombbox)[1][1]; - - switch (bboxtype) { - case SPItem::GEOMETRIC_BBOX: { - // do nothing - break; - } - case SPItem::RENDERING_BBOX: { - // convert the stroke to a path and calculate that path's geometric bbox - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - Geom::PathVector *pathv = item_outline(item); - if (pathv) { - Geom::OptRect geomstrokebbox = bounds_exact_transformed(*pathv, transform); - if (geomstrokebbox) { - NRRect strokebbox; - strokebbox.x0 = (*geomstrokebbox)[0][0]; - strokebbox.y0 = (*geomstrokebbox)[1][0]; - strokebbox.x1 = (*geomstrokebbox)[0][1]; - strokebbox.y1 = (*geomstrokebbox)[1][1]; - nr_rect_d_union (&cbbox, &cbbox, &strokebbox); - } - delete pathv; + Geom::OptRect bbox; + + if (!shape->curve) return bbox; + bbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform); + if (!bbox) return bbox; + + if (bboxtype == SPItem::VISUAL_BBOX) { + // convert the stroke to a path and calculate that path's geometric bbox + SPStyle* style = item->style; + if (!style->stroke.isNone()) { + Geom::PathVector *pathv = item_outline(item); + if (pathv) { + bbox |= bounds_exact_transformed(*pathv, transform); + delete pathv; + } + } + // Union with bboxes of the markers, if any + if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) { + /** \todo make code prettier! */ + Geom::PathVector const & pathv = shape->curve->get_pathvector(); + // START marker + for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + SPItem* marker_item = sp_item_first_item_child( marker ); + + if (marker_item) { + Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; } + + // total marker transform + tr = marker_item->transform * marker->c2p * tr * transform; + + // get bbox of the marker with that transform + bbox |= marker_item->visualBounds(tr); } - break; } - default: - case SPItem::APPROXIMATE_BBOX: { - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - double const scale = transform.descrim(); - if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - double const width = MAX(0.125, style->stroke_width.computed * scale); - if ( fabs(cbbox.x1-cbbox.x0) > -0.00001 && fabs(cbbox.y1-cbbox.y0) > -0.00001 ) { - cbbox.x0-=0.5*width; - cbbox.x1+=0.5*width; - cbbox.y0-=0.5*width; - cbbox.y1+=0.5*width; - } + } + // MID marker + for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID + SPMarker* marker = SP_MARKER (shape->marker[i]); + if ( !shape->marker[i] ) continue; + SPItem* marker_item = sp_item_first_item_child( marker ); + if ( !marker_item ) continue; + + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + // START position + if ( path_it != pathv.begin() + && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there + { + Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front())); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; + } + tr = marker_item->transform * marker->c2p * tr * transform; + bbox |= marker_item->visualBounds(tr); } + // MID position + if ( path_it->size_default() > 1) { + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + while (curve_it2 != path_it->end_default()) + { + /* Put marker between curve_it1 and curve_it2. + * Loop to end_default (so including closing segment), because when a path is closed, + * there should be a midpoint marker between last segment and closing straight line segment */ - // Union with bboxes of the markers, if any - if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) { - /** \todo make code prettier! */ - Geom::PathVector const & pathv = shape->curve->get_pathvector(); - // START marker - for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child( marker ); - - if (marker_item) { - Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - - // total marker transform - tr = marker_item->transform * marker->c2p * tr * transform; - - // get bbox of the marker with that transform - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - // union it with the shape bbox - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - } - } - // MID marker - for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID SPMarker* marker = SP_MARKER (shape->marker[i]); - if ( !shape->marker[i] ) continue; SPItem* marker_item = sp_item_first_item_child( marker ); - if ( !marker_item ) continue; - - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - // START position - if ( path_it != pathv.begin() - && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there - { - Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front())); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - tr = marker_item->transform * marker->c2p * tr * transform; - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - // MID position - if ( path_it->size_default() > 1) { - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - while (curve_it2 != path_it->end_default()) - { - /* Put marker between curve_it1 and curve_it2. - * Loop to end_default (so including closing segment), because when a path is closed, - * there should be a midpoint marker between last segment and closing straight line segment */ - - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child( marker ); - - if (marker_item) { - Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - tr = marker_item->transform * marker->c2p * tr * transform; - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - - ++curve_it1; - ++curve_it2; - } + + if (marker_item) { + Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } - // END position - if ( path_it != (pathv.end()-1) && !path_it->empty()) { - Geom::Curve const &lastcurve = path_it->back_default(); - Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - tr = marker_item->transform * marker->c2p * tr * transform; - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; } + tr = marker_item->transform * marker->c2p * tr * transform; + bbox |= marker_item->visualBounds(tr); } + + ++curve_it1; + ++curve_it2; } - // END marker - for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child( marker ); - - if (marker_item) { - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - Geom::Path const &path_last = pathv.back(); - unsigned int index = path_last.size_default(); - if (index > 0) { - index--; - } - Geom::Curve const &lastcurve = path_last[index]; - - Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - - // total marker transform - tr = marker_item->transform * marker->c2p * tr * transform; - - // get bbox of the marker with that transform - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - // union it with the shape bbox - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - } + } + // END position + if ( path_it != (pathv.end()-1) && !path_it->empty()) { + Geom::Curve const &lastcurve = path_it->back_default(); + Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; } + tr = marker_item->transform * marker->c2p * tr * transform; + bbox |= marker_item->visualBounds(); } - break; - } // end case approximate bbox type - } // end switch bboxtype + } + } + // END marker + for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + SPItem* marker_item = sp_item_first_item_child( marker ); + + if (marker_item) { + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; + + Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; + } - // copy our bbox to the variable we're given - *bbox = cbbox; + // total marker transform + tr = marker_item->transform * marker->c2p * tr * transform; + + // get bbox of the marker with that transform + bbox |= marker_item->visualBounds(tr); + } + } + } } } + return bbox; } static void @@ -736,7 +682,7 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* s void sp_shape_print (SPItem *item, SPPrintContext *ctx) { - NRRect pbox, dbox, bbox; + Geom::OptRect pbox, dbox, bbox; SPShape *shape = SP_SHAPE(item); @@ -755,22 +701,19 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) } /* fixme: Think (Lauris) */ - item->invoke_bbox( &pbox, Geom::identity(), TRUE); - dbox.x0 = 0.0; - dbox.y0 = 0.0; - dbox.x1 = item->document->getWidth(); - dbox.y1 = item->document->getHeight(); - item->getBboxDesktop (&bbox); + pbox = item->geometricBounds(); + bbox = item->desktopVisualBounds(); + dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions()); Geom::Affine const i2dt(item->i2dt_affine()); SPStyle* style = item->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); + sp_print_fill (ctx, pathv, &i2dt, style, pbox, dbox, bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); + sp_print_stroke (ctx, pathv, &i2dt, style, pbox, dbox, bbox); } /** \todo make code prettier */ @@ -1184,7 +1127,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectori2dt_affine ()); if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { - Geom::OptRect bbox = item->getBounds(i2dt); + Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } diff --git a/src/sp-shape.h b/src/sp-shape.h index 355d8e7cc..06bd704ad 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -66,7 +66,7 @@ private: static void sp_shape_modified (SPObject *object, unsigned int flags); static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); + static Geom::OptRect sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static Inkscape::DrawingItem *sp_shape_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_shape_hide (SPItem *item, unsigned int key); static void sp_shape_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index bee28f8e3..71de619c1 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -39,7 +39,7 @@ static Inkscape::XML::Node *sp_symbol_write (SPObject *object, Inkscape::XML::Do static Inkscape::DrawingItem *sp_symbol_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_symbol_hide (SPItem *item, unsigned int key); -static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); static SPGroupClass *parent_class; @@ -399,18 +399,20 @@ static void sp_symbol_hide(SPItem *item, unsigned int key) } } -static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) +static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { SPSymbol const *symbol = SP_SYMBOL(item); + Geom::OptRect bbox; if (symbol->cloned) { // Cloned is actually renderable if (((SPItemClass *) (parent_class))->bbox) { Geom::Affine const a( symbol->c2p * transform ); - ((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags); + bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); } } + return bbox; } static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 9bb674843..fc248824d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -71,7 +71,7 @@ static void sp_text_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_text_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static Inkscape::DrawingItem *sp_text_show (SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); static void sp_text_hide (SPItem *item, unsigned key); static char *sp_text_description (SPItem *item); @@ -248,14 +248,13 @@ static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) /* fixme: So check modification flag everywhere immediate state is used */ text->rebuildLayout(); - NRRect paintbox; - text->invoke_bbox( &paintbox, Geom::identity(), TRUE); + Geom::OptRect paintbox = text->geometricBounds(); for (SPItemView* v = text->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); text->_clearFlow(g); g->setStyle(object->style); // pass the bbox of the text object as paintbox (used for paintserver fills) - text->layout.show(g, &paintbox); + text->layout.show(g, paintbox); } } } @@ -277,13 +276,12 @@ static void sp_text_modified(SPObject *object, guint flags) // and create new ones. This is probably quite wasteful. if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPText *text = SP_TEXT (object); - NRRect paintbox; - text->invoke_bbox( &paintbox, Geom::identity(), TRUE); + Geom::OptRect paintbox = text->geometricBounds(); for (SPItemView* v = text->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); text->_clearFlow(g); g->setStyle(object->style); - text->layout.show(g, &paintbox); + text->layout.show(g, paintbox); } } @@ -363,25 +361,17 @@ static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Docum return repr; } -static void -sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static Geom::OptRect +sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { - SP_TEXT(item)->layout.getBoundingBox(bbox, transform); - - // Add stroke width - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - double const scale = transform.descrim(); - if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - double const width = MAX(0.125, style->stroke_width.computed * scale); - if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { - bbox->x0-=0.5*width; - bbox->x1+=0.5*width; - bbox->y0-=0.5*width; - bbox->y1+=0.5*width; - } - } + Geom::OptRect bbox = SP_TEXT(item)->layout.bounds(transform); + + // FIXME this code is incorrect + if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + double scale = transform.descrim(); + bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } + return bbox; } @@ -395,9 +385,7 @@ sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned /* key*/, unsign flowed->setStyle(group->style); // pass the bbox of the text object as paintbox (used for paintserver fills) - NRRect paintbox; - item->invoke_bbox( &paintbox, Geom::identity(), TRUE); - group->layout.show(flowed, &paintbox); + group->layout.show(flowed, group->geometricBounds()); return flowed; } @@ -509,18 +497,15 @@ sp_text_set_transform (SPItem *item, Geom::Affine const &xform) static void sp_text_print (SPItem *item, SPPrintContext *ctx) { - NRRect pbox, dbox, bbox; SPText *group = SP_TEXT (item); + Geom::OptRect pbox, bbox, dbox; - item->invoke_bbox( &pbox, Geom::identity(), TRUE); - item->getBboxDesktop (&bbox); - dbox.x0 = 0.0; - dbox.y0 = 0.0; - dbox.x1 = item->document->getWidth(); - dbox.y1 = item->document->getHeight(); + pbox = item->geometricBounds(); + bbox = item->desktopVisualBounds(); + dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions()); Geom::Affine const ctm (item->i2dt_affine()); - group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); + group->layout.print(ctx,pbox,dbox,bbox,ctm); } /* diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index dcf46f6ac..ac20ce098 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -63,7 +63,7 @@ static void sp_tref_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_tref_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_tref_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static gchar *sp_tref_description(SPItem *item); static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); @@ -314,39 +314,33 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: return repr; } -/** +/* * The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way */ -static void -sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static Geom::OptRect +sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = item; while ( parent_text && !SP_IS_TEXT(parent_text) ) { parent_text = parent_text->parent; } if (parent_text == NULL) { - return; + return bbox; } // get the bbox of our portion of the layout - SP_TEXT(parent_text)->layout.getBoundingBox( - bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + bbox = SP_TEXT(parent_text)->layout.bounds(transform, + sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); // Add stroke width - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - double const scale = transform.descrim(); - if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - double const width = MAX(0.125, style->stroke_width.computed * scale); - if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { - bbox->x0-=0.5*width; - bbox->x1+=0.5*width; - bbox->y0-=0.5*width; - bbox->y1+=0.5*width; - } - } + // FIXME this code is incorrect + if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + double scale = transform.descrim(); + bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } + return bbox; } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 199d82e1b..f4e79f7d5 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -56,7 +56,7 @@ static void sp_tspan_release(SPObject *object); static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value); static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_tspan_modified(SPObject *object, unsigned flags); -static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static char *sp_tspan_description (SPItem *item); @@ -203,34 +203,30 @@ static void sp_tspan_modified(SPObject *object, unsigned flags) } } -static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static Geom::OptRect +sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = item; while (parent_text && !SP_IS_TEXT(parent_text)) { parent_text = parent_text->parent; } if (parent_text == NULL) { - return; + return bbox; } // get the bbox of our portion of the layout - SP_TEXT(parent_text)->layout.getBoundingBox(bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + bbox = SP_TEXT(parent_text)->layout.bounds(transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + if (!bbox) return bbox; // Add stroke width - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - double const scale = transform.descrim(); - if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - double const width = MAX(0.125, style->stroke_width.computed * scale); - if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { - bbox->x0-=0.5*width; - bbox->x1+=0.5*width; - bbox->y0-=0.5*width; - bbox->y1+=0.5*width; - } - } + // FIXME this code is incorrect + if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + double scale = transform.descrim(); + bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } + return bbox; } static Inkscape::XML::Node * @@ -592,8 +588,7 @@ sp_textpath_to_text(SPObject *tp) { SPObject *text = tp->parent; - Geom::OptRect bbox; - SP_ITEM(text)->invoke_bbox(bbox, SP_ITEM(text)->i2doc_affine(), TRUE); + Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine()); if (!bbox) return; Geom::Point xy = bbox->min(); diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 89df9130d..057c01ef1 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -49,7 +49,7 @@ static Inkscape::XML::Node *sp_use_write(SPObject *object, Inkscape::XML::Docume static void sp_use_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_use_modified(SPObject *object, guint flags); -static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_use_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); static void sp_use_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_use_description(SPItem *item); @@ -276,10 +276,11 @@ sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:: return repr; } -static void -sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) +static Geom::OptRect +sp_use_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { SPUse const *use = SP_USE(item); + Geom::OptRect bbox; if (use->child && SP_IS_ITEM(use->child)) { SPItem *child = SP_ITEM(use->child); @@ -287,15 +288,9 @@ sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, uns * Geom::Translate(use->x.computed, use->y.computed) * transform ); - Geom::OptRect optbbox; - child->invoke_bbox_full( optbbox, ct, flags, FALSE); - if (optbbox) { - bbox->x0 = (*optbbox)[0][0]; - bbox->y0 = (*optbbox)[1][0]; - bbox->x1 = (*optbbox)[0][1]; - bbox->y1 = (*optbbox)[1][1]; - } + bbox = child->bounds(type, ct); } + return bbox; } static void diff --git a/src/splivarot.cpp b/src/splivarot.cpp index d3d6c3db7..28d6f90be 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1942,7 +1942,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, bool didSomething = false; - Geom::OptRect selectionBbox = selection->bounds(); + Geom::OptRect selectionBbox = selection->visualBounds(); if (!selectionBbox) { return false; } @@ -1963,7 +1963,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - Geom::OptRect itemBbox = item->getBounds(item->i2dt_affine()); + Geom::OptRect itemBbox = item->desktopVisualBounds(); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 33fffb01f..68b71b21f 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -444,7 +444,7 @@ bool sp_spray_recursive(SPDesktop *desktop, dr=dr*radius; if (mode == SPRAY_MODE_COPY) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { SPItem *item_copied; if(_fid <= population) @@ -496,7 +496,7 @@ bool sp_spray_recursive(SPDesktop *desktop, Inkscape::XML::Node *old_repr = father->getRepr(); Inkscape::XML::Node *parent = old_repr->parent(); - Geom::OptRect a = father->getBounds(father->i2doc_affine()); + Geom::OptRect a = father->documentVisualBounds(); if (a) { if (i == 2) { Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); @@ -534,7 +534,7 @@ bool sp_spray_recursive(SPDesktop *desktop, } } } else if (mode == SPRAY_MODE_CLONE) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { if(_fid <= population) { SPItem *item_copied; diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index d64fa749a..a4a6b231a 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -432,8 +432,7 @@ text_unflow () /* Set style */ rtext->setAttribute("style", flowtext->getRepr()->attribute("style")); // fixme: transfer style attrs too; and from descendants - Geom::OptRect bbox; - flowtext->invoke_bbox(bbox, flowtext->i2doc_affine(), TRUE); + Geom::OptRect bbox = flowtext->geometricBounds(flowtext->i2doc_affine()); if (bbox) { Geom::Point xy = bbox->min(); sp_repr_set_svg_double(rtext, "x", xy[Geom::X]); diff --git a/src/text-context.cpp b/src/text-context.cpp index 1468984a1..d2bf8c5f5 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -432,7 +432,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve } else { SP_CTRLRECT(tc->indicator)->setColor(0x0000ff7f, false, 0); } - Geom::OptRect ibbox = item_ungrouped->getBboxDesktop(); + Geom::OptRect ibbox = item_ungrouped->desktopVisualBounds(); if (ibbox) { SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox); } @@ -1635,7 +1635,7 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0); } sp_canvas_item_show(tc->frame); - Geom::OptRect frame_bbox = frame->getBboxDesktop(); + Geom::OptRect frame_bbox = frame->desktopVisualBounds(); if (frame_bbox) { SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox); } diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 83598d8da..5d592b83d 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -442,7 +442,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else { if (mode == TWEAK_MODE_MOVE) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -455,7 +455,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_MOVE_IN_OUT) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -469,7 +469,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_MOVE_JITTER) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { double dp = g_random_double_range(0, M_PI*2); double dr = g_random_double_range(0, radius); @@ -484,7 +484,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_SCALE) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -497,7 +497,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_ROTATE) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -510,7 +510,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_MORELESS) { - Geom::OptRect a = item->getBounds(item->i2doc_affine()); + Geom::OptRect a = item->documentVisualBounds(); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -562,7 +562,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } // skip those paths whose bboxes are entirely out of reach with our radius - Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); + Geom::OptRect bbox = item->documentVisualBounds(); if (bbox) { bbox->expandBy(radius); if (!bbox->contains(p)) { @@ -946,8 +946,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, if (!style) { return false; } - Geom::OptRect bbox = item->getBounds(item->i2doc_affine(), - SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = item->documentGeometricBounds(); if (!bbox) { return false; } @@ -976,8 +975,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, if (this_force > 0.002) { if (do_blur) { - Geom::OptRect bbox = item->getBounds(item->i2doc_affine(), - SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = item->documentGeometricBounds(); if (!bbox) { return did; } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 60379a966..adec1de5d 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -467,7 +467,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { for (GSList *i = const_cast(selection->itemList()) ; i ; i = i->next) { SPItem *item = SP_ITEM(i->data); - Geom::OptRect obj_size = item->getBboxDesktop(); + Geom::OptRect obj_size = item->desktopVisualBounds(); if ( !obj_size ) { continue; } @@ -476,7 +476,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a } // resize the selection as a whole else { - Geom::OptRect sel_size = selection->bounds(); + Geom::OptRect sel_size = selection->visualBounds(); if ( sel_size ) { sp_selection_scale_relative(selection, sel_size->midpoint(), _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); @@ -636,7 +636,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) } } - Geom::OptRect size = selection->bounds(); + Geom::OptRect size = selection->visualBounds(); if (size) { sp_repr_set_point(_clipnode, "min", size->min()); sp_repr_set_point(_clipnode, "max", size->max()); @@ -852,7 +852,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo target_document->ensureUpToDate(); // move selection either to original position (in_place) or to mouse pointer - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { // get offset of selection to original position of copied elements Geom::Point pos_original; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8728e2ef4..36d5a20d0 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -155,7 +155,7 @@ private : selected.erase(master); /*}*/ //Compute the anchor point - Geom::OptRect b = thing->getBboxDesktop (); + Geom::OptRect b = thing->desktopVisualBounds(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -172,7 +172,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->getBboxDesktop(); + Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->desktopVisualBounds(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -184,7 +184,7 @@ private : case AlignAndDistribute::SELECTION: { - Geom::OptRect b = selection->bounds(); + Geom::OptRect b = selection->visualBounds(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -211,7 +211,7 @@ private : bool changed = false; Geom::OptRect b; if (sel_as_group) - b = selection->bounds(); + b = selection->visualBounds(); //Move each item in the selected list separately for (std::list::iterator it(selected.begin()); @@ -220,7 +220,7 @@ private : { sp_desktop_document (desktop)->ensureUpToDate(); if (!sel_as_group) - b = (*it)->getBboxDesktop(); + b = (*it)->desktopVisualBounds(); if (b) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); @@ -261,7 +261,7 @@ ActionAlign::Coeffs const ActionAlign::_allCoeffs[10] = { {0., 0., 1., 0., 0., 0., 0., 1.} }; -BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd) : +BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect const &bounds, Geom::Dim2 orientation, double kBegin, double kEnd) : item(pItem), bbox (bounds) { @@ -324,7 +324,7 @@ private : it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->getBboxDesktop(); + Geom::OptRect bbox = (*it)->desktopVisualBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd)); } @@ -699,7 +699,7 @@ private : //Check 2 or more selected objects if (selected.size() < 2) return; - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (!sel_bbox) { return; } @@ -721,7 +721,7 @@ private : ++it) { sp_desktop_document (desktop)->ensureUpToDate(); - Geom::OptRect item_box = (*it)->getBboxDesktop (); + Geom::OptRect item_box = (*it)->desktopVisualBounds(); if (item_box) { // find new center, staying within bbox double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 + @@ -1245,7 +1245,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = (*it)->getBboxDesktop (); + Geom::OptRect b = (*it)->desktopVisualBounds(); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim > max) { @@ -1262,7 +1262,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = (*it)->getBboxDesktop (); + Geom::OptRect b = (*it)->desktopVisualBounds(); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim < max) { diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 99b96463c..22227cb60 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -120,7 +120,7 @@ struct BBoxSort SPItem *item; float anchor; Geom::Rect bbox; - BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd); + BBoxSort(SPItem *pItem, Geom::Rect const &bounds, Geom::Dim2 orientation, double kBegin, double kEnd); BBoxSort(const BBoxSort &rhs); }; bool operator< (const BBoxSort &a, const BBoxSort &b); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 4f4093a99..0d7a0c687 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -992,10 +992,8 @@ bool FileOpenDialogImplWin32::set_svg_preview() NRRectL bbox = {0, 0, scaledSvgWidth, scaledSvgHeight}; // write object bbox to area - Geom::OptRect maybeArea(area); svgDoc->ensureUpToDate(); - svgDoc->getRoot()->invoke_bbox( maybeArea, - svgDoc->getRoot()->i2dt_affine(), TRUE); + Geom::OptRect maybeArea = area | svgDoc->getRoot()->desktopVisualBounds(); NRArena *const arena = NRArena::create(); diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 68ad9393c..5f19a2613 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -47,8 +47,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) using Geom::X; using Geom::Y; - Geom::OptRect a = first->getBounds(first->i2doc_affine()); - Geom::OptRect b = second->getBounds(second->i2doc_affine()); + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); if ( !a || !b ) { // FIXME? @@ -87,8 +87,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - Geom::OptRect a = first->getBounds(first->i2doc_affine()); - Geom::OptRect b = second->getBounds(second->i2doc_affine()); + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); if ( !a || !b ) { // FIXME? @@ -167,7 +167,7 @@ void TileDialog::Grid_Arrange () cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - Geom::OptRect b = item->getBounds(item->i2doc_affine()); + Geom::OptRect b = item->documentVisualBounds(); if (!b) { continue; } @@ -210,7 +210,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - Geom::OptRect b = item->getBounds(item->i2doc_affine()); + Geom::OptRect b = item->documentVisualBounds(); if (b) { width = b->dimensions()[Geom::X]; height = b->dimensions()[Geom::Y]; @@ -267,7 +267,7 @@ void TileDialog::Grid_Arrange () } - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); // Fit to bbox, calculate padding between rows accordingly. if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ #ifdef DEBUG_GRID_ARRANGE @@ -317,7 +317,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h for (; current_row != NULL; current_row = current_row->next) { SPItem *item=SP_ITEM(current_row->data); Inkscape::XML::Node *repr = item->getRepr(); - Geom::OptRect b = item->getBounds(item->i2doc_affine()); + Geom::OptRect b = item->documentVisualBounds(); Geom::Point min; if (b) { width = b->dimensions()[Geom::X]; diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 92c8bd349..029a83ea5 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -467,7 +467,7 @@ Transformation::updatePageMove(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (!_check_move_relative.get_active()) { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { double x = bbox->min()[Geom::X]; double y = bbox->min()[Geom::Y]; @@ -489,7 +489,7 @@ void Transformation::updatePageScale(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { double w = bbox->dimensions()[Geom::X]; double h = bbox->dimensions()[Geom::Y]; @@ -519,7 +519,7 @@ void Transformation::updatePageSkew(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { double w = bbox->dimensions()[Geom::X]; double h = bbox->dimensions()[Geom::Y]; @@ -616,7 +616,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { sp_selection_move_relative(selection, x, y); } else { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { sp_selection_move_relative(selection, x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); @@ -637,7 +637,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->getBboxDesktop(); + Geom::OptRect bbox = (*it)->desktopVisualBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -661,7 +661,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->getBboxDesktop(); + Geom::OptRect bbox = (*it)->desktopVisualBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -680,7 +680,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) } } } else { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { sp_selection_move_relative(selection, x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); @@ -705,7 +705,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) Geom::Scale scale (0,0); // the values are increments! if (_units_scale.isAbsolute()) { - Geom::OptRect bbox(item->getBboxDesktop()); + Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { double new_width = scaleX; if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object @@ -723,7 +723,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) sp_item_scale_rel (item, scale); } } else { - Geom::OptRect bbox(selection->bounds()); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { Geom::Point center(bbox->midpoint()); // use rotation center? Geom::Scale scale (0,0); @@ -792,7 +792,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); - Geom::OptRect bbox(item->getBboxDesktop()); + Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { double width = bbox->dimensions()[Geom::X]; double height = bbox->dimensions()[Geom::Y]; @@ -801,7 +801,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } } } else { // transform whole selection - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); boost::optional center = selection->center(); if ( bbox && center ) { @@ -886,7 +886,7 @@ Transformation::onMoveRelativeToggled() //g_message("onMoveRelativeToggled: %f, %f px\n", x, y); - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { if (_check_move_relative.get_active()) { @@ -1026,7 +1026,7 @@ Transformation::onClear() _scalar_move_horizontal.setValue(0); _scalar_move_vertical.setValue(0); } else { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { _scalar_move_horizontal.setValue(bbox->min()[Geom::X], "px"); _scalar_move_vertical.setValue(bbox->min()[Geom::Y], "px"); diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index f4780896b..f3a8478ea 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -147,7 +147,7 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() { Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { SPObject *layer = _getLayer(); if (layer && SP_IS_ITEM(layer)) { - return SP_ITEM(layer)->getBboxDesktop(type); + return SP_ITEM(layer)->desktopBounds(type); } else { return Geom::OptRect(); } diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h index 6d5c96350..73f818516 100644 --- a/src/ui/widget/style-subject.h +++ b/src/ui/widget/style-subject.h @@ -45,7 +45,7 @@ public: virtual iterator begin() = 0; virtual iterator end() { return iterator(NULL); } - virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0; + virtual Geom::OptRect getBounds(SPItem::BBoxType type) = 0; virtual int queryStyle(SPStyle *query, int property) = 0; virtual void setCSS(SPCSSAttr *css) = 0; @@ -68,7 +68,7 @@ public: ~Selection(); virtual iterator begin(); - virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + virtual Geom::OptRect getBounds(SPItem::BBoxType type); virtual int queryStyle(SPStyle *query, int property); virtual void setCSS(SPCSSAttr *css); @@ -89,7 +89,7 @@ public: ~CurrentLayer(); virtual iterator begin(); - virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + virtual Geom::OptRect getBounds(SPItem::BBoxType type); virtual int queryStyle(SPStyle *query, int property); virtual void setCSS(SPCSSAttr *css); diff --git a/src/unclump.cpp b/src/unclump.cpp index e570e8fa7..6b9a8c574 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -34,7 +34,7 @@ unclump_center (SPItem *item) return i->second; } - Geom::OptRect r = item->getBounds(item->i2dt_affine()); + Geom::OptRect r = item->desktopVisualBounds(); if (r) { Geom::Point const c = r->midpoint(); c_cache[item->getId()] = c; @@ -53,7 +53,7 @@ unclump_wh (SPItem *item) if ( i != wh_cache.end() ) { wh = i->second; } else { - Geom::OptRect r = item->getBounds(item->i2dt_affine()); + Geom::OptRect r = item->desktopVisualBounds(); if (r) { wh = r->dimensions(); wh_cache[item->getId()] = wh; diff --git a/src/verbs.cpp b/src/verbs.cpp index e443e9917..ac8699654 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1325,7 +1325,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ ) if (sel->isEmpty()) return; - Geom::OptRect bbox = sel->bounds(); + Geom::OptRect bbox = sel->visualBounds(); if (!bbox) { return; } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 08f0eadfb..fff9c0a5c 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1881,7 +1881,7 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()), Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) ); - Geom::OptRect deskarea = darea | doc->getRoot()->getBboxDesktop(); + Geom::OptRect deskarea = darea | doc->getRoot()->desktopVisualBounds(); /* Canvas region we always show unconditionally */ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64), diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index a57b56b5c..9540b59d6 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1102,8 +1102,7 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, if (object && SP_IS_ITEM(object)) { SPItem *item = SP_ITEM(object); // Find bbox in document - Geom::Affine const i2doc(item->i2doc_affine()); - Geom::OptRect dbox = item->getBounds(i2doc); + Geom::OptRect dbox = item->documentVisualBounds(); if ( object->parent == NULL ) { diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 260c09c69..5f90a8997 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -70,7 +70,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) if ( sel && !sel->isEmpty() ) { int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); SPItem::BBoxType bbox_type = (prefs_bbox ==0)? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; Geom::OptRect const bbox(sel->bounds(bbox_type)); if ( bbox ) { UnitTracker *tracker = reinterpret_cast(g_object_get_data(G_OBJECT(spw), "tracker")); @@ -160,12 +160,12 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) document->ensureUpToDate (); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Geom::OptRect bbox_vis = selection->bounds(SPItem::APPROXIMATE_BBOX); - Geom::OptRect bbox_geom = selection->bounds(SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox_vis = selection->visualBounds(); + Geom::OptRect bbox_geom = selection->geometricBounds(); int prefs_bbox = prefs->getInt("/tools/bounding_box"); SPItem::BBoxType bbox_type = (prefs_bbox == 0)? - SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; Geom::OptRect bbox_user = selection->bounds(bbox_type); if ( !bbox_user ) { @@ -247,10 +247,10 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; Geom::Affine scaler; - if (bbox_type == SPItem::APPROXIMATE_BBOX) { + if (bbox_type == SPItem::VISUAL_BBOX) { scaler = get_scale_transform_with_unequal_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1); } else { - // get_scale_transform_with_stroke() is intended for VISUAL (or APPROXIMATE) bounding boxes, not geometrical ones! + // get_scale_transform_with_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero scaler = get_scale_transform_with_uniform_stroke (*bbox_user, 0, false, x0, y0, x1, y1); } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 8d9b9b429..bb9391c78 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -191,8 +191,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, SPItem *item = SP_ITEM(object); // Find object's bbox in document - Geom::Affine const i2doc(item->i2doc_affine()); - Geom::OptRect dbox = item->getBounds(i2doc); + Geom::OptRect dbox = item->documentVisualBounds(); if (!dbox) { return NULL; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 26947979d..61c7c8e88 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -5951,7 +5951,7 @@ static void lpetool_toggle_set_bbox(GtkToggleAction *act, gpointer data) SPDesktop *desktop = static_cast(data); Inkscape::Selection *selection = desktop->selection; - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->visualBounds(); if (bbox) { Geom::Point A(bbox->min()); @@ -6799,8 +6799,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) axis = Geom::Y; } - Geom::OptRect bbox - = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); + Geom::OptRect bbox = item->geometricBounds(); if (!bbox) continue; double width = bbox->dimensions()[axis]; -- cgit v1.2.3 From 84194ec2d0b9830437a5470320422265d5dd8c35 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 12:20:13 +0200 Subject: Remove NRRect use from the extension system (bzr r10582.1.2) --- src/extension/implementation/implementation.cpp | 174 +----------------------- src/extension/implementation/implementation.h | 93 +++++++------ src/extension/internal/emf-win32-print.cpp | 20 ++- src/extension/internal/emf-win32-print.h | 18 ++- src/extension/internal/latex-pstricks.cpp | 28 ++-- src/extension/internal/latex-pstricks.h | 16 ++- src/extension/print.cpp | 38 +++--- src/extension/print.h | 22 +-- src/libnrtype/Layout-TNG-Output.cpp | 5 +- src/print.cpp | 23 +--- src/print.h | 7 +- src/sp-image.cpp | 4 +- src/sp-shape.cpp | 7 +- src/sp-symbol.cpp | 2 +- 14 files changed, 149 insertions(+), 308 deletions(-) (limited to 'src') diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 63181d0c4..6f6bddb93 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -29,72 +29,15 @@ namespace Inkscape { namespace Extension { namespace Implementation { -/** - * \return Was the load sucessful? - * \brief This function is the stub load. It just returns success. - * \param module The Extension that should be loaded. - */ -bool -Implementation::load(Inkscape::Extension::Extension */*module*/) { - return TRUE; -} /* Implementation::load */ - -void -Implementation::unload(Inkscape::Extension::Extension */*module*/) { - return; -} /* Implementation::unload */ - -/** \brief Create a new document cache object - \param ext The extension that is referencing us - \param doc The document to create the cache of - \return A new document cache that is valid as long as the document - is not changed. - - This function just returns \c NULL. Subclasses are likely - to reimplement it to do something useful. -*/ -ImplementationDocumentCache * -Implementation::newDocCache( Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*view*/ ) { - return NULL; -} - -bool -Implementation::check(Inkscape::Extension::Extension */*module*/) { - /* If there are no checks, they all pass */ - return TRUE; -} /* Implemenation::check */ - -bool -Implementation::cancelProcessing (void) { - return true; -} - -void -Implementation::commitDocument (void) { - return; -} - Gtk::Widget * Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const */*filename*/) { return module->autogui(NULL, NULL); -} /* Implementation::prefs_input */ - -SPDocument * -Implementation::open(Inkscape::Extension::Input */*module*/, gchar const */*filename*/) { - /* throw open_failed(); */ - return NULL; -} /* Implementation::open */ +} Gtk::Widget * Implementation::prefs_output(Inkscape::Extension::Output *module) { return module->autogui(NULL, NULL); -} /* Implementation::prefs_output */ - -void -Implementation::save(Inkscape::Extension::Output */*module*/, SPDocument */*doc*/, gchar const */*filename*/) { - /* throw save_fail */ - return; -} /* Implementation::save */ +} Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, ImplementationDocumentCache * /*docCache*/) { @@ -117,119 +60,6 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I return module->autogui(current_document, const_cast(first_select), changeSignal); } // Implementation::prefs_effect -void -Implementation::effect(Inkscape::Extension::Effect */*module*/, Inkscape::UI::View::View */*document*/, ImplementationDocumentCache * /*docCache*/) { - /* throw filter_fail */ - return; -} /* Implementation::filter */ - -unsigned int -Implementation::setup(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - -unsigned int -Implementation::set_preview(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - - -unsigned int -Implementation::begin(Inkscape::Extension::Print */*module*/, SPDocument */*doc*/) -{ - return 0; -} - -unsigned int -Implementation::finish(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - - -/* Rendering methods */ -unsigned int -Implementation::bind(Inkscape::Extension::Print */*module*/, Geom::Affine const */*transform*/, float /*opacity*/) -{ - return 0; -} - -unsigned int -Implementation::release(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - -unsigned int -Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*comment*/) -{ - return 0; -} - -unsigned int -Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*ctm*/, SPStyle const */*style*/, - NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) -{ - return 0; -} - -unsigned int -Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*transform*/, SPStyle const */*style*/, - NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) -{ - return 0; -} - -unsigned int -Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/, - Geom::Affine const */*transform*/, SPStyle const */*style*/) -{ - return 0; -} - -unsigned int -Implementation::text(Inkscape::Extension::Print */*module*/, char const */*text*/, - Geom::Point /*p*/, SPStyle const */*style*/) -{ - return 0; -} - -void -Implementation::processPath(Inkscape::XML::Node * /*node*/) -{ - return; -} - -/** - \brief Tell the printing engine whether text should be text or path - \retval true Render the text as a path - \retval false Render text using the text function (above) - - Default value is false because most printing engines will support - paths more than they'll support text. (at least they do today) -*/ -bool -Implementation::textToPath(Inkscape::Extension::Print */*ext*/) -{ - return false; -} - -/** - \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded - \retval TRUE Fonts have to be embedded in the output so that the user might not need to install fonts to have the interpreter read the document correctly - \retval FALSE Not embed fonts - - Only available for Adobe Type 1 fonts in EPS output as of now -*/ - -bool -Implementation::fontEmbedded(Inkscape::Extension::Print * /*ext*/) -{ - return false; -} - } /* namespace Implementation */ } /* namespace Extension */ } /* namespace Inkscape */ diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index bd3edb43b..4a01a3e84 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -9,8 +9,8 @@ important for implementing the extensions themselves. This file contains the base class for all of that. */ -#ifndef __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ -#define __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H +#define SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H #include #include @@ -54,16 +54,23 @@ public: virtual ~Implementation() {} /* ----- Basic functions for all Extension ----- */ - virtual bool load(Inkscape::Extension::Extension *module); - - virtual void unload(Inkscape::Extension::Extension *module); - virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc); + virtual bool load(Inkscape::Extension::Extension *module) { return true; } + + virtual void unload(Inkscape::Extension::Extension *module) {} + /** \brief Create a new document cache object + * This function just returns \c NULL. Subclasses are likely + * to reimplement it to do something useful. + * \param ext The extension that is referencing us + * \param doc The document to create the cache of + * \return A new document cache that is valid as long as the document + * is not changed. */ + virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc) { return NULL; } /** Verify any dependencies. */ - virtual bool check(Inkscape::Extension::Extension *module); + virtual bool check(Inkscape::Extension::Extension *module) { return true; } - virtual bool cancelProcessing (void); - virtual void commitDocument (void); + virtual bool cancelProcessing () { return true; } + virtual void commitDocument () {} /* ----- Input functions ----- */ /** Find out information about the file. */ @@ -71,65 +78,75 @@ public: gchar const *filename); virtual SPDocument *open(Inkscape::Extension::Input *module, - gchar const *filename); + gchar const *filename) { return NULL; } /* ----- Output functions ----- */ /** Find out information about the file. */ virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module); - virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename); + virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename) {} /* ----- Effect functions ----- */ /** Find out information about the file. */ virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View * view, - sigc::signal * changeSignal, - ImplementationDocumentCache * docCache); + Inkscape::UI::View::View *view, + sigc::signal *changeSignal, + ImplementationDocumentCache *docCache); virtual void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, - ImplementationDocumentCache * docCache); + ImplementationDocumentCache *docCache) {} /* ----- Print functions ----- */ - virtual unsigned setup(Inkscape::Extension::Print *module); - virtual unsigned set_preview(Inkscape::Extension::Print *module); + virtual unsigned setup(Inkscape::Extension::Print *module) { return 0; } + virtual unsigned set_preview(Inkscape::Extension::Print *module) { return 0; } virtual unsigned begin(Inkscape::Extension::Print *module, - SPDocument *doc); - virtual unsigned finish(Inkscape::Extension::Print *module); - virtual bool textToPath(Inkscape::Extension::Print *ext); - virtual bool fontEmbedded(Inkscape::Extension::Print * ext); + SPDocument *doc) { return 0; } + virtual unsigned finish(Inkscape::Extension::Print *module) { return 0; } + /** \brief Tell the printing engine whether text should be text or path + * Default value is false because most printing engines will support + * paths more than they'll support text. (at least they do today) + * \retval true Render the text as a path + * \retval false Render text using the text function (above) */ + virtual bool textToPath(Inkscape::Extension::Print *ext) { return false; } + /** \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded + * Only available for Adobe Type 1 fonts in EPS output as of now + * \retval true Fonts have to be embedded in the output so that the user might not need + * to install fonts to have the interpreter read the document correctly + * \retval false Do not embed fonts */ + virtual bool fontEmbedded(Inkscape::Extension::Print * ext) { return false; } /* ----- Rendering methods ----- */ virtual unsigned bind(Inkscape::Extension::Print *module, - Geom::Affine const *transform, - float opacity); - virtual unsigned release(Inkscape::Extension::Print *module); - virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment); + Geom::Affine const &transform, + float opacity) { return 0; } + virtual unsigned release(Inkscape::Extension::Print *module) { return 0; } + virtual unsigned comment(Inkscape::Extension::Print *module, char const *comment) { return 0; } virtual unsigned fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, - Geom::Affine const *ctm, + Geom::Affine const &ctm, SPStyle const *style, - NRRect const *pbox, - NRRect const *dbox, - NRRect const *bbox); + Geom::OptRect const &pbox, + Geom::OptRect const &dbox, + Geom::OptRect const &bbox) { return 0; } virtual unsigned stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, - Geom::Affine const *transform, + Geom::Affine const &transform, SPStyle const *style, - NRRect const *pbox, - NRRect const *dbox, - NRRect const *bbox); + Geom::OptRect const &pbox, + Geom::OptRect const &dbox, + Geom::OptRect const &bbox) { return 0; } virtual unsigned image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const *transform, - SPStyle const *style); + Geom::Affine const &transform, + SPStyle const *style) { return 0; } virtual unsigned text(Inkscape::Extension::Print *module, char const *text, - Geom::Point p, - SPStyle const *style); - virtual void processPath(Inkscape::XML::Node * node); + Geom::Point const &p, + SPStyle const *style) { return 0; } + virtual void processPath(Inkscape::XML::Node * node) {} }; diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index be5bf96c3..d08304a00 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -448,15 +448,13 @@ PrintEmfWin32::flush_fill() } unsigned int -PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const *transform, float /*opacity*/) -{ - Geom::Affine tr = *transform; - +PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/) +{ if (m_tr_stack.size()) { Geom::Affine tr_top = m_tr_stack.top(); - m_tr_stack.push(tr * tr_top); + m_tr_stack.push(transform * tr_top); } else { - m_tr_stack.push(tr); + m_tr_stack.push(transform); } return 1; @@ -471,8 +469,8 @@ PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/) unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, - Geom::PathVector const &pathv, Geom::Affine const * /*transform*/, SPStyle const *style, - NRRect const * /*pbox*/, NRRect const * /*dbox*/, NRRect const * /*bbox*/) + Geom::PathVector const &pathv, Geom::Affine const & /*transform*/, SPStyle const *style, + Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { if (!hdc) return 0; @@ -500,8 +498,8 @@ PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/, - Geom::PathVector const &pathv, const Geom::Affine * /*transform*/, const SPStyle *style, - const NRRect * /*pbox*/, const NRRect * /*dbox*/, const NRRect * /*bbox*/) + Geom::PathVector const &pathv, const Geom::Affine &/*transform*/, const SPStyle *style, + Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { if (!hdc) return 0; @@ -846,7 +844,7 @@ PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext) } unsigned int -PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point p, +PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point const &p, SPStyle const *const style) { if (!hdc) return 0; diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index 44327d35e..71ce5d6d0 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -62,17 +62,21 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, - Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); + virtual unsigned int fill (Inkscape::Extension::Print *module, + Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); virtual unsigned int stroke (Inkscape::Extension::Print * module, - Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); + Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, - Geom::Point p, SPStyle const *style); + Geom::Point const &p, SPStyle const *style); bool textToPath (Inkscape::Extension::Print * ext); static void init (void); diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 18950295c..49304de96 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -164,15 +164,14 @@ PrintLatex::finish (Inkscape::Extension::Print *mod) } unsigned int -PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const *transform, float opacity) +PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const &transform, float opacity) { - Geom::Affine tr = *transform; - - if(m_tr_stack.size()){ + if (m_tr_stack.size()) { Geom::Affine tr_top = m_tr_stack.top(); - m_tr_stack.push(tr * tr_top); - }else - m_tr_stack.push(tr); + m_tr_stack.push(transform * tr_top); + } else { + m_tr_stack.push(transform); + } return 1; } @@ -194,8 +193,8 @@ unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, unsigned int PrintLatex::fill(Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) + Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -227,8 +226,9 @@ PrintLatex::fill(Inkscape::Extension::Print *mod, } unsigned int -PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) +PrintLatex::stroke (Inkscape::Extension::Print *mod, + Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -277,12 +277,12 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pat // FIXME: why is 'transform' argument not used? void -PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/) +PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/) { if (pathv_in.empty()) return; -// Geom::Affine tf=*transform; // why was this here? +// Geom::Affine tf=transform; // why was this here? Geom::Affine tf_stack=m_tr_stack.top(); // and why is transform argument not used? Geom::PathVector pathv = pathv_in * tf_stack; // generates new path, which is a bit slow, but this doesn't have to be performance optimized @@ -304,7 +304,7 @@ PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv } void -PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c ) +PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const &c) { using Geom::X; using Geom::Y; diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h index 64b0de474..5bc6eeb22 100644 --- a/src/extension/internal/latex-pstricks.h +++ b/src/extension/internal/latex-pstricks.h @@ -33,7 +33,7 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation { std::stack m_tr_stack; - void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/); + void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/); void print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c ); public: @@ -47,13 +47,17 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); + virtual unsigned int fill (Inkscape::Extension::Print *module, Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); + virtual unsigned int stroke (Inkscape::Extension::Print *module, Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); bool textToPath (Inkscape::Extension::Print * ext); diff --git a/src/extension/print.cpp b/src/extension/print.cpp index f2dbb0b9b..c37e9425c 100644 --- a/src/extension/print.cpp +++ b/src/extension/print.cpp @@ -15,7 +15,7 @@ namespace Inkscape { namespace Extension { -Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) +Print::Print (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp) : Extension(in_repr, in_imp) , base(NULL) , drawing(NULL) @@ -24,23 +24,23 @@ Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in { } -Print::~Print (void) +Print::~Print () {} bool -Print::check (void) +Print::check () { return Extension::check(); } unsigned int -Print::setup (void) +Print::setup () { return imp->setup(this); } unsigned int -Print::set_preview (void) +Print::set_preview () { return imp->set_preview(this); } @@ -52,65 +52,65 @@ Print::begin (SPDocument *doc) } unsigned int -Print::finish (void) +Print::finish () { return imp->finish(this); } unsigned int -Print::bind (const Geom::Affine *transform, float opacity) +Print::bind (const Geom::Affine &transform, float opacity) { return imp->bind (this, transform, opacity); } unsigned int -Print::release (void) +Print::release () { return imp->release(this); } unsigned int -Print::comment (const char * comment) +Print::comment (char const *comment) { - return imp->comment(this,comment); + return imp->comment(this, comment); } unsigned int -Print::fill (Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) +Print::fill (Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { return imp->fill (this, pathv, ctm, style, pbox, dbox, bbox); } unsigned int -Print::stroke (Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) +Print::stroke (Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - return imp->stroke (this, pathv, transform, style, pbox, dbox, bbox); + return imp->stroke (this, pathv, ctm, style, pbox, dbox, bbox); } unsigned int Print::image (unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const Geom::Affine *transform, const SPStyle *style) + const Geom::Affine &transform, const SPStyle *style) { return imp->image (this, px, w, h, rs, transform, style); } unsigned int -Print::text (const char* text, Geom::Point p, const SPStyle* style) +Print::text (char const *text, Geom::Point const &p, SPStyle const *style) { return imp->text (this, text, p, style); } bool -Print::textToPath (void) +Print::textToPath () { return imp->textToPath(this); } //whether embed font in print output (EPS especially) bool -Print::fontEmbedded (void) +Print::fontEmbedded () { return imp->fontEmbedded(this); } diff --git a/src/extension/print.h b/src/extension/print.h index c2276126b..9c0920499 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -41,30 +41,30 @@ public: unsigned int finish (void); /* Rendering methods */ - unsigned int bind (Geom::Affine const *transform, + unsigned int bind (Geom::Affine const &transform, float opacity); unsigned int release (void); unsigned int comment (const char * comment); unsigned int fill (Geom::PathVector const &pathv, - Geom::Affine const *ctm, + Geom::Affine const &ctm, SPStyle const *style, - NRRect const *pbox, - NRRect const *dbox, - NRRect const *bbox); + Geom::OptRect const &pbox, + Geom::OptRect const &dbox, + Geom::OptRect const &bbox); unsigned int stroke (Geom::PathVector const &pathv, - Geom::Affine const *transform, + Geom::Affine const &transform, SPStyle const *style, - NRRect const *pbox, - NRRect const *dbox, - NRRect const *bbox); + Geom::OptRect const &pbox, + Geom::OptRect const &dbox, + Geom::OptRect const &bbox); unsigned int image (unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const *transform, + Geom::Affine const &transform, SPStyle const *style); unsigned int text (char const *text, - Geom::Point p, + Geom::Point const &p, SPStyle const *style); bool textToPath (void); bool fontEmbedded (void); diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index fa1a07414..7e54a00e2 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -136,7 +136,6 @@ void Layout::print(SPPrintContext *ctx, { if (_input_stream.empty()) return; - Geom::Affine ctm_2geom(ctm); Direction block_progression = _blockProgression(); bool text_to_path = ctx->module->textToPath(); for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; ) { @@ -156,9 +155,9 @@ void Layout::print(SPPrintContext *ctx, _getGlyphTransformMatrix(glyph_index, &glyph_matrix); Geom::PathVector temp_pv = (*pv) * glyph_matrix; if (!text_source->style->fill.isNone()) - sp_print_fill(ctx, temp_pv, &ctm_2geom, text_source->style, pbox, dbox, bbox); + sp_print_fill(ctx, temp_pv, ctm, text_source->style, pbox, dbox, bbox); if (!text_source->style->stroke.isNone()) - sp_print_stroke(ctx, temp_pv, &ctm_2geom, text_source->style, pbox, dbox, bbox); + sp_print_stroke(ctx, temp_pv, ctm, text_source->style, pbox, dbox, bbox); } glyph_index++; } else { diff --git a/src/print.cpp b/src/print.cpp index 3e477c976..d2fc72175 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -27,17 +27,8 @@ #include "ui/dialog/print.h" - -/* Identity typedef */ - -unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity) -{ - Geom::Affine const ntransform(transform); - return sp_print_bind(ctx, &ntransform, opacity); -} - unsigned int -sp_print_bind(SPPrintContext *ctx, Geom::Affine const *transform, float opacity) +sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity) { return ctx->module->bind(transform, opacity); } @@ -55,25 +46,23 @@ sp_print_comment(SPPrintContext *ctx, char const *comment) } unsigned int -sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style, +sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - NRRect nrpbox(pbox), nrdbox(dbox), nrbbox(bbox); - return ctx->module->fill(pathv, ctm, style, &nrpbox, &nrdbox, &nrbbox); + return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox); } unsigned int -sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style, +sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - NRRect nrpbox(pbox), nrdbox(dbox), nrbbox(bbox); - return ctx->module->stroke(pathv, ctm, style, &nrpbox, &nrdbox, &nrbbox); + return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox); } unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const *transform, SPStyle const *style) + Geom::Affine const &transform, SPStyle const *style) { return ctx->module->image(px, w, h, rs, transform, style); } diff --git a/src/print.h b/src/print.h index 34c85d901..d584245e5 100644 --- a/src/print.h +++ b/src/print.h @@ -23,17 +23,16 @@ struct SPPrintContext { }; unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity); -unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const *transform, float opacity); unsigned int sp_print_release(SPPrintContext *ctx); unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment); -unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *ctm, SPStyle const *style, +unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); -unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style, +unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const *transform, SPStyle const *style); + Geom::Affine const &transform, SPStyle const *style); unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, SPStyle const *style); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 3ae2b6e63..1bfcc90e5 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1095,7 +1095,7 @@ static void sp_image_print( SPItem *item, SPPrintContext *ctx ) Geom::Translate ti(0.0, -1.0); t = s * tp; t = ti * t; - sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, &t, item->style); + sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, item->style); } else { // preserveAspectRatio double vw = image->width.computed / image->sx; double vh = image->height.computed / image->sy; @@ -1116,7 +1116,7 @@ static void sp_image_print( SPItem *item, SPPrintContext *ctx ) Geom::Translate ti(0.0, -1.0); t = s * tp; t = ti * t; - sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, &t, item->style); + sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, item->style); } } } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 15fa76d65..8bfa99392 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -657,7 +657,8 @@ Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &tra } static void -sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* style, SPPrintContext *ctx) { +sp_shape_print_invoke_marker_printing(SPObject *obj, Geom::Affine tr, SPStyle const *style, SPPrintContext *ctx) +{ SPMarker *marker = SP_MARKER(obj); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { tr = Geom::Scale(style->stroke_width.computed) * tr; @@ -709,11 +710,11 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) SPStyle* style = item->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, &i2dt, style, pbox, dbox, bbox); + sp_print_fill (ctx, pathv, i2dt, style, pbox, dbox, bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, &i2dt, style, pbox, dbox, bbox); + sp_print_stroke (ctx, pathv, i2dt, style, pbox, dbox, bbox); } /** \todo make code prettier */ diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 71de619c1..0a1ebdb06 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -421,7 +421,7 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) if (symbol->cloned) { // Cloned is actually renderable - sp_print_bind(ctx, &symbol->c2p, 1.0); + sp_print_bind(ctx, symbol->c2p, 1.0); if (((SPItemClass *) (parent_class))->print) { ((SPItemClass *) (parent_class))->print (item, ctx); -- cgit v1.2.3 From ac0bc3b7583e5b45ed6ec97923170a77b5648d2e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 14:36:15 +0200 Subject: Update 2Geom. Remove all use of NRRectL. (bzr r10582.1.3) --- src/2geom/affine.cpp | 60 ++++-- src/2geom/coord.h | 42 ++-- src/2geom/forward.h | 4 +- src/2geom/generic-interval.h | 31 +-- src/2geom/generic-rect.h | 36 +++- src/2geom/interval.h | 43 ++++- src/2geom/linear.h | 2 +- src/2geom/rect.h | 42 +++- src/display/canvas-arena.cpp | 8 +- src/display/canvas-arena.h | 2 +- src/display/canvas-axonomgrid.cpp | 62 +++--- src/display/canvas-bpath.cpp | 4 +- src/display/canvas-grid.cpp | 79 ++------ src/display/canvas-text.cpp | 4 +- src/display/guideline.cpp | 38 ++-- src/display/nr-filter-colormatrix.cpp | 4 - src/display/nr-filter-colormatrix.h | 1 - src/display/nr-filter-component-transfer.cpp | 4 - src/display/nr-filter-component-transfer.h | 1 - src/display/nr-filter-convolve-matrix.cpp | 11 +- src/display/nr-filter-convolve-matrix.h | 2 +- src/display/nr-filter-diffuselighting.cpp | 7 +- src/display/nr-filter-diffuselighting.h | 2 +- src/display/nr-filter-displacement-map.cpp | 7 +- src/display/nr-filter-displacement-map.h | 2 +- src/display/nr-filter-flood.cpp | 5 - src/display/nr-filter-flood.h | 1 - src/display/nr-filter-gaussian.cpp | 7 +- src/display/nr-filter-gaussian.h | 2 +- src/display/nr-filter-morphology.cpp | 7 +- src/display/nr-filter-morphology.h | 2 +- src/display/nr-filter-offset.cpp | 16 +- src/display/nr-filter-offset.h | 2 +- src/display/nr-filter-primitive.cpp | 2 +- src/display/nr-filter-primitive.h | 5 +- src/display/nr-filter-slot.h | 2 - src/display/nr-filter-specularlighting.cpp | 8 +- src/display/nr-filter-specularlighting.h | 2 +- src/display/nr-filter-tile.cpp | 4 - src/display/nr-filter-tile.h | 1 - src/display/nr-filter.cpp | 4 +- src/display/sodipodi-ctrl.cpp | 28 +-- src/display/sodipodi-ctrl.h | 2 +- src/display/sodipodi-ctrlrect.cpp | 2 +- src/display/sp-canvas-util.cpp | 9 +- src/display/sp-canvas.cpp | 154 ++++++--------- src/display/sp-canvas.h | 4 +- src/display/sp-ctrlline.cpp | 4 +- src/display/sp-ctrlpoint.cpp | 2 +- src/display/sp-ctrlquadr.cpp | 4 +- src/dropper-context.cpp | 16 +- src/dyna-draw-context.cpp | 6 +- src/livarot/Path.h | 1 - src/livarot/PathConversion.cpp | 276 --------------------------- 54 files changed, 376 insertions(+), 700 deletions(-) (limited to 'src') diff --git a/src/2geom/affine.cpp b/src/2geom/affine.cpp index c31b9ba90..1be5d9fe8 100644 --- a/src/2geom/affine.cpp +++ b/src/2geom/affine.cpp @@ -144,6 +144,7 @@ bool Affine::isNonzeroTranslation(Coord eps) const { 0 & b & 0 \\ 0 & 0 & 1 \end{array}\right]\f$. */ bool Affine::isScale(Coord eps) const { + if (isSingular(eps)) return false; return are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) && are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps); } @@ -156,6 +157,7 @@ bool Affine::isScale(Coord eps) const { 0 & b & 0 \\ 0 & 0 & 1 \end{array}\right]\f$ and \f$a, b \neq 1\f$. */ bool Affine::isNonzeroScale(Coord eps) const { + if (isSingular(eps)) return false; return (!are_near(_c[0], 1.0, eps) || !are_near(_c[3], 1.0, eps)) && //NOTE: these are the diags, and the next line opposite diags are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) && are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps); @@ -165,11 +167,12 @@ bool Affine::isNonzeroScale(Coord eps) const { * @param eps Numerical tolerance * @return True iff the matrix is of the form * \f$\left[\begin{array}{ccc} - a & 0 & 0 \\ - 0 & a & 0 \\ - 0 & 0 & 1 \end{array}\right]\f$. */ + a_1 & 0 & 0 \\ + 0 & a_2 & 0 \\ + 0 & 0 & 1 \end{array}\right]\f$ where \f$|a_1| = |a_2|\f$. */ bool Affine::isUniformScale(Coord eps) const { - return are_near(_c[0], _c[3], eps) && + if (isSingular(eps)) return false; + return are_near(fabs(_c[0]), fabs(_c[3]), eps) && are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) && are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps); } @@ -178,11 +181,16 @@ bool Affine::isUniformScale(Coord eps) const { * @param eps Numerical tolerance * @return True iff the matrix is of the form * \f$\left[\begin{array}{ccc} - a & 0 & 0 \\ - 0 & a & 0 \\ - 0 & 0 & 1 \end{array}\right]\f$ and \f$a \neq 1\f$. */ + a_1 & 0 & 0 \\ + 0 & a_2 & 0 \\ + 0 & 0 & 1 \end{array}\right]\f$ where \f$|a_1| = |a_2|\f$ + * and \f$a_1, a_2 \neq 1\f$. */ bool Affine::isNonzeroUniformScale(Coord eps) const { - return !are_near(_c[0], 1.0, eps) && are_near(_c[0], _c[3], eps) && + if (isSingular(eps)) return false; + // we need to test both c0 and c3 to handle the case of flips, + // which should be treated as nonzero uniform scales + return !(are_near(_c[0], 1.0, eps) && are_near(_c[3], 1.0, eps)) && + are_near(fabs(_c[0]), fabs(_c[3]), eps) && are_near(_c[1], 0.0, eps) && are_near(_c[2], 0.0, eps) && are_near(_c[4], 0.0, eps) && are_near(_c[5], 0.0, eps); } @@ -266,15 +274,17 @@ bool Affine::isNonzeroVShear(Coord eps) const { } /** @brief Check whether this matrix represents zooming. - * Zooming is any combination of translation and uniform scaling. It preserves angles, ratios - * of distances between arbitrary points and unit vectors of line segments. + * Zooming is any combination of translation and uniform non-flipping scaling. + * It preserves angles, ratios of distances between arbitrary points + * and unit vectors of line segments. * @param eps Numerical tolerance - * @return True iff the matrix is of the form + * @return True iff the matrix is invertible and of the form * \f$\left[\begin{array}{ccc} a & 0 & 0 \\ 0 & a & 0 \\ b & c & 1 \end{array}\right]\f$. */ bool Affine::isZoom(Coord eps) const { + if (isSingular(eps)) return false; return are_near(_c[0], _c[3], eps) && are_near(_c[1], 0, eps) && are_near(_c[2], 0, eps); } @@ -290,30 +300,42 @@ bool Affine::preservesArea(Coord eps) const } /** @brief Check whether the transformation preserves angles between lines. - * This means that the transformation can be any combination of translation, uniform scaling - * and rotation. + * This means that the transformation can be any combination of translation, uniform scaling, + * rotation and flipping. * @param eps Numerical tolerance * @return True iff the matrix is of the form * \f$\left[\begin{array}{ccc} - a & b & 0 \\ - -b & a & 0 \\ - c & d & 1 \end{array}\right]\f$. */ + a & b & 0 \\ + -b & a & 0 \\ + c & d & 1 \end{array}\right]\f$ or + \f$\left[\begin{array}{ccc} + -a & b & 0 \\ + b & a & 0 \\ + c & d & 1 \end{array}\right]\f$. */ bool Affine::preservesAngles(Coord eps) const { - return are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps); + if (isSingular(eps)) return false; + return (are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps)) || + (are_near(_c[0], -_c[3], eps) && are_near(_c[1], _c[2], eps)); } /** @brief Check whether the transformation preserves distances between points. - * This means that the transformation can be any combination of translation and rotation. + * This means that the transformation can be any combination of translation, + * rotation and flipping. * @param eps Numerical tolerance * @return True iff the matrix is of the form * \f$\left[\begin{array}{ccc} a & b & 0 \\ -b & a & 0 \\ + c & d & 1 \end{array}\right]\f$ or + \f$\left[\begin{array}{ccc} + -a & b & 0 \\ + b & a & 0 \\ c & d & 1 \end{array}\right]\f$ and \f$a^2 + b^2 = 1\f$. */ bool Affine::preservesDistances(Coord eps) const { - return are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps) && + return ((are_near(_c[0], _c[3], eps) && are_near(_c[1], -_c[2], eps)) || + (are_near(_c[0], -_c[3], eps) && are_near(_c[1], _c[2], eps))) && are_near(_c[0] * _c[0] + _c[1] * _c[1], 1.0, eps); } diff --git a/src/2geom/coord.h b/src/2geom/coord.h index 90e776665..78a852f32 100644 --- a/src/2geom/coord.h +++ b/src/2geom/coord.h @@ -75,18 +75,18 @@ struct CoordTraits { typedef OptIntRect OptRectType; typedef - boost::equality_comparable< IntervalType - , boost::additive< IntervalType - , boost::additive< IntervalType, IntCoord - , boost::orable< IntervalType + boost::equality_comparable< IntInterval + , boost::additive< IntInterval + , boost::additive< IntInterval, IntCoord + , boost::orable< IntInterval > > > > IntervalOps; typedef - boost::equality_comparable< RectType - , boost::orable< RectType - , boost::orable< RectType, OptRectType - , boost::additive< RectType, PointType + boost::equality_comparable< IntRect + , boost::orable< IntRect + , boost::orable< IntRect, OptIntRect + , boost::additive< IntRect, IntPoint > > > > RectOps; }; @@ -100,21 +100,23 @@ struct CoordTraits { typedef OptRect OptRectType; typedef - boost::equality_comparable< IntervalType - , boost::additive< IntervalType - , boost::multipliable< IntervalType - , boost::orable< IntervalType - , boost::arithmetic< IntervalType, Coord - > > > > > + boost::equality_comparable< Interval + , boost::equality_comparable< Interval, IntInterval + , boost::additive< Interval + , boost::multipliable< Interval + , boost::orable< Interval + , boost::arithmetic< Interval, Coord + > > > > > > IntervalOps; typedef - boost::equality_comparable< RectType - , boost::orable< RectType - , boost::orable< RectType, OptRectType - , boost::additive< RectType, PointType - , boost::multipliable< RectType, Affine - > > > > > + boost::equality_comparable< Rect + , boost::equality_comparable< Rect, IntRect + , boost::orable< Rect + , boost::orable< Rect, OptRect + , boost::additive< Rect, Point + , boost::multipliable< Rect, Affine + > > > > > > RectOps; }; diff --git a/src/2geom/forward.h b/src/2geom/forward.h index 0dbd9fa94..70cac1f7d 100644 --- a/src/2geom/forward.h +++ b/src/2geom/forward.h @@ -49,13 +49,13 @@ class Ray; template class GenericInterval; template class GenericOptInterval; class Interval; -typedef GenericOptInterval OptInterval; +class OptInterval; typedef GenericInterval IntInterval; typedef GenericOptInterval OptIntInterval; template class GenericRect; template class GenericOptRect; class Rect; -typedef GenericOptRect OptRect; +class OptRect; typedef GenericRect IntRect; typedef GenericOptRect OptIntRect; diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h index 0212da676..87d3be2c1 100644 --- a/src/2geom/generic-interval.h +++ b/src/2geom/generic-interval.h @@ -49,6 +49,7 @@ template class GenericInterval : CoordTraits::IntervalOps { + typedef typename CoordTraits::IntervalType CInterval; typedef GenericInterval Self; protected: C _b[2]; @@ -76,15 +77,15 @@ public: * @param end End of the range * @return Interval that contains all values from [start, end). */ template - static Self from_range(InputIterator start, InputIterator end) { + static CInterval from_range(InputIterator start, InputIterator end) { assert(start != end); - Self result(*start++); + CInterval result(*start++); for (; start != end; ++start) result.expandTo(*start); return result; } /** @brief Create an interval from a C-style array of values it should contain. */ - static Self from_array(C const *c, unsigned n) { - Self result = from_range(c, c+n); + static CInterval from_array(C const *c, unsigned n) { + CInterval result = from_range(c, c+n); return result; } /// @} @@ -94,7 +95,7 @@ public: C min() const { return _b[0]; } C max() const { return _b[1]; } C extent() const { return max() - min(); } - C middle() const { return (max() + min()) * 0.5; } + C middle() const { return (max() + min()) / 2; } bool isSingular() const { return min() == max(); } /// @} @@ -105,11 +106,11 @@ public: return min() <= val && val <= max(); } /** @brief Check whether the interval includes the given interval. */ - bool contains(Self const &val) const { + bool contains(CInterval const &val) const { return min() <= val.min() && val.max() <= max(); } /** @brief Check whether the intervals have any common elements. */ - bool intersects(Self const &val) const { + bool intersects(CInterval const &val) const { return contains(val.min()) || contains(val.max()) || val.contains(*this); } /// @} @@ -159,7 +160,7 @@ public: * The resulting interval will contain all points of both intervals. * It might also contain some points which didn't belong to either - this happens * when the intervals did not have any common elements. */ - void unionWith(Self const &a) { + void unionWith(CInterval const &a) { if(a._b[0] < _b[0]) _b[0] = a._b[0]; if(a._b[1] > _b[1]) _b[1] = a._b[1]; } @@ -187,7 +188,7 @@ public: /** @brief Add two intervals. * Sum is defined as the set of points that can be obtained by adding any two values * from both operands: \f$S = \{x \in A, y \in B: x + y\}\f$ */ - Self &operator+=(Self const &o) { + Self &operator+=(CInterval const &o) { _b[0] += o._b[0]; _b[1] += o._b[1]; return *this; @@ -196,7 +197,7 @@ public: * Difference is defined as the set of points that can be obtained by subtracting * any value from the second operand from any value from the first operand: * \f$S = \{x \in A, y \in B: x - y\}\f$ */ - Self &operator-=(Self const &o) { + Self &operator-=(CInterval const &o) { // equal to *this += -o _b[0] -= o._b[1]; _b[1] -= o._b[0]; @@ -205,12 +206,12 @@ public: /** @brief Union two intervals. * Note that the intersection-and-assignment operator is not defined, * because the result of an intersection can be empty, while Interval cannot. */ - Self &operator|=(Self const &o) { + Self &operator|=(CInterval const &o) { unionWith(o); return *this; } /** @brief Test for interval equality. */ - bool operator==(Self const &other) const { + bool operator==(CInterval const &other) const { return min() == other.min() && max() == other.max(); } /// @} @@ -230,15 +231,15 @@ inline GenericInterval unify(GenericInterval const &a, GenericInterval template class GenericOptInterval : public boost::optional::IntervalType> - , boost::orable< GenericOptInterval, typename CoordTraits::OptIntervalType - , boost::andable< GenericOptInterval, typename CoordTraits::OptIntervalType + , boost::orable< GenericOptInterval + , boost::andable< GenericOptInterval > > { typedef typename CoordTraits::IntervalType CInterval; typedef typename CoordTraits::OptIntervalType OptCInterval; typedef boost::optional Base; public: - /// @name Create optionally empty intervals of integers. + /// @name Create optionally empty intervals. /// @{ /** @brief Create an empty interval. */ GenericOptInterval() : Base() {} diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index efe499809..719b37385 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -135,10 +135,10 @@ public: /** @brief Get the corner of the rectangle with smallest coordinate values. * In 2Geom standard coordinate system, this means upper left. */ - CPoint min() const { return CPoint(f[X].min(), f[Y].min()); } + CPoint min() const { CPoint p(f[X].min(), f[Y].min()); return p; } /** @brief Get the corner of the rectangle with largest coordinate values. * In 2Geom standard coordinate system, this means lower right. */ - CPoint max() const { return CPoint(f[X].max(), f[Y].max()); } + CPoint max() const { CPoint p(f[X].max(), f[Y].max()); return p; } /** @brief Return the n-th corner of the rectangle. * Returns corners in the direction of growing angles, starting from * the one given by min(). For the standard coordinate system used @@ -242,7 +242,15 @@ public: * half of the width, the X interval will contain only the X coordinate * of the midpoint; same for height. */ void expandBy(C amount) { - f[X].expandBy(amount); f[Y].expandBy(amount); + expandBy(amount, amount); + } + /** @brief Expand the rectangle in both directions. + * Note that this is different from scaling. Negative values wil shrink the + * rectangle. If -x is larger than + * half of the width, the X interval will contain only the X coordinate + * of the midpoint; same for height. */ + void expandBy(C x, C y) { + f[X].expandBy(x); f[Y].expandBy(y); } /** @brief Expand the rectangle by the coordinates of the given point. * This will expand the width by the X coordinate of the point in both directions @@ -250,8 +258,8 @@ public: * shrink the rectangle. If -p[X] is larger than half of the width, * the X interval will contain only the X coordinate of the midpoint; * same for height. */ - void expandBy(CPoint const &p) { - f[X].expandBy(p[X]); f[Y].expandBy(p[Y]); + void expandBy(CPoint const &p) { + expandBy(p[X], p[Y]); } /// @} @@ -279,7 +287,7 @@ public: return *this; } /** @brief Test for equality of rectangles. */ - bool operator==(GenericRect const &o) const { return f[X] == o[X] && f[Y] == o[Y]; } + bool operator==(CRect const &o) const { return f[X] == o[X] && f[Y] == o[Y]; } /// @} }; @@ -290,10 +298,12 @@ public: template class GenericOptRect : public boost::optional::RectType> + , boost::equality_comparable< typename CoordTraits::OptRectType + , boost::equality_comparable< typename CoordTraits::OptRectType, typename CoordTraits::RectType , boost::orable< typename CoordTraits::OptRectType , boost::andable< typename CoordTraits::OptRectType , boost::andable< typename CoordTraits::OptRectType, typename CoordTraits::RectType - > > > + > > > > > { typedef typename CoordTraits::IntervalType CInterval; typedef typename CoordTraits::OptIntervalType OptCInterval; @@ -307,6 +317,7 @@ public: GenericOptRect() : Base() {} GenericOptRect(GenericRect const &a) : Base(CRect(a)) {} GenericOptRect(CPoint const &a, CPoint const &b) : Base(CRect(a, b)) {} + GenericOptRect(C x0, C y0, C x1, C y1) : Base(CRect(x0, y0, x1, y1)) {} /// Creates an empty OptRect when one of the argument intervals is empty. GenericOptRect(OptCInterval const &x_int, OptCInterval const &y_int) { if (x_int && y_int) { @@ -314,6 +325,7 @@ public: } // else, stay empty. } + /** @brief Create a rectangle from a range of points. * The resulting rectangle will contain all ponts from the range. * If the range contains no points, the result will be an empty rectangle. @@ -427,6 +439,16 @@ public: intersectWith(b); return *this; } + /** @brief Test for equality. + * All empty rectangles are equal. */ + bool operator==(OptCRect const &other) const { + if (!*this != !other) return false; + return *this ? (**this == *other) : true; + } + bool operator==(CRect const &other) const { + if (!*this) return false; + return **this == other; + } /// @} }; diff --git a/src/2geom/interval.h b/src/2geom/interval.h index 711eaa5e2..b1fac04d9 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -47,12 +47,6 @@ namespace Geom { -/** - * @brief Range of real numbers that can be empty. - * @ingroup Primitives - */ -typedef GenericOptInterval OptInterval; - /** * @brief Range of real numbers that is never empty. * @@ -128,8 +122,6 @@ public: /// @name Operators /// @{ - inline operator OptInterval() { return OptInterval(*this); } - // IMPL: ScalableConcept /** @brief Scale an interval */ Interval &operator*=(Coord s) { @@ -158,6 +150,12 @@ public: expandTo(mx * o.max()); return *this; } + bool operator==(IntInterval const &ii) const { + return min() == Coord(ii.min()) && max() == Coord(ii.max()); + } + bool operator==(Interval const &other) const { + return Base::operator==(other); + } /// @} /// @name Rounding to integer values @@ -177,6 +175,35 @@ public: /// @} }; +/** + * @brief Range of real numbers that can be empty. + * @ingroup Primitives + */ +class OptInterval + : public GenericOptInterval +{ + typedef GenericOptInterval Base; +public: + /// @name Create optionally empty intervals. + /// @{ + /** @brief Create an empty interval. */ + OptInterval() : Base() {} + /** @brief Wrap an existing interval. */ + OptInterval(Interval const &a) : Base(a) {} + /** @brief Create an interval containing a single point. */ + OptInterval(Coord u) : Base(u) {} + /** @brief Create an interval containing a range of numbers. */ + OptInterval(Coord u, Coord v) : Base(u,v) {} + OptInterval(Base const &b) : Base(b) {} + + /** @brief Promote from IntInterval. */ + OptInterval(IntInterval const &i) : Base(Interval(i)) {} + /** @brief Promote from OptIntInterval. */ + OptInterval(OptIntInterval const &i) : Base() { + if (i) *this = Interval(*i); + } +}; + // functions required for Python bindings inline Interval unify(Interval const &a, Interval const &b) { diff --git a/src/2geom/linear.h b/src/2geom/linear.h index 448ab3bb7..df6dd9904 100644 --- a/src/2geom/linear.h +++ b/src/2geom/linear.h @@ -55,7 +55,7 @@ class SBasis; class Linear{ public: double a[2]; - Linear() { a[0] = 0; a[1] = 0; } + Linear() {} Linear(double aa, double b) {a[0] = aa; a[1] = b;} Linear(double aa) {a[0] = aa; a[1] = aa;} diff --git a/src/2geom/rect.h b/src/2geom/rect.h index b79a0a04f..2516bcfa6 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -47,12 +47,6 @@ namespace Geom { -/** - * @brief Axis-aligned rectangle that can be empty. - * @ingroup Primitives - */ -typedef GenericOptRect OptRect; - /** * @brief Axis aligned, non-empty rectangle. * @ingroup Primitives @@ -118,9 +112,45 @@ public: /// @name Operators /// @{ Rect &operator*=(Affine const &m); + bool operator==(IntRect const &ir) const { + return f[X] == ir[X] && f[Y] == ir[Y]; + } + bool operator==(Rect const &other) const { + return Base::operator==(other); + } /// @} }; +/** + * @brief Axis-aligned rectangle that can be empty. + * @ingroup Primitives + */ +class OptRect + : public GenericOptRect +{ + typedef GenericOptRect Base; +public: + OptRect() : Base() {} + OptRect(Rect const &a) : Base(a) {} + OptRect(Point const &a, Point const &b) : Base(a, b) {} + OptRect(Coord x0, Coord y0, Coord x1, Coord y1) : Base(x0, y0, x1, y1) {} + OptRect(OptInterval const &x_int, OptInterval const &y_int) : Base(x_int, y_int) {} + OptRect(Base const &b) : Base(b) {} + + OptRect(IntRect const &r) : Base(Rect(r)) {} + OptRect(OptIntRect const &r) : Base() { + if (r) *this = Rect(*r); + } + // actually, the only reason we have this class, instead of typedefing + // to GenericOptRect, are the above constructors + bool operator==(OptRect const &other) const { + return Base::operator==(other); + } + bool operator==(Rect const &other) const { + return Base::operator==(other); + } +}; + Coord distanceSq(Point const &p, Rect const &rect); Coord distance(Point const &p, Rect const &rect); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 4688a58e3..34b0d7cab 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -376,16 +376,14 @@ sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky) } void -sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRRectL const &r) +sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, Geom::IntRect const &r) { g_return_if_fail (ca != NULL); g_return_if_fail (SP_IS_CANVAS_ARENA (ca)); - Geom::OptIntRect area = r.upgrade_2geom(); - if (!area) return; - Inkscape::DrawingContext ct(surface, area->min()); + Inkscape::DrawingContext ct(surface, r.min()); ca->drawing.update(Geom::IntRect::infinite(), ca->ctx); - ca->drawing.render(ct, *area); + ca->drawing.render(ct, r); } /* diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index f145a9c70..daab19d8e 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -61,7 +61,7 @@ GType sp_canvas_arena_get_type (void); void sp_canvas_arena_set_pick_delta (SPCanvasArena *ca, gdouble delta); void sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky); -void sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, NRRectL const &area); +void sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, Geom::IntRect const &area); G_END_DECLS diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 3ed1fa5a9..c0dabcc07 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -99,7 +99,7 @@ sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, g static void sp_grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) { - if ((x < buf->rect.x0) || (x >= buf->rect.x1)) + if ((x < buf->rect.left()) || (x >= buf->rect.right())) return; cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys); @@ -526,21 +526,21 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } cairo_save(buf->ct); - cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top()); cairo_set_line_width(buf->ct, 1.0); cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); // gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'. - // sc = screencoordinates ( for example "buf->rect.x0" is in screencoordinates ) + // sc = screencoordinates ( for example "buf->rect.left()" is in screencoordinates ) // bc = buffer patch coordinates // tl = topleft ; br = bottomright Geom::Point buf_tl_gc; Geom::Point buf_br_gc; - buf_tl_gc[Geom::X] = buf->rect.x0 - ow[Geom::X]; - buf_tl_gc[Geom::Y] = buf->rect.y0 - ow[Geom::Y]; - buf_br_gc[Geom::X] = buf->rect.x1 - ow[Geom::X]; - buf_br_gc[Geom::Y] = buf->rect.y1 - ow[Geom::Y]; + buf_tl_gc[Geom::X] = buf->rect.left() - ow[Geom::X]; + buf_tl_gc[Geom::Y] = buf->rect.top() - ow[Geom::Y]; + buf_br_gc[Geom::X] = buf->rect.right() - ow[Geom::X]; + buf_br_gc[Geom::Y] = buf->rect.bottom() - ow[Geom::Y]; gdouble x; gdouble y; @@ -549,15 +549,15 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // x-axis always goes from topleft to bottomright. (0,0) - (1,1) gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ; - gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.y0; - gint const xlinestart = round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw ); + gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.top(); + gint const xlinestart = round( (xstart_y_sc - buf->rect.left()*tan_angle[X] -ow[Geom::Y]) / lyw ); gint xlinenum = xlinestart; // lines starting on left side. - for (y = xstart_y_sc; y < buf->rect.y1; y += lyw, xlinenum++) { - gint const x0 = buf->rect.x0; + for (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.y1 - y) / tan_angle[X] ); - gint const y1 = buf->rect.y1; + gint const x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] ); + gint const y1 = buf->rect.bottom(); if (!scaled && (xlinenum % empspacing) != 0) { sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); @@ -566,11 +566,11 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } } // lines starting from top side - gdouble const xstart_x_sc = buf->rect.x0 + (lxw_x - (xstart_y_sc - buf->rect.y0) / tan_angle[X]) ; + gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ; xlinenum = xlinestart-1; - for (x = xstart_x_sc; x < buf->rect.x1; x += lxw_x, xlinenum--) { - gint const y0 = buf->rect.y0; - gint const y1 = buf->rect.y1; + for (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] ); @@ -585,27 +585,27 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X]; gint const ylinestart = round((ystart_x_sc - ow[Geom::X]) / spacing_ylines); gint ylinenum = ylinestart; - for (x = ystart_x_sc; x < buf->rect.x1; x += spacing_ylines, ylinenum++) { + for (x = ystart_x_sc; x < buf->rect.right(); x += spacing_ylines, ylinenum++) { gint const x0 = round(x); if (!scaled && (ylinenum % empspacing) != 0) { - sp_grid_vline (buf, x0, buf->rect.y0, buf->rect.y1 - 1, color); + sp_grid_vline (buf, x0, buf->rect.top(), buf->rect.bottom() - 1, color); } else { - sp_grid_vline (buf, x0, buf->rect.y0, buf->rect.y1 - 1, _empcolor); + sp_grid_vline (buf, x0, buf->rect.top(), buf->rect.bottom() - 1, _empcolor); } } // z-axis always goes from bottomleft to topright. (0,1) - (1,0) gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ; - gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.y0; - gint const zlinestart = round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw ); + gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.top(); + gint const zlinestart = round( (zstart_y_sc + buf->rect.left()*tan_angle[Z] - ow[Geom::Y]) / lyw ); gint zlinenum = zlinestart; // lines starting from left side - for (y = zstart_y_sc; y < buf->rect.y1; y += lyw, zlinenum++) { - gint const x0 = buf->rect.x0; + for (y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++) { + gint const x0 = buf->rect.left(); gint const y0 = round(y); - gint const x1 = x0 + round( (y - buf->rect.y0 ) / tan_angle[Z] ); - gint const y1 = buf->rect.y0; + gint const x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] ); + gint const y1 = buf->rect.top(); if (!scaled && (zlinenum % empspacing) != 0) { sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color); @@ -614,12 +614,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } } // draw lines from bottom-up - gdouble const zstart_x_sc = buf->rect.x0 + (y - buf->rect.y1) / tan_angle[Z] ; - for (x = zstart_x_sc; x < buf->rect.x1; x += lxw_z, zlinenum++) { - gint const y0 = buf->rect.y1; - gint const y1 = buf->rect.y0; + gdouble const zstart_x_sc = buf->rect.left() + (y - buf->rect.bottom()) / tan_angle[Z] ; + for (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.y1 - buf->rect.y0) / tan_angle[Z] ); + 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); diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 306b523ca..e015655a6 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -26,8 +26,6 @@ #include "display/cairo-utils.h" #include "helper/geom.h" -void nr_pixblock_render_bpath_rgba (Shape* theS,uint32_t color,NRRectL &area,char* destBuf,int stride); - static void sp_canvas_bpath_class_init (SPCanvasBPathClass *klass); static void sp_canvas_bpath_init (SPCanvasBPath *path); static void sp_canvas_bpath_destroy (GtkObject *object); @@ -139,7 +137,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) { SPCanvasBPath *cbp = SP_CANVAS_BPATH (item); - Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1)); + Geom::Rect area = buf->rect; if ( !cbp->curve || ((cbp->stroke_rgba & 0xff) == 0 && (cbp->fill_rgba & 0xff) == 0 ) || diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index b3ec73e78..38fe69628 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -834,94 +834,45 @@ CanvasXYGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/) static void grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba) { - if ((y < buf->rect.y0) || (y >= buf->rect.y1)) + if ((y < buf->rect.top()) || (y >= buf->rect.bottom())) return; cairo_move_to(buf->ct, 0.5 + xs, 0.5 + y); cairo_line_to(buf->ct, 0.5 + xe, 0.5 + y); ink_cairo_set_source_rgba32(buf->ct, rgba); cairo_stroke(buf->ct); -#if 0 - guint r, g, b, a; - gint x0, x1, x; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - x0 = MAX (buf->rect.x0, xs); - x1 = MIN (buf->rect.x1, xe + 1); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (x = x0; x < x1; x++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += 4; - } -#endif } static void grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) { - if ((x < buf->rect.x0) || (x >= buf->rect.x1)) + if ((x < buf->rect.left()) || (x >= buf->rect.right())) return; cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys); cairo_line_to(buf->ct, 0.5 + x, 0.5 + ye); ink_cairo_set_source_rgba32(buf->ct, rgba); cairo_stroke(buf->ct); - #if 0 - guint r, g, b, a; - gint y0, y1, y; - guchar *p; - r = NR_RGBA32_R(rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - y0 = MAX (buf->rect.y0, ys); - y1 = MIN (buf->rect.y1, ye + 1); - p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - for (y = y0; y < y1; y++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += buf->buf_rowstride; - } - #endif } static void grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) { - if ( (y < buf->rect.y0) || (y >= buf->rect.y1) - || (x < buf->rect.x0) || (x >= buf->rect.x1) ) + if ( (y < buf->rect.top()) || (y >= buf->rect.bottom()) + || (x < buf->rect.left()) || (x >= buf->rect.right()) ) return; cairo_rectangle(buf->ct, x, y, 1, 1); ink_cairo_set_source_rgba32(buf->ct, rgba); cairo_fill(buf->ct); - -#if 0 - guint r, g, b, a; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); -#endif } void CanvasXYGrid::Render (SPCanvasBuf *buf) { - gdouble const sxg = floor ((buf->rect.x0 - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X]; + gdouble const sxg = floor ((buf->rect.left() - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X]; gint const xlinestart = round((sxg - ow[Geom::X]) / sw[Geom::X]); - gdouble const syg = floor ((buf->rect.y0 - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y]; + gdouble const syg = floor ((buf->rect.top() - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y]; gint const ylinestart = round((syg - ow[Geom::Y]) / sw[Geom::Y]); //set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring) @@ -935,41 +886,41 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) } cairo_save(buf->ct); - cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top()); cairo_set_line_width(buf->ct, 1.0); cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); if (!render_dotted) { gint ylinenum; gdouble y; - for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) { + for (y = syg, ylinenum = ylinestart; y < buf->rect.bottom(); y += sw[Geom::Y], ylinenum++) { gint const y0 = round(y); if (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) { - grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color); + grid_hline (buf, y0, buf->rect.left(), buf->rect.right() - 1, color); } else { - grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, _empcolor); + grid_hline (buf, y0, buf->rect.left(), buf->rect.right() - 1, _empcolor); } } gint xlinenum; gdouble x; - for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) { + for (x = sxg, xlinenum = xlinestart; x < buf->rect.right(); x += sw[Geom::X], xlinenum++) { gint const ix = round(x); if (!scaled[Geom::X] && (xlinenum % empspacing) != 0) { - grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color); + grid_vline (buf, ix, buf->rect.top(), buf->rect.bottom(), color); } else { - grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, _empcolor); + grid_vline (buf, ix, buf->rect.top(), buf->rect.bottom(), _empcolor); } } } else { gint ylinenum; gdouble y; - for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) { + for (y = syg, ylinenum = ylinestart; y < buf->rect.bottom(); y += sw[Geom::Y], ylinenum++) { gint const iy = round(y); gint xlinenum; gdouble x; - for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) { + for (x = sxg, xlinenum = xlinestart; x < buf->rect.right(); x += sw[Geom::X], xlinenum++) { gint const ix = round(x); if ( (!scaled[Geom::X] && (xlinenum % empspacing) != 0) || (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 683e2f93c..185d10b15 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -116,8 +116,8 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) return; Geom::Point s = cl->s * cl->affine; - double offsetx = s[Geom::X] - buf->rect.x0; - double offsety = s[Geom::Y] - buf->rect.y0; + double offsetx = s[Geom::X] - buf->rect.left(); + double offsety = s[Geom::Y] - buf->rect.top(); offsetx -= anchor_offset_x; offsety -= anchor_offset_y; diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 0d2905d23..f2802c6fe 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -111,7 +111,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) SPGuideLine const *gl = SP_GUIDELINE (item); cairo_save(buf->ct); - cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top()); ink_cairo_set_source_rgba32(buf->ct, gl->rgba); cairo_set_line_width(buf->ct, 1); cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); @@ -134,49 +134,49 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) if ( Geom::are_near(normal_dt[Geom::Y], 0.) ) { // is vertical? int position = round(point_on_line_dt[Geom::X]); - cairo_move_to(buf->ct, position + 0.5, buf->rect.y0 + 0.5); - cairo_line_to(buf->ct, position + 0.5, buf->rect.y1 - 0.5); + cairo_move_to(buf->ct, position + 0.5, buf->rect.top() + 0.5); + cairo_line_to(buf->ct, position + 0.5, buf->rect.bottom() - 0.5); cairo_stroke(buf->ct); } else if ( Geom::are_near(normal_dt[Geom::X], 0.) ) { // is horizontal? int position = round(point_on_line_dt[Geom::Y]); - cairo_move_to(buf->ct, buf->rect.x0 + 0.5, position + 0.5); - cairo_line_to(buf->ct, buf->rect.x1 - 0.5, position + 0.5); + cairo_move_to(buf->ct, buf->rect.left() + 0.5, position + 0.5); + cairo_line_to(buf->ct, buf->rect.right() - 0.5, position + 0.5); cairo_stroke(buf->ct); } else { // render angled line. Once intersection has been detected, draw from there. Geom::Point parallel_to_line( normal_dt.ccw() ); //try to intersect with left vertical of rect - double y_intersect_left = (buf->rect.x0 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; - if ( (y_intersect_left >= buf->rect.y0) && (y_intersect_left <= buf->rect.y1) ) { + double y_intersect_left = (buf->rect.left() - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; + if ( (y_intersect_left >= buf->rect.top()) && (y_intersect_left <= buf->rect.bottom()) ) { // intersects with left vertical! - double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; - sp_guideline_drawline (buf, buf->rect.x0, static_cast(round(y_intersect_left)), buf->rect.x1, static_cast(round(y_intersect_right)), gl->rgba); + double y_intersect_right = (buf->rect.right() - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; + sp_guideline_drawline (buf, buf->rect.left(), static_cast(round(y_intersect_left)), buf->rect.right(), static_cast(round(y_intersect_right)), gl->rgba); goto end; } //try to intersect with right vertical of rect - double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; - if ( (y_intersect_right >= buf->rect.y0) && (y_intersect_right <= buf->rect.y1) ) { + double y_intersect_right = (buf->rect.right() - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; + if ( (y_intersect_right >= buf->rect.top()) && (y_intersect_right <= buf->rect.bottom()) ) { // intersects with right vertical! - sp_guideline_drawline (buf, buf->rect.x1, static_cast(round(y_intersect_right)), buf->rect.x0, static_cast(round(y_intersect_left)), gl->rgba); + sp_guideline_drawline (buf, buf->rect.right(), static_cast(round(y_intersect_right)), buf->rect.left(), static_cast(round(y_intersect_left)), gl->rgba); goto end; } //try to intersect with top horizontal of rect - double x_intersect_top = (buf->rect.y0 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; - if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { + double x_intersect_top = (buf->rect.top() - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; + if ( (x_intersect_top >= buf->rect.left()) && (x_intersect_top <= buf->rect.right()) ) { // intersects with top horizontal! - double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; - sp_guideline_drawline (buf, static_cast(round(x_intersect_top)), buf->rect.y0, static_cast(round(x_intersect_bottom)), buf->rect.y1, gl->rgba); + double x_intersect_bottom = (buf->rect.bottom() - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; + sp_guideline_drawline (buf, static_cast(round(x_intersect_top)), buf->rect.top(), static_cast(round(x_intersect_bottom)), buf->rect.bottom(), gl->rgba); goto end; } //try to intersect with bottom horizontal of rect - double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; - if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { + double x_intersect_bottom = (buf->rect.bottom() - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; + if ( (x_intersect_top >= buf->rect.left()) && (x_intersect_top <= buf->rect.right()) ) { // intersects with bottom horizontal! - sp_guideline_drawline (buf, static_cast(round(x_intersect_bottom)), buf->rect.y1, static_cast(round(x_intersect_top)), buf->rect.y0, gl->rgba); + sp_guideline_drawline (buf, static_cast(round(x_intersect_bottom)), buf->rect.bottom(), static_cast(round(x_intersect_top)), buf->rect.top(), gl->rgba); goto end; } } diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 6fa34bf0b..33718ed68 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -188,10 +188,6 @@ bool FilterColorMatrix::can_handle_affine(Geom::Affine const &) return true; } -void FilterColorMatrix::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/) -{ -} - double FilterColorMatrix::complexity(Geom::Affine const &) { return 2.0; diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index 5864a010e..5f21a4210 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -37,7 +37,6 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); virtual void set_type(FilterColorMatrixType type); diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index 887352f62..226a73cef 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -304,10 +304,6 @@ bool FilterComponentTransfer::can_handle_affine(Geom::Affine const &) return true; } -void FilterComponentTransfer::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/) -{ -} - double FilterComponentTransfer::complexity(Geom::Affine const &) { return 2.0; diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index 6d65ae6d1..558d097a8 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -37,7 +37,6 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); FilterComponentTransferType type[4]; diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 469baf346..5469aff88 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -202,14 +202,15 @@ void FilterConvolveMatrix::set_preserveAlpha(bool pa){ preserveAlpha = pa; } -void FilterConvolveMatrix::area_enlarge(NRRectL &area, Geom::Affine const &/*trans*/) +void FilterConvolveMatrix::area_enlarge(Geom::IntRect &area, Geom::Affine const &/*trans*/) { //Seems to me that since this filter's operation is resolution dependent, // some spurious pixels may still appear at the borders when low zooming or rotating. Needs a better fix. - area.x0 -= targetX; - area.y0 -= targetY; - area.x1 += orderX - targetX - 1; // This makes sure the last row/column in the original image corresponds to the last row/column in the new image that can be convolved without adjusting the boundary conditions). - area.y1 += orderY - targetY - 1; + area.setMin(area.min() - Geom::IntPoint(targetX, targetY)); + // This makes sure the last row/column in the original image corresponds + // to the last row/column in the new image that can be convolved without + // adjusting the boundary conditions). + area.setMax(area.max() + Geom::IntPoint(orderX - targetX - 1, orderY - targetY -1)); } double FilterConvolveMatrix::complexity(Geom::Affine const &) diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index 8b7fc35d1..c37fe721f 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -35,7 +35,7 @@ public: virtual ~FilterConvolveMatrix(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); void set_targetY(int coord); diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 14144ace5..c94df2d70 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -159,16 +159,13 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -void FilterDiffuseLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/) +void FilterDiffuseLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength // We expand the area by 1 in every direction to avoid artifacts on tile edges. // However, it means that edge pixels will be incorrect. - area.x0 -= 1; - area.x1 += 1; - area.y0 -= 1; - area.y1 += 1; + area.expandBy(1); } double FilterDiffuseLighting::complexity(Geom::Affine const &) diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index bb3ceccb3..0da6cc218 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -32,7 +32,7 @@ public: static FilterPrimitive *create(); virtual ~FilterDiffuseLighting(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); union { diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 75e310339..01c644bc1 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -125,7 +125,7 @@ void FilterDisplacementMap::set_channel_selector(int s, FilterDisplacementMapCha if (s == 1) Ychannel = ch; } -void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Affine const &trans) +void FilterDisplacementMap::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans) { //I assume scale is in user coordinates (?!?) //FIXME: trans should be multiplied by some primitiveunits2user, shouldn't it? @@ -134,10 +134,7 @@ void FilterDisplacementMap::area_enlarge(NRRectL &area, Geom::Affine const &tran double scaley = scale/2.*(std::fabs(trans[2])+std::fabs(trans[3])); //FIXME: no +2 should be there!... (noticable only for big scales at big zoom factor) - area.x0 -= (int)(scalex)+2; - area.x1 += (int)(scalex)+2; - area.y0 -= (int)(scaley)+2; - area.y1 += (int)(scaley)+2; + area.expandBy(scalex+2, scaley+2); } double FilterDisplacementMap::complexity(Geom::Affine const &) diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index 393a904c1..e4228323a 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -28,7 +28,7 @@ public: virtual ~FilterDisplacementMap(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); virtual void set_input(int slot); diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 5716c1bc5..7db14737b 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -81,11 +81,6 @@ void FilterFlood::set_opacity(double o) { void FilterFlood::set_icc(SVGICCColor *icc_color) { icc = icc_color; } - -void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/) -{ -} - double FilterFlood::complexity(Geom::Affine const &) { // flood is actually less expensive than normal rendering, diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index f744e9f48..8568502ff 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -27,7 +27,6 @@ public: virtual void render_cairo(FilterSlot &slot); virtual bool can_handle_affine(Geom::Affine const &); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); virtual bool uses_background() { return false; } diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 8a7244e02..7a65519e0 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -667,17 +667,14 @@ void FilterGaussian::render_cairo(FilterSlot &slot) } } -void FilterGaussian::area_enlarge(NRRectL &area, Geom::Affine const &trans) +void FilterGaussian::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans) { int area_x = _effect_area_scr(_deviation_x * trans.expansionX()); int area_y = _effect_area_scr(_deviation_y * trans.expansionY()); // maximum is used because rotations can mix up these directions // TODO: calculate a more tight-fitting rendering area int area_max = std::max(area_x, area_y); - area.x0 -= area_max; - area.x1 += area_max; - area.y0 -= area_max; - area.y1 += area_max; + area.expandBy(area_max); } bool FilterGaussian::can_handle_affine(Geom::Affine const &) diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index f52bea01e..1c35a0f1d 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -35,7 +35,7 @@ public: virtual ~FilterGaussian(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &m); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &m); virtual bool can_handle_affine(Geom::Affine const &m); virtual double complexity(Geom::Affine const &ctm); diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index 9e43d01f3..b6aea1b06 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -147,15 +147,12 @@ void FilterMorphology::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -void FilterMorphology::area_enlarge(NRRectL &area, Geom::Affine const &trans) +void FilterMorphology::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans) { int enlarge_x = ceil(xradius * trans.expansionX()); int enlarge_y = ceil(yradius * trans.expansionY()); - area.x0 -= enlarge_x; - area.x1 += enlarge_x; - area.y0 -= enlarge_y; - area.y1 += enlarge_y; + area.expandBy(enlarge_x, enlarge_y); } double FilterMorphology::complexity(Geom::Affine const &trans) diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index 512eca83c..0574ff4ad 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -32,7 +32,7 @@ public: virtual ~FilterMorphology(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); void set_operator(FilterMorphologyOperator &o); diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index db8b6d92a..da46095ef 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -65,24 +65,30 @@ void FilterOffset::set_dy(double amount) { dy = amount; } -void FilterOffset::area_enlarge(NRRectL &area, Geom::Affine const &trans) +void FilterOffset::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans) { Geom::Point offset(dx, dy); offset *= trans; offset[X] -= trans[4]; offset[Y] -= trans[5]; + double x0, y0, x1, y1; + x0 = area.left(); + y0 = area.top(); + x1 = area.right(); + y1 = area.bottom(); if (offset[X] > 0) { - area.x0 -= ceil(offset[X]); + x0 -= ceil(offset[X]); } else { - area.x1 -= floor(offset[X]); + x1 -= floor(offset[X]); } if (offset[Y] > 0) { - area.y0 -= ceil(offset[Y]); + y0 -= ceil(offset[Y]); } else { - area.y1 -= floor(offset[Y]); + y1 -= floor(offset[Y]); } + area = Geom::IntRect(x0, y0, x1, y1); } double FilterOffset::complexity(Geom::Affine const &) diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index 841be6008..5551131f0 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -27,7 +27,7 @@ public: virtual ~FilterOffset(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual bool can_handle_affine(Geom::Affine const &); virtual double complexity(Geom::Affine const &ctm); diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index 0a445b9e6..c6bd8a74e 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -53,7 +53,7 @@ void FilterPrimitive::render_cairo(FilterSlot &slot) slot.set(_output, in); } -void FilterPrimitive::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*m*/) +void FilterPrimitive::area_enlarge(Geom::IntRect &/*area*/, Geom::Affine const &/*m*/) { // This doesn't need to do anything by default } diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 501d76447..42a1c98b7 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -12,11 +12,10 @@ #define SEEN_NR_FILTER_PRIMITIVE_H #include <2geom/forward.h> +#include <2geom/rect.h> #include "display/nr-filter-types.h" #include "svg/svg-length.h" -struct NRRectL; - namespace Inkscape { namespace Filters { @@ -30,7 +29,7 @@ public: virtual void render_cairo(FilterSlot &slot); virtual int render(FilterSlot & /*slot*/, FilterUnits const & /*units*/) { return 0; } - virtual void area_enlarge(NRRectL &area, Geom::Affine const &m); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &m); /** * Sets the input slot number 'slot' to be used as input in rendering diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index d41b5180b..805027bfe 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -67,7 +67,6 @@ public: FilterUnits const &get_units() const { return _units; } Geom::Rect get_slot_area() const; - NRRectL get_sg_area() const { NRRectL ret(_source_graphic_area); return ret; } private: typedef std::map SlotMap; @@ -77,7 +76,6 @@ private: //Geom::Rect _source_bbox; ///< bounding box of source graphic surface //Geom::Rect _intermediate_bbox; ///< bounding box of intermediate surfaces -// NRRectL _slot_area; int _slot_w, _slot_h; double _slot_x, _slot_y; cairo_surface_t *_source_graphic; diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index c28fd485a..ddb0c06eb 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -174,14 +174,10 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } -void FilterSpecularLighting::area_enlarge(NRRectL &area, Geom::Affine const & /*trans*/) +void FilterSpecularLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength - - area.x0 -= 1; - area.x1 += 1; - area.y0 -= 1; - area.y1 += 1; + area.expandBy(1); } double FilterSpecularLighting::complexity(Geom::Affine const &) diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 8471b70b0..33ea17a87 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -33,7 +33,7 @@ public: virtual ~FilterSpecularLighting(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); + virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); union { diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 4aadde2aa..6680e7a46 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -41,10 +41,6 @@ void FilterTile::render_cairo(FilterSlot &slot) slot.set(_output, in); } -void FilterTile::area_enlarge(NRRectL &/*area*/, Geom::Affine const &/*trans*/) -{ -} - double FilterTile::complexity(Geom::Affine const &) { return 1.0; diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index 37e257f79..dc5b99a42 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -26,7 +26,6 @@ public: virtual ~FilterTile(); virtual void render_cairo(FilterSlot &slot); - virtual void area_enlarge(NRRectL &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); }; diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 450ce689d..6e3eb91d5 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -177,11 +177,9 @@ void Filter::set_primitive_units(SPFilterUnits unit) { } void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item) const { - NRRectL b(bbox); for (unsigned i = 0 ; i < _primitive.size() ; i++) { - if (_primitive[i]) _primitive[i]->area_enlarge(b, item->ctm()); + if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm()); } - bbox = *b.upgrade_2geom(); /* TODO: something. See images at the bottom of filters.svg with medium-low diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index b4d2633bb..f4f0c485a 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -112,7 +112,7 @@ sp_ctrl_init (SPCtrl *ctrl) // If moveto() is called then it will not set _moved to true because we're initially already at (0, 0) ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen - ctrl->box.x0 = ctrl->box.y0 = ctrl->box.x1 = ctrl->box.y1 = 0; + new (&ctrl->box) Geom::IntRect(0,0,0,0); ctrl->cache = NULL; ctrl->pixbuf = NULL; @@ -232,7 +232,7 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla if (!ctrl->_moved) return; if (ctrl->shown) { - sp_canvas_request_redraw (item->canvas, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1); + sp_canvas_request_redraw (item->canvas, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1); } if (!ctrl->defined) return; @@ -278,12 +278,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla break; } - ctrl->box.x0 = x; - ctrl->box.y0 = y; - ctrl->box.x1 = ctrl->box.x0 + 2 * ctrl->span; - ctrl->box.y1 = ctrl->box.y0 + 2 * ctrl->span; - - sp_canvas_update_bbox (item, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1); + ctrl->box = Geom::IntRect::from_xywh(x, y, 2*ctrl->span, 2*ctrl->span); + sp_canvas_update_bbox (item, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1); } static double @@ -293,11 +289,7 @@ sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) *actual_item = item; - double const x = p[Geom::X]; - double const y = p[Geom::Y]; - - if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0; - + if (ctrl->box.contains(p.floor())) return 0.0; return 1e18; } @@ -519,8 +511,8 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) // 1. Copy the affected part of output to a temporary surface cairo_surface_t *work = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); cairo_t *cr = cairo_create(work); - cairo_translate(cr, -ctrl->box.x0, -ctrl->box.y0); - cairo_set_source_surface(cr, cairo_get_target(buf->ct), buf->rect.x0, buf->rect.y0); + cairo_translate(cr, -ctrl->box.left(), -ctrl->box.top()); + cairo_set_source_surface(cr, cairo_get_target(buf->ct), buf->rect.left(), buf->rect.top()); cairo_paint(cr); cairo_destroy(cr); @@ -551,8 +543,8 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) // 3. Replace the affected part of output with contents of temporary surface cairo_save(buf->ct); cairo_set_source_surface(buf->ct, work, - ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0); - cairo_rectangle(buf->ct, ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0, w, h); + ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top()); + cairo_rectangle(buf->ct, ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top(), w, h); cairo_clip(buf->ct); cairo_set_operator(buf->ct, CAIRO_OPERATOR_SOURCE); cairo_paint(buf->ct); @@ -562,7 +554,7 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_surface_t *cache = cairo_image_surface_create_for_data( reinterpret_cast(ctrl->cache), CAIRO_FORMAT_ARGB32, w, h, w*4); cairo_set_source_surface(buf->ct, cache, - ctrl->box.x0 - buf->rect.x0, ctrl->box.y0 - buf->rect.y0); + ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top()); cairo_paint(buf->ct); cairo_surface_destroy(cache); } diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 4f114eac6..88cae28fd 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -48,7 +48,7 @@ struct SPCtrl : public SPCanvasItem { guint32 stroke_color; bool _moved; - NRRectL box; /* NB! x1 & y1 are included */ + Geom::IntRect box; /* NB! x1 & y1 are included */ guint32 *cache; GdkPixbuf * pixbuf; diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index b4539841b..c0e08c00a 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -132,7 +132,7 @@ void CtrlRect::render(SPCanvasBuf *buf) if ( area_w_shadow.intersects(buf->rect) ) { cairo_save(buf->ct); - cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top()); cairo_set_line_width(buf->ct, 1); if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0); cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index d1ea842fd..78936009b 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -38,15 +38,8 @@ sp_canvas_item_reset_bounds (SPCanvasItem *item) item->y2 = 0.0; } -void sp_canvas_prepare_buffer(SPCanvasBuf * /*buf*/) +void sp_canvas_prepare_buffer(SPCanvasBuf *) { - /*if (buf->is_empty) { - int y; - for (y = buf->rect.y0; y < buf->rect.y1; y++) { - memset (buf->buf + (y - buf->rect.y0) * buf->buf_rowstride, 0, 4 * (buf->rect.x1 - buf->rect.x0)); - } - buf->is_empty = false; - }*/ } Geom::Affine sp_canvas_item_i2p_affine (SPCanvasItem * item) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 7d6727ff3..a4c8500ed 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -866,10 +866,10 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf) for (GList *list = group->items; list; list = list->next) { SPCanvasItem *child = (SPCanvasItem *)list->data; if (child->flags & SP_CANVAS_ITEM_VISIBLE) { - if ((child->x1 < buf->rect.x1) && - (child->y1 < buf->rect.y1) && - (child->x2 > buf->rect.x0) && - (child->y2 > buf->rect.y0)) { + if ((child->x1 < buf->rect.right()) && + (child->y1 < buf->rect.bottom()) && + (child->x2 > buf->rect.left()) && + (child->y2 > buf->rect.top())) { if (SP_CANVAS_ITEM_GET_CLASS (child)->render) SP_CANVAS_ITEM_GET_CLASS (child)->render (child, buf); } @@ -963,8 +963,8 @@ static gint sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event); static GtkWidgetClass *canvas_parent_class; static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb); -static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb); -static void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val); +static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area); +static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val); static int do_update (SPCanvas *canvas); /** @@ -1634,46 +1634,38 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) return status; } -static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int /*sw*/) +static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/) { GtkWidget *widget = GTK_WIDGET (canvas); // Mark the region clean - sp_canvas_mark_rect(canvas, x0, y0, x1, y1, 0); + sp_canvas_mark_rect(canvas, paint_rect, 0); SPCanvasBuf buf; buf.buf = NULL; buf.buf_rowstride = 0; - buf.rect.x0 = x0; - buf.rect.y0 = y0; - buf.rect.x1 = x1; - buf.rect.y1 = y1; - buf.visible_rect.x0 = draw_x1; - buf.visible_rect.y0 = draw_y1; - buf.visible_rect.x1 = draw_x2; - buf.visible_rect.y1 = draw_y2; + buf.rect = paint_rect; + buf.visible_rect = canvas_rect; buf.is_empty = true; //buf.ct = gdk_cairo_create(widget->window); /* cairo_t *xctt = gdk_cairo_create(widget->window); - cairo_translate(xctt, x0 - canvas->x0, y0 - canvas->y0); + cairo_translate(xctt, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); cairo_set_source_rgb(xctt, 1,0,0); - cairo_rectangle(xctt, 0, 0, x1-x0, y1-y0); + cairo_rectangle(xctt, 0, 0, paint_rect.width(), paint_rect.height()); cairo_fill(xctt); cairo_destroy(xctt); //*/ // create temporary surface - int w = x1 - x0; - int h = y1 - y0; - cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0); + cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height()); buf.ct = cairo_create(imgs); //cairo_translate(buf.ct, -x0, -y0); // fix coordinates, clip all drawing to the tile and clear the background - //cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); - //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_translate(buf.ct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); + //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rect.height()); //cairo_set_line_width(buf.ct, 3); //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); //cairo_stroke_preserve(buf.ct); @@ -1681,7 +1673,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]); cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); - //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rec.height()); cairo_paint(buf.ct); cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER); @@ -1707,9 +1699,9 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int cairo_surface_flush(imgs); unsigned char *px = cairo_image_surface_get_data(imgs); int stride = cairo_image_surface_get_stride(imgs); - for (int i=0; iwindow); - cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0); - cairo_rectangle(xct, 0, 0, x1-x0, y1-y0); + cairo_translate(xct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); + cairo_rectangle(xct, 0, 0, paint_rect.width(), paint_rect.height()); cairo_clip(xct); cairo_set_source_surface(xct, imgs, 0, 0); cairo_set_operator(xct, CAIRO_OPERATOR_SOURCE); @@ -1734,7 +1726,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int struct PaintRectSetup { SPCanvas* canvas; - NRRectL big_rect; + Geom::IntRect big_rect; GTimeVal start_time; int max_pixels; Geom::Point mouse_loc; @@ -1747,7 +1739,7 @@ struct PaintRectSetup { * @return true if the drawing completes */ static int -sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) +sp_canvas_paint_rect_internal (PaintRectSetup const *setup, Geom::IntRect const &this_rect) { GTimeVal now; g_get_current_time (&now); @@ -1782,8 +1774,8 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) } // Find the optimal buffer dimensions - int bw = this_rect.x1 - this_rect.x0; - int bh = this_rect.y1 - this_rect.y0; + int bw = this_rect.width(); + int bh = this_rect.height(); if ((bw < 1) || (bh < 1)) return 0; @@ -1799,16 +1791,12 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) gdk_window_begin_paint_rect(window, &r);*/ sp_canvas_paint_single_buffer (setup->canvas, - this_rect.x0, this_rect.y0, - this_rect.x1, this_rect.y1, - setup->big_rect.x0, setup->big_rect.y0, - setup->big_rect.x1, setup->big_rect.y1, bw); + this_rect, setup->big_rect, bw); //gdk_window_end_paint(window); return 1; } - NRRectL lo = this_rect; - NRRectL hi = this_rect; + Geom::IntRect lo, hi; /* This test determines the redraw strategy: @@ -1826,13 +1814,12 @@ faster. The default for now is the strips mode. */ if (bw < bh || bh < 2 * TILE_SIZE) { - // to correctly calculate the mean of two ints, we need to sum them into a larger int type - int mid = ((long long) this_rect.x0 + (long long) this_rect.x1) / 2; + int mid = this_rect[Geom::X].middle(); // Make sure that mid lies on a tile boundary mid = (mid / TILE_SIZE) * TILE_SIZE; - lo.x1 = mid; - hi.x0 = mid; + lo = Geom::IntRect(this_rect.left(), this_rect.top(), mid, this_rect.bottom()); + hi = Geom::IntRect(mid, this_rect.top(), this_rect.right(), this_rect.bottom()); if (setup->mouse_loc[Geom::X] < mid) { // Always paint towards the mouse first @@ -1843,13 +1830,12 @@ The default for now is the strips mode. && sp_canvas_paint_rect_internal(setup, lo); } } else { - // to correctly calculate the mean of two ints, we need to sum them into a larger int type - int mid = ((long long) this_rect.y0 + (long long) this_rect.y1) / 2; + int mid = this_rect[Geom::Y].middle(); // Make sure that mid lies on a tile boundary mid = (mid / TILE_SIZE) * TILE_SIZE; - lo.y1 = mid; - hi.y0 = mid; + lo = Geom::IntRect(this_rect.left(), this_rect.top(), this_rect.right(), mid); + hi = Geom::IntRect(this_rect.left(), mid, this_rect.right(), this_rect.bottom()); if (setup->mouse_loc[Geom::Y] < mid) { // Always paint towards the mouse first @@ -1873,22 +1859,19 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) { g_return_val_if_fail (!canvas->need_update, false); - NRRectL rect; - rect.x0 = xx0; - rect.x1 = xx1; - rect.y0 = yy0; - rect.y1 = yy1; + Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + GTK_WIDGET (canvas)->allocation.width, GTK_WIDGET (canvas)->allocation.height); + Geom::IntRect paint_rect(xx0, yy0, xx1, yy1); - // Clip rect-to-draw by the current visible area - rect.x0 = MAX (rect.x0, canvas->x0); - rect.y0 = MAX (rect.y0, canvas->y0); - rect.x1 = MIN (rect.x1, canvas->x0/*draw_x1*/ + GTK_WIDGET (canvas)->allocation.width); - rect.y1 = MIN (rect.y1, canvas->y0/*draw_y1*/ + GTK_WIDGET (canvas)->allocation.height); + Geom::OptIntRect area = paint_rect & canvas_rect; + if (!area || area->hasZeroArea()) return 0; + + paint_rect = *area; PaintRectSetup setup; setup.canvas = canvas; - setup.big_rect = rect; + setup.big_rect = paint_rect; // Save the mouse location gint x, y; @@ -1909,7 +1892,7 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) g_get_current_time(&(setup.start_time)); // Go - return sp_canvas_paint_rect_internal(&setup, rect); + return sp_canvas_paint_rect_internal(&setup, paint_rect); } /** @@ -1950,14 +1933,11 @@ sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event) gdk_region_get_rectangles (event->region, &rects, &n_rects); for (int i = 0; i < n_rects; i++) { - NRRectL rect; - - rect.x0 = rects[i].x + canvas->x0; - rect.y0 = rects[i].y + canvas->y0; - rect.x1 = rect.x0 + rects[i].width; - rect.y1 = rect.y0 + rects[i].height; + Geom::IntRect r = Geom::IntRect::from_xywh( + rects[i].x + canvas->x0, rects[i].y + canvas->y0, + rects[i].width, rects[i].height); - sp_canvas_request_redraw (canvas, rect.x0, rect.y0, rect.x1, rect.y1); + sp_canvas_request_redraw (canvas, r.left(), r.top(), r.right(), r.bottom()); } if (n_rects > 0) @@ -2225,30 +2205,21 @@ sp_canvas_request_update (SPCanvas *canvas) void sp_canvas_request_redraw (SPCanvas *canvas, int x0, int y0, int x1, int y1) { - NRRectL bbox; - NRRectL visible; - NRRectL clip; - g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); if (!gtk_widget_is_drawable ( GTK_WIDGET (canvas))) return; if ((x0 >= x1) || (y0 >= y1)) return; - bbox.x0 = x0; - bbox.y0 = y0; - bbox.x1 = x1; - bbox.y1 = y1; - - visible.x0 = canvas->x0; - visible.y0 = canvas->y0; - visible.x1 = visible.x0 + GTK_WIDGET (canvas)->allocation.width; - visible.y1 = visible.y0 + GTK_WIDGET (canvas)->allocation.height; - - nr_rect_l_intersect (&clip, &bbox, &visible); - - sp_canvas_dirty_rect(canvas, clip.x0, clip.y0, clip.x1, clip.y1); - add_idle (canvas); + Geom::IntRect bbox(x0, y0, x1, y1); + Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + GTK_WIDGET (canvas)->allocation.width, GTK_WIDGET (canvas)->allocation.height); + + Geom::OptIntRect clip = bbox & canvas_rect; + if (clip) { + sp_canvas_dirty_rect(canvas, *clip); + add_idle (canvas); + } } /** @@ -2386,24 +2357,21 @@ static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int /* * Helper that queues a canvas rectangle for redraw */ -static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb) { +static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) { canvas->need_redraw = TRUE; - sp_canvas_mark_rect(canvas, nl, nt, nr, nb, 1); + sp_canvas_mark_rect(canvas, area, 1); } /** * Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise) */ -void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val) +void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val) { - if ( nl >= nr || nt >= nb ) { - return; - } - int tl=sp_canvas_tile_floor(nl); - int tt=sp_canvas_tile_floor(nt); - int tr=sp_canvas_tile_ceil(nr); - int tb=sp_canvas_tile_ceil(nb); + int tl=sp_canvas_tile_floor(area.left()); + int tt=sp_canvas_tile_floor(area.top()); + int tr=sp_canvas_tile_ceil(area.right()); + int tb=sp_canvas_tile_ceil(area.bottom()); if ( tl >= canvas->tRight || tr <= canvas->tLeft || tt >= canvas->tBottom || tb <= canvas->tTop ) return; if ( tl < canvas->tLeft ) tl=canvas->tLeft; if ( tr > canvas->tRight ) tr=canvas->tRight; diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index f284afdf2..9e716b69c 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -60,8 +60,8 @@ enum { */ struct SPCanvasBuf { cairo_t *ct; - NRRectL rect; - NRRectL visible_rect; + Geom::IntRect rect; + Geom::IntRect visible_rect; unsigned char *buf; int buf_rowstride; diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index c185234d4..cf70f324e 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -113,8 +113,8 @@ sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf) Geom::Point s = cl->s * cl->affine; Geom::Point e = cl->e * cl->affine; - cairo_move_to (buf->ct, s[Geom::X] - buf->rect.x0, s[Geom::Y] - buf->rect.y0); - cairo_line_to (buf->ct, e[Geom::X] - buf->rect.x0, e[Geom::Y] - buf->rect.y0); + cairo_move_to (buf->ct, s[Geom::X] - buf->rect.left(), s[Geom::Y] - buf->rect.top()); + cairo_line_to (buf->ct, e[Geom::X] - buf->rect.left(), e[Geom::Y] - buf->rect.top()); cairo_stroke(buf->ct); } diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp index 1cf7dded0..3a29b9b7c 100644 --- a/src/display/sp-ctrlpoint.cpp +++ b/src/display/sp-ctrlpoint.cpp @@ -105,7 +105,7 @@ sp_ctrlpoint_render (SPCanvasItem *item, SPCanvasBuf *buf) Geom::Point pt = cp->pt * cp->affine; - cairo_arc(buf->ct, pt[Geom::X] - buf->rect.x0, pt[Geom::Y] - buf->rect.y0, cp->radius, 0.0, 2 * M_PI); + cairo_arc(buf->ct, pt[Geom::X] - buf->rect.left(), pt[Geom::Y] - buf->rect.top(), cp->radius, 0.0, 2 * M_PI); cairo_stroke(buf->ct); } diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index b39886178..8cdd8170b 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -97,15 +97,13 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf) { SPCtrlQuadr *cq = SP_CTRLQUADR (item); - //Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1)); - if (!buf->ct) return; // RGB / BGR cairo_new_path(buf->ct); - Geom::Point min = Geom::Point(buf->rect.x0, buf->rect.y0); + Geom::Point min = buf->rect.min(); Geom::Point p1 = (cq->p1 * cq->affine) - min; Geom::Point p2 = (cq->p2 * cq->affine) - min; diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 9fbbcdc27..d91642bd2 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -225,25 +225,15 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv Geom::Rect r(dc->centre, dc->centre); r.expandBy(rw); if (!r.hasZeroArea()) { - NRRectL area; - area.x0 = r[Geom::X].min(); - area.y0 = r[Geom::Y].min(); - area.x1 = r[Geom::X].max(); - area.y1 = r[Geom::Y].max(); - int w = area.x1 - area.x0; - int h = area.y1 - area.y0; - cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + Geom::IntRect area = r.roundOutwards(); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height()); sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); ink_cairo_surface_average_color_premul(s, R, G, B, A); cairo_surface_destroy(s); } } else { // pick single pixel - NRRectL area; - area.x0 = floor(event->button.x); - area.y0 = floor(event->button.y); - area.x1 = area.x0 + 1; - area.y1 = area.y0 + 1; + Geom::IntRect area = Geom::IntRect::from_xywh(floor(event->button.x), floor(event->button.y), 1, 1); cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); ink_cairo_surface_average_color_premul(s, R, G, B, A); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index a3a665b1c..5bc258dbc 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -441,11 +441,7 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc) if (dc->trace_bg) { // pick single pixel double R, G, B, A; - NRRectL area; - area.x0 = floor(brush_w[Geom::X]); - area.y0 = floor(brush_w[Geom::Y]); - area.x1 = area.x0 + 1; - area.y1 = area.y0 + 1; + Geom::IntRect area = Geom::IntRect::from_xywh(brush_w.floor(), Geom::IntPoint(1, 1)); cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(SP_EVENT_CONTEXT(dc)->desktop)), s, area); ink_cairo_surface_average_color_premul(s, R, G, B, A); diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 78e90c34f..6b5d4fd95 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -112,7 +112,6 @@ public: // transforms a description in a polyline (for stroking and filling) // treshhold is the max length^2 (sort of) void Convert (double treshhold); - void Convert(NRRectL *area, double treshhold); void ConvertEvenLines (double treshhold); // decomposes line segments too, for later recomposition // same function for use when you want to later recompose the curves from the polyline void ConvertWithBackData (double treshhold); diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index 57609d1a2..74a057d06 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -401,282 +401,6 @@ void Path::Convert(double treshhold) } } -#define POINT_RELATION_TO_AREA(pt, area) ((pt)[0] < (area)->x0 ? 1 : ((pt)[0] > (area)->x1 ? 2 : ((pt)[1] < (area)->y0 ? 3 : ((pt)[1] > (area)->y1 ? 4 : 0)))) - -void Path::Convert(NRRectL *area, double treshhold) -{ - if ( descr_flags & descr_adding_bezier ) { - CancelBezier(); - } - - if ( descr_flags & descr_doing_subpath ) { - CloseSubpath(); - } - - SetBackData(false); - ResetPoints(); - if ( descr_cmd.empty() ) { - return; - } - - Geom::Point curX; - int curP = 1; - int lastMoveTo = 0; - short last_point_relation = 0; - short curent_point_relation = 0; - bool last_start_elimination = false; - bool start_elimination = false; - bool replace = false; - - // first point - { - int const firstTyp = descr_cmd[0]->getType(); - if ( firstTyp == descr_moveto ) { - curX = dynamic_cast(descr_cmd[0])->p; - } else { - curP = 0; - curX[0] = curX[1] = 0; - } - - last_point_relation = POINT_RELATION_TO_AREA(curX, area); - lastMoveTo = AddPoint(curX, true); - } - descr_cmd[0]->associated = lastMoveTo; - - // process nodes one by one - while ( curP < int(descr_cmd.size()) ) { - - int const nType = descr_cmd[curP]->getType(); - Geom::Point nextX; - - switch (nType) { - case descr_forced: { - descr_cmd[curP]->associated = AddForcedPoint(curX); - last_point_relation = 0; - curP++; - break; - } - - case descr_moveto: { - PathDescrMoveTo *nData = dynamic_cast(descr_cmd[curP]); - nextX = nData->p; - lastMoveTo = AddPoint(nextX, true); - descr_cmd[curP]->associated = lastMoveTo; - - last_point_relation = POINT_RELATION_TO_AREA(nextX, area); - start_elimination = false; - - curP++; - break; - } - - case descr_close: { - nextX = pts[lastMoveTo].p; - descr_cmd[curP]->associated = AddPoint(nextX, false); - if ( descr_cmd[curP]->associated < 0 ) { - if ( curP == 0 ) { - descr_cmd[curP]->associated = 0; - } else { - descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated; - } - } - if ( descr_cmd[curP]->associated > 0 ) { - pts[descr_cmd[curP]->associated].closed = true; - } - last_point_relation = 0; - curP++; - break; - } - - case descr_lineto: { - PathDescrLineTo *nData = dynamic_cast(descr_cmd[curP]); - nextX = nData->p; - curent_point_relation = POINT_RELATION_TO_AREA(nextX, area); - replace = false; - last_start_elimination = start_elimination; - if (curent_point_relation > 0 && curent_point_relation == last_point_relation) { - if (!start_elimination) { - start_elimination = true; - } else { - replace = true; - descr_cmd[curP]->associated = ReplacePoint(nextX); - } - } else { - start_elimination = false; - } - - if (!replace) { - descr_cmd[curP]->associated = AddPoint(nextX, false); - } - - if ( descr_cmd[curP]->associated < 0 ) { - // point is not added as position is equal to the last added - start_elimination = last_start_elimination; - if ( curP == 0 ) { - descr_cmd[curP]->associated = 0; - } else { - descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated; - } - } - last_point_relation = curent_point_relation; - curP++; - break; - } - - case descr_cubicto: { - PathDescrCubicTo *nData = dynamic_cast(descr_cmd[curP]); - nextX = nData->p; - - curent_point_relation = POINT_RELATION_TO_AREA(nextX, area); - replace = false; - last_start_elimination = start_elimination; - if (curent_point_relation > 0 && curent_point_relation == last_point_relation && - curent_point_relation == POINT_RELATION_TO_AREA(curX + (nData->start), area) && - curent_point_relation == POINT_RELATION_TO_AREA(nextX + (nData->end), area)) - { - if (!start_elimination) { - start_elimination = true; - } else { - replace = true; - descr_cmd[curP]->associated = ReplacePoint(nextX); - } - } else { - start_elimination = false; - } - - if (!replace) { - RecCubicTo(curX, nData->start, nextX, nData->end, treshhold, 8); - descr_cmd[curP]->associated = AddPoint(nextX,false); - } - - if ( descr_cmd[curP]->associated < 0 ) { - // point is not added as position is equal to the last added - start_elimination = last_start_elimination; - if ( curP == 0 ) { - descr_cmd[curP]->associated = 0; - } else { - descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated; - } - } - last_point_relation = curent_point_relation; - curP++; - break; - } - - case descr_arcto: { - PathDescrArcTo *nData = dynamic_cast(descr_cmd[curP]); - nextX = nData->p; - DoArc(curX, nextX, nData->rx, nData->ry, nData->angle, nData->large, nData->clockwise, treshhold); - descr_cmd[curP]->associated = AddPoint(nextX, false); - if ( descr_cmd[curP]->associated < 0 ) { - if ( curP == 0 ) { - descr_cmd[curP]->associated = 0; - } else { - descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated; - } - } - last_point_relation = 0; - - curP++; - break; - } - - case descr_bezierto: { - PathDescrBezierTo *nBData = dynamic_cast(descr_cmd[curP]); - int nbInterm = nBData->nb; - nextX = nBData->p; - int curBD = curP; - - curP++; - int ip = curP; - PathDescrIntermBezierTo *nData = dynamic_cast(descr_cmd[ip]); - - if ( nbInterm == 1 ) { - Geom::Point const midX = nData->p; - RecBezierTo(midX, curX, nextX, treshhold, 8); - } else if ( nbInterm > 1 ) { - Geom::Point bx = curX; - Geom::Point cx = curX; - Geom::Point dx = curX; - - dx = nData->p; - ip++; - nData = dynamic_cast(descr_cmd[ip]); - - cx = 2 * bx - dx; - - for (int k = 0; k < nbInterm - 1; k++) { - bx = cx; - cx = dx; - - dx = nData->p; - ip++; - nData = dynamic_cast(descr_cmd[ip]); - - Geom::Point stx = (bx + cx) / 2; - if ( k > 0 ) { - descr_cmd[ip - 2]->associated = AddPoint(stx, false); - if ( descr_cmd[ip - 2]->associated < 0 ) { - if ( curP == 0 ) { - descr_cmd[ip - 2]->associated = 0; - } else { - descr_cmd[ip - 2]->associated = descr_cmd[ip - 3]->associated; - } - } - } - - { - Geom::Point const mx = (cx + dx) / 2; - RecBezierTo(cx, stx, mx, treshhold, 8); - } - } - - { - bx = cx; - cx = dx; - - dx = nextX; - dx = 2 * dx - cx; - - Geom::Point stx = (bx + cx) / 2; - - descr_cmd[ip - 1]->associated = AddPoint(stx, false); - if ( descr_cmd[ip - 1]->associated < 0 ) { - if ( curP == 0 ) { - descr_cmd[ip - 1]->associated = 0; - } else { - descr_cmd[ip - 1]->associated = descr_cmd[ip - 2]->associated; - } - } - - { - Geom::Point mx = (cx + dx) / 2; - RecBezierTo(cx, stx, mx, treshhold, 8); - } - } - } - - descr_cmd[curBD]->associated = AddPoint(nextX, false); - if ( descr_cmd[curBD]->associated < 0 ) { - if ( curP == 0 ) { - descr_cmd[curBD]->associated = 0; - } else { - descr_cmd[curBD]->associated = descr_cmd[curBD - 1]->associated; - } - } - - last_point_relation = 0; - - curP += nbInterm; - break; - } - } - - curX = nextX; - } -} - - void Path::ConvertEvenLines(double treshhold) { if ( descr_flags & descr_adding_bezier ) { -- cgit v1.2.3 From 79012ca437ff3d7c25e4d164b1b9c3dccc2b4b7f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 15:20:17 +0200 Subject: Remove NRRect from paint servers and temporary calculations (bzr r10582.1.4) --- src/desktop.cpp | 1 + src/display/nr-style.cpp | 6 ++---- src/sp-gradient.cpp | 12 ++++++------ src/sp-paint-server.cpp | 6 +++--- src/sp-paint-server.h | 5 +++-- src/sp-pattern.cpp | 8 ++++---- src/widgets/desktop-widget.cpp | 10 +++------- 7 files changed, 22 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index b622d1080..f1a63d22c 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -871,6 +871,7 @@ Geom::Rect SPDesktop::get_display_area() const double const scale = _d2w[0]; + /// @fixme hardcoded desktop transform return Geom::Rect(Geom::Point(viewbox.min()[Geom::X] / scale, viewbox.max()[Geom::Y] / -scale), Geom::Point(viewbox.max()[Geom::X] / scale, viewbox.min()[Geom::Y] / -scale)); } diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index fa5dd0d98..9db52ea7e 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -150,8 +150,7 @@ bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &pai if (!fill_pattern) { switch (fill.type) { case PAINT_SERVER: { - NRRect pb(paintbox); - fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), &pb, fill.opacity); + fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), paintbox, fill.opacity); } break; case PAINT_COLOR: { SPColor const &c = fill.color; @@ -176,8 +175,7 @@ bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &p if (!stroke_pattern) { switch (stroke.type) { case PAINT_SERVER: { - NRRect pb(paintbox); - stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), &pb, stroke.opacity); + stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity); } break; case PAINT_COLOR: { SPColor const &c = stroke.color; diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 3aa14dc45..94ad0bb25 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1155,7 +1155,7 @@ static void sp_lineargradient_build(SPObject *object, static void sp_lineargradient_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPGradientClass *lg_parent_class; @@ -1318,7 +1318,7 @@ static void sp_radialgradient_build(SPObject *object, static void sp_radialgradient_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPGradientClass *rg_parent_class; @@ -1494,7 +1494,7 @@ sp_radialgradient_set_position(SPRadialGradient *rg, static void sp_gradient_pattern_common_setup(cairo_pattern_t *cp, SPGradient *gr, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { // set spread type @@ -1523,7 +1523,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, // set pattern matrix Geom::Affine gs2user = gr->gradientTransform; if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top()); gs2user *= bbox2user; } ink_cairo_pattern_set_matrix(cp, gs2user.inverse()); @@ -1532,7 +1532,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, static cairo_pattern_t * sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t */* ct */, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { SPRadialGradient *rg = SP_RADIALGRADIENT(ps); @@ -1552,7 +1552,7 @@ sp_radialgradient_create_pattern(SPPaintServer *ps, static cairo_pattern_t * sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t */* ct */, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { SPLinearGradient *lg = SP_LINEARGRADIENT(ps); diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index 2ed556b23..be7494908 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -22,7 +22,7 @@ static void sp_paint_server_class_init(SPPaintServerClass *psc); -static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPObjectClass *parent_class; @@ -70,7 +70,7 @@ void SPPaintServer::init(SPPaintServer * /*ps*/) cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { // NOTE: the ct argument is used for when rendering patterns @@ -91,7 +91,7 @@ cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, static cairo_pattern_t * sp_paint_server_create_dummy_pattern(SPPaintServer */*ps*/, cairo_t */* ct */, - NRRect const */*bbox*/, + Geom::OptRect const &/*bbox*/, double /* opacity */) { cairo_pattern_t *cp = cairo_pattern_create_rgb(1.0, 0.0, 1.0); diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index 283a97210..7d6f7a5ef 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -16,6 +16,7 @@ */ #include +#include <2geom/rect.h> #include "sp-object.h" #include "uri-references.h" @@ -44,10 +45,10 @@ private: struct SPPaintServerClass { SPObjectClass sp_object_class; /** Get SPPaint instance. */ - cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, const NRRect *bbox, double opacity); + cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); }; -cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); #endif // SEEN_SP_PAINT_SERVER_H diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9aefdf6ff..b8ccf5648 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -53,7 +53,7 @@ static void sp_pattern_modified (SPObject *object, unsigned int flags); static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); -static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPPaintServerClass * pattern_parent_class; @@ -604,7 +604,7 @@ bool pattern_hasItemChildren (SPPattern *pat) static cairo_pattern_t * sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *base_ct, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { SPPattern *pat = SP_PATTERN (ps); @@ -657,7 +657,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, ps2user = pattern_patternTransform(pat); if (!pat->viewBox_set && pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { /* BBox to user coordinate system */ - Geom::Affine bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + Geom::Affine bbox2user (bbox->width(), 0.0, 0.0, bbox->height(), bbox->left(), bbox->top()); ps2user *= bbox2user; } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; @@ -667,7 +667,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, if (pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { // interpret x, y, width, height in relation to bbox - Geom::Affine bbox2user(bbox->x1 - bbox->x0, 0,0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + Geom::Affine bbox2user(bbox->width(), 0.0, 0.0, bbox->height(), bbox->left(), bbox->top()); pattern_tile = pattern_tile * bbox2user; } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index fff9c0a5c..cbfb8fe5f 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -731,15 +731,11 @@ sp_desktop_widget_realize (GtkWidget *widget) if (GTK_WIDGET_CLASS (dtw_parent_class)->realize) (* GTK_WIDGET_CLASS (dtw_parent_class)->realize) (widget); - NRRect d; - d.x0 = 0.0; - d.y0 = 0.0; - d.x1 = (dtw->desktop->doc())->getWidth (); - d.y1 = (dtw->desktop->doc())->getHeight (); + Geom::Rect d = Geom::Rect::from_xywh(Geom::Point(0,0), (dtw->desktop->doc())->getDimensions()); - if ((fabs (d.x1 - d.x0) < 1.0) || (fabs (d.y1 - d.y0) < 1.0)) return; + if (d.width() < 1.0 || d.height() < 1.0) return; - dtw->desktop->set_display_area (d.x0, d.y0, d.x1, d.y1, 10); + dtw->desktop->set_display_area (d.left(), d.top(), d.right(), d.bottom(), 10); dtw->updateNamedview(); } -- cgit v1.2.3 From 24526cceccb4ed103a6324756476c64efb3fb5dd Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 16:58:22 +0200 Subject: Remove all NRRect use. (bzr r10582.1.5) --- src/desktop.cpp | 57 +++++++------------------ src/desktop.h | 7 +-- src/document.cpp | 44 +++++++++---------- src/document.h | 1 - src/extension/internal/cairo-render-context.cpp | 23 ++++------ src/extension/internal/cairo-renderer.cpp | 36 ++++++++-------- src/marker.cpp | 44 +++++++++---------- src/print.h | 1 - src/sp-ellipse.cpp | 25 ++++++----- src/sp-item.h | 2 +- src/sp-line.cpp | 4 +- src/sp-namedview.cpp | 5 +-- src/sp-paint-server.cpp | 3 -- src/sp-paint-server.h | 2 - src/sp-pattern.cpp | 29 +++++++------ src/sp-pattern.h | 4 +- src/sp-rect.cpp | 4 +- src/sp-root.cpp | 48 ++++++++------------- src/sp-root.h | 18 ++++---- src/sp-symbol.cpp | 56 +++++++++++------------- src/sp-symbol.h | 2 +- src/sp-use.cpp | 13 +++--- 22 files changed, 178 insertions(+), 250 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index f1a63d22c..dc06f773e 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -144,8 +144,6 @@ SPDesktop::SPDesktop() : page_border( 0 ), current( 0 ), _focusMode(false), - zooms_past( 0 ), - zooms_future( 0 ), dkey( 0 ), number( 0 ), window_state(0), @@ -410,9 +408,6 @@ void SPDesktop::destroy() delete _guides_message_context; _guides_message_context = NULL; - - g_list_free (zooms_past); - g_list_free (zooms_future); } SPDesktop::~SPDesktop() {} @@ -771,25 +766,12 @@ SPDesktop::point() const * Put current zoom data in history list. */ void -SPDesktop::push_current_zoom (GList **history) +SPDesktop::push_current_zoom (std::list &history) { - Geom::Rect const area = get_display_area(); + Geom::Rect area = get_display_area(); - NRRect *old_zoom = g_new(NRRect, 1); - old_zoom->x0 = area.min()[Geom::X]; - old_zoom->x1 = area.max()[Geom::X]; - old_zoom->y0 = area.min()[Geom::Y]; - old_zoom->y1 = area.max()[Geom::Y]; - if ( *history == NULL - || !( ( ((NRRect *) ((*history)->data))->x0 == old_zoom->x0 ) && - ( ((NRRect *) ((*history)->data))->x1 == old_zoom->x1 ) && - ( ((NRRect *) ((*history)->data))->y0 == old_zoom->y0 ) && - ( ((NRRect *) ((*history)->data))->y1 == old_zoom->y1 ) ) ) - { - *history = g_list_prepend (*history, old_zoom); - } else { - g_free(old_zoom); - old_zoom = 0; + if (history.empty() || history.front() == area) { + history.push_front(area); } } @@ -804,10 +786,9 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double // save the zoom if (log) { - push_current_zoom(&zooms_past); + push_current_zoom(zooms_past); // if we do a logged zoom, our zoom-forward list is invalidated, so delete it - g_list_free (zooms_future); - zooms_future = NULL; + zooms_future.clear(); } double const cx = 0.5 * (x0 + x1); @@ -882,23 +863,20 @@ Geom::Rect SPDesktop::get_display_area() const void SPDesktop::prev_zoom() { - if (zooms_past == NULL) { + if (zooms_past.empty()) { messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No previous zoom.")); return; } // push current zoom into forward zooms list - push_current_zoom (&zooms_future); + push_current_zoom (zooms_future); // restore previous zoom - set_display_area (((NRRect *) zooms_past->data)->x0, - ((NRRect *) zooms_past->data)->y0, - ((NRRect *) zooms_past->data)->x1, - ((NRRect *) zooms_past->data)->y1, - 0, false); + Geom::Rect past = zooms_past.front(); + set_display_area (past.left(), past.top(), past.right(), past.bottom(), 0, false); // remove the just-added zoom from the past zooms list - zooms_past = g_list_remove (zooms_past, ((NRRect *) zooms_past->data)); + zooms_past.pop_front(); } /** @@ -907,23 +885,20 @@ SPDesktop::prev_zoom() void SPDesktop::next_zoom() { - if (zooms_future == NULL) { + if (zooms_future.empty()) { this->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No next zoom.")); return; } // push current zoom into past zooms list - push_current_zoom (&zooms_past); + push_current_zoom (zooms_past); // restore next zoom - set_display_area (((NRRect *) zooms_future->data)->x0, - ((NRRect *) zooms_future->data)->y0, - ((NRRect *) zooms_future->data)->x1, - ((NRRect *) zooms_future->data)->y1, - 0, false); + Geom::Rect future = zooms_future.front(); + set_display_area (future.left(), future.top(), future.right(), future.bottom(), 0, false); // remove the just-used zoom from the zooms_future list - zooms_future = g_list_remove (zooms_future, ((NRRect *) zooms_future->data)); + zooms_future.pop_front(); } /** \brief Performs a quick zoom into what the user is working on diff --git a/src/desktop.h b/src/desktop.h index 5dcd014ca..d15fb7d69 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -117,8 +117,9 @@ public: SPCSSAttr *current; ///< current style bool _focusMode; ///< Whether we're focused working or general working - GList *zooms_past; - GList *zooms_future; + std::list zooms_past; + std::list zooms_future; + bool _quick_zoom_enabled; ///< Signifies that currently we're in quick zoom mode Geom::Rect _quick_zoom_stored_area; ///< The area of the screen before quick zoom unsigned int dkey; @@ -359,7 +360,7 @@ private: bool grids_visible; /* don't set this variable directly, use the method below */ void set_grids_visible(bool visible); - void push_current_zoom (GList**); + void push_current_zoom(std::list &); sigc::signal _document_replaced_signal; sigc::signal _activate_signal; diff --git a/src/document.cpp b/src/document.cpp index cf2474fe5..d45041296 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -534,7 +534,7 @@ gdouble SPDocument::getWidth() const gdouble result = root->width.computed; if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { - result = root->viewBox.x1 - root->viewBox.x0; + result = root->viewBox.width(); } return result; } @@ -542,7 +542,7 @@ gdouble SPDocument::getWidth() const void SPDocument::setWidth(gdouble width, const SPUnit *unit) { if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + sp_units_get_pixels (width, *unit), root->viewBox.bottom())); } else { // set to width= gdouble old_computed = root->width.computed; root->width.computed = sp_units_get_pixels (width, *unit); @@ -557,16 +557,28 @@ void SPDocument::setWidth(gdouble width, const SPUnit *unit) } if (root->viewBox_set) - root->viewBox.x1 = root->viewBox.x0 + (root->width.computed / old_computed) * (root->viewBox.x1 - root->viewBox.x0); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); } root->updateRepr(); } +gdouble SPDocument::getHeight() const +{ + g_return_val_if_fail(this->priv != NULL, 0.0); + g_return_val_if_fail(this->root != NULL, 0.0); + + gdouble result = root->height.computed; + if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { + result = root->viewBox.height(); + } + return result; +} + void SPDocument::setHeight(gdouble height, const SPUnit *unit) { if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + sp_units_get_pixels (height, *unit))); } else { // set to height= gdouble old_computed = root->height.computed; root->height.computed = sp_units_get_pixels (height, *unit); @@ -581,24 +593,12 @@ void SPDocument::setHeight(gdouble height, const SPUnit *unit) } if (root->viewBox_set) - root->viewBox.y1 = root->viewBox.y0 + (root->height.computed / old_computed) * (root->viewBox.y1 - root->viewBox.y0); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); } root->updateRepr(); } -gdouble SPDocument::getHeight() const -{ - g_return_val_if_fail(this->priv != NULL, 0.0); - g_return_val_if_fail(this->root != NULL, 0.0); - - gdouble result = root->height.computed; - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { - result = root->viewBox.y1 - root->viewBox.y0; - } - return result; -} - Geom::Point SPDocument::getDimensions() const { return Geom::Point(getWidth(), getHeight()); @@ -941,15 +941,9 @@ void SPDocument::setupViewport(SPItemCtx *ctx) ctx->i2doc = Geom::identity(); // Set up viewport in case svg has it defined as percentages if (root->viewBox_set) { // if set, take from viewBox - ctx->vp.x0 = root->viewBox.x0; - ctx->vp.y0 = root->viewBox.y0; - ctx->vp.x1 = root->viewBox.x1; - ctx->vp.y1 = root->viewBox.y1; + ctx->viewport = root->viewBox; } else { // as a last resort, set size to A4 - ctx->vp.x0 = 0.0; - ctx->vp.y0 = 0.0; - ctx->vp.x1 = 210 * PX_PER_MM; - ctx->vp.y1 = 297 * PX_PER_MM; + ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * PX_PER_MM, 297 * PX_PER_MM); } ctx->i2vp = Geom::identity(); } diff --git a/src/document.h b/src/document.h index c94b66c4d..83cb57eea 100644 --- a/src/document.h +++ b/src/document.h @@ -38,7 +38,6 @@ namespace Avoid { class Router; } -struct NRRect; struct SPDesktop; struct SPItem; struct SPObject; diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index a0573d9ff..9bafa9432 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -87,19 +87,19 @@ #define TEST(_args) // FIXME: expose these from sp-clippath/mask.cpp -struct SPClipPathView { +/*struct SPClipPathView { SPClipPathView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; struct SPMaskView { SPMaskView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; -}; + Geom::OptRect bbox; +};*/ namespace Inkscape { namespace Extension { @@ -1043,27 +1043,22 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // create pattern contents coordinate system if (pat->viewBox_set) { - NRRect *view_box = pattern_viewBox(pat); + Geom::Rect view_box = *pattern_viewBox(pat); double x, y, w, h; - double view_width, view_height; x = 0; y = 0; w = width * bbox_width_scaler; h = height * bbox_height_scaler; - view_width = view_box->x1 - view_box->x0; - view_height = view_box->y1 - view_box->y0; - //calculatePreserveAspectRatio(pat->aspect_align, pat->aspect_clip, view_width, view_height, &x, &y, &w, &h); - pcs2dev[0] = w / view_width; - pcs2dev[3] = h / view_height; - pcs2dev[4] = x - view_box->x0 * pcs2dev[0]; - pcs2dev[5] = y - view_box->y0 * pcs2dev[3]; + pcs2dev[0] = w / view_box.width(); + pcs2dev[3] = h / view_box.height(); + pcs2dev[4] = x - view_box.left() * pcs2dev[0]; + pcs2dev[5] = y - view_box.top() * pcs2dev[3]; } else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { pcs2dev[0] = pbox->width(); pcs2dev[3] = pbox->height(); - } // Calculate the size of the surface which has to be created diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index adfa0421d..3a2cea3c1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -87,14 +87,14 @@ struct SPClipPathView { SPClipPathView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; struct SPMaskView { SPMaskView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; namespace Inkscape { @@ -394,8 +394,8 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) width = 1.0; height = 1.0; - view_width = symbol->viewBox.x1 - symbol->viewBox.x0; - view_height = symbol->viewBox.y1 - symbol->viewBox.y0; + view_width = symbol->viewBox.width(); + view_height = symbol->viewBox.height(); calculatePreserveAspectRatio(symbol->aspect_align, symbol->aspect_clip, view_width, view_height, &x, &y,&width, &height); @@ -404,8 +404,8 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) vb2user = Geom::identity(); vb2user[0] = width / view_width; vb2user[3] = height / view_height; - vb2user[4] = x - symbol->viewBox.x0 * vb2user[0]; - vb2user[5] = y - symbol->viewBox.y0 * vb2user[3]; + vb2user[4] = x - symbol->viewBox.left() * vb2user[0]; + vb2user[5] = y - symbol->viewBox.top() * vb2user[3]; ctx->transform(vb2user); } @@ -668,13 +668,14 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode(); ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP); + // FIXME: the access to the first clippath view to obtain the bbox is completely bogus Geom::Affine saved_ctm; - if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { + if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && cp->display->bbox) { //SP_PRINT_DRECT("clipd", cp->display->bbox); - NRRect clip_bbox(cp->display->bbox); - Geom::Affine t(Geom::Scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0)); - t[4] = clip_bbox.x0; - t[5] = clip_bbox.y0; + Geom::Rect clip_bbox = *cp->display->bbox; + Geom::Affine t(Geom::Scale(clip_bbox.dimensions())); + t[4] = clip_bbox.left(); + t[5] = clip_bbox.top(); t *= ctx->getCurrentState()->transform; saved_ctm = ctx->getTransform(); ctx->setTransform(t); @@ -720,13 +721,14 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) if (mask == NULL) return; - //SP_PRINT_DRECT("maskd", &mask->display->bbox); - NRRect mask_bbox(mask->display->bbox); + // FIXME: the access to the first mask view to obtain the bbox is completely bogus // TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ? - if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine t(Geom::Scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0)); - t[4] = mask_bbox.x0; - t[5] = mask_bbox.y0; + if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) { + //SP_PRINT_DRECT("maskd", &mask->display->bbox); + Geom::Rect mask_bbox = *mask->display->bbox; + Geom::Affine t(Geom::Scale(mask_bbox.dimensions())); + t[4] = mask_bbox.left(); + t[5] = mask_bbox.top(); t *= ctx->getCurrentState()->transform; ctx->setTransform(t); } diff --git a/src/marker.cpp b/src/marker.cpp index 9db5cfdc1..db9779460 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -349,10 +349,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) rctx.i2doc = Geom::identity(); rctx.i2vp = Geom::identity(); /* Set up viewport */ - rctx.vp.x0 = 0.0; - rctx.vp.y0 = 0.0; - rctx.vp.x1 = marker->markerWidth.computed; - rctx.vp.y1 = marker->markerHeight.computed; + rctx.viewport = Geom::Rect::from_xywh(0, 0, marker->markerWidth.computed, marker->markerHeight.computed); /* Start with identity transform */ marker->c2p.setIdentity(); @@ -361,20 +358,20 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) if (marker->viewBox) { vb = *marker->viewBox; } else { - vb = *(rctx.vp.upgrade_2geom()); + vb = rctx.viewport; } /* Now set up viewbox transformation */ /* Determine actual viewbox in viewport coordinates */ if (marker->aspect_align == SP_ASPECT_NONE) { x = 0.0; y = 0.0; - width = rctx.vp.x1 - rctx.vp.x0; - height = rctx.vp.y1 - rctx.vp.y0; + width = rctx.viewport.width(); + height = rctx.viewport.height(); } else { double scalex, scaley, scale; /* Things are getting interesting */ - scalex = (rctx.vp.x1 - rctx.vp.x0) / (vb.width()); - scaley = (rctx.vp.y1 - rctx.vp.y0) / (vb.height()); + scalex = rctx.viewport.width() / (vb.width()); + scaley = rctx.viewport.height() / (vb.height()); scale = (marker->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); width = (vb.width()) * scale; height = (vb.height()) * scale; @@ -385,36 +382,36 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) y = 0.0; break; case SP_ASPECT_XMID_YMIN: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); + x = 0.5 * (rctx.viewport.width() - width); y = 0.0; break; case SP_ASPECT_XMAX_YMIN: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); + x = 1.0 * (rctx.viewport.width() - width); y = 0.0; break; case SP_ASPECT_XMIN_YMID: x = 0.0; - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMID_YMID: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 0.5 * (rctx.viewport.width() - width); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMAX_YMID: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 1.0 * (rctx.viewport.width() - width); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMIN_YMAX: x = 0.0; - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + y = 1.0 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMID_YMAX: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 0.5 * (rctx.viewport.width() - width); + y = 1.0 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMAX_YMAX: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 1.0 * (rctx.viewport.width() - width); + y = 1.0 * (rctx.viewport.height() - height); break; default: x = 0.0; @@ -432,10 +429,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) /* If viewBox is set reinitialize child viewport */ /* Otherwise it already correct */ if (marker->viewBox) { - rctx.vp.x0 = marker->viewBox->min()[Geom::X]; - rctx.vp.y0 = marker->viewBox->min()[Geom::Y]; - rctx.vp.x1 = marker->viewBox->max()[Geom::X]; - rctx.vp.y1 = marker->viewBox->max()[Geom::Y]; + rctx.viewport = *marker->viewBox; rctx.i2vp = Geom::identity(); } diff --git a/src/print.h b/src/print.h index d584245e5..422f18669 100644 --- a/src/print.h +++ b/src/print.h @@ -17,7 +17,6 @@ #include "forward.h" #include "extension/extension-forward.h" -struct NRRect; struct SPPrintContext { Inkscape::Extension::Print *module; }; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 99189da45..ba100a1d7 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -140,19 +140,18 @@ sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPGenericEllipse *ellipse = (SPGenericEllipse *) object; SPStyle const *style = object->style; - Geom::OptRect viewbox = ((SPItemCtx const *) ctx)->vp; - if (viewbox) { - double const dx = viewbox->width(); - double const dy = viewbox->height(); - double const dr = sqrt(dx*dx + dy*dy)/sqrt(2); - double const em = style->font_size.computed; - double const ex = em * 0.5; // fixme: get from pango or libnrtype - ellipse->cx.update(em, ex, dx); - ellipse->cy.update(em, ex, dy); - ellipse->rx.update(em, ex, dr); - ellipse->ry.update(em, ex, dr); - static_cast(object)->setShape(); - } + Geom::Rect const &viewbox = ((SPItemCtx const *) ctx)->viewport; + + double const dx = viewbox.width(); + double const dy = viewbox.height(); + double const dr = sqrt(dx*dx + dy*dy)/sqrt(2); + double const em = style->font_size.computed; + double const ex = em * 0.5; // fixme: get from pango or libnrtype + ellipse->cx.update(em, ex, dx); + ellipse->cy.update(em, ex, dy); + ellipse->rx.update(em, ex, dr); + ellipse->ry.update(em, ex, dr); + static_cast(object)->setShape(); } if (((SPObjectClass *) ge_parent_class)->update) diff --git a/src/sp-item.h b/src/sp-item.h index 62336e3c8..21b3d9006 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -88,7 +88,7 @@ public: /** Item to document transformation */ Geom::Affine i2doc; /** Viewport size */ - NRRect vp; + Geom::Rect viewport; /** Item to viewport transformation */ Geom::Affine i2vp; }; diff --git a/src/sp-line.cpp b/src/sp-line.cpp index d3faf2299..06604a1d6 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -127,8 +127,8 @@ void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) SPStyle const *style = object->style; SPItemCtx const *ictx = (SPItemCtx const *) ctx; - double const w = (ictx->vp.x1 - ictx->vp.x0); - double const h = (ictx->vp.y1 - ictx->vp.y0); + double const w = ictx->viewport.width(); + double const h = ictx->viewport.height(); double const em = style->font_size.computed; double const ex = em * 0.5; // fixme: get from pango or libnrtype. line->x1.update(em, ex, w); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 71ee8298b..e94a02265 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -807,10 +807,7 @@ void sp_namedview_window_from_document(SPDesktop *desktop) } // cancel any history of zooms up to this point - if (desktop->zooms_past) { - g_list_free(desktop->zooms_past); - desktop->zooms_past = NULL; - } + desktop->zooms_past.clear(); } bool SPNamedView::getSnapGlobal() const diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index be7494908..ceb36740f 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -73,11 +73,8 @@ cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, Geom::OptRect const &bbox, double opacity) { - // NOTE: the ct argument is used for when rendering patterns - // to create a group, instead of explicitly creating a temporary surface g_return_val_if_fail(ps != NULL, NULL); g_return_val_if_fail(SP_IS_PAINT_SERVER(ps), NULL); - g_return_val_if_fail(bbox != NULL, NULL); cairo_pattern_t *cp = NULL; SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps); diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index 7d6f7a5ef..a266ee5a5 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -20,8 +20,6 @@ #include "sp-object.h" #include "uri-references.h" -struct NRRect; - #define SP_TYPE_PAINT_SERVER (SPPaintServer::get_type()) #define SP_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PAINT_SERVER, SPPaintServer)) #define SP_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_PAINT_SERVER, SPPaintServerClass)) diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index b8ccf5648..03afc1bf3 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -245,11 +245,8 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value) height = g_ascii_strtod (eptr, &eptr); while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; if ((width > 0) && (height > 0)) { - pat->viewBox.x0 = x; - pat->viewBox.y0 = y; - pat->viewBox.x1 = x + width; - pat->viewBox.y1 = y + height; - pat->viewBox_set = TRUE; + pat->viewBox = Geom::Rect::from_xywh(x, y, width, height); + pat->viewBox_set = TRUE; } else { pat->viewBox_set = FALSE; } @@ -581,13 +578,16 @@ gdouble pattern_height (SPPattern *pat) return 0; } -NRRect *pattern_viewBox (SPPattern *pat) +Geom::OptRect pattern_viewBox (SPPattern *pat) { - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->viewBox_set) - return &(pat_i->viewBox); - } - return &(pat->viewBox); + Geom::OptRect viewbox; + for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + if (pat_i->viewBox_set) { + viewbox = pat_i->viewBox; + break; + } + } + return viewbox; } bool pattern_hasItemChildren (SPPattern *pat) @@ -647,11 +647,12 @@ sp_pattern_create_pattern(SPPaintServer *ps, } if (pat->viewBox_set) { - gdouble tmp_x = pattern_width (pat) / (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0); - gdouble tmp_y = pattern_height (pat) / (pattern_viewBox(pat)->y1 - pattern_viewBox(pat)->y0); + Geom::Rect vb = *pattern_viewBox(pat); + gdouble tmp_x = pattern_width (pat) / vb.width(); + gdouble tmp_y = pattern_height (pat) / vb.height(); // FIXME: preserveAspectRatio must be taken into account here too! - vb2ps = Geom::Affine(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - pattern_viewBox(pat)->x0 * tmp_x, pattern_y(pat) - pattern_viewBox(pat)->y0 * tmp_y); + vb2ps = Geom::Affine(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - vb.left() * tmp_x, pattern_y(pat) - vb.top() * tmp_y); } ps2user = pattern_patternTransform(pat); diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 1f545bfc4..ee7ffd477 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -72,7 +72,7 @@ struct SPPattern : public SPPaintServer { SVGLength width; SVGLength height; /* VieBox */ - NRRect viewBox; + Geom::Rect viewBox; guint viewBox_set : 1; sigc::connection modified_connection; @@ -98,7 +98,7 @@ gdouble pattern_x (SPPattern *pat); gdouble pattern_y (SPPattern *pat); gdouble pattern_width (SPPattern *pat); gdouble pattern_height (SPPattern *pat); -NRRect *pattern_viewBox (SPPattern *pat); +Geom::OptRect pattern_viewBox (SPPattern *pat); #endif // SEEN_SP_PATTERN_H diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 729e2a34c..22a403345 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -173,8 +173,8 @@ sp_rect_update(SPObject *object, SPCtx *ctx, guint flags) SPRect *rect = (SPRect *) object; SPStyle *style = object->style; SPItemCtx const *ictx = (SPItemCtx const *) ctx; - double const w = (ictx->vp.x1 - ictx->vp.x0); - double const h = (ictx->vp.y1 - ictx->vp.y0); + double const w = ictx->viewport.width(); + double const h = ictx->viewport.height(); double const em = style->font_size.computed; double const ex = 0.5 * em; // fixme: get x height from pango or libnrtype. rect->x.update(em, ex, w); diff --git a/src/sp-root.cpp b/src/sp-root.cpp index a6df580d3..788d1958a 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -123,7 +123,6 @@ sp_root_init(SPRoot *root) root->width.unset(SVGLength::PERCENT, 1.0, 1.0); root->height.unset(SVGLength::PERCENT, 1.0, 1.0); - /* root->viewbox.set_identity(); */ root->viewBox_set = FALSE; root->c2p.setIdentity(); @@ -253,10 +252,7 @@ sp_root_set(SPObject *object, unsigned int key, gchar const *value) while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; if ((width > 0) && (height > 0)) { /* Set viewbox */ - root->viewBox.x0 = x; - root->viewBox.y0 = y; - root->viewBox.x1 = x + width; - root->viewBox.y1 = y + height; + root->viewBox = Geom::Rect::from_xywh(x, y, width, height); root->viewBox_set = TRUE; } else { root->viewBox_set = FALSE; @@ -404,16 +400,16 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) /* fixme: We should calculate only if parent viewport has changed (Lauris) */ /* If position is specified as percentage, calculate actual values */ if (root->x.unit == SVGLength::PERCENT) { - root->x.computed = root->x.value * (ictx->vp.x1 - ictx->vp.x0); + root->x.computed = root->x.value * ictx->viewport.width(); } if (root->y.unit == SVGLength::PERCENT) { - root->y.computed = root->y.value * (ictx->vp.y1 - ictx->vp.y0); + root->y.computed = root->y.value * ictx->viewport.height(); } if (root->width.unit == SVGLength::PERCENT) { - root->width.computed = root->width.value * (ictx->vp.x1 - ictx->vp.x0); + root->width.computed = root->width.value * ictx->viewport.width(); } if (root->height.unit == SVGLength::PERCENT) { - root->height.computed = root->height.value * (ictx->vp.y1 - ictx->vp.y0); + root->height.computed = root->height.value * ictx->viewport.height(); } /* Create copy of item context */ @@ -445,11 +441,11 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) } else { double scalex, scaley, scale; /* Things are getting interesting */ - scalex = root->width.computed / (root->viewBox.x1 - root->viewBox.x0); - scaley = root->height.computed / (root->viewBox.y1 - root->viewBox.y0); + scalex = root->width.computed / root->viewBox.width(); + scaley = root->height.computed / root->viewBox.height(); scale = (root->aspect_clip == SP_ASPECT_MEET) ? MIN(scalex, scaley) : MAX(scalex, scaley); - width = (root->viewBox.x1 - root->viewBox.x0) * scale; - height = (root->viewBox.y1 - root->viewBox.y0) * scale; + width = root->viewBox.width() * scale; + height = root->viewBox.height() * scale; /* Now place viewbox to requested position */ /* todo: Use an array lookup to find the 0.0/0.5/1.0 coefficients, as is done for dialogs/align.cpp. */ @@ -498,38 +494,27 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) } /* Compose additional transformation from scale and position */ - Geom::Point const viewBox_min(root->viewBox.x0, - root->viewBox.y0); - Geom::Point const viewBox_max(root->viewBox.x1, - root->viewBox.y1); - Geom::Scale const viewBox_length( viewBox_max - viewBox_min ); + Geom::Scale const viewBox_length( root->viewBox.dimensions() ); Geom::Scale const new_length(width, height); /* Append viewbox transformation */ /* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS expression should have c2p at the beginning rather than at the end. Test it. */ - root->c2p = Geom::Translate(-viewBox_min) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p; + root->c2p = Geom::Translate(-root->viewBox.min()) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p; } rctx.i2doc = root->c2p * rctx.i2doc; /* Initialize child viewport */ if (root->viewBox_set) { - rctx.vp.x0 = root->viewBox.x0; - rctx.vp.y0 = root->viewBox.y0; - rctx.vp.x1 = root->viewBox.x1; - rctx.vp.y1 = root->viewBox.y1; + rctx.viewport = root->viewBox; } else { /* fixme: I wonder whether this logic is correct (Lauris) */ + Geom::Point minp(0,0); if (object->parent) { - rctx.vp.x0 = root->x.computed; - rctx.vp.y0 = root->y.computed; - } else { - rctx.vp.x0 = 0.0; - rctx.vp.y0 = 0.0; + minp = Geom::Point(root->x.computed, root->y.computed); } - rctx.vp.x1 = root->width.computed; - rctx.vp.y1 = root->height.computed; + rctx.viewport = Geom::Rect::from_xywh(minp[Geom::X], minp[Geom::Y], root->width.computed, root->height.computed); } rctx.i2vp = Geom::identity(); @@ -597,7 +582,8 @@ sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: if (root->viewBox_set) { Inkscape::SVGOStringStream os; - os << root->viewBox.x0 << " " << root->viewBox.y0 << " " << root->viewBox.x1 - root->viewBox.x0 << " " << root->viewBox.y1 - root->viewBox.y0; + os << root->viewBox.left() << " " << root->viewBox.top() << " " + << root->viewBox.width() << " " << root->viewBox.height(); repr->setAttribute("viewBox", os.str().c_str()); } diff --git a/src/sp-root.h b/src/sp-root.h index 86b92b2b3..e2bad917b 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -1,6 +1,3 @@ -#ifndef SP_ROOT_H_SEEN -#define SP_ROOT_H_SEEN - /** \file * SPRoot: SVG \ implementation. */ @@ -14,17 +11,20 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#define SP_TYPE_ROOT (sp_root_get_type()) -#define SP_ROOT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ROOT, SPRoot)) -#define SP_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_ROOT, SPRootClass)) -#define SP_IS_ROOT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ROOT)) -#define SP_IS_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ROOT)) +#ifndef SP_ROOT_H_SEEN +#define SP_ROOT_H_SEEN #include "version.h" #include "svg/svg-length.h" #include "enums.h" #include "sp-item-group.h" +#define SP_TYPE_ROOT (sp_root_get_type()) +#define SP_ROOT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ROOT, SPRoot)) +#define SP_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_ROOT, SPRootClass)) +#define SP_IS_ROOT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ROOT)) +#define SP_IS_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ROOT)) + class SPDefs; /** \ element */ @@ -41,7 +41,7 @@ struct SPRoot : public SPGroup { /* viewBox; */ unsigned int viewBox_set : 1; - NRRect viewBox; + Geom::Rect viewBox; /* preserveAspectRatio */ unsigned int aspect_set : 1; diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 0a1ebdb06..87cd210e4 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -131,10 +131,7 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value while (*eptr && ((*eptr == ',') || (*eptr == ' '))) eptr++; if ((width > 0) && (height > 0)) { /* Set viewbox */ - symbol->viewBox.x0 = x; - symbol->viewBox.y0 = y; - symbol->viewBox.x1 = x + width; - symbol->viewBox.y1 = y + height; + symbol->viewBox = Geom::Rect::from_xywh(x, y, width, height); symbol->viewBox_set = TRUE; } else { symbol->viewBox_set = FALSE; @@ -234,7 +231,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) /* Calculate child to parent transformation */ /* Apply parent translation (set up as vewport) */ - symbol->c2p = Geom::Affine(Geom::Translate(rctx.vp.x0, rctx.vp.y0)); + symbol->c2p = Geom::Translate(rctx.viewport.min()); if (symbol->viewBox_set) { double x, y, width, height; @@ -242,16 +239,16 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) if (symbol->aspect_align == SP_ASPECT_NONE) { x = 0.0; y = 0.0; - width = rctx.vp.x1 - rctx.vp.x0; - height = rctx.vp.y1 - rctx.vp.y0; + width = rctx.viewport.width(); + height = rctx.viewport.height(); } else { double scalex, scaley, scale; /* Things are getting interesting */ - scalex = (rctx.vp.x1 - rctx.vp.x0) / (symbol->viewBox.x1 - symbol->viewBox.x0); - scaley = (rctx.vp.y1 - rctx.vp.y0) / (symbol->viewBox.y1 - symbol->viewBox.y0); + scalex = rctx.viewport.width() / symbol->viewBox.width(); + scaley = rctx.viewport.height() / symbol->viewBox.height(); scale = (symbol->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = (symbol->viewBox.x1 - symbol->viewBox.x0) * scale; - height = (symbol->viewBox.y1 - symbol->viewBox.y0) * scale; + width = symbol->viewBox.width() * scale; + height = symbol->viewBox.height() * scale; /* Now place viewbox to requested position */ switch (symbol->aspect_align) { case SP_ASPECT_XMIN_YMIN: @@ -259,36 +256,36 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) y = 0.0; break; case SP_ASPECT_XMID_YMIN: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); + x = 0.5 * (rctx.viewport.width() - width); y = 0.0; break; case SP_ASPECT_XMAX_YMIN: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); + x = 1.0 * (rctx.viewport.width() - width); y = 0.0; break; case SP_ASPECT_XMIN_YMID: x = 0.0; - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMID_YMID: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 0.5 * (rctx.viewport.width() - width); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMAX_YMID: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 0.5 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 1.0 * (rctx.viewport.width() - width); + y = 0.5 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMIN_YMAX: x = 0.0; - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + y = 1.0 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMID_YMAX: - x = 0.5 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 0.5 * (rctx.viewport.width() - width); + y = 1.0 * (rctx.viewport.height() - height); break; case SP_ASPECT_XMAX_YMAX: - x = 1.0 * ((rctx.vp.x1 - rctx.vp.x0) - width); - y = 1.0 * ((rctx.vp.y1 - rctx.vp.y0) - height); + x = 1.0 * (rctx.viewport.width() - width); + y = 1.0 * (rctx.viewport.height() - height); break; default: x = 0.0; @@ -298,12 +295,12 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } /* Compose additional transformation from scale and position */ Geom::Affine q; - q[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0); + q[0] = width / symbol->viewBox.width(); q[1] = 0.0; q[2] = 0.0; - q[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0); - q[4] = -symbol->viewBox.x0 * q[0] + x; - q[5] = -symbol->viewBox.y0 * q[3] + y; + q[3] = height / symbol->viewBox.height(); + q[4] = -symbol->viewBox.left() * q[0] + x; + q[5] = -symbol->viewBox.top() * q[3] + y; /* Append viewbox transformation */ symbol->c2p = q * symbol->c2p; } @@ -313,10 +310,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) /* If viewBox is set initialize child viewport */ /* Otherwise has set it up already */ if (symbol->viewBox_set) { - rctx.vp.x0 = symbol->viewBox.x0; - rctx.vp.y0 = symbol->viewBox.y0; - rctx.vp.x1 = symbol->viewBox.x1; - rctx.vp.y1 = symbol->viewBox.y1; + rctx.viewport = symbol->viewBox; rctx.i2vp = Geom::identity(); } diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 120591459..536486bc3 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -33,7 +33,7 @@ class SPSymbolClass; struct SPSymbol : public SPGroup { /* viewBox; */ unsigned int viewBox_set : 1; - NRRect viewBox; + Geom::Rect viewBox; /* preserveAspectRatio */ unsigned int aspect_set : 1; diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 057c01ef1..04cf1eb2c 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -594,21 +594,18 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) /* Set up child viewport */ if (use->x.unit == SVGLength::PERCENT) { - use->x.computed = use->x.value * (ictx->vp.x1 - ictx->vp.x0); + use->x.computed = use->x.value * ictx->viewport.width(); } if (use->y.unit == SVGLength::PERCENT) { - use->y.computed = use->y.value * (ictx->vp.y1 - ictx->vp.y0); + use->y.computed = use->y.value * ictx->viewport.height(); } if (use->width.unit == SVGLength::PERCENT) { - use->width.computed = use->width.value * (ictx->vp.x1 - ictx->vp.x0); + use->width.computed = use->width.value * ictx->viewport.width(); } if (use->height.unit == SVGLength::PERCENT) { - use->height.computed = use->height.value * (ictx->vp.y1 - ictx->vp.y0); + use->height.computed = use->height.value * ictx->viewport.height(); } - cctx.vp.x0 = 0.0; - cctx.vp.y0 = 0.0; - cctx.vp.x1 = use->width.computed; - cctx.vp.y1 = use->height.computed; + cctx.viewport = Geom::Rect::from_xywh(0, 0, use->width.computed, use->height.computed); cctx.i2vp = Geom::identity(); flags&=~SP_OBJECT_USER_MODIFIED_FLAG_B; -- cgit v1.2.3 From d6af1140ee108cc7d7fb6e0ba89ff7e30bb7ad3a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 18:05:32 +0200 Subject: Completely remove NRRect, NRRectL, in-svg-plane.h (bzr r10582.1.6) --- src/display/canvas-axonomgrid.cpp | 4 +- src/display/canvas-grid.cpp | 6 +- src/display/drawing-group.cpp | 3 +- src/display/drawing-item.cpp | 4 +- src/display/drawing-shape.cpp | 1 - src/display/nr-filter-convolve-matrix.h | 1 - src/display/nr-filter-diffuselighting.cpp | 1 - src/display/nr-filter-displacement-map.h | 1 - src/display/nr-filter-image.cpp | 1 - src/display/nr-filter-offset.cpp | 1 - src/display/nr-filter-offset.h | 1 - src/display/nr-filter-specularlighting.cpp | 1 - src/display/nr-filter-tile.cpp | 1 + src/display/nr-filter-turbulence.cpp | 1 - src/display/nr-filter-turbulence.h | 1 - src/display/nr-filter-units.cpp | 1 - src/display/nr-filter-units.h | 1 - src/display/nr-filter.h | 1 - src/display/nr-style.cpp | 1 - src/display/sodipodi-ctrl.h | 1 - src/display/sp-canvas.h | 4 - src/extension/internal/cairo-renderer.cpp | 1 - src/extension/internal/pdfinput/svg-builder.cpp | 1 - src/helper/geom.cpp | 1 - src/inkview.cpp | 1 - src/libnr/Makefile_insert | 16 +- src/libnr/in-svg-plane-test.h | 82 ---------- src/libnr/in-svg-plane.h | 32 ---- src/libnr/nr-convert2geom.h | 34 ---- src/libnr/nr-rect-l.cpp | 59 ------- src/libnr/nr-rect-l.h | 28 ---- src/libnr/nr-rect.cpp | 203 ------------------------ src/libnr/nr-rect.h | 91 ----------- src/libnr/nr-values.cpp | 18 --- src/libnr/nr-values.h | 43 ----- src/libnrtype/FontInstance.cpp | 1 - src/libnrtype/Layout-TNG.h | 1 - src/libnrtype/font-instance.h | 2 - src/libnrtype/nr-type-primitives.cpp | 1 - src/livarot/Path.h | 1 - src/livarot/PathConversion.cpp | 3 +- src/livarot/PathCutting.cpp | 1 - src/live_effects/lpe-curvestitch.cpp | 1 - src/live_effects/lpe-rough-hatches.cpp | 1 - src/live_effects/parameter/parameter.cpp | 1 - src/live_effects/parameter/random.cpp | 1 - src/marker.cpp | 1 - src/pencil-context.cpp | 3 +- src/selection-chemistry.cpp | 1 - src/seltrans.cpp | 8 +- src/snap.cpp | 6 +- src/sp-guide.cpp | 18 +-- src/sp-item.cpp | 4 +- src/sp-item.h | 9 +- src/sp-pattern.h | 1 - src/sp-symbol.h | 1 - src/star-context.cpp | 1 - src/ui/clipboard.cpp | 2 - src/ui/dialog/align-and-distribute.h | 2 - src/ui/widget/style-subject.h | 1 - src/ui/widget/zoom-status.cpp | 1 - 61 files changed, 38 insertions(+), 682 deletions(-) delete mode 100644 src/libnr/in-svg-plane-test.h delete mode 100644 src/libnr/in-svg-plane.h delete mode 100644 src/libnr/nr-convert2geom.h delete mode 100644 src/libnr/nr-rect-l.cpp delete mode 100644 src/libnr/nr-rect-l.h delete mode 100644 src/libnr/nr-rect.cpp delete mode 100644 src/libnr/nr-rect.h delete mode 100644 src/libnr/nr-values.cpp delete mode 100644 src/libnr/nr-values.h (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index c0dabcc07..9ea06ec2d 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -744,13 +744,13 @@ CanvasAxonomGridSnapper::_getSnapLines(Geom::Point const &p) const if (use_left_half) { s.push_back(std::make_pair(norm_z, Geom::Point(grid->origin[Geom::X], y_proj_along_z_max))); s.push_back(std::make_pair(norm_x, Geom::Point(grid->origin[Geom::X], y_proj_along_x_min))); - s.push_back(std::make_pair(component_vectors[Geom::X], Geom::Point(x_max, 0))); + s.push_back(std::make_pair(Geom::Point(1, 0), Geom::Point(x_max, 0))); } if (use_right_half) { s.push_back(std::make_pair(norm_z, Geom::Point(grid->origin[Geom::X], y_proj_along_z_min))); s.push_back(std::make_pair(norm_x, Geom::Point(grid->origin[Geom::X], y_proj_along_x_max))); - s.push_back(std::make_pair(component_vectors[Geom::X], Geom::Point(x_min, 0))); + s.push_back(std::make_pair(Geom::Point(1, 0), Geom::Point(x_min, 0))); } return s; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 38fe69628..bdf0d6fb0 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -993,14 +993,16 @@ CanvasXYGridSnapper::_getSnapLines(Geom::Point const &p) const Geom::Coord rounded; Geom::Point point_on_line; + Geom::Point cvec(0.,0.); + cvec[i] = 1.; rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], spacing, grid->origin[i]); point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0); - s.push_back(std::make_pair(component_vectors[i], point_on_line)); + s.push_back(std::make_pair(cvec, point_on_line)); rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], spacing, grid->origin[i]); point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0); - s.push_back(std::make_pair(component_vectors[i], point_on_line)); + s.push_back(std::make_pair(cvec, point_on_line)); } return s; diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index a678c3feb..998c4b6e4 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -14,7 +14,6 @@ #include "display/drawing-context.h" #include "display/drawing-item.h" #include "display/drawing-group.h" -#include "libnr/nr-values.h" #include "style.h" namespace Inkscape { @@ -58,7 +57,7 @@ DrawingGroup::setChildTransform(Geom::Affine const &new_trans) current = *_child_transform; } - if (!Geom::are_near(current, new_trans, NR_EPSILON)) { + if (!Geom::are_near(current, new_trans, 1e-18)) { // mark the area where the object was for redraw. _markForRendering(); if (new_trans.isIdentity()) { diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index a5496e999..3fe56b6de 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -176,7 +176,7 @@ DrawingItem::setTransform(Geom::Affine const &new_trans) current = *_transform; } - if (!Geom::are_near(current, new_trans, NR_EPSILON)) { + if (!Geom::are_near(current, new_trans, 1e-18)) { // mark the area where the object was for redraw. _markForRendering(); if (new_trans.isIdentity()) { @@ -456,7 +456,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // If we are invisible, return immediately if (!_visible) return RENDER_OK; - if (_ctm.isSingular(NR_EPSILON)) return RENDER_OK; + if (_ctm.isSingular(1e-18)) return RENDER_OK; // TODO convert outline rendering to a separate virtual function if (outline) { diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index ac0ff2ccb..6e28c0184 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -25,7 +25,6 @@ #include "display/drawing-shape.h" #include "helper/geom-curves.h" #include "helper/geom.h" -#include "libnr/nr-convert2geom.h" #include "preferences.h" #include "style.h" #include "svg/svg.h" diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index c37fe721f..4041ff96f 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -13,7 +13,6 @@ */ #include "display/nr-filter-primitive.h" -#include "libnr/nr-rect-l.h" #include namespace Inkscape { diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index c94df2d70..9df771879 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -21,7 +21,6 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index e4228323a..a01930045 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -16,7 +16,6 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 5911f5908..8b2161425 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -19,7 +19,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-image.h" #include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index da46095ef..833f6ecc9 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -13,7 +13,6 @@ #include "display/nr-filter-offset.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index 5551131f0..1ecc1621e 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -15,7 +15,6 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index ddb0c06eb..0530e38cb 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -21,7 +21,6 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 6680e7a46..93ca50210 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -9,6 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include "display/nr-filter-tile.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index f065ded11..7e47c3bd9 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -23,7 +23,6 @@ #include "display/nr-filter-turbulence.h" #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" -#include "libnr/nr-rect-l.h" #include namespace Inkscape { diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 0b451d355..360853364 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -25,7 +25,6 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp index baf4af45d..369deeb00 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -12,7 +12,6 @@ #include #include "display/nr-filter-units.h" -#include "libnr/nr-rect-l.h" #include "sp-filter-units.h" #include <2geom/transforms.h> diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index 1cb4fdbce..f918cf12e 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -13,7 +13,6 @@ */ #include "sp-filter-units.h" -#include "libnr/nr-rect-l.h" #include <2geom/affine.h> #include <2geom/rect.h> diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 32e1df60b..d53005c5d 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -16,7 +16,6 @@ #include #include "display/nr-filter-primitive.h" #include "display/nr-filter-types.h" -#include "libnr/nr-rect.h" #include "svg/svg-length.h" #include "sp-filter-units.h" #include "gc-managed.h" diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 9db52ea7e..6e8ccb030 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -14,7 +14,6 @@ #include "sp-paint-server.h" #include "display/canvas-bpath.h" // contains SPStrokeJoinType, SPStrokeCapType etc. (WTF!) #include "display/drawing-context.h" -#include "libnr/nr-rect.h" void NRStyle::Paint::clear() { diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 88cae28fd..2617e7db2 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -9,7 +9,6 @@ #include #include -#include #include "sp-canvas-item.h" diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 9e716b69c..bffa5e4e9 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -30,12 +30,8 @@ #include #include #include - #include - #include <2geom/affine.h> -#include - #include <2geom/rect.h> G_BEGIN_DECLS diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 3a2cea3c1..3b6c26113 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -28,7 +28,6 @@ #include #include -#include "libnr/nr-rect.h" #include "libnrtype/Layout-TNG.h" #include <2geom/transforms.h> #include <2geom/pathvector.h> diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index dc995b7aa..fe383b920 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -37,7 +37,6 @@ #include "io/stringstream.h" #include "io/base64stream.h" #include "display/nr-filter-utils.h" -#include "libnr/nr-macros.h" #include "libnrtype/font-instance.h" #include "Function.h" diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index fdfbdb9d3..61551ad2e 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -22,7 +22,6 @@ #include <2geom/rect.h> #include <2geom/coord.h> #include <2geom/sbasis-to-bezier.h> -#include #include using Geom::X; diff --git a/src/inkview.cpp b/src/inkview.cpp index 09169f5be..0b1292e8e 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -39,7 +39,6 @@ #include #include -#include // #include diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index cdb0b482c..6156a45e3 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -1,23 +1,9 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ - libnr/in-svg-plane.h \ - libnr/nr-convert2geom.h \ libnr/nr-forward.h \ libnr/nr-macros.h \ libnr/nr-object.cpp \ libnr/nr-object.h \ libnr/nr-point-fns.cpp \ - libnr/nr-point-fns.h \ - libnr/nr-rect-l.cpp \ - libnr/nr-rect-l.h \ - libnr/nr-rect.cpp \ - libnr/nr-rect.h \ - libnr/nr-values.cpp \ - libnr/nr-values.h - -# ###################### -# ### CxxTest stuff #### -# ###################### -CXXTEST_TESTSUITES += \ - $(srcdir)/libnr/in-svg-plane-test.h + libnr/nr-point-fns.h diff --git a/src/libnr/in-svg-plane-test.h b/src/libnr/in-svg-plane-test.h deleted file mode 100644 index 696f82421..000000000 --- a/src/libnr/in-svg-plane-test.h +++ /dev/null @@ -1,82 +0,0 @@ -#include - -#include -#include - -#include "libnr/in-svg-plane.h" -#include <2geom/math-utils.h> -#include <2geom/point.h> - -class InSvgPlaneTest : public CxxTest::TestSuite -{ -public: - - InSvgPlaneTest() : - setupValid(true), - p3n4( 3.0, -4.0 ), - p0(0.0, 0.0), - small( pow(2.0, -1070) ), - inf( 1e400 ), - nan( inf - inf ), - small_left( -small, 0.0 ), - small_n3_4( -3.0 * small, 4.0 * small ), - part_nan( 3., nan ) - { - setupValid &= IS_NAN(nan); - setupValid &= !IS_NAN(small); - } - virtual ~InSvgPlaneTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static InSvgPlaneTest *createSuite() { return new InSvgPlaneTest(); } - static void destroySuite( InSvgPlaneTest *suite ) { delete suite; } - -// Called before each test in this suite - void setUp() - { - TS_ASSERT( setupValid ); - } - - bool setupValid; - Geom::Point const p3n4; - Geom::Point const p0; - double const small; - double const inf; - double const nan; - Geom::Point const small_left; - Geom::Point const small_n3_4; - Geom::Point const part_nan; - - - void testInSvgPlane(void) - { - TS_ASSERT( in_svg_plane(p3n4) ); - TS_ASSERT( in_svg_plane(p0) ); - TS_ASSERT( in_svg_plane(small_left) ); - TS_ASSERT( in_svg_plane(small_n3_4) ); - TS_ASSERT_DIFFERS( nan, nan ); - TS_ASSERT( !in_svg_plane(Geom::Point(nan, 3.)) ); - TS_ASSERT( !in_svg_plane(Geom::Point(inf, nan)) ); - TS_ASSERT( !in_svg_plane(Geom::Point(0., -inf)) ); - double const xs[] = {inf, -inf, nan, 1., -2., small, -small}; - for (unsigned i = 0; i < G_N_ELEMENTS(xs); ++i) { - for (unsigned j = 0; j < G_N_ELEMENTS(xs); ++j) { - TS_ASSERT_EQUALS( in_svg_plane(Geom::Point(xs[i], xs[j])), - (fabs(xs[i]) < inf && - fabs(xs[j]) < inf ) ); - } - } - } -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/in-svg-plane.h b/src/libnr/in-svg-plane.h deleted file mode 100644 index 68c9e92a0..000000000 --- a/src/libnr/in-svg-plane.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef SEEN_LIBNR_IN_SVG_PLANE_H -#define SEEN_LIBNR_IN_SVG_PLANE_H - -#include <2geom/point.h> - -/** - * Returns true iff the coordinates of \a p are finite, non-NaN, and "small enough". Currently we - * use the magic number 1e18 for determining "small enough", as this number has in the past been - * used in sodipodi code as a sort of "infinity" value. - * - * For SVG Tiny output, we might choose a smaller value corresponding to the range of valid numbers - * in SVG Tiny (which uses fixed-point arithmetic). - */ -inline bool -in_svg_plane(Geom::Point const &p) -{ - return Geom::LInfty(p) < 1e18; -} - - -#endif /* !SEEN_LIBNR_IN_SVG_PLANE_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h deleted file mode 100644 index 7e2423ea6..000000000 --- a/src/libnr/nr-convert2geom.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef INKSCAPE_LIBNR_CONVERT2GEOM_H -#define INKSCAPE_LIBNR_CONVERT2GEOM_H - -/* - * Converts between NR and 2Geom types. - * -* Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include <2geom/rect.h> - -inline Geom::OptRect to_2geom(NRRect const *nr) { - Geom::OptRect ret; - if (!nr) return ret; - if (nr->x1 < nr->x0 || nr->y1 < nr->y0) return ret; - ret = Geom::Rect(Geom::Point(nr->x0, nr->y0), Geom::Point(nr->x1, nr->y1)); - return ret; -} - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rect-l.cpp b/src/libnr/nr-rect-l.cpp deleted file mode 100644 index 1cb268266..000000000 --- a/src/libnr/nr-rect-l.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "libnr/nr-rect-l.h" - -NRRectL::NRRectL() -{ - x0 = G_MAXINT32; - y0 = G_MAXINT32; - x1 = G_MININT32; - y1 = G_MININT32; -} - -NRRectL::NRRectL(gint32 xmin, gint32 ymin, gint32 xmax, gint32 ymax) -{ - x0 = xmin; - y0 = ymin; - x1 = xmax; - y1 = ymax; -} - -NRRectL::NRRectL(Geom::OptIntRect const &r) -{ - if (r) { - x0 = r->left(); - y0 = r->top(); - x1 = r->right(); - y1 = r->bottom(); - } else { - x0 = G_MAXINT32; - y0 = G_MAXINT32; - x1 = G_MININT32; - y1 = G_MININT32; - } -} - -NRRectL::NRRectL(Geom::IntRect const &r) -{ - x0 = r.left(); - y0 = r.top(); - x1 = r.right(); - y1 = r.bottom(); -} - -Geom::OptIntRect NRRectL::upgrade_2geom() const -{ - Geom::OptIntRect ret; - if (x0 > x1 || y0 > y1) return ret; - ret = Geom::IntRect(x0, y0, x1, y1); - return ret; -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rect-l.h b/src/libnr/nr-rect-l.h deleted file mode 100644 index c4c5f5a6d..000000000 --- a/src/libnr/nr-rect-l.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SEEN_NR_RECT_L_H -#define SEEN_NR_RECT_L_H - -#include -#include <2geom/int-rect.h> - -struct NRRectL { - gint32 x0, y0, x1, y1; - NRRectL(); - NRRectL(gint32 xmin, gint32 ymin, gint32 xmax, gint32 ymax); - explicit NRRectL(Geom::IntRect const &r); - explicit NRRectL(Geom::OptIntRect const &r); - operator Geom::OptIntRect() const { Geom::OptIntRect r = upgrade_2geom(); return r; } - Geom::OptIntRect upgrade_2geom() const; -}; - -#endif /* !SEEN_NR_RECT_L_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp deleted file mode 100644 index 67857ad49..000000000 --- a/src/libnr/nr-rect.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#define __NR_RECT_C__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include -#include "nr-rect.h" -#include "nr-rect-l.h" - -NRRect::NRRect(Geom::OptRect const &rect) { - if (rect) { - x0 = rect->min()[Geom::X]; - y0 = rect->min()[Geom::Y]; - x1 = rect->max()[Geom::X]; - y1 = rect->max()[Geom::Y]; - } else { - *this = NR_RECT_EMPTY; - } -} - -Geom::OptRect NRRect::upgrade_2geom() const { - if (x0 > x1 || y0 > y1) { - return Geom::OptRect(); - } else { - return Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)); - } -} - -/** - * \param r0 Rectangle. - * \param r1 Another rectangle. - * \param d Filled in with the intersection of r0 and r1. - * \return d. - */ - -NRRectL *nr_rect_l_intersect(NRRectL *d, const NRRectL *r0, const NRRectL *r1) -{ - gint32 t; - t = std::max(r0->x0, r1->x0); - d->x1 = std::min(r0->x1, r1->x1); - d->x0 = t; - t = std::max(r0->y0, r1->y0); - d->y1 = std::min(r0->y1, r1->y1); - d->y0 = t; - - return d; -} - -NRRect * -nr_rect_d_intersect (NRRect *d, const NRRect *r0, const NRRect *r1) -{ - gint32 t; - t = MAX (r0->x0, r1->x0); - d->x1 = MIN (r0->x1, r1->x1); - d->x0 = t; - t = MAX (r0->y0, r1->y0); - d->y1 = MIN (r0->y1, r1->y1); - d->y0 = t; - - return d; -} - -// returns minimal rect which covers all of r0 not covered by r1 -NRRectL * -nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1) -{ - bool inside1 = nr_rect_l_test_inside(r1, r0->x0, r0->y0); - bool inside2 = nr_rect_l_test_inside(r1, r0->x1, r0->y0); - bool inside3 = nr_rect_l_test_inside(r1, r0->x1, r0->y1); - bool inside4 = nr_rect_l_test_inside(r1, r0->x0, r0->y1); - - if (inside1 && inside2 && inside3) { - *d = NR_RECT_L_EMPTY; - - } else if (inside1 && inside2) { - d->x0 = r0->x0; - d->y0 = r1->y1; - - d->x1 = r0->x1; - d->y1 = r0->y1; - } else if (inside2 && inside3) { - d->x0 = r0->x0; - d->y0 = r0->y0; - - d->x1 = r1->x0; - d->y1 = r0->y1; - } else if (inside3 && inside4) { - d->x0 = r0->x0; - d->y0 = r0->y0; - - d->x1 = r0->x1; - d->y1 = r1->y0; - } else if (inside4 && inside1) { - d->x0 = r1->x1; - d->y0 = r0->y0; - - d->x1 = r0->x1; - d->y1 = r0->y1; - } else { - d->x0 = r0->x0; - d->y0 = r0->y0; - - d->x1 = r0->x1; - d->y1 = r0->y1; - } - return d; -} - -gint32 nr_rect_l_area(NRRectL *r) -{ - if (!r || NR_RECT_DFLS_TEST_EMPTY (r)) { - return 0; - } - return ((r->x1 - r->x0) * (r->y1 - r->y0)); -} - -NRRect * -nr_rect_d_union (NRRect *d, const NRRect *r0, const NRRect *r1) -{ - if (NR_RECT_DFLS_TEST_EMPTY (r0)) { - if (NR_RECT_DFLS_TEST_EMPTY (r1)) { - *d = NR_RECT_EMPTY; - } else { - *d = *r1; - } - } else { - if (NR_RECT_DFLS_TEST_EMPTY (r1)) { - *d = *r0; - } else { - double t; - t = MIN (r0->x0, r1->x0); - d->x1 = MAX (r0->x1, r1->x1); - d->x0 = t; - t = MIN (r0->y0, r1->y0); - d->y1 = MAX (r0->y1, r1->y1); - d->y0 = t; - } - } - return d; -} - -NRRectL * -nr_rect_l_union (NRRectL *d, const NRRectL *r0, const NRRectL *r1) -{ - if (NR_RECT_DFLS_TEST_EMPTY (r0)) { - if (NR_RECT_DFLS_TEST_EMPTY (r1)) { - *d = NR_RECT_L_EMPTY; - } else { - *d = *r1; - } - } else { - if (NR_RECT_DFLS_TEST_EMPTY (r1)) { - *d = *r0; - } else { - double t; - t = MIN (r0->x0, r1->x0); - d->x1 = MAX (r0->x1, r1->x1); - d->x0 = t; - t = MIN (r0->y0, r1->y0); - d->y1 = MAX (r0->y1, r1->y1); - d->y0 = t; - } - } - return d; -} - -NRRect * -nr_rect_union_pt(NRRect *dst, Geom::Point const &p) -{ - return nr_rect_d_union_xy(dst, p[Geom::X], p[Geom::Y]); -} - -NRRect * -nr_rect_d_union_xy (NRRect *d, double x, double y) -{ - if ((d->x0 <= d->x1) && (d->y0 <= d->y1)) { - d->x0 = MIN (d->x0, x); - d->y0 = MIN (d->y0, y); - d->x1 = MAX (d->x1, x); - d->y1 = MAX (d->y1, y); - } else { - d->x0 = d->x1 = x; - d->y0 = d->y1 = y; - } - return d; -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h deleted file mode 100644 index 4931b3e10..000000000 --- a/src/libnr/nr-rect.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef LIBNR_NR_RECT_H_SEEN -#define LIBNR_NR_RECT_H_SEEN - -/** \file - * Definitions of NRRect and NR::Rect types, and some associated functions \& macros. - *//* - * Authors: - * Lauris Kaplinski - * Nathan Hurst - * MenTaLguY - * - * This code is in public domain - */ - -#include -#include -#include -#include -#include <2geom/rect.h> - -#include "libnr/nr-forward.h" -#include "libnr/nr-values.h" -#include "libnr/nr-macros.h" - -/* legacy rect stuff */ -/* NULL rect is infinite */ - -struct NRRect { - NRRect() - : x0(0), y0(0), x1(0), y1(0) - {} - NRRect(double xmin, double ymin, double xmax, double ymax) - : x0(xmin), y0(ymin), x1(xmax), y1(ymax) - {} - explicit NRRect(Geom::OptRect const &rect); - operator Geom::OptRect() const { return upgrade_2geom(); } - Geom::OptRect upgrade_2geom() const; - - double x0, y0, x1, y1; -}; - -// TODO convert to static overloaded functions (pointer and ref) once performance can be tested: -#define nr_rect_l_test_empty_ptr(r) ((r) && NR_RECT_DFLS_TEST_EMPTY(r)) -#define nr_rect_l_test_empty(r) NR_RECT_DFLS_TEST_EMPTY_REF(r) - -#define nr_rect_d_test_intersect(r0,r1) \ - (!nr_rect_d_test_empty(r0) && !nr_rect_d_test_empty(r1) && \ - !((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1))) - -// TODO convert to static overloaded functions (pointer and ref) once performance can be tested: -#define nr_rect_l_test_intersect_ptr(r0,r1) \ - (!nr_rect_l_test_empty_ptr(r0) && !nr_rect_l_test_empty_ptr(r1) && \ - !((r0) && (r1) && !NR_RECT_DFLS_TEST_INTERSECT(r0, r1))) -#define nr_rect_l_test_intersect(r0,r1) \ - (!nr_rect_l_test_empty(r0) && !nr_rect_l_test_empty(r1) && \ - !(!NR_RECT_DFLS_TEST_INTERSECT_REF(r0, r1))) - -#define nr_rect_d_point_d_test_inside(r,p) ((p) && (!(r) || (!NR_RECT_DF_TEST_EMPTY(r) && NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p)))) -#define nr_rect_l_point_l_test_inside(r,p) ((p) && (!(r) || (!NR_RECT_DFLS_TEST_EMPTY(r) && NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p)))) -#define nr_rect_l_test_inside(r,x,y) ((!(r) || (!NR_RECT_DFLS_TEST_EMPTY(r) && NR_RECT_LS_TEST_INSIDE(r,x,y)))) - -// returns minimal rect which covers all of r0 not covered by r1 -NRRectL *nr_rect_l_subtract(NRRectL *d, NRRectL const *r0, NRRectL const *r1); - -// returns the area of r -gint32 nr_rect_l_area(NRRectL *r); - -/* NULL values are OK for r0 and r1, but not for d */ -NRRect *nr_rect_d_intersect(NRRect *d, NRRect const *r0, NRRect const *r1); -NRRectL *nr_rect_l_intersect(NRRectL *d, NRRectL const *r0, NRRectL const *r1); - -NRRect *nr_rect_d_union(NRRect *d, NRRect const *r0, NRRect const *r1); -NRRectL *nr_rect_l_union(NRRectL *d, NRRectL const *r0, NRRectL const *r1); - -NRRect *nr_rect_union_pt(NRRect *dst, Geom::Point const &p); -NRRect *nr_rect_d_union_xy(NRRect *d, double x, double y); -NRRectL *nr_rect_l_union_xy(NRRectL *d, gint32 x, gint32 y); - - -#endif /* !LIBNR_NR_RECT_H_SEEN */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-values.cpp b/src/libnr/nr-values.cpp deleted file mode 100644 index 06f33b13f..000000000 --- a/src/libnr/nr-values.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#define __NR_VALUES_C__ - -#include "libnr/nr-values.h" -#include "libnr/nr-rect.h" -#include "libnr/nr-rect-l.h" - -/* -The following predefined objects are for reference -and comparison. -*/ -NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE); -NRRectL NR_RECT_L_EMPTY(NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L); - -/** component_vectors[i] is like $e_i$ in common mathematical usage; - or equivalently $I_i$ (where $I$ is the identity matrix). */ -Geom::Point const component_vectors[] = {Geom::Point(1., 0.), - Geom::Point(0., 1.)}; - diff --git a/src/libnr/nr-values.h b/src/libnr/nr-values.h deleted file mode 100644 index 07faec9fa..000000000 --- a/src/libnr/nr-values.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __NR_VALUES_H__ -#define __NR_VALUES_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include -#include <2geom/point.h> - -#define NR_EPSILON 1e-18 - -#define NR_HUGE 1e18 -#define NR_HUGE_L (0x7fffffff) - -/* -The following predefined objects are for reference -and comparison. They are defined in nr-values.cpp -*/ -extern NRRect NR_RECT_EMPTY; -extern NRRectL NR_RECT_L_EMPTY; - -/** component_vectors[i] has 1.0 at position i, and 0.0 elsewhere - (i.e. in the other position). */ -extern Geom::Point const component_vectors[2]; - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 641adc3ac..f8b2c3b9d 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -22,7 +22,6 @@ #include #include <2geom/pathvector.h> #include <2geom/svg-path.h> -#include "libnr/nr-rect.h" #include "libnrtype/font-glyph.h" #include "libnrtype/font-instance.h" #include "livarot/Path.h" diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index a8852ed8a..4406d9f93 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -14,7 +14,6 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include #include <2geom/d2.h> #include <2geom/affine.h> #include diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 392ac20bf..3ca3feee4 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -7,11 +7,9 @@ #include #include "FontFactory.h" -#include #include #include #include -#include "libnr/nr-rect.h" #include <2geom/d2.h> // the font_instance are the template of several raster_font; they provide metrics and outlines diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp index 34b1e43b8..2fbc18ffd 100644 --- a/src/libnrtype/nr-type-primitives.cpp +++ b/src/libnrtype/nr-type-primitives.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include "nr-type-primitives.h" /** diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 6b5d4fd95..22d989778 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -12,7 +12,6 @@ #include #include "LivarotDefs.h" #include "livarot/livarot-forward.h" -#include #include <2geom/point.h> struct SPStyle; diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index 74a057d06..ed5f03f80 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -6,10 +6,11 @@ * */ +#include +#include <2geom/transforms.h> #include "Path.h" #include "Shape.h" #include "livarot/path-description.h" -#include <2geom/transforms.h> /* * path description -> polyline diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 708d20f3f..e47ed8916 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -20,7 +20,6 @@ #include "Path.h" #include "style.h" #include "livarot/path-description.h" -#include "libnr/nr-convert2geom.h" #include <2geom/pathvector.h> #include <2geom/point.h> #include <2geom/affine.h> diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index a002901b2..9bac3b860 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -30,7 +30,6 @@ #include <2geom/affine.h> #include "ui/widget/scalar.h" -#include "libnr/nr-values.h" namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 87e3dbe5c..8324271ed 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -31,7 +31,6 @@ #include <2geom/affine.h> #include "ui/widget/scalar.h" -#include "libnr/nr-values.h" namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index fc15ce1f5..5454a5408 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -9,7 +9,6 @@ #include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" #include "svg/svg.h" -#include "libnr/nr-values.h" #include "xml/repr.h" #include #include "ui/widget/registered-widget.h" diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index cdfb1fb50..d5a6e9291 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -9,7 +9,6 @@ #include "live_effects/parameter/random.h" #include "live_effects/effect.h" #include "svg/svg.h" -#include "libnr/nr-values.h" #include "ui/widget/registered-widget.h" #include #include "ui/widget/random.h" diff --git a/src/marker.cpp b/src/marker.cpp index db9779460..e75cdff43 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -17,7 +17,6 @@ #include #include "config.h" -#include "libnr/nr-convert2geom.h" #include <2geom/affine.h> #include <2geom/transforms.h> #include "svg/svg.h" diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 57205a436..d823c1daa 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -34,7 +34,6 @@ #include <2geom/bezier-utils.h> #include "display/canvas-bpath.h" #include -#include "libnr/in-svg-plane.h" #include "context-fns.h" #include "sp-namedview.h" #include "xml/repr.h" @@ -69,6 +68,8 @@ static SPDrawContextClass *pencil_parent_class; static Geom::Point pencil_drag_origin_w(0, 0); static bool pencil_within_tolerance = false; +static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; } + /** * Register SPPencilContext class with Gdk and return its type number. */ diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 75745f4af..4c3c0f197 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -85,7 +85,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-filter-reference.h" #include "gradient-drag.h" #include "uri-references.h" -#include "libnr/nr-convert2geom.h" #include "display/curve.h" #include "display/canvas-bpath.h" #include "inkscape-private.h" diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 0e5e533fc..19c09902b 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1213,7 +1213,8 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop, false, _items_const); - Inkscape::Snapper::SnapConstraint const constraint(component_vectors[dim_b]); + Geom::Point cvec; cvec[dim_b] = 1.; + Inkscape::Snapper::SnapConstraint const constraint(cvec); // When skewing, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapSkew" for details Geom::Point const s(skew[dim_a], scale[dim_a]); Inkscape::SnappedPoint sn = m.constrainedSnapSkew(_snap_points, _point, constraint, s, _origin, Geom::Dim2(dim_b)); @@ -1475,14 +1476,15 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) // the constraint-line once. The constraint lines are parallel, but might not be colinear. // Therefore we will have to set the point through which the constraint-line runs // individually for each point to be snapped; this will be handled however by _snapTransformed() + Geom::Point cvec; cvec[dim] = 1.; s.push_back(m.constrainedSnapTranslate(_bbox_points_for_translating, _point, - Inkscape::Snapper::SnapConstraint(component_vectors[dim]), + Inkscape::Snapper::SnapConstraint(cvec), dxy)); s.push_back(m.constrainedSnapTranslate(_snap_points, _point, - Inkscape::Snapper::SnapConstraint(component_vectors[dim]), + Inkscape::Snapper::SnapConstraint(cvec), dxy)); } else { // !control diff --git a/src/snap.cpp b/src/snap.cpp index 7647341fe..1756e7dd2 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -734,7 +734,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( Geom::Coord r = Geom::L2(b); // the radius of the circular constraint dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, b, r); } else if (transformation_type == STRETCH) { // when non-uniform stretching { - dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), component_vectors[dim]); + Geom::Point cvec; cvec[dim] = 1.; + dedicated_constraint = Inkscape::Snapper::SnapConstraint((*i).getPoint(), cvec); } else if (transformation_type == TRANSLATE) { // When doing a constrained translation, all points will move in the same direction, i.e. // either horizontally or vertically. The lines along which they move are therefore all @@ -751,7 +752,8 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // When scaling, a point aligned either horizontally or vertically with the origin can only // move in that specific direction; therefore it should only snap in that direction, otherwise // we will get snapped points with an invalid transformation - dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, component_vectors[c1]); + Geom::Point cvec; cvec[c1] = 1.; + dedicated_constraint = Inkscape::Snapper::SnapConstraint(origin, cvec); snapped_point = constrainedSnap(*j, dedicated_constraint, bbox); } else { // If we have a collection of SnapCandidatePoints, with mixed constrained snapping and free snapping diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index a06d098d0..5d30800d6 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -116,7 +116,7 @@ static void sp_guide_class_init(SPGuideClass *gc) static void sp_guide_init(SPGuide *guide) { - guide->normal_to_line = component_vectors[Geom::Y]; + guide->normal_to_line = Geom::Point(0.,1.); guide->point_on_line = Geom::Point(0.,0.); guide->color = 0x0000ff7f; guide->hicolor = 0xff00007f; @@ -205,9 +205,9 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) { if (value && !strcmp(value, "horizontal")) { /* Visual representation of a horizontal line, constrain vertically (y coordinate). */ - guide->normal_to_line = component_vectors[Geom::Y]; + guide->normal_to_line = Geom::Point(0., 1.); } else if (value && !strcmp(value, "vertical")) { - guide->normal_to_line = component_vectors[Geom::X]; + guide->normal_to_line = Geom::Point(1., 0.); } else if (value) { gchar ** strarray = g_strsplit(value, ",", 2); double newx, newy; @@ -220,11 +220,11 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) guide->normal_to_line = direction; } else { // default to vertical line for bad arguments - guide->normal_to_line = component_vectors[Geom::X]; + guide->normal_to_line = Geom::Point(1., 0.); } } else { // default to vertical line for bad arguments - guide->normal_to_line = component_vectors[Geom::X]; + guide->normal_to_line = Geom::Point(1., 0.); } sp_guide_set_normal(*guide, guide->normal_to_line, false); } @@ -493,11 +493,11 @@ char *sp_guide_description(SPGuide const *guide, const bool verbose) gchar *shortcuts = g_strdup_printf("; %s", _("Shift+drag to rotate, Ctrl+drag to move origin, Del to delete")); - if ( are_near(guide->normal_to_line, component_vectors[X]) || - are_near(guide->normal_to_line, -component_vectors[X]) ) { + if ( are_near(guide->normal_to_line, Geom::Point(1., 0.)) || + are_near(guide->normal_to_line, -Geom::Point(1., 0.)) ) { descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str); - } else if ( are_near(guide->normal_to_line, component_vectors[Y]) || - are_near(guide->normal_to_line, -component_vectors[Y]) ) { + } else if ( are_near(guide->normal_to_line, Geom::Point(0., 1.)) || + are_near(guide->normal_to_line, -Geom::Point(0., 1.)) ) { descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str); } else { double const radians = guide->angle(); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index a2a603c68..c0c23ba8b 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -25,7 +25,6 @@ # include "config.h" #endif - #include "sp-item.h" #include "svg/svg.h" #include "print.h" @@ -60,7 +59,6 @@ #include "sp-title.h" #include "sp-desc.h" -#include "libnr/nr-convert2geom.h" #include "util/find-last-if.h" #include "util/reverse-list.h" #include <2geom/rect.h> @@ -1302,7 +1300,7 @@ gint SPItem::emitEvent(SPEvent &event) */ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) { - if (!matrix_equalp(transform_matrix, transform, NR_EPSILON)) { + if (!Geom::are_near(transform_matrix, transform, 1e-18)) { transform = transform_matrix; /* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a transformation. It's apparently not used anywhere else. */ diff --git a/src/sp-item.h b/src/sp-item.h index 21b3d9006..b827f6555 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -19,14 +19,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #include +#include <2geom/forward.h> +#include <2geom/affine.h> +#include <2geom/rect.h> #include "display/display-forward.h" #include "sp-object.h" -#include <2geom/affine.h> -#include -#include <2geom/forward.h> -#include -#include +#include "snap-preferences.h" #include "snap-candidate.h" class SPGuideConstraint; diff --git a/src/sp-pattern.h b/src/sp-pattern.h index ee7ffd477..acfa3e76e 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -27,7 +27,6 @@ GType sp_pattern_get_type (void); class SPPatternClass; -#include #include "svg/svg-length.h" #include "sp-paint-server.h" #include "uri-references.h" diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 536486bc3..59f343285 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -25,7 +25,6 @@ class SPSymbol; class SPSymbolClass; #include <2geom/affine.h> -#include #include "svg/svg-length.h" #include "enums.h" #include "sp-item-group.h" diff --git a/src/star-context.cpp b/src/star-context.cpp index 878ecfbe7..c954fd7d7 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -34,7 +34,6 @@ #include "desktop.h" #include "desktop-style.h" #include "message-context.h" -#include "libnr/nr-macros.h" #include "pixmaps/cursor-star.xpm" #include "sp-metrics.h" #include diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index adec1de5d..bb89879fb 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -46,8 +46,6 @@ #include "extension/input.h" #include "extension/output.h" #include "selection-chemistry.h" -#include "libnr/nr-rect.h" -#include "libnr/nr-convert2geom.h" #include <2geom/rect.h> #include <2geom/transforms.h> #include "box3d.h" diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 22227cb60..88d934f87 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -25,8 +25,6 @@ #include #include #include -#include "libnr/nr-rect.h" - #include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h index 73f818516..29684ec02 100644 --- a/src/ui/widget/style-subject.h +++ b/src/ui/widget/style-subject.h @@ -11,7 +11,6 @@ #include "util/glib-list-iterators.h" #include -#include "libnr/nr-rect.h" #include <2geom/rect.h> #include "sp-item.h" #include diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp index 9322aa803..c6d6f19a3 100644 --- a/src/ui/widget/zoom-status.cpp +++ b/src/ui/widget/zoom-status.cpp @@ -20,7 +20,6 @@ #include "desktop.h" #include "desktop-handles.h" #include "widgets/spw-utilities.h" -#include "libnr/nr-convert2geom.h" namespace Inkscape { namespace UI { -- cgit v1.2.3 From de7de7c53f938e3322813366af5266686b92936a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 18:17:25 +0200 Subject: Remove unused function project_on_linesegment from nr-point-fns.h (bzr r10582.1.7) --- src/libnr/nr-point-fns.cpp | 22 +--------------------- src/libnr/nr-point-fns.h | 2 -- 2 files changed, 1 insertion(+), 23 deletions(-) (limited to 'src') diff --git a/src/libnr/nr-point-fns.cpp b/src/libnr/nr-point-fns.cpp index a2e74c112..e4fb8cf0b 100644 --- a/src/libnr/nr-point-fns.cpp +++ b/src/libnr/nr-point-fns.cpp @@ -16,6 +16,7 @@ snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Poin return (begin + r_snapped * be); } +// equivalent to Geom::LineSegment(begin, end).nearestPoint(p) double get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end) { @@ -29,27 +30,6 @@ get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom: return (r / length); } -Geom::Point -project_on_linesegment(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2) -{ - // p_proj = projection of p on the linesegment running from p1 to p2 - // p_proj = p1 + u (p2 - p1) - // calculate u according to "Minimum Distance between a Point and a Line" - // see http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/ - - // Warning: projected points will not necessarily be in between the endpoints of the linesegments! - - if (p1 == p2) { // to avoid div. by zero below - return p; - } - - Geom::Point d1(p-p1); // delta 1 - Geom::Point d2(p2-p1); // delta 2 - double u = Geom::dot(d1, d2) / Geom::L2sq(d2); - - return (p1 + u*(p2-p1)); -} - /* Local Variables: mode:c++ diff --git a/src/libnr/nr-point-fns.h b/src/libnr/nr-point-fns.h index b26c969aa..036c943f1 100644 --- a/src/libnr/nr-point-fns.h +++ b/src/libnr/nr-point-fns.h @@ -7,8 +7,6 @@ Geom::Point snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin double get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end); -Geom::Point project_on_linesegment(Geom::Point const &p, Geom::Point const &p1, Geom::Point const &p2); - #endif /* !__NR_POINT_OPS_H__ */ /* -- cgit v1.2.3 From 49627b00f997f2068eb5836376fe4723154ca5bd Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 19:08:22 +0200 Subject: Remove nr-forward.h (bzr r10582.1.8) --- src/extension/implementation/implementation.h | 1 - src/gradient-drag.h | 1 - src/knotholder.h | 1 - src/libnr/CMakeLists.txt | 18 ----------------- src/libnr/Makefile_insert | 1 - src/libnr/nr-forward.h | 28 --------------------------- src/sp-clippath.h | 1 - src/sp-mask.h | 1 - src/svg/svg.h | 1 - src/text-editing.h | 1 - src/ui/view/view.h | 1 - src/widgets/paint-selector.h | 10 +++------- 12 files changed, 3 insertions(+), 62 deletions(-) delete mode 100644 src/libnr/nr-forward.h (limited to 'src') diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index 4a01a3e84..a09f7c863 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -18,7 +18,6 @@ #include "forward.h" #include "extension/extension-forward.h" -#include "libnr/nr-forward.h" #include "xml/node.h" #include <2geom/forward.h> #include <2geom/point.h> diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 40ab065ca..4ad9a1e16 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -20,7 +20,6 @@ #include #include -#include #include <2geom/point.h> #include diff --git a/src/knotholder.h b/src/knotholder.h index 76142ed98..0dd3bba1e 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -20,7 +20,6 @@ #include #include "knot-enums.h" #include "forward.h" -#include "libnr/nr-forward.h" #include <2geom/forward.h> #include "knot-holder-entity.h" #include diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt index 8a31e20db..0adea96f0 100644 --- a/src/libnr/CMakeLists.txt +++ b/src/libnr/CMakeLists.txt @@ -1,32 +1,14 @@ set(nr_SRC - # in-svg-plane-test.cpp nr-object.cpp nr-point-fns.cpp - # nr-point-fns-test.cpp - nr-rect.cpp - nr-rect-l.cpp - # nr-rotate-fns-test.cpp - #nr-translate-test.cpp - # nr-types-test.cpp nr-values.cpp - # testnr.cpp - # ------- # Headers - # in-svg-plane-test.h - in-svg-plane.h - nr-convert2geom.h - nr-forward.h nr-macros.h nr-object.h - # nr-point-fns-test.h nr-point-fns.h - nr-rect-l.h - nr-rect.h - # nr-translate-test.h - # nr-types-test.h nr-values.h ) diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index 6156a45e3..c4b6daa12 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -1,7 +1,6 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ - libnr/nr-forward.h \ libnr/nr-macros.h \ libnr/nr-object.cpp \ libnr/nr-object.h \ diff --git a/src/libnr/nr-forward.h b/src/libnr/nr-forward.h deleted file mode 100644 index 4895ad407..000000000 --- a/src/libnr/nr-forward.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __NR_FORWARD_H__ -#define __NR_FORWARD_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -struct NRPixBlock; -struct NRRect; -struct NRRectL; - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-clippath.h b/src/sp-clippath.h index c151851d3..4084b89d8 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -24,7 +24,6 @@ class SPClipPathView; #include "display/display-forward.h" -#include "libnr/nr-forward.h" #include "sp-object-group.h" #include "uri-references.h" #include "xml/node.h" diff --git a/src/sp-mask.h b/src/sp-mask.h index d493c2dc7..10b42ca1e 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -15,7 +15,6 @@ #include <2geom/rect.h> #include "display/display-forward.h" -#include "libnr/nr-forward.h" #include "sp-object-group.h" #include "uri-references.h" #include "xml/node.h" diff --git a/src/svg/svg.h b/src/svg/svg.h index d5335e1b4..de1d7d872 100644 --- a/src/svg/svg.h +++ b/src/svg/svg.h @@ -17,7 +17,6 @@ #include #include "svg/svg-length.h" -#include "libnr/nr-forward.h" #include <2geom/forward.h> /* Generic */ diff --git a/src/text-editing.h b/src/text-editing.h index 529b25ff5..300d0b76f 100644 --- a/src/text-editing.h +++ b/src/text-editing.h @@ -16,7 +16,6 @@ #include #include // std::pair #include "libnrtype/Layout-TNG.h" -#include #include "text-tag-attributes.h" class SPCSSAttr; diff --git a/src/ui/view/view.h b/src/ui/view/view.h index db6061434..c56d79147 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -21,7 +21,6 @@ #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" -#include #include <2geom/forward.h> /** diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index ebcac380f..f32c2c83d 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -14,8 +14,11 @@ */ #include +#include +#include "color.h" #include "fill-or-stroke.h" +#include "forward.h" #include "sp-gradient-spread.h" #include "sp-gradient-units.h" @@ -27,13 +30,6 @@ class SPGradient; #define SP_IS_PAINT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_PAINT_SELECTOR)) #define SP_IS_PAINT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_PAINT_SELECTOR)) -#include - -#include "../forward.h" -#include -#include - - /// Generic paint selector widget struct SPPaintSelector { GtkVBox vbox; -- cgit v1.2.3 From f65673d0510c6b5e52887f321ac8b932ca5fec37 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 19:15:22 +0200 Subject: Remove last forward declaration of NRPixBlock (bzr r10582.1.9) --- src/display/nr-3dutils.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h index 44cb371e6..c278c81c6 100644 --- a/src/display/nr-3dutils.h +++ b/src/display/nr-3dutils.h @@ -17,8 +17,6 @@ #include #include <2geom/forward.h> -struct NRPixBlock; - namespace NR { #define X_3D 0 -- cgit v1.2.3 From e5c85aa8478032ebecd8c586dc27afcaf77e4314 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 27 Aug 2011 22:54:42 +0200 Subject: Allow snapping to path intersections without snapping to the paths themselves (bzr r10585) --- src/object-snapper.cpp | 15 +++++++++------ src/snap-preferences.cpp | 4 ++++ src/snap-preferences.h | 1 + src/snap.cpp | 10 ++++------ src/snap.h | 2 +- src/snapper.h | 2 +- src/widgets/toolbox.cpp | 5 ++--- 7 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index fd8ef0c7c..5bb7f0d00 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -227,6 +227,9 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, // paths though but only to item nodes then we should still look for the intersections in sp_item_snappoints() bool old_pref = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_INTERSECTION); if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) { + // So if we snap to paths, then findBestSnap will find the intersections + // and therefore we temporarily disable SNAPTARGET_PATH_INTERSECTION, which will + // avoid root_item->getSnappoints() below from returning intersections _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_PATH_INTERSECTION, false); } @@ -322,7 +325,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, // Iterate through all nodes, find out which one is the closest to this guide, and snap to it! _collectNodes(SNAPSOURCE_GUIDE, true); - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) { _collectPaths(p, SNAPSOURCE_GUIDE, true); _snapPaths(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); } @@ -399,7 +402,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, //Build a list of all paths considered for snapping to //Add the item's path to snap to - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_TEXT_BASELINE)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_TEXT_BASELINE)) { if (p_is_other || p_is_a_node || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_bbox)) { if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_TEXT_BASELINE)) { @@ -420,7 +423,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; } - if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) { + if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION)) { SPCurve *curve = NULL; if (SP_IS_SHAPE(root_item)) { curve = SP_SHAPE(root_item)->getCurve(); @@ -474,7 +477,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, g_assert(_snapmanager->getDesktop() != NULL); Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p.getPoint()); - bool const node_tool_active = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH) && selected_path != NULL; + bool const node_tool_active = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION) && selected_path != NULL; if (p.getSourceNum() <= 0) { /* findCandidates() is used for snapping to both paths and nodes. It ignores the path that is @@ -689,7 +692,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, _snapNodes(sc, p, unselected_nodes); - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size(); if (n > 0) { /* While editing a path in the node tool, findCandidates must ignore that path because @@ -737,7 +740,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, _snapNodes(sc, p, unselected_nodes, c, pp); - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { _snapPathsConstrained(sc, p, c, pp); } } diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index d655564f2..a1d4b62fa 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -273,6 +273,10 @@ bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4); } +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4, Inkscape::SnapTargetType const target5) const { + return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4) || isTargetSnappable(target5); +} + bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType const target) const { bool always_on = false; // Only needed as a dummy diff --git a/src/snap-preferences.h b/src/snap-preferences.h index cfcdf6137..9f126d791 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -28,6 +28,7 @@ public: bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const; bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const; bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4, Inkscape::SnapTargetType const target5) const; bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const; void setSnapModeBBox(bool enabled); diff --git a/src/snap.cpp b/src/snap.cpp index 7647341fe..67630399f 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -288,7 +288,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // Find the best snap for this grid, including intersections of the grid-lines bool old_val = _snapindicator; _snapindicator = false; - Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, false, true); + Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, true); _snapindicator = old_val; if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) { // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position @@ -584,7 +584,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); } - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, false); + Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false); s.getPointIfSnapped(p); } @@ -1135,7 +1135,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector &points, const Geom::Point &reference) const; protected: diff --git a/src/snapper.h b/src/snapper.h index 91784d3ae..b3bf9f726 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -25,7 +25,7 @@ struct SnappedConstraints { std::list points; - std::list lines; + //std::list lines; std::list grid_lines; std::list guide_lines; std::list curves; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 26947979d..41e6eb626 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2529,11 +2529,10 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3); gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1); - bool const c4 = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH)); gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION)); - gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4); + gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP)); gtk_action_set_sensitive(GTK_ACTION(act7->gobj()), c1 && c3); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH)); -- cgit v1.2.3 From 7a24e74b5f7da7c3e511e2b9d50e912e86bdccfc Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 28 Aug 2011 14:38:19 +0200 Subject: Filters. More cleanup, and some forgotten strings made translatable (thanks to Masato HASHIMOTO). Translations. inkscape.pot and French translation update. (bzr r10586) --- src/extension/internal/filter/bumps.h | 4 ++-- src/extension/internal/filter/distort.h | 8 ++++---- src/extension/internal/filter/morphology.h | 6 +++--- src/extension/internal/filter/overlays.h | 8 ++++---- src/extension/internal/filter/paint.h | 20 ++++++++++---------- src/extension/internal/filter/textures.h | 12 ++++++------ 6 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index 9f971b0de..8db6c67d2 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -100,7 +100,7 @@ public: "15\n" "-1\n" "\n" - "\n" + "\n" "\n" "<_item value=\"distant\">" N_("Distant") "\n" "<_item value=\"point\">" N_("Point") "\n" @@ -327,7 +327,7 @@ public: "\n" "0\n" "\n" - "\n" + "\n" "-1\n" "5\n" "1.4\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index f4caf3d11..415762466 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -81,8 +81,8 @@ public: "<_item value=\"xor\">" N_("No fill") "\n" "\n" "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" + "<_item value=\"fractalNoise\">" N_("Fractal noise") "\n" + "<_item value=\"turbulence\">" N_("Turbulence") "\n" "\n" "5\n" "5\n" @@ -190,8 +190,8 @@ public: "" N_("Roughen") "\n" "org.inkscape.effect.filter.Roughen\n" "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" + "<_item value=\"fractalNoise\">" N_("Fractal noise") "\n" + "<_item value=\"turbulence\">" N_("Turbulence") "\n" "\n" "1.3\n" "1.3\n" diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 7dde0002d..123d912b0 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -58,9 +58,9 @@ public: "" N_("Cross-smooth") "\n" "org.inkscape.effect.filter.crosssmooth\n" "\n" - "<_item value=\"in\">Inner\n" - "<_item value=\"over\">Outer\n" - "<_item value=\"xor\">Open\n" + "<_item value=\"in\">" N_("Inner") "\n" + "<_item value=\"over\">" N_("Outer") "\n" + "<_item value=\"xor\">" N_("Open") "\n" "\n" "10\n" "1\n" diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h index b98577ce1..1ca745166 100644 --- a/src/extension/internal/filter/overlays.h +++ b/src/extension/internal/filter/overlays.h @@ -56,10 +56,10 @@ public: "" N_("Noise Fill") "\n" "org.inkscape.effect.filter.NoiseFill\n" "\n" - "\n" + "\n" "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" + "<_item value=\"fractalNoise\">" N_("Fractal noise") "\n" + "<_item value=\"turbulence\">" N_("Turbulence") "\n" "\n" "20\n" "40\n" @@ -69,7 +69,7 @@ public: "1\n" "false\n" "\n" - "\n" + "\n" "354957823\n" "\n" "\n" diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index cf0c869a6..b7909a512 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -88,7 +88,7 @@ public: "10\n" "1\n" "\n" - "\n" + "\n" "true\n" "1000\n" "1000\n" @@ -585,8 +585,8 @@ public: "" N_("Neon Draw") "\n" "org.inkscape.effect.filter.NeonDraw\n" "\n" - "<_item value=\"table\">Smoothed\n" - "<_item value=\"discrete\">Contrasted\n" + "<_item value=\"table\">" N_("Smoothed") "\n" + "<_item value=\"discrete\">" N_("Contrasted") "\n" "\n" "1.5\n" "1.5\n" @@ -697,10 +697,10 @@ public: "" N_("Point Engraving") "\n" "org.inkscape.effect.filter.PointEngraving\n" "\n" - "\n" + "\n" "\n" - "<_item value=\"fractalNoise\">Fractal noise\n" - "<_item value=\"turbulence\">Turbulence\n" + "<_item value=\"fractalNoise\">" N_("Fractal noise") "\n" + "<_item value=\"turbulence\">" N_("Turbulence") "\n" "\n" "100\n" "100\n" @@ -719,11 +719,11 @@ public: "0\n" "0.5\n" "\n" - "\n" + "\n" "-1\n" "false\n" "\n" - "\n" + "\n" "1666789119\n" "false\n" "\n" @@ -864,8 +864,8 @@ public: "<_item value=\"dented\">Dented\n" "\n" "\n" - "<_item value=\"discrete\">Poster\n" - "<_item value=\"table\">Painting\n" + "<_item value=\"discrete\">" N_("Poster") "\n" + "<_item value=\"table\">" N_("Painting") "\n" "\n" "5\n" "\n" diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h index 513483e26..32eef6054 100644 --- a/src/extension/internal/filter/textures.h +++ b/src/extension/internal/filter/textures.h @@ -73,12 +73,12 @@ public: "50\n" "5\n" "\n" - "<_item value=\"over\">Wide\n" - "<_item value=\"atop\">Normal\n" - "<_item value=\"in\">Narrow\n" - "<_item value=\"xor\">Overlapping\n" - "<_item value=\"out\">External\n" - "<_item value=\"arithmetic\">Custom\n" + "<_item value=\"over\">" N_("Wide") "\n" + "<_item value=\"atop\">" N_("Normal") "\n" + "<_item value=\"in\">" N_("Narrow") "\n" + "<_item value=\"xor\">" N_("Overlapping") "\n" + "<_item value=\"out\">" N_("External") "\n" + "<_item value=\"arithmetic\">" N_("Custom") "\n" "\n" "<_param name=\"customHeader\" type=\"description\" appearance=\"header\">" N_("Custom stroke options") "\n" "1.5\n" -- cgit v1.2.3 From f07487e34701b93421a2f92b4ad8d308d5a8bace Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 28 Aug 2011 15:03:49 +0200 Subject: Fix bug related to snapping to path intersections (bzr r10587) --- src/object-snapper.cpp | 10 +++++----- src/snap.cpp | 1 - src/snapper.h | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 5bb7f0d00..987b027b0 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -502,8 +502,9 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, } } - int num_path = 0; - int num_segm = 0; + int num_path = 0; // _paths_to_snap_to contains multiple path_vectors, each containing multiple paths. + // num_path will count the paths, and will not be zeroed for each path_vector. It will + // continue counting bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); @@ -549,13 +550,12 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, if (!being_edited || (c1 && c2)) { Geom::Coord const dist = Geom::distance(sp_doc, p_doc); if (dist < getSnapperTolerance()) { - sc.curves.push_back(SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + sc.curves.push_back(SnappedCurve(sp_dt, num_path, index, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); } } } - num_segm++; + num_path++; } // End of: for (Geom::PathVector::iterator ....) - num_path++; } } } diff --git a/src/snap.cpp b/src/snap.cpp index 67630399f..5779e59b0 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1149,7 +1149,6 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co /* std::cout << "Type and number of snapped constraints: " << std::endl; std::cout << " Points : " << sc.points.size() << std::endl; - // std::cout << " Lines : " << sc.lines.size() << std::endl; std::cout << " Grid lines : " << sc.grid_lines.size()<< std::endl; std::cout << " Guide lines : " << sc.guide_lines.size()<< std::endl; std::cout << " Curves : " << sc.curves.size()<< std::endl; diff --git a/src/snapper.h b/src/snapper.h index b3bf9f726..0fee9c7ed 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -25,7 +25,6 @@ struct SnappedConstraints { std::list points; - //std::list lines; std::list grid_lines; std::list guide_lines; std::list curves; -- cgit v1.2.3 From 6c492dc798047a6b3a79e1feb2f79a68b180d7a8 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 28 Aug 2011 20:42:03 +0200 Subject: Tie the snapping of rectangle corners and quadrant points of ellipses to the buttons for cusp and smooth nodes (bzr r10588) --- src/snap-preferences.cpp | 6 ++++-- src/widgets/toolbox.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index a1d4b62fa..fa5903c37 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -143,8 +143,10 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType } else if (target & SNAPTARGET_NODE_CATEGORY) { group_on = getSnapModeNode(); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths - if (target == SNAPTARGET_RECT_CORNER || target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { // Don't have their own button; on when the group is on - target = SNAPTARGET_NODE_CATEGORY; + if (target == SNAPTARGET_RECT_CORNER) { + target = SNAPTARGET_NODE_CUSP; + } else if (target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { + target = SNAPTARGET_NODE_SMOOTH; } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 41e6eb626..d2753fadf 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2351,7 +2351,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemNode", - _("To nodes"), _("Snap cusp nodes"), INKSCAPE_ICON("snap-nodes-cusp"), secondarySize, + _("To nodes"), _("Snap cusp nodes, incl. rectangle corners"), INKSCAPE_ICON("snap-nodes-cusp"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE_CUSP); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2360,7 +2360,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapToSmoothNodes", - _("Smooth nodes"), _("Snap smooth nodes"), INKSCAPE_ICON("snap-nodes-smooth"), + _("Smooth nodes"), _("Snap smooth nodes, incl. quadrant points of ellipses"), INKSCAPE_ICON("snap-nodes-smooth"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); -- cgit v1.2.3 From be7df18d6aef42dd657426b6a9d30834e5f54ca6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 28 Aug 2011 21:18:21 +0200 Subject: Remove nr-object.h and nr-macros.h (bzr r10582.1.10) --- src/extension/effect.cpp | 18 +-- src/extension/effect.h | 4 +- src/helper/action.cpp | 185 ++++++++------------------- src/helper/action.h | 51 +++----- src/interface.cpp | 37 ++---- src/libnr/Makefile_insert | 3 - src/libnr/nr-macros.h | 61 --------- src/libnr/nr-object.cpp | 318 ---------------------------------------------- src/libnr/nr-object.h | 157 ----------------------- src/verbs.cpp | 232 ++++++++------------------------- src/verbs.h | 4 +- src/widgets/button.cpp | 62 ++++----- src/widgets/button.h | 5 +- src/widgets/toolbox.cpp | 26 +--- 14 files changed, 181 insertions(+), 982 deletions(-) delete mode 100644 src/libnr/nr-macros.h delete mode 100644 src/libnr/nr-object.cpp delete mode 100644 src/libnr/nr-object.h (limited to 'src') diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index e01eb760a..b42caca06 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -355,21 +355,15 @@ Effect::set_pref_dialog (PrefDialog * prefdialog) return; } -/** \brief Create an action for a \c EffectVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ SPAction * Effect::EffectVerb::make_action (Inkscape::UI::View::View * view) { - return make_action_helper(view, &vector, static_cast(this)); + return make_action_helper(view, &perform, static_cast(this)); } /** \brief Decode the verb code and take appropriate action */ void -Effect::EffectVerb::perform( SPAction *action, void * data, void */*pdata*/ ) +Effect::EffectVerb::perform( SPAction *action, void * data ) { Inkscape::UI::View::View * current_view = sp_action_get_view(action); // SPDocument * current_document = current_view->doc; @@ -388,14 +382,6 @@ Effect::EffectVerb::perform( SPAction *action, void * data, void */*pdata*/ ) return; } -/** - * Action vector to define functions called if a staticly defined file verb - * is called. - */ -SPActionEventVector Effect::EffectVerb::vector = - {{NULL}, Effect::EffectVerb::perform, NULL, NULL, NULL, NULL}; - - } } /* namespace Inkscape, Extension */ /* diff --git a/src/extension/effect.h b/src/extension/effect.h index 28ebc5d96..61a826ad4 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -53,9 +53,7 @@ class Effect : public Extension { back to the effect that created it. */ class EffectVerb : public Inkscape::Verb { private: - static void perform (SPAction * action, void * mydata, void * otherdata); - /** \brief Function to call for specific actions */ - static SPActionEventVector vector; + static void perform (SPAction * action, void * mydata); /** \brief The effect that this verb represents. */ Effect * _effect; diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 84d150615..3eb881300 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -1,5 +1,3 @@ -#define __SP_ACTION_C__ - /** \file * SPAction implementation * @@ -23,26 +21,31 @@ static void sp_action_class_init (SPActionClass *klass); static void sp_action_init (SPAction *action); -static void sp_action_finalize (NRObject *object); +static void sp_action_finalize (GObject *object); -static NRActiveObjectClass *parent_class; +static GObjectClass *parent_class; /** * Register SPAction class and return its type. */ -NRType +GType sp_action_get_type (void) { - static unsigned int type = 0; - if (!type) { - type = nr_object_register_type (NR_TYPE_ACTIVE_OBJECT, - "SPAction", - sizeof (SPActionClass), - sizeof (SPAction), - (void (*) (NRObjectClass *)) sp_action_class_init, - (void (*) (NRObject *)) sp_action_init); - } - return type; + static GType type = 0; + if (!type) { + GTypeInfo info = { + sizeof(SPActionClass), + NULL, NULL, + (GClassInitFunc) sp_action_class_init, + NULL, NULL, + sizeof(SPAction), + 0, + (GInstanceInitFunc) sp_action_init, + NULL + }; + type = g_type_register_static(G_TYPE_OBJECT, "SPAction", &info, (GTypeFlags)0); + } + return type; } /** @@ -51,14 +54,10 @@ sp_action_get_type (void) static void sp_action_class_init (SPActionClass *klass) { - NRObjectClass * object_class; - - object_class = (NRObjectClass *) klass; + parent_class = (GObjectClass*) g_type_class_ref(G_TYPE_OBJECT); - parent_class = (NRActiveObjectClass *) (((NRObjectClass *) klass)->parent); - - object_class->finalize = sp_action_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; + GObjectClass *object_class = (GObjectClass *) klass; + object_class->finalize = sp_action_finalize; } /** @@ -72,24 +71,32 @@ sp_action_init (SPAction *action) action->view = NULL; action->id = action->name = action->tip = NULL; action->image = NULL; + + new (&action->signal_perform) sigc::signal(); + new (&action->signal_set_sensitive) sigc::signal(); + new (&action->signal_set_active) sigc::signal(); + new (&action->signal_set_name) sigc::signal(); } /** * Called before SPAction object destruction. */ static void -sp_action_finalize (NRObject *object) +sp_action_finalize (GObject *object) { - SPAction *action; + SPAction *action = SP_ACTION(object); - action = (SPAction *) object; + g_free (action->image); + g_free (action->tip); + g_free (action->name); + g_free (action->id); - if (action->image) free (action->image); - if (action->tip) free (action->tip); - if (action->name) free (action->name); - if (action->id) free (action->id); + action->signal_perform.~signal(); + action->signal_set_sensitive.~signal(); + action->signal_set_active.~signal(); + action->signal_set_name.~signal(); - ((NRObjectClass *) (parent_class))->finalize (object); + parent_class->finalize (object); } /** @@ -103,14 +110,14 @@ sp_action_new(Inkscape::UI::View::View *view, const gchar *image, Inkscape::Verb * verb) { - SPAction *action = (SPAction *)nr_object_new(SP_TYPE_ACTION); + SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); action->view = view; action->sensitive = TRUE; - if (id) action->id = strdup (id); - if (name) action->name = strdup (name); - if (tip) action->tip = strdup (tip); - if (image) action->image = strdup (image); + action->id = g_strdup (id); + action->name = g_strdup (name); + action->tip = g_strdup (tip); + action->image = g_strdup (image); action->verb = verb; return action; @@ -147,41 +154,16 @@ public: \return None \brief Executes an action \param action The action to be executed - \param data Data that is passed into the action. This depends - on the situation that the action is used in. - - This function implements the 'action' in SPActions. It first validates - its parameters, making sure it got an action passed in. Then it - turns that action into its parent class of NRActiveObject. The - NRActiveObject allows for listeners to be attached to it. This - function goes through those listeners and calls them with the - vector that was attached to the listener. + \param data ignored */ void sp_action_perform (SPAction *action, void * data) { - NRActiveObject *aobject; - - nr_return_if_fail (action != NULL); - nr_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); Inkscape::Debug::EventTracker tracker(action); - - aobject = NR_ACTIVE_OBJECT(action); - if (aobject->callbacks) { - unsigned int i; - for (i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener; - SPActionEventVector *avector; - - listener = &aobject->callbacks->listeners[i]; - avector = (SPActionEventVector *) listener->vector; - - if ((listener->size >= sizeof (SPActionEventVector)) && avector != NULL && avector->perform != NULL) { - avector->perform (action, listener->data, data); - } - } - } + action->signal_perform.emit(); } /** @@ -190,26 +172,10 @@ sp_action_perform (SPAction *action, void * data) void sp_action_set_active (SPAction *action, unsigned int active) { - nr_return_if_fail (action != NULL); - nr_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - if (active != action->active) { - NRActiveObject *aobject; - action->active = active; - aobject = (NRActiveObject *) action; - if (aobject->callbacks) { - unsigned int i; - for (i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener; - SPActionEventVector *avector; - listener = aobject->callbacks->listeners + i; - avector = (SPActionEventVector *) listener->vector; - if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_active) { - avector->set_active (action, active, listener->data); - } - } - } - } + action->signal_set_active.emit(active); } /** @@ -218,59 +184,20 @@ sp_action_set_active (SPAction *action, unsigned int active) void sp_action_set_sensitive (SPAction *action, unsigned int sensitive) { - nr_return_if_fail (action != NULL); - nr_return_if_fail (SP_IS_ACTION (action)); + g_return_if_fail (action != NULL); + g_return_if_fail (SP_IS_ACTION (action)); - if (sensitive != action->sensitive) { - NRActiveObject *aobject; - action->sensitive = sensitive; - aobject = (NRActiveObject *) action; - if (aobject->callbacks) { - unsigned int i; - for (i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener; - SPActionEventVector *avector; - listener = aobject->callbacks->listeners + i; - avector = (SPActionEventVector *) listener->vector; - if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_sensitive) { - avector->set_sensitive (action, sensitive, listener->data); - } - } - } - } + action->signal_set_sensitive.emit(sensitive); } - -/** - * Change name for all actions that can be taken with the action. - */ void -sp_action_set_name (SPAction *action, Glib::ustring name) +sp_action_set_name (SPAction *action, Glib::ustring const &name) { - nr_return_if_fail (action != NULL); - nr_return_if_fail (SP_IS_ACTION (action)); - - NRActiveObject *aobject; - g_free(action->name); - action->name = g_strdup(name.c_str()); - aobject = (NRActiveObject *) action; - if (aobject->callbacks) { - unsigned int i; - for (i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener; - SPActionEventVector *avector; - listener = aobject->callbacks->listeners + i; - avector = (SPActionEventVector *) listener->vector; - if ((listener->size >= sizeof (SPActionEventVector)) && avector->set_name) { - avector->set_name (action, name, listener->data); - } - } - } + g_free(action->name); + action->name = g_strdup(name.data()); + action->signal_set_name.emit(name); } - - - /** * Return View associated with the action. */ diff --git a/src/helper/action.h b/src/helper/action.h index 14a91b453..7e4da3312 100644 --- a/src/helper/action.h +++ b/src/helper/action.h @@ -1,11 +1,6 @@ -#ifndef __SP_ACTION_H__ -#define __SP_ACTION_H__ - /** \file * Inkscape UI action implementation - */ - -/* + *//* * Author: * Lauris Kaplinski * @@ -14,41 +9,27 @@ * This code is in public domain */ -/** A macro to get the GType for actions */ -#define SP_TYPE_ACTION (sp_action_get_type()) -/** A macro to cast and check the cast of changing an object to an action */ -#define SP_ACTION(o) (NR_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction)) -/** A macro to check whether or not something is an action */ -#define SP_IS_ACTION(o) (NR_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION)) +#ifndef SEEN_INKSCAPE_SP_ACTION_H +#define SEEN_INKSCAPE_SP_ACTION_H +#include +#include #include "helper/helper-forward.h" -#include "libnr/nr-object.h" #include "forward.h" -#include -//class Inkscape::UI::View::View; +#define SP_TYPE_ACTION (sp_action_get_type()) +#define SP_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction)) +#define SP_ACTION_CLASS(o) (G_TYPE_CHECK_CLASS_CAST((o), SP_TYPE_ACTION, SPActionClass)) +#define SP_IS_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION)) namespace Inkscape { class Verb; } - -/** This is a structure that is used to hold all the possible - actions that can be taken with an action. These are the - function pointers available. */ -struct SPActionEventVector { - NRObjectEventVector object_vector; /**< Parent class */ - void (* perform)(SPAction *action, void *ldata, void *pdata); /**< Actually do the action of the event. Called by sp_perform_action */ - void (* set_active)(SPAction *action, unsigned active, void *data); /**< Callback for activation change */ - void (* set_sensitive)(SPAction *action, unsigned sensitive, void *data); /**< Callback for a change in sensitivity */ - void (* set_shortcut)(SPAction *action, unsigned shortcut, void *data); /**< Callback for setting the shortcut for this function */ - void (* set_name)(SPAction *action, Glib::ustring, void *data); /**< Callback for setting the name for this function */ -}; - /** All the data that is required to be an action. This structure identifies the action and has the data to create menus and toolbars for the action */ -struct SPAction : public NRActiveObject { +struct SPAction : public GObject { unsigned sensitive : 1; /**< Value to track whether the action is sensitive */ unsigned active : 1; /**< Value to track whether the action is active */ Inkscape::UI::View::View *view; /**< The View to which this action is attached */ @@ -57,14 +38,19 @@ struct SPAction : public NRActiveObject { gchar *tip; /**< A tooltip to describe the action */ gchar *image; /**< An image to visually identify the action */ Inkscape::Verb *verb; /**< The verb that produced this action */ + + sigc::signal signal_perform; + sigc::signal signal_set_sensitive; + sigc::signal signal_set_active; + sigc::signal signal_set_name; }; /** The action class is the same as its parent. */ struct SPActionClass { - NRActiveObjectClass parent_class; /**< Parent Class */ + GObjectClass parent_class; /**< Parent Class */ }; -NRType sp_action_get_type(); +GType sp_action_get_type(); SPAction *sp_action_new(Inkscape::UI::View::View *view, gchar const *id, @@ -76,12 +62,11 @@ SPAction *sp_action_new(Inkscape::UI::View::View *view, void sp_action_perform(SPAction *action, void *data); void sp_action_set_active(SPAction *action, unsigned active); void sp_action_set_sensitive(SPAction *action, unsigned sensitive); -void sp_action_set_name (SPAction *action, Glib::ustring); +void sp_action_set_name(SPAction *action, Glib::ustring const &name); Inkscape::UI::View::View *sp_action_get_view(SPAction *action); #endif - /* Local Variables: mode:c++ diff --git a/src/interface.cpp b/src/interface.cpp index fb0d23e1b..8cb9698b7 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -125,25 +125,12 @@ static void sp_ui_drag_leave( GtkWidget *widget, GdkDragContext *drag_context, guint event_time, gpointer user_data ); -static void sp_ui_menu_item_set_sensitive(SPAction *action, - unsigned int sensitive, - void *data); -static void sp_ui_menu_item_set_name(SPAction *action, - Glib::ustring name, - void *data); +static void sp_ui_menu_item_set_name(GtkWidget *data, + Glib::ustring const &name); static void sp_recent_open(GtkRecentChooser *, gpointer); static void injectRenamedIcons(); -SPActionEventVector menu_item_event_vector = { - {NULL}, - NULL, - NULL, /* set_active */ - sp_ui_menu_item_set_sensitive, /* set_sensitive */ - NULL, /* set_shortcut */ - sp_ui_menu_item_set_name /* set_name */ -}; - static const int MIN_ONSCREEN_DISTANCE = 50; void @@ -508,7 +495,6 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape:: unsigned int shortcut; action = verb->get_action(view); - if (!action) return NULL; shortcut = sp_shortcut_get_primary(verb); @@ -542,7 +528,15 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape:: gtk_container_add((GtkContainer *) item, name_lbl); } - nr_active_object_add_listener((NRActiveObject *)action, (NRObjectEventVector *)&menu_item_event_vector, sizeof(SPActionEventVector), item); + action->signal_set_sensitive.connect( + sigc::bind<0>( + sigc::ptr_fun(>k_widget_set_sensitive), + item)); + action->signal_set_name.connect( + sigc::bind<0>( + sigc::ptr_fun(&sp_ui_menu_item_set_name), + item)); + if (!action->sensitive) { gtk_widget_set_sensitive(item, FALSE); } @@ -716,7 +710,6 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View * gtk_container_add((GtkContainer *) item, l); } #if 0 - nr_active_object_add_listener((NRActiveObject *)action, (NRObjectEventVector *)&menu_item_event_vector, sizeof(SPActionEventVector), item); if (!action->sensitive) { gtk_widget_set_sensitive(item, FALSE); } @@ -1587,13 +1580,7 @@ sp_ui_overwrite_file(gchar const *filename) } static void -sp_ui_menu_item_set_sensitive(SPAction */*action*/, unsigned int sensitive, void *data) -{ - return gtk_widget_set_sensitive(GTK_WIDGET(data), sensitive); -} - -static void -sp_ui_menu_item_set_name(SPAction */*action*/, Glib::ustring name, void *data) +sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) { void *child = GTK_BIN (data)->child; //child is either diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index c4b6daa12..487f34be1 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -1,8 +1,5 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ - libnr/nr-macros.h \ - libnr/nr-object.cpp \ - libnr/nr-object.h \ libnr/nr-point-fns.cpp \ libnr/nr-point-fns.h diff --git a/src/libnr/nr-macros.h b/src/libnr/nr-macros.h deleted file mode 100644 index 37a3675e6..000000000 --- a/src/libnr/nr-macros.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __NR_MACROS_H__ -#define __NR_MACROS_H__ - -/* - * Pixel buffer rendering library - * - * Authors: - * Lauris Kaplinski - * - * This code is in public domain - */ - -#include - -#if HAVE_STDLIB_H -#include -#endif -#include - -#ifndef TRUE -#define TRUE (!0) -#endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef MAX -#define MAX(a,b) (((a) < (b)) ? (b) : (a)) -#endif -#ifndef MIN -#define MIN(a,b) (((a) > (b)) ? (b) : (a)) -#endif - -/** Returns v bounded to within [a, b]. If v is NaN then returns a. - * - * \pre \a a \<= \a b. - */ -#define NR_CLAMP(v,a,b) \ - (assert (a <= b), \ - ((v) >= (a)) \ - ? (((v) > (b)) \ - ? (b) \ - : (v)) \ - : (a)) - -#undef CLAMP /* get rid of glib's version, which doesn't handle NaN correctly */ -#define CLAMP(v,a,b) NR_CLAMP(v,a,b) - -#define NR_DF_TEST_CLOSE(a,b,e) (fabs ((a) - (b)) <= (e)) - -// Todo: move these into nr-matrix.h -#define NR_RECT_DFLS_TEST_EMPTY(a) (((a)->x0 >= (a)->x1) || ((a)->y0 >= (a)->y1)) -#define NR_RECT_DFLS_TEST_EMPTY_REF(a) (((a).x0 >= (a).x1) || ((a).y0 >= (a).y1)) -#define NR_RECT_DFLS_TEST_INTERSECT(a,b) (((a)->x0 < (b)->x1) && ((a)->x1 > (b)->x0) && ((a)->y0 < (b)->y1) && ((a)->y1 > (b)->y0)) -#define NR_RECT_DFLS_TEST_INTERSECT_REF(a,b) (((a).x0 < (b).x1) && ((a).x1 > (b).x0) && ((a).y0 < (b).y1) && ((a).y1 > (b).y0)) -#define NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1)) -#define NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1)) -#define NR_RECT_LS_TEST_INSIDE(r,x,y) ((x >= (r)->x0) && (x < (r)->x1) && (y >= (r)->y0) && (y < (r)->y1)) - -#define NR_MATRIX_D_FROM_DOUBLE(d) ((NR::Matrix *) &(d)[0]) - -#endif diff --git a/src/libnr/nr-object.cpp b/src/libnr/nr-object.cpp deleted file mode 100644 index d92052d10..000000000 --- a/src/libnr/nr-object.cpp +++ /dev/null @@ -1,318 +0,0 @@ -#define __NR_OBJECT_C__ - -/* - * RGBA display list system for inkscape - * - * Authors: - * Lauris Kaplinski - * MenTaLguY - * - * This code is in public domain - */ - -#include -#include - -#include - -#include -#include - -#include "nr-object.h" -#include "debug/event-tracker.h" -#include "debug/simple-event.h" -#include "util/share.h" -#include "util/format.h" - -unsigned int nr_emit_fail_warning(const gchar *file, unsigned int line, const gchar *method, const gchar *expr) -{ - fprintf (stderr, "File %s line %d (%s): Assertion %s failed\n", file, line, method, expr); - return 1; -} - -/* NRObject */ - -static NRObjectClass **classes = NULL; -static unsigned int classes_len = 0; -static unsigned int classes_size = 0; - -NRType nr_type_is_a(NRType type, NRType test) -{ - nr_return_val_if_fail(type < classes_len, FALSE); - nr_return_val_if_fail(test < classes_len, FALSE); - - NRObjectClass *c = classes[type]; - - while (c) { - if (c->type == test) { - return TRUE; - } - c = c->parent; - } - - return FALSE; -} - -void const *nr_object_check_instance_cast(void const *ip, NRType tc) -{ - nr_return_val_if_fail(ip != NULL, NULL); - nr_return_val_if_fail(nr_type_is_a(((NRObject const *) ip)->klass->type, tc), ip); - return ip; -} - -unsigned int nr_object_check_instance_type(void const *ip, NRType tc) -{ - if (ip == NULL) { - return FALSE; - } - - return nr_type_is_a(((NRObject const *) ip)->klass->type, tc); -} - -NRType nr_object_register_type(NRType parent, - gchar const *name, - unsigned int csize, - unsigned int isize, - void (* cinit) (NRObjectClass *), - void (* iinit) (NRObject *)) -{ - if (classes_len >= classes_size) { - classes_size += 32; - classes = g_renew (NRObjectClass *, classes, classes_size); - if (classes_len == 0) { - classes[0] = NULL; - classes_len = 1; - } - } - - NRType const type = classes_len; - classes_len += 1; - - classes[type] = (NRObjectClass*) new char[csize]; - NRObjectClass *c = classes[type]; - - /* FIXME: is this necessary? */ - memset(c, 0, csize); - - if (classes[parent]) { - memcpy(c, classes[parent], classes[parent]->csize); - } - - c->type = type; - c->parent = classes[parent]; - c->name = strdup(name); - c->csize = csize; - c->isize = isize; - c->cinit = cinit; - c->iinit = iinit; - - c->cinit(c); - - return type; -} - -static void nr_object_class_init (NRObjectClass *klass); -static void nr_object_init (NRObject *object); -static void nr_object_finalize (NRObject *object); - -NRType nr_object_get_type() -{ - static NRType type = 0; - - if (!type) { - type = nr_object_register_type (0, - "NRObject", - sizeof (NRObjectClass), - sizeof (NRObject), - (void (*) (NRObjectClass *)) nr_object_class_init, - (void (*) (NRObject *)) nr_object_init); - } - - return type; -} - -static void nr_object_class_init(NRObjectClass *c) -{ - c->finalize = nr_object_finalize; - c->cpp_ctor = NRObject::invoke_ctor; -} - -static void nr_object_init (NRObject */*object*/) -{ -} - -static void nr_object_finalize (NRObject */*object*/) -{ -} - -/* Dynamic lifecycle */ - -static void nr_class_tree_object_invoke_init(NRObjectClass *c, NRObject *object) -{ - if (c->parent) { - nr_class_tree_object_invoke_init(c->parent, object); - } - c->iinit (object); -} - -namespace { - -namespace Debug = Inkscape::Debug; -namespace Util = Inkscape::Util; - -typedef Debug::SimpleEvent BaseFinalizerEvent; - -class FinalizerEvent : public BaseFinalizerEvent { -public: - FinalizerEvent(NRObject *object) - : BaseFinalizerEvent(Util::share_static_string("nr-object-finalizer")) - { - _addProperty("object", Util::format("%p", object)); - _addProperty("class", Util::share_static_string(typeid(*object).name())); - } -}; - -void finalize_object(void *base, void *) -{ - NRObject *object = reinterpret_cast(base); - Debug::EventTracker tracker(object); - object->klass->finalize(object); - object->~NRObject(); -} - -} - -NRObject *NRObject::alloc(NRType type) -{ - nr_return_val_if_fail (type < classes_len, NULL); - - NRObjectClass *c = classes[type]; - - if ( c->parent && c->cpp_ctor == c->parent->cpp_ctor ) { - g_error("Cannot instantiate NRObject class %s which has not registered a C++ constructor\n", c->name); - } - - NRObject *object = reinterpret_cast( - ::operator new(c->isize, Inkscape::GC::SCANNED, Inkscape::GC::AUTO, - &finalize_object, NULL) - ); - memset(object, 0xf0, c->isize); - - c->cpp_ctor(object); - object->klass = c; - nr_class_tree_object_invoke_init (c, object); - - return object; -} - -/* NRActiveObject */ - -static void nr_active_object_class_init(NRActiveObjectClass *c); -static void nr_active_object_init(NRActiveObject *object); -static void nr_active_object_finalize(NRObject *object); - -static NRObjectClass *parent_class; - -NRType nr_active_object_get_type() -{ - static NRType type = 0; - if (!type) { - type = nr_object_register_type (NR_TYPE_OBJECT, - "NRActiveObject", - sizeof (NRActiveObjectClass), - sizeof (NRActiveObject), - (void (*) (NRObjectClass *)) nr_active_object_class_init, - (void (*) (NRObject *)) nr_active_object_init); - } - return type; -} - -static void nr_active_object_class_init(NRActiveObjectClass *c) -{ - NRObjectClass *object_class = (NRObjectClass *) c; - - parent_class = object_class->parent; - - object_class->finalize = nr_active_object_finalize; - object_class->cpp_ctor = NRObject::invoke_ctor; -} - -static void nr_active_object_init(NRActiveObject */*object*/) -{ -} - -static void nr_active_object_finalize(NRObject *object) -{ - NRActiveObject *aobject = (NRActiveObject *) object; - - if (aobject->callbacks) { - for (unsigned int i = 0; i < aobject->callbacks->length; i++) { - NRObjectListener *listener = aobject->callbacks->listeners + i; - if ( listener->vector->dispose ) { - listener->vector->dispose(object, listener->data); - } - } - g_free (aobject->callbacks); - } - - ((NRObjectClass *) (parent_class))->finalize(object); -} - -void nr_active_object_add_listener(NRActiveObject *object, - const NRObjectEventVector *vector, - unsigned int size, - void *data) -{ - if (!object->callbacks) { - object->callbacks = (NRObjectCallbackBlock*)g_malloc(sizeof(NRObjectCallbackBlock)); - object->callbacks->size = 1; - object->callbacks->length = 0; - } - - if (object->callbacks->length >= object->callbacks->size) { - int newsize = object->callbacks->size << 1; - object->callbacks = (NRObjectCallbackBlock *) - g_realloc(object->callbacks, sizeof(NRObjectCallbackBlock) + (newsize - 1) * sizeof (NRObjectListener)); - object->callbacks->size = newsize; - } - - NRObjectListener *listener = object->callbacks->listeners + object->callbacks->length; - listener->vector = vector; - listener->size = size; - listener->data = data; - object->callbacks->length += 1; -} - -void nr_active_object_remove_listener_by_data(NRActiveObject *object, void *data) -{ - if (object->callbacks == NULL) { - return; - } - - for (unsigned i = 0; i < object->callbacks->length; i++) { - NRObjectListener *listener = object->callbacks->listeners + i; - if ( listener->data == data ) { - object->callbacks->length -= 1; - if ( object->callbacks->length < 1 ) { - g_free(object->callbacks); - object->callbacks = NULL; - } else if ( object->callbacks->length != i ) { - *listener = object->callbacks->listeners[object->callbacks->length]; - } - return; - } - } -} - - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/libnr/nr-object.h b/src/libnr/nr-object.h deleted file mode 100644 index 269130284..000000000 --- a/src/libnr/nr-object.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef __NR_OBJECT_H__ -#define __NR_OBJECT_H__ - -/* - * RGBA display list system for inkscape - * - * Authors: - * Lauris Kaplinski - * MenTaLguY - * - * This code is in public domain - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "gc-managed.h" -#include "gc-finalized.h" -#include "gc-anchored.h" - -typedef guint32 NRType; - -struct NRObject; -struct NRObjectClass; - -#define NR_TYPE_OBJECT (nr_object_get_type ()) -#define NR_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_OBJECT, NRObject)) -#define NR_IS_OBJECT(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_OBJECT)) - -#define NR_TYPE_ACTIVE_OBJECT (nr_active_object_get_type ()) -#define NR_ACTIVE_OBJECT(o) (NR_CHECK_INSTANCE_CAST ((o), NR_TYPE_ACTIVE_OBJECT, NRActiveObject)) -#define NR_IS_ACTIVE_OBJECT(o) (NR_CHECK_INSTANCE_TYPE ((o), NR_TYPE_ACTIVE_OBJECT)) - -#define nr_return_if_fail(expr) if (!(expr) && nr_emit_fail_warning (__FILE__, __LINE__, "?", #expr)) return -#define nr_return_val_if_fail(expr,val) if (!(expr) && nr_emit_fail_warning (__FILE__, __LINE__, "?", #expr)) return (val) - -unsigned int nr_emit_fail_warning (const gchar *file, unsigned int line, const gchar *method, const gchar *expr); - -#ifndef NR_DISABLE_CAST_CHECKS -#define NR_CHECK_INSTANCE_CAST(ip, tc, ct) ((ct *) nr_object_check_instance_cast (ip, tc)) -#else -#define NR_CHECK_INSTANCE_CAST(ip, tc, ct) ((ct *) ip) -#endif - -#define NR_CHECK_INSTANCE_TYPE(ip, tc) nr_object_check_instance_type (ip, tc) -#define NR_OBJECT_GET_CLASS(ip) (((NRObject *) ip)->klass) - -NRType nr_type_is_a (NRType type, NRType test); - -void const *nr_object_check_instance_cast(void const *ip, NRType tc); -unsigned int nr_object_check_instance_type(void const *ip, NRType tc); - -NRType nr_object_register_type (NRType parent, - gchar const *name, - unsigned int csize, - unsigned int isize, - void (* cinit) (NRObjectClass *), - void (* iinit) (NRObject *)); - -/* NRObject */ - -class NRObject : public Inkscape::GC::Managed<>, - public Inkscape::GC::Finalized, - public Inkscape::GC::Anchored -{ -public: - NRObjectClass *klass; - - static NRObject *alloc(NRType type); - - template - static void invoke_ctor(NRObject *object) { - new (object) T(); - } - - /* these can go away eventually */ - NRObject *reference() { - return Inkscape::GC::anchor(this); - } - NRObject *unreference() { - Inkscape::GC::release(this); - return NULL; - } - -protected: - NRObject() {} - -private: - NRObject(NRObject const &); // no copy - void operator=(NRObject const &); // no assign - - void *operator new(size_t size, void *placement) { (void)size; return placement; } -}; - -struct NRObjectClass { - NRType type; - NRObjectClass *parent; - - gchar *name; - unsigned int csize; - unsigned int isize; - void (* cinit) (NRObjectClass *); - void (* iinit) (NRObject *); - void (* finalize) (NRObject *object); - void (*cpp_ctor)(NRObject *object); -}; - -NRType nr_object_get_type (void); - -/* Dynamic lifecycle */ - -inline NRObject *nr_object_new (NRType type) { - return NRObject::alloc(type); -} - -inline NRObject *nr_object_ref (NRObject *object) { - return object->reference(); -} -inline NRObject *nr_object_unref (NRObject *object) { - return object->unreference(); -} - -/* NRActiveObject */ - -struct NRObjectEventVector { - void (* dispose) (NRObject *object, void *data); -}; - -struct NRObjectListener { - const NRObjectEventVector *vector; - unsigned int size; - void *data; -}; - -struct NRObjectCallbackBlock { - unsigned int size; - unsigned int length; - NRObjectListener listeners[1]; -}; - -struct NRActiveObject : public NRObject { - NRActiveObject() : callbacks(NULL) {} - NRObjectCallbackBlock *callbacks; -}; - -struct NRActiveObjectClass : public NRObjectClass { -}; - -NRType nr_active_object_get_type (void); - -void nr_active_object_add_listener (NRActiveObject *object, const NRObjectEventVector *vector, unsigned int size, void *data); -void nr_active_object_remove_listener_by_data (NRActiveObject *object, void *data); - -#endif - diff --git a/src/verbs.cpp b/src/verbs.cpp index ac8699654..43d100138 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -118,8 +118,7 @@ namespace Inkscape { file operations. */ class FileVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -137,8 +136,7 @@ public: edit operations. */ class EditVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -156,8 +154,7 @@ public: selection operations. */ class SelectionVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -175,8 +172,7 @@ public: layer operations. */ class LayerVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -194,8 +190,7 @@ public: operations related to objects. */ class ObjectVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -213,8 +208,7 @@ public: operations relative to context. */ class ContextVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -232,8 +226,7 @@ public: zoom operations. */ class ZoomVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -252,8 +245,7 @@ public: dialog operations. */ class DialogVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -271,8 +263,7 @@ public: help operations. */ class HelpVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -290,8 +281,7 @@ public: tutorial operations. */ class TutorialVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -309,8 +299,7 @@ public: text operations. */ class TextVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -363,9 +352,7 @@ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *im Verb::~Verb(void) { /// \todo all the actions need to be cleaned up first. - if (_actions != NULL) { - delete _actions; - } + delete _actions; if (_full_tip) { g_free(_full_tip); @@ -395,8 +382,8 @@ Verb::make_action(Inkscape::UI::View::View */*view*/) SPAction * FileVerb::make_action(Inkscape::UI::View::View *view) { - //std::cout << "fileverb: make_action: " << &vector << std::endl; - return make_action_helper(view, &vector); + //std::cout << "fileverb: make_action: " << &perform << std::endl; + return make_action_helper(view, &perform); } /** \brief Create an action for a \c EditVerb @@ -408,8 +395,8 @@ FileVerb::make_action(Inkscape::UI::View::View *view) SPAction * EditVerb::make_action(Inkscape::UI::View::View *view) { - //std::cout << "editverb: make_action: " << &vector << std::endl; - return make_action_helper(view, &vector); + //std::cout << "editverb: make_action: " << &perform << std::endl; + return make_action_helper(view, &perform); } /** \brief Create an action for a \c SelectionVerb @@ -421,7 +408,7 @@ EditVerb::make_action(Inkscape::UI::View::View *view) SPAction * SelectionVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c LayerVerb @@ -433,7 +420,7 @@ SelectionVerb::make_action(Inkscape::UI::View::View *view) SPAction * LayerVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c ObjectVerb @@ -445,7 +432,7 @@ LayerVerb::make_action(Inkscape::UI::View::View *view) SPAction * ObjectVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c ContextVerb @@ -457,7 +444,7 @@ ObjectVerb::make_action(Inkscape::UI::View::View *view) SPAction * ContextVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c ZoomVerb @@ -469,7 +456,7 @@ ContextVerb::make_action(Inkscape::UI::View::View *view) SPAction * ZoomVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c DialogVerb @@ -481,7 +468,7 @@ ZoomVerb::make_action(Inkscape::UI::View::View *view) SPAction * DialogVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c HelpVerb @@ -493,7 +480,7 @@ DialogVerb::make_action(Inkscape::UI::View::View *view) SPAction * HelpVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c TutorialVerb @@ -505,7 +492,7 @@ HelpVerb::make_action(Inkscape::UI::View::View *view) SPAction * TutorialVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Create an action for a \c TextVerb @@ -517,7 +504,7 @@ TutorialVerb::make_action(Inkscape::UI::View::View *view) SPAction * TextVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief A quick little convience function to make building actions @@ -534,7 +521,7 @@ TextVerb::make_action(Inkscape::UI::View::View *view) the vector that is passed in. */ SPAction * -Verb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *vector, void *in_pntr) +Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr) { SPAction *action; @@ -542,23 +529,14 @@ Verb::make_action_helper(Inkscape::UI::View::View *view, SPActionEventVector *ve action = sp_action_new(view, _id, _(_name), _(_tip), _image, this); - if (action != NULL) { - if (in_pntr == NULL) { - nr_active_object_add_listener( - (NRActiveObject *) action, - (NRObjectEventVector *) vector, - sizeof(SPActionEventVector), - reinterpret_cast(_code) - ); - } else { - nr_active_object_add_listener( - (NRActiveObject *) action, - (NRObjectEventVector *) vector, - sizeof(SPActionEventVector), - in_pntr - ); - } - } + if (action == NULL) return NULL; + + action->signal_perform.connect( + sigc::bind( + sigc::bind( + sigc::ptr_fun(perform_fun), + in_pntr ? in_pntr : reinterpret_cast(_code)), + action)); return action; } @@ -703,8 +681,8 @@ Verb::delete_view(Inkscape::UI::View::View *view) if (action_found != _actions->end()) { SPAction *action = action_found->second; - nr_object_unref(NR_OBJECT(action)); _actions->erase(action_found); + g_object_unref(action); } return; @@ -785,7 +763,7 @@ Verb::getbyid(gchar const *id) /** \brief Decode the verb code and take appropriate action */ void -FileVerb::perform(SPAction *action, void *data, void */*pdata*/) +FileVerb::perform(SPAction *action, void *data) { #if 0 /* These aren't used, but are here to remind people not to use @@ -857,7 +835,7 @@ FileVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -EditVerb::perform(SPAction *action, void *data, void */*pdata*/) +EditVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); if (!dt) @@ -988,7 +966,7 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/) +SelectionVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); @@ -1108,7 +1086,7 @@ SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) +LayerVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); size_t verb = reinterpret_cast(data); @@ -1312,7 +1290,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ ) +ObjectVerb::perform( SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); if (!dt) @@ -1395,7 +1373,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ ) /** \brief Decode the verb code and take appropriate action */ void -ContextVerb::perform(SPAction *action, void *data, void */*pdata*/) +ContextVerb::perform(SPAction *action, void *data) { SPDesktop *dt; sp_verb_t verb; @@ -1579,7 +1557,7 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -TextVerb::perform(SPAction *action, void */*data*/, void */*pdata*/) +TextVerb::perform(SPAction *action, void */*data*/) { SPDesktop *dt = static_cast(sp_action_get_view(action)); if (!dt) @@ -1593,7 +1571,7 @@ TextVerb::perform(SPAction *action, void */*data*/, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/) +ZoomVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); if (!dt) @@ -1754,7 +1732,7 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -DialogVerb::perform(SPAction *action, void *data, void */*pdata*/) +DialogVerb::perform(SPAction *action, void *data) { if (reinterpret_cast(data) != SP_VERB_DIALOG_TOGGLE) { // unhide all when opening a new dialog @@ -1866,7 +1844,7 @@ DialogVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -HelpVerb::perform(SPAction *action, void *data, void */*pdata*/) +HelpVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); g_assert(dt->_dlg_mgr != NULL); @@ -1900,7 +1878,7 @@ HelpVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief Decode the verb code and take appropriate action */ void -TutorialVerb::perform(SPAction */*action*/, void *data, void */*pdata*/) +TutorialVerb::perform(SPAction */*action*/, void *data) { switch (reinterpret_cast(data)) { case SP_VERB_TUTORIAL_BASIC: @@ -1942,92 +1920,12 @@ TutorialVerb::perform(SPAction */*action*/, void *data, void */*pdata*/) } } // end of sp_verb_action_tutorial_perform() - -/** - * Action vector to define functions called if a staticly defined file verb - * is called. - */ -SPActionEventVector FileVerb::vector = - {{NULL},FileVerb::perform, NULL, NULL, NULL, NULL}; -/** - * Action vector to define functions called if a staticly defined edit verb is - * called. - */ -SPActionEventVector EditVerb::vector = - {{NULL},EditVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined selection - * verb is called - */ -SPActionEventVector SelectionVerb::vector = - {{NULL},SelectionVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined layer - * verb is called - */ -SPActionEventVector LayerVerb::vector = - {{NULL}, LayerVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined object - * editing verb is called - */ -SPActionEventVector ObjectVerb::vector = - {{NULL},ObjectVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined context - * verb is called - */ -SPActionEventVector ContextVerb::vector = - {{NULL},ContextVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined zoom verb - * is called - */ -SPActionEventVector ZoomVerb::vector = - {{NULL},ZoomVerb::perform, NULL, NULL, NULL, NULL}; - - -/** - * Action vector to define functions called if a staticly defined dialog verb - * is called - */ -SPActionEventVector DialogVerb::vector = - {{NULL},DialogVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined help verb - * is called - */ -SPActionEventVector HelpVerb::vector = - {{NULL},HelpVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined tutorial verb - * is called - */ -SPActionEventVector TutorialVerb::vector = - {{NULL},TutorialVerb::perform, NULL, NULL, NULL, NULL}; - -/** - * Action vector to define functions called if a staticly defined tutorial verb - * is called - */ -SPActionEventVector TextVerb::vector = - {{NULL},TextVerb::perform, NULL, NULL, NULL, NULL}; - - /* *********** Effect Last ********** */ /** \brief A class to represent the last effect issued */ class EffectLastVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -2043,12 +1941,6 @@ public: } }; /* EffectLastVerb class */ -/** - * The vector to attach in the last effect verb. - */ -SPActionEventVector EffectLastVerb::vector = - {{NULL},EffectLastVerb::perform, NULL, NULL, NULL, NULL}; - /** \brief Create an action for a \c EffectLastVerb \param view Which view the action should be created for \return The built action. @@ -2058,12 +1950,12 @@ SPActionEventVector EffectLastVerb::vector = SPAction * EffectLastVerb::make_action(Inkscape::UI::View::View *view) { - return make_action_helper(view, &vector); + return make_action_helper(view, &perform); } /** \brief Decode the verb code and take appropriate action */ void -EffectLastVerb::perform(SPAction *action, void *data, void */*pdata*/) +EffectLastVerb::perform(SPAction *action, void *data) { /* These aren't used, but are here to remind people not to use the CURRENT_DOCUMENT macros unless they really have to. */ @@ -2094,8 +1986,7 @@ EffectLastVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief A class to represent the canvas fitting verbs */ class FitCanvasVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -2111,12 +2002,6 @@ public: } }; /* FitCanvasVerb class */ -/** - * The vector to attach in the fit canvas verb. - */ -SPActionEventVector FitCanvasVerb::vector = - {{NULL},FitCanvasVerb::perform, NULL, NULL, NULL, NULL}; - /** \brief Create an action for a \c FitCanvasVerb \param view Which view the action should be created for \return The built action. @@ -2126,13 +2011,13 @@ SPActionEventVector FitCanvasVerb::vector = SPAction * FitCanvasVerb::make_action(Inkscape::UI::View::View *view) { - SPAction *action = make_action_helper(view, &vector); + SPAction *action = make_action_helper(view, &perform); return action; } /** \brief Decode the verb code and take appropriate action */ void -FitCanvasVerb::perform(SPAction *action, void *data, void */*pdata*/) +FitCanvasVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); if (!dt) return; @@ -2163,8 +2048,7 @@ FitCanvasVerb::perform(SPAction *action, void *data, void */*pdata*/) /** \brief A class to represent the object unlocking and unhiding verbs */ class LockAndHideVerb : public Verb { private: - static void perform(SPAction *action, void *mydata, void *otherdata); - static SPActionEventVector vector; + static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: @@ -2180,12 +2064,6 @@ public: } }; /* LockAndHideVerb class */ -/** - * The vector to attach in the lock'n'hide verb. - */ -SPActionEventVector LockAndHideVerb::vector = - {{NULL},LockAndHideVerb::perform, NULL, NULL, NULL, NULL}; - /** \brief Create an action for a \c LockAndHideVerb \param view Which view the action should be created for \return The built action. @@ -2195,13 +2073,13 @@ SPActionEventVector LockAndHideVerb::vector = SPAction * LockAndHideVerb::make_action(Inkscape::UI::View::View *view) { - SPAction *action = make_action_helper(view, &vector); + SPAction *action = make_action_helper(view, &perform); return action; } /** \brief Decode the verb code and take appropriate action */ void -LockAndHideVerb::perform(SPAction *action, void *data, void */*pdata*/) +LockAndHideVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast(sp_action_get_view(action)); if (!dt) return; diff --git a/src/verbs.h b/src/verbs.h index d20189cde..224a809b0 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -403,8 +403,8 @@ public: gchar const * set_tip (gchar const * tip) { _tip = tip; return _tip; } protected: - SPAction * make_action_helper (Inkscape::UI::View::View * view, SPActionEventVector * vector, void * in_pntr = NULL); - virtual SPAction * make_action (Inkscape::UI::View::View * view); + SPAction *make_action_helper (Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL); + virtual SPAction *make_action (Inkscape::UI::View::View *view); public: /** \brief Inititalizes the Verb with the parameters diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index e0b3a0fb9..1360e0a30 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -43,20 +43,10 @@ static gint sp_button_process_event (SPButton *button, GdkEvent *event); static void sp_button_set_action (SPButton *button, SPAction *action); static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action); -static void sp_button_action_set_active (SPAction *action, unsigned int active, void *data); -static void sp_button_action_set_sensitive (SPAction *action, unsigned int sensitive, void *data); -static void sp_button_action_set_shortcut (SPAction *action, unsigned int shortcut, void *data); +static void sp_button_action_set_active (SPButton *button, bool active); static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); static GtkToggleButtonClass *parent_class; -SPActionEventVector button_event_vector = { - {NULL}, - NULL, - sp_button_action_set_active, - sp_button_action_set_sensitive, - sp_button_action_set_shortcut, - NULL -}; GType sp_button_get_type(void) { @@ -98,6 +88,8 @@ sp_button_init (SPButton *button) { button->action = NULL; button->doubleclick_action = NULL; + new (&button->c_set_active) sigc::connection(); + new (&button->c_set_sensitive) sigc::connection(); gtk_container_set_border_width (GTK_CONTAINER (button), 0); @@ -111,18 +103,18 @@ sp_button_init (SPButton *button) static void sp_button_destroy (GtkObject *object) { - SPButton *button; - - button = SP_BUTTON (object); + SPButton *button = SP_BUTTON (object); if (button->action) { sp_button_set_action (button, NULL); } - if (button->doubleclick_action) { sp_button_set_doubleclick_action (button, NULL); } + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); + ((GtkObjectClass *) (parent_class))->destroy (object); } @@ -212,12 +204,13 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action) { if (button->doubleclick_action) { - nr_object_unref ((NRObject *) button->doubleclick_action); + g_object_unref (button->doubleclick_action); } button->doubleclick_action = action; if (action) { - button->doubleclick_action = (SPAction *) nr_object_ref ((NRObject *) action); + g_object_ref(action); } + } static void @@ -226,17 +219,25 @@ sp_button_set_action (SPButton *button, SPAction *action) GtkWidget *child; if (button->action) { - nr_active_object_remove_listener_by_data ((NRActiveObject *) button->action, button); - nr_object_unref ((NRObject *) button->action); + button->c_set_active.disconnect(); + button->c_set_sensitive.disconnect(); child = gtk_bin_get_child (GTK_BIN (button)); if (child) { gtk_container_remove (GTK_CONTAINER (button), child); } + g_object_unref(button->action); } button->action = action; if (action) { - button->action = (SPAction *) nr_object_ref ((NRObject *) action); - nr_active_object_add_listener ((NRActiveObject *) action, (NRObjectEventVector *) &button_event_vector, sizeof (SPActionEventVector), button); + g_object_ref(action); + button->c_set_active = action->signal_set_active.connect( + sigc::bind<0>( + sigc::ptr_fun(&sp_button_action_set_active), + SP_BUTTON(button))); + button->c_set_sensitive = action->signal_set_sensitive.connect( + sigc::bind<0>( + sigc::ptr_fun(>k_widget_set_sensitive), + GTK_WIDGET(button))); if (action->image) { child = sp_icon_new (button->lsize, action->image); gtk_widget_show (child); @@ -248,10 +249,8 @@ sp_button_set_action (SPButton *button, SPAction *action) } static void -sp_button_action_set_active (SPAction */*action*/, unsigned int active, void *data) +sp_button_action_set_active (SPButton *button, bool active) { - SPButton *button; - button = (SPButton *) data; if (button->type != SP_BUTTON_TYPE_TOGGLE) { return; } @@ -262,19 +261,6 @@ sp_button_action_set_active (SPAction */*action*/, unsigned int active, void *da } } -static void -sp_button_action_set_sensitive (SPAction */*action*/, unsigned int sensitive, void *data) -{ - gtk_widget_set_sensitive (GTK_WIDGET (data), sensitive); -} - -static void -sp_button_action_set_shortcut (SPAction *action, unsigned int /*shortcut*/, void *data) -{ - SPButton *button=SP_BUTTON (data); - sp_button_set_composed_tooltip (GTK_WIDGET (button), action); -} - static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) { if (action) { @@ -308,7 +294,7 @@ sp_button_new_from_data( Inkscape::IconSize size, GtkWidget *button; SPAction *action=sp_action_new(view, name, name, tip, name, 0); button = sp_button_new (size, type, action, NULL); - nr_object_unref ((NRObject *) action); + g_object_unref(action); return button; } diff --git a/src/widgets/button.h b/src/widgets/button.h index 759096443..41863357d 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -17,7 +17,7 @@ #define SP_IS_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_BUTTON)) #include - +#include #include "helper/action.h" #include "icon-size.h" @@ -38,6 +38,9 @@ struct SPButton { unsigned int psize; SPAction *action; SPAction *doubleclick_action; + + sigc::connection c_set_active; + sigc::connection c_set_sensitive; }; struct SPButtonClass { diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 61c7c8e88..7edc24420 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -863,23 +863,6 @@ static void trigger_sp_action( GtkAction* /*act*/, gpointer user_data ) } } -static void sp_action_action_set_sensitive(SPAction * /*action*/, unsigned int sensitive, void *data) -{ - if ( data ) { - GtkAction* act = GTK_ACTION(data); - gtk_action_set_sensitive( act, sensitive ); - } -} - -static SPActionEventVector action_event_vector = { - {NULL}, - NULL, - NULL, - sp_action_action_set_sensitive, - NULL, - NULL -}; - static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, Inkscape::IconSize size ) { GtkAction* act = 0; @@ -891,8 +874,13 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi g_signal_connect( G_OBJECT(inky), "activate", G_CALLBACK(trigger_sp_action), targetAction ); - SPAction*rebound = dynamic_cast( nr_object_ref( dynamic_cast(targetAction) ) ); - nr_active_object_add_listener( (NRActiveObject *)rebound, (NRObjectEventVector *)&action_event_vector, sizeof(SPActionEventVector), inky ); + // FIXME: memory leak: this is not unrefed anywhere + g_object_ref(G_OBJECT(targetAction)); + g_object_set_data_full(G_OBJECT(inky), "SPAction", (void*) targetAction, (GDestroyNotify) &g_object_unref); + targetAction->signal_set_sensitive.connect( + sigc::bind<0>( + sigc::ptr_fun(>k_action_set_sensitive), + GTK_ACTION(inky))); return act; } -- cgit v1.2.3 From 7c7326a95acfd6885bf1b29d80679ea84d96c5fb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 28 Aug 2011 23:53:33 +0200 Subject: Completely remove libnr (bzr r10582.1.11) --- src/CMakeLists.txt | 1 - src/Makefile.am | 1 - src/gradient-chemistry.cpp | 14 ++++++++------ src/gradient-context.cpp | 5 ++--- src/gradient-drag.cpp | 39 ++++++++++++++++++++++----------------- src/libnr/CMakeLists.txt | 15 --------------- src/libnr/Makefile_insert | 5 ----- src/libnr/makefile.in | 17 ----------------- src/libnr/nr-point-fns.cpp | 42 ------------------------------------------ src/libnr/nr-point-fns.h | 21 --------------------- src/livarot/PathOutline.cpp | 1 - src/livarot/Shape.cpp | 1 - src/livarot/ShapeRaster.cpp | 1 - src/livarot/sweep-tree.cpp | 1 - src/satisfied-guide-cns.cpp | 1 - 15 files changed, 32 insertions(+), 133 deletions(-) delete mode 100644 src/libnr/CMakeLists.txt delete mode 100644 src/libnr/Makefile_insert delete mode 100644 src/libnr/makefile.in delete mode 100644 src/libnr/nr-point-fns.cpp delete mode 100644 src/libnr/nr-point-fns.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 038e7bb73..ce289f33c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -550,7 +550,6 @@ add_subdirectory(libcroco) add_subdirectory(libgdl) add_subdirectory(libvpsc) add_subdirectory(livarot) -add_subdirectory(libnr) add_subdirectory(libnrtype) diff --git a/src/Makefile.am b/src/Makefile.am index 5a50eb36f..2ab4d0030 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -120,7 +120,6 @@ include helper/Makefile_insert include io/Makefile_insert include libcroco/Makefile_insert include libgdl/Makefile_insert -include libnr/Makefile_insert include libnrtype/Makefile_insert include libavoid/Makefile_insert include livarot/Makefile_insert diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 5a8b20850..990695068 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -16,6 +16,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/transforms.h> +#include <2geom/bezier-curve.h> #include "style.h" #include "document-private.h" @@ -30,14 +32,12 @@ #include "sp-text.h" #include "sp-tspan.h" -#include <2geom/transforms.h> #include "xml/repr.h" #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "preferences.h" -#include "libnr/nr-point-fns.h" #define noSP_GR_VERBOSE // Terminology: @@ -838,7 +838,9 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i, case POINT_LG_MID: { // using X-coordinates only to determine the offset, assuming p has been snapped to the vector from begin to end. - double offset = get_offset_between_points (p, Geom::Point(lg->x1.computed, lg->y1.computed), Geom::Point(lg->x2.computed, lg->y2.computed)); + Geom::Point begin(lg->x1.computed, lg->y1.computed); + Geom::Point end(lg->x2.computed, lg->y2.computed); + double offset = Geom::LineSegment(begin, end).nearestPoint(p); SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (lg, false); lg->ensureVector(); lg->vector.stops.at(point_i).offset = offset; @@ -931,8 +933,8 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i, case POINT_RG_MID1: { Geom::Point start = Geom::Point (rg->cx.computed, rg->cy.computed); - Geom::Point end = Geom::Point (rg->cx.computed + rg->r.computed, rg->cy.computed); - double offset = get_offset_between_points (p, start, end); + Geom::Point end = Geom::Point (rg->cx.computed + rg->r.computed, rg->cy.computed); + double offset = Geom::LineSegment(start, end).nearestPoint(p); SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (rg, false); rg->ensureVector(); rg->vector.stops.at(point_i).offset = offset; @@ -948,7 +950,7 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i, case POINT_RG_MID2: Geom::Point start = Geom::Point (rg->cx.computed, rg->cy.computed); Geom::Point end = Geom::Point (rg->cx.computed, rg->cy.computed - rg->r.computed); - double offset = get_offset_between_points (p, start, end); + double offset = Geom::LineSegment(start, end).nearestPoint(p); SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(rg, false); rg->ensureVector(); rg->vector.stops.at(point_i).offset = offset; diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index c4bef4683..0cb000003 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -46,8 +46,6 @@ #include "sp-namedview.h" #include "rubberband.h" -#include "libnr/nr-point-fns.h" - using Inkscape::DocumentUndo; static void sp_gradient_context_class_init(SPGradientContextClass *klass); @@ -254,7 +252,8 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, Geom::Poi SPCtrlLine* line = SP_CTRLLINE(item); - Geom::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0); + Geom::LineSegment ls(line->s, line->e); + Geom::Point nearest = ls.pointAt(ls.nearestPoint(rc->mousepoint_doc)); double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance; diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 1275bf995..585c55c28 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -20,6 +20,7 @@ #include #include #include +#include <2geom/bezier-curve.h> #include "desktop-handles.h" #include "selection.h" @@ -32,7 +33,6 @@ #include "xml/repr.h" #include "svg/css-ostringstream.h" #include "svg/svg.h" -#include "libnr/nr-point-fns.h" #include "preferences.h" #include "sp-item.h" #include "style.h" @@ -339,7 +339,7 @@ guint32 GrDrag::getColor() SPStop * GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) { - gfloat offset; // type of SPStop.offset = gfloat + gfloat offset = 0; // type of SPStop.offset = gfloat SPGradient *gradient; bool fill_or_stroke = true; bool r1_knot = false; @@ -350,32 +350,34 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) if (SP_IS_LINEARGRADIENT(gradient)) { Geom::Point begin = sp_item_gradient_get_coords(item, POINT_LG_BEGIN, 0, fill_or_stroke); Geom::Point end = sp_item_gradient_get_coords(item, POINT_LG_END, 0, fill_or_stroke); - - Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0); - double dist_screen = Geom::L2 (mouse_p - nearest); + Geom::LineSegment ls(begin, end); + double offset = ls.nearestPoint(mouse_p); + Geom::Point nearest = ls.pointAt(offset); + double dist_screen = Geom::distance(mouse_p, nearest); if ( dist_screen < tolerance ) { // add the knot - offset = get_offset_between_points(nearest, begin, end); addknot = true; break; // break out of the while loop: add only one knot } } else if (SP_IS_RADIALGRADIENT(gradient)) { Geom::Point begin = sp_item_gradient_get_coords(item, POINT_RG_CENTER, 0, fill_or_stroke); Geom::Point end = sp_item_gradient_get_coords(item, POINT_RG_R1, 0, fill_or_stroke); - Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0); - double dist_screen = Geom::L2 (mouse_p - nearest); + Geom::LineSegment ls(begin, end); + double offset = ls.nearestPoint(mouse_p); + Geom::Point nearest = ls.pointAt(offset); + double dist_screen = Geom::distance(mouse_p, nearest); if ( dist_screen < tolerance ) { - offset = get_offset_between_points(nearest, begin, end); addknot = true; r1_knot = true; break; // break out of the while loop: add only one knot } end = sp_item_gradient_get_coords(item, POINT_RG_R2, 0, fill_or_stroke); - nearest = snap_vector_midpoint (mouse_p, begin, end, 0); - dist_screen = Geom::L2 (mouse_p - nearest); + ls = Geom::LineSegment(begin, end); + offset = ls.nearestPoint(mouse_p); + nearest = ls.pointAt(offset); + dist_screen = Geom::distance(mouse_p, nearest); if ( dist_screen < tolerance ) { - offset = get_offset_between_points(nearest, begin, end); addknot = true; r1_knot = false; break; // break out of the while loop: add only one knot @@ -442,7 +444,8 @@ GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p) if (lines) { for (GSList *l = lines; (l != NULL) && (!over_line); l = l->next) { line = (SPCtrlLine*) l->data; - Geom::Point nearest = snap_vector_midpoint (p, line->s, line->e, 0); + Geom::LineSegment ls(line->s, line->e); + Geom::Point nearest = ls.pointAt(ls.nearestPoint(p)); double dist_screen = Geom::L2 (p - nearest) * desktop->current_zoom(); if (line->item && dist_screen < 5) { SPStop *stop = addStopNearPoint (line->item, p, 5/desktop->current_zoom()); @@ -847,9 +850,11 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, gu gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving); if (state & GDK_CONTROL_MASK) { - p = snap_vector_midpoint (p, low_lim, high_lim, snap_fraction); + Geom::LineSegment ls(low_lim, high_lim); + p = ls.pointAt(round(ls.nearestPoint(p) / snap_fraction) * snap_fraction); } else { - p = snap_vector_midpoint (p, low_lim, high_lim, 0); + Geom::LineSegment ls(low_lim, high_lim); + p = ls.pointAt(ls.nearestPoint(p)); if (!(state & GDK_SHIFT_MASK)) { Inkscape::Snapper::SnapConstraint cl(low_lim, high_lim - low_lim); SPDesktop *desktop = dragger->parent->desktop; @@ -1885,8 +1890,8 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial) GSList *moving = NULL; gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving); - Geom::Point p(x, y); - p = snap_vector_midpoint (dragger->point + p, low_lim, high_lim, 0); + Geom::LineSegment ls(low_lim, high_lim); + Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p)); Geom::Point displacement = p - dragger->point; for (GSList const* i = moving; i != NULL; i = i->next) { diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt deleted file mode 100644 index 0adea96f0..000000000 --- a/src/libnr/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ - -set(nr_SRC - nr-object.cpp - nr-point-fns.cpp - nr-values.cpp - - # ------- - # Headers - nr-macros.h - nr-object.h - nr-point-fns.h - nr-values.h -) - -add_inkscape_lib(nr_LIB "${nr_SRC}") diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert deleted file mode 100644 index 487f34be1..000000000 --- a/src/libnr/Makefile_insert +++ /dev/null @@ -1,5 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - libnr/nr-point-fns.cpp \ - libnr/nr-point-fns.h diff --git a/src/libnr/makefile.in b/src/libnr/makefile.in deleted file mode 100644 index 9f8d3919e..000000000 --- a/src/libnr/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) libnr/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) libnr/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/libnr/nr-point-fns.cpp b/src/libnr/nr-point-fns.cpp deleted file mode 100644 index e4fb8cf0b..000000000 --- a/src/libnr/nr-point-fns.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "libnr/nr-point-fns.h" - -Geom::Point -snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap) -{ - double length = Geom::distance(begin, end); - Geom::Point be = (end - begin) / length; - double r = Geom::dot(p - begin, be); - - if (r < 0.0) return begin; - if (r > length) return end; - - double snapdist = length * snap; - double r_snapped = (snap==0) ? r : floor(r/(snapdist + 0.5)) * snapdist; - - return (begin + r_snapped * be); -} - -// equivalent to Geom::LineSegment(begin, end).nearestPoint(p) -double -get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end) -{ - double length = Geom::distance(begin, end); - Geom::Point be = (end - begin) / length; - double r = Geom::dot(p - begin, be); - - if (r < 0.0) return 0.0; - if (r > length) return 1.0; - - return (r / length); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-point-fns.h b/src/libnr/nr-point-fns.h deleted file mode 100644 index 036c943f1..000000000 --- a/src/libnr/nr-point-fns.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __NR_POINT_OPS_H__ -#define __NR_POINT_OPS_H__ - -#include <2geom/point.h> - -Geom::Point snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap); - -double get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end); - -#endif /* !__NR_POINT_OPS_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index d4fc7eb30..d170e5d3a 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -8,7 +8,6 @@ #include "livarot/Path.h" #include "livarot/path-description.h" -#include /* * the "outliner" diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index d24e4b99d..805741d3f 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -12,7 +12,6 @@ #include "Shape.h" #include "livarot/sweep-event-queue.h" #include "livarot/sweep-tree-list.h" -#include /* * Shape instances handling. diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp index 7b00cdc6b..b7b087fba 100644 --- a/src/livarot/ShapeRaster.cpp +++ b/src/livarot/ShapeRaster.cpp @@ -12,7 +12,6 @@ #include "AlphaLigne.h" #include "BitLigne.h" -#include #include "livarot/sweep-event-queue.h" #include "livarot/sweep-tree-list.h" #include "livarot/sweep-tree.h" diff --git a/src/livarot/sweep-tree.cpp b/src/livarot/sweep-tree.cpp index 9ff1143ce..0cfd6bc52 100644 --- a/src/livarot/sweep-tree.cpp +++ b/src/livarot/sweep-tree.cpp @@ -1,4 +1,3 @@ -#include "libnr/nr-point-fns.h" #include "livarot/sweep-event-queue.h" #include "livarot/sweep-tree-list.h" #include "livarot/sweep-tree.h" diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp index 6d8c4d048..7aca3b0bd 100644 --- a/src/satisfied-guide-cns.cpp +++ b/src/satisfied-guide-cns.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include -- cgit v1.2.3 From 00f289c9844b57c0a6603e7c72d05da99e99a70e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 29 Aug 2011 15:34:58 +0200 Subject: Fix compilation on Windows after libnr removal (bzr r10590) --- src/extension/internal/emf-win32-print.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index d08304a00..00486e5e3 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -147,7 +147,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) if (bbox) d = *bbox; } - d *= IN_PER_PX; + d *= Geom::Scale(IN_PER_PX); float dwInchesX = d.width(); float dwInchesY = d.height(); -- cgit v1.2.3 From 5489ec55d35af6640606ad16b73930d505958faf Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 29 Aug 2011 15:44:13 +0200 Subject: Add minimal support for reading color-interpolation and color-interpolation-filters properties (however, Inkscape assumes sRGB everywhere at the moment). Change color-interpolation-filters from attribute to style property in sp-filter.cpp as it is not allowed as an attribute in a (it is only allowed as an attribute in filter primitives). Added color-interpolation-filters:sRGB to style when new filter is created in filter-chemistry.cpp. (bzr r10591) --- src/filter-chemistry.cpp | 6 ++++++ src/sp-filter.cpp | 14 ++++++++++++-- src/style.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++---- src/style.h | 10 ++++++++++ 4 files changed, 71 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 1b63bf6f9..b8c4cf901 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -97,6 +97,12 @@ SPFilter *new_filter(SPDocument *document) Inkscape::XML::Node *repr; repr = xml_doc->createElement("svg:filter"); + // Inkscape only supports sRGB. See note in sp-filter.cpp. + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "color-interpolation-filters", "sRGB"); + sp_repr_css_change(repr, css, "style"); + sp_repr_css_attr_unref(css); + // Append the new filter node to defs defs->appendChild(repr); Inkscape::GC::release(repr); diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index a7c1aa1fb..d0fd59802 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -370,12 +370,22 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N // TODO: This is evil, correctly implement support for color-interpolation-filters!!! // The color-interpolation-filters attribute is initially set to linearRGB according to the SVG standard. - // However, Inkscape completely ignores it and implicitly assumes that it is sRGB (like color-interpolation-filters). + // However, Inkscape completely ignores it and implicitly assumes that it is sRGB (like color-interpolation). // This results in a discrepancy between Inkscape and other renderers in how they render filters. // To mitigate this problem I've (Jasper van de Gronde,th.v.d.gronde@hccnet.nl) added this to ensure that at least // any filters written by Inkscape will henceforth be rendered the same in other renderers. // In the future Inkscape should have proper support for the color-interpolation properties and this should be changed. - repr->setAttribute("color-interpolation-filters", "sRGB"); + + // repr->setAttribute("color-interpolation-filters", "sRGB"); + + // Actually, the above line is not correct as the attribute is only allowed on filter + // primitives and not objects. However, it is allowed as a property in a style + // attribute. Note, this property must also be set in sp-filter-chemistry, filter_new() as the + // code here is not necessarily called when a new filter is created. 29 Aug 2011 Tav. + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "color-interpolation-filters", "sRGB"); + sp_repr_css_change(repr, css, "style"); + sp_repr_css_attr_unref(css); if (((SPObjectClass *) filter_parent_class)->write) { ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags); diff --git a/src/style.cpp b/src/style.cpp index 44d2b0761..ffb56dfa5 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -342,6 +342,13 @@ static SPStyleEnum const enum_clip_rule[] = { {NULL, -1} }; +static SPStyleEnum const enum_color_interpolation[] = { + {"auto", SP_CSS_COLOR_INTERPOLATION_AUTO}, + {"sRGB", SP_CSS_COLOR_INTERPOLATION_SRGB}, + {"linearRGB", SP_CSS_COLOR_INTERPOLATION_LINEARRGB}, + {NULL, -1} +}; + /** * Release callback. */ @@ -662,6 +669,10 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) : NULL )); } } + /* color interpolation */ + SPS_READ_PENUM_IF_UNSET(&style->color_interpolation, repr, "color_interpolation", enum_color_interpolation, true); + /* color interpolation filters*/ + SPS_READ_PENUM_IF_UNSET(&style->color_interpolation_filters, repr, "color_interpolation_filters", enum_color_interpolation, true); /* fill */ if (!style->fill.set) { val = repr->attribute("fill"); @@ -1209,10 +1220,18 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) break; /* Paint */ case SP_PROP_COLOR_INTERPOLATION: - g_warning("Unimplemented style property SP_PROP_COLOR_INTERPOLATION: value: %s", val); + // We read it but issue warning + SPS_READ_IENUM_IF_UNSET(&style->color_interpolation, val, enum_color_interpolation, true); + if( style->color_interpolation.value != SP_CSS_COLOR_INTERPOLATION_SRGB ) { + g_warning("Inkscape currently only supports color-interpolation = sRGB"); + } break; case SP_PROP_COLOR_INTERPOLATION_FILTERS: - g_warning("Unimplemented style property SP_PROP_INTERPOLATION_FILTERS: value: %s", val); + // We read it but issue warning + SPS_READ_IENUM_IF_UNSET(&style->color_interpolation_filters, val, enum_color_interpolation, true); + if( style->color_interpolation_filters.value != SP_CSS_COLOR_INTERPOLATION_SRGB ) { + g_warning("Inkscape currently only supports color-interpolation-filters = sRGB"); + } break; case SP_PROP_COLOR_PROFILE: g_warning("Unimplemented style property SP_PROP_COLOR_PROFILE: value: %s", val); @@ -1710,6 +1729,13 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) if (!style->color.set || style->color.inherit) { sp_style_merge_ipaint(style, &style->color, &parent->color); } + if (!style->color_interpolation.set || style->color_interpolation.inherit) { + style->color_interpolation.computed = parent->color_interpolation.computed; + } + if (!style->color_interpolation_filters.set || style->color_interpolation_filters.inherit) { + style->color_interpolation_filters.computed = parent->color_interpolation_filters.computed; + } + /* Fill */ if (!style->fill.set || style->fill.inherit || style->fill.currentcolor) { @@ -2095,8 +2121,8 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare { SPIEnum SPStyle::*const fields[] = { &SPStyle::clip_rule, - //nyi: SPStyle::color_interpolation, - //nyi: SPStyle::color_interpolation_filters, + &SPStyle::color_interpolation, + &SPStyle::color_interpolation_filters, //nyi: SPStyle::color_rendering, &SPStyle::direction, &SPStyle::fill_rule, @@ -2533,6 +2559,9 @@ sp_style_write_string(SPStyle const *const style, guint const flags) if (!style->color.noneSet) { // CSS does not permit "none" for color p += sp_style_write_ipaint(p, c + BMAX - p, "color", &style->color, NULL, flags); } + p += sp_style_write_ienum(p, c + BMAX - p, "color-interpolation", enum_color_interpolation, &style->color_interpolation, NULL, flags); + p += sp_style_write_ienum(p, c + BMAX - p, "color-interpolation-filters", enum_color_interpolation, &style->color_interpolation_filters, NULL, flags); + p += sp_style_write_ipaint(p, c + BMAX - p, "fill", &style->fill, NULL, flags); // if fill:none, skip writing fill properties @@ -2700,6 +2729,8 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to) if (!from->color.noneSet) { // CSS does not permit "none" for color p += sp_style_write_ipaint(p, c + BMAX - p, "color", &from->color, &to->color, SP_STYLE_FLAG_IFSET); } + p += sp_style_write_ienum(p, c + BMAX - p, "color-interpolation", enum_color_interpolation, &from->color_interpolation, &to->color_interpolation, SP_STYLE_FLAG_IFDIFF); + p += sp_style_write_ienum(p, c + BMAX - p, "color-interpolation-filters", enum_color_interpolation, &from->color_interpolation_filters, &to->color_interpolation_filters, SP_STYLE_FLAG_IFDIFF); p += sp_style_write_ipaint(p, c + BMAX - p, "fill", &from->fill, &to->fill, SP_STYLE_FLAG_IFDIFF); // if fill:none, skip writing fill properties @@ -2943,6 +2974,8 @@ sp_style_clear(SPStyle *style) style->color.clear(); style->color.setColor(0.0, 0.0, 0.0); + style->color_interpolation.value = style->color_interpolation.computed = SP_CSS_COLOR_INTERPOLATION_SRGB; + style->color_interpolation_filters.value = style->color_interpolation_filters.computed = SP_CSS_COLOR_INTERPOLATION_LINEARRGB; style->fill.clear(); style->fill.setColor(0.0, 0.0, 0.0); @@ -4290,6 +4323,12 @@ sp_style_unset_property_attrs(SPObject *o) if (style->color.set) { repr->setAttribute("color", NULL); } + if (style->color_interpolation.set) { + repr->setAttribute("color-interpolation", NULL); + } + if (style->color_interpolation_filters.set) { + repr->setAttribute("color-interpolation-filters", NULL); + } if (style->fill.set) { repr->setAttribute("fill", NULL); } diff --git a/src/style.h b/src/style.h index b8b3d6c0d..6150b03c7 100644 --- a/src/style.h +++ b/src/style.h @@ -349,6 +349,10 @@ struct SPStyle { /** color */ SPIPaint color; + /** color-interpolation */ + SPIEnum color_interpolation; + /** color-interpolation-filters */ + SPIEnum color_interpolation_filters; /** fill */ SPIPaint fill; @@ -579,6 +583,12 @@ enum SPEnableBackground { SP_CSS_BACKGROUND_NEW }; +enum SPColorInterpolation { + SP_CSS_COLOR_INTERPOLATION_AUTO, + SP_CSS_COLOR_INTERPOLATION_SRGB, + SP_CSS_COLOR_INTERPOLATION_LINEARRGB +}; + /// An SPTextStyle has a refcount, a font family, and a font name. struct SPTextStyle { int refcount; -- cgit v1.2.3 From 8ee23ba04f83c718750c3afc1e45d6283bd04d1e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 29 Aug 2011 19:59:38 +0200 Subject: Fix compilation failure in DBus API (bzr r10594) --- src/extension/dbus/document-interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index b4f42a37d..5a2b18b8f 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -1269,7 +1269,7 @@ gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble { Inkscape::Selection * sel = sp_desktop_selection(object->desk); - Geom::OptRect sel_bbox = sel->bounds(); + Geom::OptRect sel_bbox = sel->visualBounds(); if (sel_bbox) { Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) ); sp_selection_move_relative(sel, m, true); -- cgit v1.2.3 From 65133b7baf95332b9ee6acb56bd37ed400a1db0c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 29 Aug 2011 20:02:57 +0200 Subject: Correct typo in bounding box calculation for groups. Fixes LP #836536 Fixed bugs: - https://launchpad.net/bugs/836536 (bzr r10595) --- src/sp-item-group.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index ada980b3e..a733097d5 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -706,7 +706,7 @@ Geom::OptRect CGroup::bounds(SPItem::BBoxType type, Geom::Affine const &transfor if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { SPItem *child = SP_ITEM(o); Geom::Affine const ct(child->transform * transform); - bbox |= child->bounds(type, transform); + bbox |= child->bounds(type, ct); } l = g_slist_remove (l, o); } -- cgit v1.2.3 From 35301e418f34ce11cfed9c11a7f8a923faf48cf0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 29 Aug 2011 20:30:39 +0200 Subject: Added comments. (bzr r10596) --- src/xml/repr-css.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index dc6494bcd..5c8c6bf4b 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -1,6 +1,21 @@ /* * bulia byak -*/ + * Tavmjong Bah (Documentation) + * + * Functions to manipulate SPCSSAttr which is a class derived from Inkscape::XML::Node See + * sp-css-attr.h and node.h + * + * SPCSSAttr is a special node type where the "attributes" are the properties in an element's style + * attribute. For example, style="fill:blue;stroke:none" is stored in a List (Inkscape::Util:List) + * where the key is the property (e.g. "fill" or "stroke") and the value is the property's value + * (e.g. "blue" or "none"). An element's properties are manipulated by adding, removing, or + * changing an item in the List. Utility functions are provided to go back and forth between the + * two ways of representing properties (by a string or by a list). + * + * Use sp_repr_write_string to go from a property list to a style string. + * + * Use sp_repr_css_add_component to parse a property string and add the properties to the List. + */ #define SP_REPR_CSS_C @@ -35,7 +50,9 @@ protected: static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr); - +/** + * Creates an empty SPCSSAttr (a class for manipulating CSS style properties). + */ SPCSSAttr * sp_repr_css_attr_new() { @@ -46,6 +63,9 @@ sp_repr_css_attr_new() return new SPCSSAttrImpl(attr_doc); } +/** + * Unreferences an SPCSSAttr (will be garbage collected if no references remain). + */ void sp_repr_css_attr_unref(SPCSSAttr *css) { @@ -53,6 +73,12 @@ sp_repr_css_attr_unref(SPCSSAttr *css) Inkscape::GC::release((Node *) css); } +/** + * Creates a new SPCSSAttr with one attribute (i.e. style) copied from an existing repr (node). The + * repr attribute data is in the form of a char const * string (e.g. fill:#00ff00;stroke:none). The + * string is parsed by libcroco which returns a CRDeclaration list (a typical C linked list) of + * properties and values. This list is then used to fill the attributes of the new SPCSSAttr. + */ SPCSSAttr *sp_repr_css_attr(Node *repr, gchar const *attr) { g_assert(repr != NULL); @@ -63,6 +89,9 @@ SPCSSAttr *sp_repr_css_attr(Node *repr, gchar const *attr) return css; } +/** + * Adds an attribute to an existing SPCSAttr with the cascaded value including all parents. + */ static void sp_repr_css_attr_inherited_recursive(SPCSSAttr *css, Node *repr, gchar const *attr) { @@ -72,11 +101,12 @@ sp_repr_css_attr_inherited_recursive(SPCSSAttr *css, Node *repr, gchar const *at if (parent) { sp_repr_css_attr_inherited_recursive(css, parent, attr); } - sp_repr_css_add_components(css, repr, attr); } - +/** + * Creates a new SPCSSAttr with one attribute whose value is determined by cascading. + */ SPCSSAttr *sp_repr_css_attr_inherited(Node *repr, gchar const *attr) { g_assert(repr != NULL); @@ -89,6 +119,9 @@ SPCSSAttr *sp_repr_css_attr_inherited(Node *repr, gchar const *attr) return css; } +/** + * Adds components (style properties) to an existing SPCSAttr from a character string. + */ static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr) { @@ -100,6 +133,10 @@ sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr) sp_repr_css_attr_add_from_string(css, data); } +/** + * Returns a character string of the value of a given style property or a default value if the + * attribute is not found. + */ char const * sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval) { @@ -112,6 +149,9 @@ sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval) : attr ); } +/** + * Returns true if a style property is present and its value is unset. + */ bool sp_repr_css_property_is_unset(SPCSSAttr *css, gchar const *name) { @@ -123,6 +163,9 @@ sp_repr_css_property_is_unset(SPCSSAttr *css, gchar const *name) } +/** + * Set a style property to a new value (e.g. fill to #ffff00). + */ void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value) { @@ -132,6 +175,9 @@ sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value) ((Node *) css)->setAttribute(name, value, false); } +/** + * Set a style property to "inkscape:unset". + */ void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name) { @@ -141,6 +187,9 @@ sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name) ((Node *) css)->setAttribute(name, "inkscape:unset", false); } +/** + * Return the value of a style property if property define, or a default value if not. + */ double sp_repr_css_double_property(SPCSSAttr *css, gchar const *name, double defval) { @@ -150,6 +199,9 @@ sp_repr_css_double_property(SPCSSAttr *css, gchar const *name, double defval) return sp_repr_get_double_attribute((Node *) css, name, defval); } +/** + * Write a style attribute string from a list of properties stored in an SPCSAttr object. + */ gchar * sp_repr_css_write_string(SPCSSAttr *css) { @@ -186,6 +238,9 @@ sp_repr_css_write_string(SPCSSAttr *css) return (buffer.empty() ? NULL : g_strdup (buffer.c_str())); } +/** + * Sets an attribute (e.g. style) to a string created from a list of style properties. + */ void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr) { @@ -200,6 +255,9 @@ sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr) if (value) g_free (value); } +/** + * Loops through a List of style properties, printing key/value pairs. + */ void sp_repr_css_print(SPCSSAttr *css) { @@ -212,6 +270,9 @@ sp_repr_css_print(SPCSSAttr *css) } } +/** + * Merges two SPCSSAttr's. Properties in src overwrite properties in dst if present in both. + */ void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src) { @@ -219,9 +280,12 @@ sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src) g_assert(src != NULL); dst->mergeFrom(src, ""); + sp_repr_css_print( dst ); } - +/** + * Merges style properties as parsed by libcroco into an existing SPCSSAttr. + */ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) { @@ -234,6 +298,8 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) } /** + * Merges style properties as parsed by libcroco into an existing SPCSSAttr. + * * \pre decl_list != NULL */ static void @@ -248,6 +314,10 @@ sp_repr_css_merge_from_decl_list(SPCSSAttr *css, CRDeclaration const *const decl } } +/** + * Use libcroco to parse a string for CSS properties and then merge + * them into an existing SPCSSAttr. + */ void sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p) { @@ -261,6 +331,10 @@ sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p) } } +/** + * Creates a new SPCSAttr with the values filled from a repr, merges in properties from the given + * SPCSAttr, and then replaces the that SPCSAttr with the new one. + */ void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr) { -- cgit v1.2.3 From f5e85edb29a2e69721ddd2121b649a2402bed994 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 29 Aug 2011 20:33:41 +0200 Subject: Remove forgotten call to print routine. (bzr r10597) --- src/xml/repr-css.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 5c8c6bf4b..46a16715c 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -280,7 +280,6 @@ sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src) g_assert(src != NULL); dst->mergeFrom(src, ""); - sp_repr_css_print( dst ); } /** -- cgit v1.2.3 From e92a65c4ce56d565c59a4a314378de3e9b8fc48e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 29 Aug 2011 21:07:21 +0200 Subject: Extensions. Fix for bug #813807 (Python error message window opens in a maximized state). (bzr r10598) --- src/extension/implementation/script.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e7599d996..2f3e2cd65 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -855,7 +855,6 @@ void Script::checkStderr (const Glib::ustring &data, vbox->pack_start(*scrollwindow, true, true, 5 /* fix these */); - warning.maximize(); warning.run(); return; -- cgit v1.2.3 From 82b22601b4f4c78e4e42f2681d8dcdcc513d0a56 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 29 Aug 2011 21:20:45 +0200 Subject: UI. Fix for bug #817249 (Help->About Inkscape icon missing in rev 10505, Win32). (bzr r10599) --- src/verbs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/verbs.cpp b/src/verbs.cpp index 43d100138..7de95b332 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2592,7 +2592,7 @@ Verb *Verb::_base_verbs[] = { new HelpVerb(SP_VERB_HELP_MEMORY, "HelpAboutMemory", N_("About _Memory"), N_("Memory usage information"), INKSCAPE_ICON("dialog-memory")), new HelpVerb(SP_VERB_HELP_ABOUT, "HelpAbout", N_("_About Inkscape"), - N_("Inkscape version, authors, license"), INKSCAPE_ICON("inkscape")), + N_("Inkscape version, authors, license"), INKSCAPE_ICON("inkscape-logo")), //new HelpVerb(SP_VERB_SHOW_LICENSE, "ShowLicense", N_("_License"), // N_("Distribution terms"), /*"show_license"*/"inkscape_options"), -- cgit v1.2.3 From c8a8af767399878f679cf316edecfca6c67ede20 Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Mon, 29 Aug 2011 17:28:20 -0700 Subject: Update to Potrace 1.10 (bzr r10600) --- src/trace/potrace/auxiliary.h | 2 +- src/trace/potrace/bitmap.h | 2 +- src/trace/potrace/curve.cpp | 3 +- src/trace/potrace/curve.h | 2 +- src/trace/potrace/decompose.cpp | 5 +- src/trace/potrace/decompose.h | 3 +- src/trace/potrace/greymap.cpp | 3 +- src/trace/potrace/greymap.h | 3 +- src/trace/potrace/lists.h | 3 +- src/trace/potrace/potracelib.cpp | 116 +++++++++++++++++++-------------------- src/trace/potrace/potracelib.h | 2 +- src/trace/potrace/progress.h | 2 +- src/trace/potrace/render.cpp | 3 +- src/trace/potrace/render.h | 3 +- src/trace/potrace/trace.cpp | 3 +- src/trace/potrace/trace.h | 3 +- 16 files changed, 74 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/trace/potrace/auxiliary.h b/src/trace/potrace/auxiliary.h index 1c2765816..b7480bbb8 100644 --- a/src/trace/potrace/auxiliary.h +++ b/src/trace/potrace/auxiliary.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ diff --git a/src/trace/potrace/bitmap.h b/src/trace/potrace/bitmap.h index 671382dc2..2df04b46f 100644 --- a/src/trace/potrace/bitmap.h +++ b/src/trace/potrace/bitmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ diff --git a/src/trace/potrace/curve.cpp b/src/trace/potrace/curve.cpp index 00d7bd2db..d2e32aa7b 100644 --- a/src/trace/potrace/curve.cpp +++ b/src/trace/potrace/curve.cpp @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: curve.c 227 2010-12-16 05:47:19Z selinger $ */ /* private part of the path and curve data structures */ #include diff --git a/src/trace/potrace/curve.h b/src/trace/potrace/curve.h index bfde0af1a..6ceae0c3a 100644 --- a/src/trace/potrace/curve.h +++ b/src/trace/potrace/curve.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ diff --git a/src/trace/potrace/decompose.cpp b/src/trace/potrace/decompose.cpp index 8219234c4..708c17106 100644 --- a/src/trace/potrace/decompose.cpp +++ b/src/trace/potrace/decompose.cpp @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: decompose.c 227 2010-12-16 05:47:19Z selinger $ */ #include #include @@ -12,11 +11,11 @@ #include "potracelib.h" #include "curve.h" #include "lists.h" -#include "auxiliary.h" #include "bitmap.h" #include "decompose.h" #include "progress.h" + /* ---------------------------------------------------------------------- */ /* auxiliary bitmap manipulations */ diff --git a/src/trace/potrace/decompose.h b/src/trace/potrace/decompose.h index 409439c62..89b01e504 100644 --- a/src/trace/potrace/decompose.h +++ b/src/trace/potrace/decompose.h @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: decompose.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef DECOMPOSE_H #define DECOMPOSE_H diff --git a/src/trace/potrace/greymap.cpp b/src/trace/potrace/greymap.cpp index 770dd72e6..2495575e8 100644 --- a/src/trace/potrace/greymap.cpp +++ b/src/trace/potrace/greymap.cpp @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: greymap.c 227 2010-12-16 05:47:19Z selinger $ */ /* Routines for manipulating greymaps, including reading pgm files. We only deal with greymaps of depth 8 bits. */ diff --git a/src/trace/potrace/greymap.h b/src/trace/potrace/greymap.h index 0736232a7..1fb5426c1 100644 --- a/src/trace/potrace/greymap.h +++ b/src/trace/potrace/greymap.h @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: greymap.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef GREYMAP_H #define GREYMAP_H diff --git a/src/trace/potrace/lists.h b/src/trace/potrace/lists.h index 4f78bf20f..078129afc 100644 --- a/src/trace/potrace/lists.h +++ b/src/trace/potrace/lists.h @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: lists.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef _PS_LISTS_H #define _PS_LISTS_H diff --git a/src/trace/potrace/potracelib.cpp b/src/trace/potrace/potracelib.cpp index 3dbf3230b..be92fb24e 100644 --- a/src/trace/potrace/potracelib.cpp +++ b/src/trace/potrace/potracelib.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ @@ -35,14 +35,14 @@ static const potrace_param_t param_default = { /* Return a fresh copy of the set of default parameters, or NULL on failure with errno set. */ potrace_param_t *potrace_param_default(void) { - potrace_param_t *p; - - p = (potrace_param_t *) malloc(sizeof(potrace_param_t)); - if (!p) { - return NULL; - } - memcpy(p, ¶m_default, sizeof(potrace_param_t)); - return p; + potrace_param_t *p; + + p = (potrace_param_t *) malloc(sizeof(potrace_param_t)); + if (!p) { + return NULL; + } + memcpy(p, ¶m_default, sizeof(potrace_param_t)); + return p; } /* On success, returns a Potrace state st with st->status == @@ -52,63 +52,63 @@ potrace_param_t *potrace_param_default(void) { set). Complete or incomplete Potrace state can be freed with potrace_state_free(). */ potrace_state_t *potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm) { - int r; - path_t *plist = NULL; - potrace_state_t *st; - progress_t prog; - progress_t subprog; - - /* prepare private progress bar state */ - prog.callback = param->progress.callback; - prog.data = param->progress.data; - prog.min = param->progress.min; - prog.max = param->progress.max; - prog.epsilon = param->progress.epsilon; - prog.d_prev = param->progress.min; - - /* allocate state object */ - st = (potrace_state_t *)malloc(sizeof(potrace_state_t)); - if (!st) { - return NULL; - } - - progress_subrange_start(0.0, 0.1, &prog, &subprog); - - /* process the image */ - r = bm_to_pathlist(bm, &plist, param, &subprog); - if (r) { - free(st); - return NULL; - } - - st->status = POTRACE_STATUS_OK; - st->plist = plist; - st->priv = NULL; /* private state currently unused */ - - progress_subrange_end(&prog, &subprog); - - progress_subrange_start(0.1, 1.0, &prog, &subprog); - - /* partial success. */ - r = process_path(plist, param, &subprog); - if (r) { - st->status = POTRACE_STATUS_INCOMPLETE; - } - - progress_subrange_end(&prog, &subprog); - - return st; + int r; + path_t *plist = NULL; + potrace_state_t *st; + progress_t prog; + progress_t subprog; + + /* prepare private progress bar state */ + prog.callback = param->progress.callback; + prog.data = param->progress.data; + prog.min = param->progress.min; + prog.max = param->progress.max; + prog.epsilon = param->progress.epsilon; + prog.d_prev = param->progress.min; + + /* allocate state object */ + st = (potrace_state_t *)malloc(sizeof(potrace_state_t)); + if (!st) { + return NULL; + } + + progress_subrange_start(0.0, 0.1, &prog, &subprog); + + /* process the image */ + r = bm_to_pathlist(bm, &plist, param, &subprog); + if (r) { + free(st); + return NULL; + } + + st->status = POTRACE_STATUS_OK; + st->plist = plist; + st->priv = NULL; /* private state currently unused */ + + progress_subrange_end(&prog, &subprog); + + progress_subrange_start(0.1, 1.0, &prog, &subprog); + + /* partial success. */ + r = process_path(plist, param, &subprog); + if (r) { + st->status = POTRACE_STATUS_INCOMPLETE; + } + + progress_subrange_end(&prog, &subprog); + + return st; } /* free a Potrace state, without disturbing errno. */ void potrace_state_free(potrace_state_t *st) { - pathlist_free(st->plist); - free(st); + pathlist_free(st->plist); + free(st); } /* free a parameter list, without disturbing errno. */ void potrace_param_free(potrace_param_t *p) { - free(p); + free(p); } char *potrace_version(void) { diff --git a/src/trace/potrace/potracelib.h b/src/trace/potrace/potracelib.h index d15b05e5c..cd142a6e1 100644 --- a/src/trace/potrace/potracelib.h +++ b/src/trace/potrace/potracelib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ diff --git a/src/trace/potrace/progress.h b/src/trace/potrace/progress.h index 220639c6e..93a1fa3f0 100644 --- a/src/trace/potrace/progress.h +++ b/src/trace/potrace/progress.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ diff --git a/src/trace/potrace/render.cpp b/src/trace/potrace/render.cpp index 39bec0684..3c8f79c05 100644 --- a/src/trace/potrace/render.cpp +++ b/src/trace/potrace/render.cpp @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: render.c 227 2010-12-16 05:47:19Z selinger $ */ #include #include diff --git a/src/trace/potrace/render.h b/src/trace/potrace/render.h index 6cfbe0964..ad600156a 100644 --- a/src/trace/potrace/render.h +++ b/src/trace/potrace/render.h @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: render.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef RENDER_H #define RENDER_H diff --git a/src/trace/potrace/trace.cpp b/src/trace/potrace/trace.cpp index 8fe1a1bc4..f1e88a908 100644 --- a/src/trace/potrace/trace.cpp +++ b/src/trace/potrace/trace.cpp @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: trace.c 227 2010-12-16 05:47:19Z selinger $ */ /* transform jaggy paths into smooth curves */ #include diff --git a/src/trace/potrace/trace.h b/src/trace/potrace/trace.h index 72d1a3696..dc2b9247a 100644 --- a/src/trace/potrace/trace.h +++ b/src/trace/potrace/trace.h @@ -1,8 +1,7 @@ -/* Copyright (C) 2001-2010 Peter Selinger. +/* Copyright (C) 2001-2011 Peter Selinger. This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -/* $Id: trace.h 227 2010-12-16 05:47:19Z selinger $ */ #ifndef TRACE_H #define TRACE_H -- cgit v1.2.3 From 373a83fb24eaa873d37093210db7d06da7cb61f5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 30 Aug 2011 22:16:57 +0200 Subject: Filters. Workaround for bug #808013 (Drop Shadow; 0.0 for blur doesn't work). (bzr r10602) --- src/extension/internal/filter/shadows.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index b816a3e10..6a7cf38f2 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -107,7 +107,13 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) const gchar *type = ext->get_param_enum("type"); guint32 color = ext->get_param_color("color"); - blur << ext->get_param_float("blur"); + + if (ext->get_param_float("blur") > 0) { + blur << "get_param_float("blur") << "\" result=\"blur\" />\n"; + } else { + blur << ""; + } + x << ext->get_param_float("xoffset"); y << ext->get_param_float("yoffset"); a << (color & 0xff) / 255.0F; @@ -161,7 +167,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "%s" "\n" "\n" "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), -- cgit v1.2.3 From 4089e4ac5fd3199338c76e39c8580d139c48942e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 30 Aug 2011 22:55:29 +0200 Subject: fix compilation after const change in r10589 (bzr r10605) --- src/extension/internal/emf-win32-print.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 00486e5e3..87638045c 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -917,12 +917,12 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom // Transparent text background SetBkMode(hdc, TRANSPARENT); - p = p * tf; - p[Geom::X] = (p[Geom::X] * IN_PER_PX * dwDPI); - p[Geom::Y] = (p[Geom::Y] * IN_PER_PX * dwDPI); + Geom::Point p2 = p * tf; + p2[Geom::X] = (p2[Geom::X] * IN_PER_PX * dwDPI); + p2[Geom::Y] = (p2[Geom::Y] * IN_PER_PX * dwDPI); - LONG const xpos = (LONG) round(p[Geom::X]); - LONG const ypos = (LONG) round(rc.bottom-p[Geom::Y]); + LONG const xpos = (LONG) round(p2[Geom::X]); + LONG const ypos = (LONG) round(rc.bottom - p2[Geom::Y]); { gunichar2 *unicode_text = g_utf8_to_utf16( text, -1, NULL, NULL, NULL ); -- cgit v1.2.3 From 8ddc64a6158de6a9714bca05fe6207bbb472e22a Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 31 Aug 2011 18:58:40 +0200 Subject: Extensions. Fix for bug #789122 (changing current layer through an extension) thanks to cosmin. (bzr r10608) --- src/extension/implementation/script.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 2f3e2cd65..cac67844f 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -729,8 +729,26 @@ void Script::effect(Inkscape::Extension::Effect *module, doc->doc()->emitReconstructionStart(); copy_doc(doc->doc()->rroot, mydoc->rroot); doc->doc()->emitReconstructionFinish(); - mydoc->release(); + SPObject *layer = NULL; + SPObject *obj = mydoc->getObjectById("base"); + + // Getting the named view from the document generated by the extension + SPNamedView *nv = (SPNamedView *) obj; + + //Check if it has a default layer set up + if ( nv->default_layer_id != 0 ) { + SPDocument *document = desktop->doc(); + //If so, get that layer + layer = document->getObjectById(g_quark_to_string(nv->default_layer_id)); + } + sp_namedview_update_layers_from_document(desktop); + //If that layer exists, + if (layer) { + //set the current layer + desktop->setCurrentLayer(layer); + } + mydoc->release(); } return; -- cgit v1.2.3 From f3e6d16ac75e7d1808cd49f6bbd4066dcb63ec29 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 2 Sep 2011 13:44:24 +0200 Subject: Extensions. Fix for a potential crasher in the extension scripts. (bzr r10611) --- src/extension/implementation/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index cac67844f..e4d850e5f 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -736,7 +736,7 @@ void Script::effect(Inkscape::Extension::Effect *module, SPNamedView *nv = (SPNamedView *) obj; //Check if it has a default layer set up - if ( nv->default_layer_id != 0 ) { + if ( nv != NULL and nv->default_layer_id != 0 ) { SPDocument *document = desktop->doc(); //If so, get that layer layer = document->getObjectById(g_quark_to_string(nv->default_layer_id)); -- cgit v1.2.3 From 59259f0cabfa0205acc3229c281169e8406570b3 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 2 Sep 2011 22:14:29 +0200 Subject: Rename the struct "SnappedConstraints" to the more meaningfull "IntermSnapResults" (bzr r10612) --- src/display/canvas-axonomgrid.cpp | 8 ++--- src/display/canvas-axonomgrid.h | 4 +-- src/display/canvas-grid.cpp | 8 ++--- src/display/canvas-grid.h | 4 +-- src/gradient-drag.cpp | 12 ++++---- src/guide-snapper.cpp | 12 ++++---- src/guide-snapper.h | 6 ++-- src/line-snapper.cpp | 18 +++++------ src/line-snapper.h | 10 +++--- src/object-snapper.cpp | 32 ++++++++++---------- src/object-snapper.h | 12 ++++---- src/snap.cpp | 64 +++++++++++++++++++-------------------- src/snap.h | 2 +- src/snapper.h | 6 ++-- 14 files changed, 99 insertions(+), 99 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 9ea06ec2d..d346669ef 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -756,16 +756,16 @@ CanvasAxonomGridSnapper::_getSnapLines(Geom::Point const &p) const return s; } -void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void CanvasAxonomGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); - sc.grid_lines.push_back(dummy); + isr.grid_lines.push_back(dummy); } -void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasAxonomGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); - sc.points.push_back(dummy); + isr.points.push_back(dummy); } bool CanvasAxonomGridSnapper::ThisSnapperMightSnap() const diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 282524c74..e63d660fe 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -78,8 +78,8 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasAxonomGrid *grid; }; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index bdf0d6fb0..a36252a80 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1008,16 +1008,16 @@ CanvasXYGridSnapper::_getSnapLines(Geom::Point const &p) const return s; } -void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void CanvasXYGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); - sc.grid_lines.push_back(dummy); + isr.grid_lines.push_back(dummy); } -void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void CanvasXYGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); - sc.points.push_back(dummy); + isr.points.push_back(dummy); } /** diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 160e4a4e2..db098d507 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -167,8 +167,8 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasXYGrid *grid; }; diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 585c55c28..afed09654 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -645,7 +645,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp sp_knot_moveto (knot, p); } } else if (state & GDK_CONTROL_MASK) { - SnappedConstraints sc; + IntermSnapResults isr; Inkscape::SnapCandidatePoint scp = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); unsigned snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12)); @@ -704,24 +704,24 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp sp = m.constrainedAngularSnap(scp, boost::optional(), dr_snap, snaps); } m.unSetup(); - sc.points.push_back(sp); + isr.points.push_back(sp); } } m.setup(desktop, false); // turn of the snap indicator temporarily - Inkscape::SnappedPoint bsp = m.findBestSnap(scp, sc, true); + Inkscape::SnappedPoint bsp = m.findBestSnap(scp, isr, true); m.unSetup(); if (!bsp.getSnapped()) { // If we didn't truly snap to an object or to a grid, then we will still have to look for the // closest projection onto one of the constraints. findBestSnap() will not do this for us - for (std::list::const_iterator i = sc.points.begin(); i != sc.points.end(); i++) { - if (i == sc.points.begin() || (Geom::L2((*i).getPoint() - p) < Geom::L2(bsp.getPoint() - p))) { + for (std::list::const_iterator i = isr.points.begin(); i != isr.points.end(); i++) { + if (i == isr.points.begin() || (Geom::L2((*i).getPoint() - p) < Geom::L2(bsp.getPoint() - p))) { bsp.setPoint((*i).getPoint()); bsp.setTarget(Inkscape::SNAPTARGET_CONSTRAINED_ANGLE); } } } - //p = sc.points.front().getPoint(); + //p = isr.points.front().getPoint(); p = bsp.getPoint(); sp_knot_moveto (knot, p); } diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index 2527ccb31..d2db13060 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -68,23 +68,23 @@ bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const return (_snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE) && _snapmanager->getNamedView()->showguides); } -void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const +void Inkscape::GuideSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const { SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GUIDE, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line); - sc.guide_lines.push_back(dummy); + isr.guide_lines.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void Inkscape::GuideSnapper::_addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(origin, source, source_num, Inkscape::SNAPTARGET_GUIDE_ORIGIN, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); - sc.points.push_back(dummy); + isr.points.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const +void Inkscape::GuideSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GUIDE, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); - sc.points.push_back(dummy); + isr.points.push_back(dummy); } /* diff --git a/src/guide-snapper.h b/src/guide-snapper.h index 5de1b56a4..f8b3c2cee 100644 --- a/src/guide-snapper.h +++ b/src/guide-snapper.h @@ -34,9 +34,9 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; - void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const; - void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const; + void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; }; } diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 22a964d43..d2f1193ff 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -21,7 +21,7 @@ Inkscape::LineSnapper::LineSnapper(SnapManager *sm, Geom::Coord const d) : Snapp { } -void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc, +void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &/*bbox_to_snap*/, std::vector const */*it*/, @@ -44,13 +44,13 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc, Geom::Coord const dist = Geom::L2(p_proj - p.getPoint()); //Store any line that's within snapping range if (dist < getSnapperTolerance()) { - _addSnappedLine(sc, p_proj, dist, p.getSourceType(), p.getSourceNum(), i->first, i->second); + _addSnappedLine(isr, p_proj, dist, p.getSourceType(), p.getSourceNum(), i->first, i->second); // For any line that's within range, we will also look at it's "point on line" p1. For guides // this point coincides with its origin; for grids this is of no use, but we cannot // discern between grids and guides here Geom::Coord const dist_p1 = Geom::L2(p1 - p.getPoint()); if (dist_p1 < getSnapperTolerance()) { - _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum(), false); + _addSnappedLinesOrigin(isr, p1, dist_p1, p.getSourceType(), p.getSourceNum(), false); // Only relevant for guides; grids don't have an origin per line // Therefore _addSnappedLinesOrigin() will only be implemented for guides } @@ -60,7 +60,7 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc, } } -void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, +void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &/*bbox_to_snap*/, SnapConstraint const &c, @@ -91,7 +91,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, Geom::Coord radius = c.getRadius(); if (dist == radius) { // Only one point of intersection; - _addSnappedPoint(sc, p_proj, Geom::L2(pp - p_proj), p.getSourceType(), p.getSourceNum(), true); + _addSnappedPoint(isr, p_proj, Geom::L2(pp - p_proj), p.getSourceType(), p.getSourceNum(), true); } else if (dist < radius) { // Two points of intersection, symmetrical with respect to the projected point // Calculate half the length of the linesegment between the two points of intersection @@ -99,8 +99,8 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, Geom::Coord d = Geom::L2(gridguide_line.versor()); // length of versor, needed to normalize the versor if (d > 0) { Geom::Point v = l*gridguide_line.versor()/d; - _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true); - _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true); + _addSnappedPoint(isr, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true); + _addSnappedPoint(isr, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true); } } } else { @@ -125,7 +125,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, // This snappoint is therefore fully constrained, so there's no need // to look for additional intersections; just return the snapped point // and forget about the line - _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true); + _addSnappedPoint(isr, t, dist, p.getSourceType(), p.getSourceNum(), true); } } } @@ -134,7 +134,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, // Will only be overridden in the guide-snapper class, because grid lines don't have an origin; the // grid-snapper classes will use this default empty method -void Inkscape::LineSnapper::_addSnappedLinesOrigin(SnappedConstraints &/*sc*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const +void Inkscape::LineSnapper::_addSnappedLinesOrigin(IntermSnapResults &/*isr*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const { } diff --git a/src/line-snapper.h b/src/line-snapper.h index cdc45c286..bf7d714b1 100644 --- a/src/line-snapper.h +++ b/src/line-snapper.h @@ -25,13 +25,13 @@ class LineSnapper : public Snapper public: LineSnapper(SnapManager *sm, Geom::Coord const d); - void freeSnap(SnappedConstraints &sc, + void freeSnap(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector const *it, std::vector *unselected_nodes) const; - void constrainedSnap(SnappedConstraints &sc, + void constrainedSnap(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, SnapConstraint const &c, @@ -50,12 +50,12 @@ private: */ virtual LineList _getSnapLines(Geom::Point const &p) const = 0; - virtual void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const = 0; + virtual void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const = 0; // Will only be implemented for guide lines, because grid lines don't have an origin - virtual void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + virtual void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - virtual void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; + virtual void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; }; } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 7aa8a9c08..fa992a852 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -268,7 +268,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, } } -void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, +void Inkscape::ObjectSnapper::_snapNodes(IntermSnapResults &isr, SnapCandidatePoint const &p, std::vector *unselected_nodes, SnapConstraint const &c, @@ -313,11 +313,11 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, } if (success) { - sc.points.push_back(s); + isr.points.push_back(s); } } -void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, +void Inkscape::ObjectSnapper::_snapTranslatingGuide(IntermSnapResults &isr, Geom::Point const &p, Geom::Point const &guide_normal) const { @@ -326,7 +326,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) { _collectPaths(p, SNAPSOURCE_GUIDE, true); - _snapPaths(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); + _snapPaths(isr, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); } SnappedPoint s; @@ -341,7 +341,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, Geom::Coord dist2 = Geom::L2(p - p_proj); // distance from projection of node on the guide, to the mouse location if ((dist < tol && dist2 < tol) || getSnapperAlwaysSnap()) { s = SnappedPoint(target_pt, SNAPSOURCE_GUIDE, 0, (*k).getTargetType(), dist, tol, getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox()); - sc.points.push_back(s); + isr.points.push_back(s); } } } @@ -464,7 +464,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } } -void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, +void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr, SnapCandidatePoint const &p, std::vector *unselected_nodes, SPPath const *selected_path) const @@ -548,7 +548,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, if (!being_edited || (c1 && c2)) { Geom::Coord const dist = Geom::distance(sp_doc, p_doc); if (dist < getSnapperTolerance()) { - sc.curves.push_back(SnappedCurve(sp_dt, num_path, index, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + isr.curves.push_back(SnappedCurve(sp_dt, num_path, index, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); } } } @@ -578,7 +578,7 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve return false; } -void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, +void Inkscape::ObjectSnapper::_snapPathsConstrained(IntermSnapResults &isr, SnapCandidatePoint const &p, SnapConstraint const &c, Geom::Point const &p_proj_on_constraint) const @@ -664,7 +664,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, SnappedPoint s = SnappedPoint(*p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, k->target_bbox);; // Store the snapped point if (dist <= tolerance) { // If the intersection is within snapping range, then we might snap to it - sc.points.push_back(s); + isr.points.push_back(s); } } } @@ -672,7 +672,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, } -void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, +void Inkscape::ObjectSnapper::freeSnap(IntermSnapResults &isr, SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector const *it, @@ -688,7 +688,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); } - _snapNodes(sc, p, unselected_nodes); + _snapNodes(isr, p, unselected_nodes); if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size(); @@ -705,14 +705,14 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, } // else: *it->begin() might be a SPGroup, e.g. when editing a LPE of text that has been converted to a group of paths // as reported in bug #356743. In that case we can just ignore it, i.e. not snap to this item } - _snapPaths(sc, p, unselected_nodes, path); + _snapPaths(isr, p, unselected_nodes, path); } else { - _snapPaths(sc, p, NULL, NULL); + _snapPaths(isr, p, NULL, NULL); } } } -void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, +void Inkscape::ObjectSnapper::constrainedSnap( IntermSnapResults &isr, SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, SnapConstraint const &c, @@ -736,10 +736,10 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, // This is useful for example when scaling an object while maintaining a fixed aspect ratio. It's // nodes are only allowed to move in one direction (i.e. in one degree of freedom). - _snapNodes(sc, p, unselected_nodes, c, pp); + _snapNodes(isr, p, unselected_nodes, c, pp); if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { - _snapPathsConstrained(sc, p, c, pp); + _snapPathsConstrained(isr, p, c, pp); } } diff --git a/src/object-snapper.h b/src/object-snapper.h index b97ab827c..932b62dac 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -38,13 +38,13 @@ public: 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 - void freeSnap(SnappedConstraints &sc, + void freeSnap(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector const *it, std::vector *unselected_nodes) const; - void constrainedSnap(SnappedConstraints &sc, + void constrainedSnap(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, SnapConstraint const &c, @@ -64,25 +64,25 @@ private: bool const _clip_or_mask, Geom::Affine const additional_affine) const; - void _snapNodes(SnappedConstraints &sc, + void _snapNodes(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, // in desktop coordinates std::vector *unselected_nodes, SnapConstraint const &c = SnapConstraint(), Geom::Point const &p_proj_on_constraint = Geom::Point()) const; - void _snapTranslatingGuide(SnappedConstraints &sc, + void _snapTranslatingGuide(IntermSnapResults &isr, Geom::Point const &p, Geom::Point const &guide_normal) const; void _collectNodes(Inkscape::SnapSourceType const &t, bool const &first_point) const; - void _snapPaths(SnappedConstraints &sc, + void _snapPaths(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, // in desktop coordinates std::vector *unselected_nodes, // in desktop coordinates SPPath const *selected_path) const; - void _snapPathsConstrained(SnappedConstraints &sc, + void _snapPathsConstrained(IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, // in desktop coordinates SnapConstraint const &c, Geom::Point const &p_proj_on_constraint) const; diff --git a/src/snap.cpp b/src/snap.cpp index 9020b82a3..5f65b643d 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -210,14 +210,14 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false); } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList const snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->freeSnap(sc, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); + (*i)->freeSnap(isr, p, bbox_to_snap, &_items_to_ignore, _unselected_nodes); } - return findBestSnap(p, sc, false); + return findBestSnap(p, isr, false); } void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) @@ -282,13 +282,13 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // only if the origin of the grid is at (0,0). If it's not then compensate for this // in the translation t Geom::Point const t_offset = t + grid->origin; - SnappedConstraints sc; + IntermSnapResults isr; // Only the first three parameters are being used for grid snappers - snapper->freeSnap(sc, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH),Geom::OptRect(), NULL, NULL); + snapper->freeSnap(isr, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH),Geom::OptRect(), NULL, NULL); // Find the best snap for this grid, including intersections of the grid-lines bool old_val = _snapindicator; _snapindicator = false; - Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, true); + Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), isr, false, true); _snapindicator = old_val; if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) { // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position @@ -403,13 +403,13 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint return no_snap; } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList const snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->constrainedSnap(sc, p, bbox_to_snap, constraint, &_items_to_ignore, _unselected_nodes); + (*i)->constrainedSnap(isr, p, bbox_to_snap, constraint, &_items_to_ignore, _unselected_nodes); } - result = findBestSnap(p, sc, true); + result = findBestSnap(p, isr, true); if (result.getSnapped()) { // only change the snap indicator if we really snapped to something @@ -442,7 +442,7 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi return no_snap; } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList const snappers = getSnappers(); std::vector projections; bool snapping_is_futile = !someSnapperMightSnap() || dont_snap; @@ -471,11 +471,11 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi // Try to snap to the constraint if (!snapping_is_futile) { for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->constrainedSnap(sc, p, bbox_to_snap, *c, &_items_to_ignore,_unselected_nodes); + (*i)->constrainedSnap(isr, p, bbox_to_snap, *c, &_items_to_ignore,_unselected_nodes); } } } - result = findBestSnap(p, sc, true); + result = findBestSnap(p, isr, true); } if (result.getSnapped()) { @@ -578,13 +578,13 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE); } - SnappedConstraints sc; + IntermSnapResults isr; SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); + (*i)->freeSnap(isr, candidate, Geom::OptRect(), NULL, NULL); } - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false); + Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false); s.getPointIfSnapped(p); } @@ -606,15 +606,15 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED); - SnappedConstraints sc; + IntermSnapResults isr; Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line)); SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { - (*i)->constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL); + (*i)->constrainedSnap(isr, candidate, Geom::OptRect(), cl, NULL, NULL); } - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false); + Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false); s.getPointIfSnapped(p); } @@ -1135,14 +1135,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vectordt2doc())) { + if (getClosestIntersectionCS(isr.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { closestCurvesIntersection.setSource(p.getSourceType()); sp_list.push_back(closestCurvesIntersection); } @@ -1184,13 +1184,13 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped grid line Inkscape::SnappedLine closestGridLine; - if (getClosestSL(sc.grid_lines, closestGridLine)) { + if (getClosestSL(isr.grid_lines, closestGridLine)) { sp_list.push_back(Inkscape::SnappedPoint(closestGridLine)); } // search for the closest snapped guide line Inkscape::SnappedLine closestGuideLine; - if (getClosestSL(sc.guide_lines, closestGuideLine)) { + if (getClosestSL(isr.guide_lines, closestGuideLine)) { sp_list.push_back(Inkscape::SnappedPoint(closestGuideLine)); } @@ -1203,7 +1203,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co if (!constrained) { // search for the closest snapped intersection of grid lines Inkscape::SnappedPoint closestGridPoint; - if (getClosestIntersectionSL(sc.grid_lines, closestGridPoint)) { + if (getClosestIntersectionSL(isr.grid_lines, closestGridPoint)) { closestGridPoint.setSource(p.getSourceType()); closestGridPoint.setTarget(Inkscape::SNAPTARGET_GRID_INTERSECTION); sp_list.push_back(closestGridPoint); @@ -1211,7 +1211,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped intersection of guide lines Inkscape::SnappedPoint closestGuidePoint; - if (getClosestIntersectionSL(sc.guide_lines, closestGuidePoint)) { + if (getClosestIntersectionSL(isr.guide_lines, closestGuidePoint)) { closestGuidePoint.setSource(p.getSourceType()); closestGuidePoint.setTarget(Inkscape::SNAPTARGET_GUIDE_INTERSECTION); sp_list.push_back(closestGuidePoint); @@ -1220,7 +1220,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped intersection of grid with guide lines if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION)) { Inkscape::SnappedPoint closestGridGuidePoint; - if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) { + if (getClosestIntersectionSL(isr.grid_lines, isr.guide_lines, closestGridGuidePoint)) { closestGridGuidePoint.setSource(p.getSourceType()); closestGridGuidePoint.setTarget(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION); sp_list.push_back(closestGridGuidePoint); diff --git a/src/snap.h b/src/snap.h index a7b98748e..4a8f4b7c1 100644 --- a/src/snap.h +++ b/src/snap.h @@ -199,7 +199,7 @@ public: bool getSnapIndicator() const {return _snapindicator;} - Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool allowOffScreen = false) const; + Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, IntermSnapResults const &isr, bool constrained, bool allowOffScreen = false) const; void keepClosestPointOnly(std::vector &points, const Geom::Point &reference) const; protected: diff --git a/src/snapper.h b/src/snapper.h index 0fee9c7ed..aabdfdfb6 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -23,7 +23,7 @@ #include "snap-preferences.h" #include "snap-candidate.h" -struct SnappedConstraints { +struct IntermSnapResults { std::list points; std::list grid_lines; std::list guide_lines; @@ -57,7 +57,7 @@ public: bool getEnabled() const {return _snap_enabled;} bool getSnapVisibleOnly() const {return _snap_visible_only;} - virtual void freeSnap(SnappedConstraints &/*sc*/, + virtual void freeSnap(IntermSnapResults &/*isr*/, Inkscape::SnapCandidatePoint const &/*p*/, Geom::OptRect const &/*bbox_to_snap*/, std::vector const */*it*/, @@ -134,7 +134,7 @@ public: SnapConstraintType _type; }; - virtual void constrainedSnap(SnappedConstraints &/*sc*/, + virtual void constrainedSnap(IntermSnapResults &/*isr*/, Inkscape::SnapCandidatePoint const &/*p*/, Geom::OptRect const &/*bbox_to_snap*/, SnapConstraint const &/*c*/, -- cgit v1.2.3 From 74e17c3b2817c35a4a327250436da0a72b30bd96 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 3 Sep 2011 22:26:01 +0200 Subject: Allow changing dimensions of vertical/horizontal lines using the numeric input boxes on the selector toolbar Fixed bugs: - https://launchpad.net/bugs/825840 (bzr r10614) --- src/sp-item-transform.cpp | 183 +++++++++++++++++++++++------------------ src/widgets/select-toolbar.cpp | 2 +- 2 files changed, 105 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 749a32d52..311604153 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -76,7 +76,7 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) /** * \brief Calculate the affine transformation required to transform one visual bounding box into another, accounting for a uniform strokewidth * - * PS: This function will only return accurate results for the visual bounding box of a selection of one of more objects, all having + * PS: This function will only return accurate results for the visual bounding box of a selection of one or more objects, all having * the same strokewidth. If the stroke width varies from object to object in this selection, then the function * get_scale_transform_with_unequal_stroke() should be called instead * @@ -120,23 +120,6 @@ get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble gdouble h1 = y1 - y0; // The new visual bounding box will have a stroke r1 - // We will now try to calculate the affine transformation required to transform the first visual bounding box into - // the second one, while accounting for strokewidth - - if (bbox_visual.hasZeroArea()) { // Obviously we cannot scale from empty visual bounding boxes at all, so we will only translate in such a case - Geom::Affine move = Geom::Translate(x0 - bbox_visual.min()[Geom::X], y0 - bbox_visual.min()[Geom::Y]); - return (move); - } - - Geom::Affine direct = Geom::Scale(w1 / w0, h1 / h0); // Scaling of the visual bounding box - - // Although the area of the visual bounding box is not zero, we can still have a geometric - // bounding box with one or both sides having zero length. We can't handle this and will therefore - // simply return the scaling of the visual bounding box, without accounting for any stroke scaling - if (fabs(w0 - r0) < 1e-6 || fabs(h0 - r0) < 1e-6 || (!transform_stroke && (fabs(w1 - r0) < 1e-6 || fabs(h1 - r0) < 1e-6))) { - return (p2o * direct * o2n); - } - // Here starts the calculation you've been waiting for; first do some preparation int flip_x = (w1 > 0) ? 1 : -1; int flip_y = (h1 > 0) ? 1 : -1; @@ -148,14 +131,38 @@ get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble r0 = fabs(r0); // w0 and h0 will always be positive due to the definition of the width() and height() methods. - gdouble ratio_x = (w1 - r0) / (w0 - r0); // Only valid when the stroke is kept constant, in which case r1 = r0 - gdouble ratio_y = (h1 - r0) / (h0 - r0); + // We will now try to calculate the affine transformation required to transform the first visual bounding box into + // the second one, while accounting for strokewidth - // Calculating the scaling of the geometric bounding box if the stroke is kept constant - Geom::Affine direct_constant_r = Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); + if ((fabs(w0 - r0) < 1e-6) && (fabs(h0 - r0) < 1e-6)) { + return Geom::Affine(); + } - // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find - if (transform_stroke && r0 != 0 && r0 != Geom::infinity()) { // Check if there's stroke, and we need to scale it + Geom::Affine direct; + gdouble ratio_x = 1; + gdouble ratio_y = 1; + gdouble scale_x = 1; + gdouble scale_y = 1; + gdouble r1 = r0; + + if (fabs(w0 - r0) < 1e-6) { // We have a vertical line at hand + direct = Geom::Scale(flip_x, flip_y * h1 / h0); + ratio_x = 1; + ratio_y = (h1 - r0) / (h0 - r0); + r1 = transform_stroke ? r0 * sqrt(h1/h0) : r0; + scale_x = 1; + scale_y = (h1 - r1)/(h0 - r0); + } else if (fabs(h0 - r0) < 1e-6) { // We have a horizontal line at hand + direct = Geom::Scale(flip_x * w1 / w0, flip_y); + ratio_x = (w1 - r0) / (w0 - r0); + ratio_y = 1; + r1 = transform_stroke ? r0 * sqrt(w1/w0) : r0; + scale_x = (w1 - r1)/(w0 - r0); + scale_y = 1; + } else { // We have a true 2D object at hand + direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box + ratio_x = (w1 - r0) / (w0 - r0); // Only valid when the stroke is kept constant, in which case r1 = r0 + ratio_y = (h1 - r0) / (h0 - r0); /* Initial area of the geometric bounding box: A0 = (w0-r0)*(h0-r0) * Desired area of the geometric bounding box: A1 = (w1-r1)*(h1-r1) * This is how the stroke should scale: r1^2 / A1 = r0^2 / A0 @@ -170,23 +177,29 @@ get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble gdouble C = w1 * h1 * r0*r0; if (B*B - 4*A*C > 0) { // Of the two roots, I verified experimentally that this is the one we need - gdouble r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); + r1 = fabs((-B - sqrt(B*B - 4*A*C))/(2*A)); // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier - gdouble scale_x = (w1 - r1)/(w0 - r0); - gdouble scale_y = (h1 - r1)/(h0 - r0); - // Now we account for mirroring by flipping if needed - scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); - // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed - unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); + scale_x = (w1 - r1)/(w0 - r0); + scale_y = (h1 - r1)/(h0 - r0); } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? - scale *= direct; + r1 = r0; + scale_x = w1 / w0; + scale_y = h1 / h0; } + } + + // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find + if (transform_stroke && r0 != 0 && r0 != Geom::infinity()) { // Check if there's stroke, and we need to scale it + // Now we account for mirroring by flipping if needed + scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); + // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed + unbudge *= Geom::Translate (-flip_x * 0.5 * (r0 * scale_x - r1), -flip_y * 0.5 * (r0 * scale_y - r1)); } else { // The stroke should not be scaled, or is zero if (r0 == 0 || r0 == Geom::infinity() ) { // Strokewidth is zero or infinite scale *= direct; } else { // Nonscaling strokewidth - scale *= direct_constant_r; + scale *= Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); // Scaling of the geometric bounding box for constant stroke width unbudge *= Geom::Translate (flip_x * 0.5 * r0 * (1 - ratio_x), flip_y * 0.5 * r0 * (1 - ratio_y)); } } @@ -248,29 +261,6 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re gdouble r0w = w0 - bbox_geom.width(); // r0w is the average strokewidth of the left and right edges, i.e. 0.5*(r0l + r0r) gdouble r0h = h0 - bbox_geom.height(); // r0h is the average strokewidth of the top and bottom edges, i.e. 0.5*(r0t + r0b) - if (bbox_visual.hasZeroArea()) { // Obviously we cannot scale from empty visual bounding boxes at all, so we will only translate in such a case - Geom::Affine move = Geom::Translate(x0 - bbox_visual.min()[Geom::X], y0 - bbox_visual.min()[Geom::Y]); - return (move); - } - - Geom::Affine direct = Geom::Scale(w1 / w0, h1 / h0); - - // Although the area of the visual bounding box is not zero, we can still have a geometric - // bounding box with one or both sides having zero length. We can't handle this and will therefore - // simply return the scaling of the visual bounding box, without accounting for any stroke scaling - if (fabs(w0 - r0w) < 1e-6 || fabs(h0 - r0h) < 1e-6 || (!transform_stroke && (fabs(w1 - r0w) < 1e-6 || fabs(h1 - r0h) < 1e-6))) { - return (p2o * direct * o2n); - } - - // Check whether the stroke is negative; i.e. the geometric bounding box is larger than the visual bounding box, which - // occurs for example for clipped objects (see launchpad bug #811819) - if (r0w < 0 || r0w < 0) { - // How should we handle the stroke width scaling of clipped object? I don't know if we can/should handle this, - // so for now we simply return the direct scaling - return (p2o * direct * o2n); - } - - // Here starts the calculation you've been waiting for; first do some preparation int flip_x = (w1 > 0) ? 1 : -1; int flip_y = (h1 > 0) ? 1 : -1; @@ -280,20 +270,36 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re h1 = fabs(h1); // w0 and h0 will always be positive due to the definition of the width() and height() methods. - gdouble ratio_x = (w1 - r0w) / (w0 - r0w); // Only valid when the stroke is kept constant, in which case r1 = r0 - gdouble ratio_y = (h1 - r0h) / (h0 - r0h); - - // Calculating the scaling of the geometric bounding box if the stroke is kept constant - Geom::Affine direct_constant_r = Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); - - // The calculation of the new strokewidth will only use the average stroke for each of the dimensions; To find the new stroke for each - // of the edges individually though, we will use the boundary condition that the ratio of the left/right strokewidth will not change due to the - // scaling. The same holds for the ratio of the top/bottom strokewidth. - gdouble stroke_ratio_w = fabs(r0w) < 1e-6 ? 1 : (bbox_geom[Geom::X].min() - bbox_visual[Geom::X].min())/r0w; - gdouble stroke_ratio_h = fabs(r0h) < 1e-6 ? 1 : (bbox_geom[Geom::Y].min() - bbox_visual[Geom::Y].min())/r0h; + if ((fabs(w0 - r0w) < 1e-6) && (fabs(h0 - r0h) < 1e-6)) { + return Geom::Affine(); + } - // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find - if (transform_stroke && r0w != 0 && r0w != Geom::infinity() && r0h != 0 && r0h != Geom::infinity()) { // Check if there's stroke, and we need to scale it + Geom::Affine direct; + gdouble ratio_x = 1; + gdouble ratio_y = 1; + gdouble scale_x = 1; + gdouble scale_y = 1; + gdouble r1h = r0h; + gdouble r1w = r0w; + + if (fabs(w0 - r0w) < 1e-6) { // We have a vertical line at hand + direct = Geom::Scale(flip_x, flip_y * h1 / h0); + ratio_x = 1; + ratio_y = (h1 - r0h) / (h0 - r0h); + r1h = transform_stroke ? r0h * sqrt(h1/h0) : r0h; + scale_x = 1; + scale_y = (h1 - r1h)/(h0 - r0h); + } else if (fabs(h0 - r0h) < 1e-6) { // We have a horizontal line at hand + direct = Geom::Scale(flip_x * w1 / w0, flip_y); + ratio_x = (w1 - r0w) / (w0 - r0w); + ratio_y = 1; + r1w = transform_stroke ? r0w * sqrt(w1/w0) : r0w; + scale_x = (w1 - r1w)/(w0 - r0w); + scale_y = 1; + } else { // We have a true 2D object at hand + direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box + ratio_x = (w1 - r0w) / (w0 - r0w); // Only valid when the stroke is kept constant, in which case r1 = r0 + ratio_y = (h1 - r0h) / (h0 - r0h); /* Initial area of the geometric bounding box: A0 = (w0-r0w)*(h0-r0h) * Desired area of the geometric bounding box: A1 = (w1-r1w)*(h1-r1h) * This is how the stroke should scale: r1w^2 = A1/A0 * r0w^2, AND @@ -326,24 +332,43 @@ get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Re gdouble operant = 4*h1*w1*A0+r0h2*w12-2*h1*r0h*r0w*w1+h12*r0w2; if (operant >= 0) { // Of the eight roots, I verified experimentally that these are the two we need - gdouble r1h= fabs((r0h*sqrt(operant)-r0h2*w1-h1*r0h*r0w)/(2*A0-2*r0h*r0w)); - gdouble r1w= fabs(-((h1*r0w*A0+r0h2*r0w*w1)*sqrt(operant)+(-3*h1*r0h*r0w*w1-h12*r0w2)*A0-r0h3*r0w*w12+h1*r0h2*r0w2*w1)/((r0h*A0-r0h2*r0w)*sqrt(operant)-2*h1*A02+(3*h1*r0h*r0w-r0h2*w1)*A0+r0h3*r0w*w1-h1*r0h2*r0w2)); + r1h = fabs((r0h*sqrt(operant)-r0h2*w1-h1*r0h*r0w)/(2*A0-2*r0h*r0w)); + r1w = fabs(-((h1*r0w*A0+r0h2*r0w*w1)*sqrt(operant)+(-3*h1*r0h*r0w*w1-h12*r0w2)*A0-r0h3*r0w*w12+h1*r0h2*r0w2*w1)/((r0h*A0-r0h2*r0w)*sqrt(operant)-2*h1*A02+(3*h1*r0h*r0w-r0h2*w1)*A0+r0h3*r0w*w1-h1*r0h2*r0w2)); // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier - gdouble scale_x = (w1 - r1w)/(w0 - r0w); - gdouble scale_y = (h1 - r1h)/(h0 - r0h); - // Now we account for mirroring by flipping if needed - scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); - // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed - unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * (r0w * scale_x - r1w), -flip_y * stroke_ratio_h * (r0h * scale_y - r1h)); + scale_x = (w1 - r1w)/(w0 - r0w); + scale_y = (h1 - r1h)/(h0 - r0h); } else { // Can't find the roots of the quadratic equation. Likely the input parameters are invalid? - scale *= direct; + scale_x = w1 / w0; + scale_y = h1 / h0; } + } + + // Check whether the stroke is negative; i.e. the geometric bounding box is larger than the visual bounding box, which + // occurs for example for clipped objects (see launchpad bug #811819) + if (r0w < 0 || r0h < 0) { + // How should we handle the stroke width scaling of clipped object? I don't know if we can/should handle this, + // so for now we simply return the direct scaling + return (p2o * direct * o2n); + } + + // The calculation of the new strokewidth will only use the average stroke for each of the dimensions; To find the new stroke for each + // of the edges individually though, we will use the boundary condition that the ratio of the left/right strokewidth will not change due to the + // scaling. The same holds for the ratio of the top/bottom strokewidth. + gdouble stroke_ratio_w = fabs(r0w) < 1e-6 ? 1 : (bbox_geom[Geom::X].min() - bbox_visual[Geom::X].min())/r0w; + gdouble stroke_ratio_h = fabs(r0h) < 1e-6 ? 1 : (bbox_geom[Geom::Y].min() - bbox_visual[Geom::Y].min())/r0h; + + // If the stroke is not kept constant however, the scaling of the geometric bbox is more difficult to find + if (transform_stroke && r0w != 0 && r0w != Geom::infinity() && r0h != 0 && r0h != Geom::infinity()) { // Check if there's stroke, and we need to scale it + // Now we account for mirroring by flipping if needed + scale *= Geom::Scale(flip_x * scale_x, flip_y * scale_y); + // Make sure that the lower-left corner of the visual bounding box stays where it is, even though the stroke width has changed + unbudge *= Geom::Translate (-flip_x * stroke_ratio_w * (r0w * scale_x - r1w), -flip_y * stroke_ratio_h * (r0h * scale_y - r1h)); } else { // The stroke should not be scaled, or is zero (or infinite) if (r0w == 0 || r0w == Geom::infinity() || r0h == 0 || r0h == Geom::infinity()) { // can't calculate, because apparently strokewidth is zero or infinite scale *= direct; } else { - scale *= direct_constant_r; + scale *= Geom::Scale(flip_x * ratio_x, flip_y * ratio_y); // Scaling of the geometric bounding box for constant stroke width unbudge *= Geom::Translate (flip_x * stroke_ratio_w * r0w * (1 - ratio_x), flip_y * stroke_ratio_h * r0h * (1 - ratio_y)); } } diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 5f90a8997..7b8b54fee 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -252,7 +252,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) } else { // get_scale_transform_with_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_with_uniform_stroke (*bbox_user, 0, false, x0, y0, x1, y1); + scaler = get_scale_transform_with_uniform_stroke (*bbox_geom, 0, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); -- cgit v1.2.3 From 1c0a4eca434ada5675c6edc476325b7bb64da1a6 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 4 Sep 2011 20:11:51 +0200 Subject: 1) Fix absolute scaling in transform dialog 2) Transform dialog now follows the user prefs for geometric vs. visual bounding box (bzr r10615) --- src/selection.cpp | 10 +++++ src/selection.h | 3 ++ src/seltrans.cpp | 8 ++-- src/sp-item-transform.cpp | 14 +++---- src/sp-item-transform.h | 4 +- src/sp-item.cpp | 10 +++++ src/sp-item.h | 1 + src/ui/dialog/transformation.cpp | 91 +++++++++++++++++++++------------------- src/widgets/select-toolbar.cpp | 8 ++-- 9 files changed, 90 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/selection.cpp b/src/selection.cpp index 92b35bce7..5376311b1 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -27,6 +27,7 @@ #include "selection.h" #include "helper/recthull.h" #include "xml/repr.h" +#include "preferences.h" #include "sp-shape.h" #include "sp-path.h" @@ -390,6 +391,15 @@ Geom::OptRect Selection::visualBounds() const return bbox; } +Geom::OptRect Selection::preferredBounds() const +{ + if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) { + return bounds(SPItem::VISUAL_BBOX); + } else { + return bounds(SPItem::GEOMETRIC_BBOX); + } +} + Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; diff --git a/src/selection.h b/src/selection.h index af0facc3d..39e75685e 100644 --- a/src/selection.h +++ b/src/selection.h @@ -247,6 +247,9 @@ public: Geom::OptRect bounds(SPItem::BBoxType type) const; Geom::OptRect visualBounds() const; Geom::OptRect geometricBounds() const; + /** @brief Returns either the visual or geometric bounding rectangle of the selection, based on the + * preferences specified for the selector tool */ + Geom::OptRect preferredBounds() const; /// Returns the bounding rectangle of the selectionin document coordinates. Geom::OptRect documentBounds(SPItem::BBoxType type) const; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 19c09902b..20013ab0c 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -329,7 +329,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); // Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations // this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the - // stroke width. (see get_scale_transform_with_stroke()). This however is currently only implemented for a single bbox. + // stroke width. (see get_scale_transform_for_stroke()). This however is currently only implemented for a single bbox. // That's why we have both _bbox_points_for_translating and _bbox_points. getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, c, emp, mp); if (((_items.size() > 0) && (_items.size() < 50)) || prefs->getBool("/options/snapclosestonly/value", false)) { @@ -1560,7 +1560,7 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand } // Using the Geom::Rect constructor below ensures that "min() < max()", which is important - // because this will also hold for _bbox, and which is required for get_scale_transform_with_stroke() + // because this will also hold for _bbox, and which is required for get_scale_transform_for_stroke() Geom::Rect new_bbox = Geom::Rect(_origin_for_bboxpoints, visual_handle_pos); // new visual bounding box // Please note that the new_bbox might in fact be just a single line, for example when stretching (in // which case the handle and origin will be aligned vertically or horizontally) @@ -1569,7 +1569,7 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand // Calculate the absolute affine while taking into account the scaling of the stroke width Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs->getBool("/options/transform/stroke", true); - Geom::Affine abs_affine = get_scale_transform_with_uniform_stroke (*_bbox, _strokewidth, transform_stroke, + Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, transform_stroke, new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]); // Calculate the scaled geometrical bbox @@ -1616,7 +1616,7 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_ strokewidth = _strokewidth; } - _absolute_affine = get_scale_transform_with_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke, + _absolute_affine = get_scale_transform_for_uniform_stroke (*_visual_bbox, strokewidth, transform_stroke, new_bbox_min[Geom::X], new_bbox_min[Geom::Y], new_bbox_max[Geom::X], new_bbox_max[Geom::Y]); // return the new handle position diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 311604153..d1fe14f20 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -78,7 +78,7 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) * * PS: This function will only return accurate results for the visual bounding box of a selection of one or more objects, all having * the same strokewidth. If the stroke width varies from object to object in this selection, then the function - * get_scale_transform_with_unequal_stroke() should be called instead + * get_scale_transform_for_variable_stroke() should be called instead * * When scaling or stretching an object using the selector, e.g. by dragging the handles or by entering a value, we will * need to calculate the affine transformation for the old dimensions to the new dimensions. When using a geometric bounding @@ -98,7 +98,7 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) */ Geom::Affine -get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -210,10 +210,10 @@ get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble /** * \brief Calculate the affine transformation required to transform one visual bounding box into another, accounting for a VARIABLE strokewidth * - * Note: Please try to understand get_scale_transform_with_uniform_stroke() first, and read all it's comments carefully. This function - * (get_scale_transform_with_unequal_stroke) is a bit different because it will allow for a strokewidth that's different for each + * Note: Please try to understand get_scale_transform_for_uniform_stroke() first, and read all it's comments carefully. This function + * (get_scale_transform_for_variable_stroke) is a bit different because it will allow for a strokewidth that's different for each * side of the visual bounding box. Such a situation will arise when transforming the visual bounding box of a selection of objects, - * each having a different stroke width. In fact this function is a generalized version of get_scale_transform_with_uniform_stroke(), but + * each having a different stroke width. In fact this function is a generalized version of get_scale_transform_for_uniform_stroke(), but * will not (yet) replace it because it has not been tested as carefully, and because the old function is can serve as an introduction to * understand the new one. * @@ -236,7 +236,7 @@ get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble */ Geom::Affine -get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) +get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -393,7 +393,7 @@ get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs Geom::Rect new_visual_bbox = new_geom_bbox; if (initial_strokewidth > 0 && initial_strokewidth < Geom::infinity()) { if (transform_stroke) { - // scale stroke by: sqrt (((w1-r0)/(w0-r0))*((h1-r0)/(h0-r0))) (for visual bboxes, see get_scale_transform_with_stroke) + // scale stroke by: sqrt (((w1-r0)/(w0-r0))*((h1-r0)/(h0-r0))) (for visual bboxes, see get_scale_transform_for_stroke) // equals scaling by: sqrt ((w1/w0)*(h1/h0)) for geometrical bboxes // equals scaling by: sqrt (area1/area0) for geometrical bboxes gdouble const new_strokewidth = initial_strokewidth * sqrt (new_geom_bbox.area() / initial_geom_bbox->area()); diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 47e0ec0ec..4ea8f976f 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -9,8 +9,8 @@ void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); void sp_item_skew_rel (SPItem *item, double skewX, double skewY); void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); -Geom::Affine get_scale_transform_with_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); -Geom::Affine get_scale_transform_with_unequal_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); +Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index c0c23ba8b..3069dcf73 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -791,6 +791,16 @@ Geom::OptRect SPItem::desktopVisualBounds() const { return visualBounds(i2dt_affine()); } + +Geom::OptRect SPItem::desktopPreferredBounds() const +{ + if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) { + return desktopBounds(SPItem::VISUAL_BBOX); + } else { + return desktopBounds(SPItem::GEOMETRIC_BBOX); + } +} + Geom::OptRect SPItem::desktopBounds(BBoxType type) const { if (type == GEOMETRIC_BBOX) { diff --git a/src/sp-item.h b/src/sp-item.h index b827f6555..5558d3c62 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -178,6 +178,7 @@ public: Geom::OptRect documentBounds(BBoxType type) const; Geom::OptRect desktopGeometricBounds() const; Geom::OptRect desktopVisualBounds() const; + Geom::OptRect desktopPreferredBounds() const; Geom::OptRect desktopBounds(BBoxType type) const; unsigned pos_in_parent(); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 029a83ea5..be60fac20 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -467,7 +467,7 @@ Transformation::updatePageMove(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (!_check_move_relative.get_active()) { - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { double x = bbox->min()[Geom::X]; double y = bbox->min()[Geom::Y]; @@ -489,7 +489,7 @@ void Transformation::updatePageScale(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { double w = bbox->dimensions()[Geom::X]; double h = bbox->dimensions()[Geom::Y]; @@ -519,7 +519,7 @@ void Transformation::updatePageSkew(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { double w = bbox->dimensions()[Geom::X]; double h = bbox->dimensions()[Geom::Y]; @@ -616,7 +616,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { sp_selection_move_relative(selection, x, y); } else { - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { sp_selection_move_relative(selection, x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); @@ -637,7 +637,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->desktopVisualBounds(); + Geom::OptRect bbox = (*it)->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -661,7 +661,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->desktopVisualBounds(); + Geom::OptRect bbox = (*it)->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -680,7 +680,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) } } } else { - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { sp_selection_move_relative(selection, x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); @@ -699,49 +699,54 @@ Transformation::applyPageScale(Inkscape::Selection *selection) double scaleY = _scalar_scale_vertical.getValue("px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; if (prefs->getBool("/dialogs/transformation/applyseparately")) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - Geom::Scale scale (0,0); - // the values are increments! - if (_units_scale.isAbsolute()) { - Geom::OptRect bbox = item->desktopVisualBounds(); - if (bbox) { - double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object - double new_height = scaleY; - if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / bbox->dimensions()[Geom::X], new_height / bbox->dimensions()[Geom::Y]); - } - } else { + Geom::OptRect bbox_pref = item->desktopPreferredBounds(); + Geom::OptRect bbox_geom = item->desktopGeometricBounds(); + if (bbox_pref && bbox_geom) { double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; double new_height = scaleY; + // the values are increments! + if (!_units_scale.isAbsolute()) { // Relative scaling, i.e in percent + new_width = scaleX/100 * bbox_pref->width(); + new_height = scaleY/100 * bbox_pref->height(); + } + if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / 100.0, new_height / 100.0); + + double x0 = bbox_pref->midpoint()[Geom::X] - new_width/2; + double y0 = bbox_pref->midpoint()[Geom::Y] - new_height/2; + double x1 = bbox_pref->midpoint()[Geom::X] + new_width/2; + double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; + + Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, x0, y0, x1, y1); + item->set_i2d_affine(item->i2dt_affine() * scaler); + item->doWriteTransform(item->getRepr(), item->transform); } - sp_item_scale_rel (item, scale); } } else { - Geom::OptRect bbox = selection->visualBounds(); - if (bbox) { - Geom::Point center(bbox->midpoint()); // use rotation center? - Geom::Scale scale (0,0); + Geom::OptRect bbox_pref = selection->preferredBounds(); + Geom::OptRect bbox_geom = selection->geometricBounds(); + if (bbox_pref && bbox_geom) { // the values are increments! - if (_units_scale.isAbsolute()) { - double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; - double new_height = scaleY; - if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / bbox->dimensions()[Geom::X], new_height / bbox->dimensions()[Geom::Y]); - } else { - double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; - double new_height = scaleY; - if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / 100.0, new_height / 100.0); + double new_width = scaleX; + double new_height = scaleY; + if (!_units_scale.isAbsolute()) { // Relative scaling, i.e in percent + new_width = scaleX/100 * bbox_pref->width(); + new_height = scaleY/100 * bbox_pref->height(); } - sp_selection_scale_relative(selection, center, scale); + if (fabs(new_width) < 1e-6) new_width = 1e-6; + if (fabs(new_height) < 1e-6) new_height = 1e-6; + + double x0 = bbox_pref->midpoint()[Geom::X] - new_width/2; + double y0 = bbox_pref->midpoint()[Geom::Y] - new_height/2; + double x1 = bbox_pref->midpoint()[Geom::X] + new_width/2; + double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; + Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, x0, y0, x1, y1); + + sp_selection_apply_affine(selection, scaler); } } @@ -792,7 +797,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); - Geom::OptRect bbox = item->desktopVisualBounds(); + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { double width = bbox->dimensions()[Geom::X]; double height = bbox->dimensions()[Geom::Y]; @@ -801,7 +806,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } } } else { // transform whole selection - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); boost::optional center = selection->center(); if ( bbox && center ) { @@ -886,7 +891,7 @@ Transformation::onMoveRelativeToggled() //g_message("onMoveRelativeToggled: %f, %f px\n", x, y); - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { if (_check_move_relative.get_active()) { @@ -1026,7 +1031,7 @@ Transformation::onClear() _scalar_move_horizontal.setValue(0); _scalar_move_vertical.setValue(0); } else { - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { _scalar_move_horizontal.setValue(bbox->min()[Geom::X], "px"); _scalar_move_vertical.setValue(bbox->min()[Geom::Y], "px"); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 7b8b54fee..38346ce56 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -248,11 +248,13 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) Geom::Affine scaler; if (bbox_type == SPItem::VISUAL_BBOX) { - scaler = get_scale_transform_with_unequal_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1); + scaler = get_scale_transform_for_variable_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1); } else { - // get_scale_transform_with_stroke() is intended for visual bounding boxes, not geometrical ones! + // 1) We could have use the newer get_scale_transform_for_variable_stroke() here, but to avoid regressions + // we'll just use the old get_scale_transform_for_uniform_stroke() for now. + // 2) get_scale_transform_for_uniform_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_with_uniform_stroke (*bbox_geom, 0, false, x0, y0, x1, y1); + scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); -- cgit v1.2.3 From 8e867961dfc221568661c695aeddc10552f0accb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 4 Sep 2011 23:17:50 +0200 Subject: Fix crashes with empty text objects (bzr r10617) --- src/sp-flowtext.cpp | 2 +- src/sp-text.cpp | 2 +- src/sp-tref.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index bd73a65c9..e7dcc559f 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -335,7 +335,7 @@ sp_flowtext_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBox // Add stroke width // FIXME this code is incorrect - if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + if (bbox && type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { double scale = transform.descrim(); bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index fc248824d..a9c1b2a4b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -367,7 +367,7 @@ sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType Geom::OptRect bbox = SP_TEXT(item)->layout.bounds(transform); // FIXME this code is incorrect - if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + if (bbox && type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { double scale = transform.descrim(); bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index ac20ce098..833743d24 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -336,7 +336,7 @@ sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType // Add stroke width // FIXME this code is incorrect - if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + if (bbox && type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { double scale = transform.descrim(); bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } -- cgit v1.2.3 From b4a588899df36146859d8fe54efdfbdcfcc18779 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 4 Sep 2011 23:18:40 +0200 Subject: Compute visual bounding box only when needed (bzr r10618) --- src/sp-item.cpp | 16 ++++++++++++++-- src/sp-item.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 3069dcf73..511daa5f1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -130,6 +130,7 @@ void SPItem::sp_item_init(SPItem *item) void SPItem::init() { sensitive = TRUE; + bbox_valid = FALSE; transform_center_x = 0; transform_center_y = 0; @@ -138,6 +139,7 @@ void SPItem::init() { _evaluated_status = StatusUnknown; transform = Geom::identity(); + doc_bbox = Geom::OptRect(); display = NULL; @@ -561,6 +563,8 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) } if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) { + item->bbox_valid = FALSE; + if (flags & SP_OBJECT_MODIFIED_FLAG) { for (SPItemView *v = item->display; v != NULL; v = v->next) { v->arenaitem->setTransform(item->transform); @@ -769,7 +773,11 @@ Geom::OptRect SPItem::documentGeometricBounds() const /// Get item's visual bbox in document coordinate system. Geom::OptRect SPItem::documentVisualBounds() const { - return visualBounds(i2doc_affine()); + if (!bbox_valid) { + doc_bbox = visualBounds(i2doc_affine()); + bbox_valid = true; + } + return doc_bbox; } Geom::OptRect SPItem::documentBounds(BBoxType type) const { @@ -789,7 +797,11 @@ Geom::OptRect SPItem::desktopGeometricBounds() const /// Get item's visual bbox in desktop coordinate system. Geom::OptRect SPItem::desktopVisualBounds() const { - return visualBounds(i2dt_affine()); + /// @fixme hardcoded desktop transform + Geom::Affine m = Geom::Scale(1, -1) * Geom::Translate(0, document->getHeight()); + Geom::OptRect ret = documentVisualBounds(); + if (ret) *ret *= m; + return ret; } Geom::OptRect SPItem::desktopPreferredBounds() const diff --git a/src/sp-item.h b/src/sp-item.h index 5558d3c62..1346a77e8 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -116,10 +116,12 @@ public: unsigned int sensitive : 1; unsigned int stop_paint: 1; + mutable unsigned bbox_valid : 1; double transform_center_x; double transform_center_y; Geom::Affine transform; + mutable Geom::OptRect doc_bbox; SPClipPathReference *clip_ref; SPMaskReference *mask_ref; -- cgit v1.2.3 From 8033f1dc89c36da5933ee04175e610f639d292f7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 5 Sep 2011 16:51:25 +0200 Subject: Fix incorrect marker bbox in previews (bzr r10619) --- src/sp-item.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 511daa5f1..df0394e38 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -562,9 +562,11 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags); } - if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) { - item->bbox_valid = FALSE; + // any of the modifications defined in sp-object.h might change bbox, + // so we invalidate it unconditionally + item->bbox_valid = FALSE; + if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) { if (flags & SP_OBJECT_MODIFIED_FLAG) { for (SPItemView *v = item->display; v != NULL; v = v->next) { v->arenaitem->setTransform(item->transform); -- cgit v1.2.3 From 2c77118e8580503218085a36656a121fcc4f59c0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 5 Sep 2011 17:42:23 +0200 Subject: Fix bugs in text stroke rendering and picking (bzr r10620) --- src/display/drawing-text.cpp | 26 +++++++++++--------------- src/display/drawing-text.h | 3 +-- src/libnrtype/Layout-TNG-Output.cpp | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 1134771bc..4a20875ae 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -63,14 +63,20 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, return STATE_ALL; } + _pick_bbox = Geom::IntRect(); + _bbox = Geom::IntRect(); + Geom::OptRect b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); if (b && ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) { float width, scale; scale = ctx.ctm.descrim(); + if (_transform) scale /= _transform->descrim(); // FIXME temporary hack width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); if ( fabs(ggroup->_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true b->expandBy(width); } + // save no-miter bbox for picking + _pick_bbox = b->roundOutwards(); // those pesky miters, now float miterMax = width * ggroup->_nrstyle.miter_limit; if ( miterMax > 0.01 ) { @@ -78,12 +84,7 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, // (one for each point on the curve) b->expandBy(miterMax); } - } - - if (b) { _bbox = b->roundOutwards(); - } else { - _bbox = Geom::OptIntRect(); } return STATE_ALL; @@ -95,7 +96,7 @@ DrawingGlyphs::_pickItem(Geom::Point const &p, double delta, unsigned /*flags*/) if (!_font || !_bbox) return NULL; // With text we take a simple approach: pick if the point is in a characher bbox - Geom::Rect expanded(*_bbox); + Geom::Rect expanded(_pick_bbox); expanded.expandBy(delta); if (expanded.contains(p)) return this; return NULL; @@ -135,13 +136,6 @@ DrawingText::setStyle(SPStyle *style) DrawingGroup::setStyle(style); } -void -DrawingText::setPaintBox(Geom::OptRect const &box) -{ - _paintbox = box; - _markForUpdate(STATE_ALL, false); -} - unsigned DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { @@ -175,8 +169,8 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned // NOTE: this is very similar to drawing-shape.cpp; the only difference is in path feeding bool has_stroke, has_fill; - has_fill = _nrstyle.prepareFill(ct, _paintbox); - has_stroke = _nrstyle.prepareStroke(ct, _paintbox); + has_fill = _nrstyle.prepareFill(ct, _item_bbox); + has_stroke = _nrstyle.prepareStroke(ct, _item_bbox); if (has_fill || has_stroke) { for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { @@ -189,6 +183,8 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned ct.path(*g->_font->PathVector(g->_glyph)); } + Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); if (has_fill) { _nrstyle.applyFill(ct); ct.fillPreserve(); diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index 4f3940dde..73caa6a7c 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -36,6 +36,7 @@ protected: font_instance *_font; int _glyph; + Geom::IntRect _pick_bbox; friend class DrawingText; }; @@ -50,7 +51,6 @@ public: void clear(); void addComponent(font_instance *font, int glyph, Geom::Affine const &trans); void setStyle(SPStyle *style); - void setPaintBox(Geom::OptRect const &box); protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, @@ -61,7 +61,6 @@ protected: virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); - Geom::OptRect _paintbox; NRStyle _nrstyle; friend class DrawingGlyphs; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 7e54a00e2..ebb71d388 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -99,7 +99,7 @@ void Layout::show(DrawingGroup *in_arena, Geom::OptRect const &paintbox) const } glyph_index++; } - nr_text->setPaintBox(paintbox); + nr_text->setItemBounds(paintbox); in_arena->prependChild(nr_text); } } -- cgit v1.2.3 From 45125f4504bd611ab43d9c6529b45fca81e98948 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 5 Sep 2011 23:32:08 +0200 Subject: When scaling a diagonal line to a horizontal line, the strokewidth becomes NaN. This commit allows to change the strokewidth back to a more useful value (as reported by ~suv in lp:825840) (bzr r10621) --- src/desktop-style.cpp | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 1cad282b3..c08ee8677 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -424,14 +424,16 @@ stroke_average_width (GSList const *objects) SPObject *object = SP_OBJECT(l->data); - if ( object->style->stroke.isNone() ) { + double width = object->style->stroke_width.computed * i2dt.descrim(); + + if ( object->style->stroke.isNone() || isnan(width)) { ++n_notstroked; // do not count nonstroked objects continue; } else { notstroked = false; } - avgwidth += object->style->stroke_width.computed * i2dt.descrim(); + avgwidth += width; } if (notstroked) @@ -721,18 +723,19 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) continue; } - n_stroked ++; - noneSet &= style->stroke.isNone(); Geom::Affine i2d = SP_ITEM(obj)->i2dt_affine(); double sw = style->stroke_width.computed * i2d.descrim(); - if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) - same_sw = false; - prev_sw = sw; + if (!isnan(sw)) { + if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) + same_sw = false; + prev_sw = sw; - avgwidth += sw; + avgwidth += sw; + n_stroked ++; + } } if (n_stroked > 1) @@ -945,6 +948,7 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) double linespacing_prev = 0; int texts = 0; + int no_size = 0; for (GSList const *i = objects; i != NULL; i = i->next) { SPObject *obj = SP_OBJECT (i->data); @@ -961,7 +965,12 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) } texts ++; - size += style->font_size.computed * Geom::Affine(SP_ITEM(obj)->i2dt_affine()).descrim(); /// \todo FIXME: we assume non-% units here + double dummy = style->font_size.computed * Geom::Affine(SP_ITEM(obj)->i2dt_affine()).descrim(); + if (!isnan(dummy)) { + size += dummy; /// \todo FIXME: we assume non-% units here + } else { + no_size++; + } if (style->letter_spacing.normal) { if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing)) { @@ -1016,7 +1025,9 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) return QUERY_STYLE_NOTHING; if (texts > 1) { - size /= texts; + if (texts - no_size > 0) { + size /= (texts - no_size); + } letterspacing /= texts; wordspacing /= texts; linespacing /= texts; @@ -1444,12 +1455,15 @@ objects_query_blur (GSList *objects, SPStyle *style_res) if(SP_IS_GAUSSIANBLUR(primitive)) { SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive); float num = spblur->stdDeviation.getNumber(); - blur_sum += num * i2d.descrim(); - if (blur_prev != -1 && fabs (num - blur_prev) > 1e-2) // rather low tolerance because difference in blur radii is much harder to notice than e.g. difference in sizes - same_blur = false; - blur_prev = num; - //TODO: deal with opt number, for the moment it's not necessary to the ui. - blur_items ++; + float dummy = num * i2d.descrim(); + if (!isnan(dummy)) { + blur_sum += dummy; + if (blur_prev != -1 && fabs (num - blur_prev) > 1e-2) // rather low tolerance because difference in blur radii is much harder to notice than e.g. difference in sizes + same_blur = false; + blur_prev = num; + //TODO: deal with opt number, for the moment it's not necessary to the ui. + blur_items ++; + } } } primitive_obj = primitive_obj->next; -- cgit v1.2.3 From 34c0a97e8328623b7810c6661e7a559abf282536 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 6 Sep 2011 16:47:56 +0200 Subject: Further fixes for text rendering and picking (bzr r10622) --- src/display/drawing-text.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 4a20875ae..23a7cfdfb 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -73,11 +73,11 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, if (_transform) scale /= _transform->descrim(); // FIXME temporary hack width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); if ( fabs(ggroup->_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true - b->expandBy(width); + b->expandBy(0.5 * width); } - // save no-miter bbox for picking + // save bbox without miters for picking _pick_bbox = b->roundOutwards(); - // those pesky miters, now + float miterMax = width * ggroup->_nrstyle.miter_limit; if ( miterMax > 0.01 ) { // grunt mode. we should compute the various miters instead @@ -85,6 +85,9 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, b->expandBy(miterMax); } _bbox = b->roundOutwards(); + } else if (b) { + _bbox = b->roundOutwards(); + _pick_bbox = *_bbox; } return STATE_ALL; -- cgit v1.2.3 From 8ceb1a926aaacf57ebfe1c244ac1a73b6866fda4 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 6 Sep 2011 19:56:21 +0200 Subject: Fix isnan() compilation issues (bzr r10623) --- src/desktop-style.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index c08ee8677..074e7bf67 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -46,6 +46,7 @@ #include "desktop-style.h" #include "svg/svg-icc-color.h" #include "box3d-side.h" +#include <2geom/math-utils.h> /** * Set color on selection on desktop. @@ -426,7 +427,7 @@ stroke_average_width (GSList const *objects) double width = object->style->stroke_width.computed * i2dt.descrim(); - if ( object->style->stroke.isNone() || isnan(width)) { + if ( object->style->stroke.isNone() || IS_NAN(width)) { ++n_notstroked; // do not count nonstroked objects continue; } else { @@ -728,7 +729,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) Geom::Affine i2d = SP_ITEM(obj)->i2dt_affine(); double sw = style->stroke_width.computed * i2d.descrim(); - if (!isnan(sw)) { + if (!IS_NAN(sw)) { if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) same_sw = false; prev_sw = sw; @@ -966,7 +967,7 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) texts ++; double dummy = style->font_size.computed * Geom::Affine(SP_ITEM(obj)->i2dt_affine()).descrim(); - if (!isnan(dummy)) { + if (!IS_NAN(dummy)) { size += dummy; /// \todo FIXME: we assume non-% units here } else { no_size++; @@ -1456,7 +1457,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive); float num = spblur->stdDeviation.getNumber(); float dummy = num * i2d.descrim(); - if (!isnan(dummy)) { + if (!IS_NAN(dummy)) { blur_sum += dummy; if (blur_prev != -1 && fabs (num - blur_prev) > 1e-2) // rather low tolerance because difference in blur radii is much harder to notice than e.g. difference in sizes same_blur = false; -- cgit v1.2.3 From 59e4b3b0caaf8fae935adadb9934231777054569 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 6 Sep 2011 22:29:29 +0200 Subject: Obey to dont-scale-strokewidth preference, even when scaling one dimension to zero or infinite Fixed bugs: - https://launchpad.net/bugs/825840 (bzr r10624) --- src/sp-item.cpp | 33 ++++++++++++++++++++++++++++++--- src/sp-item.h | 2 ++ 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index df0394e38..9e03631f5 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -140,6 +140,7 @@ void SPItem::init() { transform = Geom::identity(); doc_bbox = Geom::OptRect(); + freeze_stroke_width = false; display = NULL; @@ -1110,6 +1111,10 @@ void SPItem::adjust_gradient( Geom::Affine const &postmul, bool set ) void SPItem::adjust_stroke( gdouble ex ) { + if (freeze_stroke_width) { + return; + } + SPStyle *style = this->style; if (style && !style->stroke.isNone() && !Geom::are_near(ex, 1.0, Geom::EPSILON)) { @@ -1162,6 +1167,20 @@ void SPItem::adjust_stroke_width_recursive(double expansion) } } +void SPItem::freeze_stroke_width_recursive(bool freeze) +{ + freeze_stroke_width = freeze; + +// A clone's child is the ghost of its original - we must not touch it, skip recursion + if ( !SP_IS_USE(this) ) { + for ( SPObject *o = children; o; o = o->getNext() ) { + if (SP_IS_ITEM(o)) { + SP_ITEM(o)->freeze_stroke_width_recursive(freeze); + } + } + } +} + /** * Recursively adjust rx and ry of rects. */ @@ -1258,10 +1277,12 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (compensate) { - // recursively compensate for stroke scaling, depending on user preference + // recursively compensating for stroke scaling will not work, because it can be scaled to zero or infinite + // from which we cannot ever recover by applying an inverse scale; therefore we temporarily block any changes + // to the strokewidth instead, and unblock these after the transformation + // (as reported in https://bugs.launchpad.net/inkscape/+bug/825840/comments/4) if (!prefs->getBool("/options/transform/stroke", true)) { - double const expansion = 1. / advertized_transform.descrim(); - adjust_stroke_width_recursive(expansion); + freeze_stroke_width_recursive(true); } // recursively compensate rx/ry of a rect if requested @@ -1299,6 +1320,12 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra } set_item_transform(transform_attr); + if (compensate) { + if (!prefs->getBool("/options/transform/stroke", true)) { + freeze_stroke_width_recursive(false); + } + } + // Note: updateRepr comes before emitting the transformed signal since // it causes clone SPUse's copy of the original object to brought up to // date with the original. Otherwise, sp_use_bbox returns incorrect diff --git a/src/sp-item.h b/src/sp-item.h index 1346a77e8..1765089a3 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -119,6 +119,7 @@ public: mutable unsigned bbox_valid : 1; double transform_center_x; double transform_center_y; + bool freeze_stroke_width; Geom::Affine transform; mutable Geom::OptRect doc_bbox; @@ -194,6 +195,7 @@ public: void adjust_gradient(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false); void adjust_stroke(gdouble ex); void adjust_stroke_width_recursive(gdouble ex); + void freeze_stroke_width_recursive(bool freeze); void adjust_paint_recursive(Geom::Affine advertized_transform, Geom::Affine t_ancestors, bool is_pattern); void adjust_livepatheffect(Geom::Affine const &postmul, bool set = false); void doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv = NULL, bool compensate = true); -- cgit v1.2.3 From 8a73582fd88bffa4e219dfce758a930b43c06a98 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 8 Sep 2011 16:27:40 +0200 Subject: Preserve CDATA sections on output. (bzr r10625) --- src/xml/document.h | 1 + src/xml/repr-io.cpp | 12 ++++++++++-- src/xml/simple-document.cpp | 4 ++++ src/xml/simple-document.h | 4 +++- src/xml/text-node.h | 13 ++++++++++++- 5 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/xml/document.h b/src/xml/document.h index 98cc0522e..3bf0a63a6 100644 --- a/src/xml/document.h +++ b/src/xml/document.h @@ -92,6 +92,7 @@ public: */ virtual Node *createElement(char const *name)=0; virtual Node *createTextNode(char const *content)=0; + virtual Node *createTextNode(char const *content, bool is_CData)=0; virtual Node *createComment(char const *content)=0; virtual Node *createPI(char const *target, char const *content)=0; /*@}*/ diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 2a0bb6ce8..365415488 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -24,6 +24,7 @@ #include "xml/attribute-record.h" #include "xml/rebase-hrefs.h" #include "xml/simple-document.h" +#include "xml/text-node.h" #include "io/sys.h" #include "io/uristream.h" @@ -497,7 +498,9 @@ sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_ return NULL; // we do not preserve all-whitespace nodes unless we are asked to } - return xml_doc->createTextNode(reinterpret_cast(node->content)); + // We keep track of original node type so that CDATA sections are preserved on output. + return xml_doc->createTextNode(reinterpret_cast(node->content), + node->type == XML_CDATA_SECTION_NODE ); } if (node->type == XML_COMMENT_NODE) { @@ -849,7 +852,12 @@ void sp_repr_write_stream( Node *repr, Writer &out, gint indent_level, { switch (repr->type()) { case Inkscape::XML::TEXT_NODE: { - repr_quote_write( out, repr->content() ); + if( dynamic_cast(repr)->is_CData() ) { + // Preserve CDATA sections, not converting '&' to &, etc. + out.printf( "", repr->content() ); + } else { + repr_quote_write( out, repr->content() ); + } break; } case Inkscape::XML::COMMENT_NODE: { diff --git a/src/xml/simple-document.cpp b/src/xml/simple-document.cpp index 2807133af..0287c4458 100644 --- a/src/xml/simple-document.cpp +++ b/src/xml/simple-document.cpp @@ -58,6 +58,10 @@ Node *SimpleDocument::createTextNode(char const *content) { return new TextNode(Util::share_string(content), this); } +Node *SimpleDocument::createTextNode(char const *content, bool const is_CData) { + return new TextNode(Util::share_string(content), this, is_CData); +} + Node *SimpleDocument::createComment(char const *content) { return new CommentNode(Util::share_string(content), this); } diff --git a/src/xml/simple-document.h b/src/xml/simple-document.h index 8a37c577c..ff1d94b0c 100644 --- a/src/xml/simple-document.h +++ b/src/xml/simple-document.h @@ -31,7 +31,7 @@ class SimpleDocument : public SimpleNode, public: explicit SimpleDocument() : SimpleNode(g_quark_from_static_string("xml"), this), - _in_transaction(false) {} + _in_transaction(false), _is_CData(false) {} NodeType type() const { return Inkscape::XML::DOCUMENT_NODE; } @@ -44,6 +44,7 @@ public: Node *createElement(char const *name); Node *createTextNode(char const *content); + Node *createTextNode(char const *content, bool const is_CData); Node *createComment(char const *content); Node *createPI(char const *target, char const *content); @@ -76,6 +77,7 @@ protected: private: bool _in_transaction; LogBuilder _log_builder; + bool _is_CData; }; } diff --git a/src/xml/text-node.h b/src/xml/text-node.h index b0b7c884b..2fabd6953 100644 --- a/src/xml/text-node.h +++ b/src/xml/text-node.h @@ -30,14 +30,25 @@ struct TextNode : public SimpleNode { : SimpleNode(g_quark_from_static_string("string"), doc) { setContent(content); + _is_CData = false; + } + TextNode(Util::ptr_shared content, Document *doc, bool is_CData) + : SimpleNode(g_quark_from_static_string("string"), doc) + { + setContent(content); + _is_CData = is_CData; } TextNode(TextNode const &other, Document *doc) - : SimpleNode(other, doc) {} + : SimpleNode(other, doc) { + _is_CData = other._is_CData; + } Inkscape::XML::NodeType type() const { return Inkscape::XML::TEXT_NODE; } + bool is_CData() const { return _is_CData; } protected: SimpleNode *_duplicate(Document* doc) const { return new TextNode(*this, doc); } + bool _is_CData; }; } -- cgit v1.2.3 From f09608c636d8480f6fb3c1e2674f9726a854dd29 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 8 Sep 2011 21:25:40 +0200 Subject: Filters. Fix for inverted parameters in Light Eraser CPF. (bzr r10626) --- src/extension/internal/filter/transparency.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 79657749a..4e91f8854 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -185,8 +185,8 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) Make the lightest parts of the object progressively transparent. Filter's parameters: - * Expansion (1.->1000., default 100) -> colormatrix (first 3 values, multiplicator) - * Erosion (0.->1000., default 50) -> colormatrix (4th value, multiplicator) + * Expansion (0.->1000., default 50) -> colormatrix (4th value, multiplicator) + * Erosion (1.->1000., default 100) -> colormatrix (first 3 values, multiplicator) * Global opacity (0.->1., default 1.) -> composite (k2) * Inverted (boolean, default false) -> colormatrix (values, true: first 3 values positive, 4th negative) @@ -204,8 +204,8 @@ public: "\n" "" N_("Light Eraser") "\n" "org.inkscape.effect.filter.LightEraser\n" - "100\n" - "50\n" + "50\n" + "100\n" "1\n" "false\n" "\n" @@ -233,15 +233,15 @@ LightEraser::get_filter_text (Inkscape::Extension::Extension * ext) opacity << ext->get_param_float("opacity"); if (ext->get_param_bool("invert")) { - expand << (ext->get_param_float("expand") * 0.2125) << " " - << (ext->get_param_float("expand") * 0.7154) << " " - << (ext->get_param_float("expand") * 0.0721); - erode << (-ext->get_param_float("erode")); + expand << (ext->get_param_float("erode") * 0.2125) << " " + << (ext->get_param_float("erode") * 0.7154) << " " + << (ext->get_param_float("erode") * 0.0721); + erode << (-ext->get_param_float("expand")); } else { - expand << (-ext->get_param_float("expand") * 0.2125) << " " - << (-ext->get_param_float("expand") * 0.7154) << " " - << (-ext->get_param_float("expand") * 0.0721); - erode << ext->get_param_float("erode"); + expand << (-ext->get_param_float("erode") * 0.2125) << " " + << (-ext->get_param_float("erode") * 0.7154) << " " + << (-ext->get_param_float("erode") * 0.0721); + erode << ext->get_param_float("expand"); } _filter = g_strdup_printf( -- cgit v1.2.3 From 2b9f2bdedec8e0610e1ed938d823c3ff1f230d52 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 9 Sep 2011 18:56:06 -0400 Subject: pdf import. apply invert transform to all image tags (Bug 840625) Fixed bugs: - https://launchpad.net/bugs/840625 (bzr r10627) --- src/extension/internal/pdfinput/svg-builder.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index fe383b920..1aaf3a1a5 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1601,9 +1601,8 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height sp_repr_set_svg_double(image_node, "width", 1); sp_repr_set_svg_double(image_node, "height", 1); // Set transformation - if (_is_top_level) { + svgSetTransform(image_node, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0); - } // Create href if (embed_image) { -- cgit v1.2.3 From 3eeddc1ea8ac49828c23e7406bf52b8f7e0c7812 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 15 Sep 2011 20:21:22 +0200 Subject: Fix typo that causes crashes when color management is enabled. (bzr r10628) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index a4c8500ed..e6f973faf 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1701,7 +1701,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i Date: Thu, 15 Sep 2011 21:08:22 +0200 Subject: Use CSSOStringStream in writing number strings parsed by libcroco as libcroco uses %.17f for formatting, resulting in trailing zeros or small rounding errors. (bzr r10629) --- src/xml/repr-css.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 46a16715c..cb30e65ce 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -14,13 +14,15 @@ * * Use sp_repr_write_string to go from a property list to a style string. * - * Use sp_repr_css_add_component to parse a property string and add the properties to the List. */ #define SP_REPR_CSS_C #include +#include +#include #include +#include "svg/css-ostringstream.h" #include "xml/repr.h" #include "xml/simple-document.h" @@ -120,7 +122,9 @@ SPCSSAttr *sp_repr_css_attr_inherited(Node *repr, gchar const *attr) } /** - * Adds components (style properties) to an existing SPCSAttr from a character string. + * Adds components (style properties) to an existing SPCSAttr from the specified attribute's data + * (nominally a style attribute). + * */ static void sp_repr_css_add_components(SPCSSAttr *css, Node *repr, gchar const *attr) @@ -228,6 +232,7 @@ sp_repr_css_write_string(SPCSSAttr *css) } } else { buffer.append(iter->value); // unquoted + g_warning("sp_repr_css_write_string: %s %s", g_quark_to_string(iter->key), iter->value ); } if (rest(iter)) { @@ -250,6 +255,12 @@ sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr) gchar *value = sp_repr_css_write_string(css); + /* + * If the new value is different from the old value, this will sometimes send a signal via + * CompositeNodeObserver::notiftyAttributeChanged() which results in calling + * SPObject::sp_object_repr_attr_changed and thus updates the object's SPStyle. This update + * results in another call to repr->setAttribute(). + */ repr->setAttribute(attr, value); if (value) g_free (value); @@ -291,7 +302,22 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) guchar *const str_value_unsigned = cr_term_to_string(decl->value); gchar *const str_value = reinterpret_cast(str_value_unsigned); gchar *value_unquoted = attribute_unquote (str_value); // libcroco returns strings quoted in "" - ((Node *) css)->setAttribute(decl->property->stryng->str, value_unquoted, false); + + // libcroco uses %.17f for formatting... leading to trailing zeros or small rounding errors. + // CSSOStringStream is used here to write valid CSS (as in sp_style_write_string). This has + // the additional benefit of respecting the numerical precission set in the SVG Output + // preferences. We assume any numerical part comes first (if not, the whole string is copied). + std::stringstream ss( value_unquoted ); + double number; + std::string characters; + bool number_valid = !(ss >> number).fail(); + if( !number_valid ) ss.clear(); + bool character_valid = !(ss >> characters).fail(); + Inkscape::CSSOStringStream os; + if( number_valid ) os << number; + if( character_valid ) os << characters; + + ((Node *) css)->setAttribute(decl->property->stryng->str, os.str().c_str(), false); g_free(value_unquoted); g_free(str_value); } @@ -332,7 +358,8 @@ sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p) /** * Creates a new SPCSAttr with the values filled from a repr, merges in properties from the given - * SPCSAttr, and then replaces the that SPCSAttr with the new one. + * SPCSAttr, and then replaces that SPCSAttr with the new one. This is called, for example, for + * each object in turn when a selection's style is updated via sp_desktop_set_style(). */ void sp_repr_css_change(Node *repr, SPCSSAttr *css, gchar const *attr) -- cgit v1.2.3 From f21461e44a12ad13d86c125b095a8793e24dffda Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 16 Sep 2011 01:47:40 +0200 Subject: Fix incorrect argument in call to varargs function in xml/repr-css.cpp (bzr r10630) --- src/xml/repr-css.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index cb30e65ce..8e8042dfd 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -232,7 +232,7 @@ sp_repr_css_write_string(SPCSSAttr *css) } } else { buffer.append(iter->value); // unquoted - g_warning("sp_repr_css_write_string: %s %s", g_quark_to_string(iter->key), iter->value ); + g_warning("sp_repr_css_write_string: %s %s", g_quark_to_string(iter->key), iter->value.pointer() ); } if (rest(iter)) { -- cgit v1.2.3 From 043e682872b382312e0dc58c197ce452b1cf6766 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 16 Sep 2011 09:12:03 +0200 Subject: Remove left over debug g_warning... and the cause of compilation problems. (bzr r10631) --- src/xml/repr-css.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 8e8042dfd..7db1e8b86 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -232,7 +232,6 @@ sp_repr_css_write_string(SPCSSAttr *css) } } else { buffer.append(iter->value); // unquoted - g_warning("sp_repr_css_write_string: %s %s", g_quark_to_string(iter->key), iter->value.pointer() ); } if (rest(iter)) { @@ -316,7 +315,7 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) Inkscape::CSSOStringStream os; if( number_valid ) os << number; if( character_valid ) os << characters; - + ((Node *) css)->setAttribute(decl->property->stryng->str, os.str().c_str(), false); g_free(value_unquoted); g_free(str_value); -- cgit v1.2.3 From 17f63b09c2f8746e1b65d470567eac2a18d7b2ca Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 16 Sep 2011 16:32:58 +0200 Subject: Correct the formula of the displacement map so that zero alpha value means maximum negative displacement rather than zero displacement. Fixes artifacts in filters. Fixed bugs: - https://launchpad.net/bugs/849064 (bzr r10632) --- src/display/nr-filter-displacement-map.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 01c644bc1..9b44c2302 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -43,15 +43,16 @@ struct Displace { guint32 a = (mappx & 0xff000000) >> 24; guint32 xpx = 0, ypx = 0; double xtex = x, ytex = y; + + guint32 xshift = _xch * 8, yshift = _ych * 8; + xpx = (mappx & (0xff << xshift)) >> xshift; + ypx = (mappx & (0xff << yshift)) >> yshift; if (a) { - guint32 xshift = _xch * 8, yshift = _ych * 8; - xpx = (mappx & (0xff << xshift)) >> xshift; - ypx = (mappx & (0xff << yshift)) >> yshift; if (_xch != 3) xpx = unpremul_alpha(xpx, a); if (_ych != 3) ypx = unpremul_alpha(ypx, a); - xtex += _scalex * (xpx - 127.5); - ytex += _scaley * (ypx - 127.5); } + xtex += _scalex * (xpx - 127.5); + ytex += _scaley * (ypx - 127.5); if (xtex >= 0 && xtex < (_texture._w - 1) && ytex >= 0 && ytex < (_texture._h - 1)) -- cgit v1.2.3 From ee17bac8a5d9b6bf840272885c1eda57c45fb4ad Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 17 Sep 2011 01:00:05 +0200 Subject: Node tool, transforming a set of nodes: Fix crashes, and finish implementation of snapping Fixed bugs: - https://launchpad.net/bugs/590261 (bzr r10633) --- src/seltrans.cpp | 3 +- src/snap.cpp | 1 + src/ui/tool/control-point-selection.cpp | 20 +++- src/ui/tool/control-point-selection.h | 3 +- src/ui/tool/manipulator.h | 1 - src/ui/tool/node.cpp | 15 +-- src/ui/tool/node.h | 1 + src/ui/tool/transform-handle-set.cpp | 170 ++++++++++++++++++++------------ 8 files changed, 139 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 20013ab0c..c6dd0a34d 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1221,9 +1221,8 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P if (sn.getSnapped()) { // We snapped something, so change the skew to reflect it - Geom::Coord const sd = sn.getSnapped() ? sn.getTransformation()[0] : Geom::infinity(); + skew[dim_a] = sn.getTransformation()[0]; _desktop->snapindicator->set_new_snaptarget(sn); - skew[dim_a] = sd; } else { _desktop->snapindicator->remove_snaptarget(); } diff --git a/src/snap.cpp b/src/snap.cpp index 5f65b643d..ac2abd63b 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -411,6 +411,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint result = findBestSnap(p, isr, true); + if (result.getSnapped()) { // only change the snap indicator if we really snapped to something if (_snapindicator && _desktop) { diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 13da4a712..fbcb337a5 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -16,6 +16,7 @@ #include "ui/tool/event-utils.h" #include "ui/tool/selectable-control-point.h" #include "ui/tool/transform-handle-set.h" +#include "ui/tool/node.h" namespace Inkscape { namespace UI { @@ -642,13 +643,24 @@ bool ControlPointSelection::event(GdkEvent *event) return false; } -std::vector ControlPointSelection::getOriginalPoints() +void ControlPointSelection::getOriginalPoints(std::vector &pts) { - std::vector points; + pts.clear(); for (iterator i = _points.begin(); i != _points.end(); ++i) { - points.push_back(Inkscape::SnapCandidatePoint(_original_positions[*i], SNAPSOURCE_NODE_HANDLE)); + pts.push_back(Inkscape::SnapCandidatePoint(_original_positions[*i], SNAPSOURCE_NODE_HANDLE)); + } +} + +void ControlPointSelection::getUnselectedPoints(std::vector &pts) +{ + pts.clear(); + ControlPointSelection::Set &nodes = this->allPoints(); + for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + if (!(*i)->selected()) { + Node *n = static_cast(*i); + pts.push_back(n->snapCandidatePoint()); + } } - return points; } void ControlPointSelection::setOriginalPoints() diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index 7e09d50f5..67bd07644 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -111,7 +111,8 @@ public: sigc::signal signal_point_changed; sigc::signal signal_commit; - std::vector getOriginalPoints(); + void getOriginalPoints(std::vector &pts); + void getUnselectedPoints(std::vector &pts); void setOriginalPoints(); private: diff --git a/src/ui/tool/manipulator.h b/src/ui/tool/manipulator.h index 6866ec9dd..474ccd8f3 100644 --- a/src/ui/tool/manipulator.h +++ b/src/ui/tool/manipulator.h @@ -40,7 +40,6 @@ public: /// Handle input event. Returns true if handled. virtual bool event(GdkEvent *)=0; -protected: SPDesktop *const _desktop; }; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8e3da266b..e254fb9b2 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -307,12 +307,10 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) std::vector unselected; if (snap) { - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); + for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); - Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); - unselected.push_back(p); + unselected.push_back(n->snapCandidatePoint()); } sm.setupIgnoreSelection(_desktop, true, &unselected); @@ -326,7 +324,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } else if (ctrl_constraint) { // NOTE: this is subtly wrong. // We should get all possible constraints and snap along them using - // multipleConstrainedSnaps, instead of first snapping to angle and the to objects + // multipleConstrainedSnaps, instead of first snapping to angle and then to objects Inkscape::SnappedPoint p; p = sm.constrainedSnap(Inkscape::SnapCandidatePoint(new_pos, SNAPSOURCE_NODE_HANDLE), *ctrl_constraint); new_pos = p.getPoint(); @@ -1118,6 +1116,11 @@ Inkscape::SnapTargetType Node::_snapTargetType() return SNAPTARGET_NODE_CUSP; } +Inkscape::SnapCandidatePoint Node::snapCandidatePoint() +{ + return SnapCandidatePoint(position(), _snapSourceType(), _snapTargetType()); +} + /** @brief Gets the handle that faces the given adjacent node. * Will abort with error if the given node is not adjacent. */ Handle *Node::handleToward(Node *to) diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index b7145790b..f3416ed1c 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -151,6 +151,7 @@ public: static char const *node_type_to_localized_string(NodeType type); // temporarily public virtual bool _eventHandler(GdkEvent *event); + Inkscape::SnapCandidatePoint snapCandidatePoint(); protected: virtual void dragged(Geom::Point &, GdkEventMotion *); virtual bool grabbed(GdkEventMotion *); diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 26263c26b..58f064b9a 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -28,6 +28,8 @@ #include "ui/tool/event-utils.h" #include "ui/tool/transform-handle-set.h" #include "ui/tool/node-tool.h" +#include "ui/tool/node.h" +#include "seltrans.h" // FIXME BRAIN DAMAGE WARNING: this is a global variable in select-context.cpp // It should be moved to a header @@ -101,6 +103,7 @@ protected: Geom::Point _origin; TransformHandleSet &_th; std::vector _snap_points; + std::vector _unselected_points; private: virtual bool grabbed(GdkEventMotion *) { @@ -113,12 +116,13 @@ private: _setState(_state); // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SnapManager &m = desktop->namedview->snap_manager; - InkNodeTool *nt = INK_NODE_TOOL(_desktop->event_context); + SnapManager &m = _th._desktop->namedview->snap_manager; + InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); ControlPointSelection *selection = nt->_selected_nodes.get(); - _snap_points = selection->getOriginalPoints(); + selection->setOriginalPoints(); + selection->getOriginalPoints(_snap_points); + selection->getUnselectedPoints(_unselected_points); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/snapclosestonly/value", false)) { @@ -198,9 +202,6 @@ protected: _sc_center = _th.rotationCenter(); _sc_opposite = _th.bounds().corner(_corner + 2); _last_scale_x = _last_scale_y = 1.0; - InkNodeTool *nt = INK_NODE_TOOL(_desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); - selection->setOriginalPoints(); } virtual Geom::Affine computeTransform(Geom::Point const &new_pos, GdkEventMotion *event) { Geom::Point scc = held_shift(*event) ? _sc_center : _sc_opposite; @@ -214,30 +215,15 @@ protected: if (held_alt(*event)) { for (unsigned i = 0; i < 2; ++i) { - if (scale[i] >= 1.0) scale[i] = round(scale[i]); - else scale[i] = 1.0 / round(1.0 / scale[i]); + if (fabs(scale[i]) >= 1.0) { + scale[i] = round(scale[i]); + } else { + scale[i] = 1.0 / round(1.0 / MIN(scale[i],10)); + } } } else { - //SPDesktop *desktop = _th._desktop; // Won't work as _desktop is protected - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SnapManager &m = desktop->namedview->snap_manager; - - // The lines below have been copied from Handle::dragged() in node.cpp, and need to be - // activated if we want to snap to unselected (i.e. stationary) nodes and stationary pieces of paths of the - // path that's currently being edited - /* - std::vector unselected; - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast(*i); - Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); - unselected.push_back(p); - } - m.setupIgnoreSelection(_desktop, true, &unselected); - */ - - m.setupIgnoreSelection(_desktop); + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); Inkscape::SnappedPoint sp; if (held_control(*event)) { @@ -306,10 +292,30 @@ protected: vs[d1] = (new_pos - scc)[d1] / (_origin - scc)[d1]; if (held_alt(*event)) { - if (vs[d1] >= 1.0) vs[d1] = round(vs[d1]); - else vs[d1] = 1.0 / round(1.0 / vs[d1]); + if (fabs(vs[d1]) >= 1.0) { + vs[d1] = round(vs[d1]); + } else { + vs[d1] = 1.0 / round(1.0 / MIN(vs[d1],10)); + } + vs[d2] = 1.0; + } else { + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); + + bool uniform = held_control(*event); + Inkscape::SnappedPoint sp = m.constrainedSnapStretch(_snap_points, _origin, vs[d1], scc, d1, uniform); + m.unSetup(); + + if (sp.getSnapped()) { + Geom::Point result = sp.getTransformation(); + vs[d1] = result[d1]; + vs[d2] = result[d2]; + } else { + // on ctrl, apply uniform scaling instead of stretching + // Preserve aspect ratio, but never flip in the dimension not being edited (by using fabs()) + vs[d2] = uniform ? fabs(vs[d1]) : 1.0; + } } - vs[d2] = held_control(*event) ? vs[d1] : 1.0; _last_scale_x = vs[Geom::X]; _last_scale_y = vs[Geom::Y]; @@ -357,7 +363,17 @@ protected: double angle = Geom::angle_between(_origin - rotc, new_pos - rotc); if (held_control(*event)) { angle = snap_angle(angle); + } else { + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); + Inkscape::SnappedPoint sp = m.constrainedSnapRotate(_snap_points, _origin, angle, rotc); + m.unSetup(); + + if (sp.getSnapped()) { + angle = sp.getTransformation()[0]; + } } + _last_angle = angle; Geom::Affine t = Geom::Translate(-rotc) * Geom::Rotate(angle) @@ -428,44 +444,76 @@ protected: virtual Geom::Affine computeTransform(Geom::Point const &new_pos, GdkEventMotion *event) { Geom::Point scc = held_shift(*event) ? _skew_center : _skew_opposite; - // d1 and d2 are reversed with respect to ScaleSideHandle - Geom::Dim2 d1 = static_cast(_side % 2); - Geom::Dim2 d2 = static_cast((_side + 1) % 2); - Geom::Point proj, scale(1.0, 1.0); + Geom::Dim2 d1 = static_cast((_side + 1) % 2); + Geom::Dim2 d2 = static_cast(_side % 2); + + Geom::Point const initial_delta = _origin - scc; + + if (fabs(initial_delta[d1]) < 1e-15) { + return Geom::Affine(); + } + + // Calculate the scale factors, which can be either visual or geometric + // depending on which type of bbox is currently being used (see preferences -> selector tool) + Geom::Scale scale = calcScaleFactors(_origin, new_pos, scc, false); + Geom::Scale skew = calcScaleFactors(_origin, new_pos, scc, true); + scale[d2] = 1; + skew[d2] = 1; // Skew handles allow scaling up to integer multiples of the original size // in the second direction; prevent explosions - // TODO should the scaling part be only active with Alt? - if (!Geom::are_near(_origin[d2], scc[d2])) { - scale[d2] = (new_pos - scc)[d2] / (_origin - scc)[d2]; - } - if (scale[d2] < 1.0) { - scale[d2] = copysign(1.0, scale[d2]); + if (fabs(scale[d1]) < 1) { + // Prevent shrinking of the selected object, while allowing mirroring + scale[d1] = copysign(1.0, scale[d1]); } else { - scale[d2] = floor(scale[d2]); + // Allow expanding of the selected object by integer multiples + scale[d1] = floor(scale[d1] + 0.5); } - // Calculate skew angle. The angle is calculated with regards to the point obtained - // by projecting the handle position on the relevant side of the bounding box. - // This avoids degeneracies when moving the skew angle over the rotation center - proj[d1] = new_pos[d1]; - proj[d2] = scc[d2] + (_origin[d2] - scc[d2]) * scale[d2]; - double angle = 0; - if (!Geom::are_near(proj[d2], scc[d2])) - angle = Geom::angle_between(_origin - scc, proj - scc); - if (held_control(*event)) angle = snap_angle(angle); - - // skew matrix has the from [[1, k],[0, 1]] for horizontal skew - // and [[1,0],[k,1]] for vertical skew. - Geom::Affine skew = Geom::identity(); - // correct the sign of the tangent - skew[d2 + 1] = (d1 == Geom::X ? -1.0 : 1.0) * tan(angle); + double angle = atan(skew[d1] / scale[d1]); + + if (held_control(*event)) { + angle = snap_angle(angle); + skew[d1] = tan(angle) * scale[d1]; + } else { + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); + + Geom::Point cvec; cvec[d2] = 1.0; + Inkscape::Snapper::SnapConstraint const constraint(cvec); + Inkscape::SnappedPoint sp = m.constrainedSnapSkew(_snap_points, _origin, constraint, Geom::Point(skew[d1], scale[d1]), scc, d2); + m.unSetup(); + + if (sp.getSnapped()) { + skew[d1] = sp.getTransformation()[0]; + } + } _last_angle = angle; + + // Update the handle position + Geom::Point new_new_pos; + new_new_pos[d2] = initial_delta[d1] * skew[d1] + _origin[d2]; + new_new_pos[d1] = initial_delta[d1] * scale[d1] + scc[d1]; + + // Calculate the relative affine + Geom::Affine relative_affine = Geom::identity(); + relative_affine[2*d1 + d1] = (new_new_pos[d1] - scc[d1]) / initial_delta[d1]; + relative_affine[2*d1 + (d2)] = (new_new_pos[d2] - _origin[d2]) / initial_delta[d1]; + relative_affine[2*(d2) + (d1)] = 0; + relative_affine[2*(d2) + (d2)] = 1; + + for (int i = 0; i < 2; i++) { + if (fabs(relative_affine[3*i]) < 1e-15) { + relative_affine[3*i] = 1e-15; + } + } + Geom::Affine t = Geom::Translate(-scc) - * Geom::Scale(scale) * skew + * relative_affine * Geom::Translate(scc); + return t; } @@ -537,8 +585,8 @@ public: protected: virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event) { - SnapManager &sm = _desktop->namedview->snap_manager; - sm.setup(_desktop); + SnapManager &sm = _th._desktop->namedview->snap_manager; + sm.setup(_th._desktop); bool snap = !held_shift(*event) && sm.someSnapperMightSnap(); if (held_control(*event)) { // constrain to axes -- cgit v1.2.3 From fae52f4e67efad3387a1543c74619d7149cf505c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 17 Sep 2011 02:43:15 +0200 Subject: Make zero deviation Gaussian blur conform to the SVG specification. (bzr r10634) --- src/display/nr-filter-gaussian.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 7a65519e0..06c2d2718 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -551,11 +551,11 @@ void FilterGaussian::render_cairo(FilterSlot &slot) cairo_surface_t *in = slot.getcairo(_input); if (!in) return; - // zero deviation = transparent black as output - if (_deviation_x <= 0 || _deviation_y <= 0) { - cairo_surface_t *blank = ink_cairo_surface_create_identical(in); - slot.set(_output, blank); - cairo_surface_destroy(blank); + // zero deviation = no change in output + if (_deviation_x <= 0 && _deviation_y <= 0) { + cairo_surface_t *cp = ink_cairo_surface_copy(in); + slot.set(_output, cp); + cairo_surface_destroy(cp); return; } -- cgit v1.2.3 From f0fa8577f48a7b0ddb285764404be316855d2e83 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 17 Sep 2011 14:08:49 +0200 Subject: Make "snap page border" toggle independent of "snap paths" toggle Fixed bugs: - https://launchpad.net/bugs/850982 (bzr r10635) --- src/object-snapper.cpp | 2 +- src/snap.cpp | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index fa992a852..c5b2b7cd7 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -324,7 +324,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(IntermSnapResults &isr, // Iterate through all nodes, find out which one is the closest to this guide, and snap to it! _collectNodes(SNAPSOURCE_GUIDE, true); - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { _collectPaths(p, SNAPSOURCE_GUIDE, true); _snapPaths(isr, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); } diff --git a/src/snap.cpp b/src/snap.cpp index ac2abd63b..631704b5c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1167,11 +1167,9 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } // search for the closest snapped curve - if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH)) { // We might have been looking for path intersections only, and not for the paths themselves - Inkscape::SnappedCurve closestCurve; - if (getClosestCurve(isr.curves, closestCurve)) { - sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); - } + Inkscape::SnappedCurve closestCurve; + if (getClosestCurve(isr.curves, closestCurve)) { + sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); } if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { -- cgit v1.2.3 From 28c7f080499e7c52d03dc7c6fb0f6ad363990f66 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 17 Sep 2011 15:55:11 +0200 Subject: Do not apply the fix of rev. #10624 to all types of items (bzr r10636) --- src/sp-item.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9e03631f5..3ec5f249b 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1283,6 +1283,9 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra // (as reported in https://bugs.launchpad.net/inkscape/+bug/825840/comments/4) if (!prefs->getBool("/options/transform/stroke", true)) { freeze_stroke_width_recursive(true); + // This will only work if the item has a set_transform method (in this method adjust_stroke() will be called) + // We will still have to apply the inverse scaling to other items, not having a set_transform method + // such as ellipses and stars } // recursively compensate rx/ry of a rect if requested @@ -1313,18 +1316,24 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra !preserve && // user did not chose to preserve all transforms !clip_ref->getObject() && // the object does not have a clippath !mask_ref->getObject() && // the object does not have a mask - !(!transform.isTranslation() && style && style->getFilter()) - // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) + !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform); + freeze_stroke_width_recursive(false); + } else { + freeze_stroke_width_recursive(false); + if (compensate) { + if (!prefs->getBool("/options/transform/stroke", true)) { + // Recursively compensate for stroke scaling, depending on user preference + // (As to why we need to do this, see the comment a few lines above near the freeze_stroke_width_recursive(true) call) + double const expansion = 1. / advertized_transform.descrim(); + adjust_stroke_width_recursive(expansion); + } + } } set_item_transform(transform_attr); - if (compensate) { - if (!prefs->getBool("/options/transform/stroke", true)) { - freeze_stroke_width_recursive(false); - } - } + // Note: updateRepr comes before emitting the transformed signal since // it causes clone SPUse's copy of the original object to brought up to -- cgit v1.2.3 From b0cc18df9b5675cbf875e54c9af6bd5848ccb1c5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 18 Sep 2011 03:05:53 +0200 Subject: Fix crash when previewing objectBoundingBox gradients (bzr r10637) --- src/sp-gradient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 94ad0bb25..b42768f30 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1522,7 +1522,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, // set pattern matrix Geom::Affine gs2user = gr->gradientTransform; - if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { + if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX && bbox) { Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top()); gs2user *= bbox2user; } -- cgit v1.2.3 From 344d9e8077c05b86e7d423b5db163b3e3e541032 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 18 Sep 2011 19:09:29 +0200 Subject: Snap to guide-path intersections, and don't snap to paths when only path intersections are asked for Fixed bugs: - https://launchpad.net/bugs/847457 - https://launchpad.net/bugs/850982 (bzr r10639) --- src/display/snap-indicator.cpp | 3 ++ src/snap-enums.h | 1 + src/snap-preferences.cpp | 2 + src/snap.cpp | 32 ++++++++++----- src/snapped-curve.cpp | 93 +++++++++++++++++++++++++++++++++++++++++- src/snapped-curve.h | 5 ++- 6 files changed, 123 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 5b2314d51..0f31a24b9 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -102,6 +102,9 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_PATH_INTERSECTION: target_name = _("path intersection"); break; + case SNAPTARGET_PATH_GUIDE_INTERSECTION: + target_name = _("guide-path intersection"); + break; case SNAPTARGET_BBOX_CORNER: target_name = _("bounding box corner"); break; diff --git a/src/snap-enums.h b/src/snap-enums.h index 8a95bb2dd..5ade54354 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -69,6 +69,7 @@ enum SnapTargetType { SNAPTARGET_LINE_MIDPOINT, SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, + SNAPTARGET_PATH_GUIDE_INTERSECTION, SNAPTARGET_ELLIPSE_QUADRANT_POINT, // this corner is at the center of the stroke SNAPTARGET_RECT_CORNER, // of a rectangle, so this corner is at the center of the stroke //------------------------------------------------------------------- diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index fa5903c37..25e00718c 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -147,6 +147,8 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType target = SNAPTARGET_NODE_CUSP; } else if (target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { target = SNAPTARGET_NODE_SMOOTH; + } else if (target == SNAPTARGET_PATH_GUIDE_INTERSECTION) { + target = SNAPTARGET_PATH_INTERSECTION; } diff --git a/src/snap.cpp b/src/snap.cpp index 631704b5c..eeca66d74 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1168,19 +1168,13 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // search for the closest snapped curve Inkscape::SnappedCurve closestCurve; - if (getClosestCurve(isr.curves, closestCurve)) { + // We might have collected the paths only to snap to their intersection, without the intention to snap to the paths themselves + // Therefore we explicitly check whether the paths should be considered as snap targets themselves + bool exclude_paths = !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH); + if (getClosestCurve(isr.curves, closestCurve, exclude_paths)) { sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); } - if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { - // search for the closest snapped intersection of curves - Inkscape::SnappedPoint closestCurvesIntersection; - if (getClosestIntersectionCS(isr.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { - closestCurvesIntersection.setSource(p.getSourceType()); - sp_list.push_back(closestCurvesIntersection); - } - } - // search for the closest snapped grid line Inkscape::SnappedLine closestGridLine; if (getClosestSL(isr.grid_lines, closestGridLine)) { @@ -1200,6 +1194,24 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co // the grid/guide/path we're snapping to. This snappoint is therefore fully constrained, so there's // no need to look for additional intersections if (!constrained) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { + // search for the closest snapped intersection of curves + Inkscape::SnappedPoint closestCurvesIntersection; + if (getClosestIntersectionCS(isr.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { + closestCurvesIntersection.setSource(p.getSourceType()); + sp_list.push_back(closestCurvesIntersection); + } + } + + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_GUIDE_INTERSECTION)) { + // search for the closest snapped intersection of a guide with a curve + Inkscape::SnappedPoint closestCurveGuideIntersection; + if (getClosestIntersectionCL(isr.curves, isr.guide_lines, p.getPoint(), closestCurveGuideIntersection, _desktop->dt2doc())) { + closestCurveGuideIntersection.setSource(p.getSourceType()); + sp_list.push_back(closestCurveGuideIntersection); + } + } + // search for the closest snapped intersection of grid lines Inkscape::SnappedPoint closestGridPoint; if (getClosestIntersectionSL(isr.grid_lines, closestGridPoint)) { diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index 4876b896d..25b03428a 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -61,7 +61,7 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur // Calculate the intersections of two curves, which are both within snapping range, and // return only the closest intersection // The point of intersection should be considered for snapping, but might be outside the snapping range - // PS: We need p (the location of the mouse pointer) for find out which intersection is the + // PS: We need p (the location of the mouse pointer) to find out which intersection is the // closest, as there might be multiple intersections of two curves Geom::Crossings cs = crossings(*(this->_curve), *(curve._curve)); @@ -109,12 +109,67 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur return SnappedPoint(Geom::Point(Geom::infinity(), Geom::infinity()), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false, false, Geom::infinity(), 0, false); } +Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedLine const &line, Geom::Point const &p, Geom::Affine dt2doc) const +{ + // Calculate the intersections of a curve with a line, which are both within snapping range, and + // return only the closest intersection + // The point of intersection should be considered for snapping, but might be outside the snapping range + // PS: We need p (the location of the mouse pointer) to find out which intersection is the + // closest, as there might be multiple intersections of a single curve with a line + + // 1) get a Geom::Line object from the SnappedLine + // 2) convert to document coordinates (line and p are in desktop coordinates, but the curves are in document coordinate) + // 3) create a Geom::LineSegment (i.e. a curve), because we cannot use a Geom::Line for calculating intersections + // (for this we will create a 2e6 pixels long linesegment, with t running from -1e6 to 1e6; this should be long + // enough for any practical purpose) + Geom::LineSegment line_segm = line.getLine().transformed(dt2doc).segment(-1e6, 1e6); // + Geom::Curve *line_as_curve = dynamic_cast(&line_segm); + Geom::Crossings cs = crossings(*(this->_curve), *line_as_curve); + + if (cs.size() > 0) { + // There might be multiple intersections: find the closest + Geom::Coord best_dist = Geom::infinity(); + Geom::Point best_p = Geom::Point(Geom::infinity(), Geom::infinity()); + for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { + Geom::Point p_ix = this->_curve->pointAt((*i).ta); + Geom::Coord dist = Geom::distance(p_ix, p); + + if (dist < best_dist) { + best_dist = dist; + best_p = p_ix; + } + } + + // The intersection should in fact be returned in desktop coordinates + best_p = best_p * dt2doc; + + // Now we've found the closest intersection, return it as a SnappedPoint + if (_distance < line.getSnapDistance()) { + // curve is the closest, so this is our primary snap target + return SnappedPoint(best_p, Inkscape::SNAPSOURCE_UNDEFINED, this->getSourceNum(), Inkscape::SNAPTARGET_PATH_GUIDE_INTERSECTION, + Geom::L2(best_p - this->getPoint()), this->getTolerance(), this->getAlwaysSnap(), true, false, true, + Geom::L2(best_p - line.getPoint()), line.getTolerance(), line.getAlwaysSnap()); + } else { + return SnappedPoint(best_p, Inkscape::SNAPSOURCE_UNDEFINED, line.getSourceNum(), Inkscape::SNAPTARGET_PATH_GUIDE_INTERSECTION, + Geom::L2(best_p - line.getPoint()), line.getTolerance(), line.getAlwaysSnap(), true, false, true, + Geom::L2(best_p - this->getPoint()), this->getTolerance(), this->getAlwaysSnap()); + } + } + + // No intersection + return SnappedPoint(Geom::Point(Geom::infinity(), Geom::infinity()), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, Geom::infinity(), 0, false, false, false, false, Geom::infinity(), 0, false); +} + + // search for the closest snapped line -bool getClosestCurve(std::list const &list, Inkscape::SnappedCurve &result) +bool getClosestCurve(std::list const &list, Inkscape::SnappedCurve &result, bool exclude_paths) { bool success = false; for (std::list::const_iterator i = list.begin(); i != list.end(); i++) { + if (exclude_paths && ((*i).getTarget() == Inkscape::SNAPTARGET_PATH)) { + continue; + } if ((i == list.begin()) || (*i).getSnapDistance() < result.getSnapDistance()) { result = *i; success = true; @@ -158,6 +213,40 @@ bool getClosestIntersectionCS(std::list const &list, Geo return success; } + +// search for the closest intersection of two snapped curves, which are member of two different collections +bool getClosestIntersectionCL(std::list const &curve_list, std::list const &line_list, Geom::Point const &p, Inkscape::SnappedPoint &result, Geom::Affine dt2doc) +{ + bool success = false; + + for (std::list::const_iterator i = curve_list.begin(); i != curve_list.end(); i++) { + if ((*i).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes, + // as this would require two bboxes two be flashed in the snap indicator + for (std::list::const_iterator j = line_list.begin(); j != line_list.end(); j++) { + if ((*j).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes + Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc); + if (sp.getAtIntersection()) { + // if it's the first point + bool const c1 = !success; + // or, if it's closer + bool const c2 = sp.getSnapDistance() < result.getSnapDistance(); + // or, if it's just as close then look at the other distance + // (only relevant for snapped points which are at an intersection) + bool const c3 = (sp.getSnapDistance() == result.getSnapDistance()) && (sp.getSecondSnapDistance() < result.getSecondSnapDistance()); + // then prefer this point over the previous one + if (c1 || c2 || c3) { + result = sp; + success = true; + } + } + } + } + } + } + + return success; +} + /* Local Variables: mode:c++ diff --git a/src/snapped-curve.h b/src/snapped-curve.h index ed04576df..8b1080dc4 100644 --- a/src/snapped-curve.h +++ b/src/snapped-curve.h @@ -14,6 +14,7 @@ #include #include #include "snapped-point.h" +#include "snapped-line.h" #include <2geom/forward.h> namespace Inkscape @@ -27,6 +28,7 @@ public: SnappedCurve(Geom::Point const &snapped_point, int num_path, int num_segm, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve, SnapSourceType source, long source_num, SnapTargetType target, Geom::OptRect target_bbox); ~SnappedCurve(); Inkscape::SnappedPoint intersect(SnappedCurve const &curve, Geom::Point const &p, Geom::Affine dt2doc) const; //intersect with another SnappedCurve + Inkscape::SnappedPoint intersect(SnappedLine const &line, Geom::Point const &p, Geom::Affine dt2doc) const; //intersect with a SnappedLine private: Geom::Curve const *_curve; @@ -36,8 +38,9 @@ private: } -bool getClosestCurve(std::list const &list, Inkscape::SnappedCurve &result); +bool getClosestCurve(std::list const &list, Inkscape::SnappedCurve &result, bool exclude_paths = false); bool getClosestIntersectionCS(std::list const &list, Geom::Point const &p, Inkscape::SnappedPoint &result, Geom::Affine dt2doc); +bool getClosestIntersectionCL(std::list const &list1, std::list const &list2, Geom::Point const &p, Inkscape::SnappedPoint &result, Geom::Affine dt2doc); #endif /* !SEEN_SNAPPEDCURVE_H */ -- cgit v1.2.3 From c3dc05e9ba3ce3199bc839304626f3914fc81a69 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches Date: Mon, 19 Sep 2011 14:50:42 -0300 Subject: removing useless messages to stdout. (bzr r10640) --- src/extension/dbus/document-interface.cpp | 1 - src/select-context.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'src') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 5a2b18b8f..da6b4fe36 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -1444,7 +1444,6 @@ gboolean dbus_send_ping (SPDesktop* desk, SPItem *item) { //DocumentInterface *obj; g_signal_emit (desk->dbus_document_interface, signals[OBJECT_MOVED_SIGNAL], 0, item->getId()); - g_print("Ping!\n"); return TRUE; } diff --git a/src/select-context.cpp b/src/select-context.cpp index ca0ed2438..99ad35124 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -627,7 +627,6 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) seltrans->ungrab(); sc->moved = FALSE; #ifdef WITH_DBUS - g_print("moved!\n");//JAVE dbus_send_ping(desktop, sc->item); #endif } else if (sc->item && !drag_escaped) { -- cgit v1.2.3 From 252094d328e8b33beb475a090f12b7d24ca18ff1 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 21 Sep 2011 22:49:46 +0200 Subject: LPE Powerstroke: add similar line end caps as Synfig. (and fix round caps bug) (bzr r10641) --- src/live_effects/lpe-powerstroke.cpp | 171 ++++++++++++++++++++++++++--------- src/live_effects/lpe-powerstroke.h | 4 +- 2 files changed, 132 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index cd692f402..e622ea976 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -278,22 +278,38 @@ static const Util::EnumDataConverter InterpolatorTypeConverter(Interpo enum LineCapType { LINECAP_BUTT, + LINECAP_SQUARE, LINECAP_ROUND, - LINECAP_SHARP + LINECAP_PEAK }; static const Util::EnumData LineCapTypeData[] = { - {LINECAP_BUTT , N_("Butt"), "Butt"}, - {LINECAP_ROUND , N_("Round"), "Round"}, - {LINECAP_SHARP , N_("Sharp"), "Sharp"} + {LINECAP_BUTT , N_("Butt"), "butt"}, + {LINECAP_SQUARE, N_("Square"), "square"}, + {LINECAP_ROUND , N_("Round"), "round"}, + {LINECAP_PEAK , N_("Peak"), "peak"} }; static const Util::EnumDataConverter LineCapTypeConverter(LineCapTypeData, sizeof(LineCapTypeData)/sizeof(*LineCapTypeData)); +enum LineCuspType { + LINECUSP_BEVEL, + LINECUSP_ROUND, + LINECUSP_SHARP +}; +static const Util::EnumData LineCuspTypeData[] = { + {LINECUSP_BEVEL , N_("Beveled"), "bevel"}, + {LINECUSP_ROUND , N_("Rounded"), "round"}, + {LINECUSP_SHARP , N_("Sharp"), "sharp"} +}; +static const Util::EnumDataConverter LineCuspTypeConverter(LineCuspTypeData, sizeof(LineCuspTypeData)/sizeof(*LineCuspTypeData)); + LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true), interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), - linecap_type(_("Line cap type"), _("Determines the shape of the path ends."), "linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) + start_linecap_type(_("Start line cap type"), _("Determines the shape of the path's start."), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), + cusp_linecap_type(_("Cusp line cap type"), _("Determines the shape of the cusps along the path."), "cusp_linecap_type", LineCuspTypeConverter, &wr, this, LINECUSP_ROUND), + end_linecap_type(_("End line cap type"), _("Determines the shape of the path's end."), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) { show_orig_path = true; @@ -302,7 +318,9 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&offset_points) ); registerParameter( dynamic_cast(&sort_points) ); registerParameter( dynamic_cast(&interpolator_type) ); - registerParameter( dynamic_cast(&linecap_type) ); + registerParameter( dynamic_cast(&start_linecap_type) ); + //registerParameter( dynamic_cast(&cusp_linecap_type) ); + registerParameter( dynamic_cast(&end_linecap_type) ); } LPEPowerStroke::~LPEPowerStroke() @@ -347,7 +365,8 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & Piecewise > output; if (!closed_path) { - LineCapType linecap = static_cast(linecap_type.get_value()); + LineCapType start_linecap = static_cast(start_linecap_type.get_value()); + LineCapType end_linecap = static_cast(end_linecap_type.get_value()); // perhaps use std::list instead of std::vector? std::vector ts(offset_points.data().size() + 2); @@ -357,17 +376,34 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & if (sort_points) { sort(ts.begin()+1, ts.end()-1, compare_offsets); } - switch (linecap) { + + switch (start_linecap) { + /* case LINECAP_SHARP: // first and last point coincide with input path to make sharp points on ends ts.front() = Point(pwd2_in.domain().min(),0); - ts.back() = Point(pwd2_in.domain().max(),0); break; + */ + case LINECAP_PEAK: + case LINECAP_SQUARE: case LINECAP_BUTT: case LINECAP_ROUND: default: // first and last point have same distance from path as second and second to last points, respectively. ts.front() = Point(pwd2_in.domain().min(), (*(ts.begin()+1))[Geom::Y] ); + break; + } + switch (end_linecap) { + /* + case LINECAP_SHARP: + ts.back() = Point(pwd2_in.domain().max(),0); + break; + */ + case LINECAP_PEAK: + case LINECAP_SQUARE: + case LINECAP_BUTT: + case LINECAP_ROUND: + default: ts.back() = Point(pwd2_in.domain().max(), (*(ts.end()-2))[Geom::Y] ); break; } @@ -377,55 +413,106 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & Geom::Path strokepath = interpolator->interpolateToPath(ts); delete interpolator; - switch (linecap) { - case LINECAP_SHARP: - case LINECAP_BUTT: - { - Geom::Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); - strokepath.append(mirroredpath, Geom::Path::STITCH_DISCONTINUOUS); - strokepath.close(); + D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); + Piecewise x = Piecewise(patternd2[0]); + Piecewise y = Piecewise(patternd2[1]); - D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); - Piecewise x = Piecewise(patternd2[0]); - Piecewise y = Piecewise(patternd2[1]); + // find time values for which x lies outside path domain + // and only take portion of x and y that lies within those time values + std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); + std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); + if ( !rtsmin.empty() && !rtsmax.empty() ) { + x = portion(x, rtsmin.at(0), rtsmax.at(0)); + y = portion(y, rtsmin.at(0), rtsmax.at(0)); + } + + output = compose(pwd2_in,x) + y*compose(n,x); + x = reverse(x); + y = reverse(y); + Piecewise > mirrorpath = compose(pwd2_in,x) - y*compose(n,x); - output = compose(pwd2_in,x) + y*compose(n,x); + switch (end_linecap) { + case LINECAP_PEAK: + { + Geom::Point end_deriv = der.lastValue(); + double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); + Geom::Point midpoint = 0.5*(output.lastValue() + mirrorpath.firstValue()) + radius*end_deriv; + Geom::LineSegment cap11(output.lastValue(), midpoint); + Geom::LineSegment cap12(midpoint, mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap11.toSBasis())); + output.continuousConcat(Piecewise >(cap12.toSBasis())); + break; + } + case LINECAP_SQUARE: + { + Geom::Point end_deriv = der.lastValue(); + double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); + Geom::LineSegment cap11(output.lastValue(), output.lastValue() + radius*end_deriv); + Geom::LineSegment cap12(output.lastValue() + radius*end_deriv, mirrorpath.firstValue() + radius*end_deriv); + Geom::LineSegment cap13(mirrorpath.firstValue() + radius*end_deriv, mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap11.toSBasis())); + output.continuousConcat(Piecewise >(cap12.toSBasis())); + output.continuousConcat(Piecewise >(cap13.toSBasis())); + break; + } + case LINECAP_BUTT: + { + Geom::LineSegment cap1(output.lastValue(), mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap1.toSBasis())); break; } case LINECAP_ROUND: default: { - D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); - Piecewise x = Piecewise(patternd2[0]); - Piecewise y = Piecewise(patternd2[1]); - - // find time values for which x lies outside path domain - // and only take portion of x and y that lies within those time values - std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); - std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); - if ( !rtsmin.empty() && !rtsmax.empty() ) { - x = portion(x, rtsmin.at(0), rtsmax.at(0)); - y = portion(y, rtsmin.at(0), rtsmax.at(0)); - } - - output = compose(pwd2_in,x) + y*compose(n,x); - x = reverse(x); - y = reverse(y); - Piecewise > mirrorpath = compose(pwd2_in,x) - y*compose(n,x); - double radius1 = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::SVGEllipticalArc cap1(output.lastValue(), radius1, radius1, M_PI/2., false, false, mirrorpath.firstValue()); + Geom::SVGEllipticalArc cap1(output.lastValue(), radius1, radius1, M_PI/2., false, y.firstValue() < 0, mirrorpath.firstValue()); // note that y is reversed above! output.continuousConcat(Piecewise >(cap1.toSBasis())); + break; + } + } - output.continuousConcat(mirrorpath); + output.continuousConcat(mirrorpath); + switch (start_linecap) { + case LINECAP_PEAK: + { + Geom::Point start_deriv = der.firstValue(); + double radius = 0.5 * distance(output.firstValue(), output.lastValue()); + Geom::Point midpoint = 0.5*(output.lastValue() + output.firstValue()) - radius*start_deriv; + Geom::LineSegment cap21(output.lastValue(), midpoint); + Geom::LineSegment cap22(midpoint, output.firstValue()); + output.continuousConcat(Piecewise >(cap21.toSBasis())); + output.continuousConcat(Piecewise >(cap22.toSBasis())); + break; + } + case LINECAP_SQUARE: + { + Geom::Point start_deriv = der.firstValue(); + double radius = 0.5 * distance(output.firstValue(), output.lastValue()); + Geom::LineSegment cap21(output.lastValue(), output.lastValue() - radius*start_deriv); + Geom::LineSegment cap22(output.lastValue() - radius*start_deriv, output.firstValue() - radius*start_deriv); + Geom::LineSegment cap23(output.firstValue() - radius*start_deriv, output.firstValue()); + output.continuousConcat(Piecewise >(cap21.toSBasis())); + output.continuousConcat(Piecewise >(cap22.toSBasis())); + output.continuousConcat(Piecewise >(cap23.toSBasis())); + break; + } + case LINECAP_BUTT: + { + Geom::LineSegment cap2(output.lastValue(), output.firstValue()); + output.continuousConcat(Piecewise >(cap2.toSBasis())); + break; + } + case LINECAP_ROUND: + default: + { double radius2 = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::SVGEllipticalArc cap2(output.lastValue(), radius2, radius2, M_PI/2., false, false, output.firstValue()); + Geom::SVGEllipticalArc cap2(output.lastValue(), radius2, radius2, M_PI/2., false, y.lastValue() < 0, output.firstValue()); // note that y is reversed above! output.continuousConcat(Piecewise >(cap2.toSBasis())); - break; } } + } else { // path is closed // linecap parameter can be ignored diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 6f34e16e2..725c6c4cd 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -33,7 +33,9 @@ private: PowerStrokePointArrayParam offset_points; BoolParam sort_points; EnumParam interpolator_type; - EnumParam linecap_type; + EnumParam start_linecap_type; + EnumParam cusp_linecap_type; + EnumParam end_linecap_type; LPEPowerStroke(const LPEPowerStroke&); LPEPowerStroke& operator=(const LPEPowerStroke&); -- cgit v1.2.3 From 7c1dbf4ef5d42a5f90e3f0d1ed247b37c3522c6b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Sep 2011 17:49:12 +1000 Subject: fix for cmake linking (bzr r10642) --- src/CMakeLists.txt | 6 +++--- src/display/CMakeLists.txt | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce289f33c..57d935275 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -574,11 +574,11 @@ add_dependencies(inkscape inkscape_version) target_link_libraries(inkscape # order from automake sp_LIB + nrtype_LIB + inkscape_LIB sp_LIB # annoying, we need both! - - nr_LIB - nrtype_LIB + nrtype_LIB # annoying, we need both! dom_LIB croco_LIB diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index e78ddd59f..68006eb75 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -9,16 +9,18 @@ set(display_SRC canvas-temporary-item.cpp canvas-text.cpp curve.cpp + drawing-context.cpp + drawing-group.cpp + drawing-image.cpp + drawing-item.cpp + drawing-shape.cpp + drawing-surface.cpp + drawing-text.cpp + drawing.cpp gnome-canvas-acetate.cpp grayscale.cpp guideline.cpp nr-3dutils.cpp - nr-arena-glyphs.cpp - nr-arena-group.cpp - nr-arena-image.cpp - nr-arena-item.cpp - nr-arena-shape.cpp - nr-arena.cpp nr-filter-blend.cpp nr-filter-colormatrix.cpp nr-filter-component-transfer.cpp @@ -69,17 +71,18 @@ set(display_SRC curve-test.h curve.h display-forward.h + drawing-context.h + drawing-group.h + drawing-image.h + drawing-item.h + drawing-shape.h + drawing-surface.h + drawing-text.h + drawing.h gnome-canvas-acetate.h grayscale.h guideline.h nr-3dutils.h - nr-arena-forward.h - nr-arena-glyphs.h - nr-arena-group.h - nr-arena-image.h - nr-arena-item.h - nr-arena-shape.h - nr-arena.h nr-filter-blend.h nr-filter-colormatrix.h nr-filter-component-transfer.h -- cgit v1.2.3 From 2efaee4cee14b42915dc02aebf79a44bc8aecac3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Sep 2011 18:31:39 +1000 Subject: initialize value as const (clang complains about this) (bzr r10643) --- src/snapped-curve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index 25b03428a..9cb547609 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -123,7 +123,7 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedLine const &line // (for this we will create a 2e6 pixels long linesegment, with t running from -1e6 to 1e6; this should be long // enough for any practical purpose) Geom::LineSegment line_segm = line.getLine().transformed(dt2doc).segment(-1e6, 1e6); // - Geom::Curve *line_as_curve = dynamic_cast(&line_segm); + const Geom::Curve *line_as_curve = dynamic_cast(&line_segm); Geom::Crossings cs = crossings(*(this->_curve), *line_as_curve); if (cs.size() > 0) { -- cgit v1.2.3 From 6b918e1acc9da4a47a0141fef91d60af8e27315a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 22 Sep 2011 23:03:37 +0200 Subject: partial 2geom update, powerstroke wants it (bzr r10644) --- src/2geom/sbasis-to-bezier.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/sbasis-to-bezier.h b/src/2geom/sbasis-to-bezier.h index 819aa87d6..b386bd520 100644 --- a/src/2geom/sbasis-to-bezier.h +++ b/src/2geom/sbasis-to-bezier.h @@ -42,11 +42,13 @@ namespace Geom { +class PathBuilder; + void sbasis_to_bezier (Bezier & bz, SBasis const& sb, size_t sz = 0); void sbasis_to_bezier (std::vector & bz, D2 const& sb, size_t sz = 0); void bezier_to_sbasis (SBasis & sb, Bezier const& bz); void bezier_to_sbasis (D2 & sb, std::vector const& bz); - +void build_from_sbasis(PathBuilder &pb, D2 const &B, double tol, bool only_cubicbeziers); #if 0 // this produces a degree k bezier from a degree k sbasis -- cgit v1.2.3 From afeffc3d8531543a5a2c9d949f100456d518bd59 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 22 Sep 2011 23:12:59 +0200 Subject: restructure powerstroke LPE a bit in preparation for cusp fixup (bzr r10645) --- src/live_effects/lpe-powerstroke.cpp | 425 ++++++++++++++++++++--------------- src/live_effects/lpe-powerstroke.h | 12 +- 2 files changed, 253 insertions(+), 184 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index e622ea976..8884e8b21 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -21,7 +21,10 @@ #include <2geom/transforms.h> #include <2geom/bezier-utils.h> #include <2geom/svg-elliptical-arc.h> +#include <2geom/sbasis-to-bezier.h> +#include <2geom/svg-path.h> +// for the spiro interpolator: #include "live_effects/bezctx.h" #include "live_effects/bezctx_intf.h" #include "live_effects/spiro.h" @@ -319,7 +322,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&sort_points) ); registerParameter( dynamic_cast(&interpolator_type) ); registerParameter( dynamic_cast(&start_linecap_type) ); - //registerParameter( dynamic_cast(&cusp_linecap_type) ); + registerParameter( dynamic_cast(&cusp_linecap_type) ); registerParameter( dynamic_cast(&end_linecap_type) ); } @@ -345,212 +348,268 @@ static bool compare_offsets (Geom::Point first, Geom::Point second) return first[Geom::X] < second[Geom::X]; } + // find discontinuities in piecewise +std::vector find_discontinuities(Geom::Piecewise > const & pwd2_in, double eps=Geom::EPSILON) +{ + std::vector indices; + for(unsigned i = 1; i < pwd2_in.size(); i++) { + if ( ! are_near(pwd2_in[i-1].at1(), pwd2_in[i].at0(), eps) ) { + indices.push_back(i); + } + } + return indices; +} Geom::Piecewise > -LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in) +LPEPowerStroke::doEffect_pwd2_open ( Geom::Piecewise > const & pwd2_in, + Geom::Piecewise > const & der, + Geom::Piecewise > const & n ) { using namespace Geom; - offset_points.set_pwd2(pwd2_in); + Piecewise > output; + + LineCapType start_linecap = static_cast(start_linecap_type.get_value()); + LineCapType end_linecap = static_cast(end_linecap_type.get_value()); - Piecewise > der = unitVector(derivative(pwd2_in)); - Piecewise > n = rot90(der); - offset_points.set_pwd2_normal(n); + // perhaps use std::list instead of std::vector? + std::vector ts(offset_points.data().size() + 2); + for (unsigned int i = 0; i < offset_points.data().size(); ++i) { + ts.at(i+1) = offset_points.data().at(i); + } + if (sort_points) { + sort(ts.begin()+1, ts.end()-1, compare_offsets); + } - // see if we should treat the path as being closed. - bool closed_path = false; - if ( are_near(pwd2_in.firstValue(), pwd2_in.lastValue()) ) { - closed_path = true; + // first and last point have same distance from path as second and second to last points, respectively. + ts.front() = Point(pwd2_in.domain().min(), (*(ts.begin()+1))[Geom::Y] ); + ts.back() = Point(pwd2_in.domain().max(), (*(ts.end()-2))[Geom::Y] ); + + // create stroke path where points (x,y) := (t, offset) + Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); + Geom::Path strokepath = interpolator->interpolateToPath(ts); + delete interpolator; + + D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); + Piecewise x = Piecewise(patternd2[0]); + Piecewise y = Piecewise(patternd2[1]); + + // find time values for which x lies outside path domain + // and only take portion of x and y that lies within those time values + std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); + std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); + if ( !rtsmin.empty() && !rtsmax.empty() ) { + x = portion(x, rtsmin.at(0), rtsmax.at(0)); + y = portion(y, rtsmin.at(0), rtsmax.at(0)); } - Piecewise > output; - if (!closed_path) { - LineCapType start_linecap = static_cast(start_linecap_type.get_value()); - LineCapType end_linecap = static_cast(end_linecap_type.get_value()); - - // perhaps use std::list instead of std::vector? - std::vector ts(offset_points.data().size() + 2); - for (unsigned int i = 0; i < offset_points.data().size(); ++i) { - ts.at(i+1) = offset_points.data().at(i); + output = compose(pwd2_in,x) + y*compose(n,x); + + x = reverse(x); + y = reverse(y); + Piecewise > mirrorpath = compose(pwd2_in,x) - y*compose(n,x); + + switch (end_linecap) { + case LINECAP_PEAK: + { + Geom::Point end_deriv = der.lastValue(); + double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); + Geom::Point midpoint = 0.5*(output.lastValue() + mirrorpath.firstValue()) + radius*end_deriv; + Geom::LineSegment cap11(output.lastValue(), midpoint); + Geom::LineSegment cap12(midpoint, mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap11.toSBasis())); + output.continuousConcat(Piecewise >(cap12.toSBasis())); + break; } - if (sort_points) { - sort(ts.begin()+1, ts.end()-1, compare_offsets); + case LINECAP_SQUARE: + { + Geom::Point end_deriv = der.lastValue(); + double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); + Geom::LineSegment cap11(output.lastValue(), output.lastValue() + radius*end_deriv); + Geom::LineSegment cap12(output.lastValue() + radius*end_deriv, mirrorpath.firstValue() + radius*end_deriv); + Geom::LineSegment cap13(mirrorpath.firstValue() + radius*end_deriv, mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap11.toSBasis())); + output.continuousConcat(Piecewise >(cap12.toSBasis())); + output.continuousConcat(Piecewise >(cap13.toSBasis())); + break; } - - switch (start_linecap) { - /* - case LINECAP_SHARP: - // first and last point coincide with input path to make sharp points on ends - ts.front() = Point(pwd2_in.domain().min(),0); - break; - */ - case LINECAP_PEAK: - case LINECAP_SQUARE: - case LINECAP_BUTT: - case LINECAP_ROUND: - default: - // first and last point have same distance from path as second and second to last points, respectively. - ts.front() = Point(pwd2_in.domain().min(), (*(ts.begin()+1))[Geom::Y] ); - break; + case LINECAP_BUTT: + { + Geom::LineSegment cap1(output.lastValue(), mirrorpath.firstValue()); + output.continuousConcat(Piecewise >(cap1.toSBasis())); + break; } - switch (end_linecap) { - /* - case LINECAP_SHARP: - ts.back() = Point(pwd2_in.domain().max(),0); - break; - */ - case LINECAP_PEAK: - case LINECAP_SQUARE: - case LINECAP_BUTT: - case LINECAP_ROUND: - default: - ts.back() = Point(pwd2_in.domain().max(), (*(ts.end()-2))[Geom::Y] ); - break; + case LINECAP_ROUND: + default: + { + double radius1 = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); + Geom::SVGEllipticalArc cap1(output.lastValue(), radius1, radius1, M_PI/2., false, y.firstValue() < 0, mirrorpath.firstValue()); // note that y is reversed above! + output.continuousConcat(Piecewise >(cap1.toSBasis())); + break; } + } + + output.continuousConcat(mirrorpath); - // create stroke path where points (x,y) := (t, offset) - Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); - Geom::Path strokepath = interpolator->interpolateToPath(ts); - delete interpolator; - - D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); - Piecewise x = Piecewise(patternd2[0]); - Piecewise y = Piecewise(patternd2[1]); - - // find time values for which x lies outside path domain - // and only take portion of x and y that lies within those time values - std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); - std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); - if ( !rtsmin.empty() && !rtsmax.empty() ) { - x = portion(x, rtsmin.at(0), rtsmax.at(0)); - y = portion(y, rtsmin.at(0), rtsmax.at(0)); + switch (start_linecap) { + case LINECAP_PEAK: + { + Geom::Point start_deriv = der.firstValue(); + double radius = 0.5 * distance(output.firstValue(), output.lastValue()); + Geom::Point midpoint = 0.5*(output.lastValue() + output.firstValue()) - radius*start_deriv; + Geom::LineSegment cap21(output.lastValue(), midpoint); + Geom::LineSegment cap22(midpoint, output.firstValue()); + output.continuousConcat(Piecewise >(cap21.toSBasis())); + output.continuousConcat(Piecewise >(cap22.toSBasis())); + break; + } + case LINECAP_SQUARE: + { + Geom::Point start_deriv = der.firstValue(); + double radius = 0.5 * distance(output.firstValue(), output.lastValue()); + Geom::LineSegment cap21(output.lastValue(), output.lastValue() - radius*start_deriv); + Geom::LineSegment cap22(output.lastValue() - radius*start_deriv, output.firstValue() - radius*start_deriv); + Geom::LineSegment cap23(output.firstValue() - radius*start_deriv, output.firstValue()); + output.continuousConcat(Piecewise >(cap21.toSBasis())); + output.continuousConcat(Piecewise >(cap22.toSBasis())); + output.continuousConcat(Piecewise >(cap23.toSBasis())); + break; } + case LINECAP_BUTT: + { + Geom::LineSegment cap2(output.lastValue(), output.firstValue()); + output.continuousConcat(Piecewise >(cap2.toSBasis())); + break; + } + case LINECAP_ROUND: + default: + { + double radius2 = 0.5 * distance(output.firstValue(), output.lastValue()); + Geom::SVGEllipticalArc cap2(output.lastValue(), radius2, radius2, M_PI/2., false, y.lastValue() < 0, output.firstValue()); // note that y is reversed above! + output.continuousConcat(Piecewise >(cap2.toSBasis())); + break; + } + } - output = compose(pwd2_in,x) + y*compose(n,x); - x = reverse(x); - y = reverse(y); - Piecewise > mirrorpath = compose(pwd2_in,x) - y*compose(n,x); - - switch (end_linecap) { - case LINECAP_PEAK: - { - Geom::Point end_deriv = der.lastValue(); - double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::Point midpoint = 0.5*(output.lastValue() + mirrorpath.firstValue()) + radius*end_deriv; - Geom::LineSegment cap11(output.lastValue(), midpoint); - Geom::LineSegment cap12(midpoint, mirrorpath.firstValue()); - output.continuousConcat(Piecewise >(cap11.toSBasis())); - output.continuousConcat(Piecewise >(cap12.toSBasis())); - break; - } - case LINECAP_SQUARE: - { - Geom::Point end_deriv = der.lastValue(); - double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::LineSegment cap11(output.lastValue(), output.lastValue() + radius*end_deriv); - Geom::LineSegment cap12(output.lastValue() + radius*end_deriv, mirrorpath.firstValue() + radius*end_deriv); - Geom::LineSegment cap13(mirrorpath.firstValue() + radius*end_deriv, mirrorpath.firstValue()); - output.continuousConcat(Piecewise >(cap11.toSBasis())); - output.continuousConcat(Piecewise >(cap12.toSBasis())); - output.continuousConcat(Piecewise >(cap13.toSBasis())); - break; - } - case LINECAP_BUTT: - { - Geom::LineSegment cap1(output.lastValue(), mirrorpath.firstValue()); - output.continuousConcat(Piecewise >(cap1.toSBasis())); - break; - } - case LINECAP_ROUND: - default: - { - double radius1 = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::SVGEllipticalArc cap1(output.lastValue(), radius1, radius1, M_PI/2., false, y.firstValue() < 0, mirrorpath.firstValue()); // note that y is reversed above! - output.continuousConcat(Piecewise >(cap1.toSBasis())); - break; - } + return output; +} + +Geom::Piecewise > +LPEPowerStroke::doEffect_pwd2_closed ( Geom::Piecewise > const & pwd2_in, + Geom::Piecewise > const & /*der*/, + Geom::Piecewise > const & n ) +{ + using namespace Geom; + + Piecewise > output; + + // path is closed + // linecap parameter can be ignored + + // perhaps use std::list instead of std::vector? + std::vector ts = offset_points.data(); + if (sort_points) { + sort(ts.begin(), ts.end(), compare_offsets); + } + // add extra points for interpolation between first and last point + Point first_point = ts.front(); + Point last_point = ts.back(); + ts.insert(ts.begin(), last_point - Point(pwd2_in.domain().extent() ,0)); + ts.push_back( first_point + Point(pwd2_in.domain().extent() ,0) ); + // create stroke path where points (x,y) := (t, offset) + Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); + Geom::Path strokepath = interpolator->interpolateToPath(ts); + delete interpolator; + + // output 2 separate paths + D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); + Piecewise x = Piecewise(patternd2[0]); + Piecewise y = Piecewise(patternd2[1]); + // find time values for which x lies outside path domain + // and only take portion of x and y that lies within those time values + std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); + std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); + if ( !rtsmin.empty() && !rtsmax.empty() ) { + x = portion(x, rtsmin.at(0), rtsmax.at(0)); + y = portion(y, rtsmin.at(0), rtsmax.at(0)); + } + output = compose(pwd2_in,x) + y*compose(n,x); + x = reverse(x); + y = reverse(y); + output.concat(compose(pwd2_in,x) - y*compose(n,x)); + + return output; +} + +std::vector +LPEPowerStroke::doEffect_path (std::vector const & path_in) +{ + using namespace Geom; + + std::vector path_out; + + for (unsigned int i=0; i < path_in.size(); i++) { + Geom::Piecewise > pwd2_in = path_in[i].toPwSb(); + + offset_points.set_pwd2(pwd2_in); + Piecewise > der = unitVector(derivative(pwd2_in)); + Piecewise > n = rot90(der); + offset_points.set_pwd2_normal(n); + + Geom::Piecewise > pwd2_out; + if (path_in[i].closed()) { + pwd2_out = doEffect_pwd2_closed(pwd2_in, der, n); + } else { + pwd2_out = doEffect_pwd2_open(pwd2_in, der, n); + } + + std::vector path = path_from_piecewise_fix_cusps( pwd2_out, LPE_CONVERSION_TOLERANCE); + // add the output path vector to the already accumulated vector: + for (unsigned int j=0; j < path.size(); j++) { + path_out.push_back(path[j]); } + } - output.continuousConcat(mirrorpath); - - switch (start_linecap) { - case LINECAP_PEAK: - { - Geom::Point start_deriv = der.firstValue(); - double radius = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::Point midpoint = 0.5*(output.lastValue() + output.firstValue()) - radius*start_deriv; - Geom::LineSegment cap21(output.lastValue(), midpoint); - Geom::LineSegment cap22(midpoint, output.firstValue()); - output.continuousConcat(Piecewise >(cap21.toSBasis())); - output.continuousConcat(Piecewise >(cap22.toSBasis())); - break; - } - case LINECAP_SQUARE: - { - Geom::Point start_deriv = der.firstValue(); - double radius = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::LineSegment cap21(output.lastValue(), output.lastValue() - radius*start_deriv); - Geom::LineSegment cap22(output.lastValue() - radius*start_deriv, output.firstValue() - radius*start_deriv); - Geom::LineSegment cap23(output.firstValue() - radius*start_deriv, output.firstValue()); - output.continuousConcat(Piecewise >(cap21.toSBasis())); - output.continuousConcat(Piecewise >(cap22.toSBasis())); - output.continuousConcat(Piecewise >(cap23.toSBasis())); - break; + return path_out; +} + +std::vector +LPEPowerStroke::path_from_piecewise_fix_cusps(Geom::Piecewise > const &B, double tol) { + +/* per definition, the input piecewise should be closed. each discontinuity should be fixed with a cusp-ending, + as defined by cusp_linecap_type +*/ + Geom::PathBuilder pb; + if(B.size() == 0) return pb.peek(); + Geom::Point start = B[0].at0(); + pb.moveTo(start); + for(unsigned i = 0; ; i++) { + if ( (i+1 == B.size()) + || !are_near(B[i+1].at0(), B[i].at1(), tol) ) + { + //start of a new path + if (are_near(start, B[i].at1()) && sbasis_size(B[i]) <= 1) { + pb.closePath(); + //last line seg already there (because of .closePath()) + goto no_add; } - case LINECAP_BUTT: - { - Geom::LineSegment cap2(output.lastValue(), output.firstValue()); - output.continuousConcat(Piecewise >(cap2.toSBasis())); - break; + build_from_sbasis(pb, B[i], tol, false); + if (are_near(start, B[i].at1())) { + //it's closed, the last closing segment was not a straight line so it needed to be added, but still make it closed here with degenerate straight line. + pb.closePath(); } - case LINECAP_ROUND: - default: - { - double radius2 = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::SVGEllipticalArc cap2(output.lastValue(), radius2, radius2, M_PI/2., false, y.lastValue() < 0, output.firstValue()); // note that y is reversed above! - output.continuousConcat(Piecewise >(cap2.toSBasis())); + no_add: + if (i+1 >= B.size()) { break; } + start = B[i+1].at0(); + pb.moveTo(start); + } else { + build_from_sbasis(pb, B[i], tol, false); } - - } else { - // path is closed - // linecap parameter can be ignored - - // perhaps use std::list instead of std::vector? - std::vector ts = offset_points.data(); - if (sort_points) { - sort(ts.begin(), ts.end(), compare_offsets); - } - // add extra points for interpolation between first and last point - Point first_point = ts.front(); - Point last_point = ts.back(); - ts.insert(ts.begin(), last_point - Point(pwd2_in.domain().extent() ,0)); - ts.push_back( first_point + Point(pwd2_in.domain().extent() ,0) ); - // create stroke path where points (x,y) := (t, offset) - Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); - Geom::Path strokepath = interpolator->interpolateToPath(ts); - delete interpolator; - - // output 2 separate paths - D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); - Piecewise x = Piecewise(patternd2[0]); - Piecewise y = Piecewise(patternd2[1]); - // find time values for which x lies outside path domain - // and only take portion of x and y that lies within those time values - std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); - std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); - if ( !rtsmin.empty() && !rtsmax.empty() ) { - x = portion(x, rtsmin.at(0), rtsmax.at(0)); - y = portion(y, rtsmin.at(0), rtsmax.at(0)); - } - output = compose(pwd2_in,x) + y*compose(n,x); - x = reverse(x); - y = reverse(y); - output.concat(compose(pwd2_in,x) - y*compose(n,x)); } - - return output; + pb.finish(); + return pb.peek(); } /* ######################## */ diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 725c6c4cd..f941e844f 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -25,11 +25,21 @@ public: LPEPowerStroke(LivePathEffectObject *lpeobject); virtual ~LPEPowerStroke(); - virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); + virtual std::vector doEffect_path (std::vector const & path_in); virtual void doOnApply(SPLPEItem *lpeitem); private: + Geom::Piecewise > + doEffect_pwd2_open ( Geom::Piecewise > const & pwd2_in, + Geom::Piecewise > const & der, + Geom::Piecewise > const & n ); + Geom::Piecewise > + doEffect_pwd2_closed ( Geom::Piecewise > const & pwd2_in, + Geom::Piecewise > const & der, + Geom::Piecewise > const & n ); + std::vector path_from_piecewise_fix_cusps(Geom::Piecewise > const &B, double tol); + PowerStrokePointArrayParam offset_points; BoolParam sort_points; EnumParam interpolator_type; -- cgit v1.2.3 From d9d71d4545ee9ebadfe54ccb1f69fd54e4b27f56 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 24 Sep 2011 17:10:38 +0200 Subject: powerstroke: add bevel cusp. but it bugs closed paths. need to restructure... (bzr r10646) --- src/live_effects/lpe-powerstroke.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 8884e8b21..ca952785c 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -579,35 +579,28 @@ LPEPowerStroke::path_from_piecewise_fix_cusps(Geom::Piecewise(cusp_linecap_type.get_value()); + Geom::PathBuilder pb; if(B.size() == 0) return pb.peek(); Geom::Point start = B[0].at0(); pb.moveTo(start); - for(unsigned i = 0; ; i++) { - if ( (i+1 == B.size()) - || !are_near(B[i+1].at0(), B[i].at1(), tol) ) - { - //start of a new path - if (are_near(start, B[i].at1()) && sbasis_size(B[i]) <= 1) { - pb.closePath(); - //last line seg already there (because of .closePath()) - goto no_add; - } - build_from_sbasis(pb, B[i], tol, false); - if (are_near(start, B[i].at1())) { - //it's closed, the last closing segment was not a straight line so it needed to be added, but still make it closed here with degenerate straight line. - pb.closePath(); - } - no_add: - if (i+1 >= B.size()) { + build_from_sbasis(pb, B[0], tol, false); + for (unsigned i=1; i < B.size(); i++) { + if (!are_near(B[i-1].at1(), B[i].at0(), tol) ) + { // discontinuity found, so fix it :-) + switch (cusp_linecap) { + LINECUSP_ROUND: + LINECUSP_SHARP: + LINECUSP_BEVEL: + default: + pb.lineTo(B[i].at0()); break; } - start = B[i+1].at0(); - pb.moveTo(start); - } else { - build_from_sbasis(pb, B[i], tol, false); } + build_from_sbasis(pb, B[i], tol, false); } + pb.closePath(); pb.finish(); return pb.peek(); } -- cgit v1.2.3 From af72bff308bdb392312d4305a88a38fab8255e59 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 26 Sep 2011 21:01:53 +1000 Subject: cmake: aspell/gtkspell/poppler-cairo/libwpg patch #822009 to address bug #820863 from Yu-Jie Lin. (bzr r10648) --- src/extension/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 89e5a6041..bf4bf6a89 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -151,7 +151,7 @@ if(WIN32) ) endif() -if(LibWPG_FOUND) +if(LIBWPG_FOUND) list(APPEND extension_SRC internal/wpg-input.cpp internal/wpg-input.h -- cgit v1.2.3 From 278bc7c50017df7bf9ae28e639c3aecc072fa3df Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 28 Sep 2011 15:18:38 +0200 Subject: Fixed problem with font names that contain spaces. (bzr r10649) --- src/xml/repr-css.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 7db1e8b86..a0b45a42e 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -232,6 +232,7 @@ sp_repr_css_write_string(SPCSSAttr *css) } } else { buffer.append(iter->value); // unquoted + g_warning("sp_repr_css_write_string: %s %s", g_quark_to_string(iter->key), iter->value.pointer() ); } if (rest(iter)) { @@ -309,13 +310,17 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) std::stringstream ss( value_unquoted ); double number; std::string characters; + std::string temp; bool number_valid = !(ss >> number).fail(); if( !number_valid ) ss.clear(); - bool character_valid = !(ss >> characters).fail(); + while( !(ss >> temp).eof() ) { + characters += temp; + characters += " "; + } + characters += temp; Inkscape::CSSOStringStream os; if( number_valid ) os << number; - if( character_valid ) os << characters; - + os << characters; ((Node *) css)->setAttribute(decl->property->stryng->str, os.str().c_str(), false); g_free(value_unquoted); g_free(str_value); -- cgit v1.2.3 From 41a60d0f4d77fbde96f6e8196af58718995da78f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Sep 2011 03:44:58 +1000 Subject: fix for building when WITH_LIBWPG couldn't be found. (bzr r10651) --- src/extension/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index bf4bf6a89..ba1b084af 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -151,7 +151,7 @@ if(WIN32) ) endif() -if(LIBWPG_FOUND) +if(WITH_LIBWPG) list(APPEND extension_SRC internal/wpg-input.cpp internal/wpg-input.h -- cgit v1.2.3 From cecb1678464fc59eb8284c9afd19a6cbb3110b56 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 29 Sep 2011 18:26:22 +0200 Subject: PowerStroke: handle cusps in some way. properly bugged for all types but "beveled" (bzr r10652) --- src/live_effects/lpe-powerstroke.cpp | 373 ++++++++++++++++------------------- src/live_effects/lpe-powerstroke.h | 10 - 2 files changed, 167 insertions(+), 216 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index ca952785c..582ea2750 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -348,180 +348,118 @@ static bool compare_offsets (Geom::Point first, Geom::Point second) return first[Geom::X] < second[Geom::X]; } - // find discontinuities in piecewise -std::vector find_discontinuities(Geom::Piecewise > const & pwd2_in, double eps=Geom::EPSILON) +// find discontinuities in input path +struct discontinuity_data { + Geom::Point der0; // unit derivative of 'left' side of cusp + Geom::Point der1; // unit derivative of 'right' side of cusp + double width; // intended stroke width at cusp +}; +std::vector find_discontinuities( Geom::Piecewise > const & der, + Geom::Piecewise const & x, + Geom::Piecewise const & y, + double eps=Geom::EPSILON ) { - std::vector indices; - for(unsigned i = 1; i < pwd2_in.size(); i++) { - if ( ! are_near(pwd2_in[i-1].at1(), pwd2_in[i].at0(), eps) ) { - indices.push_back(i); + std::vector vect; + for(unsigned i = 1; i < der.size(); i++) { + if ( ! are_near(der[i-1].at1(), der[i].at0(), eps) ) { + discontinuity_data data; + data.der0 = der[i-1].at1(); + data.der1 = der[i].at0(); + double t = der.cuts[i]; + std::vector< double > rts = roots (x - t); /// @todo this has multiple solutions for general strokewidth paths (generated by spiro interpolator...), ignore for now + if (rts.size() > 0) { + data.width = y(rts.front()); + } else { + data.width = 1; + } + vect.push_back(data); } } - return indices; + return vect; } -Geom::Piecewise > -LPEPowerStroke::doEffect_pwd2_open ( Geom::Piecewise > const & pwd2_in, - Geom::Piecewise > const & der, - Geom::Piecewise > const & n ) -{ - using namespace Geom; - - Piecewise > output; - - LineCapType start_linecap = static_cast(start_linecap_type.get_value()); - LineCapType end_linecap = static_cast(end_linecap_type.get_value()); - - // perhaps use std::list instead of std::vector? - std::vector ts(offset_points.data().size() + 2); - for (unsigned int i = 0; i < offset_points.data().size(); ++i) { - ts.at(i+1) = offset_points.data().at(i); - } - if (sort_points) { - sort(ts.begin()+1, ts.end()-1, compare_offsets); - } - - // first and last point have same distance from path as second and second to last points, respectively. - ts.front() = Point(pwd2_in.domain().min(), (*(ts.begin()+1))[Geom::Y] ); - ts.back() = Point(pwd2_in.domain().max(), (*(ts.end()-2))[Geom::Y] ); - - // create stroke path where points (x,y) := (t, offset) - Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); - Geom::Path strokepath = interpolator->interpolateToPath(ts); - delete interpolator; - - D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); - Piecewise x = Piecewise(patternd2[0]); - Piecewise y = Piecewise(patternd2[1]); - // find time values for which x lies outside path domain - // and only take portion of x and y that lies within those time values - std::vector< double > rtsmin = roots (x - pwd2_in.domain().min()); - std::vector< double > rtsmax = roots (x - pwd2_in.domain().max()); - if ( !rtsmin.empty() && !rtsmax.empty() ) { - x = portion(x, rtsmin.at(0), rtsmax.at(0)); - y = portion(y, rtsmin.at(0), rtsmax.at(0)); +Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise > const & B, + std::vector const & cusps, + LineCuspType cusp_linecap, + double tol=Geom::EPSILON) +{ +/* per definition, each discontinuity should be fixed with a cusp-ending, as defined by cusp_linecap_type +*/ + Geom::PathBuilder pb; + if (B.size() == 0) { + return pb.peek().front(); } - output = compose(pwd2_in,x) + y*compose(n,x); - - x = reverse(x); - y = reverse(y); - Piecewise > mirrorpath = compose(pwd2_in,x) - y*compose(n,x); - - switch (end_linecap) { - case LINECAP_PEAK: - { - Geom::Point end_deriv = der.lastValue(); - double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::Point midpoint = 0.5*(output.lastValue() + mirrorpath.firstValue()) + radius*end_deriv; - Geom::LineSegment cap11(output.lastValue(), midpoint); - Geom::LineSegment cap12(midpoint, mirrorpath.firstValue()); - output.continuousConcat(Piecewise >(cap11.toSBasis())); - output.continuousConcat(Piecewise >(cap12.toSBasis())); - break; - } - case LINECAP_SQUARE: - { - Geom::Point end_deriv = der.lastValue(); - double radius = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::LineSegment cap11(output.lastValue(), output.lastValue() + radius*end_deriv); - Geom::LineSegment cap12(output.lastValue() + radius*end_deriv, mirrorpath.firstValue() + radius*end_deriv); - Geom::LineSegment cap13(mirrorpath.firstValue() + radius*end_deriv, mirrorpath.firstValue()); - output.continuousConcat(Piecewise >(cap11.toSBasis())); - output.continuousConcat(Piecewise >(cap12.toSBasis())); - output.continuousConcat(Piecewise >(cap13.toSBasis())); - break; - } - case LINECAP_BUTT: - { - Geom::LineSegment cap1(output.lastValue(), mirrorpath.firstValue()); - output.continuousConcat(Piecewise >(cap1.toSBasis())); - break; - } - case LINECAP_ROUND: - default: - { - double radius1 = 0.5 * distance(output.lastValue(), mirrorpath.firstValue()); - Geom::SVGEllipticalArc cap1(output.lastValue(), radius1, radius1, M_PI/2., false, y.firstValue() < 0, mirrorpath.firstValue()); // note that y is reversed above! - output.continuousConcat(Piecewise >(cap1.toSBasis())); - break; - } - } + unsigned int cusp_i = 0; + Geom::Point start = B[0].at0(); + pb.moveTo(start); + build_from_sbasis(pb, B[0], tol, false); + for (unsigned i=1; i < B.size(); i++) { + if (!are_near(B[i-1].at1(), B[i].at0(), tol) ) + { // discontinuity found, so fix it :-) + discontinuity_data const &cusp = cusps[cusp_i]; - output.continuousConcat(mirrorpath); + switch (cusp_linecap) { + case LINECUSP_ROUND: // properly bugged ^_^ + pb.arcTo( abs(cusp.width), abs(cusp.width), + angle_between(cusp.der0, cusp.der1), false, cusp.width < 0, + B[i].at0() ); + break; + case LINECUSP_SHARP: // no clue yet what to do here :) + case LINECUSP_BEVEL: + default: + pb.lineTo(B[i].at0()); + break; + } - switch (start_linecap) { - case LINECAP_PEAK: - { - Geom::Point start_deriv = der.firstValue(); - double radius = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::Point midpoint = 0.5*(output.lastValue() + output.firstValue()) - radius*start_deriv; - Geom::LineSegment cap21(output.lastValue(), midpoint); - Geom::LineSegment cap22(midpoint, output.firstValue()); - output.continuousConcat(Piecewise >(cap21.toSBasis())); - output.continuousConcat(Piecewise >(cap22.toSBasis())); - break; - } - case LINECAP_SQUARE: - { - Geom::Point start_deriv = der.firstValue(); - double radius = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::LineSegment cap21(output.lastValue(), output.lastValue() - radius*start_deriv); - Geom::LineSegment cap22(output.lastValue() - radius*start_deriv, output.firstValue() - radius*start_deriv); - Geom::LineSegment cap23(output.firstValue() - radius*start_deriv, output.firstValue()); - output.continuousConcat(Piecewise >(cap21.toSBasis())); - output.continuousConcat(Piecewise >(cap22.toSBasis())); - output.continuousConcat(Piecewise >(cap23.toSBasis())); - break; - } - case LINECAP_BUTT: - { - Geom::LineSegment cap2(output.lastValue(), output.firstValue()); - output.continuousConcat(Piecewise >(cap2.toSBasis())); - break; - } - case LINECAP_ROUND: - default: - { - double radius2 = 0.5 * distance(output.firstValue(), output.lastValue()); - Geom::SVGEllipticalArc cap2(output.lastValue(), radius2, radius2, M_PI/2., false, y.lastValue() < 0, output.firstValue()); // note that y is reversed above! - output.continuousConcat(Piecewise >(cap2.toSBasis())); - break; + cusp_i++; } + build_from_sbasis(pb, B[i], tol, false); } - - return output; + pb.finish(); + return pb.peek().front(); } -Geom::Piecewise > -LPEPowerStroke::doEffect_pwd2_closed ( Geom::Piecewise > const & pwd2_in, - Geom::Piecewise > const & /*der*/, - Geom::Piecewise > const & n ) + +std::vector +LPEPowerStroke::doEffect_path (std::vector const & path_in) { using namespace Geom; - Piecewise > output; + std::vector path_out; + if (path_in.size() == 0) { + return path_out; + } - // path is closed - // linecap parameter can be ignored + // for now, only regard first subpath and ignore the rest + Geom::Piecewise > pwd2_in = path_in[0].toPwSb(); + + offset_points.set_pwd2(pwd2_in); + Piecewise > der = unitVector(derivative(pwd2_in)); + Piecewise > n = rot90(der); + offset_points.set_pwd2_normal(n); - // perhaps use std::list instead of std::vector? std::vector ts = offset_points.data(); if (sort_points) { sort(ts.begin(), ts.end(), compare_offsets); } - // add extra points for interpolation between first and last point - Point first_point = ts.front(); - Point last_point = ts.back(); - ts.insert(ts.begin(), last_point - Point(pwd2_in.domain().extent() ,0)); - ts.push_back( first_point + Point(pwd2_in.domain().extent() ,0) ); + if (path_in[0].closed()) { + // add extra points for interpolation between first and last point + Point first_point = ts.front(); + Point last_point = ts.back(); + ts.insert(ts.begin(), last_point - Point(pwd2_in.domain().extent() ,0)); + ts.push_back( first_point + Point(pwd2_in.domain().extent() ,0) ); + } else { + // first and last point have same distance from path as second and second to last points, respectively. + ts.insert(ts.begin(), Point(pwd2_in.domain().min(), ts.front()[Geom::Y]) ); + ts.push_back( Point(pwd2_in.domain().max(), ts.back()[Geom::Y]) ); + } // create stroke path where points (x,y) := (t, offset) Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())); Geom::Path strokepath = interpolator->interpolateToPath(ts); delete interpolator; - // output 2 separate paths D2 > patternd2 = make_cuts_independent(strokepath.toPwSb()); Piecewise x = Piecewise(patternd2[0]); Piecewise y = Piecewise(patternd2[1]); @@ -533,78 +471,101 @@ LPEPowerStroke::doEffect_pwd2_closed ( Geom::Piecewise > x = portion(x, rtsmin.at(0), rtsmax.at(0)); y = portion(y, rtsmin.at(0), rtsmax.at(0)); } - output = compose(pwd2_in,x) + y*compose(n,x); - x = reverse(x); - y = reverse(y); - output.concat(compose(pwd2_in,x) - y*compose(n,x)); - - return output; -} - -std::vector -LPEPowerStroke::doEffect_path (std::vector const & path_in) -{ - using namespace Geom; - - std::vector path_out; - for (unsigned int i=0; i < path_in.size(); i++) { - Geom::Piecewise > pwd2_in = path_in[i].toPwSb(); - - offset_points.set_pwd2(pwd2_in); - Piecewise > der = unitVector(derivative(pwd2_in)); - Piecewise > n = rot90(der); - offset_points.set_pwd2_normal(n); + std::vector cusps = find_discontinuities(der, x, y); + LineCuspType cusp_linecap = static_cast(cusp_linecap_type.get_value()); - Geom::Piecewise > pwd2_out; - if (path_in[i].closed()) { - pwd2_out = doEffect_pwd2_closed(pwd2_in, der, n); - } else { - pwd2_out = doEffect_pwd2_open(pwd2_in, der, n); - } - - std::vector path = path_from_piecewise_fix_cusps( pwd2_out, LPE_CONVERSION_TOLERANCE); - // add the output path vector to the already accumulated vector: - for (unsigned int j=0; j < path.size(); j++) { - path_out.push_back(path[j]); + Piecewise > pwd2_out = compose(pwd2_in,x) + y*compose(n,x); + Piecewise > mirrorpath = reverse(compose(pwd2_in,x) - y*compose(n,x)); + + Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, cusps, cusp_linecap, LPE_CONVERSION_TOLERANCE); + Geom::Path fixed_mirrorpath = path_from_piecewise_fix_cusps( mirrorpath, cusps, cusp_linecap, LPE_CONVERSION_TOLERANCE); + + if (path_in[0].closed()) { + fixed_path.close(true); + path_out.push_back(fixed_path); + fixed_mirrorpath.close(true); + path_out.push_back(fixed_mirrorpath); + } else { + // add linecaps... + LineCapType end_linecap = static_cast(end_linecap_type.get_value()); + LineCapType start_linecap = static_cast(start_linecap_type.get_value()); + switch (end_linecap) { + case LINECAP_PEAK: + { + Geom::Point end_deriv = der.lastValue(); + double radius = 0.5 * distance(pwd2_out.lastValue(), mirrorpath.firstValue()); + Geom::Point midpoint = 0.5*(pwd2_out.lastValue() + mirrorpath.firstValue()) + radius*end_deriv; + fixed_path.appendNew(midpoint); + fixed_path.appendNew(mirrorpath.firstValue()); + break; + } + case LINECAP_SQUARE: + { + Geom::Point end_deriv = der.lastValue(); + double radius = 0.5 * distance(pwd2_out.lastValue(), mirrorpath.firstValue()); + fixed_path.appendNew( pwd2_out.lastValue() + radius*end_deriv ); + fixed_path.appendNew( mirrorpath.firstValue() + radius*end_deriv ); + fixed_path.appendNew( mirrorpath.firstValue() ); + break; + } + case LINECAP_BUTT: + { + fixed_path.appendNew( mirrorpath.firstValue() ); + break; + } + case LINECAP_ROUND: + default: + { + double radius1 = 0.5 * distance(pwd2_out.lastValue(), mirrorpath.firstValue()); + fixed_path.appendNew( radius1, radius1, M_PI/2., false, y.lastValue() < 0, mirrorpath.firstValue() ); + break; + } } - } - - return path_out; -} -std::vector -LPEPowerStroke::path_from_piecewise_fix_cusps(Geom::Piecewise > const &B, double tol) { + fixed_path.append(fixed_mirrorpath, Geom::Path::STITCH_DISCONTINUOUS); -/* per definition, the input piecewise should be closed. each discontinuity should be fixed with a cusp-ending, - as defined by cusp_linecap_type -*/ - LineCuspType cusp_linecap = static_cast(cusp_linecap_type.get_value()); - - Geom::PathBuilder pb; - if(B.size() == 0) return pb.peek(); - Geom::Point start = B[0].at0(); - pb.moveTo(start); - build_from_sbasis(pb, B[0], tol, false); - for (unsigned i=1; i < B.size(); i++) { - if (!are_near(B[i-1].at1(), B[i].at0(), tol) ) - { // discontinuity found, so fix it :-) - switch (cusp_linecap) { - LINECUSP_ROUND: - LINECUSP_SHARP: - LINECUSP_BEVEL: + switch (start_linecap) { + case LINECAP_PEAK: + { + Geom::Point start_deriv = der.firstValue(); + double radius = 0.5 * distance(pwd2_out.firstValue(), mirrorpath.lastValue()); + Geom::Point midpoint = 0.5*(mirrorpath.lastValue() + pwd2_out.firstValue()) - radius*start_deriv; + fixed_path.appendNew( midpoint ); + fixed_path.appendNew( pwd2_out.firstValue() ); + break; + } + case LINECAP_SQUARE: + { + Geom::Point start_deriv = der.firstValue(); + double radius = 0.5 * distance(pwd2_out.firstValue(), mirrorpath.lastValue()); + fixed_path.appendNew( mirrorpath.lastValue() - radius*start_deriv ); + fixed_path.appendNew( pwd2_out.firstValue() - radius*start_deriv ); + fixed_path.appendNew( pwd2_out.firstValue() ); + break; + } + case LINECAP_BUTT: + { + fixed_path.appendNew( pwd2_out.firstValue() ); + break; + } + case LINECAP_ROUND: default: - pb.lineTo(B[i].at0()); + { + double radius2 = 0.5 * distance(pwd2_out.firstValue(), mirrorpath.lastValue()); + fixed_path.appendNew( radius2, radius2, M_PI/2., false, y.firstValue() < 0, pwd2_out.firstValue() ); break; } } - build_from_sbasis(pb, B[i], tol, false); + + fixed_path.close(true); + path_out.push_back(fixed_path); } - pb.closePath(); - pb.finish(); - return pb.peek(); + + return path_out; } + /* ######################## */ } //namespace LivePathEffect diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index f941e844f..bcfbdadc0 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -30,16 +30,6 @@ public: virtual void doOnApply(SPLPEItem *lpeitem); private: - Geom::Piecewise > - doEffect_pwd2_open ( Geom::Piecewise > const & pwd2_in, - Geom::Piecewise > const & der, - Geom::Piecewise > const & n ); - Geom::Piecewise > - doEffect_pwd2_closed ( Geom::Piecewise > const & pwd2_in, - Geom::Piecewise > const & der, - Geom::Piecewise > const & n ); - std::vector path_from_piecewise_fix_cusps(Geom::Piecewise > const &B, double tol); - PowerStrokePointArrayParam offset_points; BoolParam sort_points; EnumParam interpolator_type; -- cgit v1.2.3 From 36a5f2e164d1c6be561c94714bf3292a60628288 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 29 Sep 2011 18:30:44 +0200 Subject: add PowerStroke to the normally visible LPEs, but with 'unstable!' warning (bzr r10653) --- src/live_effects/effect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 10abef4a1..a5b2077a5 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -100,7 +100,6 @@ const Util::EnumData LPETypeData[] = { {PATH_LENGTH, N_("Path length"), "path_length"}, {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"}, {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"}, - {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, @@ -121,7 +120,8 @@ const Util::EnumData LPETypeData[] = { {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, {SKETCH, N_("Sketch"), "sketch"}, {RULER, N_("Ruler"), "ruler"}, -/* 0.49 */ +/* 0.49 ?*/ + {POWERSTROKE, N_("[Unstable!] Power stroke"), "powerstroke"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); -- cgit v1.2.3 From 122894f12a4f8214207f533ed26569fbab5ac9f7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Oct 2011 01:26:17 -0700 Subject: Warning cleanup. (bzr r10655) --- src/display/cairo-utils.cpp | 3 +-- src/display/drawing-image.cpp | 3 +-- src/display/drawing-item.h | 12 ++++++------ src/display/drawing-shape.cpp | 3 +-- src/display/drawing-text.cpp | 9 +++------ src/helper/action.cpp | 2 +- src/helper/pixbuf-ops.cpp | 40 +++++++++++++++++----------------------- src/snap.cpp | 2 +- src/sp-cursor.cpp | 2 +- src/sp-image.cpp | 2 +- src/sp-item.cpp | 2 +- src/svg/svg-length.cpp | 2 ++ 12 files changed, 36 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 8b75f09a6..a12a3d560 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -350,8 +350,7 @@ ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb) * to gdk_pixbuf_new_from_data when creating a GdkPixbuf backed by * a Cairo surface. */ -void -ink_cairo_pixbuf_cleanup(guchar *pixels, void *data) +void ink_cairo_pixbuf_cleanup(guchar * /*pixels*/, void *data) { cairo_surface_t *surface = reinterpret_cast(data); cairo_surface_destroy(surface); diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index fa0402699..20a1eb795 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -112,8 +112,7 @@ DrawingImage::_updateItem(Geom::IntRect const &, UpdateContext const &, unsigned return STATE_ALL; } -unsigned -DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) +unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) { bool outline = _drawing.outline(); diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 424616427..ca8b21336 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -133,12 +133,12 @@ protected: void _setStyleCommon(SPStyle *&_style, SPStyle *style); double _cacheScore(); Geom::OptIntRect _cacheRect(); - virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, - unsigned flags, unsigned reset) { return 0; } - virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, - DrawingItem *stop_at) { return RENDER_OK; } - virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area) {} - virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags) { return NULL; } + virtual unsigned _updateItem(Geom::IntRect const &/*area*/, UpdateContext const &/*ctx*/, + unsigned /*flags*/, unsigned /*reset*/) { return 0; } + virtual unsigned _renderItem(DrawingContext &/*ct*/, Geom::IntRect const &/*area*/, unsigned /*flags*/, + DrawingItem * /*stop_at*/) { return RENDER_OK; } + virtual void _clipItem(DrawingContext &/*ct*/, Geom::IntRect const &/*area*/) {} + virtual DrawingItem *_pickItem(Geom::Point const &/*p*/, double /*delta*/, unsigned /*flags*/) { return NULL; } virtual bool _canClip() { return false; } // member variables start here diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 6e28c0184..93a4846e0 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -205,8 +205,7 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne return RENDER_OK; } -void -DrawingShape::_clipItem(DrawingContext &ct, Geom::IntRect const &area) +void DrawingShape::_clipItem(DrawingContext &ct, Geom::IntRect const & /*area*/) { if (!_curve) return; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 23a7cfdfb..6dde9634e 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -50,8 +50,7 @@ DrawingGlyphs::setGlyph(font_instance *font, int glyph, Geom::Affine const &tran _markForUpdate(STATE_ALL, false); } -unsigned -DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) +unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext const &ctx, unsigned /*flags*/, unsigned /*reset*/) { DrawingText *ggroup = dynamic_cast(_parent); if (!ggroup) throw InvalidItemException(); @@ -146,8 +145,7 @@ DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, un return DrawingGroup::_updateItem(area, ctx, flags, reset); } -unsigned -DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) +unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) { if (_drawing.outline()) { guint32 rgba = _drawing.outlinecolor; @@ -201,8 +199,7 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned return RENDER_OK; } -void -DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &area) +void DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &/*area*/) { Inkscape::DrawingContext::Save save(ct); diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 3eb881300..532078a3d 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -157,7 +157,7 @@ public: \param data ignored */ void -sp_action_perform (SPAction *action, void * data) +sp_action_perform (SPAction *action, void * /*data*/) { g_return_if_fail (action != NULL); g_return_if_fail (SP_IS_ACTION (action)); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 3f987dc01..9f80cc58b 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -64,28 +64,23 @@ static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dke // The dpi settings dont do anything yet, but I want them to, and was wanting to keep reasonably close // to the call for the interface to the png writing. -bool -sp_export_jpg_file(SPDocument *doc, gchar const *filename, - double x0, double y0, double x1, double y1, - unsigned width, unsigned height, double xdpi, double ydpi, - unsigned long bgcolor, double quality,GSList *items) - +bool sp_export_jpg_file(SPDocument *doc, gchar const *filename, + double x0, double y0, double x1, double y1, + unsigned width, unsigned height, double xdpi, double ydpi, + unsigned long bgcolor, double quality,GSList *items) { - - - GdkPixbuf* pixbuf; - pixbuf = sp_generate_internal_bitmap(doc, filename, x0, y0, x1, y1, + GdkPixbuf* pixbuf = 0; + pixbuf = sp_generate_internal_bitmap(doc, filename, x0, y0, x1, y1, width, height, xdpi, ydpi, bgcolor, items ); + gchar c[32]; + g_snprintf(c, 32, "%f", quality); + gboolean saved = gdk_pixbuf_save (pixbuf, filename, "jpeg", NULL, "quality", c, NULL); + g_free(c); + gdk_pixbuf_unref (pixbuf); - gchar c[32]; - g_snprintf(c, 32, "%f", quality); - gboolean saved = gdk_pixbuf_save (pixbuf, filename, "jpeg", NULL, "quality", c, NULL); - g_free(c); - gdk_pixbuf_unref (pixbuf); - if (saved) return true; - else return false; + return saved; } /** @@ -101,12 +96,11 @@ sp_export_jpg_file(SPDocument *doc, gchar const *filename, @param ydpi @return the created GdkPixbuf structure or NULL if no memory is allocable */ -GdkPixbuf* -sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, - double x0, double y0, double x1, double y1, - unsigned width, unsigned height, double xdpi, double ydpi, - unsigned long bgcolor, - GSList *items_only) +GdkPixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, + double x0, double y0, double x1, double y1, + unsigned width, unsigned height, double xdpi, double ydpi, + unsigned long /*bgcolor*/, + GSList *items_only) { if (width == 0 || height == 0) return NULL; diff --git a/src/snap.cpp b/src/snap.cpp index eeca66d74..b2c5a5a10 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -568,7 +568,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred * \param guide_normal Vector normal to the guide line */ -void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const +void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_normal*/, SPGuideDragType drag_type) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; diff --git a/src/sp-cursor.cpp b/src/sp-cursor.cpp index cc52f3c97..eb1e16888 100644 --- a/src/sp-cursor.cpp +++ b/src/sp-cursor.cpp @@ -91,7 +91,7 @@ void sp_cursor_bitmap_and_mask_from_xpm(GdkBitmap **bitmap, GdkBitmap **mask, gc *mask = gdk_bitmap_create_from_data(NULL, mask_buffer, 32, 32); } -static void free_cursor_data(guchar *pixels, gpointer data) { +static void free_cursor_data(guchar *pixels, gpointer /*data*/) { delete [] reinterpret_cast(pixels); } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 1bfcc90e5..46969897f 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1062,7 +1062,7 @@ static Inkscape::XML::Node *sp_image_write( SPObject *object, Inkscape::XML::Doc return repr; } -static Geom::OptRect sp_image_bbox( SPItem const *item,Geom::Affine const &transform, SPItem::BBoxType type ) +static Geom::OptRect sp_image_bbox( SPItem const *item,Geom::Affine const &transform, SPItem::BBoxType /*type*/ ) { SPImage const &image = *SP_IMAGE(item); Geom::OptRect bbox; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 3ec5f249b..a4d66cf1a 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -846,7 +846,7 @@ unsigned SPItem::pos_in_parent() return 0; } -void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) +void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector &/*p*/, Inkscape::SnapPreferences const * /*snapprefs*/) { /* This will only be called if the derived class doesn't override this. * see for example sp_genericellipse_snappoints in sp-ellipse.cpp diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp index 3f04588ea..6b00cc807 100644 --- a/src/svg/svg-length.cpp +++ b/src/svg/svg-length.cpp @@ -80,6 +80,7 @@ static unsigned int sp_svg_number_write_ui(gchar *buf, unsigned int val) return i; } +// TODO unsafe code ingnoring bufLen static unsigned int sp_svg_number_write_i(gchar *buf, int bufLen, int val) { int p = 0; @@ -96,6 +97,7 @@ static unsigned int sp_svg_number_write_i(gchar *buf, int bufLen, int val) return p; } +// TODO unsafe code ingnoring bufLen static unsigned sp_svg_number_write_d(gchar *buf, int bufLen, double val, unsigned int tprec, unsigned int fprec) { /* Process sign */ -- cgit v1.2.3 From b0c0eed3b05e20673469dc7b70cf3a92a42429b2 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Oct 2011 01:34:59 -0700 Subject: Removing redundant doxygen @brief tag. (bzr r10656) --- src/display/cairo-utils.cpp | 29 ++++++++++++++++++----------- src/display/canvas-grid.cpp | 2 +- src/display/drawing-context.cpp | 13 ++++++++----- src/display/drawing-group.cpp | 8 +++++--- src/display/drawing-image.cpp | 2 +- src/display/drawing-item.cpp | 34 ++++++++++++++++++++++------------ src/display/drawing-shape.cpp | 2 +- src/display/drawing-surface.cpp | 37 ++++++++++++++++++++++++------------- src/display/drawing-text.cpp | 2 +- src/display/drawing.cpp | 2 +- src/display/grayscale.cpp | 3 ++- src/display/nr-style.cpp | 2 +- 12 files changed, 85 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index a12a3d560..2e2eb42dd 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -345,7 +345,8 @@ ink_cairo_surface_create_for_argb32_pixbuf(GdkPixbuf *pb) return pbs; } -/** @brief Cleanup function for GdkPixbuf. +/** + * Cleanup function for GdkPixbuf. * This function should be passed as the GdkPixbufDestroyNotify parameter * to gdk_pixbuf_new_from_data when creating a GdkPixbuf backed by * a Cairo surface. @@ -356,9 +357,11 @@ void ink_cairo_pixbuf_cleanup(guchar * /*pixels*/, void *data) cairo_surface_destroy(surface); } -/** @brief Create an exact copy of a surface. +/** + * Create an exact copy of a surface. * Creates a surface that has the same type, content type, dimensions and contents - * as the specified surface. */ + * as the specified surface. + */ cairo_surface_t * ink_cairo_surface_copy(cairo_surface_t *s) { @@ -383,9 +386,11 @@ ink_cairo_surface_copy(cairo_surface_t *s) return ns; } -/** @brief Create a surface that differs only in pixel content. +/** + * Create a surface that differs only in pixel content. * Creates a surface that has the same type, content type and dimensions - * as the specified surface. Pixel contents are not copied. */ + * as the specified surface. Pixel contents are not copied. + */ cairo_surface_t * ink_cairo_surface_create_identical(cairo_surface_t *s) { @@ -401,9 +406,11 @@ ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c) return ns; } -/** @brief Extract the alpha channel into a new surface. +/** + * Extract the alpha channel into a new surface. * Creates a surface with a content type of CAIRO_CONTENT_ALPHA that contains - * the alpha values of pixels from @a s. */ + * the alpha values of pixels from @a s. + */ cairo_surface_t * ink_cairo_extract_alpha(cairo_surface_t *s) { @@ -623,7 +630,7 @@ guint32 pixbuf_from_argb32(guint32 c) } /** - * @brief Convert pixel data from GdkPixbuf format to ARGB. + * Convert pixel data from GdkPixbuf format to ARGB. * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. * This involves premultiplying alpha and shuffling around the channels. * Pixbuf data must have an alpha channel, otherwise the results are undefined @@ -642,7 +649,7 @@ convert_pixels_pixbuf_to_argb32(guchar *data, int w, int h, int stride) } /** - * @brief Convert pixel data from ARGB to GdkPixbuf format. + * Convert pixel data from ARGB to GdkPixbuf format. * This will convert pixel data from GdkPixbuf format to Cairo's native pixel format. * This involves premultiplying alpha and shuffling around the channels. */ @@ -659,7 +666,7 @@ convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int stride) } /** - * @brief Converts GdkPixbuf's data to premultiplied ARGB. + * Converts GdkPixbuf's data to premultiplied ARGB. * This function will convert a GdkPixbuf in place into Cairo's native pixel format. * Note that this is a hack intended to save memory. When the pixbuf is in Cairo's format, * using it with GTK will result in corrupted drawings. @@ -675,7 +682,7 @@ convert_pixbuf_normal_to_argb32(GdkPixbuf *pb) } /** - * @brief Converts GdkPixbuf's data back to its native format. + * Converts GdkPixbuf's data back to its native format. * Once this is done, the pixbuf can be used with GTK again. */ void diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index a36252a80..dbf78f561 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1,5 +1,5 @@ /** @file - * @brief Cartesian grid implementation + * Cartesian grid implementation. */ /* Copyright (C) Johan Engelen 2006-2007 * Copyright (C) Lauris Kaplinski 2000 diff --git a/src/display/drawing-context.cpp b/src/display/drawing-context.cpp index 3c0c2163b..de5beb0f6 100644 --- a/src/display/drawing-context.cpp +++ b/src/display/drawing-context.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Cairo drawing context with Inkscape extensions + * Cairo drawing context with Inkscape extensions. *//* * Authors: * Krzysztof KosiÅ„ski @@ -19,8 +19,10 @@ namespace Inkscape { using Geom::X; using Geom::Y; -/** @class DrawingContext::Save - * @brief RAII idiom for saving the state of DrawingContext. */ +/** + * @class DrawingContext::Save + * RAII idiom for saving the state of DrawingContext. + */ DrawingContext::Save::Save() : _ct(NULL) @@ -46,8 +48,9 @@ void DrawingContext::Save::save(DrawingContext &ct) _ct->save(); } -/** @class DrawingContext - * @brief Minimal wrapper over Cairo. +/** + * @class DrawingContext + * Minimal wrapper over Cairo. * * This is a wrapper over cairo_t, extended with operations that work * with 2Geom geometrical primitives. Some of this is probably duplicated diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 998c4b6e4..6d52b89fc 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Group belonging to an SVG drawing element + * Group belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski @@ -30,7 +30,8 @@ DrawingGroup::~DrawingGroup() sp_style_unref(_style); } -/** @brief Set whether the group returns children from pick calls. +/** + * Set whether the group returns children from pick calls. * Previously this feature was called "transparent groups". */ void @@ -45,7 +46,8 @@ DrawingGroup::setStyle(SPStyle *style) _setStyleCommon(_style, style); } -/** @brief Set additional transform for the group. +/** + * Set additional transform for the group. * This is applied after the normal transform and mainly useful for * markers, clipping paths, etc. */ diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 20a1eb795..0c8ac9681 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Bitmap image belonging to an SVG drawing + * Bitmap image belonging to an SVG drawing. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 3fe56b6de..bb99ed61d 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Canvas item belonging to an SVG drawing element + * Canvas item belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski @@ -23,8 +23,9 @@ namespace Inkscape { -/** @class DrawingItem - * @brief SVG drawing item for display. +/** + * @class DrawingItem + * SVG drawing item for display. * * This was previously known as NRArenaItem. It represents the renderable * portion of the SVG document. Typically this is created by the SP tree, @@ -210,7 +211,8 @@ DrawingItem::setSensitive(bool s) _sensitive = s; } -/** @brief Enable / disable storing the rendering in memory. +/** + * Enable / disable storing the rendering in memory. * Calling setCached(false, true) will also remove the persistent status */ void @@ -283,7 +285,8 @@ DrawingItem::setItemBounds(Geom::OptRect const &bounds) _item_bbox = bounds; } -/** @brief Update derived data before operations. +/** + * Update derived data before operations. * The purpose of this call is to recompute internal data which depends * on the attributes of the object, but is not directly settable by the user. * Precomputing this data speeds up later rendering, because some items @@ -435,7 +438,8 @@ struct MaskLuminanceToAlpha { } }; -/** @brief Rasterize items. +/** + * Rasterize items. * This method submits the drawing opeartions required to draw this item * to the supplied DrawingContext, restricting drawing the the specified area. * @@ -644,7 +648,8 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig _drawing.outlinecolor = saved_rgba; // restore outline color } -/** @brief Rasterize the clipping path. +/** + * Rasterize the clipping path. * This method submits drawing operations required to draw a basic filled shape * of the item to the supplied drawing context. Rendering is limited to the * given area. The rendering of the clipped object is composited into @@ -684,7 +689,8 @@ DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) } } -/** @brief Get the item under the specified point. +/** + * Get the item under the specified point. * Searches the tree for the first item in the Z-order which is closer than * @a delta to the given point. The pick should be visual - for example * an object with a thick stroke should pick on the entire area of the stroke. @@ -732,7 +738,8 @@ DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags) return NULL; } -/** Marks the current visual bounding box of the item for redrawing. +/** + * Marks the current visual bounding box of the item for redrawing. * This is called whenever the object changes its visible appearance. * For some cases (such as setting opacity) this is enough, but for others * _markForUpdate() also needs to be called. @@ -779,7 +786,8 @@ DrawingItem::_invalidateFilterBackground(Geom::IntRect const &area) } } -/** @brief Marks the item as needing a recomputation of internal data. +/** + * Marks the item as needing a recomputation of internal data. * * This mechanism avoids traversing the entire rendering tree (which could be vast) * on every trivial state changed in any item. Only items marked as needing @@ -843,10 +851,12 @@ DrawingItem::_setStyleCommon(SPStyle *&_style, SPStyle *style) _markForUpdate(STATE_ALL, false); } -/** @brief Compute the caching score. +/** + * Compute the caching score. * * Higher scores mean the item is more aggresively prioritized for automatic - * caching by Inkscape::Drawing. */ + * caching by Inkscape::Drawing. + */ double DrawingItem::_cacheScore() { diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 93a4846e0..4ca306092 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Shape (styled path) belonging to an SVG drawing + * Shape (styled path) belonging to an SVG drawing. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index 5cbfaa3fe..bddccbd96 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Cairo surface that remembers its origin + * Cairo surface that remembers its origin. *//* * Authors: * Krzysztof KosiÅ„ski @@ -20,8 +20,9 @@ using Geom::X; using Geom::Y; -/** @class DrawingSurface - * @brief Drawing surface that remembers its origin. +/** + * @class DrawingSurface + * Drawing surface that remembers its origin. * * This is a very minimalistic wrapper over cairo_surface_t. The main * extra functionality provided by this class is that it automates @@ -35,9 +36,11 @@ using Geom::Y; * of when a DrawingContext is constructed. */ -/** @brief Creates a surface with the given physical extents. +/** + * Creates a surface with the given physical extents. * When a drawing context is created for this surface, its pixels - * will cover the area under the given rectangle. */ + * will cover the area under the given rectangle. + */ DrawingSurface::DrawingSurface(Geom::IntRect const &area) : _surface(NULL) , _origin(area.min()) @@ -45,12 +48,14 @@ DrawingSurface::DrawingSurface(Geom::IntRect const &area) , _pixels(area.dimensions()) {} -/** @brief Creates a surface with the given logical and physical extents. +/** + * Creates a surface with the given logical and physical extents. * When a drawing context is created for this surface, its pixels * will cover the area under the given rectangle. IT will contain * the number of pixels specified by the second argument. * @param logbox Logical extents of the surface - * @param pixdims Pixel dimensions of the surface. */ + * @param pixdims Pixel dimensions of the surface. + */ DrawingSurface::DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &pixdims) : _surface(NULL) , _origin(logbox.min()) @@ -58,9 +63,11 @@ DrawingSurface::DrawingSurface(Geom::Rect const &logbox, Geom::IntPoint const &p , _pixels(pixdims) {} -/** @brief Wrap a cairo_surface_t. +/** + * Wrap a cairo_surface_t. * This constructor will take an extra reference on @a surface, which will - * be released on destruction. */ + * be released on destruction. + */ DrawingSurface::DrawingSurface(cairo_surface_t *surface, Geom::Point const &origin) : _surface(surface) , _origin(origin) @@ -137,8 +144,10 @@ DrawingSurface::dropContents() } } -/** @brief Create a drawing context for this surface. - * It's better to use the surface constructor of DrawingContext. */ +/** + * Create a drawing context for this surface. + * It's better to use the surface constructor of DrawingContext. + */ cairo_t * DrawingSurface::createRawContext() { @@ -253,8 +262,10 @@ DrawingCache::prepare() _pending_transform.setIdentity(); } -/** @brief Paints the clean area from cache and modifies the @a area - * parameter to the bounds of the region that must be repainted. */ +/** + * Paints the clean area from cache and modifies the @a area + * parameter to the bounds of the region that must be repainted. + */ void DrawingCache::paintFromCache(DrawingContext &ct, Geom::OptIntRect &area) { diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 6dde9634e..94a9690fb 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Group belonging to an SVG drawing element + * Group belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index 06183fed2..77f24caf3 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief SVG drawing for display + * SVG drawing for display. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/grayscale.cpp b/src/display/grayscale.cpp index e468044d3..f59cf6d23 100644 --- a/src/display/grayscale.cpp +++ b/src/display/grayscale.cpp @@ -73,7 +73,8 @@ guchar luminance(guchar r, guchar g, guchar b) { return luminance & 0xff; } -/** @brief Use this method if there is no other way to find out if grayscale view or not +/** + * Use this method if there is no other way to find out if grayscale view or not. * * In some cases, the choice between normal or grayscale is so deep in the code hierarchy, * that it is not possible to determine whether grayscale is desired or not, without using diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 6e8ccb030..86102f9e8 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief Style information for rendering + * Style information for rendering. *//* * Authors: * Krzysztof KosiÅ„ski -- cgit v1.2.3 From a87e24fa2d1c86e85444e177a3c3156f4d630c3f Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 2 Oct 2011 15:40:19 +0200 Subject: Removed forgotten debug statement. (bzr r10657) --- src/xml/repr-css.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index a0b45a42e..8de85c36d 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -232,7 +232,6 @@ sp_repr_css_write_string(SPCSSAttr *css) } } else { buffer.append(iter->value); // unquoted - g_warning("sp_repr_css_write_string: %s %s", g_quark_to_string(iter->key), iter->value.pointer() ); } if (rest(iter)) { -- cgit v1.2.3 From b3cfe2e5f5971aec70bbb94c680d00726c624ff8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Oct 2011 16:39:17 -0700 Subject: Next pass of doxygen @brief cleanup. (bzr r10658) --- src/display/cairo-templates.h | 12 +++++++----- src/display/cairo-utils.h | 12 +++++++----- src/display/canvas-axonomgrid.cpp | 10 +++++----- src/display/canvas-grid.h | 5 ++--- src/display/drawing-context.h | 2 +- src/display/drawing-group.h | 2 +- src/display/drawing-image.h | 2 +- src/display/drawing-item.h | 2 +- src/display/drawing-shape.h | 2 +- src/display/drawing-surface.h | 2 +- src/display/drawing-text.h | 2 +- src/display/drawing.h | 2 +- src/display/nr-filter-primitive.h | 6 ++++-- src/display/nr-style.h | 2 +- src/display/sodipodi-ctrlrect.h | 2 +- 15 files changed, 35 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index d4c8e1493..b48a22702 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -1,6 +1,6 @@ /** * @file - * @brief Cairo software blending templates + * Cairo software blending templates. *//* * Authors: * Krzysztof KosiÅ„ski @@ -31,11 +31,12 @@ static const int OPENMP_THRESHOLD = 2048; #include "display/cairo-utils.h" /** - * @brief Blend two surfaces using the supplied functor. + * Blend two surfaces using the supplied functor. * This template blends two Cairo image surfaces using a blending functor that takes * two 32-bit ARGB pixel values and returns a modified 32-bit pixel value. * Differences in input surface formats are handled transparently. In future, this template - * will also handle software fallback for GL surfaces. */ + * will also handle software fallback for GL surfaces. + */ template void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_surface_t *out, Blend blend) { @@ -303,12 +304,13 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter /** - * @brief Synthesize surface pixels based on their position. + * Synthesize surface pixels based on their position. * This template accepts a functor that gets called with the x and y coordinates of the pixels, * given as integers. * @param out Output surface * @param out_area The region of the output surface that should be synthesized - * @param synth Synthesis functor */ + * @param synth Synthesis functor + */ template void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const &out_area, Synth synth) { diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 1de88785d..dc11231b9 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -1,6 +1,6 @@ /** * @file - * @brief Cairo integration helpers + * Cairo integration helpers. *//* * Authors: * Krzysztof KosiÅ„ski @@ -21,9 +21,11 @@ struct SPColor; namespace Inkscape { -/** @brief RAII idiom for Cairo groups. +/** + * RAII idiom for Cairo groups. * Groups are temporary surfaces used when rendering e.g. masks and opacity. - * Use this class to ensure that each group push is matched with a pop. */ + * Use this class to ensure that each group push is matched with a pop. + */ class CairoGroup { public: CairoGroup(cairo_t *_ct); @@ -38,7 +40,7 @@ private: bool pushed; }; -/** @brief RAII idiom for Cairo state saving */ +/** RAII idiom for Cairo state saving. */ class CairoSave { public: CairoSave(cairo_t *_ct, bool save=false) @@ -64,7 +66,7 @@ private: bool saved; }; -/** @brief Cairo context with Inkscape-specific operations */ +/** Cairo context with Inkscape-specific operations. */ class CairoContext : public Cairo::Context { public: CairoContext(cairo_t *obj, bool ref = false); diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index d346669ef..089fe88d1 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -46,11 +46,11 @@ enum Dim3 { X=0, Y, Z }; static double deg_to_rad(double deg) { return deg*M_PI/180.0;} /** - \brief This function renders a line on a particular canvas buffer, - using Bresenham's line drawing function. - http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html - Coordinates are interpreted as SCREENcoordinates -*/ + * This function renders a line on a particular canvas buffer, + * using Bresenham's line drawing function. + * http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html + * Coordinates are interpreted as SCREENcoordinates + */ static void sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba) { diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index db098d507..10feeca0e 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -1,5 +1,5 @@ /** @file - * @brief Cartesian grid item for the Inkscape canvas + * Cartesian grid item for the Inkscape canvas. */ /* Copyright (C) Johan Engelen 2006-2007 * Copyright (C) Lauris Kaplinski 2000 @@ -46,8 +46,7 @@ enum GridType { class CanvasGrid; -/** \brief All the variables that are tracked for a grid specific - canvas item. */ +/** All the variables that are tracked for a grid specific canvas item. */ struct GridCanvasItem : public SPCanvasItem{ CanvasGrid *grid; // the owning grid object }; diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index 4ada79057..fb6662202 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -1,6 +1,6 @@ /** * @file - * @brief Cairo drawing context with Inkscape extensions + * Cairo drawing context with Inkscape extensions. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 961e5b9a3..974b3c977 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -1,6 +1,6 @@ /** * @file - * @brief Group belonging to an SVG drawing element + * Group belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h index 300d6f0b5..306096d0e 100644 --- a/src/display/drawing-image.h +++ b/src/display/drawing-image.h @@ -1,6 +1,6 @@ /** * @file - * @brief Bitmap image belonging to an SVG drawing + * Bitmap image belonging to an SVG drawing. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index ca8b21336..cd8f128d8 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -1,6 +1,6 @@ /** * @file - * @brief Canvas item belonging to an SVG drawing element + * Canvas item belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 27bd7fbba..ce9bed2eb 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -1,6 +1,6 @@ /** * @file - * @brief Group belonging to an SVG drawing element + * Group belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index e3637d402..1ec848405 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -1,6 +1,6 @@ /** * @file - * @brief Cairo surface that remembers its origin + * Cairo surface that remembers its origin. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index 73caa6a7c..929d2bf2d 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -1,6 +1,6 @@ /** * @file - * @brief Group belonging to an SVG drawing element + * Group belonging to an SVG drawing element. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/drawing.h b/src/display/drawing.h index cfba4ebe6..bf3c4bbe8 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -1,6 +1,6 @@ /** * @file - * @brief SVG drawing for display + * SVG drawing for display. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 42a1c98b7..da2097156 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -97,7 +97,8 @@ public: */ Geom::Rect filter_primitive_area(FilterUnits const &units); - /** @brief Indicate whether the filter primitive can handle the given affine. + /** + *Indicate whether the filter primitive can handle the given affine. * * Results of some filter primitives depend on the coordinate system used when rendering. * A gaussian blur with equal x and y deviation will remain unchanged by rotations. @@ -108,7 +109,8 @@ public: * with edges parallel to the axes of the user coordinate system. This means * the matrices from FilterUnits will contain at most a (possibly non-uniform) scale * and a translation. When all primitives of the filter return true, the rendering is - * performed in display coordinate space and no intermediate surface is used. */ + * performed in display coordinate space and no intermediate surface is used. + */ virtual bool can_handle_affine(Geom::Affine const &) { return false; } protected: diff --git a/src/display/nr-style.h b/src/display/nr-style.h index 0ba6ce2c6..ce154cec0 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -1,6 +1,6 @@ /** * @file - * @brief Style information for rendering + * Style information for rendering. *//* * Authors: * Krzysztof KosiÅ„ski diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 45f8523ed..a83c7bc38 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -3,7 +3,7 @@ /** * \file sodipodi-ctrlrect.h - * \brief Simple non-transformed rectangle, usable for rubberband + * Simple non-transformed rectangle, usable for rubberband. * * Authors: * Lauris Kaplinski -- cgit v1.2.3 From 20097d47e6945bceb57d2335d23fe764f493ab59 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Oct 2011 20:44:17 -0700 Subject: Another minor pass of Doxygen cleanup. (bzr r10659) --- src/arc-context.cpp | 11 +- src/box3d-context.cpp | 6 +- src/desktop-events.cpp | 5 +- src/desktop.cpp | 46 ++- src/doxygen-main.cpp | 33 +- src/event-context.cpp | 30 +- src/file.cpp | 5 +- src/flood-context.cpp | 137 ++++---- src/gc.cpp | 2 +- src/gradient-drag.cpp | 308 ++++++++---------- src/graphlayout.cpp | 5 +- src/guide-snapper.cpp | 4 +- src/inkscape.cpp | 5 +- src/interface.cpp | 69 ++-- src/knotholder.cpp | 4 +- src/line-snapper.cpp | 2 +- src/lpe-tool-context.cpp | 9 +- src/object-snapper.cpp | 2 +- src/rdf.cpp | 21 +- src/rect-context.cpp | 6 +- src/rubberband.cpp | 2 +- src/selection-chemistry.cpp | 6 +- src/seltrans.cpp | 2 +- src/shape-editor.cpp | 2 +- src/snap-preferences.cpp | 10 +- src/snap.cpp | 264 +++++++--------- src/snapped-curve.cpp | 2 +- src/snapped-line.cpp | 2 +- src/snapped-point.cpp | 2 +- src/snapper.cpp | 10 +- src/sp-desc.cpp | 9 +- src/sp-item-transform.cpp | 66 ++-- src/sp-item.cpp | 14 +- src/sp-metadata.cpp | 53 ++-- src/sp-title.cpp | 9 +- src/spiral-context.cpp | 9 +- src/star-context.cpp | 12 +- src/style.cpp | 5 +- src/unclump.cpp | 5 +- src/uri.cpp | 96 +++--- src/verbs.cpp | 748 +++++++++++++++++++++++--------------------- src/winconsole.cpp | 5 +- 42 files changed, 1015 insertions(+), 1028 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 96f5e1cff..1f3e118fe 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Ellipse drawing context +/** + * @file + * Ellipse drawing context. */ /* Authors: * Mitsuru Oka @@ -153,9 +154,9 @@ static void sp_arc_context_dispose(GObject *object) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new knotholder. -*/ + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new knotholder. + */ void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer data) { SPArcContext *ac = SP_ARC_CONTEXT(data); diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 87b182d10..9c144e927 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -168,9 +168,9 @@ static void sp_box3d_context_dispose(GObject *object) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new knotholder -*/ + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new knotholder. + */ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, gpointer data) { Box3DContext *bc = SP_BOX3D_CONTEXT(data); diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index b886e884e..0565402a2 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Event handlers for SPDesktop +/** + * @file + * Event handlers for SPDesktop. */ /* Author: * Lauris Kaplinski diff --git a/src/desktop.cpp b/src/desktop.cpp index dc06f773e..2bec9afec 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -736,11 +736,10 @@ SPItem *SPDesktop::getGroupAtPoint(Geom::Point const p) const } /** - * \brief Returns the mouse point in document coordinates; if mouse is - * outside the canvas, returns the center of canvas viewpoint + * Returns the mouse point in document coordinates; if mouse is + * outside the canvas, returns the center of canvas viewpoint. */ -Geom::Point -SPDesktop::point() const +Geom::Point SPDesktop::point() const { Geom::Point p = _widget->getPointer(); Geom::Point pw = sp_canvas_window_to_world (canvas, p); @@ -882,8 +881,7 @@ SPDesktop::prev_zoom() /** * Set zoom to next in list. */ -void -SPDesktop::next_zoom() +void SPDesktop::next_zoom() { if (zooms_future.empty()) { this->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No next zoom.")); @@ -901,12 +899,12 @@ SPDesktop::next_zoom() zooms_future.pop_front(); } -/** \brief Performs a quick zoom into what the user is working on - \param enable Whether we're going in or out of quick zoom - -*/ -void -SPDesktop::zoom_quick (bool enable) +/** + * Performs a quick zoom into what the user is working on. + * + * @param enable Whether we're going in or out of quick zoom. + */ +void SPDesktop::zoom_quick(bool enable) { if (enable == _quick_zoom_enabled) { return; @@ -1241,22 +1239,22 @@ SPDesktop::fullscreen() _widget->setFullscreen(); } -/** \brief Checks to see if the user is working in focused mode - - Returns the value of \c _focusMode -*/ -bool -SPDesktop::is_focusMode() +/** + * Checks to see if the user is working in focused mode. + * + * @return the value of \c _focusMode. + */ +bool SPDesktop::is_focusMode() { return _focusMode; } -/** \brief Changes whether the user is in focus mode or not - \param mode Which mode the view should be in - -*/ -void -SPDesktop::focusMode (bool mode) +/** + * Changes whether the user is in focus mode or not. + * + * @param mode Which mode the view should be in. + */ +void SPDesktop::focusMode(bool mode) { if (mode == _focusMode) { return; } diff --git a/src/doxygen-main.cpp b/src/doxygen-main.cpp index 58c2f3f9a..7b6148f7a 100644 --- a/src/doxygen-main.cpp +++ b/src/doxygen-main.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Doxygen documentation - main page and namespace documentation. +/** + * @file + * Doxygen documentation - main page and namespace documentation. */ /* Authors: * Ralf Stephan @@ -13,14 +14,14 @@ // Note: % before a word prevents that word from being linkified /** - * @brief Main %Inkscape namespace + * Main %Inkscape namespace. * * This namespace contains all code internal to %Inkscape. */ namespace Inkscape { /** - * @brief Some STL-style algorithms + * Some STL-style algorithms. * * This namespace contains a few generic algorithms used with the %XML tree. */ @@ -28,7 +29,7 @@ namespace Algorithms {} /** - * @brief Debugging utilities + * Debugging utilities. * * This namespace contains various debugging code which can help developers * to pinpoint problems with their (or others') code. @@ -36,14 +37,14 @@ namespace Algorithms {} namespace Debug {} /** - * @brief Rendering-related code + * Rendering-related code. * * This namespace contains code related to the renderer. */ namespace Display {} /** - * @brief Extension support + * Extension support. * * This namespace contains the extension subsystem and implementations * of the internal extensions. This includes input and output filters, bitmap @@ -52,7 +53,7 @@ namespace Display {} namespace Extension {} /** - * @brief Boehm-GC based garbage collector + * Boehm-GC based garbage collector. * * This namespace contains code related to the garbage collector and base * classes for %GC-managed objects. @@ -60,7 +61,7 @@ namespace Extension {} namespace GC {} /** - * @brief Low-level IO code + * Low-level IO code. * * This namespace contains low level IO-related code, including a homegrown * streams implementation, routines for formatting SVG output, and some @@ -69,7 +70,7 @@ namespace GC {} namespace IO {} /** - * @brief Live Path Effects code + * Live Path Effects code. * * This namespace contains classes and functions related to the implementation * of Live Path Effects, which apply arbitrary transformation to a path and @@ -78,7 +79,7 @@ namespace IO {} namespace LivePathEffect {} /** - * @brief Tracing backend + * Tracing backend. * * This namespace contains the integrated potrace-based tracing backend, used * in the Trace Bitmap and Paint Bucket features. @@ -86,21 +87,21 @@ namespace LivePathEffect {} namespace Trace {} /** - * @brief User interface code + * User interface code. * * This namespace contains everything related to the user interface of Inkscape. */ namespace UI { /** - * @brief Dialog code + * Dialog code. * * This namespace contains all code related to dialogs. */ namespace Dialog {} /** - * @brief Custom widgets + * Custom widgets. * * This namespace contains custom user interface widgets used thorought * Inkscape. @@ -110,7 +111,7 @@ namespace Widget {} } // namespace UI /** - * @brief Miscellaneous supporting code + * Miscellaneous supporting code. * * This namespace contains miscellaneous low-level code: an implementation of * garbage-collected lists, tuples, generic pointer iterators and length unit @@ -119,7 +120,7 @@ namespace Widget {} namespace Util {} /** - * @brief %Inkscape %XML tree + * @Inkscape %XML tree. * * This namespace contains classes and functions that comprise the XML tree * of Inkscape documents. diff --git a/src/event-context.cpp b/src/event-context.cpp index 5a1c7130a..a92ab55e2 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -1,4 +1,5 @@ -/** \file +/** + * @file * Main event handling, and related helper functions. * * Authors: @@ -233,7 +234,7 @@ static void sp_event_context_private_setup(SPEventContext *ec) { } /** - * \brief Gobbles next key events on the queue with the same keyval and mask. Returns the number of events consumed. + * Gobbles next key events on the queue with the same keyval and mask. Returns the number of events consumed. */ gint gobble_key_events(guint keyval, gint mask) { GdkEvent *event_next; @@ -259,7 +260,7 @@ gint gobble_key_events(guint keyval, gint mask) { } /** - * \brief Gobbles next motion notify events on the queue with the same mask. Returns the number of events consumed. + * Gobbles next motion notify events on the queue with the same mask. Returns the number of events consumed. */ gint gobble_motion_events(gint mask) { GdkEvent *event_next; @@ -771,9 +772,8 @@ gint sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item, } /** - * @brief: Returns true if we're hovering above a knot (needed because we don't want to pre-snap in that case) + * Returns true if we're hovering above a knot (needed because we don't want to pre-snap in that case). */ - bool sp_event_context_knot_mouseover(SPEventContext *ec) { if (ec->shape_editor) { @@ -784,7 +784,7 @@ bool sp_event_context_knot_mouseover(SPEventContext *ec) } /** - * @brief An observer that relays pref changes to the derived classes + * An observer that relays pref changes to the derived classes. */ class ToolPrefObserver: public Inkscape::Preferences::Observer { public: @@ -1184,15 +1184,15 @@ void event_context_print_event_info(GdkEvent *event, bool print_return) { } /** - * \brief Analyses the current event, calculates the mouse speed, turns snapping off (temporarily) if the + * Analyses the current event, calculates the mouse speed, turns snapping off (temporarily) if the * mouse speed is above a threshold, and stores the current event such that it can be re-triggered when needed - * (re-triggering is controlled by a watchdog timer) + * (re-triggering is controlled by a watchdog timer). * - * \param ec Pointer to the event context - * \param dse_item Pointer that store a reference to a canvas or to an item - * \param dse_item2 Another pointer, storing a reference to a knot or controlpoint - * \param event Pointer to the motion event - * \param origin Identifier (enum) specifying where the delay (and the call to this method) were initiated + * @param ec Pointer to the event context. + * @param dse_item Pointer that store a reference to a canvas or to an item. + * @param dse_item2 Another pointer, storing a reference to a knot or controlpoint. + * @param event Pointer to the motion event. + * @param origin Identifier (enum) specifying where the delay (and the call to this method) were initiated. */ void sp_event_context_snap_delay_handler(SPEventContext *ec, gpointer const dse_item, gpointer const dse_item2, GdkEventMotion *event, @@ -1270,8 +1270,8 @@ void sp_event_context_snap_delay_handler(SPEventContext *ec, } /** - * \brief When the snap delay watchdog timer barks, this method will be called and will re-inject the last motion - * event in an appropriate place, with snapping being turned on again + * When the snap delay watchdog timer barks, this method will be called and will re-inject the last motion + * event in an appropriate place, with snapping being turned on again. */ gboolean sp_event_context_snap_watchdog_callback(gpointer data) { // Snap NOW! For this the "postponed" flag will be reset and the last motion event will be repeated diff --git a/src/file.cpp b/src/file.cpp index 350281dee..e8901d306 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief File/Print operations +/** + * @file + * File/Print operations. */ /* Authors: * Lauris Kaplinski diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 9e8705862..6d291a482 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Bucket fill drawing context, works by bitmap filling an area on a rendered version +/** + * @file + * Bucket fill drawing context, works by bitmap filling an area on a rendered version * of the current display and then tracing the result using potrace. */ /* Author: @@ -158,9 +159,9 @@ static void sp_flood_context_dispose(GObject *object) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new knotholder -*/ + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new knotholder. + */ void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPFloodContext *rc = SP_FLOOD_CONTEXT(data); @@ -216,11 +217,11 @@ compose_onto (guint32 px, guint32 bg) } /** - * \brief Get the pointer to a pixel in a pixel buffer. - * \param px The pixel buffer. - * \param x The X coordinate. - * \param y The Y coordinate. - * \param stride The rowstride of the pixel buffer. + * Get the pointer to a pixel in a pixel buffer. + * @param px The pixel buffer. + * @param x The X coordinate. + * @param y The Y coordinate. + * @param stride The rowstride of the pixel buffer. */ inline guint32 get_pixel(guchar *px, int x, int y, int stride) { return *reinterpret_cast(px + y * stride + x * 4); @@ -231,7 +232,7 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width } /** - * \brief Generate the list of trace channel selection entries. + * Generate the list of trace channel selection entries. */ GList * flood_channels_dropdown_items_list() { GList *glist = NULL; @@ -249,7 +250,7 @@ GList * flood_channels_dropdown_items_list() { } /** - * \brief Generate the list of autogap selection entries. + * Generate the list of autogap selection entries. */ GList * flood_autogap_dropdown_items_list() { GList *glist = NULL; @@ -263,13 +264,13 @@ GList * flood_autogap_dropdown_items_list() { } /** - * \brief Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation. - * \param check The pixel in the pixel buffer to check. - * \param orig The original selected pixel to use as the fill target color. - * \param merged_orig_pixel The original pixel merged with the background. - * \param dtc The desktop background color. - * \param threshold The fill threshold. - * \param method The fill method to use as defined in PaintBucketChannels. + * Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation. + * @param check The pixel in the pixel buffer to check. + * @param orig The original selected pixel to use as the fill target color. + * @param merged_orig_pixel The original pixel merged with the background. + * @param dtc The desktop background color. + * @param threshold The fill threshold. + * @param method The fill method to use as defined in PaintBucketChannels. */ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixel, guint32 dtc, int threshold, PaintBucketChannels method) { @@ -367,13 +368,13 @@ struct bitmap_coords_info { }; /** - * \brief Check if a pixel can be included in the fill. - * \param px The rendered pixel buffer to check. - * \param trace_t The pixel in the trace pixel buffer to check or mark. - * \param x The X coordinate. - * \param y The y coordinate. - * \param orig_color The original selected pixel to use as the fill target color. - * \param bci The bitmap_coords_info structure. + * Check if a pixel can be included in the fill. + * @param px The rendered pixel buffer to check. + * @param trace_t The pixel in the trace pixel buffer to check or mark. + * @param x The X coordinate. + * @param y The y coordinate. + * @param orig_color The original selected pixel to use as the fill target color. + * @param bci The bitmap_coords_info structure. */ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_t, int x, int y, guint32 orig_color, bitmap_coords_info bci) { if (is_pixel_paintability_checked(trace_t)) { @@ -391,11 +392,11 @@ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_ } /** - * \brief Perform the bitmap-to-vector tracing and place the traced path onto the document. - * \param px The trace pixel buffer to trace to SVG. - * \param desktop The desktop on which to place the final SVG path. - * \param transform The transform to apply to the final SVG path. - * \param union_with_selection If true, merge the final SVG path with the current selection. + * Perform the bitmap-to-vector tracing and place the traced path onto the document. + * @param px The trace pixel buffer to trace to SVG. + * @param desktop The desktop on which to place the final SVG path. + * @param transform The transform to apply to the final SVG path. + * @param union_with_selection If true, merge the final SVG path with the current selection. */ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, Geom::Affine transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) { SPDocument *document = sp_desktop_document(desktop); @@ -526,7 +527,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto } /** - * \brief The possible return states of perform_bitmap_scanline_check() + * The possible return states of perform_bitmap_scanline_check(). */ enum ScanlineCheckResult { SCANLINE_CHECK_OK, @@ -535,10 +536,10 @@ enum ScanlineCheckResult { }; /** - * \brief Determine if the provided coordinates are within the pixel buffer limits. - * \param x The X coordinate. - * \param y The Y coordinate. - * \param bci The bitmap_coords_info structure. + * Determine if the provided coordinates are within the pixel buffer limits. + * @param x The X coordinate. + * @param y The Y coordinate. + * @param bci The bitmap_coords_info structure. */ inline static bool coords_in_range(unsigned int x, unsigned int y, bitmap_coords_info bci) { return (x < bci.width) && @@ -552,12 +553,12 @@ inline static bool coords_in_range(unsigned int x, unsigned int y, bitmap_coords #define PAINT_DIRECTION_ALL 15 /** - * \brief Paint a pixel or a square (if autogap is enabled) on the trace pixel buffer - * \param px The rendered pixel buffer to check. - * \param trace_px The trace pixel buffer. - * \param orig_color The original selected pixel to use as the fill target color. - * \param bci The bitmap_coords_info structure. - * \param original_point_trace_t The original pixel in the trace pixel buffer to check. + * Paint a pixel or a square (if autogap is enabled) on the trace pixel buffer. + * @param px The rendered pixel buffer to check. + * @param trace_px The trace pixel buffer. + * @param orig_color The original selected pixel to use as the fill target color. + * @param bci The bitmap_coords_info structure. + * @param original_point_trace_t The original pixel in the trace pixel buffer to check. */ inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, guint32 orig_color, bitmap_coords_info bci, unsigned char *original_point_trace_t) { if (bci.radius == 0) { @@ -600,12 +601,12 @@ inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, guint32 ori } /** - * \brief Push a point to be checked onto the bottom of the rendered pixel buffer check queue. - * \param fill_queue The fill queue to add the point to. - * \param max_queue_size The maximum size of the fill queue. - * \param trace_t The trace pixel buffer pixel. - * \param x The X coordinate. - * \param y The Y coordinate. + * Push a point to be checked onto the bottom of the rendered pixel buffer check queue. + * @param fill_queue The fill queue to add the point to. + * @param max_queue_size The maximum size of the fill queue. + * @param trace_t The trace pixel buffer pixel. + * @param x The X coordinate. + * @param y The Y coordinate. */ static void push_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { if (!is_pixel_queued(trace_t)) { @@ -617,12 +618,12 @@ static void push_point_onto_queue(std::deque *fill_queue, unsigned } /** - * \brief Shift a point to be checked onto the top of the rendered pixel buffer check queue. - * \param fill_queue The fill queue to add the point to. - * \param max_queue_size The maximum size of the fill queue. - * \param trace_t The trace pixel buffer pixel. - * \param x The X coordinate. - * \param y The Y coordinate. + * Shift a point to be checked onto the top of the rendered pixel buffer check queue. + * @param fill_queue The fill queue to add the point to. + * @param max_queue_size The maximum size of the fill queue. + * @param trace_t The trace pixel buffer pixel. + * @param x The X coordinate. + * @param y The Y coordinate. */ static void shift_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { if (!is_pixel_queued(trace_t)) { @@ -634,12 +635,12 @@ static void shift_point_onto_queue(std::deque *fill_queue, unsigned } /** - * \brief Scan a row in the rendered pixel buffer and add points to the fill queue as necessary. - * \param fill_queue The fill queue to add the point to. - * \param px The rendered pixel buffer. - * \param trace_px The trace pixel buffer. - * \param orig_color The original selected pixel to use as the fill target color. - * \param bci The bitmap_coords_info structure. + * Scan a row in the rendered pixel buffer and add points to the fill queue as necessary. + * @param fill_queue The fill queue to add the point to. + * @param px The rendered pixel buffer. + * @param trace_px The trace pixel buffer. + * @param orig_color The original selected pixel to use as the fill target color. + * @param bci The bitmap_coords_info structure. */ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, guint32 orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { bool aborted = false; @@ -751,26 +752,26 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque } /** - * \brief Sort the rendered pixel buffer check queue vertically. + * Sort the rendered pixel buffer check queue vertically. */ static bool sort_fill_queue_vertical(Geom::Point a, Geom::Point b) { return a[Geom::Y] > b[Geom::Y]; } /** - * \brief Sort the rendered pixel buffer check queue horizontally. + * Sort the rendered pixel buffer check queue horizontally. */ static bool sort_fill_queue_horizontal(Geom::Point a, Geom::Point b) { return a[Geom::X] > b[Geom::X]; } /** - * \brief Perform a flood fill operation. - * \param event_context The event context for this tool. - * \param event The details of this event. - * \param union_with_selection If true, union the new fill with the current selection. - * \param is_point_fill If false, use the Rubberband "touch selection" to get the initial points for the fill. - * \param is_touch_fill If true, use only the initial contact point in the Rubberband "touch selection" as the fill target color. + * Perform a flood fill operation. + * @param event_context The event context for this tool. + * @param event The details of this event. + * @param union_with_selection If true, union the new fill with the current selection. + * @param is_point_fill If false, use the Rubberband "touch selection" to get the initial points for the fill. + * @param is_touch_fill If true, use only the initial contact point in the Rubberband "touch selection" as the fill target color. */ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *event, bool union_with_selection, bool is_point_fill, bool is_touch_fill) { SPDesktop *desktop = event_context->desktop; diff --git a/src/gc.cpp b/src/gc.cpp index 6b904c05f..1ba0826ef 100644 --- a/src/gc.cpp +++ b/src/gc.cpp @@ -1,5 +1,5 @@ /** @file - * @brief Wrapper for Boehm GC + * Wrapper for Boehm GC. */ /* Authors: * MenTaLguY diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index afed09654..ad39382e5 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -95,8 +95,7 @@ gr_drag_sel_changed(Inkscape::Selection */*selection*/, gpointer data) drag->updateLevels (); } -static void -gr_drag_sel_modified (Inkscape::Selection */*selection*/, guint /*flags*/, gpointer data) +static void gr_drag_sel_modified(Inkscape::Selection */*selection*/, guint /*flags*/, gpointer data) { GrDrag *drag = (GrDrag *) data; if (drag->local_change) { @@ -109,12 +108,11 @@ gr_drag_sel_modified (Inkscape::Selection */*selection*/, guint /*flags*/, gpoin } /** -When a _query_style_signal is received, check that \a property requests fill/stroke/opacity (otherwise -skip), and fill the \a style with the averaged color of all draggables of the selected dragger, if -any. -*/ -int -gr_drag_style_query (SPStyle *style, int property, gpointer data) + * When a _query_style_signal is received, check that \a property requests fill/stroke/opacity (otherwise + * skip), and fill the \a style with the averaged color of all draggables of the selected dragger, if + * any. + */ +int gr_drag_style_query(SPStyle *style, int property, gpointer data) { GrDrag *drag = (GrDrag *) data; @@ -336,8 +334,7 @@ guint32 GrDrag::getColor() return SP_RGBA32_F_COMPOSE(cf[0], cf[1], cf[2], cf[3]); } -SPStop * -GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) +SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double tolerance) { gfloat offset = 0; // type of SPStop.offset = gfloat SPGradient *gradient; @@ -413,8 +410,7 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) } -bool -GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p) +bool GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p) { // Note: not sure if a null pointer can come in for the style, but handle that just in case bool stopIsNull = false; @@ -543,7 +539,7 @@ GrDrag::~GrDrag() this->lines = NULL; } -GrDraggable::GrDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke) +GrDraggable::GrDraggable(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke) { this->item = item; this->point_type = point_type; @@ -553,7 +549,7 @@ GrDraggable::GrDraggable (SPItem *item, guint point_type, guint point_i, bool fi g_object_ref (G_OBJECT (this->item)); } -GrDraggable::~GrDraggable () +GrDraggable::~GrDraggable() { g_object_unref (G_OBJECT (this->item)); } @@ -575,8 +571,7 @@ SPObject *GrDraggable::getServer() return server; } -static void -gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gpointer data) +static void gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gpointer data) { GrDragger *dragger = (GrDragger *) data; GrDrag *drag = dragger->parent; @@ -741,8 +736,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp } -static void -gr_midpoint_limits(GrDragger *dragger, SPObject *server, Geom::Point *begin, Geom::Point *end, Geom::Point *low_lim, Geom::Point *high_lim, GSList **moving) +static void gr_midpoint_limits(GrDragger *dragger, SPObject *server, Geom::Point *begin, Geom::Point *end, Geom::Point *low_lim, Geom::Point *high_lim, GSList **moving) { GrDrag *drag = dragger->parent; @@ -827,10 +821,9 @@ gr_midpoint_limits(GrDragger *dragger, SPObject *server, Geom::Point *begin, Geo /** -Called when a midpoint knot is dragged. -*/ -static void -gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, guint state, gpointer data) + * Called when a midpoint knot is dragged. + */ +static void gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, guint state, gpointer data) { GrDragger *dragger = (GrDragger *) data; GrDrag *drag = dragger->parent; @@ -894,8 +887,7 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, gu -static void -gr_knot_grabbed_handler (SPKnot */*knot*/, unsigned int /*state*/, gpointer data) +static void gr_knot_grabbed_handler(SPKnot */*knot*/, unsigned int /*state*/, gpointer data) { GrDragger *dragger = (GrDragger *) data; @@ -903,10 +895,9 @@ gr_knot_grabbed_handler (SPKnot */*knot*/, unsigned int /*state*/, gpointer data } /** -Called when the mouse releases a dragger knot; changes gradient writing to repr, updates other draggers if needed -*/ -static void -gr_knot_ungrabbed_handler (SPKnot *knot, unsigned int state, gpointer data) + * Called when the mouse releases a dragger knot; changes gradient writing to repr, updates other draggers if needed. + */ +static void gr_knot_ungrabbed_handler(SPKnot *knot, unsigned int state, gpointer data) { GrDragger *dragger = (GrDragger *) data; @@ -941,11 +932,10 @@ gr_knot_ungrabbed_handler (SPKnot *knot, unsigned int state, gpointer data) } /** -Called when a dragger knot is clicked; selects the dragger or deletes it depending on the -state of the keyboard keys -*/ -static void -gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data) + * Called when a dragger knot is clicked; selects the dragger or deletes it depending on the + * state of the keyboard keys. + */ +static void gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data) { GrDragger *dragger = (GrDragger *) data; GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; @@ -1005,10 +995,9 @@ gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data) } /** -Called when a dragger knot is doubleclicked; opens gradient editor with the stop from the first draggable -*/ -static void -gr_knot_doubleclicked_handler (SPKnot */*knot*/, guint /*state*/, gpointer data) + * Called when a dragger knot is doubleclicked; opens gradient editor with the stop from the first draggable. + */ +static void gr_knot_doubleclicked_handler(SPKnot */*knot*/, guint /*state*/, gpointer data) { GrDragger *dragger = (GrDragger *) data; @@ -1022,10 +1011,9 @@ gr_knot_doubleclicked_handler (SPKnot */*knot*/, guint /*state*/, gpointer data) } /** -Act upon all draggables of the dragger, setting them to the dragger's point -*/ -void -GrDragger::fireDraggables (bool write_repr, bool scale_radial, bool merging_focus) + * Act upon all draggables of the dragger, setting them to the dragger's point. + */ +void GrDragger::fireDraggables(bool write_repr, bool scale_radial, bool merging_focus) { for (GSList const* i = this->draggables; i != NULL; i = i->next) { GrDraggable *draggable = (GrDraggable *) i->data; @@ -1044,10 +1032,9 @@ GrDragger::fireDraggables (bool write_repr, bool scale_radial, bool merging_focu } /** -Checks if the dragger has a draggable with this point_type + * Checks if the dragger has a draggable with this point_type. */ -bool -GrDragger::isA (gint point_type) +bool GrDragger::isA(gint point_type) { for (GSList const* i = this->draggables; i != NULL; i = i->next) { GrDraggable *draggable = (GrDraggable *) i->data; @@ -1059,10 +1046,9 @@ GrDragger::isA (gint point_type) } /** -Checks if the dragger has a draggable with this item, point_type + point_i (number), fill_or_stroke + * Checks if the dragger has a draggable with this item, point_type + point_i (number), fill_or_stroke. */ -bool -GrDragger::isA (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke) +bool GrDragger::isA(SPItem *item, gint point_type, gint point_i, bool fill_or_stroke) { for (GSList const* i = this->draggables; i != NULL; i = i->next) { GrDraggable *draggable = (GrDraggable *) i->data; @@ -1074,10 +1060,9 @@ GrDragger::isA (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke } /** -Checks if the dragger has a draggable with this item, point_type, fill_or_stroke + * Checks if the dragger has a draggable with this item, point_type, fill_or_stroke. */ -bool -GrDragger::isA (SPItem *item, gint point_type, bool fill_or_stroke) +bool GrDragger::isA(SPItem *item, gint point_type, bool fill_or_stroke) { for (GSList const* i = this->draggables; i != NULL; i = i->next) { GrDraggable *draggable = (GrDraggable *) i->data; @@ -1088,8 +1073,7 @@ GrDragger::isA (SPItem *item, gint point_type, bool fill_or_stroke) return false; } -bool -GrDraggable::mayMerge (GrDraggable *da2) +bool GrDraggable::mayMerge(GrDraggable *da2) { if ((this->item == da2->item) && (this->fill_or_stroke == da2->fill_or_stroke)) { // we must not merge the points of the same gradient! @@ -1108,8 +1092,7 @@ GrDraggable::mayMerge (GrDraggable *da2) return true; } -bool -GrDragger::mayMerge (GrDragger *other) +bool GrDragger::mayMerge(GrDragger *other) { if (this == other) return false; @@ -1125,8 +1108,7 @@ GrDragger::mayMerge (GrDragger *other) return true; } -bool -GrDragger::mayMerge (GrDraggable *da2) +bool GrDragger::mayMerge(GrDraggable *da2) { for (GSList const* i = this->draggables; i != NULL; i = i->next) { // for all draggables of this GrDraggable *da1 = (GrDraggable *) i->data; @@ -1137,10 +1119,9 @@ GrDragger::mayMerge (GrDraggable *da2) } /** -Updates the statusbar tip of the dragger knot, based on its draggables + * Updates the statusbar tip of the dragger knot, based on its draggables. */ -void -GrDragger::updateTip () +void GrDragger::updateTip() { if (this->knot && this->knot->tip) { g_free (this->knot->tip); @@ -1181,10 +1162,9 @@ GrDragger::updateTip () } /** -Adds a draggable to the dragger + * Adds a draggable to the dragger. */ -void -GrDragger::updateKnotShape () +void GrDragger::updateKnotShape() { if (!draggables) return; @@ -1193,10 +1173,9 @@ GrDragger::updateKnotShape () } /** -Adds a draggable to the dragger + * Adds a draggable to the dragger. */ -void -GrDragger::addDraggable (GrDraggable *draggable) +void GrDragger::addDraggable(GrDraggable *draggable) { this->draggables = g_slist_prepend (this->draggables, draggable); @@ -1205,10 +1184,9 @@ GrDragger::addDraggable (GrDraggable *draggable) /** -Moves this dragger to the point of the given draggable, acting upon all other draggables + * Moves this dragger to the point of the given draggable, acting upon all other draggables. */ -void -GrDragger::moveThisToDraggable (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr) +void GrDragger::moveThisToDraggable(SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr) { GrDraggable *dr_first = (GrDraggable *) this->draggables->data; if (!dr_first) return; @@ -1233,10 +1211,10 @@ GrDragger::moveThisToDraggable (SPItem *item, gint point_type, gint point_i, boo /** -Moves all midstop draggables that depend on this one + * Moves all midstop draggables that depend on this one. */ -void -GrDragger::updateMidstopDependencies (GrDraggable *draggable, bool write_repr) { +void GrDragger::updateMidstopDependencies(GrDraggable *draggable, bool write_repr) +{ SPObject *server = draggable->getServer(); if (!server) return; @@ -1257,10 +1235,9 @@ GrDragger::updateMidstopDependencies (GrDraggable *draggable, bool write_repr) { /** -Moves all draggables that depend on this one + * Moves all draggables that depend on this one. */ -void -GrDragger::updateDependencies (bool write_repr) +void GrDragger::updateDependencies(bool write_repr) { for (GSList const* i = this->draggables; i != NULL; i = i->next) { GrDraggable *draggable = (GrDraggable *) i->data; @@ -1317,7 +1294,7 @@ GrDragger::updateDependencies (bool write_repr) -GrDragger::GrDragger (GrDrag *parent, Geom::Point p, GrDraggable *draggable) +GrDragger::GrDragger(GrDrag *parent, Geom::Point p, GrDraggable *draggable) : point(p), point_original(p) { @@ -1358,7 +1335,7 @@ GrDragger::GrDragger (GrDrag *parent, Geom::Point p, GrDraggable *draggable) updateKnotShape(); } -GrDragger::~GrDragger () +GrDragger::~GrDragger() { // unselect if it was selected this->parent->setDeselected(this); @@ -1382,10 +1359,9 @@ GrDragger::~GrDragger () } /** -Select the dragger which has the given draggable. -*/ -GrDragger * -GrDrag::getDraggerFor (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke) + * Select the dragger which has the given draggable. + */ +GrDragger *GrDrag::getDraggerFor(SPItem *item, gint point_type, gint point_i, bool fill_or_stroke) { for (GList const* i = this->draggers; i != NULL; i = i->next) { GrDragger *dragger = (GrDragger *) i->data; @@ -1403,8 +1379,7 @@ GrDrag::getDraggerFor (SPItem *item, gint point_type, gint point_i, bool fill_or } -void -GrDragger::moveOtherToDraggable (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr) +void GrDragger::moveOtherToDraggable(SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr) { GrDragger *d = this->parent->getDraggerFor (item, point_type, point_i, fill_or_stroke); if (d && d != this) { @@ -1414,20 +1389,18 @@ GrDragger::moveOtherToDraggable (SPItem *item, gint point_type, gint point_i, bo /** - Draw this dragger as selected -*/ -void -GrDragger::select() + * Draw this dragger as selected. + */ +void GrDragger::select() { this->knot->fill [SP_KNOT_STATE_NORMAL] = GR_KNOT_COLOR_SELECTED; g_object_set (G_OBJECT (this->knot->item), "fill_color", GR_KNOT_COLOR_SELECTED, NULL); } /** - Draw this dragger as normal (deselected) -*/ -void -GrDragger::deselect() + * Draw this dragger as normal (deselected). + */ +void GrDragger::deselect() { this->knot->fill [SP_KNOT_STATE_NORMAL] = GR_KNOT_COLOR_NORMAL; g_object_set (G_OBJECT (this->knot->item), "fill_color", GR_KNOT_COLOR_NORMAL, NULL); @@ -1440,10 +1413,9 @@ GrDragger::isSelected() } /** -\brief Deselect all stops/draggers (private) -*/ -void -GrDrag::deselect_all() + * Deselect all stops/draggers (private). + */ +void GrDrag::deselect_all() { while (selected) { ( (GrDragger*) selected->data)->deselect(); @@ -1452,20 +1424,18 @@ GrDrag::deselect_all() } /** -\brief Deselect all stops/draggers (public; emits signal) -*/ -void -GrDrag::deselectAll() + * Deselect all stops/draggers (public; emits signal). + */ +void GrDrag::deselectAll() { deselect_all(); this->desktop->emitToolSubselectionChanged(NULL); } /** -\brief Select all stops/draggers -*/ -void -GrDrag::selectAll() + * Select all stops/draggers. + */ +void GrDrag::selectAll() { for (GList *l = this->draggers; l != NULL; l = l->next) { GrDragger *d = ((GrDragger *) l->data); @@ -1474,10 +1444,9 @@ GrDrag::selectAll() } /** -\brief Select all stops/draggers that match the coords -*/ -void -GrDrag::selectByCoords(std::vector coords) + * Select all stops/draggers that match the coords. + */ +void GrDrag::selectByCoords(std::vector coords) { for (GList *l = this->draggers; l != NULL; l = l->next) { GrDragger *d = ((GrDragger *) l->data); @@ -1491,10 +1460,9 @@ GrDrag::selectByCoords(std::vector coords) /** -\brief Select all stops/draggers that fall within the rect -*/ -void -GrDrag::selectRect(Geom::Rect const &r) + * Select all stops/draggers that fall within the rect. + */ +void GrDrag::selectRect(Geom::Rect const &r) { for (GList *l = this->draggers; l != NULL; l = l->next) { GrDragger *d = ((GrDragger *) l->data); @@ -1505,13 +1473,12 @@ GrDrag::selectRect(Geom::Rect const &r) } /** -\brief Select a dragger -\param dragger The dragger to select -\param add_to_selection If true, add to selection, otherwise deselect others -\param override If true, always select this node, otherwise toggle selected status + * Select a dragger. + * @param dragger The dragger to select. + * @param add_to_selection If true, add to selection, otherwise deselect others. + * @param override If true, always select this node, otherwise toggle selected status. */ -void -GrDrag::setSelected (GrDragger *dragger, bool add_to_selection, bool override) +void GrDrag::setSelected(GrDragger *dragger, bool add_to_selection, bool override) { GrDragger *seldragger = NULL; @@ -1550,11 +1517,10 @@ GrDrag::setSelected (GrDragger *dragger, bool add_to_selection, bool override) } /** -\brief Deselect a dragger -\param dragger The dragger to deselect -*/ -void -GrDrag::setDeselected (GrDragger *dragger) + * Deselect a dragger. + * @param dragger The dragger to deselect. + */ +void GrDrag::setDeselected(GrDragger *dragger) { if (g_list_find(selected, dragger)) { selected = g_list_remove(selected, dragger); @@ -1566,10 +1532,9 @@ GrDrag::setDeselected (GrDragger *dragger) /** -Create a line from p1 to p2 and add it to the lines list + * Create a line from p1 to p2 and add it to the lines list. */ -void -GrDrag::addLine (SPItem *item, Geom::Point p1, Geom::Point p2, guint32 rgba) +void GrDrag::addLine(SPItem *item, Geom::Point p1, Geom::Point p2, guint32 rgba) { SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(this->desktop), SP_TYPE_CTRLLINE, NULL); @@ -1583,11 +1548,10 @@ GrDrag::addLine (SPItem *item, Geom::Point p1, Geom::Point p2, guint32 rgba) } /** -If there already exists a dragger within MERGE_DIST of p, add the draggable to it; otherwise create -new dragger and add it to draggers list + * If there already exists a dragger within MERGE_DIST of p, add the draggable to it; otherwise create + * new dragger and add it to draggers list. */ -void -GrDrag::addDragger (GrDraggable *draggable) +void GrDrag::addDragger(GrDraggable *draggable) { Geom::Point p = sp_item_gradient_get_coords (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); @@ -1607,10 +1571,9 @@ GrDrag::addDragger (GrDraggable *draggable) } /** -Add draggers for the radial gradient rg on item -*/ -void -GrDrag::addDraggersRadial (SPRadialGradient *rg, SPItem *item, bool fill_or_stroke) + * Add draggers for the radial gradient rg on item. + */ +void GrDrag::addDraggersRadial(SPRadialGradient *rg, SPItem *item, bool fill_or_stroke) { addDragger (new GrDraggable (item, POINT_RG_CENTER, 0, fill_or_stroke)); guint num = rg->vector.stops.size(); @@ -1630,10 +1593,9 @@ GrDrag::addDraggersRadial (SPRadialGradient *rg, SPItem *item, bool fill_or_stro } /** -Add draggers for the linear gradient lg on item -*/ -void -GrDrag::addDraggersLinear (SPLinearGradient *lg, SPItem *item, bool fill_or_stroke) + * Add draggers for the linear gradient lg on item. + */ +void GrDrag::addDraggersLinear(SPLinearGradient *lg, SPItem *item, bool fill_or_stroke) { addDragger (new GrDraggable (item, POINT_LG_BEGIN, 0, fill_or_stroke)); guint num = lg->vector.stops.size(); @@ -1646,10 +1608,9 @@ GrDrag::addDraggersLinear (SPLinearGradient *lg, SPItem *item, bool fill_or_stro } /** -Artificially grab the knot of this dragger; used by the gradient context -*/ -void -GrDrag::grabKnot (GrDragger *dragger, gint x, gint y, guint32 etime) + * Artificially grab the knot of this dragger; used by the gradient context. + */ +void GrDrag::grabKnot(GrDragger *dragger, gint x, gint y, guint32 etime) { if (dragger) { sp_knot_start_dragging (dragger->knot, dragger->point, x, y, etime); @@ -1657,10 +1618,9 @@ GrDrag::grabKnot (GrDragger *dragger, gint x, gint y, guint32 etime) } /** -Artificially grab the knot of the dragger with this draggable; used by the gradient context -*/ -void -GrDrag::grabKnot (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime) + * Artificially grab the knot of the dragger with this draggable; used by the gradient context. + */ +void GrDrag::grabKnot(SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime) { GrDragger *dragger = getDraggerFor (item, point_type, point_i, fill_or_stroke); if (dragger) { @@ -1669,10 +1629,10 @@ GrDrag::grabKnot (SPItem *item, gint point_type, gint point_i, bool fill_or_stro } /** -Regenerates the draggers list from the current selection; is called when selection is changed or -modified, also when a radial dragger needs to update positions of other draggers in the gradient -*/ -void GrDrag::updateDraggers () + * Regenerates the draggers list from the current selection; is called when selection is changed or + * modified, also when a radial dragger needs to update positions of other draggers in the gradient. + */ +void GrDrag::updateDraggers() { while (selected) { selected = g_list_remove(selected, selected->data); @@ -1716,11 +1676,9 @@ void GrDrag::updateDraggers () /** - * \brief Returns true if at least one of the draggers' knots has the mouse hovering above it + * Returns true if at least one of the draggers' knots has the mouse hovering above it. */ - -bool -GrDrag::mouseOver() +bool GrDrag::mouseOver() { for (GList const* i = this->draggers; i != NULL; i = i->next) { GrDragger *d = (GrDragger *) i->data; @@ -1730,12 +1688,12 @@ GrDrag::mouseOver() } return false; } + /** -Regenerates the lines list from the current selection; is called on each move of a dragger, so that -lines are always in sync with the actual gradient -*/ -void -GrDrag::updateLines () + * Regenerates the lines list from the current selection; is called on each move of a dragger, so that + * lines are always in sync with the actual gradient. + */ +void GrDrag::updateLines() { // delete old lines for (GSList const *i = this->lines; i != NULL; i = i->next) { @@ -1781,10 +1739,9 @@ GrDrag::updateLines () } /** -Regenerates the levels list from the current selection -*/ -void -GrDrag::updateLevels () + * Regenerates the levels list from the current selection. + */ +void GrDrag::updateLevels() { hor_levels.clear(); vert_levels.clear(); @@ -1806,8 +1763,7 @@ GrDrag::updateLevels () } } -void -GrDrag::selected_reverse_vector () +void GrDrag::selected_reverse_vector() { if (selected == NULL) return; @@ -1819,14 +1775,12 @@ GrDrag::selected_reverse_vector () } } -void -GrDrag::selected_move_nowrite (double x, double y, bool scale_radial) +void GrDrag::selected_move_nowrite(double x, double y, bool scale_radial) { selected_move (x, y, false, scale_radial); } -void -GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial) +void GrDrag::selected_move(double x, double y, bool write_repr, bool scale_radial) { if (selected == NULL) return; @@ -1914,8 +1868,7 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial) } } -void -GrDrag::selected_move_screen (double x, double y) +void GrDrag::selected_move_screen(double x, double y) { gdouble zoom = desktop->current_zoom(); gdouble zx = x / zoom; @@ -1925,10 +1878,9 @@ GrDrag::selected_move_screen (double x, double y) } /** -Select the knot next to the last selected one and deselect all other selected. -*/ -GrDragger * -GrDrag::select_next () + * Select the knot next to the last selected one and deselect all other selected. + */ +GrDragger *GrDrag::select_next() { GrDragger *d = NULL; if (selected == NULL || g_list_find(draggers, selected->data)->next == NULL) { @@ -1943,10 +1895,9 @@ GrDrag::select_next () } /** -Select the knot previous from the last selected one and deselect all other selected. -*/ -GrDragger * -GrDrag::select_prev () + * Select the knot previous from the last selected one and deselect all other selected. + */ +GrDragger *GrDrag::select_prev() { GrDragger *d = NULL; if (selected == NULL || g_list_find(draggers, selected->data)->prev == NULL) { @@ -1962,8 +1913,7 @@ GrDrag::select_prev () // FIXME: i.m.o. an ugly function that I just made to work, but... aargh! (Johan) -void -GrDrag::deleteSelected (bool just_one) +void GrDrag::deleteSelected(bool just_one) { if (!selected) return; diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 6197be9f7..b0e00211a 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Interface between Inkscape code (SPItem) and graphlayout functions. +/** + * @file + * Interface between Inkscape code (SPItem) and graphlayout functions. */ /* * Authors: diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index d2db13060..f772aad96 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -1,6 +1,6 @@ /** - * \file guide-snapper.cpp - * \brief Snapping things to guides. + * @file guide-snapper.cpp + * Snapping things to guides. * * Authors: * Lauris Kaplinski diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 20084da54..fe59732a5 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Legacy interface to main application +/** + * @file + * Legacy interface to main application. */ /* Authors: * Lauris Kaplinski diff --git a/src/interface.cpp b/src/interface.cpp index 8cb9698b7..646400dd6 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Main UI stuff +/** + * @file + * Main UI stuff. */ /* Authors: * Lauris Kaplinski @@ -628,11 +629,9 @@ static void taskToggled(GtkCheckMenuItem *menuitem, gpointer userData) /** - * \brief Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline) and Color display mode + * Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline) and Color display mode. */ - -static gboolean -update_view_menu(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_data) +static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_data) { SPAction *action = (SPAction *) user_data; g_assert(action->id != NULL); @@ -867,7 +866,9 @@ void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view) } -/** @brief Observer that updates the recent list's max document count */ +/** + * Observer that updates the recent list's max document count. + */ class MaxRecentObserver : public Inkscape::Preferences::Observer { public: MaxRecentObserver(GtkWidget *recent_menu) : @@ -883,23 +884,24 @@ private: GtkWidget *_rm; }; -/** \brief This function turns XML into a menu - \param menus This is the XML that defines the menu - \param menu Menu to be added to - \param view The View that this menu is being built for - - This function is realitively simple as it just goes through the XML - and parses the individual elements. In the case of a submenu, it - just calls itself recursively. Because it is only reasonable to have - a couple of submenus, it is unlikely this will go more than two or - three times. - - In the case of an unrecognized verb, a menu item is made to identify - the verb that is missing, and display that. The menu item is also made - insensitive. -*/ -void -sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view) +/** + * This function turns XML into a menu. + * + * This function is realitively simple as it just goes through the XML + * and parses the individual elements. In the case of a submenu, it + * just calls itself recursively. Because it is only reasonable to have + * a couple of submenus, it is unlikely this will go more than two or + * three times. + * + * In the case of an unrecognized verb, a menu item is made to identify + * the verb that is missing, and display that. The menu item is also made + * insensitive. + * + * @param menus This is the XML that defines the menu + * @param menu Menu to be added to + * @param view The View that this menu is being built for + */ +void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view) { if (menus == NULL) return; if (menu == NULL) return; @@ -999,15 +1001,16 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI: } } -/** \brief Build the main tool bar - \param view View to build the bar for - - Currently the main tool bar is built as a dynamic XML menu using - \c sp_ui_build_dyn_menus. This function builds the bar, and then - pass it to get items attached to it. -*/ -GtkWidget * -sp_ui_main_menubar(Inkscape::UI::View::View *view) +/** + * Build the main tool bar. + * + * Currently the main tool bar is built as a dynamic XML menu using + * \c sp_ui_build_dyn_menus. This function builds the bar, and then + * pass it to get items attached to it. + * + * @param view View to build the bar for + */ +GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view) { GtkWidget *mbar = gtk_menu_bar_new(); diff --git a/src/knotholder.cpp b/src/knotholder.cpp index c26082baa..10d03982c 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -1,5 +1,5 @@ /* - * Container for SPKnot visual handles + * Container for SPKnot visual handles. * * Authors: * Mitsuru Oka @@ -92,7 +92,7 @@ KnotHolder::update_knots() } /** - * \brief Returns true if at least one of the KnotHolderEntities has the mouse hovering above it + * Returns true if at least one of the KnotHolderEntities has the mouse hovering above it. */ bool KnotHolder::knot_mouseover() { diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index d2f1193ff..66bc8c530 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -1,6 +1,6 @@ /** * \file line-snapper.cpp - * \brief LineSnapper class. + * LineSnapper class. * * Authors: * Diederik van Lierop diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index d4c795656..f49d082b6 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -182,11 +182,10 @@ sp_lpetool_context_setup(SPEventContext *ec) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new nodepath and reassigns listeners to the new selected item's repr -*/ -void -sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data) + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new nodepath and reassigns listeners to the new selected item's repr. + */ +void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(data); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index c5b2b7cd7..7e0961c95 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -1,6 +1,6 @@ /** * \file object-snapper.cpp - * \brief Snapping things to objects. + * Snapping things to objects. * * Authors: * Carl Hetherington diff --git a/src/rdf.cpp b/src/rdf.cpp index cabbaaed3..95f9fdd3b 100644 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@ -1,5 +1,5 @@ /** @file - * @brief RDF manipulation functions + * RDF manipulation functions. * * @todo move these to xml/ instead of dialogs/ */ @@ -324,10 +324,11 @@ public: static void setDefaults( SPDocument * doc ); /** - * \brief Pull the text out of an RDF entity, depends on how it's stored - * \return A pointer to the entity's static contents as a string - * \param repr The XML element to extract from - * \param entity The desired RDF/Work entity + * Pull the text out of an RDF entity, depends on how it's stored. + * + * @return A pointer to the entity's static contents as a string + * @param repr The XML element to extract from + * @param entity The desired RDF/Work entity * */ static const gchar *getReprText( Inkscape::XML::Node const * repr, struct rdf_work_entity_t const & entity ); @@ -342,13 +343,13 @@ public: }; /** - * \brief Retrieves a known RDF/Work entity by name - * \return A pointer to an RDF/Work entity - * \param name The desired RDF/Work entity + * Retrieves a known RDF/Work entity by name. + * + * @return A pointer to an RDF/Work entity + * @param name The desired RDF/Work entity * */ -struct rdf_work_entity_t * -rdf_find_entity(gchar const * name) +struct rdf_work_entity_t *rdf_find_entity(gchar const * name) { struct rdf_work_entity_t *entity; for (entity=rdf_work_entities; entity->name; entity++) { diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 188b5a9a3..8f0ec8763 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -163,9 +163,9 @@ static void sp_rect_context_dispose(GObject *object) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new knotholder -*/ + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new knotholder. + */ void sp_rect_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPRectContext *rc = SP_RECT_CONTEXT(data); diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 398f01d3e..a59664092 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -1,6 +1,6 @@ /** * \file src/rubberband.cpp - * \brief Rubberbanding selector + * Rubberbanding selector. * * Author: * Lauris Kaplinski diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 4c3c0f197..b5919dd71 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1,5 +1,5 @@ /** @file - * @brief Miscellanous operations on selected items + * Miscellanous operations on selected items. */ /* Authors: * Lauris Kaplinski @@ -1554,7 +1554,7 @@ void sp_selection_move_relative(Inkscape::Selection *selection, double dx, doubl } /** - * @brief Rotates selected objects 90 degrees, either clock-wise or counter-clockwise, depending on the value of ccw + * Rotates selected objects 90 degrees, either clock-wise or counter-clockwise, depending on the value of ccw. */ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) { @@ -2841,7 +2841,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } /** - * \brief Creates a mask or clipPath from selection + * Creates a mask or clipPath from selection. * Two different modes: * if applyToLayer, all selection is moved to DEFS as mask/clippath * and is applied to current layer diff --git a/src/seltrans.cpp b/src/seltrans.cpp index c6dd0a34d..2d09f393e 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1,5 +1,5 @@ /** @file - * @brief Helper object for transforming selected items + * Helper object for transforming selected items. */ /* Authors: * Lauris Kaplinski diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index 1962b710c..1fe6e620b 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -227,7 +227,7 @@ bool ShapeEditor::has_selection() { } /** - * \brief Returns true if this ShapeEditor has a knot above which the mouse currently hovers + * Returns true if this ShapeEditor has a knot above which the mouse currently hovers. */ bool ShapeEditor::knot_mouseover() { diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 25e00718c..250f38b90 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -1,6 +1,6 @@ /** * \file snap-preferences.cpp - * \brief Storing of snapping preferences + * Storing of snapping preferences. * * Authors: * Diederik van Lierop @@ -120,7 +120,7 @@ bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const return (_snap_from & t); } /** - * \brief Map snap target to array index. + * Map snap target to array index. * * The status of each snap toggle (in the snap toolbar) is stored as a boolean value in an array. This method returns the position * of relevant boolean in that array, for any given type of snap target. For most snap targets, the enumerated value of that targets @@ -131,9 +131,9 @@ bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const * - For snap sources, just pass the corresponding snap target instead (each snap source should have a twin snap target, but not vice versa) * - All parameters are passed by reference, and will be overwritten * - * \param target Stores the enumerated snap target, which can be modified to correspond to the array index of this snap target - * \param always_on If true, then this snap target is always active and cannot be toggled - * \param group_on If true, then this snap target is in a snap group that has been enabled (e.g. bbox group, nodes/paths group, or "others" group + * @param target Stores the enumerated snap target, which can be modified to correspond to the array index of this snap target + * @param always_on If true, then this snap target is always active and cannot be toggled + * @param group_on If true, then this snap target is in a snap group that has been enabled (e.g. bbox group, nodes/paths group, or "others" group */ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const { diff --git a/src/snap.cpp b/src/snap.cpp index b2c5a5a10..fb6f120ec 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1,8 +1,6 @@ -#define __SP_DESKTOP_SNAP_C__ - /** * \file snap.cpp - * \brief SnapManager class. + * SnapManager class. * * Authors: * Lauris Kaplinski @@ -58,7 +56,7 @@ SnapManager::SnapManager(SPNamedView const *v) : } /** - * \brief Return a list of snappers + * Return a list of snappers. * * Inkscape snaps to objects, grids, and guides. For each of these snap targets a * separate class is used, which has been derived from the base Snapper class. The @@ -67,10 +65,9 @@ SnapManager::SnapManager(SPNamedView const *v) : * class, but any number of grid snappers (because each grid has its own snapper * instance) * - * \return List of snappers that we use. + * @return List of snappers that we use. */ -SnapManager::SnapperList -SnapManager::getSnappers() const +SnapManager::SnapperList SnapManager::getSnappers() const { SnapManager::SnapperList s; s.push_back(&guide); @@ -83,17 +80,16 @@ SnapManager::getSnappers() const } /** - * \brief Return a list of gridsnappers + * Return a list of gridsnappers. * * Each grid has its own instance of the snapper class. This way snapping can * be enabled per grid individually. A list will be returned containing the * pointers to these instances, but only for grids that are being displayed * and for which snapping is enabled. * - * \return List of gridsnappers that we use. + * @return List of gridsnappers that we use. */ -SnapManager::SnapperList -SnapManager::getGridSnappers() const +SnapManager::SnapperList SnapManager::getGridSnappers() const { SnapperList s; @@ -108,14 +104,14 @@ SnapManager::getGridSnappers() const } /** - * \brief Return true if any snapping might occur, whether its to grids, guides or objects + * Return true if any snapping might occur, whether its to grids, guides or objects. * * Each snapper instance handles its own snapping target, e.g. grids, guides or * objects. This method iterates through all these snapper instances and returns * true if any of the snappers might possible snap, considering only the relevant * snapping preferences. * - * \return true if one of the snappers will try to snap to something. + * @return true if one of the snappers will try to snap to something. */ bool SnapManager::someSnapperMightSnap() const @@ -153,7 +149,7 @@ bool SnapManager::gridSnapperMightSnap() const } /** - * \brief Try to snap a point to grids, guides or objects. + * Try to snap a point to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, * i.e. snap in any direction on the two dimensional canvas to the nearest @@ -172,11 +168,10 @@ bool SnapManager::gridSnapperMightSnap() const * 2) Only to be used when a single source point is to be snapped; it assumes * that source_num = 0, which is inefficient when snapping sets our source points * - * \param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * \param source_type Detailed description of the source type, will be used by the snap indicator - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred + * @param source_type Detailed description of the source type, will be used by the snap indicator + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation */ - void SnapManager::freeSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Geom::OptRect const &bbox_to_snap) const @@ -187,7 +182,7 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, /** - * \brief Try to snap a point to grids, guides or objects. + * Try to snap a point to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, * i.e. snap in any direction on the two dimensional canvas to the nearest @@ -197,12 +192,10 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, * PS: SnapManager::setup() must have been called before calling this method, * but only once for a set of points * - * \param p Source point to be snapped - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics + * @param p Source point to be snapped + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics */ - - Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap) const { @@ -238,7 +231,7 @@ void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) } /** - * \brief Snap to the closest multiple of a grid pitch + * Snap to the closest multiple of a grid pitch. * * When pasting, we would like to snap to the grid. Problem is that we don't know which * nodes were aligned to the grid at the time of copying, so we don't know which nodes @@ -252,10 +245,9 @@ void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) * PS2: When multiple grids are present then the result will become ambiguous. There is no * way to control to which grid this method will snap. * - * \param t Vector that represents the offset of the pasted copy with respect to the original - * \return Offset vector after snapping to the closest multiple of a grid pitch + * @param t Vector that represents the offset of the pasted copy with respect to the original + * @return Offset vector after snapping to the closest multiple of a grid pitch */ - Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point const &origin) { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) @@ -312,7 +304,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c } /** - * \brief Try to snap a point along a constraint line to grids, guides or objects. + * Try to snap a point along a constraint line to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, * i.e. snap in a specific direction on the two dimensional canvas to the nearest @@ -335,12 +327,11 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c * that source_num = 0, which is inefficient when snapping sets our source points * - * \param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * \param source_type Detailed description of the source type, will be used by the snap indicator - * \param constraint The direction or line along which snapping must occur - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred + * @param source_type Detailed description of the source type, will be used by the snap indicator + * @param constraint The direction or line along which snapping must occur + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation */ - void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Inkscape::Snapper::SnapConstraint const &constraint, @@ -351,7 +342,7 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, } /** - * \brief Try to snap a point along a constraint line to grids, guides or objects. + * Try to snap a point along a constraint line to grids, guides or objects. * * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, * i.e. snap in a specific direction on the two dimensional canvas to the nearest @@ -363,11 +354,10 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, * PS: If there's nothing to snap to or if snapping has been disabled, then this * method will still apply the constraint (but without snapping) * - * \param p Source point to be snapped - * \param constraint The direction or line along which snapping must occur - * \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation + * @param p Source point to be snapped + * @param constraint The direction or line along which snapping must occur + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation */ - Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint const &p, Inkscape::Snapper::SnapConstraint const &constraint, Geom::OptRect const &bbox_to_snap) const @@ -512,18 +502,17 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi } /** - * \brief Try to snap a point to something at a specific angle + * Try to snap a point to something at a specific angle. * * When drawing a straight line or modifying a gradient, it will snap to specific angle increments * if CTRL is being pressed. This method will enforce this angular constraint (even if there is nothing * to snap to) * - * \param p Source point to be snapped - * \param p_ref Optional original point, relative to which the angle should be calculated. If empty then + * @param p Source point to be snapped + * @param p_ref Optional original point, relative to which the angle should be calculated. If empty then * the angle will be calculated relative to the y-axis - * \param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees + * @param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees */ - Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, boost::optional const &p_ref, Geom::Point const &o, @@ -561,12 +550,12 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida } /** - * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) + * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). * * PS: SnapManager::setup() must have been called before calling this method, * - * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * \param guide_normal Vector normal to the guide line + * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred + * @param guide_normal Vector normal to the guide line */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_normal*/, SPGuideDragType drag_type) const { @@ -591,14 +580,13 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_norma } /** - * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code) + * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). * * PS: SnapManager::setup() must have been called before calling this method, * - * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * \param guide_normal Vector normal to the guide line + * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred + * @param guide_normal Vector normal to the guide line */ - void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { @@ -620,7 +608,7 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) } /** - * \brief Method for snapping sets of points while they are being transformed + * Method for snapping sets of points while they are being transformed. * * Method for snapping sets of points while they are being transformed, when using * for example the selector tool. This method is for internal use only, and should @@ -634,18 +622,17 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) * If no snap has occurred and we're asked for a constrained snap then the constraint * will be applied nevertheless * - * \param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * \param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * \param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. - * \param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. - * \param transformation_type Type of transformation to apply to points before trying to snap them. - * \param transformation Description of the transformation; details depend on the type. - * \param origin Origin of the transformation, if applicable. - * \param dim Dimension to which the transformation applies, if applicable. - * \param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + * @param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. + * @param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. + * @param transformation_type Type of transformation to apply to points before trying to snap them. + * @param transformation Description of the transformation; details depend on the type. + * @param origin Origin of the transformation, if applicable. + * @param dim Dimension to which the transformation applies, if applicable. + * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. */ - Inkscape::SnappedPoint SnapManager::_snapTransformed( std::vector const &points, Geom::Point const &pointer, @@ -937,14 +924,13 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( /** - * \brief Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom + * Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom. * - * \param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * \param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * \param tr Proposed translation; the final translation can only be calculated after snapping has occurred - * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. */ - Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector const &p, Geom::Point const &pointer, Geom::Point const &tr) @@ -959,15 +945,14 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -984,15 +969,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslate(std::vector const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -1009,15 +993,14 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -1034,17 +1017,16 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector const &p, Geom::Point const &pointer, Geom::Coord const &s, @@ -1062,17 +1044,16 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -1101,15 +1082,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector const &p, Geom::Point const &pointer, Geom::Coord const &angle, @@ -1132,16 +1112,15 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector &items_to_ignore, @@ -1355,17 +1333,16 @@ SPDocument *SnapManager::getDocument() const } /** - * \brief Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code + * Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code. * - * \param p The untransformed position of the point, paired with an identifier of the type of the snap source. - * \param transformation_type Type of transformation to apply. - * \param transformation Mathematical description of the transformation; details depend on the type. - * \param origin Origin of the transformation, if applicable. - * \param dim Dimension to which the transformation applies, if applicable. - * \param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * \return The position of the point after transformation + * @param p The untransformed position of the point, paired with an identifier of the type of the snap source. + * @param transformation_type Type of transformation to apply. + * @param transformation Mathematical description of the transformation; details depend on the type. + * @param origin Origin of the transformation, if applicable. + * @param dim Dimension to which the transformation applies, if applicable. + * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. + * @return The position of the point after transformation */ - Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, Transformation const transformation_type, Geom::Point const &transformation, @@ -1413,12 +1390,11 @@ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, } /** - * \brief Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol + * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. * - * \param point_type Category of points to which the source point belongs: node, guide or bounding box - * \param p The transformed position of the source point, paired with an identifier of the type of the snap source. + * @param point_type Category of points to which the source point belongs: node, guide or bounding box + * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. */ - void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index 9cb547609..493925d48 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -1,6 +1,6 @@ /** * \file src/snapped-curve.cpp - * \brief SnappedCurve class. + * SnappedCurve class. * * Authors: * Diederik van Lierop diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index 525208f06..d9cd48d5b 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -1,6 +1,6 @@ /** * \file src/snapped-line.cpp - * \brief SnappedLine class. + * SnappedLine class. * * Authors: * Diederik van Lierop diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index a777e4dc0..83c932539 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -1,6 +1,6 @@ /** * \file src/snapped-point.cpp - * \brief SnappedPoint class. + * SnappedPoint class. * * Authors: * Mathieu Dimanche diff --git a/src/snapper.cpp b/src/snapper.cpp index fb7281c30..8c985b732 100644 --- a/src/snapper.cpp +++ b/src/snapper.cpp @@ -1,6 +1,6 @@ /** - * \file src/snapper.cpp - * \brief Snapper class. + * @file src/snapper.cpp + * Snapper class. * * Authors: * Carl Hetherington @@ -15,8 +15,8 @@ /** * Construct new Snapper for named view. - * \param nv Named view. - * \param d Snap tolerance. + * @param nv Named view. + * @param d Snap tolerance. */ Inkscape::Snapper::Snapper(SnapManager *sm, Geom::Coord const /*t*/) : _snapmanager(sm), @@ -27,7 +27,7 @@ Inkscape::Snapper::Snapper(SnapManager *sm, Geom::Coord const /*t*/) : } /** - * \param s true to enable this snapper, otherwise false. + * @param s true to enable this snapper, otherwise false. */ void Inkscape::Snapper::setEnabled(bool s) diff --git a/src/sp-desc.cpp b/src/sp-desc.cpp index 18b1a1cad..bc7f600ae 100644 --- a/src/sp-desc.cpp +++ b/src/sp-desc.cpp @@ -1,5 +1,3 @@ -#define __SP_DESC_C__ - /* * SVG implementation * @@ -59,11 +57,10 @@ sp_desc_init(SPDesc */*desc*/) { } -/* - * \brief Writes it's settings to an incoming repr object, if any +/** + * Writes it's settings to an incoming repr object, if any. */ -static Inkscape::XML::Node * -sp_desc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node *sp_desc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr) { repr = object->getRepr()->duplicate(doc); diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index d1fe14f20..a8d553e9f 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -17,8 +17,7 @@ #include <2geom/transforms.h> #include "sp-item.h" -void -sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) +void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) { Geom::Point center = item->getCenter(); Geom::Translate const s(item->getCenter()); @@ -36,8 +35,7 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) } } -void -sp_item_scale_rel (SPItem *item, Geom::Scale const &scale) +void sp_item_scale_rel(SPItem *item, Geom::Scale const &scale) { Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { @@ -47,8 +45,7 @@ sp_item_scale_rel (SPItem *item, Geom::Scale const &scale) } } -void -sp_item_skew_rel (SPItem *item, double skewX, double skewY) +void sp_item_skew_rel(SPItem *item, double skewX, double skewY) { Geom::Point center = item->getCenter(); Geom::Translate const s(item->getCenter()); @@ -74,7 +71,7 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) } /** - * \brief Calculate the affine transformation required to transform one visual bounding box into another, accounting for a uniform strokewidth + * Calculate the affine transformation required to transform one visual bounding box into another, accounting for a uniform strokewidth. * * PS: This function will only return accurate results for the visual bounding box of a selection of one or more objects, all having * the same strokewidth. If the stroke width varies from object to object in this selection, then the function @@ -85,20 +82,18 @@ void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) * box this is very straightforward, but when using a visual bounding box this become more tricky as we need to account for * the strokewidth, which is either constant or scales width the area of the object. This function takes care of the calculation * of the affine transformation: - * \param bbox_visual Current visual bounding box - * \param strokewidth Strokewidth - * \param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box - * \param x0 Coordinate of the target visual bounding box - * \param y0 Coordinate of the target visual bounding box - * \param x1 Coordinate of the target visual bounding box - * \param y1 Coordinate of the target visual bounding box + * @param bbox_visual Current visual bounding box + * @param strokewidth Strokewidth + * @param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box + * @param x0 Coordinate of the target visual bounding box + * @param y0 Coordinate of the target visual bounding box + * @param x1 Coordinate of the target visual bounding box + * @param y1 Coordinate of the target visual bounding box * PS: we have to pass each coordinate individually, to find out if we are mirroring the object; Using a Geom::Rect() instead is - not possible here because it will only allow for a positive width and height, and therefore cannot mirror - * \return -*/ - -Geom::Affine -get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) + * not possible here because it will only allow for a positive width and height, and therefore cannot mirror + * @return + */ +Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visual, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -208,7 +203,7 @@ get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble s } /** - * \brief Calculate the affine transformation required to transform one visual bounding box into another, accounting for a VARIABLE strokewidth + * Calculate the affine transformation required to transform one visual bounding box into another, accounting for a VARIABLE strokewidth. * * Note: Please try to understand get_scale_transform_for_uniform_stroke() first, and read all it's comments carefully. This function * (get_scale_transform_for_variable_stroke) is a bit different because it will allow for a strokewidth that's different for each @@ -223,20 +218,18 @@ get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble s * the strokewidth, which is either constant or scales width the area of the object. This function takes care of the calculation * of the affine transformation: * - * \param bbox_visual Current visual bounding box - * \param bbox_geometric Current geometric bounding box (allows for calculating the strokewidth of each edge) - * \param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box - * \param x0 Coordinate of the target visual bounding box - * \param y0 Coordinate of the target visual bounding box - * \param x1 Coordinate of the target visual bounding box - * \param y1 Coordinate of the target visual bounding box - PS: we have to pass each coordinate individually, to find out if we are mirroring the object; Using a Geom::Rect() instead is - not possible here because it will only allow for a positive width and height, and therefore cannot mirror - * \return -*/ - -Geom::Affine -get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) + * @param bbox_visual Current visual bounding box + * @param bbox_geometric Current geometric bounding box (allows for calculating the strokewidth of each edge) + * @param transform_stroke If true then the stroke will be scaled proportional to the square root of the area of the geometric bounding box + * @param x0 Coordinate of the target visual bounding box + * @param y0 Coordinate of the target visual bounding box + * @param x1 Coordinate of the target visual bounding box + * @param y1 Coordinate of the target visual bounding box + * PS: we have to pass each coordinate individually, to find out if we are mirroring the object; Using a Geom::Rect() instead is + * not possible here because it will only allow for a positive width and height, and therefore cannot mirror + * @return + */ +Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1) { Geom::Affine p2o = Geom::Translate (-bbox_visual.min()); Geom::Affine o2n = Geom::Translate (x0, y0); @@ -376,8 +369,7 @@ get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Re return (p2o * scale * unbudge * o2n); } -Geom::Rect -get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke) +Geom::Rect get_visual_bbox(Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke) { g_assert(initial_geom_bbox); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index a4d66cf1a..89ff92035 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -678,8 +678,11 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML return repr; } -/** @brief Get item's geometric bounding box in this item's coordinate system. - * The geometric bounding box includes only the path, disregarding all style attributes. */ +/** + * Get item's geometric bounding box in this item's coordinate system. + * + * The geometric bounding box includes only the path, disregarding all style attributes. + */ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const { Geom::OptRect bbox; @@ -690,8 +693,11 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const return bbox; } -/** @brief Get item's visual bounding box in this item's coordinate system. - * The visual bounding box includes the stroke and the filter region. */ +/** + * Get item's visual bounding box in this item's coordinate system. + * + * The visual bounding box includes the stroke and the filter region. + */ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const { using Geom::X; diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 84dc114db..3f2d3b584 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -1,5 +1,3 @@ -#define __SP_METADATA_C__ - /* * SVG implementation * @@ -103,14 +101,14 @@ void strip_ids_recursively(Inkscape::XML::Node *node) { } -/* - * \brief Reads the Inkscape::XML::Node, and initializes SPMetadata variables. - * For this to get called, our name must be associated with - * a repr via "sp_object_type_register". Best done through - * sp-object-repr.cpp's repr_name_entries array. +/** + * Reads the Inkscape::XML::Node, and initializes SPMetadata variables. + * + * For this to get called, our name must be associated with + * a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_metadata_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_metadata_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { using Inkscape::XML::NodeSiblingIterator; @@ -129,25 +127,23 @@ sp_metadata_build (SPObject *object, SPDocument *document, Inkscape::XML::Node * ((SPObjectClass *) metadata_parent_class)->build (object, document, repr); } -/* - * \brief Drops any allocated memory +/** + * Drops any allocated memory. */ -static void -sp_metadata_release (SPObject *object) +static void sp_metadata_release(SPObject *object) { debug("0x%08x",(unsigned int)object); - /* handle ourself */ + // handle ourself if (((SPObjectClass *) metadata_parent_class)->release) ((SPObjectClass *) metadata_parent_class)->release (object); } -/* - * \brief Sets a specific value in the SPMetadata +/** + * Sets a specific value in the SPMetadata. */ -static void -sp_metadata_set (SPObject *object, unsigned int key, const gchar *value) +static void sp_metadata_set(SPObject *object, unsigned int key, const gchar *value) { debug("0x%08x %s(%u): '%s'",(unsigned int)object, sp_attribute_name(key),key,value); @@ -160,11 +156,10 @@ sp_metadata_set (SPObject *object, unsigned int key, const gchar *value) ((SPObjectClass *) metadata_parent_class)->set (object, key, value); } -/* - * \brief Receives update notifications +/** + * Receives update notifications. */ -static void -sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags) +static void sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags) { debug("0x%08x",(unsigned int)object); //SPMetadata *metadata = SP_METADATA(object); @@ -180,11 +175,10 @@ sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags) ((SPObjectClass *) metadata_parent_class)->update(object, ctx, flags); } -/* - * \brief Writes it's settings to an incoming repr object, if any +/** + * Writes it's settings to an incoming repr object, if any. */ -static Inkscape::XML::Node * -sp_metadata_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node *sp_metadata_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { debug("0x%08x",(unsigned int)object); //SPMetadata *metadata = SP_METADATA(object); @@ -204,11 +198,10 @@ sp_metadata_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML: return repr; } -/* - * \brief Retrieves the metadata object associated with a document +/** + * Retrieves the metadata object associated with a document. */ -SPMetadata * -sp_document_metadata (SPDocument *document) +SPMetadata *sp_document_metadata(SPDocument *document) { SPObject *nv; diff --git a/src/sp-title.cpp b/src/sp-title.cpp index d21c7b71e..ddeccede2 100644 --- a/src/sp-title.cpp +++ b/src/sp-title.cpp @@ -1,5 +1,3 @@ -#define __SP_TITLE_C__ - /* * SVG implementation * @@ -59,11 +57,10 @@ sp_title_init(SPTitle */*desc*/) { } -/* - * \brief Writes it's settings to an incoming repr object, if any +/** + * Writes it's settings to an incoming repr object, if any. */ -static Inkscape::XML::Node * -sp_title_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node *sp_title_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr) { repr = object->getRepr()->duplicate(doc); diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 93ff48c3e..64eedf3f9 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -157,11 +157,10 @@ sp_spiral_context_dispose(GObject *object) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new knotholder -*/ -void -sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer data) + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new knotholder. + */ +void sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPSpiralContext *sc = SP_SPIRAL_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(sc); diff --git a/src/star-context.cpp b/src/star-context.cpp index c954fd7d7..352bdfece 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -163,12 +163,12 @@ sp_star_context_dispose (GObject *object) } /** -\brief Callback that processes the "changed" signal on the selection; -destroys old and creates new knotholder -\param selection Should not be NULL. -*/ -void -sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data) + * Callback that processes the "changed" signal on the selection; + * destroys old and creates new knotholder. + * + * @param selection Should not be NULL. + */ +void sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data) { g_assert (selection != NULL); diff --git a/src/style.cpp b/src/style.cpp index ffb56dfa5..90c100f33 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief SVG stylesheets implementation. +/** + * @file + * SVG stylesheets implementation. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/unclump.cpp b/src/unclump.cpp index 6b9a8c574..43bcf5005 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Unclumping objects +/** + * @file + * Unclumping objects. */ /* Authors: * bulia byak diff --git a/src/uri.cpp b/src/uri.cpp index 1e38c034a..a5aec6f2d 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -1,6 +1,6 @@ /** * \file - * \brief Classes for representing and manipulating URIs as per RFC 2396. + * Classes for representing and manipulating URIs as per RFC 2396. * * Authors: * MenTaLguY <mental@rydia.net> @@ -17,14 +17,18 @@ namespace Inkscape { -/** \brief Copy constructor. */ +/** + * Copy constructor. + */ URI::URI(const URI &uri) { uri._impl->reference(); _impl = uri._impl; } -/** \brief Constructor from a C-style ASCII string. - \param preformed Properly quoted C-style string to be represented. +/** + * Constructor from a C-style ASCII string. + * + * @param preformed Properly quoted C-style string to be represented. */ URI::URI(gchar const *preformed) throw(BadURIException) { xmlURIPtr uri; @@ -39,12 +43,16 @@ URI::URI(gchar const *preformed) throw(BadURIException) { } -/** \brief Destructor. */ +/** + * Destructor. + */ URI::~URI() { _impl->unreference(); } -/** \brief Assignment operator. */ +/** + * Assignment operator. + */ URI &URI::operator=(URI const &uri) { // No check for self-assignment needed, as _impl refcounting increments first. uri._impl->reference(); @@ -77,32 +85,35 @@ void URI::Impl::unreference() { } } -/** \fn bool URI::isOpaque() const - \brief Determines if the URI represented is an 'opaque' URI. - \return \c true if the URI is opaque, \c false if hierarchial. -*/ +/** + * Determines if the URI represented is an 'opaque' URI. + * + * @return \c true if the URI is opaque, \c false if hierarchial. + */ bool URI::Impl::isOpaque() const { bool opq = !isRelative() && (getOpaque() != NULL); return opq; } -/** \fn bool URI::isRelative() const - \brief Determines if the URI represented is 'relative' as per RFC 2396. - \return \c true if the URI is relative, \c false if it is absolute. - - Relative URI references are distinguished by not begining with a - scheme name. -*/ +/** + * Determines if the URI represented is 'relative' as per RFC 2396. + * + * Relative URI references are distinguished by not begining with a + * scheme name. + * + * @return \c true if the URI is relative, \c false if it is absolute. + */ bool URI::Impl::isRelative() const { return !_uri->scheme; } -/** \fn bool URI::isNetPath() const - \brief Determines if the relative URI represented is a 'net-path' as per RFC 2396. - \return \c true if the URI is relative and a net-path, \c false otherwise. - - A net-path is one that starts with "\\". -*/ +/** + * Determines if the relative URI represented is a 'net-path' as per RFC 2396. + * + * A net-path is one that starts with "\\". + * + * @return \c true if the URI is relative and a net-path, \c false otherwise. + */ bool URI::Impl::isNetPath() const { bool isNet = false; if ( isRelative() ) @@ -113,12 +124,13 @@ bool URI::Impl::isNetPath() const { return isNet; } -/** \fn bool URI::isRelativePath() const - \brief Determines if the relative URI represented is a 'relative-path' as per RFC 2396. - \return \c true if the URI is relative and a relative-path, \c false otherwise. - - A relative-path is one that starts with no slashes. -*/ +/** + * Determines if the relative URI represented is a 'relative-path' as per RFC 2396. + * + * A relative-path is one that starts with no slashes. + * + * @return \c true if the URI is relative and a relative-path, \c false otherwise. + */ bool URI::Impl::isRelativePath() const { bool isRel = false; if ( isRelative() ) @@ -129,12 +141,13 @@ bool URI::Impl::isRelativePath() const { return isRel; } -/** \fn bool URI::isAbsolutePath() const - \brief Determines if the relative URI represented is a 'absolute-path' as per RFC 2396. - \return \c true if the URI is relative and an absolute-path, \c false otherwise. - - An absolute-path is one that starts with a single "\". -*/ +/** + * Determines if the relative URI represented is a 'absolute-path' as per RFC 2396. + * + * An absolute-path is one that starts with a single "\". + * + * @return \c true if the URI is relative and an absolute-path, \c false otherwise. + */ bool URI::Impl::isAbsolutePath() const { bool isAbs = false; if ( isRelative() ) @@ -230,12 +243,13 @@ URI URI::from_native_filename(gchar const *path) throw(BadURIException) { return result; } -/** \fn gchar *URI::toString() const - \brief Returns a glib string version of this URI. - \return a glib string version of this URI. - - The returned string must be freed with \c g_free(). -*/ +/** + * Returns a glib string version of this URI. + * + * The returned string must be freed with \c g_free(). + * + * @return a glib string version of this URI. + */ gchar *URI::Impl::toString() const { xmlChar *string = xmlSaveUri(_uri); if (string) { diff --git a/src/verbs.cpp b/src/verbs.cpp index 7de95b332..89e61d7a7 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1,7 +1,7 @@ /** * \file verbs.cpp * - * \brief Actions for inkscape + * Actions for inkscape. * * This file implements routines necessary to deal with verbs. A verb * is a numeric identifier used to retrieve standard SPActions for particular @@ -89,11 +89,10 @@ using Inkscape::DocumentUndo; //#endif /** - * \brief Return the name without underscores and ellipsis, for use in dialog + * Return the name without underscores and ellipsis, for use in dialog * titles, etc. Allocated memory must be freed by caller. */ -gchar * -sp_action_get_title(SPAction const *action) +gchar *sp_action_get_title(SPAction const *action) { char const *src = action->name; gchar *ret = g_new(gchar, strlen(src) + 1); @@ -114,15 +113,16 @@ sp_action_get_title(SPAction const *action) namespace Inkscape { -/** \brief A class to encompass all of the verbs which deal with - file operations. */ +/** + * A class to encompass all of the verbs which deal with file operations. + */ class FileVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ FileVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -130,17 +130,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* FileVerb class */ +}; // FileVerb class -/** \brief A class to encompass all of the verbs which deal with - edit operations. */ +/** + * A class to encompass all of the verbs which deal with edit operations. + */ class EditVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ EditVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -148,17 +149,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* EditVerb class */ +}; // EditVerb class -/** \brief A class to encompass all of the verbs which deal with - selection operations. */ +/** + * A class to encompass all of the verbs which deal with selection operations. + */ class SelectionVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ SelectionVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -166,17 +168,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* SelectionVerb class */ +}; // SelectionVerb class -/** \brief A class to encompass all of the verbs which deal with - layer operations. */ +/** + * A class to encompass all of the verbs which deal with layer operations. + */ class LayerVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ LayerVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -184,17 +187,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* LayerVerb class */ +}; // LayerVerb class -/** \brief A class to encompass all of the verbs which deal with - operations related to objects. */ +/** + * A class to encompass all of the verbs which deal with operations related to objects. + */ class ObjectVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ ObjectVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -202,17 +206,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* ObjectVerb class */ +}; // ObjectVerb class -/** \brief A class to encompass all of the verbs which deal with - operations relative to context. */ +/** + * A class to encompass all of the verbs which deal with operations relative to context. + */ class ContextVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ ContextVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -220,17 +225,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* ContextVerb class */ +}; // ContextVerb class -/** \brief A class to encompass all of the verbs which deal with - zoom operations. */ +/** + * A class to encompass all of the verbs which deal with zoom operations. + */ class ZoomVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ ZoomVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -238,18 +244,19 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* ZoomVerb class */ +}; // ZoomVerb class -/** \brief A class to encompass all of the verbs which deal with - dialog operations. */ +/** + * A class to encompass all of the verbs which deal with dialog operations. + */ class DialogVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ DialogVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -257,17 +264,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* DialogVerb class */ +}; // DialogVerb class -/** \brief A class to encompass all of the verbs which deal with - help operations. */ +/** + * A class to encompass all of the verbs which deal with help operations. + */ class HelpVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ HelpVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -275,17 +283,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* HelpVerb class */ +}; // HelpVerb class -/** \brief A class to encompass all of the verbs which deal with - tutorial operations. */ +/** + * A class to encompass all of the verbs which deal with tutorial operations. + */ class TutorialVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ TutorialVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -293,17 +302,18 @@ public: gchar const *image) : Verb(code, id, name, tip, image) { } -}; /* TutorialVerb class */ +}; // TutorialVerb class -/** \brief A class to encompass all of the verbs which deal with - text operations. */ +/** + * A class to encompass all of the verbs which deal with text operations. + */ class TextVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ TextVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -316,15 +326,16 @@ public: Verb::VerbTable Verb::_verbs; Verb::VerbIDTable Verb::_verb_ids; -/** \brief Create a verb without a code. - - This function calls the other constructor for all of the parameters, - but generates the code. It is important to READ THE OTHER DOCUMENTATION - it has important details in it. To generate the code a static is - used which starts at the last static value: \c SP_VERB_LAST. For - each call it is incremented. The list of allocated verbs is kept - in the \c _verbs hashtable which is indexed by the \c code. -*/ +/** + * Create a verb without a code. + * + * This function calls the other constructor for all of the parameters, + * but generates the code. It is important to READ THE OTHER DOCUMENTATION + * it has important details in it. To generate the code a static is + * used which starts at the last static value: \c SP_VERB_LAST. For + * each call it is incremented. The list of allocated verbs is kept + * in the \c _verbs hashtable which is indexed by the \c code. + */ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) : _actions(0), _id(id), @@ -344,11 +355,12 @@ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *im _verb_ids.insert(VerbIDTable::value_type(_id, this)); } -/** \brief Destroy a verb. - - The only allocated variable is the _actions variable. If it has - been allocated it is deleted. -*/ +/** + * Destroy a verb. + * + * The only allocated variable is the _actions variable. If it has + * been allocated it is deleted. + */ Verb::~Verb(void) { /// \todo all the actions need to be cleaned up first. @@ -360,168 +372,180 @@ Verb::~Verb(void) } } -/** \brief Verbs are no good without actions. This is a place holder - for a function that every subclass should write. Most - can be written using \c make_action_helper. - \param view Which view the action should be created for. - \return NULL to represent error (this function shouldn't ever be called) -*/ -SPAction * -Verb::make_action(Inkscape::UI::View::View */*view*/) +/** + * Verbs are no good without actions. This is a place holder + * for a function that every subclass should write. Most + * can be written using \c make_action_helper. + * + * @param view Which view the action should be created for. + * @return NULL to represent error (this function shouldn't ever be called) + */ +SPAction *Verb::make_action(Inkscape::UI::View::View */*view*/) { //std::cout << "make_action" << std::endl; return NULL; } -/** \brief Create an action for a \c FileVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -FileVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c FileVerb. + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *FileVerb::make_action(Inkscape::UI::View::View *view) { //std::cout << "fileverb: make_action: " << &perform << std::endl; return make_action_helper(view, &perform); } -/** \brief Create an action for a \c EditVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -EditVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c EditVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *EditVerb::make_action(Inkscape::UI::View::View *view) { //std::cout << "editverb: make_action: " << &perform << std::endl; return make_action_helper(view, &perform); } -/** \brief Create an action for a \c SelectionVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -SelectionVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c SelectionVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *SelectionVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c LayerVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -LayerVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c LayerVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *LayerVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c ObjectVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -ObjectVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c ObjectVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *ObjectVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c ContextVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -ContextVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c ContextVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *ContextVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c ZoomVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -ZoomVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c ZoomVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *ZoomVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c DialogVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -DialogVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c DialogVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *DialogVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c HelpVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -HelpVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c HelpVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *HelpVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c TutorialVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -TutorialVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c TutorialVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *TutorialVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Create an action for a \c TextVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -TextVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c TextVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *TextVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief A quick little convience function to make building actions - a little bit easier. - \param view Which view the action should be created for. - \param vector The function vector for the verb. - \return The created action. - - This function does a couple of things. The most obvious is that - it allocates and creates the action. When it does this it - translates the \c _name and \c _tip variables. This allows them - to be staticly allocated easily, and get translated in the end. Then, - if the action gets crated, a listener is added to the action with - the vector that is passed in. -*/ -SPAction * -Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr) +/** + * A quick little convience function to make building actions + * a little bit easier. + * + * This function does a couple of things. The most obvious is that + * it allocates and creates the action. When it does this it + * translates the \c _name and \c _tip variables. This allows them + * to be staticly allocated easily, and get translated in the end. Then, + * if the action gets crated, a listener is added to the action with + * the vector that is passed in. + * + * @param view Which view the action should be created for. + * @param vector The function vector for the verb. + * @return The created action. + */ +SPAction *Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr) { SPAction *action; @@ -541,27 +565,27 @@ Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perform_fun)(SPA return action; } -/** \brief A function to get an action if it exists, or otherwise to - build it. - \param view The view which this action would relate to - \return The action, or NULL if there is an error. - - This function will get the action for a given view for this verb. It - will create the verb if it can't be found in the ActionTable. Also, - if the \c ActionTable has not been created, it gets created by this - function. - - If the action is created, it's sensitivity must be determined. The - default for a new action is that it is sensitive. If the value in - \c _default_sensitive is \c false, then the sensitivity must be - removed. Also, if the view being created is based on the same - document as a view already created, the sensitivity should be the - same as views on that document. A view with the same document is - looked for, and the sensitivity is matched. Unfortunately, this is - currently a linear search. -*/ -SPAction * -Verb::get_action(Inkscape::UI::View::View *view) +/** + * A function to get an action if it exists, or otherwise to build it. + * + * This function will get the action for a given view for this verb. It + * will create the verb if it can't be found in the ActionTable. Also, + * if the \c ActionTable has not been created, it gets created by this + * function. + * + * If the action is created, it's sensitivity must be determined. The + * default for a new action is that it is sensitive. If the value in + * \c _default_sensitive is \c false, then the sensitivity must be + * removed. Also, if the view being created is based on the same + * document as a view already created, the sensitivity should be the + * same as views on that document. A view with the same document is + * looked for, and the sensitivity is matched. Unfortunately, this is + * currently a linear search. + * + * @param view The view which this action would relate to. + * @return The action, or NULL if there is an error. + */ +SPAction *Verb::get_action(Inkscape::UI::View::View *view) { SPAction *action = NULL; @@ -617,7 +641,9 @@ Verb::sensitive(SPDocument *in_doc, bool in_sensitive) return; } -/** \brief Accessor to get the tooltip for verb as localised string */ +/** + * Accessor to get the tooltip for verb as localised string. + */ gchar const *Verb::get_tip(void) { gchar const *result = 0; @@ -658,16 +684,17 @@ Verb::name(SPDocument *in_doc, Glib::ustring in_name) } } -/** \brief A function to remove the action associated with a view. - \param view Which view's actions should be removed. - \return None - - This function looks for the action in \c _actions. If it is - found then it is unreferenced and the entry in the action - table is erased. -*/ -void -Verb::delete_view(Inkscape::UI::View::View *view) +/** + * A function to remove the action associated with a view. + * + * This function looks for the action in \c _actions. If it is + * found then it is unreferenced and the entry in the action + * table is erased. + * + * @param view Which view's actions should be removed. + * @return None + */ +void Verb::delete_view(Inkscape::UI::View::View *view) { if (_actions == NULL) return; if (_actions->empty()) return; @@ -688,17 +715,18 @@ Verb::delete_view(Inkscape::UI::View::View *view) return; } -/** \brief A function to delete a view from all verbs - \param view Which view's actions should be removed. - \return None - - This function first looks through _base_verbs and deteles - the view from all of those views. If \c _verbs is not empty - then all of the entries in that table have all of the views - deleted also. -*/ -void -Verb::delete_all_view(Inkscape::UI::View::View *view) +/** + * A function to delete a view from all verbs. + * + * This function first looks through _base_verbs and deteles + * the view from all of those views. If \c _verbs is not empty + * then all of the entries in that table have all of the views + * deleted also. + * + * @param view Which view's actions should be removed. + * @return None + */ +void Verb::delete_all_view(Inkscape::UI::View::View *view) { for (int i = 0; i <= SP_VERB_LAST; i++) { if (_base_verbs[i]) @@ -717,16 +745,16 @@ Verb::delete_all_view(Inkscape::UI::View::View *view) return; } -/** \brief A function to turn a \c code into a Verb for dynamically - created Verbs. - \param code What code is being looked for - \return The found Verb of NULL if none is found. - - This function basically just looks through the \c _verbs hash - table. STL does all the work. -*/ -Verb * -Verb::get_search(unsigned int code) +/** + * A function to turn a \c code into a Verb for dynamically created Verbs. + * + * This function basically just looks through the \c _verbs hash + * table. STL does all the work. + * + * @param code What code is being looked for. + * @return The found Verb of NULL if none is found. + */ +Verb *Verb::get_search(unsigned int code) { Verb *verb = NULL; VerbTable::iterator verb_found = _verbs.find(code); @@ -738,15 +766,16 @@ Verb::get_search(unsigned int code) return verb; } -/** \brief Find a Verb using it's ID - \param id Which id to search for - - This function uses the \c _verb_ids has table to find the - verb by it's id. Should be much faster than previous - implementations. -*/ -Verb * -Verb::getbyid(gchar const *id) +/** + * Find a Verb using it's ID. + * + * This function uses the \c _verb_ids has table to find the + * verb by it's id. Should be much faster than previous + * implementations. + * + * @param id Which id to search for. + */ +Verb *Verb::getbyid(gchar const *id) { Verb *verb = NULL; VerbIDTable::iterator verb_found = _verb_ids.find(id); @@ -761,13 +790,14 @@ Verb::getbyid(gchar const *id) return verb; } -/** \brief Decode the verb code and take appropriate action */ -void -FileVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void FileVerb::perform(SPAction *action, void *data) { #if 0 - /* These aren't used, but are here to remind people not to use - the CURRENT_DOCUMENT macros unless they really have to. */ + // These aren't used, but are here to remind people not to use + // the CURRENT_DOCUMENT macros unless they really have to. Inkscape::UI::View::View *current_view = sp_action_get_view(action); SPDocument *current_document = current_view->doc(); #endif @@ -833,9 +863,10 @@ FileVerb::perform(SPAction *action, void *data) } // end of sp_verb_action_file_perform() -/** \brief Decode the verb code and take appropriate action */ -void -EditVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void EditVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); if (!dt) @@ -964,9 +995,10 @@ EditVerb::perform(SPAction *action, void *data) } // end of sp_verb_action_edit_perform() -/** \brief Decode the verb code and take appropriate action */ -void -SelectionVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void SelectionVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); @@ -1084,9 +1116,10 @@ SelectionVerb::perform(SPAction *action, void *data) } // end of sp_verb_action_selection_perform() -/** \brief Decode the verb code and take appropriate action */ -void -LayerVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void LayerVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); size_t verb = reinterpret_cast<std::size_t>(data); @@ -1253,11 +1286,11 @@ LayerVerb::perform(SPAction *action, void *data) survivor = Inkscape::previous_layer(dt->currentRoot(), old_layer); } - /* Deleting the old layer before switching layers is a hack to trigger the - * listeners of the deletion event (as happens when old_layer is deleted using the - * xml editor). See - * http://sourceforge.net/tracker/index.php?func=detail&aid=1339397&group_id=93438&atid=604306 - */ + // Deleting the old layer before switching layers is a hack to trigger the + // listeners of the deletion event (as happens when old_layer is deleted using the + // xml editor). See + // http://sourceforge.net/tracker/index.php?func=detail&aid=1339397&group_id=93438&atid=604306 + // old_layer->deleteObject(); sp_object_unref(old_layer, NULL); if (survivor) { @@ -1288,9 +1321,10 @@ LayerVerb::perform(SPAction *action, void *data) return; } // end of sp_verb_action_layer_perform() -/** \brief Decode the verb code and take appropriate action */ -void -ObjectVerb::perform( SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void ObjectVerb::perform( SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); if (!dt) @@ -1371,9 +1405,10 @@ ObjectVerb::perform( SPAction *action, void *data) } // end of sp_verb_action_object_perform() -/** \brief Decode the verb code and take appropriate action */ -void -ContextVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void ContextVerb::perform(SPAction *action, void *data) { SPDesktop *dt; sp_verb_t verb; @@ -1555,9 +1590,10 @@ ContextVerb::perform(SPAction *action, void *data) } // end of sp_verb_action_ctx_perform() -/** \brief Decode the verb code and take appropriate action */ -void -TextVerb::perform(SPAction *action, void */*data*/) +/** + * Decode the verb code and take appropriate action. + */ +void TextVerb::perform(SPAction *action, void */*data*/) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); if (!dt) @@ -1569,9 +1605,10 @@ TextVerb::perform(SPAction *action, void */*data*/) (void)repr; } -/** \brief Decode the verb code and take appropriate action */ -void -ZoomVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void ZoomVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); if (!dt) @@ -1681,7 +1718,7 @@ ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_FULLSCREEN: dt->fullscreen(); break; -#endif /* HAVE_GTK_WINDOW_FULLSCREEN */ +#endif // HAVE_GTK_WINDOW_FULLSCREEN case SP_VERB_FOCUSTOGGLE: dt->focusMode(!dt->is_focusMode()); break; @@ -1730,9 +1767,10 @@ ZoomVerb::perform(SPAction *action, void *data) } // end of sp_verb_action_zoom_perform() -/** \brief Decode the verb code and take appropriate action */ -void -DialogVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void DialogVerb::perform(SPAction *action, void *data) { if (reinterpret_cast<std::size_t>(data) != SP_VERB_DIALOG_TOGGLE) { // unhide all when opening a new dialog @@ -1842,9 +1880,10 @@ DialogVerb::perform(SPAction *action, void *data) } } // end of sp_verb_action_dialog_perform() -/** \brief Decode the verb code and take appropriate action */ -void -HelpVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void HelpVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); g_assert(dt->_dlg_mgr != NULL); @@ -1876,15 +1915,16 @@ HelpVerb::perform(SPAction *action, void *data) } } // end of sp_verb_action_help_perform() -/** \brief Decode the verb code and take appropriate action */ -void -TutorialVerb::perform(SPAction */*action*/, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void TutorialVerb::perform(SPAction */*action*/, void *data) { switch (reinterpret_cast<std::size_t>(data)) { case SP_VERB_TUTORIAL_BASIC: - /* TRANSLATORS: If you have translated the tutorial-basic.en.svgz file to your language, - then translate this string as "tutorial-basic.LANG.svgz" (where LANG is your language - code); otherwise leave as "tutorial-basic.svg". */ + // TRANSLATORS: If you have translated the tutorial-basic.en.svgz file to your language, + // then translate this string as "tutorial-basic.LANG.svgz" (where LANG is your language + // code); otherwise leave as "tutorial-basic.svg". sp_help_open_tutorial(NULL, (gpointer)_("tutorial-basic.svg")); break; case SP_VERB_TUTORIAL_SHAPES: @@ -1920,16 +1960,18 @@ TutorialVerb::perform(SPAction */*action*/, void *data) } } // end of sp_verb_action_tutorial_perform() -/* *********** Effect Last ********** */ +// *********** Effect Last ********** -/** \brief A class to represent the last effect issued */ +/** + * A class to represent the last effect issued. + */ class EffectLastVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ EffectLastVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -1939,26 +1981,28 @@ public: { set_default_sensitive(false); } -}; /* EffectLastVerb class */ +}; // EffectLastVerb class -/** \brief Create an action for a \c EffectLastVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -EffectLastVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c EffectLastVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *EffectLastVerb::make_action(Inkscape::UI::View::View *view) { return make_action_helper(view, &perform); } -/** \brief Decode the verb code and take appropriate action */ -void -EffectLastVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void EffectLastVerb::perform(SPAction *action, void *data) { - /* These aren't used, but are here to remind people not to use - the CURRENT_DOCUMENT macros unless they really have to. */ + // These aren't used, but are here to remind people not to use + // the CURRENT_DOCUMENT macros unless they really have to. Inkscape::UI::View::View *current_view = sp_action_get_view(action); // SPDocument *current_document = SP_VIEW_DOCUMENT(current_view); Inkscape::Extension::Effect *effect = Inkscape::Extension::Effect::get_last_effect(); @@ -1979,18 +2023,20 @@ EffectLastVerb::perform(SPAction *action, void *data) return; } -/* *********** End Effect Last ********** */ +// *********** End Effect Last ********** -/* *********** Fit Canvas ********** */ +// *********** Fit Canvas ********** -/** \brief A class to represent the canvas fitting verbs */ +/** + * A class to represent the canvas fitting verbs. + */ class FitCanvasVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ FitCanvasVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -2000,24 +2046,26 @@ public: { set_default_sensitive(false); } -}; /* FitCanvasVerb class */ - -/** \brief Create an action for a \c FitCanvasVerb - \param view Which view the action should be created for - \return The built action. +}; // FitCanvasVerb class - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -FitCanvasVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c FitCanvasVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *FitCanvasVerb::make_action(Inkscape::UI::View::View *view) { SPAction *action = make_action_helper(view, &perform); return action; } -/** \brief Decode the verb code and take appropriate action */ -void -FitCanvasVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void FitCanvasVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); if (!dt) return; @@ -2040,19 +2088,21 @@ FitCanvasVerb::perform(SPAction *action, void *data) return; } -/* *********** End Fit Canvas ********** */ +// *********** End Fit Canvas ********** -/* *********** Lock'N'Hide ********** */ +// *********** Lock'N'Hide ********** -/** \brief A class to represent the object unlocking and unhiding verbs */ +/** + * A class to represent the object unlocking and unhiding verbs. + */ class LockAndHideVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: virtual SPAction *make_action(Inkscape::UI::View::View *view); public: - /** \brief Use the Verb initializer with the same parameters. */ + /** Use the Verb initializer with the same parameters. */ LockAndHideVerb(unsigned int const code, gchar const *id, gchar const *name, @@ -2062,24 +2112,26 @@ public: { set_default_sensitive(true); } -}; /* LockAndHideVerb class */ +}; // LockAndHideVerb class -/** \brief Create an action for a \c LockAndHideVerb - \param view Which view the action should be created for - \return The built action. - - Calls \c make_action_helper with the \c vector. -*/ -SPAction * -LockAndHideVerb::make_action(Inkscape::UI::View::View *view) +/** + * Create an action for a \c LockAndHideVerb. + * + * Calls \c make_action_helper with the \c vector. + * + * @param view Which view the action should be created for. + * @return The built action. + */ +SPAction *LockAndHideVerb::make_action(Inkscape::UI::View::View *view) { SPAction *action = make_action_helper(view, &perform); return action; } -/** \brief Decode the verb code and take appropriate action */ -void -LockAndHideVerb::perform(SPAction *action, void *data) +/** + * Decode the verb code and take appropriate action. + */ +void LockAndHideVerb::perform(SPAction *action, void *data) { SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); if (!dt) return; @@ -2109,16 +2161,16 @@ LockAndHideVerb::perform(SPAction *action, void *data) return; } -/* *********** End Lock'N'Hide ********** */ +// *********** End Lock'N'Hide ********** -/* these must be in the same order as the SP_VERB_* enum in "verbs.h" */ +// these must be in the same order as the SP_VERB_* enum in "verbs.h" Verb *Verb::_base_verbs[] = { - /* Header */ + // Header new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL), new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL), - /* File */ + // File new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"), GTK_STOCK_NEW ), new FileVerb(SP_VERB_FILE_OPEN, "FileOpen", N_("_Open..."), @@ -2150,7 +2202,7 @@ Verb *Verb::_base_verbs[] = { N_("Close this document window"), GTK_STOCK_CLOSE), new FileVerb(SP_VERB_FILE_QUIT, "FileQuit", N_("_Quit"), N_("Quit Inkscape"), GTK_STOCK_QUIT), - /* Edit */ + // Edit new EditVerb(SP_VERB_EDIT_UNDO, "EditUndo", N_("_Undo"), N_("Undo last action"), GTK_STOCK_UNDO), new EditVerb(SP_VERB_EDIT_REDO, "EditRedo", N_("_Redo"), @@ -2226,7 +2278,7 @@ Verb *Verb::_base_verbs[] = { new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"), N_("Show next editable path effect parameter"), INKSCAPE_ICON("path-effect-parameter-next")), - /* Selection */ + // Selection new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"), N_("Raise selection to top"), INKSCAPE_ICON("selection-top")), new SelectionVerb(SP_VERB_SELECTION_TO_BACK, "SelectionToBack", N_("Lower to _Bottom"), @@ -2310,7 +2362,7 @@ Verb *Verb::_base_verbs[] = { N_("Break selected paths into subpaths"), INKSCAPE_ICON("path-break-apart")), new SelectionVerb(SP_VERB_SELECTION_GRIDTILE, "DialogGridArrange", N_("Ro_ws and Columns..."), N_("Arrange selected objects in a table"), INKSCAPE_ICON("dialog-rows-and-columns")), - /* Layer */ + // Layer new LayerVerb(SP_VERB_LAYER_NEW, "LayerNew", N_("_Add Layer..."), N_("Create a new layer"), INKSCAPE_ICON("layer-new")), new LayerVerb(SP_VERB_LAYER_RENAME, "LayerRename", N_("Re_name Layer..."), @@ -2338,7 +2390,7 @@ Verb *Verb::_base_verbs[] = { new LayerVerb(SP_VERB_LAYER_SOLO, "LayerSolo", N_("_Show/hide other layers"), N_("Solo the current layer"), NULL), - /* Object */ + // Object new ObjectVerb(SP_VERB_OBJECT_ROTATE_90_CW, "ObjectRotate90", N_("Rotate _90° CW"), // This is shared between tooltips and statusbar, so they // must use UTF-8, not HTML entities for special characters. @@ -2376,7 +2428,7 @@ Verb *Verb::_base_verbs[] = { new ObjectVerb(SP_VERB_OBJECT_UNSET_CLIPPATH, "ObjectUnSetClipPath", N_("_Release"), N_("Remove clipping path from selection"), NULL), - /* Tools */ + // Tools new ContextVerb(SP_VERB_CONTEXT_SELECT, "ToolSelector", N_("Select"), N_("Select and transform objects"), INKSCAPE_ICON("tool-pointer")), new ContextVerb(SP_VERB_CONTEXT_NODE, "ToolNode", N_("Node Edit"), @@ -2421,7 +2473,7 @@ Verb *Verb::_base_verbs[] = { N_("Erase existing paths"), INKSCAPE_ICON("draw-eraser")), new ContextVerb(SP_VERB_CONTEXT_LPETOOL, "ToolLPETool", N_("LPE Tool"), N_("Do geometric constructions"), "draw-geometry"), - /* Tool prefs */ + // Tool prefs new ContextVerb(SP_VERB_CONTEXT_SELECT_PREFS, "SelectPrefs", N_("Selector Preferences"), N_("Open Preferences for the Selector tool"), NULL), new ContextVerb(SP_VERB_CONTEXT_NODE_PREFS, "NodePrefs", N_("Node Tool Preferences"), @@ -2465,7 +2517,7 @@ Verb *Verb::_base_verbs[] = { new ContextVerb(SP_VERB_CONTEXT_LPETOOL_PREFS, "LPEToolPrefs", N_("LPE Tool Preferences"), N_("Open Preferences for the LPETool tool"), NULL), - /* Zoom/View */ + // Zoom/View new ZoomVerb(SP_VERB_ZOOM_IN, "ZoomIn", N_("Zoom In"), N_("Zoom in"), INKSCAPE_ICON("zoom-in")), new ZoomVerb(SP_VERB_ZOOM_OUT, "ZoomOut", N_("Zoom Out"), N_("Zoom out"), INKSCAPE_ICON("zoom-out")), new ZoomVerb(SP_VERB_TOGGLE_RULERS, "ToggleRulers", N_("_Rulers"), N_("Show or hide the canvas rulers"), NULL), @@ -2486,7 +2538,7 @@ Verb *Verb::_base_verbs[] = { #ifdef HAVE_GTK_WINDOW_FULLSCREEN new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"), INKSCAPE_ICON("view-fullscreen")), -#endif /* HAVE_GTK_WINDOW_FULLSCREEN */ +#endif // HAVE_GTK_WINDOW_FULLSCREEN new ZoomVerb(SP_VERB_FOCUSTOGGLE, "FocusToggle", N_("Toggle _Focus Mode"), N_("Remove excess toolbars to focus on drawing"), NULL), new ZoomVerb(SP_VERB_VIEW_NEW, "ViewNew", N_("Duplic_ate Window"), N_("Open a new window with the same document"), @@ -2525,7 +2577,7 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_ZOOM_SELECTION, "ZoomSelection", N_("_Selection"), N_("Zoom to fit selection in window"), INKSCAPE_ICON("zoom-fit-selection")), - /* Dialogs */ + // Dialogs new DialogVerb(SP_VERB_DIALOG_DISPLAY, "DialogPreferences", N_("In_kscape Preferences..."), N_("Edit global Inkscape preferences"), GTK_STOCK_PREFERENCES ), new DialogVerb(SP_VERB_DIALOG_NAMEDVIEW, "DialogDocumentProperties", N_("_Document Properties..."), @@ -2586,7 +2638,7 @@ Verb *Verb::_base_verbs[] = { new DialogVerb(SP_VERB_DIALOG_PRINT_COLORS_PREVIEW, "DialogPrintColorsPreview", N_("Print Colors..."), N_("Select which color separations to render in Print Colors Preview rendermode"), NULL), - /* Help */ + // Help new HelpVerb(SP_VERB_HELP_ABOUT_EXTENSIONS, "HelpAboutExtensions", N_("About E_xtensions"), N_("Information on Inkscape extensions"), NULL), new HelpVerb(SP_VERB_HELP_MEMORY, "HelpAboutMemory", N_("About _Memory"), @@ -2596,7 +2648,7 @@ Verb *Verb::_base_verbs[] = { //new HelpVerb(SP_VERB_SHOW_LICENSE, "ShowLicense", N_("_License"), // N_("Distribution terms"), /*"show_license"*/"inkscape_options"), - /* Tutorials */ + // Tutorials new TutorialVerb(SP_VERB_TUTORIAL_BASIC, "TutorialsBasic", N_("Inkscape: _Basic"), N_("Getting started with Inkscape"), NULL/*"tutorial_basic"*/), new TutorialVerb(SP_VERB_TUTORIAL_SHAPES, "TutorialsShapes", N_("Inkscape: _Shapes"), @@ -2615,20 +2667,20 @@ Verb *Verb::_base_verbs[] = { new TutorialVerb(SP_VERB_TUTORIAL_TIPS, "TutorialsTips", N_("_Tips and Tricks"), N_("Miscellaneous tips and tricks"), NULL/*"tutorial_tips"*/), - /* Effect -- renamed Extension */ + // Effect -- renamed Extension new EffectLastVerb(SP_VERB_EFFECT_LAST, "EffectLast", N_("Previous Exte_nsion"), N_("Repeat the last extension with the same settings"), NULL), new EffectLastVerb(SP_VERB_EFFECT_LAST_PREF, "EffectLastPref", N_("_Previous Extension Settings..."), N_("Repeat the last extension with new settings"), NULL), - /* Fit Page */ + // Fit Page new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION, "FitCanvasToSelection", N_("Fit Page to Selection"), N_("Fit the page to the current selection"), NULL), new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_DRAWING, "FitCanvasToDrawing", N_("Fit Page to Drawing"), N_("Fit the page to the drawing"), NULL), new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("Fit Page to Selection or Drawing"), N_("Fit the page to the current selection or the drawing if there is no selection"), NULL), - /* LockAndHide */ + // LockAndHide new LockAndHideVerb(SP_VERB_UNLOCK_ALL, "UnlockAll", N_("Unlock All"), N_("Unlock all objects in the current layer"), NULL), new LockAndHideVerb(SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, "UnlockAllInAllLayers", N_("Unlock All in All Layers"), @@ -2637,12 +2689,12 @@ Verb *Verb::_base_verbs[] = { N_("Unhide all objects in the current layer"), NULL), new LockAndHideVerb(SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, "UnhideAllInAllLayers", N_("Unhide All in All Layers"), N_("Unhide all objects in all layers"), NULL), - /*Color Management*/ + // Color Management new EditVerb(SP_VERB_EDIT_LINK_COLOR_PROFILE, "LinkColorProfile", N_("Link Color Profile"), N_("Link an ICC color profile"), NULL), new EditVerb(SP_VERB_EDIT_REMOVE_COLOR_PROFILE, "RemoveColorProfile", N_("Remove Color Profile"), N_("Remove a linked ICC color profile"), NULL), - /* Footer */ + // Footer new Verb(SP_VERB_LAST, " '\"invalid id", NULL, NULL, NULL) }; @@ -2664,7 +2716,7 @@ Verb::list (void) { return; }; -} /* namespace Inkscape */ +} // namespace Inkscape /* Local Variables: diff --git a/src/winconsole.cpp b/src/winconsole.cpp index f6ee49e13..1515d2062 100644 --- a/src/winconsole.cpp +++ b/src/winconsole.cpp @@ -1,5 +1,6 @@ -/** \file - * @brief Command-line wrapper for Windows. +/** + * \file + * Command-line wrapper for Windows. * * Windows has two types of executables: GUI and console. * The GUI executables detach immediately when run from the command -- cgit v1.2.3 From 6343a24c5cd0a998e00ae05fc6abe2081be21c71 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Mon, 3 Oct 2011 00:24:15 -0700 Subject: Doxygen cleanup. (bzr r10660) --- src/bind/dobinding.cpp | 2 +- src/bind/javabind.cpp | 2 +- src/dialogs/dialog-events.cpp | 27 +- src/dialogs/export.cpp | 373 +++++++++++++------------- src/dialogs/find.cpp | 5 +- src/dialogs/item-properties.cpp | 24 +- src/dialogs/object-attributes.cpp | 5 +- src/dialogs/spellcheck.cpp | 5 +- src/dialogs/text-edit.cpp | 5 +- src/dialogs/xml-tree.cpp | 13 +- src/helper/action.cpp | 17 +- src/live_effects/lpe-circle_with_radius.cpp | 5 +- src/live_effects/lpe-extrude.cpp | 6 +- src/live_effects/lpe-knot.cpp | 5 +- src/live_effects/lpe-perspective_path.cpp | 5 +- src/live_effects/lpe-powerstroke.cpp | 6 +- src/live_effects/lpe-recursiveskeleton.cpp | 6 +- src/live_effects/lpe-skeleton.cpp | 6 +- src/live_effects/lpe-sketch.cpp | 5 +- src/live_effects/lpegroupbbox.cpp | 15 +- src/ui/clipboard.cpp | 81 +++--- src/ui/dialog/aboutbox.cpp | 5 +- src/ui/dialog/align-and-distribute.cpp | 5 +- src/ui/dialog/calligraphic-profile-rename.cpp | 5 +- src/ui/dialog/color-item.cpp | 5 +- src/ui/dialog/debug.cpp | 7 +- src/ui/dialog/dialog-manager.cpp | 5 +- src/ui/dialog/dialog.cpp | 5 +- src/ui/dialog/dock-behavior.cpp | 5 +- src/ui/dialog/document-metadata.cpp | 16 +- src/ui/dialog/document-properties.cpp | 22 +- src/ui/dialog/extension-editor.cpp | 91 +++---- src/ui/dialog/extensions.cpp | 5 +- src/ui/dialog/filedialog.cpp | 5 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 5 +- src/ui/dialog/filedialogimpl-win32.cpp | 5 +- src/ui/dialog/fill-and-stroke.cpp | 5 +- src/ui/dialog/filter-effects-dialog.cpp | 5 +- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/floating-behavior.cpp | 39 +-- src/ui/dialog/guides.cpp | 5 +- src/ui/dialog/icon-preview.cpp | 5 +- src/ui/dialog/inkscape-preferences.cpp | 5 +- src/ui/dialog/input.cpp | 5 +- src/ui/dialog/layer-properties.cpp | 5 +- src/ui/dialog/livepatheffect-editor.cpp | 5 +- src/ui/dialog/memory.cpp | 5 +- src/ui/dialog/messages.cpp | 5 +- src/ui/dialog/ocaldialogs.cpp | 5 +- src/ui/dialog/print-colors-preview-dialog.cpp | 5 +- src/ui/dialog/print.cpp | 5 +- src/ui/dialog/scriptdialog.cpp | 5 +- src/ui/dialog/svg-fonts-dialog.cpp | 5 +- src/ui/dialog/swatches.cpp | 6 +- src/ui/dialog/tracedialog.cpp | 5 +- src/ui/dialog/transformation.cpp | 5 +- src/ui/dialog/undo-history.cpp | 5 +- src/ui/tool/control-point-selection.cpp | 16 +- src/ui/tool/control-point.cpp | 9 +- src/ui/tool/multi-path-manipulator.cpp | 23 +- src/ui/tool/node-tool.cpp | 5 +- src/ui/tool/node.cpp | 43 +-- src/ui/tool/path-manipulator.cpp | 11 +- src/ui/widget/button.cpp | 2 +- src/ui/widget/color-picker.cpp | 5 +- src/ui/widget/dock-item.cpp | 2 +- src/ui/widget/dock.cpp | 5 +- src/ui/widget/entry.cpp | 5 +- src/ui/widget/handlebox.cpp | 2 +- src/ui/widget/icon-widget.cpp | 2 +- src/ui/widget/labelled.cpp | 2 +- src/ui/widget/notebook-page.cpp | 2 +- src/ui/widget/panel.cpp | 2 +- src/ui/widget/point.cpp | 2 +- src/ui/widget/preferences-widget.cpp | 2 +- src/ui/widget/random.cpp | 2 +- src/ui/widget/rendering-options.cpp | 2 +- src/ui/widget/rotateable.cpp | 2 +- src/ui/widget/scalar-unit.cpp | 2 +- src/ui/widget/scalar.cpp | 2 +- src/ui/widget/selected-style.cpp | 2 +- src/ui/widget/spin-slider.cpp | 2 +- src/ui/widget/spinbutton.cpp | 2 +- src/ui/widget/style-subject.cpp | 2 +- src/ui/widget/style-swatch.cpp | 9 +- src/ui/widget/text.cpp | 2 +- src/ui/widget/toolbox.cpp | 2 +- src/ui/widget/unit-menu.cpp | 2 +- src/widgets/dash-selector.cpp | 7 +- src/widgets/eek-preview.cpp | 5 +- src/widgets/ege-paint-def.cpp | 5 +- src/widgets/fill-style.cpp | 5 +- src/widgets/paint-selector.cpp | 12 +- src/widgets/sp-attribute-widget.cpp | 5 +- src/widgets/spw-utilities.cpp | 16 +- src/widgets/stroke-style.cpp | 28 +- src/widgets/toolbox.cpp | 9 +- src/xml/croco-node-iface.cpp | 3 +- src/xml/log-builder.cpp | 5 +- src/xml/repr-util.cpp | 12 +- src/xml/simple-document.cpp | 5 +- src/xml/simple-node.cpp | 5 +- 102 files changed, 638 insertions(+), 603 deletions(-) (limited to 'src') diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp index 1ba708ed7..284565e92 100644 --- a/src/bind/dobinding.cpp +++ b/src/bind/dobinding.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief This is a simple mechanism to bind Inkscape to Java, and thence + * This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. * * Authors: diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index 6dc8c9a9b..db112708e 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -1,6 +1,6 @@ /** * @file - * @brief This is a simple mechanism to bind Inkscape to Java, and thence + * This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. * * Authors: diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp index 89feca23e..08600afa7 100644 --- a/src/dialogs/dialog-events.cpp +++ b/src/dialogs/dialog-events.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Event handler for dialog windows +/** + * @file + * Event handler for dialog windows. */ /* Authors: * bulia byak <bulia@dr.com> @@ -30,15 +31,12 @@ /** - * \brief Remove focus from window to whoever it is transient for... - * + * Remove focus from window to whoever it is transient for. */ -void -sp_dialog_defocus_cpp (Gtk::Window *win) +void sp_dialog_defocus_cpp(Gtk::Window *win) { - Gtk::Window *w; //find out the document window we're transient for - w = win->get_transient_for(); + Gtk::Window *w = win->get_transient_for(); //switch to it if (w) { @@ -61,11 +59,9 @@ sp_dialog_defocus (GtkWindow *win) /** - * \brief Callback to defocus a widget's parent dialog. - * + * Callback to defocus a widget's parent dialog. */ -void -sp_dialog_defocus_callback_cpp (Gtk::Entry *e) +void sp_dialog_defocus_callback_cpp(Gtk::Entry *e) { sp_dialog_defocus_cpp(dynamic_cast<Gtk::Window *>(e->get_toplevel())); } @@ -152,11 +148,10 @@ sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data) /** - * \brief Make the argument dialog transient to the currently active document - window. + * Make the argument dialog transient to the currently active document + * window. */ -void -sp_transientize (GtkWidget *dialog) +void sp_transientize(GtkWidget *dialog) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); #ifndef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index a19f9b60f..2f1b2cd89 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief PNG export dialog +/** + * @file + * PNG export dialog. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -189,32 +190,30 @@ sp_export_dialog_delete ( GtkObject */*object*/, GdkEvent */*event*/, gpointer / } // end of sp_export_dialog_delete() /** - \brief Creates a new spin button for the export dialog - \param key The name of the spin button - \param val A default value for the spin button - \param min Minimum value for the spin button - \param max Maximum value for the spin button - \param step The step size for the spin button - \param page Size of the page increment - \param us Unit selector that effects this spin button - \param t Table to put the spin button in - \param x X location in the table \c t to start with - \param y Y location in the table \c t to start with - \param ll Text to put on the left side of the spin button (optional) - \param lr Text to put on the right side of the spin button (optional) - \param digits Number of digits to display after the decimal - \param sensitive Whether the spin button is sensitive or not - \param cb Callback for when this spin button is changed (optional) - \param dlg Export dialog the spin button is being placed in - -*/ -static void -sp_export_spinbutton_new ( gchar const *key, float val, float min, float max, - float step, float page, GtkWidget *us, - GtkWidget *t, int x, int y, - const gchar *ll, const gchar *lr, - int digits, unsigned int sensitive, - GCallback cb, GtkWidget *dlg ) + * Creates a new spin button for the export dialog. + * @param key The name of the spin button + * @param val A default value for the spin button + * @param min Minimum value for the spin button + * @param max Maximum value for the spin button + * @param step The step size for the spin button + * @param page Size of the page increment + * @param us Unit selector that effects this spin button + * @param t Table to put the spin button in + * @param x X location in the table \c t to start with + * @param y Y location in the table \c t to start with + * @param ll Text to put on the left side of the spin button (optional) + * @param lr Text to put on the right side of the spin button (optional) + * @param digits Number of digits to display after the decimal + * @param sensitive Whether the spin button is sensitive or not + * @param cb Callback for when this spin button is changed (optional) + * @param dlg Export dialog the spin button is being placed in + */ +static void sp_export_spinbutton_new( gchar const *key, float val, float min, float max, + float step, float page, GtkWidget *us, + GtkWidget *t, int x, int y, + const gchar *ll, const gchar *lr, + int digits, unsigned int sensitive, + GCallback cb, GtkWidget *dlg ) { GtkObject *adj = gtk_adjustment_new( val, min, max, step, page, 0 ); g_object_set_data( G_OBJECT (adj), "key", const_cast<gchar *>(key) ); @@ -734,14 +733,12 @@ sp_export_find_default_selection(GtkWidget * dlg) /** - * \brief If selection changed or a different document activated, we must - * recalculate any chosen areas - * + * If selection changed or a different document activated, we must + * recalculate any chosen areas. */ -static void -sp_export_selection_changed ( Inkscape::Application *inkscape, - Inkscape::Selection *selection, - GtkObject *base ) +static void sp_export_selection_changed( Inkscape::Application *inkscape, + Inkscape::Selection *selection, + GtkObject *base ) { selection_type current_key; current_key = (selection_type)(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(base), "selection-type"))); @@ -1445,34 +1442,34 @@ sp_export_bbox_equal(Geom::Rect const &one, Geom::Rect const &two) } /** - \brief This function is used to detect the current selection setting - based on the values in the x0, y0, x1 and y0 fields. - \param base The export dialog itself - - One of the most confusing parts of this function is why the array - is built at the beginning. What needs to happen here is that we - should always check the current selection to see if it is the valid - one. While this is a performance improvement it is also a usability - one during the cases where things like selections and drawings match - size. This way buttons change less 'randomly' (atleast in the eyes - of the user). To do this an array is built where the current selection - type is placed first, and then the others in an order from smallest - to largest (this can be configured by reshuffling \c test_order). - - All of the values in this function are rounded to two decimal places - because that is what is shown to the user. While everything is kept - more accurate than that, the user can't control more acurrate than - that, so for this to work for them - it needs to check on that level - of accuracy. - - \todo finish writing this up -*/ -static void -sp_export_detect_size(GtkObject * base) { + *This function is used to detect the current selection setting + * based on the values in the x0, y0, x1 and y0 fields. + * + * One of the most confusing parts of this function is why the array + * is built at the beginning. What needs to happen here is that we + * should always check the current selection to see if it is the valid + * one. While this is a performance improvement it is also a usability + * one during the cases where things like selections and drawings match + * size. This way buttons change less 'randomly' (atleast in the eyes + * of the user). To do this an array is built where the current selection + * type is placed first, and then the others in an order from smallest + * to largest (this can be configured by reshuffling \c test_order). + * + * All of the values in this function are rounded to two decimal places + * because that is what is shown to the user. While everything is kept + * more accurate than that, the user can't control more acurrate than + * that, so for this to work for them - it needs to check on that level + * of accuracy. + * + * @param base The export dialog itself. + * + * @todo finish writing this up. + */ +static void sp_export_detect_size(GtkObject * base) { static const selection_type test_order[SELECTION_NUMBER_OF] = {SELECTION_SELECTION, SELECTION_DRAWING, SELECTION_PAGE, SELECTION_CUSTOM}; selection_type this_test[SELECTION_NUMBER_OF + 1]; selection_type key = SELECTION_NUMBER_OF; - + Geom::Point x(sp_export_value_get_px (base, "x0"), sp_export_value_get_px (base, "y0")); Geom::Point y(sp_export_value_get_px (base, "x1"), @@ -1719,15 +1716,14 @@ sp_export_area_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) } // end of sp_export_area_height_value_changed() /** - \brief A function to set the ydpi - \param base The export dialog - - This function grabs all of the y values and then figures out the - new bitmap size based on the changing dpi value. The dpi value is - gotten from the xdpi setting as these can not currently be independent. -*/ -static void -sp_export_set_image_y (GtkObject *base) + * A function to set the ydpi. + * @param base The export dialog. + * + * This function grabs all of the y values and then figures out the + * new bitmap size based on the changing dpi value. The dpi value is + * gotten from the xdpi setting as these can not currently be independent. + */ +static void sp_export_set_image_y(GtkObject *base) { float y0, y1, xdpi; @@ -1742,15 +1738,15 @@ sp_export_set_image_y (GtkObject *base) } // end of sp_export_set_image_y() /** - \brief A function to set the xdpi - \param base The export dialog - - This function grabs all of the x values and then figures out the - new bitmap size based on the changing dpi value. The dpi value is - gotten from the xdpi setting as these can not currently be independent. -*/ -static void -sp_export_set_image_x (GtkObject *base) + * A function to set the xdpi. + * + * This function grabs all of the x values and then figures out the + * new bitmap size based on the changing dpi value. The dpi value is + * gotten from the xdpi setting as these can not currently be independent. + * + * @param base The export dialog. + */ +static void sp_export_set_image_x(GtkObject *base) { float x0, x1, xdpi; @@ -1835,35 +1831,35 @@ sp_export_bitmap_height_value_changed (GtkAdjustment */*adj*/, GtkObject *base) } // end of sp_export_bitmap_width_value_changed() /** - \brief A function to adjust the bitmap width when the xdpi value changes - \param adj The adjustment that was changed - \param base The export dialog itself - - The first thing this function checks is to see if we are doing an - update. If we are, this function just returns because there is another - instance of it that will handle everything for us. If there is a - units change, we also assume that everyone is being updated appropriately - and there is nothing for us to do. - - If we're the highest level function, we set the update flag, and - continue on our way. - - All of the values are grabbed using the \c sp_export_value_get functions - (call to the _pt ones for x0 and x1 but just standard for xdpi). The - xdpi value is saved in the preferences for the next time the dialog - is opened. (does the selection dpi need to be set here?) - - A check is done to to ensure that we aren't outputing an invalid width, - this is set by SP_EXPORT_MIN_SIZE. If that is the case the dpi is - changed to make it valid. - - After all of this the bitmap width is changed. - - We also change the ydpi. This is a temporary hack as these can not - currently be independent. This is likely to change in the future. -*/ -void -sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base) + * A function to adjust the bitmap width when the xdpi value changes. + * + * The first thing this function checks is to see if we are doing an + * update. If we are, this function just returns because there is another + * instance of it that will handle everything for us. If there is a + * units change, we also assume that everyone is being updated appropriately + * and there is nothing for us to do. + * + * If we're the highest level function, we set the update flag, and + * continue on our way. + * + * All of the values are grabbed using the \c sp_export_value_get functions + * (call to the _pt ones for x0 and x1 but just standard for xdpi). The + * xdpi value is saved in the preferences for the next time the dialog + * is opened. (does the selection dpi need to be set here?) + * + * A check is done to to ensure that we aren't outputing an invalid width, + * this is set by SP_EXPORT_MIN_SIZE. If that is the case the dpi is + * changed to make it valid. + * + * After all of this the bitmap width is changed. + * + * We also change the ydpi. This is a temporary hack as these can not + * currently be independent. This is likely to change in the future. + * + * @param adj The adjustment that was changed. + * @param base The export dialog itself. + */ +void sp_export_xdpi_value_changed(GtkAdjustment */*adj*/, GtkObject *base) { float x0, x1, xdpi, bmwidth; @@ -1907,26 +1903,26 @@ sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base) /** - \brief A function to change the area that is used for the exported - bitmap. - \param base This is the export dialog - \param x0 Horizontal upper left hand corner of the picture in points - \param y0 Vertical upper left hand corner of the picture in points - \param x1 Horizontal lower right hand corner of the picture in points - \param y1 Vertical lower right hand corner of the picture in points - - This function just calls \c sp_export_value_set_px for each of the - parameters that is passed in. This allows for setting them all in - one convient area. - - Update is set to suspend all of the other test running while all the - values are being set up. This allows for a performance increase, but - it also means that the wrong type won't be detected with only some of - the values set. After all the values are set everyone is told that - there has been an update. -*/ -static void -sp_export_set_area ( GtkObject *base, double x0, double y0, double x1, double y1 ) + * A function to change the area that is used for the exported. + * bitmap. + * + * This function just calls \c sp_export_value_set_px for each of the + * parameters that is passed in. This allows for setting them all in + * one convient area. + * + * Update is set to suspend all of the other test running while all the + * values are being set up. This allows for a performance increase, but + * it also means that the wrong type won't be detected with only some of + * the values set. After all the values are set everyone is told that + * there has been an update. + * + * @param base This is the export dialog. + * @param x0 Horizontal upper left hand corner of the picture in points. + * @param y0 Vertical upper left hand corner of the picture in points. + * @param x1 Horizontal lower right hand corner of the picture in points. + * @param y1 Vertical lower right hand corner of the picture in points. + */ +static void sp_export_set_area( GtkObject *base, double x0, double y0, double x1, double y1 ) { g_object_set_data (G_OBJECT (base), "update", GUINT_TO_POINTER (TRUE) ); sp_export_value_set_px (base, "x1", x1); @@ -1942,38 +1938,36 @@ sp_export_set_area ( GtkObject *base, double x0, double y0, double x1, double y1 } /** - \brief Sets the value of an adjustment - \param base The export dialog - \param key Which adjustment to set - \param val What value to set it to - - This function finds the adjustment using the data stored in the - export dialog. After finding the adjustment it then sets - the value of it. -*/ -static void -sp_export_value_set ( GtkObject *base, const gchar *key, double val ) + * Sets the value of an adjustment. + * + * This function finds the adjustment using the data stored in the + * export dialog. After finding the adjustment it then sets + * the value of it. + * + * @param base The export dialog. + * @param key Which adjustment to set. + * @param val What value to set it to. + */ +static void sp_export_value_set( GtkObject *base, const gchar *key, double val ) { - GtkAdjustment *adj; - - adj = (GtkAdjustment *)g_object_get_data (G_OBJECT(base), key); + GtkAdjustment *adj = (GtkAdjustment *)g_object_get_data (G_OBJECT(base), key); gtk_adjustment_set_value (adj, val); } /** - \brief A function to set a value using the units points - \param base The export dialog - \param key Which value should be set - \param val What the value should be in points - - This function first gets the adjustment for the key that is passed - in. It then figures out what units are currently being used in the - dialog. After doing all of that, it then converts the incoming - value and sets the adjustment. -*/ -static void -sp_export_value_set_px (GtkObject *base, const gchar *key, double val) + * A function to set a value using the units points. + * + * This function first gets the adjustment for the key that is passed + * in. It then figures out what units are currently being used in the + * dialog. After doing all of that, it then converts the incoming + *value and sets the adjustment. + * + * @param base The export dialog. + * @param key Which value should be set. + * @param val What the value should be in points. + */ +static void sp_export_value_set_px(GtkObject *base, const gchar *key, double val) { const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)g_object_get_data (G_OBJECT(base), "units") ); @@ -1983,16 +1977,16 @@ sp_export_value_set_px (GtkObject *base, const gchar *key, double val) } /** - \brief Get the value of an adjustment in the export dialog - \param base The export dialog - \param key Which adjustment is being looked for - \return The value in the specified adjustment - - This function gets the adjustment from the data field in the export - dialog. It then grabs the value from the adjustment. -*/ -static float -sp_export_value_get ( GtkObject *base, const gchar *key ) + * Get the value of an adjustment in the export dialog. + * + * This function gets the adjustment from the data field in the export + * dialog. It then grabs the value from the adjustment. + * + * @param base The export dialog. + * @param key Which adjustment is being looked for. + * @return The value in the specified adjustment. + */ +static float sp_export_value_get( GtkObject *base, const gchar *key ) { GtkAdjustment *adj; @@ -2002,19 +1996,19 @@ sp_export_value_get ( GtkObject *base, const gchar *key ) } /** - \brief Grabs a value in the export dialog and converts the unit - to points - \param base The export dialog - \param key Which value should be returned - \return The value in the adjustment in points - - This function, at its most basic, is a call to \c sp_export_value_get - to get the value of the adjustment. It then finds the units that - are being used by looking at the "units" attribute of the export - dialog. Using that it converts the returned value into points. -*/ -static float -sp_export_value_get_px ( GtkObject *base, const gchar *key ) + * Grabs a value in the export dialog and converts the unit + * to points. + * + * This function, at its most basic, is a call to \c sp_export_value_get + * to get the value of the adjustment. It then finds the units that + * are being used by looking at the "units" attribute of the export + * dialog. Using that it converts the returned value into points. + * + * @param base The export dialog. + * @param key Which value should be returned. + * @return The value in the adjustment in points. + */ +static float sp_export_value_get_px( GtkObject *base, const gchar *key ) { float value = sp_export_value_get(base, key); const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)g_object_get_data (G_OBJECT(base), "units")); @@ -2023,20 +2017,19 @@ sp_export_value_get_px ( GtkObject *base, const gchar *key ) } // end of sp_export_value_get_px() /** - \brief This function is called when the filename is changed by - anyone. It resets the virgin bit. - \param object Text entry box - \param data The export dialog - \return None - - This function gets called when the text area is modified. It is - looking for the case where the text area is modified from its - original value. In that case it sets the "filename-modified" bit - to TRUE. If the text dialog returns back to the original text, the - bit gets reset. This should stop simple mistakes. -*/ -static void -sp_export_filename_modified (GtkObject * object, gpointer data) + * This function is called when the filename is changed by + * anyone. It resets the virgin bit. + * + * This function gets called when the text area is modified. It is + * looking for the case where the text area is modified from its + * original value. In that case it sets the "filename-modified" bit + * to TRUE. If the text dialog returns back to the original text, the + * bit gets reset. This should stop simple mistakes. + * + * @param object Text entry box. + * @param data The export dialog. + */ +static void sp_export_filename_modified(GtkObject * object, gpointer data) { GtkWidget * text_entry = (GtkWidget *)object; GtkWidget * export_dialog = (GtkWidget *)data; diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index b30671114..4288e7a78 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Find dialog +/** + * @file + * Find dialog. */ /* Authors: * bulia byak <bulia@users.sf.net> diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 0c81d8b3c..4ca2b2753 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Object properties dialog +/** + * @file + * Object properties dialog. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -79,11 +80,9 @@ sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*da } /** - * \brief Creates new instance of item properties widget - * + * Creates new instance of item properties widget. */ -GtkWidget * -sp_item_widget_new (void) +GtkWidget *sp_item_widget_new(void) { GtkWidget *spw, *vb, *t, *cb, *l, *f, *tf, *pb, *int_expander, *int_label; @@ -268,10 +267,9 @@ sp_item_widget_change_selection ( SPWidget *spw, /** -* \param selection Selection to use; should not be NULL. -*/ -static void -sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection ) + * @param selection Selection to use; should not be NULL. + */ +static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection ) { g_assert (selection != NULL); @@ -483,11 +481,9 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) /** - * \brief Dialog - * + * Dialog. */ -void -sp_item_dialog (void) +void sp_item_dialog(void) { if (dlg == NULL) { diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp index 57b295e4e..043454dc8 100644 --- a/src/dialogs/object-attributes.cpp +++ b/src/dialogs/object-attributes.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Generic properties editor +/** + * @file + * Generic properties editor. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index bd8381d8c..847f5b877 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Spellcheck dialog +/** + * @file + * Spellcheck dialog. */ /* Authors: * bulia byak <bulia@users.sf.net> diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 382b1d630..ae34fe4b1 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Text editing dialog +/** + * @file + * Text editing dialog. */ /* Authors: * Lauris Kaplinski <lauris@ximian.com> diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 2f489c4b5..8b4462c59 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief XML editor +/** + * @file + * XML editor. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -148,8 +149,8 @@ static gboolean sp_xml_tree_key_press(GtkWidget *widget, GdkEventKey *event); static bool in_dt_coordsys(SPObject const &item); -/* - * \brief Sets the XML status bar when the tree is selected. +/** + * Sets the XML status bar when the tree is selected. */ void tree_reset_context() { @@ -158,8 +159,8 @@ void tree_reset_context() } -/* - * \brief Sets the XML status bar, depending on which attr is selected. +/** + * Sets the XML status bar, depending on which attr is selected. */ void attr_reset_context(gint attr) { diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 532078a3d..48ba7f2ea 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -1,5 +1,6 @@ -/** \file - * SPAction implementation +/** + * @file + * SPAction implementation. * * Author: * Lauris Kaplinski <lauris@kaplinski.com> @@ -151,13 +152,11 @@ public: } /** - \return None - \brief Executes an action - \param action The action to be executed - \param data ignored -*/ -void -sp_action_perform (SPAction *action, void * /*data*/) + * Executes an action. + * @param action The action to be executed. + * @param data ignored. + */ +void sp_action_perform(SPAction *action, void * /*data*/) { g_return_if_fail (action != NULL); g_return_if_fail (SP_IS_ACTION (action)); diff --git a/src/live_effects/lpe-circle_with_radius.cpp b/src/live_effects/lpe-circle_with_radius.cpp index 4aec82377..8a32cd230 100644 --- a/src/live_effects/lpe-circle_with_radius.cpp +++ b/src/live_effects/lpe-circle_with_radius.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief LPE effect that draws a circle based on two points and a radius +/** + * @file + * LPE effect that draws a circle based on two points and a radius. * - implementation */ /* Authors: diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index 8b5badf5f..61b61f7bf 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -1,6 +1,6 @@ -#define INKSCAPE_LPE_EXTRUDE_CPP -/** \file - * @brief LPE effect for extruding paths (making them "3D"). +/** + * @file + * LPE effect for extruding paths (making them "3D"). * */ /* Authors: diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index b025debb3..4c88ac315 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief LPE knot effect implementation +/** + * @file + * LPE knot effect implementation. */ /* Authors: * Jean-Francois Barraud <jf.barraud@gmail.com> diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 58efe4ef5..9208d4aeb 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief LPE perspective path effect implementation. +/** + * @file + * LPE perspective path effect implementation. */ /* Authors: * Maximilian Albert <maximilian.albert@gmail.com> diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 582ea2750..d9806b4d7 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -1,6 +1,6 @@ -#define INKSCAPE_LPE_POWERSTROKE_CPP -/** \file - * @brief PowerStroke LPE implementation. Creates curves with modifiable stroke width. +/** + * @file + * PowerStroke LPE implementation. Creates curves with modifiable stroke width. */ /* Authors: * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl> diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index d78ad2fcb..ac8c112d6 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -1,7 +1,5 @@ -#define INKSCAPE_LPE_RECURSIVESKELETON_CPP -/** \file - * @brief - * +/** + * @file * Inspired by Hofstadter's 'Goedel Escher Bach', chapter V. */ /* Authors: diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index daf96aa13..08f31da7e 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -1,6 +1,6 @@ -#define INKSCAPE_LPE_SKELETON_CPP -/** \file - * @brief Minimal dummy LPE effect implementation, used as an example for a base +/** + * @file + * Minimal dummy LPE effect implementation, used as an example for a base * starting class when implementing new LivePathEffects. * * In vi, three global search-and-replaces will let you rename everything diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index b621f6eca..9cd6f1b57 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief LPE sketch effect implementation +/** + * @file + * LPE sketch effect implementation. */ /* Authors: * Jean-Francois Barraud <jf.barraud@gmail.com> diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index c241b9a4c..e2378265a 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -13,17 +13,16 @@ namespace Inkscape { namespace LivePathEffect { /** - * \brief Updates the \c boundingbox_X and \c boundingbox_Y values from the geometric bounding box of \c lpeitem. + * Updates the \c boundingbox_X and \c boundingbox_Y values from the geometric bounding box of \c lpeitem. * - * \pre lpeitem must have an existing geometric boundingbox (usually this is guaranteed when: \code SP_SHAPE(lpeitem)->curve != NULL \endcode ) - It's not possible to run LPEs on items without their original-d having a bbox. - * \param lpeitem This is not allowed to be NULL. - * \param absolute Determines whether the bbox should be calculated of the untransformed lpeitem (\c absolute = \c false) + * @pre lpeitem must have an existing geometric boundingbox (usually this is guaranteed when: \code SP_SHAPE(lpeitem)->curve != NULL \endcode ) + * It's not possible to run LPEs on items without their original-d having a bbox. + * @param lpeitem This is not allowed to be NULL. + * @param absolute Determines whether the bbox should be calculated of the untransformed lpeitem (\c absolute = \c false) * or of the transformed lpeitem (\c absolute = \c true) using sp_item_i2doc_affine. - * \post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met. + * @post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met. */ -void -GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) +void GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) { // Get item bounding box Geom::Affine transform; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index bb89879fb..d1191cb3b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief System-wide clipboard management - implementation +/** + * @file + * System-wide clipboard management - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk@o2.pl> @@ -82,7 +83,7 @@ #include "snap.h" #include "persp3d.h" -/// @brief Made up mimetype to represent Gdk::Pixbuf clipboard contents +/// Made up mimetype to represent Gdk::Pixbuf clipboard contents. #define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf" #define CLIPBOARD_TEXT_TARGET "text/plain" @@ -102,7 +103,7 @@ namespace UI { /** - * @brief Default implementation of the clipboard manager + * Default implementation of the clipboard manager. */ class ClipboardManagerImpl : public ClipboardManager { public: @@ -192,7 +193,7 @@ ClipboardManagerImpl::~ClipboardManagerImpl() {} /** - * @brief Copy selection contents to the clipboard + * Copy selection contents to the clipboard. */ void ClipboardManagerImpl::copy(SPDesktop *desktop) { @@ -272,8 +273,8 @@ void ClipboardManagerImpl::copy(SPDesktop *desktop) /** - * @brief Copy a Live Path Effect path parameter to the clipboard - * @param pp The path parameter to store in the clipboard + * Copy a Live Path Effect path parameter to the clipboard. + * @param pp The path parameter to store in the clipboard. */ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam *pp) { @@ -299,8 +300,8 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam } /** - * @brief Paste from the system clipboard into the active desktop - * @param in_place Whether to put the contents where they were when copied + * Paste from the system clipboard into the active desktop. + * @param in_place Whether to put the contents where they were when copied. */ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) { @@ -341,7 +342,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) } /** - * @brief Returns the id of the first visible copied object + * Returns the id of the first visible copied object. */ const gchar *ClipboardManagerImpl::getFirstObjectID() { @@ -377,7 +378,7 @@ const gchar *ClipboardManagerImpl::getFirstObjectID() /** - * @brief Implements the Paste Style action + * Implements the Paste Style action. */ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) { @@ -425,7 +426,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) /** - * @brief Resize the selection or each object in the selection to match the clipboard's size + * Resize the selection or each object in the selection to match the clipboard's size. * @param separately Whether to scale each object in the selection separately * @param apply_x Whether to scale the width of objects / selection * @param apply_y Whether to scale the height of objects / selection @@ -488,7 +489,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a /** - * @brief Applies a path effect from the clipboard to the selected path + * Applies a path effect from the clipboard to the selected path. */ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) { @@ -532,7 +533,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) /** - * @brief Get LPE path data from the clipboard + * Get LPE path data from the clipboard. * @return The retrieved path data (contents of the d attribute), or "" if no path was found */ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) @@ -555,8 +556,8 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) /** - * @brief Get object id of a shape or text item from the clipboard - * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found + * Get object id of a shape or text item from the clipboard. + * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found. */ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) { @@ -583,7 +584,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) /** - * @brief Iterate over a list of items and copy them to the clipboard. + * Iterate over a list of items and copy them to the clipboard. */ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { @@ -645,7 +646,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) /** - * @brief Recursively copy all the definitions used by a given item to the clipboard defs + * Recursively copy all the definitions used by a given item to the clipboard defs. */ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) { @@ -734,7 +735,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) /** - * @brief Copy a single gradient to the clipboard's defs element + * Copy a single gradient to the clipboard's defs element. */ void ClipboardManagerImpl::_copyGradient(SPGradient *gradient) { @@ -747,7 +748,7 @@ void ClipboardManagerImpl::_copyGradient(SPGradient *gradient) /** - * @brief Copy a single pattern to the clipboard document's defs element + * Copy a single pattern to the clipboard document's defs element. */ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) { @@ -768,7 +769,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) /** - * @brief Copy a text path to the clipboard's defs element + * Copy a text path to the clipboard's defs element. */ void ClipboardManagerImpl::_copyTextPath(SPTextPath *tp) { @@ -787,7 +788,7 @@ void ClipboardManagerImpl::_copyTextPath(SPTextPath *tp) /** - * @brief Copy a single XML node from one document to another + * Copy a single XML node from one document to another. * @param node The node to be copied * @param target_doc The document to which the node is to be copied * @param parent The node in the target document which will become the parent of the copied node @@ -803,7 +804,7 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node, /** - * @brief Paste the contents of a document into the active desktop + * Paste the contents of a document into the active desktop. * @param clipdoc The document to paste * @param in_place Whether to paste the selection where it was when copied * @pre @c clipdoc is not empty and items can be added to the current layer @@ -882,9 +883,9 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo /** - * @brief Paste SVG defs from the document retrieved from the clipboard into the active document - * @param clipdoc The document to paste - * @pre @c clipdoc != NULL and pasting into the active document is possible + * Paste SVG defs from the document retrieved from the clipboard into the active document. + * @param clipdoc The document to paste. + * @pre @c clipdoc != NULL and pasting into the active document is possible. */ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) { @@ -904,7 +905,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) /** - * @brief Retrieve a bitmap image from the clipboard and paste it into the active document + * Retrieve a bitmap image from the clipboard and paste it into the active document. */ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc) { @@ -943,7 +944,7 @@ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc) } /** - * @brief Paste text into the selected text object or create a new one to hold it + * Paste text into the selected text object or create a new one to hold it. */ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) { @@ -968,7 +969,7 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) /** - * @brief Attempt to parse the passed string as a hexadecimal RGB or RGBA color + * Attempt to parse the passed string as a hexadecimal RGB or RGBA color. * @param text The Glib::ustring to parse * @return New CSS style representation if the parsing was successful, NULL otherwise */ @@ -1038,7 +1039,7 @@ SPCSSAttr *ClipboardManagerImpl::_parseColor(const Glib::ustring &text) /** - * @brief Applies a pasted path effect to a given item + * Applies a pasted path effect to a given item. */ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectstack) { @@ -1071,7 +1072,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta /** - * @brief Retrieve the clipboard contents as a document + * Retrieve the clipboard contents as a document. * @return Clipboard contents converted to SPDocument, or NULL if no suitable content was present */ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_target) @@ -1157,7 +1158,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ /** - * @brief Callback called when some other application requests data from Inkscape + * Callback called when some other application requests data from Inkscape. * * Finds a suitable output extension to save the internal clipboard document, * then saves it to memory and sets the clipboard contents. @@ -1232,7 +1233,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) /** - * @brief Callback when someone else takes the clipboard + * Callback when someone else takes the clipboard. * * When the clipboard owner changes, this callback clears the internal clipboard document * to reduce memory usage. @@ -1245,7 +1246,7 @@ void ClipboardManagerImpl::_onClear() /** - * @brief Creates an internal clipboard document from scratch + * Creates an internal clipboard document from scratch. */ void ClipboardManagerImpl::_createInternalClipboard() { @@ -1270,7 +1271,7 @@ void ClipboardManagerImpl::_createInternalClipboard() /** - * @brief Deletes the internal clipboard document + * Deletes the internal clipboard document. */ void ClipboardManagerImpl::_discardInternalClipboard() { @@ -1286,7 +1287,7 @@ void ClipboardManagerImpl::_discardInternalClipboard() /** - * @brief Get the scale to resize an item, based on the command and desktop state + * Get the scale to resize an item, based on the command and desktop state. */ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y) { @@ -1315,7 +1316,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons /** - * @brief Find the most suitable clipboard target + * Find the most suitable clipboard target. */ Glib::ustring ClipboardManagerImpl::_getBestTarget() { @@ -1374,7 +1375,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() /** - * @brief Set the clipboard targets to reflect the mimetypes Inkscape can output + * Set the clipboard targets to reflect the mimetypes Inkscape can output. */ void ClipboardManagerImpl::_setClipboardTargets() { @@ -1449,7 +1450,7 @@ void ClipboardManagerImpl::_setClipboardTargets() /** - * @brief Set the string representation of a 32-bit RGBA color as the clipboard contents + * Set the string representation of a 32-bit RGBA color as the clipboard contents. */ void ClipboardManagerImpl::_setClipboardColor(guint32 color) { @@ -1460,7 +1461,7 @@ void ClipboardManagerImpl::_setClipboardColor(guint32 color) /** - * @brief Put a notification on the mesage stack + * Put a notification on the mesage stack. */ void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg) { diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index d1bc255b0..c8538d1fb 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Inkscape About box - implementation +/** + * @file + * Inkscape About box - implementation. */ /* Authors: * Derek P. Moore <derekm@hackunix.org> diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 36d5a20d0..573674406 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Align and Distribute dialog - implementation +/** + * @file + * Align and Distribute dialog - implementation. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index fd7299ba2..e44b46308 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Dialog for naming calligraphic profiles +/** + * @file + * Dialog for naming calligraphic profiles. * * @note This file is in the wrong directory because of link order issues - * it is required by widgets/toolbox.cpp, and libspwidgets.a comes after diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index b61925855..f245cec37 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Inkscape color swatch UI item. +/** + * @file + * Inkscape color swatch UI item. */ /* Authors: * Jon A. Cruz diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index 1f7539fc7..7a2515789 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A dialog that displays log messages +/** + * @file + * A dialog that displays log messages. */ /* Authors: * Bob Jamison @@ -27,7 +28,7 @@ namespace UI { namespace Dialog { /** - * @brief A very simple dialog for displaying Inkscape messages - implementation + * A very simple dialog for displaying Inkscape messages - implementation. */ class DebugDialogImpl : public DebugDialog, public Gtk::Dialog { diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 0c49690cc..cba0cf508 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Object for managing a set of dialogs, including their signals and +/** + * @file + * Object for managing a set of dialogs, including their signals and * construction/caching/destruction of them. */ /* Authors: diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 88724a90c..3d3ea867e 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Base class for dialogs in Inkscape - implementation +/** + * @file + * Base class for dialogs in Inkscape - implementation. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 25fa1739a..cf4d36cff 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A dockable dialog implementation. +/** + * @file + * A dockable dialog implementation. */ /* Author: * Gustav Broberg <broberg@kth.se> diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 08479275b..0dae7bd88 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Document metadata dialog, Gtkmm-style +/** + * @file + * Document metadata dialog, Gtkmm-style. */ /* Authors: * bulia byak <buliabyak@users.sf.net> @@ -108,9 +109,8 @@ DocumentMetadata::~DocumentMetadata() * possible cases: (0,0) means insert space in first column; (0, non-0) means * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. -**/ -inline void -attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0) + */ +inline void attach_all(Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0) { for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) { @@ -190,8 +190,7 @@ DocumentMetadata::build_metadata() /** * Update dialog widgets from desktop. */ -void -DocumentMetadata::update() +void DocumentMetadata::update() { if (_wr.isUpdating()) return; @@ -236,8 +235,7 @@ DocumentMetadata::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *d /** * Called when XML node attribute changed; updates dialog widgets. */ -static void -on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) +static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) { if (DocumentMetadata *dialog = static_cast<DocumentMetadata *>(data)) dialog->update(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 69d634e59..d3123345b 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Document properties dialog, Gtkmm-style +/** + * @file + * Document properties dialog, Gtkmm-style. */ /* Authors: * bulia byak <buliabyak@users.sf.net> @@ -165,9 +166,8 @@ DocumentProperties::~DocumentProperties() * possible cases: (0,0) means insert space in first column; (0, non-0) means * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. -**/ -inline void -attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0) + */ +inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0) { for (unsigned i = 0, r = start; i < n; i += 2) { @@ -904,8 +904,7 @@ void DocumentProperties::populate_script_lists(){ /** * Called for _updating_ the dialog (e.g. when a new grid was manually added in XML) */ -void -DocumentProperties::update_gridspage() +void DocumentProperties::update_gridspage() { SPDesktop *dt = getDesktop(); SPNamedView *nv = sp_desktop_namedview(dt); @@ -946,8 +945,7 @@ DocumentProperties::update_gridspage() /** * Build grid page of dialog. */ -void -DocumentProperties::build_gridspage() +void DocumentProperties::build_gridspage() { /// \todo FIXME: gray out snapping when grid is off. /// Dissenting view: you want snapping without grid. @@ -984,8 +982,7 @@ DocumentProperties::build_gridspage() /** * Update dialog widgets from desktop. Also call updateWidget routines of the grids. */ -void -DocumentProperties::update() +void DocumentProperties::update() { if (_wr.isUpdating()) return; @@ -1118,8 +1115,7 @@ on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, /** * Called when XML node attribute changed; updates dialog widgets. */ -static void -on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) +static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) { if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data)) dialog->update(); diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index 527dfe23c..282f43a25 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Extension editor dialog +/** + * @file + * Extension editor dialog. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> @@ -33,15 +34,15 @@ namespace Inkscape { namespace UI { namespace Dialog { -/** \brief Create a new ExtensionEditor dialog - \return None - - This function creates a new extension editor dialog. The dialog - consists of two basic areas. The left side is a tree widget, which - is only used as a list. And the right side is a notebook of information - about the selected extension. A handler is set up so that when - a new extension is selected, the notebooks are changed appropriately. -*/ +/** + * Create a new ExtensionEditor dialog. + * + * This function creates a new extension editor dialog. The dialog + * consists of two basic areas. The left side is a tree widget, which + * is only used as a list. And the right side is a notebook of information + * about the selected extension. A handler is set up so that when + * a new extension is selected, the notebooks are changed appropriately. + */ ExtensionEditor::ExtensionEditor() : UI::Widget::Panel ("", "/dialogs/extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR) { @@ -92,9 +93,9 @@ ExtensionEditor::ExtensionEditor() show_all_children(); } -/** \brief Destroys the extension editor dialog - \return None -*/ +/** + * Destroys the extension editor dialog. + */ ExtensionEditor::~ExtensionEditor() { } @@ -117,15 +118,14 @@ ExtensionEditor::setExtensionIter(const Gtk::TreeModel::iterator &iter) return false; } -/** \brief Called every time a new extention is selected - \return None - - This function is set up to handle the signal for a changed extension - from the tree view in the left pane. It figure out which extension - is selected and updates the widgets to have data for that extension. -*/ -void -ExtensionEditor::on_pagelist_selection_changed (void) +/** + * Called every time a new extention is selected + * + * This function is set up to handle the signal for a changed extension + * from the tree view in the left pane. It figure out which extension + * is selected and updates the widgets to have data for that extension. + */ +void ExtensionEditor::on_pagelist_selection_changed(void) { Glib::RefPtr<Gtk::TreeSelection> selection = _page_list.get_selection(); Gtk::TreeModel::iterator iter = selection->get_selected(); @@ -179,34 +179,35 @@ ExtensionEditor::on_pagelist_selection_changed (void) return; } -/** \brief A function to pass to the iterator in the Extensions Database - \param in_plug The extension to evaluate - \param in_data A pointer to the Extension Editor class - \return None - - This function is a static function with the prototype required for - the Extension Database's foreach function. It will get called for - every extension in the database, and will then turn around and - call the more object oriented function \c add_extension in the - ExtensionEditor. -*/ -void -ExtensionEditor::dbfunc (Inkscape::Extension::Extension * in_plug, gpointer in_data) +/** + * A function to pass to the iterator in the Extensions Database. + * + * This function is a static function with the prototype required for + * the Extension Database's foreach function. It will get called for + * every extension in the database, and will then turn around and + * call the more object oriented function \c add_extension in the + * ExtensionEditor. + * + * @param in_plug The extension to evaluate. + * @param in_data A pointer to the Extension Editor class. + */ +void ExtensionEditor::dbfunc(Inkscape::Extension::Extension * in_plug, gpointer in_data) { ExtensionEditor * ee = static_cast<ExtensionEditor *>(in_data); ee->add_extension(in_plug); return; } -/** \brief Adds an extension into the tree model - \param ext The extension to add - \return The iterator representing the location in the tree model - - This function takes the data out of the extension and puts it - into the tree model for the dialog. -*/ -Gtk::TreeModel::iterator -ExtensionEditor::add_extension (Inkscape::Extension::Extension * ext) +/** + * Adds an extension into the tree model. + * + * This function takes the data out of the extension and puts it + * into the tree model for the dialog. + * + * @param ext The extension to add. + * @return The iterator representing the location in the tree model. + */ +Gtk::TreeModel::iterator ExtensionEditor::add_extension(Inkscape::Extension::Extension * ext) { Gtk::TreeModel::iterator iter; diff --git a/src/ui/dialog/extensions.cpp b/src/ui/dialog/extensions.cpp index 27cd15e8c..242b79368 100644 --- a/src/ui/dialog/extensions.cpp +++ b/src/ui/dialog/extensions.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A simple dialog with information about extensions +/** + * @file + * A simple dialog with information about extensions. */ /* Authors: * Jon A. Cruz diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 8db390cd2..c31f7cf15 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Implementation of the file dialog interfaces defined in filedialog.h +/** + * @file + * Implementation of the file dialog interfaces defined in filedialog.h. */ /* Authors: * Bob Jamison diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 99662f0c2..921d89c2e 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Implementation of the file dialog interfaces defined in filedialogimpl.h +/** + * @file + * Implementation of the file dialog interfaces defined in filedialogimpl.h. */ /* Authors: * Bob Jamison diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 777f37e8f..2d23ed943 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Implementation of native file dialogs for Win32 +/** + * @file + * Implementation of native file dialogs for Win32. */ /* Authors: * Joel Holdsworth diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 5d85b2397..91b88d3f0 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Fill and Stroke dialog - implementation +/** + * @file + * Fill and Stroke dialog - implementation. * * Based on the old sp_object_properties_dialog. */ diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 30803715e..22d3c7369 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Filter Effects dialog +/** + * @file + * Filter Effects dialog. */ /* Authors: * Nicholas Bishop <nicholasbishop@gmail.org> diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index aa6b4081e..78bb8c66a 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -1,5 +1,5 @@ /** - * \brief Find dialog + * Find dialog. * * Authors: * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 6a086e0a1..5215ec167 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Floating dialog implementation. +/** + * @file + * Floating dialog implementation. */ /* Author: * Gustav Broberg <broberg@kth.se> @@ -54,15 +55,16 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : } #if GTK_VERSION_GE(2, 12) -/** \brief A function called when the window gets focus - - This function gets called on a focus event. It figures out how much - time is required for a transition, and the number of steps that'll take, - and sets up the _trans_timer function to do the work. If the transition - time is set to 0 ms it just calls _trans_timer once with _steps equal to - zero so that the transition happens instantaneously. This occurs on - windows as opacity changes cause flicker there. -*/ +/** + * A function called when the window gets focus. + * + * This function gets called on a focus event. It figures out how much + * time is required for a transition, and the number of steps that'll take, + * and sets up the _trans_timer function to do the work. If the transition + * time is set to 0 ms it just calls _trans_timer once with _steps equal to + * zero so that the transition happens instantaneously. This occurs on + * windows as opacity changes cause flicker there. + */ void FloatingBehavior::_focus_event (void) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -89,13 +91,14 @@ void FloatingBehavior::_focus_event (void) return; } -/** \brief Move the opacity of a window towards our goal - - This is a timer function that is set up by _focus_event to slightly - move the opacity of the window along in an animated fashion. It moves - the opacity half way to the goal until it runs out of steps, and then - it just forces the goal. -*/ +/** + * Move the opacity of a window towards our goal. + * + * This is a timer function that is set up by _focus_event to slightly + * move the opacity of the window along in an animated fashion. It moves + * the opacity half way to the goal until it runs out of steps, and then + * it just forces the goal. + */ bool FloatingBehavior::_trans_timer (void) { // printf("Go go gadget timer: %d\n", _steps); if (_steps == 0) { diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 542fed5bb..e353178ed 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Simple guideline dialog +/** + * @file + * Simple guideline dialog. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 9865c0cdb..0157cd267 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A simple dialog for previewing icon representation. +/** + * @file + * A simple dialog for previewing icon representation. */ /* Authors: * Jon A. Cruz diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index ae27f0720..448126091 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Inkscape Preferences dialog - implementation +/** + * @file + * Inkscape Preferences dialog - implementation. */ /* Authors: * Carl Hetherington diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 6869aa97b..e80f581c1 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Input devices dialog (new) - implementation +/** + * @file + * Input devices dialog (new) - implementation. */ /* Author: * Jon A. Cruz diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index bf15bcd76..eeef12b88 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Dialog for renaming layers +/** + * @file + * Dialog for renaming layers. */ /* Author: * Bryce W. Harrington <bryce@bryceharrington.com> diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 40b7f26ac..2227a8c5a 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Live Path Effect editing dialog - implementation +/** + * @file + * Live Path Effect editing dialog - implementation. */ /* Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp index 7f5c5cefa..8229929e5 100644 --- a/src/ui/dialog/memory.cpp +++ b/src/ui/dialog/memory.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Memory statistics dialog +/** + * @file + * Memory statistics dialog. */ /* Authors: * MenTaLguY <mental@rydia.net> diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp index 654117704..022e6ac2c 100644 --- a/src/ui/dialog/messages.cpp +++ b/src/ui/dialog/messages.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Messages dialog - implementation +/** + * @file + * Messages dialog - implementation. */ /* Authors: * Bob Jamison diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 2ae7d6989..3f9414866 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Open Clip Art Library integration dialogs - implementation +/** + * @file + * Open Clip Art Library integration dialogs - implementation. */ /* Authors: * Bruno Dilly diff --git a/src/ui/dialog/print-colors-preview-dialog.cpp b/src/ui/dialog/print-colors-preview-dialog.cpp index 1f999f692..ef5c1b6f6 100644 --- a/src/ui/dialog/print-colors-preview-dialog.cpp +++ b/src/ui/dialog/print-colors-preview-dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Print Colors Preview dialog - implementation +/** + * @file + * Print Colors Preview dialog - implementation. */ /* Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index a56cbfd9d..8da31b813 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Print dialog +/** + * @file + * Print dialog. */ /* Authors: * Kees Cook <kees@outflux.net> diff --git a/src/ui/dialog/scriptdialog.cpp b/src/ui/dialog/scriptdialog.cpp index c7f828067..ef65dce97 100644 --- a/src/ui/dialog/scriptdialog.cpp +++ b/src/ui/dialog/scriptdialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Dialog for executing and monitoring script execution +/** + * @file + * Dialog for executing and monitoring script execution. */ /* Author: * Bob Jamison diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index fbca0bf10..2c116f137 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief SVG Fonts dialog - implementation +/** + * @file + * SVG Fonts dialog - implementation. */ /* Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 910d63873..2edd24eec 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -1,6 +1,6 @@ - -/** @file - * @brief Color swatches dialog +/** + * @file + * Color swatches dialog. */ /* Authors: * Jon A. Cruz diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index 3f2cc451b..597c9a217 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Bitmap tracing settings dialog - implementation +/** + * @file + * Bitmap tracing settings dialog - implementation. */ /* Authors: * Bob Jamison <rjamison@titan.com> diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index be60fac20..570120bcd 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -1,5 +1,6 @@ -/** @file - * \brief Transform dialog - implementation +/** + * @file + * Transform dialog - implementation. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index 4c3446a51..74de33b27 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Undo History dialog - implementation +/** + * @file + * Undo History dialog - implementation. */ /* Author: * Gustav Broberg <broberg@kth.se> diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index fbcb337a5..1a1aee47c 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -1,5 +1,6 @@ -/** @file - * Node selection - implementation +/** + * @file + * Node selection - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> @@ -23,7 +24,7 @@ namespace UI { /** * @class ControlPointSelection - * @brief Group of selected control points. + * Group of selected control points. * * Some operations can be performed on all selected points regardless of their type, therefore * this class is also a Manipulator. It handles the transformations of points using @@ -446,8 +447,10 @@ bool ControlPointSelection::_keyboardMove(GdkEventKey const &event, Geom::Point return true; } -/** @brief Computes the distance to the farthest corner of the bounding box. - * Used to determine what it means to "rotate by one pixel". */ +/** + * Computes the distance to the farthest corner of the bounding box. + * Used to determine what it means to "rotate by one pixel". + */ double ControlPointSelection::_rotationRadius(Geom::Point const &rc) { if (empty()) return 1.0; // some safe value @@ -460,7 +463,8 @@ double ControlPointSelection::_rotationRadius(Geom::Point const &rc) return maxlen; } -/** Rotates the selected points in the given direction according to the modifier state +/** + * Rotates the selected points in the given direction according to the modifier state * from the supplied event. * @param event Key event to take modifier state from * @param dir Direction of rotation (math convention: 1 = counterclockwise, -1 = clockwise) diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index bece1324b..81cb53f6f 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -1,5 +1,6 @@ -/** @file - * Desktop-bound visual control object - implementation +/** + * @file + * Desktop-bound visual control object - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> @@ -29,7 +30,7 @@ namespace UI { /** * @class ControlPoint - * @brief Draggable point, the workhorse of on-canvas editing. + * Draggable point, the workhorse of on-canvas editing. * * Control points (formerly known as knots) are graphical representations of some significant * point in the drawing. The drawing can be changed by dragging the point and the things that are @@ -537,7 +538,7 @@ void ControlPoint::transferGrab(ControlPoint *prev_point, GdkEventMotion *event) } /** - * @brief Change the state of the knot + * Change the state of the knot. * Alters the appearance of the knot to match one of the states: normal, mouseover * or clicked. */ diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 082ac194b..27418d302 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -1,5 +1,6 @@ -/** @file - * Multi path manipulator - implementation +/** + * @file + * Multi path manipulator - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> @@ -149,9 +150,11 @@ void MultiPathManipulator::cleanup() } } -/** @brief Change the set of items to edit. +/** + * Change the set of items to edit. * - * This method attempts to preserve as much of the state as possible. */ + * This method attempts to preserve as much of the state as possible. + */ void MultiPathManipulator::setItems(std::set<ShapeRecord> const &s) { std::set<ShapeRecord> shapes(s); @@ -507,20 +510,24 @@ void MultiPathManipulator::showPathDirection(bool show) _show_path_direction = show; } -/** @brief Set live outline update status +/** + * Set live outline update status. * When set to true, outline will be updated continuously when dragging * or transforming nodes. Otherwise it will only update when changes are committed - * to XML. */ + * to XML. + */ void MultiPathManipulator::setLiveOutline(bool set) { invokeForAll(&PathManipulator::setLiveOutline, set); _live_outline = set; } -/** @brief Set live object update status +/** + * Set live object update status. * When set to true, objects will be updated continuously when dragging * or transforming nodes. Otherwise they will only update when changes are committed - * to XML. */ + * to XML. + */ void MultiPathManipulator::setLiveObjects(bool set) { invokeForAll(&PathManipulator::setLiveObjects, set); diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 6385fce0a..33020982e 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief New node tool - implementation +/** + * @file + * New node tool - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk@gmail.com> diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index e254fb9b2..d268a9f14 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1,5 +1,6 @@ -/** @file - * Editable node - implementation +/** + * @file + * Editable node - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> @@ -70,13 +71,11 @@ static Geom::Point direction(Geom::Point const &first, Geom::Point const &second } /** - * @class Handle - * @brief Control point of a cubic Bezier curve in a path. + * Control point of a cubic Bezier curve in a path. * * Handle keeps the node type invariant only for the opposite handle of the same node. * Keeping the invariant on node moves is left to the %Node class. */ - Geom::Point Handle::_saved_other_pos(0, 0); double Handle::_saved_length = 0.0; bool Handle::_drag_out = false; @@ -467,12 +466,10 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) } /** - * @class Node - * @brief Curve endpoint in an editable path. + * Curve endpoint in an editable path. * * The method move() keeps node type invariants during translations. */ - Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : SelectableControlPoint(data.desktop, initial_pos, Gtk::ANCHOR_CENTER, SP_CTRL_SHAPE_DIAMOND, 9.0, *data.selection, &node_colors, data.node_group) @@ -1121,8 +1118,10 @@ Inkscape::SnapCandidatePoint Node::snapCandidatePoint() return SnapCandidatePoint(position(), _snapSourceType(), _snapTargetType()); } -/** @brief Gets the handle that faces the given adjacent node. - * Will abort with error if the given node is not adjacent. */ +/** + * Gets the handle that faces the given adjacent node. + * Will abort with error if the given node is not adjacent. + */ Handle *Node::handleToward(Node *to) { if (_next() == to) { @@ -1134,8 +1133,10 @@ Handle *Node::handleToward(Node *to) g_error("Node::handleToward(): second node is not adjacent!"); } -/** @brief Gets the node in the direction of the given handle. - * Will abort with error if the handle doesn't belong to this node. */ +/** + * Gets the node in the direction of the given handle. + * Will abort with error if the handle doesn't belong to this node. + */ Node *Node::nodeToward(Handle *dir) { if (front() == dir) { @@ -1147,8 +1148,10 @@ Node *Node::nodeToward(Handle *dir) g_error("Node::nodeToward(): handle is not a child of this node!"); } -/** @brief Gets the handle that goes in the direction opposite to the given adjacent node. - * Will abort with error if the given node is not adjacent. */ +/** + * Gets the handle that goes in the direction opposite to the given adjacent node. + * Will abort with error if the given node is not adjacent. + */ Handle *Node::handleAwayFrom(Node *to) { if (_next() == to) { @@ -1160,8 +1163,10 @@ Handle *Node::handleAwayFrom(Node *to) g_error("Node::handleAwayFrom(): second node is not adjacent!"); } -/** @brief Gets the node in the direction opposite to the given handle. - * Will abort with error if the handle doesn't belong to this node. */ +/** + * Gets the node in the direction opposite to the given handle. + * Will abort with error if the handle doesn't belong to this node. + */ Node *Node::nodeAwayFrom(Handle *h) { if (front() == h) { @@ -1262,14 +1267,12 @@ SPCtrlShapeType Node::_node_type_to_shape(NodeType type) /** - * @class NodeList - * @brief An editable list of nodes representing a subpath. + * An editable list of nodes representing a subpath. * * It can optionally be cyclic to represent a closed path. * The list has iterators that act like plain node iterators, but can also be used * to obtain shared pointers to nodes. */ - NodeList::NodeList(SubpathList &splist) : _list(splist) , _closed(false) @@ -1430,7 +1433,7 @@ NodeList &NodeList::get(iterator const &i) { /** * @class SubpathList - * @brief Editable path composed of one or more subpaths + * Editable path composed of one or more subpaths. */ } // namespace UI diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1310219a1..4be8df397 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1,5 +1,6 @@ -/** @file - * Path manipulator - implementation +/** + * @file + * Path manipulator - implementation. */ /* Authors: * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> @@ -534,13 +535,15 @@ void PathManipulator::deleteNodes(bool keep_shape) } } -/** @brief Delete nodes between the two iterators. +/** + * Delete nodes between the two iterators. * The given range can cross the beginning of the subpath in closed subpaths. * @param start Beginning of the range to delete * @param end End of the range * @param keep_shape Whether to fit the handles at surrounding nodes to approximate * the shape before deletion - * @return Number of deleted nodes */ + * @return Number of deleted nodes + */ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::iterator end, bool keep_shape) { unsigned const samples_per_segment = 10; diff --git a/src/ui/widget/button.cpp b/src/ui/widget/button.cpp index 19c69ba44..fe4aa90ce 100644 --- a/src/ui/widget/button.cpp +++ b/src/ui/widget/button.cpp @@ -1,5 +1,5 @@ /** - * \brief Button and CheckButton widgets + * Button and CheckButton widgets. * * Author: * buliabyak@gmail.com diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index 650ed10f6..bd7a666d2 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -1,5 +1,6 @@ -/** \file - * \brief Color picker button & window +/** + * @file + * Color picker button & window. * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 87f4d0840..9c6758bc0 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -1,5 +1,5 @@ /** - * \brief A custom Inkscape wrapper around gdl_dock_item + * A custom Inkscape wrapper around gdl_dock_item. * * Author: * Gustav Broberg <broberg@kth.se> diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 02e1f2b41..627b01e27 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A desktop dock pane to dock dialogs. +/** + * @file + * A desktop dock pane to dock dialogs. */ /* Author: * Gustav Broberg <broberg@kth.se> diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp index 7b19ac861..ce7552fd6 100644 --- a/src/ui/widget/entry.cpp +++ b/src/ui/widget/entry.cpp @@ -1,6 +1,7 @@ -/** \file +/** + * @file * - * \brief Helperclass for Gtk::Entry widgets + * Helperclass for Gtk::Entry widgets. * * Authors: * Johan Engelen <goejendaagh@zonnet.nl> diff --git a/src/ui/widget/handlebox.cpp b/src/ui/widget/handlebox.cpp index b82b715bb..f5b716975 100644 --- a/src/ui/widget/handlebox.cpp +++ b/src/ui/widget/handlebox.cpp @@ -1,5 +1,5 @@ /** - * \brief HandleBox Widget - Adds a detachment handle to another widget. + * HandleBox Widget - Adds a detachment handle to another widget. * * This work really doesn't amount to much more than a convenience constructor * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as diff --git a/src/ui/widget/icon-widget.cpp b/src/ui/widget/icon-widget.cpp index 64415f421..c3780b616 100644 --- a/src/ui/widget/icon-widget.cpp +++ b/src/ui/widget/icon-widget.cpp @@ -1,5 +1,5 @@ /** - * \brief Icon Widget + * Icon Widget. * * Author: * Bryce Harrington <bryce@bryceharrington.org> diff --git a/src/ui/widget/labelled.cpp b/src/ui/widget/labelled.cpp index c55b57616..a62d1a470 100644 --- a/src/ui/widget/labelled.cpp +++ b/src/ui/widget/labelled.cpp @@ -1,5 +1,5 @@ /** - * \brief Labelled Widget - Adds a label with optional icon or suffix to + * Labelled Widget - Adds a label with optional icon or suffix to * another widget. * * Authors: diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp index 47035ce2f..eea8aefba 100644 --- a/src/ui/widget/notebook-page.cpp +++ b/src/ui/widget/notebook-page.cpp @@ -1,5 +1,5 @@ /** - * \brief Notebook page widget + * Notebook page widget. * * Author: * Bryce Harrington <bryce@bryceharrington.org> diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 3e0c27587..aaa8e2a70 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -1,5 +1,5 @@ /** - * \brief Panel widget + * Panel widget. * * Authors: * Bryce Harrington <bryce@bryceharrington.org> diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index ca7f7a501..7a4b4459a 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -1,5 +1,5 @@ /** - * \brief Point Widget - A labelled text box, with spin buttons and optional + * Point Widget - A labelled text box, with spin buttons and optional * icon or suffix, for entering arbitrary coordinate values. * * Authors: diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 68faa3c66..b88123ab1 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -1,5 +1,5 @@ /** - * \brief Inkscape Preferences dialog + * Inkscape Preferences dialog. * * Authors: * Marco Scholten diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 3dcf09cb5..e2fb30812 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -1,5 +1,5 @@ /** - * \brief Scalar Widget - A labelled text box, with spin buttons and optional + * Scalar Widget - A labelled text box, with spin buttons and optional * icon or suffix, for entering arbitrary number values. It adds an extra * number called "startseed", that is not UI edittable, but should be put in SVG. * This does NOT generate a random number, but provides merely the saving of diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp index 48e257af7..1ceaa784e 100644 --- a/src/ui/widget/rendering-options.cpp +++ b/src/ui/widget/rendering-options.cpp @@ -1,5 +1,5 @@ /** - * \brief Rendering options widget + * Rendering options widget. * * Author: * Kees Cook <kees@outflux.net> diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 23d5363ef..6a65d6ab3 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -1,5 +1,5 @@ /** - * \brief widget adjustable by dragging it to rotate away from a zero-change axis + * widget adjustable by dragging it to rotate away from a zero-change axis. * * Authors: * buliabyak@gmail.com diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 1c0fdff68..47e9b23b2 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -1,5 +1,5 @@ /** - * \brief Scalar Unit Widget - A labelled text box, with spin buttons and + * Scalar Unit Widget - A labelled text box, with spin buttons and * optional icon or suffix, for entering the values of various unit * types. * diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 6ada379fb..4237d9db9 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -1,5 +1,5 @@ /** - * \brief Scalar Widget - A labelled text box, with spin buttons and optional + * Scalar Widget - A labelled text box, with spin buttons and optional * icon or suffix, for entering arbitrary number values. * * Authors: diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 0aa65b1a9..516da5761 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1,5 +1,5 @@ /** - * \brief Selected style indicator (fill, stroke, opacity) + * Selected style indicator (fill, stroke, opacity). * * Author: * buliabyak@gmail.com diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 259b057aa..4a3b0dd77 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -1,5 +1,5 @@ /** - * \brief Groups an HScale and a SpinButton together using the same Adjustment + * Groups an HScale and a SpinButton together using the same Adjustment. * * Author: * Nicholas Bishop <nicholasbishop@gmail.com> diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 32090f96c..78b00bebc 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -1,5 +1,5 @@ /** - * \brief SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. + * SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. */ /* * Author: diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index f3a8478ea..4a1b83175 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -1,5 +1,5 @@ /** - * \brief Abstraction for different style widget operands + * Abstraction for different style widget operands. * * Copyright (C) 2007 MenTaLguY <mental@rydia.net> * Abhishek Sharma diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 47f6292e3..41366f749 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Static style swatch (fill, stroke, opacity) +/** + * @file + * Static style swatch (fill, stroke, opacity). */ /* Authors: * buliabyak@gmail.com @@ -43,7 +44,7 @@ namespace UI { namespace Widget { /** - * @brief Watches whether the tool uses the current style + * Watches whether the tool uses the current style. */ class StyleSwatch::ToolObserver : public Inkscape::Preferences::Observer { public: @@ -57,7 +58,7 @@ private: }; /** - * @brief Watches for changes in the observed style pref + * Watches for changes in the observed style pref. */ class StyleSwatch::StyleObserver : public Inkscape::Preferences::Observer { public: diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp index 581491f0e..a5540e428 100644 --- a/src/ui/widget/text.cpp +++ b/src/ui/widget/text.cpp @@ -1,5 +1,5 @@ /** - * \brief Text Widget - A labelled text box, with spin buttons and optional + * Text Widget - A labelled text box, with spin buttons and optional * icon or suffix, for entering arbitrary number values. * * Authors: diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp index 5e5f43263..41a13f4e9 100644 --- a/src/ui/widget/toolbox.cpp +++ b/src/ui/widget/toolbox.cpp @@ -1,5 +1,5 @@ /** - * \brief Toolbox Widget - A detachable toolbar for buttons and other widgets. + * Toolbox Widget - A detachable toolbar for buttons and other widgets. * * Author: * Derek P. Moore <derekm@hackunix.org> diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 362f5d90f..bb0b65576 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -1,5 +1,5 @@ /** - * \brief Unit Menu Widget - A drop down menu for choosing unit types. + * Unit Menu Widget - A drop down menu for choosing unit types. * * Author: * Bryce Harrington <bryce@bryceharrington.org> diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp index 3339c64d3..6b22bd396 100644 --- a/src/widgets/dash-selector.cpp +++ b/src/widgets/dash-selector.cpp @@ -1,7 +1,6 @@ -#define __SP_DASH_SELECTOR_NEW_C__ - -/** @file - * @brief Option menu for selecting dash patterns - implementation +/** + * @file + * Option menu for selecting dash patterns - implementation. */ /* Author: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 1ca656ae1..5de246f6b 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief EEK preview stuff +/** + * @file + * EEK preview stuff. */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp index 9eb54b039..36777d16a 100644 --- a/src/widgets/ege-paint-def.cpp +++ b/src/widgets/ege-paint-def.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief EGE paint definition +/** + * @file + * EGE paint definition. */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index c6e97666a..6f076b4c4 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Fill style widget +/** + * @file + * Fill style widget. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 259aa5f25..fc9dc9263 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -1,4 +1,5 @@ -/** \file +/** + * @file * SPPaintSelector: Generic paint selector widget. */ @@ -831,13 +832,10 @@ sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source* } /** - * sp_pattern_list_from_doc() - * - * \brief Pick up all patterns from source, except those that are in - * current_doc (if non-NULL), and add items to the pattern menu - * + * Pick up all patterns from source, except those that are in + * current_doc (if non-NULL), and add items to the pattern menu. */ -static void sp_pattern_list_from_doc (GtkWidget *m, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*pattern_doc*/) +static void sp_pattern_list_from_doc(GtkWidget *m, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*pattern_doc*/) { GSList *pl = ink_pattern_list_get(source); GSList *clean_pl = NULL; diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index f7cd308b2..9cdf9fab3 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Widget that listens and modifies repr attributes +/** + * @file + * Widget that listens and modifies repr attributes. */ /* Authors: * Lauris Kaplinski <lauris@ximian.com> diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 2225f2c57..ece329576 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -1,5 +1,3 @@ -#define __SPW_UTILITIES_C__ - /* * Inkscape Widget Utilities * @@ -227,10 +225,9 @@ sp_set_font_size_smaller (GtkWidget *w) } /** -\brief Finds the descendant of w which has the data with the given key and returns the data, or NULL if there's none -*/ -gpointer -sp_search_by_data_recursive (GtkWidget *w, gpointer key) + * Finds the descendant of w which has the data with the given key and returns the data, or NULL if there's none. + */ +gpointer sp_search_by_data_recursive(GtkWidget *w, gpointer key) { gpointer r = NULL; @@ -251,10 +248,9 @@ sp_search_by_data_recursive (GtkWidget *w, gpointer key) } /** -\brief Returns the descendant of w which has the given key and value pair, or NULL if there's none -*/ -GtkWidget * -sp_search_by_value_recursive (GtkWidget *w, gchar *key, gchar *value) + * Returns the descendant of w which has the given key and value pair, or NULL if there's none. + */ +GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) { gchar *r = NULL; GtkWidget *child; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index bb9391c78..b4a5b5694 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Stroke style dialog +/** + * @file + * Stroke style dialog. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -291,14 +292,10 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD } /** - * sp_marker_list_from_doc() - * - * \brief Pick up all markers from source, except those that are in - * current_doc (if non-NULL), and add items to the m menu - * + * Pick up all markers from source, except those that are in + * current_doc (if non-NULL), and add items to the m menu. */ -static void -sp_marker_list_from_doc (Gtk::Menu *m, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*markers_doc*/, SPDocument *sandbox, gchar const *menu_id) +static void sp_marker_list_from_doc(Gtk::Menu *m, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*markers_doc*/, SPDocument *sandbox, gchar const *menu_id) { GSList *ml = ink_marker_list_get(source); GSList *clean_ml = NULL; @@ -644,11 +641,9 @@ static gboolean stroke_width_set_unit(SPUnitSelector *, /** - * \brief Creates a new widget for the line stroke style. - * + * Creates a new widget for the line stroke style. */ -Gtk::Container * -sp_stroke_style_line_widget_new(void) +Gtk::Container *sp_stroke_style_line_widget_new(void) { Gtk::Widget *us; SPDashSelector *ds; @@ -1267,14 +1262,13 @@ sp_stroke_style_line_dash_changed(Gtk::Container *spw) } /** - * \brief This routine handles toggle events for buttons in the stroke style - * dialog. + * This routine handles toggle events for buttons in the stroke style dialog. + * * When activated, this routine gets the data for the various widgets, and then * calls the respective routines to update css properties, etc. * */ -static void -sp_stroke_style_any_toggled(Gtk::ToggleButton *tb, Gtk::Container *spw) +static void sp_stroke_style_any_toggled(Gtk::ToggleButton *tb, Gtk::Container *spw) { if (spw->get_data("update")) { return; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 0b37aa610..6ec393c2c 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1,6 +1,7 @@ -/** @file - * @brief Controls bars for some of Inkscape's tools (for some tools, - * they are in their own files) +/** + * @file + * Controls bars for some of Inkscape's tools (for some tools, + * they are in their own files). */ /* Authors: * MenTaLguY <mental@rydia.net> @@ -4133,7 +4134,7 @@ static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge) } /** - * \brief Generate the list of freehand advanced shape option entries. + * Generate the list of freehand advanced shape option entries. */ static GList * freehand_shape_dropdown_items_list() { GList *glist = NULL; diff --git a/src/xml/croco-node-iface.cpp b/src/xml/croco-node-iface.cpp index afea4abba..72bcba7f3 100644 --- a/src/xml/croco-node-iface.cpp +++ b/src/xml/croco-node-iface.cpp @@ -1,4 +1,3 @@ - #include <cstring> #include <string> #include <glib/gstrfuncs.h> @@ -46,7 +45,7 @@ static gboolean is_element_node(CRXMLNodePtr n) { return static_cast<Node const } /** - * @brief Interface for XML nodes used by libcroco + * Interface for XML nodes used by libcroco. * * This structure defines operations on Inkscape::XML::Node used by the libcroco * CSS parsing library. diff --git a/src/xml/log-builder.cpp b/src/xml/log-builder.cpp index 951cd4029..2cbdcfacf 100644 --- a/src/xml/log-builder.cpp +++ b/src/xml/log-builder.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Object building an event log +/** + * @file + * Object building an event log. */ /* Copyright 2005 MenTaLguY <mental@rydia.net> * diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index db1d5591e..aa244d842 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -1,4 +1,5 @@ -/** \file +/** + * @file * Miscellaneous helpers for reprs. */ @@ -404,7 +405,7 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No } /** - * @brief Find an element node using an unique attribute + * Find an element node using an unique attribute. * * This function returns the first child of the specified node that has the attribute * @c key equal to @c value. Note that this function does not recurse. @@ -414,10 +415,9 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No * @param value The value of the attribute to look for * @relatesalso Inkscape::XML::Node */ -Inkscape::XML::Node * -sp_repr_lookup_child(Inkscape::XML::Node *repr, - gchar const *key, - gchar const *value) +Inkscape::XML::Node *sp_repr_lookup_child(Inkscape::XML::Node *repr, + gchar const *key, + gchar const *value) { g_return_val_if_fail(repr != NULL, NULL); for ( Inkscape::XML::Node *child = repr->firstChild() ; child ; child = child->next() ) { diff --git a/src/xml/simple-document.cpp b/src/xml/simple-document.cpp index 0287c4458..bae28e4b4 100644 --- a/src/xml/simple-document.cpp +++ b/src/xml/simple-document.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Garbage collected XML document implementation +/** + * @file + * Garbage collected XML document implementation. */ /* Copyright 2004-2005 MenTaLguY <mental@rydia.net> * diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index b7c0c34ed..792706a18 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Garbage collected XML node implementation +/** + * @file + * Garbage collected XML node implementation. */ /* Copyright 2003-2005 MenTaLguY <mental@rydia.net> * Copyright 2003 Nathan Hurst -- cgit v1.2.3 From a68c62086eda2d4bd769318dc04633dd1aa5d34a Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Mon, 3 Oct 2011 20:55:43 -0700 Subject: Fixed mismatched quotes that confused Doxygen. (bzr r10663) --- src/libcroco/cr-selector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcroco/cr-selector.h b/src/libcroco/cr-selector.h index 6bf769733..a22e81fdb 100644 --- a/src/libcroco/cr-selector.h +++ b/src/libcroco/cr-selector.h @@ -41,7 +41,7 @@ typedef struct _CRSelector CRSelector ; /** *Abstracts a CSS2 selector as defined in the right part - *of the 'ruleset" production in the appendix D.1 of the + *of the 'ruleset' production in the appendix D.1 of the *css2 spec. *It is actually the abstraction of a comma separated list *of simple selectors list. -- cgit v1.2.3 From 23ea206a1348414f67fee482f63a69b1d90b0df6 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Mon, 3 Oct 2011 22:43:09 -0700 Subject: Purging some forward.h files. (bzr r10664) --- src/document.h | 1 + src/helper/action.h | 4 ++- src/helper/helper-forward.h | 35 -------------------------- src/helper/unit-menu.h | 11 ++++---- src/libnrtype/font-glyph.h | 1 - src/libnrtype/font-instance.h | 1 - src/libnrtype/font-style.h | 4 ++- src/livarot/Path.h | 8 +++++- src/livarot/Shape.h | 4 ++- src/livarot/int-line.h | 4 ++- src/livarot/livarot-forward.h | 28 --------------------- src/preferences.h | 1 - src/sp-namedview.h | 3 ++- src/verbs.h | 3 ++- src/xml/document.h | 1 - src/xml/event.h | 1 - src/xml/log-builder.h | 4 ++- src/xml/node-observer.h | 3 ++- src/xml/node.h | 7 +++++- src/xml/repr-sorting.h | 9 ++++++- src/xml/subtree.h | 1 - src/xml/xml-forward.h | 58 ------------------------------------------- 22 files changed, 49 insertions(+), 143 deletions(-) delete mode 100644 src/helper/helper-forward.h delete mode 100644 src/livarot/livarot-forward.h delete mode 100644 src/xml/xml-forward.h (limited to 'src') diff --git a/src/document.h b/src/document.h index 83cb57eea..efb14123a 100644 --- a/src/document.h +++ b/src/document.h @@ -43,6 +43,7 @@ struct SPItem; struct SPObject; struct SPGroup; struct SPRoot; +struct SPUnit; namespace Inkscape { struct Application; diff --git a/src/helper/action.h b/src/helper/action.h index 7e4da3312..e7c799992 100644 --- a/src/helper/action.h +++ b/src/helper/action.h @@ -14,9 +14,11 @@ #include <sigc++/sigc++.h> #include <glibmm/ustring.h> -#include "helper/helper-forward.h" #include "forward.h" +struct SPAction; +struct SPActionClass; + #define SP_TYPE_ACTION (sp_action_get_type()) #define SP_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction)) #define SP_ACTION_CLASS(o) (G_TYPE_CHECK_CLASS_CAST((o), SP_TYPE_ACTION, SPActionClass)) diff --git a/src/helper/helper-forward.h b/src/helper/helper-forward.h deleted file mode 100644 index f9b7f985b..000000000 --- a/src/helper/helper-forward.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __HELPER_FORWARD_H__ -#define __HELPER_FORWARD_H__ - -/* - * Forward declarations - * - * Author: - * Lauris Kaplinski <lauris@kaplinski.com> - * - * Copyright (C) 2002 Lauris Kaplinski - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - - -struct SPAction; -struct SPActionClass; -struct SPActionEventVector; - -struct SPUnit; -struct SPUnitSelector; -struct SPUnitSelectorClass; - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/unit-menu.h b/src/helper/unit-menu.h index 919873c58..b495a3c15 100644 --- a/src/helper/unit-menu.h +++ b/src/helper/unit-menu.h @@ -1,5 +1,5 @@ -#ifndef __SP_UNIT_MENU_H__ -#define __SP_UNIT_MENU_H__ +#ifndef SP_UNIT_MENU_H +#define SP_UNIT_MENU_H /* * SPUnitMenu @@ -13,8 +13,9 @@ #include <glib/gtypes.h> #include <gtk/gtk.h> -#include <helper/helper-forward.h> - +struct SPUnit; +struct SPUnitSelector; +struct SPUnitSelectorClass; /* Unit selector Widget */ @@ -45,7 +46,7 @@ void sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustmen -#endif +#endif // SP_UNIT_MENU_H /* Local Variables: diff --git a/src/libnrtype/font-glyph.h b/src/libnrtype/font-glyph.h index 14da5025b..b6954a482 100644 --- a/src/libnrtype/font-glyph.h +++ b/src/libnrtype/font-glyph.h @@ -2,7 +2,6 @@ #define SEEN_LIBNRTYPE_FONT_GLYPH_H #include <libnrtype/nrtype-forward.h> -#include <livarot/livarot-forward.h> #include <2geom/forward.h> // the info for a glyph in a font. it's totally resolution- and fontsize-independent diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 3ca3feee4..b66230d87 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -9,7 +9,6 @@ #include <libnrtype/nrtype-forward.h> #include <libnrtype/font-style.h> -#include <livarot/livarot-forward.h> #include <2geom/d2.h> // the font_instance are the template of several raster_font; they provide metrics and outlines diff --git a/src/libnrtype/font-style.h b/src/libnrtype/font-style.h index abfac2737..810fc72cf 100644 --- a/src/libnrtype/font-style.h +++ b/src/libnrtype/font-style.h @@ -3,10 +3,12 @@ #include <2geom/affine.h> #include <livarot/LivarotDefs.h> -#include <livarot/livarot-forward.h> // structure that holds data describing how to render glyphs of a font +class Path; +class Shape; + // Different raster styles. struct font_style { Geom::Affine transform; // the ctm. contains the font-size diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 22d989778..1f0e7a244 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -11,9 +11,15 @@ #include <vector> #include "LivarotDefs.h" -#include "livarot/livarot-forward.h" #include <2geom/point.h> +struct PathDescr; +class PathDescrLineTo; +class PathDescrArcTo; +class PathDescrCubicTo; +class PathDescrBezierTo; +class PathDescrIntermBezierTo; + struct SPStyle; /* diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index 158977897..5077a6da1 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -16,9 +16,11 @@ #include <vector> #include <2geom/point.h> -#include "livarot/livarot-forward.h" #include "livarot/LivarotDefs.h" +class Path; +class FloatLigne; + struct SweepTree; struct SweepTreeList; struct SweepEventQueue; diff --git a/src/livarot/int-line.h b/src/livarot/int-line.h index afd4d2f04..1d3bbd9d2 100644 --- a/src/livarot/int-line.h +++ b/src/livarot/int-line.h @@ -1,13 +1,15 @@ #ifndef INKSCAPE_LIVAROT_INT_LINE_H #define INKSCAPE_LIVAROT_INT_LINE_H -#include "livarot/livarot-forward.h" #include "livarot/LivarotDefs.h" /** \file * Coverage with integer boundaries. */ +class BitLigne; +class FloatLigne; + /// A run with integer boundaries. struct int_ligne_run { int st; diff --git a/src/livarot/livarot-forward.h b/src/livarot/livarot-forward.h deleted file mode 100644 index 9705b18e0..000000000 --- a/src/livarot/livarot-forward.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SEEN_LIVAROT_FORWARD_H -#define SEEN_LIVAROT_FORWARD_H - -class Path; -class Shape; -struct float_ligne_run; -class FloatLigne; -class BitLigne; -class PathDescr; -class PathDescrLineTo; -class PathDescrArcTo; -class PathDescrCubicTo; -class PathDescrBezierTo; -class PathDescrIntermBezierTo; - - -#endif /* !SEEN_LIVAROT_FORWARD_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/preferences.h b/src/preferences.h index 64bb6ac4f..86142d28b 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -19,7 +19,6 @@ #include <climits> #include <cfloat> #include <glibmm/ustring.h> -#include "xml/xml-forward.h" #include "xml/repr.h" class SPCSSAttr; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 86b16a557..1c9c9e879 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -20,13 +20,14 @@ #define SP_IS_NAMEDVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_NAMEDVIEW)) #define SP_IS_NAMEDVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_NAMEDVIEW)) -#include "helper/helper-forward.h" #include "sp-object-group.h" #include "sp-metric.h" #include "snap.h" #include "display/canvas-grid.h" #include "document.h" +struct SPUnit; + namespace Inkscape { class CanvasGrid; } diff --git a/src/verbs.h b/src/verbs.h index 224a809b0..364a9a598 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -21,10 +21,11 @@ #include <string.h> #include "config.h" #include "require-config.h" /* HAVE_GTK_WINDOW_FULLSCREEN */ -#include "helper/helper-forward.h" #include "forward.h" #include <glibmm/ustring.h> +struct SPAction; + /** \brief This anonymous enum is used to provide a list of the Verbs which are defined staticly in the verb files. There may be other verbs which are defined dynamically also. */ diff --git a/src/xml/document.h b/src/xml/document.h index 3bf0a63a6..efbc9bff7 100644 --- a/src/xml/document.h +++ b/src/xml/document.h @@ -15,7 +15,6 @@ #ifndef SEEN_INKSCAPE_XML_SP_REPR_DOC_H #define SEEN_INKSCAPE_XML_SP_REPR_DOC_H -#include "xml/xml-forward.h" #include "xml/node.h" namespace Inkscape { diff --git a/src/xml/event.h b/src/xml/event.h index 18dc47865..c2865b8c4 100644 --- a/src/xml/event.h +++ b/src/xml/event.h @@ -26,7 +26,6 @@ #include "util/share.h" #include "util/forward-pointer-iterator.h" #include "gc-managed.h" -#include "xml/xml-forward.h" #include "xml/node.h" namespace Inkscape { diff --git a/src/xml/log-builder.h b/src/xml/log-builder.h index 264c2ced7..aa8f2c1c6 100644 --- a/src/xml/log-builder.h +++ b/src/xml/log-builder.h @@ -15,12 +15,14 @@ #define SEEN_INKSCAPE_XML_LOG_BUILDER_H #include "gc-managed.h" -#include "xml/xml-forward.h" #include "xml/node-observer.h" namespace Inkscape { namespace XML { +class Event; +class Node; + /** * @brief Event log builder * diff --git a/src/xml/node-observer.h b/src/xml/node-observer.h index c3ec437b5..59142be8c 100644 --- a/src/xml/node-observer.h +++ b/src/xml/node-observer.h @@ -20,7 +20,6 @@ #include <glib/gquark.h> #include "util/share.h" -#include "xml/xml-forward.h" #ifndef INK_UNUSED #define INK_UNUSED(x) ((void)(x)) @@ -29,6 +28,8 @@ namespace Inkscape { namespace XML { +class Node; + /** * @brief Interface for XML node observers * diff --git a/src/xml/node.h b/src/xml/node.h index 17479e50b..8b7dea203 100644 --- a/src/xml/node.h +++ b/src/xml/node.h @@ -21,11 +21,16 @@ #include <glib/gtypes.h> #include "gc-anchored.h" #include "util/list.h" -#include "xml/xml-forward.h" namespace Inkscape { namespace XML { +struct AttributeRecord; +struct Document; +class Event; +class NodeObserver; +struct NodeEventVector; + /** * @brief Enumeration containing all supported node types. */ diff --git a/src/xml/repr-sorting.h b/src/xml/repr-sorting.h index d560dfa26..dddb8588c 100644 --- a/src/xml/repr-sorting.h +++ b/src/xml/repr-sorting.h @@ -7,7 +7,14 @@ #ifndef SEEN_XML_REPR_SORTING_H #define SEEN_XML_REPR_SORTING_H -#include "xml/xml-forward.h" +namespace Inkscape { +namespace XML { + +class Node; + +} // namespace XML +} // namespace Inkscape + Inkscape::XML::Node *LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *b); Inkscape::XML::Node const *LCA(Inkscape::XML::Node const *a, Inkscape::XML::Node const *b); diff --git a/src/xml/subtree.h b/src/xml/subtree.h index deee0cab1..11bf515f1 100644 --- a/src/xml/subtree.h +++ b/src/xml/subtree.h @@ -16,7 +16,6 @@ #define SEEN_INKSCAPE_XML_SUBTREE_H #include "gc-managed.h" -#include "xml/xml-forward.h" #include "xml/composite-node-observer.h" namespace Inkscape { diff --git a/src/xml/xml-forward.h b/src/xml/xml-forward.h deleted file mode 100644 index bc7b8a405..000000000 --- a/src/xml/xml-forward.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __SEEN_XML_FORWARD_H__ -#define __SEEN_XML_FORWARD_H__ - -/** @file - * @brief Forward declarations for the XML namespace. - */ -/* Authors: - * Krzysztof Kosiński <tweenk.pl@gmail.com> - * - * Copyright (C) 2008 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -namespace Inkscape { -namespace XML { - -/* Copied from the relevant Doxygen page */ - -struct AttributeRecord; -struct CommentNode; -class CompositeNodeObserver; -struct Document; -class ElementNode; -class Event; -class EventAdd; -class EventDel; -class EventChgAttr; -class EventChgContent; -class EventChgOrder; -class InvalidOperationException; -class LogBuilder; -struct NodeEventVector; -struct NodeSiblingIteratorStrategy; -struct NodeParentIteratorStrategy; -class NodeObserver; -class Node; -struct PINode; -class SimpleDocument; -class SimpleNode; -class Subtree; -struct TextNode; - -} // namespace XML -} // namespace Inkscape - -#endif // __SEEN_XML_FORWARD_H__ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 8a1cacd44e5db6437463e31dca2b4e5d4893d075 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Mon, 3 Oct 2011 23:49:12 -0700 Subject: More forward.h purging. (bzr r10665) --- src/extension/db.h | 14 ++++++++--- src/extension/dependency.cpp | 1 + src/extension/execution-env.h | 8 +++++- src/extension/extension-forward.h | 35 --------------------------- src/extension/extension.cpp | 2 +- src/extension/extension.h | 20 +++++++++++---- src/extension/implementation/implementation.h | 8 +++++- src/extension/internal/bitmap/imagemagick.h | 11 ++++++--- src/extension/internal/bluredge.h | 5 +++- src/extension/internal/filter/filter.h | 11 ++++++--- src/extension/internal/gimpgrad.h | 4 ++- src/extension/internal/grid.h | 5 +++- src/extension/param/enum.h | 2 +- src/extension/param/notebook.h | 2 +- src/extension/param/parameter.h | 4 ++- src/extension/param/radiobutton.h | 2 +- src/extension/system.h | 2 ++ src/extension/timer.h | 3 ++- src/file.h | 7 +++--- src/libnrtype/FontFactory.h | 4 ++- src/libnrtype/TextWrapper.h | 2 +- src/libnrtype/font-glyph.h | 1 - src/libnrtype/font-instance.h | 4 ++- src/libnrtype/font-lister.h | 1 - src/libnrtype/nrtype-forward.h | 20 --------------- src/print.h | 10 +++++++- src/ui/dialog/extensions.cpp | 1 + src/widgets/font-selector.h | 9 ++++--- 28 files changed, 101 insertions(+), 97 deletions(-) delete mode 100644 src/extension/extension-forward.h delete mode 100644 src/libnrtype/nrtype-forward.h (limited to 'src') diff --git a/src/extension/db.h b/src/extension/db.h index bc07c8591..0014f4449 100644 --- a/src/extension/db.h +++ b/src/extension/db.h @@ -12,18 +12,24 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifndef __MODULES_DB_H__ -#define __MODULES_DB_H__ +#ifndef SEEN_MODULES_DB_H +#define SEEN_MODULES_DB_H #include <map> #include <list> #include <cstring> -#include "extension/extension.h" +#include <glib.h> + namespace Inkscape { namespace Extension { +class Input; +class Output; +class Effect; +class Extension; + class DB { private: /** A string comparison function to be used in the moduledict @@ -74,7 +80,7 @@ extern DB db; } } /* namespace Extension, Inkscape */ -#endif /* __MODULES_DB_H__ */ +#endif // SEEN_MODULES_DB_H /* Local Variables: diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp index a83cac88d..01c3e129a 100644 --- a/src/extension/dependency.cpp +++ b/src/extension/dependency.cpp @@ -17,6 +17,7 @@ #include "path-prefix.h" #include "dependency.h" #include "db.h" +#include "extension.h" namespace Inkscape { namespace Extension { diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h index c2d4e7e4a..be7cf3fb7 100644 --- a/src/extension/execution-env.h +++ b/src/extension/execution-env.h @@ -18,12 +18,18 @@ #include <gtkmm/dialog.h> #include "forward.h" -#include "extension-forward.h" #include "extension.h" namespace Inkscape { namespace Extension { +class Effect; + +namespace Implementation +{ +class ImplementationDocumentCache; +} + class ExecutionEnv { private: enum state_t { diff --git a/src/extension/extension-forward.h b/src/extension/extension-forward.h deleted file mode 100644 index d836c29ab..000000000 --- a/src/extension/extension-forward.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef SEEN_EXTENSION_FORWARD_H -#define SEEN_EXTENSION_FORWARD_H - -namespace Inkscape { -namespace Extension { - -class Effect; -class Extension; -class Input; -class Output; -class Print; - -class Dependency; -class Parameter; -class ExpirationTimer; - -namespace Implementation { -class Implementation; -class ImplementationDocumentCache; -} - -} } - -#endif /* !SEEN_EXTENSION_FORWARD_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index a70c79943..72db7438c 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -1,4 +1,3 @@ -#define __SP_MODULE_C__ /** \file * * Inkscape::Extension::Extension: @@ -30,6 +29,7 @@ #include "inkscape.h" #include "extension/implementation/implementation.h" +#include "extension.h" #include "db.h" #include "dependency.h" diff --git a/src/extension/extension.h b/src/extension/extension.h index eddddf62c..273bc79e4 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -1,5 +1,5 @@ -#ifndef __INK_EXTENSION_H__ -#define __INK_EXTENSION_H__ +#ifndef INK_EXTENSION_H +#define INK_EXTENSION_H /** \file * Frontend to certain, possibly pluggable, actions. @@ -22,7 +22,6 @@ #include <gtkmm/table.h> #include <glibmm/ustring.h> #include "xml/repr.h" -#include "extension/extension-forward.h" /** The key that is used to identify that the I/O should be autodetected */ #define SP_MODULE_KEY_AUTODETECT "autodetect" @@ -68,6 +67,17 @@ struct SPDocument; namespace Inkscape { namespace Extension { +class Dependency; +class ExpirationTimer; +class ExpirationTimer; +class Parameter; + +namespace Implementation +{ +class Implementation; +} + + /** The object that is the basis for the Extension system. This object contains all of the information that all Extension have. The individual items are detailed within. This is the interface that @@ -163,7 +173,7 @@ public: private: void make_param (Inkscape::XML::Node * paramrepr); - Parameter * get_param (const gchar * name); + Parameter * get_param (const gchar * name); public: bool get_param_bool (const gchar * name, @@ -269,7 +279,7 @@ public: } /* namespace Extension */ } /* namespace Inkscape */ -#endif /* __INK_EXTENSION_H__ */ +#endif // INK_EXTENSION_H /* Local Variables: diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index a09f7c863..e648a66cd 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -17,13 +17,19 @@ #include <gtkmm/widget.h> #include "forward.h" -#include "extension/extension-forward.h" #include "xml/node.h" #include <2geom/forward.h> #include <2geom/point.h> namespace Inkscape { namespace Extension { + +class Effect; +class Extension; +class Input; +class Output; +class Print; + namespace Implementation { /** \brief A cache for the document and this implementation */ diff --git a/src/extension/internal/bitmap/imagemagick.h b/src/extension/internal/bitmap/imagemagick.h index 1b150fc3d..08b322503 100644 --- a/src/extension/internal/bitmap/imagemagick.h +++ b/src/extension/internal/bitmap/imagemagick.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__ +#ifndef INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H +#define INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H /* * Copyright (C) 2007 Authors: @@ -10,11 +10,14 @@ */ #include "extension/implementation/implementation.h" -#include "extension/extension-forward.h" #include <Magick++.h> namespace Inkscape { namespace Extension { + +class Effect; +class Extension; + namespace Internal { namespace Bitmap { @@ -37,4 +40,4 @@ public: }; /* namespace Extension */ }; /* namespace Inkscape */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__ */ +#endif // INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H diff --git a/src/extension/internal/bluredge.h b/src/extension/internal/bluredge.h index 48e30c054..d8fe056f7 100644 --- a/src/extension/internal/bluredge.h +++ b/src/extension/internal/bluredge.h @@ -7,11 +7,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "extension/extension-forward.h" #include "extension/implementation/implementation.h" namespace Inkscape { namespace Extension { + +class Effect; +class Extension; + namespace Internal { /** \brief Implementation class of the GIMP gradient plugin. This mostly diff --git a/src/extension/internal/filter/filter.h b/src/extension/internal/filter/filter.h index a5d5d9d4e..08bc1c3f0 100644 --- a/src/extension/internal/filter/filter.h +++ b/src/extension/internal/filter/filter.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H__ -#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H__ +#ifndef INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H +#define INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H /* * Copyright (C) 2008 Authors: @@ -11,10 +11,13 @@ #include <glibmm/i18n.h> #include "extension/implementation/implementation.h" -#include "extension/extension-forward.h" namespace Inkscape { namespace Extension { + +class Effect; +class Extension; + namespace Internal { namespace Filter { @@ -52,4 +55,4 @@ public: }; /* namespace Extension */ }; /* namespace Inkscape */ -#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H__ */ +#endif // INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H diff --git a/src/extension/internal/gimpgrad.h b/src/extension/internal/gimpgrad.h index ed409ef93..5ab48a147 100644 --- a/src/extension/internal/gimpgrad.h +++ b/src/extension/internal/gimpgrad.h @@ -13,10 +13,12 @@ #include <glibmm/ustring.h> #include "extension/implementation/implementation.h" -#include "extension/extension-forward.h" namespace Inkscape { namespace Extension { + +class Extension; + namespace Internal { /** \brief Implementation class of the GIMP gradient plugin. This mostly diff --git a/src/extension/internal/grid.h b/src/extension/internal/grid.h index 1f37b1441..c54135d81 100644 --- a/src/extension/internal/grid.h +++ b/src/extension/internal/grid.h @@ -8,10 +8,13 @@ */ #include "extension/implementation/implementation.h" -#include "extension/extension-forward.h" namespace Inkscape { namespace Extension { + +class Effect; +class Extension; + namespace Internal { /** \brief Implementation class of the GIMP gradient plugin. This mostly diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h index 6fc22e8aa..ca008cda5 100644 --- a/src/extension/param/enum.h +++ b/src/extension/param/enum.h @@ -17,13 +17,13 @@ #include <gtkmm/widget.h> #include "xml/document.h" -#include <extension/extension-forward.h> #include "parameter.h" namespace Inkscape { namespace Extension { +class Extension; // \brief A class to represent a notebookparameter of an extension diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h index fb21c9b63..983ad3161 100644 --- a/src/extension/param/notebook.h +++ b/src/extension/param/notebook.h @@ -17,13 +17,13 @@ #include <gtkmm/widget.h> #include "xml/document.h" -#include <extension/extension-forward.h> #include "parameter.h" namespace Inkscape { namespace Extension { +class Extension; // \brief A class to represent a notebookparameter of an extension diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index d8ed68439..e7a7538b7 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -18,12 +18,14 @@ #include "xml/document.h" #include "xml/node.h" #include "document.h" -#include "extension/extension-forward.h" #include <color.h> namespace Inkscape { namespace Extension { +class Extension; + + /** * @brief The root directory in the preferences database for extension-related parameters * diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h index e15afdbc7..cf33bb381 100644 --- a/src/extension/param/radiobutton.h +++ b/src/extension/param/radiobutton.h @@ -17,13 +17,13 @@ #include <gtkmm/widget.h> #include "xml/document.h" -#include <extension/extension-forward.h> #include "parameter.h" namespace Inkscape { namespace Extension { +class Extension; // \brief A class to represent a radiobutton parameter of an extension diff --git a/src/extension/system.h b/src/extension/system.h index b6740e109..716539de1 100644 --- a/src/extension/system.h +++ b/src/extension/system.h @@ -21,6 +21,8 @@ namespace Inkscape { namespace Extension { +class Print; + /** * Used to distinguish between the various invocations of the save dialogs (and thus to determine * the file type and save path offered in the dialog) diff --git a/src/extension/timer.h b/src/extension/timer.h index 33b9829e9..b257c770a 100644 --- a/src/extension/timer.h +++ b/src/extension/timer.h @@ -16,11 +16,12 @@ #include <stddef.h> #include <sigc++/sigc++.h> #include <glibmm/timeval.h> -#include "extension-forward.h" namespace Inkscape { namespace Extension { +class Extension; + class ExpirationTimer { /** \brief Circularly linked list of all timers */ static ExpirationTimer * timer_list; diff --git a/src/file.h b/src/file.h index cf3adec2b..5a43ffa5e 100644 --- a/src/file.h +++ b/src/file.h @@ -1,5 +1,5 @@ -#ifndef __SP_FILE_H__ -#define __SP_FILE_H__ +#ifndef SEEN_SP_FILE_H +#define SEEN_SP_FILE_H /* * File/Print operations @@ -19,7 +19,6 @@ #include <glib/gslist.h> #include <gtk/gtk.h> -#include "extension/extension-forward.h" #include "extension/system.h" struct SPDesktop; @@ -193,7 +192,7 @@ void sp_file_print (Gtk::Window& parentWindow); void sp_file_vacuum (); -#endif +#endif // SEEN_SP_FILE_H /* diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 9843ebcfb..58a98d1a9 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -23,7 +23,6 @@ #include "nr-type-primitives.h" #include "nr-type-pos-def.h" #include "font-style-to-pos.h" -#include <libnrtype/nrtype-forward.h> #include "../style.h" /* Freetype */ @@ -34,6 +33,9 @@ #include <freetype/freetype.h> #endif + +class font_instance; + namespace Glib { class ustring; diff --git a/src/libnrtype/TextWrapper.h b/src/libnrtype/TextWrapper.h index b4a3cc724..1f96851ef 100644 --- a/src/libnrtype/TextWrapper.h +++ b/src/libnrtype/TextWrapper.h @@ -13,7 +13,6 @@ #include <pango/pango.h> -#include <libnrtype/nrtype-forward.h> #include "libnrtype/boundary-type.h" // miscanellous but useful data for a given text: chunking into logical pieces @@ -24,6 +23,7 @@ struct text_boundary; struct one_glyph; struct one_box; struct one_para; +class font_instance; class text_wrapper { public: diff --git a/src/libnrtype/font-glyph.h b/src/libnrtype/font-glyph.h index b6954a482..3f136daaf 100644 --- a/src/libnrtype/font-glyph.h +++ b/src/libnrtype/font-glyph.h @@ -1,7 +1,6 @@ #ifndef SEEN_LIBNRTYPE_FONT_GLYPH_H #define SEEN_LIBNRTYPE_FONT_GLYPH_H -#include <libnrtype/nrtype-forward.h> #include <2geom/forward.h> // the info for a glyph in a font. it's totally resolution- and fontsize-independent diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index b66230d87..d00569984 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -7,10 +7,12 @@ #include <require-config.h> #include "FontFactory.h" -#include <libnrtype/nrtype-forward.h> #include <libnrtype/font-style.h> #include <2geom/d2.h> +class font_factory; +struct font_glyph; + // the font_instance are the template of several raster_font; they provide metrics and outlines // that are drawn by the raster_font, so the raster_font needs info relative to the way the // font need to be drawn. note that fontsize is a scale factor in the transform matrix diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 23c8548fe..57b3798a2 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -16,7 +16,6 @@ #include <glibmm.h> #include <gtkmm.h> -#include "nrtype-forward.h" #include "nr-type-primitives.h" namespace Inkscape diff --git a/src/libnrtype/nrtype-forward.h b/src/libnrtype/nrtype-forward.h deleted file mode 100644 index 6050ffa6b..000000000 --- a/src/libnrtype/nrtype-forward.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SEEN_LIBNRTYPE_NRTYPE_FORWARD_H -#define SEEN_LIBNRTYPE_NRTYPE_FORWARD_H - -class font_factory; -struct font_glyph; -class font_instance; -struct font_style; - -#endif /* !SEEN_LIBNRTYPE_NRTYPE_FORWARD_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/print.h b/src/print.h index 422f18669..35e45f6ed 100644 --- a/src/print.h +++ b/src/print.h @@ -15,7 +15,15 @@ //#include <libnr/nr-path.h> #include <2geom/forward.h> #include "forward.h" -#include "extension/extension-forward.h" + + +namespace Inkscape { +namespace Extension { + +class Print; + +} // namespace Extension +} // namespace Inkscape struct SPPrintContext { Inkscape::Extension::Print *module; diff --git a/src/ui/dialog/extensions.cpp b/src/ui/dialog/extensions.cpp index 242b79368..ed38860d1 100644 --- a/src/ui/dialog/extensions.cpp +++ b/src/ui/dialog/extensions.cpp @@ -15,6 +15,7 @@ #include "extension/db.h" #include "extensions.h" +#include "extension/extension.h" namespace Inkscape { diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 3fc425f65..340a76f7f 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -1,5 +1,5 @@ -#ifndef __SP_FONT_SELECTOR_H__ -#define __SP_FONT_SELECTOR_H__ +#ifndef SP_FONT_SELECTOR_H +#define SP_FONT_SELECTOR_H /* * Font selection widgets @@ -22,9 +22,10 @@ struct SPFontSelector; #define SP_FONT_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector)) #define SP_IS_FONT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_SELECTOR)) -#include <libnrtype/nrtype-forward.h> #include <gtk/gtkwidget.h> +class font_instance; + /* SPFontSelector */ GType sp_font_selector_get_type (void); @@ -38,7 +39,7 @@ double sp_font_selector_get_size (SPFontSelector *fsel); -#endif +#endif // SP_FONT_SELECTOR_H /* Local Variables: -- cgit v1.2.3 From c0f82d2110bcb8226efbe8435b76dcc6e0e48f70 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Tue, 4 Oct 2011 12:04:58 -0700 Subject: Cleaned up display-forward.h, including many redundant usages. (bzr r10666) --- src/common-context.cpp | 1 - src/display/canvas-arena.cpp | 1 - src/display/canvas-arena.h | 9 ++++- src/display/canvas-axonomgrid.cpp | 1 - src/display/canvas-bpath.cpp | 1 - src/display/canvas-grid.cpp | 2 - src/display/canvas-text.cpp | 1 - src/display/display-forward.h | 50 ------------------------- src/display/drawing-item.h | 14 ++++++- src/display/drawing.h | 8 +++- src/display/sp-canvas.cpp | 1 - src/display/sp-ctrlline.cpp | 1 - src/display/sp-ctrlquadr.cpp | 1 - src/extension/internal/cairo-render-context.cpp | 1 - src/extension/internal/cairo-renderer.cpp | 1 - src/extension/internal/latex-pstricks-out.cpp | 1 - src/extension/print.h | 6 ++- src/lpe-tool-context.cpp | 1 - src/sp-clippath.h | 9 ++++- src/sp-flowtext.h | 15 ++++++-- src/sp-item-group.h | 7 ++++ src/sp-item.h | 10 ++++- src/sp-mask.h | 9 ++++- src/sp-shape.h | 6 +++ src/ui/cache/svg_preview_cache.h | 10 ++++- src/widgets/stroke-style.cpp | 1 - 26 files changed, 89 insertions(+), 79 deletions(-) delete mode 100644 src/display/display-forward.h (limited to 'src') diff --git a/src/common-context.cpp b/src/common-context.cpp index 08bac0152..467d19f72 100644 --- a/src/common-context.cpp +++ b/src/common-context.cpp @@ -5,7 +5,6 @@ #include "config.h" -#include "forward.h" #include "message-context.h" #include "streq.h" #include "preferences.h" diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 34b0d7cab..9983e1c4d 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -12,7 +12,6 @@ #include <gtk/gtk.h> -#include "display/display-forward.h" #include "display/sp-canvas-util.h" #include "helper/sp-marshal.h" #include "display/canvas-arena.h" diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index daab19d8e..26f19732d 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -15,7 +15,6 @@ #include <cairo.h> #include <2geom/rect.h> -#include "display/display-forward.h" #include "display/drawing.h" #include "display/drawing-item.h" #include "display/sp-canvas.h" @@ -33,6 +32,14 @@ typedef struct _SPCanvasArena SPCanvasArena; typedef struct _SPCanvasArenaClass SPCanvasArenaClass; struct CachePrefObserver; +namespace Inkscape { + +class Drawing; +class DrawingItem; + +} // namespace Inkscape + + struct _SPCanvasArena { SPCanvasItem item; diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 089fe88d1..3598c4e4e 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -22,7 +22,6 @@ #include "display/cairo-utils.h" #include "display/canvas-axonomgrid.h" #include "display/canvas-grid.h" -#include "display/display-forward.h" #include "display/sp-canvas-util.h" #include "document.h" #include "helper/units.h" diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index e015655a6..14f120600 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -21,7 +21,6 @@ #include "display/sp-canvas-group.h" #include "display/sp-canvas-util.h" #include "display/canvas-bpath.h" -#include "display/display-forward.h" #include "display/curve.h" #include "display/cairo-utils.h" #include "helper/geom.h" diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index dbf78f561..d9f6ddcf2 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -15,12 +15,10 @@ #include "desktop.h" #include "sp-canvas-util.h" #include "util/mathfns.h" -#include "display-forward.h" #include "desktop-handles.h" #include "display/cairo-utils.h" #include "display/canvas-axonomgrid.h" #include "display/canvas-grid.h" -#include "display/display-forward.h" #include "display/sp-canvas-util.h" #include "display/sp-canvas-group.h" #include "document.h" diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 185d10b15..809bb4eeb 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -20,7 +20,6 @@ #include <sstream> #include <string.h> -#include "display-forward.h" #include "sp-canvas-util.h" #include "canvas-text.h" #include "display/cairo-utils.h" diff --git a/src/display/display-forward.h b/src/display/display-forward.h deleted file mode 100644 index 7dccb76ef..000000000 --- a/src/display/display-forward.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SEEN_DISPLAY_DISPLAY_FORWARD_H -#define SEEN_DISPLAY_DISPLAY_FORWARD_H - -#include <glib-object.h> - -struct SPCanvas; -struct SPCanvasClass; -struct SPCanvasItem; -typedef struct _SPCanvasItemClass SPCanvasItemClass; -struct SPCanvasGroup; -struct SPCanvasGroupClass; -class SPCurve; -typedef struct _SPCanvasArena SPCanvasArena; - -namespace Inkscape { -class Drawing; -class DrawingItem; -class DrawingGroup; -class DrawingImage; -class DrawingShape; -class DrawingGlyphs; -class DrawingText; -class UpdateContext; - -class DrawingContext; -class DrawingSurface; -class DrawingCache; - -namespace Display { - class TemporaryItem; - class TemporaryItemList; -} - -namespace Filters { - class Filter; -} -} - -#endif /* !SEEN_DISPLAY_DISPLAY_FORWARD_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index cd8f128d8..810a61d9d 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -19,12 +19,24 @@ #include <boost/intrusive/list.hpp> #include <2geom/rect.h> #include <2geom/affine.h> -#include "display/display-forward.h" class SPStyle; namespace Inkscape { +class Drawing; +class DrawingCache; +class DrawingContext; +class DrawingItem; + +namespace Filters { + +class Filter; + +} // namespace Filters + + + struct UpdateContext { Geom::Affine ctm; }; diff --git a/src/display/drawing.h b/src/display/drawing.h index bf3c4bbe8..8154f0783 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -13,16 +13,22 @@ #define SEEN_INKSCAPE_DISPLAY_DRAWING_H #include <set> +#include <glib.h> #include <boost/operators.hpp> #include <boost/utility.hpp> #include <sigc++/sigc++.h> #include <2geom/rect.h> -#include "display/display-forward.h" #include "display/drawing-item.h" #include "display/rendermode.h" + +typedef struct _SPCanvasArena SPCanvasArena; + + namespace Inkscape { +class DrawingItem; + class Drawing : boost::noncopyable { diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index e6f973faf..9e942ec35 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -23,7 +23,6 @@ #include "helper/sp-marshal.h" #include <helper/recthull.h> -#include "display-forward.h" #include <2geom/affine.h> #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index cf70f324e..77f5c1d15 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -24,7 +24,6 @@ #endif #include "display/sp-ctrlline.h" -#include "display/display-forward.h" #include "display/sp-canvas-util.h" #include "display/cairo-utils.h" #include "color.h" diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index 8cdd8170b..af761864c 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -13,7 +13,6 @@ # include "config.h" #endif -#include "display-forward.h" #include "sp-canvas-item.h" #include "sp-canvas.h" #include "sp-canvas-util.h" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 9bafa9432..584942c4f 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -33,7 +33,6 @@ #include <glibmm/i18n.h> #include "display/drawing.h" -#include "display/display-forward.h" #include "display/curve.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 3b6c26113..6c77005fe 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -35,7 +35,6 @@ #include <glib/gmem.h> #include <glibmm/i18n.h> -#include "display/display-forward.h" #include "display/curve.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 3a16268e6..faac9ce44 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -18,7 +18,6 @@ #include "extension/system.h" #include "extension/print.h" #include "extension/db.h" -#include "display/display-forward.h" #include "display/drawing.h" #include "sp-root.h" diff --git a/src/extension/print.h b/src/extension/print.h index 9c0920499..8d401d646 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -13,10 +13,14 @@ #include "extension.h" -#include "display/display-forward.h" #include "forward.h" #include "sp-item.h" + namespace Inkscape { + +class Drawing; +class DrawingItem; + namespace Extension { class Print : public Extension { diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index f49d082b6..c164dfbd1 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -22,7 +22,6 @@ #include <gdk/gdkkeysyms.h> #include "macros.h" -#include "forward.h" #include "pixmaps/cursor-crosshairs.xpm" #include <gtk/gtk.h> #include "desktop.h" diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 4084b89d8..6cab3f053 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -23,11 +23,18 @@ class SPClipPathView; -#include "display/display-forward.h" #include "sp-object-group.h" #include "uri-references.h" #include "xml/node.h" + +namespace Inkscape { + +class Drawing; +class DrawingItem; + +} // namespace Inkscape + class SPClipPath : public SPObjectGroup { public: class Reference; diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index de41ba47f..944503a1e 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -1,12 +1,11 @@ -#ifndef __SP_ITEM_FLOWTEXT_H__ -#define __SP_ITEM_FLOWTEXT_H__ +#ifndef SEEN_SP_ITEM_FLOWTEXT_H +#define SEEN_SP_ITEM_FLOWTEXT_H /* */ #include "sp-item.h" -#include "display/display-forward.h" #include <2geom/forward.h> #include "libnrtype/Layout-TNG.h" @@ -16,6 +15,14 @@ #define SP_IS_FLOWTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_FLOWTEXT)) #define SP_IS_FLOWTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_FLOWTEXT)) + +namespace Inkscape { + +class DrawingGroup; + +} // namespace Inkscape + + struct SPFlowtext : public SPItem { /** Completely recalculates the layout. */ void rebuildLayout(); @@ -54,7 +61,7 @@ GType sp_flowtext_get_type (void); SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p1, Geom::Point p2); -#endif +#endif // SEEN_SP_ITEM_FLOWTEXT_H /* Local Variables: diff --git a/src/sp-item-group.h b/src/sp-item-group.h index f56192925..c13fa2b75 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -26,6 +26,13 @@ class CGroup; +namespace Inkscape { + +class Drawing; +class DrawingItem; + +} // namespace Inkscape + struct SPGroup : public SPLPEItem { enum LayerMode { GROUP, LAYER, MASK_HELPER }; diff --git a/src/sp-item.h b/src/sp-item.h index 1765089a3..5cfd49446 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -23,7 +23,6 @@ #include <2geom/affine.h> #include <2geom/rect.h> -#include "display/display-forward.h" #include "sp-object.h" #include "snap-preferences.h" #include "snap-candidate.h" @@ -33,7 +32,14 @@ struct SPClipPathReference; struct SPMaskReference; struct SPAvoidRef; struct SPPrintContext; -namespace Inkscape { class URIReference;} + +namespace Inkscape { + +class Drawing; +class DrawingItem; +class URIReference; + +} enum { SP_EVENT_INVALID, diff --git a/src/sp-mask.h b/src/sp-mask.h index 10b42ca1e..6155131ff 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -14,7 +14,6 @@ */ #include <2geom/rect.h> -#include "display/display-forward.h" #include "sp-object-group.h" #include "uri-references.h" #include "xml/node.h" @@ -29,6 +28,14 @@ class SPMask; class SPMaskClass; class SPMaskView; +namespace Inkscape { + +class Drawing; +class DrawingItem; + +} // namespace Inkscape + + struct SPMask : public SPObjectGroup { unsigned int maskUnits_set : 1; unsigned int maskUnits : 1; diff --git a/src/sp-shape.h b/src/sp-shape.h index 06bd704ad..014158b21 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -33,6 +33,12 @@ struct SPDesktop; +namespace Inkscape { + +class DrawingItem; + +} // namespace Inkscape + class SPShape : public SPLPEItem { public: SPCurve *curve; diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index 2318307e2..11d26fe22 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -14,7 +14,13 @@ #include <glibmm/ustring.h> #include <2geom/rect.h> -#include "display/display-forward.h" +namespace Inkscape { + +class Drawing; +class DrawingItem; + +} // namespace Inkscape + GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize); @@ -42,7 +48,7 @@ class SvgPreview { -#endif // __SVG_PREVIEW_CACHE_H__ +#endif // SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H /* Local Variables: mode:c++ diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index b4a5b5694..3594e2049 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -29,7 +29,6 @@ #include "desktop-style.h" #include "dialogs/dialog-events.h" #include "display/canvas-bpath.h" // for SP_STROKE_LINEJOIN_* -#include "display/display-forward.h" #include "display/drawing.h" #include "document-private.h" #include "gradient-chemistry.h" -- cgit v1.2.3 From cd5e6c8856a1ac7b94e0fa799c471eaa8c8ecae4 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Wed, 5 Oct 2011 00:06:08 -0700 Subject: Cleanup for src/forward.h. (About 19 of the affected files did not require the contents forward.h at all). (bzr r10667) --- src/box3d-side.cpp | 2 + src/color-profile.cpp | 3 +- src/color-profile.h | 2 + src/color.h | 7 +- src/connector-context.h | 1 - src/desktop-handles.h | 13 +- src/desktop-style.h | 8 +- src/dialogs/dialog-events.h | 11 +- src/dialogs/item-properties.h | 6 +- src/dialogs/object-attributes.h | 4 +- src/display/canvas-temporary-item-list.h | 3 +- src/display/snap-indicator.h | 3 +- src/document-undo.h | 4 + src/draw-context.h | 7 +- src/event-context.h | 13 +- src/extension/execution-env.h | 8 +- src/extension/implementation/implementation.h | 11 +- src/extension/print.h | 1 - src/filter-chemistry.h | 7 +- src/forward.h | 175 -------------------------- src/gradient-chemistry.h | 3 +- src/gradient-drag.h | 23 +++- src/helper/action.h | 7 +- src/helper/stock-items.h | 6 +- src/inkscape-private.h | 9 +- src/inkscape.cpp | 4 + src/interface.h | 14 ++- src/knot.h | 8 +- src/knotholder.h | 7 +- src/libnrtype/font-style-to-pos.h | 11 +- src/live_effects/lpeobject-reference.h | 1 - src/live_effects/parameter/path-reference.h | 1 - src/path-chemistry.h | 17 ++- src/print.h | 4 +- src/rubberband.h | 2 +- src/satisfied-guide-cns.h | 7 +- src/selection-chemistry.h | 1 - src/selection.h | 1 - src/seltrans.h | 7 +- src/shape-editor.h | 13 +- src/snap.h | 1 + src/sp-conn-end-pair.h | 5 +- src/sp-conn-end.h | 1 + src/sp-gradient-reference.h | 2 + src/sp-gradient.h | 2 +- src/sp-guide-attachment.h | 1 - src/sp-guide-constraint.h | 8 +- src/sp-item-notify-moveto.h | 9 +- src/sp-item-rm-unsatisfied-cns.h | 9 +- src/sp-item-transform.h | 10 +- src/sp-item-update-cns.h | 11 +- src/sp-object-repr.h | 1 - src/sp-object.h | 4 +- src/sp-pattern.h | 3 +- src/sp-tref-reference.h | 1 - src/sp-use-reference.h | 1 - src/style.h | 1 - src/text-chemistry.h | 14 +-- src/tools-switch.h | 8 +- src/ui/context-menu.h | 7 +- src/ui/dialog/filedialogimpl-gtkmm.h | 3 + src/ui/tool/control-point.h | 3 +- src/ui/tool/multi-path-manipulator.h | 1 - src/ui/tool/node-tool.h | 1 - src/ui/tool/path-manipulator.h | 2 +- src/uri-references.h | 20 ++- src/verbs.h | 10 +- src/widgets/desktop-widget.h | 2 +- src/widgets/gradient-vector.h | 5 +- src/widgets/paint-selector.h | 4 +- src/widgets/sp-attribute-widget.h | 4 +- src/widgets/toolbox.h | 4 +- 72 files changed, 274 insertions(+), 319 deletions(-) delete mode 100644 src/forward.h (limited to 'src') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index fdbe33222..2148e9e97 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -24,6 +24,8 @@ #include "desktop-style.h" #include "box3d.h" +struct SPPathClass; + static void box3d_side_class_init (Box3DSideClass *klass); static void box3d_side_init (Box3DSide *side); diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 41c9d4c63..cc9e7a6cb 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -606,7 +606,8 @@ cmsHTRANSFORM ColorProfile::getTransfGamutCheck() return impl->_gamutTransf; } -bool ColorProfile::GamutCheck(SPColor color){ +bool ColorProfile::GamutCheck(SPColor color) +{ BYTE outofgamut = 0; guint32 val = color.toRGBA32(0); diff --git a/src/color-profile.h b/src/color-profile.h index a9724defc..ae63e4047 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -11,6 +11,8 @@ #include <glibmm/ustring.h> #include "cms-color-types.h" +struct SPColor; + namespace Inkscape { enum { diff --git a/src/color.h b/src/color.h index 8e6b54dd1..418b12c89 100644 --- a/src/color.h +++ b/src/color.h @@ -1,5 +1,5 @@ -#ifndef __SP_COLOR_H__ -#define __SP_COLOR_H__ +#ifndef SEEN_SP_COLOR_H +#define SEEN_SP_COLOR_H /** \file * Colors. @@ -82,5 +82,4 @@ void sp_color_rgb_to_cmyk_floatv (float *cmyk, float r, float g, float b); void sp_color_cmyk_to_rgb_floatv (float *rgb, float c, float m, float y, float k); -#endif - +#endif // SEEN_SP_COLOR_H diff --git a/src/connector-context.h b/src/connector-context.h index 97e21025d..128f2bbeb 100644 --- a/src/connector-context.h +++ b/src/connector-context.h @@ -16,7 +16,6 @@ #include <sigc++/sigc++.h> #include <sigc++/connection.h> #include "event-context.h" -#include <forward.h> #include <2geom/point.h> #include "libavoid/connector.h" #include "connection-points.h" diff --git a/src/desktop-handles.h b/src/desktop-handles.h index 74001d890..6bf6f87d2 100644 --- a/src/desktop-handles.h +++ b/src/desktop-handles.h @@ -1,5 +1,5 @@ -#ifndef __SP_DESKTOP_HANDLES_H__ -#define __SP_DESKTOP_HANDLES_H__ +#ifndef SEEN_SP_DESKTOP_HANDLES_H +#define SEEN_SP_DESKTOP_HANDLES_H /* * Frontends @@ -13,11 +13,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" +class SPDesktop; +class SPDocument; +class SPEventContext; +class SPNamedView; struct SPCanvas; -struct SPCanvasItem; struct SPCanvasGroup; +struct SPCanvasItem; namespace Inkscape { class MessageStack; @@ -46,7 +49,7 @@ SPCanvasGroup * sp_desktop_tempgroup (SPDesktop const * desktop); Inkscape::MessageStack * sp_desktop_message_stack (SPDesktop const * desktop); SPNamedView * sp_desktop_namedview (SPDesktop const * desktop); -#endif +#endif // SEEN_SP_DESKTOP_HANDLES_H /* Local Variables: diff --git a/src/desktop-style.h b/src/desktop-style.h index 6aa685a36..3719c2a9e 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -1,5 +1,5 @@ -#ifndef __SP_DESKTOP_STYLE_H__ -#define __SP_DESKTOP_STYLE_H__ +#ifndef SEEN_SP_DESKTOP_STYLE_H +#define SEEN_SP_DESKTOP_STYLE_H /* * Desktop style management @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> class ColorRGBA; struct SPCSSAttr; @@ -83,7 +83,7 @@ int sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); -#endif +#endif // SEEN_SP_DESKTOP_STYLE_H /* diff --git a/src/dialogs/dialog-events.h b/src/dialogs/dialog-events.h index 9c0a82f23..53be16682 100644 --- a/src/dialogs/dialog-events.h +++ b/src/dialogs/dialog-events.h @@ -9,11 +9,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifndef __DIALOG_EVENTS_H__ -#define __DIALOG_EVENTS_H__ +#ifndef SEEN_DIALOG_EVENTS_H +#define SEEN_DIALOG_EVENTS_H #include <gtk/gtk.h> -#include <forward.h> /* * event callback can only accept one argument, but we need two, @@ -28,6 +27,12 @@ namespace Gtk { class Window; class Entry; } + +class SPDesktop; + +namespace Inkscape { +class Application; +} // namespace Inkscape typedef struct { GtkWidget *win; diff --git a/src/dialogs/item-properties.h b/src/dialogs/item-properties.h index 7d57ae5e8..51f5d7032 100644 --- a/src/dialogs/item-properties.h +++ b/src/dialogs/item-properties.h @@ -11,13 +11,11 @@ #ifndef SEEN_DIALOGS_ITEM_PROPERTIES_H #define SEEN_DIALOGS_ITEM_PROPERTIES_H -#include <glib.h> #include <gtk/gtk.h> -#include "../forward.h" -GtkWidget *sp_item_widget_new (void); +GtkWidget *sp_item_widget_new(void); -void sp_item_dialog (void); +void sp_item_dialog(void); #endif diff --git a/src/dialogs/object-attributes.h b/src/dialogs/object-attributes.h index b490ebfa1..53b3ee37f 100644 --- a/src/dialogs/object-attributes.h +++ b/src/dialogs/object-attributes.h @@ -13,8 +13,8 @@ #define SEEN_DIALOGS_OBJECT_ATTRIBUTES_H #include <glib.h> -#include <gtk/gtk.h> -#include "../forward.h" + +class SPObject; void sp_object_attributes_dialog (SPObject *object, const gchar *tag); diff --git a/src/display/canvas-temporary-item-list.h b/src/display/canvas-temporary-item-list.h index 47556b9f1..7a9f8b87a 100644 --- a/src/display/canvas-temporary-item-list.h +++ b/src/display/canvas-temporary-item-list.h @@ -12,10 +12,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" #include <list> +#include <glib.h> struct SPCanvasItem; +class SPDesktop; namespace Inkscape { namespace Display { diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index d60ff1481..ff08a8a8c 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -14,9 +14,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" #include "snapped-point.h" +class SPDesktop; + namespace Inkscape { namespace Display { diff --git a/src/document-undo.h b/src/document-undo.h index afd595ed8..7ff45c269 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -3,8 +3,12 @@ typedef struct _GtkObject GtkObject; +class SPDesktop; + namespace Inkscape { +class Application; + class DocumentUndo { public: diff --git a/src/draw-context.h b/src/draw-context.h index 17540649b..53114d820 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -1,5 +1,5 @@ -#ifndef __SP_DRAW_CONTEXT_H__ -#define __SP_DRAW_CONTEXT_H__ +#ifndef SEEN_SP_DRAW_CONTEXT_H +#define SEEN_SP_DRAW_CONTEXT_H /* * Generic drawing context @@ -18,7 +18,6 @@ #include <sigc++/sigc++.h> #include <2geom/point.h> #include "event-context.h" -#include <forward.h> #include "live_effects/effect.h" /* Freehand context */ @@ -90,7 +89,7 @@ void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, guint sta void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item); void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state); -#endif +#endif // SEEN_SP_DRAW_CONTEXT_H /* Local Variables: diff --git a/src/event-context.h b/src/event-context.h index b0772c23a..ca13fe7e8 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -1,5 +1,5 @@ -#ifndef __SP_EVENT_CONTEXT_H__ -#define __SP_EVENT_CONTEXT_H__ +#ifndef SEEN_SP_EVENT_CONTEXT_H +#define SEEN_SP_EVENT_CONTEXT_H /** \file * SPEventContext: base class for event processors @@ -38,6 +38,13 @@ namespace Inkscape { } } + +#define SP_TYPE_EVENT_CONTEXT (sp_event_context_get_type()) +#define SP_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_EVENT_CONTEXT, SPEventContext)) +#define SP_IS_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_EVENT_CONTEXT)) + +GType sp_event_context_get_type(); + gboolean sp_event_context_snap_watchdog_callback(gpointer data); void sp_event_context_discard_delayed_snap_event(SPEventContext *ec); @@ -184,7 +191,7 @@ void ec_shape_event_attr_changed(Inkscape::XML::Node *shape_repr, void event_context_print_event_info(GdkEvent *event, bool print_return = true); -#endif +#endif // SEEN_SP_EVENT_CONTEXT_H /* diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h index be7cf3fb7..92f496b90 100644 --- a/src/extension/execution-env.h +++ b/src/extension/execution-env.h @@ -17,10 +17,16 @@ #include <gtkmm/dialog.h> -#include "forward.h" #include "extension.h" namespace Inkscape { + +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI + namespace Extension { class Effect; diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index e648a66cd..443046846 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -16,12 +16,21 @@ #include <gdkmm/types.h> #include <gtkmm/widget.h> -#include "forward.h" #include "xml/node.h" #include <2geom/forward.h> #include <2geom/point.h> +class SPDocument; +class SPStyle; + namespace Inkscape { + +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI + namespace Extension { class Effect; diff --git a/src/extension/print.h b/src/extension/print.h index 8d401d646..c1afe59b3 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -13,7 +13,6 @@ #include "extension.h" -#include "forward.h" #include "sp-item.h" namespace Inkscape { diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index 9f16419fd..2ac3ebe8f 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -14,11 +14,16 @@ #ifndef SEEN_SP_FILTER_CHEMISTRY_H #define SEEN_SP_FILTER_CHEMISTRY_H -#include "forward.h" +#include <glib.h> + #include "display/nr-filter-types.h" +class SPDocument; class SPFilter; class SPFilterPrimitive; +class SPItem; +class SPObject; + SPFilterPrimitive *filter_add_primitive(SPFilter *filter, Inkscape::Filters::FilterPrimitiveType); SPFilter *new_filter (SPDocument *document); diff --git a/src/forward.h b/src/forward.h deleted file mode 100644 index 352fae6fa..000000000 --- a/src/forward.h +++ /dev/null @@ -1,175 +0,0 @@ -#ifndef FORWARD_H_SEEN -#define FORWARD_H_SEEN - -/* - * Forward declarations of most used objects - * - * Author: - * Lauris Kaplinski <lauris@kaplinski.com> - * Abhishek Sharma - * - * Copyright (C) 2001-2002 Lauris Kaplinski - * Copyright (C) 2001 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glib-object.h> - -/* Generic containers */ - -namespace Inkscape { -struct Application; -struct ApplicationClass; -} - -/* Editing window */ - -class SPDesktop; -class SPDesktopClass; - -class SPDesktopWidget; -class SPDesktopWidgetClass; - -GType sp_desktop_get_type (); - -class SPEventContext; -class SPEventContextClass; - -#define SP_TYPE_EVENT_CONTEXT (sp_event_context_get_type ()) -#define SP_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_EVENT_CONTEXT, SPEventContext)) -#define SP_IS_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_EVENT_CONTEXT)) - -GType sp_event_context_get_type (); - -/* Document tree */ - -class SPDocument; -class SPDocumentClass; - -/* Objects */ - -class SPGroup; -class SPGroupClass; - -class SPNamedView; -class SPNamedViewClass; - -class SPGuide; -class SPGuideClass; - -class SPObjectGroup; -class SPObjectGroupClass; - -struct SPMarker; -struct SPMarkerClass; -class SPMarkerReference; - -class SPPath; -class SPPathClass; - -class SPShape; -class SPShapeClass; - -class SPPolygon; -class SPPolygonClass; - -class SPEllipse; -class SPEllipseClass; - -class SPCircle; -class SPCircleClass; - -class SPArc; -class SPArcClass; - -class SPChars; -class SPCharsClass; - -class SPText; -class SPTextClass; - -class SPTSpan; -class SPTSpanClass; - -class SPString; -class SPStringClass; - -class SPStop; -class SPStopClass; - -class SPGradient; -class SPGradientClass; -class SPGradientReference; - -class SPLinearGradient; -class SPLinearGradientClass; - -class SPRadialGradient; -class SPRadialGradientClass; - -class SPPattern; - -class SPClipPath; -class SPClipPathClass; -class SPClipPathReference; - -class SPMaskReference; - -class SPAvoidRef; - -class SPAnchor; -class SPAnchorClass; - -/* Misc */ - -class ColorRGBA; - -class SPColor; - -class SPStyle; - -class SPEvent; - -class SPPrintContext; - -namespace Inkscape { -namespace UI { -namespace View { -class View; -}; -}; -}; - -class SPViewWidget; -class SPViewWidgetClass; - -class StopOnTrue; - -namespace Inkscape { -class URI; -class URIReference; -} - -struct box_solution; - - -/* verbs */ - -typedef int sp_verb_t; -namespace Inkscape { - class Verb; -} - -#endif // FORWARD_H_SEEN - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h index e0d9a1f46..f797f928d 100644 --- a/src/gradient-chemistry.h +++ b/src/gradient-chemistry.h @@ -18,9 +18,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" #include "sp-gradient.h" +class SPItem; + /* * Either normalizes given gradient to vector, or returns fresh normalized * vector - in latter case, original gradient is flattened and stops cleared diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 4ad9a1e16..2fd0e46f0 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -1,5 +1,5 @@ -#ifndef __GRADIENT_DRAG_H__ -#define __GRADIENT_DRAG_H__ +#ifndef SEEN_GRADIENT_DRAG_H +#define SEEN_GRADIENT_DRAG_H /* * On-canvas gradient dragging @@ -18,14 +18,27 @@ #include <stddef.h> #include <sigc++/sigc++.h> #include <vector> +#include <glib.h> +#include <glibmm/ustring.h> -#include <forward.h> #include <2geom/point.h> -#include <knot-enums.h> + +#include "knot-enums.h" struct SPItem; struct SPKnot; +class SPDesktop; +class SPCSSAttr; +class SPLinearGradient; +class SPObject; +class SPRadialGradient; +class SPStop; + +namespace Inkscape { +class Selection; +} // namespace Inkscape + /** This class represents a single draggable point of a gradient. It remembers the item which has the gradient, whether it's fill or stroke, the point type (from the @@ -187,4 +200,4 @@ private: sigc::connection style_query_connection; }; -#endif +#endif // SEEN_GRADIENT_DRAG_H diff --git a/src/helper/action.h b/src/helper/action.h index e7c799992..0cd010b34 100644 --- a/src/helper/action.h +++ b/src/helper/action.h @@ -14,7 +14,7 @@ #include <sigc++/sigc++.h> #include <glibmm/ustring.h> -#include "forward.h" +#include <glib-object.h> struct SPAction; struct SPActionClass; @@ -26,6 +26,11 @@ struct SPActionClass; namespace Inkscape { class Verb; +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI } /** All the data that is required to be an action. This diff --git a/src/helper/stock-items.h b/src/helper/stock-items.h index ddad55415..7299e070e 100644 --- a/src/helper/stock-items.h +++ b/src/helper/stock-items.h @@ -1,4 +1,5 @@ -#define __INK_STOCK_ITEMS__ +#ifndef SEEN_INK_STOCK_ITEMS_H +#define SEEN_INK_STOCK_ITEMS_H /* * Stock-items @@ -14,7 +15,8 @@ #include <glib/gtypes.h> -#include <forward.h> +class SPObject; SPObject *get_stock_item(gchar const *urn); +#endif // SEEN_INK_STOCK_ITEMS_H diff --git a/src/inkscape-private.h b/src/inkscape-private.h index a6643b989..470a1f5bd 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -1,5 +1,5 @@ -#ifndef __INKSCAPE_PRIVATE_H__ -#define __INKSCAPE_PRIVATE_H__ +#ifndef SEEN_INKSCAPE_PRIVATE_H +#define SEEN_INKSCAPE_PRIVATE_H /* * Some forward declarations @@ -12,6 +12,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glib-object.h> #define SP_TYPE_INKSCAPE (inkscape_get_type ()) #define SP_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape)) @@ -19,9 +20,9 @@ #define SP_IS_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_INKSCAPE)) #define SP_IS_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE)) -#include "forward.h" #include "inkscape.h" +class SPColor; namespace Inkscape { class Selection; } GType inkscape_get_type (void); @@ -52,7 +53,7 @@ bool inkscape_remove_document (SPDocument *document); void inkscape_set_color (SPColor *color, float opacity); -#endif +#endif // SEEN_INKSCAPE_PRIVATE_H diff --git a/src/inkscape.cpp b/src/inkscape.cpp index fe59732a5..f07d0cac4 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -88,6 +88,10 @@ enum { # FORWARD DECLARATIONS ################################*/ +namespace Inkscape { +class ApplicationClass; +} + static void inkscape_class_init (Inkscape::ApplicationClass *klass); static void inkscape_init (SPObject *object); static void inkscape_dispose (GObject *object); diff --git a/src/interface.h b/src/interface.h index a39769632..2b01a20d7 100644 --- a/src/interface.h +++ b/src/interface.h @@ -17,9 +17,21 @@ #include <gtk/gtk.h> -#include "forward.h" #include "sp-item.h" +class SPViewWidget; + +namespace Inkscape { + +class Verb; + +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI +} // namespace Inkscape + /** * Create a new document window. */ diff --git a/src/knot.h b/src/knot.h index 250165f79..ad152b54c 100644 --- a/src/knot.h +++ b/src/knot.h @@ -1,5 +1,5 @@ -#ifndef __SP_KNOT_H__ -#define __SP_KNOT_H__ +#ifndef SEEN_SP_KNOT_H +#define SEEN_SP_KNOT_H /** \file * Declarations for SPKnot: Desktop-bound visual control object. @@ -16,12 +16,12 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> -#include "forward.h" #include <2geom/point.h> #include "knot-enums.h" #include <stddef.h> #include <sigc++/sigc++.h> +class SPDesktop; class SPKnot; class SPKnotClass; struct SPCanvasItem; @@ -179,7 +179,7 @@ void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot); Geom::Point sp_knot_position(SPKnot const *knot); -#endif /* !__SP_KNOT_H__ */ +#endif // SEEN_SP_KNOT_H /* Local Variables: diff --git a/src/knotholder.h b/src/knotholder.h index 0dd3bba1e..2e2844801 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -1,5 +1,5 @@ -#ifndef __SP_KNOTHOLDER_H__ -#define __SP_KNOTHOLDER_H__ +#ifndef SEEN_SP_KNOTHOLDER_H +#define SEEN_SP_KNOTHOLDER_H /* * KnotHolder - Hold SPKnot list and manage signals @@ -19,7 +19,6 @@ #include <glib/gtypes.h> #include "knot-enums.h" -#include "forward.h" #include <2geom/forward.h> #include "knot-holder-entity.h" #include <list> @@ -71,7 +70,7 @@ void knot_moved_handler(SPKnot *knot, Geom::Point const *p, guint state, gpointe void knot_ungrabbed_handler(SPKnot *knot, unsigned int state, KnotHolder *kh); **/ -#endif /* !__SP_KNOTHOLDER_H__ */ +#endif // SEEN_SP_KNOTHOLDER_H /* Local Variables: diff --git a/src/libnrtype/font-style-to-pos.h b/src/libnrtype/font-style-to-pos.h index 635c7378d..41ba6cf72 100644 --- a/src/libnrtype/font-style-to-pos.h +++ b/src/libnrtype/font-style-to-pos.h @@ -1,12 +1,13 @@ -#ifndef __FONT_STYLE_TO_POS_H__ -#define __FONT_STYLE_TO_POS_H__ +#ifndef SEEN_FONT_STYLE_TO_POS_H +#define SEEN_FONT_STYLE_TO_POS_H -#include <forward.h> /* SPStyle */ #include <libnrtype/nr-type-pos-def.h> -NRTypePosDef font_style_to_pos (SPStyle const &style); +class SPStyle; -#endif /* __FONT_STYLE_TO_POS_H__ */ +NRTypePosDef font_style_to_pos(SPStyle const &style); + +#endif // SEEN_FONT_STYLE_TO_POS_H /* Local Variables: diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h index 8d2b406eb..571c3b1f1 100644 --- a/src/live_effects/lpeobject-reference.h +++ b/src/live_effects/lpeobject-reference.h @@ -9,7 +9,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include <forward.h> #include <uri-references.h> #include <stddef.h> #include <sigc++/sigc++.h> diff --git a/src/live_effects/parameter/path-reference.h b/src/live_effects/parameter/path-reference.h index 26fce952a..d24f05a4f 100644 --- a/src/live_effects/parameter/path-reference.h +++ b/src/live_effects/parameter/path-reference.h @@ -10,7 +10,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include <forward.h> #include "sp-item.h" #include <uri-references.h> #include <stddef.h> diff --git a/src/path-chemistry.h b/src/path-chemistry.h index 03adeeff9..b88b84087 100644 --- a/src/path-chemistry.h +++ b/src/path-chemistry.h @@ -1,5 +1,5 @@ -#ifndef __PATH_CHEMISTRY_H__ -#define __PATH_CHEMISTRY_H__ +#ifndef SEEN_PATH_CHEMISTRY_H +#define SEEN_PATH_CHEMISTRY_H /* * Here are handlers for modifying selections, specific to paths @@ -13,7 +13,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" +#include <glib.h> + +class SPDesktop; +class SPItem; + +namespace Inkscape { +namespace XML { +class Node; +} // namespace XML +} // namespace Inkscape void sp_selected_path_combine (SPDesktop *desktop); void sp_selected_path_break_apart (SPDesktop *desktop); @@ -23,7 +32,7 @@ Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_ void sp_selected_path_reverse (SPDesktop *desktop); bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems = false); -#endif +#endif // SEEN_PATH_CHEMISTRY_H /* Local Variables: diff --git a/src/print.h b/src/print.h index 35e45f6ed..2f587b95b 100644 --- a/src/print.h +++ b/src/print.h @@ -14,9 +14,11 @@ #include <gtkmm.h> //#include <libnr/nr-path.h> #include <2geom/forward.h> -#include "forward.h" +class SPDocument; +class SPStyle; + namespace Inkscape { namespace Extension { diff --git a/src/rubberband.h b/src/rubberband.h index 6c857fb63..0761d8066 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -14,7 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" #include <boost/optional.hpp> #include <vector> #include <2geom/point.h> @@ -25,6 +24,7 @@ class CtrlRect; class SPCanvasItem; class SPCurve; +class SPDesktop; enum { RUBBERBAND_MODE_RECT, diff --git a/src/satisfied-guide-cns.h b/src/satisfied-guide-cns.h index 57803daf4..27fe043d0 100644 --- a/src/satisfied-guide-cns.h +++ b/src/satisfied-guide-cns.h @@ -1,7 +1,6 @@ -#ifndef __SATISFIED_GUIDE_CNS_H__ -#define __SATISFIED_GUIDE_CNS_H__ +#ifndef SEEN_SATISFIED_GUIDE_CNS_H +#define SEEN_SATISFIED_GUIDE_CNS_H -#include <forward.h> #include <2geom/forward.h> #include <vector> #include <sp-item.h> @@ -13,7 +12,7 @@ void satisfied_guide_cns(SPDesktop const &desktop, std::vector<SPGuideConstraint> &cns); -#endif /* !__SATISFIED_GUIDE_CNS_H__ */ +#endif // SEEN_SATISFIED_GUIDE_CNS_H /* Local Variables: diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index b3d64ae8e..1c193fc93 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -17,7 +17,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" #include "sp-item.h" #include "2geom/forward.h" diff --git a/src/selection.h b/src/selection.h index 39e75685e..081776427 100644 --- a/src/selection.h +++ b/src/selection.h @@ -22,7 +22,6 @@ #include <stddef.h> #include <sigc++/sigc++.h> -#include "forward.h" #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" diff --git a/src/seltrans.h b/src/seltrans.h index 9d14fda26..3a5fa006e 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -1,5 +1,5 @@ -#ifndef __SELTRANS_H__ -#define __SELTRANS_H__ +#ifndef SEEN_SELTRANS_H +#define SEEN_SELTRANS_H /* * Helper object for transforming selected items @@ -21,7 +21,6 @@ #include <2geom/affine.h> #include <2geom/rect.h> #include "knot.h" -#include "forward.h" #include "selcue.h" #include "message-context.h" #include <vector> @@ -181,7 +180,7 @@ private: } -#endif +#endif // SEEN_SELTRANS_H /* diff --git a/src/shape-editor.h b/src/shape-editor.h index 1f0958a3e..206ff269b 100644 --- a/src/shape-editor.h +++ b/src/shape-editor.h @@ -1,5 +1,5 @@ -#ifndef __SHAPE_EDITOR_H__ -#define __SHAPE_EDITOR_H__ +#ifndef SEEN_SHAPE_EDITOR_H +#define SEEN_SHAPE_EDITOR_H /* * Inkscape::ShapeEditor @@ -12,17 +12,20 @@ * */ -#include <forward.h> +#include <glib.h> + #include <2geom/forward.h> + namespace Inkscape { namespace NodePath { class Path; } } namespace Inkscape { namespace XML { class Node; } } class KnotHolder; +class LivePathEffectObject; class SPDesktop; +class SPItem; class SPNodeContext; class ShapeEditorsCollective; -class LivePathEffectObject; #include <2geom/point.h> #include <boost/optional.hpp> @@ -73,7 +76,7 @@ private: Inkscape::XML::Node *knotholder_listener_attached_for; }; -#endif +#endif // SEEN_SHAPE_EDITOR_H /* diff --git a/src/snap.h b/src/snap.h index 4a8f4b7c1..8fefa1cf2 100644 --- a/src/snap.h +++ b/src/snap.h @@ -31,6 +31,7 @@ enum SPGuideDragType { // used both here and in desktop-events.cpp SP_DRAG_NONE }; +class SPGuide; class SPNamedView; /// Class to coordinate snapping operations diff --git a/src/sp-conn-end-pair.h b/src/sp-conn-end-pair.h index 98096a246..7648e253a 100644 --- a/src/sp-conn-end-pair.h +++ b/src/sp-conn-end-pair.h @@ -13,7 +13,6 @@ */ #include <glib/gtypes.h> -#include "forward.h" #include <stddef.h> #include <sigc++/connection.h> #include <sigc++/functors/slot.h> @@ -23,7 +22,11 @@ class SPConnEnd; struct SPCurve; +class SPPath; +class SPItem; +class SPObject; +namespace Geom { class Point; } namespace Inkscape { namespace XML { class Node; diff --git a/src/sp-conn-end.h b/src/sp-conn-end.h index 052e8ddcb..d2785b0e2 100644 --- a/src/sp-conn-end.h +++ b/src/sp-conn-end.h @@ -9,6 +9,7 @@ #include "connection-points.h" #include "conn-avoid-ref.h" +class SPPath; class SPConnEnd { public: diff --git a/src/sp-gradient-reference.h b/src/sp-gradient-reference.h index 770593823..2737df702 100644 --- a/src/sp-gradient-reference.h +++ b/src/sp-gradient-reference.h @@ -2,6 +2,8 @@ #define SEEN_SP_GRADIENT_REFERENCE_H #include "uri-references.h" + +class SPGradient; class SPObject; class SPGradientReference : public Inkscape::URIReference { diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 85eb70e9b..c92d07fd3 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -29,7 +29,7 @@ #include <sigc++/connection.h> struct SPGradientReference; - +class SPStop; #define SP_TYPE_GRADIENT (SPGradient::getType()) #define SP_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT, SPGradient)) diff --git a/src/sp-guide-attachment.h b/src/sp-guide-attachment.h index e5c63d04e..09d4375df 100644 --- a/src/sp-guide-attachment.h +++ b/src/sp-guide-attachment.h @@ -1,7 +1,6 @@ #ifndef SEEN_SP_GUIDE_ATTACHMENT_H #define SEEN_SP_GUIDE_ATTACHMENT_H -#include <forward.h> #include "sp-item.h" class SPGuideAttachment { diff --git a/src/sp-guide-constraint.h b/src/sp-guide-constraint.h index a39660e75..763696788 100644 --- a/src/sp-guide-constraint.h +++ b/src/sp-guide-constraint.h @@ -1,7 +1,7 @@ -#ifndef __SP_GUIDE_CONSTRAINT_H__ -#define __SP_GUIDE_CONSTRAINT_H__ +#ifndef SEEN_SP_GUIDE_CONSTRAINT_H +#define SEEN_SP_GUIDE_CONSTRAINT_H -#include <forward.h> +class SPGuide; class SPGuideConstraint { public: @@ -29,7 +29,7 @@ public: }; -#endif /* !__SP_GUIDE_CONSTRAINT_H__ */ +#endif // SEEN_SP_GUIDE_CONSTRAINT_H /* diff --git a/src/sp-item-notify-moveto.h b/src/sp-item-notify-moveto.h index 1e6ff2854..ec47508dd 100644 --- a/src/sp-item-notify-moveto.h +++ b/src/sp-item-notify-moveto.h @@ -1,13 +1,14 @@ -#ifndef __SP_ITEM_NOTIFY_MOVETO_H__ -#define __SP_ITEM_NOTIFY_MOVETO_H__ +#ifndef SEEN_SP_ITEM_NOTIFY_MOVETO_H +#define SEEN_SP_ITEM_NOTIFY_MOVETO_H -#include <forward.h> +class SPItem; +class SPGuide; void sp_item_notify_moveto(SPItem &item, SPGuide const &g, int const snappoint_ix, double position, bool const commit); -#endif /* !__SP_ITEM_NOTIFY_MOVETO_H__ */ +#endif // SEEN_SP_ITEM_NOTIFY_MOVETO_H /* diff --git a/src/sp-item-rm-unsatisfied-cns.h b/src/sp-item-rm-unsatisfied-cns.h index 97742dd4d..62f688b51 100644 --- a/src/sp-item-rm-unsatisfied-cns.h +++ b/src/sp-item-rm-unsatisfied-cns.h @@ -1,11 +1,12 @@ -#ifndef __SP_ITEM_RM_UNSATISFIED_CNS_H__ -#define __SP_ITEM_RM_UNSATISFIED_CNS_H__ -#include <forward.h> +#ifndef SEEN_SP_ITEM_RM_UNSATISFIED_CNS_H +#define SEEN_SP_ITEM_RM_UNSATISFIED_CNS_H + +class SPItem; void sp_item_rm_unsatisfied_cns(SPItem &item); -#endif /* !__SP_ITEM_RM_UNSATISFIED_CNS_H__ */ +#endif // SEEN_SP_ITEM_RM_UNSATISFIED_CNS_H /* Local Variables: diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 4ea8f976f..5e67dd276 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -1,8 +1,10 @@ -#ifndef SP_ITEM_TRANSFORM_H -#define SP_ITEM_TRANSFORM_H +#ifndef SEEN_SP_ITEM_TRANSFORM_H +#define SEEN_SP_ITEM_TRANSFORM_H + +#include <glib.h> -#include "forward.h" #include <2geom/forward.h> +class SPItem; void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation); void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); @@ -14,7 +16,7 @@ Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_vis Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); -#endif /* !SP_ITEM_TRANSFORM_H */ +#endif // SEEN_SP_ITEM_TRANSFORM_H /* Local Variables: diff --git a/src/sp-item-update-cns.h b/src/sp-item-update-cns.h index bf8de715d..d0b080552 100644 --- a/src/sp-item-update-cns.h +++ b/src/sp-item-update-cns.h @@ -1,12 +1,15 @@ -#ifndef __SP_ITEM_UPDATE_CNS_H__ -#define __SP_ITEM_UPDATE_CNS_H__ -#include <forward.h> +#ifndef SEEN_SP_ITEM_UPDATE_CNS_H +#define SEEN_SP_ITEM_UPDATE_CNS_H + #include <2geom/forward.h> +class SPDesktop; +class SPItem; + void sp_item_update_cns(SPItem &item, SPDesktop const &desktop); -#endif /* !__SP_ITEM_UPDATE_CNS_H__ */ +#endif // SEEN_SP_ITEM_UPDATE_CNS_H /* Local Variables: diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h index 407af0bcc..0ac49bba4 100644 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@ -12,7 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" #include "sp-object.h" namespace Inkscape { namespace XML { diff --git a/src/sp-object.h b/src/sp-object.h index 38d39c4cd..a4220e720 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -57,7 +57,6 @@ class SPObjectClass; #include <sigc++/functors/slot.h> #include <sigc++/signal.h> -#include "forward.h" #include "version.h" #include "util/forward-pointer-iterator.h" #include "desktop-style.h" @@ -111,7 +110,9 @@ enum { SP_XML_SPACE_PRESERVE }; +class SPDocument; class SPIXmlSpace; +class SPObject; /// Internal class consisting of two bits. struct SPIXmlSpace { @@ -119,7 +120,6 @@ struct SPIXmlSpace { guint value : 1; }; -class SPObject; /* * Refcounting diff --git a/src/sp-pattern.h b/src/sp-pattern.h index acfa3e76e..cb6d1dbf0 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -15,7 +15,6 @@ #include <gtk/gtk.h> -#include "forward.h" #include "sp-item.h" #define SP_TYPE_PATTERN (sp_pattern_get_type ()) #define SP_PATTERN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_PATTERN, SPPattern)) @@ -25,6 +24,7 @@ GType sp_pattern_get_type (void); +class SPPattern; class SPPatternClass; #include "svg/svg-length.h" @@ -34,6 +34,7 @@ class SPPatternClass; #include <stddef.h> #include <sigc++/connection.h> + class SPPatternReference : public Inkscape::URIReference { public: SPPatternReference (SPObject *obj) : URIReference(obj) {} diff --git a/src/sp-tref-reference.h b/src/sp-tref-reference.h index 2e340f423..2d12437d9 100644 --- a/src/sp-tref-reference.h +++ b/src/sp-tref-reference.h @@ -12,7 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include <forward.h> #include "sp-item.h" #include <uri-references.h> #include <stddef.h> diff --git a/src/sp-use-reference.h b/src/sp-use-reference.h index 25a67b85b..bbedb9875 100644 --- a/src/sp-use-reference.h +++ b/src/sp-use-reference.h @@ -9,7 +9,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include <forward.h> #include "sp-item.h" #include <uri-references.h> #include <stddef.h> diff --git a/src/style.h b/src/style.h index 6150b03c7..6c9ee992e 100644 --- a/src/style.h +++ b/src/style.h @@ -16,7 +16,6 @@ */ #include "color.h" -#include "forward.h" #include "sp-marker-loc.h" #include "sp-filter.h" #include "sp-filter-reference.h" diff --git a/src/text-chemistry.h b/src/text-chemistry.h index cb86fc6c6..1ae0a1779 100644 --- a/src/text-chemistry.h +++ b/src/text-chemistry.h @@ -1,5 +1,5 @@ -#ifndef __TEXT_CHEMISTRY_H__ -#define __TEXT_CHEMISTRY_H__ +#ifndef SEEN_TEXT_CHEMISTRY_H +#define SEEN_TEXT_CHEMISTRY_H /* * Text commands @@ -12,16 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "forward.h" - -void text_put_on_path (void); -void text_remove_from_path (void); -void text_remove_all_kerns (void); +void text_put_on_path(void); +void text_remove_from_path(void); +void text_remove_all_kerns(void); void text_flow_into_shape(); void text_unflow(); void flowtext_to_text(); -#endif +#endif // SEEN_TEXT_CHEMISTRY_H /* Local Variables: diff --git a/src/tools-switch.h b/src/tools-switch.h index 75c728179..9765def92 100644 --- a/src/tools-switch.h +++ b/src/tools-switch.h @@ -12,7 +12,11 @@ #ifndef SEEN_TOOLS_SWITCH_H #define SEEN_TOOLS_SWITCH_H -#include <forward.h> +class SPDesktop; +class SPItem; +namespace Geom { +class Point; +} enum { TOOLS_INVALID, @@ -44,7 +48,7 @@ int tools_active(SPDesktop *dt); void tools_switch(SPDesktop *dt, int num); void tools_switch_by_item (SPDesktop *dt, SPItem *item, Geom::Point const p); -#endif /* !SEEN_TOOLS_SWITCH_H */ +#endif // !SEEN_TOOLS_SWITCH_H /* Local Variables: diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index 1f8208ebe..39753f93f 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -13,10 +13,13 @@ #include <gtk/gtk.h> -#include "forward.h" #include "sp-object.h" -/* Append object-specific part to context menu */ +class SPDesktop; + +/** + * Append object-specific part to context menu. + */ void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu); #endif diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index 1598a04d3..e6e771f1b 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -49,6 +49,9 @@ namespace Inkscape { + +class URI; + namespace UI { namespace Dialog diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h index 9f62fca42..72106403e 100644 --- a/src/ui/tool/control-point.h +++ b/src/ui/tool/control-point.h @@ -18,10 +18,11 @@ #include <gtkmm.h> #include <2geom/point.h> -#include "forward.h" #include "util/accumulators.h" #include "display/sodipodi-ctrl.h" +class SPDesktop; + namespace Inkscape { namespace UI { diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h index c25719790..29b618b5f 100644 --- a/src/ui/tool/multi-path-manipulator.h +++ b/src/ui/tool/multi-path-manipulator.h @@ -13,7 +13,6 @@ #include <stddef.h> #include <sigc++/connection.h> -#include "forward.h" #include "ui/tool/commit-events.h" #include "ui/tool/manipulator.h" #include "ui/tool/modifier-tracker.h" diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 218e697b7..6f7ab01d4 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -17,7 +17,6 @@ #include <stddef.h> #include <sigc++/sigc++.h> #include "event-context.h" -#include "forward.h" #include "ui/tool/node-types.h" #define INK_TYPE_NODE_TOOL (ink_node_tool_get_type ()) diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 27a83f06b..edaf5a8de 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -17,12 +17,12 @@ #include <2geom/affine.h> #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> -#include "forward.h" #include "ui/tool/node.h" #include "ui/tool/manipulator.h" struct SPCanvasItem; struct SPCurve; +struct SPPath; namespace Inkscape { namespace XML { class Node; } diff --git a/src/uri-references.h b/src/uri-references.h index 938dd4cd8..631d440da 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -1,5 +1,5 @@ -#ifndef __SP_URI_REFERENCES_H__ -#define __SP_URI_REFERENCES_H__ +#ifndef SEEN_SP_URI_REFERENCES_H +#define SEEN_SP_URI_REFERENCES_H /* * Helper methods for resolving URI References @@ -19,11 +19,12 @@ #include <sigc++/trackable.h> #include "bad-uri-exception.h" -#include "forward.h" #include "sp-object.h" namespace Inkscape { +class URI; + /** * A class encapsulating a reference to a particular URI; observers can * be notified when the URI comes to reference a different SPObject. @@ -152,4 +153,15 @@ SPObject* sp_css_uri_reference_resolve( SPDocument *document, const gchar *uri ) SPObject *sp_uri_reference_resolve (SPDocument *document, const gchar *uri); -#endif +#endif // SEEN_SP_URI_REFERENCES_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/verbs.h b/src/verbs.h index 364a9a598..7c16ff530 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -21,10 +21,18 @@ #include <string.h> #include "config.h" #include "require-config.h" /* HAVE_GTK_WINDOW_FULLSCREEN */ -#include "forward.h" #include <glibmm/ustring.h> struct SPAction; +class SPDocument; + +namespace Inkscape { +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI +} // namespace Inkscape /** \brief This anonymous enum is used to provide a list of the Verbs which are defined staticly in the verb files. There may be diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 742411fb1..29af8bd75 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -14,7 +14,6 @@ #include <gtk/gtk.h> -#include "forward.h" #include "sp-object.h" #include "message.h" #include "ui/view/view-widget.h" @@ -27,6 +26,7 @@ // forward declaration typedef struct _EgeColorProfTracker EgeColorProfTracker; struct SPCanvas; +class SPDesktopWidget; #define SP_TYPE_DESKTOP_WIDGET SPDesktopWidget::getType() diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 6b165aca2..b198895e7 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -21,7 +21,6 @@ #include <sigc++/connection.h> #include <gtk/gtk.h> -#include "../forward.h" #define SP_TYPE_GRADIENT_VECTOR_SELECTOR (sp_gradient_vector_selector_get_type ()) #define SP_GRADIENT_VECTOR_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_GRADIENT_VECTOR_SELECTOR, SPGradientVectorSelector)) @@ -29,6 +28,10 @@ #define SP_IS_GRADIENT_VECTOR_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_GRADIENT_VECTOR_SELECTOR)) #define SP_IS_GRADIENT_VECTOR_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_VECTOR_SELECTOR)) +class SPDocument; +class SPGradient; +class SPStop; + struct SPGradientVectorSelector { GtkVBox vbox; diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index f32c2c83d..25ba4aa97 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -18,11 +18,13 @@ #include "color.h" #include "fill-or-stroke.h" -#include "forward.h" #include "sp-gradient-spread.h" #include "sp-gradient-units.h" class SPGradient; +class SPDesktop; +class SPPattern; +class SPStyle; #define SP_TYPE_PAINT_SELECTOR (sp_paint_selector_get_type ()) #define SP_PAINT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_PAINT_SELECTOR, SPPaintSelector)) diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index d5445c8bb..93342ff4e 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -42,9 +42,9 @@ struct SPAttributeWidgetClass; struct SPAttributeTable; struct SPAttributeTableClass; -#include <gtk/gtk.h> +class SPObject; -#include <forward.h> +#include <gtk/gtk.h> struct SPAttributeWidget { GtkEntry entry; diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index 0f3ce83c5..a3fbddf0c 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -18,9 +18,11 @@ #include <gtk/gtk.h> #include <glibmm/ustring.h> -#include "forward.h" #include "icon-size.h" +class SPDesktop; +class SPEventContext; + namespace Inkscape { namespace UI { -- cgit v1.2.3 From 09a6e7e8970d8601814316d43a9e1f3c796e5808 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour <nicoduf@yahoo.fr> Date: Thu, 6 Oct 2011 20:09:42 +0200 Subject: Translations. Ukrainian translation update and typo patch by Yuri Chornoivan. (bzr r10668) --- src/extension/internal/filter/color.h | 2 +- src/extension/internal/filter/transparency.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 0f892365c..b6b194c8b 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -905,7 +905,7 @@ public: "<name>" N_("Invert") "</name>\n" "<id>org.inkscape.effect.filter.Invert</id>\n" "<param name=\"channels\" gui-text=\"" N_("Invert channels:") "\" type=\"enum\">\n" - "<_item value=\"0\">" N_("No invertion") "</_item>\n" + "<_item value=\"0\">" N_("No inversion") "</_item>\n" "<_item value=\"1\">" N_("Red and blue") "</_item>\n" "<_item value=\"2\">" N_("Red and green") "</_item>\n" "<_item value=\"3\">" N_("Green and blue") "</_item>\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 4e91f8854..b29a0a1b3 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -32,7 +32,7 @@ namespace Filter { /** \brief Custom predefined Blend filter. - Blend objecs with background images or with themselves + Blend objects with background images or with themselves Filter's parameters: * Source (enum [SourceGraphic,BackgroundImage], default BackgroundImage) -> blend (in2) @@ -70,7 +70,7 @@ public: "<submenu name=\"" N_("Fill and Transparency") "\"/>\n" "</submenu>\n" "</effects-menu>\n" - "<menu-tip>" N_("Blend objecs with background images or with themselves") "</menu-tip>\n" + "<menu-tip>" N_("Blend objects with background images or with themselves") "</menu-tip>\n" "</effect>\n" "</inkscape-extension>\n", new Blend()); }; -- cgit v1.2.3 From e47c0620257d767316fe5f5beb0462adc9bed920 Mon Sep 17 00:00:00 2001 From: Alvin Penner <penner@vaxxine.com> Date: Fri, 7 Oct 2011 18:36:44 -0400 Subject: emf import. allow EMR_MOVETOEX to occur before EMR_BEGINPATH (Bug 858369) Fixed bugs: - https://launchpad.net/bugs/858369 (bzr r10670) --- src/extension/internal/emf-win32-inout.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index f1f0ef3cb..f66209479 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -736,7 +736,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * lpEMFR->iType!=EMR_POLYLINETO && lpEMFR->iType!=EMR_POLYLINETO16 && lpEMFR->iType!=EMR_LINETO && lpEMFR->iType!=EMR_ARCTO && lpEMFR->iType!=EMR_SETBKCOLOR && lpEMFR->iType!=EMR_SETROP2 && - lpEMFR->iType!=EMR_SETBKMODE) + lpEMFR->iType!=EMR_SETBKMODE && lpEMFR->iType!=EMR_BEGINPATH) { *(d->outsvg) += " <path "; output_style(d, EMR_STROKEPATH); @@ -1665,8 +1665,11 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * { dbg_str << "<!-- EMR_BEGINPATH -->\n"; - tmp_path << "d=\""; - *(d->path) = ""; + if (!d->pathless_stroke) { + tmp_path << "d=\""; + *(d->path) = ""; + } + d->pathless_stroke = false; d->inpath = true; break; } -- cgit v1.2.3 From f4c59e50df9090a1a4801da06f9a0021b67ce7a2 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop <mail@diedenrezi.nl> Date: Sat, 8 Oct 2011 22:00:37 +0200 Subject: 1) make snapping to clip/mask paths optional (see document properties dialog -> snap tab) 2) for debugging purposes: code added for showing all snap candidates 3) groundwork for tangential/perpendicular snapping (bzr r10672) --- src/2geom/sbasis-geometric.cpp | 2 +- src/attributes-test.h | 2 ++ src/attributes.cpp | 2 ++ src/attributes.h | 2 ++ src/display/snap-indicator.cpp | 35 +++++++++++++++++++++++++++++++++++ src/display/snap-indicator.h | 4 ++++ src/draw-context.cpp | 4 ++-- src/draw-context.h | 2 +- src/object-snapper.cpp | 28 +++++++++++++++++++++++----- src/pen-context.cpp | 6 ++++-- src/pencil-context.cpp | 7 +++++-- src/snap-candidate.h | 15 +++++++++++++++ src/snap-enums.h | 2 ++ src/snap-preferences.cpp | 5 ++++- src/snap.cpp | 24 ++++++++++++++++++++++++ src/snap.h | 8 ++++++-- src/sp-namedview.cpp | 10 ++++++++++ src/ui/dialog/document-properties.cpp | 9 +++++++-- src/ui/dialog/document-properties.h | 2 ++ src/widgets/toolbox.cpp | 8 ++++++++ 20 files changed, 159 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp index f4b445faa..7d7ed23e4 100644 --- a/src/2geom/sbasis-geometric.cpp +++ b/src/2geom/sbasis-geometric.cpp @@ -749,7 +749,7 @@ Geom::cubics_with_prescribed_curvature(Point const &M0, Point const &M1, * \brief returns all the parameter values of A whose tangent passes through P. * \relates D2 */ -std::vector<double> find_tangents(Point P, D2<SBasis> const &A) { +std::vector<double> Geom::find_tangents(Point P, D2<SBasis> const &A) { SBasis crs (cross(A - P, derivative(A))); crs = shift(crs*Linear(-1, 0)*Linear(-1, 0), -2); // We know that there is a double root at t=0 so we divide out t^2 // JFB points out that this is equivalent to (t-1)^2 followed by a divide by s^2 (shift) diff --git a/src/attributes-test.h b/src/attributes-test.h index 02b53defc..ec2b0c6af 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -342,6 +342,8 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"sodipodi:version", false}, {"inkscape:version", true}, {"inkscape:object-paths", true}, + {"inkscape:snap-path-clip", true}, + {"inkscape:snap-path-mask", true}, {"inkscape:object-nodes", true}, {"inkscape:bbox-paths", true}, {"inkscape:bbox-nodes", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index 4552adb63..34312ebe8 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -106,6 +106,8 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT, "inkscape:snap-bbox-midpoints"}, {SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION, "inkscape:snap-intersection-paths"}, {SP_ATTR_INKSCAPE_SNAP_PATH, "inkscape:object-paths"}, + {SP_ATTR_INKSCAPE_SNAP_PATH_CLIP, "inkscape:snap-path-clip"}, + {SP_ATTR_INKSCAPE_SNAP_PATH_MASK, "inkscape:snap-path-mask"}, {SP_ATTR_INKSCAPE_SNAP_NODE_CUSP, "inkscape:object-nodes"}, {SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE, "inkscape:bbox-paths"}, {SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER, "inkscape:bbox-nodes"}, diff --git a/src/attributes.h b/src/attributes.h index 261871482..7a1dc559f 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -107,6 +107,8 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT, SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION, SP_ATTR_INKSCAPE_SNAP_PATH, + SP_ATTR_INKSCAPE_SNAP_PATH_CLIP, + SP_ATTR_INKSCAPE_SNAP_PATH_MASK, SP_ATTR_INKSCAPE_SNAP_NODE_CUSP, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE, SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER, diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 0f31a24b9..72fdfbee7 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -105,6 +105,12 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_PATH_GUIDE_INTERSECTION: target_name = _("guide-path intersection"); break; + case SNAPTARGET_PATH_CLIP: + target_name = _("clip-path"); + break; + case SNAPTARGET_PATH_MASK: + target_name = _("mask-path"); + break; case SNAPTARGET_BBOX_CORNER: target_name = _("bounding box corner"); break; @@ -325,6 +331,25 @@ SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p) } } +void +SnapIndicator::set_new_debugging_point(Geom::Point const &p) +{ + g_assert(_desktop != NULL); + SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (_desktop), + SP_TYPE_CTRL, + "anchor", GTK_ANCHOR_CENTER, + "size", 10.0, + "fill_color", 0x00ff00ff, + "stroked", FALSE, + "mode", SP_KNOT_MODE_XOR, + "shape", SP_KNOT_SHAPE_DIAMOND, + NULL ); + + SP_CTRL(canvasitem)->moveto(p); + _debugging_points.push_back(_desktop->add_temporary_canvasitem(canvasitem, 5000)); + +} + void SnapIndicator::remove_snapsource() { @@ -334,6 +359,16 @@ SnapIndicator::remove_snapsource() } } +void +SnapIndicator::remove_debugging_points() +{ + for (std::list<TemporaryItem *>::const_iterator i = _debugging_points.begin(); i != _debugging_points.end(); i++) { + _desktop->remove_temporary_canvasitem(*i); + } + _debugging_points.clear(); +} + + } //namespace Display } /* namespace Inkscape */ diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index ff08a8a8c..da66d0033 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -34,11 +34,15 @@ public: void set_new_snapsource(Inkscape::SnapCandidatePoint const &p); void remove_snapsource(); + void set_new_debugging_point(Geom::Point const &p); + void remove_debugging_points(); + protected: TemporaryItem *_snaptarget; TemporaryItem *_snaptarget_tooltip; TemporaryItem *_snaptarget_bbox; TemporaryItem *_snapsource; + std::list<TemporaryItem *> _debugging_points; bool _snaptarget_is_presnap; SPDesktop *_desktop; diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 5d324754f..ebc6e320f 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -501,7 +501,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, } -void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, guint const /*state*/) +void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_point, guint const /*state*/) { SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(ec); SnapManager &m = dt->namedview->snap_manager; @@ -511,7 +511,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, gu // TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment m.setup(dt, true, selection->singleItem()); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE, start_point); m.unSetup(); } diff --git a/src/draw-context.h b/src/draw-context.h index 53114d820..a6762bed4 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -85,7 +85,7 @@ GType sp_draw_context_get_type(void); SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p); void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed); void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o, guint state); -void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, guint state); +void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, boost::optional<Geom::Point> &start_point, guint state); void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item); void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 7e0961c95..b14415c47 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -78,6 +78,7 @@ bool Inkscape::ObjectSnapper::getSnapperAlwaysSnap() const * \param parent Pointer to the document's root, or to a clipped path or mask object * \param it List of items to ignore * \param bbox_to_snap Bounding box hulling the whole bunch of points, all from the same selection and having the same transformation + * \param clip_or_mask The parent object being passed is either a clip or mask */ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, @@ -88,7 +89,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, Geom::Affine const additional_affine) const // transformation of the item being clipped / masked { if (_snapmanager->getDesktop() == NULL) { - g_warning("desktop == NULL, so we cannot snap; please inform the developpers of this bug"); + g_warning("desktop == NULL, so we cannot snap; please inform the developers of this bug"); // Apparently the setup() method from the SnapManager class hasn't been called before trying to snap. } @@ -122,11 +123,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, // still be the subject of clipping or masking itself ; if so, then // we should also consider that path or mask for snapping to obj = SP_OBJECT(item->clip_ref->getObject()); - if (obj) { + if (obj && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_CLIP)) { _findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine()); } obj = SP_OBJECT(item->mask_ref->getObject()); - if (obj) { + if (obj && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_MASK)) { _findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine()); } } @@ -506,6 +507,7 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr, bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); + //_snapmanager->getDesktop()->snapindicator->remove_debugging_points(); for (std::vector<SnapCandidatePath >::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { if (_allowSourceToSnapToTarget(p.getSourceType(), (*it_p).target_type, strict_snapping)) { bool const being_edited = node_tool_active && (*it_p).currently_being_edited; @@ -516,12 +518,14 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr, // n curves will return n time values with 0 <= t <= 1 std::vector<double> anp = (*it_pv).nearestPointPerCurve(p_doc); + //std::cout << "#nearest points = " << anp.size() << " | p = " << p.getPoint() << std::endl; + // Now we will examine each of the nearest points, and determine whether it's within snapping range and if we should snap to it std::vector<double>::const_iterator np = anp.begin(); unsigned int index = 0; for (; np != anp.end(); np++, index++) { Geom::Curve const *curve = &((*it_pv).at_index(index)); Geom::Point const sp_doc = curve->pointAt(*np); - + //_snapmanager->getDesktop()->snapindicator->set_new_debugging_point(sp_doc*_snapmanager->getDesktop()->doc2dt()); bool c1 = true; bool c2 = true; if (being_edited) { @@ -546,9 +550,23 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr, Geom::Point const sp_dt = _snapmanager->getDesktop()->doc2dt(sp_doc); if (!being_edited || (c1 && c2)) { - Geom::Coord const dist = Geom::distance(sp_doc, p_doc); + Geom::Coord dist = Geom::distance(sp_doc, p_doc); + // std::cout << " dist -> " << dist << std::endl; if (dist < getSnapperTolerance()) { + // Add the curve we have snapped to isr.curves.push_back(SnappedCurve(sp_dt, num_path, index, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + // Find all tangential points +// boost::optional<Geom::Point> origin = p.getStartingPoint(); +// if (origin) { +// Geom::Point origin_doc = _snapmanager->getDesktop()->dt2doc(*origin); +// std::vector<double> atp = find_tangents(origin_doc, curve->toSBasis()); +// for (std::vector<double>::const_iterator t = atp.begin(); t != atp.end(); t++) { +// Geom::Point const tp_doc = curve->pointAt(*t); +// dist = Geom::distance(tp_doc, p_doc); +// Geom::Point const tp_dt = _snapmanager->getDesktop()->doc2dt(tp_doc); +// isr.points.push_back(SnappedPoint(tp_dt, p.getSourceType(), p.getSourceNum(), it_p->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, it_p->target_bbox)); +// } +// } } } } diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 19e0351a3..2be2fd87b 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -311,7 +311,8 @@ spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const sta pen_set_to_nearest_horiz_vert(pc, p, state, true); } else { // snap freely - spdc_endpoint_snap_free(pc, p, state); + boost::optional<Geom::Point> origin = pc->npoints > 0 ? pc->p[0] : boost::optional<Geom::Point>(); + spdc_endpoint_snap_free(pc, p, origin, state); // pass the origin, to allow for perpendicular / tangential snapping } } } @@ -329,7 +330,8 @@ spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint co spdc_endpoint_snap_rotation(pc, p, pc->p[pc->npoints - 2], state); } else { if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above - spdc_endpoint_snap_free(pc, p, state); + boost::optional<Geom::Point> origin = pc->p[pc->npoints - 2]; + spdc_endpoint_snap_free(pc, p, origin, state); } } } diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index d823c1daa..d67833a91 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -166,12 +166,15 @@ static void spdc_endpoint_snap(SPPencilContext const *pc, Geom::Point &p, guint const state) { if ((state & GDK_CONTROL_MASK)) { //CTRL enables constrained snapping - spdc_endpoint_snap_rotation(pc, p, pc->p[0], state); + if (pc->npoints > 0) { + spdc_endpoint_snap_rotation(pc, p, pc->p[0], state); + } } else { if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above //After all, the user explicitely asked for angular snapping by //pressing CTRL - spdc_endpoint_snap_free(pc, p, state); + boost::optional<Geom::Point> origin = pc->npoints > 0 ? pc->p[0] : boost::optional<Geom::Point>(); + spdc_endpoint_snap_free(pc, p, origin, state); } } } diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 236f2497d..43082c010 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -31,6 +31,7 @@ public: _source_num(source_num), _target_bbox(bbox) { + _line_starting_point = boost::optional<Geom::Point>(); }; SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, Inkscape::SnapTargetType const target) @@ -40,6 +41,7 @@ public: { _source_num = -1; _target_bbox = Geom::OptRect(); + _line_starting_point = boost::optional<Geom::Point>(); } SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source) @@ -49,6 +51,17 @@ public: _source_num(-1) { _target_bbox = Geom::OptRect(); + _line_starting_point = boost::optional<Geom::Point>(); + } + + SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, boost::optional<Geom::Point> starting_point) + : _point(point), + _source_type(source), + _target_type(Inkscape::SNAPTARGET_UNDEFINED), + _source_num(-1) + { + _target_bbox = Geom::OptRect(); + _line_starting_point = starting_point; } inline Geom::Point const & getPoint() const {return _point;} @@ -58,10 +71,12 @@ public: inline long getSourceNum() const {return _source_num;} void setSourceNum(long num) {_source_num = num;} inline Geom::OptRect const getTargetBBox() const {return _target_bbox;} + boost::optional<Geom::Point> const & getStartingPoint() const {return _line_starting_point;} private: // Coordinates of the point Geom::Point _point; + boost::optional<Geom::Point> _line_starting_point; // For perpendicular or tangential snapping we need to know the starting point of a line // If this SnapCandidatePoint is a snap source, then _source_type must be defined. If it // is a snap target, then _target_type must be defined. If it's yet unknown whether it will diff --git a/src/snap-enums.h b/src/snap-enums.h index 5ade54354..d28f11314 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -70,6 +70,8 @@ enum SnapTargetType { SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_PATH_GUIDE_INTERSECTION, + SNAPTARGET_PATH_CLIP, + SNAPTARGET_PATH_MASK, SNAPTARGET_ELLIPSE_QUADRANT_POINT, // this corner is at the center of the stroke SNAPTARGET_RECT_CORNER, // of a rectangle, so this corner is at the center of the stroke //------------------------------------------------------------------- diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 250f38b90..b3a95877f 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -151,7 +151,6 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType target = SNAPTARGET_PATH_INTERSECTION; } - } else if (target & SNAPTARGET_DATUMS_CATEGORY) { group_on = true; // These snap targets cannot be disabled as part of a disabled group; switch (target) { @@ -257,6 +256,8 @@ bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const if (_active_snap_targets[index] == -1) { // Catch coding errors g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index); + // This happens if setTargetSnappable() has not been called for this parameter, e.g. from within sp_namedview_set, + // or if this target index doesn't exist at all } return _active_snap_targets[index]; } @@ -292,6 +293,8 @@ bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType con if (_active_snap_targets[index] == -1) { // Catch coding errors g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index); + // This happens if setTargetSnappable() has not been called for this parameter, e.g. from within sp_namedview_set, + // or if this target index doesn't exist at all } else { if (index == target) { // I.e. if it has not been re-mapped, then we have a primary target at hand, which does have its own toggle button return _active_snap_targets[index]; diff --git a/src/snap.cpp b/src/snap.cpp index fb6f120ec..56b48d507 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -180,6 +180,13 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, s.getPointIfSnapped(p); } +void SnapManager::freeSnapReturnByRef(Geom::Point &p, + Inkscape::SnapSourceType const source_type, + boost::optional<Geom::Point> &starting_point) const +{ + Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type, starting_point), Geom::OptRect()); + s.getPointIfSnapped(p); +} /** * Try to snap a point to grids, guides or objects. @@ -1136,6 +1143,23 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co std::cout << " Curves : " << isr.curves.size()<< std::endl; */ + /* + // Display all snap candidates on the canvas + _desktop->snapindicator->remove_debugging_points(); + for (std::list<Inkscape::SnappedPoint>::const_iterator i = isr.points.begin(); i != isr.points.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + for (std::list<Inkscape::SnappedCurve>::const_iterator i = isr.curves.begin(); i != isr.curves.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + for (std::list<Inkscape::SnappedLine>::const_iterator i = isr.grid_lines.begin(); i != isr.grid_lines.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + for (std::list<Inkscape::SnappedLine>::const_iterator i = isr.guide_lines.begin(); i != isr.guide_lines.end(); i++) { + _desktop->snapindicator->set_new_debugging_point((*i).getPoint()); + } + */ + // Store all snappoints std::list<Inkscape::SnappedPoint> sp_list; diff --git a/src/snap.h b/src/snap.h index 8fefa1cf2..41cbd0a02 100644 --- a/src/snap.h +++ b/src/snap.h @@ -114,8 +114,12 @@ public: // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a // point if snapping has occurred (by overwriting p); otherwise p is untouched void freeSnapReturnByRef(Geom::Point &p, - Inkscape::SnapSourceType const source_type, - Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const; + Inkscape::SnapSourceType const source_type, + Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const; + + void freeSnapReturnByRef(Geom::Point &p, + Inkscape::SnapSourceType const source_type, + boost::optional<Geom::Point> &starting_point) const; Inkscape::SnappedPoint freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap = Geom::OptRect() ) const; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index e94a02265..c7d212d23 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -265,6 +265,8 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: object->readAttr( "inkscape:snap-grids" ); object->readAttr( "inkscape:snap-intersection-paths" ); object->readAttr( "inkscape:object-paths" ); + object->readAttr( "inkscape:snap-path-clip" ); + object->readAttr( "inkscape:snap-path-mask" ); object->readAttr( "inkscape:object-nodes" ); object->readAttr( "inkscape:bbox-paths" ); object->readAttr( "inkscape:bbox-nodes" ); @@ -515,6 +517,14 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_INKSCAPE_SNAP_PATH_CLIP: + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_CLIP, value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + case SP_ATTR_INKSCAPE_SNAP_PATH_MASK: + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_MASK, value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index d3123345b..9f8a99b1f 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -105,8 +105,10 @@ DocumentProperties::DocumentProperties() _grids_label_crea("", Gtk::ALIGN_LEFT), _grids_button_new(C_("Grid", "_New"), _("Create new grid.")), _grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")), - _grids_label_def("", Gtk::ALIGN_LEFT) + _grids_label_def("", Gtk::ALIGN_LEFT), //--------------------------------------------------------------- + _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr), + _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr) { _tt.enable(); _getContents()->set_spacing (4); @@ -292,6 +294,8 @@ DocumentProperties::build_snap() { label_o, 0, 0, _rsu_sno._vbox, + 0, &_rcb_snclp, + 0, &_rcb_snmsk, 0, 0, label_gr, 0, 0, _rsu_sn._vbox, @@ -1018,7 +1022,8 @@ void DocumentProperties::update() _rsu_sno.setValue (nv->snap_manager.snapprefs.getObjectTolerance()); _rsu_sn.setValue (nv->snap_manager.snapprefs.getGridTolerance()); _rsu_gusn.setValue (nv->snap_manager.snapprefs.getGuideTolerance()); - + _rcb_snclp.setActive (nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_CLIP)); + _rcb_snmsk.setActive (nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_MASK)); //-----------------------------------------------------------grids page diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 261287877..8f922d6fd 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -112,6 +112,8 @@ protected: UI::Widget::ToleranceSlider _rsu_sno; UI::Widget::ToleranceSlider _rsu_sn; UI::Widget::ToleranceSlider _rsu_gusn; + UI::Widget::RegisteredCheckButton _rcb_snclp; + UI::Widget::RegisteredCheckButton _rcb_snmsk; //--------------------------------------------------------------- Gtk::Menu _menu; Gtk::OptionMenu _combo_avail; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 6ec393c2c..afd066b37 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2153,6 +2153,14 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); sp_repr_set_boolean(repr, "inkscape:object-paths", !v); break; + case SP_ATTR_INKSCAPE_SNAP_PATH_CLIP: + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_CLIP); + sp_repr_set_boolean(repr, "inkscape:snap-path-clip", !v); + break; + case SP_ATTR_INKSCAPE_SNAP_PATH_MASK: + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_MASK); + sp_repr_set_boolean(repr, "inkscape:snap-path-mask", !v); + break; case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP); sp_repr_set_boolean(repr, "inkscape:object-nodes", !v); -- cgit v1.2.3 From 4b81b6cce7f299433add1815470732a013710342 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sat, 8 Oct 2011 17:34:23 +1100 Subject: update cmake file lists (bzr r10673) --- src/CMakeLists.txt | 1 - src/display/CMakeLists.txt | 31 +++++++++++++++---------------- src/extension/CMakeLists.txt | 1 - src/helper/CMakeLists.txt | 1 - src/libnrtype/CMakeLists.txt | 1 - src/livarot/CMakeLists.txt | 1 - src/xml/CMakeLists.txt | 1 - 7 files changed, 15 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 57d935275..6d68e2caa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -354,7 +354,6 @@ set(inkscape_SRC filter-chemistry.h filter-enums.h flood-context.h - forward.h gc-alloc.h gc-allocator.h gc-anchored.h diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 68006eb75..7b188b286 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -10,13 +10,13 @@ set(display_SRC canvas-text.cpp curve.cpp drawing-context.cpp - drawing-group.cpp - drawing-image.cpp - drawing-item.cpp - drawing-shape.cpp - drawing-surface.cpp - drawing-text.cpp - drawing.cpp + drawing-group.cpp + drawing-image.cpp + drawing-item.cpp + drawing-shape.cpp + drawing-surface.cpp + drawing-text.cpp + drawing.cpp gnome-canvas-acetate.cpp grayscale.cpp guideline.cpp @@ -70,15 +70,14 @@ set(display_SRC canvas-text.h curve-test.h curve.h - display-forward.h - drawing-context.h - drawing-group.h - drawing-image.h - drawing-item.h - drawing-shape.h - drawing-surface.h - drawing-text.h - drawing.h + drawing-context.h + drawing-group.h + drawing-image.h + drawing-item.h + drawing-shape.h + drawing-surface.h + drawing-text.h + drawing.h gnome-canvas-acetate.h grayscale.h guideline.h diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index ba1b084af..5761b1e8b 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -79,7 +79,6 @@ set(extension_SRC effect.h error-file.h execution-env.h - extension-forward.h extension.h init.h input.h diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index 1d6a82e41..b59cf03ba 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -33,7 +33,6 @@ set(helper_SRC geom-nodetype.h geom.h gnome-utils.h - helper-forward.h pixbuf-ops.h png-write.h recthull.h diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 1b28eb8e4..84979d7ea 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -29,7 +29,6 @@ set(nrtype_SRC font-style.h nr-type-pos-def.h nr-type-primitives.h - nrtype-forward.h one-box.h one-glyph.h one-para.h diff --git a/src/livarot/CMakeLists.txt b/src/livarot/CMakeLists.txt index 83e0f40c8..f1b83f30e 100644 --- a/src/livarot/CMakeLists.txt +++ b/src/livarot/CMakeLists.txt @@ -33,7 +33,6 @@ set(livarot_SRC Shape.h float-line.h int-line.h - livarot-forward.h path-description.h sweep-event-queue.h sweep-event.h diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index 4f86599de..2a9789384 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -49,7 +49,6 @@ set(xml_SRC sp-css-attr.h subtree.h text-node.h - xml-forward.h ) # add_inkscape_lib(xml_LIB "${xml_SRC}") -- cgit v1.2.3 From 5ff7f53cc60781dfb7dcb0cd7cb5cea190b42b6f Mon Sep 17 00:00:00 2001 From: Alvin Penner <penner@vaxxine.com> Date: Sun, 9 Oct 2011 15:04:16 -0400 Subject: modify scaling of vertical offset for text placement (Bug 868594) Fixed bugs: - https://launchpad.net/bugs/868594 (bzr r10674) --- src/extension/internal/emf-win32-inout.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index f66209479..ceebc2727 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -1837,16 +1837,16 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * y1 = d->dc[d->level].cur.y; } + double x = pix_to_x_point(d, x1, y1); + double y = pix_to_y_point(d, x1, y1); + if (!(d->dc[d->level].textAlign & TA_BOTTOM)) if (d->dc[d->level].style.baseline_shift.value) { - x1 += std::sin(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed); - y1 += std::cos(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed); + x += std::sin(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed); + y += std::cos(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed); } else - y1 += fabs(d->dc[d->level].style.font_size.computed); - - double x = pix_to_x_point(d, x1, y1); - double y = pix_to_y_point(d, x1, y1); + y += fabs(d->dc[d->level].style.font_size.computed); wchar_t *wide_text = (wchar_t *) ((char *) pEmr + pEmr->emrtext.offString); -- cgit v1.2.3 From 5feadccf4874e67e126c5133b3ba06b53c01c609 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop <mail@diedenrezi.nl> Date: Wed, 12 Oct 2011 23:23:51 +0200 Subject: Object snapper: only use the visual bounding box when absolutely needed; otherwise default to geometric bounding box (bzr r10675) --- src/object-snapper.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index b14415c47..68e63a0c1 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -137,13 +137,19 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine); } else { Geom::OptRect bbox_of_item; + Preferences *prefs = Preferences::get(); + int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); + // We'll only need to obtain the visual bounding box if the user preferences tell + // us to, AND if we are snapping to the bounding box itself. If we're snapping to + // paths only, then we can just as well use the geometric bounding box (which is faster) + SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.getSnapModeBBox()) ? + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; if (clip_or_mask) { // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine) - bbox_of_item = item->visualBounds(item->i2doc_affine() * additional_affine * - _snapmanager->getDesktop()->doc2dt()); + bbox_of_item = item->bounds(bbox_type, item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt()); } else { - bbox_of_item = item->desktopVisualBounds(); + bbox_of_item = item->bounds(bbox_type); } if (bbox_of_item) { // See if the item is within range -- cgit v1.2.3 From c3790882a616125eebcd488db9f08e5388b82d9e Mon Sep 17 00:00:00 2001 From: Diederik van Lierop <mail@diedenrezi.nl> Date: Sat, 15 Oct 2011 14:36:28 +0200 Subject: Use desktop coordinates for finding snap candidates (regression introduced in rev. #10675) Fixed bugs: - https://launchpad.net/bugs/874213 (bzr r10677) --- src/object-snapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 68e63a0c1..bf8cf166a 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -149,7 +149,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine) bbox_of_item = item->bounds(bbox_type, item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt()); } else { - bbox_of_item = item->bounds(bbox_type); + bbox_of_item = item->desktopBounds(bbox_type); } if (bbox_of_item) { // See if the item is within range @@ -183,7 +183,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, bool p_is_a_node = t & SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = t & SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & SNAPSOURCE_OTHERS_CATEGORY || t & SNAPSOURCE_DATUMS_CATEGORY; + bool p_is_other = (t & SNAPSOURCE_OTHERS_CATEGORY) || (t & SNAPSOURCE_DATUMS_CATEGORY); // A point considered for snapping should be either a node, a bbox corner or a guide/other. Pick only ONE! if (((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))) { @@ -373,7 +373,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, bool p_is_a_node = source_type & SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = source_type & SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = source_type & SNAPSOURCE_OTHERS_CATEGORY || source_type & SNAPSOURCE_DATUMS_CATEGORY; + bool p_is_other = (source_type & SNAPSOURCE_OTHERS_CATEGORY) || (source_type & SNAPSOURCE_DATUMS_CATEGORY); if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE)) { Preferences *prefs = Preferences::get(); -- cgit v1.2.3 From 47b55c0d9fccf3994f86fd764cefca3a2f734dbe Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 15 Oct 2011 22:03:44 +0200 Subject: cppcheck (bzr r10678) --- src/color-rgba.h | 4 ++-- src/composite-undo-stack-observer.cpp | 4 ++-- src/display/curve.cpp | 8 ++++---- src/display/snap-indicator.cpp | 2 +- src/extension/db.cpp | 2 +- src/extension/execution-env.cpp | 2 +- src/extension/implementation/script.cpp | 2 +- src/extension/internal/bluredge.cpp | 2 +- src/extension/internal/cairo-render-context.cpp | 2 +- src/extension/internal/odf.cpp | 12 ++++++------ src/livarot/Shape.h | 2 +- src/main-cmdlineact.cpp | 4 ++-- src/selcue.cpp | 8 ++++---- src/snapped-curve.cpp | 16 ++++++++-------- src/snapped-point.cpp | 2 +- 15 files changed, 36 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/color-rgba.h b/src/color-rgba.h index 8c21d5e52..543ef5926 100644 --- a/src/color-rgba.h +++ b/src/color-rgba.h @@ -111,7 +111,7 @@ public: Check each value to see if they are equal. If they all are, return TRUE. */ - bool operator== (const ColorRGBA other) const { + bool operator== (const ColorRGBA &other) const { for (int i = 0; i < 4; i++) { if (_c[i] != other[i]) return false; @@ -135,7 +135,7 @@ public: value are multiplied by 1.0 - weight and the second object by weight. This means that they should always be balanced by the parameter. */ - ColorRGBA average (const ColorRGBA second, const float weight = 0.5) const { + ColorRGBA average (const ColorRGBA &second, const float weight = 0.5) const { float returnval[4]; for (int i = 0; i < 4; i++) { diff --git a/src/composite-undo-stack-observer.cpp b/src/composite-undo-stack-observer.cpp index 03e4796bd..6af34d92a 100644 --- a/src/composite-undo-stack-observer.cpp +++ b/src/composite-undo-stack-observer.cpp @@ -139,14 +139,14 @@ CompositeUndoStackObserver::_unlock() if (!--this->_iterating) { // Remove marked observers UndoObserverRecordList::iterator i = this->_active.begin(); - for(; i != this->_active.begin(); i++) { + for(; i != this->_active.begin(); ++i) { if (i->to_remove) { this->_active.erase(i); } } i = this->_pending.begin(); - for(; i != this->_pending.begin(); i++) { + for(; i != this->_pending.begin(); ++i) { if (i->to_remove) { this->_active.erase(i); } diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 5c18324eb..d52ee1fba 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -322,7 +322,7 @@ SPCurve::is_closed() const return false; } else { bool closed = true; - for (Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); it++) { + for (Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { if ( ! it->closed() ) { closed = false; break; @@ -506,11 +506,11 @@ SPCurve::append(SPCurve const *curve2, _pathv.push_back( (*it) ); } - for (it++; it != curve2->_pathv.end(); it++) { + for (it++; it != curve2->_pathv.end(); ++it) { _pathv.push_back( (*it) ); } } else { - for (Geom::PathVector::const_iterator it = curve2->_pathv.begin(); it != curve2->_pathv.end(); it++) { + for (Geom::PathVector::const_iterator it = curve2->_pathv.begin(); it != curve2->_pathv.end(); ++it) { _pathv.push_back( (*it) ); } } @@ -553,7 +553,7 @@ SPCurve::append_continuous(SPCurve const *c1, gdouble tolerance) newfirstpath.setInitial(lastpath.finalPoint()); lastpath.append( newfirstpath ); - for (path_it++; path_it != c1->_pathv.end(); path_it++) { + for (++path_it; path_it != c1->_pathv.end(); ++path_it) { _pathv.push_back( (*path_it) ); } diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 72fdfbee7..e542d0c88 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -362,7 +362,7 @@ SnapIndicator::remove_snapsource() void SnapIndicator::remove_debugging_points() { - for (std::list<TemporaryItem *>::const_iterator i = _debugging_points.begin(); i != _debugging_points.end(); i++) { + for (std::list<TemporaryItem *>::const_iterator i = _debugging_points.begin(); i != _debugging_points.end(); ++i) { _desktop->remove_temporary_canvasitem(*i); } _debugging_points.clear(); diff --git a/src/extension/db.cpp b/src/extension/db.cpp index 342a18b84..a3c54915d 100644 --- a/src/extension/db.cpp +++ b/src/extension/db.cpp @@ -109,7 +109,7 @@ DB::foreach (void (*in_func)(Extension * in_plug, gpointer in_data), gpointer in { std::list <Extension *>::iterator cur; - for (cur = modulelist.begin(); cur != modulelist.end(); cur++) { + for (cur = modulelist.begin(); cur != modulelist.end(); ++cur) { // printf("foreach: %s\n", (*cur)->get_id()); in_func((*cur), in_data); } diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index b05685902..646caa36a 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -193,7 +193,7 @@ ExecutionEnv::reselect (void) { Inkscape::Selection * selection = sp_desktop_selection(desktop); - for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); i++) { + for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); ++i) { SPObject * obj = doc->getObjectById(i->c_str()); if (obj != NULL) { selection->add(obj); diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e4d850e5f..ca9c094db 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -821,7 +821,7 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr } // Delete the attributes of the old root nodes. - for (std::vector<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); it++) { + for (std::vector<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); ++it) { oldroot->setAttribute(*it, NULL); } diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 76582ab05..3d4754adc 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -68,7 +68,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View selection->clear(); for(std::list<SPItem *>::iterator item = items.begin(); - item != items.end(); item++) { + item != items.end(); ++item) { SPItem * spitem = *item; std::vector<Inkscape::XML::Node *> new_items(steps); diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 584942c4f..b8e924926 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1473,7 +1473,7 @@ unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/, unsigned int num_invalid_glyphs = 0; unsigned int i = 0; // is a counter for indexing the glyphs array, only counts the valid glyphs - for (std::vector<CairoGlyphInfo>::const_iterator it_info = glyphtext.begin() ; it_info != glyphtext.end() ; it_info++) { + for (std::vector<CairoGlyphInfo>::const_iterator it_info = glyphtext.begin() ; it_info != glyphtext.end() ; ++it_info) { // skip glyphs which are PANGO_GLYPH_EMPTY (0x0FFFFFFF) // or have the PANGO_GLYPH_UNKNOWN_FLAG (0x10000000) set if (it_info->index == 0x0FFFFFFF || it_info->index & 0x10000000) { diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 735c57798..2c6a1a80b 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1161,7 +1161,7 @@ bool OdfOutput::writeManifest(ZipFile &zf) outs.printf(" <manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"meta.xml\"/>\n"); outs.printf(" <!--List our images here-->\n"); std::map<Glib::ustring, Glib::ustring>::iterator iter; - for (iter = imageTable.begin() ; iter!=imageTable.end() ; iter++) + for (iter = imageTable.begin() ; iter!=imageTable.end() ; ++iter) { Glib::ustring oldName = iter->first; Glib::ustring newName = iter->second; @@ -1241,7 +1241,7 @@ bool OdfOutput::writeMeta(ZipFile &zf) outs.printf(" <meta:initial-creator>%#s</meta:initial-creator>\n", creator.c_str()); outs.printf(" <meta:creation-date>%#s</meta:creation-date>\n", date.c_str()); - for (iter = metadata.begin() ; iter != metadata.end() ; iter++) + for (iter = metadata.begin() ; iter != metadata.end() ; ++iter) { Glib::ustring name = iter->first; Glib::ustring value = iter->second; @@ -1303,7 +1303,7 @@ bool OdfOutput::writeStyle(ZipFile &zf) */ outs.printf("<!-- ####### Styles from Inkscape document ####### -->\n"); std::vector<StyleInfo>::iterator iter; - for (iter = styleTable.begin() ; iter != styleTable.end() ; iter++) + for (iter = styleTable.begin() ; iter != styleTable.end() ; ++iter) { outs.printf("<style:style style:name=\"%s\"", iter->name.c_str()); StyleInfo s(*iter); @@ -1331,7 +1331,7 @@ bool OdfOutput::writeStyle(ZipFile &zf) outs.printf("\n"); outs.printf("<!-- ####### Gradients from Inkscape document ####### -->\n"); std::vector<GradientInfo>::iterator giter; - for (giter = gradientTable.begin() ; giter != gradientTable.end() ; giter++) + for (giter = gradientTable.begin() ; giter != gradientTable.end() ; ++giter) { GradientInfo gi(*giter); if (gi.style == "linear") @@ -1583,7 +1583,7 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item, //Look for existing identical style; bool styleMatch = false; std::vector<StyleInfo>::iterator iter; - for (iter=styleTable.begin() ; iter!=styleTable.end() ; iter++) + for (iter=styleTable.begin() ; iter!=styleTable.end() ; ++iter) { if (si.equals(*iter)) { @@ -1701,7 +1701,7 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item, //Look for existing identical style; bool gradientMatch = false; std::vector<GradientInfo>::iterator iter; - for (iter=gradientTable.begin() ; iter!=gradientTable.end() ; iter++) + for (iter=gradientTable.begin() ; iter!=gradientTable.end() ; ++iter) { if (gi.equals(*iter)) { diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index 5077a6da1..1a804a48c 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -317,7 +317,7 @@ public: void QuickScan(float &pos, int &curP, float to, AlphaLigne* line, float step); void Transform(Geom::Affine const &tr) - {for(std::vector<dg_point>::iterator it=_pts.begin();it!=_pts.end();it++) it->x*=tr;} + {for(std::vector<dg_point>::iterator it=_pts.begin();it!=_pts.end();++it) it->x*=tr;} std::vector<back_data> ebData; std::vector<voronoi_point> vorpData; diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index dc59e1a93..9f700292e 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -71,7 +71,7 @@ CmdLineAction::doIt (Inkscape::UI::View::View * view) { void CmdLineAction::doList (Inkscape::UI::View::View * view) { for (std::list<CmdLineAction *>::iterator i = _list.begin(); - i != _list.end(); i++) { + i != _list.end(); ++i) { CmdLineAction * entry = *i; entry->doIt(view); } @@ -85,7 +85,7 @@ CmdLineAction::idle (void) { // We're going to assume one desktop per document, because no one // should have had time to make more at this point. for (std::list<SPDesktop *>::iterator i = desktops.begin(); - i != desktops.end(); i++) { + i != desktops.end(); ++i) { SPDesktop * desktop = *i; //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop); doList(desktop); diff --git a/src/selcue.cpp b/src/selcue.cpp index dbcaf4cc3..676031802 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -46,12 +46,12 @@ Inkscape::SelCue::~SelCue() _sel_changed_connection.disconnect(); _sel_modified_connection.disconnect(); - for (std::vector<SPCanvasItem*>::iterator i = _item_bboxes.begin(); i != _item_bboxes.end(); i++) { + for (std::vector<SPCanvasItem*>::iterator i = _item_bboxes.begin(); i != _item_bboxes.end(); ++i) { gtk_object_destroy(*i); } _item_bboxes.clear(); - for (std::vector<SPCanvasItem*>::iterator i = _text_baselines.begin(); i != _text_baselines.end(); i++) { + for (std::vector<SPCanvasItem*>::iterator i = _text_baselines.begin(); i != _text_baselines.end(); ++i) { gtk_object_destroy(*i); } _text_baselines.clear(); @@ -103,7 +103,7 @@ void Inkscape::SelCue::_updateItemBboxes() void Inkscape::SelCue::_newItemBboxes() { - for (std::vector<SPCanvasItem*>::iterator i = _item_bboxes.begin(); i != _item_bboxes.end(); i++) { + for (std::vector<SPCanvasItem*>::iterator i = _item_bboxes.begin(); i != _item_bboxes.end(); ++i) { gtk_object_destroy(*i); } _item_bboxes.clear(); @@ -166,7 +166,7 @@ void Inkscape::SelCue::_newItemBboxes() void Inkscape::SelCue::_newTextBaselines() { - for (std::vector<SPCanvasItem*>::iterator i = _text_baselines.begin(); i != _text_baselines.end(); i++) { + for (std::vector<SPCanvasItem*>::iterator i = _text_baselines.begin(); i != _text_baselines.end(); ++i) { gtk_object_destroy(*i); } _text_baselines.clear(); diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index 493925d48..8fdf1d46f 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -69,7 +69,7 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur // There might be multiple intersections: find the closest Geom::Coord best_dist = Geom::infinity(); Geom::Point best_p = Geom::Point(Geom::infinity(), Geom::infinity()); - for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { + for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) { Geom::Point p_ix = this->_curve->pointAt((*i).ta); Geom::Coord dist = Geom::distance(p_ix, p); @@ -130,7 +130,7 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedLine const &line // There might be multiple intersections: find the closest Geom::Coord best_dist = Geom::infinity(); Geom::Point best_p = Geom::Point(Geom::infinity(), Geom::infinity()); - for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { + for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) { Geom::Point p_ix = this->_curve->pointAt((*i).ta); Geom::Coord dist = Geom::distance(p_ix, p); @@ -166,7 +166,7 @@ bool getClosestCurve(std::list<Inkscape::SnappedCurve> const &list, Inkscape::Sn { bool success = false; - for (std::list<Inkscape::SnappedCurve>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedCurve>::const_iterator i = list.begin(); i != list.end(); ++i) { if (exclude_paths && ((*i).getTarget() == Inkscape::SNAPTARGET_PATH)) { continue; } @@ -184,12 +184,12 @@ bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geo { bool success = false; - for (std::list<Inkscape::SnappedCurve>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedCurve>::const_iterator i = list.begin(); i != list.end(); ++i) { if ((*i).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes, // as this would require two bboxes two be flashed in the snap indicator std::list<Inkscape::SnappedCurve>::const_iterator j = i; - j++; - for (; j != list.end(); j++) { + ++j; + for (; j != list.end(); ++j) { if ((*j).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc); if (sp.getAtIntersection()) { @@ -219,10 +219,10 @@ bool getClosestIntersectionCL(std::list<Inkscape::SnappedCurve> const &curve_lis { bool success = false; - for (std::list<Inkscape::SnappedCurve>::const_iterator i = curve_list.begin(); i != curve_list.end(); i++) { + for (std::list<Inkscape::SnappedCurve>::const_iterator i = curve_list.begin(); i != curve_list.end(); ++i) { if ((*i).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes, // as this would require two bboxes two be flashed in the snap indicator - for (std::list<Inkscape::SnappedLine>::const_iterator j = line_list.begin(); j != line_list.end(); j++) { + for (std::list<Inkscape::SnappedLine>::const_iterator j = line_list.begin(); j != line_list.end(); ++j) { if ((*j).getTarget() != Inkscape::SNAPTARGET_BBOX_EDGE) { // We don't support snapping to intersections of bboxes Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc); if (sp.getAtIntersection()) { diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index 83c932539..cffdda5d7 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -114,7 +114,7 @@ bool getClosestSP(std::list<Inkscape::SnappedPoint> const &list, Inkscape::Snapp { bool success = false; - for (std::list<Inkscape::SnappedPoint>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedPoint>::const_iterator i = list.begin(); i != list.end(); ++i) { if ((i == list.begin()) || (*i).getSnapDistance() < result.getSnapDistance()) { result = *i; success = true; -- cgit v1.2.3 From f53c6ac9626ae7069fe486f2f0b0667e90a1eac1 Mon Sep 17 00:00:00 2001 From: Alvin Penner <penner@vaxxine.com> Date: Mon, 17 Oct 2011 10:06:30 -0400 Subject: pdf import. modify calculation of GradientTransform (Bug 530895) Fixed bugs: - https://launchpad.net/bugs/530895 (bzr r10680) --- src/extension/internal/pdfinput/svg-builder.cpp | 39 ++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 1aaf3a1a5..f5dea54bf 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -56,6 +56,7 @@ namespace Internal { #define TRACE(_args) IFTRACE(g_print _args) +static double ttm[6] = {1, 0, 0, 1, 0, 0}; // temporary transform matrix /** * \struct SvgTransparencyGroup @@ -561,6 +562,19 @@ bool SvgBuilder::getTransform(double *transform) { */ void SvgBuilder::setTransform(double c0, double c1, double c2, double c3, double c4, double c5) { + // do not remember the group which is a layer + if (_container->attribute("inkscape:groupmode") != NULL) { + ttm[0] = ttm[3] = 1.0; + ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0; + } + else { + ttm[0] = c0; + ttm[1] = c1; + ttm[2] = c2; + ttm[3] = c3; + ttm[4] = c4; + ttm[5] = c5; + } // Avoid transforming a group with an already set clip-path if ( _container->attribute("clip-path") != NULL ) { @@ -608,8 +622,31 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_ if ( pattern != NULL ) { if ( pattern->getType() == 2 ) { // Shading pattern GfxShadingPattern *shading_pattern = (GfxShadingPattern*)pattern; + double *ptm; + double ittm[6]; // invert ttm + double m[6] = {1, 0, 0, 1, 0, 0}; + double det; + + // construct a (pattern space) -> (current space) transform matrix + + ptm = shading_pattern->getMatrix(); + det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; + if (det) { + ittm[0] = ttm[3] / det; + ittm[1] = -ttm[1] / det; + ittm[2] = -ttm[2] / det; + ittm[3] = ttm[0] / det; + ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det; + ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det; + m[0] = ptm[0] * ittm[0] + ptm[1] * ittm[2]; + m[1] = ptm[0] * ittm[1] + ptm[1] * ittm[3]; + m[2] = ptm[2] * ittm[0] + ptm[3] * ittm[2]; + m[3] = ptm[2] * ittm[1] + ptm[3] * ittm[3]; + m[4] = ptm[4] * ittm[0] + ptm[5] * ittm[2] + ittm[4]; + m[5] = ptm[4] * ittm[1] + ptm[5] * ittm[3] + ittm[5]; + } id = _createGradient(shading_pattern->getShading(), - shading_pattern->getMatrix(), + m, !is_stroke); } else if ( pattern->getType() == 1 ) { // Tiling pattern id = _createTilingPattern((GfxTilingPattern*)pattern, state, is_stroke); -- cgit v1.2.3 From 48acbc6ed82b18fb07aa5e7964f7702428bade73 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Tue, 18 Oct 2011 07:54:57 +0200 Subject: cppcheck (bzr r10681) --- src/dom/css.h | 8 ++++---- src/dom/stylesheets.h | 2 +- src/extension/internal/filter/filter.cpp | 2 +- src/extension/internal/javafx-out.cpp | 2 +- src/extension/internal/pdfinput/svg-builder.cpp | 4 ++-- src/extension/internal/pov-out.cpp | 2 +- src/io/gzipstream.cpp | 4 ++-- src/libcola/gradient_projection.h | 2 +- src/line-snapper.cpp | 4 ++-- src/live_effects/effect.cpp | 8 ++++---- src/live_effects/lpe-gears.cpp | 5 +++-- src/live_effects/lpe-knot.cpp | 2 +- src/snapped-line.cpp | 20 ++++++++++---------- src/sp-lpe-item.cpp | 12 ++++++------ src/svg/svg-path.cpp | 4 ++-- src/trace/siox.cpp | 2 +- src/trace/siox.h | 2 +- src/trace/trace.cpp | 6 +++--- src/ui/dialog/align-and-distribute.cpp | 6 +++--- src/ui/dialog/document-metadata.cpp | 4 ++-- src/ui/dialog/filedialogimpl-gtkmm.cpp | 6 +++--- src/ui/dialog/filedialogimpl-win32.cpp | 8 ++++---- src/ui/dialog/livepatheffect-editor.cpp | 2 +- src/ui/dialog/swatches.cpp | 4 ++-- src/ui/widget/page-sizer.cpp | 4 ++-- src/ui/widget/registered-widget.cpp | 4 ++-- src/ui/widget/selected-style.cpp | 2 +- 27 files changed, 66 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/dom/css.h b/src/dom/css.h index e0e9c09ec..f62b93588 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -608,7 +608,7 @@ public: virtual DOMString getPropertyValue(const DOMString &propertyName) { std::vector<CSSStyleDeclarationEntry>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; iter++) + for (iter=items.begin() ; iter!=items.end() ; ++iter) { if (iter->name == propertyName) return iter->value; @@ -637,7 +637,7 @@ public: throw (dom::DOMException) { std::vector<CSSStyleDeclarationEntry>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; iter++) + for (iter=items.begin() ; iter!=items.end() ; ++iter) { if (iter->name == propertyName) items.erase(iter); @@ -652,7 +652,7 @@ public: virtual DOMString getPropertyPriority(const DOMString &propertyName) { std::vector<CSSStyleDeclarationEntry>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; iter++) + for (iter=items.begin() ; iter!=items.end() ; ++iter) { if (iter->name == propertyName) return iter->prio; @@ -669,7 +669,7 @@ public: throw (dom::DOMException) { std::vector<CSSStyleDeclarationEntry>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; iter++) + for (iter=items.begin() ; iter!=items.end() ; ++iter) { if (iter->name == propertyName) { diff --git a/src/dom/stylesheets.h b/src/dom/stylesheets.h index 0a96a61d7..0e76d6d4e 100644 --- a/src/dom/stylesheets.h +++ b/src/dom/stylesheets.h @@ -122,7 +122,7 @@ public: throw (dom::DOMException) { std::vector<DOMString>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; iter++) + for (iter=items.begin() ; iter!=items.end() ; ++iter) { if (*iter == oldMedium) items.erase(iter); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index fb8d4de4b..25a93102f 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -136,7 +136,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); for(std::list<SPItem *>::iterator item = items.begin(); - item != items.end(); item++) { + item != items.end(); ++item) { SPItem * spitem = *item; Inkscape::XML::Node * node = spitem->getRepr(); diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 74b6a69ee..aa7073320 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -891,7 +891,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) return false; } - for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); iter++) + for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter) { fputc(*iter, f); } diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index f5dea54bf..93cfa4c71 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -122,7 +122,7 @@ void SvgBuilder::_init() { font_factory::Default()->GetUIFamiliesAndStyles(&familyStyleMap); for (FamilyToStylesMap::iterator iter = familyStyleMap.begin(); iter != familyStyleMap.end(); - iter++) { + ++iter) { _availableFontNames.push_back(iter->first.c_str()); } @@ -1334,7 +1334,7 @@ void SvgBuilder::_flushText() { } glyphs_in_a_row++; - i++; + ++i; } _container->appendChild(text_node); Inkscape::GC::release(text_node); diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index a29aade35..ecdc049e2 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -638,7 +638,7 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) if (!f) return; - for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); iter++) + for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter) { int ch = *iter; fputc(ch, f); diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index ece0ddc67..79bcb2087 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -172,7 +172,7 @@ bool GzipInputStream::load() std::vector<unsigned char>::iterator iter; Bytef *p = srcBuf; - for (iter=inputBuf.begin() ; iter != inputBuf.end() ; iter++) + for (iter=inputBuf.begin() ; iter != inputBuf.end() ; ++iter) *p++ = *iter; int headerLen = 10; @@ -390,7 +390,7 @@ void GzipOutputStream::flush() std::vector<unsigned char>::iterator iter; Bytef *p = srcbuf; - for (iter=inputBuf.begin() ; iter != inputBuf.end() ; iter++) + for (iter=inputBuf.begin() ; iter != inputBuf.end() ; ++iter) *p++ = *iter; crc = crc32(crc, (const Bytef *)srcbuf, srclen); diff --git a/src/libcola/gradient_projection.h b/src/libcola/gradient_projection.h index 9907cdb13..66fc37aba 100644 --- a/src/libcola/gradient_projection.h +++ b/src/libcola/gradient_projection.h @@ -203,7 +203,7 @@ public: vars.push_back(v); for(OffsetList::iterator o=ac->offsets.begin(); o!=ac->offsets.end(); - o++) { + ++o) { gcs.push_back(new vpsc::Constraint(v,vars[o->first],o->second,true)); } } diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 66bc8c530..45b03c38b 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -34,7 +34,7 @@ void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, /* Get the lines that we will try to snap to */ const LineList lines = _getSnapLines(p.getPoint()); - for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) { + for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) { Geom::Point const p1 = i->second; // point at guide/grid line Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line // std::cout << " line through " << i->second << " with normal " << i->first; @@ -78,7 +78,7 @@ void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, /* Get the lines that we will try to snap to */ const LineList lines = _getSnapLines(pp); - for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) { + for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) { Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : pp; Geom::Line gridguide_line(i->second, i->second + Geom::rot90(i->first)); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a5b2077a5..e040eec32 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -436,7 +436,7 @@ Effect::readallParameters(Inkscape::XML::Node * repr) param->param_set_default(); } - it++; + ++it; } } @@ -572,7 +572,7 @@ Effect::newWidget(Gtk::Tooltips * tooltips) } } - it++; + ++it; } return dynamic_cast<Gtk::Widget *>(vbox); @@ -604,7 +604,7 @@ Effect::getParameter(const char * key) return param; } - it++; + ++it; } return NULL; @@ -671,7 +671,7 @@ void Effect::transform_multiply(Geom::Affine const& postmul, bool set) { // cycle through all parameters. Most parameters will not need transformation, but path and point params do. - for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); it++) { + for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { Parameter * param = *it; param->param_transform_multiply(postmul, set); } diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp index 337beb516..ac2db1716 100644 --- a/src/live_effects/lpe-gears.cpp +++ b/src/live_effects/lpe-gears.cpp @@ -244,12 +244,13 @@ LPEGears::doEffect_path (std::vector<Geom::Path> const & path_in) gear->centre(gear_centre); gear->angle(atan2((*it).initialPoint() - gear_centre)); - it++; if ( it == gearpath.end() ) return path_out; + ++it; + if ( it == gearpath.end() ) return path_out; gear->pitch_radius(Geom::distance(gear_centre, (*it).finalPoint())); path_out.push_back( gear->path()); - for (it++ ; it != gearpath.end() ; it++) { + for (++it; it != gearpath.end() ; ++it) { // iterate through Geom::Curve in path_in Gear* gearnew = new Gear(gear->spawn( (*it).finalPoint() )); path_out.push_back( gearnew->path() ); diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 4c88ac315..c957c8f08 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -214,7 +214,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect if (cp.j == i) cuts[cp.tj] = k; } unsigned count = 0; - for ( std::map < double, unsigned >::iterator m=cuts.begin(); m!=cuts.end(); m++ ){ + for ( std::map < double, unsigned >::iterator m=cuts.begin(); m!=cuts.end(); ++m ){ if ( (*this)[m->second].i == i && (*this)[m->second].ti == m->first ){ (*this)[m->second].ni = count; }else{ diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index d9cd48d5b..6c0c411d8 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -176,7 +176,7 @@ bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape { bool success = false; - for (std::list<Inkscape::SnappedLineSegment>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedLineSegment>::const_iterator i = list.begin(); i != list.end(); ++i) { if ((i == list.begin()) || (*i).getSnapDistance() < result.getSnapDistance()) { result = *i; success = true; @@ -191,10 +191,10 @@ bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> const &li { bool success = false; - for (std::list<Inkscape::SnappedLineSegment>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedLineSegment>::const_iterator i = list.begin(); i != list.end(); ++i) { std::list<Inkscape::SnappedLineSegment>::const_iterator j = i; - j++; - for (; j != list.end(); j++) { + ++j; + for (; j != list.end(); ++j) { Inkscape::SnappedPoint sp = (*i).intersect(*j); if (sp.getAtIntersection()) { // if it's the first point @@ -221,7 +221,7 @@ bool getClosestSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::Snappe { bool success = false; - for (std::list<Inkscape::SnappedLine>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedLine>::const_iterator i = list.begin(); i != list.end(); ++i) { if ((i == list.begin()) || (*i).getSnapDistance() < result.getSnapDistance()) { result = *i; success = true; @@ -236,10 +236,10 @@ bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list, Inks { bool success = false; - for (std::list<Inkscape::SnappedLine>::const_iterator i = list.begin(); i != list.end(); i++) { + for (std::list<Inkscape::SnappedLine>::const_iterator i = list.begin(); i != list.end(); ++i) { std::list<Inkscape::SnappedLine>::const_iterator j = i; - j++; - for (; j != list.end(); j++) { + ++j; + for (; j != list.end(); ++j) { Inkscape::SnappedPoint sp = (*i).intersect(*j); if (sp.getAtIntersection()) { // if it's the first point @@ -266,8 +266,8 @@ bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list1, std { bool success = false; - for (std::list<Inkscape::SnappedLine>::const_iterator i = list1.begin(); i != list1.end(); i++) { - for (std::list<Inkscape::SnappedLine>::const_iterator j = list2.begin(); j != list2.end(); j++) { + for (std::list<Inkscape::SnappedLine>::const_iterator i = list1.begin(); i != list1.end(); ++i) { + for (std::list<Inkscape::SnappedLine>::const_iterator j = list2.begin(); j != list2.end(); ++j) { Inkscape::SnappedPoint sp = (*i).intersect(*j); if (sp.getAtIntersection()) { // if it's the first point diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index d67afce8e..d0c548a6a 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -562,7 +562,7 @@ void sp_lpe_item_down_current_path_effect(SPLPEItem *lpeitem) PathEffectList::iterator cur_it = find( new_list.begin(), new_list.end(), lperef ); if (cur_it != new_list.end()) { PathEffectList::iterator down_it = cur_it; - down_it++; + ++down_it; if (down_it != new_list.end()) { // perhaps current effect is already last effect std::iter_swap(cur_it, down_it); } @@ -583,7 +583,7 @@ void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem) PathEffectList::iterator cur_it = find( new_list.begin(), new_list.end(), lperef ); if (cur_it != new_list.end() && cur_it != new_list.begin()) { PathEffectList::iterator up_it = cur_it; - up_it--; + --up_it; std::iter_swap(cur_it, up_it); } std::string r = patheffectlist_write_svg(new_list); @@ -601,7 +601,7 @@ bool sp_lpe_item_has_broken_path_effect(SPLPEItem *lpeitem) // go through the list; if some are unknown or invalid, return true PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); - for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++) + for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; if (!lpeobj || !lpeobj->get_lpe()) @@ -619,7 +619,7 @@ bool sp_lpe_item_has_path_effect(SPLPEItem *lpeitem) // go through the list; if some are unknown or invalid, we are not an LPE item! PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); - for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++) + for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; if (!lpeobj || !lpeobj->get_lpe()) @@ -761,7 +761,7 @@ Inkscape::LivePathEffect::Effect* sp_lpe_item_get_current_lpe(SPLPEItem *lpeitem bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathEffect::LPEObjectReference* lperef) { - for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); it++) { + for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) { if ((*it)->lpeobject_repr == lperef->lpeobject_repr) { lpeitem->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list ! return true; @@ -819,7 +819,7 @@ bool sp_lpe_item_fork_path_effects_if_necessary(SPLPEItem *lpeitem, unsigned int std::vector<LivePathEffectObject const *> old_lpeobjs, new_lpeobjs; PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); - for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++) + for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; if (lpeobj) { diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 8781d75e6..f4278a5ac 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -117,7 +117,7 @@ static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve cons static void sp_svg_write_path(Inkscape::SVG::PathString & str, Geom::Path const & p) { str.moveTo( p.initialPoint()[0], p.initialPoint()[1] ); - for(Geom::Path::const_iterator cit = p.begin(); cit != p.end_open(); cit++) { + for(Geom::Path::const_iterator cit = p.begin(); cit != p.end_open(); ++cit) { sp_svg_write_curve(str, &(*cit)); } @@ -129,7 +129,7 @@ static void sp_svg_write_path(Inkscape::SVG::PathString & str, Geom::Path const gchar * sp_svg_write_path(Geom::PathVector const &p) { Inkscape::SVG::PathString str; - for(Geom::PathVector::const_iterator pit = p.begin(); pit != p.end(); pit++) { + for(Geom::PathVector::const_iterator pit = p.begin(); pit != p.end(); ++pit) { sp_svg_write_path(str, *pit); } diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index b3404fc00..a30d903cd 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -584,7 +584,7 @@ void SioxImage::assign(const SioxImage &other) /** * Write the image to a PPM file */ -bool SioxImage::writePPM(const std::string fileName) +bool SioxImage::writePPM(const std::string &fileName) { FILE *f = fopen(fileName.c_str(), "wb"); diff --git a/src/trace/siox.h b/src/trace/siox.h index 6b7256fe0..57c78bd5a 100644 --- a/src/trace/siox.h +++ b/src/trace/siox.h @@ -316,7 +316,7 @@ public: /** * Saves this image as a simple color PPM */ - bool writePPM(const std::string fileName); + bool writePPM(const std::string &fileName); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 7c47dc442..64a4a7732 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -86,7 +86,7 @@ Tracer::getSelectedSPImage() items.insert(items.begin(), item); } std::vector<SPItem *>::iterator iter; - for (iter = items.begin() ; iter!= items.end() ; iter++) + for (iter = items.begin() ; iter!= items.end() ; ++iter) { SPItem *item = *iter; if (SP_IS_IMAGE(item)) @@ -251,7 +251,7 @@ Tracer::sioxProcessImage(SPImage *img, std::vector<Inkscape::DrawingItem *> arenaItems; std::vector<SPShape *>::iterator iter; - for (iter = sioxShapes.begin() ; iter!=sioxShapes.end() ; iter++) + for (iter = sioxShapes.begin() ; iter!=sioxShapes.end() ; ++iter) { SPItem *item = *iter; Inkscape::DrawingItem *aItem = item->get_arenaitem(desktop->dkey); @@ -279,7 +279,7 @@ Tracer::sioxProcessImage(SPImage *img, //g_message("x:%f y:%f\n", point[0], point[1]); bool weHaveAHit = false; std::vector<Inkscape::DrawingItem *>::iterator aIter; - for (aIter = arenaItems.begin() ; aIter!=arenaItems.end() ; aIter++) + for (aIter = arenaItems.begin() ; aIter!=arenaItems.end() ; ++aIter) { Inkscape::DrawingItem *arenaItem = *aIter; if (arenaItem->pick(point, 1.0f, 1)) diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 573674406..708013b5d 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1087,7 +1087,7 @@ AlignAndDistribute::~AlignAndDistribute() for (std::list<Action *>::iterator it = _actionList.begin(); it != _actionList.end(); - it ++) + ++it) delete *it; } @@ -1245,7 +1245,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem case BIGGEST: { gdouble max = -1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) { + for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { Geom::OptRect b = (*it)->desktopVisualBounds(); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); @@ -1262,7 +1262,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem case SMALLEST: { gdouble max = 1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) { + for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { Geom::OptRect b = (*it)->desktopVisualBounds(); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 0dae7bd88..2aebef997 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -97,7 +97,7 @@ DocumentMetadata::~DocumentMetadata() Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->removeListenerByData (this); - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++) + for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) delete (*it); } @@ -199,7 +199,7 @@ void DocumentMetadata::update() //-----------------------------------------------------------meta pages /* update the RDF entities */ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++) + for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) (*it)->update (SP_ACTIVE_DOCUMENT); _licensor.update (SP_ACTIVE_DOCUMENT); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 921d89c2e..61013295a 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -763,7 +763,7 @@ void FileOpenDialogImplGtk::createFilterMenu() Inkscape::Extension::db.get_input_list(extension_list); for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Input * imod = *current_item; @@ -1087,7 +1087,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() knownExtensions.clear(); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Output * omod = *current_item; @@ -1342,7 +1342,7 @@ void FileExportDialogImpl::createFileTypeMenu() Inkscape::Extension::db.get_output_list(extension_list); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Output * omod = *current_item; diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 2d23ed943..4ed963148 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -227,7 +227,7 @@ void FileOpenDialogImplWin32::createFilterMenu() int filter_count = 5; // 5 - one for each filter type for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Filter filter; @@ -383,7 +383,7 @@ void FileOpenDialogImplWin32::createFilterMenu() wchar_t *filterptr = _filter; for(list<Filter>::iterator filter_iterator = filter_list.begin(); - filter_iterator != filter_list.end(); filter_iterator++) + filter_iterator != filter_list.end(); ++filter_iterator) { const Filter &filter = *filter_iterator; @@ -1616,7 +1616,7 @@ void FileSaveDialogImplWin32::createFilterMenu() int filter_length = 1; for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Output *omod = *current_item; if (omod->deactivated()) continue; @@ -1650,7 +1650,7 @@ void FileSaveDialogImplWin32::createFilterMenu() wchar_t *filterptr = _filter; for(list<Filter>::iterator filter_iterator = filter_list.begin(); - filter_iterator != filter_list.end(); filter_iterator++) + filter_iterator != filter_list.end(); ++filter_iterator) { const Filter &filter = *filter_iterator; diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 2227a8c5a..3c5d3f1a2 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -299,7 +299,7 @@ LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem) PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem); PathEffectList::iterator it; - for( it = effectlist.begin() ; it!=effectlist.end(); it++ ) + for( it = effectlist.begin() ; it!=effectlist.end(); ++it) { if ( !(*it)->lpeobject ) { continue; diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 2edd24eec..50f8a90aa 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -620,7 +620,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : int i = 0; std::vector<SwatchPage*> swatchSets = _getSwatchSets(); - for ( std::vector<SwatchPage*>::iterator it = swatchSets.begin(); it != swatchSets.end(); it++ ) { + for ( std::vector<SwatchPage*>::iterator it = swatchSets.begin(); it != swatchSets.end(); ++it) { SwatchPage* curr = *it; Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, curr->_name)); if ( curr == first ) { @@ -1134,7 +1134,7 @@ void SwatchesPanel::_rebuild() _holder->freezeUpdates(); // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); - for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { + for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); ++it) { _holder->addPreview(&*it); } _holder->thawUpdates(); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index f7759f103..67f3789c7 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -501,7 +501,7 @@ PageSizer::find_paper_size (double w, double h) const std::map<Glib::ustring, PaperSize>::const_iterator iter; for (iter = _paperSizeTable.begin() ; - iter != _paperSizeTable.end() ; iter++) { + iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; SPUnit const &i_unit = sp_unit_get_by_id(paper.unit); double smallX = sp_units_get_pixels(paper.smaller, i_unit); @@ -515,7 +515,7 @@ PageSizer::find_paper_size (double w, double h) const // We need to search paperSizeListStore explicitly for the // specified paper size because it is sorted in a different // way than paperSizeTable (which is sorted alphabetically) - for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); p++) { + for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); ++p) { if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) { return p; } diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index c2580013a..3f060f740 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -72,7 +72,7 @@ RegisteredCheckButton::setActive (bool b) setProgrammatically = true; set_active (b); //The slave button is greyed out if the master button is unchecked - for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); i++) { + for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { (*i)->set_sensitive(b); } setProgrammatically = false; @@ -92,7 +92,7 @@ RegisteredCheckButton::on_toggled() write_to_xml(get_active() ? "true" : "false"); //The slave button is greyed out if the master button is unchecked - for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); i++) { + for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { (*i)->set_sensitive(get_active()); } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 516da5761..51c3af4dd 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1092,7 +1092,7 @@ void SelectedStyle::opacity_1(void) {_opacity_sb.set_value(100);} void SelectedStyle::on_opacity_menu (Gtk::Menu *menu) { Glib::ListHandle<Gtk::Widget *> children = menu->get_children(); - for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); iter++) { + for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); ++iter) { menu->remove(*(*iter)); } -- cgit v1.2.3 From 4108bc8d8212fb10de78f44d1af5171afc71b729 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Tue, 18 Oct 2011 22:09:42 +0200 Subject: cppcheck (bzr r10683) --- src/bind/javabind.cpp | 4 ++-- src/selection-describer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index db112708e..f1a3423fe 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -568,7 +568,7 @@ static const char *commonJavaPaths[] = static bool findJVM(String &result) { std::vector<String> results; - int found = false; + bool found = false; /* Is there one specified by the user? */ const char *javaHome = getenv("JAVA_HOME"); @@ -586,7 +586,7 @@ static bool findJVM(String &result) { return false; } - if (results.size() == 0) + if (results.empty()) return false; //Look first for a Client VM for (unsigned int i=0 ; i<results.size() ; i++) diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 5693ce351..5d6f9288d 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -138,7 +138,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select } else { char const *layer_label; bool is_label = false; - if (layer && layer->label()) { + if (layer->label()) { layer_label = layer->label(); is_label = true; } else { -- cgit v1.2.3 From 4012b2b37ebabcbdf8a695b418ebc05b897ad0cd Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Thu, 20 Oct 2011 21:12:09 +0200 Subject: cppcheck (bzr r10686) --- src/extension/dxf2svg/entities.cpp | 4 ++-- src/extension/dxf2svg/read_dxf.cpp | 2 +- src/extension/dxf2svg/tables2svg_info.cpp | 2 +- src/extension/internal/emf-win32-print.cpp | 2 +- src/extension/internal/javafx-out.cpp | 4 ++-- src/extension/internal/latex-pstricks.cpp | 2 +- src/extension/internal/latex-text-renderer.cpp | 2 +- src/extension/internal/pdfinput/svg-builder.cpp | 4 ++-- src/extension/internal/pov-out.cpp | 2 +- src/rubberband.cpp | 2 +- src/unicoderange.cpp | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp index d0d33503e..c94df06f3 100644 --- a/src/extension/dxf2svg/entities.cpp +++ b/src/extension/dxf2svg/entities.cpp @@ -398,8 +398,8 @@ lwpolyline::lwpolyline( std::vector< dxfpair > section ){ } // Now put on the last data that was found - if (others.size() > 0 ){ - sections.push_back( others ); + if (!others.empty()){ + sections.push_back(others); } reset_extents(); diff --git a/src/extension/dxf2svg/read_dxf.cpp b/src/extension/dxf2svg/read_dxf.cpp index ecda343c6..1a4eefbc9 100644 --- a/src/extension/dxf2svg/read_dxf.cpp +++ b/src/extension/dxf2svg/read_dxf.cpp @@ -261,7 +261,7 @@ std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > sec } } // Because putting the data on outer depends on find a GC=0 the last bit of data may be left behind so it inner has data in it put it on outer - if ( inner.size() > 0 ){ + if (!inner.empty()){ outer.push_back( inner ); inner.clear(); } diff --git a/src/extension/dxf2svg/tables2svg_info.cpp b/src/extension/dxf2svg/tables2svg_info.cpp index 3b27a9c38..c59060306 100644 --- a/src/extension/dxf2svg/tables2svg_info.cpp +++ b/src/extension/dxf2svg/tables2svg_info.cpp @@ -22,7 +22,7 @@ char* pattern2dasharray(ltype info, int precision, double scaling, char* out){ char *out_ptr; - if (pattern.size() > 0){ + if (!pattern.empty()){ strcat(out," stroke-dasharray=\""); for(int i = 0; i < pattern.size()-1;i++){ strcat(out,gcvt(scaling*sqrt(pow(pattern[i],2)),precision,temp) ); diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 87638045c..472a11807 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -450,7 +450,7 @@ PrintEmfWin32::flush_fill() unsigned int PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/) { - if (m_tr_stack.size()) { + if (!m_tr_stack.empty()) { Geom::Affine tr_top = m_tr_stack.top(); m_tr_stack.push(transform * tr_top); } else { diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index aa7073320..7646946fd 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -311,7 +311,7 @@ bool JavaFXOutput::doGradient(SPGradient *grad, const String &id) out(" function %s(): LinearGradient {\n", jfxid.c_str()); out(" LinearGradient {\n"); std::vector<SPGradientStop> stops = g->vector.stops; - if (stops.size() > 0) + if (!stops.empty()) { out(" stops:\n"); out(" [\n"); @@ -341,7 +341,7 @@ bool JavaFXOutput::doGradient(SPGradient *grad, const String &id) out(" focusY: %s\n", DSTR(g->fy.value)); out(" radius: %s\n", DSTR(g->r.value )); std::vector<SPGradientStop> stops = g->vector.stops; - if (stops.size() > 0) + if (!stops.empty()) { out(" stops:\n"); out(" [\n"); diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 49304de96..72df53377 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -166,7 +166,7 @@ PrintLatex::finish (Inkscape::Extension::Print *mod) unsigned int PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const &transform, float opacity) { - if (m_tr_stack.size()) { + if (!m_tr_stack.empty()) { Geom::Affine tr_top = m_tr_stack.top(); m_tr_stack.push(transform * tr_top); } else { diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 0da048a17..6244512a4 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -652,7 +652,7 @@ LaTeXTextRenderer::transform() void LaTeXTextRenderer::push_transform(Geom::Affine const &tr) { - if(_transform_stack.size()){ + if(!_transform_stack.empty()){ Geom::Affine tr_top = _transform_stack.top(); _transform_stack.push(tr * tr_top); } else { diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 93cfa4c71..0103e523b 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1365,7 +1365,7 @@ void SvgBuilder::addChar(GfxState *state, double x, double y, bool is_space = ( uLen == 1 && u[0] == 32 ); // Skip beginning space - if ( is_space && _glyphs.size() < 1 ) { + if ( is_space && _glyphs.empty()) { Geom::Point delta(dx, dy); _text_position += delta; return; @@ -1405,7 +1405,7 @@ void SvgBuilder::addChar(GfxState *state, double x, double y, } // Copy current style if it has changed since the previous glyph - if (_invalidated_style || _glyphs.size() == 0 ) { + if (_invalidated_style || _glyphs.empty()) { new_glyph.style_changed = true; int render_mode = state->getRender(); // Set style diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index ecdc049e2..bb00de619 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -490,7 +490,7 @@ bool PovOutput::doTree(SPDocument *doc) return false; //## Let's make a union of all of the Shapes - if (povShapes.size()>0) + if (!povShapes.empty()) { String id = "AllShapes"; char *pfx = (char *)id.c_str(); diff --git a/src/rubberband.cpp b/src/rubberband.cpp index a59664092..00f87cf8e 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -85,7 +85,7 @@ void Inkscape::Rubberband::move(Geom::Point const &p) // we want the points to be at most 0.5 screen pixels apart, // so that we don't lose anything small; // if they are farther apart, we interpolate more points - if (_points.size() > 0 && Geom::L2(next-_points.back()) > 0.5) { + if (!_points.empty() && Geom::L2(next-_points.back()) > 0.5) { Geom::Point prev = _points.back(); int subdiv = 2 * (int) round(Geom::L2(next-prev) + 0.5); for (int i = 1; i <= subdiv; i ++) { diff --git a/src/unicoderange.cpp b/src/unicoderange.cpp index 688969207..dcf461214 100644 --- a/src/unicoderange.cpp +++ b/src/unicoderange.cpp @@ -116,9 +116,9 @@ Glib::ustring UnicodeRange::attribute_string(){ gunichar UnicodeRange::sample_glyph(){ //This could be better - if (unichars.size()) + if (!unichars.empty()) return unichars[0]; - if (range.size()) + if (!range.empty()) return hex2int(range[0].start); return (gunichar) ' '; } -- cgit v1.2.3 From 4f89fdb05ba7b39b86cb7034c22692faadb06f6b Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Fri, 21 Oct 2011 18:06:32 +0200 Subject: cppcheck (bzr r10687) --- src/live_effects/lpe-knot.cpp | 4 ++-- src/live_effects/lpe-powerstroke.cpp | 2 +- src/live_effects/lpe-rough-hatches.cpp | 2 +- src/live_effects/lpe-sketch.cpp | 2 +- src/live_effects/lpe-vonkoch.cpp | 6 +++--- src/trace/siox.cpp | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index c957c8f08..9decdea9b 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -125,7 +125,7 @@ findShadowedTime(Geom::Path const &patha, std::vector<Geom::Point> const &pt_and double tmin = 0, tmax = size_nondegenerate(patha); double period = size_nondegenerate(patha); - if (times.size()>0){ + if (!times.empty()){ unsigned rk = upper_bound( times.begin(), times.end(), ta ) - times.begin(); if ( rk < times.size() ) tmax = times[rk]; @@ -465,7 +465,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) } //If the all component is hidden, continue. - if ( dom.size() == 0){ + if (dom.empty()){ continue; } diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index d9806b4d7..74a594a4b 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -367,7 +367,7 @@ std::vector<discontinuity_data> find_discontinuities( Geom::Piecewise<Geom::D2<G data.der1 = der[i].at0(); double t = der.cuts[i]; std::vector< double > rts = roots (x - t); /// @todo this has multiple solutions for general strokewidth paths (generated by spiro interpolator...), ignore for now - if (rts.size() > 0) { + if (!rts.empty()) { data.width = y(rts.front()); } else { data.width = 1; diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 8324271ed..50f50d0ae 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -330,7 +330,7 @@ LPERoughHatches::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & std::vector<std::vector<Point> > snakePoints; snakePoints = linearSnake(transformed_pwd2_in, transformed_org); - if ( snakePoints.size() > 0 ){ + if (!snakePoints.empty()){ Piecewise<D2<SBasis> >smthSnake = smoothSnake(snakePoints); smthSnake = smthSnake*mat.inverse(); if (do_bend.get_value()){ diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index 9cd6f1b57..e39b82f20 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -272,7 +272,7 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_ } } times = roots(piecelength-s1); - if (times.size()==0) break;//we should not be there. + if (times.empty()) break;//we should not be there. t1 = times[0]; //pick a rdm perturbation, and collect the perturbed piece into output. diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 56e73e3a3..953c2d443 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -83,7 +83,7 @@ LPEVonKoch::doEffect_path (std::vector<Geom::Path> const & path_in) std::vector<Geom::Path> generating_path = generator.get_pathvector(); - if (generating_path.size()==0) { + if (generating_path.empty()) { return path_in; } @@ -124,7 +124,7 @@ LPEVonKoch::doEffect_path (std::vector<Geom::Path> const & path_in) } } - if (transforms.size()==0){ + if (transforms.empty()){ return path_in; } @@ -247,7 +247,7 @@ LPEVonKoch::doBeforeEffect (SPLPEItem *lpeitem) std::vector<Geom::Path> paths = ref_path.get_pathvector(); Geom::Point A,B; - if (paths.size()==0||paths.front().size()==0){ + if (paths.empty()||paths.front().size()==0){ //FIXME: a path is used as ref instead of 2 points to work around path/point param incompatibility bug. //refA.param_setValue( Geom::Point(boundingbox_X.min(), boundingbox_Y.middle()) ); //refB.param_setValue( Geom::Point(boundingbox_X.max(), boundingbox_Y.middle()) ); diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index a30d903cd..e7ef5b0c0 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -1011,7 +1011,7 @@ SioxImage Siox::extractForeground(const SioxImage &originalImage, } tupel.minFgDist = minFg; tupel.indexMinFg = minIndex; - if (fgSignature.size() == 0) + if (fgSignature.empty()) { isBackground = (minBg <= clusterSize); // remove next line to force behaviour of old algorithm @@ -1414,7 +1414,7 @@ int Siox::depthFirstSearch(int startPos, } - while (pixelsToVisit.size() > 0) + while (!pixelsToVisit.empty()) { int pos = pixelsToVisit[pixelsToVisit.size() - 1]; pixelsToVisit.erase(pixelsToVisit.end() - 1); @@ -1486,7 +1486,7 @@ void Siox::fillColorRegions() // int componentSize = 1; pixelsToVisit.push_back(i); // depth first search to fill region - while (pixelsToVisit.size() > 0) + while (!pixelsToVisit.empty()) { int pos = pixelsToVisit[pixelsToVisit.size() - 1]; pixelsToVisit.erase(pixelsToVisit.end() - 1); -- cgit v1.2.3 From 8dfc25432f0c295a80b419206f48da043054dcd3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 22 Oct 2011 18:19:13 +0200 Subject: cppcheck: variable initialisation / fix possible memory leak (bzr r10688) --- src/gc-anchored.h | 2 +- src/preferences.cpp | 5 +++++ src/snapper.h | 2 +- src/version.h | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gc-anchored.h b/src/gc-anchored.h index b15d11f5d..ee277be25 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -63,7 +63,7 @@ protected: private: struct Anchor : public Managed<SCANNED, MANUAL> { - Anchor() : refcount(0) {} + Anchor() : refcount(0),base(NULL) {} Anchor(Anchored const *obj) : refcount(0) { base = Core::base(const_cast<Anchored *>(obj)); } diff --git a/src/preferences.cpp b/src/preferences.cpp index 444acfcac..f026e92cd 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -521,6 +521,7 @@ struct _ObserverData { Preferences::Observer::Observer(Glib::ustring const &path) : observed_path(path) { + _data = NULL; } Preferences::Observer::~Observer() @@ -600,6 +601,10 @@ void Preferences::addObserver(Observer &o) _ObserverData *priv_data = new _ObserverData; priv_data->_node = node; priv_data->_is_attr = !attr_key.empty(); + if (o._data) + { + delete o._data; + } o._data = static_cast<void*>(priv_data); _observer_map[&o] = new PrefNodeObserver(o, attr_key); diff --git a/src/snapper.h b/src/snapper.h index aabdfdfb6..f5fbd4fdc 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -39,7 +39,7 @@ namespace Inkscape class Snapper { public: - Snapper() {} + //Snapper() {} //does not seem to be used somewhere Snapper(SnapManager *sm, ::Geom::Coord const t); virtual ~Snapper() {} diff --git a/src/version.h b/src/version.h index c62063123..faa8c38b2 100644 --- a/src/version.h +++ b/src/version.h @@ -17,7 +17,10 @@ namespace Inkscape { struct Version { - Version() {} + Version() { + major = 0; + minor = 0; + } Version(unsigned mj, unsigned mn) { // somebody pollutes our namespace with major() and minor() // macros, so we can't use new-style initializers -- cgit v1.2.3 From d4a6d2dc8d3b81d4b273b96640cfb436a0190af0 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 23 Oct 2011 00:37:24 -0700 Subject: Removed use of 'void *' as attemtp to limit access to internals. (bzr r10689) --- src/preferences.cpp | 36 ++++++++++++++++-------------------- src/preferences.h | 7 +++++-- 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/preferences.cpp b/src/preferences.cpp index f026e92cd..2a3019d28 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -505,23 +505,22 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) } -// Observer stuff -namespace { - /** - * Structure that holds additional information for registered Observers. + * Class that holds additional information for registered Observers. */ -struct _ObserverData { +class Preferences::_ObserverData +{ +public: + _ObserverData(Inkscape::XML::Node *node, bool isAttr) : _node(node), _is_attr(isAttr) {} + Inkscape::XML::Node *_node; ///< Node at which the wrapping PrefNodeObserver is registered bool _is_attr; ///< Whether this Observer watches a single attribute }; -} // anonymous namespace - Preferences::Observer::Observer(Glib::ustring const &path) : - observed_path(path) + observed_path(path), + _data(0) { - _data = NULL; } Preferences::Observer::~Observer() @@ -536,7 +535,7 @@ void Preferences::PrefNodeObserver::notifyAttributeChanged(XML::Node &node, GQua // filter out attributes we don't watch gchar const *attr_name = g_quark_to_string(name); if ( _filter.empty() || (_filter == attr_name) ) { - _ObserverData *d = static_cast<_ObserverData*>(Preferences::_get_pref_observer_data(_observer)); + _ObserverData *d = Preferences::_get_pref_observer_data(_observer); Glib::ustring notify_path = _observer.observed_path; if (!d->_is_attr) { @@ -598,19 +597,15 @@ void Preferences::addObserver(Observer &o) node = _findObserverNode(o.observed_path, node_key, attr_key, false); if (node) { // set additional data - _ObserverData *priv_data = new _ObserverData; - priv_data->_node = node; - priv_data->_is_attr = !attr_key.empty(); - if (o._data) - { + if (o._data) { delete o._data; } - o._data = static_cast<void*>(priv_data); + o._data = new _ObserverData(node, !attr_key.empty()); _observer_map[&o] = new PrefNodeObserver(o, attr_key); // if we watch a single pref, we want to receive notifications only for a single node - if (priv_data->_is_attr) { + if (o._data->_is_attr) { node->addObserver( *(_observer_map[&o]) ); } else { node->addSubtreeObserver( *(_observer_map[&o]) ); @@ -623,9 +618,9 @@ void Preferences::removeObserver(Observer &o) { // prevent removing an observer which was not added if ( _observer_map.find(&o) != _observer_map.end() ) { - Inkscape::XML::Node *node = static_cast<_ObserverData*>(o._data)->_node; - _ObserverData *priv_data = static_cast<_ObserverData*>(o._data); - o._data = NULL; + Inkscape::XML::Node *node = o._data->_node; + _ObserverData *priv_data = o._data; + o._data = 0; if (priv_data->_is_attr) { node->removeObserver( *(_observer_map[&o]) ); @@ -634,6 +629,7 @@ void Preferences::removeObserver(Observer &o) } delete priv_data; + priv_data = 0; delete _observer_map[&o]; _observer_map.erase(&o); } diff --git a/src/preferences.h b/src/preferences.h index 86142d28b..4111db8ea 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -53,6 +53,8 @@ public: * derive (e.g. GConf, flat XML file...) */ class Preferences { + class _ObserverData; + public: // ############################# // ## inner class definitions ## @@ -69,6 +71,7 @@ public: */ class Observer { friend class Preferences; + public: /** @@ -102,7 +105,7 @@ public: Glib::ustring const observed_path; ///< Path which the observer watches private: - void *_data; ///< additional data used by the implementation while the observer is active + _ObserverData *_data; ///< additional data used by the implementation while the observer is active }; @@ -547,7 +550,7 @@ private: // privilege escalation methods for PrefNodeObserver static Entry const _create_pref_value(Glib::ustring const &, void const *ptr); - static void *_get_pref_observer_data(Observer &o) { return o._data; } + static _ObserverData *_get_pref_observer_data(Observer &o) { return o._data; } static Preferences *_instance; -- cgit v1.2.3 From 124c1161ebfbc8668c373395b9f6573430cd25ab Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 23 Oct 2011 00:51:53 -0700 Subject: Fixed unused parameter warnings. Due to being included a few places, this cleans up several hundred warnings. (bzr r10690) --- src/extension/implementation/implementation.h | 160 ++++++++++++++------------ 1 file changed, 87 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index 443046846..32cc37402 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -41,9 +41,14 @@ class Print; namespace Implementation { -/** \brief A cache for the document and this implementation */ +/** + * A cache for the document and this implementation. + */ class ImplementationDocumentCache { - /** \brief The document that this instance is working on */ + + /** + * The document that this instance is working on. + */ Inkscape::UI::View::View * _view; public: ImplementationDocumentCache (Inkscape::UI::View::View * view) : @@ -62,113 +67,122 @@ public: */ class Implementation { public: - /* ----- Constructor / destructor ----- */ + // ----- Constructor / destructor ----- Implementation() {} virtual ~Implementation() {} - /* ----- Basic functions for all Extension ----- */ - virtual bool load(Inkscape::Extension::Extension *module) { return true; } + // ----- Basic functions for all Extension ----- + virtual bool load(Inkscape::Extension::Extension * /*module*/) { return true; } + + virtual void unload(Inkscape::Extension::Extension * /*module*/) {} - virtual void unload(Inkscape::Extension::Extension *module) {} - /** \brief Create a new document cache object + /** + * Create a new document cache object. * This function just returns \c NULL. Subclasses are likely * to reimplement it to do something useful. - * \param ext The extension that is referencing us - * \param doc The document to create the cache of - * \return A new document cache that is valid as long as the document - * is not changed. */ - virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc) { return NULL; } + * @param ext The extension that is referencing us + * @param doc The document to create the cache of + * @return A new document cache that is valid as long as the document + * is not changed. + */ + virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*doc*/) { return NULL; } /** Verify any dependencies. */ - virtual bool check(Inkscape::Extension::Extension *module) { return true; } + virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; } virtual bool cancelProcessing () { return true; } virtual void commitDocument () {} - /* ----- Input functions ----- */ + // ----- Input functions ----- /** Find out information about the file. */ virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module, gchar const *filename); - virtual SPDocument *open(Inkscape::Extension::Input *module, - gchar const *filename) { return NULL; } + virtual SPDocument *open(Inkscape::Extension::Input * /*module*/, + gchar const * /*filename*/) { return NULL; } - /* ----- Output functions ----- */ + // ----- Output functions ----- /** Find out information about the file. */ virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module); - virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename) {} + virtual void save(Inkscape::Extension::Output * /*module*/, SPDocument * /*doc*/, gchar const * /*filename*/) {} - /* ----- Effect functions ----- */ + // ----- Effect functions ----- /** Find out information about the file. */ virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *view, sigc::signal<void> *changeSignal, ImplementationDocumentCache *docCache); - virtual void effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View *document, - ImplementationDocumentCache *docCache) {} - - /* ----- Print functions ----- */ - virtual unsigned setup(Inkscape::Extension::Print *module) { return 0; } - virtual unsigned set_preview(Inkscape::Extension::Print *module) { return 0; } - - virtual unsigned begin(Inkscape::Extension::Print *module, - SPDocument *doc) { return 0; } - virtual unsigned finish(Inkscape::Extension::Print *module) { return 0; } - /** \brief Tell the printing engine whether text should be text or path + virtual void effect(Inkscape::Extension::Effect * /*module*/, + Inkscape::UI::View::View * /*document*/, + ImplementationDocumentCache * /*docCache*/) {} + + // ----- Print functions ----- + virtual unsigned setup(Inkscape::Extension::Print * /*module*/) { return 0; } + virtual unsigned set_preview(Inkscape::Extension::Print * /*module*/) { return 0; } + + virtual unsigned begin(Inkscape::Extension::Print * /*module*/, + SPDocument * /*doc*/) { return 0; } + virtual unsigned finish(Inkscape::Extension::Print * /*module*/) { return 0; } + + /** + * Tell the printing engine whether text should be text or path. * Default value is false because most printing engines will support * paths more than they'll support text. (at least they do today) * \retval true Render the text as a path - * \retval false Render text using the text function (above) */ - virtual bool textToPath(Inkscape::Extension::Print *ext) { return false; } - /** \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded + * \retval false Render text using the text function (above) + */ + virtual bool textToPath(Inkscape::Extension::Print * /*ext*/) { return false; } + + /** + * Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded. * Only available for Adobe Type 1 fonts in EPS output as of now * \retval true Fonts have to be embedded in the output so that the user might not need * to install fonts to have the interpreter read the document correctly - * \retval false Do not embed fonts */ - virtual bool fontEmbedded(Inkscape::Extension::Print * ext) { return false; } - - /* ----- Rendering methods ----- */ - virtual unsigned bind(Inkscape::Extension::Print *module, - Geom::Affine const &transform, - float opacity) { return 0; } - virtual unsigned release(Inkscape::Extension::Print *module) { return 0; } - virtual unsigned comment(Inkscape::Extension::Print *module, char const *comment) { return 0; } - virtual unsigned fill(Inkscape::Extension::Print *module, - Geom::PathVector const &pathv, - Geom::Affine const &ctm, - SPStyle const *style, - Geom::OptRect const &pbox, - Geom::OptRect const &dbox, - Geom::OptRect const &bbox) { return 0; } - virtual unsigned stroke(Inkscape::Extension::Print *module, - Geom::PathVector const &pathv, - Geom::Affine const &transform, - SPStyle const *style, - Geom::OptRect const &pbox, - Geom::OptRect const &dbox, - Geom::OptRect const &bbox) { return 0; } - virtual unsigned image(Inkscape::Extension::Print *module, - unsigned char *px, - unsigned int w, - unsigned int h, - unsigned int rs, - Geom::Affine const &transform, - SPStyle const *style) { return 0; } - virtual unsigned text(Inkscape::Extension::Print *module, - char const *text, - Geom::Point const &p, - SPStyle const *style) { return 0; } - virtual void processPath(Inkscape::XML::Node * node) {} + * \retval false Do not embed fonts + */ + virtual bool fontEmbedded(Inkscape::Extension::Print * /*ext*/) { return false; } + + // ----- Rendering methods ----- + virtual unsigned bind(Inkscape::Extension::Print * /*module*/, + Geom::Affine const & /*transform*/, + float /*opacity*/) { return 0; } + virtual unsigned release(Inkscape::Extension::Print * /*module*/) { return 0; } + virtual unsigned comment(Inkscape::Extension::Print * /*module*/, char const * /*comment*/) { return 0; } + virtual unsigned fill(Inkscape::Extension::Print * /*module*/, + Geom::PathVector const & /*pathv*/, + Geom::Affine const & /*ctm*/, + SPStyle const * /*style*/, + Geom::OptRect const & /*pbox*/, + Geom::OptRect const & /*dbox*/, + Geom::OptRect const & /*bbox*/) { return 0; } + virtual unsigned stroke(Inkscape::Extension::Print * /*module*/, + Geom::PathVector const & /*pathv*/, + Geom::Affine const & /*transform*/, + SPStyle const * /*style*/, + Geom::OptRect const & /*pbox*/, + Geom::OptRect const & /*dbox*/, + Geom::OptRect const & /*bbox*/) { return 0; } + virtual unsigned image(Inkscape::Extension::Print * /*module*/, + unsigned char * /*px*/, + unsigned int /*w*/, + unsigned int /*h*/, + unsigned int /*rs*/, + Geom::Affine const & /*transform*/, + SPStyle const * /*style*/) { return 0; } + virtual unsigned text(Inkscape::Extension::Print * /*module*/, + char const * /*text*/, + Geom::Point const & /*p*/, + SPStyle const * /*style*/) { return 0; } + virtual void processPath(Inkscape::XML::Node * /*node*/) {} }; -} /* namespace Implementation */ -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Implementation +} // namespace Extension +} // namespace Inkscape -#endif /* __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ */ +#endif // __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ /* Local Variables: -- cgit v1.2.3 From 72d63966662421b4316e74ff1fb0799c4629f146 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 23 Oct 2011 01:00:27 -0700 Subject: Warning cleanup. (bzr r10691) --- src/extension/internal/filter/filter.cpp | 20 ++++---- src/extension/internal/latex-pstricks.cpp | 58 +++++++++++----------- src/extension/param/bool.cpp | 81 ++++++++++++------------------- src/extension/param/bool.h | 59 +++++++++++++++++----- src/extension/param/parameter.cpp | 5 +- src/ui/dialog/document-properties.cpp | 8 +-- 6 files changed, 121 insertions(+), 110 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 25a93102f..af597685b 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -46,22 +46,20 @@ Filter::~Filter (void) { return; } -bool -Filter::load (Inkscape::Extension::Extension *module) +bool Filter::load(Inkscape::Extension::Extension * /*module*/) { - return true; + return true; } -Inkscape::Extension::Implementation::ImplementationDocumentCache * -Filter::newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc) +Inkscape::Extension::Implementation::ImplementationDocumentCache *Filter::newDocCache(Inkscape::Extension::Extension * /*ext*/, + Inkscape::UI::View::View * /*doc*/) { - return NULL; + return NULL; } -gchar const * -Filter::get_filter_text (Inkscape::Extension::Extension * ext) +gchar const *Filter::get_filter_text(Inkscape::Extension::Extension * /*ext*/) { - return _filter; + return _filter; } Inkscape::XML::Document * @@ -116,8 +114,8 @@ Filter::merge_filters( Inkscape::XML::Node * to, Inkscape::XML::Node * from, #define FILTER_SRC_GRAPHIC "fbSourceGraphic" #define FILTER_SRC_GRAPHIC_ALPHA "fbSourceGraphicAlpha" -void -Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) +void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, + Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/) { Inkscape::XML::Document *filterdoc = get_filter(module); if (filterdoc == NULL) { diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 72df53377..dd5419ee4 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -56,8 +56,7 @@ PrintLatex::~PrintLatex (void) return; } -unsigned int -PrintLatex::setup (Inkscape::Extension::Print *mod) +unsigned int PrintLatex::setup(Inkscape::Extension::Print * /*mod*/) { return TRUE; } @@ -146,25 +145,21 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc) return fprintf(_stream, "%s", os.str().c_str()); } -unsigned int -PrintLatex::finish (Inkscape::Extension::Print *mod) +unsigned int PrintLatex::finish(Inkscape::Extension::Print * /*mod*/) { - int res; - - if (!_stream) return 0; - - res = fprintf(_stream, "\\end{pspicture}\n"); + if (_stream) { + fprintf(_stream, "\\end{pspicture}\n"); - /* Flush stream to be sure. */ - (void) fflush(_stream); + // Flush stream to be sure. + fflush(_stream); - fclose(_stream); - _stream = NULL; + fclose(_stream); + _stream = NULL; + } return 0; } -unsigned int -PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const &transform, float opacity) +unsigned int PrintLatex::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/) { if (!m_tr_stack.empty()) { Geom::Affine tr_top = m_tr_stack.top(); @@ -176,27 +171,29 @@ PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const &transform, return 1; } -unsigned int -PrintLatex::release(Inkscape::Extension::Print *mod) +unsigned int PrintLatex::release(Inkscape::Extension::Print * /*mod*/) { m_tr_stack.pop(); return 1; } -unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, - const char * comment) +unsigned int PrintLatex::comment(Inkscape::Extension::Print * /*mod*/, + const char * comment) { - if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. + if (!_stream) { + return 0; // XXX: fixme, returning -1 as unsigned. + } return fprintf(_stream, "%%! %s\n",comment); } -unsigned int -PrintLatex::fill(Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, - Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) +unsigned int PrintLatex::fill(Inkscape::Extension::Print * /*mod*/, + Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, + Geom::OptRect const & /*pbox*/, Geom::OptRect const & /*dbox*/, Geom::OptRect const & /*bbox*/) { - if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. + if (!_stream) { + return 0; // XXX: fixme, returning -1 as unsigned. + } if (style->fill.isColor()) { Inkscape::SVGOStringStream os; @@ -225,12 +222,13 @@ PrintLatex::fill(Inkscape::Extension::Print *mod, return 0; } -unsigned int -PrintLatex::stroke (Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, - Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) +unsigned int PrintLatex::stroke(Inkscape::Extension::Print * /*mod*/, + Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, + Geom::OptRect const & /*pbox*/, Geom::OptRect const & /*dbox*/, Geom::OptRect const & /*bbox*/) { - if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. + if (!_stream) { + return 0; // XXX: fixme, returning -1 as unsigned. + } if (style->stroke.isColor()) { Inkscape::SVGOStringStream os; diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index 36ea9c556..3073d2e76 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -21,8 +22,7 @@ namespace Inkscape { namespace Extension { -/** \brief Use the superclass' allocator and set the \c _value */ -ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : +ParamBool::ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(false), _indent(0) { @@ -50,17 +50,7 @@ ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * d return; } -/** \brief A function to set the \c _value - \param in The value to set to - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. -*/ -bool -ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) +bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) { _value = in; @@ -72,46 +62,47 @@ ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) return _value; } -/** \brief Returns \c _value */ -bool -ParamBool::get (const SPDocument * doc, const Inkscape::XML::Node * node) +bool ParamBool::get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { - return _value; + return _value; } -/** \brief A check button which is Param aware. It works with the - parameter to change it's value as the check button changes - value. */ +/** + * A check button which is Param aware. It works with the + * parameter to change it's value as the check button changes + * value. + */ class ParamBoolCheckButton : public Gtk::CheckButton { -private: - /** \brief Param to change */ - ParamBool * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; public: - /** \brief Initialize the check button - \param param Which parameter to adjust on changing the check button - - This function sets the value of the checkbox to be that of the - parameter, and then sets up a callback to \c on_toggle. - */ + /** + * Initialize the check button. + * This function sets the value of the checkbox to be that of the + * parameter, and then sets up a callback to \c on_toggle. + * + * @param param Which parameter to adjust on changing the check button + */ ParamBoolCheckButton (ParamBool * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::CheckButton(), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_active(_pref->get(NULL, NULL) /**\todo fix */); this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle)); return; } + + /** + * A function to respond to the check box changing. + * Adjusts the value of the preference to match that in the check box. + */ void on_toggle (void); -}; -/** - \brief A function to respond to the check box changing +private: + /** Param to change. */ + ParamBool * _pref; + SPDocument * _doc; + Inkscape::XML::Node * _node; + sigc::signal<void> * _changeSignal; +}; - Adjusts the value of the preference to match that in the check box. -*/ -void -ParamBoolCheckButton::on_toggle (void) +void ParamBoolCheckButton::on_toggle(void) { _pref->set(this->get_active(), NULL /**\todo fix this */, NULL); if (_changeSignal != NULL) { @@ -120,9 +111,7 @@ ParamBoolCheckButton::on_toggle (void) return; } -/** \brief Return 'true' or 'false' */ -void -ParamBool::string (std::string &string) +void ParamBool::string(std::string &string) const { if (_value) { string += "true"; @@ -133,13 +122,7 @@ ParamBool::string (std::string &string) return; } -/** - \brief Creates a bool check button for a bool parameter - - Builds a hbox with a label and a check button in it. -*/ -Gtk::Widget * -ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) +Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_gui_hidden) { return NULL; diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h index 964778f8f..2894e8085 100644 --- a/src/extension/param/bool.h +++ b/src/extension/param/bool.h @@ -1,9 +1,10 @@ -#ifndef __INK_EXTENSION_PARAMBOOL_H__ -#define __INK_EXTENSION_PARAMBOOL_H__ +#ifndef SEEN_INK_EXTENSION_PARAMBOOL_H +#define SEEN_INK_EXTENSION_PARAMBOOL_H /* * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -15,24 +16,56 @@ namespace Inkscape { namespace Extension { -/** \brief A boolean parameter */ +/** + * A boolean parameter. + */ class ParamBool : public Parameter { +public: + + /** + * Use the superclass' allocator and set the \c _value. + */ + ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); + + /** + * Returns the current state/value. + */ + bool get(const SPDocument * doc, const Inkscape::XML::Node * node) const; + + /** + * A function to set the state/value. + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * @param in The value to set to + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed + */ + bool set(bool in, SPDocument * doc, Inkscape::XML::Node * node); + + /** + * Creates a bool check button for a bool parameter. + * Builds a hbox with a label and a check button in it. + */ + Gtk::Widget *get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); + + /** + * Appends 'true' or 'false'. + * @todo investigate. Returning a value that can then be appended would probably work better/safer. + */ + void string(std::string &string) const; + private: - /** \brief Internal value. */ + /** Internal value. */ bool _value; int _indent; -public: - ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); - bool get (const SPDocument * doc, const Inkscape::XML::Node * node); - bool set (bool in, SPDocument * doc, Inkscape::XML::Node * node); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); }; -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape -#endif /* __INK_EXTENSION_PARAMBOOL_H__ */ +#endif // SEEN_INK_EXTENSION_PARAMBOOL_H /* Local Variables: diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 455fcc3bb..0a88fdda8 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -412,9 +412,8 @@ Parameter::string (std::list <std::string> &list) return; } -/** \brief All the code in Notebook::get_param to get the notebook content */ -Parameter * -Parameter::get_param(const gchar * name) +/** All the code in Notebook::get_param to get the notebook content. */ +Parameter *Parameter::get_param(const gchar * /*name*/) { return NULL; } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 9f8a99b1f..307cf2bbc 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -101,14 +101,14 @@ DocumentProperties::DocumentProperties() _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr), _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr), _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr), + //--------------------------------------------------------------- + _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr), + _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr), //--------------------------------------------------------------- _grids_label_crea("", Gtk::ALIGN_LEFT), _grids_button_new(C_("Grid", "_New"), _("Create new grid.")), _grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")), - _grids_label_def("", Gtk::ALIGN_LEFT), - //--------------------------------------------------------------- - _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr), - _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr) + _grids_label_def("", Gtk::ALIGN_LEFT) { _tt.enable(); _getContents()->set_spacing (4); -- cgit v1.2.3 From 7cd2a14069d9d39b42b19a87d9cc6ba238c71924 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 23 Oct 2011 01:01:33 -0700 Subject: Documentation update pass. (bzr r10692) --- src/bind/javabind.cpp | 20 ++++++++++---------- src/composite-undo-stack-observer.cpp | 4 +--- src/composite-undo-stack-observer.h | 14 ++++++-------- src/console-output-undo-observer.cpp | 2 +- src/console-output-undo-observer.h | 10 ++++++---- src/libavoid/vpsc.h | 7 +++++-- src/libcola/straightener.cpp | 4 +++- src/libvpsc/blocks.h | 14 ++++++-------- src/libvpsc/constraint.cpp | 5 +---- src/libvpsc/constraint.h | 10 ++++++---- src/libvpsc/generate-constraints.cpp | 5 ++++- src/libvpsc/generate-constraints.h | 6 +++++- src/ui/dialog/glyphs.cpp | 4 ---- src/ui/dialog/glyphs.h | 5 ----- src/widgets/dash-selector.h | 12 ++++++------ src/widgets/eek-preview.cpp | 4 ---- src/widgets/eek-preview.h | 8 +++++--- src/widgets/ege-paint-def.cpp | 4 ---- src/widgets/ege-paint-def.h | 6 +++--- src/widgets/sp-attribute-widget.cpp | 4 ---- src/widgets/sp-attribute-widget.h | 5 +++-- src/widgets/stroke-style.cpp | 4 ---- src/widgets/stroke-style.h | 15 +++++++++++++-- src/widgets/toolbox.h | 7 ++++--- 24 files changed, 88 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index f1a3423fe..41da00e81 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -3,6 +3,16 @@ * This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. * + * Note: We must limit Java or JVM-specific code to this file + * and to dobinding.cpp. It should be hidden from javabind.h + * + * This file is mostly about getting things up and running, and + * providing the basic C-to-Java hooks. + * + * dobinding.cpp will have the rote and repetitious + * class-by-class binding + */ +/* * Authors: * Bob Jamison * @@ -59,16 +69,6 @@ #include <inkscape.h> #include <xml/repr.h> -/** - * Note: We must limit Java or JVM-specific code to this file - * and to dobinding.cpp. It should be hidden from javabind.h - * - * This file is mostly about getting things up and running, and - * providing the basic C-to-Java hooks. - * - * dobinding.cpp will have the rote and repetitious - * class-by-class binding - */ namespace Inkscape diff --git a/src/composite-undo-stack-observer.cpp b/src/composite-undo-stack-observer.cpp index 6af34d92a..383e08cd8 100644 --- a/src/composite-undo-stack-observer.cpp +++ b/src/composite-undo-stack-observer.cpp @@ -1,6 +1,4 @@ -/** - * Aggregates undo stack observers for convenient management and triggering in SPDocument - * +/* * Heavily inspired by Inkscape::XML::CompositeNodeObserver. * * Authors: diff --git a/src/composite-undo-stack-observer.h b/src/composite-undo-stack-observer.h index cd00d4211..c34ab7234 100644 --- a/src/composite-undo-stack-observer.h +++ b/src/composite-undo-stack-observer.h @@ -1,8 +1,4 @@ -/** - * Aggregates undo stack observers for management and triggering in SPDocument - * - * Heavily inspired by Inkscape::XML::CompositeNodeObserver. - * +/* * Authors: * David Yip <yipdw@rose-hulman.edu> * @@ -11,8 +7,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifndef __COMPOSITE_UNDO_COMMIT_OBSERVER_H__ -#define __COMPOSITE_UNDO_COMMIT_OBSERVER_H__ +#ifndef SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H +#define SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H #include "gc-alloc.h" #include "gc-managed.h" @@ -27,6 +23,8 @@ class Event; /** * Aggregates UndoStackObservers for management and triggering in an SPDocument's undo/redo * system. + * + * Heavily inspired by Inkscape::XML::CompositeNodeObserver. */ class CompositeUndoStackObserver : public UndoStackObserver { public: @@ -181,4 +179,4 @@ private: } -#endif +#endif // SEEN_COMPOSITE_UNDO_COMMIT_OBSERVER_H diff --git a/src/console-output-undo-observer.cpp b/src/console-output-undo-observer.cpp index 2cbac74f8..92c937273 100644 --- a/src/console-output-undo-observer.cpp +++ b/src/console-output-undo-observer.cpp @@ -1,4 +1,4 @@ -/** +/* * Inkscape::ConsoleOutputUndoObserver - observer for tracing calls to * SPDocumentUndo::undo, SPDocumentUndo::redo, SPDocumentUndo::maybe_done * diff --git a/src/console-output-undo-observer.h b/src/console-output-undo-observer.h index b5c08a8b5..f47a86534 100644 --- a/src/console-output-undo-observer.h +++ b/src/console-output-undo-observer.h @@ -1,7 +1,4 @@ -/** - * Inkscape::ConsoleOutputUndoObserver - observer for tracing calls to - * SPDocumentUndo::undo, SPDocumentUndo::redo, SPDocumentUndo::maybe_done - * +/* * Authors: * David Yip <yipdw@alumni.rose-hulman.edu> * Abhishek Sharma @@ -18,6 +15,11 @@ namespace Inkscape { +/** + * Inkscape::ConsoleOutputUndoObserver - observer for tracing calls to + * SPDocumentUndo::undo, SPDocumentUndo::redo, SPDocumentUndo::maybe_done. + * + */ class ConsoleOutputUndoObserver : public UndoStackObserver { public: ConsoleOutputUndoObserver() : UndoStackObserver() { } diff --git a/src/libavoid/vpsc.h b/src/libavoid/vpsc.h index 4d6d8ce61..da837c1f8 100644 --- a/src/libavoid/vpsc.h +++ b/src/libavoid/vpsc.h @@ -181,10 +181,13 @@ public: const bool equality; bool unsatisfiable; }; -/* + +/** * A block structure defined over the variables such that each block contains * 1 or more variables, with the invariant that all constraints inside a block - * are satisfied by keeping the variables fixed relative to one another + * are satisfied by keeping the variables fixed relative to one another. + * + * @todo check on this class being copy-n-paste duplicated. */ class Blocks : public std::set<Block*> { diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index 7a1020781..0ecd82faa 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -3,8 +3,10 @@ ** vim: ts=4 sw=4 et tw=0 wm=0 */ /** - * \brief Functions to automatically generate constraints for the + * Functions to automatically generate constraints for the * rectangular node overlap removal problem. + */ +/* * * Authors: * Tim Dwyer <tgdwyer@gmail.com> diff --git a/src/libvpsc/blocks.h b/src/libvpsc/blocks.h index bfe99f271..e3223822e 100644 --- a/src/libvpsc/blocks.h +++ b/src/libvpsc/blocks.h @@ -1,10 +1,4 @@ -/** - * \brief A block structure defined over the variables - * - * A block structure defined over the variables such that each block contains - * 1 or more variables, with the invariant that all constraints inside a block - * are satisfied by keeping the variables fixed relative to one another - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * @@ -24,13 +18,17 @@ #include <list> namespace vpsc { + class Block; class Variable; class Constraint; + /** * A block structure defined over the variables such that each block contains * 1 or more variables, with the invariant that all constraints inside a block - * are satisfied by keeping the variables fixed relative to one another + * are satisfied by keeping the variables fixed relative to one another. + * + * @todo check on this class being copy-n-paste duplicated. */ class Blocks : public std::set<Block*> { diff --git a/src/libvpsc/constraint.cpp b/src/libvpsc/constraint.cpp index af5da941a..2bd173155 100644 --- a/src/libvpsc/constraint.cpp +++ b/src/libvpsc/constraint.cpp @@ -1,7 +1,4 @@ -/** - * \brief A constraint determines a minimum or exact spacing required between - * two variables. - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * diff --git a/src/libvpsc/constraint.h b/src/libvpsc/constraint.h index 8a8529d7e..a3173359c 100644 --- a/src/libvpsc/constraint.h +++ b/src/libvpsc/constraint.h @@ -1,7 +1,4 @@ -/** - * \brief A constraint determines a minimum or exact spacing required between - * two variables. - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * @@ -17,6 +14,11 @@ #include "variable.h" namespace vpsc { +/** + * A constraint determines a minimum or exact spacing required between + * two variables. + * + */ class Constraint { friend std::ostream& operator <<(std::ostream &os,const Constraint &c); diff --git a/src/libvpsc/generate-constraints.cpp b/src/libvpsc/generate-constraints.cpp index 0c35ab51c..8dd2d9331 100644 --- a/src/libvpsc/generate-constraints.cpp +++ b/src/libvpsc/generate-constraints.cpp @@ -1,6 +1,9 @@ /** - * \brief Functions to automatically generate constraints for the + * @file + * Functions to automatically generate constraints for the * rectangular node overlap removal problem. + */ +/* * * Authors: * Tim Dwyer <tgdwyer@gmail.com> diff --git a/src/libvpsc/generate-constraints.h b/src/libvpsc/generate-constraints.h index 8b858af3f..b8d7cdcd9 100644 --- a/src/libvpsc/generate-constraints.h +++ b/src/libvpsc/generate-constraints.h @@ -1,6 +1,10 @@ /** - * \brief Functions to automatically generate constraints for the + * @file + * Functions to automatically generate constraints for the * rectangular node overlap removal problem. + */ +/* TODO replace file comment with appropriate doc comment on vpsc::Rectangle */ +/* * * Authors: * Tim Dwyer <tgdwyer@gmail.com> diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index fc0912539..6d823e6de 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * Abhishek Sharma diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 1440a693f..5dbfb9af5 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * @@ -40,7 +36,6 @@ class GlyphColumns; /** * A panel that displays character glyphs. */ - class GlyphsPanel : public Inkscape::UI::Widget::Panel { public: diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index 6db66f805..1fadf4385 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -1,9 +1,6 @@ -#ifndef __SP_DASH_SELECTOR_NEW_H__ -#define __SP_DASH_SELECTOR_NEW_H__ +#ifndef SEEN_SP_DASH_SELECTOR_NEW_H +#define SEEN_SP_DASH_SELECTOR_NEW_H -/** @file - * @brief Option menu for selecting dash patterns - */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Maximilian Albert <maximilian.albert> (gtkmm-ification) @@ -25,6 +22,9 @@ class Adjustment; } // TODO: should we rather derive this from OptionMenu and add the spinbutton somehow else? +/** + * Option menu for selecting dash patterns. + */ class SPDashSelector : public Gtk::HBox { public: SPDashSelector(); @@ -47,7 +47,7 @@ private: static gchar const *const _prefs_path; }; -#endif +#endif // SEEN_SP_DASH_SELECTOR_NEW_H /* Local Variables: diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 5de246f6b..d867647ed 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -1,7 +1,3 @@ -/** - * @file - * EEK preview stuff. - */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * diff --git a/src/widgets/eek-preview.h b/src/widgets/eek-preview.h index c15f25eb6..7275ab9b4 100644 --- a/src/widgets/eek-preview.h +++ b/src/widgets/eek-preview.h @@ -1,6 +1,3 @@ -/** @file - * @brief EEK preview stuff - */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,6 +40,11 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> +/** + * @file + * Generic implementation of a object that can be shown by a preview. + */ + G_BEGIN_DECLS diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp index 36777d16a..c4325659d 100644 --- a/src/widgets/ege-paint-def.cpp +++ b/src/widgets/ege-paint-def.cpp @@ -1,7 +1,3 @@ -/** - * @file - * EGE paint definition. - */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * diff --git a/src/widgets/ege-paint-def.h b/src/widgets/ege-paint-def.h index 32f92ac3d..856146019 100644 --- a/src/widgets/ege-paint-def.h +++ b/src/widgets/ege-paint-def.h @@ -1,6 +1,3 @@ -/** @file - * @brief EGE paint definition - */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,6 +46,9 @@ namespace ege typedef void (*ColorCallback)( void* data ); +/** + * Pure data representation of a color definition. + */ class PaintDef { public: diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 9cdf9fab3..b8ac50092 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -1,7 +1,3 @@ -/** - * @file - * Widget that listens and modifies repr attributes. - */ /* Authors: * Lauris Kaplinski <lauris@ximian.com> * Abhishek Sharma diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 93342ff4e..a4acf9504 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -1,5 +1,6 @@ -/** @file - * @brief Widget that listens and modifies repr attributes +/** + * @file + * Widget that listens and modifies repr attributes. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 3594e2049..488b10666 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -1,7 +1,3 @@ -/** - * @file - * Stroke style dialog. - */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Bryce Harrington <brycehar@bryceharrington.org> diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index b8ab05810..882901f45 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -1,5 +1,6 @@ -/** @file - * @brief Stroke style dialog +/** + * @file + * Widgets used in the stroke style dialog. */ /* Author: * Lauris Kaplinski <lauris@ximian.com> @@ -19,9 +20,19 @@ class Widget; class Container; } +/** + * Creates an instance of a paint style widget. + */ Gtk::Widget *sp_stroke_style_paint_widget_new(void); + +/** + * Creates an instance of a line style widget. + */ Gtk::Container *sp_stroke_style_line_widget_new(void); +/** + * Switches a line or paint style widget to track the given desktop. + */ void sp_stroke_style_widget_set_desktop(Gtk::Widget *widget, SPDesktop *desktop); #endif // SEEN_DIALOGS_STROKE_STYLE_H diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index a3fbddf0c..d7a1b9bd2 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -1,9 +1,7 @@ #ifndef SEEN_TOOLBOX_H #define SEEN_TOOLBOX_H -/** - * \brief Main toolbox - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Frank Felfe <innerspace@iname.com> @@ -26,6 +24,9 @@ class SPEventContext; namespace Inkscape { namespace UI { +/** + * Main toolbox source. + */ class ToolboxFactory { public: -- cgit v1.2.3 From f12861c744aff474afdaa457781008cbb995113f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 23 Oct 2011 02:03:12 -0700 Subject: Cleanup constructors and initialization. Removed unused macro. (bzr r10693) --- src/version.cpp | 23 ++++++++-------- src/version.h | 82 ++++++++++++++++++++++++++++++++------------------------- 2 files changed, 57 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/version.cpp b/src/version.cpp index edaa600db..1baf9d8d9 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -1,10 +1,9 @@ -#define __VERSION_C__ - /* * Versions * * Authors: * MenTaLguY <mental@rydia.net> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2003 MenTaLguY * @@ -21,31 +20,31 @@ gboolean sp_version_from_string(const gchar *string, Inkscape::Version *version) return FALSE; } - version->major = 0; - version->minor = 0; + version->_major = 0; + version->_minor = 0; return sscanf((const char *)string, "%u.%u", - &version->major, &version->minor) || - sscanf((const char *)string, "%u", &version->major); + &version->_major, &version->_minor) || + sscanf((const char *)string, "%u", &version->_major); } gchar *sp_version_to_string(Inkscape::Version version) { - return g_strdup_printf("%u.%u", version.major, version.minor); + return g_strdup_printf("%u.%u", version._major, version._minor); } gboolean sp_version_inside_range(Inkscape::Version version, unsigned major_min, unsigned minor_min, unsigned major_max, unsigned minor_max) { - if ( version.major < major_min || version.major > major_max ) { + if ( version._major < major_min || version._major > major_max ) { return FALSE; - } else if ( version.major == major_min && - version.minor <= minor_min ) + } else if ( version._major == major_min && + version._minor <= minor_min ) { return FALSE; - } else if ( version.major == major_max && - version.minor >= minor_max ) + } else if ( version._major == major_max && + version._minor >= minor_max ) { return FALSE; } else { diff --git a/src/version.h b/src/version.h index faa8c38b2..d90d27772 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,7 @@ /* * Authors: * MenTaLguY <mental@rydia.net> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2003 MenTaLguY * @@ -16,45 +17,54 @@ namespace Inkscape { -struct Version { - Version() { - major = 0; - minor = 0; - } - Version(unsigned mj, unsigned mn) { - // somebody pollutes our namespace with major() and minor() - // macros, so we can't use new-style initializers - major = mj; - minor = mn; - } - - unsigned major; - unsigned minor; - - bool operator>(Version const &other) const { - return major > other.major || - ( major == other.major && minor > other.minor ); - } - bool operator==(Version const &other) const { - return major == other.major && minor == other.minor; - } - bool operator!=(Version const &other) const { - return major != other.major || minor != other.minor; - } - bool operator<(Version const &other) const { - return major < other.major || - ( major == other.major && minor < other.minor ); - } +class Version { +public: + + Version() : _major(0), _minor(0) {} + + // Note: somebody pollutes our namespace with major() and minor() + Version(unsigned mj, unsigned mn) : _major(mj), _minor(mn) {} + + bool operator>(Version const &other) const { + return _major > other._major || + ( _major == other._major && _minor > other._minor ); + } + + bool operator==(Version const &other) const { + return _major == other._major && _minor == other._minor; + } + + bool operator!=(Version const &other) const { + return _major != other._major || _minor != other._minor; + } + + bool operator<(Version const &other) const { + return _major < other._major || + ( _major == other._major && _minor < other._minor ); + } + + unsigned int _major; + unsigned int _minor; }; } -#define SP_VERSION_IS_ZERO (v) (!(v).major && !(v).minor) +gboolean sp_version_from_string(const gchar *string, Inkscape::Version *version); -gboolean sp_version_from_string (const gchar *string, Inkscape::Version *version); -gchar *sp_version_to_string (Inkscape::Version version); -gboolean sp_version_inside_range (Inkscape::Version version, - unsigned major_min, unsigned minor_min, - unsigned major_max, unsigned minor_max); +gchar *sp_version_to_string(Inkscape::Version version); -#endif +gboolean sp_version_inside_range(Inkscape::Version version, + unsigned major_min, unsigned minor_min, + unsigned major_max, unsigned minor_max); + +#endif // SEEN_INKSCAPE_VERSION_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:75 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From b9277e5c7b687ebc58e67350174ee049566942dd Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 23 Oct 2011 02:27:51 -0700 Subject: Warning cleanup (bzr r10694) --- src/extension/internal/pdfinput/svg-builder.cpp | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 0103e523b..be60493e0 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1342,7 +1342,7 @@ void SvgBuilder::_flushText() { _glyphs.clear(); } -void SvgBuilder::beginString(GfxState *state, GooString *s) { +void SvgBuilder::beginString(GfxState *state, GooString * /*s*/) { if (_need_font_update) { updateFont(state); } @@ -1360,7 +1360,7 @@ void SvgBuilder::beginString(GfxState *state, GooString *s) { void SvgBuilder::addChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, - CharCode code, int nBytes, Unicode *u, int uLen) { + CharCode /*code*/, int /*nBytes*/, Unicode *u, int uLen) { bool is_space = ( uLen == 1 && u[0] == 32 ); @@ -1428,7 +1428,7 @@ void SvgBuilder::addChar(GfxState *state, double x, double y, _glyphs.push_back(new_glyph); } -void SvgBuilder::endString(GfxState *state) { +void SvgBuilder::endString(GfxState * /*state*/) { } void SvgBuilder::beginTextObject(GfxState *state) { @@ -1437,7 +1437,7 @@ void SvgBuilder::beginTextObject(GfxState *state) { _current_state = state; } -void SvgBuilder::endTextObject(GfxState *state) { +void SvgBuilder::endTextObject(GfxState * /*state*/) { _flushText(); // TODO: clip if render_mode >= 4 _in_text_object = false; @@ -1692,7 +1692,7 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) { } } -void SvgBuilder::addImage(GfxState *state, Stream *str, int width, int height, +void SvgBuilder::addImage(GfxState * /*state*/, Stream *str, int width, int height, GfxImageColorMap *color_map, int *mask_colors) { Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, mask_colors); @@ -1739,7 +1739,7 @@ void SvgBuilder::addImageMask(GfxState *state, Stream *str, int width, int heigh Inkscape::GC::release(rect); } -void SvgBuilder::addMaskedImage(GfxState *state, Stream *str, int width, int height, +void SvgBuilder::addMaskedImage(GfxState * /*state*/, Stream *str, int width, int height, GfxImageColorMap *color_map, Stream *mask_str, int mask_width, int mask_height, bool invert_mask) { @@ -1772,7 +1772,7 @@ void SvgBuilder::addMaskedImage(GfxState *state, Stream *str, int width, int hei } } -void SvgBuilder::addSoftMaskedImage(GfxState *state, Stream *str, int width, int height, +void SvgBuilder::addSoftMaskedImage(GfxState * /*state*/, Stream *str, int width, int height, GfxImageColorMap *color_map, Stream *mask_str, int mask_width, int mask_height, GfxImageColorMap *mask_color_map) { @@ -1803,8 +1803,8 @@ void SvgBuilder::addSoftMaskedImage(GfxState *state, Stream *str, int width, int /** * \brief Starts building a new transparency group */ -void SvgBuilder::pushTransparencyGroup(GfxState *state, double *bbox, - GfxColorSpace *blending_color_space, +void SvgBuilder::pushTransparencyGroup(GfxState * /*state*/, double *bbox, + GfxColorSpace * /*blending_color_space*/, bool isolated, bool knockout, bool for_softmask) { @@ -1824,7 +1824,7 @@ void SvgBuilder::pushTransparencyGroup(GfxState *state, double *bbox, _transp_group_stack = transpGroup; } -void SvgBuilder::popTransparencyGroup(GfxState *state) { +void SvgBuilder::popTransparencyGroup(GfxState * /*state*/) { // Restore node stack popNode(); } @@ -1832,7 +1832,7 @@ void SvgBuilder::popTransparencyGroup(GfxState *state) { /** * \brief Places the current transparency group into the current container */ -void SvgBuilder::paintTransparencyGroup(GfxState *state, double *bbox) { +void SvgBuilder::paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) { SvgTransparencyGroup *transpGroup = _transp_group_stack; _container->appendChild(transpGroup->container); Inkscape::GC::release(transpGroup->container); @@ -1844,8 +1844,8 @@ void SvgBuilder::paintTransparencyGroup(GfxState *state, double *bbox) { /** * \brief Creates a mask using the current transparency group as its content */ -void SvgBuilder::setSoftMask(GfxState *state, double *bbox, bool alpha, - Function *transfer_func, GfxColor *backdrop_color) { +void SvgBuilder::setSoftMask(GfxState * /*state*/, double * /*bbox*/, bool /*alpha*/, + Function * /*transfer_func*/, GfxColor * /*backdrop_color*/) { // Create mask Inkscape::XML::Node *mask_node = _createMask(1.0, 1.0); @@ -1864,7 +1864,7 @@ void SvgBuilder::setSoftMask(GfxState *state, double *bbox, bool alpha, delete transpGroup; } -void SvgBuilder::clearSoftMask(GfxState *state) { +void SvgBuilder::clearSoftMask(GfxState * /*state*/) { if (_state_stack.back().softmask) { _state_stack.back().softmask = NULL; popGroup(); -- cgit v1.2.3 From 1555ec455e3e23a4687f661d9389c21d11e806f7 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sun, 23 Oct 2011 12:07:29 +0200 Subject: cppcheck (bzr r10695) --- src/dom/dom.h | 16 ++++++++-------- src/dom/events.h | 8 ++++---- src/dom/io/gzipstream.cpp | 2 +- src/dom/uri.cpp | 10 +++++----- src/dom/util/digest.cpp | 2 +- src/dom/util/ziptool.cpp | 22 +++++++++++----------- 6 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/dom/dom.h b/src/dom/dom.h index 21ea44669..674a84186 100644 --- a/src/dom/dom.h +++ b/src/dom/dom.h @@ -436,7 +436,7 @@ public: * Return whether the namespaced name argument is present in the list. * This is done lexically, not identically. */ - virtual bool containsNS(const DOMString namespaceURI,const DOMString &name) + virtual bool containsNS(const DOMString &namespaceURI, const DOMString &name) { for (unsigned int i=0; i<namePairs.size() ; i++) { @@ -962,7 +962,7 @@ protected: /** * For the Ptr smart pointer - */ + */ int _refCnt; }; @@ -1122,7 +1122,7 @@ public: virtual NodePtr getNamedItem(const DOMString& name) { std::vector<NamedNodeMapEntry>::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; iter++) + for (iter = entries.begin() ; iter!=entries.end() ; ++iter) { if (iter->name == name) { @@ -1145,7 +1145,7 @@ public: DOMString namespaceURI = arg->getNamespaceURI(); DOMString name = arg->getNodeName(); std::vector<NamedNodeMapEntry>::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; iter++) + for (iter = entries.begin() ; iter!=entries.end() ; ++iter) { if (iter->name == name) { @@ -1166,7 +1166,7 @@ public: virtual NodePtr removeNamedItem(const DOMString& name) throw(DOMException) { std::vector<NamedNodeMapEntry>::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; iter++) + for (iter = entries.begin() ; iter!=entries.end() ; ++iter) { if (iter->name == name) { @@ -1203,7 +1203,7 @@ public: const DOMString& localName) { std::vector<NamedNodeMapEntry>::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; iter++) + for (iter = entries.begin() ; iter!=entries.end() ; ++iter) { if (iter->namespaceURI == namespaceURI && iter->name == localName) { @@ -1226,7 +1226,7 @@ public: DOMString namespaceURI = arg->getNamespaceURI(); DOMString name = arg->getNodeName(); std::vector<NamedNodeMapEntry>::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; iter++) + for (iter = entries.begin() ; iter!=entries.end() ; ++iter) { if (iter->namespaceURI == namespaceURI && iter->name == name) { @@ -1248,7 +1248,7 @@ public: throw(DOMException) { std::vector<NamedNodeMapEntry>::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; iter++) + for (iter = entries.begin() ; iter!=entries.end() ; ++iter) { if (iter->namespaceURI == namespaceURI && iter->name == localName) { diff --git a/src/dom/events.h b/src/dom/events.h index 1fd77890c..e6a8e0d6c 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -510,7 +510,7 @@ public: bool useCapture) { std::vector<EventListenerEntry>::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; iter++) + for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) { EventListenerEntry entry = *iter; if (entry.eventType == type && @@ -568,7 +568,7 @@ public: bool useCapture) { std::vector<EventListenerEntry>::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; iter++) + for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) { EventListenerEntry entry = *iter; if (entry.namespaceURI == namespaceURI && @@ -589,7 +589,7 @@ public: const DOMString &type) { std::vector<EventListenerEntry>::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; iter++) + for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) { EventListenerEntry entry = *iter; if (entry.namespaceURI == namespaceURI && @@ -611,7 +611,7 @@ public: const DOMString &type) { std::vector<EventListenerEntry>::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; iter++) + for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) { EventListenerEntry entry = *iter; if (entry.namespaceURI == namespaceURI && diff --git a/src/dom/io/gzipstream.cpp b/src/dom/io/gzipstream.cpp index 9ac24dc75..9dffceea2 100644 --- a/src/dom/io/gzipstream.cpp +++ b/src/dom/io/gzipstream.cpp @@ -197,7 +197,7 @@ void GzipOutputStream::flush() gz.writeBuffer(buffer); std::vector<unsigned char>::iterator iter; - for (iter=compBuf.begin() ; iter!=compBuf.end() ; iter++) + for (iter=compBuf.begin() ; iter!=compBuf.end() ; ++iter) { int ch = (int) *iter; destination.put(ch); diff --git a/src/dom/uri.cpp b/src/dom/uri.cpp index b8a9a04fb..6a34f1838 100644 --- a/src/dom/uri.cpp +++ b/src/dom/uri.cpp @@ -179,7 +179,7 @@ static DOMString toStr(const std::vector<int> &arr) { DOMString buf; std::vector<int>::const_iterator iter; - for (iter=arr.begin() ; iter!=arr.end() ; iter++) + for (iter=arr.begin() ; iter!=arr.end() ; ++iter) { int ch = *iter; if (isprint(ch)) @@ -503,13 +503,13 @@ void URI::normalize() else if (sequ(s, "..") && iter != segments.begin() && !sequ(*(iter-1), "..")) { - iter--; //back up, then erase two entries + --iter; //back up, then erase two entries iter = segments.erase(iter); iter = segments.erase(iter); edited = true; } else - iter++; + ++iter; } //## Rebuild path, if necessary @@ -521,7 +521,7 @@ void URI::normalize() path.push_back('/'); } std::vector< std::vector<int> >::iterator iter; - for (iter=segments.begin() ; iter!=segments.end() ; iter++) + for (iter=segments.begin() ; iter!=segments.end() ; ++iter) { if (iter != segments.begin()) path.push_back('/'); @@ -920,7 +920,7 @@ bool URI::parse(const DOMString &str) DOMString::const_iterator iter; unsigned int i=0; - for (iter= str.begin() ; iter!=str.end() ; iter++) + for (iter= str.begin() ; iter!=str.end() ; ++iter) { int ch = *iter; if (ch == '\\') diff --git a/src/dom/util/digest.cpp b/src/dom/util/digest.cpp index 282979775..f416f5522 100644 --- a/src/dom/util/digest.cpp +++ b/src/dom/util/digest.cpp @@ -58,7 +58,7 @@ static std::string toHex(const std::vector<unsigned char> &bytes) { std::string str; std::vector<unsigned char>::const_iterator iter; - for (iter = bytes.begin() ; iter != bytes.end() ; iter++) + for (iter = bytes.begin() ; iter != bytes.end() ; ++iter) { unsigned char ch = *iter; str.push_back(hexDigits[(ch>>4) & 0x0f]); diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp index 1e915ab0a..89e85cc84 100644 --- a/src/dom/util/ziptool.cpp +++ b/src/dom/util/ziptool.cpp @@ -175,7 +175,7 @@ void Crc32::update(char *str) void Crc32::update(const std::vector<unsigned char> &buf) { std::vector<unsigned char>::const_iterator iter; - for (iter=buf.begin() ; iter!=buf.end() ; iter++) + for (iter=buf.begin() ; iter!=buf.end() ; ++iter) { unsigned char ch = *iter; update(ch); @@ -1390,7 +1390,7 @@ bool Deflater::compress() while (window.size() < 32768 && iter != uncompressed.end()) { window.push_back(*iter); - iter++; + ++iter; } if (window.size() >= 32768) putBits(0x00, 1); //0 -- more blocks @@ -1595,7 +1595,7 @@ bool GzipFile::write() } std::vector<unsigned char>::iterator iter; - for (iter=compBuf.begin() ; iter!=compBuf.end() ; iter++) + for (iter=compBuf.begin() ; iter!=compBuf.end() ; ++iter) { unsigned char ch = *iter; putByte(ch); @@ -1636,7 +1636,7 @@ bool GzipFile::writeFile(const std::string &fileName) if (!f) return false; std::vector<unsigned char>::iterator iter; - for (iter=fileBuf.begin() ; iter!=fileBuf.end() ; iter++) + for (iter=fileBuf.begin() ; iter!=fileBuf.end() ; ++iter) { unsigned char ch = *iter; fputc(ch, f); @@ -2033,7 +2033,7 @@ void ZipEntry::finish() Crc32 c32; std::vector<unsigned char>::iterator iter; for (iter = uncompressedData.begin() ; - iter!= uncompressedData.end() ; iter++) + iter!= uncompressedData.end() ; ++iter) { unsigned char ch = *iter; c32.update(ch); @@ -2044,7 +2044,7 @@ void ZipEntry::finish() case 0: //none { for (iter = uncompressedData.begin() ; - iter!= uncompressedData.end() ; iter++) + iter!= uncompressedData.end() ; ++iter) { unsigned char ch = *iter; compressedData.push_back(ch); @@ -2135,7 +2135,7 @@ ZipFile::ZipFile() ZipFile::~ZipFile() { std::vector<ZipEntry *>::iterator iter; - for (iter=entries.begin() ; iter!=entries.end() ; iter++) + for (iter=entries.begin() ; iter!=entries.end() ; ++iter) { ZipEntry *entry = *iter; delete entry; @@ -2269,7 +2269,7 @@ bool ZipFile::putByte(unsigned char val) bool ZipFile::writeFileData() { std::vector<ZipEntry *>::iterator iter; - for (iter = entries.begin() ; iter != entries.end() ; iter++) + for (iter = entries.begin() ; iter != entries.end() ; ++iter) { ZipEntry *entry = *iter; entry->setPosition(fileBuf.size()); @@ -2299,7 +2299,7 @@ bool ZipFile::writeFileData() //##### DATA std::vector<unsigned char> &buf = entry->getCompressedData(); std::vector<unsigned char>::iterator iter; - for (iter = buf.begin() ; iter != buf.end() ; iter++) + for (iter = buf.begin() ; iter != buf.end() ; ++iter) { unsigned char ch = (unsigned char) *iter; putByte(ch); @@ -2315,7 +2315,7 @@ bool ZipFile::writeCentralDirectory() { unsigned long cdPosition = fileBuf.size(); std::vector<ZipEntry *>::iterator iter; - for (iter = entries.begin() ; iter != entries.end() ; iter++) + for (iter = entries.begin() ; iter != entries.end() ; ++iter) { ZipEntry *entry = *iter; std::string fname = entry->getFileName(); @@ -2403,7 +2403,7 @@ bool ZipFile::writeFile(const std::string &fileName) if (!f) return false; std::vector<unsigned char>::iterator iter; - for (iter=fileBuf.begin() ; iter!=fileBuf.end() ; iter++) + for (iter=fileBuf.begin() ; iter!=fileBuf.end() ; ++iter) { unsigned char ch = *iter; fputc(ch, f); -- cgit v1.2.3 From 1a5d5d8a7e796035bc70d5c727d4d901dda50726 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Tue, 25 Oct 2011 00:45:35 -0700 Subject: Cleanup pass on documentation that was dumping garbage into doxygen output. (bzr r10696) --- src/2geom/basic-intersection.h | 7 +- src/2geom/conic_section_clipper.h | 7 +- src/2geom/conic_section_clipper_cr.h | 7 +- src/2geom/conic_section_clipper_impl.h | 7 +- src/2geom/conicsec.h | 7 +- src/2geom/convex-cover.h | 7 +- src/2geom/ellipse.h | 7 +- src/2geom/geom.h | 7 +- src/2geom/linear.h | 7 +- src/2geom/nearest-point.h | 7 +- src/2geom/piecewise.h | 5 +- src/2geom/sbasis-geometric.h | 13 +- src/2geom/sbasis-math.h | 7 +- src/2geom/sbasis-poly.h | 7 +- src/2geom/sbasis.h | 7 +- src/2geom/shape.h | 7 +- src/2geom/svg-path-parser.h | 7 +- src/2geom/svg-path.h | 7 +- src/2geom/toposweep.h | 3 +- src/bind/javabind-private.h | 9 +- src/bind/javabind.h | 9 +- src/bind/javainc/jni.h | 2 +- src/color-rgba.h | 135 ++++++++++--------- src/color.h | 4 +- src/desktop.h | 4 +- src/display/canvas-temporary-item-list.h | 7 +- src/display/canvas-temporary-item.h | 7 +- src/display/curve.h | 7 +- src/display/grayscale.h | 9 +- src/display/nr-filter-utils.h | 8 +- src/display/snap-indicator.h | 6 +- src/display/sodipodi-ctrlrect.h | 5 +- src/display/sp-canvas-group.h | 8 +- src/display/sp-canvas-item.h | 6 +- src/display/sp-canvas.h | 6 +- src/dom/css.h | 10 +- src/dom/cssreader.h | 10 +- src/dom/dom.h | 10 +- src/dom/domimpl.h | 10 +- src/dom/domptr.h | 10 +- src/dom/domstring.h | 10 +- src/dom/events.h | 10 +- src/dom/io/base64stream.h | 10 +- src/dom/io/bufferstream.h | 10 +- src/dom/io/domstream.h | 10 +- src/dom/io/gzipstream.h | 9 +- src/dom/io/stringstream.h | 10 +- src/dom/io/uristream.h | 9 +- src/dom/ls.h | 10 +- src/dom/lsimpl.h | 10 +- src/dom/odf/odfdocument.h | 16 +-- src/dom/smil.h | 10 +- src/dom/smilimpl.h | 9 +- src/dom/stylesheets.h | 10 +- src/dom/svg.h | 10 +- src/dom/svg2.h | 10 +- src/dom/svgimpl.h | 10 +- src/dom/svgreader.h | 10 +- src/dom/svgtypes.h | 10 +- src/dom/traversal.h | 11 +- src/dom/ucd.h | 14 +- src/dom/uri.h | 10 +- src/dom/util/digest.h | 10 +- src/dom/util/thread.h | 11 +- src/dom/util/ziptool.h | 9 +- src/dom/views-level3.h | 12 +- src/dom/views.h | 10 +- src/dom/xmlreader.h | 9 +- src/dom/xmlwriter.h | 10 +- src/dom/xpath.h | 10 +- src/dom/xpathimpl.h | 8 +- src/dom/xpathparser.h | 18 +-- src/dom/xpathtoken.h | 10 +- src/event-context.h | 10 +- src/event-log.h | 50 +++---- src/extension/internal/gimpgrad.h | 21 +-- src/extension/internal/odf.h | 23 ++-- src/extension/internal/pdfinput/pdf-input.h | 19 +-- src/extension/internal/pdfinput/pdf-parser.h | 11 +- src/extension/internal/pdfinput/svg-builder.h | 25 ++-- src/extension/script/InkscapeScript.h | 11 +- src/gc-anchored.h | 4 +- src/gc-soft-ptr.h | 9 +- src/graphlayout.h | 6 +- src/guide-snapper.h | 10 +- src/help.h | 9 +- src/helper-fns.h | 5 +- src/helper/geom-curves.h | 4 +- src/helper/geom-nodetype.h | 4 +- src/helper/geom.h | 4 +- src/io/base64stream.h | 10 +- src/io/gzipstream.h | 10 +- src/io/inkscapestream.h | 10 +- src/io/resource.h | 7 +- src/io/uristream.h | 10 +- src/io/xsltstream.h | 9 +- src/knot-enums.h | 6 +- src/knot-holder-entity.h | 8 +- src/libcola/defs.h | 2 +- src/libvpsc/block.h | 11 +- src/libvpsc/csolve_VPSC.h | 6 +- src/libvpsc/pairingheap/PairingHeap.cpp | 6 +- src/libvpsc/pairingheap/PairingHeap.h | 15 ++- src/libvpsc/solve_VPSC.h | 6 +- src/libvpsc/variable.h | 3 +- src/line-snapper.h | 10 +- src/object-hierarchy.h | 5 +- src/object-snapper.h | 9 +- src/registrytool.h | 21 +-- src/rubberband.h | 9 +- src/selection.h | 112 ++++++++-------- src/snap-candidate.h | 7 +- src/snap-enums.h | 9 +- src/snap-preferences.h | 8 +- src/sp-gradient.h | 5 +- src/sp-object.h | 10 +- src/sp-offset.h | 9 +- src/sp-spiral.h | 11 +- src/svg-view-widget.h | 5 +- src/svg-view.h | 11 +- src/svg/path-string.h | 7 +- src/trace/siox.h | 13 +- src/trace/trace.h | 8 +- src/ui/dialog/guides.h | 8 +- src/ui/view/edit-widget-interface.h | 9 +- src/ui/view/view-widget.h | 15 ++- src/ui/view/view.h | 5 +- src/ui/widget/attr-widget.h | 7 +- src/ui/widget/button.h | 10 +- src/ui/widget/color-preview.h | 22 ++-- src/ui/widget/combo-enums.h | 10 +- src/ui/widget/dock-item.h | 7 +- src/ui/widget/entity-entry.h | 4 +- src/ui/widget/entry.h | 8 +- src/ui/widget/handlebox.h | 14 +- src/ui/widget/icon-widget.h | 7 +- src/ui/widget/labelled.h | 8 +- src/ui/widget/licensor.h | 15 ++- src/ui/widget/notebook-page.h | 7 +- src/ui/widget/page-sizer.h | 10 +- src/ui/widget/panel.h | 7 +- src/ui/widget/point.h | 10 +- src/ui/widget/preferences-widget.h | 6 +- src/ui/widget/random.h | 9 +- src/ui/widget/registered-enums.h | 7 +- src/ui/widget/registered-widget.h | 4 +- src/ui/widget/registry.h | 5 +- src/ui/widget/rendering-options.h | 7 +- src/ui/widget/rotateable.h | 7 +- src/ui/widget/ruler.h | 25 ++-- src/ui/widget/scalar-unit.h | 10 +- src/ui/widget/scalar.h | 9 +- src/ui/widget/selected-style.h | 7 +- src/ui/widget/spin-slider.h | 13 +- src/ui/widget/style-subject.h | 9 +- src/ui/widget/svg-canvas.h | 17 +-- src/ui/widget/text.h | 8 +- src/ui/widget/toolbox.h | 7 +- src/ui/widget/unit-menu.h | 7 +- src/ui/widget/zoom-status.h | 14 +- src/undo-stack-observer.h | 12 +- src/uri.h | 9 +- src/util/enums.h | 26 ++-- src/util/list.h | 39 +++--- src/verbs.h | 179 ++++++++++++++------------ src/widgets/paint-selector.h | 7 +- 166 files changed, 1055 insertions(+), 944 deletions(-) (limited to 'src') diff --git a/src/2geom/basic-intersection.h b/src/2geom/basic-intersection.h index 5a813ae99..8e29b4617 100644 --- a/src/2geom/basic-intersection.h +++ b/src/2geom/basic-intersection.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Basic intersection routines - * + * @file + * Basic intersection routines. + */ +/* * Authors: * ? <?@?.?> * diff --git a/src/2geom/conic_section_clipper.h b/src/2geom/conic_section_clipper.h index a02cda4d3..3e4ac8429 100644 --- a/src/2geom/conic_section_clipper.h +++ b/src/2geom/conic_section_clipper.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Conic section clipping with respect to a rectangle - * + * @file + * Conic section clipping with respect to a rectangle. + */ +/* * Authors: * Marco Cecchetti <mrcekets at gmail> * diff --git a/src/2geom/conic_section_clipper_cr.h b/src/2geom/conic_section_clipper_cr.h index 31f5a4269..687fa182d 100644 --- a/src/2geom/conic_section_clipper_cr.h +++ b/src/2geom/conic_section_clipper_cr.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Conic section clipping with respect to a rectangle - * + * @file + * Conic section clipping with respect to a rectangle. + */ +/* * Authors: * Marco Cecchetti <mrcekets at gmail> * diff --git a/src/2geom/conic_section_clipper_impl.h b/src/2geom/conic_section_clipper_impl.h index 7db4fca9f..ba213b8d5 100644 --- a/src/2geom/conic_section_clipper_impl.h +++ b/src/2geom/conic_section_clipper_impl.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Conic section clipping with respect to a rectangle - * + * @file + * Conic section clipping with respect to a rectangle. + */ +/* * Authors: * Marco Cecchetti <mrcekets at gmail> * diff --git a/src/2geom/conicsec.h b/src/2geom/conicsec.h index be9a68bfa..d9c5e7bc5 100644 --- a/src/2geom/conicsec.h +++ b/src/2geom/conicsec.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Conic Section - * + * @file + * Conic Section. + */ +/* * Authors: * Nathan Hurst <njh@njhurst.com> * diff --git a/src/2geom/convex-cover.h b/src/2geom/convex-cover.h index e4b5de200..4c1b59d17 100644 --- a/src/2geom/convex-cover.h +++ b/src/2geom/convex-cover.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Dynamic convex hull structure - * + * @file + * Dynamic convex hull structure. + */ +/* * Copyright 2006 Nathan Hurst <njh@mail.csse.monash.edu.au> * Copyright 2006 Michael G. Sloan <mgsloan@gmail.com> * diff --git a/src/2geom/ellipse.h b/src/2geom/ellipse.h index 297254366..2d6ba399f 100644 --- a/src/2geom/ellipse.h +++ b/src/2geom/ellipse.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Ellipse Curve - * + * @file + * Ellipse Curve. + */ +/* * Authors: * Marco Cecchetti <mrcekets at gmail.com> * diff --git a/src/2geom/geom.h b/src/2geom/geom.h index 5aeded23d..b9d910e2a 100644 --- a/src/2geom/geom.h +++ b/src/2geom/geom.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Various geometrical calculations - * + * @file + * Various geometrical calculations. + */ +/* * Authors: * Nathan Hurst <njh@mail.csse.monash.edu.au> * diff --git a/src/2geom/linear.h b/src/2geom/linear.h index df6dd9904..6302d810e 100644 --- a/src/2geom/linear.h +++ b/src/2geom/linear.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Linear fragment function class - * + * @file + * Linear fragment function class. + */ +/* * Authors: * Nathan Hurst <njh@mail.csse.monash.edu.au> * Michael Sloan <mgsloan@gmail.com> diff --git a/src/2geom/nearest-point.h b/src/2geom/nearest-point.h index 19485242c..484c47afc 100644 --- a/src/2geom/nearest-point.h +++ b/src/2geom/nearest-point.h @@ -1,7 +1,8 @@ /** - * \file - * \brief nearest point routines for D2<SBasis> and Piecewise<D2<SBasis>> - * + * @file + * nearest point routines for D2<SBasis> and Piecewise<D2<SBasis>>. + */ +/* * Authors: * * Marco Cecchetti <mrcekets at gmail.com> diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index 837f33ea7..310de23b1 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -1,7 +1,4 @@ -/** - * \file - * \brief Piecewise function class - * +/* * Copyright 2007 Michael Sloan <mgsloan@gmail.com> * * This library is free software; you can redistribute it and/or diff --git a/src/2geom/sbasis-geometric.h b/src/2geom/sbasis-geometric.h index f7216c15a..841d75a28 100644 --- a/src/2geom/sbasis-geometric.h +++ b/src/2geom/sbasis-geometric.h @@ -1,13 +1,14 @@ -#ifndef _SBASIS_GEOMETRIC -#define _SBASIS_GEOMETRIC +#ifndef SEEN_SBASIS_GEOMETRIC_ +#define SEEN_SBASIS_GEOMETRIC_ #include <2geom/d2.h> #include <2geom/piecewise.h> #include <vector> /** - * \file - * \brief two-dimensional geometric operators. - * + * @file + * two-dimensional geometric operators. + */ +/* * Copyright 2007, JFBarraud * Copyright 2007, njh * @@ -104,7 +105,7 @@ std::vector<double> find_tangents(Point P, D2<SBasis> const &A); }; -#endif +#endif // SEEN_SBASIS_GEOMETRIC_ /* Local Variables: diff --git a/src/2geom/sbasis-math.h b/src/2geom/sbasis-math.h index e6d40a3de..c3f7518eb 100644 --- a/src/2geom/sbasis-math.h +++ b/src/2geom/sbasis-math.h @@ -1,7 +1,8 @@ /** - * \file - * \brief some std functions to work with (pw)s-basis - * + * @file + * some std functions to work with (pw)s-basis. + */ +/* * Authors: * Jean-Francois Barraud * diff --git a/src/2geom/sbasis-poly.h b/src/2geom/sbasis-poly.h index e0bef9333..70abfeea1 100644 --- a/src/2geom/sbasis-poly.h +++ b/src/2geom/sbasis-poly.h @@ -5,9 +5,10 @@ #include <2geom/sbasis.h> /** - * \file - * \brief Conversion between SBasis and Poly. Not recommended for general use due to instability. - * + * @file + * Conversion between SBasis and Poly. Not recommended for general use due to instability. + */ +/* * Authors: * ? <?@?.?> * diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h index 7a7e33fe4..f3598ccc8 100644 --- a/src/2geom/sbasis.h +++ b/src/2geom/sbasis.h @@ -1,7 +1,8 @@ /** - * \file - * \brief Defines S-power basis function class - * + * @file + * Defines S-power basis function class. + */ +/* * Authors: * Nathan Hurst <njh@mail.csse.monash.edu.au> * Michael Sloan <mgsloan@gmail.com> diff --git a/src/2geom/shape.h b/src/2geom/shape.h index 0a7ee9709..9f7ead4aa 100644 --- a/src/2geom/shape.h +++ b/src/2geom/shape.h @@ -1,6 +1,4 @@ -/** - * \brief Shapes are special paths on which boolops can be performed - * +/* * Authors: * Michael G. Sloan <mgsloan@gmail.com> * Nathan Hurst <njh@mail.csse.monash.edu.au> @@ -63,6 +61,9 @@ enum { BOOLOP_UNION = BOOLOP_JUST_A | BOOLOP_JUST_B | BOOLOP_BOTH }; +/** + * Shapes are special paths on which boolops can be performed. + */ class Shape { Regions content; mutable bool fill; diff --git a/src/2geom/svg-path-parser.h b/src/2geom/svg-path-parser.h index 93fd23b77..1aab8bb36 100644 --- a/src/2geom/svg-path-parser.h +++ b/src/2geom/svg-path-parser.h @@ -1,7 +1,8 @@ /** - * \file - * \brief parse SVG path specifications - * + * @file + * parse SVG path specifications. + */ +/* * Copyright 2007 MenTaLguY <mental@rydia.net> * Copyright 2007 Aaron Spike <aaron@ekips.org> * diff --git a/src/2geom/svg-path.h b/src/2geom/svg-path.h index 89192fb72..89dcb4759 100644 --- a/src/2geom/svg-path.h +++ b/src/2geom/svg-path.h @@ -1,7 +1,8 @@ /** - * \file - * \brief callback interface for SVG path data - * + * @file + * callback interface for SVG path data. + */ +/* * Copyright 2007 MenTaLguY <mental@rydia.net> * * This library is free software; you can redistribute it and/or diff --git a/src/2geom/toposweep.h b/src/2geom/toposweep.h index 428115dd3..b8c1bdcf4 100644 --- a/src/2geom/toposweep.h +++ b/src/2geom/toposweep.h @@ -2,7 +2,8 @@ /** * \file * \brief TopoSweep - topology / graph representation of a PathVector, for boolean operations and related tasks - * + */ +/* * Authors: * Michael Sloan <mgsloan at gmail.com> * Nathan Hurst <njhurst at njhurst.com> diff --git a/src/bind/javabind-private.h b/src/bind/javabind-private.h index a03f0c1a2..56ff2e2ff 100644 --- a/src/bind/javabind-private.h +++ b/src/bind/javabind-private.h @@ -2,7 +2,8 @@ * @file * @brief This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. - * + */ +/* * Authors: * Bob Jamison * @@ -23,8 +24,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __JAVABIND_PRIVATE_H__ -#define __JAVABIND_PRIVATE_H__ +#ifndef SEEN_JAVABIND_PRIVATE_H +#define SEEN_JAVABIND_PRIVATE_H #include <jni.h> #include "javabind.h" @@ -139,7 +140,7 @@ void setString(JNIEnv *env, jobject obj, const char *name, const String &val); } // namespace Bind } // namespace Inkscape -#endif /* __JAVABIND_PRIVATE_H__ */ +#endif // SEEN_JAVABIND_PRIVATE_H //######################################################################## //# E N D O F F I L E //######################################################################## diff --git a/src/bind/javabind.h b/src/bind/javabind.h index 894f52d5d..254548bfb 100644 --- a/src/bind/javabind.h +++ b/src/bind/javabind.h @@ -2,7 +2,8 @@ * @file * @brief This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. - * + */ +/* * Authors: * Bob Jamison * @@ -23,8 +24,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __JAVABIND_H__ -#define __JAVABIND_H__ +#ifndef SEEN_JAVABIND_H +#define SEEN_JAVABIND_H #include <glibmm.h> #include <vector> @@ -397,7 +398,7 @@ protected: } // namespace Bind } // namespace Inkscape -#endif /* __JAVABIND_H__ */ +#endif // SEEN_JAVABIND_H //######################################################################## //# E N D O F F I L E //######################################################################## diff --git a/src/bind/javainc/jni.h b/src/bind/javainc/jni.h index a10aaea72..5989c043f 100644 --- a/src/bind/javainc/jni.h +++ b/src/bind/javainc/jni.h @@ -28,7 +28,7 @@ * point of our design and implementation. */ -/****************************************************************************** +/* *************************************************************************** * Java Runtime Interface * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved. *****************************************************************************/ diff --git a/src/color-rgba.h b/src/color-rgba.h index 543ef5926..0d7a0c00d 100644 --- a/src/color-rgba.h +++ b/src/color-rgba.h @@ -1,7 +1,4 @@ -/** \file color-rgba.h - - A class to handle a RGBA color as one unit. - +/* Authors: bulia byak <buliabyak@gmail.com> @@ -17,20 +14,20 @@ #include "decimal-round.h" /** - \brief A class to contain a floating point RGBA color. -*/ + * A class to contain a floating point RGBA color as one unit. + */ class ColorRGBA { public: + /** - \brief A constructor to create the color from four floating - point values. - \param c0 Red - \param c1 Green - \param c2 Blue - \param c3 Alpha - - Load the values into the array of floats in this object. - */ + * A constructor to create the color from four floating point values. + * Load the values into the array of floats in this object. + * + * @param c0 Red + * @param c1 Green + * @param c2 Blue + * @param c3 Alpha + */ ColorRGBA(float c0, float c1, float c2, float c3) { _c[0] = c0; _c[1] = c1; @@ -38,8 +35,8 @@ public: } /** - \brief Create a quick ColorRGBA with all zeros - */ + * Create a quick ColorRGBA with all zeros. + */ ColorRGBA(void) { for (int i = 0; i < 4; i++) @@ -47,14 +44,14 @@ public: } /** - \brief A constructor to create the color from an unsigned - int, as found everywhere when dealing with colors - \param intcolor rgba32 "unsigned int representation (0xRRGGBBAA) - - Separate the values and load them into the array of floats in this object. - TODO : maybe get rid of the NR_RGBA32_x C-style functions and replace - the calls with the bitshifting they do - */ + * A constructor to create the color from an unsigned int, as found everywhere when dealing with colors. + * + * Separate the values and load them into the array of floats in this object. + * TODO : maybe get rid of the NR_RGBA32_x C-style functions and replace + * the calls with the bitshifting they do + * + * @param intcolor rgba32 "unsigned int representation (0xRRGGBBAA) + */ ColorRGBA(guint32 intcolor) { _c[0] = ((intcolor & 0xff000000) >> 24) / 255.0; @@ -65,11 +62,12 @@ public: } /** - \brief Create a ColorRGBA using an array of floats - \param in_array The values to be placed into the object - - Go through each entry in the array and put it into \c _c. - */ + * Create a ColorRGBA using an array of floats. + * + * Go through each entry in the array and put it into \c _c. + * + * @param in_array The values to be placed into the object + */ ColorRGBA(float in_array[4]) { for (int i = 0; i < 4; i++) @@ -77,12 +75,12 @@ public: } /** - \brief Overwrite the values in this object with another \c ColorRGBA. - \param m Values to use for the array - \return This ColorRGBA object - - Copy all the values from \c m into \c this. - */ + * Overwrite the values in this object with another \c ColorRGBA. + * Copy all the values from \c m into \c this. + * + * @param m Values to use for the array. + * @return This ColorRGBA object. + */ ColorRGBA &operator=(ColorRGBA const &m) { for (unsigned i = 0 ; i < 4 ; ++i) { _c[i] = m._c[i]; @@ -91,26 +89,26 @@ public: } /** - \brief Grab a particular value from the ColorRGBA object - \param i Which value to grab - \return The requested value. - - First checks to make sure that the value is within the array, - and then return the value if it is. - */ + * Grab a particular value from the ColorRGBA object. + * First checks to make sure that the value is within the array, + * and then return the value if it is. + * + * @param i Which value to grab. + * @return The requested value. + */ float operator[](unsigned int const i) const { g_assert( unsigned(i) < 4 ); return _c[i]; } /** - \brief Check to ensure that two \c ColorRGBA's are equal - \param other The guy to check against - \return Whether or not they are equal - - Check each value to see if they are equal. If they all are, - return TRUE. - */ + * Check to ensure that two \c ColorRGBA's are equal. + * Check each value to see if they are equal. If they all are, + * return true. + * + * @param other The guy to check against. + * @return Whether or not they are equal. + */ bool operator== (const ColorRGBA &other) const { for (int i = 0; i < 4; i++) { if (_c[i] != other[i]) @@ -124,17 +122,17 @@ public: } /** - \brief Average two \c ColorRGBAs to create another one. - \param second The second RGBA, with this being the first - \param weight How much of each should be used. Zero is all - this while one is all the second. Default is - half and half. - - This function goes through all the points in the two objects and - merges them together based on the weighting. The current objects - value are multiplied by 1.0 - weight and the second object by weight. - This means that they should always be balanced by the parameter. - */ + * Average two \c ColorRGBAs to create another one. + * This function goes through all the points in the two objects and + * merges them together based on the weighting. The current objects + * value are multiplied by 1.0 - weight and the second object by weight. + * This means that they should always be balanced by the parameter. + * + * @param second The second RGBA, with this being the first + * @param weight How much of each should be used. Zero is all + * this while one is all the second. Default is + * half and half. + */ ColorRGBA average (const ColorRGBA &second, const float weight = 0.5) const { float returnval[4]; @@ -146,12 +144,11 @@ public: } /** - \brief Give the rgba32 "unsigned int" representation of the color - - round each components*255 and combine them (RRGGBBAA). - WARNING : this reduces color precision (from float to 0->255 int per component) - but it should be expected since we request this kind of output - */ + * Give the rgba32 "unsigned int" representation of the color. + * round each components*255 and combine them (RRGGBBAA). + * WARNING : this reduces color precision (from float to 0->255 int per component) + * but it should be expected since we request this kind of output + */ unsigned int getIntValue() const { return (int(Inkscape::decimal_round(_c[0]*255, 0)) << 24) | @@ -161,12 +158,12 @@ public: } private: - /** \brief Array of values that are stored. */ + /** Array of values that are stored. */ float _c[4]; }; -#endif /* !SEEN_COLOR_RGBA_H */ +#endif // SEEN_COLOR_RGBA_H /* Local Variables: diff --git a/src/color.h b/src/color.h index 418b12c89..746ecebbf 100644 --- a/src/color.h +++ b/src/color.h @@ -1,9 +1,7 @@ #ifndef SEEN_SP_COLOR_H #define SEEN_SP_COLOR_H -/** \file - * Colors. - * +/* * Author: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> diff --git a/src/desktop.h b/src/desktop.h index d15fb7d69..25e4387dc 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -1,9 +1,7 @@ #ifndef SEEN_SP_DESKTOP_H #define SEEN_SP_DESKTOP_H -/** \file - * SPDesktop: an editable view. - * +/* * Author: * Lauris Kaplinski <lauris@kaplinski.com> * Frank Felfe <innerspace@iname.com> diff --git a/src/display/canvas-temporary-item-list.h b/src/display/canvas-temporary-item-list.h index 7a9f8b87a..d204c692f 100644 --- a/src/display/canvas-temporary-item-list.h +++ b/src/display/canvas-temporary-item-list.h @@ -1,9 +1,7 @@ #ifndef INKSCAPE_CANVAS_TEMPORARY_ITEM_LIST_H #define INKSCAPE_CANVAS_TEMPORARY_ITEM_LIST_H -/** \file - * Provides a class that can contain active TemporaryItem's on a desktop - * +/* * Authors: * Johan Engelen * @@ -23,6 +21,9 @@ namespace Display { class TemporaryItem; +/** + * Provides a class that can contain active TemporaryItem's on a desktop. + */ class TemporaryItemList { public: TemporaryItemList(SPDesktop *desktop); diff --git a/src/display/canvas-temporary-item.h b/src/display/canvas-temporary-item.h index b73907bad..c8917b530 100644 --- a/src/display/canvas-temporary-item.h +++ b/src/display/canvas-temporary-item.h @@ -1,9 +1,7 @@ #ifndef INKSCAPE_CANVAS_TEMPORARY_ITEM_H #define INKSCAPE_CANVAS_TEMPORARY_ITEM_H -/** \file - * Provides a class to put a canvasitem temporarily on-canvas. - * +/* * Authors: * Johan Engelen * @@ -22,6 +20,9 @@ struct SPCanvasItem; namespace Inkscape { namespace Display { +/** + * Provides a class to put a canvasitem temporarily on-canvas. + */ class TemporaryItem { public: TemporaryItem(SPCanvasItem *item, guint lifetime, bool destroy_on_deselect = false); diff --git a/src/display/curve.h b/src/display/curve.h index ec828e674..4f129b542 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -1,9 +1,7 @@ #ifndef SEEN_DISPLAY_CURVE_H #define SEEN_DISPLAY_CURVE_H -/** \file - * Wrapper around a Geom::PathVector objects. - * +/* * Author: * Lauris Kaplinski <lauris@kaplinski.com> * @@ -22,6 +20,9 @@ #include <boost/optional.hpp> +/** + * Wrapper around a Geom::PathVector objects. + */ class SPCurve { public: /* Constructors */ diff --git a/src/display/grayscale.h b/src/display/grayscale.h index fe0d75cad..18162e1f3 100644 --- a/src/display/grayscale.h +++ b/src/display/grayscale.h @@ -1,9 +1,7 @@ #ifndef SEEN_DISPLAY_GRAYSCALE_H #define SEEN_DISPLAY_GRAYSCALE_H -/** \file - * Provide methods to calculate grayscale values (e.g. convert rgba value to grayscale rgba value) - * +/* * Author: * Johan Engelen <goejendaagh@zonnet.nl> * @@ -14,6 +12,9 @@ #include <gdk/gdk.h> +/** + * Provide methods to calculate grayscale values (e.g. convert rgba value to grayscale rgba value). + */ namespace Grayscale { guint32 process(guint32 rgba); guint32 process(guchar r, guchar g, guchar b, guchar a); @@ -22,7 +23,7 @@ namespace Grayscale { bool activeDesktopIsGrayscale(); }; -#endif /* !SEEN_DISPLAY_GRAYSCALE_H */ +#endif // !SEEN_DISPLAY_GRAYSCALE_H /* Local Variables: diff --git a/src/display/nr-filter-utils.h b/src/display/nr-filter-utils.h index 4d2b06bd5..7e073168f 100644 --- a/src/display/nr-filter-utils.h +++ b/src/display/nr-filter-utils.h @@ -1,9 +1,11 @@ #ifndef __NR_FILTER_UTILS_H__ #define __NR_FILTER_UTILS_H__ -/** \file - * filter utils. Definition of functions needed by several filters. - * +/** + * @file + * Definition of functions needed by several filters. + */ +/* * Authors: * Jean-Rene Reinhard <jr@komite.net> * diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index da66d0033..30040d99c 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -1,9 +1,11 @@ #ifndef INKSCAPE_DISPLAY_SNAP_INDICATOR_H #define INKSCAPE_DISPLAY_SNAP_INDICATOR_H -/** \file +/** + * @file * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap - * + */ +/* * Authors: * Johan Engelen * Diederik van Lierop diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index a83c7bc38..05688e6b5 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -2,9 +2,10 @@ #define SEEN_INKSCAPE_CTRLRECT_H /** - * \file sodipodi-ctrlrect.h + * @file * Simple non-transformed rectangle, usable for rubberband. - * + */ +/* * Authors: * Lauris Kaplinski <lauris@ximian.com> * Carl Hetherington <inkscape@carlh.net> diff --git a/src/display/sp-canvas-group.h b/src/display/sp-canvas-group.h index 354d389b7..9aa99d563 100644 --- a/src/display/sp-canvas-group.h +++ b/src/display/sp-canvas-group.h @@ -1,9 +1,11 @@ #ifndef SEEN_SP_CANVAS_GROUP_H #define SEEN_SP_CANVAS_GROUP_H -/** \file - * SPCanvasGroup - * +/** + * @file + * SPCanvasGroup. + */ +/* * Authors: * Federico Mena <federico@nuclecu.unam.mx> * Raph Levien <raph@gimp.org> diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 415c36566..2c1dbdcf0 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -1,9 +1,11 @@ #ifndef SEEN_SP_CANVAS_ITEM_H #define SEEN_SP_CANVAS_ITEM_H -/** \file +/** + * @file * SPCanvasItem. - * + */ +/* * Authors: * Federico Mena <federico@nuclecu.unam.mx> * Raph Levien <raph@gimp.org> diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index bffa5e4e9..f0deaa594 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -1,9 +1,11 @@ #ifndef SEEN_SP_CANVAS_H #define SEEN_SP_CANVAS_H -/** \file +/** + * @file * SPCanvas, SPCanvasBuf. - * + */ +/* * Authors: * Federico Mena <federico@nuclecu.unam.mx> * Raph Levien <raph@gimp.org> diff --git a/src/dom/css.h b/src/dom/css.h index f62b93588..5ea71ce95 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -1,4 +1,5 @@ /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -6,7 +7,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -36,8 +38,8 @@ */ -#ifndef __CSS_H__ -#define __CSS_H__ +#ifndef SEEN_CSS_H +#define SEEN_CSS_H #include "dom.h" #include "stylesheets.h" @@ -4663,7 +4665,7 @@ public: } //namespace org -#endif /* __CSS_H__ */ +#endif // SEEN_CSS_H /*######################################################################### ## E N D O F F I L E diff --git a/src/dom/cssreader.h b/src/dom/cssreader.h index 149db31ef..0a9a7c031 100644 --- a/src/dom/cssreader.h +++ b/src/dom/cssreader.h @@ -1,6 +1,7 @@ -#ifndef __CSSREADER_H__ -#define __CSSREADER_H__ +#ifndef SEEN_CSSREADER_H +#define SEEN_CSSREADER_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -283,7 +285,7 @@ void getColumnAndRow(int p, int &col, int &row, int &lastNL); -#endif /* __CSSREADER_H__ */ +#endif // SEEN_CSSREADER_H //######################################################################### //# E N D O F F I L E //######################################################################### diff --git a/src/dom/dom.h b/src/dom/dom.h index 674a84186..c12c02869 100644 --- a/src/dom/dom.h +++ b/src/dom/dom.h @@ -1,6 +1,7 @@ -#ifndef __DOM_H__ -#define __DOM_H__ +#ifndef SEEN_DOM_H +#define SEEN_DOM_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -12,7 +13,8 @@ * More thorough explanations of the various classes and their algorithms * can be found there. * - * + */ +/* * Authors: * Bob Jamison * @@ -2743,7 +2745,7 @@ public: } //namespace org -#endif // __DOM_H__ +#endif // SEEN_DOM_H /*######################################################################### diff --git a/src/dom/domimpl.h b/src/dom/domimpl.h index dbf81757e..4e17ce5ba 100644 --- a/src/dom/domimpl.h +++ b/src/dom/domimpl.h @@ -1,6 +1,7 @@ -#ifndef __DOMIMPL_H__ -#define __DOMIMPL_H__ +#ifndef SEEN_DOMIMPL_H +#define SEEN_DOMIMPL_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -2015,7 +2017,7 @@ protected: } //namespace org -#endif // __DOMIMPL_H__ +#endif // SEEN_DOMIMPL_H /*######################################################################### diff --git a/src/dom/domptr.h b/src/dom/domptr.h index aaf1220f3..5a1299867 100644 --- a/src/dom/domptr.h +++ b/src/dom/domptr.h @@ -1,6 +1,7 @@ -#ifndef __DOMPTR_H__ -#define __DOMPTR_H__ +#ifndef SEEN_DOMPTR_H +#define SEEN_DOMPTR_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -12,7 +13,8 @@ * More thorough explanations of the various classes and their algorithms * can be found there. * - * + */ +/* * Authors: * Bob Jamison * @@ -325,7 +327,7 @@ template<class T, class U> Ptr<T> } //namespace org -#endif // __DOMPTR_H__ +#endif // SEEN_DOMPTR_H /*######################################################################### diff --git a/src/dom/domstring.h b/src/dom/domstring.h index a963e9850..0002bd9b5 100644 --- a/src/dom/domstring.h +++ b/src/dom/domstring.h @@ -1,6 +1,7 @@ -#ifndef __DOMSTRING_H__ -#define __DOMSTRING_H__ +#ifndef SEEN_DOMSTRING_H +#define SEEN_DOMSTRING_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -306,7 +308,7 @@ DOMString &operator +(const char *b, DOMString &a); } //namespace w3c } //namespace org -#endif // __DOMSTRING_H__ +#endif // SEEN_DOMSTRING_H //######################################################################### //## E N D O F F I L E //######################################################################### diff --git a/src/dom/events.h b/src/dom/events.h index e6a8e0d6c..c4000ec29 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -1,7 +1,8 @@ -#ifndef __EVENTS_H__ -#define __EVENTS_H__ +#ifndef SEEN_EVENTS_H +#define SEEN_EVENTS_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -1601,7 +1603,7 @@ protected: } //namespace w3c } //namespace org -#endif /* __EVENTS_H__ */ +#endif // SEEN_EVENTS_H /*######################################################################### ## E N D O F F I L E diff --git a/src/dom/io/base64stream.h b/src/dom/io/base64stream.h index c6d0ad35d..93bb5c7e5 100644 --- a/src/dom/io/base64stream.h +++ b/src/dom/io/base64stream.h @@ -1,7 +1,8 @@ -#ifndef __DOM_IO_BASE64STREAM_H__ -#define __DOM_IO_BASE64STREAM_H__ +#ifndef SEEN_DOM_IO_BASE64STREAM_H +#define SEEN_DOM_IO_BASE64STREAM_H /** + * @file * Phoebe DOM Implementation. * * Base64-enabled input and output streams @@ -11,7 +12,8 @@ * the implementation from the user. * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -143,4 +145,4 @@ private: } //namespace org -#endif /* __INKSCAPE_IO_BASE64STREAM_H__ */ +#endif // SEEN_DOM_IO_BASE64STREAM_H diff --git a/src/dom/io/bufferstream.h b/src/dom/io/bufferstream.h index bdf4eb2ab..9a36b30e2 100644 --- a/src/dom/io/bufferstream.h +++ b/src/dom/io/bufferstream.h @@ -1,6 +1,7 @@ -#ifndef __BUFFERSTREAM_H__ -#define __BUFFERSTREAM_H__ +#ifndef SEEN_BUFFERSTREAM_H +#define SEEN_BUFFERSTREAM_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -130,4 +132,4 @@ private: -#endif /* __BUFFERSTREAM_H__ */ +#endif // SEEN_BUFFERSTREAM_H diff --git a/src/dom/io/domstream.h b/src/dom/io/domstream.h index 0c60aca7a..b2e308653 100644 --- a/src/dom/io/domstream.h +++ b/src/dom/io/domstream.h @@ -1,6 +1,7 @@ -#ifndef __DOMSTREAM_H__ -#define __DOMSTREAM_H__ +#ifndef SEEN_DOMSTREAM_H +#define SEEN_DOMSTREAM_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -677,7 +679,7 @@ void pipeStream(InputStream &source, OutputStream &dest); } //namespace org -#endif /* __DOMSTREAM_H__ */ +#endif // SEEN_DOMSTREAM_H //######################################################################### //# E N D O F F I L E diff --git a/src/dom/io/gzipstream.h b/src/dom/io/gzipstream.h index ea0807f32..6e82c3531 100644 --- a/src/dom/io/gzipstream.h +++ b/src/dom/io/gzipstream.h @@ -1,12 +1,13 @@ -#ifndef __GZIPSTREAM_H__ -#define __GZIPSTREAM_H__ +#ifndef SEEN_GZIPSTREAM_H +#define SEEN_GZIPSTREAM_H /** * Zlib-enabled input and output streams * * This provides a simple mechanism for reading and * writing Gzip files. We use our own 'ZipTool' class * to accomplish this, avoiding a zlib dependency. - * + */ +/* * Authors: * Bob Jamison * @@ -122,4 +123,4 @@ private: } // namespace org -#endif /* __GZIPSTREAM_H__ */ +#endif // SEEN_GZIPSTREAM_H diff --git a/src/dom/io/stringstream.h b/src/dom/io/stringstream.h index 38aaf7235..f6ed89e65 100644 --- a/src/dom/io/stringstream.h +++ b/src/dom/io/stringstream.h @@ -1,6 +1,7 @@ -#ifndef __STRINGSTREAM_H__ -#define __STRINGSTREAM_H__ +#ifndef SEEN_STRINGSTREAM_H +#define SEEN_STRINGSTREAM_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -126,4 +128,4 @@ private: -#endif /* __STRINGSTREAM_H__ */ +#endif // SEEN_STRINGSTREAM_H diff --git a/src/dom/io/uristream.h b/src/dom/io/uristream.h index a885726e4..8d60468a5 100644 --- a/src/dom/io/uristream.h +++ b/src/dom/io/uristream.h @@ -1,5 +1,5 @@ -#ifndef __URISTREAM_H__ -#define __URISTREAM_H__ +#ifndef SEEN_URISTREAM_H +#define SEEN_URISTREAM_H /** * Phoebe DOM Implementation. @@ -9,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -203,4 +204,4 @@ private: #########################################################################*/ -#endif /* __URISTREAM_H__ */ +#endif // SEEN_URISTREAM_H diff --git a/src/dom/ls.h b/src/dom/ls.h index c4bdf1120..fd224ea6b 100644 --- a/src/dom/ls.h +++ b/src/dom/ls.h @@ -1,6 +1,7 @@ -#ifndef __LS_H__ -#define __LS_H__ +#ifndef SEEN_LS_H +#define SEEN_LS_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -937,7 +939,7 @@ public: } //namespace org -#endif // __LS_H__ +#endif // SEEN_LS_H /*######################################################################### ## E N D O F F I L E diff --git a/src/dom/lsimpl.h b/src/dom/lsimpl.h index b87498517..621a5577a 100644 --- a/src/dom/lsimpl.h +++ b/src/dom/lsimpl.h @@ -1,6 +1,7 @@ -#ifndef __LSIMPL_H__ -#define __LSIMPL_H__ +#ifndef SEEN_LSIMPL_H +#define SEEN_LSIMPL_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -372,7 +374,7 @@ protected: -#endif /* __LSIMPL_H__ */ +#endif // SEEN_LSIMPL_H /*######################################################################### ## E N D O F F I L E diff --git a/src/dom/odf/odfdocument.h b/src/dom/odf/odfdocument.h index 0f892acb0..168df11c7 100644 --- a/src/dom/odf/odfdocument.h +++ b/src/dom/odf/odfdocument.h @@ -1,12 +1,6 @@ -#ifndef __ODF_DOCUMENT_H__ -#define __ODF_DOCUMENT_H__ -/** - * - * This class contains an ODF Document. - * Initially, we are just concerned with .odg content.xml + resources - * - * --------------------------------------------------------------------- - * +#ifndef SEEN_ODF_DOCUMENT_H +#define SEEN_ODF_DOCUMENT_H +/* * Copyright (C) 2006 Bob Jamison * * This program is free software; you can redistribute it and/or modify @@ -103,6 +97,8 @@ private: /** * + * This class contains an ODF Document. + * Initially, we are just concerned with .odg content.xml + resources */ class OdfDocument { @@ -146,7 +142,7 @@ private: -#endif /*__ODF_DOCUMENT_H__*/ +#endif // SEEN_ODF_DOCUMENT_H //######################################################################## //# E N D O F F I L E diff --git a/src/dom/smil.h b/src/dom/smil.h index c9de6ccb7..15bc361ac 100644 --- a/src/dom/smil.h +++ b/src/dom/smil.h @@ -1,6 +1,7 @@ -#ifndef __SMIL_H__ -#define __SMIL_H__ +#ifndef SEEN_SMIL_H +#define SEEN_SMIL_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -8,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -2486,7 +2488,7 @@ public: } //namespace w3c } //namespace org -#endif /* __SMIL_H__ */ +#endif // SEEN_SMIL_H /*######################################################################### ## E N D O F F I L E diff --git a/src/dom/smilimpl.h b/src/dom/smilimpl.h index cb06eb5f5..d71df020a 100644 --- a/src/dom/smilimpl.h +++ b/src/dom/smilimpl.h @@ -1,5 +1,5 @@ -#ifndef __SMILIMPL_H__ -#define __SMILIMPL_H__ +#ifndef SEEN_SMILIMPL_H +#define SEEN_SMILIMPL_H /** * Phoebe DOM Implementation. * @@ -8,7 +8,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -757,7 +758,7 @@ public: } //namespace w3c } //namespace org -#endif /* __SMILIMPL_H__ */ +#endif // SEEN_SMILIMPL_H /*######################################################################### ## E N D O F F I L E diff --git a/src/dom/stylesheets.h b/src/dom/stylesheets.h index 0e76d6d4e..3ba225af3 100644 --- a/src/dom/stylesheets.h +++ b/src/dom/stylesheets.h @@ -1,7 +1,8 @@ -#ifndef __STYLESHEETS_H__ -#define __STYLESHEETS_H__ +#ifndef SEEN_STYLESHEETS_H +#define SEEN_STYLESHEETS_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -584,7 +586,7 @@ protected: } //namespace org -#endif /* __STYLESHEETS_H__ */ +#endif // SEEN_STYLESHEETS_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/svg.h b/src/dom/svg.h index 5bf943cc6..09754055d 100644 --- a/src/dom/svg.h +++ b/src/dom/svg.h @@ -1,7 +1,8 @@ -#ifndef __SVG_H__ -#define __SVG_H__ +#ifndef SEEN_SVG_H +#define SEEN_SVG_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -4749,7 +4751,7 @@ public: } //namespace w3c } //namespace org -#endif // __SVG_H__ +#endif // SEEN_SVG_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/svg2.h b/src/dom/svg2.h index b1a42e8aa..011bafbea 100644 --- a/src/dom/svg2.h +++ b/src/dom/svg2.h @@ -1,7 +1,8 @@ -#ifndef __SVG_H__ -#define __SVG_H__ +#ifndef SEEN_SVG_H +#define SEEN_SVG_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -5551,7 +5553,7 @@ public: } //namespace w3c } //namespace org -#endif // __SVG_H__ +#endif // SEEN_SVG_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h index 62d6acaf3..83d56fa22 100644 --- a/src/dom/svgimpl.h +++ b/src/dom/svgimpl.h @@ -1,7 +1,8 @@ -#ifndef __SVGIMPL_H__ -#define __SVGIMPL_H__ +#ifndef SEEN_SVGIMPL_H +#define SEEN_SVGIMPL_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -5527,7 +5529,7 @@ protected: } //namespace w3c } //namespace org -#endif // __SVG_H__ +#endif // SEEN_SVGIMPL_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/svgreader.h b/src/dom/svgreader.h index 2a0106cac..3d66ce507 100644 --- a/src/dom/svgreader.h +++ b/src/dom/svgreader.h @@ -1,7 +1,8 @@ -#ifndef __SVGREADER_H__ -#define __SVGREADER_H__ +#ifndef SEEN_SVGREADER_H +#define SEEN_SVGREADER_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -179,7 +181,7 @@ private: } //namespace w3c } //namespace org -#endif /* __SVGREADER_H__ */ +#endif // SEEN_SVGREADER_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/svgtypes.h b/src/dom/svgtypes.h index 09ed00bb5..0c30069b8 100644 --- a/src/dom/svgtypes.h +++ b/src/dom/svgtypes.h @@ -1,7 +1,8 @@ -#ifndef __SVGTYPES_H__ -#define __SVGTYPES_H__ +#ifndef SEEN_SVGTYPES_H +#define SEEN_SVGTYPES_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -6895,7 +6897,7 @@ protected: } //namespace w3c } //namespace org -#endif /* __SVGTYPES_H__ */ +#endif // SEEN_SVGTYPES_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/traversal.h b/src/dom/traversal.h index 6d00bac67..0cade9576 100644 --- a/src/dom/traversal.h +++ b/src/dom/traversal.h @@ -1,7 +1,7 @@ -#ifndef __TRAVERSAL_H__ -#define __TRAVERSAL_H__ - +#ifndef SEEN_TRAVERSAL_H +#define SEEN_TRAVERSAL_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -590,7 +591,7 @@ public: } //namespace w3c } //namespace org -#endif /* __TRAVERSAL_H__ */ +#endif // SEEN_TRAVERSAL_H /*######################################################################### diff --git a/src/dom/ucd.h b/src/dom/ucd.h index c4d0ab4e0..112c45f20 100644 --- a/src/dom/ucd.h +++ b/src/dom/ucd.h @@ -1,4 +1,5 @@ /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -10,7 +11,8 @@ * More thorough explanations of the various classes and their algorithms * can be found there. * - * + */ +/* * Authors: * Bob Jamison * @@ -31,11 +33,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ -#ifndef __UCD_H__ -#define __UCD_H__ +#ifndef SEEN_UCD_H +#define SEEN_UCD_H -/************************************************ +/* *********************************************** ** Unicode character classification ************************************************/ @@ -186,7 +188,7 @@ int uni_to_upper(int ch); int uni_to_title(int ch); -/************************************************ +/* *********************************************** ** Unicode blocks ************************************************/ @@ -328,6 +330,6 @@ typedef enum } UnicodeBlocks; -#endif /* __UCD_H__ */ +#endif // SEEN_UCD_H diff --git a/src/dom/uri.h b/src/dom/uri.h index 40f80b077..4d3c384c9 100644 --- a/src/dom/uri.h +++ b/src/dom/uri.h @@ -1,7 +1,8 @@ -#ifndef __URI_H__ -#define __URI_H__ +#ifndef SEEN_URI_H +#define SEEN_URI_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -482,5 +484,5 @@ private: -#endif /* __URI_H__ */ +#endif // SEEN_URI_H diff --git a/src/dom/util/digest.h b/src/dom/util/digest.h index 8c193420f..fed5b7e86 100644 --- a/src/dom/util/digest.h +++ b/src/dom/util/digest.h @@ -1,8 +1,6 @@ -#ifndef __DIGEST_H__ -#define __DIGEST_H__ -/** - * Secure Hashing Tool - * +#ifndef SEEN_DIGEST_H +#define SEEN_DIGEST_H +/* * * Author: * Bob Jamison @@ -25,7 +23,7 @@ */ /** - * + * @file * This base class and its subclasses provide an easy API for providing * several different types of secure hashing functions for whatever use * a developer might need. This is not intended as a high-performance diff --git a/src/dom/util/thread.h b/src/dom/util/thread.h index dfad6d9b3..1408cd78f 100644 --- a/src/dom/util/thread.h +++ b/src/dom/util/thread.h @@ -1,5 +1,5 @@ -#ifndef __DOM_THREAD_H__ -#define __DOM_THREAD_H__ +#ifndef SEEN_DOM_THREAD_H +#define SEEN_DOM_THREAD_H /** * Phoebe DOM Implementation. * @@ -8,7 +8,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -29,7 +30,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** +/* * Thread wrapper. This provides a platform-independent thread * class for IO and testing. * @@ -147,7 +148,7 @@ private: -#endif /* __DOM_THREAD_H__ */ +#endif // SEEN_DOM_THREAD_H //######################################################################### //# E N D O F F I L E //######################################################################### diff --git a/src/dom/util/ziptool.h b/src/dom/util/ziptool.h index 6cef266cf..47e669962 100644 --- a/src/dom/util/ziptool.h +++ b/src/dom/util/ziptool.h @@ -1,5 +1,5 @@ -#ifndef __ZIPTOOL_H__ -#define __ZIPTOOL_H__ +#ifndef SEEN_ZIPTOOL_H +#define SEEN_ZIPTOOL_H /** * This is intended to be a standalone, reduced capability * implementation of Gzip and Zip functionality. Its @@ -11,7 +11,8 @@ * one-at-a-time tasks. What you get in return is the ability * to drop these files into your project and remove the dependencies * on ZLib and Info-Zip. Enjoy. - * + */ +/* * Authors: * Bob Jamison * @@ -559,7 +560,7 @@ private: -#endif /* __ZIPTOOL_H__ */ +#endif // SEEN_ZIPTOOL_H //######################################################################## diff --git a/src/dom/views-level3.h b/src/dom/views-level3.h index f62d18751..427051d06 100644 --- a/src/dom/views-level3.h +++ b/src/dom/views-level3.h @@ -1,7 +1,8 @@ -#ifndef __VIEWS_LEVEL3_H__ -#define __VIEWS_LEVEL3_H__ +#ifndef SEEN_VIEWS_LEVEL3_H +#define SEEN_VIEWS_LEVEL3_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -30,7 +32,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** +/* * Currently CSS is not at level 3, so we will probably not use this * Level 3 Views implementation. Rather, we'll regress back to Level 2. * This should not affect using the rest of DOM Core 3 @@ -1958,7 +1960,7 @@ protected: } //namespace org -#endif /* __VIEWS_LEVEL3_H__ */ +#endif // SEEN_VIEWS_LEVEL3_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/views.h b/src/dom/views.h index 9e87dfbe7..48afd5d16 100644 --- a/src/dom/views.h +++ b/src/dom/views.h @@ -1,7 +1,8 @@ -#ifndef __VIEWS_H__ -#define __VIEWS_H__ +#ifndef SEEN_VIEWS_H +#define SEEN_VIEWS_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -207,7 +209,7 @@ private: } //namespace org -#endif /* __VIEWS_H__ */ +#endif // SEEN_VIEWS_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/xmlreader.h b/src/dom/xmlreader.h index 3f97d87c9..7ab6de826 100644 --- a/src/dom/xmlreader.h +++ b/src/dom/xmlreader.h @@ -1,5 +1,5 @@ -#ifndef _XMLREADER_H_ -#define _XMLREADER_H_ +#ifndef SEEN_XMLREADER_H +#define SEEN_XMLREADER_H /** * Phoebe DOM Implementation. @@ -9,7 +9,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -129,4 +130,4 @@ private: } //namespace w3c } //namespace org -#endif /*_XMLREADER_H_*/ +#endif // SEEN_XMLREADER_H diff --git a/src/dom/xmlwriter.h b/src/dom/xmlwriter.h index cd787993c..f50c91bc4 100644 --- a/src/dom/xmlwriter.h +++ b/src/dom/xmlwriter.h @@ -1,7 +1,8 @@ -#ifndef __XMLWRITER_H__ -#define __XMLWRITER_H__ +#ifndef SEEN_XMLWRITER_H +#define SEEN_XMLWRITER_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -85,7 +87,7 @@ protected: -#endif /* __XMLWRITER_H__ */ +#endif // SEEN_XMLWRITER_H diff --git a/src/dom/xpath.h b/src/dom/xpath.h index 60c35d76f..ce5b88f7f 100644 --- a/src/dom/xpath.h +++ b/src/dom/xpath.h @@ -1,7 +1,8 @@ -#ifndef __XPATH_H__ -#define __XPATH_H__ +#ifndef SEEN_XPATH_H +#define SEEN_XPATH_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -340,7 +342,7 @@ public: -#endif /* __XPATH_H__ */ +#endif // SEEN_XPATH_H /*######################################################################### ## E N D O F F I L E #########################################################################*/ diff --git a/src/dom/xpathimpl.h b/src/dom/xpathimpl.h index c12e78205..82b5c48f8 100644 --- a/src/dom/xpathimpl.h +++ b/src/dom/xpathimpl.h @@ -1,7 +1,8 @@ -#ifndef __XPATHIMPL_H__ -#define __XPATHIMPL_H__ +#ifndef SEEN_XPATHIMPL_H +#define SEEN_XPATHIMPL_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * diff --git a/src/dom/xpathparser.h b/src/dom/xpathparser.h index 1ad4b5f54..041564e21 100644 --- a/src/dom/xpathparser.h +++ b/src/dom/xpathparser.h @@ -1,7 +1,8 @@ -#ifndef __XPATHPARSER_H__ -#define __XPATHPARSER_H__ +#ifndef SEEN_XPATHPARSER_H +#define SEEN_XPATHPARSER_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -794,15 +796,7 @@ private: } // namespace dom } // namespace w3c } // namespace org -#endif /* __XPATHPARSER_H__ */ +#endif // SEEN_XPATHPARSER_H //######################################################################### //# E N D O F F I L E //######################################################################### - - - - - - - - diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h index 8683b2ee1..5bb87917b 100644 --- a/src/dom/xpathtoken.h +++ b/src/dom/xpathtoken.h @@ -1,7 +1,8 @@ -#ifndef __XPATHTOKEN_H__ -#define __XPATHTOKEN_H__ +#ifndef SEEN_XPATHTOKEN_H +#define SEEN_XPATHTOKEN_H /** + * @file * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows @@ -9,7 +10,8 @@ * which are provided for reference. Most important is this one: * * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * + */ +/* * Authors: * Bob Jamison * @@ -667,7 +669,7 @@ private: -#endif /* __XPATHTOKEN_H__ */ +#endif // SEEN_XPATHTOKEN_H //######################################################################## //# E N D O F F I L E //######################################################################## diff --git a/src/event-context.h b/src/event-context.h index ca13fe7e8..1c9f46a46 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -1,12 +1,7 @@ #ifndef SEEN_SP_EVENT_CONTEXT_H #define SEEN_SP_EVENT_CONTEXT_H -/** \file - * SPEventContext: base class for event processors - * - * This is per desktop object, which (its derivatives) implements - * different actions bound to mouse events. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Frank Felfe <innerspace@iname.com> @@ -96,6 +91,9 @@ void sp_event_context_snap_delay_handler(SPEventContext *ec, gpointer const dse_ /** * Base class for Event processors. + * + * This is per desktop object, which (its derivatives) implements + * different actions bound to mouse events. */ struct SPEventContext : public GObject { void enableSelectionCue (bool enable=true); diff --git a/src/event-log.h b/src/event-log.h index 3f3c6830e..a429994c8 100644 --- a/src/event-log.h +++ b/src/event-log.h @@ -1,18 +1,4 @@ -/** - * Inkscape::EventLog - * - * A simple log for maintaining a history of commited, undone and redone events along with their - * type. It implements the UndoStackObserver and should be registered with a - * CompositeUndoStackObserver for each document. The event log is then notified on all commit, undo - * and redo events and will store a representation of them in an internal Gtk::TreeStore. - * - * Consecutive events of the same type are grouped with the first event as a parent and following - * as its children. - * - * If a Gtk::TreeView is connected to the event log, the TreeView's selection and its nodes - * expanded/collapsed state will be updated as events are commited, undone and redone. Whenever - * this happens, the event log will block the TreeView's callbacks to prevent circular updates. - * +/* * Author: * Gustav Broberg <broberg@kth.se> * @@ -36,9 +22,20 @@ namespace Inkscape { /** - * + * A simple log for maintaining a history of commited, undone and redone events along with their + * type. It implements the UndoStackObserver and should be registered with a + * CompositeUndoStackObserver for each document. The event log is then notified on all commit, undo + * and redo events and will store a representation of them in an internal Gtk::TreeStore. + * + * Consecutive events of the same type are grouped with the first event as a parent and following + * as its children. + * + * If a Gtk::TreeView is connected to the event log, the TreeView's selection and its nodes + * expanded/collapsed state will be updated as events are commited, undone and redone. Whenever + * this happens, the event log will block the TreeView's callbacks to prevent circular updates. */ -class EventLog : public UndoStackObserver { +class EventLog : public UndoStackObserver +{ public: typedef Gtk::TreeModel::iterator iterator; @@ -50,7 +47,6 @@ public: /** * Event datatype */ - struct EventModelColumns : public Gtk::TreeModelColumnRecord { Gtk::TreeModelColumn<Event *> event; @@ -64,20 +60,18 @@ public: } }; + // Implementation of Inkscape::UndoStackObserver methods + /** - * Implementation of Inkscape::UndoStackObserver methods - * \brief Modifies the log's entries and the view's selection when triggered + * Modifies the log's entries and the view's selection when triggered. */ - void notifyUndoEvent(Event *log); void notifyRedoEvent(Event *log); void notifyUndoCommitEvent(Event *log); void notifyClearUndoEvent(); void notifyClearRedoEvent(); - /** - * Accessor functions - */ + // Accessor functions Glib::RefPtr<Gtk::TreeModel> getEventListStore() const { return _event_list_store; } const EventModelColumns& getColumns() const { return _columns; } @@ -89,9 +83,7 @@ public: void blockNotifications(bool status=true) { _notifications_blocked = status; } void rememberFileSave() { _last_saved = _curr_event; } - /* - * Callback types for TreeView changes. - */ + // Callback types for TreeView changes. enum CallbackTypes { CALLB_SELECTION_CHANGE, @@ -134,9 +126,7 @@ private: // Map of connections used to temporary block/unblock callbacks in a TreeView CallbackMap *_callback_connections; - /** - * Helper functions - */ + // Helper functions const_iterator _getUndoEvent() const; //< returns the current undoable event or NULL if none const_iterator _getRedoEvent() const; //< returns the current redoable event or NULL if none diff --git a/src/extension/internal/gimpgrad.h b/src/extension/internal/gimpgrad.h index 5ab48a147..c34de840d 100644 --- a/src/extension/internal/gimpgrad.h +++ b/src/extension/internal/gimpgrad.h @@ -1,7 +1,4 @@ -/** \file - * - * Implementation class of the GIMP gradient plugin. - * +/* * Authors: * Ted Gould <ted@gould.cx> * @@ -9,7 +6,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - +// TODO add include guard #include <glibmm/ustring.h> #include "extension/implementation/implementation.h" @@ -21,10 +18,12 @@ class Extension; namespace Internal { -/** \brief Implementation class of the GIMP gradient plugin. This mostly - just creates a namespace for the GIMP gradient plugin today. -*/ -class GimpGrad : public Inkscape::Extension::Implementation::Implementation { +/** + * Implementation class of the GIMP gradient plugin. + * This mostly just creates a namespace for the GIMP gradient plugin today. + */ +class GimpGrad : public Inkscape::Extension::Implementation::Implementation +{ public: bool load(Inkscape::Extension::Extension *module); void unload(Inkscape::Extension::Extension *module); @@ -34,7 +33,9 @@ public: }; -} } } /* namespace Internal; Extension; Inkscape */ +} // namespace Internal +} // namespace Extension +} // namespace Inkscape /* Local Variables: diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h index 2a6f7799f..a4a13681a 100644 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@ -1,14 +1,4 @@ -/** - * OpenDocument <drawing> input and output - * - * This is an an entry in the extensions mechanism to begin to enable - * the inputting and outputting of OpenDocument Format (ODF) files from - * within Inkscape. Although the initial implementations will be very lossy - * do to the differences in the models of SVG and ODF, they will hopefully - * improve greatly with time. - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * +/* * Authors: * Bob Jamison * Abhishek Sharma @@ -265,6 +255,17 @@ public: +/** + * OpenDocument <drawing> input and output + * + * This is an an entry in the extensions mechanism to begin to enable + * the inputting and outputting of OpenDocument Format (ODF) files from + * within Inkscape. Although the initial implementations will be very lossy + * do to the differences in the models of SVG and ODF, they will hopefully + * improve greatly with time. + * + * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html + */ class OdfOutput : public Inkscape::Extension::Implementation::Implementation { diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index c2fd0b6d8..6d3fd104a 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -1,9 +1,7 @@ -#ifndef __EXTENSION_INTERNAL_PDFINPUT_H__ -#define __EXTENSION_INTERNAL_PDFINPUT_H__ +#ifndef SEEN_EXTENSION_INTERNAL_PDFINPUT_H +#define SEEN_EXTENSION_INTERNAL_PDFINPUT_H - /** \file - * PDF import using libpoppler. - * +/* * Authors: * miklos erdelyi * @@ -50,6 +48,9 @@ namespace Widget { namespace Extension { namespace Internal { +/** + * PDF import using libpoppler. + */ class PdfImportDialog : public Gtk::Dialog { public: @@ -125,11 +126,13 @@ public: }; -} } } /* namespace Inkscape, Extension, Implementation */ +} // namespace Implementation +} // namespace Extension +} // namespace Inkscape -#endif /* HAVE_POPPLER */ +#endif // HAVE_POPPLER -#endif /* __EXTENSION_INTERNAL_PDFINPUT_H__ */ +#endif // SEEN_EXTENSION_INTERNAL_PDFINPUT_H /* Local Variables: diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h index 21effe81d..a63d669c7 100644 --- a/src/extension/internal/pdfinput/pdf-parser.h +++ b/src/extension/internal/pdfinput/pdf-parser.h @@ -1,7 +1,4 @@ - - /** \file - * PDF parsing module using libpoppler's facilities - * + /* * Derived from Gfx.h * * Copyright 1996-2003 Glyph & Cog, LLC @@ -24,6 +21,8 @@ namespace Inkscape { } } } + +// TODO clean up and remove using: using Inkscape::Extension::Internal::SvgBuilder; #include "goo/gtypes.h" @@ -145,6 +144,10 @@ private: #define pdfNumShadingTypes 5 + +/** + * PDF parsing module using libpoppler's facilities. + */ class PdfParser { public: diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 47e5d7735..7a36be806 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -1,9 +1,7 @@ -#ifndef __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__ -#define __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__ +#ifndef SEEN_EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H +#define SEEN_EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H - /** \file - * SVG representation creator using libpoppler. - * +/* * Authors: * miklos erdelyi * @@ -58,8 +56,7 @@ namespace Internal { struct SvgTransparencyGroup; /** - * \struct SvgGraphicsState - * Holds information about the current softmask and group depth. + * Holds information about the current softmask and group depth for use of libpoppler. * Could be later used to store other graphics state parameters so that we could * emit only the differences in style settings from the parent state. */ @@ -69,7 +66,6 @@ struct SvgGraphicsState { }; /** - * \struct SvgGlyph * Holds information about glyphs added by PdfParser which haven't been added * to the document yet. */ @@ -89,10 +85,7 @@ struct SvgGlyph { }; /** - * \class SvgBuilder - * - * Builds the inner SVG representation from the calls of PdfParser - * + * Builds the inner SVG representation using libpoppler from the calls of PdfParser. */ class SvgBuilder { public: @@ -232,11 +225,13 @@ private: }; -} } } /* namespace Inkscape, Extension, Internal */ +} // namespace Internal +} // namespace Extension +} // namespace Inkscape -#endif /* HAVE_POPPLER */ +#endif // HAVE_POPPLER -#endif /* __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__ */ +#endif // SEEN_EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H /* Local Variables: diff --git a/src/extension/script/InkscapeScript.h b/src/extension/script/InkscapeScript.h index c4a59e1e2..2ebeb1b19 100644 --- a/src/extension/script/InkscapeScript.h +++ b/src/extension/script/InkscapeScript.h @@ -1,9 +1,7 @@ -#ifndef __INKSCAPE_SCRIPT_H__ -#define __INKSCAPE_SCRIPT_H__ +#ifndef SEEN_INKSCAPE_SCRIPT_H +#define SEEN_INKSCAPE_SCRIPT_H -/** - * Inkscape Scripting container - * +/* * Authors: * Bob Jamison <rjamison@titan.com> * @@ -26,7 +24,8 @@ namespace Script /** - * This class is used to run scripts, either from a file or buffer + * Inkscape Scripting container. + * This class is used to run scripts, either from a file or buffer. */ class InkscapeScript { diff --git a/src/gc-anchored.h b/src/gc-anchored.h index ee277be25..b7c0cd0e4 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -1,6 +1,4 @@ -/** \file - * Inkscape::GC::Anchored - base class for anchored GC-managed objects - * +/* * Authors: * MenTaLguY <mental@rydia.net> * * Copyright (C) 2004 MenTaLguY diff --git a/src/gc-soft-ptr.h b/src/gc-soft-ptr.h index f83a0808d..9e7304939 100644 --- a/src/gc-soft-ptr.h +++ b/src/gc-soft-ptr.h @@ -1,6 +1,4 @@ -/** \file - * Inkscape::GC::soft_ptr - "soft" pointers to avoid finalization cycles - * +/* * Copyright 2006 MenTaLguY <mental@rydia.net> * * This program is free software; you can redistribute it and/or @@ -21,8 +19,9 @@ namespace Inkscape { namespace GC { -/** @brief A class for pointers which can be automatically cleared to break - * finalization cycles. +/** + * A class for pointers which can be automatically cleared to break + * finalization cycles. */ template <typename T> class soft_ptr { diff --git a/src/graphlayout.h b/src/graphlayout.h index 40090ef6b..6083ad77f 100644 --- a/src/graphlayout.h +++ b/src/graphlayout.h @@ -1,6 +1,8 @@ /** - * \brief graph layout functions - * + * @file + * graph layout functions. + */ +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * diff --git a/src/guide-snapper.h b/src/guide-snapper.h index f8b3c2cee..f51939c08 100644 --- a/src/guide-snapper.h +++ b/src/guide-snapper.h @@ -1,10 +1,6 @@ #ifndef SEEN_GUIDE_SNAPPER_H #define SEEN_GUIDE_SNAPPER_H - -/** - * \file guide-snapper.h - * \brief Snapping things to guides. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Frank Felfe <innerspace@iname.com> @@ -22,7 +18,9 @@ struct SPNamedView; namespace Inkscape { -/// Snap to guides +/** + * Snap to guides. + */ class GuideSnapper : public LineSnapper { public: diff --git a/src/help.h b/src/help.h index b6c82fb51..2ded43c39 100644 --- a/src/help.h +++ b/src/help.h @@ -1,9 +1,6 @@ #ifndef SEEN_HELP_H #define SEEN_HELP_H - -/** - * Help/About window - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * @@ -16,7 +13,11 @@ #include <glib/gtypes.h> #include <gtk/gtk.h> +/** + * Help/About window. + */ void sp_help_about(void); + void sp_help_open_tutorial(GtkMenuItem *menuitem, gpointer data); diff --git a/src/helper-fns.h b/src/helper-fns.h index f407364a5..3ae150fdb 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -1,9 +1,6 @@ #ifndef SEEN_HELPER_FNS_H #define SEEN_HELPER_FNS_H -/** \file - * - * Some helper functions - * +/* * Authors: * Felipe Corrêa da Silva Sanches <juca@members.fsf.org> * diff --git a/src/helper/geom-curves.h b/src/helper/geom-curves.h index 5b921e572..4586a346c 100644 --- a/src/helper/geom-curves.h +++ b/src/helper/geom-curves.h @@ -2,8 +2,10 @@ #define INKSCAPE_HELPER_GEOM_CURVES_H /** + * @file * Specific curve type functions for Inkscape, not provided by lib2geom. - * + */ +/* * Author: * Johan Engelen <goejendaagh@zonnet.nl> * diff --git a/src/helper/geom-nodetype.h b/src/helper/geom-nodetype.h index 1a0d33b9d..2d299d545 100644 --- a/src/helper/geom-nodetype.h +++ b/src/helper/geom-nodetype.h @@ -2,8 +2,10 @@ #define INKSCAPE_HELPER_GEOM_NODETYPE_H /** + * @file * Specific nodetype geometry functions for Inkscape, not provided my lib2geom. - * + */ +/* * Author: * Johan Engelen <goejendaagh@zonnet.nl> * diff --git a/src/helper/geom.h b/src/helper/geom.h index 630d67aba..ee58a416d 100644 --- a/src/helper/geom.h +++ b/src/helper/geom.h @@ -2,8 +2,10 @@ #define INKSCAPE_HELPER_GEOM_H /** + * @file * Specific geometry functions for Inkscape, not provided my lib2geom. - * + */ +/* * Author: * Johan Engelen <goejendaagh@zonnet.nl> * diff --git a/src/io/base64stream.h b/src/io/base64stream.h index 7bfe73e5f..554a92fe2 100644 --- a/src/io/base64stream.h +++ b/src/io/base64stream.h @@ -1,13 +1,15 @@ -#ifndef __INKSCAPE_IO_BASE64STREAM_H__ -#define __INKSCAPE_IO_BASE64STREAM_H__ +#ifndef SEEN_INKSCAPE_IO_BASE64STREAM_H +#define SEEN_INKSCAPE_IO_BASE64STREAM_H /** + * @file * Base64-enabled input and output streams * * This class allows easy encoding and decoding * of Base64 data with a stream interface, hiding * the implementation from the user. - * + */ +/* * Authors: * Bob Jamison <rjamison@titan.com> * @@ -119,4 +121,4 @@ private: } // namespace Inkscape -#endif /* __INKSCAPE_IO_BASE64STREAM_H__ */ +#endif // SEEN_INKSCAPE_IO_BASE64STREAM_H diff --git a/src/io/gzipstream.h b/src/io/gzipstream.h index adaf50967..4debbfca9 100644 --- a/src/io/gzipstream.h +++ b/src/io/gzipstream.h @@ -1,12 +1,14 @@ -#ifndef __INKSCAPE_IO_GZIPSTREAM_H__ -#define __INKSCAPE_IO_GZIPSTREAM_H__ +#ifndef SEEN_INKSCAPE_IO_GZIPSTREAM_H +#define SEEN_INKSCAPE_IO_GZIPSTREAM_H /** - * Zlib-enabled input and output streams + * @file + * Zlib-enabled input and output streams. * * This is a thin wrapper of libz calls, in order * to provide a simple interface to our developers * for gzip input and output. - * + */ +/* * Authors: * Bob Jamison <rjamison@titan.com> * diff --git a/src/io/inkscapestream.h b/src/io/inkscapestream.h index 9358b4d51..a766e16e0 100644 --- a/src/io/inkscapestream.h +++ b/src/io/inkscapestream.h @@ -1,8 +1,6 @@ -#ifndef __INKSCAPE_IO_INKSCAPESTREAM_H__ -#define __INKSCAPE_IO_INKSCAPESTREAM_H__ -/** - * Our base basic stream classes. - * +#ifndef SEEN_INKSCAPE_IO_INKSCAPESTREAM_H +#define SEEN_INKSCAPE_IO_INKSCAPESTREAM_H +/* * Authors: * Bob Jamison <rjamison@titan.com> * @@ -667,4 +665,4 @@ void pipeStream(InputStream &source, OutputStream &dest); } // namespace Inkscape -#endif /* __INKSCAPE_IO_INKSCAPESTREAM_H__ */ +#endif // SEEN_INKSCAPE_IO_INKSCAPESTREAM_H diff --git a/src/io/resource.h b/src/io/resource.h index be3ff21b7..36fe5f81e 100644 --- a/src/io/resource.h +++ b/src/io/resource.h @@ -1,6 +1,4 @@ -/** \file - * Inkscape::IO::Resource - simple resource API - * +/* * Copyright 2006 MenTaLguY <mental@rydia.net> * * This program is free software; you can redistribute it and/or @@ -21,6 +19,9 @@ namespace Inkscape { namespace IO { +/** + * simple resource API + */ namespace Resource { enum Type { diff --git a/src/io/uristream.h b/src/io/uristream.h index d62065976..67d2f34d7 100644 --- a/src/io/uristream.h +++ b/src/io/uristream.h @@ -1,9 +1,11 @@ -#ifndef __INKSCAPE_IO_URISTREAM_H__ -#define __INKSCAPE_IO_URISTREAM_H__ +#ifndef SEEN_INKSCAPE_IO_URISTREAM_H +#define SEEN_INKSCAPE_IO_URISTREAM_H /** + * @file * This should be the only way that we provide sources/sinks * to any input/output stream. - * + */ +/* * Authors: * Bob Jamison <rjamison@titan.com> * @@ -170,4 +172,4 @@ private: } // namespace Inkscape -#endif /* __INKSCAPE_IO_URISTREAM_H__ */ +#endif // SEEN_INKSCAPE_IO_URISTREAM_H diff --git a/src/io/xsltstream.h b/src/io/xsltstream.h index 32d9d12f8..03621c7fd 100644 --- a/src/io/xsltstream.h +++ b/src/io/xsltstream.h @@ -1,9 +1,10 @@ -#ifndef __INKSCAPE_IO_XSLTSTREAM_H__ -#define __INKSCAPE_IO_XSLTSTREAM_H__ +#ifndef SEEN_INKSCAPE_IO_XSLTSTREAM_H +#define SEEN_INKSCAPE_IO_XSLTSTREAM_H /** + * @file * Xslt-enabled input and output streams - * - * + */ +/* * Authors: * Bob Jamison <ishmalius@gmail.com> * diff --git a/src/knot-enums.h b/src/knot-enums.h index e82810242..1045e0433 100644 --- a/src/knot-enums.h +++ b/src/knot-enums.h @@ -1,9 +1,11 @@ #ifndef SEEN_KNOT_ENUMS_H #define SEEN_KNOT_ENUMS_H -/** \file +/** + * @file * Some enums used by SPKnot and by related types \& functions. - * + */ +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index bd654616c..726d969c2 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -1,9 +1,6 @@ #ifndef SEEN_KNOT_HOLDER_ENTITY_H #define SEEN_KNOT_HOLDER_ENTITY_H - -/** \file - * KnotHolderEntity definition. - * +/* * Authors: * Mitsuru Oka <oka326@parkcity.ne.jp> * Maximilian Albert <maximilian.albert@gmail.com> @@ -33,6 +30,9 @@ typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item); /* fixme: Think how to make callbacks most sensitive (Lauris) */ typedef void (* SPKnotHolderReleasedFunc) (SPItem *item); +/** + * KnotHolderEntity definition. + */ class KnotHolderEntity { public: KnotHolderEntity() {} diff --git a/src/libcola/defs.h b/src/libcola/defs.h index cd8084c2c..e4e4e5096 100644 --- a/src/libcola/defs.h +++ b/src/libcola/defs.h @@ -1,7 +1,7 @@ /* $Id: defs.h,v 1.5 2005/10/18 18:42:59 ellson Exp $ $Revision: 1.5 $ */ /* vim:set shiftwidth=4 ts=8: */ -/********************************************************** +/* ******************************************************** * This software is part of the graphviz package * * http://www.graphviz.org/ * * * diff --git a/src/libvpsc/block.h b/src/libvpsc/block.h index fe4a18b78..a4625b202 100644 --- a/src/libvpsc/block.h +++ b/src/libvpsc/block.h @@ -1,8 +1,4 @@ -/** - * \brief A block is a group of variables that must be moved together to improve - * the goal function without violating already active constraints. - * The variables in a block are spanned by a tree of active constraints. - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * @@ -21,6 +17,11 @@ namespace vpsc { class Variable; class Constraint; +/** + * A block is a group of variables that must be moved together to improve + * the goal function without violating already active constraints. + * The variables in a block are spanned by a tree of active constraints. + */ class Block { typedef std::vector<Variable*> Variables; diff --git a/src/libvpsc/csolve_VPSC.h b/src/libvpsc/csolve_VPSC.h index 81e50d990..92179fc77 100644 --- a/src/libvpsc/csolve_VPSC.h +++ b/src/libvpsc/csolve_VPSC.h @@ -1,6 +1,8 @@ /** - * \brief Bridge for C programs to access solve_VPSC (which is in C++) - * + * @file + * Bridge for C programs to access solve_VPSC (which is in C++). + */ +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * diff --git a/src/libvpsc/pairingheap/PairingHeap.cpp b/src/libvpsc/pairingheap/PairingHeap.cpp index 202980b70..6e003f99c 100644 --- a/src/libvpsc/pairingheap/PairingHeap.cpp +++ b/src/libvpsc/pairingheap/PairingHeap.cpp @@ -1,12 +1,14 @@ /** - * \brief Pairing heap datastructure implementation + * @file + * Pairing heap datastructure implementation. * * Based on example code in "Data structures and Algorithm Analysis in C++" * by Mark Allen Weiss, used and released under the LGPL by permission * of the author. * * No promises about correctness. Use at your own risk! - * + */ +/* * Authors: * Mark Allen Weiss * Tim Dwyer <tgdwyer@gmail.com> diff --git a/src/libvpsc/pairingheap/PairingHeap.h b/src/libvpsc/pairingheap/PairingHeap.h index 6159e96c1..62c782d5d 100644 --- a/src/libvpsc/pairingheap/PairingHeap.h +++ b/src/libvpsc/pairingheap/PairingHeap.h @@ -1,10 +1,4 @@ -/** - * \brief Pairing heap datastructure implementation - * - * Based on example code in "Data structures and Algorithm Analysis in C++" - * by Mark Allen Weiss, used and released under the LGPL by permission - * of the author. - * +/* * No promises about correctness. Use at your own risk! * * Authors: @@ -67,6 +61,13 @@ public: virtual bool isLessThan(T const &lhs, T const &rhs) const = 0; }; +/** + * Pairing heap datastructure implementation. + * + * Based on example code in "Data structures and Algorithm Analysis in C++" + * by Mark Allen Weiss, used and released under the LGPL by permission + * of the author. + */ template <class T> class PairingHeap { diff --git a/src/libvpsc/solve_VPSC.h b/src/libvpsc/solve_VPSC.h index 0f919a22a..84f646226 100644 --- a/src/libvpsc/solve_VPSC.h +++ b/src/libvpsc/solve_VPSC.h @@ -1,7 +1,9 @@ /** - * \brief Solve an instance of the "Variable Placement with Separation + * @file + * Solve an instance of the "Variable Placement with Separation * Constraints" problem. - * + */ +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * diff --git a/src/libvpsc/variable.h b/src/libvpsc/variable.h index 25239ff20..022754a7d 100644 --- a/src/libvpsc/variable.h +++ b/src/libvpsc/variable.h @@ -1,5 +1,4 @@ -/** - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * diff --git a/src/line-snapper.h b/src/line-snapper.h index bf7d714b1..578a426ce 100644 --- a/src/line-snapper.h +++ b/src/line-snapper.h @@ -1,10 +1,6 @@ #ifndef SEEN_LINE_SNAPPER_H #define SEEN_LINE_SNAPPER_H - -/** - * \file src/line-snapper.h - * \brief Superclass for snappers to horizontal and vertical lines. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Diederik van Lierop <mail@diedenrezi.nl> @@ -20,6 +16,10 @@ namespace Inkscape { class SnapCandidatePoint; + +/** + * Superclass for snappers to horizontal and vertical lines. + */ class LineSnapper : public Snapper { public: diff --git a/src/object-hierarchy.h b/src/object-hierarchy.h index f6ae4f15d..d510e7e69 100644 --- a/src/object-hierarchy.h +++ b/src/object-hierarchy.h @@ -1,6 +1,4 @@ -/** \file - * Inkscape::ObjectHierarchy - tracks a hierarchy of active SPObjects - * +/* * Authors: * MenTaLguY <mental@rydia.net> * @@ -36,7 +34,6 @@ namespace Inkscape { * * @see SPObject */ - class ObjectHierarchy { public: ObjectHierarchy(SPObject *top=NULL); diff --git a/src/object-snapper.h b/src/object-snapper.h index 932b62dac..5526040f3 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -1,10 +1,6 @@ #ifndef SEEN_OBJECT_SNAPPER_H #define SEEN_OBJECT_SNAPPER_H - -/** - * \file object-snapper.h - * \brief Snapping things to objects. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Diederik van Lierop <mail@diedenrezi.nl> @@ -26,6 +22,9 @@ struct SPObject; namespace Inkscape { +/** + * Snapping things to objects. + */ class ObjectSnapper : public Snapper { diff --git a/src/registrytool.h b/src/registrytool.h index e98f2df38..7bb00b8f5 100644 --- a/src/registrytool.h +++ b/src/registrytool.h @@ -1,12 +1,6 @@ -#ifndef __REGISTRYTOOL_H__ -#define __REGISTRYTOOL_H__ -/** - * Inkscape Registry Tool - * - * This simple tool is intended for allowing Inkscape to append subdirectories - * to its path. This will allow extensions and other files to be accesses - * without explicit user intervention. - * +#ifndef SEEN_REGISTRYTOOL_H +#define SEEN_REGISTRYTOOL_H +/* * Authors: * Bob Jamison * @@ -30,6 +24,13 @@ #include <string> #include <glibmm.h> +/** + * Inkscape Registry Tool + * + * This simple tool is intended for allowing Inkscape to append subdirectories + * to its path. This will allow extensions and other files to be accesses + * without explicit user intervention. + */ class RegistryTool { public: @@ -53,5 +54,5 @@ public: }; -#endif /* __REGISTRYTOOL_H__ */ +#endif // SEEN_REGISTRYTOOL_H diff --git a/src/rubberband.h b/src/rubberband.h index 0761d8066..1b71f9ae2 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -1,10 +1,6 @@ #ifndef SEEN_RUBBERBAND_H #define SEEN_RUBBERBAND_H - -/** - * \file src/rubberband.h - * \brief Rubberbanding selector - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Carl Hetherington <inkscape@carlh.net> @@ -34,6 +30,9 @@ enum { namespace Inkscape { +/** + * Rubberbanding selector. + */ class Rubberband { public: diff --git a/src/selection.h b/src/selection.h index 081776427..a151be500 100644 --- a/src/selection.h +++ b/src/selection.h @@ -1,9 +1,6 @@ #ifndef SEEN_INKSCAPE_SELECTION_H #define SEEN_INKSCAPE_SELECTION_H - -/** \file - * Inkscape::Selection: per-desktop selection container - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * MenTaLguY <mental@rydia.net> @@ -43,7 +40,7 @@ class Node; namespace Inkscape { /** - * @brief The set of selected SPObjects for a given desktop. + * The set of selected SPObjects for a given desktop. * * This class represents the set of selected SPItems for a given * SPDesktop. @@ -74,49 +71,49 @@ public: ~Selection(); /** - * @brief Returns the desktop the selection is bound to + * Returns the desktop the selection is bound to * * @return the desktop the selection is bound to */ SPDesktop *desktop() { return _desktop; } /** - * @brief Returns active layer for selection (currentLayer or its parent) + * Returns active layer for selection (currentLayer or its parent). * * @return layer item the selection is bound to */ SPObject *activeContext(); /** - * @brief Add an SPObject to the set of selected objects + * Add an SPObject to the set of selected objects. * * @param obj the SPObject to add */ void add(SPObject *obj, bool persist_selection_context = false); /** - * @brief Add an XML node's SPObject to the set of selected objects + * Add an XML node's SPObject to the set of selected objects. * * @param the xml node of the item to add */ void add(XML::Node *repr) { add(_objectForXMLNode(repr)); } /** - * @brief Set the selection to a single specific object + * Set the selection to a single specific object. * * @param obj the object to select */ void set(SPObject *obj, bool persist_selection_context = false); /** - * @brief Set the selection to an XML node's SPObject + * Set the selection to an XML node's SPObject. * * @param repr the xml node of the item to select */ void set(XML::Node *repr) { set(_objectForXMLNode(repr)); } /** - * @brief Removes an item from the set of selected objects + * Removes an item from the set of selected objects. * * It is ok to call this method for an unselected item. * @@ -125,14 +122,14 @@ public: void remove(SPObject *obj); /** - * @brief Removes an item if selected, adds otherwise + * Removes an item if selected, adds otherwise. * * @param item the item to unselect */ void toggle(SPObject *obj); /** - * @brief Removes an item from the set of selected objects + * Removes an item from the set of selected objects. * * It is ok to call this method for an unselected item. * @@ -141,27 +138,27 @@ public: void remove(XML::Node *repr) { remove(_objectForXMLNode(repr)); } /** - * @brief Selects exactly the specified objects + * Selects exactly the specified objects. * * @param objs the objects to select */ void setList(GSList const *objs); /** - * @brief Adds the specified objects to selection, without deselecting first + * Adds the specified objects to selection, without deselecting first. * * @param objs the objects to select */ void addList(GSList const *objs); /** - * @brief Clears the selection and selects the specified objects + * Clears the selection and selects the specified objects. * * @param repr a list of xml nodes for the items to select */ void setReprList(GSList const *reprs); - /** \brief Add items from an STL iterator range to the selection + /** Add items from an STL iterator range to the selection. * \param from the begin iterator * \param to the end iterator */ @@ -176,102 +173,106 @@ public: } /** - * @brief Unselects all selected objects. + * Unselects all selected objects.. */ void clear(); /** - * @brief Returns true if no items are selected + * Returns true if no items are selected. */ bool isEmpty() const { return _objs == NULL; } /** - * @brief Returns true if the given object is selected + * Returns true if the given object is selected. */ bool includes(SPObject *obj) const; /** - * @brief Returns true if the given item is selected + * Returns true if the given item is selected. */ bool includes(XML::Node *repr) const { return includes(_objectForXMLNode(repr)); } /** - * @brief Returns a single selected object + * Returns a single selected object. * * @return NULL unless exactly one object is selected */ SPObject *single(); /** - * @brief Returns a single selected item + * Returns a single selected item. * * @return NULL unless exactly one object is selected */ SPItem *singleItem(); /** - * @brief Returns a single selected object's xml node + * Returns a single selected object's xml node. * * @return NULL unless exactly one object is selected */ XML::Node *singleRepr(); - /** @brief Returns the list of selected objects */ + /** Returns the list of selected objects. */ GSList const *list(); - /** @brief Returns the list of selected SPItems */ + /** Returns the list of selected SPItems. */ GSList const *itemList(); - /** @brief Returns a list of the xml nodes of all selected objects */ + /** Returns a list of the xml nodes of all selected objects. */ /// \todo only returns reprs of SPItems currently; need a separate /// method for that GSList const *reprList(); - /** @brief Returns a list of all perspectives which have a 3D box in the current selection + /** Returns a list of all perspectives which have a 3D box in the current selection. (these may also be nested in groups) */ std::list<Persp3D *> const perspList(); - /** @brief Returns a list of all 3D boxes in the current selection which are associated to @c - persp. If @c pers is @c NULL, return all selected boxes. - */ + /** + * Returns a list of all 3D boxes in the current selection which are associated to @c + * persp. If @c pers is @c NULL, return all selected boxes. + */ std::list<SPBox3D *> const box3DList(Persp3D *persp = NULL); - /** @brief Returns the number of layers in which there are selected objects */ + /** Returns the number of layers in which there are selected objects. */ guint numberOfLayers(); - /** @brief Returns the number of parents to which the selected objects belong */ + /** Returns the number of parents to which the selected objects belong. */ guint numberOfParents(); - /** @brief Returns the bounding rectangle of the selection */ + /** Returns the bounding rectangle of the selection. */ Geom::OptRect bounds(SPItem::BBoxType type) const; Geom::OptRect visualBounds() const; Geom::OptRect geometricBounds() const; - /** @brief Returns either the visual or geometric bounding rectangle of the selection, based on the - * preferences specified for the selector tool */ + + /** + * Returns either the visual or geometric bounding rectangle of the selection, based on the + * preferences specified for the selector tool + */ Geom::OptRect preferredBounds() const; /// Returns the bounding rectangle of the selectionin document coordinates. Geom::OptRect documentBounds(SPItem::BBoxType type) const; /** - * @brief Returns the rotation/skew center of the selection + * Returns the rotation/skew center of the selection. */ boost::optional<Geom::Point> center() const; /** - * @brief Gets the selection's snap points. + * Gets the selection's snap points. * @return Selection's snap points */ std::vector<Inkscape::SnapCandidatePoint> getSnapPoints(SnapPreferences const *snapprefs) const; /** - * @brief Gets the snap points of a selection that form a convex hull. + * Gets the snap points of a selection that form a convex hull. * @return Selection's convex hull points */ std::vector<Inkscape::SnapCandidatePoint> getSnapPointsConvexHull(SnapPreferences const *snapprefs) const; /** - * @brief Connects a slot to be notified of selection changes + * Connects a slot to be notified of selection changes. * * This method connects the given slot such that it will * be called upon any change in the set of selected objects. @@ -285,8 +286,7 @@ public: } /** - * @brief Connects a slot to be notified of selected - * object modifications + * Connects a slot to be notified of selected object modifications. * * This method connects the given slot such that it will * receive notifications whenever any selected item is @@ -303,36 +303,36 @@ public: } private: - /** @brief no copy */ + /** no copy. */ Selection(Selection const &); - /** @brief no assign */ + /** no assign. */ void operator=(Selection const &); - /** @brief Issues modification notification signals */ + /** Issues modification notification signals. */ static gboolean _emit_modified(Selection *selection); - /** @brief Schedules an item modification signal to be sent */ + /** Schedules an item modification signal to be sent. */ void _schedule_modified(SPObject *obj, guint flags); - /** @brief Issues modified selection signal */ + /** Issues modified selection signal. */ void _emitModified(guint flags); - /** @brief Issues changed selection signal */ + /** Issues changed selection signal. */ void _emitChanged(bool persist_selection_context = false); void _invalidateCachedLists(); - /** @brief unselect all descendants of the given item */ + /** unselect all descendants of the given item. */ void _removeObjectDescendants(SPObject *obj); - /** @brief unselect all ancestors of the given item */ + /** unselect all ancestors of the given item. */ void _removeObjectAncestors(SPObject *obj); - /** @brief clears the selection (without issuing a notification) */ + /** clears the selection (without issuing a notification). */ void _clear(); - /** @brief adds an object (without issuing a notification) */ + /** adds an object (without issuing a notification). */ void _add(SPObject *obj); - /** @brief removes an object (without issuing a notification) */ + /** removes an object (without issuing a notification). */ void _remove(SPObject *obj); - /** @brief returns the SPObject corresponding to an xml node (if any) */ + /** returns the SPObject corresponding to an xml node (if any). */ SPObject *_objectForXMLNode(XML::Node *repr) const; - /** @brief Releases an active layer object that is being removed */ + /** Releases an active layer object that is being removed. */ void _releaseContext(SPObject *obj); mutable GSList *_objs; diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 43082c010..5302b49c9 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -2,9 +2,10 @@ #define SEEN_SNAP_CANDIDATE_H /** - * \file snap-candidate.h - * \brief some utility classes to store various kinds of snap candidates. - * + * @file + * Some utility classes to store various kinds of snap candidates. + */ +/* * Authors: * Diederik van Lierop <mail@diedenrezi.nl> * diff --git a/src/snap-enums.h b/src/snap-enums.h index d28f11314..15d35092c 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -1,10 +1,6 @@ #ifndef SNAPENUMS_H_ #define SNAPENUMS_H_ - -/** - * \file snap-enums.h - * \brief enumerations of snap source types and snap target types - * +/* * Authors: * Diederik van Lierop <mail@diedenrezi.nl> * @@ -15,6 +11,9 @@ namespace Inkscape { +/** + * enumerations of snap source types and snap target types. + */ enum SnapSourceType { SNAPSOURCE_UNDEFINED = 0, //------------------------------------------------------------------- diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 9f126d791..8044d0aa7 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -1,10 +1,7 @@ #ifndef SNAPPREFERENCES_H_ #define SNAPPREFERENCES_H_ -/** - * \file snap-preferences.cpp - * \brief Storing of snapping preferences - * +/* * Authors: * Diederik van Lierop <mail@diedenrezi.nl> * @@ -19,6 +16,9 @@ namespace Inkscape { +/** + * Storing of snapping preferences. + */ class SnapPreferences { public: diff --git a/src/sp-gradient.h b/src/sp-gradient.h index c92d07fd3..e6d5b5e60 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -1,9 +1,6 @@ #ifndef SEEN_SP_GRADIENT_H #define SEEN_SP_GRADIENT_H - -/** \file - * SVG <stop> <linearGradient> and <radialGradient> implementation - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> diff --git a/src/sp-object.h b/src/sp-object.h index a4220e720..3999dc622 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -1,9 +1,7 @@ #ifndef SP_OBJECT_H_SEEN #define SP_OBJECT_H_SEEN -/** \file - * Abstract base class for all nodes - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Jon A. Cruz <jon@joncruz.org> @@ -134,7 +132,11 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner=NULL); SPObject *sp_object_href(SPObject *object, gpointer owner); SPObject *sp_object_hunref(SPObject *object, gpointer owner); -/// A refcounting tree node object. + +/** + * Abstract base class for all nodes. + * A refcounting tree node object. + */ class SPObject : public GObject { public: enum CollectionPolicy { diff --git a/src/sp-offset.h b/src/sp-offset.h index a229e0bb6..ec8c2cf29 100644 --- a/src/sp-offset.h +++ b/src/sp-offset.h @@ -1,9 +1,6 @@ -#ifndef __SP_OFFSET_H__ -#define __SP_OFFSET_H__ - -/** \file - * SPOffset class. - * +#ifndef SEEN_SP_OFFSET_H +#define SEEN_SP_OFFSET_H +/* * Authors: * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/sp-spiral.h b/src/sp-spiral.h index 7b31b19d8..6da7c38a4 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -1,9 +1,6 @@ -#ifndef __SP_SPIRAL_H__ -#define __SP_SPIRAL_H__ - -/** \file - * SPSpiral: <sodipodi:spiral> implementation - * +#ifndef SEEN_SP_SPIRAL_H +#define SEEN_SP_SPIRAL_H +/* * Authors: * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@kaplinski.com> @@ -88,4 +85,4 @@ bool sp_spiral_is_invalid (SPSpiral const *spiral); -#endif +#endif // SEEN_SP_SPIRAL_H diff --git a/src/svg-view-widget.h b/src/svg-view-widget.h index 46def687b..0c2c651ad 100644 --- a/src/svg-view-widget.h +++ b/src/svg-view-widget.h @@ -1,9 +1,6 @@ #ifndef SEEN_SP_SVG_VIEW_WIDGET_H #define SEEN_SP_SVG_VIEW_WIDGET_H - -/** \file - * SPSVGView, SPSVGSPViewWidget: Generic SVG view and widget - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Jon A. Cruz <jon@joncruz.org> diff --git a/src/svg-view.h b/src/svg-view.h index 838a95b03..5e830eb00 100644 --- a/src/svg-view.h +++ b/src/svg-view.h @@ -1,9 +1,6 @@ -#ifndef __SP_SVG_VIEW_H__ -#define __SP_SVG_VIEW_H__ - -/** \file - * SPSVGView, SPSVGSPViewWidget: Generic SVG view and widget - * +#ifndef SEEN_SP_SVG_VIEW_H +#define SEEN_SP_SVG_VIEW_H +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -61,7 +58,7 @@ private: virtual void onDocumentResized (double, double); }; -#endif +#endif // SEEN_SP_SVG_VIEW_H /* Local Variables: diff --git a/src/svg/path-string.h b/src/svg/path-string.h index 1d057519f..f959b25b7 100644 --- a/src/svg/path-string.h +++ b/src/svg/path-string.h @@ -1,6 +1,4 @@ -/** - * Inkscape::SVG::PathString - builder for SVG path strings - * +/* * Copyright 2007 MenTaLguY <mental@rydia.net> * Copyright 2008 Jasper van de Gronde <th.v.d.gronde@hccnet.nl> * @@ -25,6 +23,9 @@ namespace Inkscape { namespace SVG { +/** + * Builder for SVG path strings. + */ class PathString { public: PathString(); diff --git a/src/trace/siox.h b/src/trace/siox.h index 57c78bd5a..dd7f9422f 100644 --- a/src/trace/siox.h +++ b/src/trace/siox.h @@ -1,6 +1,6 @@ -#ifndef __SIOX_H__ -#define __SIOX_H__ -/** +#ifndef SEEN_SIOX_H +#define SEEN_SIOX_H +/* * Copyright 2005, 2006 by Gerald Friedland, Kristian Jantz and Lars Knipping * * Conversion to C++ for Inkscape by Bob Jamison @@ -18,7 +18,7 @@ * limitations under the License. */ -/** +/* * Note by Bob Jamison: * After translating the siox.org Java API to C++ and receiving an * education into this wonderful code, I began again, @@ -660,10 +660,7 @@ private: } // namespace siox } // namespace org -#endif /* __SIOX_H__ */ +#endif // SEEN_SIOX_H //######################################################################## //# E N D O F F I L E //######################################################################## - - - diff --git a/src/trace/trace.h b/src/trace/trace.h index 2c9922e10..45b18385f 100644 --- a/src/trace/trace.h +++ b/src/trace/trace.h @@ -1,7 +1,4 @@ -/** - * A generic interface for plugging different - * autotracers into Inkscape. - * +/* * Authors: * Bob Jamison <rjamison@titan.com> * @@ -110,7 +107,8 @@ private: /** - * + * A generic interface for plugging different + * autotracers into Inkscape. */ class TracingEngine { diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 88d0310b9..20136fbff 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -1,7 +1,4 @@ -/** - * - * \brief Dialog for modifying guidelines - * +/* * Author: * Andrius R. <knutux@gmail.com> * Johan Engelen @@ -40,6 +37,9 @@ namespace Widget { namespace Dialogs { +/** + * Dialog for modifying guidelines. + */ class GuidelinePropertiesDialog : public Gtk::Dialog { public: GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop); diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 577beb5ce..ba29d6225 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -1,8 +1,4 @@ -/** - * \file - * - * Abstract base class for all EditWidget implementations. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * John Bintz <jcoswell@coswellproductions.org> @@ -26,6 +22,9 @@ namespace Inkscape { namespace UI { namespace View { +/** + * Abstract base class for all EditWidget implementations. + */ struct EditWidgetInterface { EditWidgetInterface() {} diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index f216c8e27..5143054d2 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -1,9 +1,7 @@ #ifndef INKSCAPE_UI_VIEW_VIEWWIDGET_H #define INKSCAPE_UI_VIEW_VIEWWIDGET_H -/** \file - * A widget is the UI context for a document view. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -17,10 +15,13 @@ #include <gtk/gtk.h> namespace Inkscape { - namespace UI { - namespace View { - class View; - }}} +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI +} // namespace Inkscape + class SPViewWidget; class SPNamedView; diff --git a/src/ui/view/view.h b/src/ui/view/view.h index c56d79147..8b30aead2 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -1,9 +1,6 @@ #ifndef INKSCAPE_UI_VIEW_VIEW_H #define INKSCAPE_UI_VIEW_VIEW_H - -/** \file - * Abstract base class for all SVG document views - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> diff --git a/src/ui/widget/attr-widget.h b/src/ui/widget/attr-widget.h index 7b9c35ab7..94906c8e8 100644 --- a/src/ui/widget/attr-widget.h +++ b/src/ui/widget/attr-widget.h @@ -1,6 +1,4 @@ -/** - * \brief Very basic interface for classes that control attributes - * +/* * Authors: * Nicholas Bishop <nicholasbishop@gmail.com> * Rodrigo Kumpera <kumpera@gmail.com> @@ -32,6 +30,9 @@ enum DefaultValueType T_CHARPTR }; +/** + * Very basic interface for classes that control attributes. + */ class DefaultValueHolder { DefaultValueType type; diff --git a/src/ui/widget/button.h b/src/ui/widget/button.h index 7e942b324..1ed88a2da 100644 --- a/src/ui/widget/button.h +++ b/src/ui/widget/button.h @@ -1,6 +1,4 @@ -/** - * \brief Button and CheckButton widgets - * +/* * Author: * buliabyak@gmail.com * @@ -20,6 +18,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Button widget. + */ class Button : public Gtk::Button { public: @@ -29,6 +30,9 @@ protected: Gtk::Tooltips _tooltips; }; +/** + * CheckButton widget. + */ class CheckButton : public Gtk::CheckButton { public: diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h index 424c58665..aa4c7e11d 100644 --- a/src/ui/widget/color-preview.h +++ b/src/ui/widget/color-preview.h @@ -1,9 +1,6 @@ -#ifndef __COLOR_PREVIEW_H__ -#define __COLOR_PREVIEW_H__ - -/** \file - * A simple color preview widget, mainly used within a picker button. - * +#ifndef SEEN_COLOR_PREVIEW_H +#define SEEN_COLOR_PREVIEW_H +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -17,9 +14,12 @@ #include <gtkmm/eventbox.h> namespace Inkscape { - namespace UI { - namespace Widget { +namespace UI { +namespace Widget { +/** + * A simple color preview widget, mainly used within a picker button. + */ class ColorPreview : public Gtk::Widget { public: ColorPreview (guint32 rgba); @@ -34,9 +34,11 @@ protected: guint32 _rgba; }; -}}} +} // namespace Widget +} // namespace UI +} // namespace Inkscape -#endif +#endif // SEEN_COLOR_PREVIEW_H /* Local Variables: diff --git a/src/ui/widget/combo-enums.h b/src/ui/widget/combo-enums.h index d9044daa6..9dfb920a5 100644 --- a/src/ui/widget/combo-enums.h +++ b/src/ui/widget/combo-enums.h @@ -1,6 +1,4 @@ -/** - * \brief Simplified management of enumerations in the UI as combobox. - * +/* * Authors: * Nicholas Bishop <nicholasbishop@gmail.com> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> @@ -23,6 +21,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Simplified management of enumerations in the UI as combobox. + */ template<typename E> class ComboBoxEnum : public Gtk::ComboBox, public AttrWidget { private: @@ -176,6 +177,9 @@ private: }; +/** + * Simplified management of enumerations in the UI as combobox. + */ template<typename E> class LabelledComboBoxEnum : public Labelled { public: diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 1780b7525..48cd71846 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -1,6 +1,4 @@ -/** - * \brief A custom wrapper around gdl-dock-item - * +/* * Author: * Gustav Broberg <broberg@kth.se> * @@ -27,6 +25,9 @@ namespace Widget { class Dock; +/** + * A custom wrapper around gdl-dock-item. + */ class DockItem { public: diff --git a/src/ui/widget/entity-entry.h b/src/ui/widget/entity-entry.h index 5bdee9a90..c96f3351d 100644 --- a/src/ui/widget/entity-entry.h +++ b/src/ui/widget/entity-entry.h @@ -1,6 +1,4 @@ -/** \file - * \brief - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * diff --git a/src/ui/widget/entry.h b/src/ui/widget/entry.h index bb6c1321a..3338f0888 100644 --- a/src/ui/widget/entry.h +++ b/src/ui/widget/entry.h @@ -1,7 +1,4 @@ -/** \file - * - * \brief Helperclass for Gtk::Entry widgets - * +/* * Authors: * Johan Engelen <goejendaagh@zonnet.nl> * @@ -23,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Helperclass for Gtk::Entry widgets. + */ class Entry : public Labelled { public: diff --git a/src/ui/widget/handlebox.h b/src/ui/widget/handlebox.h index 41a993e9d..db384552b 100644 --- a/src/ui/widget/handlebox.h +++ b/src/ui/widget/handlebox.h @@ -1,9 +1,4 @@ -/** - * \brief HandleBox Widget - Adds a detachment handle to another widget. - * - * This work really doesn't amount to much more than a convenience constructor - * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as - * Gtkmm provides several convenience constructors for other widgets as well. +/* * * Author: * Derek P. Moore <derekm@hackunix.org> @@ -22,6 +17,13 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Adds a detachment handle to another widget. + * + * This work really doesn't amount to much more than a convenience constructor + * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as + * Gtkmm provides several convenience constructors for other widgets as well. + */ class HandleBox : public Gtk::HandleBox { public: diff --git a/src/ui/widget/icon-widget.h b/src/ui/widget/icon-widget.h index 3ca461b33..329702f2e 100644 --- a/src/ui/widget/icon-widget.h +++ b/src/ui/widget/icon-widget.h @@ -1,6 +1,4 @@ -/** - * \brief Icon Widget - General image widget (including SVG icons) - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -19,6 +17,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Icon Widget - General image widget (including SVG icons). + */ class IconWidget : public Gtk::Widget { public: diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h index a8b00ebb6..9614dc28a 100644 --- a/src/ui/widget/labelled.h +++ b/src/ui/widget/labelled.h @@ -1,7 +1,4 @@ -/** - * \brief Labelled Widget - Adds a label with optional icon or suffix to - * another widget. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -23,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Adds a label with optional icon or suffix to another widget. + */ class Labelled : public Gtk::HBox { public: diff --git a/src/ui/widget/licensor.h b/src/ui/widget/licensor.h index 9f41a6d0d..3c503b5ba 100644 --- a/src/ui/widget/licensor.h +++ b/src/ui/widget/licensor.h @@ -1,7 +1,4 @@ -/** \file - * \brief Widget for specifying a document's license; part of document - * preferences dialog. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -10,8 +7,8 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#ifndef INKSCAPE_UI_WIDGET_LICENSOR__H -#define INKSCAPE_UI_WIDGET_LICENSOR__H +#ifndef INKSCAPE_UI_WIDGET_LICENSOR_H +#define INKSCAPE_UI_WIDGET_LICENSOR_H #include <gtkmm/box.h> @@ -29,6 +26,10 @@ class EntityEntry; class Registry; +/** + * Widget for specifying a document's license; part of document + * preferences dialog. + */ class Licensor : public Gtk::VBox { public: Licensor(); @@ -45,7 +46,7 @@ protected: } // namespace UI } // namespace Inkscape -#endif // INKSCAPE_UI_WIDGET_LICENSOR__H +#endif // INKSCAPE_UI_WIDGET_LICENSOR_H /* Local Variables: diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index 38c13005e..bd53870d6 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -1,6 +1,4 @@ -/** - * \brief Notebook Page Widget - A tabbed notebook page for dialogs. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -20,6 +18,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A tabbed notebook page for dialogs. + */ class NotebookPage : public Gtk::VBox { public: diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index cb7f8a069..7f165266c 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -1,6 +1,4 @@ -/** \file - * \brief Widget for specifying page size; part of Document Preferences dialog. - * +/* * Author: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -9,8 +7,8 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER__H -#define INKSCAPE_UI_WIDGET_PAGE_SIZER__H +#ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER_H +#define INKSCAPE_UI_WIDGET_PAGE_SIZER_H #include <gtkmm.h> #include <stddef.h> @@ -238,7 +236,7 @@ protected: } // namespace Inkscape -#endif /* INKSCAPE_UI_WIDGET_PAGE_SIZER__H */ +#endif // INKSCAPE_UI_WIDGET_PAGE_SIZER_H /* Local Variables: diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index fe3e226b4..3134111c0 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -1,6 +1,4 @@ -/** - * \brief Generic Panel widget - A generic dockable container. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Jon A. Cruz <jon@joncruz.org> @@ -35,6 +33,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A generic dockable container. + */ class Panel : public Gtk::VBox { public: diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index 68d2f4c9d..651c8c8fb 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -1,7 +1,4 @@ -/** - * \brief Point Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary coordinate values. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * Carl Hetherington <inkscape@carlh.net> @@ -13,7 +10,6 @@ * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - #ifndef INKSCAPE_UI_WIDGET_POINT_H #define INKSCAPE_UI_WIDGET_POINT_H @@ -27,6 +23,10 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional icon or suffix, for + * entering arbitrary coordinate values. + */ class Point : public Labelled { public: diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 6caab11ae..83290a045 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -1,6 +1,8 @@ /** - * \brief Inkscape Preferences dialog - * + * @file + * Widgets for Inkscape Preferences dialog. + */ +/* * Authors: * Marco Scholten * Bruno Dilly <bruno.dilly@gmail.com> diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h index 71cc8d1e5..33f416e3f 100644 --- a/src/ui/widget/random.h +++ b/src/ui/widget/random.h @@ -1,7 +1,4 @@ -/** - * \brief Random Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values and generating a random number from it. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * @@ -19,6 +16,10 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional icon or suffix, for + * entering arbitrary number values and generating a random number from it. + */ class Random : public Scalar { public: diff --git a/src/ui/widget/registered-enums.h b/src/ui/widget/registered-enums.h index 056a09fed..9e1682c7d 100644 --- a/src/ui/widget/registered-enums.h +++ b/src/ui/widget/registered-enums.h @@ -1,6 +1,4 @@ -/** - * \brief Simplified management of enumerations in the UI as combobox. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * @@ -19,6 +17,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Simplified management of enumerations in the UI as combobox. + */ template<typename E> class RegisteredEnum : public RegisteredWidget< LabelledComboBoxEnum<E> > { public: diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index f05eb176a..a948e1535 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -1,6 +1,4 @@ -/** \file - * \brief - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Johan Engelen <j.b.c.engelen@utwente.nl> diff --git a/src/ui/widget/registry.h b/src/ui/widget/registry.h index 4d7ad3068..ed1281d79 100644 --- a/src/ui/widget/registry.h +++ b/src/ui/widget/registry.h @@ -1,6 +1,4 @@ -/** \file - * \brief - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -8,7 +6,6 @@ * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - #ifndef INKSCAPE_UI_WIDGET_REGISTRY__H #define INKSCAPE_UI_WIDGET_REGISTRY__H diff --git a/src/ui/widget/rendering-options.h b/src/ui/widget/rendering-options.h index 8e047e682..3e2e046d3 100644 --- a/src/ui/widget/rendering-options.h +++ b/src/ui/widget/rendering-options.h @@ -1,6 +1,4 @@ -/** - * \brief Rendering Options Widget - A container for selecting rendering options - * +/* * Author: * Kees Cook <kees@outflux.net> * @@ -20,6 +18,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A container for selecting rendering options. + */ class RenderingOptions : public Gtk::VBox { public: diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h index 79a6daa5b..15e0bf71c 100644 --- a/src/ui/widget/rotateable.h +++ b/src/ui/widget/rotateable.h @@ -1,6 +1,4 @@ -/** - * \brief widget adjustable by dragging it to rotate away from a zero-change axis - * +/* * Authors: * buliabyak@gmail.com * @@ -20,6 +18,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Widget adjustable by dragging it to rotate away from a zero-change axis. + */ class Rotateable: public Gtk::EventBox { public: diff --git a/src/ui/widget/ruler.h b/src/ui/widget/ruler.h index afe3a4ba7..319624709 100644 --- a/src/ui/widget/ruler.h +++ b/src/ui/widget/ruler.h @@ -1,9 +1,7 @@ -#ifndef __UI_WIDGET_RULER_H__ -#define __UI_WIDGET_RULER_H__ +#ifndef SEEN_UI_WIDGET_RULER_H +#define SEEN_UI_WIDGET_RULER_H -/** \file - * Gtkmm facade/wrapper around sp_rulers. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -24,9 +22,12 @@ namespace Gtk { class Ruler; } namespace Inkscape { - namespace UI { - namespace Widget { +namespace UI { +namespace Widget { +/** + * Gtkmm facade/wrapper around sp_rulers. + */ class Ruler : public Gtk::EventBox { public: @@ -52,7 +53,9 @@ private: Geom::Point get_event_dt(); }; -/// Horizontal ruler +/** + * Horizontal ruler gtkmm wrapper. + */ class HRuler : public Ruler { public: @@ -60,7 +63,9 @@ public: ~HRuler(); }; -/// Vertical ruler +/** + * Vertical ruler gtkmm wrapper. + */ class VRuler : public Ruler { public: @@ -73,7 +78,7 @@ public: } // namespace Inkscape -#endif +#endif // SEEN_UI_WIDGET_RULER_H /* diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index ed3728e69..05a7b95f8 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -1,8 +1,4 @@ -/** - * \brief Scalar Unit Widget - A labelled text box, with spin buttons and - * optional icon or suffix, for entering the values of various unit - * types. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Derek P. Moore <derekm@hackunix.org> @@ -23,6 +19,10 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional icon or suffix, for + * entering the values of various unit types. + */ class ScalarUnit : public Scalar { public: diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 7142ba93f..66bd07ddb 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -1,7 +1,4 @@ -/** - * \brief Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -21,6 +18,10 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary number values. + */ class Scalar : public Labelled { public: diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 0caa7fe4c..916cbe6d1 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -1,6 +1,4 @@ -/** - * \brief Selected style indicator (fill, stroke, opacity) - * +/* * Authors: * buliabyak@gmail.com * scislac@users.sf.net @@ -103,6 +101,9 @@ private: bool cr_set; }; +/** + * Selected style indicator (fill, stroke, opacity). + */ class SelectedStyle : public Gtk::HBox { public: diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index 703c5d896..7c2ef7ca4 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -1,6 +1,4 @@ -/** - * \brief Groups an HScale and a SpinButton together using the same Adjustment - * +/* * Author: * Nicholas Bishop <nicholasbishop@gmail.com> * @@ -22,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Groups an HScale and a SpinButton together using the same Adjustment. + */ class SpinSlider : public Gtk::HBox, public AttrWidget { public: @@ -55,7 +56,11 @@ private: Inkscape::UI::Widget::SpinButton _spin; }; -// Contains two SpinSliders for controlling number-opt-number attributes +/** + * Contains two SpinSliders for controlling number-opt-number attributes. + * + * @see SpinSlider + */ class DualSpinSlider : public Gtk::HBox, public AttrWidget { public: diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h index 29684ec02..47da91732 100644 --- a/src/ui/widget/style-subject.h +++ b/src/ui/widget/style-subject.h @@ -1,11 +1,12 @@ /** - * \brief Abstraction for different style widget operands - * + * @file + * Abstraction for different style widget operands. + */ +/* * Copyright (C) 2007 MenTaLguY <mental@rydia.net> * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - #ifndef SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H #define SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H @@ -110,7 +111,7 @@ private: } } -#endif +#endif // SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H /* Local Variables: diff --git a/src/ui/widget/svg-canvas.h b/src/ui/widget/svg-canvas.h index cb8dc4013..c513bcf26 100644 --- a/src/ui/widget/svg-canvas.h +++ b/src/ui/widget/svg-canvas.h @@ -1,9 +1,7 @@ -#ifndef __UI_WIDGET_SVGCANVAS_H__ -#define __UI_WIDGET_SVGCANVAS_H__ +#ifndef SEEN_UI_WIDGET_SVGCANVAS_H +#define SEEN_UI_WIDGET_SVGCANVAS_H -/** \file - * Gtkmm facade/wrapper around SPCanvas. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -16,9 +14,12 @@ struct SPCanvas; struct SPDesktop; namespace Gtk { class Widget; } namespace Inkscape { - namespace UI { - namespace Widget { +namespace UI { +namespace Widget { +/** + * Gtkmm facade/wrapper around SPCanvas. + */ class SVGCanvas { public: @@ -41,7 +42,7 @@ protected: } // namespace Inkscape -#endif +#endif // SEEN_UI_WIDGET_SVGCANVAS_H /* diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h index 0dcfc5cc6..bccaefa2e 100644 --- a/src/ui/widget/text.h +++ b/src/ui/widget/text.h @@ -1,7 +1,4 @@ -/** - * \brief Text Widget - A labelled text box, with optional icon or - * suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Maximilian Albert <maximilian.albert@gmail.com> @@ -23,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with optional icon or suffix, for entering arbitrary number values. + */ class Text : public Labelled { public: diff --git a/src/ui/widget/toolbox.h b/src/ui/widget/toolbox.h index 9c4e18909..f721bef8a 100644 --- a/src/ui/widget/toolbox.h +++ b/src/ui/widget/toolbox.h @@ -1,6 +1,4 @@ -/** - * \brief Toolbox Widget - A detachable toolbar for buttons and other widgets. - * +/* * Author: * Derek P. Moore <derekm@hackunix.org> * @@ -22,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A detachable toolbar for buttons and other widgets. + */ class Toolbox : public HandleBox { public: diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index cf42231ba..cb11bbb30 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -1,6 +1,4 @@ -/** - * \brief Unit Menu Widget - A drop down menu for choosing unit types. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -21,6 +19,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A drop down menu for choosing unit types. + */ class UnitMenu : public ComboText { public: diff --git a/src/ui/widget/zoom-status.h b/src/ui/widget/zoom-status.h index 85c3eeee1..b9373589f 100644 --- a/src/ui/widget/zoom-status.h +++ b/src/ui/widget/zoom-status.h @@ -1,9 +1,6 @@ -#ifndef __UI_WIDGET_ZOOMSTATUS_H__ -#define __UI_WIDGET_ZOOMSTATUS_H__ - -/** \file - * Enhanced spinbutton. - * +#ifndef SEEN_UI_WIDGET_ZOOMSTATUS_H +#define SEEN_UI_WIDGET_ZOOMSTATUS_H +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -22,6 +19,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Enhanced spinbutton. + */ class ZoomStatus : public Inkscape::UI::Widget::SpinButton { public: @@ -46,7 +46,7 @@ protected: } // namespace Inkscape -#endif +#endif // SEEN_UI_WIDGET_ZOOMSTATUS_H /* diff --git a/src/undo-stack-observer.h b/src/undo-stack-observer.h index 5bf405f7f..f4d67e841 100644 --- a/src/undo-stack-observer.h +++ b/src/undo-stack-observer.h @@ -1,8 +1,4 @@ -/** - * Undo stack observer interface - * - * Observes undo, redo, and undo log commit events. - * +/* * Authors: * David Yip <yipdw@rose-hulman.edu> * @@ -11,8 +7,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifndef __UNDO_COMMIT_OBSERVER_H__ -#define __UNDO_COMMIT_OBSERVER_H__ +#ifndef SEEN_UNDO_COMMIT_OBSERVER_H +#define SEEN_UNDO_COMMIT_OBSERVER_H #include "gc-managed.h" @@ -74,4 +70,4 @@ public: } -#endif +#endif // SEEN_UNDO_COMMIT_OBSERVER_H diff --git a/src/uri.h b/src/uri.h index 7786afcce..159cd1cfc 100644 --- a/src/uri.h +++ b/src/uri.h @@ -1,7 +1,4 @@ -/** - * \file - * \brief Classes for representing and manipulating URIs as per RFC 2396. - * +/* * Authors: * MenTaLguY <mental@rydia.net> * Jon A. Cruz <jon@joncruz.org> @@ -21,7 +18,9 @@ namespace Inkscape { -/** \brief Represents an URI as per RFC 2396. */ +/** + * Represents an URI as per RFC 2396. + */ class URI { public: URI(URI const &uri); diff --git a/src/util/enums.h b/src/util/enums.h index 824da3f75..34138ad21 100644 --- a/src/util/enums.h +++ b/src/util/enums.h @@ -1,6 +1,4 @@ -/** - * \brief Simplified management of enumerations of svg items with UI labels - * +/* * Authors: * Nicholas Bishop <nicholasbishop@gmail.com> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> @@ -9,16 +7,6 @@ * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - -/* IMPORTANT - * When initializing the EnumData struct, you cannot use _(...) to translate strings. - * Instead, one must use N_(...) and do the translation every time the string is retreived. - * - * Note that get_id_from_key and get_id_from_label return 0 if it cannot find an entry for that key string - * Note that get_label and get_key return an empty string when the requested id is not in the list. - */ - - #ifndef INKSCAPE_UTIL_ENUMS_H #define INKSCAPE_UTIL_ENUMS_H @@ -27,6 +15,12 @@ namespace Inkscape { namespace Util { +/** + * Simplified management of enumerations of svg items with UI labels. + * IMPORTANT: + * When initializing the EnumData struct, you cannot use _(...) to translate strings. + * Instead, one must use N_(...) and do the translation every time the string is retreived. + */ template<typename E> struct EnumData { @@ -37,6 +31,12 @@ struct EnumData const Glib::ustring empty_string(""); +/** + * Simplified management of enumerations of svg items with UI labels. + * + * @note that get_id_from_key and get_id_from_label return 0 if it cannot find an entry for that key string. + * @note that get_label and get_key return an empty string when the requested id is not in the list. + */ template<typename E> class EnumDataConverter { public: diff --git a/src/util/list.h b/src/util/list.h index e65aa849b..de5a458e9 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -1,6 +1,4 @@ -/** \file - * Inkscape::Util::List - managed linked list - * +/* * Authors: * MenTaLguY <mental@rydia.net> * @@ -227,7 +225,8 @@ public: MutableList const &); }; -/** @brief Creates a (non-empty) linked list. +/** + * Creates a (non-empty) linked list. * * Creates a new linked list with a copy of the given value (\a first) * in its first element; the remainder of the list will be the list @@ -241,7 +240,7 @@ public: * @param first the value for the first element of the list * @param rest the rest of the list; may be an empty list * - * @returns a new list + * @return a new list * * @see List<> * @see is_empty<> @@ -254,7 +253,8 @@ inline List<T> cons(typename Traits::Reference<T>::RValue first, return List<T>(first, rest); } -/** @brief Creates a (non-empty) linked list whose tail can be exchanged +/** + * Creates a (non-empty) linked list whose tail can be exchanged * for another. * * Creates a new linked list, but one whose tail can be exchanged for @@ -274,7 +274,7 @@ inline List<T> cons(typename Traits::Reference<T>::RValue first, * @param first the value for the first element of the list * @param rest the rest of the list; may be an empty list * - * @returns a new list + * @return a new list */ template <typename T> inline MutableList<T> cons(typename Traits::Reference<T>::RValue first, @@ -283,19 +283,21 @@ inline MutableList<T> cons(typename Traits::Reference<T>::RValue first, return MutableList<T>(first, rest); } -/** @brief Returns true if the given list is empty. +/** + * Returns true if the given list is empty. * * Returns true if the given list is empty. This is equivalent * to !list. * * @param list the list * - * @returns true if the list is empty, false otherwise. + * @return true if the list is empty, false otherwise. */ template <typename T> inline bool is_empty(List<T> const &list) { return !list._cell; } -/** @brief Returns the first value in a linked list. +/** + * Returns the first value in a linked list. * * Returns a reference to the first value in the list. This * corresponds to the value of the first argument passed to cons(). @@ -314,14 +316,15 @@ inline bool is_empty(List<T> const &list) { return !list._cell; } * * @param list the list; cannot be empty * - * @returns a reference to the first value in the list + * @return a reference to the first value in the list */ template <typename T> inline typename List<T>::reference first(List<T> const &list) { return list._cell->value; } -/** @brief Returns the remainder of a linked list after the first element. +/** + * Returns the remainder of a linked list after the first element. * * Returns the remainder of the list after the first element (its "tail"). * @@ -334,14 +337,15 @@ inline typename List<T>::reference first(List<T> const &list) { * * @param list the list; cannot be empty * - * @returns the remainder of the list + * @return the remainder of the list */ template <typename T> inline List<T> const &rest(List<T> const &list) { return reinterpret_cast<List<T> const &>(list._cell->next); } -/** @brief Returns a reference to the remainder of a linked list after +/** + * Returns a reference to the remainder of a linked list after * the first element. * * Returns a reference to the remainder of the list after the first @@ -359,14 +363,15 @@ inline List<T> const &rest(List<T> const &list) { * * @param list the list; cannot be empty * - * @returns a reference to the remainder of the list + * @return a reference to the remainder of the list */ template <typename T> inline MutableList<T> &rest(MutableList<T> const &list) { return reinterpret_cast<MutableList<T> &>(list._cell->next); } -/** @brief Sets a new tail for an existing linked list. +/** + * Sets a new tail for an existing linked list. * * Sets the tail of the given MutableList<>, corresponding to the * second argument of cons(). @@ -380,7 +385,7 @@ inline MutableList<T> &rest(MutableList<T> const &list) { * @param list the list; cannot be empty * @param rest the new tail; corresponds to the second argument of cons() * - * @returns the new tail + * @return the new tail */ template <typename T> inline MutableList<T> const &set_rest(MutableList<T> const &list, diff --git a/src/verbs.h b/src/verbs.h index 7c16ff530..d2b0acd41 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -1,9 +1,6 @@ #ifndef SEEN_SP_VERBS_H #define SEEN_SP_VERBS_H - -/** \file - * \brief Frontend to actions - * +/* * Author: * Lauris Kaplinski <lauris@kaplinski.com> * Ted Gould <ted@gould.cx> @@ -34,9 +31,11 @@ class View; } // namespace UI } // namespace Inkscape -/** \brief This anonymous enum is used to provide a list of the Verbs - which are defined staticly in the verb files. There may be - other verbs which are defined dynamically also. */ +/** + * This anonymous enum is used to provide a list of the Verbs + * which are defined staticly in the verb files. There may be + * other verbs which are defined dynamically also. + */ enum { /* Header */ SP_VERB_INVALID, /**< A dummy verb to represent doing something wrong. */ @@ -312,19 +311,20 @@ gchar *sp_action_get_title (const SPAction *action); namespace Inkscape { -/** \brief A class to represent things the user can do. In many ways - these are 'action factories' as they are used to create - individual actions that are based on a given view. -*/ +/** + * A class to represent things the user can do. In many ways + * these are 'action factories' as they are used to create + * individual actions that are based on a given view. + */ class Verb { private: - /** \brief An easy to use defition of the table of verbs by code. */ + /** An easy to use defition of the table of verbs by code. */ typedef std::map<unsigned int, Inkscape::Verb *> VerbTable; - /** \brief A table of all the dynamically created verbs. */ + /** A table of all the dynamically created verbs. */ static VerbTable _verbs; - /** \brief The table of statically created verbs which are mostly + /** The table of statically created verbs which are mostly 'base verbs'. */ static Verb * _base_verbs[SP_VERB_LAST + 1]; /* Plus one because there is an entry for SP_VERB_LAST */ @@ -343,72 +343,84 @@ private: } }; - /** \brief An easy to use definition of the table of verbs by ID. */ + /** An easy to use definition of the table of verbs by ID. */ typedef std::map<gchar const *, Verb *, ltstr> VerbIDTable; - /** \brief Quick lookup of verbs by ID */ + /** Quick lookup of verbs by ID */ static VerbIDTable _verb_ids; - /** \brief A simple typedef to make using the action table easier. */ + /** A simple typedef to make using the action table easier. */ typedef std::map<Inkscape::UI::View::View *, SPAction *> ActionTable; - /** \brief A list of all the actions that have been created for this + /** A list of all the actions that have been created for this verb. It is referenced by the view that they are created for. */ ActionTable * _actions; - /** \brief A unique textual ID for the verb. */ + /** A unique textual ID for the verb. */ gchar const * _id; - /** \brief The full name of the verb. (shown on menu entries) */ + /** The full name of the verb. (shown on menu entries) */ gchar const * _name; - /** \brief Tooltip for the verb. */ + /** Tooltip for the verb. */ gchar const * _tip; gchar * _full_tip; // includes shortcut unsigned int _shortcut; - /** \brief Name of the image that represents the verb. */ + /** Name of the image that represents the verb. */ gchar const * _image; - /** \brief Unique numerical representation of the verb. In most cases - it is a value from the anonymous enum at the top of this - file. */ + /** + * Unique numerical representation of the verb. In most cases + * it is a value from the anonymous enum at the top of this + * file. + */ unsigned int _code; - /** \brief Whether this verb is set to default to sensitive or - insensitive when new actions are created. */ + /** + * Whether this verb is set to default to sensitive or + * insensitive when new actions are created. + */ bool _default_sensitive; protected: - /** \brief Allows for preliminary setting of the \c _default_sensitive - value without effecting existing actions - \param in_val New value - - This function is mostly used at initialization where there are - not actions to effect. I can't think of another case where it - should be used. - */ + + /** + * Allows for preliminary setting of the \c _default_sensitive + * value without effecting existing actions. + * This function is mostly used at initialization where there are + * not actions to effect. I can't think of another case where it + * should be used. + * + * @param in_val New value. + */ bool set_default_sensitive (bool in_val) { return _default_sensitive = in_val; } + public: - /** \brief Accessor to get the \c _default_sensitive value */ + + /** Accessor to get the \c _default_sensitive value. */ bool get_default_sensitive (void) { return _default_sensitive; } -public: - /** \brief Accessor to get the internal variable. */ + /** Accessor to get the internal variable. */ unsigned int get_code (void) { return _code; } - /** \brief Accessor to get the internal variable. */ + + /** Accessor to get the internal variable. */ gchar const * get_id (void) { return _id; } - /** \brief Accessor to get the internal variable. */ + + /** Accessor to get the internal variable. */ gchar const * get_name (void) { return _name; } - /** \brief Accessor to get the internal variable. */ + + /** Accessor to get the internal variable. */ gchar const * get_tip (void) ; - /** \brief Accessor to get the internal variable. */ + + /** Accessor to get the internal variable. */ gchar const * get_image (void) { return _image; } - /** \brief Set the name after initialization. */ + /** Set the name after initialization. */ gchar const * set_name (gchar const * name) { _name = name; return _name; } - /** \brief Set the tooltip after initialization. */ + + /** Set the tooltip after initialization. */ gchar const * set_tip (gchar const * tip) { _tip = tip; return _tip; } protected: @@ -416,25 +428,28 @@ protected: virtual SPAction *make_action (Inkscape::UI::View::View *view); public: - /** \brief Inititalizes the Verb with the parameters - \param code Goes to \c _code - \param id Goes to \c _id - \param name Goes to \c _name - \param tip Goes to \c _tip - \param image Goes to \c _image - - This function also sets \c _actions to NULL. - - \warning NO DATA IS COPIED BY CALLING THIS FUNCTION. - - In many respects this is very bad object oriented design, but it - is done for a reason. All verbs today are of two types: 1) static - or 2) created for extension. In the static case all of the - strings are constants in the code, and thus don't really need to - be copied. In the extensions case the strings are identical to - the ones already created in the extension object, copying them - would be a waste of memory. - */ + + /** + * Inititalizes the Verb with the parameters. + * + * This function also sets \c _actions to NULL. + * + * @warning NO DATA IS COPIED BY CALLING THIS FUNCTION. + * + * In many respects this is very bad object oriented design, but it + * is done for a reason. All verbs today are of two types: 1) static + * or 2) created for extension. In the static case all of the + * strings are constants in the code, and thus don't really need to + * be copied. In the extensions case the strings are identical to + * the ones already created in the extension object, copying them + * would be a waste of memory. + * + * @param code Goes to \c _code. + * @param id Goes to \c _id. + * @param name Goes to \c _name. + * @param tip Goes to \c _tip. + * @param image Goes to \c _image. + */ Verb(const unsigned int code, gchar const * id, gchar const * name, @@ -461,16 +476,19 @@ public: private: static Verb * get_search (unsigned int code); public: - /** \brief A function to turn a code into a verb. - \param code The code to be translated - \return A pointer to a verb object or a NULL if not found. - - This is an inline function to translate the codes which are - static quickly. This should optimize into very quick code - everywhere which hard coded \c codes are used. In the case - where the \c code is not static the \c get_search function - is used. - */ + + /** + * A function to turn a code into a verb. + * + * This is an inline function to translate the codes which are + * static quickly. This should optimize into very quick code + * everywhere which hard coded \c codes are used. In the case + * where the \c code is not static the \c get_search function + * is used. + * + * @param code The code to be translated + * @return A pointer to a verb object or a NULL if not found. + */ static Verb * get (unsigned int code) { if (code <= SP_VERB_LAST) { return _base_verbs[code]; @@ -488,13 +506,16 @@ public: // Yes, multiple public, protected and private sections are bad. We'll clean that up later protected: - /** \brief Returns the size of the internal base verb array. - \return The size in elements of the internal base array. - This is an inline function intended for testing. This should normally not be used. - For testing, a subclass that returns this value can be created to verify that the - length matches the enum values, etc. - */ + /** + * Returns the size of the internal base verb array. + * + * This is an inline function intended for testing. This should normally not be used. + * For testing, a subclass that returns this value can be created to verify that the + * length matches the enum values, etc. + * + * @return The size in elements of the internal base array. + */ static int _getBaseListSize(void) {return G_N_ELEMENTS(_base_verbs);} public: diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index 25ba4aa97..69cfa602e 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -1,7 +1,6 @@ #ifndef SEEN_SP_PAINT_SELECTOR_H #define SEEN_SP_PAINT_SELECTOR_H - -/** \file +/* * Generic paint selector widget * * Authors: @@ -32,7 +31,9 @@ class SPStyle; #define SP_IS_PAINT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_PAINT_SELECTOR)) #define SP_IS_PAINT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_PAINT_SELECTOR)) -/// Generic paint selector widget +/** + * Generic paint selector widget. + */ struct SPPaintSelector { GtkVBox vbox; -- cgit v1.2.3 From 2633767789e4264b13ef91a684accf734fb4e94f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Wed, 26 Oct 2011 21:55:51 -0700 Subject: Fixing more broken and split doc comments. (bzr r10697) --- src/2geom/sbasis-geometric.cpp | 3 +- src/2geom/sbasis-roots.cpp | 3 +- src/2geom/shape.cpp | 4 +- src/2geom/svg-path-parser.cpp | 5 +- src/2geom/utils.cpp | 3 +- src/bind/dobinding.cpp | 3 +- src/color.cpp | 4 +- src/connector-context.cpp | 2 +- src/deptool.cpp | 2 +- src/desktop-style.cpp | 2 +- src/desktop.cpp | 34 +- src/desktop.h | 32 +- src/display/canvas-temporary-item-list.cpp | 2 +- src/display/canvas-temporary-item.cpp | 2 +- src/display/snap-indicator.cpp | 2 +- src/display/sp-canvas.cpp | 2 +- src/document-undo.cpp | 2 +- src/document.cpp | 2 +- src/dom/cssreader.cpp | 2 +- src/dom/domimpl.cpp | 2 +- src/dom/domptr.cpp | 2 +- src/dom/domstring.cpp | 2 +- src/dom/io/base64stream.cpp | 2 +- src/dom/io/bufferstream.cpp | 2 +- src/dom/io/domstream.cpp | 2 +- src/dom/io/gzipstream.cpp | 2 +- src/dom/io/stringstream.cpp | 2 +- src/dom/io/uristream.cpp | 2 +- src/dom/lsimpl.cpp | 2 +- src/dom/odf/odfdocument.cpp | 2 +- src/dom/prop-css.cpp | 2 +- src/dom/prop-css2.cpp | 2 +- src/dom/prop-svg.cpp | 2 +- src/dom/smilimpl.cpp | 2 +- src/dom/svgimpl.cpp | 2 +- src/dom/svgreader.cpp | 2 +- src/dom/uri.cpp | 2 +- src/dom/util/digest.cpp | 2 +- src/dom/util/thread.cpp | 2 +- src/dom/util/ziptool.cpp | 2 +- src/dom/xmlreader.cpp | 2 +- src/dom/xmlwriter.cpp | 2 +- src/dom/xpathimpl.cpp | 2 +- src/dom/xpathparser.cpp | 2 +- src/dom/xpathtoken.cpp | 2 +- src/event-context.cpp | 3 +- src/extension/internal/odf.cpp | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/internal/pdfinput/pdf-parser.cpp | 5 +- src/extension/internal/pdfinput/svg-builder.cpp | 2 +- src/extension/script/InkscapeScript.cpp | 2 +- src/guide-snapper.cpp | 3 +- src/helper/action.cpp | 3 +- src/helper/geom-nodetype.cpp | 2 +- src/helper/geom.cpp | 2 +- src/id-clash.cpp | 2 +- src/io/base64stream.cpp | 2 +- src/io/gzipstream.cpp | 2 +- src/io/inkscapestream.cpp | 2 +- src/io/resource.cpp | 2 +- src/io/stringstream.cpp | 2 +- src/io/uristream.cpp | 2 +- src/io/xsltstream.cpp | 2 +- src/io/xsltstream.h | 2 +- src/knot-holder-entity.cpp | 2 +- src/knot.cpp | 38 +- src/knot.h | 42 ++- src/libvpsc/block.cpp | 36 +- src/libvpsc/block.h | 55 ++- src/libvpsc/blocks.cpp | 31 +- src/libvpsc/blocks.h | 63 +++- src/libvpsc/csolve_VPSC.cpp | 4 +- src/libvpsc/remove_rectangle_overlap.cpp | 17 +- src/libvpsc/remove_rectangle_overlap.h | 16 +- src/libvpsc/solve_VPSC.cpp | 40 +-- src/libvpsc/solve_VPSC.h | 75 +++- src/libvpsc/variable.cpp | 4 +- src/line-snapper.cpp | 3 +- src/main.cpp | 2 +- src/object-hierarchy.cpp | 37 +- src/object-hierarchy.h | 51 ++- src/object-snapper.cpp | 22 +- src/object-snapper.h | 17 + src/registrytool.cpp | 18 +- src/registrytool.h | 10 + src/rubberband.cpp | 3 +- src/selection.cpp | 7 +- src/selection.h | 3 +- src/snap-preferences.cpp | 31 +- src/snap-preferences.h | 28 ++ src/snap.cpp | 312 +---------------- src/snap.h | 330 +++++++++++++++++- src/sp-object.cpp | 323 +---------------- src/sp-object.h | 444 +++++++++++++++++++++--- src/svg-view-widget.cpp | 40 +-- src/svg-view-widget.h | 15 +- src/svg-view.cpp | 61 ++-- src/svg-view.h | 45 ++- src/trace/trace.cpp | 35 +- src/trace/trace.h | 20 +- src/ui/dialog/desktop-tracker.cpp | 4 - src/ui/dialog/desktop-tracker.h | 4 - src/ui/dialog/find.cpp | 4 +- src/ui/view/view-widget.cpp | 16 +- src/ui/view/view-widget.h | 24 +- src/ui/view/view.cpp | 16 +- src/ui/view/view.h | 14 + src/ui/widget/button.cpp | 4 +- src/ui/widget/color-picker.cpp | 5 +- src/ui/widget/color-preview.cpp | 4 +- src/ui/widget/dock-item.cpp | 4 +- src/ui/widget/entity-entry.cpp | 3 +- src/ui/widget/entry.cpp | 6 +- src/ui/widget/handlebox.cpp | 8 +- src/ui/widget/icon-widget.cpp | 12 +- src/ui/widget/labelled.cpp | 20 +- src/ui/widget/labelled.h | 13 + src/ui/widget/licensor.cpp | 3 +- src/ui/widget/notebook-page.cpp | 8 +- src/ui/widget/notebook-page.h | 5 + src/ui/widget/page-sizer.cpp | 6 +- src/ui/widget/panel.cpp | 8 +- src/ui/widget/panel.h | 6 +- src/ui/widget/point.cpp | 116 ++----- src/ui/widget/point.h | 103 +++++- src/ui/widget/preferences-widget.cpp | 6 +- src/ui/widget/preferences-widget.h | 5 + src/ui/widget/random.cpp | 53 +-- src/ui/widget/random.h | 55 ++- src/ui/widget/registered-widget.cpp | 12 +- src/ui/widget/registered-widget.h | 6 + src/ui/widget/registry.cpp | 4 +- src/ui/widget/rendering-options.cpp | 12 +- src/ui/widget/rendering-options.h | 4 + src/ui/widget/rotateable.cpp | 4 +- src/ui/widget/scalar-unit.cpp | 127 ++----- src/ui/widget/scalar-unit.h | 95 +++++ src/ui/widget/scalar.cpp | 93 +---- src/ui/widget/scalar.h | 92 ++++- src/ui/widget/selected-style.cpp | 4 +- src/ui/widget/spin-slider.cpp | 4 +- src/ui/widget/spinbutton.cpp | 33 +- src/ui/widget/spinbutton.h | 39 ++- src/ui/widget/style-subject.cpp | 4 +- src/ui/widget/svg-canvas.cpp | 4 +- src/ui/widget/text.cpp | 27 +- src/ui/widget/text.h | 20 ++ src/ui/widget/tolerance-slider.cpp | 5 +- src/ui/widget/tolerance-slider.h | 9 +- src/ui/widget/toolbox.cpp | 4 +- src/ui/widget/unit-menu.cpp | 95 ++--- src/ui/widget/unit-menu.h | 71 ++++ src/ui/widget/zoom-status.cpp | 5 +- src/uri.cpp | 61 +--- src/uri.h | 70 ++++ src/util/expression-evaluator.cpp | 40 --- src/util/expression-evaluator.h | 48 ++- 157 files changed, 2071 insertions(+), 1943 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp index 7d7ed23e4..1c180e143 100644 --- a/src/2geom/sbasis-geometric.cpp +++ b/src/2geom/sbasis-geometric.cpp @@ -4,7 +4,8 @@ //#include <2geom/solver.h> #include <2geom/sbasis-geometric.h> -/** Geometric operators on D2<SBasis> (1D->2D). +/* + * Geometric operators on D2<SBasis> (1D->2D). * Copyright 2007 JF Barraud * Copyright 2007 N Hurst * diff --git a/src/2geom/sbasis-roots.cpp b/src/2geom/sbasis-roots.cpp index 1b870d88f..4602fced9 100644 --- a/src/2geom/sbasis-roots.cpp +++ b/src/2geom/sbasis-roots.cpp @@ -1,4 +1,5 @@ -/** root finding for sbasis functions. +/* + * root finding for sbasis functions. * Copyright 2006 N Hurst * Copyright 2007 JF Barraud * diff --git a/src/2geom/shape.cpp b/src/2geom/shape.cpp index e9f5e55dc..c389b9c6e 100644 --- a/src/2geom/shape.cpp +++ b/src/2geom/shape.cpp @@ -1,5 +1,5 @@ -/** - * \brief Shapes are special paths on which boolops can be performed +/* + * Shapes are special paths on which boolops can be performed. * * Authors: * Michael G. Sloan <mgsloan@gmail.com> diff --git a/src/2geom/svg-path-parser.cpp b/src/2geom/svg-path-parser.cpp index 4d35ccb35..24f9c81ee 100644 --- a/src/2geom/svg-path-parser.cpp +++ b/src/2geom/svg-path-parser.cpp @@ -1,7 +1,6 @@ #line 1 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" -/** - * \file - * \brief parse SVG path specifications +/* + * parse SVG path specifications. * * Copyright 2007 MenTaLguY <mental@rydia.net> * Copyright 2007 Aaron Spike <aaron@ekips.org> diff --git a/src/2geom/utils.cpp b/src/2geom/utils.cpp index a40b7253d..4c9629deb 100644 --- a/src/2geom/utils.cpp +++ b/src/2geom/utils.cpp @@ -1,4 +1,5 @@ -/** Various utility functions. +/* + * Various utility functions. * * Copyright 2008 Marco Cecchetti <mrcekets at gmail.com> * Copyright 2007 Johan Engelen <goejendaagh@zonnet.nl> diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp index 284565e92..5e783e59d 100644 --- a/src/bind/dobinding.cpp +++ b/src/bind/dobinding.cpp @@ -1,5 +1,4 @@ -/** - * @file +/* * This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. * diff --git a/src/color.cpp b/src/color.cpp index 54af89ae5..ab01ebc2a 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -1,6 +1,4 @@ -#define __SP_COLOR_C__ - -/** \file +/* * Colors. * * Author: diff --git a/src/connector-context.cpp b/src/connector-context.cpp index ecc8cdaad..b2687e540 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1,4 +1,4 @@ -/** +/* * Connector creation tool * * Authors: diff --git a/src/deptool.cpp b/src/deptool.cpp index 45a01c4e7..7233c5544 100644 --- a/src/deptool.cpp +++ b/src/deptool.cpp @@ -1,4 +1,4 @@ -/** +/* * DepTool dependency tool * * This is a simple dependency generator coded in C++ diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 074e7bf67..b29799bb3 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Desktop style management * * Authors: diff --git a/src/desktop.cpp b/src/desktop.cpp index 2bec9afec..de6b3cafe 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Editable view implementation * * Authors: @@ -21,33 +21,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/** \class SPDesktop - * SPDesktop is a subclass of View, implementing an editable document - * canvas. It is extensively used by many UI controls that need certain - * visual representations of their own. - * - * SPDesktop provides a certain set of SPCanvasItems, serving as GUI - * layers of different control objects. The one containing the whole - * document is the drawing layer. In addition to it, there are grid, - * guide, sketch and control layers. The sketch layer is used for - * temporary drawing objects, before the real objects in document are - * created. The control layer contains editing knots, rubberband and - * similar non-document UI objects. - * - * Each SPDesktop is associated with a SPNamedView node of the document - * tree. Currently, all desktops are created from a single main named - * view, but in the future there may be support for different ones. - * SPNamedView serves as an in-document container for desktop-related - * data, like grid and guideline placement, snapping options and so on. - * - * Associated with each SPDesktop are the two most important editing - * related objects - SPSelection and SPEventContext. - * - * Sodipodi keeps track of the active desktop and invokes notification - * signals whenever it changes. UI elements can use these to update their - * display to the selection of the currently active editing window. - * (Lauris Kaplinski) - */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -116,11 +89,6 @@ static void _reconstruction_start(SPDesktop * desktop); static void _reconstruction_finish(SPDesktop * desktop); static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop); -/** - * Return new desktop object. - * \pre namedview != NULL. - * \pre canvas != NULL. - */ SPDesktop::SPDesktop() : _dlg_mgr( 0 ), namedview( 0 ), diff --git a/src/desktop.h b/src/desktop.h index 25e4387dc..8921f45b8 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -82,7 +82,31 @@ namespace Inkscape { } /** - * Editable view. + * SPDesktop is a subclass of View, implementing an editable document + * canvas. It is extensively used by many UI controls that need certain + * visual representations of their own. + * + * SPDesktop provides a certain set of SPCanvasItems, serving as GUI + * layers of different control objects. The one containing the whole + * document is the drawing layer. In addition to it, there are grid, + * guide, sketch and control layers. The sketch layer is used for + * temporary drawing objects, before the real objects in document are + * created. The control layer contains editing knots, rubberband and + * similar non-document UI objects. + * + * Each SPDesktop is associated with a SPNamedView node of the document + * tree. Currently, all desktops are created from a single main named + * view, but in the future there may be support for different ones. + * SPNamedView serves as an in-document container for desktop-related + * data, like grid and guideline placement, snapping options and so on. + * + * Associated with each SPDesktop are the two most important editing + * related objects - SPSelection and SPEventContext. + * + * Sodipodi keeps track of the active desktop and invokes notification + * signals whenever it changes. UI elements can use these to update their + * display to the selection of the currently active editing window. + * (Lauris Kaplinski) * * @see \ref desktop-handles.h for desktop macros. */ @@ -185,7 +209,13 @@ public: Inkscape::Whiteboard::SessionManager* _whiteboard_session_manager; #endif + /** + * Return new desktop object. + * \pre namedview != NULL. + * \pre canvas != NULL. + */ SPDesktop(); + void init (SPNamedView* nv, SPCanvas* canvas, Inkscape::UI::View::EditWidgetInterface *widget); virtual ~SPDesktop(); void destroy(); diff --git a/src/display/canvas-temporary-item-list.cpp b/src/display/canvas-temporary-item-list.cpp index c324a5ddf..b0fec98b5 100644 --- a/src/display/canvas-temporary-item-list.cpp +++ b/src/display/canvas-temporary-item-list.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Provides a class that can contain active TemporaryItem's on a desktop * Code inspired by message-stack.cpp * diff --git a/src/display/canvas-temporary-item.cpp b/src/display/canvas-temporary-item.cpp index 8d336f0ff..abe5f2f1b 100644 --- a/src/display/canvas-temporary-item.cpp +++ b/src/display/canvas-temporary-item.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Provides a class that can contain active TemporaryItem's on a desktop * When the object is deleted, it also deletes the canvasitem it contains! * This object should be created/managed by a TemporaryItemList. diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index e542d0c88..9b61d4a4d 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap * * Authors: diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 9e942ec35..8aa3b2a6d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Port of GnomeCanvas for Inkscape needs * * Authors: diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 1559dc5ba..61c78fe8a 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Undo/Redo stack implementation * * Authors: diff --git a/src/document.cpp b/src/document.cpp index d45041296..6035ea557 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1,4 +1,4 @@ -/** \file +/* * SPDocument manipulation * * Authors: diff --git a/src/dom/cssreader.cpp b/src/dom/cssreader.cpp index 4e329d914..db114ed8d 100644 --- a/src/dom/cssreader.cpp +++ b/src/dom/cssreader.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index e12f40714..53118b1d9 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/domptr.cpp b/src/dom/domptr.cpp index 107f05b08..73999e100 100644 --- a/src/dom/domptr.cpp +++ b/src/dom/domptr.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/domstring.cpp b/src/dom/domstring.cpp index e562f079f..32e3c078f 100644 --- a/src/dom/domstring.cpp +++ b/src/dom/domstring.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/io/base64stream.cpp b/src/dom/io/base64stream.cpp index 509c67d6d..433675e18 100644 --- a/src/dom/io/base64stream.cpp +++ b/src/dom/io/base64stream.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * Base64-enabled input and output streams diff --git a/src/dom/io/bufferstream.cpp b/src/dom/io/bufferstream.cpp index 6c3956a60..7baab4814 100644 --- a/src/dom/io/bufferstream.cpp +++ b/src/dom/io/bufferstream.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/io/domstream.cpp b/src/dom/io/domstream.cpp index b38dd5329..de221f855 100644 --- a/src/dom/io/domstream.cpp +++ b/src/dom/io/domstream.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/io/gzipstream.cpp b/src/dom/io/gzipstream.cpp index 9dffceea2..e1f9f9a60 100644 --- a/src/dom/io/gzipstream.cpp +++ b/src/dom/io/gzipstream.cpp @@ -1,4 +1,4 @@ -/** +/* * Zlib-enabled input and output streams * * This is a thin wrapper of libz calls, in order diff --git a/src/dom/io/stringstream.cpp b/src/dom/io/stringstream.cpp index f2745a107..c6e47045e 100644 --- a/src/dom/io/stringstream.cpp +++ b/src/dom/io/stringstream.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/io/uristream.cpp b/src/dom/io/uristream.cpp index 306f7bdf6..09b0ac361 100644 --- a/src/dom/io/uristream.cpp +++ b/src/dom/io/uristream.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp index 6ee6d0883..94b0adeb7 100644 --- a/src/dom/lsimpl.cpp +++ b/src/dom/lsimpl.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/odf/odfdocument.cpp b/src/dom/odf/odfdocument.cpp index c3bb5d97d..50af90f6c 100644 --- a/src/dom/odf/odfdocument.cpp +++ b/src/dom/odf/odfdocument.cpp @@ -1,4 +1,4 @@ -/** +/* * * This class contains an ODF Document. * Initially, we are just concerned with .odg content.xml + resources diff --git a/src/dom/prop-css.cpp b/src/dom/prop-css.cpp index 5ef25ce49..a0d66d939 100644 --- a/src/dom/prop-css.cpp +++ b/src/dom/prop-css.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/prop-css2.cpp b/src/dom/prop-css2.cpp index b02bb0ce3..33548fbb9 100644 --- a/src/dom/prop-css2.cpp +++ b/src/dom/prop-css2.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/prop-svg.cpp b/src/dom/prop-svg.cpp index a38f23c23..bcb8dffea 100644 --- a/src/dom/prop-svg.cpp +++ b/src/dom/prop-svg.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/smilimpl.cpp b/src/dom/smilimpl.cpp index 82bbe9d0e..94726ee61 100644 --- a/src/dom/smilimpl.cpp +++ b/src/dom/smilimpl.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp index b6fbb89e5..cf28dfec5 100644 --- a/src/dom/svgimpl.cpp +++ b/src/dom/svgimpl.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/svgreader.cpp b/src/dom/svgreader.cpp index 4584ba32f..932fcec58 100644 --- a/src/dom/svgreader.cpp +++ b/src/dom/svgreader.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/uri.cpp b/src/dom/uri.cpp index 6a34f1838..d559dffeb 100644 --- a/src/dom/uri.cpp +++ b/src/dom/uri.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/util/digest.cpp b/src/dom/util/digest.cpp index f416f5522..2baed4860 100644 --- a/src/dom/util/digest.cpp +++ b/src/dom/util/digest.cpp @@ -1,4 +1,4 @@ -/** +/* * Secure Hashing Tool * * * Authors: diff --git a/src/dom/util/thread.cpp b/src/dom/util/thread.cpp index 3bb614b45..e8c06c850 100644 --- a/src/dom/util/thread.cpp +++ b/src/dom/util/thread.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp index 89e85cc84..0b13f66ba 100644 --- a/src/dom/util/ziptool.cpp +++ b/src/dom/util/ziptool.cpp @@ -1,4 +1,4 @@ -/** +/* * This is intended to be a standalone, reduced capability * implementation of Gzip and Zip functionality. Its * targeted use case is for archiving and retrieving single files diff --git a/src/dom/xmlreader.cpp b/src/dom/xmlreader.cpp index fc4eee51f..501da6193 100644 --- a/src/dom/xmlreader.cpp +++ b/src/dom/xmlreader.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/xmlwriter.cpp b/src/dom/xmlwriter.cpp index 2b056cf9f..a25dbe0b1 100644 --- a/src/dom/xmlwriter.cpp +++ b/src/dom/xmlwriter.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/xpathimpl.cpp b/src/dom/xpathimpl.cpp index b7aa2c1c8..12e1d8cf4 100644 --- a/src/dom/xpathimpl.cpp +++ b/src/dom/xpathimpl.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/xpathparser.cpp b/src/dom/xpathparser.cpp index bbe0fcc40..5fd31c12a 100644 --- a/src/dom/xpathparser.cpp +++ b/src/dom/xpathparser.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp index 921cbf044..79948e55e 100644 --- a/src/dom/xpathtoken.cpp +++ b/src/dom/xpathtoken.cpp @@ -1,4 +1,4 @@ -/** +/* * Phoebe DOM Implementation. * * This is a C++ approximation of the W3C DOM model, which follows diff --git a/src/event-context.cpp b/src/event-context.cpp index a92ab55e2..4f938bde5 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -1,5 +1,4 @@ -/** - * @file +/* * Main event handling, and related helper functions. * * Authors: diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 2c6a1a80b..3e0afdd8e 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1,4 +1,4 @@ -/** +/* * OpenDocument <drawing> input and output * * This is an an entry in the extensions mechanism to begin to enable diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 186f337c4..e083fe1a3 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -1,4 +1,4 @@ - /** \file +/* * Native PDF import using libpoppler. * * Authors: diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index ef31cd39f..db7c09575 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -1,6 +1,5 @@ - - /** \file - * PDF parsing using libpoppler + /* + * PDF parsing using libpoppler. * * Derived from poppler's Gfx.cc * diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index be60493e0..64cb0a152 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1,4 +1,4 @@ - /** \file + /* * Native PDF import using libpoppler. * * Authors: diff --git a/src/extension/script/InkscapeScript.cpp b/src/extension/script/InkscapeScript.cpp index ec9b5a8f9..9f8ebfbbb 100644 --- a/src/extension/script/InkscapeScript.cpp +++ b/src/extension/script/InkscapeScript.cpp @@ -1,4 +1,4 @@ -/** +/* * This is a simple mechanism to bind Inkscape to Java, and thence * to all of the nice things that can be layered upon that. * diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index f772aad96..d6741b642 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -1,5 +1,4 @@ -/** - * @file guide-snapper.cpp +/* * Snapping things to guides. * * Authors: diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 48ba7f2ea..4fafa191e 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -1,5 +1,4 @@ -/** - * @file +/* * SPAction implementation. * * Author: diff --git a/src/helper/geom-nodetype.cpp b/src/helper/geom-nodetype.cpp index f570fc9ae..605eaaa5f 100644 --- a/src/helper/geom-nodetype.cpp +++ b/src/helper/geom-nodetype.cpp @@ -1,6 +1,6 @@ #define INKSCAPE_HELPER_GEOM_NODETYPE_CPP -/** +/* * Specific nodetype geometry functions for Inkscape, not provided my lib2geom. * * Author: diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 61551ad2e..c0e4870d4 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -1,6 +1,6 @@ #define INKSCAPE_HELPER_GEOM_CPP -/** +/* * Specific geometry functions for Inkscape, not provided my lib2geom. * * Author: diff --git a/src/id-clash.cpp b/src/id-clash.cpp index d5740c0ba..e5a40868b 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Routines for resolving ID clashes when importing or pasting. * * Authors: diff --git a/src/io/base64stream.cpp b/src/io/base64stream.cpp index c90f3760b..0b20ef95a 100644 --- a/src/io/base64stream.cpp +++ b/src/io/base64stream.cpp @@ -1,4 +1,4 @@ -/** +/* * Base64-enabled input and output streams * * This class allows easy encoding and decoding diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index 79bcb2087..ed94974fe 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -1,4 +1,4 @@ -/** +/* * Zlib-enabled input and output streams * * This is a thin wrapper of libz calls, in order diff --git a/src/io/inkscapestream.cpp b/src/io/inkscapestream.cpp index c89dd70fc..da7870add 100644 --- a/src/io/inkscapestream.cpp +++ b/src/io/inkscapestream.cpp @@ -1,4 +1,4 @@ -/** +/* * Our base input/output stream classes. These are is directly * inherited from iostreams, and includes any extra * functionality that we might need. diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 8c76c7132..4eeaf3b8c 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Inkscape::IO::Resource - simple resource API * * Copyright 2006 MenTaLguY <mental@rydia.net> diff --git a/src/io/stringstream.cpp b/src/io/stringstream.cpp index 45fb6fe30..44d11dd04 100644 --- a/src/io/stringstream.cpp +++ b/src/io/stringstream.cpp @@ -1,4 +1,4 @@ -/** +/* * Our base String stream classes. We implement these to * be based on Glib::ustring * diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp index b5f884b29..7397d725f 100644 --- a/src/io/uristream.cpp +++ b/src/io/uristream.cpp @@ -1,4 +1,4 @@ -/** +/* * Our base String stream classes. We implement these to * be based on Glib::ustring * diff --git a/src/io/xsltstream.cpp b/src/io/xsltstream.cpp index 6f35d9cb6..6b72627d3 100644 --- a/src/io/xsltstream.cpp +++ b/src/io/xsltstream.cpp @@ -1,4 +1,4 @@ -/** +/* * XSL Transforming input and output classes * * Authors: diff --git a/src/io/xsltstream.h b/src/io/xsltstream.h index 03621c7fd..cfe9e5124 100644 --- a/src/io/xsltstream.h +++ b/src/io/xsltstream.h @@ -2,7 +2,7 @@ #define SEEN_INKSCAPE_IO_XSLTSTREAM_H /** * @file - * Xslt-enabled input and output streams + * Xslt-enabled input and output streams. */ /* * Authors: diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 835ce7550..c556195d6 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -1,4 +1,4 @@ -/** \file +/* * KnotHolderEntity definition. * * Authors: diff --git a/src/knot.cpp b/src/knot.cpp index 1ffb5269c..4dfccc18a 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -1,4 +1,4 @@ -/** \file +/* * SPKnot implementation * * Authors: @@ -68,9 +68,6 @@ static void sp_knot_set_ctrl_state(SPKnot *knot); static GObjectClass *parent_class; static guint knot_signals[LAST_SIGNAL] = { 0 }; -/** - * Registers SPKnot class and returns its type number. - */ GType sp_knot_get_type() { static GType type = 0; @@ -258,9 +255,6 @@ static void sp_knot_dispose(GObject *object) } } -/** - * Update knot for dragging and tell canvas an item was grabbed. - */ void sp_knot_start_dragging(SPKnot *knot, Geom::Point const &p, gint x, gint y, guint32 etime) { // save drag origin @@ -463,9 +457,6 @@ void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot) gobble_motion_events(GDK_BUTTON1_MASK); } -/** - * Return new knot object. - */ SPKnot *sp_knot_new(SPDesktop *desktop, const gchar *tip) { g_return_val_if_fail(desktop != NULL, NULL); @@ -495,9 +486,6 @@ SPKnot *sp_knot_new(SPDesktop *desktop, const gchar *tip) return knot; } -/** - * Show knot on its canvas. - */ void sp_knot_show(SPKnot *knot) { g_return_if_fail(knot != NULL); @@ -506,9 +494,6 @@ void sp_knot_show(SPKnot *knot) sp_knot_set_flag(knot, SP_KNOT_VISIBLE, TRUE); } -/** - * Hide knot on its canvas. - */ void sp_knot_hide(SPKnot *knot) { g_return_if_fail(knot != NULL); @@ -517,9 +502,6 @@ void sp_knot_hide(SPKnot *knot) sp_knot_set_flag(knot, SP_KNOT_VISIBLE, FALSE); } -/** - * Request or set new position for knot. - */ void sp_knot_request_position(SPKnot *knot, Geom::Point const &p, guint state) { g_return_if_fail(knot != NULL); @@ -540,9 +522,6 @@ void sp_knot_request_position(SPKnot *knot, Geom::Point const &p, guint state) } } -/** - * Return distance of point to knot's position; unused. - */ gdouble sp_knot_distance(SPKnot * knot, Geom::Point const &p, guint state) { g_return_val_if_fail(knot != NULL, 1e18); @@ -559,9 +538,6 @@ gdouble sp_knot_distance(SPKnot * knot, Geom::Point const &p, guint state) return distance; } -/** - * Move knot to new position. - */ void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state) { g_return_if_fail(knot != NULL); @@ -580,9 +556,6 @@ void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state) knot->_moved_signal.emit(knot, p, state); } -/** - * Move knot to new position, without emitting a MOVED signal. - */ void sp_knot_moveto(SPKnot *knot, Geom::Point const &p) { g_return_if_fail(knot != NULL); @@ -595,9 +568,6 @@ void sp_knot_moveto(SPKnot *knot, Geom::Point const &p) } } -/** - * Returns position of knot. - */ Geom::Point sp_knot_position(SPKnot const *knot) { g_assert(knot != NULL); @@ -606,9 +576,6 @@ Geom::Point sp_knot_position(SPKnot const *knot) return knot->pos; } -/** - * Set flag in knot, with side effects. - */ void sp_knot_set_flag(SPKnot *knot, guint flag, bool set) { g_assert(knot != NULL); @@ -640,9 +607,6 @@ void sp_knot_set_flag(SPKnot *knot, guint flag, bool set) } } -/** - * Update knot's pixbuf and set its control state. - */ void sp_knot_update_ctrl(SPKnot *knot) { if (!knot->item) { diff --git a/src/knot.h b/src/knot.h index ad152b54c..73bb226c6 100644 --- a/src/knot.h +++ b/src/knot.h @@ -149,8 +149,14 @@ struct SPKnotClass { gdouble (* distance) (SPKnot *knot, Geom::Point const &pos, guint state); }; +/** + * Registers SPKnot class and returns its type number. + */ GType sp_knot_get_type(); +/** + * Return new knot object. + */ SPKnot *sp_knot_new(SPDesktop *desktop, gchar const *tip = NULL); #define SP_KNOT_IS_VISIBLE(k) ((k->flags & SP_KNOT_VISIBLE) != 0) @@ -158,24 +164,56 @@ SPKnot *sp_knot_new(SPDesktop *desktop, gchar const *tip = NULL); #define SP_KNOT_IS_DRAGGING(k) ((k->flags & SP_KNOT_DRAGGING) != 0) #define SP_KNOT_IS_GRABBED(k) ((k->flags & SP_KNOT_GRABBED) != 0) +/** + * Show knot on its canvas. + */ void sp_knot_show(SPKnot *knot); + +/** + * Hide knot on its canvas. + */ void sp_knot_hide(SPKnot *knot); +/** + * Set flag in knot, with side effects. + */ void sp_knot_set_flag(SPKnot *knot, guint flag, bool set); + +/** + * Update knot's pixbuf and set its control state. + */ void sp_knot_update_ctrl(SPKnot *knot); +/** + * Request or set new position for knot. + */ void sp_knot_request_position(SPKnot *knot, Geom::Point const &pos, guint state); + +/** + * Return distance of point to knot's position; unused. + */ gdouble sp_knot_distance(SPKnot *knot, Geom::Point const &p, guint state); +/** + * Update knot for dragging and tell canvas an item was grabbed. + */ void sp_knot_start_dragging(SPKnot *knot, Geom::Point const &p, gint x, gint y, guint32 etime); -/** Moves knot and emits "moved" signal. */ +/** + * Move knot to new position and emits "moved" signal. + */ void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state); -/** Moves knot without any signal. */ +/** + * Move knot to new position, without emitting a MOVED signal. + */ void sp_knot_moveto(SPKnot *knot, Geom::Point const &p); void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot); + +/** + * Returns position of knot. + */ Geom::Point sp_knot_position(SPKnot const *knot); diff --git a/src/libvpsc/block.cpp b/src/libvpsc/block.cpp index 0bd662f28..8171780d4 100644 --- a/src/libvpsc/block.cpp +++ b/src/libvpsc/block.cpp @@ -1,8 +1,4 @@ -/** - * \brief A block is a group of variables that must be moved together to improve - * the goal function without violating already active constraints. - * The variables in a block are spanned by a tree of active constraints. - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * @@ -95,13 +91,7 @@ void Block::merge(Block* b, Constraint* c) { f<<" merged block="<<(b->deleted?*this:*b)<<endl; #endif } -/** - * Merges b into this block across c. Can be either a - * right merge or a left merge - * @param b block to merge into this - * @param c constraint being merged - * @param distance separation required to satisfy c - */ + void Block::merge(Block *b, Constraint *c, double dist) { #ifdef RECTANGLE_OVERLAP_LOGGING ofstream f(LOGFILE,ios::app); @@ -317,10 +307,7 @@ void Block::reset_active_lm(Variable* const v, Variable* const u) { } } } -/** - * finds the constraint with the minimum lagrange multiplier, that is, the constraint - * that most wants to split - */ + Constraint *Block::findMinLM() { Constraint *min_lm=NULL; reset_active_lm(vars->front(),NULL); @@ -363,12 +350,7 @@ bool Block::isActiveDirectedPathBetween(Variable* u, Variable *v) { } return false; } -/** - * Block needs to be split because of a violated constraint between vl and vr. - * We need to search the active constraint tree between l and r and find the constraint - * with min lagrangrian multiplier and split at that point. - * Returns the split constraint - */ + Constraint* Block::splitBetween(Variable* const vl, Variable* const vr, Block* &lb, Block* &rb) { #ifdef RECTANGLE_OVERLAP_LOGGING @@ -383,11 +365,7 @@ Constraint* Block::splitBetween(Variable* const vl, Variable* const vr, deleted = true; return c; } -/** - * Creates two new blocks, l and r, and splits this block across constraint c, - * placing the left subtree of constraints (and associated variables) into l - * and the right into r. - */ + void Block::split(Block* &l, Block* &r, Constraint* c) { c->active=false; l=new Block(); @@ -396,10 +374,6 @@ void Block::split(Block* &l, Block* &r, Constraint* c) { populateSplitBlock(r,c->right,c->left); } -/** - * Computes the cost (squared euclidean distance from desired positions) of the - * current positions for variables in this block - */ double Block::cost() { double c = 0; for (Vit v=vars->begin();v!=vars->end();++v) { diff --git a/src/libvpsc/block.h b/src/libvpsc/block.h index a4625b202..9c90fc87e 100644 --- a/src/libvpsc/block.h +++ b/src/libvpsc/block.h @@ -36,22 +36,57 @@ public: double wposn; Block(Variable* const v=NULL); virtual ~Block(void); - Constraint* findMinLM(); + + /** + * finds the constraint with the minimum lagrange multiplier, that is, the constraint + * that most wants to split + */ + Constraint* findMinLM(); + Constraint* findMinLMBetween(Variable* const lv, Variable* const rv); Constraint* findMinInConstraint(); Constraint* findMinOutConstraint(); void deleteMinInConstraint(); void deleteMinOutConstraint(); double desiredWeightedPosition(); - void merge(Block *b, Constraint *c, double dist); + + /** + * Merges b into this block across c. Can be either a + * right merge or a left merge + * @param b block to merge into this + * @param c constraint being merged + * @param distance separation required to satisfy c + */ + void merge(Block *b, Constraint *c, double dist); + void merge(Block *b, Constraint *c); void mergeIn(Block *b); void mergeOut(Block *b); - void split(Block *&l, Block *&r, Constraint *c); - Constraint* splitBetween(Variable* vl, Variable* vr, Block* &lb, Block* &rb); + + /** + * Creates two new blocks, l and r, and splits this block across constraint c, + * placing the left subtree of constraints (and associated variables) into l + * and the right into r. + */ + void split(Block *&l, Block *&r, Constraint *c); + + /** + * Block needs to be split because of a violated constraint between vl and vr. + * We need to search the active constraint tree between l and r and find the constraint + * with min lagrangrian multiplier and split at that point. + * Returns the split constraint + */ + Constraint* splitBetween(Variable* vl, Variable* vr, Block* &lb, Block* &rb); + void setUpInConstraints(); void setUpOutConstraints(); - double cost(); + + /** + * Computes the cost (squared euclidean distance from desired positions) of the + * current positions for variables in this block + */ + double cost(); + bool deleted; long timeStamp; PairingHeap<Constraint*> *in; @@ -75,3 +110,13 @@ private: } #endif // SEEN_REMOVEOVERLAP_BLOCK_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libvpsc/blocks.cpp b/src/libvpsc/blocks.cpp index fe0caacfc..7eff1e6c4 100644 --- a/src/libvpsc/blocks.cpp +++ b/src/libvpsc/blocks.cpp @@ -1,9 +1,5 @@ -/** - * \brief A block structure defined over the variables - * - * A block structure defined over the variables such that each block contains - * 1 or more variables, with the invariant that all constraints inside a block - * are satisfied by keeping the variables fixed relative to one another +/* + * A block structure defined over the variables. * * Authors: * Tim Dwyer <tgdwyer@gmail.com> @@ -47,10 +43,6 @@ Blocks::~Blocks(void) clear(); } -/** - * returns a list of variables with total ordering determined by the constraint - * DAG - */ list<Variable*> *Blocks::totalOrder() { list<Variable*> *order = new list<Variable*>; for(int i=0;i<nvs;i++) { @@ -80,10 +72,7 @@ void Blocks::dfsVisit(Variable *v, list<Variable*> *order) { #endif order->push_front(v); } -/** - * Processes incoming constraints, most violated to least, merging with the - * neighbouring (left) block until no more violated constraints are found - */ + void Blocks::mergeLeft(Block *r) { #ifdef RECTANGLE_OVERLAP_LOGGING ofstream f(LOGFILE,ios::app); @@ -115,9 +104,7 @@ void Blocks::mergeLeft(Block *r) { f<<"merged "<<*r<<endl; #endif } -/** - * Symmetrical to mergeLeft - */ + void Blocks::mergeRight(Block *l) { #ifdef RECTANGLE_OVERLAP_LOGGING ofstream f(LOGFILE,ios::app); @@ -160,10 +147,7 @@ void Blocks::cleanup() { } } } -/** - * Splits block b across constraint c into two new blocks, l and r (c's left - * and right sides respectively) - */ + void Blocks::split(Block *b, Block *&l, Block *&r, Constraint *c) { b->split(l,r,c); #ifdef RECTANGLE_OVERLAP_LOGGING @@ -184,10 +168,7 @@ void Blocks::split(Block *b, Block *&l, Block *&r, Constraint *c) { insert(l); insert(r); } -/** - * returns the cost total squared distance of variables from their desired - * positions - */ + double Blocks::cost() { double c = 0; for(set<Block*>::iterator i=begin();i!=end();++i) { diff --git a/src/libvpsc/blocks.h b/src/libvpsc/blocks.h index e3223822e..b711a529f 100644 --- a/src/libvpsc/blocks.h +++ b/src/libvpsc/blocks.h @@ -33,21 +33,62 @@ class Constraint; class Blocks : public std::set<Block*> { public: - Blocks(const int n, Variable* const vs[]); + Blocks(const int n, Variable* const vs[]); + virtual ~Blocks(void); - void mergeLeft(Block *r); - void mergeRight(Block *l); - void split(Block *b, Block *&l, Block *&r, Constraint *c); - std::list<Variable*> *totalOrder(); - void cleanup(); - double cost(); + + /** + * Processes incoming constraints, most violated to least, merging with the + * neighbouring (left) block until no more violated constraints are found. + */ + void mergeLeft(Block *r); + + /** + * Symmetrical to mergeLeft. + * @see mergeLeft + */ + void mergeRight(Block *l); + + /** + * Splits block b across constraint c into two new blocks, l and r (c's left + * and right sides respectively). + */ + void split(Block *b, Block *&l, Block *&r, Constraint *c); + + /** + * Returns a list of variables with total ordering determined by the constraint + * DAG. + */ + std::list<Variable*> *totalOrder(); + + void cleanup(); + + /** + * Returns the cost total squared distance of variables from their desired + * positions. + */ + double cost(); + private: - void dfsVisit(Variable *v, std::list<Variable*> *order); - void removeBlock(Block *doomed); - Variable* const *vs; - int nvs; + void dfsVisit(Variable *v, std::list<Variable*> *order); + + void removeBlock(Block *doomed); + + Variable* const *vs; + + int nvs; }; extern long blockTimeCtr; } #endif // SEEN_REMOVEOVERLAP_BLOCKS_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libvpsc/csolve_VPSC.cpp b/src/libvpsc/csolve_VPSC.cpp index 5176242d5..24459d09f 100644 --- a/src/libvpsc/csolve_VPSC.cpp +++ b/src/libvpsc/csolve_VPSC.cpp @@ -1,5 +1,5 @@ -/** - * \brief Bridge for C programs to access solve_VPSC (which is in C++) +/* + * Bridge for C programs to access solve_VPSC (which is in C++). * * Authors: * Tim Dwyer <tgdwyer@gmail.com> diff --git a/src/libvpsc/remove_rectangle_overlap.cpp b/src/libvpsc/remove_rectangle_overlap.cpp index 4d2750b9e..381759f3c 100644 --- a/src/libvpsc/remove_rectangle_overlap.cpp +++ b/src/libvpsc/remove_rectangle_overlap.cpp @@ -1,5 +1,5 @@ -/** @file - * @brief remove overlaps between a set of rectangles. +/* + * remove overlaps between a set of rectangles. * * Authors: * Tim Dwyer <tgdwyer@gmail.com> @@ -28,18 +28,7 @@ using namespace vpsc; double Rectangle::xBorder=0; double Rectangle::yBorder=0; -/** - * Takes an array of n rectangles and moves them as little as possible - * such that rectangles are separated by at least xBorder horizontally - * and yBorder vertically - * - * Works in three passes: - * 1) removes some overlap horizontally - * 2) removes remaining overlap vertically - * 3) a last horizontal pass removes all overlap starting from original - * x-positions - this corrects the case where rectangles were moved - * too much in the first pass. - */ + void removeRectangleOverlap(unsigned n, Rectangle *rs[], double xBorder, double yBorder) { try { // The extra gap avoids numerical imprecision problems diff --git a/src/libvpsc/remove_rectangle_overlap.h b/src/libvpsc/remove_rectangle_overlap.h index 1af90a754..3e2f4cc8f 100644 --- a/src/libvpsc/remove_rectangle_overlap.h +++ b/src/libvpsc/remove_rectangle_overlap.h @@ -1,5 +1,5 @@ -/** @file - * @brief Declaration of main internal remove-overlaps function. +/* + * Declaration of main internal remove-overlaps function. */ /* Authors: * Tim Dwyer <tgdwyer@gmail.com> @@ -16,6 +16,18 @@ namespace vpsc { class Rectangle; } +/** + * Takes an array of n rectangles and moves them as little as possible + * such that rectangles are separated by at least xBorder horizontally + * and yBorder vertically + * + * Works in three passes: + * 1) removes some overlap horizontally + * 2) removes remaining overlap vertically + * 3) a last horizontal pass removes all overlap starting from original + * x-positions - this corrects the case where rectangles were moved + * too much in the first pass. + */ void removeRectangleOverlap(unsigned n, vpsc::Rectangle *rs[], double xBorder, double yBorder); diff --git a/src/libvpsc/solve_VPSC.cpp b/src/libvpsc/solve_VPSC.cpp index ec2c48d46..f9bed649c 100644 --- a/src/libvpsc/solve_VPSC.cpp +++ b/src/libvpsc/solve_VPSC.cpp @@ -1,5 +1,5 @@ -/** - * \brief Solve an instance of the "Variable Placement with Separation +/* + * Solve an instance of the "Variable Placement with Separation * Constraints" problem. * * Authors: @@ -59,16 +59,7 @@ void Solver::printBlocks() { } #endif } -/** -* Produces a feasible - though not necessarily optimal - solution by -* examining blocks in the partial order defined by the directed acyclic -* graph of constraints. For each block (when processing left to right) we -* maintain the invariant that all constraints to the left of the block -* (incoming constraints) are satisfied. This is done by repeatedly merging -* blocks into bigger blocks across violated constraints (most violated -* first) fixing the position of variables inside blocks relative to one -* another so that constraints internal to the block are satisfied. -*/ + void Solver::satisfy() { list<Variable*> *vs=bs->totalOrder(); for(list<Variable*>::iterator i=vs->begin();i!=vs->end();++i) { @@ -129,12 +120,7 @@ void Solver::refine() { } } } -/** - * Calculate the optimal solution. After using satisfy() to produce a - * feasible solution, refine() examines each block to see if further - * refinement is possible by splitting the block. This is done repeatedly - * until no further improvement is possible. - */ + void Solver::solve() { satisfy(); refine(); @@ -156,19 +142,7 @@ void IncSolver::solve() { #endif } while(fabs(lastcost-cost)>0.0001); } -/** - * incremental version of satisfy that allows refinement after blocks are - * moved. - * - * - move blocks to new positions - * - repeatedly merge across most violated constraint until no more - * violated constraints exist - * - * Note: there is a special case to handle when the most violated constraint - * is between two variables in the same block. Then, we must split the block - * over an active constraint between the two variables. We choose the - * constraint with the most negative lagrangian multiplier. - */ + void IncSolver::satisfy() { #ifdef RECTANGLE_OVERLAP_LOGGING ofstream f(LOGFILE,ios::app); @@ -270,10 +244,6 @@ void IncSolver::splitBlocks() { bs->cleanup(); } -/** - * Scan constraint list for the most violated constraint, or the first equality - * constraint - */ Constraint* IncSolver::mostViolated(ConstraintList &l) { double minSlack = DBL_MAX; Constraint* v=NULL; diff --git a/src/libvpsc/solve_VPSC.h b/src/libvpsc/solve_VPSC.h index 84f646226..e416ef9c6 100644 --- a/src/libvpsc/solve_VPSC.h +++ b/src/libvpsc/solve_VPSC.h @@ -34,8 +34,26 @@ class Blocks; */ class Solver { public: - virtual void satisfy(); - virtual void solve(); + + /** + * Produces a feasible - though not necessarily optimal - solution by + * examining blocks in the partial order defined by the directed acyclic + * graph of constraints. For each block (when processing left to right) we + * maintain the invariant that all constraints to the left of the block + * (incoming constraints) are satisfied. This is done by repeatedly merging + * blocks into bigger blocks across violated constraints (most violated + * first) fixing the position of variables inside blocks relative to one + * another so that constraints internal to the block are satisfied. + */ + virtual void satisfy(); + + /** + * Calculate the optimal solution. After using satisfy() to produce a + * feasible solution, refine() examines each block to see if further + * refinement is possible by splitting the block. This is done repeatedly + * until no further improvement is possible. + */ + virtual void solve(); Solver(const unsigned n, Variable* const vs[], const unsigned m, Constraint *cs[]); virtual ~Solver(); @@ -56,16 +74,51 @@ private: class IncSolver : public Solver { public: - unsigned splitCnt; - void satisfy(); - void solve(); - void moveBlocks(); - void splitBlocks(); - IncSolver(const unsigned n, Variable* const vs[], const unsigned m, Constraint *cs[]); + unsigned splitCnt; + + /** + * incremental version of satisfy that allows refinement after blocks are + * moved. + * + * - move blocks to new positions + * - repeatedly merge across most violated constraint until no more + * violated constraints exist + * + * Note: there is a special case to handle when the most violated constraint + * is between two variables in the same block. Then, we must split the block + * over an active constraint between the two variables. We choose the + * constraint with the most negative lagrangian multiplier. + */ + void satisfy(); + + void solve(); + + void moveBlocks(); + + void splitBlocks(); + + IncSolver(const unsigned n, Variable* const vs[], const unsigned m, Constraint *cs[]); private: - typedef std::vector<Constraint*> ConstraintList; - ConstraintList inactive; - Constraint* mostViolated(ConstraintList &l); + + typedef std::vector<Constraint*> ConstraintList; + + ConstraintList inactive; + + /** + * Scan constraint list for the most violated constraint, or the first equality + * constraint. + */ + Constraint* mostViolated(ConstraintList &l); }; } #endif // SEEN_REMOVEOVERLAP_SOLVE_VPSC_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libvpsc/variable.cpp b/src/libvpsc/variable.cpp index 19dc0746a..29bf8dc5c 100644 --- a/src/libvpsc/variable.cpp +++ b/src/libvpsc/variable.cpp @@ -1,5 +1,4 @@ -/** - * +/* * Authors: * Tim Dwyer <tgdwyer@gmail.com> * @@ -8,6 +7,7 @@ * Released under GNU LGPL. Read the file 'COPYING' for more information. */ #include "variable.h" + namespace vpsc { std::ostream& operator <<(std::ostream &os, const Variable &v) { os << "(" << v.id << "=" << v.position() << ")"; diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 45b03c38b..6a50e8485 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -1,5 +1,4 @@ -/** - * \file line-snapper.cpp +/* * LineSnapper class. * * Authors: diff --git a/src/main.cpp b/src/main.cpp index 501a3e5d2..63fd4a454 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Inkscape - an ambitious vector drawing program * * Authors: diff --git a/src/object-hierarchy.cpp b/src/object-hierarchy.cpp index e6a1618a7..f2bf177dc 100644 --- a/src/object-hierarchy.cpp +++ b/src/object-hierarchy.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Object hierarchy implementation. * * Authors: @@ -16,10 +16,6 @@ namespace Inkscape { -/** - * Create new object hierarchy. - * \param top The first entry if non-NULL. - */ ObjectHierarchy::ObjectHierarchy(SPObject *top) { if (top) { _addBottom(top); @@ -30,17 +26,11 @@ ObjectHierarchy::~ObjectHierarchy() { _clear(); } -/** - * Remove all entries. - */ void ObjectHierarchy::clear() { _clear(); _changed_signal.emit(NULL, NULL); } -/** - * Trim or expand hierarchy on top such that object becomes top entry. - */ void ObjectHierarchy::setTop(SPObject *object) { g_return_if_fail(object != NULL); @@ -62,10 +52,6 @@ void ObjectHierarchy::setTop(SPObject *object) { _changed_signal.emit(top(), bottom()); } -/** - * Add hierarchy from junior's parent to senior to this - * hierarchy's top. - */ void ObjectHierarchy::_addTop(SPObject *senior, SPObject *junior) { g_assert(junior != NULL); g_assert(senior != NULL); @@ -77,19 +63,12 @@ void ObjectHierarchy::_addTop(SPObject *senior, SPObject *junior) { } while ( object != senior ); } -/** - * Add object to top of hierarchy. - * \pre object!=NULL - */ void ObjectHierarchy::_addTop(SPObject *object) { g_assert(object != NULL); _hierarchy.push_back(_attach(object)); _added_signal.emit(object); } -/** - * Remove all objects above limit from hierarchy. - */ void ObjectHierarchy::_trimAbove(SPObject *limit) { while ( !_hierarchy.empty() && _hierarchy.back().object != limit ) { SPObject *object=_hierarchy.back().object; @@ -102,9 +81,6 @@ void ObjectHierarchy::_trimAbove(SPObject *limit) { } } -/** - * Trim or expand hierarchy at bottom such that object becomes bottom entry. - */ void ObjectHierarchy::setBottom(SPObject *object) { g_return_if_fail(object != NULL); @@ -137,10 +113,6 @@ void ObjectHierarchy::setBottom(SPObject *object) { _changed_signal.emit(top(), bottom()); } -/** - * Remove all objects under given object. - * \param limit If NULL, remove all. - */ void ObjectHierarchy::_trimBelow(SPObject *limit) { while ( !_hierarchy.empty() && _hierarchy.front().object != limit ) { SPObject *object=_hierarchy.front().object; @@ -152,9 +124,6 @@ void ObjectHierarchy::_trimBelow(SPObject *limit) { } } -/** - * Add hierarchy from senior to junior to this hierarchy's bottom. - */ void ObjectHierarchy::_addBottom(SPObject *senior, SPObject *junior) { g_assert(junior != NULL); g_assert(senior != NULL); @@ -165,10 +134,6 @@ void ObjectHierarchy::_addBottom(SPObject *senior, SPObject *junior) { } } -/** - * Add object at bottom of hierarchy. - * \pre object!=NULL - */ void ObjectHierarchy::_addBottom(SPObject *object) { g_assert(object != NULL); _hierarchy.push_front(_attach(object)); diff --git a/src/object-hierarchy.h b/src/object-hierarchy.h index d510e7e69..34a81cf9f 100644 --- a/src/object-hierarchy.h +++ b/src/object-hierarchy.h @@ -36,7 +36,13 @@ namespace Inkscape { */ class ObjectHierarchy { public: + + /** + * Create new object hierarchy. + * @param top The first entry if non-NULL. + */ ObjectHierarchy(SPObject *top=NULL); + ~ObjectHierarchy(); bool contains(SPObject *object); @@ -52,16 +58,27 @@ public: return _changed_signal.connect(slot); } + /** + * Remove all entries. + */ void clear(); SPObject *top() { return !_hierarchy.empty() ? _hierarchy.back().object : NULL; } + + /** + * Trim or expand hierarchy on top such that object becomes top entry. + */ void setTop(SPObject *object); SPObject *bottom() { return !_hierarchy.empty() ? _hierarchy.front().object : NULL; } + + /** + * Trim or expand hierarchy at bottom such that object becomes bottom entry. + */ void setBottom(SPObject *object); private: @@ -74,23 +91,45 @@ private: }; ObjectHierarchy(ObjectHierarchy const &); // no copy + void operator=(ObjectHierarchy const &); // no assign - /// @brief adds objects in range [senior, junior) to the top + /** + * Add hierarchy from junior's parent to senior to this + * hierarchy's top. + */ void _addTop(SPObject *senior, SPObject *junior); - /// @brief adds one object to the top + + /** + * Add object to top of hierarchy. + * \pre object!=NULL. + */ void _addTop(SPObject *object); - /// @brief removes all objects above the limit object + + /** + * Remove all objects above limit from hierarchy. + */ void _trimAbove(SPObject *limit); - /// @brief adds objects in range (senior, junior] to the bottom + /** + * Add hierarchy from senior to junior, in range (senior, junior], to this hierarchy's bottom. + */ void _addBottom(SPObject *senior, SPObject *junior); - /// @brief adds one object to the bottom + + /** + * Add object at bottom of hierarchy. + * \pre object!=NULL + */ void _addBottom(SPObject *object); - /// @brief removes all objects below the limit object + + /** + * Remove all objects under given object. + * @param limit If NULL, remove all. + */ void _trimBelow(SPObject *limit); Record _attach(SPObject *object); + void _detach(Record &record); void _clear() { _trimBelow(NULL); } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index bf8cf166a..e7d9b774d 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -1,5 +1,4 @@ -/** - * \file object-snapper.cpp +/* * Snapping things to objects. * * Authors: @@ -58,9 +57,6 @@ Inkscape::ObjectSnapper::~ObjectSnapper() delete _paths_to_snap_to; } -/** - * \return Snap tolerance (desktop coordinates); depends on current zoom so that it's always the same in screen pixels - */ Geom::Coord Inkscape::ObjectSnapper::getSnapperTolerance() const { SPDesktop const *dt = _snapmanager->getDesktop(); @@ -73,14 +69,6 @@ bool Inkscape::ObjectSnapper::getSnapperAlwaysSnap() const return _snapmanager->snapprefs.getObjectTolerance() == 10000; //TODO: Replace this threshold of 10000 by a constant; see also tolerance-slider.cpp } -/** - * Find all items within snapping range. - * \param parent Pointer to the document's root, or to a clipped path or mask object - * \param it List of items to ignore - * \param bbox_to_snap Bounding box hulling the whole bunch of points, all from the same selection and having the same transformation - * \param clip_or_mask The parent object being passed is either a clip or mask - */ - void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, std::vector<SPItem const *> const *it, bool const &first_point, @@ -354,10 +342,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(IntermSnapResults &isr, } -/** - * Returns index of first NR_END bpath in array. - */ - +/// @todo investigate why Geom::Point p is passed in but ignored. void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, SnapSourceType const source_type, bool const &first_point) const @@ -767,9 +752,6 @@ void Inkscape::ObjectSnapper::constrainedSnap( IntermSnapResults &isr, } } -/** - * \return true if this Snapper will snap at least one kind of point. - */ bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const { return true; diff --git a/src/object-snapper.h b/src/object-snapper.h index 5526040f3..d51cade93 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -32,9 +32,16 @@ public: ObjectSnapper(SnapManager *sm, Geom::Coord const d); ~ObjectSnapper(); + /** + * @return true if this Snapper will snap at least one kind of point. + */ bool ThisSnapperMightSnap() const; + /** + * @return Snap tolerance (desktop coordinates); depends on current zoom so that it's always the same in screen pixels. + */ 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 void freeSnap(IntermSnapResults &isr, @@ -56,6 +63,13 @@ private: std::vector<SnapCandidatePoint> *_points_to_snap_to; std::vector<SnapCandidatePath > *_paths_to_snap_to; + /** + * Find all items within snapping range. + * @param parent Pointer to the document's root, or to a clipped path or mask object. + * @param it List of items to ignore. + * @param bbox_to_snap Bounding box hulling the whole bunch of points, all from the same selection and having the same transformation. + * @param clip_or_mask The parent object being passed is either a clip or mask. + */ void _findCandidates(SPObject* parent, std::vector<SPItem const *> const *it, bool const &first_point, @@ -88,6 +102,9 @@ private: bool isUnselectedNode(Geom::Point const &point, std::vector<Inkscape::SnapCandidatePoint> const *unselected_nodes) const; + /** + * Returns index of first NR_END bpath in array. + */ void _collectPaths(Geom::Point p, Inkscape::SnapSourceType const source_type, bool const &first_point) const; diff --git a/src/registrytool.cpp b/src/registrytool.cpp index af41c3eaf..d2cec0080 100644 --- a/src/registrytool.cpp +++ b/src/registrytool.cpp @@ -1,10 +1,6 @@ -/** +/* * Inkscape Registry Tool * - * This simple tool is intended for allowing Inkscape to append subdirectories - * to its path. This will allow extensions and other files to be accesses - * without explicit user intervention. - * * Authors: * Bob Jamison * @@ -52,9 +48,6 @@ KeyTableEntry keyTable[] = }; -/** - * Set the string value of a key/name registry entry - */ bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg, const Glib::ustring &valueName, const Glib::ustring &value) @@ -108,9 +101,6 @@ bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg, -/** - * Get the full path, directory, and base file name of this running executable - */ bool RegistryTool::getExeInfo(Glib::ustring &fullPath, Glib::ustring &path, Glib::ustring &exeName) @@ -137,10 +127,6 @@ bool RegistryTool::getExeInfo(Glib::ustring &fullPath, -/** - * Append our subdirectories to the Application Path for this - * application - */ bool RegistryTool::setPathInfo() { Glib::ustring fullPath; @@ -181,7 +167,7 @@ bool RegistryTool::setPathInfo() #ifdef TESTREG -/** +/* * Compile this file with * g++ -DTESTREG registrytool.cpp -o registrytool * to run these tests. diff --git a/src/registrytool.h b/src/registrytool.h index 7bb00b8f5..0a8139184 100644 --- a/src/registrytool.h +++ b/src/registrytool.h @@ -41,14 +41,24 @@ public: virtual ~RegistryTool() {} + /** + * Set the string value of a key/name registry entry. + */ bool setStringValue(const Glib::ustring &key, const Glib::ustring &valueName, const Glib::ustring &value); + /** + * Get the full path, directory, and base file name of this running executable. + */ bool getExeInfo(Glib::ustring &fullPath, Glib::ustring &path, Glib::ustring &exeName); + /** + * Append our subdirectories to the Application Path for this + * application. + */ bool setPathInfo(); diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 00f87cf8e..cdf41d400 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -1,5 +1,4 @@ -/** - * \file src/rubberband.cpp +/* * Rubberbanding selector. * * Author: diff --git a/src/selection.cpp b/src/selection.cpp index 5376311b1..ff444fa98 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Per-desktop selection container * * Authors: @@ -414,7 +414,6 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const return bbox; } -/** Extract the position of the center from the first selected object */ // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional<Geom::Point> Selection::center() const { @@ -434,9 +433,6 @@ boost::optional<Geom::Point> Selection::center() const { } } -/** - * Compute the list of points in the selection that are to be considered for snapping from. - */ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { GSList const *items = const_cast<Selection *>(this)->itemList(); @@ -458,6 +454,7 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc return p; } + // TODO: both getSnapPoints and getSnapPointsConvexHull are called, subsequently. Can we do this more efficient? // Why do we need to include the transformation center in one case and not the other? std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const { diff --git a/src/selection.h b/src/selection.h index a151be500..168c70dd4 100644 --- a/src/selection.h +++ b/src/selection.h @@ -260,7 +260,8 @@ public: boost::optional<Geom::Point> center() const; /** - * Gets the selection's snap points. + * Compute the list of points in the selection that are to be considered for snapping from. + * * @return Selection's snap points */ std::vector<Inkscape::SnapCandidatePoint> getSnapPoints(SnapPreferences const *snapprefs) const; diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index b3a95877f..50bb8ef2c 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -1,6 +1,5 @@ -/** - * \file snap-preferences.cpp - * Storing of snapping preferences. +/* + * Storing of snapping preferences. * * Authors: * Diederik van Lierop <mail@diedenrezi.nl> @@ -97,11 +96,6 @@ bool Inkscape::SnapPreferences::getSnapModeAny() const return (_snap_from != 0); } -/** - * Turn on/off snapping of specific point types. - * \param t Point type. - * \param s true to snap to this point type, otherwise false; - */ void Inkscape::SnapPreferences::setSnapFrom(Inkscape::SnapSourceType t, bool s) { if (s) { @@ -111,30 +105,11 @@ void Inkscape::SnapPreferences::setSnapFrom(Inkscape::SnapSourceType t, bool s) } } -/** - * \param t Point type. - * \return true if snapper will snap this type of point, otherwise false. - */ bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const { return (_snap_from & t); } -/** - * Map snap target to array index. - * - * The status of each snap toggle (in the snap toolbar) is stored as a boolean value in an array. This method returns the position - * of relevant boolean in that array, for any given type of snap target. For most snap targets, the enumerated value of that targets - * matches the position in the array (primary snap targets). This however does not hold for snap targets which don't have their own - * toggle button (secondary snap targets). - * - * PS: - * - For snap sources, just pass the corresponding snap target instead (each snap source should have a twin snap target, but not vice versa) - * - All parameters are passed by reference, and will be overwritten - * - * @param target Stores the enumerated snap target, which can be modified to correspond to the array index of this snap target - * @param always_on If true, then this snap target is always active and cannot be toggled - * @param group_on If true, then this snap target is in a snap group that has been enabled (e.g. bbox group, nodes/paths group, or "others" group - */ + void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const { if (target & SNAPTARGET_BBOX_CATEGORY) { diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 8044d0aa7..0db135f5d 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -46,7 +46,17 @@ public: void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;} bool getSnapPostponedGlobally() const {return _snap_postponed_globally;} + /** + * Turn on/off snapping of specific point types. + * @param t Point type. + * @param s true to snap to this point type, otherwise false. + */ void setSnapFrom(Inkscape::SnapSourceType t, bool s); + + /** + * @param t Point type. + * @return true if snapper will snap this type of point, otherwise false. + */ bool getSnapFrom(Inkscape::SnapSourceType t) const; bool getStrictSnapping() const {return _strict_snapping;} @@ -60,7 +70,25 @@ public: void setObjectTolerance(gdouble val) {_object_tolerance = val;} private: + + /** + * Map snap target to array index. + * + * The status of each snap toggle (in the snap toolbar) is stored as a boolean value in an array. This method returns the position + * of relevant boolean in that array, for any given type of snap target. For most snap targets, the enumerated value of that targets + * matches the position in the array (primary snap targets). This however does not hold for snap targets which don't have their own + * toggle button (secondary snap targets). + * + * PS: + * - For snap sources, just pass the corresponding snap target instead (each snap source should have a twin snap target, but not vice versa) + * - All parameters are passed by reference, and will be overwritten + * + * @param target Stores the enumerated snap target, which can be modified to correspond to the array index of this snap target. + * @param always_on If true, then this snap target is always active and cannot be toggled. + * @param group_on If true, then this snap target is in a snap group that has been enabled (e.g. bbox group, nodes/paths group, or "others" group. + */ void _mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const; + int _active_snap_targets[Inkscape::SNAPTARGET_MAX_ENUM_VALUE]; bool _snap_enabled_globally; // Toggles ALL snapping diff --git a/src/snap.cpp b/src/snap.cpp index 56b48d507..5f4872bba 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1,5 +1,4 @@ -/** - * \file snap.cpp +/* * SnapManager class. * * Authors: @@ -37,12 +36,6 @@ #include "util/mathfns.h" using std::vector; -/** - * Construct a SnapManager for a SPNamedView. - * - * \param v `Owning' SPNamedView. - */ - SnapManager::SnapManager(SPNamedView const *v) : guide(this, 0), object(this, 0), @@ -55,18 +48,6 @@ SnapManager::SnapManager(SPNamedView const *v) : { } -/** - * Return a list of snappers. - * - * Inkscape snaps to objects, grids, and guides. For each of these snap targets a - * separate class is used, which has been derived from the base Snapper class. The - * getSnappers() method returns a list of pointers to instances of this class. This - * list contains exactly one instance of the guide snapper and of the object snapper - * class, but any number of grid snappers (because each grid has its own snapper - * instance) - * - * @return List of snappers that we use. - */ SnapManager::SnapperList SnapManager::getSnappers() const { SnapManager::SnapperList s; @@ -79,16 +60,6 @@ SnapManager::SnapperList SnapManager::getSnappers() const return s; } -/** - * Return a list of gridsnappers. - * - * Each grid has its own instance of the snapper class. This way snapping can - * be enabled per grid individually. A list will be returned containing the - * pointers to these instances, but only for grids that are being displayed - * and for which snapping is enabled. - * - * @return List of gridsnappers that we use. - */ SnapManager::SnapperList SnapManager::getGridSnappers() const { SnapperList s; @@ -103,17 +74,6 @@ SnapManager::SnapperList SnapManager::getGridSnappers() const return s; } -/** - * Return true if any snapping might occur, whether its to grids, guides or objects. - * - * Each snapper instance handles its own snapping target, e.g. grids, guides or - * objects. This method iterates through all these snapper instances and returns - * true if any of the snappers might possible snap, considering only the relevant - * snapping preferences. - * - * @return true if one of the snappers will try to snap to something. - */ - bool SnapManager::someSnapperMightSnap() const { if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) { @@ -129,10 +89,6 @@ bool SnapManager::someSnapperMightSnap() const return (i != s.end()); } -/** - * \return true if one of the grids might be snapped to. - */ - bool SnapManager::gridSnapperMightSnap() const { if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) { @@ -148,30 +104,6 @@ bool SnapManager::gridSnapperMightSnap() const return (i != s.end()); } -/** - * Try to snap a point to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, - * i.e. snap in any direction on the two dimensional canvas to the nearest - * snap target. freeSnapReturnByRef() is equal in snapping behavior to - * freeSnap(), but the former returns the snapped point trough the referenced - * parameter p. This parameter p initially contains the position of the snap - * source and will we overwritten by the target position if snapping has occurred. - * This makes snapping transparent to the calling code. If this is not desired - * because either the calling code must know whether snapping has occurred, or - * because the original position should not be touched, then freeSnap() should be - * called instead. - * - * PS: - * 1) SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * 2) Only to be used when a single source point is to be snapped; it assumes - * that source_num = 0, which is inefficient when snapping sets our source points - * - * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * @param source_type Detailed description of the source type, will be used by the snap indicator - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - */ void SnapManager::freeSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Geom::OptRect const &bbox_to_snap) const @@ -188,21 +120,6 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, s.getPointIfSnapped(p); } -/** - * Try to snap a point to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, - * i.e. snap in any direction on the two dimensional canvas to the nearest - * snap target. freeSnap() is equal in snapping behavior to - * freeSnapReturnByRef(). Please read the comments of the latter for more details - * - * PS: SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * - * @param p Source point to be snapped - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics - */ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap) const { @@ -237,24 +154,6 @@ void SnapManager::preSnap(Inkscape::SnapCandidatePoint const &p) } } -/** - * Snap to the closest multiple of a grid pitch. - * - * When pasting, we would like to snap to the grid. Problem is that we don't know which - * nodes were aligned to the grid at the time of copying, so we don't know which nodes - * to snap. If we'd snap an unaligned node to the grid, previously aligned nodes would - * become unaligned. That's undesirable. Instead we will make sure that the offset - * between the source and its pasted copy is a multiple of the grid pitch. If the source - * was aligned, then the copy will therefore also be aligned. - * - * PS: Whether we really find a multiple also depends on the snapping range! Most users - * will have "always snap" enabled though, in which case a multiple will always be found. - * PS2: When multiple grids are present then the result will become ambiguous. There is no - * way to control to which grid this method will snap. - * - * @param t Vector that represents the offset of the pasted copy with respect to the original - * @return Offset vector after snapping to the closest multiple of a grid pitch - */ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point const &origin) { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) @@ -310,35 +209,6 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c return t; } -/** - * Try to snap a point along a constraint line to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, - * i.e. snap in a specific direction on the two dimensional canvas to the nearest - * snap target. - * - * constrainedSnapReturnByRef() is equal in snapping behavior to - * constrainedSnap(), but the former returns the snapped point trough the referenced - * parameter p. This parameter p initially contains the position of the snap - * source and will be overwritten by the target position if snapping has occurred. - * This makes snapping transparent to the calling code. If this is not desired - * because either the calling code must know whether snapping has occurred, or - * because the original position should not be touched, then constrainedSnap() should - * be called instead. If there's nothing to snap to or if snapping has been disabled, - * then this method will still apply the constraint (but without snapping) - * - * PS: - * 1) SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * 2) Only to be used when a single source point is to be snapped; it assumes - * that source_num = 0, which is inefficient when snapping sets our source points - - * - * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred - * @param source_type Detailed description of the source type, will be used by the snap indicator - * @param constraint The direction or line along which snapping must occur - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - */ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Inkscape::Snapper::SnapConstraint const &constraint, @@ -348,23 +218,6 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p, p = s.getPoint(); // If we didn't snap, then we will return the point projected onto the constraint } -/** - * Try to snap a point along a constraint line to grids, guides or objects. - * - * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, - * i.e. snap in a specific direction on the two dimensional canvas to the nearest - * snap target. constrainedSnap is equal in snapping behavior to - * constrainedSnapReturnByRef(). Please read the comments of the latter for more details. - * - * PS: SnapManager::setup() must have been called before calling this method, - * but only once for a set of points - * PS: If there's nothing to snap to or if snapping has been disabled, then this - * method will still apply the constraint (but without snapping) - * - * @param p Source point to be snapped - * @param constraint The direction or line along which snapping must occur - * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation - */ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint const &p, Inkscape::Snapper::SnapConstraint const &constraint, Geom::OptRect const &bbox_to_snap) const @@ -508,18 +361,6 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi return no_snap; } -/** - * Try to snap a point to something at a specific angle. - * - * When drawing a straight line or modifying a gradient, it will snap to specific angle increments - * if CTRL is being pressed. This method will enforce this angular constraint (even if there is nothing - * to snap to) - * - * @param p Source point to be snapped - * @param p_ref Optional original point, relative to which the angle should be calculated. If empty then - * the angle will be calculated relative to the y-axis - * @param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees - */ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, boost::optional<Geom::Point> const &p_ref, Geom::Point const &o, @@ -556,14 +397,6 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida return sp; } -/** - * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). - * - * PS: SnapManager::setup() must have been called before calling this method, - * - * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * @param guide_normal Vector normal to the guide line - */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_normal*/, SPGuideDragType drag_type) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { @@ -586,14 +419,6 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &/*guide_norma s.getPointIfSnapped(p); } -/** - * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). - * - * PS: SnapManager::setup() must have been called before calling this method, - * - * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred - * @param guide_normal Vector normal to the guide line - */ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { @@ -614,32 +439,6 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) s.getPointIfSnapped(p); } -/** - * Method for snapping sets of points while they are being transformed. - * - * Method for snapping sets of points while they are being transformed, when using - * for example the selector tool. This method is for internal use only, and should - * not have to be called directly. Use freeSnapTransalation(), constrainedSnapScale(), - * etc. instead. - * - * This is what is being done in this method: transform each point, find out whether - * a free snap or constrained snap is more appropriate, do the snapping, calculate - * some metrics to quantify the snap "distance", and see if it's better than the - * previous snap. Finally, the best ("nearest") snap from all these points is returned. - * If no snap has occurred and we're asked for a constrained snap then the constraint - * will be applied nevertheless - * - * @param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. - * @param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. - * @param transformation_type Type of transformation to apply to points before trying to snap them. - * @param transformation Description of the transformation; details depend on the type. - * @param origin Origin of the transformation, if applicable. - * @param dim Dimension to which the transformation applies, if applicable. - * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::_snapTransformed( std::vector<Inkscape::SnapCandidatePoint> const &points, Geom::Point const &pointer, @@ -930,14 +729,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( } -/** - * Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Point const &tr) @@ -951,15 +742,6 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector<Inkscape::Snap return result; } -/** - * Apply a translation to a set of points and try to snap along a constraint. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param constraint The direction or line along which snapping must occur. - * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred. - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslate(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -975,15 +757,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslate(std::vector<Inkscap } -/** - * Apply a scaling to a set of points and try to snap freely in 2 degrees-of-freedom. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param s Proposed scaling; the final scaling can only be calculated after snapping has occurred - * @param o Origin of the scaling - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -999,15 +772,6 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector<Inkscape::SnapCand } -/** - * Apply a scaling to a set of points and snap such that the aspect ratio of the selection is preserved. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param s Proposed scaling; the final scaling can only be calculated after snapping has occurred - * @param o Origin of the scaling - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Scale const &s, @@ -1023,17 +787,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector<Inkscape::S return result; } -/** - * Apply a stretch to a set of points and snap such that the direction of the stretch is preserved. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param s Proposed stretch; the final stretch can only be calculated after snapping has occurred - * @param o Origin of the stretching - * @param d Dimension in which to apply proposed stretch. - * @param u true if the stretch should be uniform (i.e. to be applied equally in both dimensions) - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Coord const &s, @@ -1050,17 +803,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector<Inkscape: return result; } -/** - * Apply a skew to a set of points and snap such that the direction of the skew is preserved. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param constraint The direction or line along which snapping must occur. - * @param s Proposed skew; the final skew can only be calculated after snapping has occurred - * @param o Origin of the proposed skew - * @param d Dimension in which to apply proposed skew. - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -1088,15 +830,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector<Inkscape::Sn return result; } -/** - * Apply a rotation to a set of points and snap, without scaling. - * - * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. - * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). - * @param angle Proposed rotation (in radians); the final rotation can only be calculated after snapping has occurred - * @param o Origin of the rotation - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. - */ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Coord const &angle, @@ -1118,16 +851,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector<Inkscape:: } -/** - * Given a set of possible snap targets, find the best target (which is not necessarily - * also the nearest target), and show the snap indicator if requested. - * - * @param p Source point to be snapped - * @param isr A structure holding all snap targets that have been found so far - * @param constrained True if the snap is constrained, e.g. for stretching or for purely horizontal translation. - * @param allowOffScreen If true, then snapping to points which are off the screen is allowed (needed for example when pasting to the grid) - * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics - */ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint const &p, IntermSnapResults const &isr, bool constrained, @@ -1273,7 +996,6 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co return bestSnappedPoint; } -/// Convenience shortcut when there is only one item to ignore void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, SPItem const *item_to_ignore, @@ -1293,21 +1015,6 @@ void SnapManager::setup(SPDesktop const *desktop, _rotation_center_source_items = NULL; } -/** - * Prepare the snap manager for the actual snapping, which includes building a list of snap targets - * to ignore and toggling the snap indicator. - * - * There are two overloaded setup() methods, of which the other one only allows for a single item to be ignored - * whereas this one will take a list of items to ignore - * - * @param desktop Reference to the desktop to which this snap manager is attached - * @param snapindicator If true then a snap indicator will be displayed automatically (when enabled in the preferences) - * @param items_to_ignore These items will not be snapped to, e.g. the items that are currently being dragged. This avoids "self-snapping" - * @param unselected_nodes Stationary nodes of the path that is currently being edited in the node tool and - * that can be snapped too. Nodes not in this list will not be snapped to, to avoid "self-snapping". Of each - * unselected node both the position (Geom::Point) and the type (Inkscape::SnapTargetType) will be stored - * @param guide_to_ignore Guide that is currently being dragged and should not be snapped to - */ void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, std::vector<SPItem const *> &items_to_ignore, @@ -1356,17 +1063,6 @@ SPDocument *SnapManager::getDocument() const return _named_view->document; } -/** - * Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code. - * - * @param p The untransformed position of the point, paired with an identifier of the type of the snap source. - * @param transformation_type Type of transformation to apply. - * @param transformation Mathematical description of the transformation; details depend on the type. - * @param origin Origin of the transformation, if applicable. - * @param dim Dimension to which the transformation applies, if applicable. - * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. - * @return The position of the point after transformation - */ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, Transformation const transformation_type, Geom::Point const &transformation, @@ -1413,12 +1109,6 @@ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, return transformed; } -/** - * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. - * - * @param point_type Category of points to which the source point belongs: node, guide or bounding box - * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. - */ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/snap.h b/src/snap.h index 41cbd0a02..fffbbdf6a 100644 --- a/src/snap.h +++ b/src/snap.h @@ -1,7 +1,6 @@ -/** - * \file snap.h - * \brief Per-desktop object that handles snapping queries - *//* +/* + * Per-desktop object that handles snapping queries. + * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Frank Felfe <innerspace@iname.com> @@ -23,7 +22,7 @@ #include "object-snapper.h" #include "snap-preferences.h" -/* Guides */ +// Guides enum SPGuideDragType { // used both here and in desktop-events.cpp SP_DRAG_TRANSLATE, SP_DRAG_ROTATE, @@ -34,8 +33,9 @@ enum SPGuideDragType { // used both here and in desktop-events.cpp class SPGuide; class SPNamedView; -/// Class to coordinate snapping operations /** + * Class to coordinate snapping operations. + * * The SnapManager class handles most (if not all) of the interfacing of the snapping mechanisms * with the other parts of the code base. It stores the references to the various types of snappers * for grid, guides and objects, and it stores most of the snapping preferences. Besides that @@ -63,7 +63,6 @@ class SPNamedView; * write snapping code directly in your control point's dragged handler as if there was * no timeout. */ - class SnapManager { public: @@ -75,19 +74,56 @@ public: ROTATE }; + /** + * Construct a SnapManager for a SPNamedView. + * + * @param v 'Owning' SPNamedView. + */ SnapManager(SPNamedView const *v); typedef std::list<const Inkscape::Snapper*> SnapperList; + /** + * Return true if any snapping might occur, whether its to grids, guides or objects. + * + * Each snapper instance handles its own snapping target, e.g. grids, guides or + * objects. This method iterates through all these snapper instances and returns + * true if any of the snappers might possible snap, considering only the relevant + * snapping preferences. + * + * @return true if one of the snappers will try to snap to something. + */ bool someSnapperMightSnap() const; + + /** + * @return true if one of the grids might be snapped to. + */ bool gridSnapperMightSnap() const; + /** + * Convenience shortcut when there is only one item to ignore. + */ void setup(SPDesktop const *desktop, bool snapindicator = true, SPItem const *item_to_ignore = NULL, std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes = NULL, SPGuide *guide_to_ignore = NULL); + /** + * Prepare the snap manager for the actual snapping, which includes building a list of snap targets + * to ignore and toggling the snap indicator. + * + * There are two overloaded setup() methods, of which the other one only allows for a single item to be ignored + * whereas this one will take a list of items to ignore + * + * @param desktop Reference to the desktop to which this snap manager is attached. + * @param snapindicator If true then a snap indicator will be displayed automatically (when enabled in the preferences). + * @param items_to_ignore These items will not be snapped to, e.g. the items that are currently being dragged. This avoids "self-snapping". + * @param unselected_nodes Stationary nodes of the path that is currently being edited in the node tool and + * that can be snapped too. Nodes not in this list will not be snapped to, to avoid "self-snapping". Of each + * unselected node both the position (Geom::Point) and the type (Inkscape::SnapTargetType) will be stored. + * @param guide_to_ignore Guide that is currently being dragged and should not be snapped to. + */ void setup(SPDesktop const *desktop, bool snapindicator, std::vector<SPItem const *> &items_to_ignore, @@ -113,6 +149,31 @@ public: // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a // point if snapping has occurred (by overwriting p); otherwise p is untouched + + /** + * Try to snap a point to grids, guides or objects. + * + * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, + * i.e. snap in any direction on the two dimensional canvas to the nearest + * snap target. freeSnapReturnByRef() is equal in snapping behavior to + * freeSnap(), but the former returns the snapped point trough the referenced + * parameter p. This parameter p initially contains the position of the snap + * source and will we overwritten by the target position if snapping has occurred. + * This makes snapping transparent to the calling code. If this is not desired + * because either the calling code must know whether snapping has occurred, or + * because the original position should not be touched, then freeSnap() should be + * called instead. + * + * PS: + * 1) SnapManager::setup() must have been called before calling this method, + * but only once for a set of points + * 2) Only to be used when a single source point is to be snapped; it assumes + * that source_num = 0, which is inefficient when snapping sets our source points + * + * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred. + * @param source_type Detailed description of the source type, will be used by the snap indicator. + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation. + */ void freeSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const; @@ -121,20 +182,100 @@ public: Inkscape::SnapSourceType const source_type, boost::optional<Geom::Point> &starting_point) const; + /** + * Try to snap a point to grids, guides or objects. + * + * Try to snap a point to grids, guides or objects, in two degrees-of-freedom, + * i.e. snap in any direction on the two dimensional canvas to the nearest + * snap target. freeSnap() is equal in snapping behavior to + * freeSnapReturnByRef(). Please read the comments of the latter for more details + * + * PS: SnapManager::setup() must have been called before calling this method, + * but only once for a set of points + * + * @param p Source point to be snapped. + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint freeSnap(Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap = Geom::OptRect() ) const; void preSnap(Inkscape::SnapCandidatePoint const &p); + /** + * Snap to the closest multiple of a grid pitch. + * + * When pasting, we would like to snap to the grid. Problem is that we don't know which + * nodes were aligned to the grid at the time of copying, so we don't know which nodes + * to snap. If we'd snap an unaligned node to the grid, previously aligned nodes would + * become unaligned. That's undesirable. Instead we will make sure that the offset + * between the source and its pasted copy is a multiple of the grid pitch. If the source + * was aligned, then the copy will therefore also be aligned. + * + * PS: Whether we really find a multiple also depends on the snapping range! Most users + * will have "always snap" enabled though, in which case a multiple will always be found. + * PS2: When multiple grids are present then the result will become ambiguous. There is no + * way to control to which grid this method will snap. + * + * @param t Vector that represents the offset of the pasted copy with respect to the original. + * @return Offset vector after snapping to the closest multiple of a grid pitch. + */ Geom::Point multipleOfGridPitch(Geom::Point const &t, Geom::Point const &origin); // constrainedSnapReturnByRef() is preferred over constrainedSnap(), because it only returns a // point, by overwriting p, if snapping has occurred; otherwise p is untouched + + /** + * Try to snap a point along a constraint line to grids, guides or objects. + * + * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, + * i.e. snap in a specific direction on the two dimensional canvas to the nearest + * snap target. + * + * constrainedSnapReturnByRef() is equal in snapping behavior to + * constrainedSnap(), but the former returns the snapped point trough the referenced + * parameter p. This parameter p initially contains the position of the snap + * source and will be overwritten by the target position if snapping has occurred. + * This makes snapping transparent to the calling code. If this is not desired + * because either the calling code must know whether snapping has occurred, or + * because the original position should not be touched, then constrainedSnap() should + * be called instead. If there's nothing to snap to or if snapping has been disabled, + * then this method will still apply the constraint (but without snapping) + * + * PS: + * 1) SnapManager::setup() must have been called before calling this method, + * but only once for a set of points + * 2) Only to be used when a single source point is to be snapped; it assumes + * that source_num = 0, which is inefficient when snapping sets our source points + + * + * @param p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred. + * @param source_type Detailed description of the source type, will be used by the snap indicator. + * @param constraint The direction or line along which snapping must occur. + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation. + */ void constrainedSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Inkscape::Snapper::SnapConstraint const &constraint, Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const; + /** + * Try to snap a point along a constraint line to grids, guides or objects. + * + * Try to snap a point to grids, guides or objects, in only one degree-of-freedom, + * i.e. snap in a specific direction on the two dimensional canvas to the nearest + * snap target. constrainedSnap is equal in snapping behavior to + * constrainedSnapReturnByRef(). Please read the comments of the latter for more details. + * + * PS: SnapManager::setup() must have been called before calling this method, + * but only once for a set of points + * PS: If there's nothing to snap to or if snapping has been disabled, then this + * method will still apply the constraint (but without snapping) + * + * @param p Source point to be snapped. + * @param constraint The direction or line along which snapping must occur. + * @param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation. + */ Inkscape::SnappedPoint constrainedSnap(Inkscape::SnapCandidatePoint const &p, Inkscape::Snapper::SnapConstraint const &constraint, Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const; @@ -144,33 +285,109 @@ public: bool dont_snap = false, Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const; + /** + * Try to snap a point to something at a specific angle. + * + * When drawing a straight line or modifying a gradient, it will snap to specific angle increments + * if CTRL is being pressed. This method will enforce this angular constraint (even if there is nothing + * to snap to) + * + * @param p Source point to be snapped. + * @param p_ref Optional original point, relative to which the angle should be calculated. If empty then + * the angle will be calculated relative to the y-axis. + * @param snaps Number of angular increments per PI radians; E.g. if snaps = 2 then we will snap every PI/2 = 90 degrees. + */ Inkscape::SnappedPoint constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, boost::optional<Geom::Point> const &p_ref, Geom::Point const &o, unsigned const snaps) const; + /** + * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). + * + * PS: SnapManager::setup() must have been called before calling this method, + * + * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred. + * @param guide_normal Vector normal to the guide line. + */ void guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const; + + /** + * Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code). + * + * PS: SnapManager::setup() must have been called before calling this method, + * + * @param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred. + * @param guide_normal Vector normal to the guide line. + */ void guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const; + + /** + * Apply a translation to a set of points and try to snap freely in 2 degrees-of-freedom. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint freeSnapTranslate(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Point const &tr); + /** + * Apply a translation to a set of points and try to snap along a constraint. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param constraint The direction or line along which snapping must occur. + * @param tr Proposed translation; the final translation can only be calculated after snapping has occurred. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint constrainedSnapTranslate(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, Geom::Point const &tr); + /** + * Apply a scaling to a set of points and try to snap freely in 2 degrees-of-freedom. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param s Proposed scaling; the final scaling can only be calculated after snapping has occurred. + * @param o Origin of the scaling. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint freeSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Scale const &s, Geom::Point const &o); + /** + * Apply a scaling to a set of points and snap such that the aspect ratio of the selection is preserved. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param s Proposed scaling; the final scaling can only be calculated after snapping has occurred. + * @param o Origin of the scaling. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint constrainedSnapScale(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Scale const &s, Geom::Point const &o); + /** + * Apply a stretch to a set of points and snap such that the direction of the stretch is preserved. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param s Proposed stretch; the final stretch can only be calculated after snapping has occurred. + * @param o Origin of the stretching. + * @param d Dimension in which to apply proposed stretch. + * @param u true if the stretch should be uniform (i.e. to be applied equally in both dimensions). + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint constrainedSnapStretch(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Coord const &s, @@ -178,6 +395,17 @@ public: Geom::Dim2 d, bool uniform); + /** + * Apply a skew to a set of points and snap such that the direction of the skew is preserved. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param constraint The direction or line along which snapping must occur. + * @param s Proposed skew; the final skew can only be calculated after snapping has occurred. + * @param o Origin of the proposed skew. + * @param d Dimension in which to apply proposed skew. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint constrainedSnapSkew(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Inkscape::Snapper::SnapConstraint const &constraint, @@ -185,6 +413,15 @@ public: Geom::Point const &o, Geom::Dim2 d); + /** + * Apply a rotation to a set of points and snap, without scaling. + * + * @param p Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param angle Proposed rotation (in radians); the final rotation can only be calculated after snapping has occurred. + * @param o Origin of the rotation. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint constrainedSnapRotate(std::vector<Inkscape::SnapCandidatePoint> const &p, Geom::Point const &pointer, Geom::Coord const &angle, @@ -194,7 +431,30 @@ public: Inkscape::ObjectSnapper object; ///< snapper to other objects Inkscape::SnapPreferences snapprefs; + /** + * Return a list of snappers. + * + * Inkscape snaps to objects, grids, and guides. For each of these snap targets a + * separate class is used, which has been derived from the base Snapper class. The + * getSnappers() method returns a list of pointers to instances of this class. This + * list contains exactly one instance of the guide snapper and of the object snapper + * class, but any number of grid snappers (because each grid has its own snapper + * instance) + * + * @return List of snappers that we use. + */ SnapperList getSnappers() const; + + /** + * Return a list of gridsnappers. + * + * Each grid has its own instance of the snapper class. This way snapping can + * be enabled per grid individually. A list will be returned containing the + * pointers to these instances, but only for grids that are being displayed + * and for which snapping is enabled. + * + * @return List of gridsnappers that we use. + */ SnapperList getGridSnappers() const; SPDesktop const *getDesktop() const {return _desktop;} @@ -204,7 +464,18 @@ public: bool getSnapIndicator() const {return _snapindicator;} + /** + * Given a set of possible snap targets, find the best target (which is not necessarily + * also the nearest target), and show the snap indicator if requested. + * + * @param p Source point to be snapped. + * @param isr A structure holding all snap targets that have been found so far. + * @param constrained True if the snap is constrained, e.g. for stretching or for purely horizontal translation. + * @param allowOffScreen If true, then snapping to points which are off the screen is allowed (needed for example when pasting to the grid). + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, IntermSnapResults const &isr, bool constrained, bool allowOffScreen = false) const; + void keepClosestPointOnly(std::vector<Inkscape::SnapCandidatePoint> &points, const Geom::Point &reference) const; protected: @@ -218,6 +489,32 @@ private: bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to std::vector<Inkscape::SnapCandidatePoint> *_unselected_nodes; ///< Nodes of the path that is currently being edited and which have not been selected and which will therefore be stationary. Only these nodes will be considered for snapping to. Of each unselected node both the position (Geom::Point) and the type (Inkscape::SnapTargetType) will be stored + /** + * Method for snapping sets of points while they are being transformed. + * + * Method for snapping sets of points while they are being transformed, when using + * for example the selector tool. This method is for internal use only, and should + * not have to be called directly. Use freeSnapTransalation(), constrainedSnapScale(), + * etc. instead. + * + * This is what is being done in this method: transform each point, find out whether + * a free snap or constrained snap is more appropriate, do the snapping, calculate + * some metrics to quantify the snap "distance", and see if it's better than the + * previous snap. Finally, the best ("nearest") snap from all these points is returned. + * If no snap has occurred and we're asked for a constrained snap then the constraint + * will be applied nevertheless + * + * @param points Collection of points to snap (snap sources), at their untransformed position, all points undergoing the same transformation. Paired with an identifier of the type of the snap source. + * @param pointer Location of the mouse pointer at the time dragging started (i.e. when the selection was still untransformed). + * @param constrained true if the snap is constrained, e.g. for stretching or for purely horizontal translation. + * @param constraint The direction or line along which snapping must occur, if 'constrained' is true; otherwise undefined. + * @param transformation_type Type of transformation to apply to points before trying to snap them. + * @param transformation Description of the transformation; details depend on the type. + * @param origin Origin of the transformation, if applicable. + * @param dim Dimension to which the transformation applies, if applicable. + * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. + * @return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics. + */ Inkscape::SnappedPoint _snapTransformed(std::vector<Inkscape::SnapCandidatePoint> const &points, Geom::Point const &pointer, bool constrained, @@ -228,6 +525,17 @@ private: Geom::Dim2 dim, bool uniform); + /** + * Takes an untransformed point, applies the given transformation, and returns the transformed point. Eliminates lots of duplicated code. + * + * @param p The untransformed position of the point, paired with an identifier of the type of the snap source. + * @param transformation_type Type of transformation to apply. + * @param transformation Mathematical description of the transformation; details depend on the type. + * @param origin Origin of the transformation, if applicable. + * @param dim Dimension to which the transformation applies, if applicable. + * @param uniform true if the transformation should be uniform; only applicable for stretching and scaling. + * @return The position of the point after transformation. + */ Geom::Point _transformPoint(Inkscape::SnapCandidatePoint const &p, Transformation const transformation_type, Geom::Point const &transformation, @@ -235,10 +543,16 @@ private: Geom::Dim2 const dim, bool const uniform) const; + /** + * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. + * + * @param point_type Category of points to which the source point belongs: node, guide or bounding box. + * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. + */ void _displaySnapsource(Inkscape::SnapCandidatePoint const &p) const; }; -#endif /* !SEEN_SNAP_H */ +#endif // !SEEN_SNAP_H /* Local Variables: diff --git a/src/sp-object.cpp b/src/sp-object.cpp index c12b9344b..d746e278d 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1,4 +1,4 @@ -/** \file +/* * SPObject implementation. * * Authors: @@ -14,25 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/** \class SPObject - * - * SPObject is an abstract base class of all of the document nodes at the - * SVG document level. Each SPObject subclass implements a certain SVG - * element node type, or is an abstract base class for different node - * types. The SPObject layer is bound to the SPRepr layer, closely - * following the SPRepr mutations via callbacks. During creation, - * SPObject parses and interprets all textual attributes and CSS style - * strings of the SPRepr, and later updates the internal state whenever - * it receives a signal about a change. The opposite is not true - there - * are methods manipulating SPObjects directly and such changes do not - * propagate to the SPRepr layer. This is important for implementation of - * the undo stack, animations and other features. - * - * SPObjects are bound to the higher-level container SPDocument, which - * provides document level functionality such as the undo stack, - * dictionary and so on. Source: doc/architecture.txt - */ - #include <cstring> #include <string> @@ -75,7 +56,7 @@ using std::strstr; g_print("\n"); \ } #else -# define debug(f, a...) /**/ +# define debug(f, a...) /* */ #endif guint update_in_progress = 0; // guard against update-during-update @@ -121,9 +102,6 @@ public: GObjectClass * SPObjectClass::static_parent_class = 0; -/** - * Registers the SPObject class with Gdk and returns its type number. - */ GType SPObject::sp_object_get_type() { static GType type = 0; @@ -143,9 +121,6 @@ GType SPObject::sp_object_get_type() return type; } -/** - * Initializes the SPObject vtable. - */ void SPObjectClass::sp_object_class_init(SPObjectClass *klass) { GObjectClass *object_class; @@ -168,9 +143,6 @@ void SPObjectClass::sp_object_class_init(SPObjectClass *klass) klass->write = SPObject::sp_object_private_write; } -/** - * Callback to initialize the SPObject object. - */ void SPObject::sp_object_init(SPObject *object) { debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); @@ -204,9 +176,6 @@ void SPObject::sp_object_init(SPObject *object) object->_default_label = NULL; } -/** - * Callback to destroy all members and connections of object and itself. - */ void SPObject::sp_object_finalize(GObject *object) { SPObject *spobject = (SPObject *)object; @@ -278,13 +247,6 @@ Inkscape::XML::Node const* SPObject::getRepr() const{ } -/** - * Increase reference count of object, with possible debugging. - * - * \param owner If non-NULL, make debug log entry. - * \return object, NULL is error. - * \pre object points to real object - */ SPObject *sp_object_ref(SPObject *object, SPObject *owner) { g_return_val_if_fail(object != NULL, NULL); @@ -296,14 +258,6 @@ SPObject *sp_object_ref(SPObject *object, SPObject *owner) return object; } -/** - * Decrease reference count of object, with possible debugging and - * finalization. - * - * \param owner If non-NULL, make debug log entry. - * \return always NULL - * \pre object points to real object - */ SPObject *sp_object_unref(SPObject *object, SPObject *owner) { g_return_val_if_fail(object != NULL, NULL); @@ -315,16 +269,6 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner) return NULL; } -/** - * Increase weak refcount. - * - * Hrefcount is used for weak references, for example, to - * determine whether any graphical element references a certain gradient - * node. - * \param owner Ignored. - * \return object, NULL is error - * \pre object points to real object - */ SPObject *sp_object_href(SPObject *object, gpointer /*owner*/) { g_return_val_if_fail(object != NULL, NULL); @@ -336,15 +280,6 @@ SPObject *sp_object_href(SPObject *object, gpointer /*owner*/) return object; } -/** - * Decrease weak refcount. - * - * Hrefcount is used for weak references, for example, to determine whether - * any graphical element references a certain gradient node. - * \param owner Ignored. - * \return always NULL - * \pre object points to real object and hrefcount>0 - */ SPObject *sp_object_hunref(SPObject *object, gpointer /*owner*/) { g_return_val_if_fail(object != NULL, NULL); @@ -357,9 +292,6 @@ SPObject *sp_object_hunref(SPObject *object, gpointer /*owner*/) return NULL; } -/** - * Adds increment to _total_hrefcount of object and its parents. - */ void SPObject::_updateTotalHRefCount(int increment) { SPObject *topmost_collectable = NULL; for ( SPObject *iter = this ; iter ; iter = iter->parent ) { @@ -378,9 +310,6 @@ void SPObject::_updateTotalHRefCount(int increment) { } } -/** - * True if object is non-NULL and this is some in/direct parent of object. - */ bool SPObject::isAncestorOf(SPObject const *object) const { g_return_val_if_fail(object != NULL, false); object = object->parent; @@ -401,9 +330,6 @@ bool same_objects(SPObject const &a, SPObject const &b) { } -/** - * Returns youngest object being parent to this and object. - */ SPObject const *SPObject::nearestCommonAncestor(SPObject const *object) const { g_return_val_if_fail(object != NULL, NULL); @@ -423,15 +349,6 @@ SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) { return result; } -/** - * Compares height of objects in tree. - * - * Works for different-parent objects, so long as they have a common ancestor. - * \return \verbatim - * 0 positions are equivalent - * 1 first object's position is greater than the second - * -1 first object's position is less than the second \endverbatim - */ int sp_object_compare_position(SPObject const *first, SPObject const *second) { int result = 0; @@ -458,10 +375,6 @@ int sp_object_compare_position(SPObject const *first, SPObject const *second) } -/** - * Append repr as child of this object. - * \pre this is not a cloned object - */ SPObject *SPObject::appendChildRepr(Inkscape::XML::Node *repr) { if ( !cloned ) { getRepr()->appendChild(repr); @@ -497,14 +410,10 @@ GSList *SPObject::childList(bool add_ref, Action) { } -/** Gets the label property for the object or a default if no label - * is defined. - */ gchar const *SPObject::label() const { return _label; } -/** Returns a default label property for the object. */ gchar const *SPObject::defaultLabel() const { if (_label) { return _label; @@ -520,13 +429,12 @@ gchar const *SPObject::defaultLabel() const { } } -/** Sets the label property for the object */ -void SPObject::setLabel(gchar const *label) { +void SPObject::setLabel(gchar const *label) +{ getRepr()->setAttribute("inkscape:label", label, false); } -/** Queues the object for orphan collection */ void SPObject::requestOrphanCollection() { g_return_if_fail(document != NULL); @@ -563,13 +471,6 @@ void SPObject::_sendDeleteSignalRecursive() { } } -/** - * Deletes the object reference, unparenting it from its parent. - * - * If the \a propagate parameter is set to true, it emits a delete - * signal. If the \a propagate_descendants parameter is true, it - * recursively sends the delete signal to children. - */ void SPObject::deleteObject(bool propagate, bool propagate_descendants) { sp_object_ref(this, NULL); @@ -591,10 +492,6 @@ void SPObject::deleteObject(bool propagate, bool propagate_descendants) sp_object_unref(this, NULL); } -/** - * Put object into object tree, under parent, and behind prev; - * also update object's XML space. - */ void SPObject::attach(SPObject *object, SPObject *prev) { //g_return_if_fail(parent != NULL); @@ -625,10 +522,8 @@ void SPObject::attach(SPObject *object, SPObject *prev) object->xml_space.value = this->xml_space.value; } -/** - * In list of object's siblings, move object behind prev. - */ -void SPObject::reorder(SPObject *prev) { +void SPObject::reorder(SPObject *prev) +{ //g_return_if_fail(object != NULL); //g_return_if_fail(SP_IS_OBJECT(object)); g_return_if_fail(this->parent != NULL); @@ -667,10 +562,8 @@ void SPObject::reorder(SPObject *prev) { } } -/** - * Remove object from parent's children, release and unref it. - */ -void SPObject::detach(SPObject *object) { +void SPObject::detach(SPObject *object) +{ //g_return_if_fail(parent != NULL); //g_return_if_fail(SP_IS_OBJECT(parent)); g_return_if_fail(object != NULL); @@ -703,9 +596,6 @@ void SPObject::detach(SPObject *object) { sp_object_unref(object, this); } -/** - * Return object's child whose node pointer equals repr. - */ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) { g_return_val_if_fail(repr != NULL, NULL); @@ -724,10 +614,6 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) return result; } -/** - * Callback for child_added event. - * Invoked whenever the given mutation event happens in the XML tree. - */ void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { GType type = sp_repr_type_lookup(child); @@ -742,17 +628,6 @@ void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *chil ochild->invoke_build(object->document, child, object->cloned); } -/** - * Removes, releases and unrefs all children of object. - * - * This is the opposite of build. It has to be invoked as soon as the - * object is removed from the tree, even if it is still alive according - * to reference count. The frontend unregisters the object from the - * document and releases the SPRepr bindings; implementations should free - * state data and release all child objects. Invoking release on - * SPRoot destroys the whole document tree. - * \see sp_object_build() - */ void SPObject::sp_object_release(SPObject *object) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); @@ -761,14 +636,6 @@ void SPObject::sp_object_release(SPObject *object) } } -/** - * Remove object's child whose node equals repr, release and - * unref it. - * - * Invoked whenever the given mutation event happens in the XML - * tree, BEFORE removal from the XML tree happens, so grouping - * objects can safely release the child data. - */ void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); @@ -779,12 +646,6 @@ void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *chi } } -/** - * Move object corresponding to child after sibling object corresponding - * to new_ref. - * Invoked whenever the given mutation event happens in the XML tree. - * \param old_ref Ignored - */ void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/, Inkscape::XML::Node *new_ref) { @@ -795,17 +656,6 @@ void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *ch ochild->_position_changed_signal.emit(ochild); } -/** - * Virtual build callback. - * - * This has to be invoked immediately after creation of an SPObject. The - * frontend method ensures that the new object is properly attached to - * the document and repr; implementation then will parse all of the attributes, - * generate the children objects and so on. Invoking build on the SPRoot - * object results in creation of the whole document tree (this is, what - * SPDocument does after the creation of the XML tree). - * \see sp_object_release() - */ void SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Nothing specific here */ @@ -967,9 +817,6 @@ SPObject *SPObject::getPrev() return prev; } -/** - * Callback for child_added node event. - */ void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -979,9 +826,6 @@ void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscap } } -/** - * Callback for remove_child node event. - */ void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -991,11 +835,6 @@ void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inksc } } -/** - * Callback for order_changed node event. - * - * \todo fixme: - */ void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -1005,9 +844,6 @@ void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inksc } } -/** - * Callback for set event. - */ void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) { g_assert(key != SP_ATTR_INVALID); @@ -1093,9 +929,6 @@ void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar c } } -/** - * Call virtual set() function of object. - */ void SPObject::setKeyValue(unsigned int key, gchar const *value) { //g_assert(object != NULL); @@ -1106,9 +939,6 @@ void SPObject::setKeyValue(unsigned int key, gchar const *value) } } -/** - * Read value of key attribute from XML node into object. - */ void SPObject::readAttr(gchar const *key) { //g_assert(object != NULL); @@ -1127,9 +957,6 @@ void SPObject::readAttr(gchar const *key) } } -/** - * Callback for attr_changed node event. - */ void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -1143,9 +970,6 @@ void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar } } -/** - * Callback for content_changed node event. - */ void SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -1158,8 +982,7 @@ void SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gch /** * Return string representation of space value. */ -static gchar const* -sp_xml_get_space_string(unsigned int space) +static gchar const *sp_xml_get_space_string(unsigned int space) { switch (space) { case SP_XML_SPACE_DEFAULT: @@ -1171,9 +994,6 @@ sp_xml_get_space_string(unsigned int space) } } -/** - * Callback for write event. - */ Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { @@ -1234,10 +1054,8 @@ Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inksca return repr; } -/** - * Update this object's XML node with flags value. - */ -Inkscape::XML::Node * SPObject::updateRepr(unsigned int flags) { +Inkscape::XML::Node * SPObject::updateRepr(unsigned int flags) +{ if ( !cloned ) { Inkscape::XML::Node *repr = getRepr(); if (repr) { @@ -1252,11 +1070,8 @@ Inkscape::XML::Node * SPObject::updateRepr(unsigned int flags) { } } -/** Used both to create reprs in the original document, and to create - * reprs in another document (e.g. a temporary document used when - * saving as "Plain SVG" - */ -Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) { +Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) +{ g_assert(doc != NULL); if (cloned) { @@ -1284,11 +1099,6 @@ Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscap /* Modification */ -/** - * Add \a flags to \a object's as dirtiness flags, and - * recursively add CHILD_MODIFIED flag to - * parent and ancestors (as far up as necessary). - */ void SPObject::requestDisplayUpdate(unsigned int flags) { g_return_if_fail( this->document != NULL ); @@ -1319,9 +1129,6 @@ void SPObject::requestDisplayUpdate(unsigned int flags) } } -/** - * Update views - */ void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) { g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE)); @@ -1370,11 +1177,6 @@ void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) update_in_progress --; } -/** - * Request modified always bubbles *up* the tree, as opposed to - * request display update, which trickles down and relies on the - * flags set during this pass... - */ void SPObject::requestModified(unsigned int flags) { g_return_if_fail( this->document != NULL ); @@ -1401,12 +1203,6 @@ void SPObject::requestModified(unsigned int flags) } } -/** - * Emits the MODIFIED signal with the object's flags. - * The object's mflags are the original set aside during the update pass for - * later delivery here. Once emitModified() is called, those flags don't - * need to be stored any longer. - */ void SPObject::emitModified(unsigned int flags) { /* only the MODIFIED_CASCADE flag is legal here */ @@ -1522,36 +1318,8 @@ gchar * SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id) return buf; } -/* Style */ +// Style -/** - * Returns an object style property. - * - * \todo - * fixme: Use proper CSS parsing. The current version is buggy - * in a number of situations where key is a substring of the - * style string other than as a property name (including - * where key is a substring of a property name), and is also - * buggy in its handling of inheritance for properties that - * aren't inherited by default. It also doesn't allow for - * the case where the property is specified but with an invalid - * value (in which case I believe the CSS2 error-handling - * behaviour applies, viz. behave as if the property hadn't - * been specified). Also, the current code doesn't use CRSelEng - * stuff to take a value from stylesheets. Also, we aren't - * setting any hooks to force an update for changes in any of - * the inputs (i.e., in any of the elements that this function - * queries). - * - * \par - * Given that the default value for a property depends on what - * property it is (e.g., whether to inherit or not), and given - * the above comment about ignoring invalid values, and that the - * repr parent isn't necessarily the right element to inherit - * from (e.g., maybe we need to inherit from the referencing - * <use> element instead), we should probably make the caller - * responsible for ascending the repr tree as necessary. - */ gchar const * SPObject::getStyleProperty(gchar const *key, gchar const *def) const { //g_return_val_if_fail(object != NULL, NULL); @@ -1599,9 +1367,6 @@ gchar const * SPObject::getStyleProperty(gchar const *key, gchar const *def) con return def; } -/** - * Lifts SVG version of all root objects to version. - */ void SPObject::_requireSVGVersion(Inkscape::Version version) { for ( SPObject::ParentIterator iter=this ; iter ; ++iter ) { SPObject *object = iter; @@ -1614,7 +1379,7 @@ void SPObject::_requireSVGVersion(Inkscape::Version version) { } } -/* Titles and descriptions */ +// Titles and descriptions /* Note: Titles and descriptions are stored in 'title' and 'desc' child elements @@ -1626,58 +1391,26 @@ void SPObject::_requireSVGVersion(Inkscape::Version version) { element, except when deleting a title or description. */ -/** - * Returns the title of this object, or NULL if there is none. - * The caller must free the returned string using g_free() - see comment - * for getTitleOrDesc() below. - */ gchar * SPObject::title() const { return getTitleOrDesc("svg:title"); } -/** - * Sets the title of this object - * A NULL first argument is interpreted as meaning that the existing title - * (if any) should be deleted. - * The second argument is optional - see setTitleOrDesc() below for details. - */ bool SPObject::setTitle(gchar const *title, bool verbatim) { return setTitleOrDesc(title, "svg:title", verbatim); } -/** - * Returns the description of this object, or NULL if there is none. - * The caller must free the returned string using g_free() - see comment - * for getTitleOrDesc() below. - */ gchar * SPObject::desc() const { return getTitleOrDesc("svg:desc"); } -/** - * Sets the description of this object. - * A NULL first argument is interpreted as meaning that the existing - * description (if any) should be deleted. - * The second argument is optional - see setTitleOrDesc() below for details. - */ bool SPObject::setDesc(gchar const *desc, bool verbatim) { return setTitleOrDesc(desc, "svg:desc", verbatim); } -/** - * Returns the title or description of this object, or NULL if there is none. - * - * The SVG spec allows 'title' and 'desc' elements to contain text marked up - * using elements from other namespaces. Therefore, this function cannot - * in general just return a pointer to an existing string - it must instead - * construct a string containing the title or description without the mark-up. - * Consequently, the return value is a newly allocated string (or NULL), and - * must be freed (using g_free()) by the caller. - */ gchar * SPObject::getTitleOrDesc(gchar const *svg_tagname) const { gchar *result = 0; @@ -1688,23 +1421,6 @@ gchar * SPObject::getTitleOrDesc(gchar const *svg_tagname) const return result; } -/** - * Sets or deletes the title or description of this object. - * A NULL 'value' argument causes the title or description to be deleted. - * - * 'verbatim' parameter: - * If verbatim==true, then the title or description is set to exactly the - * specified value. If verbatim==false then two exceptions are made: - * (1) If the specified value is just whitespace, then the title/description - * is deleted. - * (2) If the specified value is the same as the current value except for - * mark-up, then the current value is left unchanged. - * This is usually the desired behaviour, so 'verbatim' defaults to false for - * setTitle() and setDesc(). - * - * The return value is true if a change was made to the title/description, - * and usually false otherwise. - */ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim) { if (!verbatim) { @@ -1770,10 +1486,6 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool return true; } -/** - * Find the first child of this object with a given tag name, - * and return it. Returns NULL if there is no matching child. - */ SPObject * SPObject::findFirstChild(gchar const *tagname) const { for (SPObject *child = children; child; child = child->next) @@ -1786,11 +1498,6 @@ SPObject * SPObject::findFirstChild(gchar const *tagname) const return NULL; } -/** - * Return the full textual content of an element (typically all the - * content except the tags). - * Must not be used on anything except elements. - */ GString * SPObject::textualContent() const { GString* text = g_string_new(""); diff --git a/src/sp-object.h b/src/sp-object.h index 3999dc622..49e36d773 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -126,16 +126,71 @@ struct SPIXmlSpace { * Ref should return object, NULL is error, unref return always NULL */ +/** + * Increase reference count of object, with possible debugging. + * + * @param owner If non-NULL, make debug log entry. + * @return object, NULL is error. + * \pre object points to real object + * @todo need to move this to be a member of SPObject. + */ SPObject *sp_object_ref(SPObject *object, SPObject *owner=NULL); + +/** + * Decrease reference count of object, with possible debugging and + * finalization. + * + * @param owner If non-NULL, make debug log entry. + * @return always NULL + * \pre object points to real object + * @todo need to move this to be a member of SPObject. + */ SPObject *sp_object_unref(SPObject *object, SPObject *owner=NULL); +/** + * Increase weak refcount. + * + * Hrefcount is used for weak references, for example, to + * determine whether any graphical element references a certain gradient + * node. + * @param owner Ignored. + * @return object, NULL is error + * \pre object points to real object + * @todo need to move this to be a member of SPObject. + */ SPObject *sp_object_href(SPObject *object, gpointer owner); + +/** + * Decrease weak refcount. + * + * Hrefcount is used for weak references, for example, to determine whether + * any graphical element references a certain gradient node. + * @param owner Ignored. + * @return always NULL + * \pre object points to real object and hrefcount>0 + * @todo need to move this to be a member of SPObject. + */ SPObject *sp_object_hunref(SPObject *object, gpointer owner); /** - * Abstract base class for all nodes. - * A refcounting tree node object. + * SPObject is an abstract base class of all of the document nodes at the + * SVG document level. Each SPObject subclass implements a certain SVG + * element node type, or is an abstract base class for different node + * types. The SPObject layer is bound to the SPRepr layer, closely + * following the SPRepr mutations via callbacks. During creation, + * SPObject parses and interprets all textual attributes and CSS style + * strings of the SPRepr, and later updates the internal state whenever + * it receives a signal about a change. The opposite is not true - there + * are methods manipulating SPObjects directly and such changes do not + * propagate to the SPRepr layer. This is important for implementation of + * the undo stack, animations and other features. + * + * SPObjects are bound to the higher-level container SPDocument, which + * provides document level functionality such as the undo stack, + * dictionary and so on. Source: doc/architecture.txt + * + * @todo need to remove redundant sp_object_... prefixing on methods. */ class SPObject : public GObject { public: @@ -180,16 +235,18 @@ public: public: - /** @brief cleans up an SPObject, releasing its references and - * requesting that references to it be released + /** + * Cleans up an SPObject, releasing its references and + * requesting that references to it be released */ void releaseReferences(); - /** @brief connects to the release request signal + /** + * Connects to the release request signal * - * @param slot the slot to connect + * @param slot the slot to connect * - * @returns the sigc::connection formed + * @return the sigc::connection formed */ sigc::connection connectRelease(sigc::slot<void, SPObject *> slot) { return _release_signal.connect(slot); @@ -230,13 +287,21 @@ public: g_return_val_if_fail(object != NULL, false); return this->parent && this->parent == object->parent; } + + /** + * True if object is non-NULL and this is some in/direct parent of object. + */ bool isAncestorOf(SPObject const *object) const; + /** + * Returns youngest object being parent to this and object. + */ SPObject const *nearestCommonAncestor(SPObject const *object) const; + /* A non-const version can be similarly constructed if you want one. * (Don't just cast away the constness, which would be ill-formed.) */ - SPObject *getNext() {return next;} + SPObject const *getNext() const {return next;} /** @@ -260,32 +325,62 @@ public: */ GSList *childList(bool add_ref, Action action = ActionGeneral); + /** + * Append repr as child of this object. + * \pre this is not a cloned object + */ SPObject *appendChildRepr(Inkscape::XML::Node *repr); - /** @brief Gets the author-visible label for this object. */ + /** + * Gets the author-visible label property for the object or a default if + * no label is defined. + */ gchar const *label() const; - /** @brief Returns a default label for this object. */ + + /** + * Returns a default label property for this object. + */ gchar const *defaultLabel() const; - /** @brief Sets the author-visible label for this object. - * - * Sets the author-visible label for the object. + + /** + * Sets the author-visible label for this object. * - * @param label the new label + * @param label the new label. */ void setLabel(gchar const *label); - /** Retrieves the title of this object */ + /** + * Returns the title of this object, or NULL if there is none. + * The caller must free the returned string using g_free() - see comment + * for getTitleOrDesc() below. + */ gchar *title() const; - /** Sets the title of this object */ - bool setTitle(gchar const *title, bool verbatim=false); - /** Retrieves the description of this object */ + /** + * Sets the title of this object. + * A NULL first argument is interpreted as meaning that the existing title + * (if any) should be deleted. + * The second argument is optional - @see setTitleOrDesc() below for details. + */ + bool setTitle(gchar const *title, bool verbatim = false); + + /** + * Returns the description of this object, or NULL if there is none. + * The caller must free the returned string using g_free() - see comment + * for getTitleOrDesc() below. + */ gchar *desc() const; - /** Sets the description of this object */ + + /** + * Sets the description of this object. + * A NULL first argument is interpreted as meaning that the existing + * description (if any) should be deleted. + * The second argument is optional - @see setTitleOrDesc() below for details. + */ bool setDesc(gchar const *desc, bool verbatim=false); - /** @brief Set the policy under which this object will be - * orphan-collected. + /** + * Set the policy under which this object will be orphan-collected. * * Orphan-collection is the process of deleting all objects which no longer have * hyper-references pointing to them. The policy determines when this happens. Many objects @@ -302,21 +397,23 @@ public: * COLLECT_ALWAYS - always collect the object as soon as its * hrefcount reaches zero * - * @returns the current collection policy in effect for this object + * @return the current collection policy in effect for this object */ CollectionPolicy collectionPolicy() const { return _collection_policy; } - /** @brief Sets the orphan-collection policy in effect for this object. - * - * @see SPObject::collectionPolicy + /** + * Sets the orphan-collection policy in effect for this object. * * @param policy the new policy to adopt + * + * @see SPObject::collectionPolicy */ void setCollectionPolicy(CollectionPolicy policy) { _collection_policy = policy; } - /** @brief Requests a later automatic call to collectOrphan(). + /** + * Requests a later automatic call to collectOrphan(). * * This method requests that collectOrphan() be called during the document update cycle, * deleting the object if it is no longer used. @@ -327,7 +424,8 @@ public: */ void requestOrphanCollection(); - /** @brief Unconditionally delete the object if it is not referenced. + /** + * Unconditionally delete the object if it is not referenced. * * Unconditionally delete the object if there are no outstanding hyper-references to it. * Observers are not notified of the object's deletion (at the SPObject level; XML tree @@ -341,31 +439,36 @@ public: } } - /** @brief Check if object is referenced by any other object. + /** + * Check if object is referenced by any other object. */ bool isReferenced() { return ( _total_hrefcount > 0 ); } - /** @brief Deletes an object. + /** + * Deletes an object, unparenting it from its parent. * * Detaches the object's repr, and optionally sends notification that the object has been * deleted. * - * @param propagate notify observers that the object has been deleted? + * @param propagate If it is set to true, it emits a delete signal. * - * @param propagate_descendants notify observers of children that they have been deleted? + * @param propagate_descendants If it is is true, it recursively sends the delete signal to children. */ void deleteObject(bool propagate, bool propagate_descendants); - /** @brief Deletes on object. + /** + * Deletes on object. * * @param propagate Notify observers of this object and its children that they have been * deleted? */ - void deleteObject(bool propagate=true) { + void deleteObject(bool propagate = true) + { deleteObject(propagate, propagate); } - /** @brief Connects a slot to be called when an object is deleted. + /** + * Connects a slot to be called when an object is deleted. * * This connects a slot to an object's internal delete signal, which is invoked when the object * is deleted @@ -384,14 +487,17 @@ public: return _position_changed_signal.connect(slot); } - /** @brief Returns the object which supercedes this one (if any). + /** + * Returns the object which supercedes this one (if any). * * This is mainly useful for ensuring we can correctly perform a series of moves or deletes, * even if the objects in question have been replaced in the middle of the sequence. */ SPObject *successor() { return _successor; } - /** @brief Indicates that another object supercedes this one. */ + /** + * Indicates that another object supercedes this one. + */ void setSuccessor(SPObject *successor) { g_assert(successor != NULL); g_assert(_successor == NULL); @@ -408,18 +514,23 @@ public: * essentially just flushes any changes back to the backing store (the repr layer); maybe it * should be called something else and made public at that point. */ - /** @brief Updates the object's repr based on the object's state. + /** + * Updates the object's repr based on the object's state. * * This method updates the the repr attached to the object to reflect the object's current * state; see the three-argument version for details. * - * @param flags object write flags that apply to this update + * @param flags object write flags that apply to this update * - * @return the updated repr + * @return the updated repr */ - Inkscape::XML::Node *updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT); + Inkscape::XML::Node *updateRepr(unsigned int flags = SP_OBJECT_WRITE_EXT); - /** @brief Updates the given repr based on the object's state. + /** + * Updates the given repr based on the object's state. + * + * Used both to create reprs in the original document, and to create reprs + * in another document (e.g. a temporary document used when saving as "Plain SVG". * * This method updates the given repr to reflect the object's current state. There are * several flags that affect this: @@ -434,14 +545,15 @@ public: * SP_OBJECT_WRITE_ALL - create all nodes and attributes, * even those which might be redundant * - * @param repr the repr to update - * @param flags object write flags that apply to this update + * @param repr the repr to update + * @param flags object write flags that apply to this update * - * @return the updated repr + * @return the updated repr */ Inkscape::XML::Node *updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags); - /** @brief Queues an deferred update of this object's display. + /** + * Queues an deferred update of this object's display. * * This method sets flags to indicate updates to be performed later, during the idle loop. * @@ -459,11 +571,12 @@ public: * * One of either MODIFIED or CHILD_MODIFIED is required. * - * @param flags flags indicating what to update + * @param flags flags indicating what to update */ void requestDisplayUpdate(unsigned int flags); - /** @brief Updates the object's display immediately + /** + * Updates the object's display immediately * * This method is called during the idle loop by SPDocument in order to update the object's * display. @@ -473,33 +586,43 @@ public: * SP_OBJECT_PARENT_MODIFIED_FLAG - the parent has been * modified * - * @param ctx an SPCtx which accumulates various state + * @param ctx an SPCtx which accumulates various state * during the recursive update -- beware! some * subclasses try to cast this to an SPItemCtx * * - * @param flags flags indicating what to update (in addition + * @param flags flags indicating what to update (in addition * to any already set flags) */ void updateDisplay(SPCtx *ctx, unsigned int flags); - /** @brief Requests that a modification notification signal - * be emitted later (e.g. during the idle loop) + /** + * Requests that a modification notification signal + * be emitted later (e.g. during the idle loop) + * + * Request modified always bubbles *up* the tree, as opposed to + * request display update, which trickles down and relies on the + * flags set during this pass... * - * @param flags flags indicating what has been modified + * @param flags flags indicating what has been modified */ void requestModified(unsigned int flags); - /** @brief Emits a modification notification signal + /** + * Emits the MODIFIED signal with the object's flags. + * The object's mflags are the original set aside during the update pass for + * later delivery here. Once emitModified() is called, those flags don't + * need to be stored any longer. * - * @param flags indicating what has been modified + * @param flags indicating what has been modified. */ void emitModified(unsigned int flags); - /** @brief Connects to the modification notification signal + /** + * Connects to the modification notification signal * - * @param slot the slot to connect + * @param slot the slot to connect * - * @returns the connection formed thereby + * @return the connection formed thereby */ sigc::connection connectModified( sigc::slot<void, SPObject *, unsigned int> slot @@ -510,11 +633,18 @@ public: /** Sends the delete signal to all children of this object recursively */ void _sendDeleteSignalRecursive(); + /** + * Adds increment to _total_hrefcount of object and its parents. + */ void _updateTotalHRefCount(int increment); void _requireSVGVersion(unsigned major, unsigned minor) { _requireSVGVersion(Inkscape::Version(major, minor)); } + + /** + * Lifts SVG version of all root objects to version. + */ void _requireSVGVersion(Inkscape::Version version); sigc::signal<void, SPObject *> _release_signal; @@ -530,59 +660,246 @@ public: // Methods below should not be used outside of the SP tree, // as they operate directly on the XML representation. // In future, they will be made protected. + + /** + * Put object into object tree, under parent, and behind prev; + * also update object's XML space. + */ void attach(SPObject *object, SPObject *prev); + + /** + * In list of object's siblings, move object behind prev. + */ void reorder(SPObject *prev); + + /** + * Remove object from parent's children, release and unref it. + */ void detach(SPObject *object); + + /** + * Return object's child whose node pointer equals repr. + */ SPObject *get_child_by_repr(Inkscape::XML::Node *repr); + void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); + long long int getIntAttribute(char const *key, long long int def); + unsigned getPosition(); + gchar const * getAttribute(gchar const *name,SPException *ex=0) const; + void appendChild(Inkscape::XML::Node *child); + void addChild(Inkscape::XML::Node *child,Inkscape::XML::Node *prev=0); + + /** + * Call virtual set() function of object. + */ void setKeyValue(unsigned int key, gchar const *value); + void setAttribute(gchar const *key, gchar const *value, SPException *ex=0); + + /** + * Read value of key attribute from XML node into object. + */ void readAttr(gchar const *key); + gchar const *getTagName(SPException *ex) const; + void removeAttribute(gchar const *key, SPException *ex=0); + + /** + * Returns an object style property. + * + * \todo + * fixme: Use proper CSS parsing. The current version is buggy + * in a number of situations where key is a substring of the + * style string other than as a property name (including + * where key is a substring of a property name), and is also + * buggy in its handling of inheritance for properties that + * aren't inherited by default. It also doesn't allow for + * the case where the property is specified but with an invalid + * value (in which case I believe the CSS2 error-handling + * behaviour applies, viz. behave as if the property hadn't + * been specified). Also, the current code doesn't use CRSelEng + * stuff to take a value from stylesheets. Also, we aren't + * setting any hooks to force an update for changes in any of + * the inputs (i.e., in any of the elements that this function + * queries). + * + * \par + * Given that the default value for a property depends on what + * property it is (e.g., whether to inherit or not), and given + * the above comment about ignoring invalid values, and that the + * repr parent isn't necessarily the right element to inherit + * from (e.g., maybe we need to inherit from the referencing + * <use> element instead), we should probably make the caller + * responsible for ascending the repr tree as necessary. + */ gchar const *getStyleProperty(gchar const *key, gchar const *def) const; + void setCSS(SPCSSAttr *css, gchar const *attr); + void changeCSS(SPCSSAttr *css, gchar const *attr); + bool storeAsDouble( gchar const *key, double *val ) const; private: // Private member functions used in the definitions of setTitle(), // setDesc(), title() and desc(). + + /** + * Sets or deletes the title or description of this object. + * A NULL 'value' argument causes the title or description to be deleted. + * + * 'verbatim' parameter: + * If verbatim==true, then the title or description is set to exactly the + * specified value. If verbatim==false then two exceptions are made: + * (1) If the specified value is just whitespace, then the title/description + * is deleted. + * (2) If the specified value is the same as the current value except for + * mark-up, then the current value is left unchanged. + * This is usually the desired behaviour, so 'verbatim' defaults to false for + * setTitle() and setDesc(). + * + * The return value is true if a change was made to the title/description, + * and usually false otherwise. + */ bool setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim); + + /** + * Returns the title or description of this object, or NULL if there is none. + * + * The SVG spec allows 'title' and 'desc' elements to contain text marked up + * using elements from other namespaces. Therefore, this function cannot + * in general just return a pointer to an existing string - it must instead + * construct a string containing the title or description without the mark-up. + * Consequently, the return value is a newly allocated string (or NULL), and + * must be freed (using g_free()) by the caller. + */ gchar * getTitleOrDesc(gchar const *svg_tagname) const; + + /** + * Find the first child of this object with a given tag name, + * and return it. Returns NULL if there is no matching child. + */ SPObject * findFirstChild(gchar const *tagname) const; + + /** + * Return the full textual content of an element (typically all the + * content except the tags). + * Must not be used on anything except elements. + */ GString * textualContent() const; + /** + * Callback to initialize the SPObject object. + */ static void sp_object_init(SPObject *object); + + /** + * Callback to destroy all members and connections of object and itself. + */ static void sp_object_finalize(GObject *object); + /** + * Callback for child_added event. + * Invoked whenever the given mutation event happens in the XML tree. + */ static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); + + /** + * Remove object's child whose node equals repr, release and + * unref it. + * + * Invoked whenever the given mutation event happens in the XML + * tree, BEFORE removal from the XML tree happens, so grouping + * objects can safely release the child data. + */ static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child); + + /** + * Move object corresponding to child after sibling object corresponding + * to new_ref. + * Invoked whenever the given mutation event happens in the XML tree. + * @param old_ref Ignored + */ static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); + /** + * Removes, releases and unrefs all children of object. + * + * This is the opposite of build. It has to be invoked as soon as the + * object is removed from the tree, even if it is still alive according + * to reference count. The frontend unregisters the object from the + * document and releases the SPRepr bindings; implementations should free + * state data and release all child objects. Invoking release on + * SPRoot destroys the whole document tree. + * @see sp_object_build() + */ static void sp_object_release(SPObject *object); + + /** + * Virtual build callback. + * + * This has to be invoked immediately after creation of an SPObject. The + * frontend method ensures that the new object is properly attached to + * the document and repr; implementation then will parse all of the attributes, + * generate the children objects and so on. Invoking build on the SPRoot + * object results in creation of the whole document tree (this is, what + * SPDocument does after the creation of the XML tree). + * @see sp_object_release() + */ static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); + /** + * Callback for set event. + */ static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); + + /** + * Callback for write event. + */ static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); /* Real handlers of repr signals */ public: + + /** + * Registers the SPObject class with Gdk and returns its type number. + */ static GType sp_object_get_type(); + + /** + * Callback for attr_changed node event. + */ static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); + /** + * Callback for content_changed node event. + */ static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); + /** + * Callback for child_added node event. + */ static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); + + /** + * Callback for remove_child node event. + */ static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); + /** + * Callback for order_changed node event. + * + * \todo fixme: + */ static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); @@ -617,12 +934,25 @@ public: private: static GObjectClass *static_parent_class; + + /** + * Initializes the SPObject vtable. + */ static void sp_object_class_init(SPObjectClass *klass); friend class SPObject; }; +/** + * Compares height of objects in tree. + * + * Works for different-parent objects, so long as they have a common ancestor. + * \return \verbatim + * 0 positions are equivalent + * 1 first object's position is greater than the second + * -1 first object's position is less than the second \endverbatim + */ int sp_object_compare_position(SPObject const *first, SPObject const *second); diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index cda1ed546..44a2d4b2d 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -1,5 +1,5 @@ -/** \file - * Functions and callbacks for generic SVG view and widget +/* + * Functions and callbacks for generic SVG view and widget. * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -33,9 +33,6 @@ static void sp_svg_view_widget_view_resized (SPViewWidget *vw, Inkscape::UI::Vie static SPViewWidgetClass *widget_parent_class; -/** - * Registers SPSVGSPViewWidget class with Gtk and returns its type number. - */ GType sp_svg_view_widget_get_type(void) { static GType type = 0; @@ -60,8 +57,7 @@ GType sp_svg_view_widget_get_type(void) /** * Callback to initialize SPSVGSPViewWidget vtable. */ -static void -sp_svg_view_widget_class_init (SPSVGSPViewWidgetClass *klass) +static void sp_svg_view_widget_class_init(SPSVGSPViewWidgetClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); @@ -80,8 +76,7 @@ sp_svg_view_widget_class_init (SPSVGSPViewWidgetClass *klass) /** * Callback to initialize SPSVGSPViewWidget object. */ -static void -sp_svg_view_widget_init (SPSVGSPViewWidget *vw) +static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) { GtkStyle *style; SPCanvasItem *parent; @@ -124,21 +119,22 @@ sp_svg_view_widget_destroy (GtkObject *object) vw->canvas = NULL; - if (((GtkObjectClass *) (widget_parent_class))->destroy) + if (((GtkObjectClass *) (widget_parent_class))->destroy) { (* ((GtkObjectClass *) (widget_parent_class))->destroy) (object); + } } /** * Callback connected with size_request signal. */ -static void -sp_svg_view_widget_size_request (GtkWidget *widget, GtkRequisition *req) +static void sp_svg_view_widget_size_request(GtkWidget *widget, GtkRequisition *req) { SPSVGSPViewWidget *vw = SP_SVG_VIEW_WIDGET (widget); Inkscape::UI::View::View *v = SP_VIEW_WIDGET_VIEW (widget); - if (((GtkWidgetClass *) (widget_parent_class))->size_request) + if (((GtkWidgetClass *) (widget_parent_class))->size_request) { (* ((GtkWidgetClass *) (widget_parent_class))->size_request) (widget, req); + } if (v->doc()) { SPSVGView *svgv; @@ -170,13 +166,13 @@ sp_svg_view_widget_size_request (GtkWidget *widget, GtkRequisition *req) /** * Callback connected with size_allocate signal. */ -static void -sp_svg_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) +static void sp_svg_view_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { SPSVGSPViewWidget *svgvw = SP_SVG_VIEW_WIDGET (widget); - if (((GtkWidgetClass *) (widget_parent_class))->size_allocate) + if (((GtkWidgetClass *) (widget_parent_class))->size_allocate) { (* ((GtkWidgetClass *) (widget_parent_class))->size_allocate) (widget, allocation); + } if (!svgvw->resize) { static_cast<SPSVGView*>(SP_VIEW_WIDGET_VIEW (svgvw))->setRescale (TRUE, TRUE, @@ -187,8 +183,7 @@ sp_svg_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) /** * Callback connected with view_resized signal. */ -static void -sp_svg_view_widget_view_resized (SPViewWidget *vw, Inkscape::UI::View::View */*view*/, gdouble width, gdouble height) +static void sp_svg_view_widget_view_resized(SPViewWidget *vw, Inkscape::UI::View::View */*view*/, gdouble width, gdouble height) { SPSVGSPViewWidget *svgvw = SP_SVG_VIEW_WIDGET (vw); @@ -198,11 +193,7 @@ sp_svg_view_widget_view_resized (SPViewWidget *vw, Inkscape::UI::View::View */*v } } -/** - * Constructs new SPSVGSPViewWidget object and returns pointer to it. - */ -GtkWidget * -sp_svg_view_widget_new (SPDocument *doc) +GtkWidget *sp_svg_view_widget_new(SPDocument *doc) { GtkWidget *widget; @@ -215,9 +206,6 @@ sp_svg_view_widget_new (SPDocument *doc) return widget; } -/** - * Flags the SPSVGSPViewWidget to have its size renegotiated with Gtk. - */ void SPSVGSPViewWidget::setResize(bool resize, gdouble width, gdouble height) { g_return_if_fail( !resize || (width > 0.0) ); diff --git a/src/svg-view-widget.h b/src/svg-view-widget.h index 0c2c651ad..d489ccbdd 100644 --- a/src/svg-view-widget.h +++ b/src/svg-view-widget.h @@ -24,9 +24,15 @@ class SPSVGSPViewWidgetClass; #define SP_IS_SVG_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SVG_VIEW_WIDGET)) #define SP_IS_SVG_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SVG_VIEW_WIDGET)) -GType sp_svg_view_widget_get_type (void); +/** + * Registers SPSVGSPViewWidget class with Gtk and returns its type number. + */ +GType sp_svg_view_widget_get_type(void); -GtkWidget *sp_svg_view_widget_new (SPDocument *doc); +/** + * Constructs new SPSVGSPViewWidget object and returns pointer to it. + */ +GtkWidget *sp_svg_view_widget_new(SPDocument *doc); /** * An SPSVGSPViewWidget is an SVG view together with a canvas. @@ -43,7 +49,10 @@ public: gdouble maxwidth, maxheight; // C++ Wrappers - /// Flags the SPSVGSPViewWidget to have its size changed with Gtk. + + /** + * Flags the SPSVGSPViewWidget to have its size renegotiated with Gtk. + */ void setResize(bool resize, gdouble width, gdouble height); }; diff --git a/src/svg-view.cpp b/src/svg-view.cpp index 8773dfab7..6eca02d5c 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -1,5 +1,5 @@ -/** \file - * Functions and callbacks for generic SVG view and widget +/* + * Functions and callbacks for generic SVG view and widget. * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -21,10 +21,7 @@ #include "svg-view.h" #include "sp-root.h" -/** - * Constructs new SPSVGView object and returns pointer to it. - */ -SPSVGView::SPSVGView (SPCanvasGroup *parent) +SPSVGView::SPSVGView(SPCanvasGroup *parent) { _hscale = 1.0; _vscale = 1.0; @@ -47,11 +44,7 @@ SPSVGView::~SPSVGView() } } -/** - * Rescales SPSVGView to given proportions. - */ -void -SPSVGView::setScale (gdouble hscale, gdouble vscale) +void SPSVGView::setScale(gdouble hscale, gdouble vscale) { if (!_rescale && ((hscale != _hscale) || (vscale != _vscale))) { _hscale = hscale; @@ -60,12 +53,7 @@ SPSVGView::setScale (gdouble hscale, gdouble vscale) } } -/** - * Rescales SPSVGView and keeps aspect ratio. - */ -void -SPSVGView::setRescale -(bool rescale, bool keepaspect, gdouble width, gdouble height) +void SPSVGView::setRescale(bool rescale, bool keepaspect, gdouble width, gdouble height) { g_return_if_fail (!rescale || (width >= 0.0)); g_return_if_fail (!rescale || (height >= 0.0)); @@ -78,15 +66,17 @@ SPSVGView::setRescale doRescale (true); } -/** - * Helper function that sets rescale ratio and emits resize event. - */ -void -SPSVGView::doRescale (bool event) +void SPSVGView::doRescale(bool event) { - if (!doc()) return; - if (doc()->getWidth () < 1e-9) return; - if (doc()->getHeight () < 1e-9) return; + if (!doc()) { + return; + } + if (doc()->getWidth () < 1e-9) { + return; + } + if (doc()->getHeight () < 1e-9) { + return; + } if (_rescale) { _hscale = _width / doc()->getWidth (); @@ -110,16 +100,14 @@ SPSVGView::doRescale (bool event) } } -void -SPSVGView::mouseover() +void SPSVGView::mouseover() { GdkCursor *cursor = gdk_cursor_new(GDK_HAND2); gdk_window_set_cursor(GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)->window, cursor); gdk_cursor_unref(cursor); } -void -SPSVGView::mouseout() +void SPSVGView::mouseout() { gdk_window_set_cursor(GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)->window, NULL); } @@ -129,8 +117,7 @@ SPSVGView::mouseout() * Callback connected with arena_event. */ /// \todo fixme. -static gint -arena_handler (SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPSVGView *svgview) +static gint arena_handler(SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPSVGView *svgview) { static gdouble x, y; static gboolean active = FALSE; @@ -185,11 +172,7 @@ arena_handler (SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *ev return TRUE; } -/** - * Callback connected with set_document signal. - */ -void -SPSVGView::setDocument (SPDocument *document) +void SPSVGView::setDocument(SPDocument *document) { if (doc()) { doc()->getRoot()->invoke_hide(_dkey); @@ -216,11 +199,7 @@ SPSVGView::setDocument (SPDocument *document) } } -/** - * Callback connected with document_resized signal. - */ -void -SPSVGView::onDocumentResized (gdouble width, gdouble height) +void SPSVGView::onDocumentResized(gdouble width, gdouble height) { setScale (width, height); doRescale (!_rescale); diff --git a/src/svg-view.h b/src/svg-view.h index 5e830eb00..33a9b569a 100644 --- a/src/svg-view.h +++ b/src/svg-view.h @@ -33,29 +33,50 @@ public: gdouble _height; - SPSVGView (SPCanvasGroup* parent); + /** + * Constructs new SPSVGView object and returns pointer to it. + */ + SPSVGView(SPCanvasGroup* parent); + virtual ~SPSVGView(); - /// Rescales SPSVGView to given proportions. - void setScale (gdouble hscale, gdouble vscale); + /** + * Rescales SPSVGView to given proportions. + */ + void setScale(gdouble hscale, gdouble vscale); - /// Rescales SPSVGView and keeps aspect ratio. - void setRescale (bool rescale, bool keepaspect, gdouble width, gdouble height); + /** + * Rescales SPSVGView and keeps aspect ratio. + */ + void setRescale(bool rescale, bool keepaspect, gdouble width, gdouble height); + + /** + * Helper function that sets rescale ratio and emits resize event. + */ + void doRescale(bool event); - void doRescale (bool event); + /** + * Callback connected with set_document signal. + */ + virtual void setDocument(SPDocument *document); - virtual void setDocument (SPDocument*); virtual void mouseover(); + virtual void mouseout(); + virtual bool shutdown() { return true; } private: - virtual void onPositionSet (double, double) {} - virtual void onResized (double, double) {} + virtual void onPositionSet(double, double) {} + virtual void onResized(double, double) {} virtual void onRedrawRequested() {} - virtual void onStatusMessage (Inkscape::MessageType /*type*/, gchar const */*message*/) {} - virtual void onDocumentURISet (gchar const* /*uri*/) {} - virtual void onDocumentResized (double, double); + virtual void onStatusMessage(Inkscape::MessageType /*type*/, gchar const */*message*/) {} + virtual void onDocumentURISet(gchar const* /*uri*/) {} + + /** + * Callback connected with document_resized signal. + */ + virtual void onDocumentResized(double, double); }; #endif // SEEN_SP_SVG_VIEW_H diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 64a4a7732..8f04d7a2d 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -1,4 +1,4 @@ -/** +/* * A generic interface for plugging different * autotracers into Inkscape. * @@ -38,12 +38,7 @@ namespace Inkscape { namespace Trace { -/** - * Get the selected image. Also check for any SPItems over it, in - * case the user wants SIOX pre-processing. - */ -SPImage * -Tracer::getSelectedSPImage() +SPImage *Tracer::getSelectedSPImage() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -198,13 +193,7 @@ public: -/** - * Process a GdkPixbuf, according to which areas have been - * obscured in the GUI. - */ -Glib::RefPtr<Gdk::Pixbuf> -Tracer::sioxProcessImage(SPImage *img, - Glib::RefPtr<Gdk::Pixbuf>origPixbuf) +Glib::RefPtr<Gdk::Pixbuf> Tracer::sioxProcessImage(SPImage *img, Glib::RefPtr<Gdk::Pixbuf>origPixbuf) { if (!sioxEnabled) return origPixbuf; @@ -334,11 +323,7 @@ Tracer::sioxProcessImage(SPImage *img, } -/** - * - */ -Glib::RefPtr<Gdk::Pixbuf> -Tracer::getSelectedImage() +Glib::RefPtr<Gdk::Pixbuf> Tracer::getSelectedImage() { @@ -378,18 +363,12 @@ Tracer::getSelectedImage() //# T R A C E //######################################################################### -/** - * Whether we want to enable SIOX subimage selection - */ void Tracer::enableSiox(bool enable) { sioxEnabled = enable; } -/** - * Threaded method that does single bitmap--->path conversion - */ void Tracer::traceThread() { //## Remember. NEVER leave this method without setting @@ -559,9 +538,6 @@ void Tracer::traceThread() -/** - * Main tracing method - */ void Tracer::trace(TracingEngine *theEngine) { //Check if we are already running @@ -588,9 +564,6 @@ void Tracer::trace(TracingEngine *theEngine) -/** - * Abort the thread that is executing trace() - */ void Tracer::abort() { diff --git a/src/trace/trace.h b/src/trace/trace.h index 45b18385f..29b8716ee 100644 --- a/src/trace/trace.h +++ b/src/trace/trace.h @@ -6,8 +6,8 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifndef __TRACE_H__ -#define __TRACE_H__ +#ifndef SEEN_TRACE_H +#define SEEN_TRACE_H #ifdef HAVE_CONFIG_H # include "config.h" @@ -207,7 +207,7 @@ public: void abort(); /** - * Whether we want to enable SIOX subimage selection + * Whether we want to enable SIOX subimage selection. */ void enableSiox(bool enable); @@ -216,6 +216,7 @@ private: /** * This is the single path code that is called by its counterpart above. + * Threaded method that does single bitmap--->path conversion. */ void traceThread(); @@ -231,14 +232,21 @@ private: */ TracingEngine *engine; + /** + * Get the selected image. Also check for any SPItems over it, in + * case the user wants SIOX pre-processing. + */ SPImage *getSelectedSPImage(); std::vector<SPShape *> sioxShapes; bool sioxEnabled; - Glib::RefPtr<Gdk::Pixbuf> sioxProcessImage( - SPImage *img, Glib::RefPtr<Gdk::Pixbuf> origPixbuf); + /** + * Process a GdkPixbuf, according to which areas have been + * obscured in the GUI. + */ + Glib::RefPtr<Gdk::Pixbuf> sioxProcessImage(SPImage *img, Glib::RefPtr<Gdk::Pixbuf> origPixbuf); Glib::RefPtr<Gdk::Pixbuf> lastSioxPixbuf; Glib::RefPtr<Gdk::Pixbuf> lastOrigPixbuf; @@ -254,7 +262,7 @@ private: -#endif //__TRACE_H__ +#endif // SEEN_TRACE_H //######################################################################### //# E N D O F F I L E diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 4eeac74b9..42447a141 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index d73071194..da276fae4 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 78bb8c66a..49bdc0a30 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -1,6 +1,4 @@ -/** - * Find dialog. - * +/* * Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * Johan Engelen <goejendaagh@zonnet.nl> diff --git a/src/ui/view/view-widget.cpp b/src/ui/view/view-widget.cpp index d43877569..7876928f7 100644 --- a/src/ui/view/view-widget.cpp +++ b/src/ui/view/view-widget.cpp @@ -1,6 +1,4 @@ -/** \file - * SPViewWidget implementation. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -16,7 +14,7 @@ //using namespace Inkscape::UI::View; -/* SPViewWidget */ +// SPViewWidget static void sp_view_widget_class_init(SPViewWidgetClass *vwc); static void sp_view_widget_init(SPViewWidget *widget); @@ -24,9 +22,6 @@ static void sp_view_widget_destroy(GtkObject *object); static GtkEventBoxClass *widget_parent_class; -/** - * Registers the SPViewWidget class with Glib and returns its type number. - */ GType sp_view_widget_get_type(void) { static GType type = 0; @@ -89,10 +84,6 @@ static void sp_view_widget_destroy(GtkObject *object) Inkscape::GC::request_early_collection(); } -/** - * Connects widget to view's 'resized' signal and calls virtual set_view() - * function. - */ void sp_view_widget_set_view(SPViewWidget *vw, Inkscape::UI::View::View *view) { g_return_if_fail(vw != NULL); @@ -109,9 +100,6 @@ void sp_view_widget_set_view(SPViewWidget *vw, Inkscape::UI::View::View *view) } } -/** - * Calls the virtual shutdown() function of the SPViewWidget. - */ bool sp_view_widget_shutdown(SPViewWidget *vw) { g_return_val_if_fail(vw != NULL, TRUE); diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index 5143054d2..668f9d19a 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -33,15 +33,27 @@ class SPNamedView; #define SP_VIEW_WIDGET_VIEW(w) (SP_VIEW_WIDGET (w)->view) #define SP_VIEW_WIDGET_DOCUMENT(w) (SP_VIEW_WIDGET (w)->view ? ((SPViewWidget *) (w))->view->doc : NULL) -GType sp_view_widget_get_type (void); +/** + * Registers the SPViewWidget class with Glib and returns its type number. + */ +GType sp_view_widget_get_type(void); -void sp_view_widget_set_view (SPViewWidget *vw, Inkscape::UI::View::View *view); +/** + * Connects widget to view's 'resized' signal and calls virtual set_view() + * function. + */ +void sp_view_widget_set_view(SPViewWidget *vw, Inkscape::UI::View::View *view); -/// Allows presenting 'save changes' dialog, FALSE - continue, TRUE - cancel -bool sp_view_widget_shutdown (SPViewWidget *vw); +/** + * Allows presenting 'save changes' dialog, FALSE - continue, TRUE - cancel. + * Calls the virtual shutdown() function of the SPViewWidget. + */ +bool sp_view_widget_shutdown(SPViewWidget *vw); -/// Create a new SPViewWidget (which happens to be a SPDesktopWidget). -SPViewWidget *sp_desktop_widget_new (SPNamedView *namedview); +/** + * Create a new SPViewWidget (which happens to be a SPDesktopWidget). + */ +SPViewWidget *sp_desktop_widget_new(SPNamedView *namedview); /** * SPViewWidget is a GUI widget that contain a single View. It is also diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index dc6307ab0..e13976cc4 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -1,6 +1,4 @@ -/** \file - * View implementation - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -78,9 +76,6 @@ View::View() _message_changed_connection = _message_stack->connectChanged (sigc::bind (sigc::ptr_fun (&_onStatusMessage), this)); } -/** - * Deletes and nulls all View message stacks and disconnects it from signals. - */ View::~View() { _close(); @@ -127,15 +122,6 @@ void View::requestRedraw() _redraw_requested_signal.emit(); } -/** - * Disconnects the view from the document signals, connects the view - * to a new one, and emits the _document_set_signal on the view. - * - * This is code comon to all subclasses and called from their - * setDocument() methods after they are done. - * - * \param doc The new document to connect the view to. - */ void View::setDocument(SPDocument *doc) { g_return_if_fail(doc != NULL); diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 8b30aead2..6ed9f476c 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -72,6 +72,10 @@ class View : public GC::Managed<>, public: View(); + + /** + * Deletes and nulls all View message stacks and disconnects it from signals. + */ virtual ~View(); void close() { _close(); } @@ -110,6 +114,16 @@ protected: Inkscape::MessageContext *_tips_message_context; virtual void _close(); + + /** + * Disconnects the view from the document signals, connects the view + * to a new one, and emits the _document_set_signal on the view. + * + * This is code comon to all subclasses and called from their + * setDocument() methods after they are done. + * + * @param doc The new document to connect the view to. + */ virtual void setDocument(SPDocument *doc); sigc::signal<void,double,double> _position_set_signal; diff --git a/src/ui/widget/button.cpp b/src/ui/widget/button.cpp index fe4aa90ce..ae1dbbe98 100644 --- a/src/ui/widget/button.cpp +++ b/src/ui/widget/button.cpp @@ -1,6 +1,4 @@ -/** - * Button and CheckButton widgets. - * +/* * Author: * buliabyak@gmail.com * diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index bd7a666d2..f32e25885 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -1,7 +1,4 @@ -/** - * @file - * Color picker button & window. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index a4212c7ba..22ca1ebe0 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -1,6 +1,4 @@ -/** \file - * Implemenmtation of a simple color preview widget - * +/* * Author: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 9c6758bc0..14b219110 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -1,6 +1,4 @@ -/** - * A custom Inkscape wrapper around gdl_dock_item. - * +/* * Author: * Gustav Broberg <broberg@kth.se> * diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index e62eb009c..aaf67a7a2 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -1,5 +1,4 @@ -/** \file - * +/* * Authors: * bulia byak <buliabyak@users.sf.net> * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp index ce7552fd6..7ac8532fb 100644 --- a/src/ui/widget/entry.cpp +++ b/src/ui/widget/entry.cpp @@ -1,8 +1,4 @@ -/** - * @file - * - * Helperclass for Gtk::Entry widgets. - * +/* * Authors: * Johan Engelen <goejendaagh@zonnet.nl> * diff --git a/src/ui/widget/handlebox.cpp b/src/ui/widget/handlebox.cpp index f5b716975..0ac84ef3a 100644 --- a/src/ui/widget/handlebox.cpp +++ b/src/ui/widget/handlebox.cpp @@ -1,10 +1,4 @@ -/** - * HandleBox Widget - Adds a detachment handle to another widget. - * - * This work really doesn't amount to much more than a convenience constructor - * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as - * Gtkmm provides several convenience constructors for other widgets as well. - * +/* * Author: * Derek P. Moore <derekm@hackunix.org> * diff --git a/src/ui/widget/icon-widget.cpp b/src/ui/widget/icon-widget.cpp index c3780b616..1bc4ad308 100644 --- a/src/ui/widget/icon-widget.cpp +++ b/src/ui/widget/icon-widget.cpp @@ -1,6 +1,4 @@ -/** - * Icon Widget. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -21,14 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * General purpose icon widget, supporting SVG, etc. icon loading - * - * \param ... - * - * An icon widget is a ... - */ - IconWidget::IconWidget() { _pb = NULL; diff --git a/src/ui/widget/labelled.cpp b/src/ui/widget/labelled.cpp index a62d1a470..0a13d6347 100644 --- a/src/ui/widget/labelled.cpp +++ b/src/ui/widget/labelled.cpp @@ -1,7 +1,4 @@ -/** - * Labelled Widget - Adds a label with optional icon or suffix to - * another widget. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -24,18 +21,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Labelled Widget. - * - * \param label Label. - * \param widget Widget to label; should be allocated with new, as it will - * be passed to Gtk::manage(). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the text - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Widget *widget, Glib::ustring const &suffix, @@ -60,9 +45,6 @@ Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, } -/** - * Allow the setting of the width of the labelled widget - */ void Labelled::setWidgetSizeRequest(int width, int height) { if (_widget) diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h index 9614dc28a..8c2ec8939 100644 --- a/src/ui/widget/labelled.h +++ b/src/ui/widget/labelled.h @@ -26,6 +26,19 @@ namespace Widget { class Labelled : public Gtk::HBox { public: + + /** + * Construct a Labelled Widget. + * + * @param label Label. + * @param widget Widget to label; should be allocated with new, as it will + * be passed to Gtk::manage(). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the text + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Widget *widget, Glib::ustring const &suffix = "", diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index c9550bb27..9cb904c9f 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -1,5 +1,4 @@ -/** \file - * +/* * Authors: * bulia byak <buliabyak@users.sf.net> * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp index eea8aefba..92bcb6937 100644 --- a/src/ui/widget/notebook-page.cpp +++ b/src/ui/widget/notebook-page.cpp @@ -1,4 +1,4 @@ -/** +/* * Notebook page widget. * * Author: @@ -19,12 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a NotebookPage - * - * \param label Label. - */ - NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, guint padding) :_table(n_rows, n_columns) { diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index bd53870d6..a541f3ba0 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -24,7 +24,12 @@ namespace Widget { class NotebookPage : public Gtk::VBox { public: + NotebookPage(); + + /** + * Construct a NotebookPage. + */ NotebookPage(int n_rows, int n_columns, bool expand=false, bool fill=false, guint padding=0); Gtk::Table& table() { return _table; } diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 67f3789c7..a6b0fb76d 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -1,7 +1,9 @@ -/** \file +/** + * @file * * Paper-size widget and helper functions - * + */ +/* * Authors: * bulia byak <buliabyak@users.sf.net> * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index aaa8e2a70..8c8603640 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -1,6 +1,4 @@ -/** - * Panel widget. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Jon A. Cruz <jon@joncruz.org> @@ -54,10 +52,6 @@ void Panel::prep() { eek_preview_set_size_mappings( G_N_ELEMENTS(sizes), sizes ); } -/** - * Construct a Panel - */ - Panel::Panel(Glib::ustring const &label, gchar const *prefs_path, int verb_num, Glib::ustring const &apply_label, bool menu_desired) : diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 3134111c0..d51d942dd 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -41,11 +41,15 @@ class Panel : public Gtk::VBox { public: static void prep(); - virtual ~Panel(); + /** + * Construct a Panel. + */ Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0, int verb_num = 0, Glib::ustring const &apply_label = "", bool menu_desired = false); + virtual ~Panel(); + gchar const *getPrefsPath() const; void setLabel(Glib::ustring const &label); Glib::ustring const &getLabel() const; diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index 7a4b4459a..385b60122 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -1,7 +1,4 @@ -/** - * Point Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary coordinate values. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * Carl Hetherington <inkscape@carlh.net> @@ -28,16 +25,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Point Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -51,17 +38,6 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, static_cast<Gtk::VBox*>(_widget)->show_all_children(); } -/** - * Construct a Point Widget. - * - * \param label Label. - * \param digits Number of decimal digits to display. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix, @@ -76,18 +52,6 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, static_cast<Gtk::VBox*>(_widget)->show_all_children(); } -/** - * Construct a Point Widget. - * - * \param label Label. - * \param adjust Adjustment to use for the SpinButton. - * \param digits Number of decimal digits to display (defaults to 0). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, unsigned digits, @@ -103,131 +67,105 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, static_cast<Gtk::VBox*>(_widget)->show_all_children(); } -/** Fetches the precision of the spin buton */ -unsigned -Point::getDigits() const +unsigned Point::getDigits() const { return xwidget.getDigits(); } -/** Gets the current step ingrement used by the spin button */ -double -Point::getStep() const +double Point::getStep() const { return xwidget.getStep(); } -/** Gets the current page increment used by the spin button */ -double -Point::getPage() const +double Point::getPage() const { return xwidget.getPage(); } -/** Gets the minimum range value allowed for the spin button */ -double -Point::getRangeMin() const +double Point::getRangeMin() const { return xwidget.getRangeMin(); } -/** Gets the maximum range value allowed for the spin button */ -double -Point::getRangeMax() const +double Point::getRangeMax() const { return xwidget.getRangeMax(); } -/** Get the value in the spin_button . */ -double -Point::getXValue() const +double Point::getXValue() const { return xwidget.getValue(); } -double -Point::getYValue() const + +double Point::getYValue() const { return ywidget.getValue(); } -Geom::Point -Point::getValue() const + +Geom::Point Point::getValue() const { return Geom::Point( getXValue() , getYValue() ); } -/** Get the value spin_button represented as an integer. */ -int -Point::getXValueAsInt() const +int Point::getXValueAsInt() const { return xwidget.getValueAsInt(); } -int -Point::getYValueAsInt() const + +int Point::getYValueAsInt() const { return ywidget.getValueAsInt(); } -/** Sets the precision to be displayed by the spin button */ -void -Point::setDigits(unsigned digits) +void Point::setDigits(unsigned digits) { xwidget.setDigits(digits); ywidget.setDigits(digits); } -/** Sets the step and page increments for the spin button */ -void -Point::setIncrements(double step, double page) +void Point::setIncrements(double step, double page) { xwidget.setIncrements(step, page); ywidget.setIncrements(step, page); } -/** Sets the minimum and maximum range allowed for the spin button */ -void -Point::setRange(double min, double max) +void Point::setRange(double min, double max) { xwidget.setRange(min, max); ywidget.setRange(min, max); } -/** Sets the value of the spin button */ -void -Point::setValue(Geom::Point const & p) +void Point::setValue(Geom::Point const & p) { xwidget.setValue(p[0]); ywidget.setValue(p[1]); } -/** Manually forces an update of the spin button */ -void -Point::update() { +void Point::update() +{ xwidget.update(); ywidget.update(); } -/** Check 'setProgrammatically' of both scalar widgets. False if value is changed by user by clicking the widget. */ -bool -Point::setProgrammatically() { +bool Point::setProgrammatically() +{ return (xwidget.setProgrammatically || ywidget.setProgrammatically); } -void -Point::clearProgrammatically() { +void Point::clearProgrammatically() +{ xwidget.setProgrammatically = false; ywidget.setProgrammatically = false; } -/** Signal raised when the spin button's value changes */ -Glib::SignalProxy0<void> -Point::signal_x_value_changed() +Glib::SignalProxy0<void> Point::signal_x_value_changed() { return xwidget.signal_value_changed(); } -Glib::SignalProxy0<void> -Point::signal_y_value_changed() + +Glib::SignalProxy0<void> Point::signal_y_value_changed() { return ywidget.signal_value_changed(); } diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index 651c8c8fb..ced43c47a 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -30,17 +30,54 @@ namespace Widget { class Point : public Labelled { public: + + + /** + * Construct a Point Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Point Widget. + * + * @param label Label. + * @param digits Number of decimal digits to display. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Point Widget. + * + * @param label Label. + * @param adjust Adjustment to use for the SpinButton. + * @param digits Number of decimal digits to display (defaults to 0). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, @@ -49,35 +86,93 @@ public: Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Fetches the precision of the spin buton. + */ unsigned getDigits() const; + + /** + * Gets the current step ingrement used by the spin button. + */ double getStep() const; + + /** + * Gets the current page increment used by the spin button. + */ double getPage() const; + + /** + * Gets the minimum range value allowed for the spin button. + */ double getRangeMin() const; + + /** + * Gets the maximum range value allowed for the spin button. + */ double getRangeMax() const; + bool getSnapToTicks() const; + + /** + * Get the value in the spin_button. + */ double getXValue() const; + double getYValue() const; + Geom::Point getValue() const; + + /** + * Get the value spin_button represented as an integer. + */ int getXValueAsInt() const; + int getYValueAsInt() const; + /** + * Sets the precision to be displayed by the spin button. + */ void setDigits(unsigned digits); + + /** + * Sets the step and page increments for the spin button. + */ void setIncrements(double step, double page); + + /** + * Sets the minimum and maximum range allowed for the spin button. + */ void setRange(double min, double max); + + /** + * Sets the value of the spin button. + */ void setValue(Geom::Point const & p); + /** + * Manually forces an update of the spin button. + */ void update(); + /** + * Signal raised when the spin button's value changes. + */ Glib::SignalProxy0<void> signal_x_value_changed(); + Glib::SignalProxy0<void> signal_y_value_changed(); - bool setProgrammatically(); // true if the value was set by setValue, not changed by the user; - // if a callback checks it, it must reset it back to false + /** + * Check 'setProgrammatically' of both scalar widgets. False if value is changed by user by clicking the widget. + * true if the value was set by setValue, not changed by the user; + * if a callback checks it, it must reset it back to false. + */ + bool setProgrammatically(); + void clearProgrammatically(); protected: - Scalar xwidget, ywidget; - + Scalar xwidget; + Scalar ywidget; }; } // namespace Widget diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index b88123ab1..001d2277d 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -1,4 +1,4 @@ -/** +/* * Inkscape Preferences dialog. * * Authors: @@ -583,10 +583,6 @@ void PrefCombo::init(Glib::ustring const &prefs_path, this->set_active(row); } -/** - initialize a combo box - second form uses strings as key values -*/ void PrefCombo::init(Glib::ustring const &prefs_path, Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value) { diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 83290a045..ea5c377a3 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -164,6 +164,11 @@ class PrefCombo : public Gtk::ComboBoxText public: void init(Glib::ustring const &prefs_path, Glib::ustring labels[], int values[], int num_items, int default_value); + + /** + * Initialize a combo box. + * second form uses strings as key values. + */ void init(Glib::ustring const &prefs_path, Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value); protected: diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index e2fb30812..03cea7d5a 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -1,10 +1,4 @@ -/** - * Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. It adds an extra - * number called "startseed", that is not UI edittable, but should be put in SVG. - * This does NOT generate a random number, but provides merely the saving of - * the startseed value. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -31,16 +25,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Random scalar Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -51,17 +35,6 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, addReseedButton(); } -/** - * Construct a Random Scalar Widget. - * - * \param label Label. - * \param digits Number of decimal digits to display. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix, @@ -73,18 +46,6 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, addReseedButton(); } -/** - * Construct a Random Scalar Widget. - * - * \param label Label. - * \param adjust Adjustment to use for the SpinButton. - * \param digits Number of decimal digits to display (defaults to 0). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, unsigned digits, @@ -97,23 +58,17 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, addReseedButton(); } -/** Gets the startseed */ -long -Random::getStartSeed() const +long Random::getStartSeed() const { return startseed; } -/** Sets the startseed number */ -void -Random::setStartSeed(long newseed) +void Random::setStartSeed(long newseed) { startseed = newseed; } -/** Add reseed button to the widget */ -void -Random::addReseedButton() +void Random::addReseedButton() { Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "randomize", Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h index 33f416e3f..cb8c223dc 100644 --- a/src/ui/widget/random.h +++ b/src/ui/widget/random.h @@ -17,23 +17,62 @@ namespace UI { namespace Widget { /** - * A labelled text box, with spin buttons and optional icon or suffix, for - * entering arbitrary number values and generating a random number from it. + * A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary number values. It adds an extra + * number called "startseed", that is not UI edittable, but should be put in SVG. + * This does NOT generate a random number, but provides merely the saving of + * the startseed value. */ class Random : public Scalar { public: + + /** + * Construct a Random scalar Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Random Scalar Widget. + * + * @param label Label. + * @param digits Number of decimal digits to display. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Random Scalar Widget. + * + * @param label Label. + * @param adjust Adjustment to use for the SpinButton. + * @param digits Number of decimal digits to display (defaults to 0). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, @@ -42,7 +81,14 @@ public: Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Gets the startseed. + */ long getStartSeed() const; + + /** + * Sets the startseed number. + */ void setStartSeed(long newseed); sigc::signal <void> signal_reseeded; @@ -51,7 +97,12 @@ protected: long startseed; private: + + /** + * Add reseed button to the widget. + */ void addReseedButton(); + void onReseedButtonClick(); }; diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 3f060f740..f923a7c9c 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -1,6 +1,4 @@ -/** \file - * - * +/* * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * bulia byak <buliabyak@users.sf.net> @@ -632,13 +630,7 @@ RegisteredVector::setValue(Geom::Point const & p, Geom::Point const & origin) _origin = origin; } -/** - * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector. - * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length. - * After changing the coords type (polar/non-polar), the value has to be reset (setValue). - */ -void -RegisteredVector::setPolarCoords(bool polar_coords) +void RegisteredVector::setPolarCoords(bool polar_coords) { _polar_coords = polar_coords; if (polar_coords) { diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index a948e1535..df2377464 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -345,6 +345,12 @@ public: // redefine setValue, because transform must be applied void setValue(Geom::Point const & p); void setValue(Geom::Point const & p, Geom::Point const & origin); + + /** + * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector. + * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length. + * After changing the coords type (polar/non-polar), the value has to be reset (setValue). + */ void setPolarCoords(bool polar_coords = true); protected: diff --git a/src/ui/widget/registry.cpp b/src/ui/widget/registry.cpp index aa92e6ecb..725e52791 100644 --- a/src/ui/widget/registry.cpp +++ b/src/ui/widget/registry.cpp @@ -1,6 +1,4 @@ -/** \file - * - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp index 1ceaa784e..bbc0a0039 100644 --- a/src/ui/widget/rendering-options.cpp +++ b/src/ui/widget/rendering-options.cpp @@ -1,6 +1,4 @@ -/** - * Rendering options widget. - * +/* * Author: * Kees Cook <kees@outflux.net> * @@ -23,17 +21,11 @@ namespace Inkscape { namespace UI { namespace Widget { -void -RenderingOptions::_toggled() +void RenderingOptions::_toggled() { _frame_bitmap.set_sensitive(as_bitmap()); } -/** - * Construct a Rendering Options widget - * - */ - RenderingOptions::RenderingOptions () : Gtk::VBox (), _frame_backends ( Glib::ustring(_("Backend")) ), diff --git a/src/ui/widget/rendering-options.h b/src/ui/widget/rendering-options.h index 3e2e046d3..241683fe6 100644 --- a/src/ui/widget/rendering-options.h +++ b/src/ui/widget/rendering-options.h @@ -24,6 +24,10 @@ namespace Widget { class RenderingOptions : public Gtk::VBox { public: + + /** + * Construct a Rendering Options widget. + */ RenderingOptions(); bool as_bitmap(); // should we render as a bitmap? diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 6a65d6ab3..c31e6f529 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -1,6 +1,4 @@ -/** - * widget adjustable by dragging it to rotate away from a zero-change axis. - * +/* * Authors: * buliabyak@gmail.com * diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 47e9b23b2..99ff70846 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -1,17 +1,4 @@ -/** - * Scalar Unit Widget - A labelled text box, with spin buttons and - * optional icon or suffix, for entering the values of various unit - * types. - * - * A ScalarUnit is a control for entering, viewing, or manipulating - * numbers with units. This differs from ordinary numbers like 2 or - * 3.14 because the number portion of a scalar *only* has meaning - * when considered with its unit type. For instance, 12 m and 12 in - * have very different actual values, but 1 m and 100 cm have the same - * value. The ScalarUnit allows us to abstract the presentation of - * the scalar to the user from the internal representations used by - * the program. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Derek P. Moore <derekm@hackunix.org> @@ -33,19 +20,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a ScalarUnit - * - * \param label Label. - * \param unit_type Unit type (defaults to UNIT_TYPE_LINEAR). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param unit_menu UnitMenu drop down; if not specified, one will be created - * and displayed after the widget (defaults to NULL). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, UnitType unit_type, Glib::ustring const &suffix, @@ -72,18 +46,6 @@ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, lastUnits = _unit_menu->getUnitAbbr(); } -/** - * Construct a ScalarUnit - * - * \param label Label. - * \param tooltip Tooltip text. - * \param take_unitmenu Use the unitmenu from this parameter. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, ScalarUnit &take_unitmenu, Glib::ustring const &suffix, @@ -104,12 +66,7 @@ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, } -/** - * Initializes the scalar based on the settings in _unit_menu. - * Requires that _unit_menu has already been initialized. - */ -void -ScalarUnit::initScalar(double min_value, double max_value) +void ScalarUnit::initScalar(double min_value, double max_value) { g_assert(_unit_menu != NULL); Scalar::setDigits(_unit_menu->getDefaultDigits()); @@ -118,9 +75,8 @@ ScalarUnit::initScalar(double min_value, double max_value) Scalar::setRange(min_value, max_value); } -/** Sets the unit for the ScalarUnit widget */ -bool -ScalarUnit::setUnit(Glib::ustring const &unit) { +bool ScalarUnit::setUnit(Glib::ustring const &unit) +{ g_assert(_unit_menu != NULL); // First set the unit if (!_unit_menu->setUnit(unit)) { @@ -130,47 +86,41 @@ ScalarUnit::setUnit(Glib::ustring const &unit) { return true; } -/** Adds the unit type to the ScalarUnit widget */ -void -ScalarUnit::setUnitType(UnitType unit_type) { +void ScalarUnit::setUnitType(UnitType unit_type) +{ g_assert(_unit_menu != NULL); _unit_menu->setUnitType(unit_type); lastUnits = _unit_menu->getUnitAbbr(); } -/** Resets the unit type for the ScalarUnit widget */ -void -ScalarUnit::resetUnitType(UnitType unit_type) { +void ScalarUnit::resetUnitType(UnitType unit_type) +{ g_assert(_unit_menu != NULL); _unit_menu->resetUnitType(unit_type); lastUnits = _unit_menu->getUnitAbbr(); } -/** Gets the object for the currently selected unit */ -Unit -ScalarUnit::getUnit() const { +Unit ScalarUnit::getUnit() const +{ g_assert(_unit_menu != NULL); return _unit_menu->getUnit(); } -/** Gets the UnitType ID for the unit */ -UnitType -ScalarUnit::getUnitType() const { +UnitType ScalarUnit::getUnitType() const +{ g_assert(_unit_menu); return _unit_menu->getUnitType(); } -/** Sets the number and unit system */ -void -ScalarUnit::setValue(double number, Glib::ustring const &units) { +void ScalarUnit::setValue(double number, Glib::ustring const &units) +{ g_assert(_unit_menu != NULL); _unit_menu->setUnit(units); Scalar::setValue(number); } -/** Convert and sets the number only and keeps the current unit. */ -void -ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) { +void ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) +{ g_assert(_unit_menu != NULL); if (units == "") { // set the value in the default units @@ -181,15 +131,13 @@ ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) { } } -/** Sets the number only */ -void -ScalarUnit::setValue(double number) { +void ScalarUnit::setValue(double number) +{ Scalar::setValue(number); } -/** Returns the value in the given unit system */ -double -ScalarUnit::getValue(Glib::ustring const &unit_name) const { +double ScalarUnit::getValue(Glib::ustring const &unit_name) const +{ g_assert(_unit_menu != NULL); if (unit_name == "") { // Return the value in the default units @@ -200,36 +148,29 @@ ScalarUnit::getValue(Glib::ustring const &unit_name) const { } } -/** Grab focus, and select the text that is in the entry field. - */ -void -ScalarUnit::grabFocusAndSelectEntry() { +void ScalarUnit::grabFocusAndSelectEntry() +{ _widget->grab_focus(); static_cast<SpinButton*>(_widget)->select_region(0, 20); } -void -ScalarUnit::setHundredPercent(double number) +void ScalarUnit::setHundredPercent(double number) { _hundred_percent = number; } -void -ScalarUnit::setAbsoluteIsIncrement(bool value) +void ScalarUnit::setAbsoluteIsIncrement(bool value) { _absolute_is_increment = value; } -void -ScalarUnit::setPercentageIsIncrement(bool value) +void ScalarUnit::setPercentageIsIncrement(bool value) { _percentage_is_increment = value; } -/** Convert value from % to absolute, using _hundred_percent and *_is_increment flags */ -double -ScalarUnit::PercentageToAbsolute(double value) +double ScalarUnit::PercentageToAbsolute(double value) { // convert from percent to absolute double convertedVal = 0; @@ -243,9 +184,7 @@ ScalarUnit::PercentageToAbsolute(double value) return convertedVal; } -/** Convert value from absolute to %, using _hundred_percent and *_is_increment flags */ -double -ScalarUnit::AbsoluteToPercentage(double value) +double ScalarUnit::AbsoluteToPercentage(double value) { double convertedVal = 0; // convert from absolute to percent @@ -266,27 +205,21 @@ ScalarUnit::AbsoluteToPercentage(double value) return convertedVal; } -/** Assuming the current unit is absolute, get the corresponding % value */ -double -ScalarUnit::getAsPercentage() +double ScalarUnit::getAsPercentage() { double convertedVal = AbsoluteToPercentage(Scalar::getValue()); return convertedVal; } -/** Assuming the current unit is absolute, set the value corresponding to a given % */ -void -ScalarUnit::setFromPercentage(double value) +void ScalarUnit::setFromPercentage(double value) { double absolute = PercentageToAbsolute(value); Scalar::setValue(absolute); } -/** Signal handler for updating the value and suffix label when unit is changed */ -void -ScalarUnit::on_unit_changed() +void ScalarUnit::on_unit_changed() { g_assert(_unit_menu != NULL); diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index 05a7b95f8..4f22f438c 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -22,47 +22,142 @@ namespace Widget { /** * A labelled text box, with spin buttons and optional icon or suffix, for * entering the values of various unit types. + * + * A ScalarUnit is a control for entering, viewing, or manipulating + * numbers with units. This differs from ordinary numbers like 2 or + * 3.14 because the number portion of a scalar *only* has meaning + * when considered with its unit type. For instance, 12 m and 12 in + * have very different actual values, but 1 m and 100 cm have the same + * value. The ScalarUnit allows us to abstract the presentation of + * the scalar to the user from the internal representations used by + * the program. */ class ScalarUnit : public Scalar { public: + /** + * Construct a ScalarUnit. + * + * @param label Label. + * @param unit_type Unit type (defaults to UNIT_TYPE_LINEAR). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param unit_menu UnitMenu drop down; if not specified, one will be created + * and displayed after the widget (defaults to NULL). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, UnitType unit_type = UNIT_TYPE_LINEAR, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", UnitMenu *unit_menu = NULL, bool mnemonic = true); + + /** + * Construct a ScalarUnit. + * + * @param label Label. + * @param tooltip Tooltip text. + * @param take_unitmenu Use the unitmenu from this parameter. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, ScalarUnit &take_unitmenu, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Initializes the scalar based on the settings in _unit_menu. + * Requires that _unit_menu has already been initialized. + */ void initScalar(double min_value, double max_value); + /** + * Gets the object for the currently selected unit. + */ Unit getUnit() const; + + /** + * Gets the UnitType ID for the unit. + */ UnitType getUnitType() const; + + /** + * Returns the value in the given unit system. + */ double getValue(Glib::ustring const &units) const; + /** + * Sets the unit for the ScalarUnit widget. + */ bool setUnit(Glib::ustring const &units); + + /** + * Adds the unit type to the ScalarUnit widget. + */ void setUnitType(UnitType unit_type); + + /** + * Resets the unit type for the ScalarUnit widget. + */ void resetUnitType(UnitType unit_type); + + /** + * Sets the number and unit system. + */ void setValue(double number, Glib::ustring const &units); + + /** + * Convert and sets the number only and keeps the current unit. + */ void setValueKeepUnit(double number, Glib::ustring const &units); + + /** + * Sets the number only. + */ void setValue(double number); + /** + * Grab focus, and select the text that is in the entry field. + */ void grabFocusAndSelectEntry(); void setHundredPercent(double number); + void setAbsoluteIsIncrement(bool value); + void setPercentageIsIncrement(bool value); + /** + * Convert value from % to absolute, using _hundred_percent and *_is_increment flags. + */ double PercentageToAbsolute(double value); + + /** + * Convert value from absolute to %, using _hundred_percent and *_is_increment flags. + */ double AbsoluteToPercentage(double value); + /** + * Assuming the current unit is absolute, get the corresponding % value. + */ double getAsPercentage(); + + /** + * Assuming the current unit is absolute, set the value corresponding to a given %. + */ void setFromPercentage(double value); + /** + * Signal handler for updating the value and suffix label when unit is changed. + */ void on_unit_changed(); protected: diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 4237d9db9..220498561 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -1,7 +1,4 @@ -/** - * Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -24,16 +21,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Scalar Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -43,17 +30,6 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, { } -/** - * Construct a Scalar Widget. - * - * \param label Label. - * \param digits Number of decimal digits to display. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix, @@ -64,18 +40,6 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, { } -/** - * Construct a Scalar Widget. - * - * \param label Label. - * \param adjust Adjustment to use for the SpinButton. - * \param digits Number of decimal digits to display (defaults to 0). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, unsigned digits, @@ -87,17 +51,13 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, { } -/** Fetches the precision of the spin buton */ -unsigned -Scalar::getDigits() const +unsigned Scalar::getDigits() const { g_assert(_widget != NULL); return static_cast<SpinButton*>(_widget)->get_digits(); } -/** Gets the current step ingrement used by the spin button */ -double -Scalar::getStep() const +double Scalar::getStep() const { g_assert(_widget != NULL); double step, page; @@ -105,9 +65,7 @@ Scalar::getStep() const return step; } -/** Gets the current page increment used by the spin button */ -double -Scalar::getPage() const +double Scalar::getPage() const { g_assert(_widget != NULL); double step, page; @@ -115,9 +73,7 @@ Scalar::getPage() const return page; } -/** Gets the minimum range value allowed for the spin button */ -double -Scalar::getRangeMin() const +double Scalar::getRangeMin() const { g_assert(_widget != NULL); double min, max; @@ -125,9 +81,7 @@ Scalar::getRangeMin() const return min; } -/** Gets the maximum range value allowed for the spin button */ -double -Scalar::getRangeMax() const +double Scalar::getRangeMax() const { g_assert(_widget != NULL); double min, max; @@ -135,70 +89,53 @@ Scalar::getRangeMax() const return max; } -/** Get the value in the spin_button . */ -double -Scalar::getValue() const +double Scalar::getValue() const { g_assert(_widget != NULL); return static_cast<SpinButton*>(_widget)->get_value(); } -/** Get the value spin_button represented as an integer. */ -int -Scalar::getValueAsInt() const +int Scalar::getValueAsInt() const { g_assert(_widget != NULL); return static_cast<SpinButton*>(_widget)->get_value_as_int(); } -/** Sets the precision to be displayed by the spin button */ -void -Scalar::setDigits(unsigned digits) +void Scalar::setDigits(unsigned digits) { g_assert(_widget != NULL); static_cast<SpinButton*>(_widget)->set_digits(digits); } -/** Sets the step and page increments for the spin button - * @todo Remove the second parameter - deprecated - */ -void -Scalar::setIncrements(double step, double /*page*/) +void Scalar::setIncrements(double step, double /*page*/) { g_assert(_widget != NULL); static_cast<SpinButton*>(_widget)->set_increments(step, 0); } -/** Sets the minimum and maximum range allowed for the spin button */ -void -Scalar::setRange(double min, double max) +void Scalar::setRange(double min, double max) { g_assert(_widget != NULL); static_cast<SpinButton*>(_widget)->set_range(min, max); } -/** Sets the value of the spin button */ -void -Scalar::setValue(double value) +void Scalar::setValue(double value) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares static_cast<SpinButton*>(_widget)->set_value(value); } -/** Manually forces an update of the spin button */ -void -Scalar::update() { +void Scalar::update() +{ g_assert(_widget != NULL); static_cast<SpinButton*>(_widget)->update(); } -/** Signal raised when the spin button's value changes */ -Glib::SignalProxy0<void> -Scalar::signal_value_changed() +Glib::SignalProxy0<void> Scalar::signal_value_changed() { return static_cast<SpinButton*>(_widget)->signal_value_changed(); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 66bd07ddb..c73bcc62a 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -25,17 +25,52 @@ namespace Widget { class Scalar : public Labelled { public: + /** + * Construct a Scalar Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Scalar Widget. + * + * @param label Label. + * @param digits Number of decimal digits to display. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Scalar Widget. + * + * @param label Label. + * @param adjust Adjustment to use for the SpinButton. + * @param digits Number of decimal digits to display (defaults to 0). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, @@ -44,26 +79,79 @@ public: Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Fetches the precision of the spin buton. + */ unsigned getDigits() const; + + /** + * Gets the current step ingrement used by the spin button. + */ double getStep() const; + + /** + * Gets the current page increment used by the spin button. + */ double getPage() const; + + /** + * Gets the minimum range value allowed for the spin button. + */ double getRangeMin() const; + + /** + * Gets the maximum range value allowed for the spin button. + */ double getRangeMax() const; + bool getSnapToTicks() const; + + /** + * Get the value in the spin_button. + */ double getValue() const; + + /** + * Get the value spin_button represented as an integer. + */ int getValueAsInt() const; + /** + * Sets the precision to be displayed by the spin button. + */ void setDigits(unsigned digits); + + /** + * Sets the step and page increments for the spin button. + * @todo Remove the second parameter - deprecated + */ void setIncrements(double step, double page); + + /** + * Sets the minimum and maximum range allowed for the spin button. + */ void setRange(double min, double max); + + /** + * Sets the value of the spin button. + */ void setValue(double value); + /** + * Manually forces an update of the spin button. + */ void update(); + /** + * Signal raised when the spin button's value changes. + */ Glib::SignalProxy0<void> signal_value_changed(); - bool setProgrammatically; // true if the value was set by setValue, not changed by the user; - // if a callback checks it, it must reset it back to false + /** + * true if the value was set by setValue, not changed by the user; + * if a callback checks it, it must reset it back to false. + */ + bool setProgrammatically; }; } // namespace Widget diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 51c3af4dd..b6722f4cf 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1,6 +1,4 @@ -/** - * Selected style indicator (fill, stroke, opacity). - * +/* * Author: * buliabyak@gmail.com * Abhishek Sharma diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 4a3b0dd77..da2db991e 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -1,6 +1,4 @@ -/** - * Groups an HScale and a SpinButton together using the same Adjustment. - * +/* * Author: * Nicholas Bishop <nicholasbishop@gmail.com> * Felipe C. da S. Sanches <juca@members.fsf.org> diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 78b00bebc..60b7856f6 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -1,6 +1,3 @@ -/** - * SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. - */ /* * Author: * Johan B. C. Engelen @@ -32,15 +29,7 @@ SpinButton::connect_signals() { signal_key_press_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_key_press_event)); }; -/** - * This callback function should try to convert the entered text to a number and write it to newvalue. - * It calls a method to evaluate the (potential) mathematical expression. - * - * @retval false No conversion done, continue with default handler. - * @retval true Conversion successful, don't call default handler. - */ -int -SpinButton::on_input(double* newvalue) +int SpinButton::on_input(double* newvalue) { try { Inkscape::Util::GimpEevlQuantity result; @@ -66,23 +55,13 @@ SpinButton::on_input(double* newvalue) return true; } -/** When focus is obtained, save the value to enable undo later. - * @retval false continue with default handler. - * @retval true don't call default handler. -*/ -bool -SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) +bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) { on_focus_in_value = get_value(); return false; // do not consume the event } -/** Handle specific keypress events, like Ctrl+Z - * @retval false continue with default handler. - * @retval true don't call default handler. -*/ -bool -SpinButton::on_my_key_press_event(GdkEventKey* event) +bool SpinButton::on_my_key_press_event(GdkEventKey* event) { switch (get_group0_keyval (event)) { case GDK_Escape: @@ -103,11 +82,7 @@ SpinButton::on_my_key_press_event(GdkEventKey* event) return false; // do not consume the event } -/** - * Undo the editing, by resetting the value upon when the spinbutton got focus. - */ -void -SpinButton::undo() +void SpinButton::undo() { set_value(on_focus_in_value); } diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index df913553d..b7764d979 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -1,6 +1,3 @@ -/** - * \brief SpinButton widget, that allows entry of both '.' and ',' for the decimal, even when in numeric mode. - */ /* * Author: * Johan B. C. Engelen @@ -22,7 +19,8 @@ namespace Widget { class UnitMenu; /** - * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu). + * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), + * and allows entry of both '.' and ',' for the decimal, even when in numeric mode. * * Calling "set_numeric()" effectively disables the expression parsing. If no unit menu is linked, all unitlike characters are ignored. */ @@ -50,10 +48,35 @@ protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. void connect_signals(); - int on_input(double* newvalue); - bool on_my_focus_in_event(GdkEventFocus* event); - bool on_my_key_press_event(GdkEventKey* event); - void undo(); + + /** + * This callback function should try to convert the entered text to a number and write it to newvalue. + * It calls a method to evaluate the (potential) mathematical expression. + * + * @retval false No conversion done, continue with default handler. + * @retval true Conversion successful, don't call default handler. + */ + int on_input(double* newvalue); + + /** + * When focus is obtained, save the value to enable undo later. + * @retval false continue with default handler. + * @retval true don't call default handler. + */ + bool on_my_focus_in_event(GdkEventFocus* event); + + /** + * Handle specific keypress events, like Ctrl+Z. + * + * @retval false continue with default handler. + * @retval true don't call default handler. + */ + bool on_my_key_press_event(GdkEventKey* event); + + /** + * Undo the editing, by resetting the value upon when the spinbutton got focus. + */ + void undo(); double on_focus_in_value; diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 4a1b83175..d9bf7e2aa 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -1,6 +1,4 @@ -/** - * Abstraction for different style widget operands. - * +/* * Copyright (C) 2007 MenTaLguY <mental@rydia.net> * Abhishek Sharma * diff --git a/src/ui/widget/svg-canvas.cpp b/src/ui/widget/svg-canvas.cpp index f0eb24a10..d3d9f70f2 100644 --- a/src/ui/widget/svg-canvas.cpp +++ b/src/ui/widget/svg-canvas.cpp @@ -1,6 +1,4 @@ -/** \file - * Gtkmm facade/wrapper around SPCanvas. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp index a5540e428..b79bea067 100644 --- a/src/ui/widget/text.cpp +++ b/src/ui/widget/text.cpp @@ -1,7 +1,4 @@ -/** - * Text Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Maximilian Albert <maximilian.albert@gmail.com> @@ -22,16 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Text Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -41,26 +28,20 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, { } -/** Get the text in the entry */ -const char * -Text::getText() const +const char *Text::getText() const { g_assert(_widget != NULL); return static_cast<Gtk::Entry*>(_widget)->get_text().c_str(); } -/** Sets the text of the text entry */ -void -Text::setText(const char* text) +void Text::setText(const char* text) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares static_cast<Gtk::Entry*>(_widget)->set_text(text); // FIXME: set correctly } -/** Signal raised when the spin button's value changes */ -Glib::SignalProxy0<void> -Text::signal_activate() +Glib::SignalProxy0<void> Text::signal_activate() { return static_cast<Gtk::Entry*>(_widget)->signal_activate(); } diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h index bccaefa2e..0f6efd01f 100644 --- a/src/ui/widget/text.h +++ b/src/ui/widget/text.h @@ -26,18 +26,38 @@ namespace Widget { class Text : public Labelled { public: + + /** + * Construct a Text Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Text(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Get the text in the entry. + */ const char* getText() const; + /** + * Sets the text of the text entry. + */ void setText(const char* text); void update(); + /** + * Signal raised when the spin button's value changes. + */ Glib::SignalProxy0<void> signal_activate(); bool setProgrammatically; // true if the value was set by setValue, not changed by the user; diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 51e0a262f..40f58f0ae 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -1,7 +1,4 @@ -/** \file - * - Implementation of tolerance slider widget. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Abhishek Sharma diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index 22c04d361..0a9663bc3 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -1,8 +1,3 @@ -/** \file - * \brief - * - * This widget is part of the Document properties dialog. - */ /* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> @@ -27,6 +22,10 @@ namespace Widget { class Registry; +/** + * Implementation of tolerance slider widget. + * This widget is part of the Document properties dialog. + */ class ToleranceSlider { public: ToleranceSlider(); diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp index 41a13f4e9..99891fc44 100644 --- a/src/ui/widget/toolbox.cpp +++ b/src/ui/widget/toolbox.cpp @@ -1,6 +1,4 @@ -/** - * Toolbox Widget - A detachable toolbar for buttons and other widgets. - * +/* * Author: * Derek P. Moore <derekm@hackunix.org> * diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index bb0b65576..085783481 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -1,6 +1,4 @@ -/** - * Unit Menu Widget - A drop down menu for choosing unit types. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -21,10 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a UnitMenu - * - */ UnitMenu::UnitMenu() : _type(UNIT_TYPE_NONE) { set_active(0); @@ -33,14 +27,9 @@ UnitMenu::UnitMenu() : _type(UNIT_TYPE_NONE) UnitMenu::~UnitMenu() { } -/** Adds the unit type to the widget. This extracts the corresponding - units from the unit map matching the given type, and appends them - to the dropdown widget. It causes the primary unit for the given - unit_type to be selected. */ -bool -UnitMenu::setUnitType(UnitType unit_type) +bool UnitMenu::setUnitType(UnitType unit_type) { - /* Expand the unit widget with unit entries from the unit table */ + // Expand the unit widget with unit entries from the unit table UnitTable::UnitMap m = _unit_table.units(unit_type); UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { @@ -54,31 +43,21 @@ UnitMenu::setUnitType(UnitType unit_type) return true; } -/** Removes all unit entries, then adds the unit type to the widget. - This extracts the corresponding - units from the unit map matching the given type, and appends them - to the dropdown widget. It causes the primary unit for the given - unit_type to be selected. */ -bool -UnitMenu::resetUnitType(UnitType unit_type) +bool UnitMenu::resetUnitType(UnitType unit_type) { clear_text(); return setUnitType(unit_type); } -/** Adds a unit, possibly user-defined, to the menu. */ -void -UnitMenu::addUnit(Unit const& u) +void UnitMenu::addUnit(Unit const& u) { _unit_table.addUnit(u, false); append_text(u.abbr); } -/** Returns the Unit object corresponding to the current selection - in the dropdown widget */ -Unit -UnitMenu::getUnit() const { +Unit UnitMenu::getUnit() const +{ if (get_active_text() == "") { g_assert(_type != UNIT_TYPE_NONE); return _unit_table.getUnit(_unit_table.primary(_type)); @@ -86,11 +65,8 @@ UnitMenu::getUnit() const { return _unit_table.getUnit(get_active_text()); } -/** Sets the dropdown widget to the given unit abbreviation. - Returns true if the unit was selectable, false if not - (i.e., if the unit was not present in the widget) */ -bool -UnitMenu::setUnit(Glib::ustring const & unit) { +bool UnitMenu::setUnit(Glib::ustring const & unit) +{ // TODO: Determine if 'unit' is available in the dropdown. // If not, return false @@ -98,63 +74,41 @@ UnitMenu::setUnit(Glib::ustring const & unit) { return true; } -/** Returns the abbreviated unit name of the selected unit */ -Glib::ustring -UnitMenu::getUnitAbbr() const { +Glib::ustring UnitMenu::getUnitAbbr() const +{ if (get_active_text() == "") { return ""; } return getUnit().abbr; } -/** Returns the UnitType of the selected unit */ -UnitType -UnitMenu::getUnitType() const { +UnitType UnitMenu::getUnitType() const +{ return getUnit().type; } -/** Returns the unit factor for the selected unit */ -double -UnitMenu::getUnitFactor() const +double UnitMenu::getUnitFactor() const { return getUnit().factor; } -/** Returns the recommended number of digits for displaying - * numbers of this unit type. - */ -int -UnitMenu::getDefaultDigits() const +int UnitMenu::getDefaultDigits() const { return getUnit().defaultDigits(); } -/** Returns the recommended step size in spin buttons - * displaying units of this type - */ -double -UnitMenu::getDefaultStep() const +double UnitMenu::getDefaultStep() const { int factor_digits = -1*int(log10(getUnit().factor)); return pow(10.0, factor_digits); } -/** Returns the recommended page size (when hitting pgup/pgdn) - * in spin buttons displaying units of this type - */ -double -UnitMenu::getDefaultPage() const +double UnitMenu::getDefaultPage() const { return 10 * getDefaultStep(); } -/** - * Returns the conversion factor required to convert values - * of the currently selected unit into units of type - * new_unit_abbr. - */ -double -UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr) const +double UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr) const { double old_factor = getUnit().factor; if (old_unit_abbr != "no_unit") @@ -171,18 +125,13 @@ UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const return old_factor / new_unit.factor; } -/** Returns true if the selected unit is not dimensionless - * (false for %, true for px, pt, cm, etc) - */ -bool -UnitMenu::isAbsolute() const { +bool UnitMenu::isAbsolute() const +{ return getUnitType() != UNIT_TYPE_DIMENSIONLESS; } -/** Returns true if the selected unit is radial (deg or rad) - */ -bool -UnitMenu::isRadial() const { +bool UnitMenu::isRadial() const +{ return getUnitType() == UNIT_TYPE_RADIAL; } diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index cb11bbb30..61e93bd65 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -25,27 +25,98 @@ namespace Widget { class UnitMenu : public ComboText { public: + + /** + * Construct a UnitMenu + */ UnitMenu(); + virtual ~UnitMenu(); + /** + * Adds the unit type to the widget. This extracts the corresponding + * units from the unit map matching the given type, and appends them + * to the dropdown widget. It causes the primary unit for the given + * unit_type to be selected. + */ bool setUnitType(UnitType unit_type); + + /** + * Removes all unit entries, then adds the unit type to the widget. + * This extracts the corresponding + * units from the unit map matching the given type, and appends them + * to the dropdown widget. It causes the primary unit for the given + * unit_type to be selected. + */ bool resetUnitType(UnitType unit_type); + + /** + * Adds a unit, possibly user-defined, to the menu. + */ void addUnit(Unit const& u); + /** + * Sets the dropdown widget to the given unit abbreviation. + * Returns true if the unit was selectable, false if not + * (i.e., if the unit was not present in the widget). + */ bool setUnit(Glib::ustring const &unit); + /** + * Returns the Unit object corresponding to the current selection + * in the dropdown widget. + */ Unit getUnit() const; + + /** + * Returns the abbreviated unit name of the selected unit. + */ Glib::ustring getUnitAbbr() const; + + /** + * Returns the UnitType of the selected unit. + */ UnitType getUnitType() const; + + /** + * Returns the unit factor for the selected unit. + */ double getUnitFactor() const; + /** + * Returns the recommended number of digits for displaying + * numbers of this unit type. + */ int getDefaultDigits() const; + + /** + * Returns the recommended step size in spin buttons + * displaying units of this type. + */ double getDefaultStep() const; + + /** + * Returns the recommended page size (when hitting pgup/pgdn) + * in spin buttons displaying units of this type. + */ double getDefaultPage() const; + /** + * Returns the conversion factor required to convert values + * of the currently selected unit into units of type + * new_unit_abbr. + */ double getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr = "no_unit") const; + /** + * Returns true if the selected unit is not dimensionless + * (false for %, true for px, pt, cm, etc). + */ bool isAbsolute() const; + + /** + * Returns true if the selected unit is radial (deg or rad). + */ bool isRadial() const; UnitTable &getUnitTable() {return _unit_table;} diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp index c6d6f19a3..fa8191671 100644 --- a/src/ui/widget/zoom-status.cpp +++ b/src/ui/widget/zoom-status.cpp @@ -1,7 +1,4 @@ -/** \file - * Gtkmm facade/wrapper around zoom_status code that formerly lived - * in desktop-widget.cpp - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Lauris Kaplinski <lauris@kaplinski.com> diff --git a/src/uri.cpp b/src/uri.cpp index a5aec6f2d..de6a454ec 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -1,7 +1,4 @@ -/** - * \file - * Classes for representing and manipulating URIs as per RFC 2396. - * +/* * Authors: * MenTaLguY <mental@rydia.net> * Jon A. Cruz <jon@joncruz.org> @@ -17,19 +14,11 @@ namespace Inkscape { -/** - * Copy constructor. - */ URI::URI(const URI &uri) { uri._impl->reference(); _impl = uri._impl; } -/** - * Constructor from a C-style ASCII string. - * - * @param preformed Properly quoted C-style string to be represented. - */ URI::URI(gchar const *preformed) throw(BadURIException) { xmlURIPtr uri; if (!preformed) { @@ -42,17 +31,10 @@ URI::URI(gchar const *preformed) throw(BadURIException) { _impl = Impl::create(uri); } - -/** - * Destructor. - */ URI::~URI() { _impl->unreference(); } -/** - * Assignment operator. - */ URI &URI::operator=(URI const &uri) { // No check for self-assignment needed, as _impl refcounting increments first. uri._impl->reference(); @@ -85,35 +67,15 @@ void URI::Impl::unreference() { } } -/** - * Determines if the URI represented is an 'opaque' URI. - * - * @return \c true if the URI is opaque, \c false if hierarchial. - */ bool URI::Impl::isOpaque() const { bool opq = !isRelative() && (getOpaque() != NULL); return opq; } -/** - * Determines if the URI represented is 'relative' as per RFC 2396. - * - * Relative URI references are distinguished by not begining with a - * scheme name. - * - * @return \c true if the URI is relative, \c false if it is absolute. - */ bool URI::Impl::isRelative() const { return !_uri->scheme; } -/** - * Determines if the relative URI represented is a 'net-path' as per RFC 2396. - * - * A net-path is one that starts with "\\". - * - * @return \c true if the URI is relative and a net-path, \c false otherwise. - */ bool URI::Impl::isNetPath() const { bool isNet = false; if ( isRelative() ) @@ -124,13 +86,6 @@ bool URI::Impl::isNetPath() const { return isNet; } -/** - * Determines if the relative URI represented is a 'relative-path' as per RFC 2396. - * - * A relative-path is one that starts with no slashes. - * - * @return \c true if the URI is relative and a relative-path, \c false otherwise. - */ bool URI::Impl::isRelativePath() const { bool isRel = false; if ( isRelative() ) @@ -141,13 +96,6 @@ bool URI::Impl::isRelativePath() const { return isRel; } -/** - * Determines if the relative URI represented is a 'absolute-path' as per RFC 2396. - * - * An absolute-path is one that starts with a single "\". - * - * @return \c true if the URI is relative and an absolute-path, \c false otherwise. - */ bool URI::Impl::isAbsolutePath() const { bool isAbs = false; if ( isRelative() ) @@ -243,13 +191,6 @@ URI URI::from_native_filename(gchar const *path) throw(BadURIException) { return result; } -/** - * Returns a glib string version of this URI. - * - * The returned string must be freed with \c g_free(). - * - * @return a glib string version of this URI. - */ gchar *URI::Impl::toString() const { xmlChar *string = xmlSaveUri(_uri); if (string) { diff --git a/src/uri.h b/src/uri.h index 159cd1cfc..6866f58a1 100644 --- a/src/uri.h +++ b/src/uri.h @@ -23,28 +23,98 @@ namespace Inkscape { */ class URI { public: + + /** + * Copy constructor. + */ URI(URI const &uri); + + /** + * Constructor from a C-style ASCII string. + * + * @param preformed Properly quoted C-style string to be represented. + */ explicit URI(gchar const *preformed) throw(BadURIException); + + /** + * Destructor. + */ ~URI(); + /** + * Determines if the URI represented is an 'opaque' URI. + * + * @return \c true if the URI is opaque, \c false if hierarchial. + */ bool isOpaque() const { return _impl->isOpaque(); } + + /** + * Determines if the URI represented is 'relative' as per RFC 2396. + * + * Relative URI references are distinguished by not begining with a + * scheme name. + * + * @return \c true if the URI is relative, \c false if it is absolute. + */ bool isRelative() const { return _impl->isRelative(); } + + /** + * Determines if the relative URI represented is a 'net-path' as per RFC 2396. + * + * A net-path is one that starts with "\\". + * + * @return \c true if the URI is relative and a net-path, \c false otherwise. + */ bool isNetPath() const { return _impl->isNetPath(); } + + /** + * Determines if the relative URI represented is a 'relative-path' as per RFC 2396. + * + * A relative-path is one that starts with no slashes. + * + * @return \c true if the URI is relative and a relative-path, \c false otherwise. + */ bool isRelativePath() const { return _impl->isRelativePath(); } + + /** + * Determines if the relative URI represented is a 'absolute-path' as per RFC 2396. + * + * An absolute-path is one that starts with a single "\". + * + * @return \c true if the URI is relative and an absolute-path, \c false otherwise. + */ bool isAbsolutePath() const { return _impl->isAbsolutePath(); } + const gchar *getScheme() const { return _impl->getScheme(); } + const gchar *getPath() const { return _impl->getPath(); } + const gchar *getQuery() const { return _impl->getQuery(); } + const gchar *getFragment() const { return _impl->getFragment(); } + const gchar *getOpaque() const { return _impl->getOpaque(); } static URI fromUtf8( gchar const* path ) throw (BadURIException); + static URI from_native_filename(gchar const *path) throw(BadURIException); + static gchar *to_native_filename(gchar const* uri) throw(BadURIException); gchar *toNativeFilename() const throw(BadURIException); + + /** + * Returns a glib string version of this URI. + * + * The returned string must be freed with \c g_free(). + * + * @return a glib string version of this URI. + */ gchar *toString() const { return _impl->toString(); } + /** + * Assignment operator. + */ URI &operator=(URI const &uri); private: diff --git a/src/util/expression-evaluator.cpp b/src/util/expression-evaluator.cpp index 87937be9a..37e9d6cc1 100644 --- a/src/util/expression-evaluator.cpp +++ b/src/util/expression-evaluator.cpp @@ -22,46 +22,6 @@ * <http://www.gnu.org/licenses/>. */ -/** Introducing eevl eva, the evaluator. A straightforward recursive - * descent parser, no fuss, no new dependencies. The lexer is hand - * coded, tedious, not extremely fast but works. It evaluates the - * expression as it goes along, and does not create a parse tree or - * anything, and will not optimize anything. It uses doubles for - * precision, with the given use case, that's enough to combat any - * rounding errors (as opposed to optimizing the evalutation). - * - * It relies on external unit resolving through a callback and does - * elementary dimensionality constraint check (e.g. "2 mm + 3 px * 4 - * in" is an error, as L + L^2 is a missmatch). It uses g_strtod() for numeric - * conversions and it's non-destructive in terms of the paramters, and - * it's reentrant. - * - * EBNF: - * - * expression ::= term { ('+' | '-') term }* | - * <empty string> ; - * - * term ::= signed factor { ( '*' | '/' ) signed factor }* ; - * - * signed factor ::= ( '+' | '-' )? factor ; - * - * unit factor ::= factor unit? ; - * - * factor ::= number | '(' expression ')' ; - * - * number ::= ? what g_strtod() consumes ? ; - * - * unit ::= ? what not g_strtod() consumes and not whitespace ? ; - * - * The code should match the EBNF rather closely (except for the - * non-terminal unit factor, which is inlined into factor) for - * maintainability reasons. - * - * It will allow 1++1 and 1+-1 (resulting in 2 and 0, respectively), - * but I figured one might want that, and I don't think it's going to - * throw anyone off. - */ - #include "config.h" #include "util/expression-evaluator.h" diff --git a/src/util/expression-evaluator.h b/src/util/expression-evaluator.h index 90789a25f..4b1065268 100644 --- a/src/util/expression-evaluator.h +++ b/src/util/expression-evaluator.h @@ -22,8 +22,8 @@ * <http://www.gnu.org/licenses/>. */ -#ifndef __GIMP_EEVL_H__ -#define __GIMP_EEVL_H__ +#ifndef SEEN_GIMP_EEVL_H +#define SEEN_GIMP_EEVL_H #include "util/units.h" @@ -31,6 +31,48 @@ #include <sstream> #include <string> +/** + * @file + * Introducing eevl eva, the evaluator. A straightforward recursive + * descent parser, no fuss, no new dependencies. The lexer is hand + * coded, tedious, not extremely fast but works. It evaluates the + * expression as it goes along, and does not create a parse tree or + * anything, and will not optimize anything. It uses doubles for + * precision, with the given use case, that's enough to combat any + * rounding errors (as opposed to optimizing the evalutation). + * + * It relies on external unit resolving through a callback and does + * elementary dimensionality constraint check (e.g. "2 mm + 3 px * 4 + * in" is an error, as L + L^2 is a missmatch). It uses g_strtod() for numeric + * conversions and it's non-destructive in terms of the paramters, and + * it's reentrant. + * + * EBNF: + * + * expression ::= term { ('+' | '-') term }* | + * <empty string> ; + * + * term ::= signed factor { ( '*' | '/' ) signed factor }* ; + * + * signed factor ::= ( '+' | '-' )? factor ; + * + * unit factor ::= factor unit? ; + * + * factor ::= number | '(' expression ')' ; + * + * number ::= ? what g_strtod() consumes ? ; + * + * unit ::= ? what not g_strtod() consumes and not whitespace ? ; + * + * The code should match the EBNF rather closely (except for the + * non-terminal unit factor, which is inlined into factor) for + * maintainability reasons. + * + * It will allow 1++1 and 1+-1 (resulting in 2 and 0, respectively), + * but I figured one might want that, and I don't think it's going to + * throw anyone off. + */ + namespace Inkscape { namespace Util { @@ -77,4 +119,4 @@ protected: } } -#endif /* __GIMP_EEVL_H__ */ +#endif // SEEN_GIMP_EEVL_H -- cgit v1.2.3 From 417886607ad74808410a6cdebdaa1b13af295c6e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 28 Oct 2011 20:34:55 +0200 Subject: fix initialization. add todo comment about gui-hidden not being used. (bzr r10698) --- src/extension/param/notebook.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index e1ab1de6d..637208b04 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -62,7 +62,8 @@ public: ParamNotebookPage::ParamNotebookPage (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext) + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _tooltips(NULL) { parameters = NULL; @@ -119,6 +120,7 @@ ParamNotebookPage::paramString (std::list <std::string> &list) in the XML file describing the extension (it's private so people have to use the system) :) \param in_repr The XML describing the page + \todo the 'gui-hidden' attribute is read but not used! This function first grabs all of the data out of the Repr and puts it into local variables. Actually, these are just pointers, and the -- cgit v1.2.3 From efbfc732bbed46c3e615fcd88294a02ee98b7530 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 28 Oct 2011 21:41:31 +0200 Subject: one constructor cannot call the other to initialize the object. See C++faq-lite 10.3 (bzr r10699) --- src/extension/param/parameter.cpp | 20 ++++++++++++++++++-- src/extension/param/parameter.h | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 0a88fdda8..106cd76a6 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -307,11 +307,27 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d _gui_tip = g_strdup(gui_tip); } + if (guitext != NULL) { + _text = g_strdup(guitext); + } else { + _text = g_strdup(name); + } + + return; +} - if (guitext != NULL) +/** \brief Oop, now that we need a parameter, we need it's name. */ +Parameter::Parameter (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext) : + extension(ext), _name(NULL), _desc(NULL), _scope(Parameter::SCOPE_USER), _text(NULL), _gui_hidden(false), _gui_tip(NULL) +{ + if (name != NULL) { + _name = g_strdup(name); + } + if (guitext != NULL) { _text = g_strdup(guitext); - else + } else { _text = g_strdup(name); + } return; } diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index e7a7538b7..ad07f5306 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -83,9 +83,7 @@ public: Inkscape::Extension::Extension * ext); Parameter (const gchar * name, const gchar * guitext, - Inkscape::Extension::Extension * ext) { - Parameter(name, guitext, NULL, Parameter::SCOPE_USER, false, NULL, ext); - }; + Inkscape::Extension::Extension * ext); virtual ~Parameter (void); bool get_bool (const SPDocument * doc, -- cgit v1.2.3 From 85d37c9276535da0bf2684666af856f63ac3495c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 28 Oct 2011 22:00:48 +0200 Subject: add a cppcheck suppression for memleak that is not a memleak (bzr r10700) --- src/ui/dialog/debug.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index 7a2515789..426cd5d99 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -154,6 +154,8 @@ void DebugDialog::showInstance() { DebugDialog *debugDialog = getInstance(); debugDialog->show(); + // this is not a real memleak because getInstance() only creates a debug dialog once, and returns that instance for all subsequent calls + // cppcheck-suppress memleak } -- cgit v1.2.3 From 7e0fda9d3090574eeed02370e3ae6826cd14fdd2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 28 Oct 2011 22:03:11 +0200 Subject: fix potential null pointer deref (bzr r10701) --- src/libnrtype/TextWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libnrtype/TextWrapper.cpp b/src/libnrtype/TextWrapper.cpp index 3de85fcdf..63af17f2e 100644 --- a/src/libnrtype/TextWrapper.cpp +++ b/src/libnrtype/TextWrapper.cpp @@ -206,8 +206,8 @@ void text_wrapper::DoLayout(void) GSList *curR = pLine->runs; // get ready to iterate over the runs of this line while ( curR ) { PangoLayoutRun *pRun = (PangoLayoutRun*)curR->data; - int prOffset = pRun->item->offset; // start of the run in the line if ( pRun ) { + int prOffset = pRun->item->offset; // start of the run in the line // a run has uniform font/directionality/etc... int o_g_l = glyph_length; // save the index of the first glyph we'll add for (int i = 0; i < pRun->glyphs->num_glyphs; i++) { // add glyph sequentially, reading them from the run -- cgit v1.2.3 From 1937d8b83734173f61d1a620c7431f7e692ae88f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 28 Oct 2011 22:04:48 +0200 Subject: fix potential null pointer deref (bzr r10702) --- src/extension/effect.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index b42caca06..4f87e98cd 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -296,18 +296,20 @@ Effect::effect (Inkscape::UI::View::View * doc) void Effect::set_last_effect (Effect * in_effect) { - gchar const * verb_id = in_effect->get_verb()->get_id(); - gchar const * help_id_prefix = "org.inkscape.help."; - - // We don't want these "effects" to register as the last effect, - // this wouldn't be helpful to the user who selects a real effect, - // then goes to the help file (implemented as an effect), then goes - // back to the effect, only to see it written over by the help file - // selection. - - // This snippet should fix this bug: - // https://bugs.launchpad.net/inkscape/+bug/600671 - if (strncmp(verb_id, help_id_prefix, strlen(help_id_prefix)) == 0) return; + if (in_effect) { + gchar const * verb_id = in_effect->get_verb()->get_id(); + gchar const * help_id_prefix = "org.inkscape.help."; + + // We don't want these "effects" to register as the last effect, + // this wouldn't be helpful to the user who selects a real effect, + // then goes to the help file (implemented as an effect), then goes + // back to the effect, only to see it written over by the help file + // selection. + + // This snippet should fix this bug: + // https://bugs.launchpad.net/inkscape/+bug/600671 + if (strncmp(verb_id, help_id_prefix, strlen(help_id_prefix)) == 0) return; + } if (in_effect == NULL) { Inkscape::Verb::get(SP_VERB_EFFECT_LAST)->sensitive(NULL, false); -- cgit v1.2.3 From f2ce84926660eba51119fa6720921c345d5a6e0e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sat, 29 Oct 2011 00:15:36 +0200 Subject: fix order of checks. (bzr r10703) --- src/live_effects/parameter/vector.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 9086ab376..6d0824ae0 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -53,9 +53,12 @@ bool VectorParam::param_readSVGValue(const gchar * strvalue) { gchar ** strarray = g_strsplit(strvalue, ",", 4); + if (!strarray) { + return false; + } double val[4]; unsigned int i = 0; - while (strarray[i] && i < 4) { + while (i < 4 && strarray[i]) { if (sp_svg_number_read_d(strarray[i], &val[i]) != 0) { i++; } else { -- cgit v1.2.3 From d7a3d42e527b4a7754b52640006d8eed01e71fc8 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 29 Oct 2011 18:41:49 +0200 Subject: cppcheck: variable initialisation (bzr r10705) --- src/display/nr-filter-turbulence.cpp | 2 ++ src/removeoverlap.cpp | 2 +- src/snapped-point.cpp | 1 + src/widgets/sp-color-wheel-selector.cpp | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 7e47c3bd9..fff327590 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -36,6 +36,8 @@ public: , _wrapw(0) , _wraph(0) , _inited(false) + , _seed(0) + , _octaves(0) {} void init(long seed, Geom::Rect const &tile, Geom::Point const &freq, bool stitch, diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 6dd8d6a79..0c45e34a9 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -26,7 +26,7 @@ namespace { Geom::Point midpoint; Rectangle *vspc_rect; - Record() {} + Record() : item(0), vspc_rect(0) {} Record(SPItem *i, Geom::Point m, Rectangle *r) : item(i), midpoint(m), vspc_rect(r) {} }; diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index cffdda5d7..72875995d 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -84,6 +84,7 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p) _source_num = -1, _target = SNAPTARGET_UNDEFINED, _at_intersection = false; + _constrained_snap = false; _fully_constrained = false; _distance = Geom::infinity(); _tolerance = 1; diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 18fc76a2d..148f3e834 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -83,7 +83,8 @@ ColorWheelSelector::ColorWheelSelector( SPColorSelector* csel ) _adj(0), _wheel(0), _sbtn(0), - _label(0) + _label(0), + _slider(0) { } -- cgit v1.2.3 From e7136d8c08bc408e060130fb9725a6c8e5b81a45 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 29 Oct 2011 20:49:27 +0200 Subject: fix usage of iterator when iterator's erase function is used (Bug #812018) Fixed bugs: - https://launchpad.net/bugs/812018 (bzr r10706) --- src/dom/css.h | 11 +++++++---- src/dom/events.h | 26 ++++++++++++++++---------- src/dom/stylesheets.h | 13 ++++++++----- src/ui/tool/path-manipulator.cpp | 2 +- 4 files changed, 32 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/dom/css.h b/src/dom/css.h index 5ea71ce95..4459a1006 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -639,11 +639,14 @@ public: throw (dom::DOMException) { std::vector<CSSStyleDeclarationEntry>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - items.erase(iter); + for (iter=items.begin() ; iter!=items.end() ; ){ + if (iter->name == propertyName){ + iter = items.erase(iter); } + else{ + ++iter; + } + } return propertyName; } diff --git a/src/dom/events.h b/src/dom/events.h index c4000ec29..b44df6dcd 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -510,17 +510,20 @@ public: virtual void removeEventListener(const DOMString &type, const EventListener *listener, bool useCapture) - { + { std::vector<EventListenerEntry>::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) - { + for (iter = listeners.begin() ; iter != listeners.end() ; ){ EventListenerEntry entry = *iter; if (entry.eventType == type && entry.listener == listener && - useCapture && entry.useCapture) - listeners.erase(iter); + useCapture && entry.useCapture){ + iter = listeners.erase(iter); + } + else{ + ++iter; } } + } /** * This method allows the dispatch of events into the implementation's event @@ -568,18 +571,21 @@ public: const DOMString &type, const EventListener *listener, bool useCapture) - { + { std::vector<EventListenerEntry>::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) - { + for (iter = listeners.begin() ; iter != listeners.end() ; ){ EventListenerEntry entry = *iter; if (entry.namespaceURI == namespaceURI && entry.eventType == type && entry.listener == listener && - useCapture && entry.useCapture) - listeners.erase(iter); + useCapture && entry.useCapture){ + iter = listeners.erase(iter); + } + else { + ++iter; } } + } /** * This method allows the DOM application to know if an event listener, attached diff --git a/src/dom/stylesheets.h b/src/dom/stylesheets.h index 3ba225af3..fc1bc9d88 100644 --- a/src/dom/stylesheets.h +++ b/src/dom/stylesheets.h @@ -122,14 +122,17 @@ public: */ virtual void deleteMedium(const DOMString& oldMedium) throw (dom::DOMException) - { + { std::vector<DOMString>::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (*iter == oldMedium) - items.erase(iter); + for (iter=items.begin() ; iter!=items.end() ; ){ + if (*iter == oldMedium){ + iter = items.erase(iter); + } + else{ + ++iter; } } + } /** * Adds the medium newMedium to the end of the list. If the newMedium diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 4be8df397..a7369f915 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1006,7 +1006,7 @@ void PathManipulator::_createControlPointsFromGeometry() // When we erase an element, the next one slides into position, // so we do not increment the iterator even though it is theoretically invalidated. if (i->empty()) { - pathv.erase(i); + i = pathv.erase(i); } else { ++i; } -- cgit v1.2.3 From 7f48710afe4963d02b606a06fca489e8319c8789 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sat, 29 Oct 2011 13:34:00 -0700 Subject: Updating use of libpng jump buffer. Fixes bug #721029. Fixed bugs: - https://launchpad.net/bugs/721029 (bzr r10707) --- src/extension/internal/pdfinput/svg-builder.cpp | 2 +- src/helper/png-write.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 64cb0a152..344c3c5d2 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1481,7 +1481,7 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height return NULL; } // Set error handler - if (setjmp(png_ptr->jmpbuf)) { + if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); return NULL; } diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 24da697c1..992c7b886 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -166,8 +166,8 @@ sp_png_write_rgba_striped(SPDocument *doc, /* Set error handling. REQUIRED if you aren't supplying your own * error hadnling functions in the png_create_write_struct() call. */ - if (setjmp(png_ptr->jmpbuf)) { - /* If we get here, we had a problem reading the file */ + if (setjmp(png_jmpbuf(png_ptr))) { + // If we get here, we had a problem reading the file fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); return false; -- cgit v1.2.3 From 863cfa417c873cf2c9fb9e006dfef98ba30341e8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sat, 29 Oct 2011 16:53:45 -0700 Subject: Fixing initializer order and missing initializers. (bzr r10708) --- src/display/nr-filter-turbulence.cpp | 35 ++++++++++++++++++++------------- src/widgets/sp-color-wheel-selector.cpp | 4 ++-- src/widgets/sp-color-wheel-selector.h | 6 +++--- 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index fff327590..bce532f21 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -30,14 +30,20 @@ namespace Filters{ class TurbulenceGenerator { public: - TurbulenceGenerator() - : _wrapx(0) - , _wrapy(0) - , _wrapw(0) - , _wraph(0) - , _inited(false) - , _seed(0) - , _octaves(0) + TurbulenceGenerator() : + _tile(), + _baseFreq(), + _latticeSelector(), + _gradient(), + _seed(0), + _octaves(0), + _stitchTiles(false), + _wrapx(0), + _wrapy(0), + _wrapw(0), + _wraph(0), + _inited(false), + _fractalnoise(false) {} void init(long seed, Geom::Rect const &tile, Geom::Point const &freq, bool stitch, @@ -275,11 +281,9 @@ private: RAND_r = 2836; // m % a // other constants - static int const - BSize = 0x100, - BMask = 0xff; - static double const - PerlinOffset = 4096.0; + static int const BSize = 0x100; + static int const BMask = 0xff; + static double const PerlinOffset = 4096.0; Geom::Rect _tile; Geom::Point _baseFreq; @@ -288,7 +292,10 @@ private: long _seed; int _octaves; bool _stitchTiles; - int _wrapx, _wrapy, _wrapw, _wraph; + int _wrapx; + int _wrapy; + int _wrapw; + int _wraph; bool _inited; bool _fractalnoise; }; diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 148f3e834..89008288a 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -82,9 +82,9 @@ ColorWheelSelector::ColorWheelSelector( SPColorSelector* csel ) _dragging( FALSE ), _adj(0), _wheel(0), + _slider(0), _sbtn(0), - _label(0), - _slider(0) + _label(0) { } diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index d8bcb730b..5674850cb 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -38,11 +38,11 @@ protected: gboolean _updating : 1; gboolean _dragging : 1; - GtkAdjustment* _adj; /* Channel adjustment */ + GtkAdjustment* _adj; // Channel adjustment GtkWidget* _wheel; GtkWidget* _slider; - GtkWidget* _sbtn; /* Spinbutton */ - GtkWidget* _label; /* Label */ + GtkWidget* _sbtn; // Spinbutton + GtkWidget* _label; // Label private: // By default, disallow copy constructor and assignment operator -- cgit v1.2.3 From 9acea06b41c7a081a9f059331a01d26a5be9a563 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour <nicoduf@yahoo.fr> Date: Tue, 1 Nov 2011 09:41:37 +0100 Subject: Filters. Removing deprecated workaround in drop shadow (see Bug #808013 ). (bzr r10709) --- src/extension/internal/filter/shadows.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 6a7cf38f2..d76358a96 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -108,12 +108,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) const gchar *type = ext->get_param_enum("type"); guint32 color = ext->get_param_color("color"); - if (ext->get_param_float("blur") > 0) { - blur << "<feGaussianBlur in=\"composite1\" stdDeviation=\"" << ext->get_param_float("blur") << "\" result=\"blur\" />\n"; - } else { - blur << ""; - } - + blur << ext->get_param_float("blur"); x << ext->get_param_float("xoffset"); y << ext->get_param_float("yoffset"); a << (color & 0xff) / 255.0F; @@ -167,7 +162,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Drop Shadow\">\n" "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite1\" />\n" - "%s" + "<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur\" />\n" "<feOffset dx=\"%s\" dy=\"%s\" result=\"offset\" />\n" "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite2\" />\n" "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), -- cgit v1.2.3 From ec0a1c050e60e5f604cf3cbddb11993a77458283 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Tue, 1 Nov 2011 16:43:39 -0200 Subject: fix bug 828400 measurement tool: display total length between first and last intersection points (bzr r10710) --- src/measure-context.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 8cb30f983..16becc7eb 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -248,6 +248,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } } + //draw control line SPCanvasItem * control_line = NULL; control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); @@ -357,6 +358,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SPUnit unit = sp_unit_get_by_id(unitid); double fontsize = prefs->getInt("/tools/measure/fontsize"); + SPCanvasItem *canvas_tooltip; Geom::Point previous_point; if (intersections.size()>0) @@ -371,7 +373,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv char* measure_str = (char*) malloc(sizeof(char)*20); sprintf(measure_str, "%.2f %s", lengthval, unit.abbr); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); + canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; @@ -387,9 +389,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv char* angle_str = (char*) malloc(sizeof(char)*20); sprintf(angle_str, "%.2f °", angle * 180/M_PI ); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); + canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); - sp_canvastext_set_rgba32 (SP_CANVASTEXT(canvas_tooltip), 0x337f33ff, 0xffffffff); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; SP_CANVASTEXT(canvas_tooltip)->outline = false; @@ -398,6 +399,38 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(angle_str); + /* Display measurement of total length from first until last intersection points */ + + if (intersections.size()>2){ + Geom::Point normal = Geom::rot90(Geom::unit_vector(intersections[intersections.size()-1] - intersections[0])); + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]) + desktop->w2d(normal*60), desktop->doc2dt(intersections[intersections.size()-1]) + desktop->w2d(normal*60)); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); + + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]), desktop->doc2dt(intersections[0]) + desktop->w2d(normal*65)); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); + + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[intersections.size()-1]), desktop->doc2dt(intersections[intersections.size()-1]) + desktop->w2d(normal*65)); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); + + double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length(); + sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); + char* total_str = (char*) malloc(sizeof(char)*20); + sprintf(total_str, "%.2f %s", totallengthval, unit.abbr); + + canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc((intersections[0] + intersections[intersections.size()-1])/2) + desktop->w2d(normal*60), total_str); + sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; + + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); + free(total_str); + } + gobble_motion_events(GDK_BUTTON1_MASK); } break; -- cgit v1.2.3 From eef5ddd2fe2b3cd3206a46b4ce785894a5c71f01 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Wed, 2 Nov 2011 23:18:19 -0700 Subject: Misc cleanup including casts and variable lifetime and initialization. (bzr r10712) --- src/measure-context.cpp | 171 +++++++++++++++++++++++++----------------------- src/measure-context.h | 14 ++-- 2 files changed, 97 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 16becc7eb..8a9928d93 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -3,6 +3,7 @@ * * Authors: * Felipe Correa da Silva Sanches <juca@members.fsf.org> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2011 Authors * @@ -44,17 +45,20 @@ static void sp_measure_context_class_init(SPMeasureContextClass *klass); static void sp_measure_context_init(SPMeasureContext *measure_context); static void sp_measure_context_setup(SPEventContext *ec); -static void sp_measure_context_finish (SPEventContext *ec); +static void sp_measure_context_finish(SPEventContext *ec); static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event); static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); static SPEventContextClass *parent_class; -static gint xp = 0, yp = 0; // where drag started +static gint xp = 0; // where drag started +static gint yp = 0; static gint tolerance = 0; static bool within_tolerance = false; + Geom::Point start_point; + std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items; GType sp_measure_context_get_type(void) @@ -65,14 +69,14 @@ GType sp_measure_context_get_type(void) GTypeInfo info = { sizeof(SPMeasureContextClass), NULL, NULL, - (GClassInitFunc) sp_measure_context_class_init, + reinterpret_cast<GClassInitFunc>(sp_measure_context_class_init), // TODO needs two params? NULL, NULL, sizeof(SPMeasureContext), 4, - (GInstanceInitFunc) sp_measure_context_init, - NULL, /* value_table */ + reinterpret_cast<GInstanceInitFunc>(sp_measure_context_init), // TODO needs two params? + NULL, // value_table }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeasureContext", &info, (GTypeFlags) 0); + type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeasureContext", &info, static_cast<GTypeFlags>(0)); } return type; @@ -80,9 +84,9 @@ GType sp_measure_context_get_type(void) static void sp_measure_context_class_init(SPMeasureContextClass *klass) { - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; + SPEventContextClass *event_context_class = reinterpret_cast<SPEventContextClass *>(klass); - parent_class = (SPEventContextClass*) g_type_class_peek_parent(klass); + parent_class = static_cast<SPEventContextClass*>(g_type_class_peek_parent(klass)); event_context_class->setup = sp_measure_context_setup; event_context_class->finish = sp_measure_context_finish; @@ -91,7 +95,7 @@ static void sp_measure_context_class_init(SPMeasureContextClass *klass) event_context_class->item_handler = sp_measure_context_item_handler; } -static void sp_measure_context_init (SPMeasureContext *measure_context) +static void sp_measure_context_init(SPMeasureContext *measure_context) { SPEventContext *event_context = SP_EVENT_CONTEXT(measure_context); @@ -100,12 +104,11 @@ static void sp_measure_context_init (SPMeasureContext *measure_context) event_context->hot_y = 4; } -static void -sp_measure_context_finish (SPEventContext *ec) +static void sp_measure_context_finish(SPEventContext *ec) { - SPMeasureContext *mc = SP_MEASURE_CONTEXT(ec); - - ec->enableGrDrag(false); + SPMeasureContext *mc = SP_MEASURE_CONTEXT(ec); + + ec->enableGrDrag(false); if (mc->grabbed) { sp_canvas_item_ungrab(mc->grabbed, GDK_CURRENT_TIME); @@ -115,8 +118,8 @@ sp_measure_context_finish (SPEventContext *ec) static void sp_measure_context_setup(SPEventContext *ec) { - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (parent_class->setup) { + parent_class->setup(ec); } } @@ -124,8 +127,8 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte { gint ret = FALSE; - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler (event_context, item, event); + if (parent_class->item_handler) { + ret = parent_class->item_handler(event_context, item, event); } return ret; @@ -133,10 +136,11 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2) { - if (p1[Geom::Y] == p2[Geom::Y]) + if (p1[Geom::Y] == p2[Geom::Y]) { return p1[Geom::X] < p2[Geom::X]; - else + } else { return p1[Geom::Y] < p2[Geom::Y]; + } } void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector *lineseg, SPCurve *curve, std::vector<Geom::Point> *intersections) @@ -156,7 +160,7 @@ void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVe if (((*m).ta > eps && item == doc->getItemAtPoint(desktop->dkey, (*lineseg)[0].pointAt((*m).ta - eps), false, NULL)) || ((*m).ta + eps < 1 && - item == doc->getItemAtPoint(desktop->dkey, (*lineseg)[0].pointAt((*m).ta + eps), false, NULL)) ){ + item == doc->getItemAtPoint(desktop->dkey, (*lineseg)[0].pointAt((*m).ta + eps), false, NULL)) ) { intersections->push_back(intersection); } #else @@ -170,7 +174,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SPDesktop *desktop = event_context->desktop; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - + SPMeasureContext *mc = SP_MEASURE_CONTEXT(event_context); gint ret = FALSE; @@ -181,8 +185,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv start_point = desktop->w2d(button_w); if (event->button.button == 1 && !event_context->space_panning) { // save drag origin - xp = (gint) event->button.x; - yp = (gint) event->button.y; + xp = static_cast<gint>(event->button.x); + yp = static_cast<gint>(event->button.y); within_tolerance = true; ret = TRUE; @@ -200,7 +204,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv break; } - case GDK_MOTION_NOTIFY: + case GDK_MOTION_NOTIFY: { if (!((event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning)) { if (!(event->motion.state & GDK_SHIFT_MASK)) { @@ -217,8 +221,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv ret = TRUE; if ( within_tolerance - && ( abs( (gint) event->motion.x - xp ) < tolerance ) - && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) { + && ( abs( static_cast<gint>(event->motion.x) - xp ) < tolerance ) + && ( abs( static_cast<gint>(event->motion.y) - yp ) < tolerance ) ) { break; // do not drag if we're within tolerance from origin } // Once the user has moved farther than tolerance from the original location @@ -227,8 +231,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv within_tolerance = false; //clear previous temporary canvas items, we'll draw new ones - unsigned int idx; - for (idx=0; idx<measure_tmp_items.size(); idx++){ + for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); } measure_tmp_items.clear(); @@ -251,7 +254,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv //draw control line SPCanvasItem * control_line = NULL; - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point, end_point); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); @@ -270,9 +273,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv #define NPOINTS 800 std::vector<Geom::Point> points; - double i; - for (i=0; i<NPOINTS; i++){ - points.push_back(desktop->d2w(start_point + (i/NPOINTS)*(end_point-start_point))); + for (double i = 0; i < NPOINTS; i++) { + points.push_back(desktop->d2w(start_point + (i / NPOINTS) * (end_point - start_point))); } // TODO: Felipe, why don't you simply iterate over all items, and test whether their bounding boxes intersect @@ -281,34 +283,36 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv //select elements crossed by line segment: GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points); - SPItem* item; - GSList *l; std::vector<Geom::Point> intersections; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool ignore_1st_and_last = prefs->getBool("/tools/measure/ignore_1st_and_last", true); - if (!ignore_1st_and_last){ + if (!ignore_1st_and_last) { intersections.push_back(desktop->dt2doc(start_point)); } - for (l = items; l != NULL; l = l->next){ - item = (SPItem*) (l->data); + // TODO switch to a different variable name. The single letter 'l' is easy to misread. + for (GSList *l = items; l != NULL; l = l->next) { + SPItem *item = static_cast<SPItem*>(l->data); if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, &lineseg, SP_SHAPE(item)->getCurve(), &intersections); } else { - if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)){ - Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin(); + if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { + Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin(); do { Inkscape::Text::Layout::iterator iter_next = iter; iter_next.nextGlyph(); // iter_next is one glyph ahead from iter - if (iter == iter_next) + if (iter == iter_next) { break; + } // get path from iter to iter_next: SPCurve *curve = te_get_layout(item)->convertToCurves(iter, iter_next); iter = iter_next; // shift to next glyph - if (!curve) continue; // error converting this glyph + if (!curve) { + continue; // error converting this glyph + } if (curve->is_empty()) { // whitespace glyph? curve->unref(); continue; @@ -319,27 +323,27 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv calculate_intersections(desktop, item, &lineseg, curve, &intersections); - if (iter == te_get_layout(item)->end()) + if (iter == te_get_layout(item)->end()) { break; - + } } while (true); } } } - if (!ignore_1st_and_last){ + if (!ignore_1st_and_last) { intersections.push_back(desktop->dt2doc(end_point)); } //sort intersections - if (intersections.size()>2){ + if (intersections.size() > 2) { std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); } - for (idx=0;idx<intersections.size(); idx++){ + for (size_t idx = 0; idx < intersections.size(); ++idx) { // Display the intersection indicator (i.e. the cross) SPCanvasItem * canvasitem = NULL; - canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (desktop), + canvasitem = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRL, "anchor", GTK_ANCHOR_CENTER, "size", 8.0, @@ -351,31 +355,31 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv SP_CTRL(canvasitem)->moveto(desktop->doc2dt(intersections[idx])); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvasitem, 0)); - } SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/measure/unitid", SP_UNIT_PX)); SPUnit unit = sp_unit_get_by_id(unitid); double fontsize = prefs->getInt("/tools/measure/fontsize"); - SPCanvasItem *canvas_tooltip; Geom::Point previous_point; - if (intersections.size()>0) + if (intersections.size() > 0) { previous_point = intersections[0]; + } - for (idx=1; idx < intersections.size(); idx++){ - Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; + for (size_t idx = 1; idx < intersections.size(); ++idx) { + Geom::Point measure_text_pos = (previous_point + intersections[idx]) / 2; //TODO: shift label a few pixels in the y coordinate double lengthval = (intersections[idx] - previous_point).length(); sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - char* measure_str = (char*) malloc(sizeof(char)*20); + // TODO cleanup memory, Glib::ustring, etc.: + char* measure_str = static_cast<char*>(malloc(20)); sprintf(measure_str, "%.2f %s", lengthval, unit.abbr); - canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); - sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x0000007f; SP_CANVASTEXT(canvas_tooltip)->outline = false; @@ -387,41 +391,46 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv previous_point = intersections[idx]; } - char* angle_str = (char*) malloc(sizeof(char)*20); - sprintf(angle_str, "%.2f °", angle * 180/M_PI ); - canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); - sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); - SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; - SP_CANVASTEXT(canvas_tooltip)->outline = false; - SP_CANVASTEXT(canvas_tooltip)->background = true; + { + // TODO cleanup memory, Glib::ustring, etc.: + char* angle_str = static_cast<char*>(malloc(20)); + sprintf(angle_str, "%.2f °", angle * 180/M_PI ); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; - measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); - free(angle_str); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); + free(angle_str); + } - /* Display measurement of total length from first until last intersection points */ + // Display measurement of total length from first until last intersection points - if (intersections.size()>2){ + if (intersections.size() > 2) { Geom::Point normal = Geom::rot90(Geom::unit_vector(intersections[intersections.size()-1] - intersections[0])); - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]) + desktop->w2d(normal*60), desktop->doc2dt(intersections[intersections.size()-1]) + desktop->w2d(normal*60)); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]), desktop->doc2dt(intersections[0]) + desktop->w2d(normal*65)); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[intersections.size()-1]), desktop->doc2dt(intersections[intersections.size()-1]) + desktop->w2d(normal*65)); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length(); sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - char* total_str = (char*) malloc(sizeof(char)*20); + + // TODO cleanup memory, Glib::ustring, etc.: + char* total_str = static_cast<char*>(malloc(20)); sprintf(total_str, "%.2f %s", totallengthval, unit.abbr); - canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc((intersections[0] + intersections[intersections.size()-1])/2) + desktop->w2d(normal*60), total_str); - sp_canvastext_set_fontsize (SP_CANVASTEXT(canvas_tooltip), fontsize); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc((intersections[0] + intersections[intersections.size()-1])/2) + desktop->w2d(normal*60), total_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; SP_CANVASTEXT(canvas_tooltip)->outline = false; @@ -436,13 +445,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv break; } - case GDK_BUTTON_RELEASE: + case GDK_BUTTON_RELEASE: { sp_event_context_discard_delayed_snap_event(event_context); //clear all temporary canvas items related to the measurement tool. - unsigned int idx; - for (idx=0; idx<measure_tmp_items.size(); idx++){ + for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { desktop->remove_temporary_canvasitem(measure_tmp_items[idx]); } measure_tmp_items.clear(); @@ -451,16 +459,17 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv sp_canvas_item_ungrab(mc->grabbed, event->button.time); mc->grabbed = NULL; } - xp = yp = 0; + xp = 0; + yp = 0; break; } - default: + default: break; } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (parent_class->root_handler) { + ret = parent_class->root_handler(event_context, event); } } diff --git a/src/measure-context.h b/src/measure-context.h index 24cdf5ac8..baf74d30e 100644 --- a/src/measure-context.h +++ b/src/measure-context.h @@ -1,5 +1,5 @@ -#ifndef __SP_MEASURING_CONTEXT_H__ -#define __SP_MEASURING_CONTEXT_H__ +#ifndef SEEN_SP_MEASURING_CONTEXT_H +#define SEEN_SP_MEASURING_CONTEXT_H /* * Our fine measuring tool @@ -14,9 +14,9 @@ #include "event-context.h" -#define SP_TYPE_MEASURE_CONTEXT (sp_measure_context_get_type ()) -#define SP_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) -#define SP_IS_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_MEASURE_CONTEXT)) +#define SP_TYPE_MEASURE_CONTEXT (sp_measure_context_get_type()) +#define SP_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) +#define SP_IS_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_MEASURE_CONTEXT)) class SPMeasureContext; class SPMeasureContextClass; @@ -30,6 +30,6 @@ struct SPMeasureContextClass { SPEventContextClass parent_class; }; -GType sp_measure_context_get_type (void); +GType sp_measure_context_get_type(void); -#endif +#endif // SEEN_SP_MEASURING_CONTEXT_H -- cgit v1.2.3 From 0fd3c208b31848c3c26208aadd7811de7a56c3e4 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Thu, 3 Nov 2011 06:49:06 -0200 Subject: measure tool: fix handling of coordinate systems and add display of total measurement (between start and end drag points) (bzr r10713) --- src/measure-context.cpp | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 8a9928d93..3e8566419 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -377,7 +377,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv // TODO cleanup memory, Glib::ustring, etc.: char* measure_str = static_cast<char*>(malloc(20)); sprintf(measure_str, "%.2f %s", lengthval, unit.abbr); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->doc2dt(measure_text_pos), measure_str); sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; @@ -408,18 +408,47 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv // Display measurement of total length from first until last intersection points + Geom::Point normal = desktop->w2d(Geom::unit_vector(Geom::rot90(desktop->d2w(end_point - start_point)))); + + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point - normal*60, end_point - normal*60); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); + + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point, start_point - normal*65); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); + + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), end_point, end_point - normal*65); + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); + + double totallengthval = (end_point - start_point).length(); + sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); + char* total_str = (char*) malloc(sizeof(char)*20); + sprintf(total_str, "%.2f %s", totallengthval, unit.abbr); + + SPCanvasItem* canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, (start_point + end_point)/2 - normal*60, total_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; + + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); + free(total_str); + + if (intersections.size() > 2) { - Geom::Point normal = Geom::rot90(Geom::unit_vector(intersections[intersections.size()-1] - intersections[0])); - control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); - sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]) + desktop->w2d(normal*60), desktop->doc2dt(intersections[intersections.size()-1]) + desktop->w2d(normal*60)); + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]) + normal*60, desktop->doc2dt(intersections[intersections.size()-1]) + normal*60); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); - sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]), desktop->doc2dt(intersections[0]) + desktop->w2d(normal*65)); + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]), desktop->doc2dt(intersections[0]) + normal*65); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - control_line = sp_canvas_item_new(sp_desktop_tempgroup(desktop), SP_TYPE_CTRLLINE, NULL); - sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[intersections.size()-1]), desktop->doc2dt(intersections[intersections.size()-1]) + desktop->w2d(normal*65)); + control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); + sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[intersections.size()-1]), desktop->doc2dt(intersections[intersections.size()-1]) + normal*65); measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length(); @@ -429,7 +458,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv char* total_str = static_cast<char*>(malloc(20)); sprintf(total_str, "%.2f %s", totallengthval, unit.abbr); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc((intersections[0] + intersections[intersections.size()-1])/2) + desktop->w2d(normal*60), total_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->doc2dt((intersections[0] + intersections[intersections.size()-1])/2) + normal*60, total_str); sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; -- cgit v1.2.3 From faa2b3b333ca7660b6d2824d20b1df20f6ef1da8 Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Thu, 3 Nov 2011 17:14:10 -0200 Subject: measurement tool: display total length near angle info (bzr r10714) --- src/measure-context.cpp | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 3e8566419..f3583a07c 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -392,10 +392,11 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } { + SPCanvasItem *canvas_tooltip; // TODO cleanup memory, Glib::ustring, etc.: char* angle_str = static_cast<char*>(malloc(20)); - sprintf(angle_str, "%.2f °", angle * 180/M_PI ); - SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); + sprintf(angle_str, "%.2f °", angle * 180/M_PI); + canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; @@ -404,40 +405,24 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(angle_str); - } - - // Display measurement of total length from first until last intersection points - - Geom::Point normal = desktop->w2d(Geom::unit_vector(Geom::rot90(desktop->d2w(end_point - start_point)))); - - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); - sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point - normal*60, end_point - normal*60); - measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); - sp_ctrlline_set_coords(SP_CTRLLINE(control_line), start_point, start_point - normal*65); - measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - - control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); - sp_ctrlline_set_coords(SP_CTRLLINE(control_line), end_point, end_point - normal*65); - measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0)); - double totallengthval = (end_point - start_point).length(); - sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - char* total_str = (char*) malloc(sizeof(char)*20); - sprintf(total_str, "%.2f %s", totallengthval, unit.abbr); - - SPCanvasItem* canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, (start_point + end_point)/2 - normal*60, total_str); - sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); - SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; - SP_CANVASTEXT(canvas_tooltip)->outline = false; - SP_CANVASTEXT(canvas_tooltip)->background = true; + double totallengthval = (end_point - start_point).length(); + sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); - free(total_str); + char* totallength_str = static_cast<char*>(malloc(20)); + sprintf(totallength_str, "%.2f %s", totallengthval, unit.abbr); + canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,-2*fontsize)), totallength_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; + measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); + free(totallength_str); + } + Geom::Point normal = desktop->w2d(Geom::unit_vector(Geom::rot90(desktop->d2w(end_point - start_point)))); if (intersections.size() > 2) { control_line = sp_canvas_item_new(sp_desktop_tempgroup (desktop), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_coords(SP_CTRLLINE(control_line), desktop->doc2dt(intersections[0]) + normal*60, desktop->doc2dt(intersections[intersections.size()-1]) + normal*60); -- cgit v1.2.3 From 5275ef6b1a4f048096272586754a85317486052d Mon Sep 17 00:00:00 2001 From: Felipe Corr??a da Silva Sanches <juca@members.fsf.org> Date: Thu, 3 Nov 2011 18:03:08 -0200 Subject: measurement tool: display length info in white with transparent black background (just like the other length labels. green background is just for angle info) (bzr r10715) --- src/measure-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index f3583a07c..1197927f4 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -414,7 +414,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,-2*fontsize)), totallength_str); sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; - SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x3333337f; SP_CANVASTEXT(canvas_tooltip)->outline = false; SP_CANVASTEXT(canvas_tooltip)->background = true; -- cgit v1.2.3 From 3ea31b795fbba57e497f513bc4c66f6d6ad99e04 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 4 Nov 2011 20:26:44 +0100 Subject: make significant digits consistent for grids (bzr r10716) --- src/display/canvas-axonomgrid.cpp | 6 +++--- src/display/canvas-grid.cpp | 8 ++++---- src/ui/dialog/inkscape-preferences.cpp | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 3598c4e4e..4cb050b6e 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -379,13 +379,13 @@ _wr.setUpdating (true); Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger( _("_Major grid line every:"), "", _("lines"), "empspacing", _wr, repr, doc ) ); - _rsu_ox->setDigits(4); + _rsu_ox->setDigits(5); _rsu_ox->setIncrements(0.1, 1.0); - _rsu_oy->setDigits(4); + _rsu_oy->setDigits(5); _rsu_oy->setIncrements(0.1, 1.0); - _rsu_sy->setDigits(4); + _rsu_sy->setDigits(5); _rsu_sy->setIncrements(0.1, 1.0); _wr.setUpdating (false); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index d9f6ddcf2..ee3b6fe5a 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -697,16 +697,16 @@ CanvasXYGrid::newSpecificWidget() _wr.setUpdating (true); - _rsu_ox->setDigits(4); + _rsu_ox->setDigits(5); _rsu_ox->setIncrements(0.1, 1.0); - _rsu_oy->setDigits(4); + _rsu_oy->setDigits(5); _rsu_oy->setIncrements(0.1, 1.0); - _rsu_sx->setDigits(4); + _rsu_sx->setDigits(5); _rsu_sx->setIncrements(0.1, 1.0); - _rsu_sy->setDigits(4); + _rsu_sy->setDigits(5); _rsu_sy->setIncrements(0.1, 1.0); Inkscape::UI::Widget::RegisteredCheckButton * _rcb_dotted = Gtk::manage( diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 448126091..6d28e8c88 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1049,10 +1049,14 @@ void InkscapePreferences::initPageGrids() _grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false); _grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); _grids_xy_origin_y.init("/options/grids/xy/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); + _grids_xy_origin_x.set_digits(5); + _grids_xy_origin_y.set_digits(5); _grids_xy.add_line( false, _("Origin X:"), _grids_xy_origin_x, "", _("X coordinate of grid origin"), false); _grids_xy.add_line( false, _("Origin Y:"), _grids_xy_origin_y, "", _("Y coordinate of grid origin"), false); _grids_xy_spacing_x.init("/options/grids/xy/spacing_x", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false); _grids_xy_spacing_y.init("/options/grids/xy/spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false); + _grids_xy_spacing_x.set_digits(5); + _grids_xy_spacing_y.set_digits(5); _grids_xy.add_line( false, _("Spacing X:"), _grids_xy_spacing_x, "", _("Distance between vertical grid lines"), false); _grids_xy.add_line( false, _("Spacing Y:"), _grids_xy_spacing_y, "", _("Distance between horizontal grid lines"), false); @@ -1070,9 +1074,12 @@ void InkscapePreferences::initPageGrids() _grids_axonom.add_line( false, _("Grid units:"), _grids_axonom_units, "", "", false); _grids_axonom_origin_x.init("/options/grids/axonom/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); _grids_axonom_origin_y.init("/options/grids/axonom/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); + _grids_axonom_origin_x.set_digits(5); + _grids_axonom_origin_y.set_digits(5); _grids_axonom.add_line( false, _("Origin X:"), _grids_axonom_origin_x, "", _("X coordinate of grid origin"), false); _grids_axonom.add_line( false, _("Origin Y:"), _grids_axonom_origin_y, "", _("Y coordinate of grid origin"), false); _grids_axonom_spacing_y.init("/options/grids/axonom/spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false); + _grids_axonom_spacing_y.set_digits(5); _grids_axonom.add_line( false, _("Spacing Y:"), _grids_axonom_spacing_y, "", _("Base length of z-axis"), false); _grids_axonom_angle_x.init("/options/grids/axonom/angle_x", -360.0, 360.0, 1.0, 10.0, 30.0, false, false); _grids_axonom_angle_z.init("/options/grids/axonom/angle_z", -360.0, 360.0, 1.0, 10.0, 30.0, false, false); -- cgit v1.2.3 From e9890d9640d9bb5f7dc74b377f1b220dcb1bdd96 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 4 Nov 2011 20:59:10 +0100 Subject: add missing units to grid length interpretation (we have 4 different unit conversions thingies in Inkscape! ...) Fixed bugs: - https://launchpad.net/bugs/885500 (bzr r10717) --- src/display/canvas-axonomgrid.cpp | 4 ++++ src/display/canvas-grid.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 4cb050b6e..a669142d1 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -225,6 +225,10 @@ static gboolean sp_nv_read_length(gchar const *str, guint base, gdouble *val, SP *unit = &sp_unit_get_by_id(SP_UNIT_M); } else if (!strncmp(u, "in", 2)) { *unit = &sp_unit_get_by_id(SP_UNIT_IN); + } else if (!strncmp(u, "ft", 2)) { + *unit = &sp_unit_get_by_id(SP_UNIT_FT); + } else if (!strncmp(u, "pc", 2)) { + *unit = &sp_unit_get_by_id(SP_UNIT_PC); } else { return FALSE; } diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index ee3b6fe5a..8428a277e 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -492,6 +492,10 @@ sp_nv_read_length(gchar const *str, guint base, gdouble *val, SPUnit const **uni *unit = &sp_unit_get_by_id(SP_UNIT_M); } else if (!strncmp(u, "in", 2)) { *unit = &sp_unit_get_by_id(SP_UNIT_IN); + } else if (!strncmp(u, "ft", 2)) { + *unit = &sp_unit_get_by_id(SP_UNIT_FT); + } else if (!strncmp(u, "pc", 2)) { + *unit = &sp_unit_get_by_id(SP_UNIT_PC); } else { return FALSE; } -- cgit v1.2.3 From f3820e6a3674478658c6a8d61875c4218a8b8193 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 4 Nov 2011 21:11:46 +0100 Subject: reduce scope of some variables (bzr r10718) --- src/live_effects/spiro.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/live_effects/spiro.cpp b/src/live_effects/spiro.cpp index abc9c94ca..b98e12213 100644 --- a/src/live_effects/spiro.cpp +++ b/src/live_effects/spiro.cpp @@ -631,8 +631,6 @@ add_mat_line(bandmat *m, double *v, double derivs[4], double x, double y, int j, int jj, int jinc, int nmat) { - int k; - if (jj >= 0) { int joff = (j + 5 - jj + nmat) % nmat; if (nmat < 6) { @@ -644,7 +642,7 @@ add_mat_line(bandmat *m, double *v, printf("add_mat_line j=%d jj=%d jinc=%d nmat=%d joff=%d\n", j, jj, jinc, nmat, joff); #endif v[jj] += x; - for (k = 0; k < jinc; k++) + for (int k = 0; k < jinc; k++) m[jj].a[joff + k] += y * derivs[k]; } } @@ -831,9 +829,6 @@ spiro_seg_to_bpath(const double ks[4], double xy[2]; double ch, th; double scale, rot; - double th_even, th_odd; - double ul, vl; - double ur, vr; integrate_spiro(ks, xy); ch = hypot(xy[0], xy[1]); @@ -841,6 +836,9 @@ spiro_seg_to_bpath(const double ks[4], scale = seg_ch / ch; rot = seg_th - th; if (depth > 5 || bend < 1.) { + double ul, vl; + double ur, vr; + double th_even, th_odd; th_even = (1./384) * ks[3] + (1./8) * ks[1] + rot; th_odd = (1./48) * ks[2] + .5 * ks[0]; ul = (scale * (1./3)) * cos(th_even - th_odd); @@ -944,7 +942,6 @@ test_integ(void) { double ks[] = {1, 2, 3, 4}; double xy[2]; double xynom[2]; - double ch, th; int i, j; int nsubdiv; @@ -963,9 +960,10 @@ test_integ(void) { en = get_time(); err = hypot(xy[0] - xynom[0], xy[1] - xynom[1]); printf("%d %d %g %g\n", ORDER, n, (en - st) / n_iter, err); +#if 0 + double ch, th; ch = hypot(xy[0], xy[1]); th = atan2(xy[1], xy[0]); -#if 0 printf("n = %d: integ(%g %g %g %g) = %g %g, ch = %g, th = %g\n", n, ks[0], ks[1], ks[2], ks[3], xy[0], xy[1], ch, th); printf("%d: %g %g\n", n, xy[0] - xynom[0], xy[1] - xynom[1]); @@ -988,9 +986,6 @@ print_seg(const double ks[4], double x0, double y0, double x1, double y1) double xy[2]; double ch, th; double scale, rot; - double th_even, th_odd; - double ul, vl; - double ur, vr; integrate_spiro(ks, xy); ch = hypot(xy[0], xy[1]); @@ -998,6 +993,9 @@ print_seg(const double ks[4], double x0, double y0, double x1, double y1) scale = seg_ch / ch; rot = seg_th - th; if (bend < 1.) { + double th_even, th_odd; + double ul, vl; + double ur, vr; th_even = (1./384) * ks[3] + (1./8) * ks[1] + rot; th_odd = (1./48) * ks[2] + .5 * ks[0]; ul = (scale * (1./3)) * cos(th_even - th_odd); -- cgit v1.2.3 From faf187547d7028652e2940ed4fbd14ffe930b40c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Fri, 4 Nov 2011 22:07:55 +0100 Subject: Powerstroke: add erasing of knots with ctrl+alt (LPE parameter editing on-canvas code is seriously flawed) (bzr r10719) --- .../parameter/powerstrokepointarray.cpp | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 66337fd8f..5139f0e41 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -93,6 +93,11 @@ public: virtual Geom::Point knot_get(); virtual void knot_click(guint state); + /** Checks whether the index falls within the size of the parameter's vector */ + bool valid_index(unsigned int index) { + return (_pparam->_vector.size() > index); + }; + private: PowerStrokePointArrayParam *_pparam; unsigned int _index; @@ -107,8 +112,13 @@ PowerStrokePointArrayParamKnotHolderEntity::PowerStrokePointArrayParamKnotHolder void PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { -/// @todo how about item transforms??? using namespace Geom; + + if (!valid_index(_index)) { + return; + } + + /// @todo how about item transforms??? Piecewise<D2<SBasis> > const & pwd2 = _pparam->get_pwd2(); Piecewise<D2<SBasis> > const & n = _pparam->get_pwd2_normal(); @@ -123,6 +133,11 @@ Geom::Point PowerStrokePointArrayParamKnotHolderEntity::knot_get() { using namespace Geom; + + if (!valid_index(_index)) { + return Geom::Point(infinity(), infinity()); + } + Piecewise<D2<SBasis> > const & pwd2 = _pparam->get_pwd2(); Piecewise<D2<SBasis> > const & n = _pparam->get_pwd2_normal(); @@ -135,15 +150,22 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_get() void PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) { - g_print ("This is the %d handle associated to parameter '%s'\n", _index, _pparam->param_key.c_str()); +//g_print ("This is the %d handle associated to parameter '%s'\n", _index, _pparam->param_key.c_str()); if (state & GDK_CONTROL_MASK) { - std::vector<Geom::Point> & vec = _pparam->_vector; - vec.insert(vec.begin() + _index, 1, vec.at(_index)); - _pparam->param_set_and_write_new_value(vec); - g_print ("Added handle %d associated to parameter '%s'\n", _index, _pparam->param_key.c_str()); - /// @todo this BUGS ! the knot stuff should be reloaded when adding a new node! - } + if (state & GDK_MOD1_MASK) { + // delete the clicked knot + std::vector<Geom::Point> & vec = _pparam->_vector; + vec.erase(vec.begin() + _index); + _pparam->param_set_and_write_new_value(vec); + } else { + // add a knot + std::vector<Geom::Point> & vec = _pparam->_vector; + vec.insert(vec.begin() + _index, 1, vec.at(_index)); + _pparam->param_set_and_write_new_value(vec); + } + } + } void -- cgit v1.2.3 From 224a99dc216119d34eb3ed13d12f123158acfe3c Mon Sep 17 00:00:00 2001 From: Diederik van Lierop <mail@diedenrezi.nl> Date: Fri, 4 Nov 2011 22:30:19 +0100 Subject: 1) Cycle to the next-closest-snap-source when pressing tab, if the snap-closest-point-only-option has been activated. Works for the selector tool, but also when scaling/stretching/skewing a selection of nodes in the node tool 2) Cleanup and simplification of the code that finds the closest snapsource (bzr r10720) --- src/display/snap-indicator.cpp | 2 +- src/event-context.cpp | 218 ++++++++++++++++---------------- src/select-context.cpp | 16 ++- src/seltrans.cpp | 150 ++++++++++++---------- src/seltrans.h | 16 ++- src/snap-candidate.h | 8 +- src/snap.cpp | 53 +++----- src/snap.h | 15 +-- src/ui/tool/control-point-selection.cpp | 1 - src/ui/tool/control-point.cpp | 27 ++++ src/ui/tool/transform-handle-set.cpp | 147 ++++++++++++--------- src/ui/tool/transform-handle-set.h | 26 ++++ 12 files changed, 387 insertions(+), 292 deletions(-) (limited to 'src') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 9b61d4a4d..3b9bb57e1 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -310,7 +310,7 @@ SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p) { remove_snapsource(); - g_assert(_desktop != NULL); + g_assert(_desktop != NULL); // If this fails, then likely setup() has not been called on the snap manager (see snap.cpp -> setup()) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool value = prefs->getBool("/options/snapindicator/value", true); diff --git a/src/event-context.cpp b/src/event-context.cpp index 4f938bde5..7dc52bea0 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -541,117 +541,117 @@ static gint sp_event_context_private_root_handler( // in the editing window). So we resteal them back and run our regular shortcut // invoker on them. unsigned int shortcut; - case GDK_Tab: - case GDK_ISO_Left_Tab: - case GDK_F1: - shortcut = get_group0_keyval(&event->key); - if (event->key.state & GDK_SHIFT_MASK) - shortcut |= SP_SHORTCUT_SHIFT_MASK; - if (event->key.state & GDK_CONTROL_MASK) - shortcut |= SP_SHORTCUT_CONTROL_MASK; - if (event->key.state & GDK_MOD1_MASK) - shortcut |= SP_SHORTCUT_ALT_MASK; - ret = sp_shortcut_invoke(shortcut, desktop); - break; + case GDK_Tab: + case GDK_ISO_Left_Tab: + case GDK_F1: + shortcut = get_group0_keyval(&event->key); + if (event->key.state & GDK_SHIFT_MASK) + shortcut |= SP_SHORTCUT_SHIFT_MASK; + if (event->key.state & GDK_CONTROL_MASK) + shortcut |= SP_SHORTCUT_CONTROL_MASK; + if (event->key.state & GDK_MOD1_MASK) + shortcut |= SP_SHORTCUT_ALT_MASK; + ret = sp_shortcut_invoke(shortcut, desktop); + break; - case GDK_D: - case GDK_d: - if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { - sp_toggle_dropper(desktop); - ret = TRUE; - } - break; - case GDK_Q: - case GDK_q: - if (desktop->quick_zoomed()) { - ret = TRUE; - } - if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { - desktop->zoom_quick(true); - ret = TRUE; - } - break; - case GDK_W: - case GDK_w: - case GDK_F4: - /* Close view */ - if (MOD__CTRL_ONLY) { - sp_ui_close_view(NULL); - ret = TRUE; - } - break; - case GDK_Left: // Ctrl Left - case GDK_KP_Left: - case GDK_KP_4: - if (MOD__CTRL_ONLY) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, sp_desktop_canvas(desktop))); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - event_context->desktop->scroll_world(i, 0); - ret = TRUE; - } - break; - case GDK_Up: // Ctrl Up - case GDK_KP_Up: - case GDK_KP_8: - if (MOD__CTRL_ONLY) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, sp_desktop_canvas(desktop))); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - event_context->desktop->scroll_world(0, i); - ret = TRUE; - } - break; - case GDK_Right: // Ctrl Right - case GDK_KP_Right: - case GDK_KP_6: - if (MOD__CTRL_ONLY) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, sp_desktop_canvas(desktop))); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - event_context->desktop->scroll_world(-i, 0); - ret = TRUE; - } - break; - case GDK_Down: // Ctrl Down - case GDK_KP_Down: - case GDK_KP_2: - if (MOD__CTRL_ONLY) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, sp_desktop_canvas(desktop))); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - event_context->desktop->scroll_world(0, -i); - ret = TRUE; - } - break; - case GDK_F10: - if (MOD__SHIFT_ONLY) { - sp_event_root_menu_popup(desktop, NULL, event); - ret = TRUE; - } - break; - case GDK_space: - if (prefs->getBool("/options/spacepans/value")) { - event_context->space_panning = true; - event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, - _("<b>Space+mouse drag</b> to pan canvas")); - ret = TRUE; - } else { - sp_toggle_selector(desktop); - ret = TRUE; - } - break; - case GDK_z: - case GDK_Z: - if (MOD__ALT_ONLY) { - desktop->zoom_grab_focus(); - ret = TRUE; - } - break; - default: - break; + case GDK_D: + case GDK_d: + if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { + sp_toggle_dropper(desktop); + ret = TRUE; + } + break; + case GDK_Q: + case GDK_q: + if (desktop->quick_zoomed()) { + ret = TRUE; + } + if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { + desktop->zoom_quick(true); + ret = TRUE; + } + break; + case GDK_W: + case GDK_w: + case GDK_F4: + /* Close view */ + if (MOD__CTRL_ONLY) { + sp_ui_close_view(NULL); + ret = TRUE; + } + break; + case GDK_Left: // Ctrl Left + case GDK_KP_Left: + case GDK_KP_4: + if (MOD__CTRL_ONLY) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, sp_desktop_canvas(desktop))); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + event_context->desktop->scroll_world(i, 0); + ret = TRUE; + } + break; + case GDK_Up: // Ctrl Up + case GDK_KP_Up: + case GDK_KP_8: + if (MOD__CTRL_ONLY) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, sp_desktop_canvas(desktop))); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + event_context->desktop->scroll_world(0, i); + ret = TRUE; + } + break; + case GDK_Right: // Ctrl Right + case GDK_KP_Right: + case GDK_KP_6: + if (MOD__CTRL_ONLY) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, sp_desktop_canvas(desktop))); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + event_context->desktop->scroll_world(-i, 0); + ret = TRUE; + } + break; + case GDK_Down: // Ctrl Down + case GDK_KP_Down: + case GDK_KP_2: + if (MOD__CTRL_ONLY) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, sp_desktop_canvas(desktop))); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + event_context->desktop->scroll_world(0, -i); + ret = TRUE; + } + break; + case GDK_F10: + if (MOD__SHIFT_ONLY) { + sp_event_root_menu_popup(desktop, NULL, event); + ret = TRUE; + } + break; + case GDK_space: + if (prefs->getBool("/options/spacepans/value")) { + event_context->space_panning = true; + event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, + _("<b>Space+mouse drag</b> to pan canvas")); + ret = TRUE; + } else { + sp_toggle_selector(desktop); + ret = TRUE; + } + break; + case GDK_z: + case GDK_Z: + if (MOD__ALT_ONLY) { + desktop->zoom_grab_focus(); + ret = TRUE; + } + break; + default: + break; + } } - } break; case GDK_KEY_RELEASE: switch (get_group0_keyval(&event->key)) { diff --git a/src/select-context.cpp b/src/select-context.cpp index 99ad35124..3803b7d07 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -398,6 +398,16 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE seltrans->stamp(); ret = TRUE; } + } else if (get_group0_keyval (&event->key) == GDK_Tab) { + if (sc->dragging && sc->grabbed) { + seltrans->getNextClosestPoint(false); + ret = TRUE; + } + } else if (get_group0_keyval (&event->key) == GDK_ISO_Left_Tab) { + if (sc->dragging && sc->grabbed) { + seltrans->getNextClosestPoint(true); + ret = TRUE; + } } break; @@ -531,8 +541,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_MOTION_NOTIFY: { - tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) { + tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); + if ((event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) { Geom::Point const motion_pt(event->motion.x, event->motion.y); Geom::Point const p(desktop->w2d(motion_pt)); @@ -549,7 +559,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (sc->button_press_ctrl || (sc->button_press_alt && !sc->button_press_shift && !selection->isEmpty())) { // if it's not click and ctrl or alt was pressed (the latter with some selection // but not with shift) we want to drag rather than rubberband - sc->dragging = TRUE; + sc->dragging = TRUE; gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, CursorSelectDragging); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 2d09f393e..4889f7dc1 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -163,6 +163,8 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _sel_modified_connection = _selection->connectModified( sigc::mem_fun(*this, &Inkscape::SelTrans::_selModified) ); + + _all_snap_sources_iter = _all_snap_sources_sorted.end(); } Inkscape::SelTrans::~SelTrans() @@ -296,13 +298,10 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s std::vector<Inkscape::SnapCandidatePoint> snap_points_hull = selection->getSnapPointsConvexHull(&m.snapprefs); if (_snap_points.size() > 200) { /* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes - An average user would rarely ever try to snap such a large number of nodes anyway, because - (s)he could hardly discern which node would be snapping */ - if (prefs->getBool("/options/snapclosestonly/value", false)) { - m.keepClosestPointOnly(_snap_points, p); - } else { - _snap_points = snap_points_hull; - } + A typical user would rarely ever try to snap such a large number of nodes anyway, because + (s)he would hardly be able to discern which node would be snapping */ + _snap_points = snap_points_hull; + //} // Unfortunately, by now we will have lost the font-baseline snappoints :-( } @@ -321,26 +320,27 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s } _bbox_points.clear(); - _bbox_points_for_translating.clear(); // Collect the bounding box's corners and midpoints for each selected item if (m.snapprefs.getSnapModeBBox()) { bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER); bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT); bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); - // Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations + // 1) Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations // this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the // stroke width. (see get_scale_transform_for_stroke()). This however is currently only implemented for a single bbox. - // That's why we have both _bbox_points_for_translating and _bbox_points. - getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, c, emp, mp); - if (((_items.size() > 0) && (_items.size() < 50)) || prefs->getBool("/options/snapclosestonly/value", false)) { - // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl - // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole + // 2) More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl + // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole + bool c1 = (_items.size() > 0) && (_items.size() < 50); + bool c2 = prefs->getBool("/options/snapclosestonly/value", false); + if (translating && (c1 || c2)) { + // Get the bounding box points for each item in the selection for (unsigned i = 0; i < _items.size(); i++) { Geom::OptRect b = _items[i]->desktopBounds(_snap_bbox_type); - getBBoxPoints(b, &_bbox_points_for_translating, false, c, emp, mp); + getBBoxPoints(b, &_bbox_points, false, c, emp, mp); } } else { - _bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole + // Only get the bounding box points of the selection as a whole + getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, c, emp, mp); } } @@ -357,54 +357,10 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s } // When snapping the node closest to the mouse pointer is absolutely preferred over the closest snap - // (i.e. when weight == 1), then we will not even try to snap to other points and discard those other - // points immediately. + // (i.e. when weight == 1), then we will not even try to snap to other points and disregard those other points if (prefs->getBool("/options/snapclosestonly/value", false)) { - if (m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers() || m.snapprefs.getSnapModeDatums()) { - m.keepClosestPointOnly(_snap_points, p); - } else { - _snap_points.clear(); // don't keep any point - } - - if (m.snapprefs.getSnapModeBBox()) { - m.keepClosestPointOnly(_bbox_points, p); - m.keepClosestPointOnly(_bbox_points_for_translating, p); - } else { - _bbox_points.clear(); // don't keep any point - _bbox_points_for_translating.clear(); - } - - // Each of the three vectors of snappoints now contains either one snappoint or none at all. - if (_snap_points.size() > 1 || _bbox_points.size() > 1 || _bbox_points_for_translating.size() > 1) { - g_warning("Incorrect assumption encountered while finding the snap source; nothing serious, but please report to Diederik"); - } - - // Now let's reduce this to a single closest snappoint - Geom::Coord dsp = _snap_points.size() == 1 ? Geom::L2((_snap_points.at(0)).getPoint() - p) : Geom::infinity(); - Geom::Coord dbbp = _bbox_points.size() == 1 ? Geom::L2((_bbox_points.at(0)).getPoint() - p) : Geom::infinity(); - Geom::Coord dbbpft = _bbox_points_for_translating.size() == 1 ? Geom::L2((_bbox_points_for_translating.at(0)).getPoint() - p) : Geom::infinity(); - - if (translating) { - _bbox_points.clear(); - if (dsp > dbbpft) { - _snap_points.clear(); - } else { - _bbox_points_for_translating.clear(); - } - } else { - _bbox_points_for_translating.clear(); - if (dsp > dbbp) { - _snap_points.clear(); - } else { - _bbox_points.clear(); - } - } - - if ((_snap_points.size() + _bbox_points.size() + _bbox_points_for_translating.size()) > 1) { - g_warning("Checking number of snap sources failed; nothing serious, but please report to Diederik"); - } - + _keepClosestPointOnly(p, translating); } if ((x != -1) && (y != -1)) { @@ -1476,7 +1432,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) // Therefore we will have to set the point through which the constraint-line runs // individually for each point to be snapped; this will be handled however by _snapTransformed() Geom::Point cvec; cvec[dim] = 1.; - s.push_back(m.constrainedSnapTranslate(_bbox_points_for_translating, + s.push_back(m.constrainedSnapTranslate(_bbox_points, _point, Inkscape::Snapper::SnapConstraint(cvec), dxy)); @@ -1493,7 +1449,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) g_get_current_time(&starttime); */ /* Snap to things with no constraint */ - s.push_back(m.freeSnapTranslate(_bbox_points_for_translating, _point, dxy)); + s.push_back(m.freeSnapTranslate(_bbox_points, _point, dxy)); s.push_back(m.freeSnapTranslate(_snap_points, _point, dxy)); /*g_get_current_time(&endtime); @@ -1643,6 +1599,72 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineGeom(Geom::Scale const geom_scale) return _calcAbsAffineDefault(geom_scale); // this is bogus, but we must return _something_ } +void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p, bool const translating) +{ + SnapManager const &m = _desktop->namedview->snap_manager; + + if (!(m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers() || m.snapprefs.getSnapModeDatums())) { + _snap_points.clear(); + } + + if (!m.snapprefs.getSnapModeBBox()) { + _bbox_points.clear(); + } + + _all_snap_sources_sorted = _snap_points; + _all_snap_sources_sorted.insert(_all_snap_sources_sorted.end(), _bbox_points.begin(), _bbox_points.end()); + + // Calculate and store the distance to the reference point for each snap candidate point + for(std::vector<Inkscape::SnapCandidatePoint>::iterator i = _all_snap_sources_sorted.begin(); i != _all_snap_sources_sorted.end(); ++i) { + (*i).setDistance(Geom::L2((*i).getPoint() - p)); + } + + // Sort them ascending, using the distance calculated above as the single criteria + std::sort(_all_snap_sources_sorted.begin(), _all_snap_sources_sorted.end()); + + // Now get the closest snap source + _snap_points.clear(); + _bbox_points.clear(); + if (!_all_snap_sources_sorted.empty()) { + _all_snap_sources_iter = _all_snap_sources_sorted.begin(); + if (_all_snap_sources_sorted.front().getSourceType() & SNAPSOURCE_BBOX_CATEGORY) { + _bbox_points.push_back(_all_snap_sources_sorted.front()); + } else { + _snap_points.push_back(_all_snap_sources_sorted.front()); + } + } + +} + +void Inkscape::SelTrans::getNextClosestPoint(bool reverse) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/options/snapclosestonly/value", false)) { + if (!_all_snap_sources_sorted.empty()) { + if (reverse) { // Shift-tab will find a closer point + if (_all_snap_sources_iter == _all_snap_sources_sorted.begin()) { + _all_snap_sources_iter = _all_snap_sources_sorted.end(); + } + --_all_snap_sources_iter; + } else { // Tab will find a point further away + ++_all_snap_sources_iter; + if (_all_snap_sources_iter == _all_snap_sources_sorted.end()) { + _all_snap_sources_iter = _all_snap_sources_sorted.begin(); + } + } + + _snap_points.clear(); + _bbox_points.clear(); + + if ((*_all_snap_sources_iter).getSourceType() & SNAPSOURCE_BBOX_CATEGORY) { + _bbox_points.push_back(*_all_snap_sources_iter); + } else { + _snap_points.push_back(*_all_snap_sources_iter); + } + } + } +} + /* Local Variables: mode:c++ diff --git a/src/seltrans.h b/src/seltrans.h index 3a5fa006e..58764c48e 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -89,9 +89,11 @@ public: bool isGrabbed() { return _grabbed; } - bool centerIsVisible() { - return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) ); - } + bool centerIsVisible() { + return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) ); + } + + void getNextClosestPoint(bool reverse); private: void _updateHandles(); @@ -103,7 +105,7 @@ private: Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos); Geom::Point _calcAbsAffineDefault(Geom::Scale const default_scale); Geom::Point _calcAbsAffineGeom(Geom::Scale const geom_scale); - void _display_snapsource(); + void _keepClosestPointOnly(Geom::Point const &p, bool const translating); enum State { STATE_SCALE, //scale or stretch @@ -118,9 +120,9 @@ private: std::vector<Geom::Point> _items_centers; std::vector<Inkscape::SnapCandidatePoint> _snap_points; - std::vector<Inkscape::SnapCandidatePoint> _bbox_points; // the bbox point of the selection as a whole, i.e. max. 4 corners plus optionally some midpoints - std::vector<Inkscape::SnapCandidatePoint> _bbox_points_for_translating; // the bbox points of each selected item, only to be used for translating - + std::vector<Inkscape::SnapCandidatePoint> _bbox_points; + std::vector<Inkscape::SnapCandidatePoint> _all_snap_sources_sorted; + std::vector<Inkscape::SnapCandidatePoint>::iterator _all_snap_sources_iter; Inkscape::SelCue _selcue; Inkscape::Selection *_selection; diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 5302b49c9..857a2c2a4 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -71,6 +71,9 @@ public: inline Inkscape::SnapTargetType getTargetType() const {return _target_type;} inline long getSourceNum() const {return _source_num;} void setSourceNum(long num) {_source_num = num;} + void setDistance(Geom::Coord dist) {_dist = dist;} + Geom::Coord getDistance() { return _dist;} + bool operator <(const SnapCandidatePoint other) const { return _dist < other._dist; } // Needed for sorting the SnapCandidatePoints inline Geom::OptRect const getTargetBBox() const {return _target_bbox;} boost::optional<Geom::Point> const & getStartingPoint() const {return _line_starting_point;} @@ -93,6 +96,9 @@ private: // If this is a target and it belongs to a bounding box, e.g. when the target type is // SNAPTARGET_BBOX_EDGE_MIDPOINT, then _target_bbox stores the relevant bounding box Geom::OptRect _target_bbox; + + // For finding the snap candidate closest to the mouse pointer + Geom::Coord _dist; }; class SnapCandidateItem @@ -127,7 +133,5 @@ public: bool currently_being_edited; // true for the path that's currently being edited in the node tool (if any) }; - } // end of namespace Inkscape - #endif /* !SEEN_SNAP_CANDIDATE_H */ diff --git a/src/snap.cpp b/src/snap.cpp index 5f4872bba..853268b4b 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -736,7 +736,7 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector<Inkscape::Snap Inkscape::SnappedPoint result = _snapTransformed(p, pointer, false, Geom::Point(0,0), TRANSLATE, tr, Geom::Point(0,0), Geom::X, false); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -750,7 +750,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslate(std::vector<Inkscap Inkscape::SnappedPoint result = _snapTransformed(p, pointer, true, constraint, TRANSLATE, tr, Geom::Point(0,0), Geom::X, false); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -765,7 +765,7 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(std::vector<Inkscape::SnapCand Inkscape::SnappedPoint result = _snapTransformed(p, pointer, false, Geom::Point(0,0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, false); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -781,7 +781,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(std::vector<Inkscape::S Inkscape::SnappedPoint result = _snapTransformed(p, pointer, true, Geom::Point(0,0), SCALE, Geom::Point(s[Geom::X], s[Geom::Y]), o, Geom::X, true); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -797,7 +797,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(std::vector<Inkscape: Inkscape::SnappedPoint result = _snapTransformed(p, pointer, true, Geom::Point(0,0), STRETCH, Geom::Point(s, s), o, d, u); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -824,7 +824,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector<Inkscape::Sn Inkscape::SnappedPoint result = _snapTransformed(p, pointer, true, constraint, SKEW, s, o, d, false); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -844,7 +844,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector<Inkscape:: Inkscape::SnappedPoint result = _snapTransformed(p, pointer, true, Geom::Point(0,0), ROTATE, Geom::Point(angle, angle), o, Geom::X, false); if (p.size() == 1) { - _displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); + displaySnapsource(Inkscape::SnapCandidatePoint(result.getPoint(), p.at(0).getSourceType())); } return result; @@ -1109,14 +1109,19 @@ Geom::Point SnapManager::_transformPoint(Inkscape::SnapCandidatePoint const &p, return transformed; } -void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) const { - +/** + * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. + * + * @param point_type Category of points to which the source point belongs: node, guide or bounding box + * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. + */ +void SnapManager::displaySnapsource(Inkscape::SnapCandidatePoint const &p) const { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/snapclosestonly/value")) { Inkscape::SnapSourceType t = p.getSourceType(); bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY; bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY || t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY; + bool p_is_other = (t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY) || (t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY); g_assert(_desktop != NULL); if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { @@ -1126,34 +1131,6 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons } } } - -void SnapManager::keepClosestPointOnly(std::vector<Inkscape::SnapCandidatePoint> &points, const Geom::Point &reference) const -{ - if (points.size() == 0) { - return; - } - - if (points.size() == 1) { - points.front().setSourceNum(-1); // Just in case - return; - } - - Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(Geom::infinity(), Geom::infinity()), Inkscape::SNAPSOURCE_UNDEFINED, Inkscape::SNAPTARGET_UNDEFINED); - Geom::Coord closest_dist = Geom::infinity(); - - for(std::vector<Inkscape::SnapCandidatePoint>::const_iterator i = points.begin(); i != points.end(); i++) { - Geom::Coord dist = Geom::L2((*i).getPoint() - reference); - if (i == points.begin() || dist < closest_dist) { - closest_point = *i; - closest_dist = dist; - } - } - - closest_point.setSourceNum(-1); - points.clear(); - points.push_back(closest_point); -} - /* Local Variables: mode:c++ diff --git a/src/snap.h b/src/snap.h index fffbbdf6a..3eb4c2b7a 100644 --- a/src/snap.h +++ b/src/snap.h @@ -476,7 +476,13 @@ public: */ Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, IntermSnapResults const &isr, bool constrained, bool allowOffScreen = false) const; - void keepClosestPointOnly(std::vector<Inkscape::SnapCandidatePoint> &points, const Geom::Point &reference) const; + /** + * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. + * + * @param point_type Category of points to which the source point belongs: node, guide or bounding box. + * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. + */ + void displaySnapsource(Inkscape::SnapCandidatePoint const &p) const; protected: SPNamedView const *_named_view; @@ -543,13 +549,6 @@ private: Geom::Dim2 const dim, bool const uniform) const; - /** - * Mark the location of the snap source (not the snap target!) on the canvas by drawing a symbol. - * - * @param point_type Category of points to which the source point belongs: node, guide or bounding box. - * @param p The transformed position of the source point, paired with an identifier of the type of the snap source. - */ - void _displaySnapsource(Inkscape::SnapCandidatePoint const &p) const; }; #endif // !SEEN_SNAP_H diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 1a1aee47c..308359c33 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -675,7 +675,6 @@ void ControlPointSelection::setOriginalPoints() } } - } // namespace UI } // namespace Inkscape diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index 81cb53f6f..79d70d453 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -22,6 +22,7 @@ #include "preferences.h" #include "ui/tool/control-point.h" #include "ui/tool/event-utils.h" +#include "ui/tool/transform-handle-set.h" namespace Inkscape { namespace UI { @@ -437,6 +438,32 @@ bool ControlPoint::_eventHandler(GdkEvent *event) // update tips on modifier state change // TODO add ESC keybinding as drag cancel case GDK_KEY_PRESS: + switch (get_group0_keyval(&event->key)) + { + case GDK_Tab: + {// Downcast from ControlPoint to TransformHandle, if possible + // This is an ugly hack; we should have the transform handle intercept the keystrokes itself + TransformHandle *th = dynamic_cast<TransformHandle*>(this); + if (th) { + th->getNextClosestPoint(false); + return true; + } + break; + } + case GDK_ISO_Left_Tab: + {// Downcast from ControlPoint to TransformHandle, if possible + // This is an ugly hack; we should have the transform handle intercept the keystrokes itself + TransformHandle *th = dynamic_cast<TransformHandle*>(this); + if (th) { + th->getNextClosestPoint(true); + return true; + } + break; + } + default: + break; + } + // Do not break here, to allow for updating tooltips and such case GDK_KEY_RELEASE: if (mouseovered_point != this) return false; if (_drag_initiated) { diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 58f064b9a..7a12f4fbd 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -84,72 +84,101 @@ ControlPoint::ColorSet center_cset = { } // anonymous namespace /** Base class for node transform handles to simplify implementation */ -class TransformHandle : public ControlPoint { -public: - TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pb) - : ControlPoint(th._desktop, Geom::Point(), anchor, pb, &thandle_cset, - th._transform_handle_group) - , _th(th) - { - setVisible(false); +TransformHandle::TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pb) + : ControlPoint(th._desktop, Geom::Point(), anchor, pb, &thandle_cset, + th._transform_handle_group) + , _th(th) +{ + setVisible(false); +} + +void TransformHandle::getNextClosestPoint(bool reverse) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/options/snapclosestonly/value", false)) { + if (!_all_snap_sources_sorted.empty()) { + if (reverse) { // Shift-tab will find a closer point + if (_all_snap_sources_iter == _all_snap_sources_sorted.begin()) { + _all_snap_sources_iter = _all_snap_sources_sorted.end(); + } + --_all_snap_sources_iter; + } else { // Tab will find a point further away + ++_all_snap_sources_iter; + if (_all_snap_sources_iter == _all_snap_sources_sorted.end()) { + _all_snap_sources_iter = _all_snap_sources_sorted.begin(); + } + } + + _snap_points.clear(); + _snap_points.push_back(*_all_snap_sources_iter); + + } } -protected: - virtual void startTransform() {} - virtual void endTransform() {} - virtual Geom::Affine computeTransform(Geom::Point const &pos, GdkEventMotion *event) = 0; - virtual CommitEvent getCommitEvent() = 0; +} - Geom::Affine _last_transform; - Geom::Point _origin; - TransformHandleSet &_th; - std::vector<Inkscape::SnapCandidatePoint> _snap_points; - std::vector<Inkscape::SnapCandidatePoint> _unselected_points; +bool TransformHandle::grabbed(GdkEventMotion *) +{ + _origin = position(); + _last_transform.setIdentity(); + startTransform(); -private: - virtual bool grabbed(GdkEventMotion *) { - _origin = position(); - _last_transform.setIdentity(); - startTransform(); - - _th._setActiveHandle(this); - _cset = &invisible_cset; - _setState(_state); - - // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. - SnapManager &m = _th._desktop->namedview->snap_manager; - InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); - - selection->setOriginalPoints(); - selection->getOriginalPoints(_snap_points); - selection->getUnselectedPoints(_unselected_points); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (prefs->getBool("/options/snapclosestonly/value", false)) { - m.keepClosestPointOnly(_snap_points, _origin); + _th._setActiveHandle(this); + _cset = &invisible_cset; + _setState(_state); + + // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. + InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); + ControlPointSelection *selection = nt->_selected_nodes.get(); + + selection->setOriginalPoints(); + selection->getOriginalPoints(_snap_points); + selection->getUnselectedPoints(_unselected_points); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/options/snapclosestonly/value", false)) { + // Find the closest snap source candidate + _all_snap_sources_sorted = _snap_points; + + // Calculate and store the distance to the reference point for each snap candidate point + for(std::vector<Inkscape::SnapCandidatePoint>::iterator i = _all_snap_sources_sorted.begin(); i != _all_snap_sources_sorted.end(); ++i) { + (*i).setDistance(Geom::L2((*i).getPoint() - _origin)); } - return false; - } - virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event) - { - Geom::Affine t = computeTransform(new_pos, event); - // protect against degeneracies - if (t.isSingular()) return; - Geom::Affine incr = _last_transform.inverse() * t; - if (incr.isSingular()) return; - _th.signal_transform.emit(incr); - _last_transform = t; - } - virtual void ungrabbed(GdkEventButton *) { + // Sort them ascending, using the distance calculated above as the single criteria + std::sort(_all_snap_sources_sorted.begin(), _all_snap_sources_sorted.end()); + + // Now get the closest snap source _snap_points.clear(); - _th._clearActiveHandle(); - _cset = &thandle_cset; - _setState(_state); - endTransform(); - _th.signal_commit.emit(getCommitEvent()); + if (!_all_snap_sources_sorted.empty()) { + _all_snap_sources_iter = _all_snap_sources_sorted.begin(); + _snap_points.push_back(_all_snap_sources_sorted.front()); + } } -}; + + return false; +} + +void TransformHandle::dragged(Geom::Point &new_pos, GdkEventMotion *event) +{ + Geom::Affine t = computeTransform(new_pos, event); + // protect against degeneracies + if (t.isSingular()) return; + Geom::Affine incr = _last_transform.inverse() * t; + if (incr.isSingular()) return; + _th.signal_transform.emit(incr); + _last_transform = t; +} + +void TransformHandle::ungrabbed(GdkEventButton *) +{ + _snap_points.clear(); + _th._clearActiveHandle(); + _cset = &thandle_cset; + _setState(_state); + endTransform(); + _th.signal_commit.emit(getCommitEvent()); +} + class ScaleHandle : public TransformHandle { public: diff --git a/src/ui/tool/transform-handle-set.h b/src/ui/tool/transform-handle-set.h index 0557b1278..8ce7011c5 100644 --- a/src/ui/tool/transform-handle-set.h +++ b/src/ui/tool/transform-handle-set.h @@ -78,6 +78,32 @@ private: friend class RotationCenter; }; +/** Base class for node transform handles to simplify implementation */ +class TransformHandle : public ControlPoint { +public: + TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pb); + void getNextClosestPoint(bool reverse); + +protected: + virtual void startTransform() {} + virtual void endTransform() {} + virtual Geom::Affine computeTransform(Geom::Point const &pos, GdkEventMotion *event) = 0; + virtual CommitEvent getCommitEvent() = 0; + + Geom::Affine _last_transform; + Geom::Point _origin; + TransformHandleSet &_th; + std::vector<Inkscape::SnapCandidatePoint> _snap_points; + std::vector<Inkscape::SnapCandidatePoint> _unselected_points; + std::vector<Inkscape::SnapCandidatePoint> _all_snap_sources_sorted; + std::vector<Inkscape::SnapCandidatePoint>::iterator _all_snap_sources_iter; + +private: + virtual bool grabbed(GdkEventMotion *); + virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event); + virtual void ungrabbed(GdkEventButton *); +}; + } // namespace UI } // namespace Inkscape -- cgit v1.2.3 From 7b1b14913ac759e86176d212afa6d90f67eb8bb6 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 5 Nov 2011 08:20:36 +0100 Subject: Various fixes: initialization, memory leak, wrong iterator usage (bzr r10721) --- src/composite-undo-stack-observer.cpp | 14 ++++++++++---- src/dom/views.h | 19 ++++++++++++------- src/snap-candidate.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/composite-undo-stack-observer.cpp b/src/composite-undo-stack-observer.cpp index 383e08cd8..81a0b27c7 100644 --- a/src/composite-undo-stack-observer.cpp +++ b/src/composite-undo-stack-observer.cpp @@ -137,16 +137,22 @@ CompositeUndoStackObserver::_unlock() if (!--this->_iterating) { // Remove marked observers UndoObserverRecordList::iterator i = this->_active.begin(); - for(; i != this->_active.begin(); ++i) { + for(; i != this->_active.begin(); ) { if (i->to_remove) { - this->_active.erase(i); + i = this->_active.erase(i); + } + else{ + ++i; } } i = this->_pending.begin(); - for(; i != this->_pending.begin(); ++i) { + for(; i != this->_pending.begin(); ) { if (i->to_remove) { - this->_active.erase(i); + i = this->_active.erase(i); + } + else { + ++i; } } diff --git a/src/dom/views.h b/src/dom/views.h index 48afd5d16..f165d2a9b 100644 --- a/src/dom/views.h +++ b/src/dom/views.h @@ -125,12 +125,14 @@ public: private: void assign(const AbstractView &other) + { + if (documentView != NULL) { + free(documentView); //NOTE: is free the correct method? + } documentView = other.documentView; - } - - DocumentView *documentView; - + } + DocumentView *documentView; }; @@ -163,7 +165,7 @@ public: /** * */ - DocumentView() {} + DocumentView() {defaultView = NULL;} /** * @@ -190,10 +192,13 @@ public: private: void assign(const DocumentView &other) + { + if (defaultView != NULL) { + free(defaultView); //NOTE: is free the correct method? + } defaultView = other.defaultView; - } - + } AbstractView *defaultView; }; diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 857a2c2a4..1c5cf3234 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -73,7 +73,7 @@ public: void setSourceNum(long num) {_source_num = num;} void setDistance(Geom::Coord dist) {_dist = dist;} Geom::Coord getDistance() { return _dist;} - bool operator <(const SnapCandidatePoint other) const { return _dist < other._dist; } // Needed for sorting the SnapCandidatePoints + bool operator <(const SnapCandidatePoint &other) const { return _dist < other._dist; } // Needed for sorting the SnapCandidatePoints inline Geom::OptRect const getTargetBBox() const {return _target_bbox;} boost::optional<Geom::Point> const & getStartingPoint() const {return _line_starting_point;} -- cgit v1.2.3 From b46cc1a396cacef9d38411aa7639518afaebf891 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sat, 5 Nov 2011 03:04:17 -0700 Subject: Minor code safety and warning cleanup. (bzr r10722) --- src/measure-context.cpp | 8 ++++---- src/seltrans.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 1197927f4..8d33608a0 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -392,11 +392,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } { - SPCanvasItem *canvas_tooltip; // TODO cleanup memory, Glib::ustring, etc.: char* angle_str = static_cast<char*>(malloc(20)); sprintf(angle_str, "%.2f °", angle * 180/M_PI); - canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str); sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x337f337f; @@ -405,13 +404,14 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv measure_tmp_items.push_back(desktop->add_temporary_canvasitem(canvas_tooltip, 0)); free(angle_str); - + } + { double totallengthval = (end_point - start_point).length(); sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); char* totallength_str = static_cast<char*>(malloc(20)); sprintf(totallength_str, "%.2f %s", totallengthval, unit.abbr); - canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,-2*fontsize)), totallength_str); + SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(5*fontsize,-2*fontsize)), totallength_str); sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x3333337f; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 4889f7dc1..84cd5574e 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1599,7 +1599,7 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineGeom(Geom::Scale const geom_scale) return _calcAbsAffineDefault(geom_scale); // this is bogus, but we must return _something_ } -void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p, bool const translating) +void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p, bool const /*translating*/) { SnapManager const &m = _desktop->namedview->snap_manager; -- cgit v1.2.3 From 9c742405cf7d906a14ab5003a612b37d4c496849 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop <mail@diedenrezi.nl> Date: Sat, 5 Nov 2011 20:53:36 +0100 Subject: Remove unused parameter (bzr r10723) --- src/seltrans.cpp | 4 ++-- src/seltrans.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 84cd5574e..cb8270bf2 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -360,7 +360,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // (i.e. when weight == 1), then we will not even try to snap to other points and disregard those other points if (prefs->getBool("/options/snapclosestonly/value", false)) { - _keepClosestPointOnly(p, translating); + _keepClosestPointOnly(p); } if ((x != -1) && (y != -1)) { @@ -1599,7 +1599,7 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineGeom(Geom::Scale const geom_scale) return _calcAbsAffineDefault(geom_scale); // this is bogus, but we must return _something_ } -void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p, bool const /*translating*/) +void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p) { SnapManager const &m = _desktop->namedview->snap_manager; diff --git a/src/seltrans.h b/src/seltrans.h index 58764c48e..3804caef3 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -105,7 +105,7 @@ private: Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos); Geom::Point _calcAbsAffineDefault(Geom::Scale const default_scale); Geom::Point _calcAbsAffineGeom(Geom::Scale const geom_scale); - void _keepClosestPointOnly(Geom::Point const &p, bool const translating); + void _keepClosestPointOnly(Geom::Point const &p); enum State { STATE_SCALE, //scale or stretch -- cgit v1.2.3 From 8843d5284ad2b880ef249d84c583958a1a93dc6c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sat, 5 Nov 2011 22:55:14 +0100 Subject: increase significant digits for page dimensions Fixed bugs: - https://launchpad.net/bugs/171980 (bzr r10724) --- src/ui/widget/page-sizer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index a6b0fb76d..0b18f1039 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -241,6 +241,14 @@ PageSizer::PageSizer(Registry & _wr) _lockMarginUpdate(false), _widgetRegistry(&_wr) { + // set precision of scalar entry boxes + _dimensionWidth.setDigits(5); + _dimensionHeight.setDigits(5); + _marginTop.setDigits(5); + _marginLeft.setDigits(5); + _marginRight.setDigits(5); + _marginBottom.setDigits(5); + //# Set up the Paper Size combo box _paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns); _paperSizeList.set_model(_paperSizeListStore); -- cgit v1.2.3 From 41b56e11fb939c3fd20723e14ef0f3f34c8c8797 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sat, 5 Nov 2011 23:28:36 +0100 Subject: increase significant digits in clone tile dialog Fixed bugs: - https://launchpad.net/bugs/171980 (bzr r10725) --- src/dialogs/clonetiler.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index a92b6392e..29098abf6 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1517,7 +1517,8 @@ static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double } gtk_widget_set_tooltip_text (sb, tip); - gtk_entry_set_width_chars (GTK_ENTRY (sb), 4); + gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(sb), 3); gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2681,7 +2682,7 @@ void clonetiler_dialog(void) gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0); gtk_widget_set_tooltip_text (sb, _("How many rows in the tiling")); - gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); + gtk_entry_set_width_chars (GTK_ENTRY (sb), 7); gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(a), "value_changed", @@ -2701,7 +2702,7 @@ void clonetiler_dialog(void) gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value); GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0); gtk_widget_set_tooltip_text (sb, _("How many columns in the tiling")); - gtk_entry_set_width_chars (GTK_ENTRY (sb), 5); + gtk_entry_set_width_chars (GTK_ENTRY (sb), 7); gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(a), "value_changed", @@ -2731,7 +2732,8 @@ void clonetiler_dialog(void) GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2); gtk_widget_set_tooltip_text (e, _("Width of the rectangle to be filled")); - gtk_entry_set_width_chars (GTK_ENTRY (e), 5); + gtk_entry_set_width_chars (GTK_ENTRY (e), 7); + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(e), 4); gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(a), "value_changed", G_CALLBACK(clonetiler_fill_width_changed), u); @@ -2756,7 +2758,8 @@ void clonetiler_dialog(void) GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2); gtk_widget_set_tooltip_text (e, _("Height of the rectangle to be filled")); - gtk_entry_set_width_chars (GTK_ENTRY (e), 5); + gtk_entry_set_width_chars (GTK_ENTRY (e), 7); + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(e), 4); gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(a), "value_changed", G_CALLBACK(clonetiler_fill_height_changed), u); -- cgit v1.2.3 From 9b817fee1a7d83afe4084158cf1613dfe6bc6450 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sat, 5 Nov 2011 23:58:52 +0100 Subject: increase max values in rows&cols dialog. increase significant digits Fixed bugs: - https://launchpad.net/bugs/268576 (bzr r10726) --- src/ui/dialog/tile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 5f19a2613..9d1e314f7 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -665,7 +665,7 @@ TileDialog::TileDialog() NoOfRowsSpinner.set_digits(0); NoOfRowsSpinner.set_increments(1, 0); - NoOfRowsSpinner.set_range(1.0, 100.0); + NoOfRowsSpinner.set_range(1.0, 10000.0); NoOfRowsSpinner.set_value(PerCol); NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_col_spinbutton_changed)); tips.set_tip(NoOfRowsSpinner, _("Number of rows")); @@ -737,7 +737,7 @@ TileDialog::TileDialog() NoOfColsSpinner.set_digits(0); NoOfColsSpinner.set_increments(1, 0); - NoOfColsSpinner.set_range(1.0, 100.0); + NoOfColsSpinner.set_range(1.0, 10000.0); NoOfColsSpinner.set_value(PerRow); NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_row_spinbutton_changed)); tips.set_tip(NoOfColsSpinner, _("Number of columns")); @@ -819,14 +819,14 @@ TileDialog::TileDialog() { /*#### Padding ####*/ - YPadding.setDigits(1); + YPadding.setDigits(5); YPadding.setIncrements(0.2, 0); YPadding.setRange(-10000, 10000); double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); YPadding.setValue(yPad, "px"); YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - XPadding.setDigits(1); + XPadding.setDigits(5); XPadding.setIncrements(0.2, 0); XPadding.setRange(-10000, 10000); double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); -- cgit v1.2.3 From 326caf26ec1e9819d1ca34cc1992b16b23b2a977 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sun, 6 Nov 2011 00:05:56 +0100 Subject: fix LPE toggle icon (bzr r10727) --- src/ui/dialog/livepatheffect-editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 3c5d3f1a2..b48022360 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -139,7 +139,7 @@ LivePathEffectEditor::LivePathEffectEditor() //Add the visibility icon column: Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-visible")) ); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1; eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) ); eyeRenderer->property_activatable() = true; -- cgit v1.2.3 From d98a89be688002c6fb69775a324af6669203090a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sun, 6 Nov 2011 00:46:09 +0100 Subject: Powerstroke: adjust control points when adding or deleting knots, to try and keep the shape a bit the same... (bzr r10728) --- src/live_effects/lpe-powerstroke.cpp | 11 +++++-- src/live_effects/lpe-powerstroke.h | 3 ++ .../parameter/powerstrokepointarray.cpp | 36 ++++++++++++++++++++++ src/live_effects/parameter/powerstrokepointarray.h | 5 +-- src/ui/tool/curve-drag-point.cpp | 2 +- src/ui/tool/multi-path-manipulator.cpp | 18 +++++------ src/ui/tool/multi-path-manipulator.h | 4 +-- src/ui/tool/path-manipulator.cpp | 34 +++++++++++++++----- src/ui/tool/path-manipulator.h | 4 +-- 9 files changed, 90 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 74a594a4b..56248907c 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -301,7 +301,7 @@ enum LineCuspType { static const Util::EnumData<unsigned> LineCuspTypeData[] = { {LINECUSP_BEVEL , N_("Beveled"), "bevel"}, {LINECUSP_ROUND , N_("Rounded"), "round"}, - {LINECUSP_SHARP , N_("Sharp"), "sharp"} +// not yet supported {LINECUSP_SHARP , N_("Sharp"), "sharp"} }; static const Util::EnumDataConverter<unsigned> LineCuspTypeConverter(LineCuspTypeData, sizeof(LineCuspTypeData)/sizeof(*LineCuspTypeData)); @@ -343,6 +343,12 @@ LPEPowerStroke::doOnApply(SPLPEItem *lpeitem) offset_points.param_set_and_write_new_value(points); } +void +LPEPowerStroke::adjustForNewPath(std::vector<Geom::Path> const & path_in) +{ + offset_points.recalculate_controlpoints_for_new_pwd2(path_in[0].toPwSb()); +} + static bool compare_offsets (Geom::Point first, Geom::Point second) { return first[Geom::X] < second[Geom::X]; @@ -435,10 +441,9 @@ LPEPowerStroke::doEffect_path (std::vector<Geom::Path> const & path_in) // for now, only regard first subpath and ignore the rest Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = path_in[0].toPwSb(); - offset_points.set_pwd2(pwd2_in); Piecewise<D2<SBasis> > der = unitVector(derivative(pwd2_in)); Piecewise<D2<SBasis> > n = rot90(der); - offset_points.set_pwd2_normal(n); + offset_points.set_pwd2(pwd2_in, n); std::vector<Geom::Point> ts = offset_points.data(); if (sort_points) { diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index bcfbdadc0..6c005f792 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -29,6 +29,9 @@ public: virtual void doOnApply(SPLPEItem *lpeitem); + // methods called by path-manipulator upon edits + void adjustForNewPath(std::vector<Geom::Path> const & path_in); + private: PowerStrokePointArrayParam offset_points; BoolParam sort_points; diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 5139f0e41..fccbad7e5 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -76,6 +76,42 @@ void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& /* } +/** call this method to recalculate the controlpoints such that they stay at the same location relative to the new path. Useful after adding/deleting nodes to the path.*/ +void +PowerStrokePointArrayParam::recalculate_controlpoints_for_new_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) +{ + if (!last_pwd2.empty()) { + if (last_pwd2.size() > pwd2_in.size()) { + // Path has become shorter: rescale offsets + double factor = (double)pwd2_in.size() / (double)last_pwd2.size(); + for (unsigned int i = 0; i < _vector.size(); ++i) { + _vector[i][Geom::X] *= factor; + } + } else if (last_pwd2.size() < pwd2_in.size()) { + // Path has become longer: probably node added, maintain position of knots + Geom::Piecewise<Geom::D2<Geom::SBasis> > normal = rot90(unitVector(derivative(pwd2_in))); + for (unsigned int i = 0; i < _vector.size(); ++i) { + Geom::Point pt = _vector[i]; + Geom::Point position = last_pwd2.valueAt(pt[Geom::X]) + pt[Geom::Y] * last_pwd2_normal.valueAt(pt[Geom::X]); + + double t = nearest_point(position, pwd2_in); + double offset = dot(position - pwd2_in.valueAt(t), normal.valueAt(t)); + _vector[i] = Geom::Point(t, offset); + } + } + + write_to_SVG(); + } +} + +void +PowerStrokePointArrayParam::set_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in, Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_normal_in) +{ + last_pwd2 = pwd2_in; + last_pwd2_normal = pwd2_normal_in; +} + + void PowerStrokePointArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index d984a7de5..550866384 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -43,11 +43,12 @@ public: virtual bool providesKnotHolderEntities() { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - void set_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) { last_pwd2 = pwd2_in; } + void set_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in, Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_normal_in); Geom::Piecewise<Geom::D2<Geom::SBasis> > const & get_pwd2() { return last_pwd2; } - void set_pwd2_normal(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) { last_pwd2_normal = pwd2_in; } Geom::Piecewise<Geom::D2<Geom::SBasis> > const & get_pwd2_normal() { return last_pwd2_normal; } + void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); + friend class PowerStrokePointArrayParamKnotHolderEntity; private: diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index a3fb5aa6e..8dafb55d7 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -153,7 +153,7 @@ void CurveDragPoint::_insertNode(bool take_selection) } _pm._selection.insert(inserted.ptr()); - _pm.update(); + _pm.update(true); _pm._commit(_("Add node")); } diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 27418d302..2316058ed 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -402,21 +402,21 @@ void MultiPathManipulator::joinNodes() invokeForAll(&PathManipulator::weldNodes, preserve_pos); } - _doneWithCleanup(_("Join nodes")); + _doneWithCleanup(_("Join nodes"), true); } void MultiPathManipulator::breakNodes() { if (_selection.empty()) return; invokeForAll(&PathManipulator::breakNodes); - _done(_("Break nodes")); + _done(_("Break nodes"), true); } void MultiPathManipulator::deleteNodes(bool keep_shape) { if (_selection.empty()) return; invokeForAll(&PathManipulator::deleteNodes, keep_shape); - _doneWithCleanup(_("Delete nodes")); + _doneWithCleanup(_("Delete nodes"), true); } /** Join selected endpoints to create segments. */ @@ -442,14 +442,14 @@ void MultiPathManipulator::joinSegments() if (joins.empty()) { invokeForAll(&PathManipulator::weldSegments); } - _doneWithCleanup("Join segments"); + _doneWithCleanup("Join segments", true); } void MultiPathManipulator::deleteSegments() { if (_selection.empty()) return; invokeForAll(&PathManipulator::deleteSegments); - _doneWithCleanup("Delete segments"); + _doneWithCleanup("Delete segments", true); } void MultiPathManipulator::alignNodes(Geom::Dim2 d) @@ -801,17 +801,17 @@ void MultiPathManipulator::_commit(CommitEvent cps) } /** Commits changes to XML and adds undo stack entry. */ -void MultiPathManipulator::_done(gchar const *reason) { - invokeForAll(&PathManipulator::update); +void MultiPathManipulator::_done(gchar const *reason, bool alert_LPE) { + invokeForAll(&PathManipulator::update, alert_LPE); invokeForAll(&PathManipulator::writeXML); DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); signal_coords_changed.emit(); } /** Commits changes to XML, adds undo stack entry and removes empty manipulators. */ -void MultiPathManipulator::_doneWithCleanup(gchar const *reason) { +void MultiPathManipulator::_doneWithCleanup(gchar const *reason, bool alert_LPE) { _changed.block(); - _done(reason); + _done(reason, alert_LPE); cleanup(); _changed.unblock(); } diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h index 29b618b5f..6b5686139 100644 --- a/src/ui/tool/multi-path-manipulator.h +++ b/src/ui/tool/multi-path-manipulator.h @@ -102,8 +102,8 @@ private: } void _commit(CommitEvent cps); - void _done(gchar const *); - void _doneWithCleanup(gchar const *); + void _done(gchar const *reason, bool alert_LPE = false); + void _doneWithCleanup(gchar const *reason, bool alert_LPE = false); guint32 _getOutlineColor(ShapeRole role); MapType _mmap; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index a7369f915..96b3a1bb1 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -30,7 +30,9 @@ #include "document.h" #include "live_effects/effect.h" #include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" +#include "live_effects/lpe-powerstroke.h" #include "sp-path.h" #include "helper/geom.h" #include "preferences.h" @@ -137,7 +139,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(_outline), 0, SP_WIND_RULE_NONZERO); _selection.signal_update.connect( - sigc::mem_fun(*this, &PathManipulator::update)); + sigc::bind(sigc::mem_fun(*this, &PathManipulator::update), false)); _selection.signal_point_changed.connect( sigc::mem_fun(*this, &PathManipulator::_selectionChanged)); _desktop->signal_zoom_changed.connect( @@ -175,10 +177,12 @@ bool PathManipulator::empty() { return !_path || _subpaths.empty(); } -/** Update the display and the outline of the path. */ -void PathManipulator::update() +/** Update the display and the outline of the path. + * \param alert_LPE if true, alerts an applied LPE to what the path is going to be changed to, so it can adjust its parameters for nicer user interfacing + */ +void PathManipulator::update(bool alert_LPE) { - _createGeometryFromControlPoints(); + _createGeometryFromControlPoints(alert_LPE); } /** Store the changes to the path in XML. */ @@ -1094,8 +1098,10 @@ void PathManipulator::_createControlPointsFromGeometry() } /** Construct the geometric representation of nodes and handles, update the outline - * and display */ -void PathManipulator::_createGeometryFromControlPoints() + * and display + * \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it + */ +void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) { Geom::PathBuilder builder; for (std::list<SubpathPtr>::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) { @@ -1123,7 +1129,18 @@ void PathManipulator::_createGeometryFromControlPoints() ++spi; } builder.finish(); - _spcurve->set_pathvector(builder.peek() * (_edit_transform * _i2d_transform).inverse()); + Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); + _spcurve->set_pathvector(pathv); + if (alert_LPE) { + if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { + PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast<LivePathEffect::LPEPowerStroke*>( effect_list.front()->lpeobject->get_lpe() ); + if (lpe_pwr) { + lpe_pwr->adjustForNewPath(pathv); + } + } + } + if (_live_outline) _updateOutline(); if (_live_objects) @@ -1281,8 +1298,9 @@ bool PathManipulator::_nodeClicked(Node *n, GdkEventButton *event) } if (!empty()) { - update(); + update(true); } + // We need to call MPM's method because it could have been our last node _multi_path_manipulator._doneWithCleanup(_("Delete node")); diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index edaf5a8de..e3b724e37 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -60,7 +60,7 @@ public: bool empty(); void writeXML(); - void update(); // update display, but don't commit + void update(bool alert_LPE = false); // update display, but don't commit void clear(); // remove all nodes from manipulator SPPath *item() { return _path; } @@ -102,7 +102,7 @@ private: typedef boost::shared_ptr<NodeList> SubpathPtr; void _createControlPointsFromGeometry(); - void _createGeometryFromControlPoints(); + void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); void _updateOutline(); -- cgit v1.2.3 From 5e7d96110e0c4b19b7e1b05e949f70673358be05 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Mon, 7 Nov 2011 15:03:20 +0100 Subject: cppcheck: performance and initialisation (bzr r10729) --- src/dom/css.h | 3 ++- src/dom/domimpl.cpp | 4 ++-- src/dom/uri.cpp | 19 ++++++++++--------- src/dom/util/digest.h | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/dom/css.h b/src/dom/css.h index 4459a1006..3f0af9ad0 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -390,7 +390,7 @@ public: /** * */ - CSSStyleSheet() : stylesheets::StyleSheet() + CSSStyleSheet() : stylesheets::StyleSheet(), ownerRule(0) { } @@ -1217,6 +1217,7 @@ public: */ void assign(const CSSImportRule &other) { + href = other.href; mediaList = other.mediaList; styleSheet = other.styleSheet; } diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 53118b1d9..1a562e5c6 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -2077,7 +2077,7 @@ void UserDataHandlerImpl::handle(unsigned short /*operation*/, /** * */ -DOMErrorImpl::DOMErrorImpl() +DOMErrorImpl::DOMErrorImpl() : message(""), severity(0), type("") { } @@ -2183,7 +2183,7 @@ bool DOMErrorHandlerImpl::handleError(const DOMError *error) /** * */ -DOMLocatorImpl::DOMLocatorImpl() +DOMLocatorImpl::DOMLocatorImpl() : byteOffset(0), columnNumber (0), uri(""), lineNumber(0), relatedNode(0), utf16Offset(0) { } diff --git a/src/dom/uri.cpp b/src/dom/uri.cpp index d559dffeb..e1089017d 100644 --- a/src/dom/uri.cpp +++ b/src/dom/uri.cpp @@ -144,6 +144,7 @@ void URI::init() scheme = SCHEME_NONE; schemeStr.clear(); port = 0; + portSpecified = false; authority.clear(); path.clear(); absolute = false; @@ -200,18 +201,18 @@ static DOMString toStr(const std::vector<int> &arr) DOMString URI::toString() const { DOMString str = schemeStr; - if (authority.size() > 0) + if (!authority.empty()) { str.append("//"); str.append(toStr(authority)); } str.append(toStr(path)); - if (query.size() > 0) + if (!query.empty()) { str.append("?"); str.append(toStr(query)); } - if (fragment.size() > 0) + if (!fragment.empty()) { str.append("#"); str.append(toStr(fragment)); @@ -380,11 +381,11 @@ URI URI::resolve(const URI &other) const return other; //## 2 - if (other.fragment.size() > 0 && - other.path.size() == 0 && - other.scheme == SCHEME_NONE && - other.authority.size() == 0 && - other.query.size() == 0 ) + if (!other.fragment.empty() && + other.path.empty() && + other.scheme == SCHEME_NONE && + other.authority.empty() && + other.query.empty()) { URI fragUri = *this; fragUri.fragment = other.fragment; @@ -398,7 +399,7 @@ URI URI::resolve(const URI &other) const newUri.schemeStr = schemeStr; newUri.query = other.query; newUri.fragment = other.fragment; - if (other.authority.size() > 0) + if (!other.authority.empty()) { //# 3.2 if (absolute || other.absolute) diff --git a/src/dom/util/digest.h b/src/dom/util/digest.h index fed5b7e86..c161b86bb 100644 --- a/src/dom/util/digest.h +++ b/src/dom/util/digest.h @@ -146,8 +146,8 @@ public: /** * Append a byte vector to the hash */ - virtual void append(const std::vector<unsigned char> buf) - { + virtual void append(const std::vector<unsigned char> &buf) + { //NOTE: function seems to be unused for (unsigned int i=0 ; i<buf.size() ; i++) update(buf[i]); } -- cgit v1.2.3 From 60a0aff288154cbff0db5867e624da8add39f0c6 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Mon, 7 Nov 2011 21:52:09 -0800 Subject: Fixed initialization order. (bzr r10730) --- src/dom/domimpl.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 1a562e5c6..1d562005f 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -2077,7 +2077,10 @@ void UserDataHandlerImpl::handle(unsigned short /*operation*/, /** * */ -DOMErrorImpl::DOMErrorImpl() : message(""), severity(0), type("") +DOMErrorImpl::DOMErrorImpl() : + severity(0), + message(), + type() { } @@ -2183,7 +2186,13 @@ bool DOMErrorHandlerImpl::handleError(const DOMError *error) /** * */ -DOMLocatorImpl::DOMLocatorImpl() : byteOffset(0), columnNumber (0), uri(""), lineNumber(0), relatedNode(0), utf16Offset(0) +DOMLocatorImpl::DOMLocatorImpl() : + lineNumber(0), + columnNumber(0), + byteOffset(0), + utf16Offset(0), + relatedNode(0), + uri() { } -- cgit v1.2.3 From b1e076e2e3199b4242231f567e1d8dd2af56d214 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Tue, 8 Nov 2011 21:56:10 +0100 Subject: split interpolator code from main powerstroke code (bzr r10732) --- src/live_effects/CMakeLists.txt | 1 + src/live_effects/Makefile_insert | 1 + src/live_effects/lpe-powerstroke-interpolators.h | 276 +++++++++++++++++++++++ src/live_effects/lpe-powerstroke.cpp | 244 +------------------- 4 files changed, 279 insertions(+), 243 deletions(-) create mode 100644 src/live_effects/lpe-powerstroke-interpolators.h (limited to 'src') diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 01cd7f25f..94112a52e 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -84,6 +84,7 @@ set(live_effects_SRC lpe-perp_bisector.h lpe-perspective_path.h lpe-powerstroke.h + lpe-powerstroke-interpolators.h lpe-recursiveskeleton.h lpe-rough-hatches.h lpe-ruler.h diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index aacabc2db..692503201 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -69,6 +69,7 @@ ink_common_sources += \ live_effects/lpe-copy_rotate.h \ live_effects/lpe-powerstroke.cpp \ live_effects/lpe-powerstroke.h \ + live_effects/lpe-powerstroke-interpolators.h \ live_effects/lpe-offset.cpp \ live_effects/lpe-offset.h \ live_effects/lpe-ruler.cpp \ diff --git a/src/live_effects/lpe-powerstroke-interpolators.h b/src/live_effects/lpe-powerstroke-interpolators.h new file mode 100644 index 000000000..88bc13ff2 --- /dev/null +++ b/src/live_effects/lpe-powerstroke-interpolators.h @@ -0,0 +1,276 @@ +/** @file + * Interpolators for lists of points. + */ +/* Authors: + * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl> + * + * Copyright (C) 2010-2011 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_LPE_POWERSTROKE_INTERPOLATORS_H +#define INKSCAPE_LPE_POWERSTROKE_INTERPOLATORS_H + +#include <2geom/path.h> +#include <2geom/bezier-utils.h> +#include <2geom/sbasis-to-bezier.h> + +#include "live_effects/bezctx.h" +#include "live_effects/bezctx_intf.h" +#include "live_effects/spiro.h" + + +/// @TODO Move this to 2geom? +namespace Geom { +namespace Interpolate { + +enum InterpolatorType { + INTERP_LINEAR, + INTERP_CUBICBEZIER, + INTERP_CUBICBEZIER_JOHAN, + INTERP_SPIRO +}; + +class Interpolator { +public: + Interpolator() {}; + virtual ~Interpolator() {}; + + static Interpolator* create(InterpolatorType type); + + virtual Geom::Path interpolateToPath(std::vector<Point> const &points) const = 0; + +private: + Interpolator(const Interpolator&); + Interpolator& operator=(const Interpolator&); +}; + +class Linear : public Interpolator { +public: + Linear() {}; + virtual ~Linear() {}; + + virtual Path interpolateToPath(std::vector<Point> const &points) const { + Path path; + path.start( points.at(0) ); + for (unsigned int i = 1 ; i < points.size(); ++i) { + path.appendNew<Geom::LineSegment>(points.at(i)); + } + return path; + }; + +private: + Linear(const Linear&); + Linear& operator=(const Linear&); +}; + +// this class is terrible +class CubicBezierFit : public Interpolator { +public: + CubicBezierFit() {}; + virtual ~CubicBezierFit() {}; + + virtual Path interpolateToPath(std::vector<Point> const &points) const { + unsigned int n_points = points.size(); + // worst case gives us 2 segment per point + int max_segs = 8*n_points; + Geom::Point * b = g_new(Geom::Point, max_segs); + Geom::Point * points_array = g_new(Geom::Point, 4*n_points); + for (unsigned i = 0; i < n_points; ++i) { + points_array[i] = points.at(i); + } + + double tolerance_sq = 0; // this value is just a random guess + + int const n_segs = Geom::bezier_fit_cubic_r(b, points_array, n_points, + tolerance_sq, max_segs); + + Geom::Path fit; + if ( n_segs > 0) + { + fit.start(b[0]); + for (int c = 0; c < n_segs; c++) { + fit.appendNew<Geom::CubicBezier>(b[4*c+1], b[4*c+2], b[4*c+3]); + } + } + g_free(b); + g_free(points_array); + return fit; + }; + +private: + CubicBezierFit(const CubicBezierFit&); + CubicBezierFit& operator=(const CubicBezierFit&); +}; + +/// @todo invent name for this class +class CubicBezierJohan : public Interpolator { +public: + CubicBezierJohan(double beta = 0.2) { + _beta = beta; + }; + virtual ~CubicBezierJohan() {}; + + virtual Path interpolateToPath(std::vector<Point> const &points) const { + Path fit; + fit.start(points.at(0)); + for (unsigned int i = 1; i < points.size(); ++i) { + Point p0 = points.at(i-1); + Point p1 = points.at(i); + Point dx = Point(p1[X] - p0[X], 0); + fit.appendNew<CubicBezier>(p0+_beta*dx, p1-_beta*dx, p1); + } + return fit; + }; + + double _beta; + +private: + CubicBezierJohan(const CubicBezierJohan&); + CubicBezierJohan& operator=(const CubicBezierJohan&); +}; + + +#define SPIRO_SHOW_INFINITE_COORDINATE_CALLS +class SpiroInterpolator : public Interpolator { +public: + SpiroInterpolator() {}; + virtual ~SpiroInterpolator() {}; + + virtual Path interpolateToPath(std::vector<Point> const &points) const { + Path fit; + + Coord scale_y = 100.; + + guint len = points.size(); + bezctx *bc = new_bezctx_ink(&fit); + spiro_cp *controlpoints = g_new (spiro_cp, len); + for (unsigned int i = 0; i < len; ++i) { + controlpoints[i].x = points[i][X]; + controlpoints[i].y = points[i][Y] / scale_y; + controlpoints[i].ty = 'c'; + } + controlpoints[0].ty = '{'; + controlpoints[1].ty = 'v'; + controlpoints[len-2].ty = 'v'; + controlpoints[len-1].ty = '}'; + + spiro_seg *s = run_spiro(controlpoints, len); + spiro_to_bpath(s, len, bc); + free(s); + free(bc); + + fit *= Scale(1,scale_y); + return fit; + }; + +private: + typedef struct { + bezctx base; + Path *path; + int is_open; + } bezctx_ink; + + static void bezctx_ink_moveto(bezctx *bc, double x, double y, int /*is_open*/) + { + bezctx_ink *bi = (bezctx_ink *) bc; + if ( IS_FINITE(x) && IS_FINITE(y) ) { + bi->path->start(Point(x, y)); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro moveto not finite"); + } + #endif + } + + static void bezctx_ink_lineto(bezctx *bc, double x, double y) + { + bezctx_ink *bi = (bezctx_ink *) bc; + if ( IS_FINITE(x) && IS_FINITE(y) ) { + bi->path->appendNew<LineSegment>( Point(x, y) ); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro lineto not finite"); + } + #endif + } + + static void bezctx_ink_quadto(bezctx *bc, double xm, double ym, double x3, double y3) + { + bezctx_ink *bi = (bezctx_ink *) bc; + + if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) { + bi->path->appendNew<QuadraticBezier>(Point(xm, ym), Point(x3, y3)); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro quadto not finite"); + } + #endif + } + + static void bezctx_ink_curveto(bezctx *bc, double x1, double y1, double x2, double y2, + double x3, double y3) + { + bezctx_ink *bi = (bezctx_ink *) bc; + if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) { + bi->path->appendNew<CubicBezier>(Point(x1, y1), Point(x2, y2), Point(x3, y3)); + } + #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS + else { + g_message("spiro curveto not finite"); + } + #endif + } + + bezctx * + new_bezctx_ink(Geom::Path *path) const { + bezctx_ink *result = g_new(bezctx_ink, 1); + result->base.moveto = bezctx_ink_moveto; + result->base.lineto = bezctx_ink_lineto; + result->base.quadto = bezctx_ink_quadto; + result->base.curveto = bezctx_ink_curveto; + result->base.mark_knot = NULL; + result->path = path; + return &result->base; + } + + SpiroInterpolator(const SpiroInterpolator&); + SpiroInterpolator& operator=(const SpiroInterpolator&); +}; + + +Interpolator* +Interpolator::create(InterpolatorType type) { + switch (type) { + case INTERP_LINEAR: + return new Geom::Interpolate::Linear(); + case INTERP_CUBICBEZIER: + return new Geom::Interpolate::CubicBezierFit(); + case INTERP_CUBICBEZIER_JOHAN: + return new Geom::Interpolate::CubicBezierJohan(); + case INTERP_SPIRO: + return new Geom::Interpolate::SpiroInterpolator(); + default: + return new Geom::Interpolate::Linear(); + } +} + +} //namespace Interpolate +} //namespace Geom + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 56248907c..1cf8ff764 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -11,6 +11,7 @@ */ #include "live_effects/lpe-powerstroke.h" +#include "live_effects/lpe-powerstroke-interpolators.h" #include "sp-shape.h" #include "display/curve.h" @@ -24,249 +25,6 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/svg-path.h> -// for the spiro interpolator: -#include "live_effects/bezctx.h" -#include "live_effects/bezctx_intf.h" -#include "live_effects/spiro.h" - - -/// @TODO Move this to 2geom -namespace Geom { -namespace Interpolate { - -enum InterpolatorType { - INTERP_LINEAR, - INTERP_CUBICBEZIER, - INTERP_CUBICBEZIER_JOHAN, - INTERP_SPIRO -}; - -class Interpolator { -public: - Interpolator() {}; - virtual ~Interpolator() {}; - - static Interpolator* create(InterpolatorType type); - -// virtual Piecewise<D2<SBasis> > interpolateToPwD2Sb(std::vector<Point> points) = 0; - virtual Geom::Path interpolateToPath(std::vector<Point> points) = 0; - -private: - Interpolator(const Interpolator&); - Interpolator& operator=(const Interpolator&); -}; - -class Linear : public Interpolator { -public: - Linear() {}; - virtual ~Linear() {}; - - virtual Path interpolateToPath(std::vector<Point> points) { - Path path; - path.start( points.at(0) ); - for (unsigned int i = 1 ; i < points.size(); ++i) { - path.appendNew<Geom::LineSegment>(points.at(i)); - } - return path; - }; - -private: - Linear(const Linear&); - Linear& operator=(const Linear&); -}; - -// this class is terrible -class CubicBezierFit : public Interpolator { -public: - CubicBezierFit() {}; - virtual ~CubicBezierFit() {}; - - virtual Path interpolateToPath(std::vector<Point> points) { - unsigned int n_points = points.size(); - // worst case gives us 2 segment per point - int max_segs = 8*n_points; - Geom::Point * b = g_new(Geom::Point, max_segs); - Geom::Point * points_array = g_new(Geom::Point, 4*n_points); - for (unsigned i = 0; i < n_points; ++i) { - points_array[i] = points.at(i); - } - - double tolerance_sq = 0; // this value is just a random guess - - int const n_segs = Geom::bezier_fit_cubic_r(b, points_array, n_points, - tolerance_sq, max_segs); - - Geom::Path fit; - if ( n_segs > 0) - { - fit.start(b[0]); - for (int c = 0; c < n_segs; c++) { - fit.appendNew<Geom::CubicBezier>(b[4*c+1], b[4*c+2], b[4*c+3]); - } - } - g_free(b); - g_free(points_array); - return fit; - }; - -private: - CubicBezierFit(const CubicBezierFit&); - CubicBezierFit& operator=(const CubicBezierFit&); -}; - -/// @todo invent name for this class -class CubicBezierJohan : public Interpolator { -public: - CubicBezierJohan() {}; - virtual ~CubicBezierJohan() {}; - - virtual Path interpolateToPath(std::vector<Point> points) { - Path fit; - fit.start(points.at(0)); - for (unsigned int i = 1; i < points.size(); ++i) { - Point p0 = points.at(i-1); - Point p1 = points.at(i); - Point dx = Point(p1[X] - p0[X], 0); - fit.appendNew<CubicBezier>(p0+0.2*dx, p1-0.2*dx, p1); - } - return fit; - }; - -private: - CubicBezierJohan(const CubicBezierJohan&); - CubicBezierJohan& operator=(const CubicBezierJohan&); -}; - - -#define SPIRO_SHOW_INFINITE_COORDINATE_CALLS -class SpiroInterpolator : public Interpolator { -public: - SpiroInterpolator() {}; - virtual ~SpiroInterpolator() {}; - - virtual Path interpolateToPath(std::vector<Point> points) { - Path fit; - - Coord scale_y = 100.; - - guint len = points.size(); - bezctx *bc = new_bezctx_ink(&fit); - spiro_cp *controlpoints = g_new (spiro_cp, len); - for (unsigned int i = 0; i < len; ++i) { - controlpoints[i].x = points[i][X]; - controlpoints[i].y = points[i][Y] / scale_y; - controlpoints[i].ty = 'c'; - } - controlpoints[0].ty = '{'; - controlpoints[1].ty = 'v'; - controlpoints[len-2].ty = 'v'; - controlpoints[len-1].ty = '}'; - - spiro_seg *s = run_spiro(controlpoints, len); - spiro_to_bpath(s, len, bc); - free(s); - free(bc); - - fit *= Scale(1,scale_y); - return fit; - }; - -private: - typedef struct { - bezctx base; - Path *path; - int is_open; - } bezctx_ink; - - static void bezctx_ink_moveto(bezctx *bc, double x, double y, int /*is_open*/) - { - bezctx_ink *bi = (bezctx_ink *) bc; - if ( IS_FINITE(x) && IS_FINITE(y) ) { - bi->path->start(Point(x, y)); - } - #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS - else { - g_message("spiro moveto not finite"); - } - #endif - } - - static void bezctx_ink_lineto(bezctx *bc, double x, double y) - { - bezctx_ink *bi = (bezctx_ink *) bc; - if ( IS_FINITE(x) && IS_FINITE(y) ) { - bi->path->appendNew<LineSegment>( Point(x, y) ); - } - #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS - else { - g_message("spiro lineto not finite"); - } - #endif - } - - static void bezctx_ink_quadto(bezctx *bc, double xm, double ym, double x3, double y3) - { - bezctx_ink *bi = (bezctx_ink *) bc; - - if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) { - bi->path->appendNew<QuadraticBezier>(Point(xm, ym), Point(x3, y3)); - } - #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS - else { - g_message("spiro quadto not finite"); - } - #endif - } - - static void bezctx_ink_curveto(bezctx *bc, double x1, double y1, double x2, double y2, - double x3, double y3) - { - bezctx_ink *bi = (bezctx_ink *) bc; - if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) { - bi->path->appendNew<CubicBezier>(Point(x1, y1), Point(x2, y2), Point(x3, y3)); - } - #ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS - else { - g_message("spiro curveto not finite"); - } - #endif - } - - bezctx * - new_bezctx_ink(Geom::Path *path) { - bezctx_ink *result = g_new(bezctx_ink, 1); - result->base.moveto = bezctx_ink_moveto; - result->base.lineto = bezctx_ink_lineto; - result->base.quadto = bezctx_ink_quadto; - result->base.curveto = bezctx_ink_curveto; - result->base.mark_knot = NULL; - result->path = path; - return &result->base; - } - - SpiroInterpolator(const SpiroInterpolator&); - SpiroInterpolator& operator=(const SpiroInterpolator&); -}; - - -Interpolator* -Interpolator::create(InterpolatorType type) { - switch (type) { - case INTERP_LINEAR: - return new Geom::Interpolate::Linear(); - case INTERP_CUBICBEZIER: - return new Geom::Interpolate::CubicBezierFit(); - case INTERP_CUBICBEZIER_JOHAN: - return new Geom::Interpolate::CubicBezierJohan(); - case INTERP_SPIRO: - return new Geom::Interpolate::SpiroInterpolator(); - default: - return new Geom::Interpolate::Linear(); - } -} - -} //namespace Interpolate -} //namespace Geom namespace Inkscape { namespace LivePathEffect { -- cgit v1.2.3 From 8e5adaadb93502ad0a9f476b246a934ebfee8410 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Tue, 8 Nov 2011 22:27:40 +0100 Subject: Powerstroke: add smoothness parameter for CubicBezierJohan (bzr r10733) --- src/live_effects/lpe-powerstroke-interpolators.h | 4 ++++ src/live_effects/lpe-powerstroke.cpp | 5 +++++ src/live_effects/lpe-powerstroke.h | 1 + 3 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke-interpolators.h b/src/live_effects/lpe-powerstroke-interpolators.h index 88bc13ff2..7f9cb3ddb 100644 --- a/src/live_effects/lpe-powerstroke-interpolators.h +++ b/src/live_effects/lpe-powerstroke-interpolators.h @@ -124,6 +124,10 @@ public: return fit; }; + void setBeta(double beta) { + _beta = beta; + } + double _beta; private: diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 1cf8ff764..fc6026d31 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -68,6 +68,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true), interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), + interpolator_beta(_("Smoothness"), _("Sets the smoothness for the CubicBezierJohan interpolator. 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), start_linecap_type(_("Start line cap type"), _("Determines the shape of the path's start."), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), cusp_linecap_type(_("Cusp line cap type"), _("Determines the shape of the cusps along the path."), "cusp_linecap_type", LineCuspTypeConverter, &wr, this, LINECUSP_ROUND), end_linecap_type(_("End line cap type"), _("Determines the shape of the path's end."), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) @@ -79,6 +80,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast<Parameter *>(&offset_points) ); registerParameter( dynamic_cast<Parameter *>(&sort_points) ); registerParameter( dynamic_cast<Parameter *>(&interpolator_type) ); + registerParameter( dynamic_cast<Parameter *>(&interpolator_beta) ); registerParameter( dynamic_cast<Parameter *>(&start_linecap_type) ); registerParameter( dynamic_cast<Parameter *>(&cusp_linecap_type) ); registerParameter( dynamic_cast<Parameter *>(&end_linecap_type) ); @@ -220,6 +222,9 @@ LPEPowerStroke::doEffect_path (std::vector<Geom::Path> const & path_in) } // create stroke path where points (x,y) := (t, offset) Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value())); + if (Geom::Interpolate::CubicBezierJohan *johan = dynamic_cast<Geom::Interpolate::CubicBezierJohan*>(interpolator)) { + johan->setBeta(interpolator_beta); + } Geom::Path strokepath = interpolator->interpolateToPath(ts); delete interpolator; diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 6c005f792..4c9c6d327 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -36,6 +36,7 @@ private: PowerStrokePointArrayParam offset_points; BoolParam sort_points; EnumParam<unsigned> interpolator_type; + ScalarParam interpolator_beta; EnumParam<unsigned> start_linecap_type; EnumParam<unsigned> cusp_linecap_type; EnumParam<unsigned> end_linecap_type; -- cgit v1.2.3 From c8422f9ff3009ea6756b0a94aa0116dd2b2224f5 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Wed, 9 Nov 2011 21:12:11 +0100 Subject: add const just because it can :) (was intended to start using it for RegisteredWidget<>) (bzr r10734) --- src/ui/widget/spin-slider.cpp | 2 +- src/ui/widget/spin-slider.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index da2db991e..d159ecc15 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -18,7 +18,7 @@ namespace UI { namespace Widget { SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc, - double climb_rate, int digits, const SPAttributeEnum a, char* tip_text) + double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text) : AttrWidget(a, value), _adjustment(value, lower, upper, step_inc), _scale(_adjustment), _spin(_adjustment, climb_rate, digits) { diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index 7c2ef7ca4..d2f41603a 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -27,7 +27,7 @@ class SpinSlider : public Gtk::HBox, public AttrWidget { public: SpinSlider(double value, double lower, double upper, double step_inc, - double climb_rate, int digits, const SPAttributeEnum a = SP_ATTR_INVALID, char* tip_text = NULL); + double climb_rate, int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); virtual Glib::ustring get_as_attribute() const; virtual void set_from_attribute(SPObject*); -- cgit v1.2.3 From 519fdb8d3f3338f26db41292b2f0fb8f2efd14db Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Wed, 9 Nov 2011 21:13:18 +0100 Subject: lpe: add slider to scalar param optionally (does not work very well yet) (bzr r10735) --- src/live_effects/lpe-powerstroke.cpp | 3 +++ src/live_effects/parameter/parameter.cpp | 6 +++++- src/live_effects/parameter/parameter.h | 3 +++ src/ui/widget/scalar.cpp | 11 +++++++++-- src/ui/widget/scalar.h | 5 +++++ 5 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index fc6026d31..25cb72b42 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -77,6 +77,9 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : /// @todo offset_points are initialized with empty path, is that bug-save? + interpolator_beta.addSlider(true); + interpolator_beta.param_set_range(0.,1.); + registerParameter( dynamic_cast<Parameter *>(&offset_points) ); registerParameter( dynamic_cast<Parameter *>(&sort_points) ); registerParameter( dynamic_cast<Parameter *>(&interpolator_type) ); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 5454a5408..cc8982860 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -58,7 +58,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, defvalue(default_value), digits(2), inc_step(0.1), - inc_page(1) + inc_page(1), + add_slider(false) { } @@ -134,6 +135,9 @@ ScalarParam::param_newWidget(Gtk::Tooltips * /*tooltips*/) rsu->setIncrements(inc_step, inc_page); rsu->setRange(min, max); rsu->setProgrammatically = false; + if (add_slider) { + rsu->addSlider(); + } rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index cee10bc70..fe93e8dca 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -109,6 +109,8 @@ public: void param_set_digits(unsigned digits); void param_set_increments(double step, double page); + void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; + virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips); inline operator gdouble() @@ -123,6 +125,7 @@ protected: unsigned digits; double inc_step; double inc_page; + bool add_slider; private: ScalarParam(const ScalarParam&); diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 220498561..cc051599c 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -3,8 +3,9 @@ * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> * Bryce Harrington <bryce@bryceharrington.org> + * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl> * - * Copyright (C) 2004 Carl Hetherington + * Copyright (C) 2004-2011 authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -16,6 +17,7 @@ #include "scalar.h" #include "spinbutton.h" +#include <gtkmm/scale.h> namespace Inkscape { namespace UI { @@ -133,7 +135,12 @@ void Scalar::update() static_cast<SpinButton*>(_widget)->update(); } - +void Scalar::addSlider() +{ + Gtk::HScale *scale = new Gtk::HScale( * static_cast<SpinButton*>(_widget)->get_adjustment() ); + scale->set_draw_value(false); + add (*manage (scale)); +} Glib::SignalProxy0<void> Scalar::signal_value_changed() { diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index c73bcc62a..19ccb7ae0 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -142,6 +142,11 @@ public: */ void update(); + /** + * Adds a slider (HScale) to the left of the spinbox. + */ + void addSlider(); + /** * Signal raised when the spin button's value changes. */ -- cgit v1.2.3 From 57558641a9819e4da97bc014ac35f9323306ae1f Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Thu, 10 Nov 2011 23:23:06 +0100 Subject: cppcheck: initialization / warning cleanup (bzr r10736) --- src/util/units.cpp | 37 +++++++++++++++++------------------ src/widgets/ege-paint-def.cpp | 10 +++++++--- src/widgets/sp-color-icc-selector.cpp | 3 +++ src/xml/repr-css.cpp | 2 +- 4 files changed, 29 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/util/units.cpp b/src/util/units.cpp index a251dc5db..b79bbc9cc 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -17,7 +17,7 @@ namespace Util { class UnitsSAXHandler : public Inkscape::IO::FlatSaxHandler { public: - UnitsSAXHandler(UnitTable *table) : FlatSaxHandler(), tbl(table) {} + UnitsSAXHandler(UnitTable *table); virtual ~UnitsSAXHandler() {} virtual void _startElement(xmlChar const *name, xmlChar const **attrs); @@ -29,6 +29,14 @@ public: Unit unit; }; +UnitsSAXHandler::UnitsSAXHandler(UnitTable *table) : + FlatSaxHandler(), + tbl(table), + primary(0), + skip(0), + unit() +{ +} #define BUFSIZE (255) @@ -70,8 +78,7 @@ UnitTable::~UnitTable() { } /** Add a new unit to the table */ -void -UnitTable::addUnit(Unit const &u, bool primary) { +void UnitTable::addUnit(Unit const &u, bool primary) { _unit_map[u.abbr] = new Unit(u); if (primary) { _primary_unit[u.type] = u.abbr; @@ -79,8 +86,7 @@ UnitTable::addUnit(Unit const &u, bool primary) { } /** Retrieve a given unit based on its string identifier */ -Unit -UnitTable::getUnit(Glib::ustring const &unit_abbr) const { +Unit UnitTable::getUnit(Glib::ustring const &unit_abbr) const { UnitMap::const_iterator iter = _unit_map.find(unit_abbr); if (iter != _unit_map.end()) { return *((*iter).second); @@ -90,8 +96,7 @@ UnitTable::getUnit(Glib::ustring const &unit_abbr) const { } /** Remove a unit definition from the given unit type table */ -bool -UnitTable::deleteUnit(Unit const &u) { +bool UnitTable::deleteUnit(Unit const &u) { if (u.abbr == _primary_unit[u.type]) { // Cannot delete the primary unit type since it's // used for conversions @@ -108,15 +113,13 @@ UnitTable::deleteUnit(Unit const &u) { } /** Returns true if the given string 'name' is a valid unit in the table */ -bool -UnitTable::hasUnit(Glib::ustring const &unit) const { +bool UnitTable::hasUnit(Glib::ustring const &unit) const { UnitMap::const_iterator iter = _unit_map.find(unit); return (iter != _unit_map.end()); } /** Provides an iteratable list of items in the given unit table */ -UnitTable::UnitMap -UnitTable::units(UnitType type) const +UnitTable::UnitMap UnitTable::units(UnitType type) const { UnitMap submap; for (UnitMap::const_iterator iter = _unit_map.begin(); @@ -130,16 +133,14 @@ UnitTable::units(UnitType type) const } /** Returns the default unit abbr for the given type */ -Glib::ustring -UnitTable::primary(UnitType type) const { +Glib::ustring UnitTable::primary(UnitType type) const { return _primary_unit[type]; } /** Merges the contents of the given file into the UnitTable, possibly overwriting existing unit definitions. This loads from a text file */ -bool -UnitTable::loadText(Glib::ustring const &filename) { +bool UnitTable::loadText(Glib::ustring const &filename) { char buf[BUFSIZE]; // Open file for reading @@ -221,8 +222,7 @@ UnitTable::loadText(Glib::ustring const &filename) { return true; } -bool -UnitTable::load(Glib::ustring const &filename) { +bool UnitTable::load(Glib::ustring const &filename) { UnitsSAXHandler handler(this); int result = handler.parseFile( filename.c_str() ); @@ -237,8 +237,7 @@ UnitTable::load(Glib::ustring const &filename) { } /** Saves the current UnitTable to the given file. */ -bool -UnitTable::save(Glib::ustring const &filename) { +bool UnitTable::save(Glib::ustring const &filename) { // open file for writing FILE *f = fopen(filename.c_str(), "w"); diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp index c4325659d..542205b53 100644 --- a/src/widgets/ege-paint-def.cpp +++ b/src/widgets/ege-paint-def.cpp @@ -69,7 +69,8 @@ PaintDef::PaintDef() : r(0), g(0), b(0), - editable(false) + editable(false), + _listeners() { } @@ -79,7 +80,8 @@ PaintDef::PaintDef( ColorType type ) : r(0), g(0), b(0), - editable(false) + editable(false), + _listeners() { switch (type) { case CLEAR: @@ -100,7 +102,8 @@ PaintDef::PaintDef( unsigned int r, unsigned int g, unsigned int b, const std::s r(r), g(g), b(b), - editable(false) + editable(false), + _listeners() { } @@ -125,6 +128,7 @@ PaintDef& PaintDef::operator=( PaintDef const &other ) b = other.b; descr = other.descr; editable = other.editable; + //TODO: _listeners should be assigned a value } return *this; } diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 888cc2629..28a317717 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -129,6 +129,8 @@ ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) _updating( FALSE ), _dragging( FALSE ), _fixupNeeded(0), + _fixupBtn(0), + _profileSel(0), _fooCount(0), _fooScales(0), _fooAdj(0), @@ -137,6 +139,7 @@ ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) _fooLabel(0), _fooMap(0), _adj(0), + _slider(0), _sbtn(0), _label(0) #if ENABLE_LCMS diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index 8de85c36d..ced4f5da4 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -307,7 +307,7 @@ sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl) // the additional benefit of respecting the numerical precission set in the SVG Output // preferences. We assume any numerical part comes first (if not, the whole string is copied). std::stringstream ss( value_unquoted ); - double number; + double number = 0; std::string characters; std::string temp; bool number_valid = !(ss >> number).fail(); -- cgit v1.2.3 From 354f364c1ce5428453a8601b31c91b910b7b8ef3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sun, 13 Nov 2011 20:18:47 +0100 Subject: various: warnings and initalization (bzr r10737) --- src/ui/dialog/document-properties.cpp | 93 +++++++++++++++-------------------- src/ui/dialog/svg-fonts-dialog.cpp | 27 +++++----- src/ui/dialog/svg-fonts-dialog.h | 6 +-- src/ui/widget/icon-widget.cpp | 17 ++++--- src/ui/widget/licensor.cpp | 9 ++-- src/ui/widget/tolerance-slider.cpp | 21 +++----- src/ui/widget/tolerance-slider.h | 14 ++++-- 7 files changed, 90 insertions(+), 97 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 307cf2bbc..fa392cccc 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -74,8 +74,7 @@ static Inkscape::XML::NodeEventVector const _repr_events = { }; -DocumentProperties & -DocumentProperties::getInstance() +DocumentProperties& DocumentProperties::getInstance() { DocumentProperties &instance = *new DocumentProperties(); instance.init(); @@ -85,9 +84,13 @@ DocumentProperties::getInstance() DocumentProperties::DocumentProperties() : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW), - _page_page(1, 1, true, true), _page_guides(1, 1), - _page_snap(1, 1), _page_cms(1, 1), _page_scripting(1, 1), - _page_external_scripts(1, 1), _page_embedded_scripts(1, 1), + _page_page(1, 1, true, true), + _page_guides(1, 1), + _page_snap(1, 1), + _page_cms(1, 1), + _page_scripting(1, 1), + _page_external_scripts(1, 1), + _page_embedded_scripts(1, 1), //--------------------------------------------------------------- _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), @@ -101,6 +104,21 @@ DocumentProperties::DocumentProperties() _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr), _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr), _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr), + //--------------------------------------------------------------- + _rsu_sno(_("Snap _distance"), _("Snap only when _closer than:"), _("Always snap"), + _("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"), + _("If set, objects only snap to another object when it's within the range specified below"), + "objecttolerance", _wr), + //Options for snapping to grids + _rsu_sn(_("Snap d_istance"), _("Snap only when c_loser than:"), _("Always snap"), + _("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"), + _("If set, objects only snap to a grid line when it's within the range specified below"), + "gridtolerance", _wr), + //Options for snapping to guides + _rsu_gusn(_("Snap dist_ance"), _("Snap only when close_r than:"), _("Always snap"), + _("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"), + _("If set, objects only snap to a guide when it's within the range specified below"), + "guidetolerance", _wr), //--------------------------------------------------------------- _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr), _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr), @@ -138,8 +156,7 @@ DocumentProperties::DocumentProperties() signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); } -void -DocumentProperties::init() +void DocumentProperties::init() { update(); @@ -210,8 +227,7 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con } } -void -DocumentProperties::build_page() +void DocumentProperties::build_page() { _page_page.show(); @@ -242,8 +258,7 @@ DocumentProperties::build_page() attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array)); } -void -DocumentProperties::build_guides() +void DocumentProperties::build_guides() { _page_guides.show(); @@ -261,28 +276,10 @@ DocumentProperties::build_guides() attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array)); } -void -DocumentProperties::build_snap() +void DocumentProperties::build_snap() { _page_snap.show(); - _rsu_sno.init (_("Snap _distance"), _("Snap only when _closer than:"), _("Always snap"), - _("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"), - _("If set, objects only snap to another object when it's within the range specified below"), - "objecttolerance", _wr); - - //Options for snapping to grids - _rsu_sn.init (_("Snap d_istance"), _("Snap only when c_loser than:"), _("Always snap"), - _("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"), - _("If set, objects only snap to a grid line when it's within the range specified below"), - "gridtolerance", _wr); - - //Options for snapping to guides - _rsu_gusn.init (_("Snap dist_ance"), _("Snap only when close_r than:"), _("Always snap"), - _("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"), - _("If set, objects only snap to a guide when it's within the range specified below"), - "guidetolerance", _wr); - Gtk::Label *label_o = manage (new Gtk::Label); label_o->set_markup (_("<b>Snap to objects</b>")); Gtk::Label *label_gr = manage (new Gtk::Label); @@ -369,8 +366,7 @@ static void sanitizeName( Glib::ustring& str ) } } -void -DocumentProperties::linkSelectedProfile() +void DocumentProperties::linkSelectedProfile() { //store this profile in the SVG document (create <color-profile> element in the XML) // TODO remove use of 'active' desktop @@ -410,8 +406,7 @@ DocumentProperties::linkSelectedProfile() } } -void -DocumentProperties::populate_linked_profiles_box() +void DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); @@ -505,8 +500,7 @@ void DocumentProperties::removeSelectedProfile(){ populate_linked_profiles_box(); } -void -DocumentProperties::build_cms() +void DocumentProperties::build_cms() { _page_cms.show(); @@ -571,8 +565,7 @@ DocumentProperties::build_cms() } #endif // ENABLE_LCMS -void -DocumentProperties::build_scripting() +void DocumentProperties::build_scripting() { _page_scripting.show(); @@ -1057,8 +1050,7 @@ DocumentProperties::_createPageTabLabel(const Glib::ustring& label, const char * //-------------------------------------------------------------------- -void -DocumentProperties::on_response (int id) +void DocumentProperties::on_response (int id) { if (id == Gtk::RESPONSE_DELETE_EVENT || id == Gtk::RESPONSE_CLOSE) { @@ -1072,8 +1064,7 @@ DocumentProperties::on_response (int id) hide(); } -void -DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document) +void DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); @@ -1082,8 +1073,7 @@ DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *docu update(); } -void -DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop) +void DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); @@ -1092,8 +1082,7 @@ DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *d update(); } -void -DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop) +void DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); @@ -1101,15 +1090,13 @@ DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop root->removeListenerByData(this); } -static void -on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) +static void on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) { if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data)) dialog->update_gridspage(); } -static void -on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) +static void on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) { if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data)) dialog->update_gridspage(); @@ -1131,8 +1118,7 @@ static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar con # BUTTON CLICK HANDLERS (callbacks) ########################################################################*/ -void -DocumentProperties::onNewGrid() +void DocumentProperties::onNewGrid() { SPDesktop *dt = getDesktop(); Inkscape::XML::Node *repr = sp_desktop_namedview(dt)->getRepr(); @@ -1146,8 +1132,7 @@ DocumentProperties::onNewGrid() } -void -DocumentProperties::onRemoveGrid() +void DocumentProperties::onRemoveGrid() { gint pagenum = _grids_notebook.get_current_page(); if (pagenum == -1) // no pages diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 2c116f137..658ef6613 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -28,24 +28,27 @@ #include "xml/node.h" #include "xml/repr.h" -SvgFontDrawingArea::SvgFontDrawingArea(){ - this->text = ""; - this->svgfont = NULL; +SvgFontDrawingArea::SvgFontDrawingArea(): + _x(0), + _y(0), + _svgfont(0), + _text() +{ } void SvgFontDrawingArea::set_svgfont(SvgFont* svgfont){ - this->svgfont = svgfont; + _svgfont = svgfont; } void SvgFontDrawingArea::set_text(Glib::ustring text){ - this->text = text; + _text = text; redraw(); } void SvgFontDrawingArea::set_size(int x, int y){ - this->x = x; - this->y = y; - ((Gtk::Widget*) this)->set_size_request(x, y); + _x = x; + _y = y; + ((Gtk::Widget*) this)->set_size_request(_x, _y); } void SvgFontDrawingArea::redraw(){ @@ -53,13 +56,13 @@ void SvgFontDrawingArea::redraw(){ } bool SvgFontDrawingArea::on_expose_event (GdkEventExpose */*event*/){ - if (this->svgfont){ + if (_svgfont){ Glib::RefPtr<Gdk::Window> window = get_window(); Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context(); - cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(this->svgfont->get_font_face(), false /* does not have reference */)) ); - cr->set_font_size (this->y-20); + cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(_svgfont->get_font_face(), false /* does not have reference */)) ); + cr->set_font_size (_y-20); cr->move_to (10, 10); - cr->show_text (this->text.c_str()); + cr->show_text (_text.c_str()); } return TRUE; } diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 8c2bdc1a4..41bd6ecc8 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -39,9 +39,9 @@ public: void set_size(int x, int y); void redraw(); private: - int x,y; - SvgFont* svgfont; - Glib::ustring text; + int _x,_y; + SvgFont* _svgfont; + Glib::ustring _text; bool on_expose_event (GdkEventExpose *event); }; diff --git a/src/ui/widget/icon-widget.cpp b/src/ui/widget/icon-widget.cpp index 1bc4ad308..b671e8812 100644 --- a/src/ui/widget/icon-widget.cpp +++ b/src/ui/widget/icon-widget.cpp @@ -19,13 +19,16 @@ namespace Inkscape { namespace UI { namespace Widget { -IconWidget::IconWidget() +IconWidget::IconWidget() : + _pb(0), + _size(0), + _do_bitmap_icons(false) { - _pb = NULL; - _size = 0; } -IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) +IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) : + _pb(0), + _do_bitmap_icons(false) { _size = std::max((int unsigned)128, std::min(size, (int unsigned)1)); @@ -35,7 +38,7 @@ IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) if (pixels == NULL) { g_warning("Couldn't find matching icon for %s - has this application been installed?", name); - _pb = NULL; + //_pb = NULL; } else { /* TODO _pb = gdk_pixbuf_new_from_data(pixels, GDK_COLORSPACE_RGB, @@ -45,7 +48,9 @@ IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) } } -IconWidget::IconWidget(int unsigned size, guchar const */*px*/) +IconWidget::IconWidget(int unsigned size, guchar const */*px*/) : + _pb(0), + _do_bitmap_icons(false) { _size = std::max((int unsigned)128, std::min(size, (int unsigned)1)); diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index 9cb904c9f..7caf732a4 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -57,8 +57,7 @@ LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* enti } /// \pre it is assumed that the license URI entry is a Gtk::Entry -void -LicenseItem::on_toggled() +void LicenseItem::on_toggled() { if (_wr.isUpdating()) return; @@ -83,8 +82,7 @@ Licensor::~Licensor() if (_eentry) delete _eentry; } -void -Licensor::init (Gtk::Tooltips& tt, Registry& wr) +void Licensor::init (Gtk::Tooltips& tt, Registry& wr) { /* add license-specific metadata entry areas */ rdf_work_entity_t* entity = rdf_find_entity ( "license_uri" ); @@ -118,8 +116,7 @@ Licensor::init (Gtk::Tooltips& tt, Registry& wr) show_all_children(); } -void -Licensor::update (SPDocument *doc) +void Licensor::update (SPDocument *doc) { /* identify the license info */ struct rdf_license_t * license = rdf_get_license (doc); diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 40f58f0ae..aa749fb39 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -40,9 +40,10 @@ namespace Widget { //==================================================== -ToleranceSlider::ToleranceSlider() +ToleranceSlider::ToleranceSlider(const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr) : _vbox(0) { + init(label1, label2, label3, tip1, tip2, tip3, key, wr); } ToleranceSlider::~ToleranceSlider() @@ -51,8 +52,7 @@ ToleranceSlider::~ToleranceSlider() _scale_changed_connection.disconnect(); } -void -ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr) +void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr) { // hbox = label + slider // @@ -109,8 +109,7 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, _vbox->show_all_children(); } -void -ToleranceSlider::setValue (double val) +void ToleranceSlider::setValue (double val) { Gtk::Adjustment *adj = _hscale->get_adjustment(); @@ -135,21 +134,18 @@ ToleranceSlider::setValue (double val) _hbox->show_all(); } -void -ToleranceSlider::setLimits (double theMin, double theMax) +void ToleranceSlider::setLimits (double theMin, double theMax) { _hscale->set_range (theMin, theMax); _hscale->get_adjustment()->set_step_increment (1); } -void -ToleranceSlider::on_scale_changed() +void ToleranceSlider::on_scale_changed() { update (_hscale->get_value()); } -void -ToleranceSlider::on_toggled() +void ToleranceSlider::on_toggled() { if (!_button2->get_active()) { @@ -168,8 +164,7 @@ ToleranceSlider::on_toggled() } } -void -ToleranceSlider::update (double val) +void ToleranceSlider::update (double val) { if (_wr->isUpdating()) return; diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index 0a9663bc3..6865ec769 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -28,9 +28,7 @@ class Registry; */ class ToleranceSlider { public: - ToleranceSlider(); - ~ToleranceSlider(); - void init (const Glib::ustring& label1, + ToleranceSlider(const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, @@ -38,9 +36,19 @@ public: const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr); + ~ToleranceSlider(); void setValue (double); void setLimits (double, double); Gtk::VBox* _vbox; +private: + void init (const Glib::ustring& label1, + const Glib::ustring& label2, + const Glib::ustring& label3, + const Glib::ustring& tip1, + const Glib::ustring& tip2, + const Glib::ustring& tip3, + const Glib::ustring& key, + Registry& wr); protected: void on_scale_changed(); -- cgit v1.2.3 From bc07253a7ceeb7989244830bc53169c651b8dbc9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Mon, 14 Nov 2011 19:17:26 +0100 Subject: Fix text redraw problems (LP #837291) Fixed bugs: - https://launchpad.net/bugs/837291 (bzr r10739) --- src/display/drawing-item.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index bb99ed61d..df44a3de0 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -158,6 +158,7 @@ DrawingItem::prependChild(DrawingItem *item) void DrawingItem::clearChildren() { + _markForRendering(); // prevent children from referencing the parent during deletion // this way, children won't try to remove themselves from a list // from which they have already been removed by clear_and_dispose @@ -166,6 +167,7 @@ DrawingItem::clearChildren() i->_child_type = CHILD_ORPHAN; } _children.clear_and_dispose(DeleteDisposer()); + _markForUpdate(STATE_ALL, false); } /// Set the incremental transform for this item -- cgit v1.2.3 From 263beb7e8c7a5f658672ffaee2ae8f172c00fd23 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Mon, 14 Nov 2011 19:47:11 +0100 Subject: Add a tolerance-based hack, so that radial gradients with focus outside the outer circle work reliably. Fixes #845153 Fixed bugs: - https://launchpad.net/bugs/845153 (bzr r10740) --- src/sp-gradient.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index b42768f30..0acdac76e 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1531,7 +1531,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, static cairo_pattern_t * sp_radialgradient_create_pattern(SPPaintServer *ps, - cairo_t */* ct */, + cairo_t *ct, Geom::OptRect const &bbox, double opacity) { @@ -1540,9 +1540,30 @@ sp_radialgradient_create_pattern(SPPaintServer *ps, gr->ensureVector(); + Geom::Point focus(rg->fx.computed, rg->fy.computed); + Geom::Point center(rg->cx.computed, rg->cy.computed); + double radius = rg->r.computed; + double scale = 1.0; + double tolerance = cairo_get_tolerance(ct); + + // code below suggested by Cairo devs to overcome tolerance problems + // more: https://bugs.freedesktop.org/show_bug.cgi?id=40918 + Geom::Point d = focus - center; + if (d.length() + tolerance > radius) { + scale = radius / d.length(); + + double dx = d.x(), dy = d.y(); + cairo_user_to_device_distance(ct, &dx, &dy); + if (!Geom::are_near(dx, 0, tolerance) || + !Geom::are_near(dy, 0, tolerance)) + { + scale *= 1.0 - 2.0 * tolerance / hypot(dx, dy); + } + } + cairo_pattern_t *cp = cairo_pattern_create_radial( - rg->fx.computed, rg->fy.computed, 0, - rg->cx.computed, rg->cy.computed, rg->r.computed); + scale * d.x() + center.x(), scale * d.y() + center.y(), 0, + center.x(), center.y(), radius); sp_gradient_pattern_common_setup(cp, gr, bbox, opacity); -- cgit v1.2.3 From 20dcad58b6b48db59a3f81e9f7da613b3a7d5829 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski <tweenk.pl@gmail.com> Date: Thu, 17 Nov 2011 01:01:22 +0100 Subject: Fix crash when dropping Ctrl-dragged text when DBus interface is enabled (bzr r10741) --- src/extension/dbus/document-interface.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index da6b4fe36..47e02afc8 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -1443,6 +1443,7 @@ DocumentInterface *fugly; gboolean dbus_send_ping (SPDesktop* desk, SPItem *item) { //DocumentInterface *obj; + if (!item) return TRUE; g_signal_emit (desk->dbus_document_interface, signals[OBJECT_MOVED_SIGNAL], 0, item->getId()); return TRUE; } -- cgit v1.2.3 From 30cddc5e49b86f6624f6c6b57eb269afbc1bb3fd Mon Sep 17 00:00:00 2001 From: Alvin Penner <penner@vaxxine.com> Date: Wed, 16 Nov 2011 20:51:58 -0500 Subject: load Win32 symbol fonts. disable USE_PANGO_WIN32 (Bug 165665) Fixed bugs: - https://launchpad.net/bugs/165665 (bzr r10742) --- src/libnrtype/FontFactory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 58a98d1a9..42f975ab7 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -16,7 +16,7 @@ # include <config.h> #endif #ifdef _WIN32 -#define USE_PANGO_WIN32 +//#define USE_PANGO_WIN32 // disable for Bug 165665 #endif #include <pango/pango.h> -- cgit v1.2.3 From 290f89399b7f3af1a8629271b915c3340fe57ca8 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Fri, 18 Nov 2011 16:12:39 +0100 Subject: dropped unused variables (bzr r10743) --- src/ui/dialog/scriptdialog.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/scriptdialog.h b/src/ui/dialog/scriptdialog.h index 0b26f169a..a54f865f8 100644 --- a/src/ui/dialog/scriptdialog.h +++ b/src/ui/dialog/scriptdialog.h @@ -51,12 +51,6 @@ class ScriptDialog : public UI::Widget::Panel */ virtual ~ScriptDialog() {}; - - private: - int _max_dialog_width; - int _max_dialog_height; - - }; // class ScriptDialog -- cgit v1.2.3 From 2c2601527cd6082e53cee79c0feb99e703c0b220 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Fri, 18 Nov 2011 16:13:41 +0100 Subject: cppcheck: initialisation and warning cleanup (bzr r10744) --- src/trace/potrace/inkscape-potrace.cpp | 21 ++++++++++++--------- src/trace/potrace/inkscape-potrace.h | 2 +- src/trace/siox.cpp | 22 ++++++++++++++++++---- src/trace/siox.h | 13 +++++-------- src/ui/dialog/filedialogimpl-gtkmm.h | 2 +- src/ui/dialog/filter-effects-dialog.cpp | 3 ++- src/ui/dialog/scriptdialog.cpp | 4 +--- 7 files changed, 40 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp index 6583fb735..0907573e9 100644 --- a/src/trace/potrace/inkscape-potrace.cpp +++ b/src/trace/potrace/inkscape-potrace.cpp @@ -77,20 +77,23 @@ namespace Potrace { /** * */ -PotraceTracingEngine::PotraceTracingEngine() +PotraceTracingEngine::PotraceTracingEngine() : + keepGoing(1), + traceType(TRACE_BRIGHTNESS), + invert(false), + quantizationNrColors(8), + brightnessThreshold(0.45), + brightnessFloor(0), + cannyHighThreshold(0.65), + multiScanNrColors(8), + multiScanStack(true), + multiScanSmooth(false), + multiScanRemoveBackground(false) { /* get default parameters */ potraceParams = potrace_param_default(); potraceParams->progress.callback = potraceStatusCallback; potraceParams->progress.data = (void *)this; - - //##### Our defaults - invert = false; - traceType = TRACE_BRIGHTNESS; - quantizationNrColors = 8; - brightnessThreshold = 0.45; - cannyHighThreshold = 0.65; - } PotraceTracingEngine::~PotraceTracingEngine() diff --git a/src/trace/potrace/inkscape-potrace.h b/src/trace/potrace/inkscape-potrace.h index 5ed0c0e5a..f2fc9a71f 100644 --- a/src/trace/potrace/inkscape-potrace.h +++ b/src/trace/potrace/inkscape-potrace.h @@ -245,7 +245,7 @@ class PotraceTracingEngine : public TracingEngine potrace_param_t *potraceParams; TraceType traceType; - //## do i invert at the end? + //## do I invert at the end? bool invert; //## Color-->b&w quantization diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index e7ef5b0c0..4c6cf1eac 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -736,19 +736,33 @@ const float Siox::CERTAIN_BACKGROUND_CONFIDENCE=0.0f; /** * Construct a Siox engine */ -Siox::Siox() +Siox::Siox() : + sioxObserver(0), + keepGoing(true), + width(0), + height(0), + pixelCount(0), + image(0), + cm(0), + labelField(0) { - sioxObserver = NULL; init(); } /** * Construct a Siox engine */ -Siox::Siox(SioxObserver *observer) +Siox::Siox(SioxObserver *observer) : + sioxObserver(observer), + keepGoing(true), + width(0), + height(0), + pixelCount(0), + image(0), + cm(0), + labelField(0) { init(); - sioxObserver = observer; } diff --git a/src/trace/siox.h b/src/trace/siox.h index dd7f9422f..9a44ce1cf 100644 --- a/src/trace/siox.h +++ b/src/trace/siox.h @@ -507,11 +507,6 @@ private: */ bool keepGoing; - /** - * Our signature limits - */ - float limits[3]; - /** * Image width */ @@ -543,6 +538,11 @@ private: int *labelField; + /** + * Our signature limits + */ + float limits[3]; + /** * Maximum distance of two lab values. */ @@ -649,9 +649,6 @@ private: */ float sqrEuclidianDist(float *p, int pSize, float *q); - - - }; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index e6e771f1b..ba61d618f 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -79,7 +79,7 @@ findExpanderWidgets(Gtk::Container *parent, class FileType { public: - FileType() {} + FileType(): name(), pattern(),extension(0) {} ~FileType() {} Glib::ustring name; Glib::ustring pattern; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 22d3c7369..f5a5041e2 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1379,7 +1379,8 @@ void FilterEffectsDialog::FilterModifier::rename_filter() FilterEffectsDialog::CellRendererConnection::CellRendererConnection() : Glib::ObjectBase(typeid(CellRendererConnection)), - _primitive(*this, "primitive", 0) + _primitive(*this, "primitive", 0), + _text_width(0) {} Glib::PropertyProxy<void*> FilterEffectsDialog::CellRendererConnection::property_primitive() diff --git a/src/ui/dialog/scriptdialog.cpp b/src/ui/dialog/scriptdialog.cpp index ef65dce97..b775c74a1 100644 --- a/src/ui/dialog/scriptdialog.cpp +++ b/src/ui/dialog/scriptdialog.cpp @@ -152,9 +152,7 @@ void ScriptDialogImpl::clear() /** * Execute the script in the dialog */ -void -ScriptDialogImpl::execute(Inkscape::Extension::Script::InkscapeScript::ScriptLanguage -lang) +void ScriptDialogImpl::execute(Inkscape::Extension::Script::InkscapeScript::ScriptLanguage lang) { Glib::ustring script = scriptText.get_buffer()->get_text(true); Glib::ustring output; -- cgit v1.2.3 From 7d09a4c6f251d24bd87f3c786e835e84255bcabf Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 19 Nov 2011 19:50:23 +0100 Subject: fix pointer usage after releasing memory (bzr r10745) --- src/io/uristream.cpp | 20 +++++++++++--------- src/io/uristream.h | 9 +++------ 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp index 7397d725f..19994bc82 100644 --- a/src/io/uristream.cpp +++ b/src/io/uristream.cpp @@ -98,27 +98,26 @@ UriInputStream::UriInputStream(Inkscape::URI &source) scheme = SCHEME_FILE; else if (strncmp("data", schemestr, 4)==0) scheme = SCHEME_DATA; - //printf("in schemestr:'%s' scheme:'%d'\n", schemestr, scheme); - gchar *cpath = NULL; + gchar *cpath = NULL; switch (scheme) { case SCHEME_FILE: cpath = uri.toNativeFilename(); - //printf("in cpath:'%s'\n", cpath); inf = fopen_utf8name(cpath, FILE_READ); - //inf = fopen(cpath, "rb"); - g_free(cpath); if (!inf) { Glib::ustring err = "UriInputStream cannot open file "; err += cpath; + g_free(cpath); throw StreamException(err); } + else{ + g_free(cpath); + } break; case SCHEME_DATA: data = (unsigned char *) uri.getPath(); - //printf("in data:'%s'\n", data); dataPos = 0; dataLen = strlen((const char *)data); break; @@ -131,15 +130,18 @@ UriInputStream::UriInputStream(Inkscape::URI &source) * */ UriInputStream::UriInputStream(FILE *source, Inkscape::URI &uri) - throw (StreamException): inf(source), - uri(uri) + throw (StreamException): uri(uri), + inf(source), + data(0), + dataPos(0), + dataLen(0), + closed(false) { scheme = SCHEME_FILE; if (!inf) { Glib::ustring err = "UriInputStream passed NULL"; throw StreamException(err); } - closed = false; } /** diff --git a/src/io/uristream.h b/src/io/uristream.h index 67d2f34d7..16b1b0894 100644 --- a/src/io/uristream.h +++ b/src/io/uristream.h @@ -50,18 +50,15 @@ public: virtual int get() throw(StreamException); private: - - bool closed; - + Inkscape::URI &uri; FILE *inf; //for file: uris unsigned char *data; //for data: uris int dataPos; // current read position in data field int dataLen; // length of data buffer - - Inkscape::URI &uri; - + bool closed; int scheme; + }; // class UriInputStream -- cgit v1.2.3 From d0a75e28a727327d766b9050cda471a12e799511 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 19 Nov 2011 19:53:12 +0100 Subject: variable initialisation (bzr r10746) --- src/extension/implementation/script.cpp | 9 ++-- src/extension/internal/emf-win32-print.cpp | 56 +++++++++--------------- src/extension/internal/odf.h | 2 +- src/extension/internal/pdfinput/svg-builder.cpp | 10 +++-- src/extension/internal/pdfinput/svg-builder.h | 3 +- src/extension/param/color.cpp | 15 +++---- src/io/base64stream.cpp | 13 +++--- src/sp-animation.cpp | 57 +++++++++---------------- src/sp-guide-attachment.h | 3 +- src/sp-guide-constraint.h | 3 +- 10 files changed, 71 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index ca9c094db..08624aff0 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -149,7 +149,8 @@ std::string Script::resolveInterpreterExecutable(const Glib::ustring &interpName of memory in the unloaded state. */ Script::Script() : - Implementation() + Implementation(), + _canceled(false) { } @@ -177,8 +178,7 @@ Script::~Script() string. This means that the caller of this function can always free what they are given (and should do it too!). */ -std::string -Script::solve_reldir(Inkscape::XML::Node *reprin) { +std::string Script::solve_reldir(Inkscape::XML::Node *reprin) { gchar const *s = reprin->attribute("reldir"); @@ -361,8 +361,7 @@ void Script::unload(Inkscape::Extension::Extension */*module*/) \param module The Extension in question */ -bool -Script::check(Inkscape::Extension::Extension *module) +bool Script::check(Inkscape::Extension::Extension *module) { int script_count = 0; Inkscape::XML::Node *child_repr = sp_repr_children(module->get_repr()); diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 472a11807..f4c36dd92 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -76,6 +76,8 @@ static float dwDPI = 2540; PrintEmfWin32::PrintEmfWin32 (void): + _width(0), + _height(0), hdc(NULL), hbrush(NULL), hbrushOld(NULL), @@ -105,15 +107,13 @@ PrintEmfWin32::~PrintEmfWin32 (void) } -unsigned int -PrintEmfWin32::setup (Inkscape::Extension::Print * /*mod*/) +unsigned int PrintEmfWin32::setup (Inkscape::Extension::Print * /*mod*/) { return TRUE; } -unsigned int -PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) +unsigned int PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) { gchar const *utf8_fn = mod->get_param_string("destination"); @@ -229,8 +229,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) } -unsigned int -PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/) +unsigned int PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/) { if (!hdc) return 0; @@ -248,8 +247,7 @@ PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/) } -unsigned int -PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/, +unsigned int PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/, const char * /*comment*/) { if (!hdc) return 0; @@ -260,8 +258,7 @@ PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/, } -int -PrintEmfWin32::create_brush(SPStyle const *style) +int PrintEmfWin32::create_brush(SPStyle const *style) { float rgb[3]; @@ -287,8 +284,7 @@ PrintEmfWin32::create_brush(SPStyle const *style) } -void -PrintEmfWin32::destroy_brush() +void PrintEmfWin32::destroy_brush() { SelectObject( hdc, hbrushOld ); if (hbrush) @@ -298,8 +294,7 @@ PrintEmfWin32::destroy_brush() } -void -PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transform) +void PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transform) { if (style) { float rgb[3]; @@ -422,8 +417,7 @@ PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transform) } -void -PrintEmfWin32::destroy_pen() +void PrintEmfWin32::destroy_pen() { SelectObject( hdc, hpenOld ); if (hpen) @@ -432,8 +426,7 @@ PrintEmfWin32::destroy_pen() } -void -PrintEmfWin32::flush_fill() +void PrintEmfWin32::flush_fill() { if (!fill_pathv.empty()) { stroke_and_fill = false; @@ -447,8 +440,7 @@ PrintEmfWin32::flush_fill() } } -unsigned int -PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/) +unsigned int PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/) { if (!m_tr_stack.empty()) { Geom::Affine tr_top = m_tr_stack.top(); @@ -460,15 +452,13 @@ PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &tr return 1; } -unsigned int -PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/) +unsigned int PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/) { m_tr_stack.pop(); return 1; } -unsigned int -PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, +unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, Geom::PathVector const &pathv, Geom::Affine const & /*transform*/, SPStyle const *style, Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { @@ -496,8 +486,7 @@ PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, } -unsigned int -PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/, +unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/, Geom::PathVector const &pathv, const Geom::Affine &/*transform*/, const SPStyle *style, Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { @@ -536,8 +525,7 @@ PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/, } -bool -PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Affine &transform) +bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Affine &transform) { Geom::PathVector pv = pathv_to_linear_and_cubic_beziers( pathv * transform ); @@ -732,8 +720,7 @@ PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff return done; } -unsigned int -PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform) +unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform) { simple_shape = print_simple_shape(pathv, transform); @@ -837,14 +824,12 @@ PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &tr } -bool -PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext) +bool PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext) { return ext->get_param_bool("textToPath"); } -unsigned int -PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point const &p, +unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point const &p, SPStyle const *const style) { if (!hdc) return 0; @@ -935,8 +920,7 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom return 0; } -void -PrintEmfWin32::init (void) +void PrintEmfWin32::init (void) { Inkscape::Extension::Extension * ext; diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h index a4a13681a..47cd47296 100644 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@ -131,7 +131,7 @@ public: class GradientStop { public: - GradientStop() + GradientStop() : rgb(0), opacity(0) {} GradientStop(unsigned long rgbArg, double opacityArg) { rgb = rgbArg; opacity = opacityArg; } diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 344c3c5d2..e8d6363f0 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -110,12 +110,16 @@ SvgBuilder::~SvgBuilder() { } void SvgBuilder::_init() { - _in_text_object = false; - _need_font_update = true; - _invalidated_style = true; _font_style = NULL; _current_font = NULL; + _font_specification = NULL; + _font_scaling = 1; + _need_font_update = true; + _in_text_object = false; + _invalidated_style = true; _current_state = NULL; + _width = 0; + _height = 0; // Fill _availableFontNames (Bug LP #179589) (code cfr. FontLister) FamilyToStylesMap familyStyleMap; diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 7a36be806..c289d9b36 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -221,7 +221,8 @@ private: Inkscape::XML::Node *_root; // Root node from the point of view of this SvgBuilder Inkscape::XML::Node *_container; // Current container (group/pattern/mask) Inkscape::XML::Node *_preferences; // Preferences container node - double _width, _height; // Document size in px + double _width; // Document size in px + double _height; // Document size in px }; diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp index 58db85748..1e5dee51c 100644 --- a/src/extension/param/color.cpp +++ b/src/extension/param/color.cpp @@ -40,8 +40,7 @@ ParamColor::~ParamColor(void) } -guint32 -ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) +guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) { _value = in; @@ -58,7 +57,8 @@ ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node* /** \brief Initialize the object, to do that, copy the data. */ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext) + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _changeSignal(0) { const char * defaulthex = NULL; if (sp_repr_children(xml) != NULL) @@ -77,8 +77,7 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * return; } -void -ParamColor::string (std::string &string) +void ParamColor::string (std::string &string) { char str[16]; sprintf(str, "%i", _value); @@ -86,8 +85,7 @@ ParamColor::string (std::string &string) return; } -Gtk::Widget * -ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) +Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) { if (_gui_hidden) return NULL; @@ -112,8 +110,7 @@ ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, si return dynamic_cast<Gtk::Widget *>(hbox); } -void -sp_color_param_changed(SPColorSelector *csel, GObject *obj) +void sp_color_param_changed(SPColorSelector *csel, GObject *obj) { const SPColor color = csel->base->getColor(); float alpha = csel->base->getAlpha(); diff --git a/src/io/base64stream.cpp b/src/io/base64stream.cpp index 0b20ef95a..0a28a8cc3 100644 --- a/src/io/base64stream.cpp +++ b/src/io/base64stream.cpp @@ -51,12 +51,15 @@ static int base64decode[] = * */ Base64InputStream::Base64InputStream(InputStream &sourceStream) - : BasicInputStream(sourceStream) + : BasicInputStream(sourceStream), + outCount(0), + padCount(0), + done(false) { - outCount = 0; - padCount = 0; - closed = false; - done = false; + for (int k=0;k<3;k++) + { + outBytes[k]=0; + } } /** diff --git a/src/sp-animation.cpp b/src/sp-animation.cpp index f0796b7c6..2951a76fd 100644 --- a/src/sp-animation.cpp +++ b/src/sp-animation.cpp @@ -17,8 +17,7 @@ #if 0 /* Feel free to remove this function and its calls. */ -static void -log_set_attr(char const *const classname, unsigned int const key, char const *const value) +static void log_set_attr(char const *const classname, unsigned int const key, char const *const value) { unsigned char const *const attr_name = sp_attribute_name(key); if (value) { @@ -42,8 +41,7 @@ static void sp_animation_set(SPObject *object, unsigned int key, gchar const *va static SPObjectClass *animation_parent_class; -GType -sp_animation_get_type(void) +GType sp_animation_get_type(void) { static GType animation_type = 0; @@ -63,8 +61,7 @@ sp_animation_get_type(void) return animation_type; } -static void -sp_animation_class_init(SPAnimationClass *klass) +static void sp_animation_class_init(SPAnimationClass *klass) { //GObjectClass *gobject_class = (GObjectClass *) klass; SPObjectClass *sp_object_class = (SPObjectClass *) klass; @@ -76,14 +73,12 @@ sp_animation_class_init(SPAnimationClass *klass) sp_object_class->set = sp_animation_set; } -static void -sp_animation_init(SPAnimation */*animation*/) +static void sp_animation_init(SPAnimation */*animation*/) { } -static void -sp_animation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_animation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { if (((SPObjectClass *) animation_parent_class)->build) ((SPObjectClass *) animation_parent_class)->build(object, document, repr); @@ -102,13 +97,11 @@ sp_animation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node * object->readAttr( "fill" ); } -static void -sp_animation_release(SPObject */*object*/) +static void sp_animation_release(SPObject */*object*/) { } -static void -sp_animation_set(SPObject *object, unsigned int key, gchar const *value) +static void sp_animation_set(SPObject *object, unsigned int key, gchar const *value) { //SPAnimation *animation = SP_ANIMATION(object); @@ -129,8 +122,7 @@ static void sp_ianimation_set(SPObject *object, unsigned int key, gchar const *v static SPObjectClass *ianimation_parent_class; -GType -sp_ianimation_get_type(void) +GType sp_ianimation_get_type(void) { static GType type = 0; @@ -150,8 +142,7 @@ sp_ianimation_get_type(void) return type; } -static void -sp_ianimation_class_init(SPIAnimationClass *klass) +static void sp_ianimation_class_init(SPIAnimationClass *klass) { //GObjectClass *gobject_class = (GObjectClass *) klass; SPObjectClass *sp_object_class = (SPObjectClass *) klass; @@ -163,14 +154,12 @@ sp_ianimation_class_init(SPIAnimationClass *klass) sp_object_class->set = sp_ianimation_set; } -static void -sp_ianimation_init(SPIAnimation */*animation*/) +static void sp_ianimation_init(SPIAnimation */*animation*/) { } -static void -sp_ianimation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_ianimation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { if (((SPObjectClass *) ianimation_parent_class)->build) ((SPObjectClass *) ianimation_parent_class)->build(object, document, repr); @@ -186,13 +175,11 @@ sp_ianimation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node object->readAttr( "accumulate" ); } -static void -sp_ianimation_release(SPObject */*object*/) +static void sp_ianimation_release(SPObject */*object*/) { } -static void -sp_ianimation_set(SPObject *object, unsigned int key, gchar const *value) +static void sp_ianimation_set(SPObject *object, unsigned int key, gchar const *value) { //SPIAnimation *ianimation = SP_IANIMATION(object); @@ -213,8 +200,7 @@ static void sp_animate_set(SPObject *object, unsigned int key, gchar const *valu static SPIAnimationClass *animate_parent_class; -GType -sp_animate_get_type(void) +GType sp_animate_get_type(void) { static GType type = 0; @@ -234,8 +220,7 @@ sp_animate_get_type(void) return type; } -static void -sp_animate_class_init(SPAnimateClass *klass) +static void sp_animate_class_init(SPAnimateClass *klass) { //GObjectClass *gobject_class = (GObjectClass *) klass; SPObjectClass *sp_object_class = (SPObjectClass *) klass; @@ -247,26 +232,22 @@ sp_animate_class_init(SPAnimateClass *klass) sp_object_class->set = sp_animate_set; } -static void -sp_animate_init(SPAnimate */*animate*/) +static void sp_animate_init(SPAnimate */*animate*/) { } -static void -sp_animate_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_animate_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { if (((SPObjectClass *) animate_parent_class)->build) ((SPObjectClass *) animate_parent_class)->build(object, document, repr); } -static void -sp_animate_release(SPObject */*object*/) +static void sp_animate_release(SPObject */*object*/) { } -static void -sp_animate_set(SPObject *object, unsigned int key, gchar const *value) +static void sp_animate_set(SPObject *object, unsigned int key, gchar const *value) { //SPAnimate *animate = SP_ANIMATE(object); diff --git a/src/sp-guide-attachment.h b/src/sp-guide-attachment.h index 09d4375df..45d2096c2 100644 --- a/src/sp-guide-attachment.h +++ b/src/sp-guide-attachment.h @@ -10,7 +10,8 @@ public: public: SPGuideAttachment() : - item(static_cast<SPItem *>(0)) + item(static_cast<SPItem *>(0)), + snappoint_ix(0) { } SPGuideAttachment(SPItem *i, int s) : diff --git a/src/sp-guide-constraint.h b/src/sp-guide-constraint.h index 763696788..ebc3b01ce 100644 --- a/src/sp-guide-constraint.h +++ b/src/sp-guide-constraint.h @@ -10,7 +10,8 @@ public: public: explicit SPGuideConstraint() : - g(static_cast<SPGuide *>(0)) + g(static_cast<SPGuide *>(0)), + snappoint_ix(0) { } explicit SPGuideConstraint(SPGuide *g, int snappoint_ix) : -- cgit v1.2.3 From 4bff1c9162c4640f84bbb256802b01bb23b3da7b Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Tue, 22 Nov 2011 17:19:04 +0100 Subject: initialisation (bzr r10748) --- src/dom/css.h | 19 +++++++++++++++---- src/dom/cssreader.h | 12 +++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/dom/css.h b/src/dom/css.h index 3f0af9ad0..d9c124447 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -1612,23 +1612,34 @@ public: /** * */ - CSSPrimitiveValue() : CSSValue() + CSSPrimitiveValue() : + CSSValue(), + primitiveType(0), + doubleValue(0), + stringValue() { } /** * */ - CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other) + CSSPrimitiveValue(const CSSPrimitiveValue &other) : + CSSValue() { + primitiveType = other.primitiveType; + doubleValue = other.doubleValue; + stringValue = other.stringValue; } /** * */ - CSSPrimitiveValue &operator=(const CSSPrimitiveValue &/*other*/) + CSSPrimitiveValue &operator=(const CSSPrimitiveValue &other) { - return *this; + primitiveType = other.primitiveType; + doubleValue = other.doubleValue; + stringValue = other.stringValue; + return *this; } /** diff --git a/src/dom/cssreader.h b/src/dom/cssreader.h index 0a9a7c031..8f795fc9c 100644 --- a/src/dom/cssreader.h +++ b/src/dom/cssreader.h @@ -53,7 +53,11 @@ public: /** * */ - CssReader() + CssReader() : + stylesheet(), + parsebuf(), + parselen(0), + lastPosition(0) {} /** @@ -75,9 +79,10 @@ public: private: + CSSStyleSheet stylesheet; DOMString parsebuf; long parselen; - CSSStyleSheet stylesheet; + int lastPosition; /** @@ -262,9 +267,6 @@ int getFunction(int p0); */ int getHexColor(int p0); - -int lastPosition; - /** * Get the column and row number of the given character position. * Also gets the last-occuring newline before the position -- cgit v1.2.3 From b64acc36e0105aa38477885637420158f0cc5fac Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sun, 27 Nov 2011 00:41:18 +0100 Subject: small clean up in axonometric grid code (bzr r10751) --- src/display/canvas-axonomgrid.cpp | 52 ++++++--------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index a669142d1..b5fa9e10a 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -1,5 +1,9 @@ /* - * Copyright (C) 2006-2008 Johan Engelen <johan@shouraizou.nl> + * Authors: + * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl> + * + * Copyright (C) 2006-2011 Authors + * Released under GNU GPL, read the file 'COPYING' for more information */ /* @@ -12,15 +16,15 @@ /* * TODO: * THIS FILE AND THE HEADER FILE NEED CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO. - * For example: the line drawing code should not be here. There _must_ be a function somewhere else that can provide this functionality... */ +#include "display/canvas-axonomgrid.h" + #include "2geom/line.h" #include "desktop.h" #include "canvas-grid.h" #include "desktop-handles.h" #include "display/cairo-utils.h" -#include "display/canvas-axonomgrid.h" #include "display/canvas-grid.h" #include "display/sp-canvas-util.h" #include "document.h" @@ -34,8 +38,6 @@ #include "xml/node-event-vector.h" #include "round.h" -#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params - enum Dim3 { X=0, Y, Z }; #ifndef M_PI @@ -45,9 +47,7 @@ enum Dim3 { X=0, Y, Z }; static double deg_to_rad(double deg) { return deg*M_PI/180.0;} /** - * This function renders a line on a particular canvas buffer, - * using Bresenham's line drawing function. - * http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html + * This function calls Cairo to render a line on a particular canvas buffer. * Coordinates are interpreted as SCREENcoordinates */ static void @@ -57,42 +57,6 @@ sp_caxonomgrid_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, g cairo_line_to(buf->ct, 0.5 + x1, 0.5 + y1); ink_cairo_set_source_rgba32(buf->ct, rgba); cairo_stroke(buf->ct); - -#if 0 - int dy = y1 - y0; - int dx = x1 - x0; - int stepx, stepy; - - if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } - if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } - dy <<= 1; // dy is now 2*dy - dx <<= 1; // dx is now 2*dx - - sp_caxonomgrid_setpixel(buf, x0, y0, rgba); - if (dx > dy) { - int fraction = dy - (dx >> 1); // same as 2*dy - dx - while (x0 != x1) { - if (fraction >= 0) { - y0 += stepy; - fraction -= dx; // same as fraction -= 2*dx - } - x0 += stepx; - fraction += dy; // same as fraction -= 2*dy - sp_caxonomgrid_setpixel(buf, x0, y0, rgba); - } - } else { - int fraction = dx - (dy >> 1); - while (y0 != y1) { - if (fraction >= 0) { - x0 += stepx; - fraction -= dy; - } - y0 += stepy; - fraction += dx; - sp_caxonomgrid_setpixel(buf, x0, y0, rgba); - } - } -#endif } static void -- cgit v1.2.3 From 02287189426c0d3e7873e2dd58d2af92068607ba Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sun, 27 Nov 2011 14:49:30 +0100 Subject: preferences read out: when no unit is specified, assume it is in the requested units Fixed bugs: - https://launchpad.net/bugs/799848 (bzr r10752) --- src/preferences.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/preferences.cpp b/src/preferences.cpp index 2a3019d28..4615fd6e1 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -770,7 +770,12 @@ double Preferences::_extractDouble(Entry const &v, Glib::ustring const &requeste double val = _extractDouble(v); Glib::ustring unit = _extractUnit(v); - return val * (unit_table.getUnit(unit).factor / unit_table.getUnit(requested_unit).factor); + if (unit.length() == 0) { + // no unit specified, don't do conversion + return val; + } else { + return val * (unit_table.getUnit(unit).factor / unit_table.getUnit(requested_unit).factor); + } } Glib::ustring Preferences::_extractString(Entry const &v) -- cgit v1.2.3 From 771029025214cffd0bc9783656c29e08ad208743 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah <tavmjong@free.fr> Date: Tue, 29 Nov 2011 12:27:10 +0100 Subject: Add possibility to check validity of attributes and usefulness of properties. This code adds the ability to check for every elment in an SVG document if its attributes are valid and the styling properties are useful. Options under the SVG Output section of the Inkscape Preferences dialog control what should be checked when, and what actions should be taken if invalid attributes or non-useful properties are found. (bzr r10753) --- src/Makefile_insert | 3 + src/attribute-rel-css.cpp | 195 +++++++++++++++++++++ src/attribute-rel-css.h | 66 +++++++ src/attribute-rel-svg.cpp | 120 +++++++++++++ src/attribute-rel-svg.h | 49 ++++++ src/attribute-rel-util.cpp | 312 +++++++++++++++++++++++++++++++++ src/attribute-rel-util.h | 87 +++++++++ src/path-prefix.h | 4 + src/preferences-skeleton.h | 18 +- src/sp-object.cpp | 27 ++- src/ui/dialog/inkscape-preferences.cpp | 36 ++++ src/ui/dialog/inkscape-preferences.h | 11 ++ src/xml/repr-io.cpp | 23 ++- src/xml/simple-node.cpp | 60 ++++++- 14 files changed, 1002 insertions(+), 9 deletions(-) create mode 100644 src/attribute-rel-css.cpp create mode 100644 src/attribute-rel-css.h create mode 100644 src/attribute-rel-svg.cpp create mode 100644 src/attribute-rel-svg.h create mode 100644 src/attribute-rel-util.cpp create mode 100644 src/attribute-rel-util.h (limited to 'src') diff --git a/src/Makefile_insert b/src/Makefile_insert index 2cb689740..c649b26b1 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -6,6 +6,9 @@ ink_common_sources += \ approx-equal.h remove-last.h \ arc-context.cpp arc-context.h \ attributes.cpp attributes.h \ + attribute-rel-svg.cpp attribute-rel-svg.h \ + attribute-rel-css.cpp attribute-rel-css.h \ + attribute-rel-util.cpp attribute-rel-util.h \ axis-manip.cpp axis-manip.h \ bad-uri-exception.h \ box3d-context.cpp box3d-context.h \ diff --git a/src/attribute-rel-css.cpp b/src/attribute-rel-css.cpp new file mode 100644 index 000000000..b014aeb77 --- /dev/null +++ b/src/attribute-rel-css.cpp @@ -0,0 +1,195 @@ +/* + * attribute-rel-css.cpp + * + * Created on: Jul 25, 2011 + * Author: abhishek + */ + +/** \class SPAttributeRelCSS + * + * SPAttributeRelCSS class stores the mapping of element->style_properties + * relationship and provides a static function to access that + * mapping indirectly(only reading). + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <fstream> +#include <sstream> +#include <string> +#include <iostream> + +#include "attribute-rel-css.h" + +#include "path-prefix.h" +#include "preferences.h" + +SPAttributeRelCSS * SPAttributeRelCSS::instance = NULL; + +/* + * This function checks whether an element -> CSS property pair + * is allowed or not + */ +bool SPAttributeRelCSS::findIfValid(Glib::ustring property, Glib::ustring element) +{ + if (SPAttributeRelCSS::instance == NULL) { + SPAttributeRelCSS::instance = new SPAttributeRelCSS(); + } + + // Strip of "svg:" from the element's name + Glib::ustring temp = element; + if ( temp.find("svg:") != std::string::npos ) { + temp.erase( temp.find("svg:"), 4 ); + } + + // Don't check for properties with -, role, aria etc. to allow for more accessbility + // FixMe: Name space list should be created when file read in. + if (property[0] == '-' + || property.substr(0,4) == "role" + || property.substr(0,4) == "aria" + || property.substr(0,5) == "xmlns" + || property.substr(0,8) == "inkscape:" + || property.substr(0,9) == "sodipodi:" + || property.substr(0,4) == "rdf:" + || property.substr(0,3) == "cc:" + || (SPAttributeRelCSS::instance->propertiesOfElements[temp].find(property) + != SPAttributeRelCSS::instance->propertiesOfElements[temp].end()) ) { + return true; + } else { + //g_warning( "Invalid attribute: %s used on <%s>", property.c_str(), element.c_str() ); + return false; + } +} + +/* + * This function checks whether an CSS property -> default value + * pair is allowed or not + */ +bool SPAttributeRelCSS::findIfDefault(Glib::ustring property, Glib::ustring value) +{ + if (SPAttributeRelCSS::instance == NULL) { + SPAttributeRelCSS::instance = new SPAttributeRelCSS(); + } + + if( instance->defaultValuesOfProps[property] == value) { + return true; + } else { + return false; + } +} + +/* + * Check if property can be inherited. + */ +bool SPAttributeRelCSS::findIfInherit(Glib::ustring property) +{ + if (SPAttributeRelCSS::instance == NULL) { + SPAttributeRelCSS::instance = new SPAttributeRelCSS(); + } + + return instance->inheritProps[property]; +} + +/* + * Check if attribute is a property. + */ +bool SPAttributeRelCSS::findIfProperty(Glib::ustring property) +{ + if (SPAttributeRelCSS::instance == NULL) { + SPAttributeRelCSS::instance = new SPAttributeRelCSS(); + } + + return ( instance->defaultValuesOfProps.find( property ) + != instance->defaultValuesOfProps.end() ); +} + +SPAttributeRelCSS::SPAttributeRelCSS() +{ + // Read data from standard path + std::string filepath = INKSCAPE_ATTRRELDIR; + filepath += "/cssprops"; + + // Try and load data from filepath + if (!readDataFromFileIn(filepath, SPAttributeRelCSS::prop_element_pair)) { + // Set default preference for CSS property checking to ignore + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/options/svgoutput/incorrect_style_properties", 3); + } + + // Read data from standard path + filepath = INKSCAPE_ATTRRELDIR; + filepath += "/css_defaults"; + + // Try and load data from filepath + if (!readDataFromFileIn(filepath, SPAttributeRelCSS::prop_defValue_pair)) { + // Set default preference for CSS defaults checking to ignore + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/options/svgoutput/style_defaults", 3); + } +} + +bool SPAttributeRelCSS::readDataFromFileIn(Glib::ustring fileName, storageType type) +{ + std::fstream file; + file.open(fileName.c_str(), std::ios::in); + + if (!file.is_open()) { + // Display warning for file not open + g_warning("Could not open the data file for CSS attribute-element map construction: %s", fileName.c_str()); + file.close(); + return false; + } + + while (!file.eof()) { + std::stringstream ss; + std::string s; + + std::getline(file,s,'"'); + std::getline(file,s,'"'); + if (s.size() > 0 && s[0] != '\n') { + std::string prop = s; + getline(file,s); + ss << s; + + // Load data to structure that holds element -> set of CSS props + if (type == SPAttributeRelCSS::prop_element_pair) { + while (std::getline(ss,s,'"')) { + std::string element; + std::getline(ss,s,'"'); + element = s; + propertiesOfElements[element].insert(prop); + } + // Load data to structure that holds CSS prop -> default value + } else if (type == SPAttributeRelCSS::prop_defValue_pair) { + std::string value; + std::getline(ss,s,'"'); + std::getline(ss,s,'"'); + value = s; + defaultValuesOfProps[prop] = value; + std::getline(ss,s,'"'); + std::getline(ss,s,'"'); + gboolean inherit = false; + if ( s.find( "yes" ) != std::string::npos ) { + inherit = true; + } + inheritProps[prop] = inherit; + } + } + } + + file.close(); + return true; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/attribute-rel-css.h b/src/attribute-rel-css.h new file mode 100644 index 000000000..b5077f8a0 --- /dev/null +++ b/src/attribute-rel-css.h @@ -0,0 +1,66 @@ +#ifndef __SP_ATTRIBUTE_REL_CSS_H__ +#define __SP_ATTRIBUTE_REL_CSS_H__ + +/* + * attribute-rel-css.h + * + * Created on: Jul 25, 2011 + * Author: abhishek + */ + +#include <string> +#include <map> +#include <set> +#include <glibmm/ustring.h> + +// This data structure stores the valid (element -> set of CSS properties) pair +typedef std::map<Glib::ustring, std::set<Glib::ustring> > hashList; + +/* + * Utility class that helps check whether a given element -> CSS property is + * valid or not and whether the value assumed by a CSS property has a default + * value. + */ +class SPAttributeRelCSS { +public: + static bool findIfValid(Glib::ustring property, Glib::ustring element); + static bool findIfDefault(Glib::ustring property, Glib::ustring value); + static bool findIfInherit(Glib::ustring property); + static bool findIfProperty(Glib::ustring property); + +private: + SPAttributeRelCSS(); + SPAttributeRelCSS(const SPAttributeRelCSS&); + SPAttributeRelCSS& operator= (const SPAttributeRelCSS&); + +private: + /* + * Allows checking whether data loading is to be done for element -> CSS properties + * or CSS property -> default value. + */ + enum storageType { + prop_element_pair, + prop_defValue_pair + }; + static SPAttributeRelCSS *instance; + hashList propertiesOfElements; + + // Data structure to store CSS property and default value pair + std::map<Glib::ustring, Glib::ustring> defaultValuesOfProps; + std::map<Glib::ustring, gboolean> inheritProps; + bool readDataFromFileIn(Glib::ustring fileName, storageType type); +}; + + +#endif /* __SP_ATTRIBUTE_REL_CSS_H__ */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/attribute-rel-svg.cpp b/src/attribute-rel-svg.cpp new file mode 100644 index 000000000..3f5ce9395 --- /dev/null +++ b/src/attribute-rel-svg.cpp @@ -0,0 +1,120 @@ +/* + * attribute-rel-svg.cpp + * + * Created on: Jul 25, 2011 + * Author: abhishek + */ + +/** \class SPAttributeRelSVG + * + * SPAttributeRelSVG class stores the mapping of element->attribute + * relationship and provides a static function to access that + * mapping indirectly(only reading). + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <fstream> +#include <sstream> +#include <string> + +#include "attribute-rel-svg.h" + +#include "path-prefix.h" +#include "preferences.h" + +SPAttributeRelSVG * SPAttributeRelSVG::instance = NULL; + +/* + * This functions checks whether an element -> attribute pair is allowed or not + */ +bool SPAttributeRelSVG::findIfValid(Glib::ustring attribute, Glib::ustring element) +{ + if (SPAttributeRelSVG::instance == NULL) { + SPAttributeRelSVG::instance = new SPAttributeRelSVG(); + } + + // Strip of "svg:" from the element's name + Glib::ustring temp = element; + if ( temp.find("svg:") != std::string::npos ) { + temp.erase( temp.find("svg:"), 4 ); + } + + // Check for attributes with -, role, aria etc. to allow for more accessbility + if (attribute[0] == '-' + || attribute.substr(0,4) == "role" + || attribute.substr(0,4) == "aria" + || attribute.substr(0,5) == "xmlns" + || attribute.substr(0,9) == "inkscape:" + || attribute.substr(0,9) == "sodipodi:" + || attribute.substr(0,4) == "rdf:" + || attribute.substr(0,3) == "cc:" + || (SPAttributeRelSVG::instance->attributesOfElements[temp].find(attribute) + != SPAttributeRelSVG::instance->attributesOfElements[temp].end()) ) { + return true; + } else { + //g_warning( "Invalid attribute: %s used on <%s>", attribute.c_str(), element.c_str() ); + return false; + } +} + +/* + * One timer singleton constructor, to load the element -> attributes data + * into memory. + */ +SPAttributeRelSVG::SPAttributeRelSVG() +{ + std::fstream f; + + // Read data from standard path + std::string filepath = INKSCAPE_ATTRRELDIR; + filepath += "/svgprops"; + + f.open(filepath.c_str(), std::ios::in); + + if (!f.is_open()) { + // Set the default preference of attribute checking to ignore + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/options/svgoutput/incorrect_attributes", 3); + + // Display warning for file not open + g_warning("Could not open the data file for XML attribute-element map construction: %s", filepath.c_str()); + f.close(); + return ; + } + + while (!f.eof()){ + std::stringstream ss; + std::string s; + + std::getline(f,s,'"'); + std::getline(f,s,'"'); + if(s.size() > 0 && s[0] != '\n'){ + std::string prop = s; + getline(f,s); + ss << s; + + while(std::getline(ss,s,'"')){ + std::string element; + std::getline(ss,s,'"'); + element = s; + attributesOfElements[element].insert(prop); + } + } + } + + f.close(); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/attribute-rel-svg.h b/src/attribute-rel-svg.h new file mode 100644 index 000000000..f0ba314b6 --- /dev/null +++ b/src/attribute-rel-svg.h @@ -0,0 +1,49 @@ +#ifndef __SP_ATTRIBUTE_REL_SVG_H__ +#define __SP_ATTRIBUTE_REL_SVG_H__ + +/* + * attribute-rel-svg.h + * + * Created on: Jul 25, 2011 + * Author: abhishek + */ + +#include <string> +#include <map> +#include <set> +#include <glibmm/ustring.h> + +// This data structure stores the valid (element -> set of attributes) pair +typedef std::map<Glib::ustring, std::set<Glib::ustring> > hashList; + +/* + * Utility class to check whether a combination of element and attribute + * is valid or not. + */ +class SPAttributeRelSVG { +public: + static bool findIfValid(Glib::ustring attribute, Glib::ustring element); + +private: + SPAttributeRelSVG(); + SPAttributeRelSVG(const SPAttributeRelSVG&); + SPAttributeRelSVG& operator= (const SPAttributeRelSVG&); + +private: + static SPAttributeRelSVG *instance; + hashList attributesOfElements; +}; + + +#endif /* __SP_ATTRIBUTE_REL_SVG_H__ */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp new file mode 100644 index 000000000..9104e26c1 --- /dev/null +++ b/src/attribute-rel-util.cpp @@ -0,0 +1,312 @@ +/* + * attribute-rel-util.h + * + * Created on: Sep 8, 2011 + * Author: tavmjong + */ + +/** + * Utility functions for cleaning SVG tree of unneeded attributes and style properties. + */ + +#include <fstream> +#include <sstream> +#include <string> +#include <iostream> + +#include "preferences.h" + +#include "xml/attribute-record.h" + +#include "attribute-rel-css.h" +#include "attribute-rel-svg.h" + +#include "attribute-rel-util.h" + +using Inkscape::XML::Node; +using Inkscape::XML::AttributeRecord; +using Inkscape::Util::List; + +/** + * Get preferences + */ +unsigned int sp_attribute_clean_get_prefs() { + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + unsigned int flags = 0; + if( prefs->getBool("/options/svgoutput/incorrect_attributes_warn") ) flags += SP_ATTR_CLEAN_ATTR_WARN; + if( prefs->getBool("/options/svgoutput/incorrect_attributes_remove") ) flags += SP_ATTR_CLEAN_ATTR_REMOVE; + if( prefs->getBool("/options/svgoutput/incorrect_style_properties_warn") ) flags += SP_ATTR_CLEAN_STYLE_WARN; + if( prefs->getBool("/options/svgoutput/incorrect_style_properties_remove" ) ) flags += SP_ATTR_CLEAN_STYLE_REMOVE; + if( prefs->getBool("/options/svgoutput/style_defaults_warn") ) flags += SP_ATTR_CLEAN_DEFAULT_WARN; + if( prefs->getBool("/options/svgoutput/style_defaults_remove") ) flags += SP_ATTR_CLEAN_DEFAULT_REMOVE; + + return flags; +} + +/** + * Remove or warn about inappropriate attributes and useless stype properties. + * repr: the root node in a document or any other node. + */ +void sp_attribute_clean_tree(Node *repr) { + + g_return_if_fail (repr != NULL); + + unsigned int flags = sp_attribute_clean_get_prefs(); + + if( flags ) { + sp_attribute_clean_recursive( repr, flags ); + } +} + +/** + * Clean recursively over all elements. + */ +void sp_attribute_clean_recursive(Node *repr, unsigned int flags) { + + g_return_if_fail (repr != NULL); + + if( repr->type() == Inkscape::XML::ELEMENT_NODE ) { + Glib::ustring element = repr->name(); + + // Only clean elements in svg namespace + if( element.substr(0,4) == "svg:" ) { + sp_attribute_clean_element(repr, flags ); + } + } + + for(Node *child=sp_repr_children( repr ) ; child ; child = sp_repr_next( child ) ) { + sp_attribute_clean_recursive( child, flags ); + } +} + +/** + * Clean attributes on an element + */ +void sp_attribute_clean_element(Node *repr, unsigned int flags) { + + g_return_if_fail (repr != NULL); + g_return_if_fail (repr->type() == Inkscape::XML::ELEMENT_NODE); + + Glib::ustring element = repr->name(); + Glib::ustring id = (repr->attribute( "id" )==NULL ? "" : repr->attribute( "id" )); + + // Clean style: this attribute is unique in that normally we want to change it and not simply + // delete it. + sp_attribute_clean_style(repr, flags ); + + // Clean attributes + List<AttributeRecord const> attributes = repr->attributeList(); + + std::set<Glib::ustring> attributesToDelete; + for ( List<AttributeRecord const> iter = attributes ; iter ; ++iter ) { + + Glib::ustring attribute = g_quark_to_string(iter->key); + //Glib::ustring value = (const char*)iter->value; + + bool is_useful = sp_attribute_check_attribute( element, id, attribute, flags & SP_ATTR_CLEAN_ATTR_WARN ); + if( !is_useful ) { + attributesToDelete.insert( attribute ); + } + } + + // Do actual deleting (done after so as not to perturb List iterator). + for( std::set<Glib::ustring>::const_iterator iter_d = attributesToDelete.begin(); + iter_d != attributesToDelete.end(); ++iter_d ) { + repr->setAttribute( (*iter_d).c_str(), NULL, false ); + } +} + + +/** + * Clean CSS style on an element. + */ +void sp_attribute_clean_style(Node *repr, unsigned int flags) { + + g_return_if_fail (repr != NULL); + g_return_if_fail (repr->type() == Inkscape::XML::ELEMENT_NODE); + + // Find element's style + SPCSSAttr *css = sp_repr_css_attr( repr, "style" ); + + sp_attribute_clean_style(repr, css, flags); + + // g_warning( "sp_repr_write_stream_element(): Final style:" ); + //sp_repr_css_print( css ); + + // Convert css node's properties data to string and set repr node's attribute "style" to that string. + // sp_repr_css_set( repr, css, "style"); // Don't use as it will cause loop. + gchar *value = sp_repr_css_write_string(css); + repr->setAttribute("style", value); + if (value) g_free (value); + + sp_repr_css_attr_unref( css ); +} + + +/** + * Clean CSS style on an element. + */ +gchar * sp_attribute_clean_style(Node *repr, gchar const *string, unsigned int flags) { + + g_return_val_if_fail (repr != NULL, NULL); + g_return_val_if_fail (repr->type() == Inkscape::XML::ELEMENT_NODE, NULL); + + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string( css, string ); + sp_attribute_clean_style(repr, css, flags); + gchar* string_cleaned = sp_repr_css_write_string( css ); + + sp_repr_css_attr_unref( css ); + + return string_cleaned; +} + + +/** + * Clean CSS style on an element. + * + * 1. Is a style property appropriate on the given element? + * e.g, font-size is useless on <svg:rect> + * 2. Is the value of the style property useful? + * Is it the same as the parent and it inherits? + * Is it the default value (and the property on the parent is not set or does not inherit)? + */ +void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags) { + + g_return_if_fail (repr != NULL); + g_return_if_fail (css != NULL); + + Glib::ustring element = repr->name(); + Glib::ustring id = (repr->attribute( "id" )==NULL ? "" : repr->attribute( "id" )); + + // Find parent's style, including properties that are inherited. + // Note, a node may not have a parent if it has not yet been added to tree. + SPCSSAttr *css_parent = NULL; + if( repr->parent() ) css_parent = sp_repr_css_attr_inherited( repr->parent(), "style" ); + + // Loop over all properties in "style" node, keeping track of which to delete. + std::set<Glib::ustring> toDelete; + for ( List<AttributeRecord const> iter = css->attributeList() ; iter ; ++iter ) { + + gchar const * property = g_quark_to_string(iter->key); + gchar const * value = iter->value; + + // Check if a property is applicable to an element (i.e. is font-family useful for a <rect>?). + if( !SPAttributeRelCSS::findIfValid( property, element ) ) { + if( flags & SP_ATTR_CLEAN_STYLE_WARN ) { + g_warning( "<%s id=\"%s\">: CSS Style property: \"%s\" is inappropriate.", + element.c_str(), id.c_str(), property ); + } + if( flags & SP_ATTR_CLEAN_STYLE_REMOVE ) { + toDelete.insert(property); + } + continue; + } + + // Find parent value for same property (property) + gchar const * property_p = NULL; + gchar const * value_p = NULL; + if( css_parent != NULL ) { + for ( List<AttributeRecord const> iter_p = css_parent->attributeList() ; iter_p ; ++iter_p ) { + + property_p = g_quark_to_string(iter_p->key); + + if( !g_strcmp0( property, property_p ) ) { + value_p = iter_p->value; + break; + } + } + } + + // If parent has same property value and property is inherited, mark for deletion. + if ( !g_strcmp0( value, value_p ) && SPAttributeRelCSS::findIfInherit( property ) ) { + + if ( flags & SP_ATTR_CLEAN_DEFAULT_WARN ) { + g_warning( "<%s id=\"%s\">: CSS Style property: \"%s\" has same value as parent (%s).", + element.c_str(), id.c_str(), property, value ); + } + if ( flags & SP_ATTR_CLEAN_DEFAULT_REMOVE ) { + toDelete.insert( property ); + } + continue; + } + + // If property value is same as default and the parent value not set or property is not inherited, + // mark for deletion. + if ( SPAttributeRelCSS::findIfDefault( property, value ) && + ( (css_parent != NULL && value_p == NULL) || !SPAttributeRelCSS::findIfInherit( property ) ) ) { + + if ( flags & SP_ATTR_CLEAN_DEFAULT_WARN ) { + g_warning( "<%s id=\"%s\">: CSS Style property: \"%s\" with default value (%s) not needed.", + element.c_str(), id.c_str(), property, value ); + } + if ( flags & SP_ATTR_CLEAN_DEFAULT_REMOVE ) { + toDelete.insert( property ); + } + continue; + } + + } // End loop over style properties + + // Delete unneeded style properties. Do this at the end so as to not perturb List iterator. + for( std::set<Glib::ustring>::const_iterator iter_d = toDelete.begin(); iter_d != toDelete.end(); ++iter_d ) { + sp_repr_css_set_property( css, (*iter_d).c_str(), NULL ); + } + +} + +/** + * Check one attribute on an element + */ +bool sp_attribute_check_attribute(Glib::ustring element, Glib::ustring id, Glib::ustring attribute, bool warn) { + + bool is_useful = true; + + if( SPAttributeRelCSS::findIfProperty( attribute ) ) { + + // First check if it is a presentation attribute. Presentation attributes can be applied to + // any element. At the moment, we are only going to check if it is a possibly useful + // attribute. Note, we don't explicitely check against the list of elements where presentation + // attributes are allowed (See SVG1.1 spec, Appendix M.2). + if( !SPAttributeRelCSS::findIfValid( attribute, element ) ) { + + // Non-useful presentation attribute on SVG <element> + if( warn ) { + g_warning( "<%s id=\"%s\">: Non-useful presentation attribute: \"%s\" found.", + element.c_str(), + id.c_str(), + attribute.c_str() ); + } + is_useful = false; + } + + } else { + + // Second check if it is a valid attribute + if ( !SPAttributeRelSVG::findIfValid( attribute, element ) ) { + + // Invalid attribute on SVG <element> + if( warn ) { + g_warning( "<%s id=\"%s\">: Invalid attribute: \"%s\" found.", + element.c_str(), + id.c_str(), + attribute.c_str() ); + } + is_useful = false; + } + } + + return is_useful; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/attribute-rel-util.h b/src/attribute-rel-util.h new file mode 100644 index 000000000..d9d270a13 --- /dev/null +++ b/src/attribute-rel-util.h @@ -0,0 +1,87 @@ +#ifndef __SP_ATTRIBUTE_REL_UTIL_H__ +#define __SP_ATTRIBUTE_REL_UTIL_H__ + +/* + * attribute-rel-util.h + * + * Created on: Sep 8, 2011 + * Author: tavmjong + */ + +#include "glibmm/ustring.h" +#include "xml/node.h" +#include "xml/sp-css-attr.h" + +using Inkscape::XML::Node; + +/** + * Utility functions for cleaning XML tree. + */ + +/** + * Enum for preferences + */ +enum SPAttrClean { + SP_ATTR_CLEAN_ATTR_WARN = 1, + SP_ATTR_CLEAN_ATTR_REMOVE = 2, + SP_ATTR_CLEAN_STYLE_WARN = 4, + SP_ATTR_CLEAN_STYLE_REMOVE = 8, + SP_ATTR_CLEAN_DEFAULT_WARN = 16, + SP_ATTR_CLEAN_DEFAULT_REMOVE = 32 +}; + +/** + * Get preferences + */ +unsigned int sp_attribute_clean_get_prefs(); + +/** + * Remove or warn about inappropriate attributes and useless style properties. + * repr: the root node in a document or any other node. + */ +void sp_attribute_clean_tree(Node *repr); + +/** + * Recursively clean. + * repr: the root node in a document or any other node. + * pref_attr, pref_style, pref_defaults: ignore, delete, or warn. + */ +void sp_attribute_clean_recursive(Node *repr, unsigned int flags); + +/** + * Clean one element (attributes and style properties). + */ +void sp_attribute_clean_element(Node *repr, unsigned int flags); + +/** + * Clean style properties for one element. + */ +void sp_attribute_clean_style(Node *repr, unsigned int flags); + +/** + * Clean style properties for one style string. + */ +gchar* sp_attribute_clean_style(Node *repr, gchar const *string, unsigned int flags); + +/** + * Clean style properties for one CSS. + */ +void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags); + +/** + * Check one attribute on an element + */ +bool sp_attribute_check_attribute(Glib::ustring element, Glib::ustring id, Glib::ustring attribute, bool warn); + +#endif /* __SP_ATTRIBUTE_REL_UTIL_H__ */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/path-prefix.h b/src/path-prefix.h index b2ff6ff88..193801532 100644 --- a/src/path-prefix.h +++ b/src/path-prefix.h @@ -22,6 +22,7 @@ extern "C" { #ifdef ENABLE_BINRELOC # define INKSCAPE_APPICONDIR BR_DATADIR( "/pixmaps" ) +# define INKSCAPE_ATTRRELDIR BR_DATADIR( "/inkscape/attributes" ) # define INKSCAPE_BINDDIR BR_DATADIR( "/inkscape/bind" ) # define INKSCAPE_EXAMPLESDIR BR_DATADIR( "/inkscape/examples" ) # define INKSCAPE_EXTENSIONDIR BR_DATADIR( "/inkscape/extensions" ) @@ -43,6 +44,7 @@ extern "C" { #else # ifdef WIN32 # define INKSCAPE_APPICONDIR WIN32_DATADIR("pixmaps") +# define INKSCAPE_ATTRRELDIR WIN32_DATADIR "share\\attributes" # define INKSCAPE_BINDDIR WIN32_DATADIR("share\\bind") # define INKSCAPE_EXAMPLESDIR WIN32_DATADIR("share\\examples") # define INKSCAPE_EXTENSIONDIR WIN32_DATADIR("share\\extensions") @@ -63,6 +65,7 @@ extern "C" { # define CREATE_PATTERNSDIR WIN32_DATADIR("create\\patterns\\vector") # elif defined ENABLE_OSX_APP_LOCATIONS # define INKSCAPE_APPICONDIR "Contents/Resources/pixmaps" +# define INKSCAPE_ATTRRELDIR "Contents/Resources/attributes" # define INKSCAPE_BINDDIR "Contents/Resources/bind" # define INKSCAPE_EXAMPLESDIR "Contents/Resources/examples" # define INKSCAPE_EXTENSIONDIR "Contents/Resources/extensions" @@ -83,6 +86,7 @@ extern "C" { # define CREATE_PATTERNSDIR "/Library/Application Support/create/patterns/vector" # else # define INKSCAPE_APPICONDIR INKSCAPE_DATADIR "/pixmaps" +# define INKSCAPE_ATTRRELDIR INKSCAPE_DATADIR "/inkscape/attributes" # define INKSCAPE_BINDDIR INKSCAPE_DATADIR "/inkscape/bind" # define INKSCAPE_EXAMPLESDIR INKSCAPE_DATADIR "/inkscape/examples" # define INKSCAPE_EXTENSIONDIR INKSCAPE_DATADIR "/inkscape/extensions" diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 70193bf96..b4f1e12cc 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -315,7 +315,23 @@ static char const preferences_skeleton[] = " images=\"4278190335\"" //ff0000ff " clips=\"16711935\"" // 00ff00ff " masks=\"65535\"/>\n" // 0x0000ffff -" <group id=\"svgoutput\" usenamedcolors=\"0\" numericprecision=\"8\" minimumexponent=\"-8\" inlineattrs=\"0\" indent=\"2\" allowrelativecoordinates=\"1\" forcerepeatcommands=\"0\"/>\n" +" <group id=\"svgoutput\" " +" usenamedcolors=\"0\" " +" numericprecision=\"8\" " +" minimumexponent=\"-8\" " +" inlineattrs=\"0\" " +" indent=\"2\" " +" allowrelativecoordinates=\"1\" " +" forcerepeatcommands=\"0\" " +" incorrect_attributes_warn=\"1\" " +" incorrect_attributes_remove=\"0\" " +" incorrect_style_properties_warn=\"1\" " +" incorrect_style_properties_remove=\"0\" " +" style_defaults_warn=\"1\" " +" style_defaults_remove=\"0\" " +" check_on_reading=\"0\" " +" check_on_editing=\"0\" " +" check_on_writing=\"0\"/>\n" " <group id=\"forkgradientvectors\" value=\"1\"/>\n" " <group id=\"iconrender\" named_nodelay=\"0\"/>\n" " <group id=\"autosave\" enable=\"0\" interval=\"10\" path=\"\" max=\"10\"/>\n" diff --git a/src/sp-object.cpp b/src/sp-object.cpp index d746e278d..bf85d074e 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -20,8 +20,10 @@ #include "helper/sp-marshal.h" #include "xml/node-event-vector.h" #include "attributes.h" +#include "attribute-rel-util.h" #include "color-profile.h" #include "document.h" +#include "preferences.h" #include "style.h" #include "sp-object-repr.h" #include "sp-paint-server.h" @@ -1021,8 +1023,31 @@ Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inksca SPStyle const *const obj_style = object->style; if (obj_style) { gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET); - repr->setAttribute("style", ( *s ? s : NULL )); + + // Check for valid attributes. This may be time consuming. + // It is useful, though, for debugging Inkscape code. + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if( prefs->getBool("/options/svgoutput/check_on_editing") ) { + + unsigned int flags = sp_attribute_clean_get_prefs(); + gchar *s_cleaned = sp_attribute_clean_style( repr, s, flags ); + + // g_warning("SPObject::sp_object_private_write: %s", object->getId() ); + // g_warning(" old: :%s:", repr->attribute("style") ); + // g_warning(" new: :%s:", s ); + // g_warning(" cleaned: :%s:", s_cleaned ); + + g_free( s ); + s = s_cleaned; + } + + if( s == NULL || strcmp(s,"") == 0 ) { + repr->setAttribute("style", NULL); + } else { + repr->setAttribute("style", s); + } g_free(s); + } else { /** \todo I'm not sure what to do in this case. Bug #1165868 * suggests that it can arise, but the submitter doesn't know diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6d28e8c88..cb4d2b755 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1124,6 +1124,42 @@ void InkscapePreferences::initPageSVGOutput() _svgoutput_minimumexponent.init("/options/svgoutput/minimumexponent", -32.0, -1, 1.0, 2.0, -8.0, true, false); _page_svgoutput.add_line( false, _("Minimum exponent:"), _svgoutput_minimumexponent, "", _("The smallest number written to SVG is 10 to the power of this exponent; anything smaller is written as zero"), false); + /* Code to add controls for attribute checking options */ + + /* Add incorrect style properties options */ + _page_svgoutput.add_group_header( _("Improper Attributes Actions")); + + _svgoutput_attrwarn.init( _("Print warnings"), "/options/svgoutput/incorrect_attributes_warn", true); + _page_svgoutput.add_line( false, "", _svgoutput_attrwarn, "", _("Print warning if invalid or non-useful attributes found. Database files located in inkscape_data_dir/attributes."), false); + _svgoutput_attrremove.init( _("Remove attributes"), "/options/svgoutput/incorrect_attributes_remove", false); + _page_svgoutput.add_line( false, "", _svgoutput_attrremove, "", _("Delete invalid or non-useful attributes from element tag."), false); + + /* Add incorrect style properties options */ + _page_svgoutput.add_group_header( _("Inappropriate Style Properties Actions")); + + _svgoutput_stylepropwarn.init( _("Print warnings"), "/options/svgoutput/incorrect_style_properties_warn", true); + _page_svgoutput.add_line( false, "", _svgoutput_stylepropwarn, "", _("Print warning if inappropriate style properties found (i.e. 'font-family' set on a <rect>). Database files located in inkscape_data_dir/attributes."), false); + _svgoutput_stylepropremove.init( _("Remove style properties"), "/options/svgoutput/incorrect_style_properties_remove", false); + _page_svgoutput.add_line( false, "", _svgoutput_stylepropremove, "", _("Delete inappropriate style properties."), false); + + /* Add default or inherited style properties options */ + _page_svgoutput.add_group_header( _("Non-useful Style Properties Actions")); + + _svgoutput_styledefaultswarn.init( _("Print warnings"), "/options/svgoutput/style_defaults_warn", true); + _page_svgoutput.add_line( false, "", _svgoutput_styledefaultswarn, "", _("Print warning if redundant style properties found (i.e. if a property has the default value and a different value is not inherited or if value is the same as would be inherited). Database files located in inkscape_data_dir/attributes."), false); + _svgoutput_styledefaultsremove.init( _("Remove style properties"), "/options/svgoutput/style_defaults_remove", false); + _page_svgoutput.add_line( false, "", _svgoutput_styledefaultsremove, "", _("Delete redundant style properties."), false); + + _page_svgoutput.add_group_header( _("Check Attributes and Style Properties on:")); + + _svgoutput_check_reading.init( _("Reading"), "/options/svgoutput/check_on_reading", false); + _page_svgoutput.add_line( false, "", _svgoutput_check_reading, "", _("Check attributes and style properties on reading in SVG files (including those internal to Inkscape which will slow down startup)."), false); + _svgoutput_check_editing.init( _("Editing"), "/options/svgoutput/check_on_editing", false); + _page_svgoutput.add_line( false, "", _svgoutput_check_editing, "", _("Check attributes and style properties while editing SVG files (may slow down Inkscape, mostly useful for debugging)."), false); + _svgoutput_check_writing.init( _("Writing"), "/options/svgoutput/check_on_writing", true); + _page_svgoutput.add_line( false, "", _svgoutput_check_writing, "", _("Check attributes and style properties on writing out SVG files."), false); + + this->AddPage(_page_svgoutput, _("SVG output"), PREFS_PAGE_SVGOUTPUT); } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index d783a2df1..a72b74203 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -358,6 +358,17 @@ protected: UI::Widget::PrefCheckButton _svgoutput_allowrelativecoordinates; UI::Widget::PrefCheckButton _svgoutput_forcerepeatcommands; + // Attribute Checking controls for SVG Output page: + UI::Widget::PrefCheckButton _svgoutput_attrwarn; + UI::Widget::PrefCheckButton _svgoutput_attrremove; + UI::Widget::PrefCheckButton _svgoutput_stylepropwarn; + UI::Widget::PrefCheckButton _svgoutput_stylepropremove; + UI::Widget::PrefCheckButton _svgoutput_styledefaultswarn; + UI::Widget::PrefCheckButton _svgoutput_styledefaultsremove; + UI::Widget::PrefCheckButton _svgoutput_check_reading; + UI::Widget::PrefCheckButton _svgoutput_check_editing; + UI::Widget::PrefCheckButton _svgoutput_check_writing; + UI::Widget::PrefEntryButtonHBox _importexport_ocal_url; UI::Widget::PrefEntry _importexport_ocal_username; UI::Widget::PrefEntry _importexport_ocal_password; diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 365415488..39eb2637a 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -33,6 +33,8 @@ #include "extension/extension.h" +#include "attribute-rel-util.h" + #include "preferences.h" using Inkscape::IO::Writer; @@ -256,6 +258,7 @@ int XmlSource::close() Document * sp_repr_read_file (const gchar * filename, const gchar *default_ns) { + // g_warning( "Reading file: %s", filename ); xmlDocPtr doc = 0; Document * rdoc = 0; @@ -446,6 +449,18 @@ sp_repr_do_read (xmlDocPtr doc, const gchar *default_ns) promote_to_namespace(root, INKSCAPE_EXTENSION_NS_NC); } } + + + // Clean unnecessary attributes and style properties from SVG documents. (Controlled by + // preferences.) Note: internal Inkscape svg files will also be cleaned (filters.svg, + // icons.svg). How can one tell if a file is internal? + if ( !strcmp(root->name(), "svg:svg" ) ) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool clean = prefs->getBool("/options/svgoutput/check_on_reading"); + if( clean ) { + sp_attribute_clean_tree( root ); + } + } } g_hash_table_destroy (prefix_map); @@ -806,6 +821,12 @@ sp_repr_write_stream_root_element(Node *repr, Writer &out, using Inkscape::Util::ptr_shared; g_assert(repr != NULL); + + // Clean unnecessary attributes and stype properties. (Controlled by preferences.) + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool clean = prefs->getBool("/options/svgoutput/check_on_writing"); + if (clean) sp_attribute_clean_tree( repr ); + Glib::QueryQuark xml_prefix=g_quark_from_static_string("xml"); NSMap ns_map; @@ -928,7 +949,7 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, add_whitespace = false; } - + // THIS DOESN'T APPEAR TO DO ANYTHING. Can it be commented out or deleted? { GQuark const href_key = g_quark_from_static_string("xlink:href"); GQuark const absref_key = g_quark_from_static_string("sodipodi:absref"); diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index 792706a18..44ddba237 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -1,6 +1,5 @@ -/** - * @file - * Garbage collected XML node implementation. +/** @file + * @brief Garbage collected XML node implementation */ /* Copyright 2003-2005 MenTaLguY <mental@rydia.net> * Copyright 2003 Nathan Hurst @@ -17,8 +16,11 @@ #include <cstring> #include <string> + #include <glib/gstrfuncs.h> +#include "preferences.h" + #include "xml/node.h" #include "xml/simple-node.h" #include "xml/node-event-vector.h" @@ -29,6 +31,8 @@ #include "util/share.h" #include "util/format.h" +#include "attribute-rel-util.h" + namespace Inkscape { namespace XML { @@ -312,6 +316,47 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_ { g_return_if_fail(name && *name); + // Check usefulness of attributes on elements in the svg namespace, optionally don't add them to tree. + Glib::ustring element = g_quark_to_string(_name); + //g_warning("setAttribute: %s: %s: %s", element.c_str(), name, value); + + gchar* cleaned_value = g_strdup( value ); + + // Only check elements in SVG name space and don't block setting attribute to NULL. + if( element.substr(0,4) == "svg:" && value != NULL) { + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if( prefs->getBool("/options/svgoutput/check_on_editing") ) { + + gchar const *id_char = attribute("id"); + Glib::ustring id = (id_char == NULL ? "" : id_char ); + unsigned int flags = sp_attribute_clean_get_prefs(); + bool attr_warn = flags & SP_ATTR_CLEAN_ATTR_WARN; + bool attr_remove = flags & SP_ATTR_CLEAN_ATTR_REMOVE; + + // Check attributes + if( (attr_warn || attr_remove) && value != NULL ) { + bool is_useful = sp_attribute_check_attribute( element, id, name, attr_warn ); + if( !is_useful && attr_remove ) { + g_free( cleaned_value ); + return; // Don't add to tree. + } + } + + // Check style properties -- Note: if element is not yet inserted into + // tree (and thus has no parent), default values will not be tested. + if( !strcmp( name, "style" ) && (flags >= SP_ATTR_CLEAN_STYLE_WARN) ) { + g_free( cleaned_value ); + cleaned_value = sp_attribute_clean_style( this, value, flags ); + // if( g_strcmp0( value, cleaned_value ) ) { + // g_warning( "SimpleNode::setAttribute: %s", id.c_str() ); + // g_warning( " original: %s", value); + // g_warning( " cleaned: %s", cleaned_value); + // } + } + } + } + GQuark const key = g_quark_from_string(name); MutableList<AttributeRecord> ref; @@ -322,14 +367,13 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_ } ref = existing; } - Debug::EventTracker<> tracker; ptr_shared<char> old_value=( existing ? existing->value : ptr_shared<char>() ); ptr_shared<char> new_value=ptr_shared<char>(); - if (value) { - new_value = share_string(value); + if (cleaned_value) { + new_value = share_string(cleaned_value); tracker.set<DebugSetAttribute>(*this, key, new_value); if (!existing) { if (ref) { @@ -355,7 +399,11 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_ if ( new_value != old_value && (!old_value || !new_value || strcmp(old_value, new_value))) { _document->logger()->notifyAttributeChanged(*this, key, old_value, new_value); _observers.notifyAttributeChanged(*this, key, old_value, new_value); + //g_warning( "setAttribute notified: %s: %s: %s: %s", name, element.c_str(), old_value, new_value ); } + + g_free( cleaned_value ); + } void SimpleNode::addChild(Node *generic_child, Node *generic_ref) { -- cgit v1.2.3 From f8c23dc7d4dff313109ddee26b68e2f10465d200 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah <tavmjong@free.fr> Date: Tue, 29 Nov 2011 16:47:27 +0100 Subject: Add feMergeNode to "in" list in svgprops. Fix bug in preferences for deleting invalid attributes. (bzr r10754) --- src/attribute-rel-util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index 9104e26c1..49b6fd73e 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -105,8 +105,8 @@ void sp_attribute_clean_element(Node *repr, unsigned int flags) { //Glib::ustring value = (const char*)iter->value; bool is_useful = sp_attribute_check_attribute( element, id, attribute, flags & SP_ATTR_CLEAN_ATTR_WARN ); - if( !is_useful ) { - attributesToDelete.insert( attribute ); + if( !is_useful && (flags & SP_ATTR_CLEAN_ATTR_REMOVE) ) { + attributesToDelete.insert( attribute ); } } -- cgit v1.2.3 From f7bcc3fdb2d10dd16a9db10d6c00b624bacae2ca Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Tue, 29 Nov 2011 22:50:07 +0100 Subject: fix typo to repair build on windows (bzr r10755) --- src/path-prefix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/path-prefix.h b/src/path-prefix.h index 193801532..bdb6b35f7 100644 --- a/src/path-prefix.h +++ b/src/path-prefix.h @@ -44,7 +44,7 @@ extern "C" { #else # ifdef WIN32 # define INKSCAPE_APPICONDIR WIN32_DATADIR("pixmaps") -# define INKSCAPE_ATTRRELDIR WIN32_DATADIR "share\\attributes" +# define INKSCAPE_ATTRRELDIR WIN32_DATADIR("share\\attributes") # define INKSCAPE_BINDDIR WIN32_DATADIR("share\\bind") # define INKSCAPE_EXAMPLESDIR WIN32_DATADIR("share\\examples") # define INKSCAPE_EXTENSIONDIR WIN32_DATADIR("share\\extensions") -- cgit v1.2.3 From b84cfccf51ae64c718c1afde9c785aab3faf62ba Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Fri, 2 Dec 2011 14:35:14 +1100 Subject: add missing files into cmake list (bzr r10756) --- src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d68e2caa..ba7b753de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,6 +8,9 @@ set(main_SRC ) set(sp_SRC + attribute-rel-css.cpp + attribute-rel-svg.cpp + attribute-rel-util.cpp sp-anchor.cpp # sp-animation.cpp sp-clippath.cpp @@ -78,6 +81,9 @@ set(sp_SRC # ------- # Headers + attribute-rel-css.h + attribute-rel-svg.h + attribute-rel-util.h sp-anchor.h sp-animation.h sp-clippath.h -- cgit v1.2.3 From 568092089e052882df7f160a3ba8bec9e275c437 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sun, 4 Dec 2011 11:10:12 +0100 Subject: cppcheck (bzr r10759) --- src/dom/css.h | 4 ++++ src/dom/lsimpl.h | 16 ++++++++++++---- src/dom/odf/odfdocument.cpp | 4 +++- src/dom/svgreader.h | 13 +++++-------- src/dom/traversal.h | 13 +++++++++++-- src/dom/util/ziptool.cpp | 45 +++++++++++++++++++++++++++++++++------------ src/dom/util/ziptool.h | 2 -- src/dom/xmlreader.cpp | 30 ++++++++++++++++++------------ src/dom/xmlreader.h | 21 +++++++-------------- src/dom/xmlwriter.cpp | 4 +++- src/dom/xmlwriter.h | 13 +------------ src/dom/xpathparser.cpp | 2 +- src/dom/xpathparser.h | 19 +++++++++---------- src/xml/repr-io.cpp | 4 ++++ 14 files changed, 111 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/src/dom/css.h b/src/dom/css.h index d9c124447..2776b6d20 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -1636,6 +1636,10 @@ public: */ CSSPrimitiveValue &operator=(const CSSPrimitiveValue &other) { + if(this == &other) + { + return *this; + } primitiveType = other.primitiveType; doubleValue = other.doubleValue; stringValue = other.stringValue; diff --git a/src/dom/lsimpl.h b/src/dom/lsimpl.h index 621a5577a..fcfd42a4b 100644 --- a/src/dom/lsimpl.h +++ b/src/dom/lsimpl.h @@ -100,13 +100,18 @@ public: /** * */ - LSParserImpl() + LSParserImpl() : + reader(), + filter(0) {} /** * */ - LSParserImpl(const LSParserImpl &other) : LSParser(other) + LSParserImpl(const LSParserImpl &other) : + LSParser(other), + reader(), + filter(0) {} /** @@ -214,9 +219,12 @@ public: /** * */ - LSSerializerImpl() + LSSerializerImpl() : + outbuf(), + indent(0), + domConfig(0), + filter(0) { - indent = 0; } /** diff --git a/src/dom/odf/odfdocument.cpp b/src/dom/odf/odfdocument.cpp index 50af90f6c..1e7a61e4e 100644 --- a/src/dom/odf/odfdocument.cpp +++ b/src/dom/odf/odfdocument.cpp @@ -110,7 +110,9 @@ void ImageData::setData(const std::vector<unsigned char> &buf) /** * */ -OdfDocument::OdfDocument() +OdfDocument::OdfDocument() : + content(0), + images() { } diff --git a/src/dom/svgreader.h b/src/dom/svgreader.h index 3d66ce507..3178293fd 100644 --- a/src/dom/svgreader.h +++ b/src/dom/svgreader.h @@ -65,14 +65,11 @@ public: /** * */ - SVGReader() - { - } - - /** - * - */ - SVGReader(const SVGReader &/*other*/) + SVGReader() : + parsebuf(), + parselen(0), + lastPosition(0), + doc(0) { } diff --git a/src/dom/traversal.h b/src/dom/traversal.h index 0cade9576..13850f78e 100644 --- a/src/dom/traversal.h +++ b/src/dom/traversal.h @@ -286,7 +286,11 @@ public: /** * */ - NodeIterator() {} + NodeIterator() : + whatToShow(0), + filter(), + expandEntityReferences(0) + {} /** * @@ -485,7 +489,12 @@ public: /** * */ - TreeWalker() {} + TreeWalker() : + whatToShow(0), + filter(), + expandEntityReferences(0), + currentNode(0) + {} /** * diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp index 0b13f66ba..081bcbbc4 100644 --- a/src/dom/util/ziptool.cpp +++ b/src/dom/util/ziptool.cpp @@ -302,7 +302,12 @@ private: /** * */ -Inflater::Inflater() +Inflater::Inflater() : + dest(), + src(), + srcPos(0), + bitBuf(0), + bitCnt(0) { } @@ -800,7 +805,7 @@ bool Inflater::inflate(std::vector<unsigned char> &destination, //######################################################################## - +#define DEFLATER_BUF_SIZE 32768 class Deflater { public: @@ -862,14 +867,14 @@ private: bool compress(); + std::vector<unsigned char> compressed; + std::vector<unsigned char> uncompressed; std::vector<unsigned char> window; unsigned int windowPos; - std::vector<unsigned char> compressed; - //#### Output unsigned int outputBitBuf; unsigned int outputNrBits; @@ -887,9 +892,9 @@ private: //#### Huffman Encode void encodeLiteralStatic(unsigned int ch); - unsigned char windowBuf[32768]; + unsigned char windowBuf[DEFLATER_BUF_SIZE]; //assume 32-bit ints - unsigned int windowHashBuf[32768]; + unsigned int windowHashBuf[DEFLATER_BUF_SIZE]; }; @@ -919,11 +924,17 @@ Deflater::~Deflater() */ void Deflater::reset() { - outputBitBuf = 0; - outputNrBits = 0; - window.clear(); compressed.clear(); uncompressed.clear(); + window.clear(); + windowPos = 0; + outputBitBuf = 0; + outputNrBits = 0; + for (int k=0; k<DEFLATER_BUF_SIZE; k++) + { + windowBuf[k]=0; + windowHashBuf[k]=0; + } } /** @@ -1415,7 +1426,12 @@ bool Deflater::compress() /** * Constructor */ -GzipFile::GzipFile() +GzipFile::GzipFile() : + data(), + fileName(), + fileBuf(), + fileBufPos(0), + compressionMethod(0) { } @@ -1883,6 +1899,7 @@ ZipEntry::ZipEntry() { crc = 0L; compressionMethod = 8; + position = 0; } /** @@ -1895,6 +1912,7 @@ ZipEntry::ZipEntry(const std::string &fileNameArg, compressionMethod = 8; fileName = fileNameArg; comment = commentArg; + position = 0; } /** @@ -2124,9 +2142,12 @@ unsigned long ZipEntry::getPosition() /** * Constructor */ -ZipFile::ZipFile() +ZipFile::ZipFile() : + entries(), + fileBuf(), + fileBufPos(0), + comment() { - } /** diff --git a/src/dom/util/ziptool.h b/src/dom/util/ziptool.h index 47e669962..dbae8ac60 100644 --- a/src/dom/util/ziptool.h +++ b/src/dom/util/ziptool.h @@ -216,8 +216,6 @@ private: #endif ; - unsigned long crc; - std::vector<unsigned char> fileBuf; unsigned long fileBufPos; diff --git a/src/dom/xmlreader.cpp b/src/dom/xmlreader.cpp index 501da6193..29519d592 100644 --- a/src/dom/xmlreader.cpp +++ b/src/dom/xmlreader.cpp @@ -950,25 +950,31 @@ XmlReader::loadFile(const DOMString &fileName) /** * */ -XmlReader::XmlReader() +XmlReader::XmlReader() : + document(), + parsebuf(), + keepGoing(false), + parseAsData(false), + pos(0), + len(0), + lineNr(1), + colNr(0) { - len = 0; - lineNr = 1; - colNr = 0; - parseAsData = false; - keepGoing = false; } /** * */ -XmlReader::XmlReader(bool parseAsDataArg) +XmlReader::XmlReader(bool parseAsDataArg) : + document(), + parsebuf(), + keepGoing(false), + parseAsData(parseAsDataArg), + pos(0), + len(0), + lineNr(1), + colNr(0) { - len = 0; - lineNr = 1; - colNr = 0; - parseAsData = parseAsDataArg; - keepGoing = false; } diff --git a/src/dom/xmlreader.h b/src/dom/xmlreader.h index 7ab6de826..f45601d33 100644 --- a/src/dom/xmlreader.h +++ b/src/dom/xmlreader.h @@ -100,30 +100,23 @@ private: int parseVersion(int pos); int parseDoctype(int pos); - int parseCDATA (int pos, CDATASectionPtr cdata); int parseComment(int pos, CommentPtr comment); int parseText(int pos, TextPtr text); - int parseEntity(int pos, DOMString &buf); - int parseAttributes(int p0, NodePtr node, bool *quickClose); - int parseNode(int p0, NodePtr node, int depth); - bool keepGoing; - bool parseAsData; - int pos; //current parse position - int len; //length of parsed region - DOMString parsebuf; - DOMString loadFile(const DOMString &fileName); - int lineNr; - int colNr; - DocumentPtr document; - + DOMString parsebuf; + bool keepGoing; + bool parseAsData; + int pos; //current parse position + int len; //length of parsed region + int lineNr; + int colNr; }; } //namespace dom diff --git a/src/dom/xmlwriter.cpp b/src/dom/xmlwriter.cpp index a25dbe0b1..4fda5b5fe 100644 --- a/src/dom/xmlwriter.cpp +++ b/src/dom/xmlwriter.cpp @@ -175,7 +175,9 @@ void XmlWriter::writeFile(FILE *f, const NodePtr node) /** * */ -XmlWriter::XmlWriter() +XmlWriter::XmlWriter() : + indent(0), + buf() { } diff --git a/src/dom/xmlwriter.h b/src/dom/xmlwriter.h index f50c91bc4..ada0be04c 100644 --- a/src/dom/xmlwriter.h +++ b/src/dom/xmlwriter.h @@ -50,30 +50,19 @@ namespace dom class XmlWriter { public: - XmlWriter(); - virtual ~XmlWriter(); - - void write(const NodePtr node); - void writeFile(FILE *f, const NodePtr node); protected: - - int indent; - void spaces(); - void po(const char *str, ...) G_GNUC_PRINTF(2,3); - void pos(const DOMString &str); + int indent; DOMString buf; - - }; diff --git a/src/dom/xpathparser.cpp b/src/dom/xpathparser.cpp index 5fd31c12a..f0e929687 100644 --- a/src/dom/xpathparser.cpp +++ b/src/dom/xpathparser.cpp @@ -467,7 +467,7 @@ int XPathParser::lexicalScan() { long op = (long)entry->ival; //according to the disambiguating rule for * in the spec - if (op == MULTIPLY && lexicalTokens.size() > 0) + if (op == MULTIPLY && !lexicalTokens.empty()) { int ltyp = lexTokType(lexicalTokens.size()-1); if (ltyp != AMPR && ltyp != DOUBLE_COLON && diff --git a/src/dom/xpathparser.h b/src/dom/xpathparser.h index 041564e21..7e5f774f1 100644 --- a/src/dom/xpathparser.h +++ b/src/dom/xpathparser.h @@ -371,9 +371,16 @@ public: /** * */ - XPathParser() + XPathParser() : + debug(false), + parsebuf(0), + parselen(0), + position(0), + numberString(), + number(0), + lexicalTokens(), + tokens() { - debug = false; } /** @@ -781,17 +788,9 @@ private: * this is executable via execute() */ TokenList tokens; - - - - }; - - - - } // namespace xpath } // namespace dom } // namespace w3c diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 39eb2637a..7252845b1 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -82,6 +82,10 @@ public: instr(0), gzin(0) { + for (int k=0;k<4;k++) + { + firstFew[k]=0; + } } virtual ~XmlSource() { -- cgit v1.2.3 From 2608034f3607bfacf354151097c28be36b6c0a8c Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sun, 4 Dec 2011 22:03:12 +0100 Subject: cppcheck - dropped unused variable - changed use of obsolute function 'alloca' (see http://stackoverflow.com/questions/1018853/why-is-alloca-not-considered-good-practice and http://linux.die.net/man/3/alloca). (bzr r10760) --- src/color.cpp | 2 -- src/dialogs/object-attributes.cpp | 30 +++++++++---------- src/widgets/sp-attribute-widget.cpp | 57 +++++++++++++------------------------ 3 files changed, 32 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/color.cpp b/src/color.cpp index ab01ebc2a..ca5d50f14 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -183,8 +183,6 @@ guint32 SPColor::toRGBA32( gdouble alpha ) const std::string SPColor::toString() const { CSSOStringStream css; - - std::string result; char tmp[64] = {0}; sp_svg_write_color(tmp, sizeof(tmp), toRGBA32(0x0ff)); diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp index 043454dc8..f83d3ef1f 100644 --- a/src/dialogs/object-attributes.cpp +++ b/src/dialogs/object-attributes.cpp @@ -66,16 +66,14 @@ static const SPAttrDesc image_nohref_desc[] = { }; -static void -object_released( SPObject */*object*/, GtkWidget *widget ) +static void object_released( SPObject */*object*/, GtkWidget *widget ) { gtk_widget_destroy (widget); } -static void -window_destroyed( GtkObject *window, GtkObject */*object*/ ) +static void window_destroyed( GtkObject *window, GtkObject */*object*/ ) { sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(window), "release_connection"); release_connection->disconnect(); @@ -84,21 +82,20 @@ window_destroyed( GtkObject *window, GtkObject */*object*/ ) -static void -sp_object_attr_show_dialog ( SPObject *object, +static void sp_object_attr_show_dialog ( SPObject *object, const SPAttrDesc *desc, const gchar *tag ) { const gchar **labels, **attrs; gint len, i; - gchar *title; + Glib::ustring title; GtkWidget *w, *t; len = 0; while (desc[len].label) len += 1; - labels = (const gchar **)alloca (len * sizeof (char *)); - attrs = (const gchar **)alloca (len * sizeof (char *)); + labels = (const gchar **) new gchar* [len]; + attrs = (const gchar **) new gchar* [len]; for (i = 0; i < len; i++) { labels[i] = desc[i].label; @@ -106,19 +103,20 @@ sp_object_attr_show_dialog ( SPObject *object, } if (!strcmp (tag, "Link")) { - title = g_strdup_printf (_("Link Properties")); + title = _("Link Properties"); } else if (!strcmp (tag, "Image")) { - title = g_strdup_printf (_("Image Properties")); + title = _("Image Properties"); } else { - title = g_strdup_printf (_("%s Properties"), tag); + title = Glib::ustring::compose(_("%1 Properties"), tag); } - w = sp_window_new (title, TRUE); - g_free (title); + w = sp_window_new (title.c_str(), TRUE); t = sp_attribute_table_new (object, len, labels, attrs); gtk_widget_show (t); gtk_container_add (GTK_CONTAINER (w), t); + delete labels; + delete attrs; g_signal_connect ( G_OBJECT (w), "destroy", G_CALLBACK (window_destroyed), object ); @@ -128,13 +126,11 @@ sp_object_attr_show_dialog ( SPObject *object, g_object_set_data(G_OBJECT(w), "release_connection", release_connection); gtk_widget_show (w); - } // end of sp_object_attr_show_dialog() -void -sp_object_attributes_dialog (SPObject *object, const gchar *tag) +void sp_object_attributes_dialog (SPObject *object, const gchar *tag) { g_return_if_fail (object != NULL); g_return_if_fail (SP_IS_OBJECT (object)); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index b8ac50092..f3bdc062d 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -60,8 +60,7 @@ GType sp_attribute_widget_get_type(void) -static void -sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) +static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) { GtkObjectClass *object_class; GtkEditableClass *editable_class; @@ -79,8 +78,7 @@ sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) -static void -sp_attribute_widget_init (SPAttributeWidget *spaw) +static void sp_attribute_widget_init (SPAttributeWidget *spaw) { spaw->blocked = FALSE; spaw->hasobj = FALSE; @@ -95,8 +93,7 @@ sp_attribute_widget_init (SPAttributeWidget *spaw) -static void -sp_attribute_widget_destroy (GtkObject *object) +static void sp_attribute_widget_destroy (GtkObject *object) { SPAttributeWidget *spaw; @@ -132,8 +129,7 @@ sp_attribute_widget_destroy (GtkObject *object) -static void -sp_attribute_widget_changed (GtkEditable *editable) +static void sp_attribute_widget_changed (GtkEditable *editable) { SPAttributeWidget *spaw; @@ -164,8 +160,7 @@ sp_attribute_widget_changed (GtkEditable *editable) -GtkWidget * -sp_attribute_widget_new ( SPObject *object, const gchar *attribute ) +GtkWidget *sp_attribute_widget_new ( SPObject *object, const gchar *attribute ) { SPAttributeWidget *spaw; @@ -182,8 +177,7 @@ sp_attribute_widget_new ( SPObject *object, const gchar *attribute ) -GtkWidget * -sp_attribute_widget_new_repr ( Inkscape::XML::Node *repr, const gchar *attribute ) +GtkWidget *sp_attribute_widget_new_repr ( Inkscape::XML::Node *repr, const gchar *attribute ) { SPAttributeWidget *spaw; @@ -196,8 +190,7 @@ sp_attribute_widget_new_repr ( Inkscape::XML::Node *repr, const gchar *attribute -void -sp_attribute_widget_set_object ( SPAttributeWidget *spaw, +void sp_attribute_widget_set_object ( SPAttributeWidget *spaw, SPObject *object, const gchar *attribute ) { @@ -251,8 +244,7 @@ sp_attribute_widget_set_object ( SPAttributeWidget *spaw, -void -sp_attribute_widget_set_repr ( SPAttributeWidget *spaw, +void sp_attribute_widget_set_repr ( SPAttributeWidget *spaw, Inkscape::XML::Node *repr, const gchar *attribute ) { @@ -300,8 +292,7 @@ sp_attribute_widget_set_repr ( SPAttributeWidget *spaw, -static void -sp_attribute_widget_object_modified ( SPObject */*object*/, +static void sp_attribute_widget_object_modified ( SPObject */*object*/, guint flags, SPAttributeWidget *spaw ) { @@ -377,8 +368,7 @@ GType sp_attribute_table_get_type(void) -static void -sp_attribute_table_class_init (SPAttributeTableClass *klass) +static void sp_attribute_table_class_init (SPAttributeTableClass *klass) { GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); @@ -390,8 +380,7 @@ sp_attribute_table_class_init (SPAttributeTableClass *klass) -static void -sp_attribute_table_init ( SPAttributeTable *spat ) +static void sp_attribute_table_init ( SPAttributeTable *spat ) { spat->blocked = FALSE; spat->hasobj = FALSE; @@ -405,8 +394,7 @@ sp_attribute_table_init ( SPAttributeTable *spat ) new (&spat->release_connection) sigc::connection(); } -static void -sp_attribute_table_destroy ( GtkObject *object ) +static void sp_attribute_table_destroy ( GtkObject *object ) { SPAttributeTable *spat; @@ -451,8 +439,7 @@ sp_attribute_table_destroy ( GtkObject *object ) } // end of sp_attribute_table_destroy() -GtkWidget * -sp_attribute_table_new ( SPObject *object, +GtkWidget * sp_attribute_table_new ( SPObject *object, gint num_attr, const gchar **labels, const gchar **attributes ) @@ -473,8 +460,7 @@ sp_attribute_table_new ( SPObject *object, -GtkWidget * -sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, +GtkWidget *sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, gint num_attr, const gchar **labels, const gchar **attributes ) @@ -496,8 +482,7 @@ sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, #define XPAD 4 #define YPAD 0 -void -sp_attribute_table_set_object ( SPAttributeTable *spat, +void sp_attribute_table_set_object ( SPAttributeTable *spat, SPObject *object, gint num_attr, const gchar **labels, @@ -600,8 +585,7 @@ sp_attribute_table_set_object ( SPAttributeTable *spat, -void -sp_attribute_table_set_repr ( SPAttributeTable *spat, +void sp_attribute_table_set_repr ( SPAttributeTable *spat, Inkscape::XML::Node *repr, gint num_attr, const gchar **labels, @@ -697,8 +681,7 @@ sp_attribute_table_set_repr ( SPAttributeTable *spat, -static void -sp_attribute_table_object_modified ( SPObject */*object*/, +static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { @@ -725,16 +708,14 @@ sp_attribute_table_object_modified ( SPObject */*object*/, -static void -sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat) +static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat) { sp_attribute_table_set_object (spat, NULL, 0, NULL, NULL); } -static void -sp_attribute_table_entry_changed ( GtkEditable *editable, +static void sp_attribute_table_entry_changed ( GtkEditable *editable, SPAttributeTable *spat ) { if (!spat->blocked) -- cgit v1.2.3 From 466edb5fd657d34abcdf49a15bbbbd5051f6a872 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour <nicoduf@yahoo.fr> Date: Wed, 7 Dec 2011 15:38:09 +0100 Subject: Colors. Patch for Bug #677081 (Default paste color opacity) by Romain. (bzr r10761) --- src/widgets/sp-color-notebook.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 1324e0b16..c9a09349b 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -486,9 +486,14 @@ void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry) if (t) { Glib::ustring text = t; bool changed = false; - if (!text.empty() && text[0] == '#') { + + // Here we deal with pasted colors with theformat '#RRGGBB' or 'RRGGBB' + // In those cases we keep (and so add) the current alpha value. + if (!text.empty()) { changed = true; - text.erase(0,1); + if (text[0] == '#') { + text.erase(0,1); + } if (text.size() == 6) { // it was a standard RGB hex unsigned int alph = SP_COLOR_F_TO_U(_alpha); -- cgit v1.2.3 From 4e51446f417ad82d2cdac758d0c5ce908ff88038 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 8 Dec 2011 11:53:54 +0000 Subject: Switch to top-level glib headers. Thanks to DimStar for patch Fixed bugs: - https://launchpad.net/bugs/898538 (bzr r10762) --- src/attributes.cpp | 1 - src/attributes.h | 3 +-- src/bind/javabind.cpp | 2 +- src/cms-color-types.h | 2 +- src/cms-system.h | 2 +- src/color-profile.h | 2 +- src/color-rgba.h | 1 - src/conn-avoid-ref.h | 2 +- src/debug/logger.cpp | 2 +- src/debug/simple-event.h | 2 -- src/debug/timestamp.cpp | 3 +-- src/dialogs/clonetiler.cpp | 2 +- src/dir-util.cpp | 6 +----- src/dir-util.h | 2 +- src/display/canvas-bpath.h | 2 +- src/display/canvas-temporary-item.h | 2 +- src/display/curve.cpp | 2 +- src/display/curve.h | 3 +-- src/display/gnome-canvas-acetate.h | 2 +- src/display/nr-3dutils.cpp | 2 +- src/display/nr-filter-diffuselighting.cpp | 2 +- src/display/nr-filter-specularlighting.cpp | 2 +- src/display/sodipodi-ctrlrect.h | 2 +- src/display/sp-canvas.h | 2 +- src/document-subset.cpp | 2 +- src/draw-anchor.h | 2 +- src/dyna-draw-context.cpp | 2 +- src/eraser-context.cpp | 2 +- src/extension/internal/cairo-render-context.cpp | 2 +- src/extension/internal/cairo-renderer.cpp | 2 +- src/extension/internal/pdfinput/svg-builder.h | 2 +- src/extract-uri.h | 2 +- src/file.cpp | 2 +- src/file.h | 2 +- src/gc-anchored.h | 2 +- src/gc-core.h | 2 +- src/gc.cpp | 2 +- src/gradient-drag.h | 1 - src/help.h | 2 +- src/helper/gnome-utils.h | 3 +-- src/helper/pixbuf-ops.cpp | 1 - src/helper/pixbuf-ops.h | 2 +- src/helper/png-write.cpp | 2 +- src/helper/png-write.h | 2 +- src/helper/stlport.h | 3 +-- src/helper/stock-items.h | 2 +- src/helper/unit-menu.h | 2 +- src/helper/units.h | 4 +--- src/inkscape.h | 2 +- src/inkview.cpp | 2 +- src/io/inkjar.h | 3 +-- src/io/resource.cpp | 3 --- src/io/sys.cpp | 2 -- src/io/sys.h | 4 +--- src/knot-holder-entity.h | 2 +- src/knotholder.h | 2 +- src/libcroco/cr-libxml-node-iface.h | 2 +- src/libcroco/cr-node-iface.h | 3 +-- src/libnrtype/FontFactory.cpp | 2 +- src/libnrtype/Layout-TNG-Output.cpp | 2 +- src/libnrtype/nr-type-primitives.cpp | 2 +- src/libnrtype/nr-type-primitives.h | 2 +- src/livarot/AlphaLigne.cpp | 2 +- src/livarot/BitLigne.cpp | 2 +- src/livarot/PathSimplify.cpp | 2 +- src/livarot/Shape.cpp | 2 +- src/livarot/ShapeSweep.cpp | 1 - src/livarot/int-line.cpp | 2 +- src/livarot/sweep-event.cpp | 2 +- src/livarot/sweep-tree-list.cpp | 2 +- src/live_effects/parameter/array.h | 2 +- src/live_effects/parameter/bool.h | 2 +- src/live_effects/parameter/enum.h | 2 +- src/live_effects/parameter/path.h | 2 +- src/live_effects/parameter/point.h | 2 +- src/live_effects/parameter/powerstrokepointarray.h | 2 +- src/live_effects/parameter/text.h | 2 +- src/live_effects/parameter/vector.h | 2 +- src/main-cmdlineact.h | 2 +- src/message-context.cpp | 2 +- src/message-stack.cpp | 2 +- src/modifier-fns.h | 2 +- src/object-hierarchy.h | 2 +- src/path-chemistry.cpp | 2 +- src/removeoverlap.h | 2 +- src/sp-conn-end-pair.h | 2 +- src/sp-conn-end.h | 2 +- src/sp-gradient-fns.h | 2 +- src/sp-gradient-vector.h | 2 +- src/sp-linear-gradient-fns.h | 2 +- src/sp-metrics.h | 3 +-- src/sp-radial-gradient.h | 2 +- src/sp-stop.h | 2 +- src/sp-text.h | 2 +- src/sp-textpath.h | 2 +- src/sp-tspan.h | 2 +- src/splivarot.cpp | 2 +- src/spray-context.cpp | 2 +- src/svg/css-ostringstream.cpp | 3 +-- src/svg/css-ostringstream.h | 2 +- src/svg/stringstream.h | 2 +- src/svg/strip-trailing-zeros.cpp | 2 +- src/svg/svg-affine.cpp | 2 +- src/svg/svg-color.cpp | 5 ----- src/svg/svg-color.h | 2 +- src/svg/svg-length.cpp | 2 +- src/svg/svg-length.h | 2 +- src/svg/svg-path-geom-test.h | 2 +- src/svg/svg-path.cpp | 3 --- src/svg/svg.h | 2 +- src/svg/test-stubs.h | 2 +- src/text-editing.h | 2 +- src/text-tag-attributes.h | 2 +- src/trace/potrace/potracelib.cpp | 2 +- src/tweak-context.cpp | 2 +- src/ui/cache/svg_preview_cache.cpp | 2 +- src/ui/dialog/desktop-tracker.h | 2 +- src/ui/dialog/dialog-manager.h | 2 +- src/ui/dialog/icon-preview.cpp | 2 +- src/ui/widget/icon-widget.cpp | 2 +- src/unclump.h | 2 +- src/uri.h | 2 +- src/util/ege-appear-time-tracker.h | 2 +- src/util/share.cpp | 2 +- src/version.cpp | 2 +- src/version.h | 2 +- src/widgets/icon.cpp | 2 +- src/widgets/sp-color-icc-selector.h | 2 +- src/widgets/sp-color-scales.h | 2 +- src/widgets/sp-color-wheel-selector.h | 2 +- src/widgets/spinbutton-events.h | 2 +- src/widgets/spw-utilities.h | 2 +- src/widgets/stroke-style.cpp | 2 +- src/xml/attribute-record.h | 3 +-- src/xml/comment-node.h | 2 +- src/xml/croco-node-iface.cpp | 2 +- src/xml/event.h | 3 +-- src/xml/node-event-vector.h | 2 +- src/xml/node-observer.h | 2 +- src/xml/node.h | 2 +- src/xml/pi-node.h | 2 +- src/xml/quote.cpp | 2 +- src/xml/rebase-hrefs.cpp | 4 +--- src/xml/rebase-hrefs.h | 2 +- src/xml/repr.h | 2 +- src/xml/simple-node.cpp | 2 +- src/xml/text-node.h | 2 +- 147 files changed, 137 insertions(+), 178 deletions(-) (limited to 'src') diff --git a/src/attributes.cpp b/src/attributes.cpp index 34312ebe8..9203d916b 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -18,7 +18,6 @@ #endif #include <glib.h> // g_assert() -#include <glib/ghash.h> #include "attributes.h" typedef struct { diff --git a/src/attributes.h b/src/attributes.h index 7a1dc559f..1c1d092cf 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -13,8 +13,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> -#include <glib/gmessages.h> +#include <glib.h> unsigned int sp_attribute_lookup(gchar const *key); unsigned char const *sp_attribute_name(unsigned int id); diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index 41da00e81..d2091eb1b 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -62,7 +62,7 @@ #include "javabind-private.h" #include <path-prefix.h> #include <prefix.h> -#include <glib/gmessages.h> +#include <glib.h> //For repr and document #include <document.h> diff --git a/src/cms-color-types.h b/src/cms-color-types.h index 74fdac12c..ec285a8a2 100644 --- a/src/cms-color-types.h +++ b/src/cms-color-types.h @@ -5,7 +5,7 @@ * A simple abstraction to provide opaque compatibility with either lcms or lcms2. */ -#include <glib/gtypes.h> +#include <glib.h> typedef void * cmsHPROFILE; diff --git a/src/cms-system.h b/src/cms-system.h index 1f75f8619..c528deb94 100644 --- a/src/cms-system.h +++ b/src/cms-system.h @@ -6,7 +6,7 @@ */ #include <glib-object.h> -#include <glib/gtypes.h> +#include <glib.h> #include <vector> #include <glibmm/ustring.h> #include "cms-color-types.h" diff --git a/src/color-profile.h b/src/color-profile.h index ae63e4047..8b23c1b04 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -6,7 +6,7 @@ */ #include <vector> -#include <glib/gtypes.h> +#include <glib.h> #include <sp-object.h> #include <glibmm/ustring.h> #include "cms-color-types.h" diff --git a/src/color-rgba.h b/src/color-rgba.h index 0d7a0c00d..ef7d9aee1 100644 --- a/src/color-rgba.h +++ b/src/color-rgba.h @@ -10,7 +10,6 @@ #define SEEN_COLOR_RGBA_H #include <glib.h> // g_assert() -#include <glib/gmessages.h> #include "decimal-round.h" /** diff --git a/src/conn-avoid-ref.h b/src/conn-avoid-ref.h index 9a028371a..f99d1f0cb 100644 --- a/src/conn-avoid-ref.h +++ b/src/conn-avoid-ref.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gslist.h> +#include <glib.h> #include <stddef.h> #include <sigc++/connection.h> diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index bc761d67e..485dbc365 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -11,7 +11,7 @@ #include <fstream> #include <vector> -#include <glib/gmessages.h> +#include <glib.h> #include "inkscape-version.h" #include "debug/logger.h" #include "debug/simple-event.h" diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index d09358224..506ee1b03 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -15,8 +15,6 @@ #include <stdarg.h> #include <vector> #include <glib.h> // g_assert() -#include <glib/gstrfuncs.h> -#include <glib/gmessages.h> #include "gc-alloc.h" #include "debug/event.h" diff --git a/src/debug/timestamp.cpp b/src/debug/timestamp.cpp index 4c014e965..e100134c8 100644 --- a/src/debug/timestamp.cpp +++ b/src/debug/timestamp.cpp @@ -10,8 +10,7 @@ */ -#include <glib/gtypes.h> -#include <glib/gmain.h> +#include <glib.h> #include <glibmm/ustring.h> #include "debug/simple-event.h" diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 29098abf6..1bb6b75d0 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -16,7 +16,7 @@ #endif #include <climits> -#include <glib/gmem.h> +#include <glib.h> #include <gtk/gtk.h> #include <glibmm/i18n.h> #include <2geom/transforms.h> diff --git a/src/dir-util.cpp b/src/dir-util.cpp index acec39953..7d4054745 100644 --- a/src/dir-util.cpp +++ b/src/dir-util.cpp @@ -6,11 +6,7 @@ #include <errno.h> #include <string> #include <cstring> -#include <glib/gutils.h> -#include <glib/gmem.h> -#include <glib/gerror.h> -#include <glib/gconvert.h> -#include <glib/gstrfuncs.h> +#include <glib.h> std::string sp_relative_path_from_path( std::string const &path, std::string const &base) { diff --git a/src/dir-util.h b/src/dir-util.h index f7700cfa3..17261af41 100644 --- a/src/dir-util.h +++ b/src/dir-util.h @@ -10,7 +10,7 @@ */ #include <stdlib.h> -#include <glib/gtypes.h> +#include <glib.h> /** * Returns a form of \a path relative to \a base if that is easy to construct (eg if \a path diff --git a/src/display/canvas-bpath.h b/src/display/canvas-bpath.h index 752ed73ea..f0520f012 100644 --- a/src/display/canvas-bpath.h +++ b/src/display/canvas-bpath.h @@ -15,7 +15,7 @@ * */ -#include <glib/gtypes.h> +#include <glib.h> #include "sp-canvas-item.h" diff --git a/src/display/canvas-temporary-item.h b/src/display/canvas-temporary-item.h index c8917b530..09d243fa1 100644 --- a/src/display/canvas-temporary-item.h +++ b/src/display/canvas-temporary-item.h @@ -13,7 +13,7 @@ #include <stddef.h> #include <sigc++/sigc++.h> -#include <glib/gtypes.h> +#include <glib.h> struct SPCanvasItem; diff --git a/src/display/curve.cpp b/src/display/curve.cpp index d52ee1fba..1a788b59a 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -19,7 +19,7 @@ #include "display/curve.h" -#include <glib/gmessages.h> +#include <glib.h> #include <2geom/pathvector.h> #include <2geom/sbasis-geometric.h> #include <2geom/sbasis-to-bezier.h> diff --git a/src/display/curve.h b/src/display/curve.h index 4f129b542..4866655c4 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -13,8 +13,7 @@ * Released under GNU GPL */ -#include <glib/gtypes.h> -#include <glib/gslist.h> +#include <glib.h> #include <2geom/forward.h> diff --git a/src/display/gnome-canvas-acetate.h b/src/display/gnome-canvas-acetate.h index ed6c99811..447c3a9c4 100644 --- a/src/display/gnome-canvas-acetate.h +++ b/src/display/gnome-canvas-acetate.h @@ -15,7 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include "display/sp-canvas-item.h" diff --git a/src/display/nr-3dutils.cpp b/src/display/nr-3dutils.cpp index eb6858374..d2ac7d82b 100644 --- a/src/display/nr-3dutils.cpp +++ b/src/display/nr-3dutils.cpp @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gmessages.h> +#include <glib.h> #include "display/nr-3dutils.h" #include <cmath> diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 9df771879..fcc986189 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -11,7 +11,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gmessages.h> +#include <glib.h> #include "display/cairo-templates.h" #include "display/cairo-utils.h" diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 0530e38cb..0242754eb 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -10,7 +10,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gmessages.h> +#include <glib.h> #include <cmath> #include "display/cairo-templates.h" diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 05688e6b5..65a40a850 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -17,7 +17,7 @@ * */ -#include <glib/gtypes.h> +#include <glib.h> #include "sp-canvas-item.h" #include <2geom/rect.h> #include <2geom/int-rect.h> diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index f0deaa594..14cbab6c3 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -29,7 +29,7 @@ # endif #endif -#include <glib/gtypes.h> +#include <glib.h> #include <gdk/gdk.h> #include <gtk/gtk.h> #include <glibmm/ustring.h> diff --git a/src/document-subset.cpp b/src/document-subset.cpp index e71b9bad5..1cc337cb7 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -13,7 +13,7 @@ #include "document.h" #include "sp-object.h" -#include <glib/gmessages.h> +#include <glib.h> #include <sigc++/signal.h> #include <sigc++/functors/mem_fun.h> diff --git a/src/draw-anchor.h b/src/draw-anchor.h index 4aa713b52..fc3ebaffc 100644 --- a/src/draw-anchor.h +++ b/src/draw-anchor.h @@ -5,7 +5,7 @@ * Drawing anchors. */ -#include <glib/gtypes.h> +#include <glib.h> #include <2geom/point.h> struct SPDrawContext; diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 5bc258dbc..32da6de4e 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -38,7 +38,7 @@ #include <2geom/pathvector.h> #include <2geom/bezier-utils.h> #include "display/curve.h" -#include <glib/gmem.h> +#include <glib.h> #include "macros.h" #include "document.h" #include "selection.h" diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 11b150aa0..2352d909f 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -38,7 +38,7 @@ #include "display/canvas-bpath.h" #include <2geom/bezier-utils.h> -#include <glib/gmem.h> +#include <glib.h> #include "macros.h" #include "document.h" #include "selection.h" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index b8e924926..78f705298 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -29,7 +29,7 @@ #include <errno.h> #include <2geom/pathvector.h> -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> #include "display/drawing.h" diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 6c77005fe..42c60f52c 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -32,7 +32,7 @@ #include <2geom/transforms.h> #include <2geom/pathvector.h> -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> #include "display/curve.h" diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index c289d9b36..a550565d6 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -47,7 +47,7 @@ class XRef; class SPCSSAttr; #include <vector> -#include <glib/gtypes.h> +#include <glib.h> namespace Inkscape { namespace Extension { diff --git a/src/extract-uri.h b/src/extract-uri.h index b41a2b9d9..a6707f1a1 100644 --- a/src/extract-uri.h +++ b/src/extract-uri.h @@ -1,7 +1,7 @@ #ifndef SEEN_EXTRACT_URI_H #define SEEN_EXTRACT_URI_H -#include <glib/gtypes.h> +#include <glib.h> gchar *extract_uri(gchar const *s, gchar const** endptr = 0); diff --git a/src/file.cpp b/src/file.cpp index e8901d306..4feb36f9d 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -30,7 +30,7 @@ #endif #include <gtk/gtk.h> -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> #include "desktop.h" diff --git a/src/file.h b/src/file.h index 5a43ffa5e..7e44d7da1 100644 --- a/src/file.h +++ b/src/file.h @@ -16,7 +16,7 @@ */ #include <gtkmm.h> -#include <glib/gslist.h> +#include <glib.h> #include <gtk/gtk.h> #include "extension/system.h" diff --git a/src/gc-anchored.h b/src/gc-anchored.h index b7c0cd0e4..a20904dce 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -9,7 +9,7 @@ #ifndef SEEN_INKSCAPE_GC_ANCHORED_H #define SEEN_INKSCAPE_GC_ANCHORED_H -#include <glib/gmessages.h> +#include <glib.h> #include "gc-managed.h" namespace Inkscape { diff --git a/src/gc-core.h b/src/gc-core.h index 32779c83f..85fbada60 100644 --- a/src/gc-core.h +++ b/src/gc-core.h @@ -24,7 +24,7 @@ #else # include <gc.h> #endif -#include <glib/gmain.h> +#include <glib.h> namespace Inkscape { namespace GC { diff --git a/src/gc.cpp b/src/gc.cpp index 1ba0826ef..9c59691cb 100644 --- a/src/gc.cpp +++ b/src/gc.cpp @@ -13,7 +13,7 @@ #include <stdexcept> #include <cstring> #include <string> -#include <glib/gmessages.h> +#include <glib.h> #include <sigc++/functors/ptr_fun.h> #include <glibmm/main.h> #include <cstddef> diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 2fd0e46f0..cb3f13e71 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -14,7 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gslist.h> #include <stddef.h> #include <sigc++/sigc++.h> #include <vector> diff --git a/src/help.h b/src/help.h index 2ded43c39..3fce65fef 100644 --- a/src/help.h +++ b/src/help.h @@ -10,7 +10,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> /** diff --git a/src/helper/gnome-utils.h b/src/helper/gnome-utils.h index 1a087433e..3502b28df 100644 --- a/src/helper/gnome-utils.h +++ b/src/helper/gnome-utils.h @@ -15,8 +15,7 @@ #ifndef __GNOME_UTILS_H__ #define __GNOME_UTILS_H__ -#include <glib/gtypes.h> -#include <glib/glist.h> +#include <glib.h> GList *gnome_uri_list_extract_uris(gchar const *uri_list); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 9f80cc58b..f980953dc 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -16,7 +16,6 @@ #endif #include <glib.h> -#include <glib/gmessages.h> #include <png.h> #include <2geom/transforms.h> diff --git a/src/helper/pixbuf-ops.h b/src/helper/pixbuf-ops.h index a985be297..af573277c 100644 --- a/src/helper/pixbuf-ops.h +++ b/src/helper/pixbuf-ops.h @@ -12,7 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> struct SPDocument; diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 992c7b886..febdb645e 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -19,7 +19,7 @@ #include "interface.h" #include <2geom/rect.h> #include <2geom/transforms.h> -#include <glib/gmessages.h> +#include <glib.h> #include <png.h> #include "png-write.h" #include "io/sys.h" diff --git a/src/helper/png-write.h b/src/helper/png-write.h index 83321aa4e..f8ba4bbf6 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -12,7 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <2geom/forward.h> struct SPDocument; diff --git a/src/helper/stlport.h b/src/helper/stlport.h index c9389e814..c7b00eb28 100644 --- a/src/helper/stlport.h +++ b/src/helper/stlport.h @@ -3,8 +3,7 @@ #include <list> -#include <glib/glist.h> -#include <glib/gslist.h> +#include <glib.h> template <typename T> class StlConv { diff --git a/src/helper/stock-items.h b/src/helper/stock-items.h index 7299e070e..990f45254 100644 --- a/src/helper/stock-items.h +++ b/src/helper/stock-items.h @@ -13,7 +13,7 @@ * */ -#include <glib/gtypes.h> +#include <glib.h> class SPObject; diff --git a/src/helper/unit-menu.h b/src/helper/unit-menu.h index b495a3c15..b3ee6bcd1 100644 --- a/src/helper/unit-menu.h +++ b/src/helper/unit-menu.h @@ -10,7 +10,7 @@ * */ -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> struct SPUnit; diff --git a/src/helper/units.h b/src/helper/units.h index 8dc62fee6..93bd70615 100644 --- a/src/helper/units.h +++ b/src/helper/units.h @@ -15,9 +15,7 @@ * */ -#include <glib/gmessages.h> -#include <glib/gslist.h> -#include <glib/gtypes.h> +#include <glib.h> #include "sp-metric.h" diff --git a/src/inkscape.h b/src/inkscape.h index 64cee1560..6ab07be86 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -13,7 +13,7 @@ */ #include <list> -#include <glib/gtypes.h> +#include <glib.h> struct SPDesktop; struct SPDocument; diff --git a/src/inkview.cpp b/src/inkview.cpp index 0b1292e8e..1fd5c2d56 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -38,7 +38,7 @@ #include <sys/stat.h> #include <locale.h> -#include <glib/gmem.h> +#include <glib.h> // #include <stropts.h> diff --git a/src/io/inkjar.h b/src/io/inkjar.h index 0fe088b24..ea4b0ee32 100644 --- a/src/io/inkjar.h +++ b/src/io/inkjar.h @@ -26,8 +26,7 @@ # endif #endif -#include <glib/garray.h> -#include <glib/gtypes.h> +#include <glib.h> namespace Inkjar { diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 4eeaf3b8c..ac1c5f06b 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -17,9 +17,6 @@ #endif #include <glib.h> // g_assert() -#include <glib/gmessages.h> -#include <glib/gstrfuncs.h> -#include <glib/gfileutils.h> #include "path-prefix.h" #include "inkscape.h" #include "io/resource.h" diff --git a/src/io/sys.cpp b/src/io/sys.cpp index 437a9d18c..e83861237 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -17,9 +17,7 @@ #include <glib.h> #include <glib/gstdio.h> -#include <glib/gutils.h> #include <glibmm/fileutils.h> -#include <glib/gstdio.h> #include <glibmm/ustring.h> #include <gtk/gtk.h> diff --git a/src/io/sys.h b/src/io/sys.h index 8623f6be9..83ffdb41c 100644 --- a/src/io/sys.h +++ b/src/io/sys.h @@ -15,9 +15,7 @@ #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> -#include <glib/gtypes.h> -#include <glib/gdir.h> -#include <glib/gfileutils.h> +#include <glib.h> #include <glibmm/spawn.h> #include <string> diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index 726d969c2..e708486ca 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -14,7 +14,7 @@ * Released under GNU GPL */ -#include <glib/gtypes.h> +#include <glib.h> #include "knot.h" #include <2geom/forward.h> #include "snapper.h" diff --git a/src/knotholder.h b/src/knotholder.h index 2e2844801..9a4dda1da 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -17,7 +17,7 @@ * */ -#include <glib/gtypes.h> +#include <glib.h> #include "knot-enums.h" #include <2geom/forward.h> #include "knot-holder-entity.h" diff --git a/src/libcroco/cr-libxml-node-iface.h b/src/libcroco/cr-libxml-node-iface.h index 5da0d9ae3..b4a621293 100644 --- a/src/libcroco/cr-libxml-node-iface.h +++ b/src/libcroco/cr-libxml-node-iface.h @@ -1,7 +1,7 @@ #ifndef __CR_LIBXML_NODE_IFACE_H__ #define __CR_LIBXML_NODE_IFACE_H__ -#include <glib/gmacros.h> +#include <glib.h> #include "cr-node-iface.h" G_BEGIN_DECLS diff --git a/src/libcroco/cr-node-iface.h b/src/libcroco/cr-node-iface.h index 9c2d30efe..01898d641 100644 --- a/src/libcroco/cr-node-iface.h +++ b/src/libcroco/cr-node-iface.h @@ -1,8 +1,7 @@ #ifndef __CR_NODE_IFACE_H__ #define __CR_NODE_IFACE_H__ -#include <glib/gmacros.h> -#include <glib/gtypes.h> +#include <glib.h> G_BEGIN_DECLS diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index e6d22e070..63f9bd6b0 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -15,7 +15,7 @@ #endif #include <glibmm.h> -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> // _() #include <pango/pangoft2.h> #include "libnrtype/FontFactory.h" diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index ebb71d388..8546e706f 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -8,7 +8,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gmem.h> +#include <glib.h> #include "Layout-TNG.h" #include "display/drawing-text.h" #include "style.h" diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp index 2fbc18ffd..63a3abcc5 100644 --- a/src/libnrtype/nr-type-primitives.cpp +++ b/src/libnrtype/nr-type-primitives.cpp @@ -14,7 +14,7 @@ #include <stdlib.h> #include <string.h> -#include <glib/gmem.h> +#include <glib.h> #include "nr-type-primitives.h" /** diff --git a/src/libnrtype/nr-type-primitives.h b/src/libnrtype/nr-type-primitives.h index 92b94e9a8..9bb181c4b 100644 --- a/src/libnrtype/nr-type-primitives.h +++ b/src/libnrtype/nr-type-primitives.h @@ -11,7 +11,7 @@ * This code is in public domain */ -#include <glib/gtypes.h> +#include <glib.h> struct NRNameList; struct NRStyleList; diff --git a/src/livarot/AlphaLigne.cpp b/src/livarot/AlphaLigne.cpp index f878c1bb3..5b8321b72 100644 --- a/src/livarot/AlphaLigne.cpp +++ b/src/livarot/AlphaLigne.cpp @@ -12,7 +12,7 @@ #include <math.h> #include <stdio.h> #include <stdlib.h> -#include <glib/gmem.h> +#include <glib.h> AlphaLigne::AlphaLigne(int iMin,int iMax) { diff --git a/src/livarot/BitLigne.cpp b/src/livarot/BitLigne.cpp index c4c134615..d7cce26eb 100644 --- a/src/livarot/BitLigne.cpp +++ b/src/livarot/BitLigne.cpp @@ -15,7 +15,7 @@ #include <string> #include <cmath> #include <cstdio> -#include <glib/gmem.h> +#include <glib.h> BitLigne::BitLigne(int ist,int ien,float iScale) { diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index fe1981e4d..d6e916197 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -6,7 +6,7 @@ * */ -#include <glib/gmem.h> +#include <glib.h> #include <2geom/affine.h> #include "livarot/Path.h" #include "livarot/path-description.h" diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index 805741d3f..c29444a33 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -8,7 +8,7 @@ #include <cstdio> #include <cstdlib> -#include <glib/gmem.h> +#include <glib.h> #include "Shape.h" #include "livarot/sweep-event-queue.h" #include "livarot/sweep-tree-list.h" diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index e3fb0296d..2073d1cd2 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -10,7 +10,6 @@ #include <cstdlib> #include <cstring> #include <glib.h> -#include <glib/gmem.h> #include <2geom/affine.h> #include "Shape.h" #include "livarot/sweep-event-queue.h" diff --git a/src/livarot/int-line.cpp b/src/livarot/int-line.cpp index c1e388fe2..d03d62cd7 100644 --- a/src/livarot/int-line.cpp +++ b/src/livarot/int-line.cpp @@ -9,7 +9,7 @@ * */ -#include <glib/gmem.h> +#include <glib.h> #include <cmath> #include <cstring> #include <string> diff --git a/src/livarot/sweep-event.cpp b/src/livarot/sweep-event.cpp index 268d0e363..6f3a4d246 100644 --- a/src/livarot/sweep-event.cpp +++ b/src/livarot/sweep-event.cpp @@ -1,4 +1,4 @@ -#include <glib/gmem.h> +#include <glib.h> #include "livarot/sweep-event-queue.h" #include "livarot/sweep-tree.h" #include "livarot/sweep-event.h" diff --git a/src/livarot/sweep-tree-list.cpp b/src/livarot/sweep-tree-list.cpp index bef6a1797..ea9e9a5d2 100644 --- a/src/livarot/sweep-tree-list.cpp +++ b/src/livarot/sweep-tree-list.cpp @@ -1,4 +1,4 @@ -#include <glib/gmem.h> +#include <glib.h> #include "livarot/sweep-tree.h" #include "livarot/sweep-tree-list.h" diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index 89c344594..45db19e7f 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -11,7 +11,7 @@ #include <vector> -#include <glib/gtypes.h> +#include <glib.h> #include <gtkmm/tooltips.h> diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 8f5196dad..851476f13 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include "live_effects/parameter/parameter.h" diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index 05f3bdd57..2d2268ea9 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include "ui/widget/registered-enums.h" #include <gtkmm/tooltips.h> diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 8c4de7cff..0a35014ab 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <2geom/path.h> #include <gtkmm/tooltips.h> diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 2d4e942c0..9ea06bce8 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <2geom/point.h> #include <gtkmm/tooltips.h> diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index 550866384..b00e69e76 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <2geom/point.h> #include <gtkmm/tooltips.h> diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 8539a8046..82654303b 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include "display/canvas-bpath.h" #include "live_effects/parameter/parameter.h" diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index cb7094b7f..8afc05699 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <2geom/point.h> #include <gtkmm/tooltips.h> diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h index aca039f98..03f0eb0fc 100644 --- a/src/main-cmdlineact.h +++ b/src/main-cmdlineact.h @@ -15,7 +15,7 @@ * Released under GNU GPL v2.x, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> namespace Inkscape { diff --git a/src/message-context.cpp b/src/message-context.cpp index 6b8944185..2c07f4a43 100644 --- a/src/message-context.cpp +++ b/src/message-context.cpp @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gstrfuncs.h> +#include <glib.h> #include "message-context.h" #include "message-stack.h" diff --git a/src/message-stack.cpp b/src/message-stack.cpp index c1669e3db..bc89520b7 100644 --- a/src/message-stack.cpp +++ b/src/message-stack.cpp @@ -10,7 +10,7 @@ */ #include <string.h> -#include <glib/gstrfuncs.h> +#include <glib.h> #include <cstring> #include <string> #include "message-stack.h" diff --git a/src/modifier-fns.h b/src/modifier-fns.h index c1b35e948..cab110467 100644 --- a/src/modifier-fns.h +++ b/src/modifier-fns.h @@ -12,7 +12,7 @@ */ #include <gdk/gdk.h> -#include <glib/gtypes.h> +#include <glib.h> inline bool mod_shift(guint const state) diff --git a/src/object-hierarchy.h b/src/object-hierarchy.h index 34a81cf9f..0343d850e 100644 --- a/src/object-hierarchy.h +++ b/src/object-hierarchy.h @@ -15,7 +15,7 @@ #include <stddef.h> #include <sigc++/connection.h> #include <sigc++/signal.h> -#include <glib/gmessages.h> +#include <glib.h> class SPObject; diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index bd72632b2..f1ad17857 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -22,7 +22,7 @@ #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> #include "sp-path.h" #include "sp-text.h" diff --git a/src/removeoverlap.h b/src/removeoverlap.h index 5b16e706b..1ba41572a 100644 --- a/src/removeoverlap.h +++ b/src/removeoverlap.h @@ -13,7 +13,7 @@ #ifndef SEEN_REMOVEOVERLAP_H #define SEEN_REMOVEOVERLAP_H -#include <glib/gslist.h> +#include <glib.h> void removeoverlap(GSList const *items, double xGap, double yGap); diff --git a/src/sp-conn-end-pair.h b/src/sp-conn-end-pair.h index 7648e253a..53dd61ccf 100644 --- a/src/sp-conn-end-pair.h +++ b/src/sp-conn-end-pair.h @@ -11,7 +11,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <stddef.h> #include <sigc++/connection.h> diff --git a/src/sp-conn-end.h b/src/sp-conn-end.h index d2785b0e2..de0d2c0b7 100644 --- a/src/sp-conn-end.h +++ b/src/sp-conn-end.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_CONN_END #define SEEN_SP_CONN_END -#include <glib/gtypes.h> +#include <glib.h> #include <stddef.h> #include <sigc++/connection.h> diff --git a/src/sp-gradient-fns.h b/src/sp-gradient-fns.h index 5fb939905..f408affd1 100644 --- a/src/sp-gradient-fns.h +++ b/src/sp-gradient-fns.h @@ -5,7 +5,7 @@ * Macros and fn declarations related to gradients. */ -#include <glib/gtypes.h> +#include <glib.h> #include <glib-object.h> #include <2geom/forward.h> #include "sp-gradient-spread.h" diff --git a/src/sp-gradient-vector.h b/src/sp-gradient-vector.h index 5bb2a848a..8e860c169 100644 --- a/src/sp-gradient-vector.h +++ b/src/sp-gradient-vector.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_GRADIENT_VECTOR_H #define SEEN_SP_GRADIENT_VECTOR_H -#include <glib/gtypes.h> +#include <glib.h> #include <vector> #include "color.h" diff --git a/src/sp-linear-gradient-fns.h b/src/sp-linear-gradient-fns.h index 9f2f541dd..1bdf0b89e 100644 --- a/src/sp-linear-gradient-fns.h +++ b/src/sp-linear-gradient-fns.h @@ -6,7 +6,7 @@ */ #include <glib-object.h> -#include <glib/gtypes.h> +#include <glib.h> namespace Inkscape { namespace XML { diff --git a/src/sp-metrics.h b/src/sp-metrics.h index 23c1b6c13..c2f968797 100644 --- a/src/sp-metrics.h +++ b/src/sp-metrics.h @@ -1,8 +1,7 @@ #ifndef SP_METRICS_H #define SP_METRICS_H -#include <glib/gstring.h> -#include <glib/gtypes.h> +#include <glib.h> #include "sp-metric.h" gdouble sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, const SPMetric metric_dst); diff --git a/src/sp-radial-gradient.h b/src/sp-radial-gradient.h index 143afd79c..b46b9fff3 100644 --- a/src/sp-radial-gradient.h +++ b/src/sp-radial-gradient.h @@ -5,7 +5,7 @@ * SPRadialGradient: SVG <radialgradient> implementtion. */ -#include <glib/gtypes.h> +#include <glib.h> #include "sp-gradient.h" #include "svg/svg-length.h" #include "sp-radial-gradient-fns.h" diff --git a/src/sp-stop.h b/src/sp-stop.h index 692e67c5b..ec6c4525f 100644 --- a/src/sp-stop.h +++ b/src/sp-stop.h @@ -8,7 +8,7 @@ * Authors? */ -#include <glib/gtypes.h> +#include <glib.h> #include <glibmm/ustring.h> #include "sp-object.h" #include "color.h" diff --git a/src/sp-text.h b/src/sp-text.h index e426c425b..457f11f06 100644 --- a/src/sp-text.h +++ b/src/sp-text.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <stddef.h> #include <sigc++/sigc++.h> #include "sp-item.h" diff --git a/src/sp-textpath.h b/src/sp-textpath.h index 2f30f6023..d79f4d346 100644 --- a/src/sp-textpath.h +++ b/src/sp-textpath.h @@ -1,7 +1,7 @@ #ifndef INKSCAPE_SP_TEXTPATH_H #define INKSCAPE_SP_TEXTPATH_H -#include <glib/gtypes.h> +#include <glib.h> #include "svg/svg-length.h" #include "sp-item.h" #include "sp-text.h" diff --git a/src/sp-tspan.h b/src/sp-tspan.h index a0e641b8e..3672fd3b5 100644 --- a/src/sp-tspan.h +++ b/src/sp-tspan.h @@ -5,7 +5,7 @@ * tspan and textpath, based on the flowtext routines */ -#include <glib/gtypes.h> +#include <glib.h> #include "sp-item.h" #include "text-tag-attributes.h" diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 28d6f90be..ea035f0ab 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -19,7 +19,7 @@ #include <cstring> #include <string> #include <vector> -#include <glib/gmem.h> +#include <glib.h> #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 68b71b21f..ab5423f27 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -28,7 +28,7 @@ #include "svg/svg.h" -#include <glib/gmem.h> +#include <glib.h> #include "macros.h" #include "document.h" #include "selection.h" diff --git a/src/svg/css-ostringstream.cpp b/src/svg/css-ostringstream.cpp index f6e6a7293..33985443e 100644 --- a/src/svg/css-ostringstream.cpp +++ b/src/svg/css-ostringstream.cpp @@ -1,8 +1,7 @@ #include "svg/css-ostringstream.h" #include "svg/strip-trailing-zeros.h" #include "preferences.h" -#include <glib/gmessages.h> -#include <glib/gstrfuncs.h> +#include <glib.h> Inkscape::CSSOStringStream::CSSOStringStream() { diff --git a/src/svg/css-ostringstream.h b/src/svg/css-ostringstream.h index 52019f0d5..8cedb0979 100644 --- a/src/svg/css-ostringstream.h +++ b/src/svg/css-ostringstream.h @@ -1,7 +1,7 @@ #ifndef SVG_CSS_OSTRINGSTREAM_H_INKSCAPE #define SVG_CSS_OSTRINGSTREAM_H_INKSCAPE -#include <glib/gtypes.h> +#include <glib.h> #include <sstream> namespace Inkscape { diff --git a/src/svg/stringstream.h b/src/svg/stringstream.h index 5c819fcc6..d143abee8 100644 --- a/src/svg/stringstream.h +++ b/src/svg/stringstream.h @@ -1,7 +1,7 @@ #ifndef INKSCAPE_STRINGSTREAM_H #define INKSCAPE_STRINGSTREAM_H -#include <glib/gtypes.h> +#include <glib.h> #include <sstream> #include <string> diff --git a/src/svg/strip-trailing-zeros.cpp b/src/svg/strip-trailing-zeros.cpp index b0a14a74d..47da93249 100644 --- a/src/svg/strip-trailing-zeros.cpp +++ b/src/svg/strip-trailing-zeros.cpp @@ -1,7 +1,7 @@ #include <cstring> #include <string> -#include <glib/gmessages.h> +#include <glib.h> #include "svg/strip-trailing-zeros.h" diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index a986e5986..44567a2bd 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -19,7 +19,7 @@ #include <string> #include <cstdlib> #include <cstdio> -#include <glib/gstrfuncs.h> +#include <glib.h> #include <2geom/transforms.h> #include <2geom/angle.h> #include "svg.h" diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 9293564d5..a8dff0bf0 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -21,12 +21,7 @@ #include <string> #include <cassert> #include <math.h> -#include <glib/gmem.h> #include <glib.h> // g_assert -#include <glib/gmessages.h> -#include <glib/gstrfuncs.h> -#include <glib/ghash.h> -#include <glib/gutils.h> #include <errno.h> #include "strneq.h" diff --git a/src/svg/svg-color.h b/src/svg/svg-color.h index a3868c149..d1c7bee03 100644 --- a/src/svg/svg-color.h +++ b/src/svg/svg-color.h @@ -1,7 +1,7 @@ #ifndef SVG_SVG_COLOR_H_SEEN #define SVG_SVG_COLOR_H_SEEN -#include <glib/gtypes.h> +#include <glib.h> class SVGICCColor; diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp index 6b00cc807..d2f4332d8 100644 --- a/src/svg/svg-length.cpp +++ b/src/svg/svg-length.cpp @@ -19,7 +19,7 @@ #include <cstring> #include <string> #include <math.h> -#include <glib/gstrfuncs.h> +#include <glib.h> #include "svg.h" #include "stringstream.h" diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h index 66f473cfd..6c8f1e1dd 100644 --- a/src/svg/svg-length.h +++ b/src/svg/svg-length.h @@ -16,7 +16,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> class SVGLength { diff --git a/src/svg/svg-path-geom-test.h b/src/svg/svg-path-geom-test.h index 5735b6017..3558b4e55 100644 --- a/src/svg/svg-path-geom-test.h +++ b/src/svg/svg-path-geom-test.h @@ -8,7 +8,7 @@ #include <stdio.h> #include <string> #include <vector> -#include <glib/gmem.h> +#include <glib.h> class SvgPathGeomTest : public CxxTest::TestSuite { diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index f4278a5ac..3f3b944ff 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -31,9 +31,6 @@ #include <cstring> #include <string> #include <cassert> -#include <glib/gmem.h> -#include <glib/gmessages.h> -#include <glib/gstrfuncs.h> #include <glib.h> // g_assert() #include "svg/svg.h" diff --git a/src/svg/svg.h b/src/svg/svg.h index de1d7d872..a7795b82e 100644 --- a/src/svg/svg.h +++ b/src/svg/svg.h @@ -11,7 +11,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <vector> #include <cstring> #include <string> diff --git a/src/svg/test-stubs.h b/src/svg/test-stubs.h index 4e0731520..32acc0ef5 100644 --- a/src/svg/test-stubs.h +++ b/src/svg/test-stubs.h @@ -12,7 +12,7 @@ #ifndef SEEN_TEST_STUBS_H #define SEEN_TEST_STUBS_H -#include <glib/gtypes.h> +#include <glib.h> long long int prefs_get_int_attribute(gchar const *path, gchar const *attr, long long int def); diff --git a/src/text-editing.h b/src/text-editing.h index 300d0b76f..c0f104dec 100644 --- a/src/text-editing.h +++ b/src/text-editing.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <utility> // std::pair #include "libnrtype/Layout-TNG.h" #include "text-tag-attributes.h" diff --git a/src/text-tag-attributes.h b/src/text-tag-attributes.h index fdcfa8ce0..d2bfd854e 100644 --- a/src/text-tag-attributes.h +++ b/src/text-tag-attributes.h @@ -2,7 +2,7 @@ #define INKSCAPE_TEXT_TAG_ATTRIBUTES_H #include <vector> -#include <glib/gtypes.h> +#include <glib.h> #include "libnrtype/Layout-TNG.h" #include "svg/svg-length.h" diff --git a/src/trace/potrace/potracelib.cpp b/src/trace/potrace/potracelib.cpp index be92fb24e..0fb835593 100644 --- a/src/trace/potrace/potracelib.cpp +++ b/src/trace/potrace/potracelib.cpp @@ -4,7 +4,7 @@ #include <stdlib.h> #include <string.h> -#include <glib/gstrfuncs.h> +#include <glib.h> #include "potracelib.h" #include "inkscape-version.h" diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 5d592b83d..bd106a1bf 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -21,7 +21,7 @@ #include "svg/svg.h" -#include <glib/gmem.h> +#include <glib.h> #include "macros.h" #include "document.h" #include "selection.h" diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 912bc1a40..f8a806a13 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -19,7 +19,7 @@ # include "config.h" #endif -#include <glib/gmem.h> +#include <glib.h> #include <gtk/gtk.h> #include <2geom/transforms.h> #include "sp-namedview.h" diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index da276fae4..0c8af66bf 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -9,7 +9,7 @@ #include <stddef.h> #include <sigc++/connection.h> -#include <glib/gtypes.h> +#include <glib.h> typedef struct _GtkWidget GtkWidget; class SPDesktop; diff --git a/src/ui/dialog/dialog-manager.h b/src/ui/dialog/dialog-manager.h index 90e1862f1..45d8d8f66 100644 --- a/src/ui/dialog/dialog-manager.h +++ b/src/ui/dialog/dialog-manager.h @@ -14,7 +14,7 @@ #ifndef INKSCAPE_UI_DIALOG_MANAGER_H #define INKSCAPE_UI_DIALOG_MANAGER_H -#include <glib/gquark.h> +#include <glib.h> #include "dialog.h" #include <map> diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 0157cd267..a2b952677 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -19,7 +19,7 @@ #include <boost/scoped_ptr.hpp> #include <gtk/gtk.h> -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> #include <gtkmm/alignment.h> #include <gtkmm/buttonbox.h> diff --git a/src/ui/widget/icon-widget.cpp b/src/ui/widget/icon-widget.cpp index b671e8812..d04f89b15 100644 --- a/src/ui/widget/icon-widget.cpp +++ b/src/ui/widget/icon-widget.cpp @@ -12,7 +12,7 @@ # include <config.h> #endif -#include <glib/gmem.h> +#include <glib.h> #include "icon-widget.h" namespace Inkscape { diff --git a/src/unclump.h b/src/unclump.h index f7fcea087..18148b215 100644 --- a/src/unclump.h +++ b/src/unclump.h @@ -11,7 +11,7 @@ #ifndef SEEN_DIALOGS_UNCLUMP_H #define SEEN_DIALOGS_UNCLUMP_H -#include <glib/gslist.h> +#include <glib.h> void unclump(GSList *items); diff --git a/src/uri.h b/src/uri.h index 6866f58a1..adcc76d6b 100644 --- a/src/uri.h +++ b/src/uri.h @@ -11,7 +11,7 @@ #ifndef INKSCAPE_URI_H #define INKSCAPE_URI_H -#include <glib/gtypes.h> +#include <glib.h> #include <exception> #include <libxml/uri.h> #include "bad-uri-exception.h" diff --git a/src/util/ege-appear-time-tracker.h b/src/util/ege-appear-time-tracker.h index b5ea8b5d2..1d0c90991 100644 --- a/src/util/ege-appear-time-tracker.h +++ b/src/util/ege-appear-time-tracker.h @@ -37,7 +37,7 @@ * * ***** END LICENSE BLOCK ***** */ -#include <glib/gtimer.h> +#include <glib.h> #include <glibmm/ustring.h> typedef union _GdkEvent GdkEvent; diff --git a/src/util/share.cpp b/src/util/share.cpp index 606ed9d47..3cb289b10 100644 --- a/src/util/share.cpp +++ b/src/util/share.cpp @@ -10,7 +10,7 @@ */ #include "util/share.h" -#include <glib/gmessages.h> +#include <glib.h> namespace Inkscape { namespace Util { diff --git a/src/version.cpp b/src/version.cpp index 1baf9d8d9..438e47da9 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -11,7 +11,7 @@ */ #include <stdio.h> -#include <glib/gstrfuncs.h> +#include <glib.h> #include "version.h" gboolean sp_version_from_string(const gchar *string, Inkscape::Version *version) diff --git a/src/version.h b/src/version.h index d90d27772..26fbc11a3 100644 --- a/src/version.h +++ b/src/version.h @@ -11,7 +11,7 @@ #ifndef SEEN_INKSCAPE_VERSION_H #define SEEN_INKSCAPE_VERSION_H -#include <glib/gtypes.h> +#include <glib.h> #define SVG_VERSION "1.1" diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 9540b59d6..09caaa7f1 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -17,7 +17,7 @@ #endif #include <cstring> -#include <glib/gmem.h> +#include <glib.h> #include <glib/gstdio.h> #include <gtk/gtk.h> #include <gtkmm.h> diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index a3915cd48..166348830 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_COLOR_ICC_SELECTOR_H #define SEEN_SP_COLOR_ICC_SELECTOR_H -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> #include "../color.h" diff --git a/src/widgets/sp-color-scales.h b/src/widgets/sp-color-scales.h index 8ffe5e7a8..3b11bc05e 100644 --- a/src/widgets/sp-color-scales.h +++ b/src/widgets/sp-color-scales.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_COLOR_SCALES_H #define SEEN_SP_COLOR_SCALES_H -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> #include <color.h> diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index 5674850cb..4d8f79976 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -1,7 +1,7 @@ #ifndef SEEN_SP_COLOR_WHEEL_SELECTOR_H #define SEEN_SP_COLOR_WHEEL_SELECTOR_H -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> #include "../color.h" diff --git a/src/widgets/spinbutton-events.h b/src/widgets/spinbutton-events.h index 46652a346..cf8c7b44b 100644 --- a/src/widgets/spinbutton-events.h +++ b/src/widgets/spinbutton-events.h @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> /* GtkWidget */ gboolean spinbutton_focus_in (GtkWidget *w, GdkEventKey *event, gpointer data); diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h index 443831353..7ae36aa29 100644 --- a/src/widgets/spw-utilities.h +++ b/src/widgets/spw-utilities.h @@ -18,7 +18,7 @@ SPObject, that reacts to modification. */ -#include <glib/gtypes.h> +#include <glib.h> #include <gtk/gtk.h> /* GtkWidget */ #include <gtkmm/widget.h> diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 488b10666..23c02ea35 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -17,7 +17,7 @@ #define noSP_SS_VERBOSE -#include <glib/gmem.h> +#include <glib.h> #include <gtk/gtk.h> #include <glibmm/i18n.h> diff --git a/src/xml/attribute-record.h b/src/xml/attribute-record.h index bab0b5aa4..a61329b83 100644 --- a/src/xml/attribute-record.h +++ b/src/xml/attribute-record.h @@ -5,8 +5,7 @@ #ifndef SEEN_XML_SP_REPR_ATTR_H #define SEEN_XML_SP_REPR_ATTR_H -#include <glib/gquark.h> -#include <glib/gtypes.h> +#include <glib.h> #include "gc-managed.h" #include "util/share.h" diff --git a/src/xml/comment-node.h b/src/xml/comment-node.h index 2232fb61e..56b8ad476 100644 --- a/src/xml/comment-node.h +++ b/src/xml/comment-node.h @@ -15,7 +15,7 @@ #ifndef SEEN_INKSCAPE_XML_COMMENT_NODE_H #define SEEN_INKSCAPE_XML_COMMENT_NODE_H -#include <glib/gquark.h> +#include <glib.h> #include "xml/simple-node.h" namespace Inkscape { diff --git a/src/xml/croco-node-iface.cpp b/src/xml/croco-node-iface.cpp index 72bcba7f3..6bd5a6920 100644 --- a/src/xml/croco-node-iface.cpp +++ b/src/xml/croco-node-iface.cpp @@ -1,6 +1,6 @@ #include <cstring> #include <string> -#include <glib/gstrfuncs.h> +#include <glib.h> #include "xml/croco-node-iface.h" #include "xml/node.h" diff --git a/src/xml/event.h b/src/xml/event.h index c2865b8c4..55e2add88 100644 --- a/src/xml/event.h +++ b/src/xml/event.h @@ -18,8 +18,7 @@ #ifndef SEEN_INKSCAPE_XML_SP_REPR_ACTION_H #define SEEN_INKSCAPE_XML_SP_REPR_ACTION_H -#include <glib/gtypes.h> -#include <glib/gquark.h> +#include <glib.h> #include <glibmm/ustring.h> #include <iterator> diff --git a/src/xml/node-event-vector.h b/src/xml/node-event-vector.h index 0c291c230..e6396877d 100644 --- a/src/xml/node-event-vector.h +++ b/src/xml/node-event-vector.h @@ -14,7 +14,7 @@ #ifndef SEEN_INKSCAPE_XML_SP_REPR_EVENT_VECTOR #define SEEN_INKSCAPE_XML_SP_REPR_EVENT_VECTOR -#include <glib/gtypes.h> +#include <glib.h> #include "xml/node.h" diff --git a/src/xml/node-observer.h b/src/xml/node-observer.h index 59142be8c..d0c85d1dd 100644 --- a/src/xml/node-observer.h +++ b/src/xml/node-observer.h @@ -18,7 +18,7 @@ #ifndef SEEN_INKSCAPE_XML_NODE_OBSERVER_H #define SEEN_INKSCAPE_XML_NODE_OBSERVER_H -#include <glib/gquark.h> +#include <glib.h> #include "util/share.h" #ifndef INK_UNUSED diff --git a/src/xml/node.h b/src/xml/node.h index 8b7dea203..c11f2fbdf 100644 --- a/src/xml/node.h +++ b/src/xml/node.h @@ -18,7 +18,7 @@ #ifndef SEEN_INKSCAPE_XML_NODE_H #define SEEN_INKSCAPE_XML_NODE_H -#include <glib/gtypes.h> +#include <glib.h> #include "gc-anchored.h" #include "util/list.h" diff --git a/src/xml/pi-node.h b/src/xml/pi-node.h index e1f59ab27..1f892f97a 100644 --- a/src/xml/pi-node.h +++ b/src/xml/pi-node.h @@ -14,7 +14,7 @@ #ifndef SEEN_INKSCAPE_XML_PI_NODE_H #define SEEN_INKSCAPE_XML_PI_NODE_H -#include <glib/gquark.h> +#include <glib.h> #include "xml/simple-node.h" namespace Inkscape { diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp index e569ed818..51f9ffb97 100644 --- a/src/xml/quote.cpp +++ b/src/xml/quote.cpp @@ -12,7 +12,7 @@ */ #include <cstring> -#include <glib/gmem.h> +#include <glib.h> /** \return strlen(xml_quote_strdup(\a val)) (without doing the malloc). diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index 4a7e050fa..9d4f4f9fc 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -7,9 +7,7 @@ #include "util/share.h" #include "xml/attribute-record.h" #include "xml/node.h" -#include <glib/gmem.h> -#include <glib/gurifuncs.h> -#include <glib/gutils.h> +#include <glib.h> #include <glibmm/miscutils.h> #include <glibmm/convert.h> #include <glibmm/uriutils.h> diff --git a/src/xml/rebase-hrefs.h b/src/xml/rebase-hrefs.h index 4cbdec9a5..adb09e52a 100644 --- a/src/xml/rebase-hrefs.h +++ b/src/xml/rebase-hrefs.h @@ -1,7 +1,7 @@ #ifndef REBASE_HREFS_H_SEEN #define REBASE_HREFS_H_SEEN -#include <glib/gtypes.h> +#include <glib.h> #include "util/list.h" #include "xml/attribute-record.h" struct SPDocument; diff --git a/src/xml/repr.h b/src/xml/repr.h index 5fa9387c7..ffb8ab16b 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -15,7 +15,7 @@ #define SEEN_SP_REPR_H #include <stdio.h> -#include <glib/gtypes.h> +#include <glib.h> #include "gc-anchored.h" #include "xml/node.h" diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index 44ddba237..c197d648b 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -17,7 +17,7 @@ #include <cstring> #include <string> -#include <glib/gstrfuncs.h> +#include <glib.h> #include "preferences.h" diff --git a/src/xml/text-node.h b/src/xml/text-node.h index 2fabd6953..53798b822 100644 --- a/src/xml/text-node.h +++ b/src/xml/text-node.h @@ -15,7 +15,7 @@ #ifndef SEEN_INKSCAPE_XML_TEXT_NODE_H #define SEEN_INKSCAPE_XML_TEXT_NODE_H -#include <glib/gquark.h> +#include <glib.h> #include "xml/simple-node.h" namespace Inkscape { -- cgit v1.2.3 From f183f56d4c8c5767e94556852eb9d065f2ab06c2 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 8 Dec 2011 12:59:53 +0000 Subject: Replace deprecated G_CONST_RETURN glib symbol with const (bzr r10763) --- src/libgdl/gdl-dock-object.c | 2 +- src/libgdl/gdl-dock-object.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 129cc28d9..08ef7ff27 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -911,7 +911,7 @@ gdl_dock_object_register_init (void) g_relation_insert (dock_register, "placeholder", (gpointer) GDL_TYPE_DOCK_PLACEHOLDER); } -G_CONST_RETURN gchar * +const gchar * gdl_dock_object_nick_from_type (GType type) { GTuples *tuples; diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h index d1c27ffbd..fe5c9bcc3 100644 --- a/src/libgdl/gdl-dock-object.h +++ b/src/libgdl/gdl-dock-object.h @@ -204,7 +204,7 @@ gboolean gdl_dock_object_child_placement (GdlDockObject *object, GType gdl_dock_param_get_type (void); /* functions for setting/retrieving nick names for serializing GdlDockObject types */ -G_CONST_RETURN gchar *gdl_dock_object_nick_from_type (GType type); +const gchar *gdl_dock_object_nick_from_type (GType type); GType gdl_dock_object_type_from_nick (const gchar *nick); GType gdl_dock_object_set_type_for_nick (const gchar *nick, GType type); -- cgit v1.2.3 From e36c534d5676a2a36fef713b4eac230f5129282e Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Mon, 12 Dec 2011 00:10:01 +0100 Subject: mixed usage of class and struct for same object (bzr r10766.1.1) --- src/conn-avoid-ref.h | 6 +++--- src/context-fns.h | 4 ++-- src/desktop-events.h | 6 +++--- src/desktop-style.h | 4 ++-- src/desktop.h | 4 ++-- src/display/canvas-axonomgrid.h | 2 +- src/display/canvas-grid.h | 4 ++-- src/display/canvas-text.h | 4 ++-- src/display/sp-ctrlline.h | 2 +- src/display/sp-ctrlpoint.h | 2 +- src/document.h | 4 ++-- src/event-context.h | 6 +++--- src/gradient-drag.h | 2 +- src/knot-holder-entity.h | 2 +- src/live_effects/effect.h | 12 ++++++------ src/live_effects/parameter/parameter.h | 4 ++-- src/object-snapper.h | 4 ++-- src/rubberband.h | 8 ++++---- src/selcue.h | 4 ++-- src/seltrans.h | 6 +++--- src/snap-candidate.h | 2 +- src/snapper.h | 2 +- src/sp-shape.h | 2 +- src/splivarot.h | 2 +- src/svg-view.h | 2 +- src/text-editing.h | 6 +++--- src/trace/trace.h | 2 +- src/ui/dialog/calligraphic-profile-rename.h | 2 +- src/ui/dialog/icon-preview.h | 2 +- src/ui/widget/ruler.h | 2 +- src/widgets/select-toolbar.h | 2 +- 31 files changed, 58 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/conn-avoid-ref.h b/src/conn-avoid-ref.h index f99d1f0cb..89e86ded7 100644 --- a/src/conn-avoid-ref.h +++ b/src/conn-avoid-ref.h @@ -13,12 +13,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> +#include <glib/gslist.h> #include <stddef.h> #include <sigc++/connection.h> -struct SPDesktop; -struct SPItem; +class SPDesktop; +class SPItem; struct ConnectionPoint; typedef std::map<int, ConnectionPoint> IdConnectionPointMap; namespace Avoid { class ShapeRef; } diff --git a/src/context-fns.h b/src/context-fns.h index c56c67a27..12d6e6194 100644 --- a/src/context-fns.h +++ b/src/context-fns.h @@ -14,8 +14,8 @@ #include <gdk/gdk.h> #include <2geom/forward.h> -struct SPDesktop; -struct SPItem; +class SPDesktop; +class SPItem; struct SPEventContext; const double goldenratio = 1.61803398874989484820; // golden ratio diff --git a/src/desktop-events.h b/src/desktop-events.h index e573fc878..cac7e089f 100644 --- a/src/desktop-events.h +++ b/src/desktop-events.h @@ -16,9 +16,9 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> -class SPDesktop; -class SPDesktopWidget; -class SPCanvasItem; +class SPDesktop; +class SPDesktopWidget; +struct SPCanvasItem; /* Item handlers */ diff --git a/src/desktop-style.h b/src/desktop-style.h index 3719c2a9e..81485420b 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -17,8 +17,8 @@ class ColorRGBA; struct SPCSSAttr; -struct SPDesktop; -struct SPObject; +class SPDesktop; +class SPObject; struct SPStyle; namespace Inkscape { namespace XML { diff --git a/src/desktop.h b/src/desktop.h index 8921f45b8..b466fff15 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -44,9 +44,9 @@ struct SPCanvas; struct SPCanvasItem; struct SPCanvasGroup; struct SPEventContext; -struct SPItem; +class SPItem; struct SPNamedView; -struct SPObject; +class SPObject; struct SPStyle; typedef struct _DocumentInterface DocumentInterface;//struct DocumentInterface; diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index e63d660fe..1f8bad51d 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -24,7 +24,7 @@ #include "canvas-grid.h" -struct SPDesktop; +class SPDesktop; struct SPNamedView; namespace Inkscape { diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 10feeca0e..f7cc3c032 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -24,10 +24,10 @@ #include "snapper.h" #include "line-snapper.h" -struct SPDesktop; +class SPDesktop; struct SPNamedView; struct SPCanvasBuf; -class SPDocument; +class SPDocument; namespace Inkscape { diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h index 85333d84e..90c02717c 100644 --- a/src/display/canvas-text.h +++ b/src/display/canvas-text.h @@ -16,8 +16,8 @@ #include "sp-canvas-item.h" -struct SPItem; -struct SPDesktop; +class SPItem; +class SPDesktop; #define SP_TYPE_CANVASTEXT (sp_canvastext_get_type ()) #define SP_CANVASTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVASTEXT, SPCanvasText)) diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index eeed7e75d..4bfe50a77 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -16,7 +16,7 @@ #include "sp-canvas-item.h" -struct SPItem; +class SPItem; #define SP_TYPE_CTRLLINE (sp_ctrlline_get_type ()) #define SP_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLLINE, SPCtrlLine)) diff --git a/src/display/sp-ctrlpoint.h b/src/display/sp-ctrlpoint.h index 907f74bf8..a7a5475b7 100644 --- a/src/display/sp-ctrlpoint.h +++ b/src/display/sp-ctrlpoint.h @@ -14,7 +14,7 @@ #include "sp-canvas-item.h" -struct SPItem; +class SPItem; #define SP_TYPE_CTRLPOINT (sp_ctrlpoint_get_type ()) #define SP_CTRLPOINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLPOINT, SPCtrlPoint)) diff --git a/src/document.h b/src/document.h index efb14123a..b799cb832 100644 --- a/src/document.h +++ b/src/document.h @@ -39,8 +39,8 @@ class Router; } struct SPDesktop; -struct SPItem; -struct SPObject; +class SPItem; +class SPObject; struct SPGroup; struct SPRoot; struct SPUnit; diff --git a/src/event-context.h b/src/event-context.h index 1c9f46a46..1e641e6ef 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -20,9 +20,9 @@ #include "preferences.h" struct GrDrag; -struct SPDesktop; -struct SPItem; -class ShapeEditor; +class SPDesktop; +class SPItem; +class ShapeEditor; struct SPEventContext; namespace Inkscape { diff --git a/src/gradient-drag.h b/src/gradient-drag.h index cb3f13e71..8aa9a6550 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -24,12 +24,12 @@ #include "knot-enums.h" -struct SPItem; struct SPKnot; class SPDesktop; class SPCSSAttr; class SPLinearGradient; +class SPItem; class SPObject; class SPRadialGradient; class SPStop; diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index e708486ca..5422e6d1b 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -19,7 +19,7 @@ #include <2geom/forward.h> #include "snapper.h" -struct SPItem; +class SPItem; struct SPKnot; class SPDesktop; diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 91d09fef6..48577c225 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -21,13 +21,13 @@ struct SPDocument; struct SPDesktop; -struct SPItem; -class SPNodeContext; +class SPItem; +class SPNodeContext; struct LivePathEffectObject; -class SPLPEItem; -class KnotHolder; -class KnotHolderEntity; -class SPPath; +class SPLPEItem; +class KnotHolder; +class KnotHolderEntity; +class SPPath; struct SPCurve; namespace Gtk { diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index fe93e8dca..92c2c8b41 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -15,8 +15,8 @@ class KnotHolder; class SPLPEItem; -struct SPDesktop; -struct SPItem; +class SPDesktop; +class SPItem; namespace Gtk { class Widget; diff --git a/src/object-snapper.h b/src/object-snapper.h index d51cade93..59e2f10ce 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -16,8 +16,8 @@ #include "snap-candidate.h" struct SPNamedView; -struct SPItem; -struct SPObject; +class SPItem; +class SPObject; namespace Inkscape { diff --git a/src/rubberband.h b/src/rubberband.h index 1b71f9ae2..fbebe2b08 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -17,10 +17,10 @@ /* fixme: do multidocument safe */ -class CtrlRect; -class SPCanvasItem; -class SPCurve; -class SPDesktop; +class CtrlRect; +struct SPCanvasItem; +class SPCurve; +class SPDesktop; enum { RUBBERBAND_MODE_RECT, diff --git a/src/selcue.h b/src/selcue.h index 0869a597d..f62ef768a 100644 --- a/src/selcue.h +++ b/src/selcue.h @@ -17,8 +17,8 @@ #include <stddef.h> #include <sigc++/sigc++.h> -class SPDesktop; -class SPCanvasItem; +class SPDesktop; +struct SPCanvasItem; namespace Inkscape { diff --git a/src/seltrans.h b/src/seltrans.h index 3804caef3..122e7a522 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -27,9 +27,9 @@ #include "sp-item.h" struct SPKnot; -class SPDesktop; -class SPCanvasItem; -class SPSelTransHandle; +class SPDesktop; +struct SPCanvasItem; +class SPSelTransHandle; namespace Inkscape { diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 1c5cf3234..5f17c8572 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -17,7 +17,7 @@ //#include "snapped-point.h" #include "snap-enums.h" -struct SPItem; // forward declaration +class SPItem; // forward declaration namespace Inkscape { diff --git a/src/snapper.h b/src/snapper.h index f5fbd4fdc..78d32c12c 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -31,7 +31,7 @@ struct IntermSnapResults { }; class SnapManager; -struct SPItem; +class SPItem; namespace Inkscape { diff --git a/src/sp-shape.h b/src/sp-shape.h index 014158b21..c5e9588b3 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -31,7 +31,7 @@ #define SP_SHAPE_WRITE_PATH (1 << 2) -struct SPDesktop; +class SPDesktop; namespace Inkscape { diff --git a/src/splivarot.h b/src/splivarot.h index 40089ad71..9dc596888 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -11,7 +11,7 @@ #include <2geom/forward.h> #include <2geom/path.h> class SPCurve; -struct SPItem; +class SPItem; // boolean operations // work on the current selection diff --git a/src/svg-view.h b/src/svg-view.h index 33a9b569a..aaaa8a9a5 100644 --- a/src/svg-view.h +++ b/src/svg-view.h @@ -14,7 +14,7 @@ #include "ui/view/view.h" class SPCanvasGroup; -class SPCanvasItem; +struct SPCanvasItem; /** diff --git a/src/text-editing.h b/src/text-editing.h index c0f104dec..37527d385 100644 --- a/src/text-editing.h +++ b/src/text-editing.h @@ -18,9 +18,9 @@ #include "libnrtype/Layout-TNG.h" #include "text-tag-attributes.h" -class SPCSSAttr; -struct SPItem; -struct SPObject; +class SPCSSAttr; +class SPItem; +class SPObject; struct SPStyle; typedef std::pair<Inkscape::Text::Layout::iterator, Inkscape::Text::Layout::iterator> iterator_pair; diff --git a/src/trace/trace.h b/src/trace/trace.h index 29b8716ee..a7fbe0cc8 100644 --- a/src/trace/trace.h +++ b/src/trace/trace.h @@ -27,7 +27,7 @@ #include <sp-shape.h> struct SPImage; -struct SPItem; +class SPItem; namespace Inkscape { diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index e9f6a8b95..f0eb0b491 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -15,7 +15,7 @@ #include <gtkmm/entry.h> #include <gtkmm/label.h> #include <gtkmm/table.h> -struct SPDesktop; +class SPDesktop; namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 9c10eb89b..ec4b3cac4 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -26,7 +26,7 @@ #include "ui/widget/panel.h" #include "desktop-tracker.h" -struct SPObject; +class SPObject; namespace Glib { class Timer; } diff --git a/src/ui/widget/ruler.h b/src/ui/widget/ruler.h index 319624709..1a455a325 100644 --- a/src/ui/widget/ruler.h +++ b/src/ui/widget/ruler.h @@ -14,7 +14,7 @@ #include <2geom/point.h> struct SPCanvasItem; -struct SPDesktop; +class SPDesktop; namespace Glib { class ustring; } diff --git a/src/widgets/select-toolbar.h b/src/widgets/select-toolbar.h index a4c42880f..e3573da66 100644 --- a/src/widgets/select-toolbar.h +++ b/src/widgets/select-toolbar.h @@ -15,7 +15,7 @@ */ #include <gtk/gtk.h> -struct SPDesktop; +class SPDesktop; void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder); -- cgit v1.2.3 From 48a43f957441a3b86ff12c15052789865e422e64 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Mon, 12 Dec 2011 00:13:51 +0100 Subject: SPAttributeWidget C++ified (bzr r10766.1.2) --- src/display/gnome-canvas-acetate.cpp | 18 +- src/widgets/sp-attribute-widget.cpp | 317 ++++++++++------------------------- src/widgets/sp-attribute-widget.h | 48 ++---- 3 files changed, 109 insertions(+), 274 deletions(-) (limited to 'src') diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index bdda3a120..544efe61f 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -25,8 +25,7 @@ static double sp_canvas_acetate_point (SPCanvasItem *item, Geom::Point p, SPCanv static SPCanvasItemClass *parent_class; -GType -sp_canvas_acetate_get_type (void) +GType sp_canvas_acetate_get_type (void) { static GType acetate_type = 0; if (!acetate_type) { @@ -45,8 +44,7 @@ sp_canvas_acetate_get_type (void) return acetate_type; } -static void -sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) +static void sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) { GtkObjectClass *object_class; SPCanvasItemClass *item_class; @@ -62,14 +60,12 @@ sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) item_class->point = sp_canvas_acetate_point; } -static void -sp_canvas_acetate_init (SPCanvasAcetate */*acetate*/) +static void sp_canvas_acetate_init (SPCanvasAcetate */*acetate*/) { /* Nothing here */ } -static void -sp_canvas_acetate_destroy (GtkObject *object) +static void sp_canvas_acetate_destroy (GtkObject *object) { SPCanvasAcetate *acetate; @@ -82,8 +78,7 @@ sp_canvas_acetate_destroy (GtkObject *object) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } -static void -sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, unsigned int /*flags*/ ) +static void sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, unsigned int /*flags*/ ) { item->x1 = -G_MAXINT; item->y1 = -G_MAXINT; @@ -91,8 +86,7 @@ sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, un item->y2 = G_MAXINT; } -static double -sp_canvas_acetate_point( SPCanvasItem *item, Geom::Point /*p*/, SPCanvasItem **actual_item ) +static double sp_canvas_acetate_point( SPCanvasItem *item, Geom::Point /*p*/, SPCanvasItem **actual_item ) { *actual_item = item; diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index f3bdc062d..7d4424cfd 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -20,277 +20,133 @@ using Inkscape::DocumentUndo; -static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass); -static void sp_attribute_widget_init (SPAttributeWidget *widget); -static void sp_attribute_widget_destroy (GtkObject *object); - -static void sp_attribute_widget_changed (GtkEditable *editable); - static void sp_attribute_widget_object_modified ( SPObject *object, guint flags, SPAttributeWidget *spaw ); static void sp_attribute_widget_object_release ( SPObject *object, SPAttributeWidget *spaw ); -static GtkEntryClass *parent_class; - - - -GType sp_attribute_widget_get_type(void) +SPAttributeWidget::SPAttributeWidget () : + blocked(0), + hasobj(0), + _attribute(), + modified_connection(), + release_connection() { - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPAttributeWidgetClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_attribute_widget_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPAttributeWidget), - 0, // n_preallocs - (GInstanceInitFunc)sp_attribute_widget_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_ENTRY, "SPAttributeWidget", &info, static_cast<GTypeFlags>(0)); - } - return type; -} // end of sp_attribute_widget_get_type() - - - -static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass) -{ - GtkObjectClass *object_class; - GtkEditableClass *editable_class; - - object_class = GTK_OBJECT_CLASS (klass); - editable_class = GTK_EDITABLE_CLASS (klass); - - parent_class = (GtkEntryClass*)g_type_class_peek_parent (klass); - - object_class->destroy = sp_attribute_widget_destroy; - - editable_class->changed = sp_attribute_widget_changed; - -} // end of sp_attribute_widget_class_init() - - - -static void sp_attribute_widget_init (SPAttributeWidget *spaw) -{ - spaw->blocked = FALSE; - spaw->hasobj = FALSE; - - spaw->src.object = NULL; - - spaw->attribute = NULL; - - new (&spaw->modified_connection) sigc::connection(); - new (&spaw->release_connection) sigc::connection(); + src.object = NULL; } - - -static void sp_attribute_widget_destroy (GtkObject *object) +SPAttributeWidget::~SPAttributeWidget () { - - SPAttributeWidget *spaw; - - spaw = SP_ATTRIBUTE_WIDGET (object); - - if (spaw->attribute) { - g_free (spaw->attribute); - spaw->attribute = NULL; - } - - - if (spaw->hasobj) { - - if (spaw->src.object) { - spaw->modified_connection.disconnect(); - spaw->release_connection.disconnect(); - spaw->src.object = NULL; - } - } else { - - if (spaw->src.repr) { - spaw->src.repr = Inkscape::GC::release(spaw->src.repr); + if (hasobj) + { + if (src.object) + { + modified_connection.disconnect(); + release_connection.disconnect(); + src.object = NULL; } - } // end of if() - - spaw->modified_connection.~connection(); - spaw->release_connection.~connection(); - - ((GtkObjectClass *) parent_class)->destroy (object); - -} - - - -static void sp_attribute_widget_changed (GtkEditable *editable) -{ - - SPAttributeWidget *spaw; - - spaw = SP_ATTRIBUTE_WIDGET (editable); - - if (!spaw->blocked) { - - const gchar *text; - spaw->blocked = TRUE; - text = gtk_entry_get_text (GTK_ENTRY (spaw)); - if (!*text) - text = NULL; - - if (spaw->hasobj && spaw->src.object) { - spaw->src.object->getRepr()->setAttribute(spaw->attribute, text, false); - DocumentUndo::done(spaw->src.object->document, SP_VERB_NONE, - _("Set attribute")); - - } else if (spaw->src.repr) { - spaw->src.repr->setAttribute(spaw->attribute, text, false); - /* TODO: Warning! Undo will not be flushed in given case */ + } + else + { + if (src.repr) + { + src.repr = Inkscape::GC::release(src.repr); } - spaw->blocked = FALSE; } - -} // end of sp_attribute_widget_changed() - - - -GtkWidget *sp_attribute_widget_new ( SPObject *object, const gchar *attribute ) -{ - SPAttributeWidget *spaw; - - g_return_val_if_fail (!object || SP_IS_OBJECT (object), NULL); - g_return_val_if_fail (!object || attribute, NULL); - - spaw = (SPAttributeWidget*)g_object_new (SP_TYPE_ATTRIBUTE_WIDGET, NULL); - - sp_attribute_widget_set_object (spaw, object, attribute); - - return GTK_WIDGET (spaw); - -} // end of sp_attribute_widget_new() - - - -GtkWidget *sp_attribute_widget_new_repr ( Inkscape::XML::Node *repr, const gchar *attribute ) -{ - SPAttributeWidget *spaw; - - spaw = (SPAttributeWidget*)g_object_new (SP_TYPE_ATTRIBUTE_WIDGET, NULL); - - sp_attribute_widget_set_repr (spaw, repr, attribute); - - return GTK_WIDGET (spaw); } - - -void sp_attribute_widget_set_object ( SPAttributeWidget *spaw, - SPObject *object, - const gchar *attribute ) +void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) { - - g_return_if_fail (spaw != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_WIDGET (spaw)); - g_return_if_fail (!object || SP_IS_OBJECT (object)); - g_return_if_fail (!object || attribute); - g_return_if_fail (attribute != NULL); - - if (spaw->attribute) { - g_free (spaw->attribute); - spaw->attribute = NULL; - } - - if (spaw->hasobj) { - - if (spaw->src.object) { - spaw->modified_connection.disconnect(); - spaw->release_connection.disconnect(); - spaw->src.object = NULL; + if (hasobj) { + if (src.object) { + modified_connection.disconnect(); + release_connection.disconnect(); + src.object = NULL; } } else { - if (spaw->src.repr) { - spaw->src.repr = Inkscape::GC::release(spaw->src.repr); + if (src.repr) { + src.repr = Inkscape::GC::release(src.repr); } } - spaw->hasobj = TRUE; - + hasobj = true; + if (object) { const gchar *val; - spaw->blocked = TRUE; - spaw->src.object = object; + blocked = true; + src.object = object; - spaw->modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), spaw)); - spaw->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), spaw)); + modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), this)); + release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), this)); - spaw->attribute = g_strdup (attribute); + _attribute = attribute; val = object->getRepr()->attribute(attribute); - gtk_entry_set_text (GTK_ENTRY (spaw), val ? val : (const gchar *) ""); - spaw->blocked = FALSE; + set_text (val ? val : (const gchar *) ""); + blocked = false; } + gtk_widget_set_sensitive (GTK_WIDGET(this), (src.object != NULL)); +} - gtk_widget_set_sensitive (GTK_WIDGET (spaw), (spaw->src.object != NULL)); - -} // end of sp_attribute_widget_set_object() - - - -void sp_attribute_widget_set_repr ( SPAttributeWidget *spaw, - Inkscape::XML::Node *repr, - const gchar *attribute ) +void SPAttributeWidget::set_repr(Inkscape::XML::Node *repr, const gchar *attribute) { - - g_return_if_fail (spaw != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_WIDGET (spaw)); - g_return_if_fail (attribute != NULL); - - if (spaw->attribute) { - g_free (spaw->attribute); - spaw->attribute = NULL; - } - - if (spaw->hasobj) { - - if (spaw->src.object) { - spaw->modified_connection.disconnect(); - spaw->release_connection.disconnect(); - spaw->src.object = NULL; + if (hasobj) { + if (src.object) { + modified_connection.disconnect(); + release_connection.disconnect(); + src.object = NULL; } } else { - if (spaw->src.repr) { - spaw->src.repr = Inkscape::GC::release(spaw->src.repr); + if (src.repr) { + src.repr = Inkscape::GC::release(src.repr); } } - spaw->hasobj = FALSE; - + hasobj = false; + if (repr) { const gchar *val; - spaw->blocked = TRUE; - spaw->src.repr = Inkscape::GC::anchor(repr); - spaw->attribute = g_strdup (attribute); + blocked = true; + src.repr = Inkscape::GC::anchor(repr); + attribute = g_strdup (attribute); val = repr->attribute(attribute); - gtk_entry_set_text (GTK_ENTRY (spaw), val ? val : (const gchar *) ""); - spaw->blocked = FALSE; + set_text (val ? val : (const gchar *) ""); + blocked = false; } + gtk_widget_set_sensitive (GTK_WIDGET (this), (src.repr != NULL)); +} - gtk_widget_set_sensitive (GTK_WIDGET (spaw), (spaw->src.repr != NULL)); - -} // end of sp_attribute_widget_set_repr() +void SPAttributeWidget::on_changed (void) +{ + if (!blocked) + { + Glib::ustring text1; + const gchar *text; + blocked = TRUE; + text1 = get_text (); + text=text1.c_str(); + if (!*text) + text = NULL; + if (hasobj && src.object) { + src.object->getRepr()->setAttribute(_attribute.c_str(), text, false); + DocumentUndo::done(src.object->document, SP_VERB_NONE, + _("Set attribute")); + } else if (src.repr) { + src.repr->setAttribute(_attribute.c_str(), text, false); + /* TODO: Warning! Undo will not be flushed in given case */ + } + blocked = false; + } +} static void sp_attribute_widget_object_modified ( SPObject */*object*/, guint flags, @@ -300,17 +156,17 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, if (flags && SP_OBJECT_MODIFIED_FLAG) { const gchar *val, *text; - val = spaw->src.object->getRepr()->attribute(spaw->attribute); + val = spaw->src.object->getRepr()->attribute(spaw->get_attribute().c_str()); text = gtk_entry_get_text (GTK_ENTRY (spaw)); if (val || text) { if (!val || !text || strcmp (val, text)) { /* We are different */ - spaw->blocked = TRUE; + spaw->set_blocked(true); gtk_entry_set_text ( GTK_ENTRY (spaw), val ? val : (const gchar *) ""); - spaw->blocked = FALSE; + spaw->set_blocked(false); } // end of if() } // end of if() @@ -319,13 +175,10 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, } // end of sp_attribute_widget_object_modified() - - -static void -sp_attribute_widget_object_release ( SPObject */*object*/, - SPAttributeWidget *spaw ) +static void sp_attribute_widget_object_release ( SPObject */*object*/, + SPAttributeWidget * spaw ) { - sp_attribute_widget_set_object (spaw, NULL, NULL); + spaw->set_object (NULL, NULL); } diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index a4acf9504..b3437eea7 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -14,16 +14,11 @@ #ifndef SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H #define SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H +#include <gtkmm/entry.h> #include <glib.h> #include <stddef.h> #include <sigc++/connection.h> -#define SP_TYPE_ATTRIBUTE_WIDGET (sp_attribute_widget_get_type ()) -#define SP_ATTRIBUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidget)) -#define SP_ATTRIBUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_WIDGET, SPAttributeWidgetClass)) -#define SP_IS_ATTRIBUTE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ATTRIBUTE_WIDGET)) -#define SP_IS_ATTRIBUTE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_WIDGET)) - #define SP_TYPE_ATTRIBUTE_TABLE (sp_attribute_table_get_type ()) #define SP_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTable)) #define SP_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTableClass)) @@ -36,10 +31,6 @@ class Node; } } - -struct SPAttributeWidget; -struct SPAttributeWidgetClass; - struct SPAttributeTable; struct SPAttributeTableClass; @@ -47,35 +38,32 @@ class SPObject; #include <gtk/gtk.h> -struct SPAttributeWidget { - GtkEntry entry; - guint blocked : 1; - guint hasobj : 1; +class SPAttributeWidget : Gtk::Entry { +//NOTE: SPAttributeWidget does not seem to be used nowhere in Inkscape, conversion to c++ not tested +public: + SPAttributeWidget (); + ~SPAttributeWidget (); + void set_object(SPObject *object, const gchar *attribute); + void set_repr(Inkscape::XML::Node *repr, const gchar *attribute); + Glib::ustring get_attribute(void) {return _attribute;}; + void set_blocked(guint b) {blocked = b;}; + union { SPObject *object; Inkscape::XML::Node *repr; } src; - gchar *attribute; +protected: + void on_changed (void); + +private: + guint blocked; + guint hasobj; + Glib::ustring _attribute; sigc::connection modified_connection; sigc::connection release_connection; }; -struct SPAttributeWidgetClass { - GtkEntryClass entry_class; -}; - -GType sp_attribute_widget_get_type (void); - -GtkWidget *sp_attribute_widget_new (SPObject *object, const gchar *attribute); -GtkWidget *sp_attribute_widget_new_repr (Inkscape::XML::Node *repr, const gchar *attribute); - -void sp_attribute_widget_set_object ( SPAttributeWidget *spw, - SPObject *object, - const gchar *attribute ); -void sp_attribute_widget_set_repr ( SPAttributeWidget *spw, - Inkscape::XML::Node *repr, - const gchar *attribute ); /* SPAttributeTable */ -- cgit v1.2.3 From 7c124c77c3f5db80e46ad23d74dfc92d8f3aa069 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Mon, 12 Dec 2011 00:18:05 +0100 Subject: SPAttributeTable C++ified (bzr r10766.1.3) --- src/dialogs/item-properties.cpp | 20 +- src/dialogs/object-attributes.cpp | 40 ++- src/widgets/sp-attribute-widget.cpp | 551 ++++++++++++++---------------------- src/widgets/sp-attribute-widget.h | 70 ++--- 4 files changed, 278 insertions(+), 403 deletions(-) (limited to 'src') diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 4ca2b2753..ce8d4e362 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -356,13 +356,25 @@ static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection gtk_container_remove(GTK_CONTAINER(w), int_table); } - const gchar* int_labels[10] = {"onclick", "onmouseover", "onmouseout", "onmousedown", "onmouseup", "onmousemove","onfocusin", "onfocusout", "onactivate", "onload"}; - - int_table = sp_attribute_table_new (obj, 10, int_labels, int_labels); + std::vector<Glib::ustring> int_labels; + std::vector<Glib::ustring> int_attributes; + int_labels.push_back("onclick"); + int_labels.push_back("onmouseover"); + int_labels.push_back("onmouseout"); + int_labels.push_back("onmousedown"); + int_labels.push_back("onmouseup"); + int_labels.push_back("onmousemove"); + int_labels.push_back("onfocusin"); + int_labels.push_back("onfocusout"); + int_labels.push_back("onfocusout"); + int_labels.push_back("onload"); +int_attributes=int_labels; + SPAttributeTable* t = new SPAttributeTable (obj, int_labels, int_attributes, GTK_CONTAINER (w)); + int_table = (GtkWidget*) t->gobj(); gtk_widget_show_all (int_table); g_object_set_data(G_OBJECT(spw), "interactivity_table", int_table); - gtk_container_add (GTK_CONTAINER (w), int_table); +// gtk_container_add (GTK_CONTAINER (w), int_table); } diff --git a/src/dialogs/object-attributes.cpp b/src/dialogs/object-attributes.cpp index f83d3ef1f..bdb292622 100644 --- a/src/dialogs/object-attributes.cpp +++ b/src/dialogs/object-attributes.cpp @@ -72,7 +72,6 @@ static void object_released( SPObject */*object*/, GtkWidget *widget ) } - static void window_destroyed( GtkObject *window, GtkObject */*object*/ ) { sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(window), "release_connection"); @@ -81,26 +80,16 @@ static void window_destroyed( GtkObject *window, GtkObject */*object*/ ) } - static void sp_object_attr_show_dialog ( SPObject *object, const SPAttrDesc *desc, const gchar *tag ) { - const gchar **labels, **attrs; - gint len, i; + int len; + GtkWidget *w; + SPAttributeTable* t; Glib::ustring title; - GtkWidget *w, *t; - - len = 0; - while (desc[len].label) len += 1; - - labels = (const gchar **) new gchar* [len]; - attrs = (const gchar **) new gchar* [len]; - - for (i = 0; i < len; i++) { - labels[i] = desc[i].label; - attrs[i] = desc[i].attribute; - } + std::vector<Glib::ustring> labels; + std::vector<Glib::ustring> attrs; if (!strcmp (tag, "Link")) { title = _("Link Properties"); @@ -110,17 +99,21 @@ static void sp_object_attr_show_dialog ( SPObject *object, title = Glib::ustring::compose(_("%1 Properties"), tag); } + len = 0; + while (desc[len].label) + { + labels.push_back(desc[len].label); + attrs.push_back (desc[len].attribute); + len += 1; + } + w = sp_window_new (title.c_str(), TRUE); - - t = sp_attribute_table_new (object, len, labels, attrs); - gtk_widget_show (t); - gtk_container_add (GTK_CONTAINER (w), t); - delete labels; - delete attrs; + t = new SPAttributeTable (object, labels, attrs, GTK_CONTAINER (w)); + t->show(); + //gtk_container_add (GTK_CONTAINER (w), (GtkWidget*)t->gobj()); g_signal_connect ( G_OBJECT (w), "destroy", G_CALLBACK (window_destroyed), object ); - sigc::connection *release_connection = new sigc::connection(); *release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&object_released), w)); g_object_set_data(G_OBJECT(w), "release_connection", release_connection); @@ -129,7 +122,6 @@ static void sp_object_attr_show_dialog ( SPObject *object, } // end of sp_object_attr_show_dialog() - void sp_object_attributes_dialog (SPObject *object, const gchar *tag) { g_return_if_fail (object != NULL); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 7d4424cfd..8cc521449 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -1,6 +1,7 @@ /* Authors: * Lauris Kaplinski <lauris@ximian.com> - * Abhishek Sharma + * Abhishek Sharma + * Kris De Gussem <Kris.DeGussem@gmail.com> * * Copyright (C) 2001 Ximian, Inc. * Released under GNU GPL, read the file 'COPYING' for more information @@ -129,9 +130,9 @@ void SPAttributeWidget::on_changed (void) { Glib::ustring text1; const gchar *text; - blocked = TRUE; + blocked = true; text1 = get_text (); - text=text1.c_str(); + text = text1.c_str(); if (!*text) text = NULL; @@ -155,17 +156,18 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, if (flags && SP_OBJECT_MODIFIED_FLAG) { - const gchar *val, *text; - val = spaw->src.object->getRepr()->attribute(spaw->get_attribute().c_str()); - text = gtk_entry_get_text (GTK_ENTRY (spaw)); + const gchar *val; + Glib::ustring text; + Glib::ustring attr = spaw->get_attribute(); + val = spaw->src.object->getRepr()->attribute(attr.c_str()); + text = spaw->get_text(); - if (val || text) { + if (val || !text.empty()) { - if (!val || !text || strcmp (val, text)) { + if (!val || text.empty() || (text == val)) { /* We are different */ spaw->set_blocked(true); - gtk_entry_set_text ( GTK_ENTRY (spaw), - val ? val : (const gchar *) ""); + spaw->set_text(val ? val : (const gchar *) ""); spaw->set_blocked(false); } // end of if() @@ -184,374 +186,258 @@ static void sp_attribute_widget_object_release ( SPObject */*object*/, /* SPAttributeTable */ - -static void sp_attribute_table_class_init (SPAttributeTableClass *klass); -static void sp_attribute_table_init (SPAttributeTable *widget); -static void sp_attribute_table_destroy (GtkObject *object); - static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw); -static void sp_attribute_table_object_release (SPObject *object, SPAttributeTable *spaw); -static void sp_attribute_table_entry_changed (GtkEditable *editable, SPAttributeTable *spat); - -static GtkVBoxClass *table_parent_class; - - +//static void sp_attribute_table_object_release (SPObject *object, SPAttributeTable *spaw); +static void sp_attribute_table_entry_changed (Gtk::Editable *editable, SPAttributeTable *spat); +#define XPAD 4 +#define YPAD 0 -GType sp_attribute_table_get_type(void) +SPAttributeTable::SPAttributeTable () : + blocked(0), + hasobj(0), + table(0), + _attributes(), + _entries(), + modified_connection()/*, + release_connection()*/ { - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPAttributeTableClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_attribute_table_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPAttributeTable), - 0, // n_preallocs - (GInstanceInitFunc)sp_attribute_table_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_VBOX, "SPAttributeTable", &info, static_cast<GTypeFlags>(0)); - } - return type; -} // end of sp_attribute_table_get_type() - - +g_message("SPAttributeTable"); + src.object = NULL; +} -static void sp_attribute_table_class_init (SPAttributeTableClass *klass) +SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent) : + blocked(0), + hasobj(0), + table(0), + _attributes(), + _entries(), + modified_connection()/*, + release_connection()*/ { - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - - table_parent_class = (GtkVBoxClass*)g_type_class_peek_parent (klass); - - object_class->destroy = sp_attribute_table_destroy; - -} // end of sp_attribute_table_class_init() - - +g_message("SPAttributeTable"); + src.object = NULL; + set_object(object, labels, attributes, parent); +} -static void sp_attribute_table_init ( SPAttributeTable *spat ) +SPAttributeTable::~SPAttributeTable () { - spat->blocked = FALSE; - spat->hasobj = FALSE; - spat->table = NULL; - spat->src.object = NULL; - spat->num_attr = 0; - spat->attributes = NULL; - spat->entries = NULL; - - new (&spat->modified_connection) sigc::connection(); - new (&spat->release_connection) sigc::connection(); +g_message("~SPAttributeTable"); + clear(); } -static void sp_attribute_table_destroy ( GtkObject *object ) +void SPAttributeTable::clear(void) { - SPAttributeTable *spat; - - spat = SP_ATTRIBUTE_TABLE (object); - - if (spat->attributes) { - gint i; - for (i = 0; i < spat->num_attr; i++) { - g_free (spat->attributes[i]); +g_message("clear"); + Gtk::Widget *w; + +g_message("destroy 1"); + if (table) + { + std::vector<Widget*> ch = table->get_children(); + +g_message("destroy 2a"); + for (int i = (ch.size())-1; i >=0 ; i--) + { +g_message("destroy 2c"); + w = ch[i]; + ch.pop_back(); +g_message("destroy 2d"); + if (w != NULL) + { + try + { + delete w; + } + catch(...) + { +g_message("destroy 2d catched"); + } +g_message("destroy 2e"); } - g_free (spat->attributes); - spat->attributes = NULL; } + ch.clear(); +g_message("destroy 3"); + _attributes.clear(); + _entries.clear(); - if (spat->hasobj) { + delete table; + table = NULL; + } - if (spat->src.object) { - spat->modified_connection.disconnect(); - spat->release_connection.disconnect(); - spat->src.object = NULL; + if (hasobj) { + if (src.object) { + modified_connection.disconnect(); + //release_connection.disconnect(); + src.object = NULL; } } else { - if (spat->src.repr) { - spat->src.repr = Inkscape::GC::release(spat->src.repr); + if (src.repr) { + src.repr = Inkscape::GC::release(src.repr); } - } // end of if() - - spat->modified_connection.~connection(); - spat->release_connection.~connection(); - - if (spat->entries) { - g_free (spat->entries); - spat->entries = NULL; - } - - spat->table = NULL; - - if (((GtkObjectClass *) table_parent_class)->destroy) { - (* ((GtkObjectClass *) table_parent_class)->destroy) (object); } +g_message("destroy 4"); +} -} // end of sp_attribute_table_destroy() - - -GtkWidget * sp_attribute_table_new ( SPObject *object, - gint num_attr, - const gchar **labels, - const gchar **attributes ) -{ - SPAttributeTable *spat; - - g_return_val_if_fail (!object || SP_IS_OBJECT (object), NULL); - g_return_val_if_fail (!object || (num_attr > 0), NULL); - g_return_val_if_fail (!num_attr || (labels && attributes), NULL); - - spat = (SPAttributeTable*)g_object_new (SP_TYPE_ATTRIBUTE_TABLE, NULL); - - sp_attribute_table_set_object (spat, object, num_attr, labels, attributes); - - return GTK_WIDGET (spat); - -} // end of sp_attribute_table_new() - - - -GtkWidget *sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, - gint num_attr, - const gchar **labels, - const gchar **attributes ) -{ - SPAttributeTable *spat; - - g_return_val_if_fail (!num_attr || (labels && attributes), NULL); - - spat = (SPAttributeTable*)g_object_new (SP_TYPE_ATTRIBUTE_TABLE, NULL); - - sp_attribute_table_set_repr (spat, repr, num_attr, labels, attributes); - - return GTK_WIDGET (spat); - -} // end of sp_attribute_table_new_repr() - - - -#define XPAD 4 -#define YPAD 0 - -void sp_attribute_table_set_object ( SPAttributeTable *spat, - SPObject *object, - gint num_attr, - const gchar **labels, - const gchar **attributes ) +void SPAttributeTable::set_object(SPObject *object, + std::vector<Glib::ustring> &labels, + std::vector<Glib::ustring> &attributes, + GtkContainer* parent) { - - g_return_if_fail (spat != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_TABLE (spat)); +g_message("set_object"); + g_return_if_fail (parent); g_return_if_fail (!object || SP_IS_OBJECT (object)); - g_return_if_fail (!object || (num_attr > 0)); - g_return_if_fail (!num_attr || (labels && attributes)); - - if (spat->table) { - gtk_widget_destroy (spat->table); - spat->table = NULL; - } + g_return_if_fail (!object || !labels.empty() || !attributes.empty()); + g_return_if_fail (labels.size() == attributes.size()); - if (spat->attributes) { - gint i; - for (i = 0; i < spat->num_attr; i++) { - g_free (spat->attributes[i]); - } - g_free (spat->attributes); - spat->attributes = NULL; - } - - if (spat->entries) { - g_free (spat->entries); - spat->entries = NULL; - } - - if (spat->hasobj) { - if (spat->src.object) { - spat->modified_connection.disconnect(); - spat->release_connection.disconnect(); - spat->src.object = NULL; - } - } else { - if (spat->src.repr) { - spat->src.repr = Inkscape::GC::release(spat->src.repr); - } - } - - spat->hasobj = TRUE; + clear(); + hasobj = true; +g_message("1"); if (object) { - gint i; - - spat->blocked = TRUE; +g_message("2"); + blocked = true; /* Set up object */ - spat->src.object = object; - spat->num_attr = num_attr; + src.object = object; - spat->modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), spat)); - spat->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), spat)); + modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), this)); + //release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), this)); /* Create table */ - spat->table = gtk_table_new (num_attr, 2, FALSE); - gtk_container_add (GTK_CONTAINER (spat), spat->table); - /* Arrays */ - spat->attributes = g_new0 (gchar *, num_attr); - spat->entries = g_new0 (GtkWidget *, num_attr); +g_message("3a"); + table = new Gtk::Table (attributes.size(), 2, false); +g_message("3b"); + gtk_container_add (parent,(GtkWidget*)table->gobj()); +g_message("3c"); + /* Fill rows */ - for (i = 0; i < num_attr; i++) { - GtkWidget *w; + _attributes = attributes; + for (gint i = 0; i < (attributes.size()); i++) { + Gtk::Label *ll; + Gtk::Entry *ee; + Gtk::Widget *w; const gchar *val; - spat->attributes[i] = g_strdup (attributes[i]); - w = gtk_label_new (_(labels[i])); - gtk_widget_show (w); - gtk_misc_set_alignment (GTK_MISC (w), 1.0, 0.5); - gtk_table_attach ( GTK_TABLE (spat->table), w, 0, 1, i, i + 1, - GTK_FILL, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + ll = new Gtk::Label (_(labels[i].c_str())); + w = (Gtk::Widget *) ll; + ll->show(); + ll->set_alignment (1.0, 0.5); + table->attach (*w, 0, 1, i, i + 1, + Gtk::FILL, + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - w = gtk_entry_new (); - gtk_widget_show (w); - val = object->getRepr()->attribute(attributes[i]); - gtk_entry_set_text (GTK_ENTRY (w), val ? val : (const gchar *) ""); - gtk_table_attach ( GTK_TABLE (spat->table), w, 1, 2, i, i + 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), +g_message("4a"); + ee = new Gtk::Entry(); + w = (Gtk::Widget *) ee; + ee->show(); + val = object->getRepr()->attribute(attributes[i].c_str()); + ee->set_text (val ? val : (const gchar *) ""); + table->attach (*w, 1, 2, i, i + 1, + (Gtk::EXPAND | Gtk::FILL), + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - spat->entries[i] = w; - g_signal_connect ( G_OBJECT (w), "changed", + _entries.push_back(w); + g_signal_connect ( w->gobj(), "changed", G_CALLBACK (sp_attribute_table_entry_changed), - spat ); + this ); +g_message("4b"); } /* Show table */ - gtk_widget_show (spat->table); - - spat->blocked = FALSE; + table->show (); + blocked = false; } - gtk_widget_set_sensitive ( GTK_WIDGET (spat), - (spat->src.object != NULL) ); - -} // end of sp_attribute_table_set_object() - - + //set_sensitive ((src.object != NULL) ); +g_message("5"); +} -void sp_attribute_table_set_repr ( SPAttributeTable *spat, - Inkscape::XML::Node *repr, - gint num_attr, - const gchar **labels, - const gchar **attributes ) +void SPAttributeTable::set_repr (Inkscape::XML::Node *repr, + std::vector<Glib::ustring> &labels, + std::vector<Glib::ustring> &attributes, + GtkContainer* parent) { - g_return_if_fail (spat != NULL); - g_return_if_fail (SP_IS_ATTRIBUTE_TABLE (spat)); - g_return_if_fail (!num_attr || (labels && attributes)); +g_message("set_repr"); + g_return_if_fail (!labels.empty() || !attributes.empty()); + g_return_if_fail (labels.size() == attributes.size()); - if (spat->table) { - gtk_widget_destroy (spat->table); - spat->table = NULL; - } + clear(); - if (spat->attributes) { - gint i; - for (i = 0; i < spat->num_attr; i++) { - g_free (spat->attributes[i]); - } - g_free (spat->attributes); - spat->attributes = NULL; - } - - if (spat->entries) { - g_free (spat->entries); - spat->entries = NULL; - } - - if (spat->hasobj) { - if (spat->src.object) { - spat->modified_connection.disconnect(); - spat->release_connection.disconnect(); - spat->src.object = NULL; - } - } else { - if (spat->src.repr) { - spat->src.repr = Inkscape::GC::release(spat->src.repr); - } - } - - spat->hasobj = FALSE; + hasobj = false; if (repr) { - gint i; - - spat->blocked = TRUE; - - /* Set up repr */ - spat->src.repr = Inkscape::GC::anchor(repr); - spat->num_attr = num_attr; - /* Create table */ - spat->table = gtk_table_new (num_attr, 2, FALSE); - gtk_container_add (GTK_CONTAINER (spat), spat->table); - /* Arrays */ - spat->attributes = g_new0 (gchar *, num_attr); - spat->entries = g_new0 (GtkWidget *, num_attr); + blocked = true; - /* Fill rows */ - for (i = 0; i < num_attr; i++) { - GtkWidget *w; + // Set up repr + src.repr = Inkscape::GC::anchor(repr); + + // Create table + table = new Gtk::Table (attributes.size(), 2, false); + gtk_container_add (parent,(GtkWidget*)table->gobj()); + + // Fill rows + _attributes = attributes; + for (gint i = 0; i < (attributes.size()); i++) { + Gtk::Label *ll; + Gtk::Entry *ee; + Gtk::Widget *w; const gchar *val; - spat->attributes[i] = g_strdup (attributes[i]); - w = gtk_label_new (labels[i]); - gtk_widget_show (w); - gtk_misc_set_alignment (GTK_MISC (w), 1.0, 0.5); - gtk_table_attach ( GTK_TABLE (spat->table), w, 0, 1, i, i + 1, - GTK_FILL, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + ll = new Gtk::Label (_(labels[i].c_str())); + w = (Gtk::Widget *) ll; + ll->show (); + ll->set_alignment (1.0, 0.5); + table->attach (*w, 0, 1, i, i + 1, + Gtk::FILL, + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - w = gtk_entry_new (); - gtk_widget_show (w); - val = repr->attribute(attributes[i]); - gtk_entry_set_text (GTK_ENTRY (w), val ? val : (const gchar *) ""); - gtk_table_attach ( GTK_TABLE (spat->table), w, 1, 2, i, i + 1, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + ee = new Gtk::Entry(); + w = (Gtk::Widget *) ee; + ee->show(); + val = repr->attribute(attributes[i].c_str()); + ee->set_text (val ? val : (const gchar *) ""); + table->attach (*w, 1, 2, i, i + 1, + (Gtk::EXPAND | Gtk::FILL), + (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); - spat->entries[i] = w; - g_signal_connect ( G_OBJECT (w), "changed", + _entries.push_back(w); +//ee->on_change = sp_attribute_table_entry_changed; + g_signal_connect ( w->gobj(), "changed", G_CALLBACK (sp_attribute_table_entry_changed), - spat ); + this ); } /* Show table */ - gtk_widget_show (spat->table); - - spat->blocked = FALSE; + table->show (); + blocked = false; } - gtk_widget_set_sensitive (GTK_WIDGET (spat), (spat->src.repr != NULL)); - -} // end of sp_attribute_table_set_repr() - + //set_sensitive ((src.repr != NULL)); +} static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { +g_message("sp_attribute_table_object_modified"); if (flags && SP_OBJECT_MODIFIED_FLAG) { gint i; - for (i = 0; i < spat->num_attr; i++) { - const gchar *val, *text; - val = spat->src.object->getRepr()->attribute(spat->attributes[i]); - text = gtk_entry_get_text (GTK_ENTRY (spat->entries[i])); - if (val || text) { - if (!val || !text || strcmp (val, text)) { + std::vector<Glib::ustring> attributes = spat->get_attributes(); + std::vector<Gtk::Widget *> entries = spat->get_entries(); + Gtk::Entry* e; + Glib::ustring text; + for (i = 0; i < (attributes.size()); i++) { + const gchar *val; + e = (Gtk::Entry*) entries[i]; + val = spat->src.object->getRepr()->attribute(attributes[i].c_str()); + text = e->get_text (); + if (val || !text.empty()) { + if (text != val) { /* We are different */ - spat->blocked = TRUE; - gtk_entry_set_text ( GTK_ENTRY (spat->entries[i]), - val ? val : (const gchar *) ""); - spat->blocked = FALSE; + spat->blocked = true; + e->set_text (val ? val : (const gchar *) ""); + spat->blocked = false; } } } @@ -559,42 +445,41 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, } // end of sp_attribute_table_object_modified() +//static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat) +/*{ +g_message("sp_attribute_table_object_release"); + std::vector<Glib::ustring> labels; + std::vector<Glib::ustring> attributes; + spat->set_object (NULL, labels, attributes, NULL); +}*/ - -static void sp_attribute_table_object_release (SPObject */*object*/, SPAttributeTable *spat) -{ - sp_attribute_table_set_object (spat, NULL, 0, NULL, NULL); -} - - - -static void sp_attribute_table_entry_changed ( GtkEditable *editable, +static void sp_attribute_table_entry_changed ( Gtk::Editable *editable, SPAttributeTable *spat ) { +g_message("sp_attribute_table_entry_changed"); if (!spat->blocked) { gint i; - for (i = 0; i < spat->num_attr; i++) { - - if (GTK_WIDGET (editable) == spat->entries[i]) { - const gchar *text; - spat->blocked = TRUE; - text = gtk_entry_get_text (GTK_ENTRY (spat->entries[i])); - - if (!*text) - text = NULL; + std::vector<Glib::ustring> attributes = spat->get_attributes(); + std::vector<Gtk::Widget *> entries = spat->get_entries(); + Gtk::Entry *e; + for (i = 0; i < (attributes.size()); i++) { + e = (Gtk::Entry *) entries[i]; + if ((GtkWidget*) (editable) == (GtkWidget*) e->gobj()) { + spat->blocked = true; + Glib::ustring text = e->get_text (); if (spat->hasobj && spat->src.object) { - spat->src.object->getRepr()->setAttribute(spat->attributes[i], text, false); + spat->src.object->getRepr()->setAttribute(attributes[i].c_str(), text.c_str(), false); DocumentUndo::done(spat->src.object->document, SP_VERB_NONE, _("Set attribute")); } else if (spat->src.repr) { - spat->src.repr->setAttribute(spat->attributes[i], text, false); + spat->src.repr->setAttribute(attributes[i].c_str(), text.c_str(), false); /* TODO: Warning! Undo will not be flushed in given case */ } - spat->blocked = FALSE; + spat->blocked = false; return; } } diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index b3437eea7..aac567987 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -4,6 +4,7 @@ */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> + * Kris De Gussem <Kris.DeGussem@gmail.com> * * Copyright (C) 2002 authors * Copyright (C) 2001 Ximian, Inc. @@ -14,16 +15,14 @@ #ifndef SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H #define SEEN_DIALOGS_SP_ATTRIBUTE_WIDGET_H -#include <gtkmm/entry.h> +#include <gtk/gtk.h> +#include <gtkmm.h> +//#include <gtkmm/entry.h> +//#include <gtkmm/table.h> #include <glib.h> #include <stddef.h> #include <sigc++/connection.h> - -#define SP_TYPE_ATTRIBUTE_TABLE (sp_attribute_table_get_type ()) -#define SP_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTable)) -#define SP_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_ATTRIBUTE_TABLE, SPAttributeTableClass)) -#define SP_IS_ATTRIBUTE_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ATTRIBUTE_TABLE)) -#define SP_IS_ATTRIBUTE_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_ATTRIBUTE_TABLE)) +#include <vector.h> namespace Inkscape { namespace XML { @@ -33,12 +32,9 @@ class Node; struct SPAttributeTable; struct SPAttributeTableClass; +class SPObject; -class SPObject; - -#include <gtk/gtk.h> - -class SPAttributeWidget : Gtk::Entry { +class SPAttributeWidget : public Gtk::Entry { //NOTE: SPAttributeWidget does not seem to be used nowhere in Inkscape, conversion to c++ not tested public: SPAttributeWidget (); @@ -67,44 +63,34 @@ private: /* SPAttributeTable */ -struct SPAttributeTable { - GtkVBox vbox; - guint blocked : 1; - guint hasobj : 1; - GtkWidget *table; +class SPAttributeTable : public Gtk::Widget { +public: + SPAttributeTable (); + SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + ~SPAttributeTable (); + void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + void set_repr(Inkscape::XML::Node *repr, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + std::vector<Glib::ustring> get_attributes(void) {return _attributes;}; + std::vector<Gtk::Widget *> get_entries(void) {return _entries;}; union { SPObject *object; Inkscape::XML::Node *repr; } src; - gint num_attr; - gchar **attributes; - GtkWidget **entries; + guint blocked; + guint hasobj; +private: +// GtkVBox vbox; + Gtk::Table *table; +// Gtk::Container *_parent; + std::vector<Glib::ustring> _attributes; + std::vector<Gtk::Widget *> _entries; sigc::connection modified_connection; - sigc::connection release_connection; -}; - -struct SPAttributeTableClass { - GtkEntryClass entry_class; + //sigc::connection release_connection; + + void clear(void); }; -GType sp_attribute_table_get_type (void); - -GtkWidget *sp_attribute_table_new ( SPObject *object, gint num_attr, - const gchar **labels, - const gchar **attributes ); -GtkWidget *sp_attribute_table_new_repr ( Inkscape::XML::Node *repr, gint num_attr, - const gchar **labels, - const gchar **attributes ); -void sp_attribute_table_set_object ( SPAttributeTable *spw, - SPObject *object, gint num_attr, - const gchar **labels, - const gchar **attrs ); -void sp_attribute_table_set_repr ( SPAttributeTable *spw, - Inkscape::XML::Node *repr, gint num_attr, - const gchar **labels, - const gchar **attrs ); - #endif /* -- cgit v1.2.3 From 9c22f60bc2b10f153843789ad3c714b8d830bcc4 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 00:07:08 +0000 Subject: Replace deprecated gtk_widget_hide_all Fixed bugs: - https://launchpad.net/bugs/903670 (bzr r10767) --- src/dialogs/find.cpp | 8 ++++---- src/widgets/desktop-widget.cpp | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index 4288e7a78..7219c910e 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -447,7 +447,7 @@ toggle_alltypes (GtkToggleButton *tb, gpointer data) { GtkWidget *alltypes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "all-pane")); if (gtk_toggle_button_get_active (tb)) { - gtk_widget_hide_all (alltypes_pane); + gtk_widget_hide (alltypes_pane); } else { gtk_widget_show_all (alltypes_pane); @@ -470,7 +470,7 @@ toggle_shapes (GtkToggleButton *tb, gpointer data) { GtkWidget *shapes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "shapes-pane")); if (gtk_toggle_button_get_active (tb)) { - gtk_widget_hide_all (shapes_pane); + gtk_widget_hide (shapes_pane); } else { gtk_widget_show_all (shapes_pane); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (data), "rects")), FALSE); @@ -596,7 +596,7 @@ sp_find_types () g_object_set_data (G_OBJECT (vb), "shapes-pane", hb); gtk_box_pack_start (GTK_BOX (vb_all), hb, FALSE, FALSE, 0); - gtk_widget_hide_all (hb); + gtk_widget_hide (hb); } { @@ -635,7 +635,7 @@ sp_find_types () gtk_box_pack_start (GTK_BOX (vb), vb_all, FALSE, FALSE, 0); g_object_set_data (G_OBJECT (vb), "all-pane", vb_all); - gtk_widget_hide_all (vb_all); + gtk_widget_hide (vb_all); } return vb; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index cbfb8fe5f..b65d78117 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1265,26 +1265,26 @@ void SPDesktopWidget::layoutWidgets() #ifndef GDK_WINDOWING_QUARTZ if (!prefs->getBool(pref_root + "menu/state", true)) { - gtk_widget_hide_all (dtw->menubar); + gtk_widget_hide (dtw->menubar); } else { gtk_widget_show_all (dtw->menubar); } #endif if (!prefs->getBool(pref_root + "commands/state", true)) { - gtk_widget_hide_all (dtw->commands_toolbox); + gtk_widget_hide (dtw->commands_toolbox); } else { gtk_widget_show_all (dtw->commands_toolbox); } if (!prefs->getBool(pref_root + "snaptoolbox/state", true)) { - gtk_widget_hide_all (dtw->snap_toolbox); + gtk_widget_hide (dtw->snap_toolbox); } else { gtk_widget_show_all (dtw->snap_toolbox); } if (!prefs->getBool(pref_root + "toppanel/state", true)) { - gtk_widget_hide_all (dtw->aux_toolbox); + gtk_widget_hide (dtw->aux_toolbox); } else { // we cannot just show_all because that will show all tools' panels; // this is a function from toolbox.cpp that shows only the current tool's panel @@ -1292,27 +1292,27 @@ void SPDesktopWidget::layoutWidgets() } if (!prefs->getBool(pref_root + "toolbox/state", true)) { - gtk_widget_hide_all (dtw->tool_toolbox); + gtk_widget_hide (dtw->tool_toolbox); } else { gtk_widget_show_all (dtw->tool_toolbox); } if (!prefs->getBool(pref_root + "statusbar/state", true)) { - gtk_widget_hide_all (dtw->statusbar); + gtk_widget_hide (dtw->statusbar); } else { gtk_widget_show_all (dtw->statusbar); } if (!prefs->getBool(pref_root + "panels/state", true)) { - gtk_widget_hide_all( GTK_WIDGET(dtw->panels->gobj()) ); + gtk_widget_hide ( GTK_WIDGET(dtw->panels->gobj()) ); } else { gtk_widget_show_all( GTK_WIDGET(dtw->panels->gobj()) ); } if (!prefs->getBool(pref_root + "scrollbars/state", true)) { - gtk_widget_hide_all (dtw->hscrollbar); - gtk_widget_hide_all (dtw->vscrollbar_box); - gtk_widget_hide_all( dtw->cms_adjust ); + gtk_widget_hide (dtw->hscrollbar); + gtk_widget_hide (dtw->vscrollbar_box); + gtk_widget_hide ( dtw->cms_adjust ); } else { gtk_widget_show_all (dtw->hscrollbar); gtk_widget_show_all (dtw->vscrollbar_box); @@ -1320,8 +1320,8 @@ void SPDesktopWidget::layoutWidgets() } if (!prefs->getBool(pref_root + "rulers/state", true)) { - gtk_widget_hide_all (dtw->hruler); - gtk_widget_hide_all (dtw->vruler); + gtk_widget_hide (dtw->hruler); + gtk_widget_hide (dtw->vruler); } else { gtk_widget_show_all (dtw->hruler); gtk_widget_show_all (dtw->vruler); @@ -1794,8 +1794,8 @@ sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (gtk_widget_get_visible (dtw->hruler)) { - gtk_widget_hide_all (dtw->hruler); - gtk_widget_hide_all (dtw->vruler); + gtk_widget_hide (dtw->hruler); + gtk_widget_hide (dtw->vruler); prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", false); } else { gtk_widget_show_all (dtw->hruler); @@ -1809,9 +1809,9 @@ sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (gtk_widget_get_visible (dtw->hscrollbar)) { - gtk_widget_hide_all (dtw->hscrollbar); - gtk_widget_hide_all (dtw->vscrollbar_box); - gtk_widget_hide_all( dtw->cms_adjust ); + gtk_widget_hide (dtw->hscrollbar); + gtk_widget_hide (dtw->vscrollbar_box); + gtk_widget_hide ( dtw->cms_adjust ); prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", false); } else { gtk_widget_show_all (dtw->hscrollbar); @@ -1839,7 +1839,7 @@ sp_spw_toggle_menubar (SPDesktopWidget *dtw, bool is_fullscreen) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (gtk_widget_get_visible (dtw->menubar)) { - gtk_widget_hide_all (dtw->menubar); + gtk_widget_hide (dtw->menubar); prefs->setBool(is_fullscreen ? "/fullscreen/menu/state" : "/window/menu/state", false); } else { gtk_widget_show_all (dtw->menubar); -- cgit v1.2.3 From 4e747d93764079dec0ac17d21a3e31593eebfd59 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 01:59:02 +0000 Subject: Replace deprecated GtkToolbar API (bzr r10768) --- src/dialogs/xml-tree.cpp | 250 +++++++++++++++++++++++++++++++---------------- 1 file changed, 168 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index 8b4462c59..5e0766ded 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -190,7 +190,7 @@ void sp_xml_tree_dialog() if (dlg == NULL) { // very long block - GtkWidget *box, *sw, *paned, *toolbar, *button; + GtkWidget *box, *sw, *paned, *toolbar; GtkWidget *text_container, *attr_container, *attr_subpaned_container, *box2; GtkWidget *set_attr; @@ -280,148 +280,222 @@ void sp_xml_tree_dialog() gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), - NULL, - _("New element node"), - NULL, - sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON("xml-element-new") ), - G_CALLBACK(cmd_new_element_node), - NULL); + GtkToolItem *xml_element_new_button = gtk_tool_button_new ( + sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, + INKSCAPE_ICON("xml-element-new")), + NULL); + + g_signal_connect (G_OBJECT(xml_element_new_button), + "clicked", + G_CALLBACK(cmd_new_element_node), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET(xml_element_new_button), + _("New element node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), xml_element_new_button, -1); g_signal_connect_object (G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_element), - button, + xml_element_new_button, (GConnectFlags)0); g_signal_connect_object (G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + xml_element_new_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(xml_element_new_button), FALSE); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), - NULL, _("New text node"), NULL, - sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON("xml-text-new") ), - G_CALLBACK(cmd_new_text_node), - NULL); + GtkToolItem *xml_text_new_button = gtk_tool_button_new ( + sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, + INKSCAPE_ICON("xml-text-new")), + NULL); + + g_signal_connect (G_OBJECT(xml_text_new_button), + "clicked", + G_CALLBACK(cmd_new_text_node), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET(xml_text_new_button), + _("New text node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), xml_text_new_button, -1); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_element), - button, + xml_text_new_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + xml_text_new_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(xml_text_new_button), FALSE); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), - NULL, _("Duplicate node"), NULL, - sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON("xml-node-duplicate") ), - G_CALLBACK(cmd_duplicate_node), - NULL); + GtkToolItem *xml_node_duplicate_button = gtk_tool_button_new ( + sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, + INKSCAPE_ICON("xml-node-duplicate")), + NULL); + + g_signal_connect (G_OBJECT(xml_node_duplicate_button), + "clicked", + G_CALLBACK(cmd_duplicate_node), + NULL); - g_signal_connect_object(G_OBJECT(tree), + gtk_widget_set_tooltip_text (GTK_WIDGET(xml_node_duplicate_button), + _("Duplicate node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), xml_node_duplicate_button, -1); + + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_mutable), - button, + xml_node_duplicate_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + xml_node_duplicate_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(xml_node_duplicate_button), FALSE); + + GtkToolItem *separator = gtk_separator_tool_item_new (); + gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM(separator), FALSE); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), separator, -1); - gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); + GtkToolItem *xml_node_delete_button = gtk_tool_button_new ( + sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, + INKSCAPE_ICON ("xml-node-delete")), + NULL); + + g_signal_connect (G_OBJECT(xml_node_delete_button), + "clicked", + G_CALLBACK(cmd_delete_node), + NULL); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), - NULL, Q_("nodeAsInXMLdialogTooltip|Delete node"), NULL, - sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON("xml-node-delete") ), - G_CALLBACK(cmd_delete_node), NULL ); + gtk_widget_set_tooltip_text (GTK_WIDGET(xml_node_delete_button), + Q_("nodeAsInXMLdialogTooltip|Delete node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), xml_node_delete_button, -1); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_mutable), - button, + xml_node_delete_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + xml_node_delete_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(xml_node_delete_button), FALSE); + + GtkToolItem *separator2 = gtk_separator_tool_item_new (); + gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM(separator2), FALSE); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), separator2, -1); + + GtkToolItem *unindent_node_button = gtk_tool_button_new ( + gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_IN), + "<"); - gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); + g_signal_connect (G_OBJECT(unindent_node_button), + "clicked", + G_CALLBACK(cmd_unindent_node), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET(unindent_node_button), + _("Unindent node")); - button = gtk_toolbar_append_item( GTK_TOOLBAR(toolbar), "<", - _("Unindent node"), NULL, - gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_IN), - G_CALLBACK(cmd_unindent_node), NULL); + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), unindent_node_button, -1); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_has_grandparent), - button, + unindent_node_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + unindent_node_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(unindent_node_button), FALSE); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), ">", - _("Indent node"), NULL, - gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN), - G_CALLBACK(cmd_indent_node), NULL); - g_signal_connect_object(G_OBJECT(tree), "tree_select_row", + GtkToolItem *indent_node_button = gtk_tool_button_new ( + gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_IN), + ">"); + + g_signal_connect (G_OBJECT(indent_node_button), + "clicked", + G_CALLBACK(cmd_indent_node), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET(indent_node_button), + _("Indent node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), indent_node_button, -1); + + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_indentable), - button, + indent_node_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", (GCallback) on_tree_unselect_row_disable, - button, + indent_node_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); - - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "^", - _("Raise node"), NULL, - gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_IN), - G_CALLBACK(cmd_raise_node), NULL); - g_signal_connect_object(G_OBJECT(tree), "tree_select_row", + gtk_widget_set_sensitive(GTK_WIDGET(indent_node_button), FALSE); + + GtkToolItem *raise_node_button = gtk_tool_button_new ( + gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_IN), + "^"); + + g_signal_connect (G_OBJECT(raise_node_button), + "clicked", + G_CALLBACK(cmd_raise_node), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET (raise_node_button), + _("Raise node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), raise_node_button, -1); + + g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_not_first_child), - button, + raise_node_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + raise_node_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(raise_node_button), FALSE); + + GtkToolItem *lower_node_button = gtk_tool_button_new ( + gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN), + "v"); + + g_signal_connect (G_OBJECT(lower_node_button), + "clicked", + G_CALLBACK(cmd_lower_node), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET (lower_node_button), + _("Lower node")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), lower_node_button, -1); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "v", - _("Lower node"), NULL, - gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN), - G_CALLBACK(cmd_lower_node), NULL); g_signal_connect_object(G_OBJECT(tree), "tree_select_row", G_CALLBACK(on_tree_select_row_enable_if_not_last_child), - button, + lower_node_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", G_CALLBACK(on_tree_unselect_row_disable), - button, + lower_node_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(lower_node_button), FALSE); gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, TRUE, 0); @@ -429,7 +503,7 @@ void sp_xml_tree_dialog() gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - gtk_box_pack_start(GTK_BOX(box), sw, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), sw, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(tree)); @@ -456,25 +530,37 @@ void sp_xml_tree_dialog() gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0); - button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), - NULL, _("Delete attribute"), NULL, - sp_icon_new( Inkscape::ICON_SIZE_LARGE_TOOLBAR, - INKSCAPE_ICON("xml-attribute-delete") ), - (GCallback) cmd_delete_attr, NULL); + GtkToolItem* xml_attribute_delete_button = gtk_tool_button_new ( + sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, + INKSCAPE_ICON ("xml-attribute-delete")), + NULL); + + g_signal_connect (G_OBJECT(xml_attribute_delete_button), + "clicked", + G_CALLBACK(cmd_delete_attr), + NULL); + + gtk_widget_set_tooltip_text (GTK_WIDGET(xml_attribute_delete_button), + _("Delete attribute")); + + gtk_toolbar_insert (GTK_TOOLBAR(toolbar), xml_attribute_delete_button, -1); g_signal_connect_object(G_OBJECT(attributes), "select_row", - (GCallback) on_attr_select_row_enable, button, + (GCallback) on_attr_select_row_enable, + xml_attribute_delete_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(attributes), "unselect_row", - (GCallback) on_attr_unselect_row_disable, button, + (GCallback) on_attr_unselect_row_disable, + xml_attribute_delete_button, (GConnectFlags)0); g_signal_connect_object(G_OBJECT(tree), "tree_unselect_row", - (GCallback) on_tree_unselect_row_disable, button, + (GCallback) on_tree_unselect_row_disable, + xml_attribute_delete_button, (GConnectFlags)0); - gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(xml_attribute_delete_button), FALSE); gtk_box_pack_start( GTK_BOX(attr_container), GTK_WIDGET(toolbar), FALSE, TRUE, 0 ); -- cgit v1.2.3 From 3dd57b23ff0008756b2f00285978ea5b0ce4a5b3 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 12:20:27 +0000 Subject: Migrate gradient selector to GtkComboBox (bzr r10769) --- src/widgets/gradient-selector.cpp | 51 ++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index a6e9be581..bece60a08 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -45,8 +45,7 @@ static void sp_gradient_selector_destroy (GtkObject *object); static void sp_gradient_selector_vector_set (SPGradientVectorSelector *gvs, SPGradient *gr, SPGradientSelector *sel); static void sp_gradient_selector_edit_vector_clicked (GtkWidget *w, SPGradientSelector *sel); static void sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel); - -static void sp_gradient_selector_spread_activate (GtkWidget *widget, SPGradientSelector *sel); +static void sp_gradient_selector_spread_changed (GtkComboBox *widget, SPGradientSelector *sel); static GtkVBoxClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; @@ -158,7 +157,22 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) gtk_widget_show(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); - sel->spread = gtk_option_menu_new(); +// The GtkComboBoxText API only appeared in Gtk 2.24 but Inkscape supports +// builds for Gtk >= 2.20. +// Older versions need to use now-deprecated parts of +// the GtkComboBox API instead. +#if GTK_CHECK_VERSION(2,24,0) + sel->spread = gtk_combo_box_text_new (); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (sel->spread), _("none")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (sel->spread), _("reflected")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (sel->spread), _("direct")); +#else + sel->spread = gtk_combo_box_new_text (); + gtk_combo_box_append_text (GTK_COMBO_BOX (sel->spread), _("none")); + gtk_combo_box_append_text (GTK_COMBO_BOX (sel->spread), _("reflected")); + gtk_combo_box_append_text (GTK_COMBO_BOX (sel->spread), _("direct")); +#endif + sel->nonsolid.push_back(sel->spread); gtk_widget_show(sel->spread); gtk_box_pack_end( GTK_BOX(hb), sel->spread, FALSE, FALSE, 0 ); @@ -169,22 +183,8 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) "(spreadMethod=\"repeat\"), or repeat the gradient in alternating opposite " "directions (spreadMethod=\"reflect\")")); - GtkWidget *m = gtk_menu_new(); - GtkWidget *mi = gtk_menu_item_new_with_label(_("none")); - gtk_menu_shell_append(GTK_MENU_SHELL (m), mi); - g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_PAD)); - g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel); - mi = gtk_menu_item_new_with_label (_("reflected")); - g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_REFLECT)); - g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel); - gtk_menu_shell_append(GTK_MENU_SHELL (m), mi); - mi = gtk_menu_item_new_with_label (_("direct")); - g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_REPEAT)); - g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel); - gtk_menu_shell_append(GTK_MENU_SHELL (m), mi); - gtk_widget_show_all (m); - - gtk_option_menu_set_menu( GTK_OPTION_MENU(sel->spread), m ); + g_signal_connect (G_OBJECT (sel->spread), "changed", + G_CALLBACK (sp_gradient_selector_spread_changed), sel); sel->spreadLbl = gtk_label_new( _("Repeat:") ); sel->nonsolid.push_back(sel->spreadLbl); @@ -241,8 +241,7 @@ void SPGradientSelector::setUnits(SPGradientUnits units) void SPGradientSelector::setSpread(SPGradientSpread spread) { gradientSpread = spread; - - gtk_option_menu_set_history(GTK_OPTION_MENU(this->spread), gradientSpread); + gtk_combo_box_set_active (GTK_COMBO_BOX(this->spread), gradientSpread); } SPGradientUnits SPGradientSelector::getUnits() @@ -368,17 +367,13 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s Inkscape::GC::release(repr); } - - static void -sp_gradient_selector_spread_activate (GtkWidget *widget, SPGradientSelector *sel) +sp_gradient_selector_spread_changed (GtkComboBox *widget, SPGradientSelector *sel) { - sel->gradientSpread = (SPGradientSpread)GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "gradientSpread")); - - g_signal_emit (G_OBJECT (sel), signals[CHANGED], 0); + sel->gradientSpread = (SPGradientSpread) gtk_combo_box_get_active (GTK_COMBO_BOX(widget)); + g_signal_emit (G_OBJECT (sel), signals[CHANGED], 0); } - /* Local Variables: mode:c++ -- cgit v1.2.3 From 7814ffa6db59191e19d28b6d35b6aa8ae51dbe62 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 13:29:35 +0000 Subject: Replace deprecated gtk flags (bzr r10770) --- src/widgets/gradient-image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 1aeb43c91..3e5f15499 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -76,7 +76,7 @@ sp_gradient_image_class_init (SPGradientImageClass *klass) static void sp_gradient_image_init (SPGradientImage *image) { - GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET(image), FALSE); image->gradient = NULL; @@ -191,7 +191,7 @@ sp_gradient_image_gradient_modified (SPObject *, guint /*flags*/, SPGradientImag static void sp_gradient_image_update (SPGradientImage *image) { - if (GTK_WIDGET_DRAWABLE (image)) { + if (gtk_widget_is_drawable (GTK_WIDGET(image))) { gtk_widget_queue_draw (GTK_WIDGET (image)); } } -- cgit v1.2.3 From 90f1dcfe3c81dfe33708afcb9acbe17ab9382bac Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 13:53:02 +0000 Subject: Replace deprecated orientation symbols (bzr r10771) --- src/widgets/toolbox.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index afd066b37..a5d05a1e4 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1775,7 +1775,7 @@ static void setupToolboxCommon( GtkWidget *toolbox, GtkPositionType pos = static_cast<GtkPositionType>(GPOINTER_TO_INT(g_object_get_data( G_OBJECT(toolbox), HANDLE_POS_MARK ))); orientation = ((pos == GTK_POS_LEFT) || (pos == GTK_POS_RIGHT)) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; } - gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), orientation); + gtk_orientable_set_orientation (GTK_ORIENTABLE(toolBar), orientation); gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE); g_object_set_data(G_OBJECT(toolBar), "desktop", NULL); @@ -1838,7 +1838,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati #endif // DUMP_DETAILS if (GTK_IS_TOOLBAR(child3)) { GtkToolbar* childBar = GTK_TOOLBAR(child3); - gtk_toolbar_set_orientation(childBar, orientation); + gtk_orientable_set_orientation(GTK_ORIENTABLE(childBar), orientation); } } g_list_free(children2); @@ -1848,7 +1848,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati if (GTK_IS_TOOLBAR(child2)) { GtkToolbar* childBar = GTK_TOOLBAR(child2); - gtk_toolbar_set_orientation(childBar, orientation); + gtk_orientable_set_orientation(GTK_ORIENTABLE(childBar), orientation); if (GTK_IS_HANDLE_BOX(toolbox)) { handleBox = GTK_HANDLE_BOX(toolbox); } @@ -1867,7 +1867,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati } } else if (GTK_IS_TOOLBAR(child)) { GtkToolbar* toolbar = GTK_TOOLBAR(child); - gtk_toolbar_set_orientation( toolbar, orientation ); + gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), orientation ); if (GTK_IS_HANDLE_BOX(toolbox)) { handleBox = GTK_HANDLE_BOX(toolbox); } -- cgit v1.2.3 From 9584665e133abbdbf213c8caa7da668d7afd290c Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 13:55:18 +0000 Subject: Get rid of deprecated gtk_type_is_a (bzr r10772) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 8aa3b2a6d..d00ba38ef 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -172,7 +172,7 @@ sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_na g_return_val_if_fail (parent != NULL, NULL); g_return_val_if_fail (SP_IS_CANVAS_GROUP (parent), NULL); - g_return_val_if_fail (gtk_type_is_a (type, sp_canvas_item_get_type ()), NULL); + g_return_val_if_fail (g_type_is_a (type, sp_canvas_item_get_type ()), NULL); SPCanvasItem *item = SP_CANVAS_ITEM (g_object_new (type, NULL)); -- cgit v1.2.3 From cf6be892c0250b2a21faf3224a54df100bb9c7b5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Wed, 14 Dec 2011 14:00:58 +0000 Subject: Get rid of deprecated gtk_idle* (bzr r10773) --- src/display/sp-canvas.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index d00ba38ef..add69401b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1073,7 +1073,7 @@ static void remove_idle (SPCanvas *canvas) { if (canvas->idle_id) { - gtk_idle_remove (canvas->idle_id); + g_source_remove (canvas->idle_id); canvas->idle_id = 0; } } @@ -2118,7 +2118,8 @@ add_idle (SPCanvas *canvas) if (canvas->idle_id != 0) return; - canvas->idle_id = gtk_idle_add_priority (sp_canvas_update_priority, idle_handler, canvas); + canvas->idle_id = g_idle_add_full (sp_canvas_update_priority, idle_handler, + canvas, NULL); } /** -- cgit v1.2.3 From 75145ce1349a9508b1d3688b215ec334abaefdda Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Fri, 16 Dec 2011 00:39:15 +0100 Subject: - Dropped deprecated sp_window_new - quick and dirty memory leak fix for item properties window (bzr r10766.1.5) --- src/dialogs/item-properties.cpp | 68 +++++++++++++++++-------------------- src/widgets/sp-attribute-widget.cpp | 49 +++++++++++--------------- src/widgets/sp-attribute-widget.h | 11 ++---- 3 files changed, 54 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index ce8d4e362..eec8cce16 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -39,6 +39,7 @@ using Inkscape::DocumentUndo; #define MIN_ONSCREEN_DISTANCE 50 static GtkWidget *dlg = NULL; +static SPAttributeTable* attrTable = NULL; static win_data wd; // impossible original values to make sure they are read from prefs @@ -52,16 +53,18 @@ static void sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw static void sp_item_widget_hidden_toggled (GtkWidget *widget, SPWidget *spw); static void sp_item_widget_label_changed (GtkWidget *widget, SPWidget *spw); -static void -sp_item_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ ) +static void sp_item_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ ) { + if (attrTable) + { + delete attrTable; + } sp_signal_disconnect_by_data (INKSCAPE, dlg); wd.win = dlg = NULL; wd.stop = 0; } -static gboolean -sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/ ) +static gboolean sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/ ) { gtk_window_get_position ((GtkWindow *) dlg, &x, &y); gtk_window_get_size ((GtkWindow *) dlg, &w, &h); @@ -246,8 +249,7 @@ GtkWidget *sp_item_widget_new(void) -static void -sp_item_widget_modify_selection( SPWidget *spw, +static void sp_item_widget_modify_selection( SPWidget *spw, Inkscape::Selection *selection, guint /*flags*/, GtkWidget */*itemw*/ ) @@ -257,8 +259,7 @@ sp_item_widget_modify_selection( SPWidget *spw, -static void -sp_item_widget_change_selection ( SPWidget *spw, +static void sp_item_widget_change_selection ( SPWidget *spw, Inkscape::Selection *selection, GtkWidget */*itemw*/ ) { @@ -352,12 +353,11 @@ static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection w = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "interactivity")); GtkWidget* int_table = GTK_WIDGET(g_object_get_data(G_OBJECT(spw), "interactivity_table")); - if (int_table){ - gtk_container_remove(GTK_CONTAINER(w), int_table); - } + //if (int_table){ + // gtk_container_remove(GTK_CONTAINER(w), int_table); + //} std::vector<Glib::ustring> int_labels; - std::vector<Glib::ustring> int_attributes; int_labels.push_back("onclick"); int_labels.push_back("onmouseover"); int_labels.push_back("onmouseout"); @@ -368,14 +368,15 @@ static void sp_item_widget_setup( SPWidget *spw, Inkscape::Selection *selection int_labels.push_back("onfocusout"); int_labels.push_back("onfocusout"); int_labels.push_back("onload"); -int_attributes=int_labels; - SPAttributeTable* t = new SPAttributeTable (obj, int_labels, int_attributes, GTK_CONTAINER (w)); - int_table = (GtkWidget*) t->gobj(); - gtk_widget_show_all (int_table); - g_object_set_data(G_OBJECT(spw), "interactivity_table", int_table); - -// gtk_container_add (GTK_CONTAINER (w), int_table); - + + if (attrTable) + { + delete(attrTable); + } + attrTable = new SPAttributeTable (obj, int_labels, int_labels, (Gtk::Container*) w); + attrTable->show_all(); + g_object_set_data(G_OBJECT(spw), "interactivity_table", (GtkWidget*) attrTable->gobj()); + //gtk_container_add (GTK_CONTAINER (w), int_table); } g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); @@ -385,8 +386,7 @@ int_attributes=int_labels; -static void -sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) +static void sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) { if (g_object_get_data(G_OBJECT (spw), "blocked")) return; @@ -404,8 +404,7 @@ sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw) g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } -void -sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) +void sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) { if (g_object_get_data(G_OBJECT (spw), "blocked")) return; @@ -423,8 +422,7 @@ sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw) g_object_set_data (G_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } -static void -sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) +static void sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) { if (g_object_get_data(G_OBJECT (spw), "blocked")) return; @@ -502,8 +500,9 @@ void sp_item_dialog(void) gchar title[500]; sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_ITEM), title); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - dlg = sp_window_new (title, TRUE); + + Gtk::Window* window = Inkscape::UI::window_new (title, true); + dlg = (GtkWidget*)window->gobj(); if (x == -1000 || y == -1000) { x = prefs->getInt(prefs_path + "x", -1000); y = prefs->getInt(prefs_path + "y", -1000); @@ -513,9 +512,6 @@ void sp_item_dialog(void) h = prefs->getInt(prefs_path + "h", 0); } -// if (x<0) x=0; -// if (y<0) y=0; - if (w && h) { gtk_window_resize ((GtkWindow *) dlg, w, h); } @@ -525,24 +521,22 @@ void sp_item_dialog(void) gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); } - sp_transientize (dlg); wd.win = dlg; wd.stop = 0; - g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); + g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_item_dialog_destroy), dlg); g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); + g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_item_dialog_delete), dlg); + g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); + g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); // Dialog-specific stuff GtkWidget *itemw = sp_item_widget_new (); gtk_widget_show (itemw); gtk_container_add (GTK_CONTAINER (dlg), itemw); - } gtk_window_present ((GtkWindow *) dlg); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 8cc521449..1943eef86 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -24,16 +24,16 @@ using Inkscape::DocumentUndo; static void sp_attribute_widget_object_modified ( SPObject *object, guint flags, SPAttributeWidget *spaw ); -static void sp_attribute_widget_object_release ( SPObject *object, - SPAttributeWidget *spaw ); +// static void sp_attribute_widget_object_release ( SPObject *object, + // SPAttributeWidget *spaw ); SPAttributeWidget::SPAttributeWidget () : blocked(0), hasobj(0), _attribute(), - modified_connection(), - release_connection() + modified_connection()//, + // release_connection() { src.object = NULL; } @@ -45,7 +45,7 @@ SPAttributeWidget::~SPAttributeWidget () if (src.object) { modified_connection.disconnect(); - release_connection.disconnect(); + // release_connection.disconnect(); src.object = NULL; } } @@ -63,7 +63,7 @@ void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) if (hasobj) { if (src.object) { modified_connection.disconnect(); - release_connection.disconnect(); + // release_connection.disconnect(); src.object = NULL; } } else { @@ -82,7 +82,7 @@ void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) src.object = object; modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), this)); - release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), this)); + // release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_widget_object_release), this)); _attribute = attribute; @@ -98,7 +98,7 @@ void SPAttributeWidget::set_repr(Inkscape::XML::Node *repr, const gchar *attribu if (hasobj) { if (src.object) { modified_connection.disconnect(); - release_connection.disconnect(); + // release_connection.disconnect(); src.object = NULL; } } else { @@ -177,17 +177,16 @@ static void sp_attribute_widget_object_modified ( SPObject */*object*/, } // end of sp_attribute_widget_object_modified() -static void sp_attribute_widget_object_release ( SPObject */*object*/, - SPAttributeWidget * spaw ) -{ - spaw->set_object (NULL, NULL); -} +//static void sp_attribute_widget_object_release ( SPObject */*object*/, +// SPAttributeWidget * spaw ) +//{ +// spaw->set_object (NULL, NULL); +//} /* SPAttributeTable */ static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw); -//static void sp_attribute_table_object_release (SPObject *object, SPAttributeTable *spaw); static void sp_attribute_table_entry_changed (Gtk::Editable *editable, SPAttributeTable *spat); #define XPAD 4 @@ -199,21 +198,19 @@ SPAttributeTable::SPAttributeTable () : table(0), _attributes(), _entries(), - modified_connection()/*, - release_connection()*/ + modified_connection() { g_message("SPAttributeTable"); src.object = NULL; } -SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent) : +SPAttributeTable::SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, Gtk::Container *parent) : blocked(0), hasobj(0), table(0), _attributes(), _entries(), - modified_connection()/*, - release_connection()*/ + modified_connection() { g_message("SPAttributeTable"); src.object = NULL; @@ -268,7 +265,6 @@ g_message("destroy 3"); if (hasobj) { if (src.object) { modified_connection.disconnect(); - //release_connection.disconnect(); src.object = NULL; } } else { @@ -282,10 +278,10 @@ g_message("destroy 4"); void SPAttributeTable::set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, - GtkContainer* parent) + Gtk::Container* parent) { g_message("set_object"); - g_return_if_fail (parent); + // g_return_if_fail (parent); g_return_if_fail (!object || SP_IS_OBJECT (object)); g_return_if_fail (!object || !labels.empty() || !attributes.empty()); g_return_if_fail (labels.size() == attributes.size()); @@ -302,13 +298,12 @@ g_message("2"); src.object = object; modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), this)); - //release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), this)); /* Create table */ g_message("3a"); - table = new Gtk::Table (attributes.size(), 2, false); + table = Gtk::manage(new Gtk::Table (attributes.size(), 2, false)); g_message("3b"); - gtk_container_add (parent,(GtkWidget*)table->gobj()); + gtk_container_add (GTK_CONTAINER ((GtkWidget*) parent),(GtkWidget*)table->gobj());// g_message("3c"); /* Fill rows */ @@ -347,8 +342,6 @@ g_message("4b"); table->show (); blocked = false; } - - //set_sensitive ((src.object != NULL) ); g_message("5"); } @@ -410,8 +403,6 @@ g_message("set_repr"); table->show (); blocked = false; } - - //set_sensitive ((src.repr != NULL)); } diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index aac567987..d108aa827 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -17,8 +17,6 @@ #include <gtk/gtk.h> #include <gtkmm.h> -//#include <gtkmm/entry.h> -//#include <gtkmm/table.h> #include <glib.h> #include <stddef.h> #include <sigc++/connection.h> @@ -57,7 +55,7 @@ private: guint hasobj; Glib::ustring _attribute; sigc::connection modified_connection; - sigc::connection release_connection; + //sigc::connection release_connection; }; @@ -66,9 +64,9 @@ private: class SPAttributeTable : public Gtk::Widget { public: SPAttributeTable (); - SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + SPAttributeTable (SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, Gtk::Container* parent); ~SPAttributeTable (); - void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); + void set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, Gtk::Container* parent); void set_repr(Inkscape::XML::Node *repr, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkContainer* parent); std::vector<Glib::ustring> get_attributes(void) {return _attributes;}; std::vector<Gtk::Widget *> get_entries(void) {return _entries;}; @@ -80,13 +78,10 @@ public: guint hasobj; private: -// GtkVBox vbox; Gtk::Table *table; -// Gtk::Container *_parent; std::vector<Glib::ustring> _attributes; std::vector<Gtk::Widget *> _entries; sigc::connection modified_connection; - //sigc::connection release_connection; void clear(void); }; -- cgit v1.2.3 From 601e06b80fec0d1a7aaf35d86d0d590f6797cb99 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 17 Dec 2011 08:18:50 +0100 Subject: fix compiler warning (bzr r10776) --- src/widgets/sp-attribute-widget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 4b4260127..311d9ba66 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -20,7 +20,7 @@ #include <glib.h> #include <stddef.h> #include <sigc++/connection.h> -#include <vector.h> +//#include <vector.h> namespace Inkscape { namespace XML { -- cgit v1.2.3 From 4ad98494f8d6e48acdf44bbf8bbcdfb4378d5316 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 17 Dec 2011 08:25:34 +0100 Subject: fix compiler warnings (bzr r10777) --- src/widgets/sp-attribute-widget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index eb90df60e..1c7d36b4d 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -277,7 +277,7 @@ void SPAttributeTable::set_object(SPObject *object, // Fill rows _attributes = attributes; - for (gint i = 0; i < (attributes.size()); i++) { + for (guint i = 0; i < (attributes.size()); i++) { Gtk::Label *ll; Gtk::Entry *ee; Gtk::Widget *w; @@ -335,7 +335,7 @@ void SPAttributeTable::set_repr (Inkscape::XML::Node *repr, // Fill rows _attributes = attributes; - for (gint i = 0; i < (attributes.size()); i++) { + for (guint i = 0; i < (attributes.size()); i++) { Gtk::Label *ll; Gtk::Entry *ee; Gtk::Widget *w; @@ -376,7 +376,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, { if (flags && SP_OBJECT_MODIFIED_FLAG) { - gint i; + guint i; std::vector<Glib::ustring> attributes = spat->get_attributes(); std::vector<Gtk::Widget *> entries = spat->get_entries(); Gtk::Entry* e; @@ -404,7 +404,7 @@ static void sp_attribute_table_entry_changed ( Gtk::Editable *editable, { if (!spat->blocked) { - gint i; + guint i; std::vector<Glib::ustring> attributes = spat->get_attributes(); std::vector<Gtk::Widget *> entries = spat->get_entries(); Gtk::Entry *e; -- cgit v1.2.3 From c21a3c75d968aac77597843426ce65d7757bbdb3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 17 Dec 2011 08:33:41 +0100 Subject: Dropped unused SPAttributeWidget (bzr r10778) --- src/widgets/sp-attribute-widget.cpp | 152 ------------------------------------ src/widgets/sp-attribute-widget.h | 29 ------- 2 files changed, 181 deletions(-) (limited to 'src') diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 1c7d36b4d..d2c52e2ae 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -22,158 +22,6 @@ using Inkscape::DocumentUndo; -static void sp_attribute_widget_object_modified ( SPObject *object, - guint flags, - SPAttributeWidget *spaw ); - - -SPAttributeWidget::SPAttributeWidget () : - blocked(0), - hasobj(0), - _attribute(), - modified_connection() -{ - src.object = NULL; -} - -SPAttributeWidget::~SPAttributeWidget () -{ - if (hasobj) - { - if (src.object) - { - modified_connection.disconnect(); - src.object = NULL; - } - } - else - { - if (src.repr) - { - src.repr = Inkscape::GC::release(src.repr); - } - } -} - -void SPAttributeWidget::set_object(SPObject *object, const gchar *attribute) -{ - if (hasobj) { - if (src.object) { - modified_connection.disconnect(); - src.object = NULL; - } - } else { - - if (src.repr) { - src.repr = Inkscape::GC::release(src.repr); - } - } - - hasobj = true; - - if (object) { - const gchar *val; - - blocked = true; - src.object = object; - - modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_widget_object_modified), this)); - - _attribute = attribute; - - val = object->getRepr()->attribute(attribute); - set_text (val ? val : (const gchar *) ""); - blocked = false; - } - gtk_widget_set_sensitive (GTK_WIDGET(this), (src.object != NULL)); -} - -void SPAttributeWidget::set_repr(Inkscape::XML::Node *repr, const gchar *attribute) -{ - if (hasobj) { - if (src.object) { - modified_connection.disconnect(); - src.object = NULL; - } - } else { - - if (src.repr) { - src.repr = Inkscape::GC::release(src.repr); - } - } - - hasobj = false; - - if (repr) { - const gchar *val; - - blocked = true; - src.repr = Inkscape::GC::anchor(repr); - attribute = g_strdup (attribute); - - val = repr->attribute(attribute); - set_text (val ? val : (const gchar *) ""); - blocked = false; - } - gtk_widget_set_sensitive (GTK_WIDGET (this), (src.repr != NULL)); -} - -void SPAttributeWidget::on_changed (void) -{ - if (!blocked) - { - Glib::ustring text1; - const gchar *text; - blocked = true; - text1 = get_text (); - text = text1.c_str(); - if (!*text) - text = NULL; - - if (hasobj && src.object) { - src.object->getRepr()->setAttribute(_attribute.c_str(), text, false); - DocumentUndo::done(src.object->document, SP_VERB_NONE, - _("Set attribute")); - - } else if (src.repr) { - src.repr->setAttribute(_attribute.c_str(), text, false); - /* TODO: Warning! Undo will not be flushed in given case */ - } - blocked = false; - } -} - -static void sp_attribute_widget_object_modified ( SPObject */*object*/, - guint flags, - SPAttributeWidget *spaw ) -{ - - if (flags && SP_OBJECT_MODIFIED_FLAG) { - - const gchar *val; - Glib::ustring text; - Glib::ustring attr = spaw->get_attribute(); - val = spaw->src.object->getRepr()->attribute(attr.c_str()); - text = spaw->get_text(); - - if (val || !text.empty()) { - - if (!val || text.empty() || (text == val)) { - /* We are different */ - spaw->set_blocked(true); - spaw->set_text(val ? val : (const gchar *) ""); - spaw->set_blocked(false); - } // end of if() - - } // end of if() - - } //end of if() - -} // end of sp_attribute_widget_object_modified() - - - -/* SPAttributeTable */ static void sp_attribute_table_object_modified (SPObject *object, guint flags, SPAttributeTable *spaw); static void sp_attribute_table_entry_changed (Gtk::Editable *editable, SPAttributeTable *spat); diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index 311d9ba66..a03b9b193 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -20,7 +20,6 @@ #include <glib.h> #include <stddef.h> #include <sigc++/connection.h> -//#include <vector.h> namespace Inkscape { namespace XML { @@ -32,34 +31,6 @@ struct SPAttributeTable; struct SPAttributeTableClass; class SPObject; -class SPAttributeWidget : public Gtk::Entry { -//NOTE: SPAttributeWidget does not seem to be used nowhere in Inkscape, conversion to c++ not tested -public: - SPAttributeWidget (); - ~SPAttributeWidget (); - void set_object(SPObject *object, const gchar *attribute); - void set_repr(Inkscape::XML::Node *repr, const gchar *attribute); - Glib::ustring get_attribute(void) {return _attribute;}; - void set_blocked(guint b) {blocked = b;}; - - union { - SPObject *object; - Inkscape::XML::Node *repr; - } src; - -protected: - void on_changed (void); - -private: - guint blocked; - guint hasobj; - Glib::ustring _attribute; - sigc::connection modified_connection; -}; - - -/* SPAttributeTable */ - class SPAttributeTable : public Gtk::Widget { public: SPAttributeTable (); -- cgit v1.2.3 From c9d06adc5f8252eb3d2a90570d65afd0fd4c891b Mon Sep 17 00:00:00 2001 From: Kris De Gussem <kris.degussem@gmail.com> Date: Sat, 17 Dec 2011 21:43:37 +0100 Subject: some static code analysis stuff (cppcheck warnings) (bzr r10779) --- src/display/canvas-axonomgrid.cpp | 2 +- src/display/gnome-canvas-acetate.cpp | 4 ---- src/extension/dxf2svg/blocks.cpp | 5 ----- src/extension/effect.h | 6 +----- src/extension/implementation/script.cpp | 2 +- src/extension/internal/latex-text-renderer.cpp | 4 ++-- 6 files changed, 5 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index b5fa9e10a..bdc323f8d 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -690,7 +690,7 @@ CanvasAxonomGridSnapper::_getSnapLines(Geom::Point const &p) const { inters = Geom::intersection(line_x, line_z); } - catch (Geom::InfiniteSolutions e) + catch (Geom::InfiniteSolutions &e) { // We're probably dealing with parallel lines; this is useless! return s; diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index 544efe61f..d6ebfa175 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -67,13 +67,9 @@ static void sp_canvas_acetate_init (SPCanvasAcetate */*acetate*/) static void sp_canvas_acetate_destroy (GtkObject *object) { - SPCanvasAcetate *acetate; - g_return_if_fail (object != NULL); g_return_if_fail (GNOME_IS_CANVAS_ACETATE (object)); - acetate = SP_CANVAS_ACETATE (object); - if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } diff --git a/src/extension/dxf2svg/blocks.cpp b/src/extension/dxf2svg/blocks.cpp index 75f348bde..36f2b9e7e 100644 --- a/src/extension/dxf2svg/blocks.cpp +++ b/src/extension/dxf2svg/blocks.cpp @@ -39,13 +39,8 @@ void block::block_info( std::vector< dxfpair > info){ } - - - - blocks::blocks(std::vector< std::vector< dxfpair > > sections){ // Read the main information about the entities section and then put it in the enetites class - int value; char string[10000]; std::vector< dxfpair > single_line; std::vector< std::vector< dxfpair > > ents; diff --git a/src/extension/effect.h b/src/extension/effect.h index 61a826ad4..83b5cc036 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -24,11 +24,7 @@ struct SPDocument; namespace Inkscape { -namespace UI { -namespace View { -typedef View View; -}; -}; + namespace Extension { diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 08624aff0..0a0282284 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -971,7 +971,7 @@ int Script::execute (const std::list<std::string> &in_command, NULL, // STDIN &stdout_pipe, // STDOUT &stderr_pipe); // STDERR - } catch (Glib::Error e) { + } catch (Glib::Error &e) { printf("Can't Spawn!!! spawn returns: %s\n", e.what().data()); return 0; } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 6244512a4..0134ea895 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -266,7 +266,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) SPText *textobj = SP_TEXT (item); SPStyle *style = item->style; - gchar *strtext = sp_te_get_string_multiline(item); + /*gchar *strtext = sp_te_get_string_multiline(item); if (!strtext) { return; } @@ -274,7 +274,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) gchar ** splitstr = g_strsplit(strtext, "\n", -1); gchar *str = g_strjoinv("\\\\ ", splitstr); g_free(strtext); - g_strfreev(splitstr); + g_strfreev(splitstr);*/ // get position and alignment // Align vertically on the baseline of the font (retreived from the anchor point) -- cgit v1.2.3 From 8f1c271f1e1d226061e9fe63faa40cefdd1dcd81 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop <mail@diedenrezi.nl> Date: Sun, 18 Dec 2011 13:45:52 +0100 Subject: Refactor snap-preferences a bit more (bzr r10780) --- src/line-snapper.cpp | 4 +- src/object-snapper.cpp | 8 +-- src/seltrans.cpp | 8 ++- src/snap-enums.h | 2 +- src/snap-preferences.cpp | 160 ++++++++++++++++++++++++----------------------- src/snap-preferences.h | 28 ++------- src/snap.cpp | 2 +- src/sp-namedview.cpp | 6 +- src/widgets/toolbox.cpp | 12 ++-- 9 files changed, 108 insertions(+), 122 deletions(-) (limited to 'src') diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 6a50e8485..3fb503354 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -26,7 +26,7 @@ void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, std::vector<SPItem const *> const */*it*/, std::vector<Inkscape::SnapCandidatePoint> */*unselected_nodes*/) const { - if (!(_snap_enabled && _snapmanager->snapprefs.getSnapFrom(p.getSourceType())) ) { + if (!(_snap_enabled && _snapmanager->snapprefs.isSourceSnappable(p.getSourceType())) ) { return; } @@ -67,7 +67,7 @@ void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, std::vector<SnapCandidatePoint> */*unselected_nodes*/) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false) { return; } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index e7d9b774d..b1c118e92 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -130,7 +130,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, // We'll only need to obtain the visual bounding box if the user preferences tell // us to, AND if we are snapping to the bounding box itself. If we're snapping to // paths only, then we can just as well use the geometric bounding box (which is faster) - SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.getSnapModeBBox()) ? + SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; if (clip_or_mask) { // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to @@ -368,7 +368,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } // Consider the page border for snapping - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_BORDER) && _snapmanager->snapprefs.getSnapModeAny()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_BORDER) && _snapmanager->snapprefs.isAnyCategorySnappable()) { Geom::PathVector *border_path = _getBorderPathv(); if (border_path != NULL) { _paths_to_snap_to->push_back(SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); @@ -687,7 +687,7 @@ void Inkscape::ObjectSnapper::freeSnap(IntermSnapResults &isr, std::vector<SPItem const *> const *it, std::vector<SnapCandidatePoint> *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } @@ -728,7 +728,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( IntermSnapResults &isr, std::vector<SPItem const *> const *it, std::vector<SnapCandidatePoint> *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index cb8270bf2..9439ed0ac 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -321,7 +321,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s _bbox_points.clear(); // Collect the bounding box's corners and midpoints for each selected item - if (m.snapprefs.getSnapModeBBox()) { + if (m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) { bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER); bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT); bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); @@ -1603,11 +1603,13 @@ void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p) { SnapManager const &m = _desktop->namedview->snap_manager; - if (!(m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers() || m.snapprefs.getSnapModeDatums())) { + // If we're not going to snap nodes, then we might just as well get rid of their snappoints right away + if (!(m.snapprefs.isTargetSnappable(SNAPTARGET_NODE_CATEGORY, SNAPTARGET_OTHERS_CATEGORY) || m.snapprefs.isAnyDatumSnappable())) { _snap_points.clear(); } - if (!m.snapprefs.getSnapModeBBox()) { + // If we're not going to snap bounding boxes, then we might just as well get rid of their snappoints right away + if (!m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) { _bbox_points.clear(); } diff --git a/src/snap-enums.h b/src/snap-enums.h index 15d35092c..df1324001 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -4,7 +4,7 @@ * Authors: * Diederik van Lierop <mail@diedenrezi.nl> * - * Copyright (C) 2010 Authors + * Copyright (C) 2010 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 50bb8ef2c..f3df788c9 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -24,100 +24,39 @@ Inkscape::SnapPreferences::SnapPreferences() : g_assert((SNAPTARGET_DATUMS_CATEGORY != 0) && !(SNAPTARGET_DATUMS_CATEGORY & (SNAPTARGET_DATUMS_CATEGORY - 1))); g_assert((SNAPTARGET_OTHERS_CATEGORY != 0) && !(SNAPTARGET_OTHERS_CATEGORY & (SNAPTARGET_OTHERS_CATEGORY - 1))); - setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_DATUMS_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab - for (int n = 0; n < Inkscape::SNAPTARGET_MAX_ENUM_VALUE; n++) { + for (int n = 0; n < SNAPTARGET_MAX_ENUM_VALUE; n++) { _active_snap_targets[n] = -1; } } -/* - * The snappers have too many parameters to adjust individually. Therefore only - * three snapping modes are presented to the user: snapping bounding box corners (to - * other bounding boxes, grids or guides), and/or snapping nodes (to other nodes, - * paths, grids or guides), and or snapping to/from others (e.g. grids, guide, text, etc) - * To select either of these three modes (or all), use the - * methods defined below: setSnapModeBBox(), setSnapModeNode(), or setSnapModeOthers() - * - * */ - - -void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_BBOX_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_BBOX_CATEGORY); - } - setTargetSnappable(SNAPTARGET_BBOX_CATEGORY, enabled); -} - -bool Inkscape::SnapPreferences::getSnapModeBBox() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_BBOX_CATEGORY); -} - -void Inkscape::SnapPreferences::setSnapModeNode(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_NODE_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_NODE_CATEGORY); - } - setTargetSnappable(SNAPTARGET_NODE_CATEGORY, enabled); -} - -bool Inkscape::SnapPreferences::getSnapModeNode() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_NODE_CATEGORY); -} - -void Inkscape::SnapPreferences::setSnapModeOthers(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } - setTargetSnappable(SNAPTARGET_OTHERS_CATEGORY, enabled); -} - -bool Inkscape::SnapPreferences::getSnapModeOthers() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); -} - -bool Inkscape::SnapPreferences::getSnapModeDatums() const +bool Inkscape::SnapPreferences::isAnyDatumSnappable() const { - return isTargetSnappable(Inkscape::SNAPTARGET_GUIDE); + return isTargetSnappable(SNAPTARGET_GUIDE, SNAPTARGET_GRID, SNAPTARGET_PAGE_BORDER); } -bool Inkscape::SnapPreferences::getSnapModeAny() const +bool Inkscape::SnapPreferences::isAnyCategorySnappable() const { - return (_snap_from != 0); + return isTargetSnappable(SNAPTARGET_NODE_CATEGORY, SNAPTARGET_BBOX_CATEGORY, SNAPTARGET_OTHERS_CATEGORY) || isTargetSnappable(SNAPTARGET_GUIDE, SNAPTARGET_GRID, SNAPTARGET_PAGE_BORDER); } -void Inkscape::SnapPreferences::setSnapFrom(Inkscape::SnapSourceType t, bool s) +void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const { - if (s) { - _snap_from = SnapSourceType(_snap_from | t); - } else { - _snap_from = SnapSourceType(_snap_from & ~t); + if (target == SNAPTARGET_BBOX_CATEGORY || + target == SNAPTARGET_NODE_CATEGORY || + target == SNAPTARGET_OTHERS_CATEGORY || + target == SNAPTARGET_DATUMS_CATEGORY) { + // These main targets should be handled separately, because otherwise we might call isTargetSnappable() + // for them (to check whether the corresponding group is on) which would lead to an infinite recursive loop + always_on = (target == SNAPTARGET_DATUMS_CATEGORY); + group_on = true; + return; } -} - -bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const -{ - return (_snap_from & t); -} -void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const -{ if (target & SNAPTARGET_BBOX_CATEGORY) { - group_on = getSnapModeBBox(); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets - + group_on = isTargetSnappable(SNAPTARGET_BBOX_CATEGORY); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets } else if (target & SNAPTARGET_NODE_CATEGORY) { - group_on = getSnapModeNode(); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths + group_on = isTargetSnappable(SNAPTARGET_NODE_CATEGORY); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths if (target == SNAPTARGET_RECT_CORNER) { target = SNAPTARGET_NODE_CUSP; } else if (target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { @@ -162,7 +101,7 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType } else if (target & SNAPTARGET_OTHERS_CATEGORY) { // Only if the group with "other" snap sources/targets has been enabled, then we might snap to any of those targets // ... but this doesn't hold for the page border, grids, and guides - group_on = getSnapModeOthers(); + group_on = isTargetSnappable(SNAPTARGET_OTHERS_CATEGORY); switch (target) { // Some snap targets don't have their own toggle. These targets are called "secondary targets". We will re-map // them to their cousin which does have a toggle, and which is called a "primary target" @@ -281,6 +220,69 @@ bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType con return false; } +Inkscape::SnapTargetType Inkscape::SnapPreferences::source2target(Inkscape::SnapSourceType source) const +{ + switch (source) + { + case SNAPSOURCE_UNDEFINED: + return SNAPTARGET_UNDEFINED; + case SNAPSOURCE_BBOX_CATEGORY: + return SNAPTARGET_BBOX_CATEGORY; + case SNAPSOURCE_BBOX_CORNER: + return SNAPTARGET_BBOX_CORNER; + case SNAPSOURCE_BBOX_MIDPOINT: + return SNAPTARGET_BBOX_MIDPOINT; + case SNAPSOURCE_BBOX_EDGE_MIDPOINT: + return SNAPTARGET_BBOX_EDGE_MIDPOINT; + case SNAPSOURCE_NODE_CATEGORY: + return SNAPTARGET_NODE_CATEGORY; + case SNAPSOURCE_NODE_SMOOTH: + return SNAPTARGET_NODE_SMOOTH; + case SNAPSOURCE_NODE_CUSP: + return SNAPTARGET_NODE_CUSP; + case SNAPSOURCE_LINE_MIDPOINT: + return SNAPTARGET_LINE_MIDPOINT; + case SNAPSOURCE_PATH_INTERSECTION: + return SNAPTARGET_PATH_INTERSECTION; + case SNAPSOURCE_RECT_CORNER: + return SNAPTARGET_RECT_CORNER; + case SNAPSOURCE_ELLIPSE_QUADRANT_POINT: + return SNAPTARGET_ELLIPSE_QUADRANT_POINT; + case SNAPSOURCE_DATUMS_CATEGORY: + return SNAPTARGET_DATUMS_CATEGORY; + case SNAPSOURCE_GUIDE: + return SNAPTARGET_GUIDE; + case SNAPSOURCE_GUIDE_ORIGIN: + return SNAPTARGET_GUIDE_ORIGIN; + case SNAPSOURCE_OTHERS_CATEGORY: + return SNAPTARGET_OTHERS_CATEGORY; + case SNAPSOURCE_ROTATION_CENTER: + return SNAPTARGET_ROTATION_CENTER; + case SNAPSOURCE_OBJECT_MIDPOINT: + return SNAPTARGET_OBJECT_MIDPOINT; + case SNAPSOURCE_IMG_CORNER: + return SNAPTARGET_IMG_CORNER; + case SNAPSOURCE_TEXT_ANCHOR: + return SNAPTARGET_TEXT_ANCHOR; + + case SNAPSOURCE_NODE_HANDLE: + case SNAPSOURCE_OTHER_HANDLE: + case SNAPSOURCE_CONVEX_HULL_CORNER: + // For these snapsources there doesn't exist an equivalent snap target + return SNAPTARGET_NODE_CATEGORY; + case SNAPSOURCE_GRID_PITCH: + return SNAPTARGET_GRID; + default: + g_warning("Mapping of snap source to snap target undefined"); + return SNAPTARGET_UNDEFINED; + } +} + +bool Inkscape::SnapPreferences::isSourceSnappable(Inkscape::SnapSourceType const source) const +{ + return isTargetSnappable(source2target(source)); +} + /* Local Variables: diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 0db135f5d..71f6c1247 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -31,14 +31,11 @@ public: bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4, Inkscape::SnapTargetType const target5) const; bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const; - void setSnapModeBBox(bool enabled); - void setSnapModeNode(bool enabled); - void setSnapModeOthers(bool enabled); - bool getSnapModeBBox() const; - bool getSnapModeNode() const; - bool getSnapModeDatums() const; - bool getSnapModeOthers() const; - bool getSnapModeAny() const; + SnapTargetType source2target(SnapSourceType source) const; + bool isSourceSnappable(Inkscape::SnapSourceType const source) const; + + bool isAnyDatumSnappable() const; // Needed because we cannot toggle the datum snap targets as a group + bool isAnyCategorySnappable() const; void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;} bool getSnapEnabledGlobally() const {return _snap_enabled_globally;} @@ -46,19 +43,6 @@ public: void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;} bool getSnapPostponedGlobally() const {return _snap_postponed_globally;} - /** - * Turn on/off snapping of specific point types. - * @param t Point type. - * @param s true to snap to this point type, otherwise false. - */ - void setSnapFrom(Inkscape::SnapSourceType t, bool s); - - /** - * @param t Point type. - * @return true if snapper will snap this type of point, otherwise false. - */ - bool getSnapFrom(Inkscape::SnapSourceType t) const; - bool getStrictSnapping() const {return _strict_snapping;} gdouble getGridTolerance() const {return _grid_tolerance;} @@ -94,8 +78,6 @@ private: bool _snap_enabled_globally; // Toggles ALL snapping bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast - SnapSourceType _snap_from; ///< bitmap of point types that we will snap from - //If enabled, then bbox corners will only snap to bboxes, //and nodes will only snap to nodes and paths. We will not //snap bbox corners to nodes, or nodes to bboxes. diff --git a/src/snap.cpp b/src/snap.cpp index 853268b4b..36d17102d 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1124,7 +1124,7 @@ void SnapManager::displaySnapsource(Inkscape::SnapCandidatePoint const &p) const bool p_is_other = (t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY) || (t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY); g_assert(_desktop != NULL); - if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { + if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY)) || (p_is_a_bbox && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY)))) { _desktop->snapindicator->set_new_snapsource(p); } else { _desktop->snapindicator->remove_snapsource(); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index c7d212d23..ca30ccae2 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -462,15 +462,15 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX: - nv->snap_manager.snapprefs.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE: - nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: - nv->snap_manager.snapprefs.setSnapModeOthers(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index a5d05a1e4..0638e9ca7 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2134,7 +2134,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi dt->toggleSnapGlobal(); break; case SP_ATTR_INKSCAPE_SNAP_BBOX: - v = nv->snap_manager.snapprefs.getSnapModeBBox(); + v = nv->snap_manager.snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY); sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: @@ -2146,7 +2146,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_NODE: - v = nv->snap_manager.snapprefs.getSnapModeNode(); + v = nv->snap_manager.snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY); sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_PATH: @@ -2174,7 +2174,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: - v = nv->snap_manager.snapprefs.getSnapModeOthers(); + v = nv->snap_manager.snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY); sp_repr_set_boolean(repr, "inkscape:snap-others", !v); break; case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: @@ -2509,7 +2509,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev bool const c1 = nv->snap_manager.snapprefs.getSnapEnabledGlobally(); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act1->gobj()), c1); - bool const c2 = nv->snap_manager.snapprefs.getSnapModeBBox(); + bool const c2 = nv->snap_manager.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act2->gobj()), c2); gtk_action_set_sensitive(GTK_ACTION(act2->gobj()), c1); @@ -2522,7 +2522,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act4c->gobj()), c1 && c2); - bool const c3 = nv->snap_manager.snapprefs.getSnapModeNode(); + bool const c3 = nv->snap_manager.snapprefs.isTargetSnappable(SNAPTARGET_NODE_CATEGORY); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3); gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1); @@ -2537,7 +2537,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); - bool const c5 = nv->snap_manager.snapprefs.getSnapModeOthers(); + bool const c5 = nv->snap_manager.snapprefs.isTargetSnappable(SNAPTARGET_OTHERS_CATEGORY); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), c5); gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); -- cgit v1.2.3 From c44b0a03dcba67ce7c94c647340ab9c62e9231ab Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Sun, 18 Dec 2011 17:23:34 +0100 Subject: remove unused code (bzr r10781) --- src/extension/internal/latex-text-renderer.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 0134ea895..4923f6bee 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -266,16 +266,6 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) SPText *textobj = SP_TEXT (item); SPStyle *style = item->style; - /*gchar *strtext = sp_te_get_string_multiline(item); - if (!strtext) { - return; - } - // replace carriage return with double slash - gchar ** splitstr = g_strsplit(strtext, "\n", -1); - gchar *str = g_strjoinv("\\\\ ", splitstr); - g_free(strtext); - g_strfreev(splitstr);*/ - // get position and alignment // Align vertically on the baseline of the font (retreived from the anchor point) // Align horizontally on anchorpoint -- cgit v1.2.3 From 2e8fe5caefaf6303f1906cfefee13c680d8452b4 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Sun, 18 Dec 2011 22:59:47 +0000 Subject: Remove more deprecated GTK macros (bzr r10782) --- src/display/sodipodi-ctrl.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index f4f0c485a..a23cbd745 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -73,15 +73,15 @@ sp_ctrl_class_init (SPCtrlClass *klass) parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass); - gtk_object_add_arg_type ("SPCtrl::shape", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_SHAPE); - gtk_object_add_arg_type ("SPCtrl::mode", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MODE); - gtk_object_add_arg_type ("SPCtrl::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR); - gtk_object_add_arg_type ("SPCtrl::size", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_SIZE); - gtk_object_add_arg_type ("SPCtrl::pixbuf", GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PIXBUF); - gtk_object_add_arg_type ("SPCtrl::filled", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_FILLED); - gtk_object_add_arg_type ("SPCtrl::fill_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_FILL_COLOR); - gtk_object_add_arg_type ("SPCtrl::stroked", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_STROKED); - gtk_object_add_arg_type ("SPCtrl::stroke_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_STROKE_COLOR); + gtk_object_add_arg_type ("SPCtrl::shape", G_TYPE_INT, G_PARAM_READWRITE, ARG_SHAPE); + gtk_object_add_arg_type ("SPCtrl::mode", G_TYPE_INT, G_PARAM_READWRITE, ARG_MODE); + gtk_object_add_arg_type ("SPCtrl::anchor", GTK_TYPE_ANCHOR_TYPE, G_PARAM_READWRITE, ARG_ANCHOR); + gtk_object_add_arg_type ("SPCtrl::size", G_TYPE_DOUBLE, G_PARAM_READWRITE, ARG_SIZE); + gtk_object_add_arg_type ("SPCtrl::pixbuf", G_TYPE_POINTER, G_PARAM_READWRITE, ARG_PIXBUF); + gtk_object_add_arg_type ("SPCtrl::filled", G_TYPE_BOOLEAN, G_PARAM_READWRITE, ARG_FILLED); + gtk_object_add_arg_type ("SPCtrl::fill_color", G_TYPE_INT, G_PARAM_READWRITE, ARG_FILL_COLOR); + gtk_object_add_arg_type ("SPCtrl::stroked", G_TYPE_BOOLEAN, G_PARAM_READWRITE, ARG_STROKED); + gtk_object_add_arg_type ("SPCtrl::stroke_color", G_TYPE_INT, G_PARAM_READWRITE, ARG_STROKE_COLOR); object_class->destroy = sp_ctrl_destroy; object_class->set_arg = sp_ctrl_set_arg; -- cgit v1.2.3 From af07ce24271fc904e432cdf77714f49b8cbc8db8 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" <jon@joncruz.org> Date: Sun, 18 Dec 2011 22:54:08 -0800 Subject: Const correctness fixes that also correct bug #893146. Fixed bugs: - https://launchpad.net/bugs/893146 (bzr r10783) --- src/extension/extension.cpp | 43 +----- src/extension/extension.h | 39 +++++- src/extension/param/bool.h | 7 +- src/extension/param/color.cpp | 6 +- src/extension/param/color.h | 39 ++++-- src/extension/param/enum.cpp | 89 ++++++------ src/extension/param/enum.h | 12 +- src/extension/param/float.cpp | 64 +++++---- src/extension/param/float.h | 19 ++- src/extension/param/int.cpp | 69 +++++---- src/extension/param/int.h | 19 ++- src/extension/param/notebook.cpp | 144 +++++++++---------- src/extension/param/notebook.h | 26 +++- src/extension/param/parameter.cpp | 269 ++++++++++++++++-------------------- src/extension/param/parameter.h | 212 ++++++++++++++++++---------- src/extension/param/radiobutton.cpp | 78 +++++------ src/extension/param/radiobutton.h | 24 +++- src/extension/param/string.cpp | 88 ++++++------ src/extension/param/string.h | 17 ++- 19 files changed, 684 insertions(+), 580 deletions(-) (limited to 'src') diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 72db7438c..f0b266df0 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -44,8 +44,6 @@ namespace Extension { std::vector<const gchar *> Extension::search_path; std::ofstream Extension::error_file; -Parameter * get_param (const gchar * name); - /** \return none \brief Constructs an Extension from a Inkscape::XML::Node @@ -381,26 +379,7 @@ Extension::deactivated (void) return get_state() == STATE_DEACTIVATED; } -/** - \return Parameter structure with a name of 'name' - \brief This function looks through the linked list for a parameter - structure with the name of the passed in name - \param name The name to search for - - This is an inline function that is used by all the get_param and - set_param functions to find a param_t in the linked list with - the passed in name. - - This function can throw a 'param_not_exist' exception if the - name is not found. - - The first thing that this function checks is if the list is NULL. - It could be NULL because there are no parameters for this extension - or because all of them have been checked. If the list - is NULL then the 'param_not_exist' exception is thrown. -*/ -Parameter * -Extension::get_param (const gchar * name) +Parameter *Extension::get_param(gchar const *name) { if (name == NULL) { throw Extension::param_not_exist(); @@ -427,22 +406,14 @@ g_slist_next(list)) { throw Extension::param_not_exist(); } -/** - \return A constant pointer to the string held by the parameters. - \brief Gets a parameter identified by name with the string placed - in value. It isn't duplicated into the value string. - \param name The name of the parameter to get - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter +Parameter const *Extension::get_param(const gchar * name) const +{ + return const_cast<Extension *>(this)->get_param(name); +} - Look up in the parameters list, then execute the function on that - found parameter. -*/ -const gchar * -Extension::get_param_string (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +gchar const *Extension::get_param_string(gchar const *name, SPDocument const *doc, Inkscape::XML::Node const *node) const { - Parameter * param; - param = get_param(name); + Parameter const *param = get_param(name); return param->get_string(doc, node); } diff --git a/src/extension/extension.h b/src/extension/extension.h index 273bc79e4..13cb409a8 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -173,7 +173,28 @@ public: private: void make_param (Inkscape::XML::Node * paramrepr); - Parameter * get_param (const gchar * name); + /** + * This function looks through the linked list for a parameter + * structure with the name of the passed in name. + * + * This is an inline function that is used by all the get_param and + * set_param functions to find a param_t in the linked list with + * the passed in name. + * + * This function can throw a 'param_not_exist' exception if the + * name is not found. + * + * The first thing that this function checks is if the list is NULL. + * It could be NULL because there are no parameters for this extension + * or because all of them have been checked. If the list + * is NULL then the 'param_not_exist' exception is thrown. + * + * @param name The name to search for. + * @return Parameter structure with a name of 'name'. + */ + Parameter *get_param(const gchar * name); + + Parameter const *get_param(const gchar * name) const; public: bool get_param_bool (const gchar * name, @@ -188,9 +209,19 @@ public: const SPDocument * doc = NULL, const Inkscape::XML::Node * node = NULL); - const gchar * get_param_string (const gchar * name, - const SPDocument * doc = NULL, - const Inkscape::XML::Node * node = NULL); + /** + * Gets a parameter identified by name with the string placed in value. + * It isn't duplicated into the value string. Look up in the parameters list, + * then execute the function on that found parameter. + * + * @param name The name of the parameter to get. + * @param doc The document to look in for document specific parameters. + * @param node The node to look in for a specific parameter. + * @return A constant pointer to the string held by the parameters. + */ + gchar const *get_param_string(gchar const *name, + SPDocument const *doc = NULL, + Inkscape::XML::Node const *node = NULL) const; guint32 get_param_color (const gchar * name, const SPDocument * doc = NULL, diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h index 2894e8085..11d06e1c0 100644 --- a/src/extension/param/bool.h +++ b/src/extension/param/bool.h @@ -30,7 +30,7 @@ public: /** * Returns the current state/value. */ - bool get(const SPDocument * doc, const Inkscape::XML::Node * node) const; + bool get(const SPDocument *doc, const Inkscape::XML::Node *node) const; /** * A function to set the state/value. @@ -50,11 +50,14 @@ public: */ Gtk::Widget *get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + /** * Appends 'true' or 'false'. * @todo investigate. Returning a value that can then be appended would probably work better/safer. */ - void string(std::string &string) const; + virtual void string(std::string &string) const; private: /** Internal value. */ diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp index 1e5dee51c..6600d5f2a 100644 --- a/src/extension/param/color.cpp +++ b/src/extension/param/color.cpp @@ -3,6 +3,7 @@ * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * Christopher Brown <audiere@gmail.com> + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -73,16 +74,13 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * defaulthex = paramval.data(); _value = atoi(defaulthex); - - return; } -void ParamColor::string (std::string &string) +void ParamColor::string(std::string &string) const { char str[16]; sprintf(str, "%i", _value); string += str; - return; } Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) diff --git a/src/extension/param/color.h b/src/extension/param/color.h index e6b44fbcb..f46e26286 100644 --- a/src/extension/param/color.h +++ b/src/extension/param/color.h @@ -1,9 +1,10 @@ -#ifndef __INK_EXTENSION_PARAMCOLOR_H__ -#define __INK_EXTENSION_PARAMCOLOR_H__ +#ifndef SEEN_INK_EXTENSION_PARAMCOLOR_H__ +#define SEEN_INK_EXTENSION_PARAMCOLOR_H__ /* * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -21,16 +22,36 @@ private: guint32 _value; public: ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); + virtual ~ParamColor(void); - /** \brief Returns \c _value, with a \i const to protect it. */ - guint32 get( const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/ ) { return _value; } + + /** Returns \c _value, with a \i const to protect it. */ + guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _value; } + guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); + + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + + virtual void string (std::string &string) const; + sigc::signal<void> * _changeSignal; -}; /* class ParamColor */ +}; // class ParamColor -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape -#endif /* __INK_EXTENSION_PARAMCOLOR_H__ */ +#endif // SEEN_INK_EXTENSION_PARAMCOLOR_H__ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index e25559eeb..755cc92ad 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -7,6 +7,7 @@ /* * Author: * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2006-2007 Johan Engelen * @@ -118,8 +119,6 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g if (defaultval != NULL) { _value = g_strdup(defaultval); } - - return; } ParamComboBox::~ParamComboBox (void) @@ -134,21 +133,22 @@ ParamComboBox::~ParamComboBox (void) } -/** \brief A function to set the \c _value - \param in The value to set - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets ONLY the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. - - To copy the data into _value the old memory must be free'd first. - It is important to note that \c g_free handles \c NULL just fine. Then - the passed in value is duplicated using \c g_strdup(). -*/ -const gchar * -ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * + * This function sets ONLY the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * To copy the data into _value the old memory must be free'd first. + * It is important to note that \c g_free handles \c NULL just fine. Then + * the passed in value is duplicated using \c g_strdup(). + * + * @param in The value to set. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { if (in == NULL) { return NULL; /* Can't have NULL string */ @@ -181,22 +181,15 @@ ParamComboBox::changed (void) { } - -/** - \brief A function to get the value of the parameter in string form - \return A string with the 'value' as command line argument -*/ -void -ParamComboBox::string (std::string &string) +void ParamComboBox::string(std::string &string) const { string += _value; - return; } -/** \brief A special category of Gtk::Entry to handle string parameteres */ +/** A special category of Gtk::Entry to handle string parameteres. */ class ParamComboBoxEntry : public Gtk::ComboBoxText { private: ParamComboBox * _pref; @@ -204,10 +197,11 @@ private: Inkscape::XML::Node * _node; sigc::signal<void> * _changeSignal; public: - /** \brief Build a string preference for the given parameter - \param pref Where to get the string from, and where to put it - when it changes. - */ + /** + * Build a string preference for the given parameter. + * @param pref Where to get the string from, and where to put it + * when it changes. + */ ParamComboBoxEntry (ParamComboBox * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::ComboBoxText(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { this->signal_changed().connect(sigc::mem_fun(this, &ParamComboBoxEntry::changed)); @@ -215,11 +209,12 @@ public: void changed (void); }; -/** \brief Respond to the text box changing - - This function responds to the box changing by grabbing the value - from the text box and putting it in the parameter. -*/ +/** + * Respond to the text box changing. + * + * This function responds to the box changing by grabbing the value + * from the text box and putting it in the parameter. + */ void ParamComboBoxEntry::changed (void) { @@ -231,12 +226,11 @@ ParamComboBoxEntry::changed (void) } /** - \brief Creates a combobox widget for an enumeration parameter -*/ -Gtk::Widget * -ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) + * Creates a combobox widget for an enumeration parameter. + */ +Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_gui_hidden) { return NULL; } @@ -270,5 +264,16 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s } -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h index ca008cda5..a598458c5 100644 --- a/src/extension/param/enum.h +++ b/src/extension/param/enum.h @@ -6,8 +6,9 @@ */ /* - * Author: + * Authors: * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2006-2007 Johan Engelen * @@ -40,9 +41,14 @@ public: ParamComboBox(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); virtual ~ParamComboBox(void); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); - const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + + virtual void string(std::string &string) const; + + gchar const *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; } + const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); void changed (void); diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index ea6a70855..2b501a9a4 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -23,7 +24,7 @@ namespace Inkscape { namespace Extension { -/** \brief Use the superclass' allocator and set the \c _value */ +/** Use the superclass' allocator and set the \c _value. */ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, @@ -88,17 +89,18 @@ ParamFloat::ParamFloat (const gchar * name, return; } -/** \brief A function to set the \c _value - \param in The value to set to - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. -*/ -float -ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * @param in The value to set to. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +float ParamFloat::set(float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { _value = in; if (_value > _max) { @@ -116,9 +118,7 @@ ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) return _value; } -/** \brief Return the value as a string */ -void -ParamFloat::string (std::string &string) +void ParamFloat::string(std::string &string) const { char startstring[G_ASCII_DTOSTR_BUF_SIZE]; g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value); @@ -126,15 +126,15 @@ ParamFloat::string (std::string &string) return; } -/** \brief A class to make an adjustment that uses Extension params */ +/** A class to make an adjustment that uses Extension params. */ class ParamFloatAdjustment : public Gtk::Adjustment { - /** The parameter to adjust */ + /** The parameter to adjust. */ ParamFloat * _pref; SPDocument * _doc; Inkscape::XML::Node * _node; sigc::signal<void> * _changeSignal; public: - /** \brief Make the adjustment using an extension and the string + /** Make the adjustment using an extension and the string describing the parameter. */ ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { @@ -146,14 +146,13 @@ public: void val_changed (void); }; /* class ParamFloatAdjustment */ -/** \brief A function to respond to the value_changed signal from the - adjustment. - - This function just grabs the value from the adjustment and writes - it to the parameter. Very simple, but yet beautiful. -*/ -void -ParamFloatAdjustment::val_changed (void) +/** + * A function to respond to the value_changed signal from the adjustment. + * + * This function just grabs the value from the adjustment and writes + * it to the parameter. Very simple, but yet beautiful. + */ +void ParamFloatAdjustment::val_changed(void) { //std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set(this->get_value(), _doc, _node); @@ -164,14 +163,13 @@ ParamFloatAdjustment::val_changed (void) } /** - \brief Creates a Float Adjustment for a float parameter - - Builds a hbox with a label and a float adjustment in it. -*/ -Gtk::Widget * -ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) + * Creates a Float Adjustment for a float parameter. + * + * Builds a hbox with a label and a float adjustment in it. + */ +Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_gui_hidden) { return NULL; } diff --git a/src/extension/param/float.h b/src/extension/param/float.h index a2c19441d..24747b5f1 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -5,6 +5,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -30,16 +31,26 @@ public: Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml, AppearanceMode mode); - /** \brief Returns \c _value */ - float get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } + /** Returns \c _value. */ + float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + float set (float in, SPDocument * doc, Inkscape::XML::Node * node); + float max (void) { return _max; } + float min (void) { return _min; } + float precision (void) { return _precision; } + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); + + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + + virtual void string(std::string &string) const; + private: - /** \brief Internal value. */ + /** Internal value. */ float _value; AppearanceMode _mode; int _indent; diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index 090441c17..cd6815c4d 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -23,7 +24,7 @@ namespace Inkscape { namespace Extension { -/** \brief Use the superclass' allocator and set the \c _value */ +/** Use the superclass' allocator and set the \c _value. */ ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, @@ -77,21 +78,19 @@ ParamInt::ParamInt (const gchar * name, if (_value < _min) { _value = _min; } - - return; } -/** \brief A function to set the \c _value - \param in The value to set to - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. -*/ -int -ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * @param in The value to set to. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +int ParamInt::set(int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { _value = in; if (_value > _max) { @@ -109,48 +108,45 @@ ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) return _value; } -/** \brief A class to make an adjustment that uses Extension params */ +/** A class to make an adjustment that uses Extension params. */ class ParamIntAdjustment : public Gtk::Adjustment { - /** The parameter to adjust */ + /** The parameter to adjust. */ ParamInt * _pref; SPDocument * _doc; Inkscape::XML::Node * _node; sigc::signal<void> * _changeSignal; public: - /** \brief Make the adjustment using an extension and the string - describing the parameter. */ + /** Make the adjustment using an extension and the string + describing the parameter. */ ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); - return; }; void val_changed (void); }; /* class ParamIntAdjustment */ -/** \brief A function to respond to the value_changed signal from the - adjustment. - - This function just grabs the value from the adjustment and writes - it to the parameter. Very simple, but yet beautiful. -*/ -void -ParamIntAdjustment::val_changed (void) +/** + * A function to respond to the value_changed signal from the adjustment. + * + * This function just grabs the value from the adjustment and writes + * it to the parameter. Very simple, but yet beautiful. + */ +void ParamIntAdjustment::val_changed(void) { //std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set((int)this->get_value(), _doc, _node); if (_changeSignal != NULL) { _changeSignal->emit(); } - return; } /** - \brief Creates a Int Adjustment for a int parameter - - Builds a hbox with a label and a int adjustment in it. -*/ + * Creates a Int Adjustment for a int parameter. + * + * Builds a hbox with a label and a int adjustment in it. + */ Gtk::Widget * ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { @@ -183,18 +179,15 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal return dynamic_cast<Gtk::Widget *>(hbox); } -/** \brief Return the value as a string */ -void -ParamInt::string (std::string &string) +void ParamInt::string(std::string &string) const { char startstring[32]; sprintf(startstring, "%d", _value); string += startstring; - return; } -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape /* Local Variables: diff --git a/src/extension/param/int.h b/src/extension/param/int.h index 138368ff3..83fc67be9 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -5,6 +5,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -30,15 +31,25 @@ public: Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml, AppearanceMode mode); - /** \brief Returns \c _value */ - int get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } + + /** Returns \c _value. */ + int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + int set (int in, SPDocument * doc, Inkscape::XML::Node * node); + int max (void) { return _max; } + int min (void) { return _min; } + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); + + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + + virtual void string(std::string &string) const; + private: - /** \brief Internal value. */ + /** Internal value. */ int _value; AppearanceMode _mode; int _indent; diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index 637208b04..80042febc 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -3,8 +3,9 @@ */ /* - * Author: + * Authors: * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2006 Author * @@ -33,15 +34,19 @@ #include "notebook.h" -/** \brief The root directory in the preferences database for extension - related parameters. */ +/** + * The root directory in the preferences database for extension + * related parameters. + */ #define PREF_DIR "extensions" namespace Inkscape { namespace Extension { -// \brief A class to represent the pages of a notebookparameter of an extension +/** + * A class to represent the pages of a notebookparameter of an extension. + */ class ParamNotebookPage : public Parameter { private: GSList * parameters; /**< A table to store the parameters for this page. @@ -85,8 +90,6 @@ ParamNotebookPage::ParamNotebookPage (const gchar * name, const gchar * guitext, child_repr = sp_repr_next(child_repr); } } - - return; } ParamNotebookPage::~ParamNotebookPage (void) @@ -100,16 +103,13 @@ ParamNotebookPage::~ParamNotebookPage (void) g_slist_free(parameters); } -/** \brief Return the value as a string */ -void -ParamNotebookPage::paramString (std::list <std::string> &list) +/** Return the value as a string. */ +void ParamNotebookPage::paramString(std::list <std::string> &list) { for (GSList * plist = parameters; plist != NULL; plist = g_slist_next(plist)) { Parameter * param = reinterpret_cast<Parameter *>(plist->data); param->string(list); } - - return; } @@ -193,16 +193,19 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension: /** - \brief Creates a notebookpage widget for a notebook - - Builds a notebook page (a vbox) and puts parameters on it. -*/ -Gtk::Widget * -ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) + * Creates a notebookpage widget for a notebook. + * + * Builds a notebook page (a vbox) and puts parameters on it. + */ +Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } - if (!_tooltips) _tooltips = new Gtk::Tooltips(); + if (!_tooltips) { + _tooltips = new Gtk::Tooltips(); + } Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox); vbox->set_border_width(5); @@ -266,8 +269,6 @@ ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const g defaultval = paramval.data(); if (defaultval != NULL) _value = g_strdup(defaultval); // allocate space for _value - - return; } ParamNotebook::~ParamNotebook (void) @@ -283,21 +284,22 @@ ParamNotebook::~ParamNotebook (void) } -/** \brief A function to set the \c _value - \param in The number of the page which value must be set - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. - - To copy the data into _value the old memory must be free'd first. - It is important to note that \c g_free handles \c NULL just fine. Then - the passed in value is duplicated using \c g_strdup(). -*/ -const gchar * -ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * To copy the data into _value the old memory must be free'd first. + * It is important to note that \c g_free handles \c NULL just fine. Then + * the passed in value is duplicated using \c g_strdup(). + * + * @param in The number of the page which value must be set. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +const gchar *ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { ParamNotebookPage * page = NULL; int i = 0; @@ -319,13 +321,7 @@ ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /* return _value; } - -/** - \brief A function to get the currentpage and the parameters in a string form - \return A string with the 'value' and all the parameters on all pages as command line arguments -*/ -void -ParamNotebook::string (std::list <std::string> &list) +void ParamNotebook::string(std::list <std::string> &list) const { std::string param_string; param_string += "--"; @@ -341,51 +337,47 @@ ParamNotebook::string (std::list <std::string> &list) ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(pglist->data); page->paramString(list); } - - return; } -/** \brief A special category of Gtk::Notebook to handle notebook parameters */ +/** A special category of Gtk::Notebook to handle notebook parameters. */ class ParamNotebookWdg : public Gtk::Notebook { private: ParamNotebook * _pref; SPDocument * _doc; Inkscape::XML::Node * _node; public: - /** \brief Build a notebookpage preference for the given parameter - \param pref Where to get the string (pagename) from, and where to put it - when it changes. - */ + /** + * Build a notebookpage preference for the given parameter. + * @param pref Where to get the string (pagename) from, and where to put it + * when it changes. + */ ParamNotebookWdg (ParamNotebook * pref, SPDocument * doc, Inkscape::XML::Node * node) : Gtk::Notebook(), _pref(pref), _doc(doc), _node(node), activated(false) { // don't have to set the correct page: this is done in ParamNotebook::get_widget. // hook function this->signal_switch_page().connect(sigc::mem_fun(this, &ParamNotebookWdg::changed_page)); - return; }; void changed_page(GtkNotebookPage *page, guint pagenum); bool activated; }; -/** \brief Respond to the selected page of notebook changing - This function responds to the changing by reporting it to - ParamNotebook. The change is only reported when the notebook - is actually visible. This to exclude 'fake' changes when the - notebookpages are added or removed. -*/ -void -ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/, - guint pagenum) +/** + * Respond to the selected page of notebook changing. + * This function responds to the changing by reporting it to + * ParamNotebook. The change is only reported when the notebook + * is actually visible. This to exclude 'fake' changes when the + * notebookpages are added or removed. + */ +void ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/, + guint pagenum) { if (is_visible()) { _pref->set((int)pagenum, _doc, _node); } - return; } -/** \brief Search the parameter's name in the notebook content */ -Parameter * -ParamNotebook::get_param(const gchar * name) +/** Search the parameter's name in the notebook content. */ +Parameter *ParamNotebook::get_param(const gchar * name) { if (name == NULL) { throw Extension::param_not_exist(); @@ -401,9 +393,8 @@ ParamNotebook::get_param(const gchar * name) return NULL; } -/** \brief Search the parameter's name in the page content */ -Parameter * -ParamNotebookPage::get_param(const gchar * name) +/** Search the parameter's name in the page content. */ +Parameter *ParamNotebookPage::get_param(const gchar * name) { if (name == NULL) { throw Extension::param_not_exist(); @@ -424,14 +415,15 @@ ParamNotebookPage::get_param(const gchar * name) } /** - \brief Creates a Notebook widget for a notebook parameter - - Builds a notebook and puts pages in it. -*/ -Gtk::Widget * -ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) + * Creates a Notebook widget for a notebook parameter. + * + * Builds a notebook and puts pages in it. + */ +Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) return NULL; + if (_gui_hidden) { + return NULL; + } ParamNotebookWdg * nb = Gtk::manage(new ParamNotebookWdg(this, doc, node)); @@ -456,8 +448,8 @@ ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s } -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape /* Local Variables: diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h index 983ad3161..23058f465 100644 --- a/src/extension/param/notebook.h +++ b/src/extension/param/notebook.h @@ -8,6 +8,7 @@ /* * Author: * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2006 Author * @@ -26,12 +27,14 @@ namespace Extension { class Extension; -// \brief A class to represent a notebookparameter of an extension +/** A class to represent a notebookparameter of an extension. */ class ParamNotebook : public Parameter { private: - /** \brief Internal value. This should point to a string that has - been allocated in memory. And should be free'd. - It is the name of the current page. */ + /** + * Internal value. This should point to a string that has + * been allocated in memory. And should be free'd. + * It is the name of the current page. + */ gchar * _value; GSList * pages; /**< A table to store the pages with parameters for this notebook. @@ -41,7 +44,16 @@ public: ParamNotebook(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); virtual ~ParamNotebook(void); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::list <std::string> &list); + + /** + * A function to get the currentpage and the parameters in a string form. + * @return A string with the 'value' and all the parameters on all pages as command line arguments. + */ + virtual void string (std::list <std::string> &list) const; + + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::string &string) const {return Parameter::string(string);} + Parameter * get_param (const gchar * name); @@ -53,8 +65,8 @@ public: -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape #endif /* INK_EXTENSION_PARAMNOTEBOOK_H_SEEN */ diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 106cd76a6..063ec32be 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -1,5 +1,5 @@ /** @file - * @brief Parameters for extensions. + * Parameters for extensions. */ /* Author: * Ted Gould <ted@gould.cx> @@ -42,76 +42,52 @@ namespace Inkscape { namespace Extension { -/** - \return None - \brief This function creates a parameter that can be used later. This - is typically done in the creation of the extension and defined - in the XML file describing the extension (it's private so people - have to use the system) :) - \param in_repr The XML describing the parameter - - This function first grabs all of the data out of the Repr and puts - it into local variables. Actually, these are just pointers, and the - data is not duplicated so we need to be careful with it. If there - isn't a name or a type in the XML, then no parameter is created as - the function just returns. - - From this point on, we're pretty committed as we've allocated an - object and we're starting to fill it. The name is set first, and - is created with a strdup to actually allocate memory for it. Then - there is a case statement (roughly because strcmp requires 'ifs') - based on what type of parameter this is. Depending which type it - is, the value is interpreted differently, but they are relatively - straight forward. In all cases the value is set to the default - value from the XML and the type is set to the interpreted type. -*/ -Parameter * -Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext) +Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext) { - const char * name; - const char * type; - const char * guitext; - const char * desc; - const char * scope_str; - Parameter::_scope_t scope = Parameter::SCOPE_USER; - bool gui_hidden = false; - const char * gui_hide; - const char * gui_tip; - - name = in_repr->attribute("name"); - type = in_repr->attribute("type"); - guitext = in_repr->attribute("gui-text"); - if (guitext == NULL) + const char *name = in_repr->attribute("name"); + const char *type = in_repr->attribute("type"); + + // In this case we just don't have enough information + if (!name || !type) { + return NULL; + } + + const char *guitext = in_repr->attribute("gui-text"); + if (guitext == NULL) { guitext = in_repr->attribute("_gui-text"); - gui_tip = in_repr->attribute("gui-tip"); - if (gui_tip == NULL) + } + const char *gui_tip = in_repr->attribute("gui-tip"); + if (gui_tip == NULL) { gui_tip = in_repr->attribute("_gui-tip"); - desc = in_repr->attribute("gui-description"); - if (desc == NULL) + } + const char *desc = in_repr->attribute("gui-description"); + if (desc == NULL) { desc = in_repr->attribute("_gui-description"); - scope_str = in_repr->attribute("scope"); - gui_hide = in_repr->attribute("gui-hidden"); - if (gui_hide != NULL) { - if (strcmp(gui_hide, "1") == 0 || - strcmp(gui_hide, "true") == 0) { - gui_hidden = true; - } - /* else stays false */ - } - const gchar* appearance = in_repr->attribute("appearance"); - - /* In this case we just don't have enough information */ - if (name == NULL || type == NULL) { - return NULL; } + bool gui_hidden = false; + { + const char *gui_hide = in_repr->attribute("gui-hidden"); + if (gui_hide != NULL) { + if (strcmp(gui_hide, "1") == 0 || + strcmp(gui_hide, "true") == 0) { + gui_hidden = true; + } + /* else stays false */ + } + } + const gchar* appearance = in_repr->attribute("appearance"); - if (scope_str != NULL) { - if (!strcmp(scope_str, "user")) { - scope = Parameter::SCOPE_USER; - } else if (!strcmp(scope_str, "document")) { - scope = Parameter::SCOPE_DOCUMENT; - } else if (!strcmp(scope_str, "node")) { - scope = Parameter::SCOPE_NODE; + Parameter::_scope_t scope = Parameter::SCOPE_USER; + { + const char *scope_str = in_repr->attribute("scope"); + if (scope_str != NULL) { + if (!strcmp(scope_str, "user")) { + scope = Parameter::SCOPE_USER; + } else if (!strcmp(scope_str, "document")) { + scope = Parameter::SCOPE_DOCUMENT; + } else if (!strcmp(scope_str, "node")) { + scope = Parameter::SCOPE_NODE; + } } } @@ -132,10 +108,10 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * } } else if (!strcmp(type, "string")) { param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); - const gchar * max_length = in_repr->attribute("max_length"); + gchar const * max_length = in_repr->attribute("max_length"); if (max_length != NULL) { - ParamString * ps = dynamic_cast<ParamString *>(param); - ps->setMaxLength(atoi(max_length)); + ParamString * ps = dynamic_cast<ParamString *>(param); + ps->setMaxLength(atoi(max_length)); } } else if (!strcmp(type, "description")) { if (appearance && !strcmp(appearance, "header")) { @@ -157,82 +133,74 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } - /* Note: param could equal NULL */ + // Note: param could equal NULL return param; } -/** \brief Wrapper to cast to the object and use it's function. */ -bool -Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node) +bool Parameter::get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const { - ParamBool * boolpntr = dynamic_cast<ParamBool *>(this); - if (boolpntr == NULL) + ParamBool const *boolpntr = dynamic_cast<ParamBool const *>(this); + if (!boolpntr) { throw Extension::param_not_bool_param(); + } return boolpntr->get(doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -int -Parameter::get_int (const SPDocument * doc, const Inkscape::XML::Node * node) +int Parameter::get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const { - ParamInt * intpntr = dynamic_cast<ParamInt *>(this); - if (intpntr == NULL) + ParamInt const *intpntr = dynamic_cast<ParamInt const *>(this); + if (!intpntr) { throw Extension::param_not_int_param(); + } return intpntr->get(doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -float -Parameter::get_float (const SPDocument * doc, const Inkscape::XML::Node * node) +float Parameter::get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const { - ParamFloat * floatpntr = dynamic_cast<ParamFloat *>(this); - if (floatpntr == NULL) + ParamFloat const *floatpntr = dynamic_cast<ParamFloat const *>(this); + if (!floatpntr) { throw Extension::param_not_float_param(); + } return floatpntr->get(doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -const gchar * -Parameter::get_string (const SPDocument * doc, const Inkscape::XML::Node * node) +gchar const *Parameter::get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const { - ParamString * stringpntr = dynamic_cast<ParamString *>(this); - if (stringpntr == NULL) + ParamString const *stringpntr = dynamic_cast<ParamString const *>(this); + if (!stringpntr) { throw Extension::param_not_string_param(); + } return stringpntr->get(doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -const gchar * -Parameter::get_enum (const SPDocument * doc, const Inkscape::XML::Node * node) +gchar const *Parameter::get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const { - ParamComboBox * param = dynamic_cast<ParamComboBox *>(this); - if (param == NULL) + ParamComboBox const *param = dynamic_cast<ParamComboBox const *>(this); + if (!param) { throw Extension::param_not_enum_param(); + } return param->get(doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -gchar const *Parameter::get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const * node) +gchar const *Parameter::get_optiongroup(SPDocument const *doc, Inkscape::XML::Node const * node) const { - ParamRadioButton * param = dynamic_cast<ParamRadioButton *>(this); + ParamRadioButton const *param = dynamic_cast<ParamRadioButton const *>(this); if (!param) { throw Extension::param_not_optiongroup_param(); } return param->get(doc, node); } -guint32 -Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node) +guint32 Parameter::get_color(const SPDocument* doc, Inkscape::XML::Node const *node) const { - ParamColor* param = dynamic_cast<ParamColor *>(this); - if (param == NULL) + ParamColor const *param = dynamic_cast<ParamColor const *>(this); + if (!param) { throw Extension::param_not_color_param(); + } return param->get(doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -bool -Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node) +bool Parameter::set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node) { ParamBool * boolpntr = dynamic_cast<ParamBool *>(this); if (boolpntr == NULL) @@ -240,9 +208,7 @@ Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node) return boolpntr->set(in, doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -int -Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node) +int Parameter::set_int(int in, SPDocument * doc, Inkscape::XML::Node * node) { ParamInt * intpntr = dynamic_cast<ParamInt *>(this); if (intpntr == NULL) @@ -250,7 +216,7 @@ Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node) return intpntr->set(in, doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ +/** Wrapper to cast to the object and use it's function. */ float Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node) { @@ -261,9 +227,9 @@ Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node) return floatpntr->set(in, doc, node); } -/** \brief Wrapper to cast to the object and use it's function. */ -const gchar * -Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node) +/** Wrapper to cast to the object and use it's function. */ +gchar const * +Parameter::set_string (gchar const * in, SPDocument * doc, Inkscape::XML::Node * node) { ParamString * stringpntr = dynamic_cast<ParamString *>(this); if (stringpntr == NULL) @@ -281,7 +247,7 @@ gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, In } -/** \brief Wrapper to cast to the object and use it's function. */ +/** Wrapper to cast to the object and use it's function. */ guint32 Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) { @@ -292,9 +258,15 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) } -/** \brief Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext) : - extension(ext), _name(NULL), _desc(NULL), _scope(scope), _text(NULL), _gui_hidden(gui_hidden), _gui_tip(NULL) +/** Oop, now that we need a parameter, we need it's name. */ +Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, Inkscape::Extension::Extension * ext) : + _desc(0), + _scope(scope), + _text(0), + _gui_hidden(gui_hidden), + _gui_tip(0), + extension(ext), + _name(0) { if (name != NULL) { _name = g_strdup(name); @@ -316,9 +288,15 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d return; } -/** \brief Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter (const gchar * name, const gchar * guitext, Inkscape::Extension::Extension * ext) : - extension(ext), _name(NULL), _desc(NULL), _scope(Parameter::SCOPE_USER), _text(NULL), _gui_hidden(false), _gui_tip(NULL) +/** Oop, now that we need a parameter, we need it's name. */ +Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Extension::Extension * ext) : + _desc(0), + _scope(Parameter::SCOPE_USER), + _text(0), + _gui_hidden(false), + _gui_tip(0), + extension(ext), + _name(0) { if (name != NULL) { _name = g_strdup(name); @@ -332,19 +310,22 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, Inkscape::Exten return; } -/** \brief Just free the allocated name. */ -Parameter::~Parameter (void) +Parameter::~Parameter(void) { g_free(_name); + _name = 0; + g_free(_text); - g_free(_gui_tip); + _text = 0; + + g_free(_gui_tip); + _gui_tip = 0; + g_free(_desc); + _desc = 0; } -/** \brief Build the name to write the parameter from the extension's - ID and the name of this parameter. */ -gchar * -Parameter::pref_name (void) +gchar *Parameter::pref_name(void) const { return g_strdup_printf("%s.%s", extension->get_id(), _name); } @@ -395,49 +376,43 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) return params; } -/** \brief Basically, if there is no widget pass a NULL. */ +/** Basically, if there is no widget pass a NULL. */ Gtk::Widget * Parameter::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { return NULL; } -/** \brief If I'm not sure which it is, just don't return a value. */ -void -Parameter::string (std::string &/*string*/) +/** If I'm not sure which it is, just don't return a value. */ +void Parameter::string(std::string &/*string*/) const { - return; + // TODO investigate clearing the target string. } -void -Parameter::string (std::list <std::string> &list) +void Parameter::string(std::list <std::string> &list) const { std::string value; string(value); - if (value == "") { - return; + if (!value.empty()) { + std::string final; + final += "--"; + final += name(); + final += "="; + final += value; + + list.insert(list.end(), final); } - - std::string final; - final += "--"; - final += name(); - final += "="; - final += value; - - list.insert(list.end(), final); - return; } -/** All the code in Notebook::get_param to get the notebook content. */ -Parameter *Parameter::get_param(const gchar * /*name*/) +Parameter *Parameter::get_param(gchar const * /*name*/) { return NULL; } Glib::ustring const extension_pref_root = "/extensions/"; -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape /* Local Variables: diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index ad07f5306..8d80e6c40 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -1,8 +1,9 @@ /** @file - * @brief Parameters for extensions. + * Parameters for extensions. */ /* Authors: * Ted Gould <ted@gould.cx> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2005-2006 Authors * @@ -27,108 +28,169 @@ class Extension; /** - * @brief The root directory in the preferences database for extension-related parameters + * The root directory in the preferences database for extension-related parameters. * * The directory path has both a leading and a trailing slash, so that extension_pref_root + pref_name works * without having to append a separator. */ extern Glib::ustring const extension_pref_root; -/** \brief A class to represent the parameter of an extension - - This is really a super class that allows them to abstract all - the different types of parameters into some that can be passed - around. There is also a few functions that are used by all the - different parameters. -*/ +/** + * A class to represent the parameter of an extension. + * + * This is really a super class that allows them to abstract all + * the different types of parameters into some that can be passed + * around. There is also a few functions that are used by all the + * different parameters. + */ class Parameter { -private: - /** \brief Which extension is this parameter attached to? */ - Inkscape::Extension::Extension * extension; - /** \brief The name of this parameter. */ - gchar * _name; protected: - /** \brief Description of the parameter. */ - gchar * _desc; - /** \brief List of possible scopes. */ + /** List of possible scopes. */ typedef enum { SCOPE_USER, /**< Parameter value is saved in the user's configuration file. (default) */ SCOPE_DOCUMENT, /**< Parameter value is saved in the document. */ SCOPE_NODE /**< Parameter value is attached to the node. */ } _scope_t; - /** \brief Scope of the parameter. */ + +public: + Parameter(gchar const *name, + gchar const *guitext, + gchar const *desc, + const Parameter::_scope_t scope, + bool gui_hidden, + gchar const *gui_tip, + Inkscape::Extension::Extension * ext); + + Parameter(gchar const *name, + gchar const *guitext, + Inkscape::Extension::Extension * ext); + + virtual ~Parameter(void); + + /** Wrapper to cast to the object and use its function. */ + bool get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const; + + /** Wrapper to cast to the object and use it's function. */ + int get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const; + + /** Wrapper to cast to the object and use it's function. */ + float get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const; + + /** Wrapper to cast to the object and use it's function. */ + gchar const *get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const; + + guint32 get_color(SPDocument const *doc, Inkscape::XML::Node const *node) const; + + /** Wrapper to cast to the object and use it's function. */ + gchar const *get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const; + + /** Wrapper to cast to the object and use it's function. */ + gchar const *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const; + + + /** Wrapper to cast to the object and use it's function. */ + bool set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node); + + /** Wrapper to cast to the object and use it's function. */ + int set_int(int in, SPDocument * doc, Inkscape::XML::Node * node); + + float set_float(float in, SPDocument * doc, Inkscape::XML::Node * node); + + gchar const *set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node); + + gchar const *set_string(gchar const * in, SPDocument * doc, Inkscape::XML::Node * node); + + guint32 set_color(guint32 in, SPDocument * doc, Inkscape::XML::Node * node); + + gchar const * name(void) const {return _name;} + + /** + * This function creates a parameter that can be used later. This + * is typically done in the creation of the extension and defined + * in the XML file describing the extension (it's private so people + * have to use the system) :) + * + * This function first grabs all of the data out of the Repr and puts + * it into local variables. Actually, these are just pointers, and the + * data is not duplicated so we need to be careful with it. If there + * isn't a name or a type in the XML, then no parameter is created as + * the function just returns. + * + * From this point on, we're pretty committed as we've allocated an + * object and we're starting to fill it. The name is set first, and + * is created with a strdup to actually allocate memory for it. Then + * there is a case statement (roughly because strcmp requires 'ifs') + * based on what type of parameter this is. Depending which type it + * is, the value is interpreted differently, but they are relatively + * straight forward. In all cases the value is set to the default + * value from the XML and the type is set to the interpreted type. + * + * @param in_repr The XML describing the parameter. + * @return a pointer to a new Parameter if applicable, null otherwise.. + */ + static Parameter *make(Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext); + + virtual Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); + + gchar const * get_tooltip(void) const { return _desc; } + + /** Indicates if the GUI for this parameter is hidden or not */ + bool get_gui_hidden() const { return _gui_hidden; } + + virtual void string(std::list <std::string> &list) const; + + /** + * Gets the current value of the parameter in a string form. + * @return A string with the 'value'. + */ + virtual void string(std::string &string) const; + + /** All the code in Notebook::get_param to get the notebook content. */ + virtual Parameter *get_param(gchar const *name); + +protected: + /** Description of the parameter. */ + gchar * _desc; + + /** Scope of the parameter. */ _scope_t _scope; - /** \brief Text for the GUI selection of this. */ + + /** Text for the GUI selection of this. */ gchar * _text; - /** \brief Whether the GUI is visible */ + + /** Whether the GUI is visible. */ bool _gui_hidden; - /** \brief A tip for the GUI if there is one */ + + /** A tip for the GUI if there is one. */ gchar * _gui_tip; /* **** funcs **** */ - gchar * pref_name (void); + + /** + * Build the name to write the parameter from the extension's ID and the name of this parameter. + */ + gchar *pref_name(void) const; + Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult); + Inkscape::XML::Node * document_param_node (SPDocument * doc); + Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent); -public: - Parameter (const gchar * name, - const gchar * guitext, - const gchar * desc, - const Parameter::_scope_t scope, - bool gui_hidden, - const gchar * gui_tip, - Inkscape::Extension::Extension * ext); - Parameter (const gchar * name, - const gchar * guitext, - Inkscape::Extension::Extension * ext); - virtual ~Parameter (void); - - bool get_bool (const SPDocument * doc, - const Inkscape::XML::Node * node); - int get_int (const SPDocument * doc, - const Inkscape::XML::Node * node); - float get_float (const SPDocument * doc, - const Inkscape::XML::Node * node); - const gchar * get_string (const SPDocument * doc, - const Inkscape::XML::Node * node); - guint32 get_color (const SPDocument * doc, - const Inkscape::XML::Node * node); - const gchar * get_enum (const SPDocument * doc, - const Inkscape::XML::Node * node); - - gchar const * get_optiongroup( SPDocument const * doc, - Inkscape::XML::Node const * node); - - bool set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node); - int set_int (int in, SPDocument * doc, Inkscape::XML::Node * node); - float set_float (float in, SPDocument * doc, Inkscape::XML::Node * node); - gchar const * set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node); - const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); - guint32 set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); - - const gchar * name (void) {return _name;} - - static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext); - virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - - gchar const * get_tooltip (void) { return _desc; } - - /** \brief Indicates if the GUI for this parameter is hidden or not */ - bool get_gui_hidden () { return _gui_hidden; } - - virtual void string (std::list <std::string> &list); - virtual void string (std::string &string); - - virtual Parameter * get_param (const gchar * name); +private: + /** Which extension is this parameter attached to. */ + Inkscape::Extension::Extension *extension; + + /** The name of this parameter. */ + gchar *_name; }; -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape -#endif /* __INK_EXTENSION_PARAM_H__ */ +#endif // SEEN_INK_EXTENSION_PARAM_H__ /* Local Variables: diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index a805efc7e..a9fcbfd6c 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -35,8 +35,10 @@ #include "radiobutton.h" -/** \brief The root directory in the preferences database for extension - related parameters. */ +/** + * The root directory in the preferences database for extension + * related parameters. + */ #define PREF_DIR "extensions" namespace Inkscape { @@ -136,8 +138,6 @@ ParamRadioButton::ParamRadioButton (const gchar * name, if (defaultval != NULL) { _value = g_strdup(defaultval); // allocate space for _value } - - return; } ParamRadioButton::~ParamRadioButton (void) @@ -152,21 +152,22 @@ ParamRadioButton::~ParamRadioButton (void) } -/** \brief A function to set the \c _value - \param in The value to set - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets ONLY the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. - - To copy the data into _value the old memory must be free'd first. - It is important to note that \c g_free handles \c NULL just fine. Then - the passed in value is duplicated using \c g_strdup(). -*/ -const gchar * -ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * + * This function sets ONLY the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * To copy the data into _value the old memory must be free'd first. + * It is important to note that \c g_free handles \c NULL just fine. Then + * the passed in value is duplicated using \c g_strdup(). + * + * @param in The value to set. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { if (in == NULL) { return NULL; /* Can't have NULL string */ @@ -194,19 +195,12 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No return _value; } - -/** - \brief A function to get the current value of the parameter in a string form - \return A string with the 'value' as command line argument -*/ -void -ParamRadioButton::string (std::string &string) +void ParamRadioButton::string(std::string &string) const { string += _value; - return; } -/** \brief A special radiobutton class to use in ParamRadioButton */ +/** A special radiobutton class to use in ParamRadioButton. */ class ParamRadioButtonWdg : public Gtk::RadioButton { private: ParamRadioButton * _pref; @@ -214,9 +208,10 @@ private: Inkscape::XML::Node * _node; sigc::signal<void> * _changeSignal; public: - /** \brief Build a string preference for the given parameter - \param pref Where to put the radiobutton's string when it is selected. - */ + /** + * Build a string preference for the given parameter. + * @param pref Where to put the radiobutton's string when it is selected. + */ ParamRadioButtonWdg ( Gtk::RadioButtonGroup& group, const Glib::ustring& label, ParamRadioButton * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal ) : Gtk::RadioButton(group, label), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { @@ -233,13 +228,13 @@ public: void changed (void); }; -/** \brief Respond to the selected radiobutton changing - - This function responds to the radiobutton selection changing by grabbing the value - from the text box and putting it in the parameter. -*/ -void -ParamRadioButtonWdg::changed (void) +/** + * Respond to the selected radiobutton changing. + * + * This function responds to the radiobutton selection changing by grabbing the value + * from the text box and putting it in the parameter. + */ +void ParamRadioButtonWdg::changed(void) { if (this->get_active()) { Glib::ustring data = this->get_label(); @@ -275,10 +270,9 @@ protected: }; /** - \brief Creates a combobox widget for an enumeration parameter -*/ -Gtk::Widget * -ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) + * Creates a combobox widget for an enumeration parameter. + */ +Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_gui_hidden) { return NULL; diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h index cf33bb381..957a5b9df 100644 --- a/src/extension/param/radiobutton.h +++ b/src/extension/param/radiobutton.h @@ -6,8 +6,9 @@ */ /* - * Author: + * Authors: * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2006-2007 Johan Engelen * @@ -44,10 +45,15 @@ public: AppearanceMode mode); virtual ~ParamRadioButton(void); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); - const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } - const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + + virtual void string(std::string &string) const; + + const gchar *get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + + const gchar *set(const gchar *in, SPDocument *doc, Inkscape::XML::Node *node); private: /** \brief Internal value. This should point to a string that has @@ -69,3 +75,13 @@ private: #endif /* INK_EXTENSION_PARAMRADIOBUTTON_H_SEEN */ +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 18cc754a6..13b8e326a 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -22,27 +23,29 @@ namespace Inkscape { namespace Extension { -/** \brief Free the allocated data. */ +/** Free the allocated data. */ ParamString::~ParamString(void) { g_free(_value); + _value = 0; } -/** \brief A function to set the \c _value - \param in The value to set to - \param doc A document that should be used to set the value. - \param node The node where the value may be placed - - This function sets the internal value, but it also sets the value - in the preferences structure. To put it in the right place, \c PREF_DIR - and \c pref_name() are used. - - To copy the data into _value the old memory must be free'd first. - It is important to note that \c g_free handles \c NULL just fine. Then - the passed in value is duplicated using \c g_strdup(). -*/ -const gchar * -ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place, \c PREF_DIR + * and \c pref_name() are used. + * + * To copy the data into _value the old memory must be free'd first. + * It is important to note that \c g_free handles \c NULL just fine. Then + * the passed in value is duplicated using \c g_strdup(). + * + * @param in The value to set to. + * @param doc A document that should be used to set the value. + * @param node The node where the value may be placed. + */ +const gchar * ParamString::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { if (in == NULL) { return NULL; /* Can't have NULL string */ @@ -62,18 +65,14 @@ ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * return _value; } -/** \brief Return the value as a string */ -void -ParamString::string (std::string &string) +void ParamString::string(std::string &string) const { - if (_value == NULL) { - return; + if (_value) { + string += _value; } - string += _value; - return; } -/** \brief Initialize the object, to do that, copy the data. */ +/** Initialize the object, to do that, copy the data. */ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL), _indent(0) @@ -101,11 +100,9 @@ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar } _max_length = 0; - - return; } -/** \brief A special type of Gtk::Entry to handle string parameteres */ +/** A special type of Gtk::Entry to handle string parameteres. */ class ParamStringEntry : public Gtk::Entry { private: ParamString * _pref; @@ -113,10 +110,11 @@ private: Inkscape::XML::Node * _node; sigc::signal<void> * _changeSignal; public: - /** \brief Build a string preference for the given parameter - \param pref Where to get the string from, and where to put it - when it changes. - */ + /** + * Build a string preference for the given parameter. + * @param pref Where to get the string from, and where to put it + * when it changes. + */ ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { if (_pref->get(NULL, NULL) != NULL) { @@ -129,31 +127,29 @@ public: }; -/** \brief Respond to the text box changing - - This function responds to the box changing by grabbing the value - from the text box and putting it in the parameter. -*/ -void -ParamStringEntry::changed_text (void) +/** + * Respond to the text box changing. + * + * This function responds to the box changing by grabbing the value + * from the text box and putting it in the parameter. + */ +void ParamStringEntry::changed_text(void) { Glib::ustring data = this->get_text(); _pref->set(data.c_str(), _doc, _node); if (_changeSignal != NULL) { _changeSignal->emit(); } - return; } /** - \brief Creates a text box for the string parameter - - Builds a hbox with a label and a text box in it. -*/ -Gtk::Widget * -ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) + * Creates a text box for the string parameter. + * + * Builds a hbox with a label and a text box in it. + */ +Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_gui_hidden) { return NULL; } diff --git a/src/extension/param/string.h b/src/extension/param/string.h index a1892fe9c..8e7f093f7 100644 --- a/src/extension/param/string.h +++ b/src/extension/param/string.h @@ -5,6 +5,7 @@ * Copyright (C) 2005-2007 Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -28,18 +29,26 @@ private: public: ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); virtual ~ParamString(void); + /** \brief Returns \c _value, with a \i const to protect it. */ - const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } + const gchar *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; } + const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - void string (std::string &string); + + // Explicitly call superclass version to avoid method being hidden. + virtual void string(std::list <std::string> &list) const { return Parameter::string(list); } + + virtual void string(std::string &string) const; + void setMaxLength(int maxLenght) { _max_length = maxLenght; } int getMaxLength(void) { return _max_length; } }; -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Extension +} // namespace Inkscape #endif /* INK_EXTENSION_PARAMSTRING_H_SEEN */ -- cgit v1.2.3 From 2e528b49454741349b56399fa49337ea96ddc6af Mon Sep 17 00:00:00 2001 From: Nicolas Dufour <nicoduf@yahoo.fr> Date: Tue, 20 Dec 2011 06:49:29 +0100 Subject: UI. Patch for wishlist Bug #169623 (Canvas color option) by William Swanson. (bzr r10784) --- src/desktop.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index de6b3cafe..995f35ab6 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1673,17 +1673,16 @@ static void _reconstruction_finish(SPDesktop * desktop) /** * Namedview_modified callback. */ -static void -_namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) +static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) { SPNamedView *nv=SP_NAMEDVIEW(obj); if (flags & SP_OBJECT_MODIFIED_FLAG) { /* Show/hide page background */ - if (nv->pagecolor & 0xff) { + if (nv->pagecolor | (0xff != 0xffffffff)) { sp_canvas_item_show (desktop->table); - ((CtrlRect *) desktop->table)->setColor(0x00000000, true, nv->pagecolor); + ((CtrlRect *) desktop->table)->setColor(0x00000000, true, nv->pagecolor | 0xff); sp_canvas_item_move_to_z (desktop->table, 0); } else { sp_canvas_item_hide (desktop->table); @@ -1722,11 +1721,10 @@ _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (SP_RGBA32_A_U(nv->pagecolor) < 128 || - (SP_RGBA32_R_U(nv->pagecolor) + - SP_RGBA32_G_U(nv->pagecolor) + - SP_RGBA32_B_U(nv->pagecolor)) >= 384) { - // the background color is light or transparent, use black outline + if (SP_RGBA32_R_U(nv->pagecolor) + + SP_RGBA32_G_U(nv->pagecolor) + + SP_RGBA32_B_U(nv->pagecolor) >= 384) { + // the background color is light, use black outline SP_CANVAS_ARENA (desktop->drawing)->drawing.outlinecolor = prefs->getInt("/options/wireframecolors/onlight", 0xff); } else { // use white outline SP_CANVAS_ARENA (desktop->drawing)->drawing.outlinecolor = prefs->getInt("/options/wireframecolors/ondark", 0xffffffff); @@ -1813,3 +1811,4 @@ Geom::Point SPDesktop::dt2doc(Geom::Point const &p) const End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : + -- cgit v1.2.3 From eeb3996524855096fe9b70e0dcb42cf0dd2419b0 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Tue, 20 Dec 2011 23:05:15 +0100 Subject: fix bug in emphasized line drawing for axonometric grid when origin is not zero (bzr r10786) --- src/display/canvas-axonomgrid.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index bdc323f8d..6d453367f 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -476,7 +476,6 @@ CanvasAxonomGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/) if (empspacing == 0) { scaled = true; } - } void @@ -499,7 +498,7 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'. // sc = screencoordinates ( for example "buf->rect.left()" is in screencoordinates ) - // bc = buffer patch coordinates + // bc = buffer patch coordinates (x=0 on left side of page, y=0 on bottom of page) // tl = topleft ; br = bottomright Geom::Point buf_tl_gc; @@ -509,18 +508,15 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) buf_br_gc[Geom::X] = buf->rect.right() - ow[Geom::X]; buf_br_gc[Geom::Y] = buf->rect.bottom() - ow[Geom::Y]; - gdouble x; - gdouble y; - // render the three separate line groups representing the main-axes // x-axis always goes from topleft to bottomright. (0,0) - (1,1) gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ; gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.top(); - gint const xlinestart = round( (xstart_y_sc - buf->rect.left()*tan_angle[X] -ow[Geom::Y]) / lyw ); + gint const xlinestart = round( (xstart_y_sc - buf_tl_gc[Geom::X]*tan_angle[X] - ow[Geom::Y]) / lyw ); gint xlinenum = xlinestart; // lines starting on left side. - for (y = xstart_y_sc; y < buf->rect.bottom(); y += lyw, xlinenum++) { + 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] ); @@ -535,7 +531,7 @@ 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 (x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) { + 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); @@ -552,7 +548,7 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X]; gint const ylinestart = round((ystart_x_sc - ow[Geom::X]) / spacing_ylines); gint ylinenum = ylinestart; - for (x = ystart_x_sc; x < buf->rect.right(); x += spacing_ylines, ylinenum++) { + for (gdouble x = ystart_x_sc; x < buf->rect.right(); x += spacing_ylines, ylinenum++) { gint const x0 = round(x); if (!scaled && (ylinenum % empspacing) != 0) { @@ -565,10 +561,11 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // z-axis always goes from bottomleft to topright. (0,1) - (1,0) gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ; gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.top(); - gint const zlinestart = round( (zstart_y_sc + buf->rect.left()*tan_angle[Z] - ow[Geom::Y]) / lyw ); + gint const zlinestart = round( (zstart_y_sc + buf_tl_gc[Geom::X]*tan_angle[Z] - ow[Geom::Y]) / lyw ); gint zlinenum = zlinestart; // lines starting from left side - for (y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++) { + gdouble next_y = zstart_y_sc; + 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] ); @@ -581,8 +578,8 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } } // draw lines from bottom-up - gdouble const zstart_x_sc = buf->rect.left() + (y - buf->rect.bottom()) / tan_angle[Z] ; - for (x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) { + 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); -- cgit v1.2.3 From 14b6891e5d84dc76829749d888e9dd769c037ebb Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" <jbc.engelen@swissonline.ch> Date: Tue, 20 Dec 2011 23:07:22 +0100 Subject: when resizing page, move the origin of the grids too. This way all objects will stay aligned to the grids. (bzr r10787) --- src/display/canvas-grid.cpp | 20 +++++++++++++++++++- src/display/canvas-grid.h | 1 + src/document.cpp | 1 + src/sp-namedview.cpp | 9 +++++++++ src/sp-namedview.h | 1 + 5 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 8428a277e..734ce2043 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -28,6 +28,7 @@ #include "sp-namedview.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "svg/stringstream.h" #include "util/mathfns.h" #include "xml/node-event-vector.h" @@ -377,6 +378,22 @@ bool CanvasGrid::isEnabled() return snapper->getEnabled(); } +void CanvasGrid::setOrigin(Geom::Point const &origin_px) +{ + Inkscape::SVGOStringStream os_x, os_y; + gdouble val; + + val = origin_px[Geom::X]; + val = sp_pixels_get_units (val, *gridunit); + os_x << val << sp_unit_get_abbreviation(gridunit); + val = origin_px[Geom::Y]; + val = sp_pixels_get_units (val, *gridunit); + os_y << val << sp_unit_get_abbreviation(gridunit); + repr->setAttribute("originx", os_x.str().c_str()); + repr->setAttribute("originy", os_y.str().c_str()); +} + + // ########################################################## // CanvasXYGrid @@ -427,8 +444,9 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/xy/units").data() ); - if (!gridunit) + if (!gridunit) { gridunit = &sp_unit_get_by_id(SP_UNIT_PX); + } origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_x", 0.0), *gridunit); origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_y", 0.0), *gridunit); color = prefs->getInt("/options/grids/xy/color", 0x0000ff20); diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index f7cc3c032..2788316fd 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -86,6 +86,7 @@ public: Gtk::Widget * newWidget(); + void setOrigin(Geom::Point const &origin_px); /**< writes new origin (specified in px units) to SVG */ Geom::Point origin; /**< Origin of the grid */ guint32 color; /**< Color for normal lines */ guint32 empcolor; /**< Color for emphasis lines */ diff --git a/src/document.cpp b/src/document.cpp index 6035ea557..ce8e6d125 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -662,6 +662,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) if(nv) { Geom::Translate tr2(-rect_with_margins.min()); nv->translateGuides(tr2); + nv->translateGrids(tr2); // update the viewport so the drawing appears to stay where it was nv->scrollAllDesktops(-tr2[0], tr2[1], false); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index ca30ccae2..2de38d9f8 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -1116,6 +1116,15 @@ void SPNamedView::translateGuides(Geom::Translate const &tr) { } } +void SPNamedView::translateGrids(Geom::Translate const &tr) { + for (GSList *l = grids; l != NULL; l = l->next) { + Inkscape::CanvasGrid* g = reinterpret_cast<Inkscape::CanvasGrid*>(l->data); + if (g) { + g->setOrigin(g->origin * tr); + } + } +} + void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) { for(GSList *l = views; l; l = l->next) { SPDesktop *desktop = static_cast<SPDesktop *>(l->data); diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 1c9c9e879..8c51ad838 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -84,6 +84,7 @@ struct SPNamedView : public SPObjectGroup { SPMetric getDefaultMetric() const; void translateGuides(Geom::Translate const &translation); + void translateGrids(Geom::Translate const &translation); void scrollAllDesktops(double dx, double dy, bool is_scrolling); void writeNewGrid(SPDocument *document,int gridtype); bool getSnapGlobal() const; -- cgit v1.2.3 From 9b462bfca467c85b72e00beacdee406d0c907e25 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 22 Dec 2011 14:09:29 +0000 Subject: GDL: rebase on upstream commit 19723 (2010-04-18) (bzr r10789) --- src/libgdl/gdl-dock-item-grip.c | 8 ++++---- src/libgdl/gdl-dock-item.c | 14 ++++++++------ src/libgdl/gdl-dock.c | 17 +++++++---------- 3 files changed, 19 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index c5eb6f370..1272b950a 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -491,13 +491,13 @@ gdl_dock_item_grip_size_request (GtkWidget *widget, gtk_widget_size_request (grip->_priv->close_button, &child_requisition); layout_height = MAX (layout_height, child_requisition.height); - if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) { + if (gtk_widget_get_visible (grip->_priv->close_button)) { requisition->width += child_requisition.width; } gtk_widget_size_request (grip->_priv->iconify_button, &child_requisition); layout_height = MAX (layout_height, child_requisition.height); - if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { + if (gtk_widget_get_visible (grip->_priv->iconify_button)) { requisition->width += child_requisition.width; } @@ -547,7 +547,7 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, child_allocation.y = container->border_width; /* Layout Close Button */ - if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) { + if (gtk_widget_get_visible (grip->_priv->close_button)) { if(space_for_buttons) { if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) @@ -566,7 +566,7 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, } /* Layout Iconify Button */ - if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) { + if (gtk_widget_get_visible (grip->_priv->iconify_button)) { if(space_for_buttons) { if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index 22f261b32..d946c0c01 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -896,8 +896,8 @@ gdl_dock_item_map (GtkWidget *widget) gtk_widget_map (item->child); if (item->_priv->grip - && gtk_widget_get_visible (item->_priv->grip) - && !gtk_widget_get_mapped (item->_priv->grip)) + && gtk_widget_get_visible (GTK_WIDGET (item->_priv->grip)) + && !gtk_widget_get_mapped (GTK_WIDGET (item->_priv->grip))) gtk_widget_map (item->_priv->grip); } @@ -954,7 +954,7 @@ gdl_dock_item_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, - gtk_widget_get_state (GTK_WIDGET(item))); + gtk_widget_get_state (GTK_WIDGET (item))); gdk_window_set_back_pixmap (widget->window, NULL, TRUE); if (item->child) @@ -973,7 +973,9 @@ gdl_dock_item_style_set (GtkWidget *widget, g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) { + if (gtk_widget_get_realized (widget) && + gtk_widget_get_has_window (widget)) + { gtk_style_set_background (widget->style, widget->window, widget->state); if (gtk_widget_is_drawable (widget)) @@ -1481,7 +1483,7 @@ gdl_dock_item_dock (GdlDockObject *object, gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent)); /* show automatic object */ - if (gtk_widget_get_visible (GTK_WIDGET (object))) + if (gtk_widget_get_visible (GTK_WIDGET (object))) { gtk_widget_show (GTK_WIDGET (new_parent)); GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW); @@ -1803,7 +1805,7 @@ gdl_dock_item_new_with_pixbuf_icon (const gchar *name, /** * gdl_dock_item_dock_to: * @item: The dock item that will be relocated to the dock position. - * @target: The dock item that will be used as the point of reference. + * @target: (allow-none): The dock item that will be used as the point of reference. * @position: The position to dock #item, relative to #target. * @docking_param: This value is unused, and will be ignored. * diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index 47a4f5b3d..37d17a983 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -551,7 +551,7 @@ gdl_dock_size_request (GtkWidget *widget, border_width = container->border_width; /* make request to root */ - if (dock->root && gtk_widget_get_visible( GTK_WIDGET(dock->root) )) + if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root))) gtk_widget_size_request (GTK_WIDGET (dock->root), requisition); else { requisition->width = 0; @@ -587,9 +587,8 @@ gdl_dock_size_allocate (GtkWidget *widget, allocation->width = MAX (1, allocation->width - 2 * border_width); allocation->height = MAX (1, allocation->height - 2 * border_width); - if (dock->root && gtk_widget_get_visible( GTK_WIDGET(dock->root) )) { + if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root))) gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation); - } } static void @@ -921,16 +920,15 @@ gdl_dock_dock (GdlDockObject *object, /* Realize the item (create its corresponding GdkWindow) when GdlDock has been realized. */ - if ( gtk_widget_get_realized( GTK_WIDGET(dock) )) { + if (gtk_widget_get_realized (GTK_WIDGET (dock))) gtk_widget_realize (widget); - } /* Map the widget if it's visible and the parent is visible and has been mapped. This is done to make sure that the GdkWindow is visible. */ - if (gtk_widget_get_visible( GTK_WIDGET(dock) ) && + if (gtk_widget_get_visible (GTK_WIDGET (dock)) && gtk_widget_get_visible (widget)) { - if (gtk_widget_get_mapped( GTK_WIDGET(dock) )) + if (gtk_widget_get_mapped (GTK_WIDGET (dock))) gtk_widget_map (widget); /* Make the widget resize. */ @@ -1260,11 +1258,10 @@ gdl_dock_add_floating_item (GdlDock *dock, "floaty", y, NULL)); - if (gtk_widget_get_visible( GTK_WIDGET(dock) )) { + if (gtk_widget_get_visible (GTK_WIDGET (dock))) { gtk_widget_show (GTK_WIDGET (new_dock)); - if (gtk_widget_get_mapped( GTK_WIDGET(dock) )) { + if (gtk_widget_get_mapped (GTK_WIDGET (dock))) gtk_widget_map (GTK_WIDGET (new_dock)); - } /* Make the widget resize. */ gtk_widget_queue_resize (GTK_WIDGET (new_dock)); -- cgit v1.2.3 From d261aa85eaae8b94bfca3161b658aef094942a0b Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 22 Dec 2011 14:33:05 +0000 Subject: GDL: rebase on upstream commit F29CB (2010-04-18) (bzr r10790) --- src/libgdl/gdl-dock-object.c | 9 ++++++++- src/libgdl/gdl-dock-object.h | 2 +- src/libgdl/gdl-dock-placeholder.c | 27 ++++++++------------------- 3 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 08ef7ff27..9e5d10b52 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -578,6 +578,13 @@ gdl_dock_object_dock_request (GdlDockObject *object, FALSE); } +/** + * gdl_dock_object_dock: + * @object: + * @requestor: + * @position: + * @other_data: (allow-none): + **/ void gdl_dock_object_dock (GdlDockObject *object, GdlDockObject *requestor, @@ -911,7 +918,7 @@ gdl_dock_object_register_init (void) g_relation_insert (dock_register, "placeholder", (gpointer) GDL_TYPE_DOCK_PLACEHOLDER); } -const gchar * +G_CONST_RETURN gchar * gdl_dock_object_nick_from_type (GType type) { GTuples *tuples; diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h index fe5c9bcc3..d1c27ffbd 100644 --- a/src/libgdl/gdl-dock-object.h +++ b/src/libgdl/gdl-dock-object.h @@ -204,7 +204,7 @@ gboolean gdl_dock_object_child_placement (GdlDockObject *object, GType gdl_dock_param_get_type (void); /* functions for setting/retrieving nick names for serializing GdlDockObject types */ -const gchar *gdl_dock_object_nick_from_type (GType type); +G_CONST_RETURN gchar *gdl_dock_object_nick_from_type (GType type); GType gdl_dock_object_type_from_nick (const gchar *nick); GType gdl_dock_object_set_type_for_nick (const gchar *nick, GType type); diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index 7a86ebe81..7f75e23d0 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -189,15 +189,15 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property ( g_object_class, PROP_FLOAT_X, - g_param_spec_int ("floatx", _("X-Coordinate"), - _("X-Coordinate for dock when floating"), + g_param_spec_int ("floatx", _("X Coordinate"), + _("X coordinate for dock when floating"), -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | GDL_DOCK_PARAM_EXPORT)); g_object_class_install_property ( g_object_class, PROP_FLOAT_Y, - g_param_spec_int ("floaty", _("Y-Coordinate"), - _("Y-Coordinate for dock when floating"), + g_param_spec_int ("floaty", _("Y Coordinate"), + _("Y coordinate for dock when floating"), -1, G_MAXINT, -1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | GDL_DOCK_PARAM_EXPORT)); @@ -221,6 +221,8 @@ gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph) gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE); ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1); + + GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC); } static void @@ -554,22 +556,9 @@ gdl_dock_placeholder_new (const gchar *name, ph = GDL_DOCK_PLACEHOLDER (g_object_new (GDL_TYPE_DOCK_PLACEHOLDER, "name", name, "sticky", sticky, + "next-placement", position, + "host", object, NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC); - - if (object) { - gdl_dock_placeholder_attach (ph, object); - if (position == GDL_DOCK_NONE) - position = GDL_DOCK_CENTER; - g_object_set (G_OBJECT (ph), "next-placement", position, NULL); - if (GDL_IS_DOCK (object)) { - /* the top placement will be consumed by the toplevel - dock, so add a dummy placement */ - g_object_set (G_OBJECT (ph), "next-placement", GDL_DOCK_CENTER, NULL); - } - /* try a recursion */ - do_excursion (ph); - } return GTK_WIDGET (ph); } -- cgit v1.2.3 From d9fadbaae0b55acca8e8fc125951f20954ae3484 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 22 Dec 2011 14:45:14 +0000 Subject: GDL: rebase on upstream commit 19B12 (2010-04-24) (bzr r10791) --- src/libgdl/gdl-dock-object.c | 4 +-- src/libgdl/gdl-switcher.c | 58 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 9e5d10b52..28213fe32 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -128,14 +128,14 @@ gdl_dock_object_class_init (GdlDockObjectClass *klass) g_param_spec_string ("long-name", _("Long name"), _("Human readable name for the dock object"), NULL, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property ( g_object_class, PROP_STOCK_ID, g_param_spec_string ("stock-id", _("Stock Icon"), _("Stock icon for the dock object"), NULL, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property ( g_object_class, PROP_PIXBUF_ICON, diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 65013e390..895e708a5 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -52,7 +52,8 @@ static void gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *tooltips, const gchar *stock_id, const GdkPixbuf *pixbuf_icon, - gint switcher_id); + gint switcher_id, + GtkWidget *page); /* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */ static void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id); static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id); @@ -72,6 +73,7 @@ typedef struct { GtkWidget *icon; GtkWidget *arrow; GtkWidget *hbox; + GtkWidget *page; int id; } Button; @@ -98,9 +100,36 @@ GDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK /* Utility functions. */ +static void +gdl_switcher_long_name_changed (GObject* object, + GParamSpec* spec, + gpointer user_data) +{ + Button* button = user_data; + gchar* label; + + g_object_get (object, "long-name", &label, NULL); + gtk_label_set_text (GTK_LABEL (button->label), label); + g_free (label); +} + +static void +gdl_switcher_stock_id_changed (GObject* object, + GParamSpec* spec, + gpointer user_data) +{ + Button* button = user_data; + gchar* id; + + g_object_get (object, "stock-id", &id, NULL); + gtk_image_set_from_stock (GTK_IMAGE(button->icon), id, GTK_ICON_SIZE_MENU); + g_free (id); +} + + static Button * button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, - GtkWidget *arrow, GtkWidget *hbox, int id) + GtkWidget *arrow, GtkWidget *hbox, int id, GtkWidget *page) { Button *button = g_new (Button, 1); @@ -110,7 +139,13 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, button->arrow = arrow; button->hbox = hbox; button->id = id; + button->page = page; + g_signal_connect (page, "notify::long-name", G_CALLBACK (gdl_switcher_long_name_changed), + button); + g_signal_connect (page, "notify::stock-id", G_CALLBACK (gdl_switcher_stock_id_changed), + button); + g_object_ref (button_widget); g_object_ref (label); g_object_ref (icon); @@ -123,6 +158,13 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, static void button_free (Button *button) { + g_signal_handlers_disconnect_by_func (button->page, + gdl_switcher_long_name_changed, + button); + g_signal_handlers_disconnect_by_func (button->page, + gdl_switcher_stock_id_changed, + button); + g_object_unref (button->button_widget); g_object_unref (button->label); g_object_unref (button->icon); @@ -632,7 +674,7 @@ gdl_switcher_page_added_cb (GtkNotebook *nb, GtkWidget *page, switcher_id = gdl_switcher_get_page_id (page); gdl_switcher_add_button (GDL_SWITCHER (switcher), NULL, NULL, NULL, NULL, - switcher_id); + switcher_id, page); gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id); } @@ -742,7 +784,8 @@ gdl_switcher_new (void) void gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, const gchar *tooltips, const gchar *stock_id, - const GdkPixbuf *pixbuf_icon, gint switcher_id) + const GdkPixbuf *pixbuf_icon, + gint switcher_id, GtkWidget* page) { GtkWidget *event_box; GtkWidget *button_widget; @@ -809,7 +852,7 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, g_slist_append (switcher->priv->buttons, button_new (button_widget, label_widget, icon_widget, - arrow, hbox, switcher_id)); + arrow, hbox, switcher_id, page)); gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher)); gtk_widget_queue_resize (GTK_WIDGET (switcher)); @@ -843,6 +886,7 @@ gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id) /* Select the notebook page associated with this button */ gdl_switcher_select_page (switcher, switcher_id); } + gint gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page, @@ -861,12 +905,14 @@ gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page, gtk_widget_show (tab_widget); } switcher_id = gdl_switcher_get_page_id (page); - gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id); + gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id, page); + ret_position = gtk_notebook_insert_page (GTK_NOTEBOOK (switcher), page, tab_widget, position); g_signal_handlers_unblock_by_func (switcher, gdl_switcher_page_added_cb, switcher); + return ret_position; } -- cgit v1.2.3 From 94ef6db44fc98d35bdbca24776e1e9208afac6c9 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 22 Dec 2011 14:59:53 +0000 Subject: GDL: rebase on upstream commit 3CE71 (2010-04-24) (bzr r10792) --- src/libgdl/gdl-dock-item.c | 73 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index d946c0c01..c21ee4444 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -181,12 +181,15 @@ struct _GdlDockItemPrivate { guint grip_size; GtkWidget *tab_label; + gboolean intern_tab_label; + guint notify_label; + guint notify_stock_id; gint preferred_width; gint preferred_height; GdlDockPlaceholder *ph; - + gint start_x, start_y; }; @@ -491,10 +494,33 @@ gdl_dock_item_instance_init (GdlDockItem *item) item->_priv->preferred_width = item->_priv->preferred_height = -1; item->_priv->tab_label = NULL; + item->_priv->intern_tab_label = FALSE; item->_priv->ph = NULL; } +static void +on_long_name_changed (GObject* item, + GParamSpec* spec, + gpointer user_data) +{ + gchar* long_name; + g_object_get (item, "long-name", &long_name, NULL); + gtk_label_set_label (GTK_LABEL (user_data), long_name); + g_free(long_name); +} + +static void +on_stock_id_changed (GObject* item, + GParamSpec* spec, + gpointer user_data) +{ + gchar* stock_id; + g_object_get (item, "stock_id", &stock_id, NULL); + gtk_image_set_from_stock (GTK_IMAGE (user_data), stock_id, GTK_ICON_SIZE_MENU); + g_free(stock_id); +} + static GObject * gdl_dock_item_constructor (GType type, guint n_construct_properties, @@ -510,6 +536,11 @@ gdl_dock_item_constructor (GType type, NULL); if (g_object) { GdlDockItem *item = GDL_DOCK_ITEM (g_object); + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *icon; + gchar* long_name; + gchar* stock_id; if (GDL_DOCK_ITEM_HAS_GRIP (item)) { item->_priv->grip_shown = TRUE; @@ -520,6 +551,33 @@ gdl_dock_item_constructor (GType type, else { item->_priv->grip_shown = FALSE; } + GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); + + g_object_get (g_object, "long-name", &long_name, "stock-id", &stock_id, NULL); + + hbox = gtk_hbox_new (FALSE, 5); + label = gtk_label_new (long_name); + icon = gtk_image_new (); + if (stock_id) + gtk_image_set_from_stock (GTK_IMAGE (icon), stock_id, + GTK_ICON_SIZE_MENU); + gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + item->_priv->notify_label = + g_signal_connect (item, "notify::long-name", G_CALLBACK (on_long_name_changed), + label); + item->_priv->notify_stock_id = + g_signal_connect (item, "notify::stock-id", G_CALLBACK (on_stock_id_changed), + icon); + + gtk_widget_show_all (hbox); + + gdl_dock_item_set_tablabel (item, hbox); + item->_priv->intern_tab_label = TRUE; + + g_free (long_name); + g_free (stock_id); } return g_object; @@ -1743,8 +1801,7 @@ gdl_dock_item_new (const gchar *name, "long-name", long_name, "behavior", behavior, NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); - gdl_dock_item_set_tablabel (item, gtk_label_new (long_name)); + return GTK_WIDGET (item); } @@ -1774,9 +1831,6 @@ gdl_dock_item_new_with_stock (const gchar *name, "stock-id", stock_id, "behavior", behavior, NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); - gdl_dock_item_set_tablabel (item, gtk_label_new (long_name)); - return GTK_WIDGET (item); } @@ -1918,6 +1972,13 @@ gdl_dock_item_set_tablabel (GdlDockItem *item, { g_return_if_fail (item != NULL); + if (item->_priv->intern_tab_label) + { + item->_priv->intern_tab_label = FALSE; + g_signal_handler_disconnect (item, item->_priv->notify_label); + g_signal_handler_disconnect (item, item->_priv->notify_stock_id); + } + if (item->_priv->tab_label) { /* disconnect and unref the previous tablabel */ if (GDL_IS_DOCK_TABLABEL (item->_priv->tab_label)) { -- cgit v1.2.3 From 351a91afaaadb7c6b9017fd681a9bfe7799d5684 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 22 Dec 2011 15:09:17 +0000 Subject: GDL: rebase on upstream commit 012C4 (2010-05-02) (bzr r10793) --- src/libgdl/gdl-dock-item.c | 4 +++- src/libgdl/gdl-dock-placeholder.c | 3 +-- src/libgdl/gdl-dock.c | 27 ++++++++++++++++----------- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index c21ee4444..d9aa9eff5 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -551,7 +551,6 @@ gdl_dock_item_constructor (GType type, else { item->_priv->grip_shown = FALSE; } - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); g_object_get (g_object, "long-name", &long_name, "stock-id", &stock_id, NULL); @@ -1801,6 +1800,7 @@ gdl_dock_item_new (const gchar *name, "long-name", long_name, "behavior", behavior, NULL)); + GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); return GTK_WIDGET (item); } @@ -1831,6 +1831,8 @@ gdl_dock_item_new_with_stock (const gchar *name, "stock-id", stock_id, "behavior", behavior, NULL)); + GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); + return GTK_WIDGET (item); } diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index 7f75e23d0..a4b84b56f 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -221,8 +221,6 @@ gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph) gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE); ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1); - - GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC); } static void @@ -559,6 +557,7 @@ gdl_dock_placeholder_new (const gchar *name, "next-placement", position, "host", object, NULL)); + GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC); return GTK_WIDGET (ph); } diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index 37d17a983..c82fead9c 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -460,7 +460,6 @@ gdl_dock_set_title (GdlDock *dock) { GdlDockObject *object = GDL_DOCK_OBJECT (dock); gchar *title = NULL; - gboolean free_title = FALSE; if (!dock->_priv->window) return; @@ -470,25 +469,22 @@ gdl_dock_set_title (GdlDock *dock) } else if (object->master) { g_object_get (object->master, "default-title", &title, NULL); - free_title = TRUE; } if (!title && dock->root) { g_object_get (dock->root, "long-name", &title, NULL); - free_title = TRUE; } if (!title) { /* set a default title in the long_name */ dock->_priv->auto_title = TRUE; - free_title = FALSE; - title = object->long_name = g_strdup_printf ( + title = g_strdup_printf ( _("Dock #%d"), GDL_DOCK_MASTER (object->master)->dock_number++); } gtk_window_set_title (GTK_WINDOW (dock->_priv->window), title); - if (free_title) - g_free (title); + + g_free (title); } static void @@ -497,15 +493,24 @@ gdl_dock_notify_cb (GObject *object, gpointer user_data) { GdlDock *dock; + gchar* long_name; (void)pspec; (void)user_data; g_return_if_fail (object != NULL || GDL_IS_DOCK (object)); - - dock = GDL_DOCK (object); - dock->_priv->auto_title = FALSE; - gdl_dock_set_title (dock); + + g_object_get (object, "long-name", &long_name, NULL); + + g_message ("Notify long_name: %s", long_name); + + if (long_name) + { + dock = GDL_DOCK (object); + dock->_priv->auto_title = FALSE; + gdl_dock_set_title (dock); + } + g_free (long_name); } static void -- cgit v1.2.3 From ed9b50d93f24dd949d910f049991d8bfddc6d8d8 Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Thu, 22 Dec 2011 16:14:02 +0000 Subject: GDL: Rebase on upstream commit 871CA (2010-06-26) (bzr r10794) --- src/libgdl/gdl-dock-bar.c | 795 ++++++++++++++++---------------- src/libgdl/gdl-dock-item-button-image.c | 13 +- src/libgdl/gdl-dock-item-grip.c | 162 ++++--- src/libgdl/gdl-dock-item.c | 194 ++++---- src/libgdl/gdl-dock-master.c | 25 +- src/libgdl/gdl-dock-notebook.c | 21 +- src/libgdl/gdl-dock-object.c | 54 ++- src/libgdl/gdl-dock-paned.c | 92 ++-- src/libgdl/gdl-dock-placeholder.c | 23 +- src/libgdl/gdl-dock-tablabel.c | 101 ++-- src/libgdl/gdl-dock.c | 109 ++--- src/libgdl/gdl-switcher.c | 64 ++- src/libgdl/gdl-tools.h | 187 -------- src/libgdl/gdl.h | 1 - 14 files changed, 861 insertions(+), 980 deletions(-) delete mode 100644 src/libgdl/gdl-tools.h (limited to 'src') diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 663378b7f..84a901308 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the GNOME Devtools Libraries. * @@ -27,7 +27,6 @@ #include <stdlib.h> #include <string.h> -#include "gdl-tools.h" #include "gdl-dock.h" #include "gdl-dock-master.h" #include "gdl-dock-bar.h" @@ -42,7 +41,6 @@ enum { /* ----- Private prototypes ----- */ static void gdl_dock_bar_class_init (GdlDockBarClass *klass); -static void gdl_dock_bar_instance_init (GdlDockBar *dockbar); static void gdl_dock_bar_get_property (GObject *object, guint prop_id, @@ -71,7 +69,7 @@ struct _GdlDockBarPrivate { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockBar, gdl_dock_bar, GtkBox, GTK_TYPE_BOX) +G_DEFINE_TYPE (GdlDockBar, gdl_dock_bar, GTK_TYPE_BOX) static void gdl_dock_bar_size_request (GtkWidget *widget, GtkRequisition *requisition ); @@ -124,7 +122,7 @@ gdl_dock_bar_class_init (GdlDockBarClass *klass) } static void -gdl_dock_bar_instance_init (GdlDockBar *dockbar) +gdl_dock_bar_init (GdlDockBar *dockbar) { dockbar->_priv = g_new0 (GdlDockBarPrivate, 1); dockbar->_priv->master = NULL; @@ -209,7 +207,7 @@ gdl_dock_bar_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_bar_parent_class)->destroy (object); } static void @@ -463,464 +461,479 @@ static void gdl_dock_bar_size_allocate (GtkWidget *widget, } static void gdl_dock_bar_size_vrequest (GtkWidget *widget, - GtkRequisition *requisition ) + GtkRequisition *requisition ) { - GtkBox *box; - GtkBoxChild *child; - GtkRequisition child_requisition; - GList *children; - gint nvis_children; - gint height; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - children = box->children; - while (children) + GtkBox *box; + GtkBoxChild *child; + GtkRequisition child_requisition; + GList *children; + gint nvis_children; + gint height; + guint border_width; + + box = GTK_BOX (widget); + requisition->width = 0; + requisition->height = 0; + nvis_children = 0; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) - { - gtk_widget_size_request (child->widget, &child_requisition); - - if (box->homogeneous) - { - height = child_requisition.height + child->padding * 2; - requisition->height = MAX (requisition->height, height); - } - else - { - requisition->height += child_requisition.height + child->padding * 2; - } - - requisition->width = MAX (requisition->width, child_requisition.width); - - nvis_children += 1; - } + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + gtk_widget_size_request (child->widget, &child_requisition); + + if (gtk_box_get_homogeneous (box)) + { + height = child_requisition.height + child->padding * 2; + requisition->height = MAX (requisition->height, height); + } + else + { + requisition->height += child_requisition.height + child->padding * 2; + } + + requisition->width = MAX (requisition->width, child_requisition.width); + + nvis_children += 1; + } } - if (nvis_children > 0) + if (nvis_children > 0) { - if (box->homogeneous) - requisition->height *= nvis_children; - requisition->height += (nvis_children - 1) * box->spacing; + if (gtk_box_get_homogeneous (box)) + requisition->height *= nvis_children; + requisition->height += (nvis_children - 1) * gtk_box_get_spacing (box); } - requisition->width += GTK_CONTAINER (box)->border_width * 2; - requisition->height += GTK_CONTAINER (box)->border_width * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + requisition->width += border_width * 2; + requisition->height += border_width * 2; } static void gdl_dock_bar_size_vallocate (GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { - GtkBox *box; - GtkBoxChild *child; - GList *children; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_height; - gint height; - gint extra; - gint y; - - box = GTK_BOX (widget); - widget->allocation = *allocation; - - nvis_children = 0; - nexpand_children = 0; - children = box->children; - - while (children) + GtkBox *box; + GtkBoxChild *child; + GList *children; + GtkAllocation child_allocation; + gint nvis_children; + gint nexpand_children; + gint child_height; + gint height; + gint extra; + gint y; + guint border_width; + GtkRequisition requisition; + + box = GTK_BOX (widget); + gtk_widget_set_allocation (widget, allocation); + + gtk_widget_get_requisition (widget, &requisition); + + nvis_children = 0; + nexpand_children = 0; + children = gtk_container_get_children (GTK_CONTAINER (box)); + + while (children) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) - { - nvis_children += 1; - if (child->expand) - nexpand_children += 1; - } + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + nvis_children += 1; + if (child->expand) + nexpand_children += 1; + } } - if (nvis_children > 0) + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + + if (nvis_children > 0) { - if (box->homogeneous) - { - height = (allocation->height - - GTK_CONTAINER (box)->border_width * 2 - - (nvis_children - 1) * box->spacing); - extra = height / nvis_children; - } - else if (nexpand_children > 0) - { - height = (gint) allocation->height - (gint) widget->requisition.height; - extra = height / nexpand_children; - } - else - { - height = 0; - extra = 0; - } - - y = allocation->y + GTK_CONTAINER (box)->border_width; - child_allocation.x = allocation->x + GTK_CONTAINER (box)->border_width; - child_allocation.width = MAX (1, (gint) allocation->width - (gint) GTK_CONTAINER (box)->border_width * 2); - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) - { - if (box->homogeneous) - { - if (nvis_children == 1) - child_height = height; - else - child_height = extra; - - nvis_children -= 1; - height -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_height = child_requisition.height + child->padding * 2; - - if (child->expand) - { - if (nexpand_children == 1) - child_height += height; - else - child_height += extra; - - nexpand_children -= 1; - height -= extra; - } - } - - if (child->fill) - { - child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); - child_allocation.y = y + child->padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_allocation.height = child_requisition.height; - child_allocation.y = y + (child_height - child_allocation.height) / 2; - } - - gtk_widget_size_allocate (child->widget, &child_allocation); - - y += child_height + box->spacing; - } - } - - y = allocation->y + allocation->height - GTK_CONTAINER (box)->border_width; - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - if (box->homogeneous) + if (gtk_box_get_homogeneous (box)) + { + height = (allocation->height - + border_width * 2 - + (nvis_children - 1) * gtk_box_get_spacing (box)); + extra = height / nvis_children; + } + else if (nexpand_children > 0) + { + height = (gint) allocation->height - (gint) requisition.height; + extra = height / nexpand_children; + } + else + { + height = 0; + extra = 0; + } + + y = allocation->y + border_width; + child_allocation.x = allocation->x + border_width; + child_allocation.width = MAX (1, (gint) allocation->width - (gint) border_width * 2); + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) + { + if (gtk_box_get_homogeneous (box)) { - if (nvis_children == 1) - child_height = height; - else - child_height = extra; + if (nvis_children == 1) + child_height = height; + else + child_height = extra; - nvis_children -= 1; - height -= extra; + nvis_children -= 1; + height -= extra; } - else + else { - child_height = child_requisition.height + child->padding * 2; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_height = child_requisition.height + child->padding * 2; - if (child->expand) + if (child->expand) { - if (nexpand_children == 1) - child_height += height; - else - child_height += extra; + if (nexpand_children == 1) + child_height += height; + else + child_height += extra; - nexpand_children -= 1; - height -= extra; + nexpand_children -= 1; + height -= extra; } } - if (child->fill) + if (child->fill) { - child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); - child_allocation.y = y + child->padding - child_height; + child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); + child_allocation.y = y + child->padding; } - else + else { - child_allocation.height = child_requisition.height; - child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.height = child_requisition.height; + child_allocation.y = y + (child_height - child_allocation.height) / 2; } - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (child->widget, &child_allocation); + + y += child_height + gtk_box_get_spacing (box); + } + } - y -= (child_height + box->spacing); - } - } + y = allocation->y + allocation->height - border_width; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) + { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + if (gtk_box_get_homogeneous (box)) + { + if (nvis_children == 1) + child_height = height; + else + child_height = extra; + + nvis_children -= 1; + height -= extra; + } + else + { + child_height = child_requisition.height + child->padding * 2; + + if (child->expand) + { + if (nexpand_children == 1) + child_height += height; + else + child_height += extra; + + nexpand_children -= 1; + height -= extra; + } + } + + if (child->fill) + { + child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); + child_allocation.y = y + child->padding - child_height; + } + else + { + child_allocation.height = child_requisition.height; + child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; + } + + gtk_widget_size_allocate (child->widget, &child_allocation); + + y -= (child_height + gtk_box_get_spacing (box)); + } + } } } static void gdl_dock_bar_size_hrequest (GtkWidget *widget, - GtkRequisition *requisition ) + GtkRequisition *requisition ) { - GtkBox *box; - GtkBoxChild *child; - GList *children; - gint nvis_children; - gint width; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - children = box->children; - while (children) + GtkBox *box; + GtkBoxChild *child; + GList *children; + gint nvis_children; + gint width; + guint border_width; + + box = GTK_BOX (widget); + requisition->width = 0; + requisition->height = 0; + nvis_children = 0; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) { - child = children->data; - children = children->next; + child = children->data; + children = children->next; - if (gtk_widget_get_visible (child->widget)) - { - GtkRequisition child_requisition; + if (gtk_widget_get_visible (child->widget)) + { + GtkRequisition child_requisition; - gtk_widget_size_request (child->widget, &child_requisition); + gtk_widget_size_request (child->widget, &child_requisition); - if (box->homogeneous) - { - width = child_requisition.width + child->padding * 2; - requisition->width = MAX (requisition->width, width); - } - else - { - requisition->width += child_requisition.width + child->padding * 2; - } + if (gtk_box_get_homogeneous (box)) + { + width = child_requisition.width + child->padding * 2; + requisition->width = MAX (requisition->width, width); + } + else + { + requisition->width += child_requisition.width + child->padding * 2; + } - requisition->height = MAX (requisition->height, child_requisition.height); + requisition->height = MAX (requisition->height, child_requisition.height); - nvis_children += 1; - } + nvis_children += 1; + } } - if (nvis_children > 0) + if (nvis_children > 0) { - if (box->homogeneous) - requisition->width *= nvis_children; - requisition->width += (nvis_children - 1) * box->spacing; + if (gtk_box_get_homogeneous (box)) + requisition->width *= nvis_children; + requisition->width += (nvis_children - 1) * gtk_box_get_spacing (box); } - requisition->width += GTK_CONTAINER (box)->border_width * 2; - requisition->height += GTK_CONTAINER (box)->border_width * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + requisition->width += border_width * 2; + requisition->height += border_width * 2; } static void gdl_dock_bar_size_hallocate (GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { - GtkBox *box; - GtkBoxChild *child; - GList *children; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_width; - gint width; - gint extra; - gint x; - GtkTextDirection direction; - - box = GTK_BOX (widget); - widget->allocation = *allocation; - - direction = gtk_widget_get_direction (widget); - - nvis_children = 0; - nexpand_children = 0; - children = box->children; - - while (children) + GtkBox *box; + GtkBoxChild *child; + GList *children; + GtkAllocation child_allocation; + gint nvis_children; + gint nexpand_children; + gint child_width; + gint width; + gint extra; + gint x; + guint border_width; + GtkTextDirection direction; + GtkRequisition requisition; + + box = GTK_BOX (widget); + gtk_widget_set_allocation (widget, allocation); + gtk_widget_get_requisition (widget, &requisition); + + direction = gtk_widget_get_direction (widget); + + nvis_children = 0; + nexpand_children = 0; + children = gtk_container_get_children (GTK_CONTAINER (box)); + + while (children) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) - { - nvis_children += 1; - if (child->expand) - nexpand_children += 1; - } + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + nvis_children += 1; + if (child->expand) + nexpand_children += 1; + } } - if (nvis_children > 0) + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + + if (nvis_children > 0) { - if (box->homogeneous) - { - width = (allocation->width - - GTK_CONTAINER (box)->border_width * 2 - - (nvis_children - 1) * box->spacing); - extra = width / nvis_children; - } - else if (nexpand_children > 0) - { - width = (gint) allocation->width - (gint) widget->requisition.width; - extra = width / nexpand_children; - } - else - { - width = 0; - extra = 0; - } - - x = allocation->x + GTK_CONTAINER (box)->border_width; - child_allocation.y = allocation->y + GTK_CONTAINER (box)->border_width; - child_allocation.height = MAX (1, (gint) allocation->height - (gint) GTK_CONTAINER (box)->border_width * 2); - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) - { - if (box->homogeneous) - { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; - - nvis_children -= 1; - width -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - child_width = child_requisition.width + child->padding * 2; - - if (child->expand) - { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; - - nexpand_children -= 1; - width -= extra; - } - } - - if (child->fill) - { - child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); - child_allocation.x = x + child->padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2; - } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - - gtk_widget_size_allocate (child->widget, &child_allocation); - - x += child_width + box->spacing; - } - } - - x = allocation->x + allocation->width - GTK_CONTAINER (box)->border_width; - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - if (box->homogeneous) + if (gtk_box_get_homogeneous (box)) + { + width = (allocation->width - + border_width * 2 - + (nvis_children - 1) * gtk_box_get_spacing (box)); + extra = width / nvis_children; + } + else if (nexpand_children > 0) + { + width = (gint) allocation->width - (gint) requisition.width; + extra = width / nexpand_children; + } + else + { + width = 0; + extra = 0; + } + + x = allocation->x + border_width; + child_allocation.y = allocation->y + border_width; + child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2); + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) + { + if (gtk_box_get_homogeneous (box)) { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; + if (nvis_children == 1) + child_width = width; + else + child_width = extra; - nvis_children -= 1; - width -= extra; + nvis_children -= 1; + width -= extra; } - else + else { - child_width = child_requisition.width + child->padding * 2; + GtkRequisition child_requisition; - if (child->expand) + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + child_width = child_requisition.width + child->padding * 2; + + if (child->expand) { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; + if (nexpand_children == 1) + child_width += width; + else + child_width += extra; - nexpand_children -= 1; - width -= extra; + nexpand_children -= 1; + width -= extra; } } - if (child->fill) + if (child->fill) { - child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); - child_allocation.x = x + child->padding - child_width; + child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); + child_allocation.x = x + child->padding; } - else + else { - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.width = child_requisition.width; + child_allocation.x = x + (child_width - child_allocation.width) / 2; } - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + if (direction == GTK_TEXT_DIR_RTL) + child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (child->widget, &child_allocation); + + x += child_width + gtk_box_get_spacing (box); + } + } - x -= (child_width + box->spacing); - } - } + x = allocation->x + allocation->width - border_width; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) + { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + if (gtk_box_get_homogeneous (box)) + { + if (nvis_children == 1) + child_width = width; + else + child_width = extra; + + nvis_children -= 1; + width -= extra; + } + else + { + child_width = child_requisition.width + child->padding * 2; + + if (child->expand) + { + if (nexpand_children == 1) + child_width += width; + else + child_width += extra; + + nexpand_children -= 1; + width -= extra; + } + } + + if (child->fill) + { + child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); + child_allocation.x = x + child->padding - child_width; + } + else + { + child_allocation.width = child_requisition.width; + child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; + } + + if (direction == GTK_TEXT_DIR_RTL) + child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + + gtk_widget_size_allocate (child->widget, &child_allocation); + + x -= (child_width + gtk_box_get_spacing (box)); + } + } } } diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c index ce5c33ea6..da0cba274 100644 --- a/src/libgdl/gdl-dock-item-button-image.c +++ b/src/libgdl/gdl-dock-item-button-image.c @@ -23,13 +23,12 @@ #include "gdl-dock-item-button-image.h" #include <math.h> -#include "gdl-tools.h" #define ICON_SIZE 12 -GDL_CLASS_BOILERPLATE (GdlDockItemButtonImage, - gdl_dock_item_button_image, - GtkWidget, GTK_TYPE_WIDGET); +G_DEFINE_TYPE (GdlDockItemButtonImage, + gdl_dock_item_button_image, + GTK_TYPE_WIDGET); static gint gdl_dock_item_button_image_expose (GtkWidget *widget, @@ -115,10 +114,10 @@ gdl_dock_item_button_image_expose (GtkWidget *widget, } static void -gdl_dock_item_button_image_instance_init ( +gdl_dock_item_button_image_init ( GdlDockItemButtonImage *button_image) { - GTK_WIDGET_SET_FLAGS (button_image, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (button_image), FALSE); } static void @@ -140,8 +139,6 @@ gdl_dock_item_button_image_class_init ( GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - widget_class->expose_event = gdl_dock_item_button_image_expose; widget_class->size_request = diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 1272b950a..f0a90459c 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -39,7 +39,6 @@ #include "gdl-dock-item-grip.h" #include "gdl-dock-item-button-image.h" #include "gdl-switcher.h" -#include "gdl-tools.h" #define ALIGN_BORDER 5 #define DRAG_HANDLE_SIZE 10 @@ -58,8 +57,7 @@ struct _GdlDockItemGripPrivate { gboolean handle_shown; }; -GDL_CLASS_BOILERPLATE (GdlDockItemGrip, gdl_dock_item_grip, - GtkContainer, GTK_TYPE_CONTAINER); +G_DEFINE_TYPE (GdlDockItemGrip, gdl_dock_item_grip, GTK_TYPE_CONTAINER); GtkWidget* gdl_dock_item_create_label_widget(GdlDockItemGrip *grip) @@ -115,55 +113,33 @@ gdl_dock_item_grip_expose (GtkWidget *widget, GdkEventExpose *event) { GdlDockItemGrip *grip; -/*<<<<<<< HEAD */ + GtkAllocation allocation; GdkRectangle handle_area; GdkRectangle expose_area; grip = GDL_DOCK_ITEM_GRIP (widget); - - if(grip->_priv->handle_shown) { -/*======= - GdkRectangle title_area; - GdkRectangle expose_area; - GdkGC *bg_style; - gint layout_width; - gint layout_height; - gint text_x; - gint text_y; - - grip = GDL_DOCK_ITEM_GRIP (widget); - gdl_dock_item_grip_get_title_area (grip, &title_area); */ - - /* draw background, highlight it if the dock item or any of its - * descendants have focus */ -/* bg_style = (gdl_dock_item_or_child_has_focus (grip->item) ? - gtk_widget_get_style (widget)->dark_gc[widget->state] : - gtk_widget_get_style (widget)->mid_gc[widget->state]); + if(grip->_priv->handle_shown) { - gdk_draw_rectangle (GDK_DRAWABLE (widget->window), bg_style, TRUE, - 1, 0, widget->allocation.width - 1, widget->allocation.height); + gtk_widget_get_allocation (widget, &allocation); - if (grip->_priv->icon_pixbuf) { - GdkRectangle pixbuf_rect; ->>>>>>> gdl-2.26.0-with-inkscape */ - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { - handle_area.x = widget->allocation.x; - handle_area.y = widget->allocation.y; + handle_area.x = allocation.x; + handle_area.y = allocation.y; handle_area.width = DRAG_HANDLE_SIZE; - handle_area.height = widget->allocation.height; + handle_area.height = allocation.height; } else { - handle_area.x = widget->allocation.x + widget->allocation.width - - DRAG_HANDLE_SIZE; - handle_area.y = widget->allocation.y; + handle_area.x = allocation.x + allocation.width - DRAG_HANDLE_SIZE; + handle_area.y = allocation.y; handle_area.width = DRAG_HANDLE_SIZE; - handle_area.height = widget->allocation.height; + handle_area.height = allocation.height; } if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) { - gtk_paint_handle (widget->style, widget->window, widget->state, + gtk_paint_handle (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), + gtk_widget_get_state (widget), GTK_SHADOW_NONE, &expose_area, widget, "handlebox", handle_area.x, handle_area.y, handle_area.width, handle_area.height, @@ -173,7 +149,7 @@ gdl_dock_item_grip_expose (GtkWidget *widget, } - return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->expose_event (widget, event); } static void @@ -240,7 +216,7 @@ gdl_dock_item_grip_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_item_grip_parent_class)->destroy (object); } static void @@ -291,6 +267,45 @@ gdl_dock_item_grip_close_clicked (GtkWidget *widget, gdl_dock_item_hide_item (grip->item); } +#if !GTK_CHECK_VERSION (2, 22, 0) +# define gtk_button_get_event_window(button) button->event_window +#endif // Gtk+ >= 2.22 + +static void +gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip) +{ + GtkWidget *iconify_button = grip->_priv->iconify_button; + GdkWindow *window = NULL; + GdkEvent *event = NULL; + + GdkModifierType modifiers; + gint x = 0, y = 0; + + g_return_if_fail (gtk_widget_get_realized (iconify_button)); + + window = gtk_button_get_event_window (GTK_BUTTON (iconify_button)); + event = gdk_event_new (GDK_LEAVE_NOTIFY); + + g_assert (GDK_IS_WINDOW (window)); + gdk_window_get_pointer (window, &x, &y, &modifiers); + + event->crossing.window = g_object_ref (window); + event->crossing.send_event = FALSE; + event->crossing.subwindow = g_object_ref (window); + event->crossing.time = GDK_CURRENT_TIME; + event->crossing.x = x; + event->crossing.y = y; + event->crossing.x_root = event->crossing.y_root = 0; + event->crossing.mode = GDK_CROSSING_STATE_CHANGED; + event->crossing.detail = GDK_NOTIFY_NONLINEAR; + event->crossing.focus = FALSE; + event->crossing.state = modifiers; + + gtk_widget_event (iconify_button, event); + + gdk_event_free (event); +} + static void gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, GdlDockItemGrip *grip) @@ -300,6 +315,9 @@ gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, (void)widget; g_return_if_fail (grip->item != NULL); + /* Workaround to unhighlight the iconify button. */ + gdl_dock_item_grip_fix_iconify_button (grip); + parent = gtk_widget_get_parent (GTK_WIDGET (grip->item)); if (GDL_IS_SWITCHER (parent)) { @@ -323,14 +341,10 @@ gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, { gdl_dock_item_iconify_item (grip->item); } - - /* Workaround to unhighlight the iconify button. */ - GTK_BUTTON (grip->_priv->iconify_button)->in_button = FALSE; - gtk_button_leave (GTK_BUTTON (grip->_priv->iconify_button)); } static void -gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) +gdl_dock_item_grip_init (GdlDockItemGrip *grip) { GtkWidget *image; @@ -344,7 +358,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) gtk_widget_push_composite_child (); grip->_priv->close_button = gtk_button_new (); gtk_widget_pop_composite_child (); - + gtk_widget_set_can_focus (grip->_priv->close_button, FALSE); gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip)); gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE); @@ -361,7 +375,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) gtk_widget_push_composite_child (); grip->_priv->iconify_button = gtk_button_new (); gtk_widget_pop_composite_child (); - + gtk_widget_set_can_focus (grip->_priv->iconify_button, FALSE); gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip)); gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE); @@ -386,20 +400,23 @@ gdl_dock_item_grip_realize (GtkWidget *widget) { GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->realize (widget); g_return_if_fail (grip->_priv != NULL); if (!grip->title_window) { + GtkAllocation allocation; GdkWindowAttr attributes; GdkCursor *cursor; g_return_if_fail (grip->_priv->label != NULL); - attributes.x = grip->_priv->label->allocation.x; - attributes.y = grip->_priv->label->allocation.y; - attributes.width = grip->_priv->label->allocation.width; - attributes.height = grip->_priv->label->allocation.height; + gtk_widget_get_allocation (grip->_priv->label, &allocation); + + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = GDK_ALL_EVENTS_MASK; @@ -410,11 +427,11 @@ gdl_dock_item_grip_realize (GtkWidget *widget) gdk_window_set_user_data (grip->title_window, grip); /* Unref the ref from parent realize for NO_WINDOW */ - g_object_unref (widget->window); + g_object_unref (gtk_widget_get_window (widget)); /* Need to ref widget->window, because parent unrealize unrefs it */ - widget->window = g_object_ref (grip->title_window); - GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW); + gtk_widget_set_window (widget, g_object_ref (grip->title_window)); + gtk_widget_set_has_window (widget, TRUE); /* Unset the background so as to make the colour match the parent window */ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, NULL); @@ -437,13 +454,13 @@ gdl_dock_item_grip_unrealize (GtkWidget *widget) GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); if (grip->title_window) { - GTK_WIDGET_SET_FLAGS(widget, GTK_NO_WINDOW); + gtk_widget_set_has_window (widget, FALSE); gdk_window_set_user_data (grip->title_window, NULL); gdk_window_destroy (grip->title_window); grip->title_window = NULL; } - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unrealize (widget); } static void @@ -451,7 +468,7 @@ gdl_dock_item_grip_map (GtkWidget *widget) { GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->map (widget); if (grip->title_window) gdk_window_show (grip->title_window); @@ -465,7 +482,7 @@ gdl_dock_item_grip_unmap (GtkWidget *widget) if (grip->title_window) gdk_window_hide (grip->title_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unmap (widget); } static void @@ -473,18 +490,18 @@ gdl_dock_item_grip_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkRequisition child_requisition; - GtkContainer *container; GdlDockItemGrip *grip; gint layout_height = 0; + guint border_width; g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); g_return_if_fail (requisition != NULL); - container = GTK_CONTAINER (widget); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); grip = GDL_DOCK_ITEM_GRIP (widget); - requisition->width = container->border_width * 2/* + ALIGN_BORDER*/; - requisition->height = container->border_width * 2; + requisition->width = border_width * 2/* + ALIGN_BORDER*/; + requisition->height = border_width * 2; if(grip->_priv->handle_shown) requisition->width += DRAG_HANDLE_SIZE; @@ -513,19 +530,19 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GdlDockItemGrip *grip; - GtkContainer *container; GtkRequisition close_requisition = { 0, }; GtkRequisition iconify_requisition = { 0, }; GtkAllocation child_allocation; GdkRectangle label_area; + guint border_width; g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); g_return_if_fail (allocation != NULL); grip = GDL_DOCK_ITEM_GRIP (widget); - container = GTK_CONTAINER (widget); + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->size_allocate (widget, allocation); gtk_widget_size_request (grip->_priv->close_button, &close_requisition); @@ -534,17 +551,17 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, /* Calculate the Minimum Width where buttons will fit */ int min_width = close_requisition.width + iconify_requisition.width - + container->border_width * 2; + + border_width * 2; if(grip->_priv->handle_shown) min_width += DRAG_HANDLE_SIZE; const gboolean space_for_buttons = (allocation->width >= min_width); /* Set up the rolling child_allocation rectangle */ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x = container->border_width/* + ALIGN_BORDER*/; + child_allocation.x = border_width/* + ALIGN_BORDER*/; else - child_allocation.x = allocation->width - container->border_width; - child_allocation.y = container->border_width; + child_allocation.x = allocation->width - border_width; + child_allocation.y = border_width; /* Layout Close Button */ if (gtk_widget_get_visible (grip->_priv->close_button)) { @@ -587,7 +604,7 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, /* Layout the Grip Handle*/ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { child_allocation.width = child_allocation.x; - child_allocation.x = container->border_width/* + ALIGN_BORDER*/; + child_allocation.x = border_width/* + ALIGN_BORDER*/; if(grip->_priv->handle_shown) { child_allocation.x += DRAG_HANDLE_SIZE; @@ -605,8 +622,8 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget, if(child_allocation.width < 0) child_allocation.width = 0; - child_allocation.y = container->border_width; - child_allocation.height = allocation->height - container->border_width * 2; + child_allocation.y = border_width; + child_allocation.height = allocation->height - border_width * 2; if(grip->_priv->label) { gtk_widget_size_allocate (grip->_priv->label, &child_allocation); } @@ -675,7 +692,6 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass) GtkWidgetClass *widget_class; GtkContainerClass *container_class; - parent_class = g_type_class_peek_parent (klass); gobject_class = G_OBJECT_CLASS (klass); gtk_object_class = GTK_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index d9aa9eff5..50be88583 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -37,7 +37,6 @@ #include <string.h> #include <gdk/gdkkeysyms.h> -#include "gdl-tools.h" #include "gdl-dock.h" #include "gdl-dock-item.h" #include "gdl-dock-item-grip.h" @@ -54,7 +53,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_item_class_init (GdlDockItemClass *class); -static void gdl_dock_item_instance_init (GdlDockItem *item); static GObject *gdl_dock_item_constructor (GType type, guint n_construct_properties, @@ -200,7 +198,7 @@ struct _GdlDockItemPrivate { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockItem, gdl_dock_item, GdlDockObject, GDL_TYPE_DOCK_OBJECT); +G_DEFINE_TYPE (GdlDockItem, gdl_dock_item, GDL_TYPE_DOCK_OBJECT); static void add_tab_bindings (GtkBindingSet *binding_set, @@ -475,7 +473,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) } static void -gdl_dock_item_instance_init (GdlDockItem *item) +gdl_dock_item_init (GdlDockItem *item) { gtk_widget_set_has_window (GTK_WIDGET (item), TRUE); gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE); @@ -528,12 +526,9 @@ gdl_dock_item_constructor (GType type, { GObject *g_object; - g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS, - constructor, - (type, - n_construct_properties, - construct_param), - NULL); + g_object = G_OBJECT_CLASS (gdl_dock_item_parent_class)-> constructor (type, + n_construct_properties, + construct_param); if (g_object) { GdlDockItem *item = GDL_DOCK_ITEM (g_object); GtkWidget *hbox; @@ -705,7 +700,7 @@ gdl_dock_item_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_item_parent_class)->destroy (object); } static void @@ -806,8 +801,8 @@ gdl_dock_item_set_focus_child (GtkContainer *container, { g_return_if_fail (GDL_IS_DOCK_ITEM (container)); - if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child) { - (* GTK_CONTAINER_CLASS (parent_class)->set_focus_child) (container, child); + if (GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) { + (* GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) (container, child); } gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container)); @@ -817,9 +812,11 @@ static void gdl_dock_item_size_request (GtkWidget *widget, GtkRequisition *requisition) { + GdlDockItem *item; GtkRequisition child_requisition; GtkRequisition grip_requisition; - GdlDockItem *item; + GtkStyle *style; + guint border_width; g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); g_return_if_fail (requisition != NULL); @@ -863,10 +860,13 @@ gdl_dock_item_size_request (GtkWidget *widget, requisition->width = 0; } - requisition->width += (GTK_CONTAINER (widget)->border_width + widget->style->xthickness) * 2; - requisition->height += (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + style = gtk_widget_get_style (widget); + + requisition->width += (border_width + style->xthickness) * 2; + requisition->height += (border_width + style->ythickness) * 2; - widget->requisition = *requisition; + //gtk_widget_size_request (widget, requisition); } static void @@ -880,31 +880,33 @@ gdl_dock_item_size_allocate (GtkWidget *widget, item = GDL_DOCK_ITEM (widget); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); /* Once size is allocated, preferred size is no longer necessary */ item->_priv->preferred_height = -1; item->_priv->preferred_width = -1; if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gdk_window_move_resize (gtk_widget_get_window (widget), + allocation->x, + allocation->y, + allocation->width, + allocation->height); if (item->child && gtk_widget_get_visible (item->child)) { GtkAllocation child_allocation; - int border_width; + GtkStyle *style; + guint border_width; - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + style = gtk_widget_get_style (widget); - child_allocation.x = border_width + widget->style->xthickness; - child_allocation.y = border_width + widget->style->ythickness; + child_allocation.x = border_width + style->xthickness; + child_allocation.y = border_width + style->ythickness; child_allocation.width = allocation->width - - 2 * (border_width + widget->style->xthickness); + - 2 * (border_width + style->xthickness); child_allocation.height = allocation->height - - 2 * (border_width + widget->style->ythickness); + - 2 * (border_width + style->ythickness); if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) { GtkAllocation grip_alloc = child_allocation; @@ -945,7 +947,7 @@ gdl_dock_item_map (GtkWidget *widget) item = GDL_DOCK_ITEM (widget); - gdk_window_show (widget->window); + gdk_window_show (gtk_widget_get_window (widget)); if (item->child && gtk_widget_get_visible (item->child) @@ -970,7 +972,7 @@ gdl_dock_item_unmap (GtkWidget *widget) item = GDL_DOCK_ITEM (widget); - gdk_window_hide (widget->window); + gdk_window_hide (gtk_widget_get_window (widget)); if (item->_priv->grip) gtk_widget_unmap (item->_priv->grip); @@ -979,9 +981,11 @@ gdl_dock_item_unmap (GtkWidget *widget) static void gdl_dock_item_realize (GtkWidget *widget) { + GdlDockItem *item; + GtkAllocation allocation; + GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; - GdlDockItem *item; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); @@ -991,10 +995,11 @@ gdl_dock_item_realize (GtkWidget *widget) gtk_widget_set_realized (widget, TRUE); /* widget window */ - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); @@ -1005,26 +1010,28 @@ gdl_dock_item_realize (GtkWidget *widget) GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, + window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); + + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), window, gtk_widget_get_state (GTK_WIDGET (item))); - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_set_back_pixmap (window, NULL, TRUE); if (item->child) - gtk_widget_set_parent_window (item->child, widget->window); - + gtk_widget_set_parent_window (item->child, window); + if (item->_priv->grip) - gtk_widget_set_parent_window (item->_priv->grip, widget->window); + gtk_widget_set_parent_window (item->_priv->grip, window); } static void gdl_dock_item_style_set (GtkWidget *widget, GtkStyle *previous_style) { + GdkWindow *window; (void)previous_style; g_return_if_fail (widget != NULL); @@ -1033,10 +1040,12 @@ gdl_dock_item_style_set (GtkWidget *widget, if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) { - gtk_style_set_background (widget->style, widget->window, - widget->state); + window = gtk_widget_get_window (widget); + gtk_style_set_background (gtk_widget_get_style (widget), + window, + gtk_widget_get_state (widget)); if (gtk_widget_is_drawable (widget)) - gdk_window_clear (widget->window); + gdk_window_clear (window); } } @@ -1044,8 +1053,12 @@ static void gdl_dock_item_paint (GtkWidget *widget, GdkEventExpose *event) { - gtk_paint_box (widget->style, - widget->window, + GdlDockItem *item; + + item = GDL_DOCK_ITEM (widget); + + gtk_paint_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), gtk_widget_get_state (widget), GTK_SHADOW_NONE, &event->area, widget, @@ -1061,9 +1074,11 @@ gdl_dock_item_expose (GtkWidget *widget, g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - if (gtk_widget_is_drawable (widget) && event->window == widget->window) { + if (gtk_widget_is_drawable (widget) && + event->window == gtk_widget_get_window (widget)) + { gdl_dock_item_paint (widget, event); - GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event)); + GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->expose_event (widget,event); } return FALSE; @@ -1088,10 +1103,11 @@ gdl_dock_item_button_changed (GtkWidget *widget, GdkEventButton *event) { GdlDockItem *item; + GtkAllocation allocation; + GdkCursor *cursor; gboolean locked; gboolean event_handled; gboolean in_handle; - GdkCursor *cursor; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE); @@ -1106,13 +1122,15 @@ gdl_dock_item_button_changed (GtkWidget *widget, event_handled = FALSE; + gtk_widget_get_allocation (item->_priv->grip, &allocation); + /* Check if user clicked on the drag handle. */ switch (item->orientation) { case GTK_ORIENTATION_HORIZONTAL: - in_handle = event->x < item->_priv->grip->allocation.width; + in_handle = event->x < allocation.width; break; case GTK_ORIENTATION_VERTICAL: - in_handle = event->y < item->_priv->grip->allocation.height; + in_handle = event->y < allocation.height; break; default: in_handle = FALSE; @@ -1228,10 +1246,7 @@ gdl_dock_item_key_press (GtkWidget *widget, if (event_handled) return TRUE; else - return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS, - key_press_event, - (widget, event), - FALSE); + return GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->key_press_event (widget, event); } static gboolean @@ -1240,21 +1255,21 @@ gdl_dock_item_dock_request (GdlDockObject *object, gint y, GdlDockRequest *request) { - GtkAllocation *alloc; + GtkAllocation alloc; gint rel_x, rel_y; /* we get (x,y) in our allocation coordinates system */ /* Get item's allocation. */ - alloc = &(GTK_WIDGET (object)->allocation); + gtk_widget_get_allocation (GTK_WIDGET (object), &alloc); /* Get coordinates relative to our window. */ - rel_x = x - alloc->x; - rel_y = y - alloc->y; + rel_x = x - alloc.x; + rel_y = y - alloc.y; /* Location is inside. */ - if (rel_x > 0 && rel_x < alloc->width && - rel_y > 0 && rel_y < alloc->height) { + if (rel_x > 0 && rel_x < alloc.width && + rel_y > 0 && rel_y < alloc.height) { float rx, ry; GtkRequisition my, other; gint divider = -1; @@ -1264,8 +1279,8 @@ gdl_dock_item_dock_request (GdlDockObject *object, gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my); /* Calculate location in terms of the available space (0-100%). */ - rx = (float) rel_x / alloc->width; - ry = (float) rel_y / alloc->height; + rx = (float) rel_x / alloc.width; + ry = (float) rel_y / alloc.height; /* Determine dock location. */ if (rx < SPLIT_RATIO) { @@ -1291,8 +1306,8 @@ gdl_dock_item_dock_request (GdlDockObject *object, /* Reset rectangle coordinates to entire item. */ request->rect.x = 0; request->rect.y = 0; - request->rect.width = alloc->width; - request->rect.height = alloc->height; + request->rect.width = alloc.width; + request->rect.height = alloc.height; GdlDockItemBehavior behavior = GDL_DOCK_ITEM(object)->behavior; @@ -1339,8 +1354,8 @@ gdl_dock_item_dock_request (GdlDockObject *object, /* adjust returned coordinates so they are have the same origin as our window */ - request->rect.x += alloc->x; - request->rect.y += alloc->y; + request->rect.x += alloc.x; + request->rect.y += alloc.y; /* Set possible target location and return TRUE. */ request->target = object; @@ -1367,6 +1382,7 @@ gdl_dock_item_dock (GdlDockObject *object, { GdlDockObject *new_parent = NULL; GdlDockObject *parent, *requestor_parent; + GtkAllocation allocation; gboolean add_ourselves_first = FALSE; guint available_space=0; @@ -1381,8 +1397,9 @@ gdl_dock_item_dock (GdlDockObject *object, gdl_dock_item_preferred_size (GDL_DOCK_ITEM (parent), &parent_req); else { - parent_req.height = GTK_WIDGET (parent)->allocation.height; - parent_req.width = GTK_WIDGET (parent)->allocation.width; + gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation); + parent_req.height = allocation.height; + parent_req.width = allocation.width; } /* If preferred size is not set on the requestor (perhaps a new item), @@ -1672,7 +1689,10 @@ gdl_dock_item_tab_button (GtkWidget *widget, GdkEventButton *event, gpointer data) { - GdlDockItem *item = GDL_DOCK_ITEM(data); + GdlDockItem *item; + GtkAllocation allocation; + + item = GDL_DOCK_ITEM(data); (void)widget; @@ -1686,8 +1706,9 @@ gdl_dock_item_tab_button (GtkWidget *widget, drag handle */ switch (item->orientation) { case GTK_ORIENTATION_HORIZONTAL: + gtk_widget_get_allocation (GTK_WIDGET (data), &allocation); /*item->dragoff_x = item->_priv->grip_size / 2;*/ - item->dragoff_y = GTK_WIDGET (data)->allocation.height / 2; + item->dragoff_y = allocation.height / 2; break; case GTK_ORIENTATION_VERTICAL: /*item->dragoff_x = GTK_WIDGET (data)->allocation.width / 2;*/ @@ -1934,8 +1955,8 @@ gdl_dock_item_set_orientation (GdlDockItem *item, "orientation", orientation, NULL); }; - - GDL_CALL_VIRTUAL (item, GDL_DOCK_ITEM_GET_CLASS, set_orientation, (item, orientation)); + if (GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation) + GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation (item, orientation); g_object_notify (G_OBJECT (item), "orientation"); } } @@ -2116,6 +2137,8 @@ gdl_dock_item_unbind (GdlDockItem *item) void gdl_dock_item_hide_item (GdlDockItem *item) { + GtkAllocation allocation; + g_return_if_fail (item != NULL); if (!GDL_DOCK_OBJECT_ATTACHED (item)) @@ -2142,8 +2165,9 @@ gdl_dock_item_hide_item (GdlDockItem *item) "floaty",&y, NULL); } else { - item->_priv->preferred_width=GTK_WIDGET (item)->allocation.width; - item->_priv->preferred_height=GTK_WIDGET (item)->allocation.height; + gtk_widget_get_allocation (GTK_WIDGET (item), &allocation); + item->_priv->preferred_width = allocation.width; + item->_priv->preferred_height = allocation.height; } item->_priv->ph = GDL_DOCK_PLACEHOLDER ( g_object_new (GDL_TYPE_DOCK_PLACEHOLDER, @@ -2323,13 +2347,15 @@ void gdl_dock_item_preferred_size (GdlDockItem *item, GtkRequisition *req) { + GtkAllocation allocation; + if (!req) return; - req->width = MAX (item->_priv->preferred_width, - GTK_WIDGET (item)->allocation.width); - req->height = MAX (item->_priv->preferred_height, - GTK_WIDGET (item)->allocation.height); + gtk_widget_get_allocation (GTK_WIDGET (item), &allocation); + + req->width = MAX (item->_priv->preferred_width, allocation.width); + req->height = MAX (item->_priv->preferred_height, allocation.height); } diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c index 57d0618ec..2bbb8eb3b 100644 --- a/src/libgdl/gdl-dock-master.c +++ b/src/libgdl/gdl-dock-master.c @@ -27,7 +27,6 @@ #include "gdl-i18n.h" -#include "gdl-tools.h" #include "gdl-dock-master.h" #include "gdl-dock.h" #include "gdl-dock-item.h" @@ -42,7 +41,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_master_class_init (GdlDockMasterClass *klass); -static void gdl_dock_master_instance_init (GdlDockMaster *master); static void gdl_dock_master_dispose (GObject *g_object); static void gdl_dock_master_set_property (GObject *object, @@ -128,7 +126,7 @@ static guint master_signals [LAST_SIGNAL] = { 0 }; /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockMaster, gdl_dock_master, GObject, G_TYPE_OBJECT); +G_DEFINE_TYPE (GdlDockMaster, gdl_dock_master, G_TYPE_OBJECT); static void gdl_dock_master_class_init (GdlDockMasterClass *klass) @@ -189,7 +187,7 @@ gdl_dock_master_class_init (GdlDockMasterClass *klass) } static void -gdl_dock_master_instance_init (GdlDockMaster *master) +gdl_dock_master_init (GdlDockMaster *master) { master->dock_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -323,7 +321,7 @@ gdl_dock_master_dispose (GObject *g_object) master->_priv = NULL; } - GDL_CALL_PARENT (G_OBJECT_CLASS, dispose, (g_object)); + G_OBJECT_CLASS (gdl_dock_master_parent_class)->dispose (g_object); } static void @@ -484,6 +482,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item, GdlDockMaster *master; GdlDockRequest my_request, *request; GdkWindow *window; + GdkWindow *widget_window; gint win_x, win_y; gint x, y; GdlDock *dock = NULL; @@ -508,15 +507,17 @@ gdl_dock_master_drag_motion (GdlDockItem *item, if (GTK_IS_WIDGET (widget)) { while (widget && (!GDL_IS_DOCK (widget) || GDL_DOCK_OBJECT_GET_MASTER (widget) != master)) - widget = widget->parent; + widget = gtk_widget_get_parent (widget); if (widget) { gint win_w, win_h; + widget_window = gtk_widget_get_window (widget); + /* verify that the pointer is still in that dock (the user could have moved it) */ - gdk_window_get_geometry (widget->window, + gdk_window_get_geometry (widget_window, NULL, NULL, &win_w, &win_h, NULL); - gdk_window_get_origin (widget->window, &win_x, &win_y); + gdk_window_get_origin (widget_window, &win_x, &win_y); if (root_x >= win_x && root_x < win_x + win_w && root_y >= win_y && root_y < win_y + win_h) dock = GDL_DOCK (widget); @@ -525,9 +526,11 @@ gdl_dock_master_drag_motion (GdlDockItem *item, } if (dock) { + GdkWindow *dock_window = gtk_widget_get_window (GTK_WIDGET (dock)); + /* translate root coordinates into dock object coordinates (i.e. widget coordinates) */ - gdk_window_get_origin (GTK_WIDGET (dock)->window, &win_x, &win_y); + gdk_window_get_origin (dock_window, &win_x, &win_y); x = root_x - win_x; y = root_y - win_y; may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock), @@ -538,10 +541,12 @@ gdl_dock_master_drag_motion (GdlDockItem *item, /* try to dock the item in all the docks in the ring in turn */ for (l = master->toplevel_docks; l; l = l->next) { + GdkWindow *dock_window; dock = GDL_DOCK (l->data); + dock_window = gtk_widget_get_window (GTK_WIDGET (dock)); /* translate root coordinates into dock object coordinates (i.e. widget coordinates) */ - gdk_window_get_origin (GTK_WIDGET (dock)->window, &win_x, &win_y); + gdk_window_get_origin (dock_window, &win_x, &win_y); x = root_x - win_x; y = root_y - win_y; may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock), diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c index 3db3fab3f..6b6b4f755 100644 --- a/src/libgdl/gdl-dock-notebook.c +++ b/src/libgdl/gdl-dock-notebook.c @@ -26,7 +26,6 @@ #include "gdl-i18n.h" #include "gdl-switcher.h" -#include "gdl-tools.h" #include "gdl-dock-notebook.h" #include "gdl-dock-tablabel.h" @@ -34,7 +33,6 @@ /* Private prototypes */ static void gdl_dock_notebook_class_init (GdlDockNotebookClass *klass); -static void gdl_dock_notebook_instance_init (GdlDockNotebook *notebook); static void gdl_dock_notebook_set_property (GObject *object, guint prop_id, const GValue *value, @@ -90,7 +88,7 @@ enum { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockNotebook, gdl_dock_notebook, GdlDockItem, GDL_TYPE_DOCK_ITEM) ; +G_DEFINE_TYPE (GdlDockNotebook, gdl_dock_notebook, GDL_TYPE_DOCK_ITEM); static void gdl_dock_notebook_class_init (GdlDockNotebookClass *klass) @@ -179,7 +177,7 @@ gdl_dock_notebook_button_cb (GtkWidget *widget, } static void -gdl_dock_notebook_instance_init (GdlDockNotebook *notebook) +gdl_dock_notebook_init (GdlDockNotebook *notebook) { GdlDockItem *item; @@ -253,7 +251,7 @@ gdl_dock_notebook_destroy (GtkObject *object) /* we need to call the virtual first, since in GdlDockDestroy our children dock objects are detached */ - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->destroy (object); /* after that we can remove the GtkNotebook */ if (item->child) { @@ -275,7 +273,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, notebook = GDL_DOCK_NOTEBOOK (data); /* deactivate old tablabel */ - if (nb->cur_page) { + if (gtk_notebook_get_current_page (nb)) { tablabel = gtk_notebook_get_tab_label ( nb, gtk_notebook_get_nth_page ( nb, gtk_notebook_get_current_page (nb))); @@ -327,8 +325,8 @@ gdl_dock_notebook_forall (GtkContainer *container, if (include_internals) { /* use GdlDockItem's forall */ - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall, - (container, include_internals, callback, callback_data)); + GTK_CONTAINER_CLASS (gdl_dock_notebook_parent_class)->forall + (container, include_internals, callback, callback_data); } else { item = GDL_DOCK_ITEM (container); @@ -432,8 +430,7 @@ gdl_dock_notebook_dock (GdlDockObject *object, } } else - GDL_CALL_PARENT (GDL_DOCK_OBJECT_CLASS, dock, - (object, requestor, position, other_data)); + GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->dock (object, requestor, position, other_data); } static void @@ -447,7 +444,7 @@ gdl_dock_notebook_set_orientation (GdlDockItem *item, gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_LEFT); } - GDL_CALL_PARENT (GDL_DOCK_ITEM_CLASS, set_orientation, (item, orientation)); + GDL_DOCK_ITEM_CLASS (gdl_dock_notebook_parent_class)->set_orientation (item, orientation); } static gboolean @@ -492,7 +489,7 @@ gdl_dock_notebook_present (GdlDockObject *object, if (i >= 0) gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), i); - GDL_CALL_PARENT (GDL_DOCK_OBJECT_CLASS, present, (object, child)); + GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->present (object, child); } static gboolean diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 28213fe32..4058d8752 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -29,7 +29,6 @@ #include <stdlib.h> #include <string.h> -#include "gdl-tools.h" #include "gdl-dock-object.h" #include "gdl-dock-master.h" #include "libgdltypebuiltins.h" @@ -46,7 +45,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_object_class_init (GdlDockObjectClass *klass); -static void gdl_dock_object_instance_init (GdlDockObject *object); static void gdl_dock_object_set_property (GObject *g_object, guint prop_id, @@ -96,7 +94,7 @@ static guint gdl_dock_object_signals [LAST_SIGNAL] = { 0 }; /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockObject, gdl_dock_object, GtkContainer, GTK_TYPE_CONTAINER); +G_DEFINE_TYPE (GdlDockObject, gdl_dock_object, GTK_TYPE_CONTAINER); static void gdl_dock_object_class_init (GdlDockObjectClass *klass) @@ -193,7 +191,7 @@ gdl_dock_object_class_init (GdlDockObjectClass *klass) } static void -gdl_dock_object_instance_init (GdlDockObject *object) +gdl_dock_object_init (GdlDockObject *object) { object->flags = GDL_DOCK_AUTOMATIC; object->freeze_count = 0; @@ -282,7 +280,7 @@ gdl_dock_object_finalize (GObject *g_object) object->stock_id = NULL; object->pixbuf_icon = NULL; - GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (g_object)); + G_OBJECT_CLASS (gdl_dock_object_parent_class)->finalize (g_object); } static void @@ -320,7 +318,7 @@ gdl_dock_object_destroy (GtkObject *gtk_object) if (object->master) gdl_dock_object_unbind (object); - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (gtk_object)); + GTK_OBJECT_CLASS(gdl_dock_object_parent_class)->destroy (gtk_object); } static void @@ -341,7 +339,7 @@ gdl_dock_object_show (GtkWidget *widget) (GtkCallback) gdl_dock_object_foreach_automatic, gtk_widget_show); } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, show, (widget)); + GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->show (widget); } static void @@ -352,7 +350,7 @@ gdl_dock_object_hide (GtkWidget *widget) (GtkCallback) gdl_dock_object_foreach_automatic, gtk_widget_hide); } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, hide, (widget)); + GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->hide (widget); } static void @@ -375,8 +373,8 @@ gdl_dock_object_real_detach (GdlDockObject *object, GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED); parent = gdl_dock_object_get_parent_object (object); widget = GTK_WIDGET (object); - if (widget->parent) - gtk_container_remove (GTK_CONTAINER (widget->parent), widget); + if (gtk_widget_get_parent (widget)) + gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (widget))), widget); if (parent) gdl_dock_object_reduce (parent); } @@ -514,9 +512,9 @@ gdl_dock_object_get_parent_object (GdlDockObject *object) g_return_val_if_fail (object != NULL, NULL); - parent = GTK_WIDGET (object)->parent; + parent = gtk_widget_get_parent (GTK_WIDGET (object)); while (parent && !GDL_IS_DOCK_OBJECT (parent)) { - parent = parent->parent; + parent = gtk_widget_get_parent (parent); } return parent ? GDL_DOCK_OBJECT (parent) : NULL; @@ -560,7 +558,8 @@ gdl_dock_object_reduce (GdlDockObject *object) return; } - GDL_CALL_VIRTUAL (object, GDL_DOCK_OBJECT_GET_CLASS, reduce, (object)); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->reduce) + GDL_DOCK_OBJECT_GET_CLASS (object)->reduce (object); } gboolean @@ -571,11 +570,10 @@ gdl_dock_object_dock_request (GdlDockObject *object, { g_return_val_if_fail (object != NULL && request != NULL, FALSE); - return GDL_CALL_VIRTUAL_WITH_DEFAULT (object, - GDL_DOCK_OBJECT_GET_CLASS, - dock_request, - (object, x, y, request), - FALSE); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request) + return GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request (object, x, y, request); + else + return FALSE; } /** @@ -696,11 +694,10 @@ gdl_dock_object_reorder (GdlDockObject *object, { g_return_val_if_fail (object != NULL && child != NULL, FALSE); - return GDL_CALL_VIRTUAL_WITH_DEFAULT (object, - GDL_DOCK_OBJECT_GET_CLASS, - reorder, - (object, child, new_position, other_data), - FALSE); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->reorder) + GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data); + else + return FALSE; } void @@ -716,7 +713,8 @@ gdl_dock_object_present (GdlDockObject *object, /* chain the call to our parent */ gdl_dock_object_present (parent, object); - GDL_CALL_VIRTUAL (object, GDL_DOCK_OBJECT_GET_CLASS, present, (object, child)); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->present) + GDL_DOCK_OBJECT_GET_CLASS (object)->present (object, child); } /** @@ -749,10 +747,10 @@ gdl_dock_object_child_placement (GdlDockObject *object, if (!gdl_dock_object_is_compound (object)) return FALSE; - return GDL_CALL_VIRTUAL_WITH_DEFAULT (object, GDL_DOCK_OBJECT_GET_CLASS, - child_placement, - (object, child, placement), - FALSE); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement) + GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement); + else + return FALSE; } diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c index 141770aa2..299384de4 100644 --- a/src/libgdl/gdl-dock-paned.c +++ b/src/libgdl/gdl-dock-paned.c @@ -29,14 +29,13 @@ #include <string.h> #include <gtk/gtk.h> -#include "gdl-tools.h" #include "gdl-dock-paned.h" /* Private prototypes */ static void gdl_dock_paned_class_init (GdlDockPanedClass *klass); -static void gdl_dock_paned_instance_init (GdlDockPaned *paned); +static void gdl_dock_paned_init (GdlDockPaned *paned); static GObject *gdl_dock_paned_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_param); @@ -88,7 +87,7 @@ enum { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockPaned, gdl_dock_paned, GdlDockItem, GDL_TYPE_DOCK_ITEM); +G_DEFINE_TYPE (GdlDockPaned, gdl_dock_paned, GDL_TYPE_DOCK_ITEM); static void gdl_dock_paned_class_init (GdlDockPanedClass *klass) @@ -136,7 +135,7 @@ gdl_dock_paned_class_init (GdlDockPanedClass *klass) } static void -gdl_dock_paned_instance_init (GdlDockPaned *paned) +gdl_dock_paned_init (GdlDockPaned *paned) { paned->position_changed = FALSE; paned->in_drag = FALSE; @@ -347,13 +346,10 @@ gdl_dock_paned_constructor (GType type, GObjectConstructParam *construct_param) { GObject *g_object; - - g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS, - constructor, - (type, - n_construct_properties, - construct_param), - NULL); + + g_object = G_OBJECT_CLASS (gdl_dock_paned_parent_class)-> constructor (type, + n_construct_properties, + construct_param); if (g_object) { GdlDockItem *item = GDL_DOCK_ITEM (g_object); @@ -416,7 +412,7 @@ gdl_dock_paned_destroy (GtkObject *object) /* we need to call the virtual first, since in GdlDockDestroy our children dock objects are detached */ - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_paned_parent_class)->destroy (object); /* after that we can remove the GtkNotebook */ if (item->child) { @@ -430,8 +426,9 @@ gdl_dock_paned_add (GtkContainer *container, GtkWidget *widget) { GdlDockItem *item; - GtkPaned *paned; GdlDockPlacement pos = GDL_DOCK_NONE; + GtkPaned *paned; + GtkWidget *child1, *child2; g_return_if_fail (container != NULL && widget != NULL); g_return_if_fail (GDL_IS_DOCK_PANED (container)); @@ -439,13 +436,16 @@ gdl_dock_paned_add (GtkContainer *container, item = GDL_DOCK_ITEM (container); g_return_if_fail (item->child != NULL); + paned = GTK_PANED (item->child); - g_return_if_fail (!paned->child1 || !paned->child2); + child1 = gtk_paned_get_child1 (paned); + child2 = gtk_paned_get_child2 (paned); + g_return_if_fail (!child1 || !child2); - if (!paned->child1) + if (!child1) pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? GDL_DOCK_LEFT : GDL_DOCK_TOP; - else if (!paned->child2) + else if (!child2) pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM; @@ -469,8 +469,8 @@ gdl_dock_paned_forall (GtkContainer *container, if (include_internals) { /* use GdlDockItem's forall */ - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall, - (container, include_internals, callback, callback_data)); + GTK_CONTAINER_CLASS (gdl_dock_paned_parent_class)->forall + (container, include_internals, callback, callback_data); } else { item = GDL_DOCK_ITEM (container); @@ -520,7 +520,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, GdlDockItem *item; guint bw; gint rel_x, rel_y; - GtkAllocation *alloc; + GtkAllocation alloc; gboolean may_dock = FALSE; GdlDockRequest my_request; @@ -531,19 +531,19 @@ gdl_dock_paned_dock_request (GdlDockObject *object, item = GDL_DOCK_ITEM (object); /* Get item's allocation. */ - alloc = &(GTK_WIDGET (object)->allocation); - bw = GTK_CONTAINER (object)->border_width; + gtk_widget_get_allocation (GTK_WIDGET (object), &alloc); + bw = gtk_container_get_border_width (GTK_CONTAINER (object)); /* Get coordinates relative to our window. */ - rel_x = x - alloc->x; - rel_y = y - alloc->y; + rel_x = x - alloc.x; + rel_y = y - alloc.y; if (request) my_request = *request; /* Check if coordinates are inside the widget. */ - if (rel_x > 0 && rel_x < alloc->width && - rel_y > 0 && rel_y < alloc->height) { + if (rel_x > 0 && rel_x < alloc.width && + rel_y > 0 && rel_y < alloc.height) { GtkRequisition my, other; gint divider = -1; @@ -556,8 +556,8 @@ gdl_dock_paned_dock_request (GdlDockObject *object, /* Set docking indicator rectangle to the widget size. */ my_request.rect.x = bw; my_request.rect.y = bw; - my_request.rect.width = alloc->width - 2*bw; - my_request.rect.height = alloc->height - 2*bw; + my_request.rect.width = alloc.width - 2*bw; + my_request.rect.height = alloc.height - 2*bw; my_request.target = object; @@ -566,7 +566,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, my_request.position = GDL_DOCK_LEFT; my_request.rect.width *= SPLIT_RATIO; divider = other.width; - } else if (rel_x > alloc->width - bw) { + } else if (rel_x > alloc.width - bw) { my_request.position = GDL_DOCK_RIGHT; my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); my_request.rect.width *= SPLIT_RATIO; @@ -575,7 +575,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, my_request.position = GDL_DOCK_TOP; my_request.rect.height *= SPLIT_RATIO; divider = other.height; - } else if (rel_y > alloc->height - bw) { + } else if (rel_y > alloc.height - bw) { my_request.position = GDL_DOCK_BOTTOM; my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); my_request.rect.height *= SPLIT_RATIO; @@ -606,7 +606,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, or left/right */ may_dock = TRUE; if (item->orientation == GTK_ORIENTATION_HORIZONTAL) { - if (rel_y < alloc->height / 2) { + if (rel_y < alloc.height / 2) { my_request.position = GDL_DOCK_TOP; my_request.rect.height *= SPLIT_RATIO; divider = other.height; @@ -617,7 +617,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, divider = MAX (0, my.height - other.height); } } else { - if (rel_x < alloc->width / 2) { + if (rel_x < alloc.width / 2) { my_request.position = GDL_DOCK_LEFT; my_request.rect.width *= SPLIT_RATIO; divider = other.width; @@ -641,8 +641,8 @@ gdl_dock_paned_dock_request (GdlDockObject *object, if (may_dock) { /* adjust returned coordinates so they are relative to our allocation */ - my_request.rect.x += alloc->x; - my_request.rect.y += alloc->y; + my_request.rect.x += alloc.x; + my_request.rect.y += alloc.y; } } @@ -659,6 +659,7 @@ gdl_dock_paned_dock (GdlDockObject *object, GValue *other_data) { GtkPaned *paned; + GtkWidget *child1, *child2; gboolean done = FALSE; gboolean hresize = FALSE; gboolean wresize = FALSE; @@ -679,22 +680,25 @@ gdl_dock_paned_dock (GdlDockObject *object, wresize = TRUE; } + child1 = gtk_paned_get_child1 (paned); + child2 = gtk_paned_get_child2 (paned); + /* see if we can dock the item in our paned */ switch (GDL_DOCK_ITEM (object)->orientation) { case GTK_ORIENTATION_HORIZONTAL: - if (!paned->child1 && position == GDL_DOCK_LEFT) { + if (!child1 && position == GDL_DOCK_LEFT) { gtk_paned_pack1 (paned, GTK_WIDGET (requestor), FALSE, FALSE); done = TRUE; - } else if (!paned->child2 && position == GDL_DOCK_RIGHT) { + } else if (!child2 && position == GDL_DOCK_RIGHT) { gtk_paned_pack2 (paned, GTK_WIDGET (requestor), TRUE, FALSE); done = TRUE; } break; case GTK_ORIENTATION_VERTICAL: - if (!paned->child1 && position == GDL_DOCK_TOP) { + if (!child1 && position == GDL_DOCK_TOP) { gtk_paned_pack1 (paned, GTK_WIDGET (requestor), hresize, FALSE); done = TRUE; - } else if (!paned->child2 && position == GDL_DOCK_BOTTOM) { + } else if (!child2 && position == GDL_DOCK_BOTTOM) { gtk_paned_pack2 (paned, GTK_WIDGET (requestor), TRUE, FALSE); done = TRUE; } @@ -705,8 +709,8 @@ gdl_dock_paned_dock (GdlDockObject *object, if (!done) { /* this will create another paned and reparent us there */ - GDL_CALL_PARENT (GDL_DOCK_OBJECT_CLASS, dock, (object, requestor, position, - other_data)); + GDL_DOCK_OBJECT_CLASS (gdl_dock_paned_parent_class)->dock (object, requestor, position, + other_data); } else { gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor)); @@ -735,8 +739,8 @@ gdl_dock_paned_set_orientation (GdlDockItem *item, if (old_paned) { new_paned = GTK_PANED (item->child); - child1 = old_paned->child1; - child2 = old_paned->child2; + child1 = gtk_paned_get_child1 (old_paned); + child2 = gtk_paned_get_child2 (old_paned); if (child1) { g_object_ref (child1); @@ -752,7 +756,7 @@ gdl_dock_paned_set_orientation (GdlDockItem *item, } } - GDL_CALL_PARENT (GDL_DOCK_ITEM_CLASS, set_orientation, (item, orientation)); + GDL_DOCK_ITEM_CLASS (gdl_dock_paned_parent_class)->set_orientation (item, orientation); } static gboolean @@ -766,10 +770,10 @@ gdl_dock_paned_child_placement (GdlDockObject *object, if (item->child) { paned = GTK_PANED (item->child); - if (GTK_WIDGET (child) == paned->child1) + if (GTK_WIDGET (child) == gtk_paned_get_child1 (paned)) pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? GDL_DOCK_LEFT : GDL_DOCK_TOP; - else if (GTK_WIDGET (child) == paned->child2) + else if (GTK_WIDGET (child) == gtk_paned_get_child2 (paned)) pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM; } diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index a4b84b56f..b8fba9723 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -27,7 +27,6 @@ #include "gdl-i18n.h" -#include "gdl-tools.h" #include "gdl-dock-placeholder.h" #include "gdl-dock-item.h" #include "gdl-dock-paned.h" @@ -40,7 +39,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass); -static void gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph); static void gdl_dock_placeholder_set_property (GObject *g_object, guint prop_id, @@ -120,8 +118,7 @@ struct _GdlDockPlaceholderPrivate { /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockPlaceholder, gdl_dock_placeholder, - GdlDockObject, GDL_TYPE_DOCK_OBJECT); +G_DEFINE_TYPE (GdlDockPlaceholder, gdl_dock_placeholder, GDL_TYPE_DOCK_OBJECT); static void gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) @@ -214,10 +211,9 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) } static void -gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph) +gdl_dock_placeholder_init (GdlDockPlaceholder *ph) { gtk_widget_set_has_window (GTK_WIDGET (ph), FALSE); - gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE); ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1); @@ -327,7 +323,7 @@ gdl_dock_placeholder_destroy (GtkObject *object) ph->_priv = NULL; } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_placeholder_parent_class)->destroy (object); } static void @@ -378,6 +374,7 @@ find_biggest_dock_item (GtkContainer *container, GtkWidget **biggest_child, gint *biggest_child_area) { GList *children, *child; + GtkAllocation allocation; children = gtk_container_get_children (GTK_CONTAINER (container)); child = children; @@ -393,7 +390,8 @@ find_biggest_dock_item (GtkContainer *container, GtkWidget **biggest_child, child = g_list_next (child); continue; } - area = child_widget->allocation.width * child_widget->allocation.height; + gtk_widget_get_allocation (child_widget, &allocation); + area = allocation.width * allocation.height; if (area > *biggest_child_area) { *biggest_child_area = area; @@ -409,8 +407,13 @@ attempt_to_dock_on_host (GdlDockPlaceholder *ph, GdlDockObject *host, gpointer other_data) { GdlDockObject *parent; - gint host_width = GTK_WIDGET (host)->allocation.width; - gint host_height = GTK_WIDGET (host)->allocation.height; + GtkAllocation allocation; + gint host_width; + gint host_height; + + gtk_widget_get_allocation (GTK_WIDGET (host), &allocation); + host_width = allocation.width; + host_height = allocation.height; if (placement != GDL_DOCK_CENTER || !GDL_IS_DOCK_PANED (host)) { /* we simply act as a proxy for our host */ diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c index fb233fc3e..65f87ab1d 100644 --- a/src/libgdl/gdl-dock-tablabel.c +++ b/src/libgdl/gdl-dock-tablabel.c @@ -29,7 +29,6 @@ #include <gtk/gtk.h> #include "gdl-dock-tablabel.h" -#include "gdl-tools.h" #include "gdl-dock-item.h" #include "libgdlmarshal.h" @@ -37,7 +36,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass); -static void gdl_dock_tablabel_instance_init (GdlDockTablabel *tablabel); static void gdl_dock_tablabel_set_property (GObject *object, guint prop_id, @@ -93,8 +91,7 @@ static guint dock_tablabel_signals [LAST_SIGNAL] = { 0 }; /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockTablabel, gdl_dock_tablabel, - GtkBin, GTK_TYPE_BIN); +G_DEFINE_TYPE (GdlDockTablabel, gdl_dock_tablabel, GTK_TYPE_BIN); static void gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass) @@ -146,7 +143,7 @@ gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass) } static void -gdl_dock_tablabel_instance_init (GdlDockTablabel *tablabel) +gdl_dock_tablabel_init (GdlDockTablabel *tablabel) { GtkWidget *widget; GtkWidget *label_widget; @@ -212,9 +209,9 @@ gdl_dock_tablabel_set_property (GObject *object, tablabel->drag_handle_size = 0; bin = GTK_BIN (tablabel); - if (bin->child && g_object_class_find_property ( - G_OBJECT_GET_CLASS (bin->child), "label")) - g_object_set (bin->child, "label", long_name, NULL); + if (gtk_bin_get_child (bin) && g_object_class_find_property ( + G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label")) + g_object_set (gtk_bin_get_child (bin), "label", long_name, NULL); g_free (long_name); }; break; @@ -266,9 +263,9 @@ gdl_dock_tablabel_item_notify (GObject *master, tablabel->drag_handle_size = 0; bin = GTK_BIN (tablabel); - if (bin->child && g_object_class_find_property ( - G_OBJECT_GET_CLASS (bin->child), "label")) - g_object_set (bin->child, "label", label, NULL); + if (gtk_bin_get_child (bin) && g_object_class_find_property ( + G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label")) + g_object_set (gtk_bin_get_child (bin), "label", label, NULL); g_free (label); gtk_widget_queue_resize (GTK_WIDGET (tablabel)); @@ -281,6 +278,7 @@ gdl_dock_tablabel_size_request (GtkWidget *widget, GtkBin *bin; GtkRequisition child_req; GdlDockTablabel *tablabel; + guint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget)); @@ -292,18 +290,20 @@ gdl_dock_tablabel_size_request (GtkWidget *widget, requisition->width = tablabel->drag_handle_size; requisition->height = 0; - if (bin->child) - gtk_widget_size_request (bin->child, &child_req); + if (gtk_bin_get_child (bin)) + gtk_widget_size_request (gtk_bin_get_child (bin), &child_req); else child_req.width = child_req.height = 0; requisition->width += child_req.width; requisition->height += child_req.height; - requisition->width += GTK_CONTAINER (widget)->border_width * 2; - requisition->height += GTK_CONTAINER (widget)->border_width * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - widget->requisition = *requisition; + requisition->width += border_width * 2; + requisition->height += border_width * 2; + + //gtk_widget_size_request (widget, requisition); } static void @@ -311,6 +311,7 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkBin *bin; + GtkAllocation widget_allocation; GdlDockTablabel *tablabel; gint border_width; @@ -321,9 +322,9 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, bin = GTK_BIN (widget); tablabel = GDL_DOCK_TABLABEL (widget); - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) gdk_window_move_resize (tablabel->event_window, @@ -332,11 +333,12 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, allocation->width, allocation->height); - if (bin->child && gtk_widget_get_visible (bin->child)) { + if (gtk_bin_get_child (bin) && gtk_widget_get_visible (gtk_bin_get_child (bin))) { GtkAllocation child_allocation; - child_allocation.x = widget->allocation.x + border_width; - child_allocation.y = widget->allocation.y + border_width; + gtk_widget_get_allocation (widget, &widget_allocation); + child_allocation.x = widget_allocation.x + border_width; + child_allocation.y = widget_allocation.y + border_width; allocation->width = MAX (1, (int) allocation->width - (int) tablabel->drag_handle_size); @@ -347,7 +349,7 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, child_allocation.height = MAX (1, (int) allocation->height - 2 * border_width); - gtk_widget_size_allocate (bin->child, &child_allocation); + gtk_widget_size_allocate (gtk_bin_get_child (bin), &child_allocation); } } @@ -357,20 +359,22 @@ gdl_dock_tablabel_paint (GtkWidget *widget, { GdkRectangle dest, rect; GtkBin *bin; + GtkAllocation widget_allocation; GdlDockTablabel *tablabel; gint border_width; bin = GTK_BIN (widget); tablabel = GDL_DOCK_TABLABEL (widget); - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - rect.x = widget->allocation.x + border_width; - rect.y = widget->allocation.y + border_width; + gtk_widget_get_allocation (widget, &widget_allocation); + rect.x = widget_allocation.x + border_width; + rect.y = widget_allocation.y + border_width; rect.width = tablabel->drag_handle_size * HANDLE_RATIO; - rect.height = widget->allocation.height - 2*border_width; + rect.height = widget_allocation.height - 2*border_width; if (gdk_rectangle_intersect (&event->area, &rect, &dest)) { - gtk_paint_handle (widget->style, widget->window, + gtk_paint_handle (gtk_widget_get_style (widget), gtk_widget_get_window (widget), tablabel->active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_NONE, &dest, widget, "dock-tablabel", @@ -388,7 +392,7 @@ gdl_dock_tablabel_expose (GtkWidget *widget, g_return_val_if_fail (event != NULL, FALSE); if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) { - GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event)); + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->expose_event (widget,event); gdl_dock_tablabel_paint (widget, event); }; @@ -400,6 +404,7 @@ gdl_dock_tablabel_button_event (GtkWidget *widget, GdkEventButton *event) { GdlDockTablabel *tablabel; + GtkAllocation widget_allocation; gboolean event_handled; g_return_val_if_fail (widget != NULL, FALSE); @@ -422,7 +427,7 @@ gdl_dock_tablabel_button_event (GtkWidget *widget, GtkBin *bin; bin = GTK_BIN (widget); - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); rel_x = event->x - border_width; rel_y = event->y - border_width; @@ -460,8 +465,9 @@ gdl_dock_tablabel_button_event (GtkWidget *widget, e = *event; e.window = gtk_widget_get_parent_window (widget); - e.x += widget->allocation.x; - e.y += widget->allocation.y; + gtk_widget_get_allocation (widget, &widget_allocation); + e.x += widget_allocation.x; + e.y += widget_allocation.y; gdk_event_put ((GdkEvent *) &e); }; @@ -474,6 +480,7 @@ gdl_dock_tablabel_motion_event (GtkWidget *widget, GdkEventMotion *event) { GdlDockTablabel *tablabel; + GtkAllocation widget_allocation; gboolean event_handled; g_return_val_if_fail (widget != NULL, FALSE); @@ -508,8 +515,9 @@ gdl_dock_tablabel_motion_event (GtkWidget *widget, e = *event; e.window = gtk_widget_get_parent_window (widget); - e.x += widget->allocation.x; - e.y += widget->allocation.y; + gtk_widget_get_allocation (widget, &widget_allocation); + e.x += widget_allocation.x; + e.y += widget_allocation.y; gdk_event_put ((GdkEvent *) &e); }; @@ -522,15 +530,17 @@ gdl_dock_tablabel_realize (GtkWidget *widget) { GdlDockTablabel *tablabel; GdkWindowAttr attributes; + GtkAllocation widget_allocation; int attributes_mask; tablabel = GDL_DOCK_TABLABEL (widget); attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + gtk_widget_get_allocation (widget, &widget_allocation); + attributes.x = widget_allocation.x; + attributes.y = widget_allocation.y; + attributes.width = widget_allocation.width; + attributes.height = widget_allocation.height; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_EXPOSURE_MASK | @@ -541,15 +551,16 @@ gdl_dock_tablabel_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); + gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget)); + g_object_ref (gtk_widget_get_window (widget)); tablabel->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (tablabel->event_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); + + gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget), + gtk_widget_get_window (widget))); gtk_widget_set_realized (widget, TRUE); } @@ -565,15 +576,15 @@ gdl_dock_tablabel_unrealize (GtkWidget *widget) tablabel->event_window = NULL; } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget)); + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unrealize (widget); } static void gdl_dock_tablabel_map (GtkWidget *widget) { GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget); - - GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); + + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->map (widget); gdk_window_show (tablabel->event_window); } @@ -585,7 +596,7 @@ gdl_dock_tablabel_unmap (GtkWidget *widget) gdk_window_hide (tablabel->event_window); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, unmap, (widget)); + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unmap (widget); } /* ----- Public interface ----- */ diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index c82fead9c..3b90f3757 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the GNOME Devtools Libraries. * @@ -28,7 +28,6 @@ #include <stdlib.h> #include <string.h> -#include "gdl-tools.h" #include "gdl-dock.h" #include "gdl-dock-master.h" #include "gdl-dock-paned.h" @@ -41,7 +40,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_class_init (GdlDockClass *class); -static void gdl_dock_instance_init (GdlDock *dock); static GObject *gdl_dock_constructor (GType type, guint n_construct_properties, @@ -147,7 +145,7 @@ static guint dock_signals [LAST_SIGNAL] = { 0 }; /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDock, gdl_dock, GdlDockObject, GDL_TYPE_DOCK_OBJECT); +G_DEFINE_TYPE (GdlDock, gdl_dock, GDL_TYPE_DOCK_OBJECT); static void gdl_dock_class_init (GdlDockClass *klass) @@ -258,7 +256,7 @@ gdl_dock_class_init (GdlDockClass *klass) } static void -gdl_dock_instance_init (GdlDock *dock) +gdl_dock_init (GdlDock *dock) { gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE); @@ -294,17 +292,14 @@ gdl_dock_constructor (GType type, GObjectConstructParam *construct_param) { GObject *g_object; - - g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS, - constructor, - (type, - n_construct_properties, - construct_param), - NULL); + + g_object = G_OBJECT_CLASS (gdl_dock_parent_class)-> constructor (type, + n_construct_properties, + construct_param); if (g_object) { GdlDock *dock = GDL_DOCK (g_object); GdlDockMaster *master; - + /* create a master for the dock if none was provided in the construction */ master = GDL_DOCK_OBJECT_GET_MASTER (GDL_DOCK_OBJECT (dock)); if (!master) { @@ -316,11 +311,11 @@ gdl_dock_constructor (GType type, if (dock->_priv->floating) { GdlDockObject *controller; - + /* create floating window for this dock */ dock->_priv->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_set_data (G_OBJECT (dock->_priv->window), "dock", dock); - + /* set position and default size */ gtk_window_set_position (GTK_WINDOW (dock->_priv->window), GTK_WIN_POS_MOUSE); @@ -337,27 +332,27 @@ gdl_dock_constructor (GType type, gtk_window_move (GTK_WINDOW (dock->_priv->window), dock->_priv->float_x, dock->_priv->float_y); - + /* connect to the configure event so we can track down window geometry */ g_signal_connect (dock->_priv->window, "configure_event", (GCallback) gdl_dock_floating_configure_event_cb, dock); - + /* set the title and connect to the long_name notify queue - so we can reset the title when this prop changes */ + so we can reset the title when this prop changes */ gdl_dock_set_title (dock); g_signal_connect (dock, "notify::long-name", (GCallback) gdl_dock_notify_cb, NULL); - + gtk_container_add (GTK_CONTAINER (dock->_priv->window), GTK_WIDGET (dock)); - + g_signal_connect (dock->_priv->window, "delete_event", G_CALLBACK (gdl_dock_floating_window_delete_event_cb), NULL); } GDL_DOCK_OBJECT_SET_FLAGS (dock, GDL_DOCK_ATTACHED); } - + return g_object; } @@ -502,8 +497,6 @@ gdl_dock_notify_cb (GObject *object, g_object_get (object, "long-name", &long_name, NULL); - g_message ("Notify long_name: %s", long_name); - if (long_name) { dock = GDL_DOCK (object); @@ -537,7 +530,7 @@ gdl_dock_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_parent_class)->destroy (object); } static void @@ -553,7 +546,7 @@ gdl_dock_size_request (GtkWidget *widget, dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); - border_width = container->border_width; + border_width = gtk_container_get_border_width (container); /* make request to root */ if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root))) @@ -566,7 +559,7 @@ gdl_dock_size_request (GtkWidget *widget, requisition->width += 2 * border_width; requisition->height += 2 * border_width; - widget->requisition = *requisition; + //gtk_widget_size_request (widget, requisition); } static void @@ -582,9 +575,9 @@ gdl_dock_size_allocate (GtkWidget *widget, dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); - border_width = container->border_width; + border_width = gtk_container_get_border_width (container); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); /* reduce allocation by border width */ allocation->x += border_width; @@ -607,7 +600,7 @@ gdl_dock_map (GtkWidget *widget) dock = GDL_DOCK (widget); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->map (widget); if (dock->root) { child = GTK_WIDGET (dock->root); @@ -627,7 +620,7 @@ gdl_dock_unmap (GtkWidget *widget) dock = GDL_DOCK (widget); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, unmap, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->unmap (widget); if (dock->root) { child = GTK_WIDGET (dock->root); @@ -657,7 +650,7 @@ gdl_dock_show (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, show, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->show (widget); dock = GDL_DOCK (widget); if (dock->_priv->floating && dock->_priv->window) @@ -678,7 +671,7 @@ gdl_dock_hide (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, hide, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->hide (widget); dock = GDL_DOCK (widget); if (dock->_priv->floating && dock->_priv->window) @@ -771,6 +764,7 @@ static void gdl_dock_reduce (GdlDockObject *object) { GdlDock *dock = GDL_DOCK (object); + GtkWidget *parent; if (dock->root) return; @@ -784,8 +778,9 @@ gdl_dock_reduce (GdlDockObject *object) gtk_widget_hide (GTK_WIDGET (dock)); else { GtkWidget *widget = GTK_WIDGET (object); - if (widget->parent) - gtk_container_remove (GTK_CONTAINER (widget->parent), widget); + parent = gtk_widget_get_parent (widget); + if (parent) + gtk_container_remove (GTK_CONTAINER (parent), widget); } } } @@ -799,7 +794,7 @@ gdl_dock_dock_request (GdlDockObject *object, GdlDock *dock; guint bw; gint rel_x, rel_y; - GtkAllocation *alloc; + GtkAllocation alloc; gboolean may_dock = FALSE; GdlDockRequest my_request; @@ -810,28 +805,28 @@ gdl_dock_dock_request (GdlDockObject *object, dock = GDL_DOCK (object); /* Get dock size. */ - alloc = &(GTK_WIDGET (dock)->allocation); - bw = GTK_CONTAINER (dock)->border_width; + gtk_widget_get_allocation (GTK_WIDGET (dock), &alloc); + bw = gtk_container_get_border_width (GTK_CONTAINER (dock)); /* Get coordinates relative to our allocation area. */ - rel_x = x - alloc->x; - rel_y = y - alloc->y; + rel_x = x - alloc.x; + rel_y = y - alloc.y; if (request) my_request = *request; /* Check if coordinates are in GdlDock widget. */ - if (rel_x > 0 && rel_x < alloc->width && - rel_y > 0 && rel_y < alloc->height) { + if (rel_x > 0 && rel_x < alloc.width && + rel_y > 0 && rel_y < alloc.height) { /* It's inside our area. */ may_dock = TRUE; /* Set docking indicator rectangle to the GdlDock size. */ - my_request.rect.x = alloc->x + bw; - my_request.rect.y = alloc->y + bw; - my_request.rect.width = alloc->width - 2*bw; - my_request.rect.height = alloc->height - 2*bw; + my_request.rect.x = alloc.x + bw; + my_request.rect.y = alloc.y + bw; + my_request.rect.width = alloc.width - 2*bw; + my_request.rect.height = alloc.height - 2*bw; /* If GdlDock has no root item yet, set the dock itself as possible target. */ @@ -845,14 +840,14 @@ gdl_dock_dock_request (GdlDockObject *object, if (rel_x < bw) { my_request.position = GDL_DOCK_LEFT; my_request.rect.width *= SPLIT_RATIO; - } else if (rel_x > alloc->width - bw) { + } else if (rel_x > alloc.width - bw) { my_request.position = GDL_DOCK_RIGHT; my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); my_request.rect.width *= SPLIT_RATIO; } else if (rel_y < bw) { my_request.position = GDL_DOCK_TOP; my_request.rect.height *= SPLIT_RATIO; - } else if (rel_y > alloc->height - bw) { + } else if (rel_y > alloc.height - bw) { my_request.position = GDL_DOCK_BOTTOM; my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); my_request.rect.height *= SPLIT_RATIO; @@ -1068,17 +1063,20 @@ static GdlDockPlacement gdl_dock_refine_placement (GdlDock *dock, GdlDockItem *dock_item, GdlDockPlacement placement) { + GtkAllocation allocation; GtkRequisition object_size; gdl_dock_item_preferred_size (dock_item, &object_size); - g_return_val_if_fail (GTK_WIDGET (dock)->allocation.width > 0, placement); - g_return_val_if_fail (GTK_WIDGET (dock)->allocation.height > 0, placement); + gtk_widget_get_allocation (GTK_WIDGET (dock), &allocation); + + g_return_val_if_fail (allocation.width > 0, placement); + g_return_val_if_fail (allocation.height > 0, placement); g_return_val_if_fail (object_size.width > 0, placement); g_return_val_if_fail (object_size.height > 0, placement); if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT) { /* Check if dock_object touches center in terms of width */ - if (GTK_WIDGET (dock)->allocation.width/2 > object_size.width) { + if (allocation.width/2 > object_size.width) { return GDL_DOCK_TOP; } } @@ -1335,6 +1333,7 @@ gdl_dock_xor_rect (GdlDock *dock, GdkRectangle *rect) { GtkWidget *widget; + GdkWindow *window; gint8 dash_list [2]; widget = GTK_WIDGET (dock); @@ -1346,7 +1345,7 @@ gdl_dock_xor_rect (GdlDock *dock, values.function = GDK_INVERT; values.subwindow_mode = GDK_INCLUDE_INFERIORS; dock->_priv->xor_gc = gdk_gc_new_with_values - (widget->window, &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW); + (gtk_widget_get_window (widget), &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW); } else return; }; @@ -1355,19 +1354,21 @@ gdl_dock_xor_rect (GdlDock *dock, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL); - + + window = gtk_widget_get_window (widget); + dash_list [0] = 1; dash_list [1] = 1; gdk_gc_set_dashes (dock->_priv->xor_gc, 1, dash_list, 2); - gdk_draw_rectangle (widget->window, dock->_priv->xor_gc, 0, + gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE, rect->x, rect->y, rect->width, rect->height); gdk_gc_set_dashes (dock->_priv->xor_gc, 0, dash_list, 2); - gdk_draw_rectangle (widget->window, dock->_priv->xor_gc, 0, + gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE, rect->x + 1, rect->y + 1, rect->width - 2, rect->height - 2); } diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 895e708a5..183ae66c0 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -32,7 +32,6 @@ #include "gdl-i18n.h" #include "gdl-switcher.h" -#include "gdl-tools.h" #include "libgdlmarshal.h" #include "libgdltypebuiltins.h" @@ -89,7 +88,7 @@ struct _GdlSwitcherPrivate { gboolean in_toggle; }; -GDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK) +G_DEFINE_TYPE (GdlSwitcher, gdl_switcher, GTK_TYPE_NOTEBOOK) #define INTERNAL_MODE(switcher) (switcher->priv->switcher_style == \ GDL_SWITCHER_STYLE_TOOLBAR ? switcher->priv->toolbar_style : \ @@ -257,7 +256,7 @@ static int layout_buttons (GdlSwitcher *switcher) { GtkRequisition client_requisition = {0,}; - GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation; + GtkAllocation allocation; GdlSwitcherStyle switcher_style; gboolean icons_only; int num_btns = g_slist_length (switcher->priv->buttons); @@ -272,13 +271,14 @@ layout_buttons (GdlSwitcher *switcher) int i; int rows_count; int last_buttons_height; + + gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation); last_buttons_height = switcher->priv->buttons_height_request; - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_request, - (GTK_WIDGET (switcher), &client_requisition)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), &client_requisition); - y = allocation->y + allocation->height - V_PADDING - 1; + y = allocation.y + allocation.height - V_PADDING - 1; if (num_btns == 0) return y; @@ -300,10 +300,10 @@ layout_buttons (GdlSwitcher *switcher) } /* Figure out how many rows and columns we'll use. */ - btns_per_row = allocation->width / (max_btn_width + H_PADDING); + btns_per_row = allocation.width / (max_btn_width + H_PADDING); /* If all the buttons could fit in the single row, have it so */ - if (allocation->width >= optimal_layout_width) + if (allocation.width >= optimal_layout_width) { btns_per_row = num_btns; } @@ -380,7 +380,7 @@ layout_buttons (GdlSwitcher *switcher) /* Check for possible size over flow (taking into account client * requisition */ - if (y < (allocation->y + client_requisition.height)) { + if (y < (allocation.y + client_requisition.height)) { /* We have an overflow: Insufficient allocation */ if (last_buttons_height < switcher->priv->buttons_height_request) { /* Request for a new resize */ @@ -388,11 +388,11 @@ layout_buttons (GdlSwitcher *switcher) return -1; } } - x = H_PADDING + allocation->x; + x = H_PADDING + allocation.x; len = g_slist_length (rows[i]); if (switcher_style == GDL_SWITCHER_STYLE_TEXT || switcher_style == GDL_SWITCHER_STYLE_BOTH) - extra_width = (allocation->width - (len * max_btn_width ) + extra_width = (allocation.width - (len * max_btn_width ) - (len * H_PADDING)) / len; else extra_width = 0; @@ -432,26 +432,27 @@ layout_buttons (GdlSwitcher *switcher) static void do_layout (GdlSwitcher *switcher) { - GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation; + GtkAllocation allocation; GtkAllocation child_allocation; int y; + gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation); + if (switcher->priv->show) { y = layout_buttons (switcher); if (y < 0) /* Layout did not happen and a resize was requested */ return; } else - y = allocation->y + allocation->height; + y = allocation.y + allocation.height; /* Place the parent widget. */ - child_allocation.x = allocation->x; - child_allocation.y = allocation->y; - child_allocation.width = allocation->width; - child_allocation.height = y - allocation->y; + child_allocation.x = allocation.x; + child_allocation.y = allocation.y; + child_allocation.width = allocation.width; + child_allocation.height = y - allocation.y; - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, - (GTK_WIDGET (switcher), &child_allocation)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_allocate (GTK_WIDGET (switcher), &child_allocation); } /* GtkContainer methods. */ @@ -464,9 +465,9 @@ gdl_switcher_forall (GtkContainer *container, gboolean include_internals, GDL_SWITCHER (container); GSList *p; - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall, - (GTK_CONTAINER (switcher), include_internals, - callback, callback_data)); + GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->forall (GTK_CONTAINER (switcher), + include_internals, + callback, callback_data); if (include_internals) { for (p = switcher->priv->buttons; p != NULL; p = p->next) { GtkWidget *widget = ((Button *) p->data)->button_widget; @@ -496,8 +497,7 @@ gdl_switcher_remove (GtkContainer *container, GtkWidget *widget) break; } } - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, remove, - (GTK_CONTAINER (switcher), widget)); + GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->remove (GTK_CONTAINER (switcher), widget); } /* GtkWidget methods. */ @@ -509,8 +509,7 @@ gdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition) GSList *p; gint button_height = 0; - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_request, - (GTK_WIDGET (switcher), requisition)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), requisition); if (!switcher->priv->show) return; @@ -537,7 +536,7 @@ gdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition) static void gdl_switcher_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); do_layout (GDL_SWITCHER (widget)); } @@ -553,8 +552,7 @@ gdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event) button, event); } } - return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS, expose_event, - (widget, event), FALSE); + return GTK_WIDGET_CLASS (gdl_switcher_parent_class)->expose_event (widget, event); } static void @@ -569,7 +567,7 @@ gdl_switcher_map (GtkWidget *widget) gtk_widget_map (button); } } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->map (widget); } /* GObject methods. */ @@ -629,7 +627,7 @@ gdl_switcher_dispose (GObject *object) g_slist_free (priv->buttons); priv->buttons = NULL; - GDL_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); + G_OBJECT_CLASS (gdl_switcher_parent_class)->dispose (object); } static void @@ -639,7 +637,7 @@ gdl_switcher_finalize (GObject *object) g_free (priv); - GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (gdl_switcher_parent_class)->finalize (object); } /* Signal handlers */ @@ -748,7 +746,7 @@ gdl_switcher_class_init (GdlSwitcherClass *klass) } static void -gdl_switcher_instance_init (GdlSwitcher *switcher) +gdl_switcher_init (GdlSwitcher *switcher) { GdlSwitcherPrivate *priv; diff --git a/src/libgdl/gdl-tools.h b/src/libgdl/gdl-tools.h deleted file mode 100644 index 4e515b23b..000000000 --- a/src/libgdl/gdl-tools.h +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtool Libraries - * - * Copyright (C) 1999-2000 Dave Camp <dave@helixcode.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Miscellaneous GDL tools/macros */ - -#ifndef __GDL_TOOLS_H__ -#define __GDL_TOOLS_H__ - -#include <glib.h> -#include <gtk/gtk.h> - -/* FIXME: Toggle this */ - -G_BEGIN_DECLS - -#define DO_GDL_TRACE - -#ifdef DO_GDL_TRACE - -#ifdef __GNUC__ - -#define GDL_TRACE() G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s)", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__); } G_STMT_END - -#define GDL_TRACE_EXTRA(format, args...) G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s): "format, \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - ##args); } G_STMT_END - -#else /* __GNUC__ */ - -#define GDL_TRACE() G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d", \ - __FILE__, \ - __LINE__); } G_STMT_END - -#define GDL_TRACE_EXTRA(format, args...) G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d: "format, \ - __FILE__, \ - __LINE__, \ - ##args); } G_STMT_END -#endif /* __GNUC__ */ - -#else /* DO_GDL_TRACE */ - -#define GDL_TRACE() -#define GDL_TRACE_EXTRA() - -#endif /* DO_GDL_TRACE */ - -/* - * Class boilerplate and base class call macros copied from - * bonobo/bonobo-macros.h. Original copyright follows. - * - * - * Author: - * Darin Adler <darin@bentspoon.com> - * - * Copyright 2001 Ben Tea Spoons, Inc. - */ - -/* Macros for defining classes. Ideas taken from Nautilus and GOB. */ - -/* Define the boilerplate type stuff to reduce typos and code size. Defines - * the get_type method and the parent_class static variable. */ - -#define GDL_BOILERPLATE(type, type_as_function, corba_type, \ - parent_type, parent_type_macro, \ - register_type_macro) \ -static void type_as_function ## _class_init (type ## Class *klass); \ -static void type_as_function ## _instance_init (type *object); \ -static parent_type ## Class *parent_class = NULL; \ -static void \ -type_as_function ## _class_init_trampoline (gpointer klass, \ - gpointer data) \ -{ \ - (void)data; \ - parent_class = (parent_type ## Class *)g_type_class_ref ( \ - parent_type_macro); \ - type_as_function ## _class_init ((type ## Class *)klass); \ -} \ -GType \ -type_as_function ## _get_type (void) \ -{ \ - static GType object_type = 0; \ - if (object_type == 0) { \ - static const GTypeInfo object_info = { \ - sizeof (type ## Class), \ - NULL, /* base_init */ \ - NULL, /* base_finalize */ \ - type_as_function ## _class_init_trampoline, \ - NULL, /* class_finalize */ \ - NULL, /* class_data */ \ - sizeof (type), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc) type_as_function ## _instance_init , \ - NULL, /* value_table */ \ - }; \ - object_type = register_type_macro \ - (type, type_as_function, corba_type, \ - parent_type, parent_type_macro); \ - } \ - return object_type; \ -} - -/* Just call the parent handler. This assumes that there is a variable - * named parent_class that points to the (duh!) parent class. Note that - * this macro is not to be used with things that return something, use - * the _WITH_DEFAULT version for that */ -#define GDL_CALL_PARENT(parent_class_cast, name, args) \ - ((parent_class_cast(parent_class)->name != NULL) ? \ - parent_class_cast(parent_class)->name args : (void)0) - -#define GDL_CALL_PARENT_GBOOLEAN(parent_class_cast, name, args) \ - ((parent_class_cast(parent_class)->name != NULL) ? \ - parent_class_cast(parent_class)->name args : (gboolean)0) - - -/* Same as above, but in case there is no implementation, it evaluates - * to def_return */ -#define GDL_CALL_PARENT_WITH_DEFAULT(parent_class_cast, \ - name, args, def_return) \ - ((parent_class_cast(parent_class)->name != NULL) ? \ - parent_class_cast(parent_class)->name args : def_return) - -/* Define the boilerplate type stuff to reduce typos and code size. Defines - * the get_type method and the parent_class static variable. */ -#define GDL_CLASS_BOILERPLATE(type, type_as_function, \ - parent_type, parent_type_macro) \ - GDL_BOILERPLATE(type, type_as_function, type, \ - parent_type, parent_type_macro, \ - GDL_REGISTER_TYPE) -#define GDL_REGISTER_TYPE(type, type_as_function, corba_type, \ - parent_type, parent_type_macro) \ - g_type_register_static (parent_type_macro, #type, &object_info, 0) - - -#define GDL_CALL_VIRTUAL(object, get_class_cast, method, args) \ - (get_class_cast (object)->method ? (* get_class_cast (object)->method) args : (void)0) -#define GDL_CALL_VIRTUAL_WITH_DEFAULT(object, get_class_cast, method, args, default) \ - (get_class_cast (object)->method ? (* get_class_cast (object)->method) args : default) - -/* GdlPixmap structure and method have been copied from Evolution. */ -typedef struct _GdlPixmap { - const char *path; - const char *fname; - char *pixbuf; -} GdlPixmap; - -#define GDL_PIXMAP(path,fname) { (path), (fname), NULL } -#define GDL_PIXMAP_END { NULL, NULL, NULL } - -G_END_DECLS - -#endif - diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h index d136b9295..235c5e3eb 100644 --- a/src/libgdl/gdl.h +++ b/src/libgdl/gdl.h @@ -22,7 +22,6 @@ #ifndef __GDL_H__ #define __GDL_H__ -#include "libgdl/gdl-tools.h" #include "libgdl/gdl-dock-object.h" #include "libgdl/gdl-dock-master.h" #include "libgdl/gdl-dock.h" -- cgit v1.2.3 From 20849c6e4c30a52b90f8a1aea9ee9054a84536eb Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Fri, 23 Dec 2011 13:12:28 +0000 Subject: GDL: Rebase on upstream commit 2648F (2010-10-26) (bzr r10795) --- src/libgdl/gdl-dock-bar.c | 257 ++++++++++++++++++++------------ src/libgdl/gdl-dock-item-button-image.c | 2 +- src/libgdl/gdl-dock-item-grip.c | 9 +- src/libgdl/gdl-dock-item.h | 35 ++++- src/libgdl/gdl-dock-notebook.c | 2 +- 5 files changed, 202 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 84a901308..f742a2d73 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -464,9 +464,8 @@ static void gdl_dock_bar_size_vrequest (GtkWidget *widget, GtkRequisition *requisition ) { GtkBox *box; - GtkBoxChild *child; GtkRequisition child_requisition; - GList *children; + GList *child; gint nvis_children; gint height; guint border_width; @@ -476,24 +475,34 @@ static void gdl_dock_bar_size_vrequest (GtkWidget *widget, requisition->height = 0; nvis_children = 0; - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) + if (gtk_widget_get_visible (GTK_WIDGET (child->data))) { - gtk_widget_size_request (child->widget, &child_requisition); - + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition); + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + if (gtk_box_get_homogeneous (box)) { - height = child_requisition.height + child->padding * 2; + height = child_requisition.height + padding * 2; requisition->height = MAX (requisition->height, height); } else { - requisition->height += child_requisition.height + child->padding * 2; + requisition->height += child_requisition.height + padding * 2; } requisition->width = MAX (requisition->width, child_requisition.width); @@ -519,8 +528,7 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, GtkAllocation *allocation) { GtkBox *box; - GtkBoxChild *child; - GList *children; + GList *child; GtkAllocation child_allocation; gint nvis_children; gint nexpand_children; @@ -538,17 +546,25 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, nvis_children = 0; nexpand_children = 0; - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + if (gtk_widget_get_visible (GTK_WIDGET(child->data))) { nvis_children += 1; - if (child->expand) + if (expand) nexpand_children += 1; } } @@ -579,13 +595,22 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, child_allocation.x = allocation->x + border_width; child_allocation.width = MAX (1, (gint) allocation->width - (gint) border_width * 2); - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + + if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data))) { if (gtk_box_get_homogeneous (box)) { @@ -601,10 +626,10 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, { GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_height = child_requisition.height + child->padding * 2; + gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); + child_height = child_requisition.height + padding * 2; - if (child->expand) + if (expand) { if (nexpand_children == 1) child_height += height; @@ -616,21 +641,21 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, } } - if (child->fill) + if (fill) { - child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); - child_allocation.y = y + child->padding; + child_allocation.height = MAX (1, child_height - padding * 2); + child_allocation.y = y + padding; } else { GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); + gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); child_allocation.height = child_requisition.height; child_allocation.y = y + (child_height - child_allocation.height) / 2; } - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); y += child_height + gtk_box_get_spacing (box); } @@ -638,16 +663,25 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, y = allocation->y + allocation->height - border_width; - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + + if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data))) { GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); + gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); if (gtk_box_get_homogeneous (box)) { @@ -661,9 +695,9 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, } else { - child_height = child_requisition.height + child->padding * 2; + child_height = child_requisition.height + padding * 2; - if (child->expand) + if (expand) { if (nexpand_children == 1) child_height += height; @@ -675,10 +709,10 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, } } - if (child->fill) + if (fill) { - child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); - child_allocation.y = y + child->padding - child_height; + child_allocation.height = MAX (1, child_height - padding * 2); + child_allocation.y = y + padding - child_height; } else { @@ -686,7 +720,7 @@ static void gdl_dock_bar_size_vallocate (GtkWidget *widget, child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; } - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); y -= (child_height + gtk_box_get_spacing (box)); } @@ -698,8 +732,7 @@ static void gdl_dock_bar_size_hrequest (GtkWidget *widget, GtkRequisition *requisition ) { GtkBox *box; - GtkBoxChild *child; - GList *children; + GList *child; gint nvis_children; gint width; guint border_width; @@ -709,26 +742,36 @@ static void gdl_dock_bar_size_hrequest (GtkWidget *widget, requisition->height = 0; nvis_children = 0; - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + - if (gtk_widget_get_visible (child->widget)) + if (gtk_widget_get_visible (GTK_WIDGET (child->data))) { GtkRequisition child_requisition; - gtk_widget_size_request (child->widget, &child_requisition); + gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition); if (gtk_box_get_homogeneous (box)) { - width = child_requisition.width + child->padding * 2; + width = child_requisition.width + padding * 2; requisition->width = MAX (requisition->width, width); } else { - requisition->width += child_requisition.width + child->padding * 2; + requisition->width += child_requisition.width + padding * 2; } requisition->height = MAX (requisition->height, child_requisition.height); @@ -753,8 +796,7 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, GtkAllocation *allocation) { GtkBox *box; - GtkBoxChild *child; - GList *children; + GList *child; GtkAllocation child_allocation; gint nvis_children; gint nexpand_children; @@ -774,17 +816,26 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, nvis_children = 0; nexpand_children = 0; - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + + if (gtk_widget_get_visible (GTK_WIDGET (child->data))) { nvis_children += 1; - if (child->expand) + if (expand) nexpand_children += 1; } } @@ -815,13 +866,22 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, child_allocation.y = allocation->y + border_width; child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2); - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + + if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data))) { if (gtk_box_get_homogeneous (box)) { @@ -837,11 +897,11 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, { GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); + gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - child_width = child_requisition.width + child->padding * 2; + child_width = child_requisition.width + padding * 2; - if (child->expand) + if (expand) { if (nexpand_children == 1) child_width += width; @@ -853,16 +913,16 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, } } - if (child->fill) + if (fill) { - child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); - child_allocation.x = x + child->padding; + child_allocation.width = MAX (1, child_width - padding * 2); + child_allocation.x = x + padding; } else { GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); + gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); child_allocation.width = child_requisition.width; child_allocation.x = x + (child_width - child_allocation.width) / 2; } @@ -870,7 +930,7 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, if (direction == GTK_TEXT_DIR_RTL) child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); x += child_width + gtk_box_get_spacing (box); } @@ -878,16 +938,25 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, x = allocation->x + allocation->width - border_width; - children = gtk_container_get_children (GTK_CONTAINER (box)); - while (children) + for (child = gtk_container_get_children (GTK_CONTAINER (box)); + child != NULL; child = g_list_next (child)) { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) + guint padding; + gboolean expand; + gboolean fill; + GtkPackType pack_type; + + gtk_box_query_child_packing (box, + child->data, + &expand, + &fill, + &padding, + &pack_type); + + if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data))) { GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); + gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); if (gtk_box_get_homogeneous (box)) { @@ -901,9 +970,9 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, } else { - child_width = child_requisition.width + child->padding * 2; + child_width = child_requisition.width + padding * 2; - if (child->expand) + if (expand) { if (nexpand_children == 1) child_width += width; @@ -915,10 +984,10 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, } } - if (child->fill) + if (fill) { - child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); - child_allocation.x = x + child->padding - child_width; + child_allocation.width = MAX (1, child_width - padding * 2); + child_allocation.x = x + padding - child_width; } else { @@ -929,7 +998,7 @@ static void gdl_dock_bar_size_hallocate (GtkWidget *widget, if (direction == GTK_TEXT_DIR_RTL) child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); x -= (child_width + gtk_box_get_spacing (box)); } diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c index da0cba274..31613a898 100644 --- a/src/libgdl/gdl-dock-item-button-image.c +++ b/src/libgdl/gdl-dock-item-button-image.c @@ -149,7 +149,7 @@ gdl_dock_item_button_image_class_init ( /** * gdl_dock_item_button_image_new: - * @param image_type: Specifies what type of image the widget should + * @image_type: Specifies what type of image the widget should * display * * Creates a new GDL dock button image object. diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index f0a90459c..b7c3d0f5b 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -280,10 +280,11 @@ gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip) GdkModifierType modifiers; gint x = 0, y = 0; + gboolean ev_ret; g_return_if_fail (gtk_widget_get_realized (iconify_button)); - window = gtk_button_get_event_window (GTK_BUTTON (iconify_button)); + window = gtk_widget_get_parent_window (iconify_button); event = gdk_event_new (GDK_LEAVE_NOTIFY); g_assert (GDK_IS_WINDOW (window)); @@ -301,7 +302,9 @@ gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip) event->crossing.focus = FALSE; event->crossing.state = modifiers; - gtk_widget_event (iconify_button, event); + //GTK_BUTTON (iconify_button)->in_button = FALSE; + g_signal_emit_by_name (iconify_button, "leave-notify-event", + event, &ev_ret, 0); gdk_event_free (event); } @@ -774,7 +777,7 @@ gdl_dock_item_grip_set_label (GdlDockItemGrip *grip, } /** * gdl_dock_item_grip_hide_handle: - * @item: The dock item grip to hide the handle of. + * @grip: The dock item grip to hide the handle of. * * This function hides the dock item's grip widget handle hatching. **/ diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h index d97fdf6fd..b9378f783 100644 --- a/src/libgdl/gdl-dock-item.h +++ b/src/libgdl/gdl-dock-item.h @@ -42,7 +42,26 @@ G_BEGIN_DECLS #define GDL_IS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM)) #define GDL_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass)) -/* data types & structures */ +/** + * GdlDockItemBehavior: + * @GDL_DOCK_ITEM_BEH_NORMAL: Normal dock item + * @GDL_DOCK_ITEM_BEH_NEVER_FLOATING: item cannot be undocked + * @GDL_DOCK_ITEM_BEH_NEVER_VERTICAL: item cannot be docked vertically + * @GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL: item cannot be docked horizontally + * @GDL_DOCK_ITEM_BEH_LOCKED: item is locked, it cannot be moved around + * @GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP: item cannot be docked at top + * @GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM: item cannot be docked at bottom + * @GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT: item cannot be docked left + * @GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT: item cannot be docked right + * @GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER: item cannot be docked at center + * @GDL_DOCK_ITEM_BEH_CANT_CLOSE: item cannot be closed + * @GDL_DOCK_ITEM_BEH_CANT_ICONIFY: item cannot be iconified + * @GDL_DOCK_ITEM_BEH_NO_GRIP: item doesn't have a grip + * + * Described the behaviour of a doc item. The item can have multiple flags set. + * + **/ + typedef enum { GDL_DOCK_ITEM_BEH_NORMAL = 0, GDL_DOCK_ITEM_BEH_NEVER_FLOATING = 1 << 0, @@ -59,12 +78,21 @@ typedef enum { GDL_DOCK_ITEM_BEH_NO_GRIP = 1 << 11 } GdlDockItemBehavior; + +/** + * GdlDockItemFlags: + * @GDL_DOCK_IN_DRAG: item is in a drag operation + * @GDL_DOCK_IN_PREDRAG: item is in a predrag operation + * @GDL_DOCK_ICONIFIED: item is iconified + * @GDL_DOCK_USER_ACTION: indicates the user has started an action on the dock item + * + * Status flag of a GdlDockItem. Don't use unless you derive a widget from GdlDockItem + * + **/ typedef enum { GDL_DOCK_IN_DRAG = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT, GDL_DOCK_IN_PREDRAG = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 1), GDL_DOCK_ICONIFIED = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2), - /* for general use: indicates the user has started an action on - the dock item */ GDL_DOCK_USER_ACTION = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 3) } GdlDockItemFlags; @@ -105,7 +133,6 @@ struct _GdlDockItemClass { GtkOrientation orientation); }; -/* additional macros */ #define GDL_DOCK_ITEM_FLAGS(item) (GDL_DOCK_OBJECT (item)->flags) #define GDL_DOCK_ITEM_IN_DRAG(item) \ ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0) diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c index 6b6b4f755..a14b9e09c 100644 --- a/src/libgdl/gdl-dock-notebook.c +++ b/src/libgdl/gdl-dock-notebook.c @@ -293,7 +293,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, "layout-changed"); /* Signal that a new dock item has been selected */ - item = GDL_DOCK_ITEM (gtk_notebook_get_nth_page (nb, page_num)); + item = GDL_DOCK_ITEM (page); gdl_dock_item_notify_selected (item); } -- cgit v1.2.3 From 3705a6ec250fedea13308689f98fef3e40fc76cb Mon Sep 17 00:00:00 2001 From: Alex Valavanis <valavanisalex@gmail.com> Date: Mon, 26 Dec 2011 01:43:50 +0000 Subject: GDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (bzr r10796) --- src/libgdl/gdl-dock-object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 4058d8752..da5e08d38 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -695,7 +695,7 @@ gdl_dock_object_reorder (GdlDockObject *object, g_return_val_if_fail (object != NULL && child != NULL, FALSE); if (GDL_DOCK_OBJECT_GET_CLASS (object)->reorder) - GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data); + return GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data); else return FALSE; } @@ -748,7 +748,7 @@ gdl_dock_object_child_placement (GdlDockObject *object, return FALSE; if (GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement) - GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement); + return GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement); else return FALSE; } -- cgit v1.2.3